diff --git a/res/layout/conversation_activity.xml b/res/layout/conversation_activity.xml index 5a3f3aaed3..eb4c4891a9 100644 --- a/res/layout/conversation_activity.xml +++ b/res/layout/conversation_activity.xml @@ -20,9 +20,15 @@ android:gravity="center_vertical" android:orientation="horizontal"> + + { Log.i(TAG, "onModifiedRun(): " + recipient.getRegistered()); updateTitleTextView(recipient); + updateProfilePicture(); updateSubtitleTextView(); // titleView.setVerified(identityRecords.isVerified()); updateInputUI(recipient, isSecureText, isDefaultSms); @@ -3100,6 +3107,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } } + private void updateProfilePicture() { + profilePictureView.glide = GlideApp.with(this); + profilePictureView.update(recipient, threadId); + } + private void updateSubtitleTextView() { muteIndicatorImageView.setVisibility(View.GONE); subtitleTextView.setVisibility(View.VISIBLE); diff --git a/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt b/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt index 382ac63a84..ebc6c679be 100644 --- a/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt +++ b/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt @@ -55,30 +55,8 @@ class ConversationView : LinearLayout { accentView.setBackgroundResource(R.color.accent) accentView.visibility = if (thread.unreadCount > 0) View.VISIBLE else View.INVISIBLE } - if (thread.recipient.isGroupRecipient) { - if ("Session Public Chat" == thread.recipient.name) { - profilePictureView.publicKey = "" - profilePictureView.additionalPublicKey = null - profilePictureView.isRSSFeed = true - } else { - val users = MentionsManager.shared.userPublicKeyCache[thread.threadId]?.toMutableList() ?: mutableListOf() - users.remove(TextSecurePreferences.getLocalNumber(context)) - val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context) - if (masterPublicKey != null) { - users.remove(masterPublicKey) - } - val randomUsers = users.sorted() // Sort to provide a level of stability - profilePictureView.publicKey = randomUsers.getOrNull(0) ?: "" - profilePictureView.additionalPublicKey = randomUsers.getOrNull(1) ?: "" - profilePictureView.isRSSFeed = thread.recipient.name == "Loki News" || thread.recipient.name == "Session Updates" - } - } else { - profilePictureView.publicKey = thread.recipient.address.toString() - profilePictureView.additionalPublicKey = null - profilePictureView.isRSSFeed = false - } profilePictureView.glide = glide - profilePictureView.update() + profilePictureView.update(thread.recipient, thread.threadId) val senderDisplayName = if (thread.recipient.isLocalNumber) context.getString(R.string.note_to_self) else if (!thread.recipient.name.isNullOrEmpty()) thread.recipient.name else thread.recipient.address.toString() btnGroupNameDisplay.text = senderDisplayName timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date) diff --git a/src/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt b/src/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt index 362f5ff35d..de93c4b81d 100644 --- a/src/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt +++ b/src/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt @@ -8,6 +8,7 @@ import android.view.View import android.widget.ImageView import android.widget.RelativeLayout import com.bumptech.glide.load.engine.DiskCacheStrategy +import kotlinx.android.synthetic.main.view_conversation.view.* import kotlinx.android.synthetic.main.view_profile_picture.view.* import network.loki.messenger.R import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto @@ -16,6 +17,7 @@ import org.thoughtcrime.securesms.loki.todo.JazzIdenticonDrawable import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.util.TextSecurePreferences +import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager // TODO: Look into a better way of handling different sizes. Maybe an enum (with associated values) encapsulating the different modes? @@ -51,6 +53,32 @@ class ProfilePictureView : RelativeLayout { // endregion // region Updating + fun update(recipient: Recipient, threadID: Long) { + if (recipient.isGroupRecipient) { + if ("Session Public Chat" == recipient.name) { + publicKey = "" + additionalPublicKey = null + isRSSFeed = true + } else { + val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf() + users.remove(TextSecurePreferences.getLocalNumber(context)) + val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context) + if (masterPublicKey != null) { + users.remove(masterPublicKey) + } + val randomUsers = users.sorted() // Sort to provide a level of stability + publicKey = randomUsers.getOrNull(0) ?: "" + additionalPublicKey = randomUsers.getOrNull(1) ?: "" + isRSSFeed = recipient.name == "Loki News" || recipient.name == "Session Updates" + } + } else { + publicKey = recipient.address.toString() + additionalPublicKey = null + isRSSFeed = false + } + update() + } + fun update() { val publicKey = publicKey ?: return val additionalPublicKey = additionalPublicKey