Move contact join events to separate channel.

fork-5.53.8
Cody Henthorne 2021-04-14 09:35:14 -04:00 zatwierdzone przez Greyson Parrelli
rodzic e796968d19
commit 5df1fa3c65
4 zmienionych plików z 19 dodań i 7 usunięć

Wyświetl plik

@ -62,6 +62,7 @@ public class NotificationChannels {
public static final String LOCKED_STATUS = "locked_status_v2"; public static final String LOCKED_STATUS = "locked_status_v2";
public static final String OTHER = "other_v3"; public static final String OTHER = "other_v3";
public static final String VOICE_NOTES = "voice_notes"; public static final String VOICE_NOTES = "voice_notes";
public static final String JOIN_EVENTS = "join_events";
/** /**
* Ensures all of the notification channels are created. No harm in repeat calls. Call is safely * Ensures all of the notification channels are created. No harm in repeat calls. Call is safely
@ -519,6 +520,7 @@ public class NotificationChannels {
NotificationChannel lockedStatus = new NotificationChannel(LOCKED_STATUS, context.getString(R.string.NotificationChannel_locked_status), NotificationManager.IMPORTANCE_LOW); NotificationChannel lockedStatus = new NotificationChannel(LOCKED_STATUS, context.getString(R.string.NotificationChannel_locked_status), NotificationManager.IMPORTANCE_LOW);
NotificationChannel other = new NotificationChannel(OTHER, context.getString(R.string.NotificationChannel_other), NotificationManager.IMPORTANCE_LOW); NotificationChannel other = new NotificationChannel(OTHER, context.getString(R.string.NotificationChannel_other), NotificationManager.IMPORTANCE_LOW);
NotificationChannel voiceNotes = new NotificationChannel(VOICE_NOTES, context.getString(R.string.NotificationChannel_voice_notes), NotificationManager.IMPORTANCE_LOW); NotificationChannel voiceNotes = new NotificationChannel(VOICE_NOTES, context.getString(R.string.NotificationChannel_voice_notes), NotificationManager.IMPORTANCE_LOW);
NotificationChannel joinEvents = new NotificationChannel(JOIN_EVENTS, context.getString(R.string.NotificationChannel_contact_joined_signal), NotificationManager.IMPORTANCE_DEFAULT);
messages.setGroup(CATEGORY_MESSAGES); messages.setGroup(CATEGORY_MESSAGES);
messages.enableVibration(TextSecurePreferences.isNotificationVibrateEnabled(context)); messages.enableVibration(TextSecurePreferences.isNotificationVibrateEnabled(context));
@ -532,8 +534,9 @@ public class NotificationChannels {
other.setVibrationPattern(new long[]{0}); other.setVibrationPattern(new long[]{0});
other.enableVibration(true); other.enableVibration(true);
voiceNotes.setShowBadge(false); voiceNotes.setShowBadge(false);
joinEvents.setShowBadge(false);
notificationManager.createNotificationChannels(Arrays.asList(messages, calls, failures, backups, lockedStatus, other, voiceNotes)); notificationManager.createNotificationChannels(Arrays.asList(messages, calls, failures, backups, lockedStatus, other, voiceNotes, joinEvents));
if (BuildConfig.PLAY_STORE_DISABLED) { if (BuildConfig.PLAY_STORE_DISABLED) {
NotificationChannel appUpdates = new NotificationChannel(APP_UPDATES, context.getString(R.string.NotificationChannel_app_updates), NotificationManager.IMPORTANCE_HIGH); NotificationChannel appUpdates = new NotificationChannel(APP_UPDATES, context.getString(R.string.NotificationChannel_app_updates), NotificationManager.IMPORTANCE_HIGH);

Wyświetl plik

@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto
import org.thoughtcrime.securesms.conversation.ConversationIntents import org.thoughtcrime.securesms.conversation.ConversationIntents
import org.thoughtcrime.securesms.notifications.DeleteNotificationReceiver import org.thoughtcrime.securesms.notifications.DeleteNotificationReceiver
import org.thoughtcrime.securesms.notifications.MarkReadReceiver import org.thoughtcrime.securesms.notifications.MarkReadReceiver
import org.thoughtcrime.securesms.notifications.NotificationChannels
import org.thoughtcrime.securesms.notifications.NotificationIds import org.thoughtcrime.securesms.notifications.NotificationIds
import org.thoughtcrime.securesms.notifications.RemoteReplyReceiver import org.thoughtcrime.securesms.notifications.RemoteReplyReceiver
import org.thoughtcrime.securesms.notifications.ReplyMethod import org.thoughtcrime.securesms.notifications.ReplyMethod
@ -41,6 +42,7 @@ class NotificationConversation(
val sortKey: Long = Long.MAX_VALUE - mostRecentNotification.timestamp val sortKey: Long = Long.MAX_VALUE - mostRecentNotification.timestamp
val messageCount: Int = notificationItems.size val messageCount: Int = notificationItems.size
val isGroup: Boolean = recipient.isGroup val isGroup: Boolean = recipient.isGroup
val isOnlyContactJoinedEvent: Boolean = messageCount == 1 && mostRecentNotification.isJoined
fun getContentTitle(context: Context): CharSequence { fun getContentTitle(context: Context): CharSequence {
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) { return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
@ -119,6 +121,14 @@ class NotificationConversation(
return notificationItems.any { it.isNewNotification } return notificationItems.any { it.isNewNotification }
} }
fun getChannelId(context: Context): String {
return if (isOnlyContactJoinedEvent) {
NotificationChannels.JOIN_EVENTS
} else {
recipient.notificationChannel ?: NotificationChannels.getMessagesChannel(context)
}
}
fun getPendingIntent(context: Context): PendingIntent { fun getPendingIntent(context: Context): PendingIntent {
val intent: Intent = ConversationIntents.createBuilder(context, recipient.id, threadId) val intent: Intent = ConversationIntents.createBuilder(context, recipient.id, threadId)
.withStartingPosition(mostRecentNotification.getStartingPosition(context)) .withStartingPosition(mostRecentNotification.getStartingPosition(context))

Wyświetl plik

@ -66,7 +66,6 @@ object NotificationFactory {
notifyForConversation( notifyForConversation(
context = context, context = context,
conversation = conversation, conversation = conversation,
recipient = conversation.recipient,
targetThreadId = targetThreadId, targetThreadId = targetThreadId,
defaultBubbleState = defaultBubbleState defaultBubbleState = defaultBubbleState
) )
@ -112,7 +111,6 @@ object NotificationFactory {
private fun notifyForConversation( private fun notifyForConversation(
context: Context, context: Context,
conversation: NotificationConversation, conversation: NotificationConversation,
recipient: Recipient,
targetThreadId: Long, targetThreadId: Long,
defaultBubbleState: BubbleUtil.BubbleState defaultBubbleState: BubbleUtil.BubbleState
) { ) {
@ -124,11 +122,11 @@ object NotificationFactory {
setCategory(NotificationCompat.CATEGORY_MESSAGE) setCategory(NotificationCompat.CATEGORY_MESSAGE)
setGroup(DefaultMessageNotifier.NOTIFICATION_GROUP) setGroup(DefaultMessageNotifier.NOTIFICATION_GROUP)
setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN) setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
setChannelId(recipient.notificationChannel ?: NotificationChannels.getMessagesChannel(context)) setChannelId(conversation.getChannelId(context))
setContentTitle(conversation.getContentTitle(context)) setContentTitle(conversation.getContentTitle(context))
setLargeIcon(conversation.getLargeIcon(context)) setLargeIcon(conversation.getLargeIcon(context))
addPerson(recipient) addPerson(conversation.recipient)
setShortcutId(ConversationUtil.getShortcutId(recipient)) setShortcutId(ConversationUtil.getShortcutId(conversation.recipient))
setContentInfo(conversation.messageCount.toString()) setContentInfo(conversation.messageCount.toString())
setNumber(conversation.messageCount) setNumber(conversation.messageCount)
setContentText(conversation.getContentText(context)) setContentText(conversation.getContentText(context))
@ -146,7 +144,7 @@ object NotificationFactory {
setBubbleMetadata(conversation, if (targetThreadId == conversation.threadId) defaultBubbleState else BubbleUtil.BubbleState.HIDDEN) setBubbleMetadata(conversation, if (targetThreadId == conversation.threadId) defaultBubbleState else BubbleUtil.BubbleState.HIDDEN)
} }
if (conversation.messageCount == 1 && conversation.mostRecentNotification.isJoined) { if (conversation.isOnlyContactJoinedEvent) {
builder.addTurnOffJoinedNotificationsAction(conversation.getTurnOffJoinedNotificationsIntent(context)) builder.addTurnOffJoinedNotificationsAction(conversation.getTurnOffJoinedNotificationsIntent(context))
} }

Wyświetl plik

@ -1727,6 +1727,7 @@
<string name="NotificationChannel_group_messages">Messages</string> <string name="NotificationChannel_group_messages">Messages</string>
<string name="NotificationChannel_missing_display_name">Unknown</string> <string name="NotificationChannel_missing_display_name">Unknown</string>
<string name="NotificationChannel_voice_notes">Voice Notes</string> <string name="NotificationChannel_voice_notes">Voice Notes</string>
<string name="NotificationChannel_contact_joined_signal">Contact joined Signal</string>
<string name="NotificationChannels__no_activity_available_to_open_notification_channel_settings">No activity available to open notification channel settings.</string> <string name="NotificationChannels__no_activity_available_to_open_notification_channel_settings">No activity available to open notification channel settings.</string>
<!-- ProfileEditNameFragment --> <!-- ProfileEditNameFragment -->