diff --git a/android/app/src/main/java/app/organicmaps/Map.java b/android/app/src/main/java/app/organicmaps/Map.java index 03d8a99b7d..8c609b8aa7 100644 --- a/android/app/src/main/java/app/organicmaps/Map.java +++ b/android/app/src/main/java/app/organicmaps/Map.java @@ -253,7 +253,7 @@ public final class Map public void onPause(final Context context) { - mUiThemeOnPause = Config.getUiThemeSettings(context); + mUiThemeOnPause = Config.getThemeSettings(context); // Pause/Resume can be called without surface creation/destroy. if (mSurfaceAttached) @@ -363,7 +363,7 @@ public final class Map private boolean isThemeChangingProcess(final Context context) { - return mUiThemeOnPause != null && !mUiThemeOnPause.equals(Config.getUiThemeSettings(context)); + return mUiThemeOnPause != null && !mUiThemeOnPause.equals(Config.getThemeSettings(context)); } // Engine diff --git a/android/app/src/main/java/app/organicmaps/base/BaseMwmFragmentActivity.java b/android/app/src/main/java/app/organicmaps/base/BaseMwmFragmentActivity.java index 9c8de1428f..b4ff839308 100644 --- a/android/app/src/main/java/app/organicmaps/base/BaseMwmFragmentActivity.java +++ b/android/app/src/main/java/app/organicmaps/base/BaseMwmFragmentActivity.java @@ -1,7 +1,6 @@ package app.organicmaps.base; import android.content.ComponentName; -import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.content.res.Configuration; @@ -14,7 +13,6 @@ import androidx.activity.SystemBarStyle; import androidx.annotation.CallSuper; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.StyleRes; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; @@ -27,7 +25,6 @@ import app.organicmaps.SplashActivity; import app.organicmaps.util.Config; import app.organicmaps.util.RtlUtils; import app.organicmaps.util.ThemeSwitcher; -import app.organicmaps.util.ThemeUtils; import app.organicmaps.util.concurrency.UiThread; import app.organicmaps.util.log.Logger; @@ -68,7 +65,7 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity protected final void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mThemeName = Config.getUiThemeSettings(getApplicationContext()); + mThemeName = Config.getThemeSettings(getApplicationContext()); //setTheme(getThemeResourceId(mThemeName)); EdgeToEdge.enable(this, SystemBarStyle.dark(Color.TRANSPARENT)); RtlUtils.manageRtl(this); @@ -128,7 +125,7 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity public void onPostResume() { super.onPostResume(); - if (!mThemeName.equals(Config.getUiThemeSettings(getApplicationContext()))) + if (!mThemeName.equals(Config.getThemeSettings(getApplicationContext()))) { // Workaround described in https://code.google.com/p/android/issues/detail?id=93731 UiThread.runLater(this::recreate); diff --git a/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java b/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java index 2597c3fd4c..816385f861 100644 --- a/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java +++ b/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java @@ -395,12 +395,12 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La { final ListPreference pref = getPreference(getString(R.string.pref_map_style)); - String curTheme = Config.getUiThemeSettings(requireContext()); + String curTheme = Config.getThemeSettings(requireContext()); pref.setValue(curTheme); pref.setSummary(pref.getEntry()); pref.setOnPreferenceChangeListener((preference, newValue) -> { final String themeName = (String) newValue; - if (!Config.setUiThemeSettings(requireContext(), themeName)) + if (!Config.setThemeSettings(requireContext(), themeName)) return true; ThemeSwitcher.INSTANCE.restart(false); diff --git a/android/app/src/main/java/app/organicmaps/util/Config.java b/android/app/src/main/java/app/organicmaps/util/Config.java index 23ac69d341..068a39b9c9 100644 --- a/android/app/src/main/java/app/organicmaps/util/Config.java +++ b/android/app/src/main/java/app/organicmaps/util/Config.java @@ -2,7 +2,6 @@ package app.organicmaps.util; import android.content.Context; import android.content.SharedPreferences; -import android.content.res.Resources; import android.os.Build; import androidx.annotation.NonNull; @@ -253,7 +252,7 @@ public final class Config } @NonNull - public static String getUiThemeSettings(@NonNull Context context) + public static String getThemeSettings(@NonNull Context context) { // Fallback & default theme String fallbackTheme = MwmApplication.from(context).getString(R.string.theme_follow_system); @@ -264,9 +263,9 @@ public final class Config return fallbackTheme; } - public static boolean setUiThemeSettings(@NonNull Context context, @NonNull String theme) + public static boolean setThemeSettings(@NonNull Context context, @NonNull String theme) { - if (getUiThemeSettings(context).equals(theme)) + if (getThemeSettings(context).equals(theme)) return false; setString(KEY_MISC_UI_THEME, theme); diff --git a/android/app/src/main/java/app/organicmaps/util/ThemeSwitcher.java b/android/app/src/main/java/app/organicmaps/util/ThemeSwitcher.java index 03eef31636..faf5cbf7b4 100644 --- a/android/app/src/main/java/app/organicmaps/util/ThemeSwitcher.java +++ b/android/app/src/main/java/app/organicmaps/util/ThemeSwitcher.java @@ -69,7 +69,7 @@ public enum ThemeSwitcher public void restart(boolean isRendererActive) { mRendererActive = isRendererActive; - String storedTheme = Config.getUiThemeSettings(mContext); + String storedTheme = Config.getThemeSettings(mContext); int currentMapStyle = Framework.nativeGetMapStyle(); // Resolve dynamic themes (follow-system, nav-auto etc.) diff --git a/android/app/src/main/java/app/organicmaps/util/ThemeUtils.java b/android/app/src/main/java/app/organicmaps/util/ThemeUtils.java index b620518c78..854c47ce19 100644 --- a/android/app/src/main/java/app/organicmaps/util/ThemeUtils.java +++ b/android/app/src/main/java/app/organicmaps/util/ThemeUtils.java @@ -7,7 +7,6 @@ import android.util.TypedValue; import androidx.annotation.AttrRes; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; -import androidx.annotation.StyleRes; import app.organicmaps.R; @@ -66,7 +65,7 @@ public final class ThemeUtils public static boolean isDefaultTheme(@NonNull Context context) { - return isDefaultTheme(context, Config.getUiThemeSettings(context)); + return isDefaultTheme(context, Config.getThemeSettings(context)); } public static boolean isDefaultTheme(@NonNull Context context, String theme) @@ -77,7 +76,7 @@ public final class ThemeUtils public static boolean isNightTheme(@NonNull Context context) { - return isNightTheme(context, Config.getUiThemeSettings(context)); + return isNightTheme(context, Config.getThemeSettings(context)); } public static boolean isNightTheme(@NonNull Context context, String theme) @@ -88,7 +87,7 @@ public final class ThemeUtils public static boolean isSystemTheme(@NonNull Context context) { - return isSystemTheme(context, Config.getUiThemeSettings(context)); + return isSystemTheme(context, Config.getThemeSettings(context)); } public static boolean isSystemTheme(@NonNull Context context, String theme) @@ -99,7 +98,7 @@ public final class ThemeUtils public static boolean isNavAutoTheme(@NonNull Context context) { - return isNavAutoTheme(context, Config.getUiThemeSettings(context)); + return isNavAutoTheme(context, Config.getThemeSettings(context)); } public static boolean isNavAutoTheme(@NonNull Context context, String theme) @@ -110,7 +109,7 @@ public final class ThemeUtils public static boolean isAutoTheme(@NonNull Context context) { - return isSystemTheme(context, Config.getUiThemeSettings(context)); + return isSystemTheme(context, Config.getThemeSettings(context)); } public static boolean isAutoTheme(@NonNull Context context, String theme)