diff --git a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt index df29c29161..d4aa5873fd 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt @@ -24,7 +24,6 @@ import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.amo_collection_override_dialog.view.* -import kotlinx.android.synthetic.main.fragment_installed_add_on_details.view.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -187,7 +186,7 @@ class SettingsFragment : PreferenceFragmentCompat() { } val tabSettingsPreference = - requirePreference(R.string.pref_key_close_tabs) + requirePreference(R.string.pref_key_tabs) tabSettingsPreference.summary = context?.settings()?.getTabTimeoutString() setupPreferences() @@ -212,8 +211,8 @@ class SettingsFragment : PreferenceFragmentCompat() { resources.getString(R.string.pref_key_sign_in) -> { SettingsFragmentDirections.actionSettingsFragmentToTurnOnSyncFragment() } - resources.getString(R.string.pref_key_close_tabs) -> { - SettingsFragmentDirections.actionSettingsFragmentToCloseTabsSettingsFragment() + resources.getString(R.string.pref_key_tabs) -> { + SettingsFragmentDirections.actionSettingsFragmentToTabsSettingsFragment() } resources.getString(R.string.pref_key_search_settings) -> { SettingsFragmentDirections.actionSettingsFragmentToSearchEngineFragment() diff --git a/app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt similarity index 72% rename from app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.kt rename to app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt index 9bb15f2952..6898f493b3 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt @@ -13,31 +13,42 @@ import org.mozilla.fenix.utils.view.addToRadioGroup /** * Lets the user customize auto closing tabs. */ -class CloseTabsSettingsFragment : PreferenceFragmentCompat() { +class TabsSettingsFragment : PreferenceFragmentCompat() { + private lateinit var listRadioButton: RadioButtonPreference + private lateinit var gridRadioButton: RadioButtonPreference private lateinit var radioManual: RadioButtonPreference private lateinit var radioOneDay: RadioButtonPreference private lateinit var radioOneWeek: RadioButtonPreference private lateinit var radioOneMonth: RadioButtonPreference override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - setPreferencesFromResource(R.xml.close_tabs_preferences, rootKey) + setPreferencesFromResource(R.xml.tabs_preferences, rootKey) } override fun onResume() { super.onResume() - showToolbar(getString(R.string.preferences_close_tabs)) + showToolbar(getString(R.string.preferences_tabs)) setupPreferences() } private fun setupPreferences() { + listRadioButton = requirePreference(R.string.pref_key_tab_view_list) + gridRadioButton = requirePreference(R.string.pref_key_tab_view_grid) + radioManual = requirePreference(R.string.pref_key_close_tabs_manually) radioOneDay = requirePreference(R.string.pref_key_close_tabs_after_one_day) radioOneWeek = requirePreference(R.string.pref_key_close_tabs_after_one_week) radioOneMonth = requirePreference(R.string.pref_key_close_tabs_after_one_month) + setupRadioGroups() } private fun setupRadioGroups() { + addToRadioGroup( + listRadioButton, + gridRadioButton + ) + addToRadioGroup( radioManual, radioOneDay, diff --git a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt index 41c6ddf404..b871eba3bb 100644 --- a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt +++ b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt @@ -92,7 +92,7 @@ class DefaultTabTrayController( } override fun handleTabSettingsClicked() { - navController.navigate(TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment()) + navController.navigate(TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()) } override fun onTabTrayDismissed() { @@ -187,7 +187,7 @@ class DefaultTabTrayController( } override fun handleSetUpAutoCloseTabsClicked() { - val directions = TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment() + val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment() navController.navigate(directions) } } 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 16f07e4381..247ce6696e 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -345,6 +345,16 @@ class Settings(private val appContext: Context) : PreferencesHolder { default = false ) + 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 + ) + var manuallyCloseTabs by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_close_tabs_manually), default = true diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 67edefc7e8..2fca420f10 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -111,8 +111,8 @@ android:id="@+id/action_global_tabHistoryDialogFragment" app:destination="@id/tabHistoryDialogFragment" /> + android:id="@+id/action_global_tabSettingsFragment" + app:destination="@id/tabsSettingsFragment" /> + android:id="@+id/tabsSettingsFragment" + android:name="org.mozilla.fenix.settings.TabsSettingsFragment" + android:label="@string/preferences_tabs" /> pref_home_category - - pref_key_website_pull_to_refresh pref_key_dynamic_toolbar pref_key_swipe_toolbar_switch_tabs @@ -225,7 +223,10 @@ pref_key_show_collections_home - pref_key_close_tabs + + pref_key_tab_view_list + pref_key_tab_view_grid + pref_key_tabs pref_key_close_tabs_manually pref_key_close_tabs_after_one_day pref_key_close_tabs_after_one_week diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2d744301eb..a10bfe6e7b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -531,6 +531,14 @@ No recently closed tabs here + + Tabs + + Tab view + + List + + Grid Close tabs diff --git a/app/src/main/res/xml/close_tabs_preferences.xml b/app/src/main/res/xml/close_tabs_preferences.xml deleted file mode 100644 index c6d5f962bf..0000000000 --- a/app/src/main/res/xml/close_tabs_preferences.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 9fcdcf3162..62403f75d2 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -53,6 +53,11 @@ android:key="@string/pref_key_search_settings" android:title="@string/preferences_search" /> + + - - + + + + + + + + + + + + + + + + + + diff --git a/app/src/test/java/org/mozilla/fenix/tabtray/DefaultTabTrayControllerTest.kt b/app/src/test/java/org/mozilla/fenix/tabtray/DefaultTabTrayControllerTest.kt index c484c82a21..1d4ade6851 100644 --- a/app/src/test/java/org/mozilla/fenix/tabtray/DefaultTabTrayControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/tabtray/DefaultTabTrayControllerTest.kt @@ -106,7 +106,7 @@ class DefaultTabTrayControllerTest { verify { navController.navigate( - TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment() + TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment() ) } } @@ -252,7 +252,7 @@ class DefaultTabTrayControllerTest { @Test fun handleSetUpAutoCloseTabsClicked() { controller.handleSetUpAutoCloseTabsClicked() - val directions = TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment() + val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment() verify { navController.navigate(directions)