mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Update shortcut drawable to use content id.
This commit is contained in:
committed by
Nicholas Tinsley
parent
9337201ffb
commit
6d4b487428
@@ -114,22 +114,8 @@ public final class AvatarUtil {
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static @NonNull IconCompat getIconCompatForShortcut(@NonNull Context context, @NonNull Recipient recipient) {
|
||||
try {
|
||||
GlideRequest<Bitmap> glideRequest = GlideApp.with(context).asBitmap().load(new ConversationShortcutPhoto(recipient));
|
||||
if (recipient.shouldBlurAvatar()) {
|
||||
glideRequest = glideRequest.transform(new BlurTransformation(context, 0.25f, BlurTransformation.MAX_RADIUS));
|
||||
}
|
||||
return IconCompat.createWithAdaptiveBitmap(glideRequest.submit().get());
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
Log.w(TAG, "Failed to generate shortcut icon for recipient " + recipient.getId() + ". Generating fallback.", e);
|
||||
|
||||
Drawable fallbackDrawable = getFallback(context, recipient, DrawableUtil.SHORTCUT_INFO_WRAPPED_SIZE);
|
||||
Bitmap fallbackBitmap = DrawableUtil.toBitmap(fallbackDrawable, DrawableUtil.SHORTCUT_INFO_WRAPPED_SIZE, DrawableUtil.SHORTCUT_INFO_WRAPPED_SIZE);
|
||||
Bitmap wrappedBitmap = DrawableUtil.wrapBitmapForShortcutInfo(fallbackBitmap);
|
||||
|
||||
return IconCompat.createWithAdaptiveBitmap(wrappedBitmap);
|
||||
}
|
||||
public static @NonNull IconCompat getIconCompatForShortcut(@NonNull Recipient recipient) {
|
||||
return getIconWithUriForNotification(recipient.getId());
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
@@ -223,7 +209,7 @@ public final class AvatarUtil {
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
Log.d(TAG, "AvatarTarget#onResourceReady:");
|
||||
Log.d(TAG, "AvatarTarget#onResourceReady: " + resource.getWidth() + ", " + resource.getHeight() + ", s:" + size);
|
||||
bitmap.set(resource);
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public final class ConversationUtil {
|
||||
.setIntent(ConversationIntents.createBuilderSync(context, resolved.getId(), threadId).build())
|
||||
.setShortLabel(shortName)
|
||||
.setLongLabel(longName)
|
||||
.setIcon(AvatarUtil.getIconCompatForShortcut(context, resolved))
|
||||
.setIcon(AvatarUtil.getIconCompatForShortcut(resolved))
|
||||
.setPersons(persons)
|
||||
.setCategories(Sets.newHashSet(CATEGORY_SHARE_TARGET))
|
||||
.setActivity(activity)
|
||||
|
||||
Reference in New Issue
Block a user