Search in sources :

Example 1 with LocusIdCompat

use of androidx.core.content.LocusIdCompat in project Signal-Android by WhisperSystems.

the class ConversationUtil method buildShortcutInfo.

/**
 * Builds the shortcut info object for a given Recipient.
 *
 * @param context   The Context under which we are operating
 * @param recipient The Recipient to generate a ShortcutInfo for
 * @param rank      The rank that should be assigned to this recipient
 * @return The new ShortcutInfo
 */
@WorkerThread
@NonNull
private static ShortcutInfoCompat buildShortcutInfo(@NonNull Context context, @NonNull Recipient recipient, int rank) {
    Recipient resolved = recipient.resolve();
    Person[] persons = buildPersons(context, resolved);
    Long threadId = SignalDatabase.threads().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).setLongLabel(longName).setIcon(AvatarUtil.getIconCompatForShortcut(context, resolved)).setPersons(persons).setCategories(Collections.singleton(CATEGORY_SHARE_TARGET)).setActivity(new ComponentName(context, "org.thoughtcrime.securesms.RoutingActivity")).setRank(rank).setLocusId(new LocusIdCompat(shortcutId)).build();
}
Also used : Recipient(org.thoughtcrime.securesms.recipients.Recipient) ComponentName(android.content.ComponentName) Person(androidx.core.app.Person) ShortcutInfoCompat(androidx.core.content.pm.ShortcutInfoCompat) LocusIdCompat(androidx.core.content.LocusIdCompat) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Aggregations

ComponentName (android.content.ComponentName)1 NonNull (androidx.annotation.NonNull)1 WorkerThread (androidx.annotation.WorkerThread)1 Person (androidx.core.app.Person)1 LocusIdCompat (androidx.core.content.LocusIdCompat)1 ShortcutInfoCompat (androidx.core.content.pm.ShortcutInfoCompat)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1