diff --git a/app/src/main/kotlin/com/numero/sojodia/extension/AppThemeExtension.kt b/app/src/main/kotlin/com/numero/sojodia/extension/AppThemeExtension.kt index 5d39f208..cf045103 100644 --- a/app/src/main/kotlin/com/numero/sojodia/extension/AppThemeExtension.kt +++ b/app/src/main/kotlin/com/numero/sojodia/extension/AppThemeExtension.kt @@ -1,5 +1,6 @@ package com.numero.sojodia.extension +import android.os.Build import androidx.appcompat.app.AppCompatDelegate import com.numero.sojodia.model.AppTheme @@ -7,8 +8,11 @@ fun AppTheme.applyApplication() { val mode = when (this) { AppTheme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO AppTheme.DARK -> AppCompatDelegate.MODE_NIGHT_YES - AppTheme.SYSTEM_DEFAULT -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM - AppTheme.AUTO_BATTERY -> AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY + AppTheme.SYSTEM_DEFAULT -> if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { + AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY + } else { + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + } } AppCompatDelegate.setDefaultNightMode(mode) } \ No newline at end of file diff --git a/app/src/main/kotlin/com/numero/sojodia/ui/settings/SettingsActivity.kt b/app/src/main/kotlin/com/numero/sojodia/ui/settings/SettingsActivity.kt index f07ec175..5af679fd 100644 --- a/app/src/main/kotlin/com/numero/sojodia/ui/settings/SettingsActivity.kt +++ b/app/src/main/kotlin/com/numero/sojodia/ui/settings/SettingsActivity.kt @@ -2,6 +2,7 @@ package com.numero.sojodia.ui.settings import android.content.Context import android.content.Intent +import android.os.Build import android.os.Bundle import android.view.MenuItem import android.view.View @@ -113,7 +114,7 @@ class SettingsActivity : AppCompatActivity() { R.id.theme_light -> AppTheme.LIGHT R.id.theme_dark -> AppTheme.DARK R.id.theme_system -> AppTheme.SYSTEM_DEFAULT - R.id.theme_auto_battery -> AppTheme.AUTO_BATTERY + R.id.theme_auto_battery -> AppTheme.SYSTEM_DEFAULT else -> throw Exception() } configRepository.appTheme = theme @@ -130,8 +131,11 @@ class SettingsActivity : AppCompatActivity() { return when (this) { AppTheme.LIGHT -> R.string.theme_light AppTheme.DARK -> R.string.theme_dark - AppTheme.SYSTEM_DEFAULT -> R.string.theme_system_default - AppTheme.AUTO_BATTERY -> R.string.theme_auto_battery + AppTheme.SYSTEM_DEFAULT -> if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { + R.string.theme_auto_battery + } else { + R.string.theme_system_default + } } } diff --git a/model/src/main/java/com/numero/sojodia/model/AppTheme.kt b/model/src/main/java/com/numero/sojodia/model/AppTheme.kt index 56cba30f..d8c981e4 100644 --- a/model/src/main/java/com/numero/sojodia/model/AppTheme.kt +++ b/model/src/main/java/com/numero/sojodia/model/AppTheme.kt @@ -4,8 +4,7 @@ enum class AppTheme(val key: String) { LIGHT("LIGHT"), DARK("DARK"), - SYSTEM_DEFAULT("SYSTEM_DEFAULT"), - AUTO_BATTERY("AUTO_BATTERY"); + SYSTEM_DEFAULT("SYSTEM_DEFAULT"); companion object { fun from(key: String): AppTheme { diff --git a/repository/src/main/java/com/numero/sojodia/repository/ConfigRepositoryImpl.kt b/repository/src/main/java/com/numero/sojodia/repository/ConfigRepositoryImpl.kt index 33277d95..89f7180c 100644 --- a/repository/src/main/java/com/numero/sojodia/repository/ConfigRepositoryImpl.kt +++ b/repository/src/main/java/com/numero/sojodia/repository/ConfigRepositoryImpl.kt @@ -43,7 +43,7 @@ class ConfigRepositoryImpl(context: Context) : ConfigRepository { } } get() { - val entry = sharedPreferences.getStringOrThrow(KEY_APP_THEME, AppTheme.LIGHT.key) + val entry = sharedPreferences.getStringOrThrow(KEY_APP_THEME, AppTheme.SYSTEM_DEFAULT.key) return AppTheme.from(entry) }