Skip to content

Commit

Permalink
Fix #3178 (Calculator mode does not show on launch unless app is runn…
Browse files Browse the repository at this point in the history
…ing in background)
  • Loading branch information
tuomas2 committed Jan 25, 2024
1 parent 98fd22e commit b446a2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ class PreferenceStore: PreferenceDataStore() {

override fun getInt(key: String, defValue: Int): Int = prefs.getInt(key, defValue)

override fun getBoolean(key: String, defValue: Boolean): Boolean = prefs.getBoolean(key, defValue)
override fun getBoolean(key: String, defValue: Boolean): Boolean =
if (useRealShared(key)) CommonUtils.realSharedPreferences.getBoolean(key, defValue)
else prefs.getBoolean(key, defValue)

override fun putBoolean(key: String, value: Boolean) = prefs.setBoolean(key, value)

private fun useRealShared(key: String): Boolean = key == "locale_pref" || key == "calculator_pin" || key.startsWith("night_mode")
override fun putBoolean(key: String, value: Boolean) =
if(useRealShared(key)) CommonUtils.realSharedPreferences.edit().putBoolean(key, value).apply()
else prefs.setBoolean(key, value)

private fun useRealShared(key: String): Boolean = key == "locale_pref" || key == "calculator_pin" || key == "show_calculator" || key.startsWith("night_mode")

override fun putString(key: String, value: String?) =
if(useRealShared(key)) CommonUtils.realSharedPreferences.edit().putString(key, value).apply()
Expand Down Expand Up @@ -155,6 +160,7 @@ class SettingsActivity: ActivityBase() {
}
CommonUtils.realSharedPreferences.edit().remove("locale_pref").apply()
CommonUtils.realSharedPreferences.edit().remove("calculator_pin").apply()
CommonUtils.realSharedPreferences.edit().remove("show_calculator").apply()
recreate()
}
.setNegativeButton(R.string.cancel, null)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/net/bible/service/common/CommonUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,8 @@ object CommonUtils : CommonUtilsBase() {
val isCloudSyncEnabled: Boolean get () =
if(!isCloudSyncAvailable) false
else SyncableDatabaseDefinition.ALL.any { it.enabled }
val isDiscrete get() = settings.getBoolean("discrete_mode", false) || BuildVariant.Appearance.isDiscrete
val showCalculator get() = settings.getBoolean("show_calculator", false) || BuildVariant.Appearance.isDiscrete
val isDiscrete get() = BuildVariant.Appearance.isDiscrete ||settings.getBoolean("discrete_mode", false)
val showCalculator get() = BuildVariant.Appearance.isDiscrete || realSharedPreferences.getBoolean("show_calculator", false)

fun md5Hash(str: String): String {
val md = MessageDigest.getInstance("MD5")
Expand Down

0 comments on commit b446a2f

Please sign in to comment.