Skip to content

Commit

Permalink
refactor: directly read theme name instead of caching using local var…
Browse files Browse the repository at this point in the history
…iable

fix #1168
  • Loading branch information
goofyz committed Jan 17, 2024
1 parent 1914c30 commit af709fe
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
1 change: 0 additions & 1 deletion app/src/main/java/com/osfans/trime/data/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ object ThemeManager : DataDirectoryChangeListener.Listener {

@JvmStatic
fun switchTheme(theme: String) {
currentThemeName = theme
AppPrefs.defaultInstance().themeAndColor.selectedTheme = theme
}

var sharedThemes: MutableList<String> = listThemes(DataManager.sharedDataDir)

var userThemes: MutableList<String> = listThemes(DataManager.userDataDir)

private lateinit var currentThemeName: String

/**
* Update sharedThemes and userThemes.
*/
Expand All @@ -37,10 +34,6 @@ object ThemeManager : DataDirectoryChangeListener.Listener {
userThemes = listThemes(DataManager.userDataDir)
}

fun init() {
currentThemeName = AppPrefs.defaultInstance().themeAndColor.selectedTheme
}

@JvmStatic
fun getAllThemes(): List<String> {
if (DataManager.sharedDataDir.absolutePath == DataManager.userDataDir.absolutePath) {
Expand All @@ -50,5 +43,5 @@ object ThemeManager : DataDirectoryChangeListener.Listener {
}

@JvmStatic
fun getActiveTheme() = currentThemeName
fun getActiveTheme() = AppPrefs.defaultInstance().themeAndColor.selectedTheme
}

0 comments on commit af709fe

Please sign in to comment.