mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Show mark read action on admin-only group notifications for non-admin members.
This commit is contained in:
committed by
Michelle Tang
parent
b677827c86
commit
db5cced91b
@@ -39,7 +39,7 @@ private const val BIG_PICTURE_DIMEN = 500
|
||||
|
||||
/**
|
||||
* Wraps the compat and OS versions of the Notification builders so we can more easily access native
|
||||
* features in newer versions. Also provides some domain specific helpers.
|
||||
* features in newer versions. Also provides some domain-specific helpers.
|
||||
*
|
||||
* Note: All business logic should exist in the base builder or the models that drive the notifications
|
||||
* like NotificationConversation and NotificationItemV2.
|
||||
@@ -66,7 +66,6 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
abstract fun setOnlyAlertOnce(onlyAlertOnce: Boolean)
|
||||
abstract fun setGroupSummary(isGroupSummary: Boolean)
|
||||
abstract fun setSubText(subText: String)
|
||||
abstract fun addMarkAsReadActionActual(state: NotificationState)
|
||||
abstract fun setPriority(priority: Int)
|
||||
abstract fun setAlarms(recipient: Recipient?)
|
||||
abstract fun setTicker(ticker: CharSequence?)
|
||||
@@ -79,6 +78,8 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
protected abstract fun setShortcutIdActual(shortcutId: String)
|
||||
protected abstract fun setWhen(timestamp: Long)
|
||||
protected abstract fun addActions(replyMethod: ReplyMethod, conversation: NotificationConversation)
|
||||
protected abstract fun addMarkAsReadActionActual(conversation: NotificationConversation)
|
||||
protected abstract fun addMarkAsReadActionActual(state: NotificationState)
|
||||
protected abstract fun addMessagesActual(conversation: NotificationConversation, includeShortcut: Boolean)
|
||||
protected abstract fun addMessagesActual(state: NotificationState)
|
||||
protected abstract fun setBubbleMetadataActual(conversation: NotificationConversation, bubbleState: BubbleUtil.BubbleState)
|
||||
@@ -119,6 +120,7 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
if (conversation.recipient.isPushV2Group) {
|
||||
val group: Optional<GroupRecord> = SignalDatabase.groups.getGroup(conversation.recipient.requireGroupId())
|
||||
if (group.isPresent && group.get().isAnnouncementGroup && !group.get().isAdmin(Recipient.self())) {
|
||||
addMarkAsReadAction(conversation)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -127,6 +129,12 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
fun addMarkAsReadAction(conversation: NotificationConversation) {
|
||||
if (privacy.isDisplayMessage && isNotLocked) {
|
||||
addMarkAsReadActionActual(conversation)
|
||||
}
|
||||
}
|
||||
|
||||
fun addMarkAsReadAction(state: NotificationState) {
|
||||
if (privacy.isDisplayMessage && isNotLocked) {
|
||||
addMarkAsReadActionActual(state)
|
||||
@@ -191,17 +199,7 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
override fun addActions(replyMethod: ReplyMethod, conversation: NotificationConversation) {
|
||||
val extender: NotificationCompat.WearableExtender = NotificationCompat.WearableExtender()
|
||||
|
||||
val markAsRead: PendingIntent? = conversation.getMarkAsReadIntent(context)
|
||||
if (markAsRead != null) {
|
||||
val markAsReadAction: NotificationCompat.Action =
|
||||
NotificationCompat.Action.Builder(R.drawable.symbol_check_24, context.getString(R.string.MessageNotifier_mark_read), markAsRead)
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
||||
.setShowsUserInterface(false)
|
||||
.build()
|
||||
|
||||
builder.addAction(markAsReadAction)
|
||||
extender.addAction(markAsReadAction)
|
||||
}
|
||||
addMarkAsReadActionActual(conversation)
|
||||
|
||||
if (conversation.mostRecentNotification.canReply(context)) {
|
||||
val quickReply: PendingIntent? = conversation.getQuickReplyIntent(context)
|
||||
@@ -235,6 +233,20 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
builder.extend(extender)
|
||||
}
|
||||
|
||||
override fun addMarkAsReadActionActual(conversation: NotificationConversation) {
|
||||
val markAsRead: PendingIntent? = conversation.getMarkAsReadIntent(context)
|
||||
if (markAsRead != null) {
|
||||
val markAsReadAction: NotificationCompat.Action =
|
||||
NotificationCompat.Action.Builder(R.drawable.symbol_check_24, context.getString(R.string.MessageNotifier_mark_read), markAsRead)
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
||||
.setShowsUserInterface(false)
|
||||
.build()
|
||||
|
||||
builder.addAction(markAsReadAction)
|
||||
builder.extend(NotificationCompat.WearableExtender().addAction(markAsReadAction))
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMarkAsReadActionActual(state: NotificationState) {
|
||||
val markAsRead: PendingIntent? = state.getMarkAsReadIntent(context)
|
||||
|
||||
@@ -369,6 +381,7 @@ sealed class NotificationBuilder(protected val context: Context) {
|
||||
builder.bubbleMetadata = bubbleMetadata
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLights(@ColorInt color: Int, onTime: Int, offTime: Int) {
|
||||
if (NotificationChannels.supported()) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user