For #5905 - Combine theme and toolbar settings
parent
cfb9b16863
commit
ef6913ec25
@ -1,55 +0,0 @@
|
|||||||
/* 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/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix.settings
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
|
||||||
import org.mozilla.fenix.ext.components
|
|
||||||
import org.mozilla.fenix.ext.getPreferenceKey
|
|
||||||
import org.mozilla.fenix.ext.settings
|
|
||||||
import org.mozilla.fenix.ext.showToolbar
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Settings to adjust the position of the browser toolbar.
|
|
||||||
*/
|
|
||||||
class ToolbarSettingsFragment : PreferenceFragmentCompat() {
|
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
||||||
setPreferencesFromResource(R.xml.toolbar_preferences, rootKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
showToolbar(getString(R.string.preferences_toolbar))
|
|
||||||
|
|
||||||
setupPreferences()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupPreferences() {
|
|
||||||
val keyToolbarTop = getPreferenceKey(R.string.pref_key_toolbar_top)
|
|
||||||
val topPreference = requireNotNull(findPreference<RadioButtonPreference>(keyToolbarTop))
|
|
||||||
topPreference.onClickListener {
|
|
||||||
requireContext().components.analytics.metrics.track(Event.ToolbarPositionChanged(
|
|
||||||
Event.ToolbarPositionChanged.Position.TOP
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
val keyToolbarBottom = getPreferenceKey(R.string.pref_key_toolbar_bottom)
|
|
||||||
val bottomPreference = requireNotNull(findPreference<RadioButtonPreference>(keyToolbarBottom))
|
|
||||||
bottomPreference.onClickListener {
|
|
||||||
requireContext().components.analytics.metrics.track(Event.ToolbarPositionChanged(
|
|
||||||
Event.ToolbarPositionChanged.Position.BOTTOM
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
topPreference.setCheckedWithoutClickListener(!requireContext().settings().shouldUseBottomToolbar)
|
|
||||||
bottomPreference.setCheckedWithoutClickListener(requireContext().settings().shouldUseBottomToolbar)
|
|
||||||
|
|
||||||
topPreference.addToRadioGroup(bottomPreference)
|
|
||||||
bottomPreference.addToRadioGroup(topPreference)
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,45 @@
|
|||||||
|
<?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:title="@string/preferences_theme"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:allowDividerBelow="false">
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="@bool/underAPI28"
|
||||||
|
android:key="@string/pref_key_light_theme"
|
||||||
|
android:title="@string/preference_light_theme" />
|
||||||
|
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_key_dark_theme"
|
||||||
|
android:title="@string/preference_dark_theme" />
|
||||||
|
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_key_auto_battery_theme"
|
||||||
|
android:title="@string/preference_auto_battery_theme"
|
||||||
|
app:isPreferenceVisible="@bool/underAPI28" />
|
||||||
|
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:defaultValue="@bool/API28"
|
||||||
|
android:key="@string/pref_key_follow_device_theme"
|
||||||
|
android:title="@string/preference_follow_device_theme"
|
||||||
|
app:isPreferenceVisible="@bool/API28" />
|
||||||
|
</androidx.preference.PreferenceCategory>
|
||||||
|
|
||||||
|
<androidx.preference.PreferenceCategory
|
||||||
|
android:title="@string/preferences_toolbar"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:allowDividerAbove="false">
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:key="@string/pref_key_toolbar_top"
|
||||||
|
android:title="@string/preference_top_toolbar" />
|
||||||
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
|
android:key="@string/pref_key_toolbar_bottom"
|
||||||
|
android:title="@string/preference_bottom_toolbar" />
|
||||||
|
</androidx.preference.PreferenceCategory>
|
||||||
|
</androidx.preference.PreferenceScreen>
|
@ -1,29 +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"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="@bool/underAPI28"
|
|
||||||
android:key="@string/pref_key_light_theme"
|
|
||||||
android:title="@string/preference_light_theme" />
|
|
||||||
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/pref_key_dark_theme"
|
|
||||||
android:title="@string/preference_dark_theme" />
|
|
||||||
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/pref_key_auto_battery_theme"
|
|
||||||
android:title="@string/preference_auto_battery_theme"
|
|
||||||
app:isPreferenceVisible="@bool/underAPI28" />
|
|
||||||
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:defaultValue="@bool/API28"
|
|
||||||
android:key="@string/pref_key_follow_device_theme"
|
|
||||||
android:title="@string/preference_follow_device_theme"
|
|
||||||
app:isPreferenceVisible="@bool/API28" />
|
|
||||||
</androidx.preference.PreferenceScreen>
|
|
@ -1,12 +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/. -->
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:key="@string/pref_key_toolbar_top"
|
|
||||||
android:title="@string/preference_top_toolbar" />
|
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
||||||
android:key="@string/pref_key_toolbar_bottom"
|
|
||||||
android:title="@string/preference_bottom_toolbar" />
|
|
||||||
</PreferenceScreen>
|
|
Loading…
Reference in New Issue