Add a notification action to resend a failed message

This commit is contained in:
Inhishonor
2025-06-07 15:35:15 -07:00
parent f36709e144
commit cb74067f5d
2 changed files with 22 additions and 0 deletions
@@ -53,6 +53,7 @@ import dev.octoshrimpy.quik.receiver.MarkReadReceiver
import dev.octoshrimpy.quik.receiver.MarkSeenReceiver
import dev.octoshrimpy.quik.receiver.RemoteMessagingReceiver
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver
import dev.octoshrimpy.quik.receiver.SendSmsReceiver
import dev.octoshrimpy.quik.repository.ContactRepository
import dev.octoshrimpy.quik.repository.ConversationRepository
import dev.octoshrimpy.quik.repository.MessageRepository
@@ -371,9 +372,29 @@ class NotificationManagerImpl @Inject constructor(
.addNextIntent(contentIntent)
val contentPI = taskStackBuilder.getPendingIntent(threadId.toInt(), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
//Action for resending a failed message
val resendIntent = Intent(context, SendSmsReceiver::class.java).apply {
putExtra("id", message.id)
}
val resendPendingIntent = PendingIntent.getBroadcast(
context,
message.id.toInt(),
resendIntent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val resendAction = NotificationCompat.Action.Builder(
R.drawable.ic_send_black_24dp,
context.getString(R.string.notification_message_failed_action),
resendPendingIntent
)
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_NONE)
.build()
val notification = NotificationCompat.Builder(context, getChannelIdForNotification(threadId))
.setContentTitle(context.getString(R.string.notification_message_failed_title))
.setContentText(context.getString(R.string.notification_message_failed_text, conversation.getTitle()))
.addAction(resendAction)
.setColor(colors.theme(lastRecipient).theme)
.setPriority(NotificationManagerCompat.IMPORTANCE_MAX)
.setSmallIcon(R.drawable.ic_notification_failed)
@@ -487,6 +487,7 @@
</plurals>
<string name="notification_message_failed_title">Message not sent</string>
<string name="notification_message_failed_text">The message to %s failed to send</string>
<string name="notification_message_failed_action">Resend</string>
<string-array name="night_modes">
<item>System</item>