diff --git a/app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt b/app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt index b61b2f7c..84e607dd 100644 --- a/app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt +++ b/app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt @@ -26,6 +26,7 @@ import android.view.Menu import android.view.MenuItem import android.view.View import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.app.AppCompatDelegate import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.core.view.GravityCompat import androidx.drawerlayout.widget.DrawerLayout @@ -61,7 +62,9 @@ class MainActivity : val settings = mainContext.settings settings.initializeDefaultValues() - setTheme(settings.themeStyle().themeNoActionBar) + val themeStyle = settings.themeStyle() + AppCompatDelegate.setDefaultNightMode(themeStyle.nightMode) + setTheme(themeStyle.themeNoActionBar) mainReload = MainReload(settings) diff --git a/app/src/main/kotlin/com/vrem/wifianalyzer/settings/Settings.kt b/app/src/main/kotlin/com/vrem/wifianalyzer/settings/Settings.kt index acf95922..d2ff2024 100644 --- a/app/src/main/kotlin/com/vrem/wifianalyzer/settings/Settings.kt +++ b/app/src/main/kotlin/com/vrem/wifianalyzer/settings/Settings.kt @@ -106,7 +106,7 @@ class Settings( fun keepScreenOn(): Boolean = repository.boolean(R.string.keep_screen_on_key, repository.resourceBoolean(R.bool.keep_screen_on_default)) - fun themeStyle(): ThemeStyle = settingsFind(ThemeStyle.entries, R.string.theme_key, ThemeStyle.DARK) + fun themeStyle(): ThemeStyle = settingsFind(ThemeStyle.entries, R.string.theme_key, ThemeStyle.SYSTEM) fun selectedMenu(): NavigationMenu = settingsFind(NavigationMenu.entries, R.string.selected_menu_key, NavigationMenu.ACCESS_POINTS) diff --git a/app/src/main/kotlin/com/vrem/wifianalyzer/settings/ThemeStyle.kt b/app/src/main/kotlin/com/vrem/wifianalyzer/settings/ThemeStyle.kt index 6f638576..f457f599 100644 --- a/app/src/main/kotlin/com/vrem/wifianalyzer/settings/ThemeStyle.kt +++ b/app/src/main/kotlin/com/vrem/wifianalyzer/settings/ThemeStyle.kt @@ -20,15 +20,17 @@ package com.vrem.wifianalyzer.settings import android.graphics.Color import androidx.annotation.ColorInt import androidx.annotation.StyleRes +import androidx.appcompat.app.AppCompatDelegate import com.vrem.wifianalyzer.R enum class ThemeStyle( @param:StyleRes val theme: Int, @param:StyleRes val themeNoActionBar: Int, @param:ColorInt val colorGraphText: Int, + val nightMode: Int, ) { - DARK(R.style.ThemeDark, R.style.ThemeDarkNoActionBar, Color.WHITE), - LIGHT(R.style.ThemeLight, R.style.ThemeLightNoActionBar, Color.BLACK), - SYSTEM(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.GRAY), - BLACK(R.style.ThemeBlack, R.style.ThemeBlackNoActionBar, Color.WHITE), + DARK(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.WHITE, AppCompatDelegate.MODE_NIGHT_YES), + LIGHT(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.BLACK, AppCompatDelegate.MODE_NIGHT_NO), + SYSTEM(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.GRAY, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM), + BLACK(R.style.ThemeBlack, R.style.ThemeBlackNoActionBar, Color.WHITE, AppCompatDelegate.MODE_NIGHT_YES), } diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 60e7451e..50a3c57b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -18,26 +18,6 @@ - - - - - - - -