Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): specify default Tab.tintColor #11777

Merged
merged 5 commits into from
Jun 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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