mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Observe display name changes
This commit is contained in:
parent
956f20fc0e
commit
c0a9500706
@ -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
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
@ -697,7 +697,7 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return this.address.hashCode();
|
||||
}
|
||||
|
||||
private void notifyListeners() {
|
||||
public void notifyListeners() {
|
||||
Set<RecipientModifiedListener> localListeners;
|
||||
|
||||
synchronized (this) {
|
||||
|
Loading…
Reference in New Issue
Block a user