isdarktheme now should work depending on the dark theme of the app

This commit is contained in:
gdlbo
2022-06-14 13:08:20 +03:00
parent e38d93fa2b
commit 203a7d00f2
@@ -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;
}
}