From c7a2532c1dee64c8407a9f1990cf4dca38c92921 Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Thu, 3 Jun 2021 23:40:12 -0400 Subject: [PATCH] Issue #19809: Change default tab tray view to grid layout --- app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt | 1 - .../org/mozilla/fenix/settings/TabsSettingsFragment.kt | 7 ++++++- .../org/mozilla/fenix/tabstray/browser/BrowserTrayList.kt | 2 +- app/src/main/java/org/mozilla/fenix/utils/Settings.kt | 7 +------ app/src/main/res/values/preference_keys.xml | 3 ++- app/src/main/res/xml/tabs_preferences.xml | 6 +++--- .../fenix/tabstray/TabsTrayInfoBannerBindingTest.kt | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt index 8d59f0663be5..d70ac3023004 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -1096,7 +1096,6 @@ class SmokeTest { verifyExistingOpenTabs("Test_Page_1") verifyCloseTabsButton("Test_Page_1") verifyOpenedTabThumbnail() - verifyBrowserTabsTrayURL("localhost") verifyTabTrayOverflowMenu(true) verifyNewTabButton() } diff --git a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt index d31fc341213e..23124d9a16a5 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt @@ -40,7 +40,12 @@ class TabsSettingsFragment : PreferenceFragmentCompat() { } private fun setupPreferences() { - listRadioButton = requirePreference(R.string.pref_key_tab_view_list) + // This should be the only use case for pref_key_tab_view_list_do_not_use. + // In the Fenix impl of RadioGroups, we need to always have an individual pref value + // for it to work. This is weird for a radio group that should hold a value from that group. + // For the tabs tray, we only need a boolean value, so let's rely on only the + // pref_key_tab_view_grid and look into using the native RadioGroup in the future. + listRadioButton = requirePreference(R.string.pref_key_tab_view_list_do_not_use) gridRadioButton = requirePreference(R.string.pref_key_tab_view_grid) radioManual = requirePreference(R.string.pref_key_close_tabs_manually) diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTrayList.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTrayList.kt index b3291c432c23..39f595a4cb24 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTrayList.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/BrowserTrayList.kt @@ -63,7 +63,7 @@ class BrowserTrayList @JvmOverloads constructor( TabsTouchHelper( observable = adapter as TabsAdapter, onViewHolderTouched = { swipeToDelete.isSwipeable }, - onViewHolderDraw = { context.components.settings.listTabView } + onViewHolderDraw = { context.components.settings.gridTabView.not() } ) } diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index dd304404a34e..e451a73f76c6 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -321,14 +321,9 @@ class Settings(private val appContext: Context) : PreferencesHolder { numberOfAppLaunches > APP_LAUNCHES_TO_SHOW_DEFAULT_BROWSER_CARD } - var listTabView by booleanPreference( - appContext.getPreferenceKey(R.string.pref_key_tab_view_list), - default = true - ) - var gridTabView by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_tab_view_grid), - default = false + default = true ) var manuallyCloseTabs by booleanPreference( diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 1dd74ffd4698..9292fd28a14c 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -254,7 +254,8 @@ pref_key_show_collections_home - pref_key_tab_view_list + + pref_key_tab_view_list pref_key_tab_view_grid pref_key_tabs pref_key_close_tabs_manually diff --git a/app/src/main/res/xml/tabs_preferences.xml b/app/src/main/res/xml/tabs_preferences.xml index 6476fd099dcd..d26f828cca8a 100644 --- a/app/src/main/res/xml/tabs_preferences.xml +++ b/app/src/main/res/xml/tabs_preferences.xml @@ -10,12 +10,12 @@ app:allowDividerAbove="false" app:iconSpaceReserved="false"> diff --git a/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayInfoBannerBindingTest.kt b/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayInfoBannerBindingTest.kt index b0b7664c5b7f..1b24bec798fc 100644 --- a/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayInfoBannerBindingTest.kt +++ b/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayInfoBannerBindingTest.kt @@ -80,7 +80,7 @@ class TabsTrayInfoBannerBindingTest { @Test fun `WHEN dismiss THEN auto close tabs info banner will not open tab settings`() { view.visibility = GONE - settings.listTabView = false + settings.gridTabView = true val binding = TabsTrayInfoBannerBinding(