Skip to content

Commit b446a2f

Browse files
author
Tuomas Airaksinen
committed
Fix #3178 (Calculator mode does not show on launch unless app is running in background)
1 parent 98fd22e commit b446a2f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

app/src/main/java/net/bible/android/view/activity/settings/SettingsActivity.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ class PreferenceStore: PreferenceDataStore() {
5959

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

62-
override fun getBoolean(key: String, defValue: Boolean): Boolean = prefs.getBoolean(key, defValue)
62+
override fun getBoolean(key: String, defValue: Boolean): Boolean =
63+
if (useRealShared(key)) CommonUtils.realSharedPreferences.getBoolean(key, defValue)
64+
else prefs.getBoolean(key, defValue)
6365

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

66-
private fun useRealShared(key: String): Boolean = key == "locale_pref" || key == "calculator_pin" || key.startsWith("night_mode")
67+
override fun putBoolean(key: String, value: Boolean) =
68+
if(useRealShared(key)) CommonUtils.realSharedPreferences.edit().putBoolean(key, value).apply()
69+
else prefs.setBoolean(key, value)
70+
71+
private fun useRealShared(key: String): Boolean = key == "locale_pref" || key == "calculator_pin" || key == "show_calculator" || key.startsWith("night_mode")
6772

6873
override fun putString(key: String, value: String?) =
6974
if(useRealShared(key)) CommonUtils.realSharedPreferences.edit().putString(key, value).apply()
@@ -155,6 +160,7 @@ class SettingsActivity: ActivityBase() {
155160
}
156161
CommonUtils.realSharedPreferences.edit().remove("locale_pref").apply()
157162
CommonUtils.realSharedPreferences.edit().remove("calculator_pin").apply()
163+
CommonUtils.realSharedPreferences.edit().remove("show_calculator").apply()
158164
recreate()
159165
}
160166
.setNegativeButton(R.string.cancel, null)

app/src/main/java/net/bible/service/common/CommonUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,8 +1503,8 @@ object CommonUtils : CommonUtilsBase() {
15031503
val isCloudSyncEnabled: Boolean get () =
15041504
if(!isCloudSyncAvailable) false
15051505
else SyncableDatabaseDefinition.ALL.any { it.enabled }
1506-
val isDiscrete get() = settings.getBoolean("discrete_mode", false) || BuildVariant.Appearance.isDiscrete
1507-
val showCalculator get() = settings.getBoolean("show_calculator", false) || BuildVariant.Appearance.isDiscrete
1506+
val isDiscrete get() = BuildVariant.Appearance.isDiscrete ||settings.getBoolean("discrete_mode", false)
1507+
val showCalculator get() = BuildVariant.Appearance.isDiscrete || realSharedPreferences.getBoolean("show_calculator", false)
15081508

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

0 commit comments

Comments
 (0)