Add per-contact notification channels.

Fixes #8119
Fixes #8121
Fixes #8122
This commit is contained in:
Greyson Parrelli
2018-08-16 09:47:43 -07:00
parent e23fd9d491
commit e9b85a10a6
20 changed files with 609 additions and 68 deletions

View File

@@ -54,7 +54,7 @@ public class TextSecurePreferences {
private static final String LAST_EXPERIENCE_VERSION_PREF = "last_experience_version_code";
private static final String EXPERIENCE_DISMISSED_PREF = "experience_dismissed";
public static final String RINGTONE_PREF = "pref_key_ringtone";
private static final String VIBRATE_PREF = "pref_key_vibrate";
public static final String VIBRATE_PREF = "pref_key_vibrate";
private static final String NOTIFICATION_PREF = "pref_key_enable_notifications";
public static final String LED_COLOR_PREF = "pref_led_color";
public static final String LED_BLINK_PREF = "pref_led_blink";
@@ -159,6 +159,9 @@ public class TextSecurePreferences {
private static final String LOG_ENCRYPTED_SECRET = "pref_log_encrypted_secret";
private static final String LOG_UNENCRYPTED_SECRET = "pref_log_unencrypted_secret";
private static final String NOTIFICATION_CHANNEL_VERSION = "pref_notification_channel_version";
private static final String NOTIFICATION_MESSAGES_CHANNEL_VERSION = "pref_notification_messages_channel_version";
public static boolean isScreenLockEnabled(@NonNull Context context) {
return getBooleanPreference(context, SCREEN_LOCK, false);
}
@@ -960,6 +963,22 @@ public class TextSecurePreferences {
return getStringPreference(context, LOG_UNENCRYPTED_SECRET, null);
}
public static int getNotificationChannelVersion(Context context) {
return getIntegerPreference(context, NOTIFICATION_CHANNEL_VERSION, 1);
}
public static void setNotificationChannelVersion(Context context, int version) {
setIntegerPrefrence(context, NOTIFICATION_CHANNEL_VERSION, version);
}
public static int getNotificationMessagesChannelVersion(Context context) {
return getIntegerPreference(context, NOTIFICATION_MESSAGES_CHANNEL_VERSION, 1);
}
public static void setNotificationMessagesChannelVersion(Context context, int version) {
setIntegerPrefrence(context, NOTIFICATION_MESSAGES_CHANNEL_VERSION, version);
}
public static void setBooleanPreference(Context context, String key, boolean value) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply();
}