mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-12 10:37:44 +00:00
Clean
This commit is contained in:
@@ -3,28 +3,44 @@ package org.session.libsession.messaging.contacts
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
|
||||
class Contact(val sessionID: String) {
|
||||
// The URL from which to fetch the contact's profile picture.
|
||||
/**
|
||||
* The URL from which to fetch the contact's profile picture.
|
||||
*/
|
||||
var profilePictureURL: String? = null
|
||||
// The file name of the contact's profile picture on local storage.
|
||||
/**
|
||||
* The file name of the contact's profile picture on local storage.
|
||||
*/
|
||||
var profilePictureFileName: String? = null
|
||||
// The key with which the profile picture is encrypted.
|
||||
/**
|
||||
* The key with which the profile picture is encrypted.
|
||||
*/
|
||||
var profilePictureEncryptionKey: ByteArray? = null
|
||||
// The ID of the thread associated with this contact.
|
||||
/**
|
||||
* The ID of the thread associated with this contact.
|
||||
*/
|
||||
var threadID: Long? = null
|
||||
// This flag is used to determine whether we should auto-download files sent by this contact.
|
||||
/**
|
||||
* This flag is used to determine whether we should auto-download files sent by this contact.
|
||||
*/
|
||||
var isTrusted = false
|
||||
|
||||
// region: Name
|
||||
// The name of the contact. Use this whenever you need the "real", underlying name of a user (e.g. when sending a message).
|
||||
// region Name
|
||||
/**
|
||||
* The name of the contact. Use this whenever you need the "real", underlying name of a user (e.g. when sending a message).
|
||||
*/
|
||||
var name: String? = null
|
||||
// The contact's nickname, if the user set one.
|
||||
/**
|
||||
* The contact's nickname, if the user set one.
|
||||
*/
|
||||
var nickname: String? = null
|
||||
// The name to display in the UI. For local use only.
|
||||
/**
|
||||
* The name to display in the UI. For local use only.
|
||||
*/
|
||||
fun displayName(context: ContactContext): String? {
|
||||
this.nickname?.let { return it }
|
||||
return when {
|
||||
context == ContactContext.REGULAR -> this.name
|
||||
context == ContactContext.OPEN_GROUP -> {
|
||||
return when (context) {
|
||||
ContactContext.REGULAR -> this.name
|
||||
ContactContext.OPEN_GROUP -> {
|
||||
// In open groups, where it's more likely that multiple users have the same name,
|
||||
// we display a bit of the Session ID after a user's display name for added context.
|
||||
this.name?.let {
|
||||
@@ -32,10 +48,9 @@ class Contact(val sessionID: String) {
|
||||
}
|
||||
return null
|
||||
}
|
||||
else -> throw Exception("Unknown contact context!")
|
||||
}
|
||||
}
|
||||
//end region
|
||||
// endregion
|
||||
|
||||
enum class ContactContext {
|
||||
REGULAR, OPEN_GROUP
|
||||
@@ -48,11 +63,7 @@ class Contact(val sessionID: String) {
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return if (other is Contact) {
|
||||
other.sessionID == this.sessionID
|
||||
} else {
|
||||
false
|
||||
}
|
||||
return this.sessionID == (other as? Contact)?.sessionID
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
@@ -64,9 +75,13 @@ class Contact(val sessionID: String) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun contextForRecipient(recipient: Recipient): ContactContext {
|
||||
return if (recipient.isOpenGroupRecipient) { ContactContext.OPEN_GROUP }
|
||||
else { ContactContext.REGULAR }
|
||||
return if (recipient.isOpenGroupRecipient) {
|
||||
ContactContext.OPEN_GROUP
|
||||
} else {
|
||||
ContactContext.REGULAR
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,7 +30,6 @@ class SSKEnvironment(
|
||||
}
|
||||
|
||||
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)
|
||||
fun setUnidentifiedAccessMode(context: Context, recipient: Recipient, unidentifiedAccessMode: Recipient.UnidentifiedAccessMode)
|
||||
|
Reference in New Issue
Block a user