From 203a7d00f20f9c9e2635541b98def3b27060e12f Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Tue, 14 Jun 2022 13:08:20 +0300 Subject: [PATCH] isdarktheme now should work depending on the dark theme of the app --- app/src/main/java/ru/vtosters/lite/utils/Themes.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 e8b3c91ed..d851c5bdc 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Themes.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Themes.java @@ -1,6 +1,7 @@ package ru.vtosters.lite.utils; import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; +import static ru.vtosters.lite.utils.Globals.edit; import static ru.vtosters.lite.utils.Globals.getIdentifier; import static ru.vtosters.lite.utils.Globals.getPrefsValue; import static ru.vtosters.lite.utils.Globals.getResources; @@ -325,24 +326,31 @@ public class Themes { } public static void systemThemeChanger() { - if (isDarkTheme()){ + Boolean isDarkTheme = isDarkTheme(); + + if (isDarkTheme){ applyTheme(getDarkTheme(), getImDarkTheme()); } else { applyTheme(getLightTheme(), getImLightTheme()); } + edit().putBoolean("isdark", isDarkTheme).commit(); + if (!systemtheme()) 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: applyTheme(getLightTheme(), getImLightTheme()); + edit().putBoolean("isdark", !isDarkTheme).commit(); break; case Configuration.UI_MODE_NIGHT_YES: applyTheme(getDarkTheme(), getImDarkTheme()); + edit().putBoolean("isdark", isDarkTheme).commit(); break; } }