0

Remove non-modern code from AccessibilityTabModelWrapper

Bug: 876051

Change-Id: I7826a815732a64d4b728be2f6b8565c5259f974c
Reviewed-on: https://chromium-review.googlesource.com/1217585
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Reviewed-by: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590074}
This commit is contained in:
Pedro Amaral
2018-09-10 21:44:44 +00:00
committed by Commit Bot
parent e52ac2b6a5
commit dc46b63fa2

@@ -10,7 +10,6 @@ import android.support.design.widget.TabLayout;
import android.support.v7.content.res.AppCompatResources;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -22,7 +21,6 @@ import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.browser.widget.TintedImageView;
import org.chromium.chrome.browser.widget.accessibility.AccessibilityTabModelAdapter.AccessibilityTabModelAdapterListener;
@@ -34,15 +32,12 @@ import org.chromium.chrome.browser.widget.accessibility.AccessibilityTabModelAda
*/
public class AccessibilityTabModelWrapper extends LinearLayout {
private AccessibilityTabModelListView mAccessibilityView;
private LinearLayout mStackButtonWrapper;
private ImageButton mStandardButton;
private ImageButton mIncognitoButton;
private View mModernLayout;
private TabLayout mModernStackButtonWrapper;
private TabLayout.Tab mModernStandardButton;
private TabLayout.Tab mModernIncognitoButton;
private TintedImageView mModernStandardButtonIcon;
private TintedImageView mModernIncognitoButtonIcon;
private View mLayout;
private TabLayout mStackButtonWrapper;
private TabLayout.Tab mStandardButton;
private TabLayout.Tab mIncognitoButton;
private TintedImageView mStandardButtonIcon;
private TintedImageView mIncognitoButtonIcon;
private ColorStateList mTabIconDarkColor;
private ColorStateList mTabIconLightColor;
@@ -101,63 +96,53 @@ public class AccessibilityTabModelWrapper extends LinearLayout {
* parent.
*/
public void setup(AccessibilityTabModelAdapterListener listener) {
if (FeatureUtilities.isChromeModernDesignEnabled()) {
mTabIconDarkColor =
AppCompatResources.getColorStateList(getContext(), R.color.dark_mode_tint);
mTabIconSelectedDarkColor =
AppCompatResources.getColorStateList(getContext(), R.color.light_active_color);
mTabIconLightColor =
AppCompatResources.getColorStateList(getContext(), R.color.white_alpha_70);
mTabIconSelectedLightColor =
AppCompatResources.getColorStateList(getContext(), R.color.white_mode_tint);
// Setting scaleY here to make sure the icons are not flipped due to the scaleY of its
// container layout.
mModernStandardButtonIcon = new TintedImageView(getContext());
mModernStandardButtonIcon.setImageResource(R.drawable.btn_normal_tabs);
mModernStandardButtonIcon.setScaleY(-1.0f);
mModernIncognitoButtonIcon = new TintedImageView(getContext());
mModernIncognitoButtonIcon.setImageResource(R.drawable.btn_incognito_tabs);
mModernIncognitoButtonIcon.setScaleY(-1.0f);
mTabIconDarkColor =
AppCompatResources.getColorStateList(getContext(), R.color.dark_mode_tint);
mTabIconSelectedDarkColor =
AppCompatResources.getColorStateList(getContext(), R.color.light_active_color);
mTabIconLightColor =
AppCompatResources.getColorStateList(getContext(), R.color.white_alpha_70);
mTabIconSelectedLightColor =
AppCompatResources.getColorStateList(getContext(), R.color.white_mode_tint);
// Setting scaleY here to make sure the icons are not flipped due to the scaleY of its
// container layout.
mStandardButtonIcon = new TintedImageView(getContext());
mStandardButtonIcon.setImageResource(R.drawable.btn_normal_tabs);
mStandardButtonIcon.setScaleY(-1.0f);
mIncognitoButtonIcon = new TintedImageView(getContext());
mIncognitoButtonIcon.setImageResource(R.drawable.btn_incognito_tabs);
mIncognitoButtonIcon.setScaleY(-1.0f);
setDividerDrawable(null);
((ListView) findViewById(R.id.list_view)).setDivider(null);
setDividerDrawable(null);
((ListView) findViewById(R.id.list_view)).setDivider(null);
mModernLayout = findViewById(R.id.tab_wrapper);
mModernStackButtonWrapper = findViewById(R.id.tab_layout);
mModernStandardButton =
mModernStackButtonWrapper.newTab()
.setCustomView(mModernStandardButtonIcon)
.setContentDescription(
R.string.accessibility_tab_switcher_standard_stack);
mModernStackButtonWrapper.addTab(mModernStandardButton);
mModernIncognitoButton =
mModernStackButtonWrapper.newTab()
.setCustomView(mModernIncognitoButtonIcon)
.setContentDescription(
ChromeFeatureList.isEnabled(ChromeFeatureList.INCOGNITO_STRINGS)
? R.string.accessibility_tab_switcher_private_stack
: R.string.accessibility_tab_switcher_incognito_stack);
mModernStackButtonWrapper.addTab(mModernIncognitoButton);
mModernStackButtonWrapper.addOnTabSelectedListener(
new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
setSelectedModel(mModernIncognitoButton.isSelected());
}
mLayout = findViewById(R.id.tab_wrapper);
mStackButtonWrapper = findViewById(R.id.tab_layout);
mStandardButton =
mStackButtonWrapper.newTab()
.setCustomView(mStandardButtonIcon)
.setContentDescription(R.string.accessibility_tab_switcher_standard_stack);
mStackButtonWrapper.addTab(mStandardButton);
mIncognitoButton =
mStackButtonWrapper.newTab()
.setCustomView(mIncognitoButtonIcon)
.setContentDescription(
ChromeFeatureList.isEnabled(ChromeFeatureList.INCOGNITO_STRINGS)
? R.string.accessibility_tab_switcher_private_stack
: R.string.accessibility_tab_switcher_incognito_stack);
mStackButtonWrapper.addTab(mIncognitoButton);
mStackButtonWrapper.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
setSelectedModel(mIncognitoButton.isSelected());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {}
@Override
public void onTabUnselected(TabLayout.Tab tab) {}
@Override
public void onTabReselected(TabLayout.Tab tab) {}
});
} else {
mStackButtonWrapper = (LinearLayout) findViewById(R.id.button_wrapper);
mStandardButton = (ImageButton) findViewById(R.id.standard_tabs_button);
mStandardButton.setOnClickListener(new ButtonOnClickListener(false));
mIncognitoButton = (ImageButton) findViewById(R.id.incognito_tabs_button);
mIncognitoButton.setOnClickListener(new ButtonOnClickListener(true));
}
@Override
public void onTabReselected(TabLayout.Tab tab) {}
});
mAccessibilityView = (AccessibilityTabModelListView) findViewById(R.id.list_view);
@@ -191,37 +176,27 @@ public class AccessibilityTabModelWrapper extends LinearLayout {
boolean incognitoSelected = mTabModelSelector.isIncognitoSelected();
updateVisibilityForLayoutOrStackButton();
if (FeatureUtilities.isChromeModernDesignEnabled()) {
if (incognitoSelected) {
setBackgroundColor(ApiCompatibilityUtils.getColor(
getResources(), R.color.incognito_modern_primary_color));
mModernStackButtonWrapper.setSelectedTabIndicatorColor(
mTabIconSelectedLightColor.getDefaultColor());
mModernStandardButtonIcon.setTint(mTabIconLightColor);
mModernIncognitoButtonIcon.setTint(mTabIconSelectedLightColor);
} else {
setBackgroundColor(ApiCompatibilityUtils.getColor(
getResources(), R.color.modern_primary_color));
mModernStackButtonWrapper.setSelectedTabIndicatorColor(
mTabIconSelectedDarkColor.getDefaultColor());
mModernStandardButtonIcon.setTint(mTabIconSelectedDarkColor);
mModernIncognitoButtonIcon.setTint(mTabIconDarkColor);
}
// Ensure the tab in tab layout is correctly selected when tab switcher is
// first opened.
if (incognitoSelected && !mModernIncognitoButton.isSelected()) {
mModernIncognitoButton.select();
} else if (!incognitoSelected && !mModernStandardButton.isSelected()) {
mModernStandardButton.select();
}
if (incognitoSelected) {
setBackgroundColor(ApiCompatibilityUtils.getColor(
getResources(), R.color.incognito_modern_primary_color));
mStackButtonWrapper.setSelectedTabIndicatorColor(
mTabIconSelectedLightColor.getDefaultColor());
mStandardButtonIcon.setTint(mTabIconLightColor);
mIncognitoButtonIcon.setTint(mTabIconSelectedLightColor);
} else {
if (incognitoSelected) {
mIncognitoButton.setBackgroundResource(R.drawable.btn_bg_holo_active);
mStandardButton.setBackgroundResource(R.drawable.btn_bg_holo);
} else {
mIncognitoButton.setBackgroundResource(R.drawable.btn_bg_holo);
mStandardButton.setBackgroundResource(R.drawable.btn_bg_holo_active);
}
setBackgroundColor(
ApiCompatibilityUtils.getColor(getResources(), R.color.modern_primary_color));
mStackButtonWrapper.setSelectedTabIndicatorColor(
mTabIconSelectedDarkColor.getDefaultColor());
mStandardButtonIcon.setTint(mTabIconSelectedDarkColor);
mIncognitoButtonIcon.setTint(mTabIconDarkColor);
}
// Ensure the tab in tab layout is correctly selected when tab switcher is
// first opened.
if (incognitoSelected && !mIncognitoButton.isSelected()) {
mIncognitoButton.select();
} else if (!incognitoSelected && !mStandardButton.isSelected()) {
mStandardButton.select();
}
mAccessibilityView.setContentDescription(incognitoSelected
@@ -265,11 +240,7 @@ public class AccessibilityTabModelWrapper extends LinearLayout {
private void updateVisibilityForLayoutOrStackButton() {
boolean incognitoEnabled =
mTabModelSelector.getModel(true).getComprehensiveModel().getCount() > 0;
if (FeatureUtilities.isChromeModernDesignEnabled()) {
mModernLayout.setVisibility(incognitoEnabled ? View.VISIBLE : View.GONE);
} else {
mStackButtonWrapper.setVisibility(incognitoEnabled ? View.VISIBLE : View.GONE);
}
mLayout.setVisibility(incognitoEnabled ? View.VISIBLE : View.GONE);
}
@Override
@@ -287,11 +258,11 @@ public class AccessibilityTabModelWrapper extends LinearLayout {
@VisibleForTesting
public TabLayout.Tab getIncognitoTabsButton() {
return mModernIncognitoButton;
return mIncognitoButton;
}
@VisibleForTesting
public TabLayout.Tab getStandardTabsButton() {
return mModernStandardButton;
return mStandardButton;
}
}