From 53e1da0f4324bcd406526c944f1a5f0f16ae5fe6 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Thu, 13 May 2021 13:14:36 -0300 Subject: [PATCH] Fix bad preference class setting. --- .../app/notifications/NotificationsSettingsViewModel.kt | 2 +- .../thoughtcrime/securesms/util/TextSecurePreferences.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt index afdb1414b..0a156bfee 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt @@ -69,7 +69,7 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer } fun setMessageNotificationPriority(priority: Int) { - sharedPreferences.edit().putInt(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF, priority).apply() + sharedPreferences.edit().putString(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF, priority.toString()).apply() store.update { getState() } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java b/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java index 7943c43db..43d76cf4b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/TextSecurePreferences.java @@ -501,7 +501,11 @@ public class TextSecurePreferences { } public static int getNotificationPriority(Context context) { - return Integer.valueOf(getStringPreference(context, NOTIFICATION_PRIORITY_PREF, String.valueOf(NotificationCompat.PRIORITY_HIGH))); + try { + return Integer.parseInt(getStringPreference(context, NOTIFICATION_PRIORITY_PREF, String.valueOf(NotificationCompat.PRIORITY_HIGH))); + } catch (ClassCastException e) { + return getIntegerPreference(context, NOTIFICATION_PRIORITY_PREF, NotificationCompat.PRIORITY_HIGH); + } } /**