diff --git a/app/src/main/java/ru/vtosters/lite/hooks/ui/SystemThemeChangerHook.java b/app/src/main/java/ru/vtosters/lite/hooks/ui/SystemThemeChangerHook.java index 54b73e236..ae59c23d3 100644 --- a/app/src/main/java/ru/vtosters/lite/hooks/ui/SystemThemeChangerHook.java +++ b/app/src/main/java/ru/vtosters/lite/hooks/ui/SystemThemeChangerHook.java @@ -15,6 +15,10 @@ import static ru.vtosters.lite.utils.AndroidUtils.getCenterScreenCoords; public class SystemThemeChangerHook { public static void onThemeChanged(Configuration configuration) { + onThemeChanged(configuration, true); + } + + public static void onThemeChanged(Configuration configuration, Boolean restartActivity) { if (Preferences.systemtheme()) { var uiMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK; @@ -26,7 +30,7 @@ public class SystemThemeChangerHook { theme = ThemesUtils.getLightTheme(); if (theme != null && theme != ThemesUtils.getCurrentTheme()) { - ThemesUtils.applyTheme(theme); + ThemesUtils.applyTheme(theme, restartActivity); } } } @@ -34,6 +38,6 @@ public class SystemThemeChangerHook { public static void themeOnStart(Activity activity) { if (activity == null) activity = LifecycleUtils.getCurrentActivity(); - onThemeChanged(activity.getResources().getConfiguration()); + onThemeChanged(activity.getResources().getConfiguration(), false); } } diff --git a/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java b/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java index 4903bdfc9..8229bfcfd 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java @@ -40,9 +40,9 @@ import static ru.vtosters.lite.utils.AndroidUtils.*; import static ru.vtosters.lite.utils.Preferences.*; public class ThemesUtils { - public static void applyTheme(VKTheme theme) { + public static void applyTheme(VKTheme theme, Boolean restartActivity) { try { - setTheme(theme, LifecycleUtils.getCurrentActivity(), true); + setTheme(theme, LifecycleUtils.getCurrentActivity(), restartActivity); } catch (Exception e) { e.printStackTrace(); }