Added back/forward icon enable/disabling on tablet devices
This commit is contained in:
parent
f2d2c8ed5f
commit
737c02d6e8
@ -179,6 +179,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
private int mOriginalOrientation;
|
||||
private int mBackgroundColor;
|
||||
private int mIconColor;
|
||||
private int mDisabledIconColor;
|
||||
private int mCurrentUiColor = Color.BLACK;
|
||||
private String mSearchText;
|
||||
private String mUntitledTitle;
|
||||
@ -258,6 +259,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
//TODO make sure dark theme flag gets set correctly
|
||||
mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito();
|
||||
mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this);
|
||||
mDisabledIconColor = mDarkTheme ? ContextCompat.getColor(this, R.color.icon_dark_theme_disabled) :
|
||||
ContextCompat.getColor(this, R.color.icon_light_theme_disabled);
|
||||
mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet());
|
||||
|
||||
// initialize background ColorDrawable
|
||||
@ -1360,14 +1363,45 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
mDrawerLayout.closeDrawers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForwardButtonEnabled(boolean enabled) {
|
||||
if (mForwardMenuItem != null && mForwardMenuItem.getIcon() != null) {
|
||||
int colorFilter;
|
||||
if (enabled) {
|
||||
colorFilter = mIconColor;
|
||||
} else {
|
||||
colorFilter = mDisabledIconColor;
|
||||
}
|
||||
mForwardMenuItem.getIcon().setColorFilter(colorFilter, PorterDuff.Mode.SRC_IN);
|
||||
mForwardMenuItem.setIcon(mForwardMenuItem.getIcon());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackButtonEnabled(boolean enabled) {
|
||||
if (mBackMenuItem != null && mBackMenuItem.getIcon() != null) {
|
||||
int colorFilter;
|
||||
if (enabled) {
|
||||
colorFilter = mIconColor;
|
||||
} else {
|
||||
colorFilter = mDisabledIconColor;
|
||||
}
|
||||
mBackMenuItem.getIcon().setColorFilter(colorFilter, PorterDuff.Mode.SRC_IN);
|
||||
mBackMenuItem.setIcon(mBackMenuItem.getIcon());
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem mBackMenuItem;
|
||||
private MenuItem mForwardMenuItem;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuItem back = menu.findItem(R.id.action_back);
|
||||
MenuItem forward = menu.findItem(R.id.action_forward);
|
||||
if (back != null && back.getIcon() != null)
|
||||
back.getIcon().setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
|
||||
if (forward != null && forward.getIcon() != null)
|
||||
forward.getIcon().setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
|
||||
mBackMenuItem = menu.findItem(R.id.action_back);
|
||||
mForwardMenuItem = menu.findItem(R.id.action_forward);
|
||||
if (mBackMenuItem != null && mBackMenuItem.getIcon() != null)
|
||||
mBackMenuItem.getIcon().setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
|
||||
if (mForwardMenuItem != null && mForwardMenuItem.getIcon() != null)
|
||||
mForwardMenuItem.getIcon().setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,8 @@ public class BrowserPresenter {
|
||||
newTab.resumeTimers();
|
||||
newTab.setForegroundTab(true);
|
||||
mView.updateProgress(newTab.getProgress());
|
||||
mView.setBackButtonEnabled(newTab.canGoBack());
|
||||
mView.setForwardButtonEnabled(newTab.canGoForward());
|
||||
mView.updateUrl(newTab.getUrl(), true);
|
||||
mView.setTabView(newTab.getWebView());
|
||||
}
|
||||
|
@ -25,4 +25,8 @@ public interface BrowserView {
|
||||
|
||||
void showSnackbar(@StringRes int resource);
|
||||
|
||||
void setForwardButtonEnabled(boolean enabled);
|
||||
|
||||
void setBackButtonEnabled(boolean enabled);
|
||||
|
||||
}
|
||||
|
@ -55,4 +55,8 @@ public interface UIController {
|
||||
|
||||
void newTabClicked();
|
||||
|
||||
void setForwardButtonEnabled(boolean enabled);
|
||||
|
||||
void setBackButtonEnabled(boolean enabled);
|
||||
|
||||
}
|
||||
|
@ -97,6 +97,8 @@ public class LightningWebClient extends WebViewClient {
|
||||
public void onPageFinished(@NonNull WebView view, String url) {
|
||||
if (view.isShown()) {
|
||||
mUIController.updateUrl(url, true);
|
||||
mUIController.setBackButtonEnabled(view.canGoBack());
|
||||
mUIController.setForwardButtonEnabled(view.canGoForward());
|
||||
view.postInvalidate();
|
||||
}
|
||||
if (view.getTitle() == null || view.getTitle().isEmpty()) {
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
<color name="icon_light_theme">#8A000000</color>
|
||||
<color name="icon_dark_theme">#FFFFFFFF</color>
|
||||
<color name="icon_light_theme_disabled">#40000000</color>
|
||||
<color name="icon_dark_theme_disabled">#8AFFFFFF</color>
|
||||
|
||||
<color name="error_red">#F44336</color>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user