Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/4363/display email guests #4473

Merged
merged 12 commits into from
Nov 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public RaisedHand getRaisedHand() {
return raisedHand;
}

public Participant.ActorType getActorType() {
return actorType;
}

public void addObserver(Observer observer) {
participantDisplayItemNotifier.addObserver(observer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.nextcloud.talk.R;
import com.nextcloud.talk.activities.CallActivity;
import com.nextcloud.talk.extensions.ImageViewExtensionsKt;
import com.nextcloud.talk.models.json.participants.Participant;

import org.webrtc.MediaStream;
import org.webrtc.MediaStreamTrack;
Expand Down Expand Up @@ -143,7 +144,15 @@ public View getView(int position, View convertView, ViewGroup parent) {
nickTextView.setVisibility(View.VISIBLE);
nickTextView.setText(participantDisplayItem.getNick());
}
ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar());
if (participantDisplayItem.getActorType() == Participant.ActorType.GUESTS ||
participantDisplayItem.getActorType() == Participant.ActorType.EMAILS) {
ImageViewExtensionsKt.loadFirstLetterAvatar(
imageView,
String.valueOf(participantDisplayItem.getNick().charAt(0))
);
} else {
ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar());
}
}

ImageView audioOffView = convertView.findViewById(R.id.remote_audio_off);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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.loadFederatedUserAvatar
import com.nextcloud.talk.extensions.loadGuestAvatar
import com.nextcloud.talk.extensions.loadUserAvatar
import com.nextcloud.talk.models.json.mention.Mention
import com.nextcloud.talk.models.json.status.StatusType
Expand Down Expand Up @@ -109,7 +110,6 @@ class MentionAutocompleteItem(
)
} else {
holder.binding.nameText.text = displayName
holder.binding.secondaryText.text = "@$objectId"
}
var avatarId = objectId
when (source) {
Expand Down Expand Up @@ -147,9 +147,9 @@ class MentionAutocompleteItem(
)
}

SOURCE_GUESTS -> {
run { avatarId = displayName }
run { holder.binding.avatarView.loadUserAvatar(currentUser, avatarId!!, true, false) }
SOURCE_GUESTS, SOURCE_EMAILS -> {
avatarId = displayName
holder.binding.avatarView.loadGuestAvatar(currentUser, avatarId!!, false)
}

else -> {
Expand Down Expand Up @@ -218,6 +218,7 @@ class MentionAutocompleteItem(
const val SOURCE_CALLS = "calls"
const val SOURCE_GUESTS = "guests"
const val SOURCE_GROUPS = "groups"
const val SOURCE_EMAILS = "emails"
const val SOURCE_FEDERATION = "federated_users"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ import com.nextcloud.talk.adapters.items.ParticipantItem.ParticipantItemViewHold
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.RvItemConversationInfoParticipantBinding
import com.nextcloud.talk.extensions.loadDefaultAvatar
import com.nextcloud.talk.extensions.loadDefaultGroupCallAvatar
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
import com.nextcloud.talk.extensions.loadGuestAvatar
import com.nextcloud.talk.extensions.loadMailAvatar
import com.nextcloud.talk.extensions.loadFirstLetterAvatar
import com.nextcloud.talk.extensions.loadUserAvatar
import com.nextcloud.talk.models.domain.ConversationModel
import com.nextcloud.talk.models.json.participants.Participant
import com.nextcloud.talk.models.json.participants.Participant.InCallFlags
import com.nextcloud.talk.models.json.status.StatusType
import com.nextcloud.talk.ui.StatusDrawable
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ConversationUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.DisplayUtils.convertDpToPixel
import eu.davidea.flexibleadapter.FlexibleAdapter
Expand All @@ -45,7 +47,7 @@ class ParticipantItem(
val model: Participant,
private val user: User,
private val viewThemeUtils: ViewThemeUtils,
private val roomToken: String
private val conversation: ConversationModel
) : AbstractFlexibleItem<ParticipantItemViewHolder>(), IFilterable<String?> {
var isOnline = true
override fun equals(o: Any?): Boolean {
Expand Down Expand Up @@ -128,7 +130,13 @@ class ParticipantItem(
Participant.ParticipantType.GUEST -> {
userType = sharedApplication!!.getString(R.string.nc_guest)
if (model.calculatedActorType == Participant.ActorType.EMAILS) {
userType = sharedApplication!!.getString(R.string.nc_email)
userType = sharedApplication!!.getString(R.string.nc_guest)
}

if (model.invitedActorId?.isNotEmpty() == true &&
ConversationUtils.isParticipantOwnerOrModerator(conversation)) {
holder.binding.conversationInfoStatusMessage.text = model.invitedActorId
alignUsernameVertical(holder, 0f)
}
}

Expand Down Expand Up @@ -165,6 +173,7 @@ class ParticipantItem(
}
}

@SuppressLint("StringFormatInvalid")
private fun showCallIcons(holder: ParticipantItemViewHolder) {
val resources = sharedApplication!!.resources
val inCallFlag = model.inCall
Expand Down Expand Up @@ -197,28 +206,26 @@ class ParticipantItem(
holder.binding.avatarView.loadDefaultGroupCallAvatar(viewThemeUtils)
}

Participant.ActorType.EMAILS -> {
holder.binding.avatarView.loadMailAvatar(viewThemeUtils)
}

Participant.ActorType.USERS -> {
holder.binding.avatarView.loadUserAvatar(user, model.calculatedActorId!!, true, false)
}

Participant.ActorType.GUESTS -> {
var displayName: String? = sharedApplication!!.resources.getString(R.string.nc_guest)
if (!TextUtils.isEmpty(model.displayName)) {
displayName = model.displayName
Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> {
if (model.displayName.isNullOrEmpty()) {
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
} else {
holder.binding.avatarView.loadFirstLetterAvatar(
model.displayName!!.first().toString()
)
}
holder.binding.avatarView.loadGuestAvatar(user, displayName!!, false)
}

Participant.ActorType.FEDERATED -> {
val darkTheme = if (DisplayUtils.isDarkModeOn(context)) 1 else 0
holder.binding.avatarView.loadFederatedUserAvatar(
user,
user.baseUrl!!,
roomToken,
conversation.token,
model.actorId!!,
darkTheme,
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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.message.MessageUtils
import com.nextcloud.talk.utils.preferences.AppPreferences
Expand Down Expand Up @@ -168,7 +169,7 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold
}

if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
setAvatarOnMessage(message)
ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
} else {
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE
Expand All @@ -179,19 +180,6 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold
}
}

private fun setAvatarOnMessage(message: ChatMessage) {
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)
}
}

private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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.message.MessageUtils
import com.nextcloud.talk.utils.preferences.AppPreferences
Expand Down Expand Up @@ -146,7 +147,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
}

if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
setAvatarOnMessage(message)
ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
} else {
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE
Expand All @@ -157,19 +158,6 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
}
}

private fun setAvatarOnMessage(message: ChatMessage) {
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)
}
}

