mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +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()
|
nameEditText.clearFocus()
|
||||||
nameTextViewContainer.visibility = View.VISIBLE
|
nameTextViewContainer.visibility = View.VISIBLE
|
||||||
nameEditContainer.visibility = View.INVISIBLE
|
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)
|
SSKEnvironment.shared.profileManager.setDisplayName(requireContext(), recipient, newNickName)
|
||||||
nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous"
|
nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous"
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import android.view.View
|
|||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import kotlinx.android.synthetic.main.view_conversation.view.*
|
import kotlinx.android.synthetic.main.view_conversation.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.utilities.SSKEnvironment
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||||
import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded
|
import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded
|
||||||
@ -56,7 +57,7 @@ class ConversationView : LinearLayout {
|
|||||||
}
|
}
|
||||||
profilePictureView.glide = glide
|
profilePictureView.glide = glide
|
||||||
profilePictureView.update(thread.recipient, thread.threadId)
|
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
|
btnGroupNameDisplay.text = senderDisplayName
|
||||||
timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date)
|
timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date)
|
||||||
muteIndicatorImageView.visibility = if (thread.recipient.isMuted) VISIBLE else GONE
|
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
|
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob
|
||||||
|
|
||||||
class ProfileManager: SSKEnvironment.ProfileManagerProtocol {
|
class ProfileManager: SSKEnvironment.ProfileManagerProtocol {
|
||||||
override fun setDisplayName(context: Context, recipient: Recipient, displayName: String) {
|
override fun setDisplayName(context: Context, recipient: Recipient, displayName: String?) {
|
||||||
val database = DatabaseFactory.getLokiUserDatabase(context)
|
|
||||||
val sessionID = recipient.address.serialize()
|
val sessionID = recipient.address.serialize()
|
||||||
database.setDisplayName(sessionID, displayName)
|
|
||||||
// New API
|
// New API
|
||||||
val contactDatabase = DatabaseFactory.getSessionContactDatabase(context)
|
val contactDatabase = DatabaseFactory.getSessionContactDatabase(context)
|
||||||
var contact = contactDatabase.getContactWithSessionID(sessionID)
|
var contact = contactDatabase.getContactWithSessionID(sessionID)
|
||||||
@ -21,6 +19,10 @@ class ProfileManager: SSKEnvironment.ProfileManagerProtocol {
|
|||||||
contact.nickname = displayName
|
contact.nickname = displayName
|
||||||
contactDatabase.setContact(contact)
|
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) {
|
override fun setProfileName(context: Context, recipient: Recipient, profileName: String) {
|
||||||
|
@ -30,7 +30,7 @@ class SSKEnvironment(
|
|||||||
const val NAME_PADDED_LENGTH = 26
|
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 setProfileName(context: Context, recipient: Recipient, profileName: String)
|
||||||
fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String)
|
fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String)
|
||||||
fun setProfileKey(context: Context, recipient: Recipient, profileKey: ByteArray)
|
fun setProfileKey(context: Context, recipient: Recipient, profileKey: ByteArray)
|
||||||
|
Loading…
Reference in New Issue
Block a user