mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 18:28:26 +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)
|
?.downloadOpenGroupAvatar(server, info.profilePictureURL)
|
||||||
avatar = BitmapUtil.fromByteArray(avatarBytes)
|
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)
|
val result = GroupManager.createOpenGroup(chat.id, context, avatar, chat.displayName)
|
||||||
threadID = result.threadId
|
threadID = result.threadId
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,7 @@ class ProfilePictureView : RelativeLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun isOpenGroupWithAvatar(recipient: Recipient): Boolean {
|
fun isOpenGroupWithAvatar(recipient: Recipient): Boolean {
|
||||||
return recipient.isOpenGroupRecipient &&
|
return recipient.isOpenGroupRecipient && recipient.groupAvatarId != null
|
||||||
DatabaseFactory.getGroupDatabase(context).hasAvatar(recipient.address.toString())
|
|
||||||
}
|
}
|
||||||
if (recipient.isGroupRecipient && !isOpenGroupWithAvatar(recipient)) {
|
if (recipient.isGroupRecipient && !isOpenGroupWithAvatar(recipient)) {
|
||||||
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
||||||
|
@ -84,13 +84,17 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
ContactPhoto contactPhoto = recipient.getContactPhoto();
|
ContactPhoto contactPhoto = recipient.getContactPhoto();
|
||||||
if (contactPhoto != null) {
|
if (contactPhoto != null) {
|
||||||
try {
|
try {
|
||||||
setLargeIcon(GlideApp.with(context.getApplicationContext())
|
// AC: For some reason, if not use ".asBitmap()" method, the returned BitmapDrawable
|
||||||
.load(contactPhoto)
|
// wraps a recycled bitmap and leads to a crash.
|
||||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
Bitmap iconBitmap = GlideApp.with(context.getApplicationContext())
|
||||||
.circleCrop()
|
.asBitmap()
|
||||||
.submit(context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
|
.load(contactPhoto)
|
||||||
context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height))
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
.get());
|
.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) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
setLargeIcon(getPlaceholderDrawable(context, recipient));
|
setLargeIcon(getPlaceholderDrawable(context, recipient));
|
||||||
|
@ -509,6 +509,11 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
if (notify) notifyListeners();
|
if (notify) notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public synchronized Long getGroupAvatarId() {
|
||||||
|
return groupAvatarId;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized @Nullable Uri getMessageRingtone() {
|
public synchronized @Nullable Uri getMessageRingtone() {
|
||||||
if (messageRingtone != null && messageRingtone.getScheme() != null && messageRingtone.getScheme().startsWith("file")) {
|
if (messageRingtone != null && messageRingtone.getScheme() != null && messageRingtone.getScheme().startsWith("file")) {
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user