mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Use a Bitmap instead of a BitmapDrawable for open group attachment notification icon.
This commit is contained in:
parent
7dffacf957
commit
f620d1cdb9
@ -79,8 +79,6 @@ class PublicChatManager(private val context: Context) {
|
||||
?.downloadOpenGroupAvatar(server, info.profilePictureURL)
|
||||
avatar = BitmapUtil.fromByteArray(avatarBytes)
|
||||
}
|
||||
// FIXME: If updating the avatar here, there can be a memory issue if a public chat message contains some attachment.
|
||||
// The error message is "Failed to execute task in background: Canvas: trying to use a recycled bitmap android.graphics.Bitmap"
|
||||
val result = GroupManager.createOpenGroup(chat.id, context, avatar, chat.displayName)
|
||||
threadID = result.threadId
|
||||
}
|
||||
|
@ -69,8 +69,7 @@ class ProfilePictureView : RelativeLayout {
|
||||
}
|
||||
}
|
||||
fun isOpenGroupWithAvatar(recipient: Recipient): Boolean {
|
||||
return recipient.isOpenGroupRecipient &&
|
||||
DatabaseFactory.getGroupDatabase(context).hasAvatar(recipient.address.toString())
|
||||
return recipient.isOpenGroupRecipient && recipient.groupAvatarId != null
|
||||
}
|
||||
if (recipient.isGroupRecipient && !isOpenGroupWithAvatar(recipient)) {
|
||||
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
||||
|
@ -84,13 +84,17 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
ContactPhoto contactPhoto = recipient.getContactPhoto();
|
||||
if (contactPhoto != null) {
|
||||
try {
|
||||
setLargeIcon(GlideApp.with(context.getApplicationContext())
|
||||
.load(contactPhoto)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.circleCrop()
|
||||
.submit(context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
|
||||
context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height))
|
||||
.get());
|
||||
// AC: For some reason, if not use ".asBitmap()" method, the returned BitmapDrawable
|
||||
// wraps a recycled bitmap and leads to a crash.
|
||||
Bitmap iconBitmap = GlideApp.with(context.getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(contactPhoto)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.circleCrop()
|
||||
.submit(context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
|
||||
context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height))
|
||||
.get();
|
||||
setLargeIcon(iconBitmap);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
Log.w(TAG, e);
|
||||
setLargeIcon(getPlaceholderDrawable(context, recipient));
|
||||
|
@ -509,6 +509,11 @@ public class Recipient implements RecipientModifiedListener {
|
||||
if (notify) notifyListeners();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public synchronized Long getGroupAvatarId() {
|
||||
return groupAvatarId;
|
||||
}
|
||||
|
||||
public synchronized @Nullable Uri getMessageRingtone() {
|
||||
if (messageRingtone != null && messageRingtone.getScheme() != null && messageRingtone.getScheme().startsWith("file")) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user