From af709fea6d9c37ee4936606c0222d9afc946093a Mon Sep 17 00:00:00 2001 From: Goofyz Leung Date: Tue, 16 Jan 2024 09:44:54 +0800 Subject: [PATCH] refactor: directly read theme name instead of caching using local variable fix #1168 --- app/src/main/java/com/osfans/trime/data/theme/Theme.kt | 1 - .../java/com/osfans/trime/data/theme/ThemeManager.kt | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/src/main/java/com/osfans/trime/data/theme/Theme.kt b/app/src/main/java/com/osfans/trime/data/theme/Theme.kt index ee2c5ad070..22d59e382f 100644 --- a/app/src/main/java/com/osfans/trime/data/theme/Theme.kt +++ b/app/src/main/java/com/osfans/trime/data/theme/Theme.kt @@ -85,7 +85,6 @@ class Theme private constructor(isDarkMode: Boolean) { init { self = this - ThemeManager.init() init(isDarkMode) Timber.d("Setting sound from color ...") SoundThemeManager.switchSound(colors.getString("sound")) diff --git a/app/src/main/java/com/osfans/trime/data/theme/ThemeManager.kt b/app/src/main/java/com/osfans/trime/data/theme/ThemeManager.kt index 4889b54c7f..009b46e19a 100644 --- a/app/src/main/java/com/osfans/trime/data/theme/ThemeManager.kt +++ b/app/src/main/java/com/osfans/trime/data/theme/ThemeManager.kt @@ -19,7 +19,6 @@ object ThemeManager : DataDirectoryChangeListener.Listener { @JvmStatic fun switchTheme(theme: String) { - currentThemeName = theme AppPrefs.defaultInstance().themeAndColor.selectedTheme = theme } @@ -27,8 +26,6 @@ object ThemeManager : DataDirectoryChangeListener.Listener { var userThemes: MutableList = listThemes(DataManager.userDataDir) - private lateinit var currentThemeName: String - /** * Update sharedThemes and userThemes. */ @@ -37,10 +34,6 @@ object ThemeManager : DataDirectoryChangeListener.Listener { userThemes = listThemes(DataManager.userDataDir) } - fun init() { - currentThemeName = AppPrefs.defaultInstance().themeAndColor.selectedTheme - } - @JvmStatic fun getAllThemes(): List { if (DataManager.sharedDataDir.absolutePath == DataManager.userDataDir.absolutePath) { @@ -50,5 +43,5 @@ object ThemeManager : DataDirectoryChangeListener.Listener { } @JvmStatic - fun getActiveTheme() = currentThemeName + fun getActiveTheme() = AppPrefs.defaultInstance().themeAndColor.selectedTheme }