Set LocusID on shortcut and notification for on device intelligence.

This commit is contained in:
Aaron Labiaga
2021-09-03 09:33:51 -04:00
committed by Alex Hart
parent 08a7da3339
commit b4465953d8
3 changed files with 24 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.core.app.NotificationCompat
import androidx.core.app.RemoteInput
import androidx.core.content.LocusIdCompat
import androidx.core.graphics.drawable.IconCompat
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.conversation.ConversationIntents
@@ -70,6 +71,7 @@ sealed class NotificationBuilder(protected val context: Context) {
abstract fun setTicker(ticker: CharSequence?)
abstract fun addTurnOffJoinedNotificationsAction(pendingIntent: PendingIntent)
abstract fun setAutoCancel(autoCancel: Boolean)
abstract fun setLocusIdActual(locusId: String)
abstract fun build(): Notification
protected abstract fun addPersonActual(recipient: Recipient)
@@ -87,6 +89,12 @@ sealed class NotificationBuilder(protected val context: Context) {
}
}
fun setLocusId(locusId: String) {
if (privacy.isDisplayContact && isNotLocked) {
setLocusIdActual(locusId)
}
}
fun setShortcutId(shortcutId: String) {
if (privacy.isDisplayContact && isNotLocked) {
setShortcutIdActual(shortcutId)
@@ -453,6 +461,10 @@ sealed class NotificationBuilder(protected val context: Context) {
override fun setSubText(subText: String) {
builder.setSubText(subText)
}
override fun setLocusIdActual(locusId: String) {
builder.setLocusId(LocusIdCompat(locusId))
}
}
}

View File

@@ -188,6 +188,7 @@ object NotificationFactory {
setLargeIcon(conversation.getContactLargeIcon(context).toLargeBitmap(context))
addPerson(conversation.recipient)
setShortcutId(ConversationUtil.getShortcutId(conversation.recipient))
setLocusId(ConversationUtil.getShortcutId(conversation.recipient))
setContentInfo(conversation.messageCount.toString())
setNumber(conversation.messageCount)
setContentText(conversation.getContentText(context))
@@ -368,6 +369,7 @@ object NotificationFactory {
setLargeIcon(conversation.getContactLargeIcon(context).toLargeBitmap(context))
addPerson(conversation.recipient)
setShortcutId(ConversationUtil.getShortcutId(conversation.recipient))
setLocusId(ConversationUtil.getShortcutId(conversation.recipient))
addMessages(conversation)
setBubbleMetadata(conversation, BubbleUtil.BubbleState.SHOWN)
}