mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-18 14:42:16 +03:00
Merge pull request #4494 from nextcloud/bugfix/noid/fixEmailGuestWhitspaces
Bugfix/noid/fix email guest whitspaces
This commit is contained in:
commit
4cffb5b8e4
12 changed files with 59 additions and 48 deletions
|
@ -148,7 +148,7 @@ public class ParticipantsAdapter extends BaseAdapter {
|
|||
participantDisplayItem.getActorType() == Participant.ActorType.EMAILS) {
|
||||
ImageViewExtensionsKt.loadFirstLetterAvatar(
|
||||
imageView,
|
||||
String.valueOf(participantDisplayItem.getNick().charAt(0))
|
||||
String.valueOf(participantDisplayItem.getNick())
|
||||
);
|
||||
} else {
|
||||
ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar());
|
||||
|
|
|
@ -20,6 +20,7 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.adapters.items.ConversationItem.ConversationItemViewHolder
|
||||
import com.nextcloud.talk.adapters.messages.MessagePayload
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
import com.nextcloud.talk.chat.data.model.ChatMessage.MessageType
|
||||
import com.nextcloud.talk.data.database.mappers.asModel
|
||||
|
@ -249,14 +250,15 @@ class ConversationItem(
|
|||
} else if (model.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
|
||||
lastMessageDisplayText
|
||||
} else {
|
||||
val authorDisplayName =
|
||||
if (!TextUtils.isEmpty(chatMessage?.actorDisplayName)) {
|
||||
chatMessage?.actorDisplayName
|
||||
} else if ("guests" == chatMessage?.actorType) {
|
||||
appContext.getString(R.string.nc_guest)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
val actorName = chatMessage?.actorDisplayName
|
||||
val authorDisplayName = if (!actorName.isNullOrBlank()) {
|
||||
actorName
|
||||
} else if ("guests" == chatMessage?.actorType || "emails" == chatMessage?.actorType) {
|
||||
appContext.getString(R.string.nc_guest)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
String.format(
|
||||
appContext.getString(R.string.nc_formatted_message),
|
||||
authorDisplayName,
|
||||
|
|
|
@ -16,6 +16,7 @@ import androidx.core.content.res.ResourcesCompat
|
|||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.adapters.items.ParticipantItem.ParticipantItemViewHolder
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.extensions.loadDefaultAvatar
|
||||
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
||||
import com.nextcloud.talk.extensions.loadGuestAvatar
|
||||
import com.nextcloud.talk.extensions.loadUserAvatar
|
||||
|
@ -56,7 +57,15 @@ class MentionAutocompleteItem(
|
|||
init {
|
||||
mentionId = mention.mentionId
|
||||
objectId = mention.id
|
||||
displayName = mention.label
|
||||
|
||||
displayName = if (!mention.label.isNullOrBlank()) {
|
||||
mention.label
|
||||
} else if ("guests" == mention.source || "emails" == mention.source) {
|
||||
context.resources.getString(R.string.nc_guest)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
source = mention.source
|
||||
status = mention.status
|
||||
statusIcon = mention.statusIcon
|
||||
|
@ -149,7 +158,11 @@ class MentionAutocompleteItem(
|
|||
|
||||
SOURCE_GUESTS, SOURCE_EMAILS -> {
|
||||
avatarId = displayName
|
||||
holder.binding.avatarView.loadGuestAvatar(currentUser, avatarId!!, false)
|
||||
if (displayName.equals(context.resources.getString(R.string.nc_guest))) {
|
||||
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
|
||||
} else {
|
||||
holder.binding.avatarView.loadGuestAvatar(currentUser, avatarId!!, false)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
|
|
@ -85,6 +85,10 @@ class ParticipantItem(
|
|||
setOnlineStateColor(holder)
|
||||
holder.binding.nameText.text = model.displayName
|
||||
|
||||
if (model.type == Participant.ParticipantType.GUEST && model.displayName.isNullOrBlank()) {
|
||||
holder.binding.nameText.text = sharedApplication!!.getString(R.string.nc_guest)
|
||||
}
|
||||
|
||||
if (adapter!!.hasFilter()) {
|
||||
viewThemeUtils.talk.themeAndHighlightText(
|
||||
holder.binding.nameText,
|
||||
|
@ -211,12 +215,11 @@ class ParticipantItem(
|
|||
}
|
||||
|
||||
Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> {
|
||||
if (model.displayName.isNullOrEmpty()) {
|
||||
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
|
||||
val actorName = model.displayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
holder.binding.avatarView.loadFirstLetterAvatar(actorName)
|
||||
} else {
|
||||
holder.binding.avatarView.loadFirstLetterAvatar(
|
||||
model.displayName!!.first().toString()
|
||||
)
|
||||
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,10 +157,10 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold
|
|||
}
|
||||
|
||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||
val author: String = message.actorDisplayName!!
|
||||
if (!TextUtils.isEmpty(author)) {
|
||||
val actorName = message.actorDisplayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageAuthor.text = actorName
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
|
|
|
@ -135,10 +135,10 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
|
|||
}
|
||||
|
||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||
val author: String = message.actorDisplayName!!
|
||||
if (!TextUtils.isEmpty(author)) {
|
||||
val actorName = message.actorDisplayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageAuthor.text = actorName
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.nextcloud.talk.extensions.loadChangelogBotAvatar
|
|||
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ChatMessageUtils
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
import com.nextcloud.talk.utils.UriUtils
|
||||
import com.nextcloud.talk.utils.message.MessageUtils
|
||||
|
@ -119,10 +120,10 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
|||
}
|
||||
|
||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||
val author: String = message.actorDisplayName!!
|
||||
if (!TextUtils.isEmpty(author)) {
|
||||
val actorName = message.actorDisplayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageAuthor.text = actorName
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
|
@ -131,16 +132,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
|||
}
|
||||
|
||||
if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
|
||||
binding.messageUserAvatar.visibility = View.VISIBLE
|
||||
if (message.actorType == "guests") {
|
||||
// do nothing, avatar is set
|
||||
} else if (message.actorType == "bots" && message.actorId == "changelog") {
|
||||
binding.messageUserAvatar.loadChangelogBotAvatar()
|
||||
} else if (message.actorType == "bots") {
|
||||
binding.messageUserAvatar.loadBotsAvatar()
|
||||
} else if (message.actorType == "federated_users") {
|
||||
binding.messageUserAvatar.loadFederatedUserAvatar(message)
|
||||
}
|
||||
ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
|
||||
} else {
|
||||
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
|
||||
binding.messageUserAvatar.visibility = View.GONE
|
||||
|
|
|
@ -142,10 +142,10 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
|
|||
}
|
||||
|
||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||
val author: String = message.actorDisplayName!!
|
||||
if (!TextUtils.isEmpty(author)) {
|
||||
val actorName = message.actorDisplayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageAuthor.text = actorName
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
|
|
|
@ -144,10 +144,10 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
|||
}
|
||||
|
||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||
val author: String = message.actorDisplayName!!
|
||||
if (!TextUtils.isEmpty(author)) {
|
||||
val actorName = message.actorDisplayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageAuthor.text = actorName
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
|
|
|
@ -238,10 +238,10 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
|
|||
}
|
||||
|
||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||
val author: String = message.actorDisplayName!!
|
||||
if (!TextUtils.isEmpty(author)) {
|
||||
val actorName = message.actorDisplayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageAuthor.text = actorName
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
|
|
|
@ -305,10 +305,10 @@ fun ImageView.loadNoteToSelfAvatar(): io.reactivex.disposables.Disposable {
|
|||
)
|
||||
}
|
||||
|
||||
fun ImageView.loadFirstLetterAvatar(letter: String): io.reactivex.disposables.Disposable {
|
||||
fun ImageView.loadFirstLetterAvatar(name: String): io.reactivex.disposables.Disposable {
|
||||
val layers = arrayOfNulls<Drawable>(2)
|
||||
layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
|
||||
layers[1] = createTextDrawable(context, letter.uppercase(Locale.ROOT))
|
||||
layers[1] = createTextDrawable(context, name.trimStart().uppercase(Locale.ROOT))
|
||||
|
||||
val layerDrawable = LayerDrawable(layers)
|
||||
val data: Any = layerDrawable
|
||||
|
|
|
@ -21,8 +21,9 @@ class ChatMessageUtils {
|
|||
fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils : ViewThemeUtils) {
|
||||
view.visibility = View.VISIBLE
|
||||
if (message.actorType == "guests" || message.actorType == "emails") {
|
||||
if (message.actorDisplayName?.isNotEmpty() == true) {
|
||||
view.loadFirstLetterAvatar(message.actorDisplayName?.first().toString())
|
||||
val actorName = message.actorDisplayName
|
||||
if (!actorName.isNullOrBlank()) {
|
||||
view.loadFirstLetterAvatar(actorName)
|
||||
} else {
|
||||
view.loadDefaultAvatar(viewThemeUtils)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue