diff --git a/src/org/thoughtcrime/securesms/loki/FriendRequestView.kt b/src/org/thoughtcrime/securesms/loki/FriendRequestView.kt index 925124de3e..aa1909ec77 100644 --- a/src/org/thoughtcrime/securesms/loki/FriendRequestView.kt +++ b/src/org/thoughtcrime/securesms/loki/FriendRequestView.kt @@ -87,6 +87,7 @@ class FriendRequestView(context: Context, attrs: AttributeSet?, defStyleAttr: In private fun updateUI() { val database = DatabaseFactory.getLokiMessageFriendRequestDatabase(context) val contactID = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(message!!.threadId)!!.address.toString() + val contactDisplayName = DatabaseFactory.getLokiUserDisplayNameDatabase(context).getDisplayName(contactID) ?: contactID if (!message!!.isOutgoing) { val friendRequestStatus = database.getFriendRequestStatus(message!!.id) visibility = if (friendRequestStatus == LokiMessageFriendRequestStatus.NONE) View.GONE else View.VISIBLE @@ -98,7 +99,7 @@ class FriendRequestView(context: Context, attrs: AttributeSet?, defStyleAttr: In LokiMessageFriendRequestStatus.REQUEST_REJECTED -> R.string.view_friend_request_incoming_declined_message LokiMessageFriendRequestStatus.REQUEST_EXPIRED -> R.string.view_friend_request_incoming_expired_message } - label.text = resources.getString(formatID, contactID) + label.text = resources.getString(formatID, contactDisplayName) } else { val friendRequestStatus = database.getFriendRequestStatus(message!!.id) visibility = if (friendRequestStatus == LokiMessageFriendRequestStatus.NONE) View.GONE else View.VISIBLE @@ -111,7 +112,7 @@ class FriendRequestView(context: Context, attrs: AttributeSet?, defStyleAttr: In LokiMessageFriendRequestStatus.REQUEST_EXPIRED -> R.string.view_friend_request_outgoing_expired_message } if (formatID != null) { - label.text = resources.getString(formatID, contactID) + label.text = resources.getString(formatID, contactDisplayName) } label.visibility = if (formatID != null) View.VISIBLE else View.GONE topSpacer.visibility = label.visibility diff --git a/src/org/thoughtcrime/securesms/loki/LokiUserDisplayNameDatabase.kt b/src/org/thoughtcrime/securesms/loki/LokiUserDisplayNameDatabase.kt index 2c3b16ac61..53117ca59d 100644 --- a/src/org/thoughtcrime/securesms/loki/LokiUserDisplayNameDatabase.kt +++ b/src/org/thoughtcrime/securesms/loki/LokiUserDisplayNameDatabase.kt @@ -2,8 +2,10 @@ package org.thoughtcrime.securesms.loki import android.content.ContentValues import android.content.Context +import org.thoughtcrime.securesms.database.Address import org.thoughtcrime.securesms.database.Database import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper +import org.thoughtcrime.securesms.recipients.Recipient class LokiUserDisplayNameDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) { @@ -27,5 +29,6 @@ class LokiUserDisplayNameDatabase(context: Context, helper: SQLCipherOpenHelper) row.put(Companion.hexEncodedPublicKey, hexEncodedPublicKey) row.put(Companion.displayName, displayName) database.insertOrUpdate(tableName, row, "${Companion.hexEncodedPublicKey} = ?", arrayOf( hexEncodedPublicKey )) + Recipient.from(context, Address.fromSerialized(hexEncodedPublicKey), false).notifyListeners() } } \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index 52d51ed775..f12619d948 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -697,7 +697,7 @@ public class Recipient implements RecipientModifiedListener { return this.address.hashCode(); } - private void notifyListeners() { + public void notifyListeners() { Set localListeners; synchronized (this) {