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 OTHER = "other_v3";
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
@ -519,6 +520,7 @@ public class NotificationChannels {
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 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.enableVibration(TextSecurePreferences.isNotificationVibrateEnabled(context));
@ -532,8 +534,9 @@ public class NotificationChannels {
other.setVibrationPattern(new long[]{0});
other.enableVibration(true);
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) {
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.notifications.DeleteNotificationReceiver
import org.thoughtcrime.securesms.notifications.MarkReadReceiver
import org.thoughtcrime.securesms.notifications.NotificationChannels
import org.thoughtcrime.securesms.notifications.NotificationIds
import org.thoughtcrime.securesms.notifications.RemoteReplyReceiver
import org.thoughtcrime.securesms.notifications.ReplyMethod
@ -41,6 +42,7 @@ class NotificationConversation(
val sortKey: Long = Long.MAX_VALUE - mostRecentNotification.timestamp
val messageCount: Int = notificationItems.size
val isGroup: Boolean = recipient.isGroup
val isOnlyContactJoinedEvent: Boolean = messageCount == 1 && mostRecentNotification.isJoined
fun getContentTitle(context: Context): CharSequence {
return if (TextSecurePreferences.getNotificationPrivacy(context).isDisplayContact) {
@ -119,6 +121,14 @@ class NotificationConversation(
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 {
val intent: Intent = ConversationIntents.createBuilder(context, recipient.id, threadId)
.withStartingPosition(mostRecentNotification.getStartingPosition(context))

Wyświetl plik

@ -66,7 +66,6 @@ object NotificationFactory {
notifyForConversation(
context = context,
conversation = conversation,
recipient = conversation.recipient,
targetThreadId = targetThreadId,
defaultBubbleState = defaultBubbleState
)
@ -112,7 +111,6 @@ object NotificationFactory {
private fun notifyForConversation(
context: Context,
conversation: NotificationConversation,
recipient: Recipient,
targetThreadId: Long,
defaultBubbleState: BubbleUtil.BubbleState
) {
@ -124,11 +122,11 @@ object NotificationFactory {
setCategory(NotificationCompat.CATEGORY_MESSAGE)
setGroup(DefaultMessageNotifier.NOTIFICATION_GROUP)
setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
setChannelId(recipient.notificationChannel ?: NotificationChannels.getMessagesChannel(context))
setChannelId(conversation.getChannelId(context))
setContentTitle(conversation.getContentTitle(context))
setLargeIcon(conversation.getLargeIcon(context))
addPerson(recipient)
setShortcutId(ConversationUtil.getShortcutId(recipient))
addPerson(conversation.recipient)
setShortcutId(ConversationUtil.getShortcutId(conversation.recipient))
setContentInfo(conversation.messageCount.toString())
setNumber(conversation.messageCount)
setContentText(conversation.getContentText(context))
@ -146,7 +144,7 @@ object NotificationFactory {
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))
}

Wyświetl plik

@ -1727,6 +1727,7 @@
<string name="NotificationChannel_group_messages">Messages</string>
<string name="NotificationChannel_missing_display_name">Unknown</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>
<!-- ProfileEditNameFragment -->