mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Refactor app settings.
This commit is contained in:
committed by
Greyson Parrelli
parent
a94d77d81e
commit
f2d5ea0391
@@ -14,6 +14,7 @@ import androidx.core.app.NotificationCompat;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@@ -49,8 +50,8 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
||||
}
|
||||
|
||||
public void setAlarms(@Nullable Uri ringtone, RecipientDatabase.VibrateState vibrate) {
|
||||
Uri defaultRingtone = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : TextSecurePreferences.getNotificationRingtone(context);
|
||||
boolean defaultVibrate = NotificationChannels.supported() ? NotificationChannels.getMessageVibrate(context) : TextSecurePreferences.isNotificationVibrateEnabled(context);
|
||||
Uri defaultRingtone = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : SignalStore.settings().getMessageNotificationSound();
|
||||
boolean defaultVibrate = NotificationChannels.supported() ? NotificationChannels.getMessageVibrate(context) : SignalStore.settings().isMessageVibrateEnabled();
|
||||
|
||||
if (ringtone == null && !TextUtils.isEmpty(defaultRingtone.toString())) setSound(defaultRingtone);
|
||||
else if (ringtone != null && !ringtone.toString().isEmpty()) setSound(ringtone);
|
||||
@@ -63,8 +64,8 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
||||
}
|
||||
|
||||
private void setLed() {
|
||||
String ledColor = TextSecurePreferences.getNotificationLedColor(context);
|
||||
String ledBlinkPattern = TextSecurePreferences.getNotificationLedPattern(context);
|
||||
String ledColor = SignalStore.settings().getMessageLedColor();
|
||||
String ledBlinkPattern = SignalStore.settings().getMessageLedBlinkPattern();
|
||||
String ledBlinkPatternCustom = TextSecurePreferences.getNotificationLedPatternCustom(context);
|
||||
|
||||
if (!ledColor.equals("none")) {
|
||||
|
||||
@@ -60,6 +60,7 @@ import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.ReactionRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.messages.IncomingMessageObserver;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
@@ -139,7 +140,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
Intent intent = ConversationIntents.createBuilder(context, recipient.getId(), threadId)
|
||||
.withDataUri(Uri.parse("custom://" + System.currentTimeMillis()))
|
||||
.build();
|
||||
FailedNotificationBuilder builder = new FailedNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context), intent);
|
||||
FailedNotificationBuilder builder = new FailedNotificationBuilder(context, SignalStore.settings().getMessageNotificationsPrivacy(), intent);
|
||||
|
||||
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
||||
.notify((int)threadId, builder.build());
|
||||
@@ -220,7 +221,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
|
||||
@Override
|
||||
public void updateNotification(@NonNull Context context) {
|
||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
||||
if (!SignalStore.settings().isMessageNotificationsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -261,7 +262,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
private boolean shouldNotify(@NonNull Context context, @Nullable Recipient recipient, long threadId) {
|
||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
||||
if (!SignalStore.settings().isMessageNotificationsEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -281,7 +282,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
int reminderCount,
|
||||
@NonNull BubbleUtil.BubbleState defaultBubbleState)
|
||||
{
|
||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
||||
if (!SignalStore.settings().isMessageNotificationsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -371,7 +372,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
return false;
|
||||
}
|
||||
|
||||
NotificationPrivacyPreference notificationPrivacy = TextSecurePreferences.getNotificationPrivacy(context);
|
||||
NotificationPrivacyPreference notificationPrivacy = SignalStore.settings().getMessageNotificationsPrivacy();
|
||||
SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, notificationPrivacy);
|
||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||
Recipient recipient = notifications.get(0).getRecipient();
|
||||
@@ -442,7 +443,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
NotificationManagerCompat.from(context).notify(notificationId, notification);
|
||||
Log.i(TAG, "Posted notification.");
|
||||
} catch (SecurityException e) {
|
||||
Uri defaultValue = TextSecurePreferences.getNotificationRingtone(context);
|
||||
Uri defaultValue = SignalStore.settings().getMessageNotificationSound();
|
||||
if (!defaultValue.equals(notificationState.getRingtone(context))) {
|
||||
Log.e(TAG, "Security exception when posting notification with custom ringtone", e);
|
||||
clearNotificationRingtone(context, notifications.get(0).getRecipient());
|
||||
@@ -465,7 +466,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationPrivacyPreference notificationPrivacy = TextSecurePreferences.getNotificationPrivacy(context);
|
||||
NotificationPrivacyPreference notificationPrivacy = SignalStore.settings().getMessageNotificationsPrivacy();
|
||||
MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, notificationPrivacy);
|
||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||
boolean shouldAlert = signal && Stream.of(notifications).anyMatch(item -> item.getNotifiedTimestamp() == 0);
|
||||
@@ -506,7 +507,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
NotificationManagerCompat.from(context).notify(NotificationIds.MESSAGE_SUMMARY, builder.build());
|
||||
Log.i(TAG, "Posted notification. " + notification.toString());
|
||||
} catch (SecurityException securityException) {
|
||||
Uri defaultValue = TextSecurePreferences.getNotificationRingtone(context);
|
||||
Uri defaultValue = SignalStore.settings().getMessageNotificationSound();
|
||||
if (!defaultValue.equals(notificationState.getRingtone(context))) {
|
||||
Log.e(TAG, "Security exception when posting notification with custom ringtone", securityException);
|
||||
clearNotificationRingtone(context, notifications.get(0).getRecipient());
|
||||
@@ -524,7 +525,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
private static void sendInThreadNotification(Context context, Recipient recipient) {
|
||||
if (!TextSecurePreferences.isInThreadNotifications(context) ||
|
||||
if (!SignalStore.settings().isMessageNotificationsInChatSoundsEnabled() ||
|
||||
ServiceUtil.getAudioManager(context).getRingerMode() != AudioManager.RINGER_MODE_NORMAL)
|
||||
{
|
||||
return;
|
||||
@@ -536,7 +537,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
if (uri == null) {
|
||||
uri = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : TextSecurePreferences.getNotificationRingtone(context);
|
||||
uri = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : SignalStore.settings().getMessageNotificationSound();
|
||||
}
|
||||
|
||||
if (uri.toString().isEmpty()) {
|
||||
@@ -729,7 +730,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
private static void scheduleReminder(Context context, int count) {
|
||||
if (count >= TextSecurePreferences.getRepeatAlertsCount(context)) {
|
||||
if (count >= SignalStore.settings().getMessageNotificationsRepeatAlerts()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@@ -158,7 +159,7 @@ public class NotificationChannels {
|
||||
if (recipient.getId().isUnknown()) return null;
|
||||
|
||||
VibrateState vibrateState = recipient.getMessageVibrate();
|
||||
boolean vibrationEnabled = vibrateState == VibrateState.DEFAULT ? TextSecurePreferences.isNotificationVibrateEnabled(context) : vibrateState == VibrateState.ENABLED;
|
||||
boolean vibrationEnabled = vibrateState == VibrateState.DEFAULT ? SignalStore.settings().isMessageVibrateEnabled() : vibrateState == VibrateState.ENABLED;
|
||||
Uri messageRingtone = recipient.getMessageRingtone() != null ? recipient.getMessageRingtone() : getMessageRingtone(context);
|
||||
String displayName = recipient.getDisplayName(context);
|
||||
|
||||
@@ -180,7 +181,7 @@ public class NotificationChannels {
|
||||
|
||||
NotificationChannel channel = new NotificationChannel(channelId, displayName, NotificationManager.IMPORTANCE_HIGH);
|
||||
|
||||
setLedPreference(channel, TextSecurePreferences.getNotificationLedColor(context));
|
||||
setLedPreference(channel, SignalStore.settings().getMessageLedColor());
|
||||
channel.setGroup(CATEGORY_MESSAGES);
|
||||
channel.enableVibration(vibrationEnabled);
|
||||
|
||||
@@ -523,9 +524,9 @@ public class NotificationChannels {
|
||||
NotificationChannel joinEvents = new NotificationChannel(JOIN_EVENTS, context.getString(R.string.NotificationChannel_contact_joined_signal), NotificationManager.IMPORTANCE_DEFAULT);
|
||||
|
||||
messages.setGroup(CATEGORY_MESSAGES);
|
||||
messages.enableVibration(TextSecurePreferences.isNotificationVibrateEnabled(context));
|
||||
messages.setSound(TextSecurePreferences.getNotificationRingtone(context), getRingtoneAudioAttributes());
|
||||
setLedPreference(messages, TextSecurePreferences.getNotificationLedColor(context));
|
||||
messages.enableVibration(SignalStore.settings().isMessageVibrateEnabled());
|
||||
messages.setSound(SignalStore.settings().getMessageNotificationSound(), getRingtoneAudioAttributes());
|
||||
setLedPreference(messages, SignalStore.settings().getMessageLedColor());
|
||||
|
||||
calls.setShowBadge(false);
|
||||
backups.setShowBadge(false);
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.MessageDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.messages.IncomingMessageObserver
|
||||
import org.thoughtcrime.securesms.notifications.DefaultMessageNotifier
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier
|
||||
@@ -27,7 +28,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService
|
||||
import org.thoughtcrime.securesms.util.BubbleUtil.BubbleState
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder
|
||||
import org.whispersystems.signalservice.internal.util.Util
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -47,7 +47,7 @@ class MessageNotifierV2(context: Application) : MessageNotifier {
|
||||
@Volatile private var lastAudibleNotification: Long = -1
|
||||
@Volatile private var lastScheduledReminder: Long = 0
|
||||
@Volatile private var previousLockedStatus: Boolean = KeyCachingService.isLocked(context)
|
||||
@Volatile private var previousPrivacyPreference: NotificationPrivacyPreference = TextSecurePreferences.getNotificationPrivacy(context)
|
||||
@Volatile private var previousPrivacyPreference: NotificationPrivacyPreference = SignalStore.settings().messageNotificationsPrivacy
|
||||
@Volatile private var previousState: NotificationStateV2 = NotificationStateV2.EMPTY
|
||||
|
||||
private val threadReminders: MutableMap<Long, Reminder> = ConcurrentHashMap()
|
||||
@@ -116,12 +116,12 @@ class MessageNotifierV2(context: Application) : MessageNotifier {
|
||||
reminderCount: Int,
|
||||
defaultBubbleState: BubbleState
|
||||
) {
|
||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
||||
if (!SignalStore.settings().isMessageNotificationsEnabled) {
|
||||
return
|
||||
}
|
||||
|
||||
val currentLockStatus: Boolean = KeyCachingService.isLocked(context)
|
||||
val currentPrivacyPreference: NotificationPrivacyPreference = TextSecurePreferences.getNotificationPrivacy(context)
|
||||
val currentPrivacyPreference: NotificationPrivacyPreference = SignalStore.settings().messageNotificationsPrivacy
|
||||
val notificationConfigurationChanged: Boolean = currentLockStatus != previousLockedStatus || currentPrivacyPreference != previousPrivacyPreference
|
||||
previousLockedStatus = currentLockStatus
|
||||
previousPrivacyPreference = currentPrivacyPreference
|
||||
@@ -211,7 +211,7 @@ class MessageNotifierV2(context: Application) : MessageNotifier {
|
||||
}
|
||||
|
||||
private fun updateReminderTimestamps(context: Context, alertOverrides: Set<Long>, threadsThatAlerted: Set<Long>) {
|
||||
if (TextSecurePreferences.getRepeatAlertsCount(context) == 0) {
|
||||
if (SignalStore.settings().messageNotificationsRepeatAlerts == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ class MessageNotifierV2(context: Application) : MessageNotifier {
|
||||
val (id: Long, reminder: Reminder) = entry
|
||||
if (alertOverrides.contains(id)) {
|
||||
val notifyCount: Int = reminder.count + 1
|
||||
if (notifyCount >= TextSecurePreferences.getRepeatAlertsCount(context)) {
|
||||
if (notifyCount >= SignalStore.settings().messageNotificationsRepeatAlerts) {
|
||||
iterator.remove()
|
||||
} else {
|
||||
entry.setValue(Reminder(lastAudibleNotification, notifyCount))
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.core.graphics.drawable.IconCompat
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.notifications.DefaultMessageNotifier
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
||||
import org.thoughtcrime.securesms.notifications.ReplyMethod
|
||||
@@ -45,7 +46,7 @@ private const val BIG_PICTURE_DIMEN = 500
|
||||
*/
|
||||
sealed class NotificationBuilder(protected val context: Context) {
|
||||
|
||||
private val privacy: NotificationPrivacyPreference = TextSecurePreferences.getNotificationPrivacy(context)
|
||||
private val privacy: NotificationPrivacyPreference = SignalStore.settings().messageNotificationsPrivacy
|
||||
private val isNotLocked: Boolean = !KeyCachingService.isLocked(context)
|
||||
|
||||
abstract fun setSmallIcon(@DrawableRes drawable: Int)
|
||||
@@ -145,10 +146,10 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
}
|
||||
|
||||
fun setLights() {
|
||||
val ledColor: String = TextSecurePreferences.getNotificationLedColor(context)
|
||||
val ledColor: String = SignalStore.settings().messageLedColor
|
||||
|
||||
if (ledColor != "none") {
|
||||
var blinkPattern = TextSecurePreferences.getNotificationLedPattern(context)
|
||||
var blinkPattern = SignalStore.settings().messageLedBlinkPattern
|
||||
if (blinkPattern == "custom") {
|
||||
blinkPattern = TextSecurePreferences.getNotificationLedPatternCustom(context)
|
||||
}
|
||||
@@ -297,8 +298,8 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
val ringtone: Uri? = recipient?.messageRingtone
|
||||
val vibrate = recipient?.messageVibrate
|
||||
|
||||
val defaultRingtone: Uri = TextSecurePreferences.getNotificationRingtone(context)
|
||||
val defaultVibrate: Boolean = TextSecurePreferences.isNotificationVibrateEnabled(context)
|
||||
val defaultRingtone: Uri = SignalStore.settings().messageNotificationSound
|
||||
val defaultVibrate: Boolean = SignalStore.settings().isMessageVibrateEnabled
|
||||
|
||||
if (ringtone == null && !TextUtils.isEmpty(defaultRingtone.toString())) {
|
||||
builder.setSound(defaultRingtone)
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.thoughtcrime.securesms.contacts.TurnOffContactJoinedNotificationsActi
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors
|
||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto
|
||||
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.notifications.DeleteNotificationReceiver
|
||||
import org.thoughtcrime.securesms.notifications.MarkReadReceiver
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
||||
@@ -21,7 +22,6 @@ import org.thoughtcrime.securesms.notifications.ReplyMethod
|
||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ data class NotificationConversation(
|
||||
val isOnlyContactJoinedEvent: Boolean = messageCount == 1 && mostRecentNotification.isJoined
|
||||
|
||||
fun getContentTitle(context: Context): CharSequence {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
recipient.getDisplayName(context)
|
||||
} else {
|
||||
context.getString(R.string.SingleRecipientNotificationBuilder_signal)
|
||||
@@ -49,7 +49,7 @@ data class NotificationConversation(
|
||||
}
|
||||
|
||||
fun getContactLargeIcon(context: Context): Drawable? {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
recipient.getContactDrawable(context)
|
||||
} else {
|
||||
GeneratedContactPhoto("Unknown", R.drawable.ic_profile_outline_40).asDrawable(context, ContactColors.UNKNOWN_COLOR.toConversationColor(context))
|
||||
@@ -57,7 +57,7 @@ data class NotificationConversation(
|
||||
}
|
||||
|
||||
fun getContactUri(context: Context): String? {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
recipient.contactUri?.toString()
|
||||
} else {
|
||||
null
|
||||
@@ -65,7 +65,7 @@ data class NotificationConversation(
|
||||
}
|
||||
|
||||
fun getSlideBigPictureUri(context: Context): Uri? {
|
||||
return if (notificationItems.size == 1 && TextSecurePreferences.getNotificationPrivacy(context).isDisplayMessage && !KeyCachingService.isLocked(context)) {
|
||||
return if (notificationItems.size == 1 && SignalStore.settings().messageNotificationsPrivacy.isDisplayMessage && !KeyCachingService.isLocked(context)) {
|
||||
mostRecentNotification.getBigPictureUri()
|
||||
} else {
|
||||
null
|
||||
@@ -73,7 +73,7 @@ data class NotificationConversation(
|
||||
}
|
||||
|
||||
fun getContentText(context: Context): CharSequence? {
|
||||
val privacy: NotificationPrivacyPreference = TextSecurePreferences.getNotificationPrivacy(context)
|
||||
val privacy: NotificationPrivacyPreference = SignalStore.settings().messageNotificationsPrivacy
|
||||
val stringBuilder = SpannableStringBuilder()
|
||||
|
||||
if (privacy.isDisplayContact && recipient.isGroup) {
|
||||
@@ -88,7 +88,7 @@ data class NotificationConversation(
|
||||
}
|
||||
|
||||
fun getConversationTitle(context: Context): CharSequence? {
|
||||
if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
|
||||
if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
return if (isGroup) recipient.getDisplayName(context) else null
|
||||
}
|
||||
return context.getString(R.string.SingleRecipientNotificationBuilder_signal)
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.MainActivity
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.notifications.DefaultMessageNotifier
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
||||
import org.thoughtcrime.securesms.notifications.NotificationIds
|
||||
@@ -250,7 +251,7 @@ object NotificationFactory {
|
||||
}
|
||||
|
||||
private fun notifyInThread(context: Context, recipient: Recipient, lastAudibleNotification: Long) {
|
||||
if (!TextSecurePreferences.isInThreadNotifications(context) ||
|
||||
if (!SignalStore.settings().isMessageNotificationsInChatSoundsEnabled ||
|
||||
ServiceUtil.getAudioManager(context).ringerMode != AudioManager.RINGER_MODE_NORMAL ||
|
||||
(System.currentTimeMillis() - lastAudibleNotification) < DefaultMessageNotifier.MIN_AUDIBLE_PERIOD_MILLIS
|
||||
) {
|
||||
@@ -260,7 +261,7 @@ object NotificationFactory {
|
||||
val uri: Uri = if (NotificationChannels.supported()) {
|
||||
NotificationChannels.getMessageRingtone(context, recipient) ?: NotificationChannels.getMessageRingtone(context)
|
||||
} else {
|
||||
recipient.messageRingtone ?: TextSecurePreferences.getNotificationRingtone(context)
|
||||
recipient.messageRingtone ?: SignalStore.settings().messageNotificationSound
|
||||
}
|
||||
|
||||
if (uri.toString().isEmpty()) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.database.ThreadBodyUtil
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.ReactionRecord
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.mms.Slide
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck
|
||||
import org.thoughtcrime.securesms.notifications.AbstractNotificationBuilder
|
||||
@@ -25,7 +26,6 @@ import org.thoughtcrime.securesms.service.KeyCachingService
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.MessageRecordUtil
|
||||
import org.thoughtcrime.securesms.util.SpanUtil
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
|
||||
private val TAG: String = Log.tag(NotificationItemV2::class.java)
|
||||
@@ -72,7 +72,7 @@ sealed class NotificationItemV2(val threadRecipient: Recipient, protected val re
|
||||
}
|
||||
|
||||
fun getStyledPrimaryText(context: Context, trimmed: Boolean = false): CharSequence {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayNothing) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayNothing) {
|
||||
context.getString(R.string.SingleRecipientNotificationBuilder_new_message)
|
||||
} else {
|
||||
SpannableStringBuilder().apply {
|
||||
@@ -87,7 +87,7 @@ sealed class NotificationItemV2(val threadRecipient: Recipient, protected val re
|
||||
}
|
||||
|
||||
fun getPersonName(context: Context): CharSequence {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
individualRecipient.getDisplayName(context)
|
||||
} else {
|
||||
context.getString(R.string.SingleRecipientNotificationBuilder_signal)
|
||||
@@ -99,7 +99,7 @@ sealed class NotificationItemV2(val threadRecipient: Recipient, protected val re
|
||||
}
|
||||
|
||||
fun getPersonUri(context: Context): String? {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact && individualRecipient.isSystemContact) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact && individualRecipient.isSystemContact) {
|
||||
individualRecipient.contactUri.toString()
|
||||
} else {
|
||||
null
|
||||
@@ -107,7 +107,7 @@ sealed class NotificationItemV2(val threadRecipient: Recipient, protected val re
|
||||
}
|
||||
|
||||
fun getPersonIcon(context: Context): Bitmap? {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
individualRecipient.getContactDrawable(context).toLargeBitmap(context)
|
||||
} else {
|
||||
null
|
||||
@@ -115,7 +115,7 @@ sealed class NotificationItemV2(val threadRecipient: Recipient, protected val re
|
||||
}
|
||||
|
||||
fun getPrimaryText(context: Context): CharSequence {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayMessage) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayMessage) {
|
||||
if (RecipientUtil.isMessageRequestAccepted(context, threadId)) {
|
||||
getPrimaryTextActual(context)
|
||||
} else {
|
||||
@@ -128,7 +128,7 @@ sealed class NotificationItemV2(val threadRecipient: Recipient, protected val re
|
||||
|
||||
fun getInboxLine(context: Context): CharSequence? {
|
||||
return when {
|
||||
TextSecurePreferences.getNotificationPrivacy(context).isDisplayNothing -> null
|
||||
SignalStore.settings().messageNotificationsPrivacy.isDisplayNothing -> null
|
||||
else -> getStyledPrimaryText(context, true)
|
||||
}
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class MessageNotification(threadRecipient: Recipient, record: MessageRecord) : N
|
||||
}
|
||||
|
||||
override fun getThumbnailInfo(context: Context): ThumbnailInfo {
|
||||
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayMessage && !KeyCachingService.isLocked(context)) {
|
||||
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayMessage && !KeyCachingService.isLocked(context)) {
|
||||
val thumbnailSlide: Slide? = slideDeck?.thumbnailSlide
|
||||
ThumbnailInfo(thumbnailSlide?.publicUri, thumbnailSlide?.contentType)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user