Files
cromite/build/patches/Use-list-mode-for-tab-switcher.patch
T

173 lines
9.0 KiB
Diff

From: uazo <uazo@users.noreply.github.com>
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 | 6 ++++
.../flags/cromite/sTabSwitcherListMode.java | 33 +++++++++++++++++++
.../Use-list-mode-for-tab-switcher.grdp | 9 +++++
.../browser/toolbar/top/ToolbarPhone.java | 16 +++++----
.../tab-switcher-list-mode.inc | 3 ++
6 files changed, 63 insertions(+), 8 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
@@ -11,6 +11,7 @@ import org.chromium.base.ResettersForTesting;
import org.chromium.base.SysUtils;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.ui.base.DeviceFormFactor;
+import org.chromium.chrome.browser.flags.cromite.sTabSwitcherListMode;
import java.util.Locale;
import java.util.Set;
@@ -46,8 +47,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() || ChromeFeatureList.sForceListTabSwitcher.isEnabled();
+ return sTabSwitcherListMode.getInstance().isEnabled() || ChromeFeatureList.sForceListTabSwitcher.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
@@ -95,6 +95,12 @@ found in the LICENSE file.
android:summary="@string/allow_external_intent_requests_summary"
app:featureName="AllowExternalIntentRequests"
app:needRestart="false" />
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
+ android:key="use_tab_switcher_list_mode"
+ android:title="@string/tab_switcher_list_mode_title"
+ android:summary="@string/tab_switcher_list_mode_summary"
+ app:featureName="TabSwitcherListMode"
+ app:needRestart="true" />
<PreferenceCategory
android:key="security_section"
android:title="@string/security_section_title" />
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 <https://www.gnu.org/licenses/>.
+*/
+
+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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grit-part>
+ <message name="IDS_TAB_SWITCHER_LIST_MODE_TITLE" desc="Text for 'Use list mode for tab switcher' settings-privacy option.">
+ Use list mode for tab switcher
+ </message>
+ <message name="IDS_TAB_SWITCHER_LIST_MODE_SUMMARY" desc="Summary text for 'Use list mode for tab switcher' settings-privacy option.">
+ Activates the list view of tabs in the tab switcher
+ </message>
+</grit-part>
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
@@ -51,6 +51,7 @@ import org.chromium.base.MathUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.supplier.ObservableSupplier;
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;
@@ -503,7 +504,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() {
@@ -1935,7 +1937,7 @@ 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.
- if (inTabSwitcherMode) {
+ if (inTabSwitcherMode && !sTabSwitcherListMode.getInstance().isEnabled()) {
mLocationBar.setUrlBarFocusable(false);
}
@@ -1952,9 +1954,10 @@ public class ToolbarPhone extends ToolbarLayout
&& (mTabSwitcherState == STATIC_TAB || mTabSwitcherState == EXITING_TAB_SWITCHER)) {
return;
}
- // Prevent pressing the tab switcher button until after transition finishes.
- mToggleTabStackButton.setClickable(false);
-
+ if (!sTabSwitcherListMode.getInstance().isEnabled()) {
+ // Prevent pressing the tab switcher button until after transition finishes.
+ mToggleTabStackButton.setClickable(false);
+ }
mTabSwitcherState = inTabSwitcherMode ? ENTERING_TAB_SWITCHER : EXITING_TAB_SWITCHER;
// The width of location bar depends on mTabSwitcherState so layout request is needed. See
@@ -2014,7 +2017,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.
if (mTabSwitcherState == STATIC_TAB) {
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);
--