From 33395d91763e747bf2757e5aa49ed852a9d3b4f7 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Thu, 11 Jun 2020 12:22:48 +0530 Subject: [PATCH] Fix possible crash after changing themes and then selecting a check box option. --- .../edu/berkeley/boinc/SettingsFragment.kt | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/android/BOINC/app/src/main/java/edu/berkeley/boinc/SettingsFragment.kt b/android/BOINC/app/src/main/java/edu/berkeley/boinc/SettingsFragment.kt index d125113374..70eeeefa9e 100644 --- a/android/BOINC/app/src/main/java/edu/berkeley/boinc/SettingsFragment.kt +++ b/android/BOINC/app/src/main/java/edu/berkeley/boinc/SettingsFragment.kt @@ -99,23 +99,13 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { when (key) { // General - "autostart" -> { - BOINCActivity.monitor!!.autostart = sharedPreferences.getBoolean(key, - resources.getBoolean(R.bool.prefs_default_autostart)) - } - "showNotification" -> { - BOINCActivity.monitor!!.showNotificationForNotices = - sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.prefs_default_notification_notices)) - } + "autostart" -> BOINCActivity.monitor!!.autostart = sharedPreferences.getBoolean(key, true) + "showNotification" -> BOINCActivity.monitor!!.showNotificationForNotices = sharedPreferences.getBoolean(key, true) "showAdvanced" -> { - BOINCActivity.monitor!!.showAdvanced = sharedPreferences.getBoolean(key, - resources.getBoolean(R.bool.prefs_default_advanced)) + BOINCActivity.monitor!!.showAdvanced = sharedPreferences.getBoolean(key, false) setAdvancedPreferencesVisibility() } - "suspendWhenScreenOn" -> { - BOINCActivity.monitor!!.suspendWhenScreenOn = sharedPreferences.getBoolean(key, - resources.getBoolean(R.bool.prefs_suspend_when_screen_on)) - } + "suspendWhenScreenOn" -> BOINCActivity.monitor!!.suspendWhenScreenOn = sharedPreferences.getBoolean(key, true) "deviceName" -> BOINCActivity.monitor!!.setDomainName(sharedPreferences.getString(key, "")) "theme" -> { val theme = sharedPreferences.getString(key, "default")!! @@ -148,10 +138,7 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP lifecycleScope.launch { writeClientPrefs(prefs) } } - "stationaryDeviceMode" -> { - BOINCActivity.monitor!!.stationaryDeviceMode = sharedPreferences.getBoolean(key, - resources.getBoolean(R.bool.prefs_stationary_device_mode)) - } + "stationaryDeviceMode" -> BOINCActivity.monitor!!.stationaryDeviceMode = sharedPreferences.getBoolean(key, false) "maxBatteryTemp" -> { prefs.batteryMaxTemperature = sharedPreferences.getString(key, "40")?.toDouble() ?: 40.0