mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
For #15115 - Part 1: Convert the CloseTabsSettingsFragment to a general TabsSettingsFragment
- Renames CloseTabsSettingsFragment.kt to TabsSettingsFragment.kt - Renames close_tabs_preferences.xml to tabs_preferences.xml - Adds preference options for the switching between the Grid and List tab views
This commit is contained in:
parent
7c0d00c800
commit
ed3986662f
@ -24,7 +24,6 @@ import androidx.preference.Preference
|
|||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.synthetic.main.amo_collection_override_dialog.view.*
|
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.CoroutineScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -187,7 +186,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val tabSettingsPreference =
|
val tabSettingsPreference =
|
||||||
requirePreference<Preference>(R.string.pref_key_close_tabs)
|
requirePreference<Preference>(R.string.pref_key_tabs)
|
||||||
tabSettingsPreference.summary = context?.settings()?.getTabTimeoutString()
|
tabSettingsPreference.summary = context?.settings()?.getTabTimeoutString()
|
||||||
|
|
||||||
setupPreferences()
|
setupPreferences()
|
||||||
@ -212,8 +211,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||||||
resources.getString(R.string.pref_key_sign_in) -> {
|
resources.getString(R.string.pref_key_sign_in) -> {
|
||||||
SettingsFragmentDirections.actionSettingsFragmentToTurnOnSyncFragment()
|
SettingsFragmentDirections.actionSettingsFragmentToTurnOnSyncFragment()
|
||||||
}
|
}
|
||||||
resources.getString(R.string.pref_key_close_tabs) -> {
|
resources.getString(R.string.pref_key_tabs) -> {
|
||||||
SettingsFragmentDirections.actionSettingsFragmentToCloseTabsSettingsFragment()
|
SettingsFragmentDirections.actionSettingsFragmentToTabsSettingsFragment()
|
||||||
}
|
}
|
||||||
resources.getString(R.string.pref_key_search_settings) -> {
|
resources.getString(R.string.pref_key_search_settings) -> {
|
||||||
SettingsFragmentDirections.actionSettingsFragmentToSearchEngineFragment()
|
SettingsFragmentDirections.actionSettingsFragmentToSearchEngineFragment()
|
||||||
|
@ -13,31 +13,42 @@ import org.mozilla.fenix.utils.view.addToRadioGroup
|
|||||||
/**
|
/**
|
||||||
* Lets the user customize auto closing tabs.
|
* 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 radioManual: RadioButtonPreference
|
||||||
private lateinit var radioOneDay: RadioButtonPreference
|
private lateinit var radioOneDay: RadioButtonPreference
|
||||||
private lateinit var radioOneWeek: RadioButtonPreference
|
private lateinit var radioOneWeek: RadioButtonPreference
|
||||||
private lateinit var radioOneMonth: RadioButtonPreference
|
private lateinit var radioOneMonth: RadioButtonPreference
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.close_tabs_preferences, rootKey)
|
setPreferencesFromResource(R.xml.tabs_preferences, rootKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
showToolbar(getString(R.string.preferences_close_tabs))
|
showToolbar(getString(R.string.preferences_tabs))
|
||||||
setupPreferences()
|
setupPreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun 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)
|
radioManual = requirePreference(R.string.pref_key_close_tabs_manually)
|
||||||
radioOneDay = requirePreference(R.string.pref_key_close_tabs_after_one_day)
|
radioOneDay = requirePreference(R.string.pref_key_close_tabs_after_one_day)
|
||||||
radioOneWeek = requirePreference(R.string.pref_key_close_tabs_after_one_week)
|
radioOneWeek = requirePreference(R.string.pref_key_close_tabs_after_one_week)
|
||||||
radioOneMonth = requirePreference(R.string.pref_key_close_tabs_after_one_month)
|
radioOneMonth = requirePreference(R.string.pref_key_close_tabs_after_one_month)
|
||||||
|
|
||||||
setupRadioGroups()
|
setupRadioGroups()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupRadioGroups() {
|
private fun setupRadioGroups() {
|
||||||
|
addToRadioGroup(
|
||||||
|
listRadioButton,
|
||||||
|
gridRadioButton
|
||||||
|
)
|
||||||
|
|
||||||
addToRadioGroup(
|
addToRadioGroup(
|
||||||
radioManual,
|
radioManual,
|
||||||
radioOneDay,
|
radioOneDay,
|
@ -92,7 +92,7 @@ class DefaultTabTrayController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleTabSettingsClicked() {
|
override fun handleTabSettingsClicked() {
|
||||||
navController.navigate(TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment())
|
navController.navigate(TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTabTrayDismissed() {
|
override fun onTabTrayDismissed() {
|
||||||
@ -187,7 +187,7 @@ class DefaultTabTrayController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleSetUpAutoCloseTabsClicked() {
|
override fun handleSetUpAutoCloseTabsClicked() {
|
||||||
val directions = TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment()
|
val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()
|
||||||
navController.navigate(directions)
|
navController.navigate(directions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,6 +345,16 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
|||||||
default = false
|
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(
|
var manuallyCloseTabs by booleanPreference(
|
||||||
appContext.getPreferenceKey(R.string.pref_key_close_tabs_manually),
|
appContext.getPreferenceKey(R.string.pref_key_close_tabs_manually),
|
||||||
default = true
|
default = true
|
||||||
|
@ -111,8 +111,8 @@
|
|||||||
android:id="@+id/action_global_tabHistoryDialogFragment"
|
android:id="@+id/action_global_tabHistoryDialogFragment"
|
||||||
app:destination="@id/tabHistoryDialogFragment" />
|
app:destination="@id/tabHistoryDialogFragment" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_global_closeTabSettingsFragment"
|
android:id="@+id/action_global_tabSettingsFragment"
|
||||||
app:destination="@id/closeTabsSettingsFragment" />
|
app:destination="@id/tabsSettingsFragment" />
|
||||||
|
|
||||||
<dialog
|
<dialog
|
||||||
android:id="@+id/tabTrayDialogFragment"
|
android:id="@+id/tabTrayDialogFragment"
|
||||||
@ -513,17 +513,17 @@
|
|||||||
app:popEnterAnim="@anim/slide_in_left"
|
app:popEnterAnim="@anim/slide_in_left"
|
||||||
app:popExitAnim="@anim/slide_out_right" />
|
app:popExitAnim="@anim/slide_out_right" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_settingsFragment_to_closeTabsSettingsFragment"
|
android:id="@+id/action_settingsFragment_to_tabsSettingsFragment"
|
||||||
app:destination="@id/closeTabsSettingsFragment"
|
app:destination="@id/tabsSettingsFragment"
|
||||||
app:enterAnim="@anim/slide_in_right"
|
app:enterAnim="@anim/slide_in_right"
|
||||||
app:exitAnim="@anim/slide_out_left"
|
app:exitAnim="@anim/slide_out_left"
|
||||||
app:popEnterAnim="@anim/slide_in_left"
|
app:popEnterAnim="@anim/slide_in_left"
|
||||||
app:popExitAnim="@anim/slide_out_right" />
|
app:popExitAnim="@anim/slide_out_right" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/closeTabsSettingsFragment"
|
android:id="@+id/tabsSettingsFragment"
|
||||||
android:name="org.mozilla.fenix.settings.CloseTabsSettingsFragment"
|
android:name="org.mozilla.fenix.settings.TabsSettingsFragment"
|
||||||
android:label="@string/preferences_close_tabs" />
|
android:label="@string/preferences_tabs" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/dataChoicesFragment"
|
android:id="@+id/dataChoicesFragment"
|
||||||
android:name="org.mozilla.fenix.settings.DataChoicesFragment"
|
android:name="org.mozilla.fenix.settings.DataChoicesFragment"
|
||||||
|
@ -129,8 +129,6 @@
|
|||||||
|
|
||||||
<!-- Customization Settings -->
|
<!-- Customization Settings -->
|
||||||
<string name="pref_home_category" translatable="false">pref_home_category</string>
|
<string name="pref_home_category" translatable="false">pref_home_category</string>
|
||||||
|
|
||||||
<!-- Customization Settings -->
|
|
||||||
<string name="pref_key_website_pull_to_refresh" translatable="false">pref_key_website_pull_to_refresh</string>
|
<string name="pref_key_website_pull_to_refresh" translatable="false">pref_key_website_pull_to_refresh</string>
|
||||||
<string name="pref_key_dynamic_toolbar" translatable="false">pref_key_dynamic_toolbar</string>
|
<string name="pref_key_dynamic_toolbar" translatable="false">pref_key_dynamic_toolbar</string>
|
||||||
<string name="pref_key_swipe_toolbar_switch_tabs" translatable="false">pref_key_swipe_toolbar_switch_tabs</string>
|
<string name="pref_key_swipe_toolbar_switch_tabs" translatable="false">pref_key_swipe_toolbar_switch_tabs</string>
|
||||||
@ -225,7 +223,10 @@
|
|||||||
|
|
||||||
<string name="pref_key_show_collections_placeholder_home" translatable="false">pref_key_show_collections_home</string>
|
<string name="pref_key_show_collections_placeholder_home" translatable="false">pref_key_show_collections_home</string>
|
||||||
|
|
||||||
<string name="pref_key_close_tabs" translatable="false">pref_key_close_tabs</string>
|
<!-- Tabs Settings -->
|
||||||
|
<string name="pref_key_tab_view_list" translatable="false">pref_key_tab_view_list</string>
|
||||||
|
<string name="pref_key_tab_view_grid" translatable="false">pref_key_tab_view_grid</string>
|
||||||
|
<string name="pref_key_tabs" translatable="false">pref_key_tabs</string>
|
||||||
<string name="pref_key_close_tabs_manually" translatable="false">pref_key_close_tabs_manually</string>
|
<string name="pref_key_close_tabs_manually" translatable="false">pref_key_close_tabs_manually</string>
|
||||||
<string name="pref_key_close_tabs_after_one_day" translatable="false">pref_key_close_tabs_after_one_day</string>
|
<string name="pref_key_close_tabs_after_one_day" translatable="false">pref_key_close_tabs_after_one_day</string>
|
||||||
<string name="pref_key_close_tabs_after_one_week" translatable="false">pref_key_close_tabs_after_one_week</string>
|
<string name="pref_key_close_tabs_after_one_week" translatable="false">pref_key_close_tabs_after_one_week</string>
|
||||||
|
@ -531,6 +531,14 @@
|
|||||||
<string name="recently_closed_empty_message">No recently closed tabs here</string>
|
<string name="recently_closed_empty_message">No recently closed tabs here</string>
|
||||||
|
|
||||||
<!-- Tab Management -->
|
<!-- Tab Management -->
|
||||||
|
<!-- Title of preference for tabs management -->
|
||||||
|
<string name="preferences_tabs">Tabs</string>
|
||||||
|
<!-- Title of preference that allows a user to specify the tab view -->
|
||||||
|
<string name="preferences_tab_view">Tab view</string>
|
||||||
|
<!-- Option for a list tab view -->
|
||||||
|
<string name="tab_view_list">List</string>
|
||||||
|
<!-- Option for a grid tab view -->
|
||||||
|
<string name="tab_view_grid">Grid</string>
|
||||||
<!-- Title of preference that allows a user to auto close tabs after a specified amount of time -->
|
<!-- Title of preference that allows a user to auto close tabs after a specified amount of time -->
|
||||||
<string name="preferences_close_tabs">Close tabs</string>
|
<string name="preferences_close_tabs">Close tabs</string>
|
||||||
<!-- Option for auto closing tabs that will never auto close tabs, always allows user to manually close tabs -->
|
<!-- Option for auto closing tabs that will never auto close tabs, always allows user to manually close tabs -->
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
||||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:key="@string/pref_key_close_tabs_manually"
|
|
||||||
android:title="@string/close_tabs_manually" />
|
|
||||||
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/pref_key_close_tabs_after_one_day"
|
|
||||||
android:title="@string/close_tabs_after_one_day" />
|
|
||||||
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/pref_key_close_tabs_after_one_week"
|
|
||||||
android:title="@string/close_tabs_after_one_week" />
|
|
||||||
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/pref_key_close_tabs_after_one_month"
|
|
||||||
android:title="@string/close_tabs_after_one_month" />
|
|
||||||
</androidx.preference.PreferenceScreen>
|
|
@ -53,6 +53,11 @@
|
|||||||
android:key="@string/pref_key_search_settings"
|
android:key="@string/pref_key_search_settings"
|
||||||
android:title="@string/preferences_search" />
|
android:title="@string/preferences_search" />
|
||||||
|
|
||||||
|
<androidx.preference.Preference
|
||||||
|
android:icon="@drawable/ic_multiple_tabs"
|
||||||
|
android:key="@string/pref_key_tabs"
|
||||||
|
android:title="@string/preferences_tabs" />
|
||||||
|
|
||||||
<androidx.preference.Preference
|
<androidx.preference.Preference
|
||||||
android:icon="@drawable/ic_customize"
|
android:icon="@drawable/ic_customize"
|
||||||
android:key="@string/pref_key_customize"
|
android:key="@string/pref_key_customize"
|
||||||
@ -77,11 +82,6 @@
|
|||||||
android:icon="@drawable/ic_internet"
|
android:icon="@drawable/ic_internet"
|
||||||
android:key="@string/pref_key_make_default_browser"
|
android:key="@string/pref_key_make_default_browser"
|
||||||
android:title="@string/preferences_set_as_default_browser" />
|
android:title="@string/preferences_set_as_default_browser" />
|
||||||
|
|
||||||
<androidx.preference.Preference
|
|
||||||
android:icon="@drawable/ic_multiple_tabs"
|
|
||||||
android:key="@string/pref_key_close_tabs"
|
|
||||||
android:title="@string/preferences_close_tabs" />
|
|
||||||
</androidx.preference.PreferenceCategory>
|
</androidx.preference.PreferenceCategory>
|
||||||
|
|
||||||
<androidx.preference.PreferenceCategory
|
<androidx.preference.PreferenceCategory
|
||||||
|
48
app/src/main/res/xml/tabs_preferences.xml
Normal file
48
app/src/main/res/xml/tabs_preferences.xml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<androidx.preference.PreferenceCategory
|
||||||
|
android:layout="@layout/preference_cat_style"
|
||||||
|
android:title="@string/preferences_tab_view"
|
||||||
|
app:allowDividerAbove="false"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/pref_key_tab_view_list"
|
||||||
|
android:title="@string/tab_view_list" />
|
||||||
|
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_key_tab_view_grid"
|
||||||
|
android:title="@string/tab_view_grid" />
|
||||||
|
</androidx.preference.PreferenceCategory>
|
||||||
|
|
||||||
|
<androidx.preference.PreferenceCategory
|
||||||
|
android:layout="@layout/preference_cat_style"
|
||||||
|
android:title="@string/preferences_close_tabs"
|
||||||
|
app:allowDividerAbove="false"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/pref_key_close_tabs_manually"
|
||||||
|
android:title="@string/close_tabs_manually" />
|
||||||
|
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_key_close_tabs_after_one_day"
|
||||||
|
android:title="@string/close_tabs_after_one_day" />
|
||||||
|
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_key_close_tabs_after_one_week"
|
||||||
|
android:title="@string/close_tabs_after_one_week" />
|
||||||
|
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_key_close_tabs_after_one_month"
|
||||||
|
android:title="@string/close_tabs_after_one_month" />
|
||||||
|
</androidx.preference.PreferenceCategory>
|
||||||
|
</androidx.preference.PreferenceScreen>
|
@ -106,7 +106,7 @@ class DefaultTabTrayControllerTest {
|
|||||||
|
|
||||||
verify {
|
verify {
|
||||||
navController.navigate(
|
navController.navigate(
|
||||||
TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment()
|
TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ class DefaultTabTrayControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
fun handleSetUpAutoCloseTabsClicked() {
|
fun handleSetUpAutoCloseTabsClicked() {
|
||||||
controller.handleSetUpAutoCloseTabsClicked()
|
controller.handleSetUpAutoCloseTabsClicked()
|
||||||
val directions = TabTrayDialogFragmentDirections.actionGlobalCloseTabSettingsFragment()
|
val directions = TabTrayDialogFragmentDirections.actionGlobalTabSettingsFragment()
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
navController.navigate(directions)
|
navController.navigate(directions)
|
||||||
|
Loading…
Reference in New Issue
Block a user