Fix bad preference class setting.

This commit is contained in:
Alex Hart
2021-05-13 13:14:36 -03:00
committed by Greyson Parrelli
parent b41989de03
commit 53e1da0f43
2 changed files with 6 additions and 2 deletions

View File

@@ -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() }
}

View File

@@ -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);
}
}
/**