mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 02:56:45 -06:00
Add system theme setting for Android 10 (#554)
This commit is contained in:
parent
b602657d55
commit
ce9b12eb93
@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.base
|
||||
import android.content.pm.PackageManager.GET_ACTIVITIES
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
||||
import io.github.wulkanowy.R
|
||||
@ -22,8 +23,12 @@ class ThemeManager @Inject constructor(private val preferencesRepository: Prefer
|
||||
|
||||
fun applyDefaultTheme() {
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
if (preferencesRepository.appTheme == "light") MODE_NIGHT_NO
|
||||
else MODE_NIGHT_YES
|
||||
when (val theme = preferencesRepository.appTheme) {
|
||||
"light" -> MODE_NIGHT_NO
|
||||
"dark", "black" -> MODE_NIGHT_YES
|
||||
"system" -> MODE_NIGHT_FOLLOW_SYSTEM
|
||||
else -> throw IllegalArgumentException("Wrong theme: $theme")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
9
app/src/main/res/values-pl-v29/preferences_values.xml
Normal file
9
app/src/main/res/values-pl-v29/preferences_values.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string-array name="app_theme_entries" tools:ignore="InconsistentArrays">
|
||||
<item>Motyw systemu</item>
|
||||
<item>Jasny</item>
|
||||
<item>Ciemny</item>
|
||||
<item>Czarny (AMOLED)</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string-array name="services_interval_entries">
|
||||
<item>15 minut</item>
|
||||
<item>30 minut</item>
|
||||
@ -10,7 +10,7 @@
|
||||
<item>24 godziny</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="app_theme_entries">
|
||||
<string-array name="app_theme_entries" tools:ignore="InconsistentArrays">
|
||||
<item>Jasny</item>
|
||||
<item>Ciemny</item>
|
||||
<item>Czarny (AMOLED)</item>
|
||||
|
4
app/src/main/res/values-v29/preferences_defaults.xml
Normal file
4
app/src/main/res/values-v29/preferences_defaults.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<string name="pref_default_app_theme">system</string>
|
||||
</resources>
|
15
app/src/main/res/values-v29/preferences_values.xml
Normal file
15
app/src/main/res/values-v29/preferences_values.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string-array name="app_theme_entries" tools:ignore="InconsistentArrays">
|
||||
<item>System theme</item>
|
||||
<item>Light</item>
|
||||
<item>Dark</item>
|
||||
<item>Black (AMOLED)</item>
|
||||
</string-array>
|
||||
<string-array name="app_theme_values" translatable="false" tools:ignore="InconsistentArrays">
|
||||
<item>system</item>
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
<item>black</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string-array name="startup_tab_entries" translatable="false">
|
||||
<item>@string/grade_title</item>
|
||||
<item>@string/attendance_title</item>
|
||||
@ -13,12 +13,12 @@
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="app_theme_entries">
|
||||
<string-array name="app_theme_entries" tools:ignore="InconsistentArrays">
|
||||
<item>Light</item>
|
||||
<item>Dark</item>
|
||||
<item>Black (AMOLED)</item>
|
||||
</string-array>
|
||||
<string-array name="app_theme_values" translatable="false">
|
||||
<string-array name="app_theme_values" translatable="false" tools:ignore="InconsistentArrays">
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
<item>black</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user