private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.nextcloud.talk.extensions.loadFederatedUserAvatar
import com.nextcloud.talk.polls.ui.PollMainDialogFragment
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.message.MessageUtils
import com.nextcloud.talk.utils.preferences.AppPreferences
Expand Down Expand Up @@ -153,7 +154,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
}

if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
setAvatarOnMessage(message)
ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
} else {
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE
Expand All @@ -164,19 +165,6 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
}
}

private fun setAvatarOnMessage(message: ChatMessage) {
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)
}
}

private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ import com.nextcloud.talk.chat.data.model.ChatMessage
import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding
import com.nextcloud.talk.extensions.loadBotsAvatar
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
import com.nextcloud.talk.extensions.loadDefaultAvatar
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
import com.nextcloud.talk.extensions.loadFirstLetterAvatar
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.TextMatchers
import com.nextcloud.talk.utils.message.MessageUtils
Expand Down Expand Up @@ -153,7 +156,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
}

if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
setAvatarOnMessage(message)
ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
} else {
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE
Expand All @@ -164,19 +167,6 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
}
}

private fun setAvatarOnMessage(message: ChatMessage) {
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)
}
}

private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}
Expand Down Expand Up @@ -252,17 +242,6 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
}
}

private fun showAvatarOnChatMessage(message: ChatMessage) {
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()
}
}

fun assignCommonMessageInterface(commonMessageInterface: CommonMessageInterface) {
this.commonMessageInterface = commonMessageInterface
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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.message.MessageUtils
import com.nextcloud.talk.utils.preferences.AppPreferences
Expand Down Expand Up @@ -249,7 +250,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
}

if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
setAvatarOnMessage(message)
ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
} else {
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE
Expand All @@ -260,19 +261,6 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
}
}

private fun setAvatarOnMessage(message: ChatMessage) {
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)
}
}

private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,8 @@ class MessageInputFragment : Fragment() {
val shouldQuote = mentionId.contains(" ") ||
mentionId.contains("@") ||
mentionId.startsWith("guest/") ||
mentionId.startsWith("group/")
mentionId.startsWith("group/") ||
mentionId.startsWith("email/")
if (shouldQuote) {
mentionId = "\"" + mentionId + "\""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class ConversationInfoActivity :

for (i in participants.indices) {
participant = participants[i]
userItem = ParticipantItem(this, participant, conversationUser, viewThemeUtils, conversationToken)
userItem = ParticipantItem(this, participant, conversationUser, viewThemeUtils, conversation!!)
if (participant.sessionId != null) {
userItem.isOnline = !participant.sessionId.equals("0")
} else {
Expand Down
Loading
Loading