mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
General cleanup
Fixed a bug where open groups were incorrectly displaying closed group avatar images Removed some commented out code
This commit is contained in:
parent
cc5c63b211
commit
a2fcb3195d
@ -34,6 +34,8 @@ class ProfilePictureView @JvmOverloads constructor(
|
||||
private val profilePicturesCache = mutableMapOf<String, String?>()
|
||||
private val unknownRecipientDrawable = ResourceContactPhoto(R.drawable.ic_profile_default)
|
||||
.asDrawable(context, ContactColors.UNKNOWN_COLOR.toConversationColor(context), false)
|
||||
private val unknownOpenGroupDrawable = ResourceContactPhoto(R.drawable.ic_notification)
|
||||
.asDrawable(context, ContactColors.UNKNOWN_COLOR.toConversationColor(context), false)
|
||||
|
||||
// endregion
|
||||
|
||||
@ -43,10 +45,8 @@ class ProfilePictureView @JvmOverloads constructor(
|
||||
val contact = DatabaseComponent.get(context).sessionContactDatabase().getContactWithSessionID(publicKey)
|
||||
return contact?.displayName(Contact.ContactContext.REGULAR) ?: publicKey
|
||||
}
|
||||
fun isOpenGroupWithProfilePicture(recipient: Recipient): Boolean {
|
||||
return recipient.isOpenGroupRecipient && recipient.groupAvatarId != null
|
||||
}
|
||||
if (recipient.isGroupRecipient && !isOpenGroupWithProfilePicture(recipient)) {
|
||||
|
||||
if (recipient.isClosedGroupRecipient) {
|
||||
val members = DatabaseComponent.get(context).groupDatabase()
|
||||
.getGroupMemberAddresses(recipient.address.toGroupString(), true)
|
||||
.sorted()
|
||||
@ -107,7 +107,7 @@ class ProfilePictureView @JvmOverloads constructor(
|
||||
if (profilePicturesCache.containsKey(publicKey) && profilePicturesCache[publicKey] == recipient.profileAvatar) return
|
||||
val signalProfilePicture = recipient.contactPhoto
|
||||
val avatar = (signalProfilePicture as? ProfileContactPhoto)?.avatarObject
|
||||
val placeholder = PlaceholderAvatarPhoto(context, publicKey, displayName ?: "${publicKey.take(4)}...${publicKey.takeLast(4)}")
|
||||
|
||||
if (signalProfilePicture != null && avatar != "0" && avatar != "") {
|
||||
glide.clear(imageView)
|
||||
glide.load(signalProfilePicture)
|
||||
@ -117,7 +117,12 @@ class ProfilePictureView @JvmOverloads constructor(
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.circleCrop()
|
||||
.into(imageView)
|
||||
} else if (recipient.isOpenGroupRecipient && recipient.groupAvatarId == null) {
|
||||
glide.clear(imageView)
|
||||
imageView.setImageDrawable(unknownOpenGroupDrawable)
|
||||
} else {
|
||||
val placeholder = PlaceholderAvatarPhoto(context, publicKey, displayName ?: "${publicKey.take(4)}...${publicKey.takeLast(4)}")
|
||||
|
||||
glide.clear(imageView)
|
||||
glide.load(placeholder)
|
||||
.placeholder(unknownRecipientDrawable)
|
||||
|
@ -194,31 +194,4 @@ open class ThumbnailView: FrameLayout {
|
||||
|
||||
return future
|
||||
}
|
||||
|
||||
// fun showDownloadText(showDownloadText: Boolean) {
|
||||
// getTransferControls()?.setShowDownloadText(showDownloadText);
|
||||
// }
|
||||
//
|
||||
// fun setDownloadClickListener(listener: SlidesClickedListener) {
|
||||
// this.downloadClickListener = listener;
|
||||
// }
|
||||
//
|
||||
// private fun getTransferControls(): TransferControlView? {
|
||||
// if (transferControls == null) {
|
||||
// transferControls = ViewUtil.inflateStub(this, R.id.transfer_controls_stub);
|
||||
// }
|
||||
//
|
||||
// return transferControls
|
||||
// }
|
||||
// endregion
|
||||
|
||||
// private class DownloadClickDispatcher : OnClickListener {
|
||||
// override fun onClick(view: View?) {
|
||||
// if (downloadClickListener != null && slide != null) {
|
||||
// downloadClickListener.onClick(view, Collections.singletonList(slide))
|
||||
// } else {
|
||||
// Log.w(TAG, "Received a download button click, but unable to execute it. slide: " + String.valueOf(slide) + " downloadClickListener: " + String.valueOf(downloadClickListener))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user