diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index 7c3dfde..707057c 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -167,7 +167,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements mIsFullScreen = false, mIsImmersive = false, mShowTabsInDrawer; - private int mOriginalOrientation, mBackgroundColor, mIdGenerator, mIconColor; + private int mOriginalOrientation, mBackgroundColor, mIdGenerator, mIconColor, + mCurrentUiColor; private String mSearchText, mUntitledTitle, mHomepage, mCameraPhotoPath; // Storage @@ -1307,6 +1308,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements private final CloseTabListener mExitListener; private final Drawable mBackgroundTabDrawable; private final Drawable mForegroundTabDrawable; + private final Bitmap mForegroundTabBitmap; private final DrawerItemClickListener mClickListener; private final DrawerItemLongClickListener mLongClickListener; private ColorMatrix mColorMatrix; @@ -1324,6 +1326,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements if (mShowTabsInDrawer) { mBackgroundTabDrawable = null; + mForegroundTabBitmap = null; mForegroundTabDrawable = ThemeUtils.getSelectedBackground(context, mDarkTheme); } else { int backgroundColor = Utils.mixTwoColors(ThemeUtils.getPrimaryColor(mActivity), Color.BLACK, 0.75f); @@ -1332,9 +1335,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements mBackgroundTabDrawable = new BitmapDrawable(getResources(), backgroundTabBitmap); int foregroundColor = ThemeUtils.getPrimaryColor(context); - Bitmap foregroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); - Utils.drawTrapezoid(new Canvas(foregroundTabBitmap), foregroundColor, false); - mForegroundTabDrawable = new BitmapDrawable(getResources(), foregroundTabBitmap).mutate(); + mForegroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); + Utils.drawTrapezoid(new Canvas(mForegroundTabBitmap), foregroundColor, false); + mForegroundTabDrawable = null; } } @@ -1364,13 +1367,22 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements } else { holder.txtTitle.setTextAppearance(context, R.style.boldText); } + Drawable foregroundDrawable; + if (!mShowTabsInDrawer) { + foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap); + if (!isIncognito() && mColorMode) { + foregroundDrawable.setColorFilter(mCurrentUiColor, PorterDuff.Mode.SRC_IN); + } + } else { + foregroundDrawable = mForegroundTabDrawable; + } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - holder.layout.setBackground(mForegroundTabDrawable); + holder.layout.setBackground(foregroundDrawable); } else { - holder.layout.setBackgroundDrawable(mForegroundTabDrawable); + holder.layout.setBackgroundDrawable(foregroundDrawable); } if (!isIncognito() && mColorMode) { - changeToolbarBackground(favicon, null /* mForegroundTabDrawable */); + changeToolbarBackground(favicon, foregroundDrawable); } holder.favicon.setImageBitmap(favicon); } else { @@ -1448,16 +1460,15 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements * @param tabBackground the optional LinearLayout to color */ private void changeToolbarBackground(@NonNull Bitmap favicon, @Nullable final Drawable tabBackground) { - if (!mShowTabsInDrawer) { - // TODO something is messed up and keeping this from working when the tablet tabs are used - return; - } final int defaultColor; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { defaultColor = getResources().getColor(R.color.primary_color); } else { defaultColor = getColor(R.color.primary_color); } + if (mCurrentUiColor == Color.BLACK) { + mCurrentUiColor = defaultColor; + } Palette.from(favicon).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { @@ -1467,13 +1478,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements int finalColor; // Lighten up the dark color if it is // too dark - if (Utils.isColorTooDark(color)) { + if (!mShowTabsInDrawer || Utils.isColorTooDark(color)) { finalColor = Utils.mixTwoColors(defaultColor, color, 0.25f); } else { finalColor = color; } - ValueAnimator anim = ValueAnimator.ofInt(mBackground.getColor(), finalColor); + ValueAnimator anim = ValueAnimator.ofInt(mCurrentUiColor, finalColor); anim.setEvaluator(new ArgbEvaluator()); final Window window = getWindow(); if (!mShowTabsInDrawer) { @@ -1490,6 +1501,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements } else if (tabBackground != null) { tabBackground.setColorFilter(color, PorterDuff.Mode.SRC_IN); } + mCurrentUiColor = color; mToolbarLayout.setBackgroundColor(color); } diff --git a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java index c4f93d5..6698e29 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java @@ -490,9 +490,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe v.setPadding(padding, padding, 0, padding); layout.addView(v); layout.addView(getDownload); - if (API < Build.VERSION_CODES.JELLY_BEAN) { - layout.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.edit_text)); - } else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Drawable drawable; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable = getResources().getDrawable(android.R.drawable.edit_text, getActivity().getTheme()); @@ -500,6 +498,8 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe drawable = getResources().getDrawable(android.R.drawable.edit_text); } layout.setBackground(drawable); + } else { + layout.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.edit_text)); } downLocationPicker.setView(layout); downLocationPicker.setPositiveButton(getResources().getString(R.string.action_ok), @@ -611,7 +611,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe mPreferences.setGoogleSearchSuggestionsEnabled((Boolean) newValue); cbgooglesuggest.setChecked((Boolean) newValue); return true; - case SETTINGS_DRAWERTABS: + case SETTINGS_DRAWERTABS: mPreferences.setShowTabsInDrawer((Boolean) newValue); cbDrawerTabs.setChecked((Boolean) newValue); default: