follow system theme (light/dark)

This commit is contained in:
aliveoutside
2022-09-10 17:35:41 +03:00
parent 6e55514edf
commit 0ed16b0836
2 changed files with 23 additions and 0 deletions
@@ -0,0 +1,21 @@
package ru.vtosters.lite.hooks.ui;
import android.content.res.Configuration;
import ru.vtosters.lite.utils.ThemesUtils;
public class SystemThemeChangerHook {
public static void onThemeChanged(Configuration configuration) {
switch (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) {
case Configuration.UI_MODE_NIGHT_YES:
// Night mode is active, we're using dark theme
ThemesUtils.applyTheme(ThemesUtils.getDarkTheme());
break;
case Configuration.UI_MODE_NIGHT_NO:
case Configuration.UI_MODE_NIGHT_UNDEFINED:
// Night mode is not active, we're using light theme
ThemesUtils.applyTheme(ThemesUtils.getLightTheme());
break;
}
}
}