@ -167,7 +167,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mIsFullScreen = false ,
mIsFullScreen = false ,
mIsImmersive = false ,
mIsImmersive = false ,
mShowTabsInDrawer ;
mShowTabsInDrawer ;
private int mOriginalOrientation , mBackgroundColor , mIdGenerator , mIconColor ;
private int mOriginalOrientation , mBackgroundColor , mIdGenerator , mIconColor ,
mCurrentUiColor ;
private String mSearchText , mUntitledTitle , mHomepage , mCameraPhotoPath ;
private String mSearchText , mUntitledTitle , mHomepage , mCameraPhotoPath ;
// Storage
// Storage
@ -1307,6 +1308,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private final CloseTabListener mExitListener ;
private final CloseTabListener mExitListener ;
private final Drawable mBackgroundTabDrawable ;
private final Drawable mBackgroundTabDrawable ;
private final Drawable mForegroundTabDrawable ;
private final Drawable mForegroundTabDrawable ;
private final Bitmap mForegroundTabBitmap ;
private final DrawerItemClickListener mClickListener ;
private final DrawerItemClickListener mClickListener ;
private final DrawerItemLongClickListener mLongClickListener ;
private final DrawerItemLongClickListener mLongClickListener ;
private ColorMatrix mColorMatrix ;
private ColorMatrix mColorMatrix ;
@ -1324,6 +1326,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
if ( mShowTabsInDrawer ) {
if ( mShowTabsInDrawer ) {
mBackgroundTabDrawable = null ;
mBackgroundTabDrawable = null ;
mForegroundTabBitmap = null ;
mForegroundTabDrawable = ThemeUtils . getSelectedBackground ( context , mDarkTheme ) ;
mForegroundTabDrawable = ThemeUtils . getSelectedBackground ( context , mDarkTheme ) ;
} else {
} else {
int backgroundColor = Utils . mixTwoColors ( ThemeUtils . getPrimaryColor ( mActivity ) , Color . BLACK , 0 . 75f ) ;
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 ) ;
mBackgroundTabDrawable = new BitmapDrawable ( getResources ( ) , backgroundTabBitmap ) ;
int foregroundColor = ThemeUtils . getPrimaryColor ( context ) ;
int foregroundColor = ThemeUtils . getPrimaryColor ( context ) ;
Bitmap f oregroundTabBitmap = Bitmap . createBitmap ( Utils . dpToPx ( 175 ) , Utils . dpToPx ( 30 ) , Bitmap . Config . ARGB_8888 ) ;
mF oregroundTabBitmap = Bitmap . createBitmap ( Utils . dpToPx ( 175 ) , Utils . dpToPx ( 30 ) , Bitmap . Config . ARGB_8888 ) ;
Utils . drawTrapezoid ( new Canvas ( f oregroundTabBitmap) , foregroundColor , false ) ;
Utils . drawTrapezoid ( new Canvas ( mF oregroundTabBitmap) , foregroundColor , false ) ;
mForegroundTabDrawable = new BitmapDrawable ( getReso urces ( ) , foregroundTabBitmap ) . mutate ( ) ;
mForegroundTabDrawable = n ull ;
}
}
}
}
@ -1364,13 +1367,22 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} else {
} else {
holder . txtTitle . setTextAppearance ( context , R . style . boldText ) ;
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 ) {
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . JELLY_BEAN ) {
holder . layout . setBackground ( mForegroundTabDrawable ) ;
holder . layout . setBackground ( foreground Drawable) ;
} else {
} else {
holder . layout . setBackgroundDrawable ( mForegroundTabDrawable ) ;
holder . layout . setBackgroundDrawable ( foreground Drawable) ;
}
}
if ( ! isIncognito ( ) & & mColorMode ) {
if ( ! isIncognito ( ) & & mColorMode ) {
changeToolbarBackground ( favicon , null /* mForegroundTabDrawable */ ) ;
changeToolbarBackground ( favicon , foregroundDrawable ) ;
}
}
holder . favicon . setImageBitmap ( favicon ) ;
holder . favicon . setImageBitmap ( favicon ) ;
} else {
} else {
@ -1448,16 +1460,15 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* @param tabBackground the optional LinearLayout to color
* @param tabBackground the optional LinearLayout to color
* /
* /
private void changeToolbarBackground ( @NonNull Bitmap favicon , @Nullable final Drawable tabBackground ) {
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 ;
final int defaultColor ;
if ( Build . VERSION . SDK_INT < = Build . VERSION_CODES . LOLLIPOP_MR1 ) {
if ( Build . VERSION . SDK_INT < = Build . VERSION_CODES . LOLLIPOP_MR1 ) {
defaultColor = getResources ( ) . getColor ( R . color . primary_color ) ;
defaultColor = getResources ( ) . getColor ( R . color . primary_color ) ;
} else {
} else {
defaultColor = getColor ( R . color . primary_color ) ;
defaultColor = getColor ( R . color . primary_color ) ;
}
}
if ( mCurrentUiColor = = Color . BLACK ) {
mCurrentUiColor = defaultColor ;
}
Palette . from ( favicon ) . generate ( new Palette . PaletteAsyncListener ( ) {
Palette . from ( favicon ) . generate ( new Palette . PaletteAsyncListener ( ) {
@Override
@Override
public void onGenerated ( Palette palette ) {
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
int finalColor ; // Lighten up the dark color if it is
// too dark
// too dark
if ( Utils . isColorTooDark ( color ) ) {
if ( ! mShowTabsInDrawer | | Utils . isColorTooDark ( color ) ) {
finalColor = Utils . mixTwoColors ( defaultColor , color , 0 . 25f ) ;
finalColor = Utils . mixTwoColors ( defaultColor , color , 0 . 25f ) ;
} else {
} else {
finalColor = color ;
finalColor = color ;
}
}
ValueAnimator anim = ValueAnimator . ofInt ( mBackground . getColor ( ) , finalColor ) ;
ValueAnimator anim = ValueAnimator . ofInt ( mCurrentUiColor , finalColor ) ;
anim . setEvaluator ( new ArgbEvaluator ( ) ) ;
anim . setEvaluator ( new ArgbEvaluator ( ) ) ;
final Window window = getWindow ( ) ;
final Window window = getWindow ( ) ;
if ( ! mShowTabsInDrawer ) {
if ( ! mShowTabsInDrawer ) {
@ -1490,6 +1501,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} else if ( tabBackground ! = null ) {
} else if ( tabBackground ! = null ) {
tabBackground . setColorFilter ( color , PorterDuff . Mode . SRC_IN ) ;
tabBackground . setColorFilter ( color , PorterDuff . Mode . SRC_IN ) ;
}
}
mCurrentUiColor = color ;
mToolbarLayout . setBackgroundColor ( color ) ;
mToolbarLayout . setBackgroundColor ( color ) ;
}
}