Commit 2bfdf22c authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Hide tab switcher button instead of removing in HTS

Previously the tab switcher button was removed when HTS was enabled.
This is incorrect since accessibility mode could mean reverting to using
the old tab switcher top toolbar with the tab switcher button. This CL
hides and shows the tab switcher button depending on the accessibility
state.

Bug: 914858

Change-Id: I1b74f5ed2e94380e260d2a4c6f0fb746f270e2e5
Reviewed-on: https://chromium-review.googlesource.com/c/1385126
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619848}
parent 975c38bb
...@@ -43,11 +43,11 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout ...@@ -43,11 +43,11 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout
private IncognitoStateProvider mIncognitoStateProvider; private IncognitoStateProvider mIncognitoStateProvider;
private @Nullable IncognitoToggleTabLayout mIncognitoToggleTabLayout; private @Nullable IncognitoToggleTabLayout mIncognitoToggleTabLayout;
private @Nullable ToggleTabStackButton mToggleTabStackButton;
// The following two buttons are not used when Duet is enabled. // The following three buttons are not used when Duet is enabled.
private @Nullable NewTabButton mNewTabButton; private @Nullable NewTabButton mNewTabButton;
private @Nullable MenuButton mMenuButton; private @Nullable MenuButton mMenuButton;
private @Nullable ToggleTabStackButton mToggleTabStackButton;
private int mPrimaryColor; private int mPrimaryColor;
private boolean mUseLightIcons; private boolean mUseLightIcons;
...@@ -74,7 +74,16 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout ...@@ -74,7 +74,16 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout
if (isBottomToolbarEnabled) { if (isBottomToolbarEnabled) {
UiUtils.removeViewFromParent(mNewTabButton); UiUtils.removeViewFromParent(mNewTabButton);
mNewTabButton.destroy();
mNewTabButton = null;
UiUtils.removeViewFromParent(mMenuButton); UiUtils.removeViewFromParent(mMenuButton);
mMenuButton.destroy();
mMenuButton = null;
UiUtils.removeViewFromParent(mToggleTabStackButton);
mToggleTabStackButton.destroy();
mToggleTabStackButton = null;
} else { } else {
// TODO(twellington): Try to make NewTabButton responsible for handling its own clicks. // TODO(twellington): Try to make NewTabButton responsible for handling its own clicks.
// TabSwitcherBottomToolbarCoordinator also uses NewTabButton and // TabSwitcherBottomToolbarCoordinator also uses NewTabButton and
...@@ -86,9 +95,7 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout ...@@ -86,9 +95,7 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout
if (usingHorizontalTabSwitcher() if (usingHorizontalTabSwitcher()
&& PrefServiceBridge.getInstance().isIncognitoModeEnabled()) { && PrefServiceBridge.getInstance().isIncognitoModeEnabled()) {
inflateIncognitoToggle(); updateTabSwitchingElements(true);
} else if (isBottomToolbarEnabled) {
removeToggleTabStackButton();
} }
} }
...@@ -246,11 +253,9 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout ...@@ -246,11 +253,9 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout
void onAccessibilityStatusChanged(boolean enabled) { void onAccessibilityStatusChanged(boolean enabled) {
if (mNewTabButton != null) mNewTabButton.onAccessibilityStatusChanged(); if (mNewTabButton != null) mNewTabButton.onAccessibilityStatusChanged();
if (mIncognitoToggleTabLayout != null) { if (ChromeFeatureList.isEnabled(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID)
mIncognitoToggleTabLayout.setVisibility(enabled ? View.GONE : View.VISIBLE);
} else if (usingHorizontalTabSwitcher()
&& PrefServiceBridge.getInstance().isIncognitoModeEnabled()) { && PrefServiceBridge.getInstance().isIncognitoModeEnabled()) {
inflateIncognitoToggle(); updateTabSwitchingElements(!enabled);
} }
updatePrimaryColorAndTint(); updatePrimaryColorAndTint();
...@@ -316,15 +321,23 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout ...@@ -316,15 +321,23 @@ public class TabSwitcherModeTTPhone extends OptimizedFrameLayout
if (mTabModelSelector != null) { if (mTabModelSelector != null) {
mIncognitoToggleTabLayout.setTabModelSelector(mTabModelSelector); mIncognitoToggleTabLayout.setTabModelSelector(mTabModelSelector);
} }
}
removeToggleTabStackButton(); private void setIncognitoToggleVisibility(boolean showIncognitoToggle) {
if (mIncognitoToggleTabLayout == null) {
if (showIncognitoToggle) inflateIncognitoToggle();
} else {
mIncognitoToggleTabLayout.setVisibility(showIncognitoToggle ? View.VISIBLE : View.GONE);
}
} }
private void removeToggleTabStackButton() { private void setToggleTabStackButtonVisibility(boolean showToggleTabStackButton) {
if (mToggleTabStackButton == null) return; if (mToggleTabStackButton == null) return;
mToggleTabStackButton.setVisibility(showToggleTabStackButton ? View.VISIBLE : View.GONE);
}
UiUtils.removeViewFromParent(mToggleTabStackButton); private void updateTabSwitchingElements(boolean showIncognitoToggle) {
mToggleTabStackButton.destroy(); setIncognitoToggleVisibility(showIncognitoToggle);
mToggleTabStackButton = null; setToggleTabStackButtonVisibility(!showIncognitoToggle);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment