diff --git a/app/src/main/java/ru/vtosters/lite/utils/Globals.java b/app/src/main/java/ru/vtosters/lite/utils/Globals.java index 5c593312e..5cc38cb6b 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Globals.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Globals.java @@ -3,6 +3,7 @@ package ru.vtosters.lite.utils; import static androidx.core.content.ContextCompat.getDrawable; import static ru.vtosters.lite.utils.Preferences.getLocale; import static ru.vtosters.lite.utils.Preferences.preferences; +import static ru.vtosters.lite.utils.Themes.isDarkTheme; import android.app.Activity; import android.app.Application; @@ -322,6 +323,8 @@ public class Globals { configuration.setLayoutDirection(locale); resources.updateConfiguration(configuration, resources.getDisplayMetrics()); + edit().putBoolean("isdark", isDarkTheme()).commit(); + return context; } // Language changer and BaseContext injector diff --git a/app/src/main/java/ru/vtosters/lite/utils/Themes.java b/app/src/main/java/ru/vtosters/lite/utils/Themes.java index d851c5bdc..ca103c25b 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Themes.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Themes.java @@ -326,7 +326,7 @@ public class Themes { } public static void systemThemeChanger() { - Boolean isDarkTheme = isDarkTheme(); + boolean isDarkTheme = isDarkTheme(); if (isDarkTheme){ applyTheme(getDarkTheme(), getImDarkTheme()); @@ -334,23 +334,21 @@ public class Themes { applyTheme(getLightTheme(), getImLightTheme()); } - edit().putBoolean("isdark", isDarkTheme).commit(); - - if (!systemtheme()) return; + if (!systemtheme()){ + edit().putBoolean("isdark", isDarkTheme).commit(); + return; + } int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; switch (currentNightMode) { case Configuration.UI_MODE_NIGHT_UNDEFINED: - applyTheme(getLightTheme(), getImLightTheme()); - edit().putBoolean("isdark", !isDarkTheme).commit(); - break; case Configuration.UI_MODE_NIGHT_NO: + edit().putBoolean("isdark", false).commit(); applyTheme(getLightTheme(), getImLightTheme()); - edit().putBoolean("isdark", !isDarkTheme).commit(); break; case Configuration.UI_MODE_NIGHT_YES: + edit().putBoolean("isdark", true).commit(); applyTheme(getDarkTheme(), getImDarkTheme()); - edit().putBoolean("isdark", isDarkTheme).commit(); break; } }