mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Add notification for failed story messages.
This commit is contained in:
@@ -21,6 +21,7 @@ public interface MessageNotifier {
|
||||
void clearVisibleThread();
|
||||
void setLastDesktopActivityTimestamp(long timestamp);
|
||||
void notifyMessageDeliveryFailed(@NonNull Context context, @NonNull Recipient recipient, @NonNull ConversationId conversationId);
|
||||
void notifyStoryDeliveryFailed(@NonNull Context context, @NonNull Recipient recipient, @NonNull ConversationId conversationId);
|
||||
void notifyProofRequired(@NonNull Context context, @NonNull Recipient recipient, @NonNull ConversationId conversationId);
|
||||
void cancelDelayedNotifications();
|
||||
void updateNotification(@NonNull Context context);
|
||||
|
||||
@@ -58,6 +58,11 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
getNotifier().notifyMessageDeliveryFailed(context, recipient, conversationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyStoryDeliveryFailed(@NonNull Context context, @NonNull Recipient recipient, @NonNull ConversationId threadId) {
|
||||
getNotifier().notifyStoryDeliveryFailed(context, recipient, threadId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyProofRequired(@NonNull Context context, @NonNull Recipient recipient, @NonNull ConversationId conversationId) {
|
||||
getNotifier().notifyProofRequired(context, recipient, conversationId);
|
||||
|
||||
@@ -85,6 +85,10 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
NotificationFactory.notifyMessageDeliveryFailed(context, recipient, conversationId, visibleThread)
|
||||
}
|
||||
|
||||
override fun notifyStoryDeliveryFailed(context: Context, recipient: Recipient, conversationId: ConversationId) {
|
||||
NotificationFactory.notifyStoryDeliveryFailed(context, recipient, conversationId)
|
||||
}
|
||||
|
||||
override fun notifyProofRequired(context: Context, recipient: Recipient, conversationId: ConversationId) {
|
||||
NotificationFactory.notifyProofRequired(context, recipient, conversationId, visibleThread)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.MainActivity
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiStrings
|
||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto
|
||||
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
||||
import org.thoughtcrime.securesms.conversation.colors.AvatarColor
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.InMemoryMessageRecord
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
@@ -324,6 +327,46 @@ object NotificationFactory {
|
||||
NotificationManagerCompat.from(context).safelyNotify(recipient, NotificationIds.getNotificationIdForMessageDeliveryFailed(thread), builder.build())
|
||||
}
|
||||
|
||||
fun notifyStoryDeliveryFailed(context: Context, recipient: Recipient, thread: ConversationId) {
|
||||
val intent = Intent(context, MyStoriesActivity::class.java).makeUniqueToPreventMerging()
|
||||
|
||||
val contentTitle = if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
if (recipient.isGroup) {
|
||||
context.getString(R.string.MessageNotifier_group_story_title, recipient.getDisplayName(context))
|
||||
} else {
|
||||
recipient.getDisplayName(context)
|
||||
}
|
||||
} else {
|
||||
context.getString(R.string.SingleRecipientNotificationBuilder_signal)
|
||||
}
|
||||
|
||||
val largeIcon = if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
|
||||
if (recipient.isMyStory) {
|
||||
Recipient.self().getContactDrawable(context)
|
||||
} else {
|
||||
recipient.getContactDrawable(context)
|
||||
}
|
||||
} else {
|
||||
GeneratedContactPhoto("Unknown", R.drawable.ic_profile_outline_40).asDrawable(context, AvatarColor.UNKNOWN)
|
||||
}.toLargeBitmap(context)
|
||||
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||
|
||||
builder.apply {
|
||||
setSmallIcon(R.drawable.ic_notification)
|
||||
setLargeIcon(largeIcon)
|
||||
setContentTitle(contentTitle)
|
||||
setContentText(String.format("%s %s", EmojiStrings.FAILED_STORY, context.getString(R.string.MessageNotifier_story_delivery_failed)))
|
||||
setTicker(context.getString(R.string.MessageNotifier_story_delivery_failed))
|
||||
setContentIntent(NotificationPendingIntentHelper.getActivity(context, 0, intent, PendingIntentFlags.mutable()))
|
||||
setAutoCancel(true)
|
||||
setAlarms(recipient)
|
||||
setChannelId(NotificationChannels.getInstance().FAILURES)
|
||||
}
|
||||
|
||||
NotificationManagerCompat.from(context).safelyNotify(recipient, NotificationIds.getNotificationIdForMessageDeliveryFailed(thread), builder.build())
|
||||
}
|
||||
|
||||
fun notifyProofRequired(context: Context, recipient: Recipient, thread: ConversationId, visibleThread: ConversationId?) {
|
||||
if (thread == visibleThread) {
|
||||
notifyInThread(context, recipient, 0)
|
||||
|
||||
Reference in New Issue
Block a user