Fixed bug where changing theme resulted in default tab icons being incorrectly themed
This commit is contained in:
parent
8f230e3550
commit
87ae1eb8fe
@ -117,7 +117,7 @@ public class LightningView {
|
|||||||
mUIController = (UIController) activity;
|
mUIController = (UIController) activity;
|
||||||
mWebView = new WebView(activity);
|
mWebView = new WebView(activity);
|
||||||
mIsIncognitoTab = isIncognito;
|
mIsIncognitoTab = isIncognito;
|
||||||
mTitle = new LightningViewTitle(activity, mUIController.getUseDarkTheme());
|
mTitle = new LightningViewTitle(activity);
|
||||||
|
|
||||||
mMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();
|
mMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();
|
||||||
|
|
||||||
@ -1000,7 +1000,7 @@ public class LightningView {
|
|||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public Bitmap getFavicon() {
|
public Bitmap getFavicon() {
|
||||||
return mTitle.getFavicon();
|
return mTitle.getFavicon(mUIController.getUseDarkTheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,16 +16,15 @@ import acr.browser.lightning.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
class LightningViewTitle {
|
class LightningViewTitle {
|
||||||
|
|
||||||
@Nullable private static Bitmap DEFAULT_ICON;
|
@Nullable private static Bitmap DEFAULT_DARK_ICON;
|
||||||
|
@Nullable private static Bitmap DEFAULT_LIGHT_ICON;
|
||||||
|
|
||||||
@NonNull private final Bitmap mDefault;
|
@Nullable private Bitmap mFavicon = null;
|
||||||
@NonNull private Bitmap mFavicon;
|
|
||||||
@NonNull private String mTitle;
|
@NonNull private String mTitle;
|
||||||
|
@NonNull Context mContext;
|
||||||
|
|
||||||
public LightningViewTitle(@NonNull Context context, boolean darkTheme) {
|
public LightningViewTitle(@NonNull Context context) {
|
||||||
DEFAULT_ICON = getDefault(context, darkTheme);
|
mContext = context;
|
||||||
mDefault = DEFAULT_ICON;
|
|
||||||
mFavicon = mDefault;
|
|
||||||
mTitle = context.getString(R.string.action_new_tab);
|
mTitle = context.getString(R.string.action_new_tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,25 +36,32 @@ class LightningViewTitle {
|
|||||||
*/
|
*/
|
||||||
public void setFavicon(@Nullable Bitmap favicon) {
|
public void setFavicon(@Nullable Bitmap favicon) {
|
||||||
if (favicon == null) {
|
if (favicon == null) {
|
||||||
mFavicon = mDefault;
|
mFavicon = null;
|
||||||
} else {
|
} else {
|
||||||
mFavicon = Utils.padFavicon(favicon);
|
mFavicon = Utils.padFavicon(favicon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to initialize the DEFAULT_ICON variable.
|
* Helper method to initialize the DEFAULT_ICON variables
|
||||||
*
|
*
|
||||||
* @param context the context needed to initialize the Bitmap.
|
* @param context the context needed to initialize the Bitmap.
|
||||||
* @param darkTheme whether the icon should be themed dark or not.
|
* @param darkTheme whether the icon should be themed dark or not.
|
||||||
* @return a not null icon.
|
* @return a not null icon.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
private static Bitmap getDefault(@NonNull Context context, boolean darkTheme) {
|
private static Bitmap getDefaultIcon(@NonNull Context context, boolean darkTheme) {
|
||||||
if (DEFAULT_ICON == null) {
|
if (darkTheme) {
|
||||||
DEFAULT_ICON = ThemeUtils.getThemedBitmap(context, R.drawable.ic_webpage, darkTheme);
|
if (DEFAULT_DARK_ICON == null) {
|
||||||
|
DEFAULT_DARK_ICON = ThemeUtils.getThemedBitmap(context, R.drawable.ic_webpage, true);
|
||||||
|
}
|
||||||
|
return DEFAULT_DARK_ICON;
|
||||||
|
} else {
|
||||||
|
if (DEFAULT_LIGHT_ICON == null) {
|
||||||
|
DEFAULT_LIGHT_ICON = ThemeUtils.getThemedBitmap(context, R.drawable.ic_webpage, false);
|
||||||
|
}
|
||||||
|
return DEFAULT_LIGHT_ICON;
|
||||||
}
|
}
|
||||||
return DEFAULT_ICON;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +96,10 @@ class LightningViewTitle {
|
|||||||
* @return the favicon or a default if that is null.
|
* @return the favicon or a default if that is null.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public Bitmap getFavicon() {
|
public Bitmap getFavicon(boolean darkTheme) {
|
||||||
|
if (mFavicon == null) {
|
||||||
|
return getDefaultIcon(mContext, darkTheme);
|
||||||
|
}
|
||||||
return mFavicon;
|
return mFavicon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user