From: uazo Date: Tue, 12 Dec 2023 16:38:10 +0000 Subject: Use list mode for tab switcher Added a setting for the option need: Add-cromite-flags-support.patch License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html --- .../tab_management/TabUiFeatureUtilities.java | 4 +-- .../java/res/xml/privacy_preferences.xml | 7 ++++ .../flags/cromite/sTabSwitcherListMode.java | 33 +++++++++++++++++++ .../Use-list-mode-for-tab-switcher.grdp | 9 +++++ .../browser/toolbar/top/ToolbarPhone.java | 15 ++++++--- .../tab-switcher-list-mode.inc | 3 ++ 6 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sTabSwitcherListMode.java create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Use-list-mode-for-tab-switcher.grdp create mode 100644 cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/tab-switcher-list-mode.inc diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java @@ -16,6 +16,7 @@ import org.chromium.build.BuildConfig; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; import org.chromium.ui.base.DeviceFormFactor; +import org.chromium.chrome.browser.flags.cromite.sTabSwitcherListMode; import java.util.Collections; import java.util.HashSet; @@ -115,8 +116,7 @@ public class TabUiFeatureUtilities { /** Returns whether the Grid Tab Switcher UI should use list mode. */ public static boolean shouldUseListMode() { - // Low-end forces list mode. - return SysUtils.isLowEndDevice(); + return sTabSwitcherListMode.getInstance().isEnabled(); } /** diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml --- a/chrome/android/java/res/xml/privacy_preferences.xml +++ b/chrome/android/java/res/xml/privacy_preferences.xml @@ -74,6 +74,13 @@ found in the LICENSE file. android:summary="@string/settings_incognito_tab_lock_summary_android_setting_off" android:persistent="false" /> + + diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sTabSwitcherListMode.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sTabSwitcherListMode.java new file mode 100644 --- /dev/null +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sTabSwitcherListMode.java @@ -0,0 +1,33 @@ +/* + This file is part of Cromite. + + Cromite is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Cromite is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Cromite. If not, see . +*/ + +package org.chromium.chrome.browser.flags.cromite; + +import org.chromium.base.cached_flags.CachedFlag; +import org.chromium.chrome.browser.flags.ChromeFeatureMap; + +public class sTabSwitcherListMode { + private static final CachedFlag sInstance = + new CachedFlag(ChromeFeatureMap.getInstance(), + "TabSwitcherListMode", false); + + private sTabSwitcherListMode() {} + + public static CachedFlag getInstance() { + return sInstance; + } +} diff --git a/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Use-list-mode-for-tab-switcher.grdp b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Use-list-mode-for-tab-switcher.grdp new file mode 100644 --- /dev/null +++ b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Use-list-mode-for-tab-switcher.grdp @@ -0,0 +1,9 @@ + + + + Use list mode for tab switcher + + + Activates the list view of tabs in the tab switcher + + diff --git a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java --- a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java +++ b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java @@ -53,6 +53,7 @@ import org.chromium.base.TraceEvent; import org.chromium.base.supplier.ObservableSupplier; import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.flags.ChromeFeatureList; +import org.chromium.chrome.browser.flags.cromite.sTabSwitcherListMode; import org.chromium.chrome.browser.omnibox.LocationBar; import org.chromium.chrome.browser.omnibox.LocationBarCoordinator; import org.chromium.chrome.browser.omnibox.NewTabPageDelegate; @@ -520,7 +521,8 @@ public class ToolbarPhone extends ToolbarLayout private void inflateTabSwitchingResources() { mToggleTabStackButton = findViewById(R.id.tab_switcher_button); - mToggleTabStackButton.setClickable(false); + if (!sTabSwitcherListMode.getInstance().isEnabled()) + mToggleTabStackButton.setClickable(false); } private void enableTabSwitchingResources() { @@ -2044,14 +2046,15 @@ public class ToolbarPhone extends ToolbarLayout // On entering the tab switcher, set the focusability of the url bar to be false. This will // occur at the start of the enter event, and will later be reset to true upon finishing the // exit event only in #onStartSurfaceStateChanged. - if (inTabSwitcherMode) { + if (inTabSwitcherMode && !sTabSwitcherListMode.getInstance().isEnabled()) { mLocationBar.setUrlBarFocusable(false); } // This method is only used for grid tab switcher with the start surface disabled. When // start surface is enabled, omnibox state is updated in onStartSurfaceStateChanged(), which // is always called before setTabSwitcherMode(), so skip here. - if (getToolbarDataProvider().shouldShowLocationBarInOverviewMode()) { + if (getToolbarDataProvider().shouldShowLocationBarInOverviewMode() + && !sTabSwitcherListMode.getInstance().isEnabled()) { // Prevent pressing the tab switcher button until after transition finishes. mToggleTabStackButton.setClickable(false); return; @@ -2071,7 +2074,8 @@ public class ToolbarPhone extends ToolbarLayout return; } // Prevent pressing the tab switcher button until after transition finishes. - mToggleTabStackButton.setClickable(false); + if (!sTabSwitcherListMode.getInstance().isEnabled()) + mToggleTabStackButton.setClickable(false); mTabSwitcherState = inTabSwitcherMode ? ENTERING_TAB_SWITCHER : EXITING_TAB_SWITCHER; @@ -2165,7 +2169,8 @@ public class ToolbarPhone extends ToolbarLayout } if (mTabSwitcherState == ENTERING_TAB_SWITCHER) { mTabSwitcherState = TAB_SWITCHER; - mToggleTabStackButton.setClickable(false); + if (!sTabSwitcherListMode.getInstance().isEnabled()) + mToggleTabStackButton.setClickable(false); } // Ensure clickable if in STATIC_TAB mode. This handles both when the state transitions // are ignored in favor of onStartSurfaceStateChanged() and when normal transitions occur. diff --git a/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/tab-switcher-list-mode.inc b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/tab-switcher-list-mode.inc new file mode 100644 --- /dev/null +++ b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/tab-switcher-list-mode.inc @@ -0,0 +1,3 @@ +CROMITE_FEATURE(kTabSwitcherListMode, + "TabSwitcherListMode", + base::FEATURE_DISABLED_BY_DEFAULT); --