Skip to content

Commit

Permalink
[TIMOB-27117] Android: Fixed TabGroup bar background color to not be …
Browse files Browse the repository at this point in the history
…transparent on Android 4.4 (#10935)

- Regression as of Titanium 8.0.0
- Modified to fetch colors from ActionBar style XML for backward compaitibility with apps built before Titanium 8.0.0
  • Loading branch information
jquick-axway authored and lokeshchdhry committed Jun 11, 2019
1 parent bc4b291 commit 723e360
Showing 1 changed file with 17 additions and 8 deletions.
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,14 +120,21 @@ public TiUIAbstractTabGroup(final TabGroupProxy proxy, TiBaseActivity activity)
{
super(proxy);

TypedValue colorPrimaryValue = new TypedValue();
activity.getTheme().resolveAttribute(android.R.attr.colorPrimary, colorPrimaryValue, true);

TypedValue textColorPrimaryValue = new TypedValue();
activity.getTheme().resolveAttribute(android.R.attr.textColorPrimary, textColorPrimaryValue, true);

this.colorPrimaryInt = colorPrimaryValue.data;
this.textColorInt = textColorPrimaryValue.data;
// 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

0 comments on commit 723e360

Please sign in to comment.