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)(8_0_X): TabGroup bar background color is wrongly transparent on Android 4.4 as of 8.0.0 #10930

Merged
merged 2 commits into from
Jun 11, 2019
Merged
Changes from 1 commit
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 @@ -28,13 +28,15 @@
import android.view.View;
import android.view.ViewGroup;

import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.titanium.TiBaseActivity;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.ActivityProxy;
import org.appcelerator.titanium.util.TiColorHelper;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiRHelper;
import org.appcelerator.titanium.view.TiInsetsProvider;
import org.appcelerator.titanium.view.TiUIView;

Expand Down Expand Up @@ -118,16 +120,21 @@ public TiUIAbstractTabGroup(final TabGroupProxy proxy, TiBaseActivity activity)
{
super(proxy);

// Getting the value for colorPrimary from the currently used theme.
TypedValue colorPrimaryTypedValue = new TypedValue();
TypedArray colorPrimary =
activity.obtainStyledAttributes(colorPrimaryTypedValue.data, new int[] { android.R.attr.colorPrimary });
this.colorPrimaryInt = colorPrimary.getColor(0, 0);
// Getting the value for textColorPrimary for the currently used theme.
TypedValue typedValue = new TypedValue();
TypedArray textColor =
activity.obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.textColorPrimary });
this.textColorInt = textColor.getColor(0, 0);
// Fetch primary background and text colors from ActionBar style assigned to activity theme.
// 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.
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);
this.colorPrimaryInt = typedArray.getColor(0, this.colorPrimaryInt);
this.textColorInt = typedArray.getColor(1, this.textColorInt);
typedArray.recycle();
} catch (Exception ex) {
Log.e(TAG, "Failed to fetch color from theme.", ex);
}

this.tabGroupPagerAdapter = new TabGroupFragmentPagerAdapter(activity.getSupportFragmentManager());

Expand Down