mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
use seperate xml designs for Items (+use viewbinding)
Resolves #1829 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
7227347339
commit
f47690db22
@ -1,10 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Nextcloud Talk application
|
* Nextcloud Talk application
|
||||||
*
|
*
|
||||||
* @author Marcel Hibbe
|
|
||||||
* @author Mario Danic
|
* @author Mario Danic
|
||||||
* Copyright (C) 2022 Marcel Hibbe (dev@mhibbe.de)
|
* @author Marcel Hibbe
|
||||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
* @author Andy Scherzinger
|
||||||
|
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
|
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
|
||||||
|
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -49,8 +51,8 @@ import eu.davidea.flexibleadapter.items.IFilterable;
|
|||||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
import eu.davidea.flexibleadapter.items.IFlexible;
|
||||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
||||||
|
|
||||||
public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantItem.ParticipantItemViewHolder>
|
||||||
implements IFilterable<String> {
|
implements IFilterable<String> {
|
||||||
|
|
||||||
private static final float STATUS_SIZE_IN_DP = 9f;
|
private static final float STATUS_SIZE_IN_DP = 9f;
|
||||||
private static final String NO_ICON = "";
|
private static final String NO_ICON = "";
|
||||||
@ -67,9 +69,9 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public MentionAutocompleteItem(
|
public MentionAutocompleteItem(
|
||||||
Mention mention,
|
Mention mention,
|
||||||
UserEntity currentUser,
|
UserEntity currentUser,
|
||||||
Context activityContext) {
|
Context activityContext) {
|
||||||
this.objectId = mention.getId();
|
this.objectId = mention.getId();
|
||||||
this.displayName = mention.getLabel();
|
this.displayName = mention.getLabel();
|
||||||
this.source = mention.getSource();
|
this.source = mention.getSource();
|
||||||
@ -112,45 +114,46 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserItem.UserItemViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
public ParticipantItem.ParticipantItemViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
||||||
return new UserItem.UserItemViewHolder(view, adapter);
|
return new ParticipantItem.ParticipantItemViewHolder(view, adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
public void bindViewHolder(
|
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter,
|
||||||
FlexibleAdapter<IFlexible> adapter,
|
ParticipantItem.ParticipantItemViewHolder holder,
|
||||||
UserItem.UserItemViewHolder holder,
|
int position,
|
||||||
int position,
|
List<Object> payloads) {
|
||||||
List<Object> payloads) {
|
|
||||||
|
|
||||||
holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(context.getResources(),
|
holder.binding.nameText.setTextColor(
|
||||||
R.color.conversation_item_header,
|
ResourcesCompat.getColor(context.getResources(),
|
||||||
null));
|
R.color.conversation_item_header,
|
||||||
|
null));
|
||||||
if (adapter.hasFilter()) {
|
if (adapter.hasFilter()) {
|
||||||
FlexibleUtils.highlightText(holder.contactDisplayName,
|
FlexibleUtils.highlightText(holder.binding.nameText,
|
||||||
displayName,
|
displayName,
|
||||||
String.valueOf(adapter.getFilter(String.class)),
|
String.valueOf(adapter.getFilter(String.class)),
|
||||||
Objects.requireNonNull(NextcloudTalkApplication.Companion.getSharedApplication())
|
Objects.requireNonNull(NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication())
|
||||||
.getResources().getColor(R.color.colorPrimary));
|
.getResources().getColor(R.color.colorPrimary));
|
||||||
if (holder.contactMentionId != null) {
|
if (holder.binding.secondaryText != null) {
|
||||||
FlexibleUtils.highlightText(holder.contactMentionId,
|
FlexibleUtils.highlightText(holder.binding.secondaryText,
|
||||||
"@" + objectId,
|
"@" + objectId,
|
||||||
String.valueOf(adapter.getFilter(String.class)),
|
String.valueOf(adapter.getFilter(String.class)),
|
||||||
NextcloudTalkApplication.Companion.getSharedApplication()
|
NextcloudTalkApplication.Companion.getSharedApplication()
|
||||||
.getResources().getColor(R.color.colorPrimary));
|
.getResources().getColor(R.color.colorPrimary));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
holder.contactDisplayName.setText(displayName);
|
holder.binding.nameText.setText(displayName);
|
||||||
if (holder.contactMentionId != null) {
|
if (holder.binding.secondaryText != null) {
|
||||||
holder.contactMentionId.setText("@" + objectId);
|
holder.binding.secondaryText.setText("@" + objectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SOURCE_CALLS.equals(source)) {
|
if (SOURCE_CALLS.equals(source)) {
|
||||||
if (holder.participantAvatar != null){
|
if (holder.binding.avatarDraweeView != null) {
|
||||||
holder.participantAvatar.setImageResource(R.drawable.ic_circular_group);
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String avatarId = objectId;
|
String avatarId = objectId;
|
||||||
@ -165,25 +168,27 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||||||
R.dimen.avatar_size_big);
|
R.dimen.avatar_size_big);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(holder.participantAvatar != null){
|
if (holder.binding.avatarDraweeView != null) {
|
||||||
holder.participantAvatar.setController(null);
|
holder.binding.avatarDraweeView.setController(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
.setOldController(holder.participantAvatar.getController())
|
.setOldController(holder.binding.avatarDraweeView.getController())
|
||||||
.setAutoPlayAnimations(true)
|
.setAutoPlayAnimations(true)
|
||||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(avatarUrl, null))
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(avatarUrl, null))
|
||||||
.build();
|
.build();
|
||||||
holder.participantAvatar.setController(draweeController);
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawStatus(holder);
|
drawStatus(holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawStatus(UserItem.UserItemViewHolder holder) {
|
private void drawStatus(ParticipantItem.ParticipantItemViewHolder holder) {
|
||||||
if (holder.statusMessage != null && holder.participantEmoji != null && holder.userStatusImage != null) {
|
if (holder.binding.conversationInfoStatusMessage != null &&
|
||||||
|
holder.binding.participantStatusEmoji != null &&
|
||||||
|
holder.binding.userStatusImage != null) {
|
||||||
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
|
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
|
||||||
holder.userStatusImage.setImageDrawable(new StatusDrawable(
|
holder.binding.userStatusImage.setImageDrawable(new StatusDrawable(
|
||||||
status,
|
status,
|
||||||
NO_ICON,
|
NO_ICON,
|
||||||
size,
|
size,
|
||||||
@ -191,49 +196,49 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||||||
context));
|
context));
|
||||||
|
|
||||||
if (statusMessage != null) {
|
if (statusMessage != null) {
|
||||||
holder.statusMessage.setText(statusMessage);
|
holder.binding.conversationInfoStatusMessage.setText(statusMessage);
|
||||||
alignUsernameVertical(holder, 0);
|
alignUsernameVertical(holder, 0);
|
||||||
} else {
|
} else {
|
||||||
holder.statusMessage.setText("");
|
holder.binding.conversationInfoStatusMessage.setText("");
|
||||||
alignUsernameVertical(holder, 10);
|
alignUsernameVertical(holder, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusIcon != null && !statusIcon.isEmpty()) {
|
if (statusIcon != null && !statusIcon.isEmpty()) {
|
||||||
holder.participantEmoji.setText(statusIcon);
|
holder.binding.participantStatusEmoji.setText(statusIcon);
|
||||||
} else {
|
} else {
|
||||||
holder.participantEmoji.setVisibility(View.GONE);
|
holder.binding.participantStatusEmoji.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != null && status.equals(StatusType.DND.getString())) {
|
if (status != null && status.equals(StatusType.DND.getString())) {
|
||||||
if (statusMessage == null || statusMessage.isEmpty()) {
|
if (statusMessage == null || statusMessage.isEmpty()) {
|
||||||
holder.statusMessage.setText(R.string.dnd);
|
holder.binding.conversationInfoStatusMessage.setText(R.string.dnd);
|
||||||
}
|
}
|
||||||
} else if (status != null && status.equals(StatusType.AWAY.getString())) {
|
} else if (status != null && status.equals(StatusType.AWAY.getString())) {
|
||||||
if (statusMessage == null || statusMessage.isEmpty()) {
|
if (statusMessage == null || statusMessage.isEmpty()) {
|
||||||
holder.statusMessage.setText(R.string.away);
|
holder.binding.conversationInfoStatusMessage.setText(R.string.away);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void alignUsernameVertical(UserItem.UserItemViewHolder holder, float densityPixelsFromTop) {
|
private void alignUsernameVertical(ParticipantItem.ParticipantItemViewHolder holder, float densityPixelsFromTop) {
|
||||||
ConstraintLayout.LayoutParams layoutParams =
|
ConstraintLayout.LayoutParams layoutParams =
|
||||||
(ConstraintLayout.LayoutParams) holder.contactDisplayName.getLayoutParams();
|
(ConstraintLayout.LayoutParams) holder.binding.nameText.getLayoutParams();
|
||||||
layoutParams.topMargin = (int) DisplayUtils.convertDpToPixel(densityPixelsFromTop, context);
|
layoutParams.topMargin = (int) DisplayUtils.convertDpToPixel(densityPixelsFromTop, context);
|
||||||
holder.contactDisplayName.setLayoutParams(layoutParams);
|
holder.binding.nameText.setLayoutParams(layoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filter(String constraint) {
|
public boolean filter(String constraint) {
|
||||||
return objectId != null &&
|
return objectId != null &&
|
||||||
|
Pattern
|
||||||
|
.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
|
.matcher(objectId)
|
||||||
|
.find() ||
|
||||||
|
displayName != null &&
|
||||||
Pattern
|
Pattern
|
||||||
.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
.matcher(objectId)
|
.matcher(displayName)
|
||||||
.find() ||
|
.find();
|
||||||
displayName != null &&
|
|
||||||
Pattern
|
|
||||||
.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
|
||||||
.matcher(displayName)
|
|
||||||
.find();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,336 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* @author Marcel Hibbe
|
||||||
|
* @author Andy Scherzinger
|
||||||
|
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
|
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
|
||||||
|
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nextcloud.talk.adapters.items;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
|
import com.facebook.drawee.interfaces.DraweeController;
|
||||||
|
import com.nextcloud.talk.R;
|
||||||
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.databinding.RvItemConversationInfoParticipantBinding;
|
||||||
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||||
|
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.utils.ApiUtils;
|
||||||
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||||
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||||
|
import eu.davidea.flexibleadapter.items.IFilterable;
|
||||||
|
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
||||||
|
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||||
|
|
||||||
|
public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.ParticipantItemViewHolder> implements
|
||||||
|
IFilterable<String> {
|
||||||
|
|
||||||
|
private static final float STATUS_SIZE_IN_DP = 9f;
|
||||||
|
private static final String NO_ICON = "";
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private Participant participant;
|
||||||
|
private UserEntity userEntity;
|
||||||
|
public boolean isOnline = true;
|
||||||
|
|
||||||
|
public ParticipantItem(Context activityContext,
|
||||||
|
Participant participant,
|
||||||
|
UserEntity userEntity) {
|
||||||
|
this.context = activityContext;
|
||||||
|
this.participant = participant;
|
||||||
|
this.userEntity = userEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Participant getModel() {
|
||||||
|
return participant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o instanceof UserItem) {
|
||||||
|
UserItem inItem = (UserItem) o;
|
||||||
|
return participant.getActorType() == inItem.getModel().getActorType() &&
|
||||||
|
participant.getActorId().equals(inItem.getModel().getActorId());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return participant.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayoutRes() {
|
||||||
|
return R.layout.rv_item_conversation_info_participant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParticipantItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
||||||
|
return new ParticipantItemViewHolder(view, adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
@Override
|
||||||
|
public void bindViewHolder(FlexibleAdapter adapter, ParticipantItemViewHolder holder, int position, List payloads) {
|
||||||
|
|
||||||
|
holder.binding.avatarDraweeView.setController(null);
|
||||||
|
|
||||||
|
drawStatus(holder);
|
||||||
|
|
||||||
|
if (!isOnline) {
|
||||||
|
holder.binding.nameText.setTextColor(ResourcesCompat.getColor(
|
||||||
|
holder.binding.nameText.getContext().getResources(),
|
||||||
|
R.color.medium_emphasis_text,
|
||||||
|
null)
|
||||||
|
);
|
||||||
|
holder.binding.avatarDraweeView.setAlpha(0.38f);
|
||||||
|
} else {
|
||||||
|
holder.binding.nameText.setTextColor(ResourcesCompat.getColor(
|
||||||
|
holder.binding.nameText.getContext().getResources(),
|
||||||
|
R.color.high_emphasis_text,
|
||||||
|
null)
|
||||||
|
);
|
||||||
|
holder.binding.avatarDraweeView.setAlpha(1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adapter.hasFilter()) {
|
||||||
|
FlexibleUtils.highlightText(holder.binding.nameText, participant.getDisplayName(),
|
||||||
|
String.valueOf(adapter.getFilter(String.class)),
|
||||||
|
NextcloudTalkApplication.Companion.getSharedApplication()
|
||||||
|
.getResources()
|
||||||
|
.getColor(R.color.colorPrimary));
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.binding.nameText.setText(participant.getDisplayName());
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(participant.getDisplayName()) &&
|
||||||
|
(participant.getType().equals(Participant.ParticipantType.GUEST) ||
|
||||||
|
participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
|
||||||
|
holder.binding.nameText.setText(NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_guest));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (participant.getActorType() == Participant.ActorType.GROUPS ||
|
||||||
|
"groups".equals(participant.getSource()) ||
|
||||||
|
participant.getActorType() == Participant.ActorType.CIRCLES ||
|
||||||
|
"circles".equals(participant.getSource())) {
|
||||||
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
|
||||||
|
} else if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
||||||
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail);
|
||||||
|
} else if (participant.getActorType() == Participant.ActorType.GUESTS ||
|
||||||
|
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
||||||
|
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
||||||
|
|
||||||
|
String displayName = NextcloudTalkApplication.Companion.getSharedApplication()
|
||||||
|
.getResources().getString(R.string.nc_guest);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(participant.getDisplayName())) {
|
||||||
|
displayName = participant.getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
|
.setOldController(holder.binding.avatarDraweeView.getController())
|
||||||
|
.setAutoPlayAnimations(true)
|
||||||
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
||||||
|
ApiUtils.getUrlForAvatarWithNameForGuests(userEntity.getBaseUrl(),
|
||||||
|
displayName, R.dimen.avatar_size), null))
|
||||||
|
.build();
|
||||||
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
|
|
||||||
|
} else if (participant.getActorType() == Participant.ActorType.USERS ||
|
||||||
|
participant.getSource().equals("users")) {
|
||||||
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
|
.setOldController(holder.binding.avatarDraweeView.getController())
|
||||||
|
.setAutoPlayAnimations(true)
|
||||||
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
||||||
|
ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||||
|
participant.getActorId(), R.dimen.avatar_size), null))
|
||||||
|
.build();
|
||||||
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
|
}
|
||||||
|
|
||||||
|
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
|
||||||
|
|
||||||
|
Long inCallFlag = participant.getInCall();
|
||||||
|
if ((inCallFlag & InCallFlags.WITH_PHONE) > 0) {
|
||||||
|
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_call_grey_600_24dp);
|
||||||
|
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
||||||
|
holder.binding.videoCallIcon.setContentDescription(
|
||||||
|
resources.getString(R.string.nc_call_state_with_phone, participant.displayName));
|
||||||
|
} else if ((inCallFlag & InCallFlags.WITH_VIDEO) > 0) {
|
||||||
|
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_videocam_grey_600_24dp);
|
||||||
|
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
||||||
|
holder.binding.videoCallIcon.setContentDescription(
|
||||||
|
resources.getString(R.string.nc_call_state_with_video, participant.displayName));
|
||||||
|
} else if (inCallFlag > InCallFlags.DISCONNECTED) {
|
||||||
|
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_mic_grey_600_24dp);
|
||||||
|
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
||||||
|
holder.binding.videoCallIcon.setContentDescription(
|
||||||
|
resources.getString(R.string.nc_call_state_in_call, participant.displayName));
|
||||||
|
} else {
|
||||||
|
holder.binding.videoCallIcon.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (holder.binding.secondaryText != null) {
|
||||||
|
String userType = "";
|
||||||
|
|
||||||
|
switch (new EnumParticipantTypeConverter().convertToInt(participant.getType())) {
|
||||||
|
case 1:
|
||||||
|
//userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_owner);
|
||||||
|
//break;
|
||||||
|
case 2:
|
||||||
|
case 6: // Guest moderator
|
||||||
|
userType = NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_moderator);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
userType = NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_user);
|
||||||
|
if (participant.getActorType() == Participant.ActorType.GROUPS) {
|
||||||
|
userType = NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_group);
|
||||||
|
}
|
||||||
|
if (participant.getActorType() == Participant.ActorType.CIRCLES) {
|
||||||
|
userType = NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_circle);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest);
|
||||||
|
if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
||||||
|
userType = NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_email);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
userType = NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_following_link);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userType.equals(NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_user))) {
|
||||||
|
holder.binding.secondaryText.setText("(" + userType + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawStatus(ParticipantItemViewHolder holder) {
|
||||||
|
if (holder.binding.conversationInfoStatusMessage != null &&
|
||||||
|
holder.binding.participantStatusEmoji != null &&
|
||||||
|
holder.binding.userStatusImage != null) {
|
||||||
|
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
|
||||||
|
holder.binding.userStatusImage.setImageDrawable(new StatusDrawable(
|
||||||
|
participant.status,
|
||||||
|
NO_ICON,
|
||||||
|
size,
|
||||||
|
context.getResources().getColor(R.color.bg_default),
|
||||||
|
context));
|
||||||
|
|
||||||
|
if (participant.statusMessage != null) {
|
||||||
|
holder.binding.conversationInfoStatusMessage.setText(participant.statusMessage);
|
||||||
|
alignUsernameVertical(holder, 0);
|
||||||
|
} else {
|
||||||
|
holder.binding.conversationInfoStatusMessage.setText("");
|
||||||
|
alignUsernameVertical(holder, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
|
||||||
|
holder.binding.participantStatusEmoji.setText(participant.statusIcon);
|
||||||
|
} else {
|
||||||
|
holder.binding.participantStatusEmoji.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (participant.status != null && participant.status.equals(StatusType.DND.getString())) {
|
||||||
|
if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
|
||||||
|
holder.binding.conversationInfoStatusMessage.setText(R.string.dnd);
|
||||||
|
}
|
||||||
|
} else if (participant.status != null && participant.status.equals(StatusType.AWAY.getString())) {
|
||||||
|
if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
|
||||||
|
holder.binding.conversationInfoStatusMessage.setText(R.string.away);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void alignUsernameVertical(ParticipantItem.ParticipantItemViewHolder holder, float densityPixelsFromTop) {
|
||||||
|
ConstraintLayout.LayoutParams layoutParams =
|
||||||
|
(ConstraintLayout.LayoutParams) holder.binding.nameText.getLayoutParams();
|
||||||
|
layoutParams.topMargin = (int) DisplayUtils.convertDpToPixel(densityPixelsFromTop, context);
|
||||||
|
holder.binding.nameText.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean filter(String constraint) {
|
||||||
|
return participant.getDisplayName() != null &&
|
||||||
|
(Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
|
.matcher(participant.getDisplayName().trim()).find() ||
|
||||||
|
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
|
.matcher(participant.getActorId().trim()).find());
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ParticipantItemViewHolder extends FlexibleViewHolder {
|
||||||
|
|
||||||
|
RvItemConversationInfoParticipantBinding binding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
ParticipantItemViewHolder(View view, FlexibleAdapter adapter) {
|
||||||
|
super(view, adapter);
|
||||||
|
binding = RvItemConversationInfoParticipantBinding.bind(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,8 +3,10 @@
|
|||||||
*
|
*
|
||||||
* @author Mario Danic
|
* @author Mario Danic
|
||||||
* @author Marcel Hibbe
|
* @author Marcel Hibbe
|
||||||
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
|
* @author Andy Scherzinger
|
||||||
* Copyright (C) 2022 Marcel Hibbe (dev@mhibbe.de)
|
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
|
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
|
||||||
|
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -23,35 +25,23 @@
|
|||||||
package com.nextcloud.talk.adapters.items;
|
package com.nextcloud.talk.adapters.items;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
import com.facebook.drawee.interfaces.DraweeController;
|
import com.facebook.drawee.interfaces.DraweeController;
|
||||||
import com.facebook.drawee.view.SimpleDraweeView;
|
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
|
import com.nextcloud.talk.databinding.RvItemContactBinding;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
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.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import androidx.emoji.widget.EmojiTextView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||||
import eu.davidea.flexibleadapter.items.IFilterable;
|
import eu.davidea.flexibleadapter.items.IFilterable;
|
||||||
@ -62,20 +52,18 @@ import eu.davidea.viewholders.FlexibleViewHolder;
|
|||||||
public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder> implements
|
public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder> implements
|
||||||
ISectionable<UserItem.UserItemViewHolder, GenericTextHeaderItem>, IFilterable<String> {
|
ISectionable<UserItem.UserItemViewHolder, GenericTextHeaderItem>, IFilterable<String> {
|
||||||
|
|
||||||
private static final float STATUS_SIZE_IN_DP = 9f;
|
public static final String PARTICIPANT_SOURCE_CIRCLES = "circles";
|
||||||
private static final String NO_ICON = "";
|
public static final String PARTICIPANT_SOURCE_GROUPS = "groups";
|
||||||
|
public static final String PARTICIPANT_SOURCE_USERS = "users";
|
||||||
|
|
||||||
private Context context;
|
private final Participant participant;
|
||||||
private Participant participant;
|
private final UserEntity userEntity;
|
||||||
private UserEntity userEntity;
|
|
||||||
private GenericTextHeaderItem header;
|
private GenericTextHeaderItem header;
|
||||||
public boolean isOnline = true;
|
public boolean isOnline = true;
|
||||||
|
|
||||||
public UserItem(Context activityContext,
|
public UserItem(Participant participant,
|
||||||
Participant participant,
|
|
||||||
UserEntity userEntity,
|
UserEntity userEntity,
|
||||||
GenericTextHeaderItem genericTextHeaderItem) {
|
GenericTextHeaderItem genericTextHeaderItem) {
|
||||||
this.context = activityContext;
|
|
||||||
this.participant = participant;
|
this.participant = participant;
|
||||||
this.userEntity = userEntity;
|
this.userEntity = userEntity;
|
||||||
this.header = genericTextHeaderItem;
|
this.header = genericTextHeaderItem;
|
||||||
@ -99,23 +87,14 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
/**
|
/**
|
||||||
* @return the model object
|
* @return the model object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Participant getModel() {
|
public Participant getModel() {
|
||||||
return participant;
|
return participant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity getEntity() {
|
|
||||||
return userEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutRes() {
|
public int getLayoutRes() {
|
||||||
if (header != null) {
|
return R.layout.rv_item_contact;
|
||||||
return R.layout.rv_item_contact;
|
|
||||||
} else {
|
|
||||||
return R.layout.rv_item_conversation_info_participant;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -127,59 +106,72 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
@Override
|
@Override
|
||||||
public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position, List payloads) {
|
public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position, List payloads) {
|
||||||
|
|
||||||
if (holder.participantAvatar != null) {
|
if (holder.binding.avatarDraweeView != null) {
|
||||||
holder.participantAvatar.setController(null);
|
holder.binding.avatarDraweeView.setController(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder.checkedImageView != null) {
|
if (holder.binding.checkedImageView != null) {
|
||||||
if (participant.isSelected()) {
|
if (participant.isSelected()) {
|
||||||
holder.checkedImageView.setVisibility(View.VISIBLE);
|
holder.binding.checkedImageView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.checkedImageView.setVisibility(View.GONE);
|
holder.binding.checkedImageView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drawStatus(holder);
|
|
||||||
|
|
||||||
if (!isOnline) {
|
if (!isOnline) {
|
||||||
holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(
|
holder.binding.nameText.setTextColor(ResourcesCompat.getColor(
|
||||||
holder.contactDisplayName.getContext().getResources(),
|
holder.binding.nameText.getContext().getResources(),
|
||||||
R.color.medium_emphasis_text,
|
R.color.medium_emphasis_text,
|
||||||
null)
|
null)
|
||||||
);
|
);
|
||||||
holder.participantAvatar.setAlpha(0.38f);
|
holder.binding.avatarDraweeView.setAlpha(0.38f);
|
||||||
} else {
|
} else {
|
||||||
holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(
|
holder.binding.nameText.setTextColor(ResourcesCompat.getColor(
|
||||||
holder.contactDisplayName.getContext().getResources(),
|
holder.binding.nameText.getContext().getResources(),
|
||||||
R.color.high_emphasis_text,
|
R.color.high_emphasis_text,
|
||||||
null)
|
null)
|
||||||
);
|
);
|
||||||
holder.participantAvatar.setAlpha(1.0f);
|
holder.binding.avatarDraweeView.setAlpha(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adapter.hasFilter()) {
|
if (adapter.hasFilter()) {
|
||||||
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getDisplayName(),
|
FlexibleUtils.highlightText(holder.binding.nameText,
|
||||||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.Companion.getSharedApplication()
|
participant.getDisplayName(),
|
||||||
.getResources().getColor(R.color.colorPrimary));
|
String.valueOf(adapter.getFilter(String.class)),
|
||||||
|
NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getResources()
|
||||||
|
.getColor(R.color.colorPrimary));
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.contactDisplayName.setText(participant.getDisplayName());
|
holder.binding.nameText.setText(participant.getDisplayName());
|
||||||
|
|
||||||
if (TextUtils.isEmpty(participant.getDisplayName()) &&
|
if (TextUtils.isEmpty(participant.getDisplayName()) &&
|
||||||
(participant.getType().equals(Participant.ParticipantType.GUEST) || participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
|
(participant.getType().equals(Participant.ParticipantType.GUEST) ||
|
||||||
holder.contactDisplayName.setText(NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest));
|
participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
|
||||||
|
holder.binding.nameText.setText(NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getString(R.string.nc_guest));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.getActorType() == Participant.ActorType.GROUPS ||
|
if (
|
||||||
"groups".equals(participant.getSource()) ||
|
participant.getActorType() == Participant.ActorType.GROUPS ||
|
||||||
participant.getActorType() == Participant.ActorType.CIRCLES ||
|
PARTICIPANT_SOURCE_GROUPS.equals(participant.getSource()) ||
|
||||||
"circles".equals(participant.getSource())) {
|
participant.getActorType() == Participant.ActorType.CIRCLES ||
|
||||||
holder.participantAvatar.setImageResource(R.drawable.ic_circular_group);
|
PARTICIPANT_SOURCE_CIRCLES.equals(participant.getSource())) {
|
||||||
|
|
||||||
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
|
||||||
|
|
||||||
} else if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
} else if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
||||||
holder.participantAvatar.setImageResource(R.drawable.ic_circular_mail);
|
|
||||||
} else if (participant.getActorType() == Participant.ActorType.GUESTS ||
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail);
|
||||||
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
|
||||||
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
} else if (
|
||||||
|
participant.getActorType() == Participant.ActorType.GUESTS ||
|
||||||
|
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
||||||
|
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
||||||
|
|
||||||
String displayName = NextcloudTalkApplication.Companion.getSharedApplication()
|
String displayName = NextcloudTalkApplication.Companion.getSharedApplication()
|
||||||
.getResources().getString(R.string.nc_guest);
|
.getResources().getString(R.string.nc_guest);
|
||||||
@ -189,134 +181,40 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
}
|
}
|
||||||
|
|
||||||
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
.setOldController(holder.participantAvatar.getController())
|
.setOldController(holder.binding.avatarDraweeView.getController())
|
||||||
.setAutoPlayAnimations(true)
|
.setAutoPlayAnimations(true)
|
||||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithNameForGuests(userEntity.getBaseUrl(),
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
||||||
displayName, R.dimen.avatar_size), null))
|
ApiUtils.getUrlForAvatarWithNameForGuests(userEntity.getBaseUrl(),
|
||||||
|
displayName,
|
||||||
|
R.dimen.avatar_size),
|
||||||
|
null))
|
||||||
.build();
|
.build();
|
||||||
holder.participantAvatar.setController(draweeController);
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
|
|
||||||
} else if (participant.getActorType() == Participant.ActorType.USERS || participant.getSource().equals("users")) {
|
} else if (participant.getActorType() == Participant.ActorType.USERS ||
|
||||||
|
PARTICIPANT_SOURCE_USERS.equals(participant.getSource())) {
|
||||||
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
.setOldController(holder.participantAvatar.getController())
|
.setOldController(holder.binding.avatarDraweeView.getController())
|
||||||
.setAutoPlayAnimations(true)
|
.setAutoPlayAnimations(true)
|
||||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
||||||
participant.getActorId(), R.dimen.avatar_size), null))
|
ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||||
|
participant.getActorId(),
|
||||||
|
R.dimen.avatar_size),
|
||||||
|
null))
|
||||||
.build();
|
.build();
|
||||||
holder.participantAvatar.setController(draweeController);
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
}
|
}
|
||||||
|
|
||||||
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
|
|
||||||
|
|
||||||
if (header == null) {
|
|
||||||
Long inCallFlag = participant.getInCall();
|
|
||||||
if ((inCallFlag & InCallFlags.WITH_PHONE) > 0) {
|
|
||||||
holder.videoCallIconView.setImageResource(R.drawable.ic_call_grey_600_24dp);
|
|
||||||
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
||||||
holder.videoCallIconView.setContentDescription(
|
|
||||||
resources.getString(R.string.nc_call_state_with_phone, participant.displayName));
|
|
||||||
} else if ((inCallFlag & InCallFlags.WITH_VIDEO) > 0) {
|
|
||||||
holder.videoCallIconView.setImageResource(R.drawable.ic_videocam_grey_600_24dp);
|
|
||||||
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
||||||
holder.videoCallIconView.setContentDescription(
|
|
||||||
resources.getString(R.string.nc_call_state_with_video, participant.displayName));
|
|
||||||
} else if (inCallFlag > InCallFlags.DISCONNECTED) {
|
|
||||||
holder.videoCallIconView.setImageResource(R.drawable.ic_mic_grey_600_24dp);
|
|
||||||
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
||||||
holder.videoCallIconView.setContentDescription(
|
|
||||||
resources.getString(R.string.nc_call_state_in_call, participant.displayName));
|
|
||||||
} else {
|
|
||||||
holder.videoCallIconView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (holder.contactMentionId != null) {
|
|
||||||
String userType = "";
|
|
||||||
|
|
||||||
switch (new EnumParticipantTypeConverter().convertToInt(participant.getType())) {
|
|
||||||
case 1:
|
|
||||||
//userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_owner);
|
|
||||||
//break;
|
|
||||||
case 2:
|
|
||||||
case 6: // Guest moderator
|
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_moderator);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_user);
|
|
||||||
if (participant.getActorType() == Participant.ActorType.GROUPS) {
|
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_group);
|
|
||||||
}
|
|
||||||
if (participant.getActorType() == Participant.ActorType.CIRCLES) {
|
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_circle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest);
|
|
||||||
if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_email);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_following_link);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!userType.equals(NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_user))) {
|
|
||||||
holder.contactMentionId.setText("(" + userType + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawStatus(UserItemViewHolder holder) {
|
|
||||||
if (holder.statusMessage != null && holder.participantEmoji != null && holder.userStatusImage != null) {
|
|
||||||
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
|
|
||||||
holder.userStatusImage.setImageDrawable(new StatusDrawable(
|
|
||||||
participant.status,
|
|
||||||
NO_ICON,
|
|
||||||
size,
|
|
||||||
context.getResources().getColor(R.color.bg_default),
|
|
||||||
context));
|
|
||||||
|
|
||||||
if (participant.statusMessage != null) {
|
|
||||||
holder.statusMessage.setText(participant.statusMessage);
|
|
||||||
alignUsernameVertical(holder, 0);
|
|
||||||
} else {
|
|
||||||
holder.statusMessage.setText("");
|
|
||||||
alignUsernameVertical(holder, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
|
|
||||||
holder.participantEmoji.setText(participant.statusIcon);
|
|
||||||
} else {
|
|
||||||
holder.participantEmoji.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (participant.status != null && participant.status.equals(StatusType.DND.getString())) {
|
|
||||||
if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
|
|
||||||
holder.statusMessage.setText(R.string.dnd);
|
|
||||||
}
|
|
||||||
} else if (participant.status != null && participant.status.equals(StatusType.AWAY.getString())) {
|
|
||||||
if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
|
|
||||||
holder.statusMessage.setText(R.string.away);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void alignUsernameVertical(UserItem.UserItemViewHolder holder, float densityPixelsFromTop) {
|
|
||||||
ConstraintLayout.LayoutParams layoutParams =
|
|
||||||
(ConstraintLayout.LayoutParams) holder.contactDisplayName.getLayoutParams();
|
|
||||||
layoutParams.topMargin = (int) DisplayUtils.convertDpToPixel(densityPixelsFromTop, context);
|
|
||||||
holder.contactDisplayName.setLayoutParams(layoutParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filter(String constraint) {
|
public boolean filter(String constraint) {
|
||||||
return participant.getDisplayName() != null &&
|
return participant.getDisplayName() != null &&
|
||||||
(Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL).matcher(participant.getDisplayName().trim()).find() ||
|
(Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL).matcher(participant.getActorId().trim()).find());
|
.matcher(participant.getDisplayName().trim())
|
||||||
|
.find() ||
|
||||||
|
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
|
.matcher(participant.getActorId().trim())
|
||||||
|
.find());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -331,36 +229,14 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
|
|
||||||
static class UserItemViewHolder extends FlexibleViewHolder {
|
static class UserItemViewHolder extends FlexibleViewHolder {
|
||||||
|
|
||||||
@BindView(R.id.name_text)
|
RvItemContactBinding binding;
|
||||||
public EmojiTextView contactDisplayName;
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.avatar_drawee_view)
|
|
||||||
public SimpleDraweeView participantAvatar;
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.secondary_text)
|
|
||||||
public EmojiTextView contactMentionId;
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.videoCallIcon)
|
|
||||||
ImageView videoCallIconView;
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.checkedImageView)
|
|
||||||
ImageView checkedImageView;
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.participant_status_emoji)
|
|
||||||
com.vanniktech.emoji.EmojiEditText participantEmoji;
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.user_status_image)
|
|
||||||
ImageView userStatusImage;
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.conversation_info_status_message)
|
|
||||||
EmojiTextView statusMessage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
UserItemViewHolder(View view, FlexibleAdapter adapter) {
|
UserItemViewHolder(View view, FlexibleAdapter adapter) {
|
||||||
super(view, adapter);
|
super(view, adapter);
|
||||||
ButterKnife.bind(this, view);
|
binding = RvItemContactBinding.bind(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
}
|
}
|
||||||
|
|
||||||
UserItem newContactItem = new UserItem(
|
UserItem newContactItem = new UserItem(
|
||||||
getApplicationContext(),
|
|
||||||
participant,
|
participant,
|
||||||
currentUser,
|
currentUser,
|
||||||
userHeaderItems.get(headerTitle)
|
userHeaderItems.get(headerTitle)
|
||||||
|
@ -49,7 +49,7 @@ import com.bluelinelabs.conductor.RouterTransaction
|
|||||||
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
|
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco
|
import com.facebook.drawee.backends.pipeline.Fresco
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.adapters.items.UserItem
|
import com.nextcloud.talk.adapters.items.ParticipantItem
|
||||||
import com.nextcloud.talk.api.NcApi
|
import com.nextcloud.talk.api.NcApi
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||||
import com.nextcloud.talk.controllers.base.NewBaseController
|
import com.nextcloud.talk.controllers.base.NewBaseController
|
||||||
@ -87,6 +87,7 @@ import io.reactivex.schedulers.Schedulers
|
|||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
import java.util.ArrayList
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.Comparator
|
import java.util.Comparator
|
||||||
@ -122,8 +123,8 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
private var databaseStorageModule: DatabaseStorageModule? = null
|
private var databaseStorageModule: DatabaseStorageModule? = null
|
||||||
private var conversation: Conversation? = null
|
private var conversation: Conversation? = null
|
||||||
|
|
||||||
private var adapter: FlexibleAdapter<UserItem>? = null
|
private var adapter: FlexibleAdapter<ParticipantItem>? = null
|
||||||
private var userItems: MutableList<UserItem> = ArrayList()
|
private var userItems: MutableList<ParticipantItem> = ArrayList()
|
||||||
|
|
||||||
private var saveStateHandler: LovelySaveStateHandler? = null
|
private var saveStateHandler: LovelySaveStateHandler? = null
|
||||||
|
|
||||||
@ -378,15 +379,15 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleParticipants(participants: List<Participant>) {
|
private fun handleParticipants(participants: List<Participant>) {
|
||||||
var userItem: UserItem
|
var userItem: ParticipantItem
|
||||||
var participant: Participant
|
var participant: Participant
|
||||||
|
|
||||||
userItems = ArrayList()
|
userItems = ArrayList()
|
||||||
var ownUserItem: UserItem? = null
|
var ownUserItem: ParticipantItem? = null
|
||||||
|
|
||||||
for (i in participants.indices) {
|
for (i in participants.indices) {
|
||||||
participant = participants[i]
|
participant = participants[i]
|
||||||
userItem = UserItem(router.activity, participant, conversationUser, null)
|
userItem = ParticipantItem(router.activity, participant, conversationUser)
|
||||||
if (participant.sessionId != null) {
|
if (participant.sessionId != null) {
|
||||||
userItem.isOnline = !participant.sessionId.equals("0")
|
userItem.isOnline = !participant.sessionId.equals("0")
|
||||||
} else {
|
} else {
|
||||||
@ -402,7 +403,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(userItems, UserItemComparator())
|
Collections.sort(userItems, ParticipantItemComparator())
|
||||||
|
|
||||||
if (ownUserItem != null) {
|
if (ownUserItem != null) {
|
||||||
userItems.add(0, ownUserItem)
|
userItems.add(0, ownUserItem)
|
||||||
@ -956,7 +957,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
val userItem = adapter?.getItem(position) as UserItem
|
val userItem = adapter?.getItem(position) as ParticipantItem
|
||||||
val participant = userItem.model
|
val participant = userItem.model
|
||||||
|
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||||
@ -1108,8 +1109,8 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
/**
|
/**
|
||||||
* Comparator for participants, sorts by online-status, moderator-status and display name.
|
* Comparator for participants, sorts by online-status, moderator-status and display name.
|
||||||
*/
|
*/
|
||||||
class UserItemComparator : Comparator<UserItem> {
|
class ParticipantItemComparator : Comparator<ParticipantItem> {
|
||||||
override fun compare(left: UserItem, right: UserItem): Int {
|
override fun compare(left: ParticipantItem, right: ParticipantItem): Int {
|
||||||
val leftIsGroup = left.model.actorType == GROUPS || left.model.actorType == CIRCLES
|
val leftIsGroup = left.model.actorType == GROUPS || left.model.actorType == CIRCLES
|
||||||
val rightIsGroup = right.model.actorType == GROUPS || right.model.actorType == CIRCLES
|
val rightIsGroup = right.model.actorType == GROUPS || right.model.actorType == CIRCLES
|
||||||
if (leftIsGroup != rightIsGroup) {
|
if (leftIsGroup != rightIsGroup) {
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
android:layout_marginBottom="@dimen/standard_half_margin"
|
android:layout_marginBottom="@dimen/standard_half_margin"
|
||||||
android:layout_marginTop="@dimen/standard_margin">
|
android:layout_marginTop="@dimen/standard_margin">
|
||||||
|
|
||||||
|
|
||||||
<com.facebook.drawee.view.SimpleDraweeView
|
<com.facebook.drawee.view.SimpleDraweeView
|
||||||
android:id="@+id/avatar_drawee_view"
|
android:id="@+id/avatar_drawee_view"
|
||||||
android:layout_width="@dimen/small_item_height"
|
android:layout_width="@dimen/small_item_height"
|
||||||
|
Loading…
Reference in New Issue
Block a user