mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 12:35:17 +00:00
Fixed there's no label for the UserView's avatar placeholder.
This commit is contained in:
parent
f9b1166587
commit
b14cf5fcf8
@ -1,6 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.loki.views
|
package org.thoughtcrime.securesms.loki.views
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.text.TextUtils
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -8,6 +9,7 @@ import android.widget.LinearLayout
|
|||||||
import kotlinx.android.synthetic.main.view_conversation.view.profilePictureView
|
import kotlinx.android.synthetic.main.view_conversation.view.profilePictureView
|
||||||
import kotlinx.android.synthetic.main.view_user.view.*
|
import kotlinx.android.synthetic.main.view_user.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.groups.GroupManager
|
import org.thoughtcrime.securesms.groups.GroupManager
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
@ -56,16 +58,20 @@ class UserView : LinearLayout {
|
|||||||
profilePictureView.isRSSFeed = true
|
profilePictureView.isRSSFeed = true
|
||||||
} else {
|
} else {
|
||||||
val threadID = GroupManager.getThreadIDFromGroupID(address, context)
|
val threadID = GroupManager.getThreadIDFromGroupID(address, context)
|
||||||
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toList() ?: listOf()
|
val userKeys = MentionsManager.shared.userPublicKeyCache[threadID]?.toList() ?: listOf()
|
||||||
val randomUsers = users.sorted() // Sort to provide a level of stability
|
val sortedUserKeys = userKeys.sorted() // Sort to provide a level of stability
|
||||||
profilePictureView.publicKey = randomUsers.getOrNull(0) ?: ""
|
val userKey0 = sortedUserKeys.getOrNull(0) ?: ""
|
||||||
profilePictureView.displayName = null
|
val userKey1 = sortedUserKeys.getOrNull(1) ?: ""
|
||||||
profilePictureView.additionalPublicKey = randomUsers.getOrNull(1) ?: ""
|
|
||||||
|
profilePictureView.publicKey = userKey0
|
||||||
|
profilePictureView.displayName = getUserDisplayName(userKey0)
|
||||||
|
profilePictureView.additionalPublicKey = userKey1
|
||||||
|
profilePictureView.additionalDisplayName = getUserDisplayName(userKey1)
|
||||||
profilePictureView.isRSSFeed = false
|
profilePictureView.isRSSFeed = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
profilePictureView.publicKey = address
|
profilePictureView.publicKey = address
|
||||||
profilePictureView.displayName = null
|
profilePictureView.displayName = getUserDisplayName(address)
|
||||||
profilePictureView.additionalPublicKey = null
|
profilePictureView.additionalPublicKey = null
|
||||||
profilePictureView.isRSSFeed = false
|
profilePictureView.isRSSFeed = false
|
||||||
}
|
}
|
||||||
@ -87,5 +93,10 @@ class UserView : LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getUserDisplayName(publicKey: String?): String? {
|
||||||
|
if (TextUtils.isEmpty(publicKey)) return null
|
||||||
|
return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey!!)
|
||||||
|
}
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user