Skip to content

Commit

Permalink
fix(android): specify default tintColor (#11777)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27963
  • Loading branch information
garymathews committed Jun 29, 2020
1 parent 5cff6a2 commit 9a6d417
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public abstract class TiUIAbstractTabGroup extends TiUIView

// region private fields
private int textColorInt;
private int unselectedTextColorInt;
private AtomicLong fragmentIdGenerator = new AtomicLong();
private ArrayList<Long> tabFragmentIDs = new ArrayList<Long>();
protected ArrayList<TiUITab> tabs = new ArrayList<TiUITab>();
Expand All @@ -157,13 +158,19 @@ public TiUIAbstractTabGroup(final TabGroupProxy proxy, TiBaseActivity activity)
// Note: We use ActionBar style for backward compatibility with Titanium versions older than 8.0.0.
this.colorPrimaryInt = 0xFF212121; // Default to dark gray.
this.textColorInt = 0xFFFFFFFF; // Default to white.
this.unselectedTextColorInt = 0xFFBBBBBB; // Default to light gray.
try {
int styleAttributeId = TiRHelper.getResource("attr.actionBarStyle");
int[] idArray = new int[] { TiRHelper.getResource("attr.colorPrimary"),
TiRHelper.getResource("attr.textColorPrimary") };
TypedArray typedArray = activity.obtainStyledAttributes(null, idArray, styleAttributeId, 0);
final int styleAttributeId = TiRHelper.getResource("attr.actionBarStyle");
final int[] idArray = new int[] {
TiRHelper.getResource("attr.colorPrimary"),
TiRHelper.getResource("attr.textColorPrimary"),
TiRHelper.getResource("attr.colorControlNormal")
};
final TypedArray typedArray = activity.obtainStyledAttributes(null, idArray, styleAttributeId, 0);

this.colorPrimaryInt = typedArray.getColor(0, this.colorPrimaryInt);
this.textColorInt = typedArray.getColor(1, this.textColorInt);
this.unselectedTextColorInt = typedArray.getColor(2, this.unselectedTextColorInt);
typedArray.recycle();
} catch (Exception ex) {
Log.e(TAG, "Failed to fetch color from theme.", ex);
Expand Down Expand Up @@ -260,7 +267,7 @@ protected ColorStateList textColorStateList(TiViewProxy tabProxy, int stateToUse
}

int[][] textColorStates = new int[][] { new int[] { -stateToUse }, new int[] { stateToUse } };
int[] textColors = { this.textColorInt, this.textColorInt };
int[] textColors = { this.unselectedTextColorInt, this.textColorInt };

final KrollDict tabProperties = tabProxy.getProperties();
final KrollDict properties = getProxy().getProperties();
Expand Down Expand Up @@ -481,6 +488,7 @@ public Drawable updateIconTint(TiViewProxy tabProxy, Drawable drawable, boolean
}
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
} else {
color = this.unselectedTextColorInt;
if (tabProperties.containsKeyAndNotNull(TiC.PROPERTY_TINT_COLOR)
|| properties.containsKeyAndNotNull(TiC.PROPERTY_TINT_COLOR)
|| tabProperties.containsKeyAndNotNull(TiC.PROPERTY_TITLE_COLOR)
Expand Down

0 comments on commit 9a6d417

Please sign in to comment.