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) {
|
participantDisplayItem.getActorType() == Participant.ActorType.EMAILS) {
|
||||||
ImageViewExtensionsKt.loadFirstLetterAvatar(
|
ImageViewExtensionsKt.loadFirstLetterAvatar(
|
||||||
imageView,
|
imageView,
|
||||||
String.valueOf(participantDisplayItem.getNick().charAt(0))
|
String.valueOf(participantDisplayItem.getNick())
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar());
|
ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar());
|
||||||
|
|
|
@ -20,6 +20,7 @@ import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.adapters.items.ConversationItem.ConversationItemViewHolder
|
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.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||||
import com.nextcloud.talk.chat.data.model.ChatMessage.MessageType
|
import com.nextcloud.talk.chat.data.model.ChatMessage.MessageType
|
||||||
import com.nextcloud.talk.data.database.mappers.asModel
|
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) {
|
} else if (model.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
|
||||||
lastMessageDisplayText
|
lastMessageDisplayText
|
||||||
} else {
|
} else {
|
||||||
val authorDisplayName =
|
val actorName = chatMessage?.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(chatMessage?.actorDisplayName)) {
|
val authorDisplayName = if (!actorName.isNullOrBlank()) {
|
||||||
chatMessage?.actorDisplayName
|
actorName
|
||||||
} else if ("guests" == chatMessage?.actorType) {
|
} else if ("guests" == chatMessage?.actorType || "emails" == chatMessage?.actorType) {
|
||||||
appContext.getString(R.string.nc_guest)
|
appContext.getString(R.string.nc_guest)
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
String.format(
|
String.format(
|
||||||
appContext.getString(R.string.nc_formatted_message),
|
appContext.getString(R.string.nc_formatted_message),
|
||||||
authorDisplayName,
|
authorDisplayName,
|
||||||
|
|
|
@ -16,6 +16,7 @@ import androidx.core.content.res.ResourcesCompat
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.adapters.items.ParticipantItem.ParticipantItemViewHolder
|
import com.nextcloud.talk.adapters.items.ParticipantItem.ParticipantItemViewHolder
|
||||||
import com.nextcloud.talk.data.user.model.User
|
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.loadFederatedUserAvatar
|
||||||
import com.nextcloud.talk.extensions.loadGuestAvatar
|
import com.nextcloud.talk.extensions.loadGuestAvatar
|
||||||
import com.nextcloud.talk.extensions.loadUserAvatar
|
import com.nextcloud.talk.extensions.loadUserAvatar
|
||||||
|
@ -56,7 +57,15 @@ class MentionAutocompleteItem(
|
||||||
init {
|
init {
|
||||||
mentionId = mention.mentionId
|
mentionId = mention.mentionId
|
||||||
objectId = mention.id
|
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
|
source = mention.source
|
||||||
status = mention.status
|
status = mention.status
|
||||||
statusIcon = mention.statusIcon
|
statusIcon = mention.statusIcon
|
||||||
|
@ -149,7 +158,11 @@ class MentionAutocompleteItem(
|
||||||
|
|
||||||
SOURCE_GUESTS, SOURCE_EMAILS -> {
|
SOURCE_GUESTS, SOURCE_EMAILS -> {
|
||||||
avatarId = displayName
|
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 -> {
|
else -> {
|
||||||
|
|
|
@ -85,6 +85,10 @@ class ParticipantItem(
|
||||||
setOnlineStateColor(holder)
|
setOnlineStateColor(holder)
|
||||||
holder.binding.nameText.text = model.displayName
|
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()) {
|
if (adapter!!.hasFilter()) {
|
||||||
viewThemeUtils.talk.themeAndHighlightText(
|
viewThemeUtils.talk.themeAndHighlightText(
|
||||||
holder.binding.nameText,
|
holder.binding.nameText,
|
||||||
|
@ -211,12 +215,11 @@ class ParticipantItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> {
|
Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> {
|
||||||
if (model.displayName.isNullOrEmpty()) {
|
val actorName = model.displayName
|
||||||
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
|
if (!actorName.isNullOrBlank()) {
|
||||||
|
holder.binding.avatarView.loadFirstLetterAvatar(actorName)
|
||||||
} else {
|
} else {
|
||||||
holder.binding.avatarView.loadFirstLetterAvatar(
|
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
|
||||||
model.displayName!!.first().toString()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,10 +157,10 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||||
val author: String = message.actorDisplayName!!
|
val actorName = message.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(author)) {
|
if (!actorName.isNullOrBlank()) {
|
||||||
binding.messageAuthor.visibility = View.VISIBLE
|
binding.messageAuthor.visibility = View.VISIBLE
|
||||||
binding.messageAuthor.text = author
|
binding.messageAuthor.text = actorName
|
||||||
binding.messageUserAvatar.setOnClickListener {
|
binding.messageUserAvatar.setOnClickListener {
|
||||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,10 +135,10 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||||
val author: String = message.actorDisplayName!!
|
val actorName = message.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(author)) {
|
if (!actorName.isNullOrBlank()) {
|
||||||
binding.messageAuthor.visibility = View.VISIBLE
|
binding.messageAuthor.visibility = View.VISIBLE
|
||||||
binding.messageAuthor.text = author
|
binding.messageAuthor.text = actorName
|
||||||
binding.messageUserAvatar.setOnClickListener {
|
binding.messageUserAvatar.setOnClickListener {
|
||||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
(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.extensions.loadFederatedUserAvatar
|
||||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
|
import com.nextcloud.talk.utils.ChatMessageUtils
|
||||||
import com.nextcloud.talk.utils.DateUtils
|
import com.nextcloud.talk.utils.DateUtils
|
||||||
import com.nextcloud.talk.utils.UriUtils
|
import com.nextcloud.talk.utils.UriUtils
|
||||||
import com.nextcloud.talk.utils.message.MessageUtils
|
import com.nextcloud.talk.utils.message.MessageUtils
|
||||||
|
@ -119,10 +120,10 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||||
val author: String = message.actorDisplayName!!
|
val actorName = message.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(author)) {
|
if (!actorName.isNullOrBlank()) {
|
||||||
binding.messageAuthor.visibility = View.VISIBLE
|
binding.messageAuthor.visibility = View.VISIBLE
|
||||||
binding.messageAuthor.text = author
|
binding.messageAuthor.text = actorName
|
||||||
binding.messageUserAvatar.setOnClickListener {
|
binding.messageUserAvatar.setOnClickListener {
|
||||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
(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) {
|
if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
|
||||||
binding.messageUserAvatar.visibility = View.VISIBLE
|
ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
|
||||||
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)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
|
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
|
||||||
binding.messageUserAvatar.visibility = View.GONE
|
binding.messageUserAvatar.visibility = View.GONE
|
||||||
|
|
|
@ -142,10 +142,10 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||||
val author: String = message.actorDisplayName!!
|
val actorName = message.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(author)) {
|
if (!actorName.isNullOrBlank()) {
|
||||||
binding.messageAuthor.visibility = View.VISIBLE
|
binding.messageAuthor.visibility = View.VISIBLE
|
||||||
binding.messageAuthor.text = author
|
binding.messageAuthor.text = actorName
|
||||||
binding.messageUserAvatar.setOnClickListener {
|
binding.messageUserAvatar.setOnClickListener {
|
||||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,10 +144,10 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||||
val author: String = message.actorDisplayName!!
|
val actorName = message.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(author)) {
|
if (!actorName.isNullOrBlank()) {
|
||||||
binding.messageAuthor.visibility = View.VISIBLE
|
binding.messageAuthor.visibility = View.VISIBLE
|
||||||
binding.messageAuthor.text = author
|
binding.messageAuthor.text = actorName
|
||||||
binding.messageUserAvatar.setOnClickListener {
|
binding.messageUserAvatar.setOnClickListener {
|
||||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,10 +238,10 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
|
||||||
val author: String = message.actorDisplayName!!
|
val actorName = message.actorDisplayName
|
||||||
if (!TextUtils.isEmpty(author)) {
|
if (!actorName.isNullOrBlank()) {
|
||||||
binding.messageAuthor.visibility = View.VISIBLE
|
binding.messageAuthor.visibility = View.VISIBLE
|
||||||
binding.messageAuthor.text = author
|
binding.messageAuthor.text = actorName
|
||||||
binding.messageUserAvatar.setOnClickListener {
|
binding.messageUserAvatar.setOnClickListener {
|
||||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
(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)
|
val layers = arrayOfNulls<Drawable>(2)
|
||||||
layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
|
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 layerDrawable = LayerDrawable(layers)
|
||||||
val data: Any = layerDrawable
|
val data: Any = layerDrawable
|
||||||
|
|
|
@ -21,8 +21,9 @@ class ChatMessageUtils {
|
||||||
fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils : ViewThemeUtils) {
|
fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils : ViewThemeUtils) {
|
||||||
view.visibility = View.VISIBLE
|
view.visibility = View.VISIBLE
|
||||||
if (message.actorType == "guests" || message.actorType == "emails") {
|
if (message.actorType == "guests" || message.actorType == "emails") {
|
||||||
if (message.actorDisplayName?.isNotEmpty() == true) {
|
val actorName = message.actorDisplayName
|
||||||
view.loadFirstLetterAvatar(message.actorDisplayName?.first().toString())
|
if (!actorName.isNullOrBlank()) {
|
||||||
|
view.loadFirstLetterAvatar(actorName)
|
||||||
} else {
|
} else {
|
||||||
view.loadDefaultAvatar(viewThemeUtils)
|
view.loadDefaultAvatar(viewThemeUtils)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue