1
0
Fork 0

For #1399 - Only show battery saver theme preference for API <P

master
ekager 2019-04-04 20:12:31 -07:00 committed by Colin Lee
parent 203e2e28c5
commit 3ad204712a
5 changed files with 14 additions and 10 deletions

View File

@ -152,12 +152,14 @@ open class FenixApplication : Application() {
AppCompatDelegate.MODE_NIGHT_YES
)
}
Settings.getInstance(this).shouldUseAutoBatteryTheme -> {
android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.P &&
Settings.getInstance(this).shouldUseAutoBatteryTheme -> {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY
)
}
Settings.getInstance(this).shouldFollowDeviceTheme -> {
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P &&
Settings.getInstance(this).shouldFollowDeviceTheme -> {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
)

View File

@ -42,22 +42,21 @@ class ThemeFragment : PreferenceFragmentCompat() {
private fun setupRadioGroups() {
radioLightTheme.addToRadioGroup(radioDarkTheme)
radioLightTheme.addToRadioGroup(radioAutoBatteryTheme)
radioDarkTheme.addToRadioGroup(radioLightTheme)
radioDarkTheme.addToRadioGroup(radioAutoBatteryTheme)
radioAutoBatteryTheme.addToRadioGroup(radioLightTheme)
radioAutoBatteryTheme.addToRadioGroup(radioDarkTheme)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
radioLightTheme.addToRadioGroup(radioFollowDeviceTheme)
radioDarkTheme.addToRadioGroup(radioFollowDeviceTheme)
radioAutoBatteryTheme.addToRadioGroup(radioFollowDeviceTheme)
radioFollowDeviceTheme.addToRadioGroup(radioDarkTheme)
radioFollowDeviceTheme.addToRadioGroup(radioLightTheme)
radioFollowDeviceTheme.addToRadioGroup(radioAutoBatteryTheme)
} else {
radioLightTheme.addToRadioGroup(radioAutoBatteryTheme)
radioDarkTheme.addToRadioGroup(radioAutoBatteryTheme)
radioAutoBatteryTheme.addToRadioGroup(radioLightTheme)
radioAutoBatteryTheme.addToRadioGroup(radioDarkTheme)
}
}

View File

@ -4,4 +4,5 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources>
<bool name="API28">true</bool>
<bool name="underAPI28">false</bool>
</resources>

View File

@ -5,4 +5,5 @@
<resources>
<bool name="theme_is_light">true</bool>
<bool name="API28">false</bool>
<bool name="underAPI28">true</bool>
</resources>

View File

@ -18,7 +18,8 @@
<org.mozilla.fenix.settings.RadioButtonPreference
android:defaultValue="false"
android:key="@string/pref_key_auto_battery_theme"
android:title="@string/preference_auto_battery_theme" />
android:title="@string/preference_auto_battery_theme"
app:isPreferenceVisible="@bool/underAPI28" />
<org.mozilla.fenix.settings.RadioButtonPreference
android:defaultValue="false"