kopia lustrzana https://github.com/ryukoposting/Signal-Android
Set LocusID on shortcut and notification for on device intelligence.
rodzic
08a7da3339
commit
b4465953d8
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import androidx.core.app.Person;
|
||||
import androidx.core.content.LocusIdCompat;
|
||||
import androidx.core.content.pm.ShortcutInfoCompat;
|
||||
import androidx.core.content.pm.ShortcutManagerCompat;
|
||||
|
||||
|
@ -193,13 +194,14 @@ public final class ConversationUtil {
|
|||
@NonNull Recipient recipient,
|
||||
int rank)
|
||||
{
|
||||
Recipient resolved = recipient.resolve();
|
||||
Person[] persons = buildPersons(context, resolved);
|
||||
Long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(resolved.getId());
|
||||
String shortName = resolved.isSelf() ? context.getString(R.string.note_to_self) : resolved.getShortDisplayName(context);
|
||||
String longName = resolved.isSelf() ? context.getString(R.string.note_to_self) : resolved.getDisplayName(context);
|
||||
|
||||
return new ShortcutInfoCompat.Builder(context, getShortcutId(resolved))
|
||||
Recipient resolved = recipient.resolve();
|
||||
Person[] persons = buildPersons(context, resolved);
|
||||
Long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(resolved.getId());
|
||||
String shortName = resolved.isSelf() ? context.getString(R.string.note_to_self) : resolved.getShortDisplayName(context);
|
||||
String longName = resolved.isSelf() ? context.getString(R.string.note_to_self) : resolved.getDisplayName(context);
|
||||
String shortcutId = getShortcutId(resolved);
|
||||
|
||||
return new ShortcutInfoCompat.Builder(context, shortcutId)
|
||||
.setLongLived(true)
|
||||
.setIntent(ConversationIntents.createBuilder(context, resolved.getId(), threadId != null ? threadId : -1).build())
|
||||
.setShortLabel(shortName)
|
||||
|
@ -209,6 +211,7 @@ public final class ConversationUtil {
|
|||
.setCategories(Collections.singleton(CATEGORY_SHARE_TARGET))
|
||||
.setActivity(new ComponentName(context, "org.thoughtcrime.securesms.RoutingActivity"))
|
||||
.setRank(rank)
|
||||
.setLocusId(new LocusIdCompat(shortcutId))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue