From c9f5810ea0b23fc7e35166cede8ace76cd17735d Mon Sep 17 00:00:00 2001 From: bemusementpark Date: Thu, 18 Jul 2024 23:55:12 +0930 Subject: [PATCH] Fix tests --- .../org/session/libsession/utilities/TextSecurePreferences.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt index 6f81d1c22b..9277f01172 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt @@ -40,6 +40,7 @@ fun Pref(name: String, default: Boolean) = Pref(name, default, SharedPreferences fun Pref(name: String, default: Int) = Pref(name, default, SharedPreferences::getInt, SharedPreferences.Editor::putInt) fun Pref(name: String, default: Long) = Pref(name, default, SharedPreferences::getLong, SharedPreferences.Editor::putLong) fun Pref(name: String, default: String) = Pref(name, default, { _, _ -> getString(name, null) ?: default }, SharedPreferences.Editor::putStringOrRemove) +fun NullablePref(name: String, default: String?) = Pref(name, default, { _, _ -> getString(name, null) ?: default }, SharedPreferences.Editor::putStringOrRemove) fun Pref(name: String) = Pref(name, null, SharedPreferences::getString, SharedPreferences.Editor::putStringOrRemove) fun Pref(name: String, default: Set) = Pref(name, default, SharedPreferences::getStringSet, SharedPreferences.Editor::putStringSet) @@ -82,7 +83,7 @@ class TextSecurePreferences @Inject constructor( val DISABLE_PASSPHRASE_PREF = Pref("pref_disable_passphrase", true) val LANGUAGE_PREF = Pref("pref_language", "zz") val LAST_VERSION_CODE_PREF = Pref("last_version_code", 0) - val RINGTONE_PREF = Pref("pref_key_ringtone", Settings.System.DEFAULT_NOTIFICATION_URI.toString()) + val RINGTONE_PREF = NullablePref("pref_key_ringtone", Settings.System.DEFAULT_NOTIFICATION_URI?.toString()) val VIBRATE_PREF = Pref("pref_key_vibrate", true) val NOTIFICATION_PREF = Pref("pref_key_enable_notifications", true) val PASSPHRASE_TIMEOUT_INTERVAL_PREF = Pref("pref_timeout_interval", 5 * 60)