mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
make editting nickname work
This commit is contained in:
parent
b43000bdd0
commit
4c63b724ee
@ -49,7 +49,10 @@ public class UserDetailsBottomSheet : BottomSheetDialogFragment() {
|
||||
nameEditText.clearFocus()
|
||||
nameTextViewContainer.visibility = View.VISIBLE
|
||||
nameEditContainer.visibility = View.INVISIBLE
|
||||
var newNickName = null
|
||||
var newNickName: String? = null
|
||||
if (!nameEditText.text.isEmpty()) {
|
||||
newNickName = nameEditText.text.toString()
|
||||
}
|
||||
SSKEnvironment.shared.profileManager.setDisplayName(requireContext(), recipient, newNickName)
|
||||
nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous"
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import kotlinx.android.synthetic.main.view_conversation.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.SSKEnvironment
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||
import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded
|
||||
@ -56,7 +57,7 @@ class ConversationView : LinearLayout {
|
||||
}
|
||||
profilePictureView.glide = glide
|
||||
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()
|
||||
val senderDisplayName = if (thread.recipient.isLocalNumber) context.getString(R.string.note_to_self) else SSKEnvironment.shared.profileManager.getDisplayName(context, thread.recipient) ?: thread.recipient.address.toString()
|
||||
btnGroupNameDisplay.text = senderDisplayName
|
||||
timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date)
|
||||
muteIndicatorImageView.visibility = if (thread.recipient.isMuted) VISIBLE else GONE
|
||||
|
@ -9,10 +9,8 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob
|
||||
|
||||
class ProfileManager: SSKEnvironment.ProfileManagerProtocol {
|
||||
override fun setDisplayName(context: Context, recipient: Recipient, displayName: String) {
|
||||
val database = DatabaseFactory.getLokiUserDatabase(context)
|
||||
override fun setDisplayName(context: Context, recipient: Recipient, displayName: String?) {
|
||||
val sessionID = recipient.address.serialize()
|
||||
database.setDisplayName(sessionID, displayName)
|
||||
// New API
|
||||
val contactDatabase = DatabaseFactory.getSessionContactDatabase(context)
|
||||
var contact = contactDatabase.getContactWithSessionID(sessionID)
|
||||
@ -21,6 +19,10 @@ class ProfileManager: SSKEnvironment.ProfileManagerProtocol {
|
||||
contact.nickname = displayName
|
||||
contactDatabase.setContact(contact)
|
||||
}
|
||||
// Old API
|
||||
if (displayName == null) return
|
||||
val database = DatabaseFactory.getLokiUserDatabase(context)
|
||||
database.setDisplayName(sessionID, displayName)
|
||||
}
|
||||
|
||||
override fun setProfileName(context: Context, recipient: Recipient, profileName: String) {
|
||||
|
@ -30,7 +30,7 @@ class SSKEnvironment(
|
||||
const val NAME_PADDED_LENGTH = 26
|
||||
}
|
||||
|
||||
fun setDisplayName(context: Context, recipient: Recipient, displayName: String) // Client-side Nickname
|
||||
fun setDisplayName(context: Context, recipient: Recipient, displayName: String?) // Client-side Nickname
|
||||
fun setProfileName(context: Context, recipient: Recipient, profileName: String)
|
||||
fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String)
|
||||
fun setProfileKey(context: Context, recipient: Recipient, profileKey: ByteArray)
|
||||
|
Loading…
Reference in New Issue
Block a user