Skip to content

Commit

Permalink
fix(android): fix Android FAB tintColor (#13972)
Browse files Browse the repository at this point in the history
* fix(android): fix Android FAB tintColor

* remove from excludes
  • Loading branch information
m1ga authored Feb 11, 2024
1 parent 6e40edb commit 60cb3f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package ti.modules.titanium.ui.widget;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

Expand Down Expand Up @@ -54,6 +55,9 @@ public void processProperties(KrollDict d)
if (d.containsKey("maxImageSize")) {
setMaxImageSize(TiConvert.toInt(d.get("maxImageSize")));
}
if (d.containsKey(TiC.PROPERTY_TINT_COLOR)) {
setTintColor(d.getString("tintColor"));
}
if (d.containsKeyAndNotNull(TiC.PROPERTY_TOUCH_FEEDBACK_COLOR)) {
ColorStateList colorStateList = null;
colorStateList = ColorStateList.valueOf(
Expand Down Expand Up @@ -91,6 +95,12 @@ private void setImage(Object obj)
}
}

public void setTintColor(String color)
{
int tintColor = TiConvert.toColor(color, TiApplication.getAppCurrentActivity());
fab.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN);
}

@Override
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy)
{
Expand All @@ -106,6 +116,8 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
ColorStateList colorStateList = null;
colorStateList = ColorStateList.valueOf(TiConvert.toColor(newValue, proxy.getActivity()));
fab.setRippleColor(colorStateList);
} else if (key.equals(TiC.PROPERTY_TINT_COLOR)) {
setTintColor(TiConvert.toString(newValue));
}
}
}
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/Android/FloatingActionButton.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ excludes:
backgroundImage, backgroundLeftCap, backgroundRepeat, backgroundSelectedColor,
backgroundSelectedImage, backgroundTopCap, borderColor, borderRadius, borderWidth, center,
children, clipMode, focusable, height, horizontalWrap, keepScreenOn, layout, opacity, overrideCurrentAnimation,
pullBackgroundColor, rect, size, softKeyboardOnFocus, tintColor, touchEnabled, touchFeedback, transform,
pullBackgroundColor, rect, size, softKeyboardOnFocus, touchEnabled, touchFeedback, transform,
viewShadowColor, viewShadowOffset, viewShadowRadius, width, zIndex]

events:
Expand Down

0 comments on commit 60cb3f5

Please sign in to comment.