|
@@ -20,15 +20,12 @@
|
|
|
|
|
|
package com.nextcloud.talk.adapters.items;
|
|
package com.nextcloud.talk.adapters.items;
|
|
|
|
|
|
|
|
+import android.content.Context;
|
|
import android.content.res.Resources;
|
|
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 android.widget.ImageView;
|
|
|
|
|
|
-import androidx.annotation.Nullable;
|
|
|
|
-import androidx.core.content.res.ResourcesCompat;
|
|
|
|
-import androidx.emoji.widget.EmojiTextView;
|
|
|
|
-
|
|
|
|
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.facebook.drawee.view.SimpleDraweeView;
|
|
@@ -38,12 +35,17 @@ import com.nextcloud.talk.models.database.UserEntity;
|
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
|
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.participants.Participant.InCallFlags;
|
|
|
|
+import com.nextcloud.talk.models.json.status.StatusType;
|
|
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.core.content.ContextCompat;
|
|
|
|
+import androidx.core.content.res.ResourcesCompat;
|
|
|
|
+import androidx.emoji.widget.EmojiTextView;
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
import butterknife.ButterKnife;
|
|
import butterknife.ButterKnife;
|
|
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
|
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
|
@@ -54,14 +56,19 @@ import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
|
import eu.davidea.viewholders.FlexibleViewHolder;
|
|
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 Context context;
|
|
private Participant participant;
|
|
private Participant participant;
|
|
private UserEntity userEntity;
|
|
private UserEntity userEntity;
|
|
private GenericTextHeaderItem header;
|
|
private GenericTextHeaderItem header;
|
|
public boolean isOnline = true;
|
|
public boolean isOnline = true;
|
|
|
|
|
|
- public UserItem(Participant participant, UserEntity userEntity, GenericTextHeaderItem genericTextHeaderItem) {
|
|
|
|
|
|
+ public UserItem(Context activityContext,
|
|
|
|
+ Participant participant,
|
|
|
|
+ UserEntity userEntity,
|
|
|
|
+ GenericTextHeaderItem genericTextHeaderItem) {
|
|
|
|
+ this.context = activityContext;
|
|
this.participant = participant;
|
|
this.participant = participant;
|
|
this.userEntity = userEntity;
|
|
this.userEntity = userEntity;
|
|
this.header = genericTextHeaderItem;
|
|
this.header = genericTextHeaderItem;
|
|
@@ -72,7 +79,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|
if (o instanceof UserItem) {
|
|
if (o instanceof UserItem) {
|
|
UserItem inItem = (UserItem) o;
|
|
UserItem inItem = (UserItem) o;
|
|
return participant.getActorType() == inItem.getModel().getActorType() &&
|
|
return participant.getActorType() == inItem.getModel().getActorType() &&
|
|
- participant.getActorId().equals(inItem.getModel().getActorId());
|
|
|
|
|
|
+ participant.getActorId().equals(inItem.getModel().getActorId());
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -112,7 +119,7 @@ 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) {
|
|
|
|
|
|
- holder.simpleDraweeView.setController(null);
|
|
|
|
|
|
+ holder.participantAvatar.setController(null);
|
|
|
|
|
|
if (holder.checkedImageView != null) {
|
|
if (holder.checkedImageView != null) {
|
|
if (participant.isSelected()) {
|
|
if (participant.isSelected()) {
|
|
@@ -122,69 +129,88 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (participant.status != null && participant.status.equals(StatusType.DND.getString())) {
|
|
|
|
+ setOnlineStateIcon(holder, R.drawable.ic_user_status_dnd_with_border);
|
|
|
|
+ } else if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
|
|
|
|
+ holder.participantOnlineStateImage.setVisibility(View.GONE);
|
|
|
|
+ holder.participantEmoji.setVisibility(View.VISIBLE);
|
|
|
|
+ holder.participantEmoji.setText(participant.statusIcon);
|
|
|
|
+ } else if (participant.status != null && participant.status.equals(StatusType.AWAY.getString())) {
|
|
|
|
+ setOnlineStateIcon(holder, R.drawable.ic_user_status_away_with_border);
|
|
|
|
+ } else if (participant.status != null && participant.status.equals(StatusType.ONLINE.getString())) {
|
|
|
|
+ setOnlineStateIcon(holder, R.drawable.online_status_with_border);
|
|
|
|
+ } else {
|
|
|
|
+ holder.participantEmoji.setVisibility(View.GONE);
|
|
|
|
+ holder.participantOnlineStateImage.setVisibility(View.GONE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (participant.statusMessage != null) {
|
|
|
|
+ holder.statusMessage.setText(participant.statusMessage);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!isOnline) {
|
|
if (!isOnline) {
|
|
holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(
|
|
holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(
|
|
- holder.contactDisplayName.getContext().getResources(),
|
|
|
|
- R.color.medium_emphasis_text,
|
|
|
|
- null)
|
|
|
|
- );
|
|
|
|
- holder.simpleDraweeView.setAlpha(0.38f);
|
|
|
|
|
|
+ holder.contactDisplayName.getContext().getResources(),
|
|
|
|
+ R.color.medium_emphasis_text,
|
|
|
|
+ null)
|
|
|
|
+ );
|
|
|
|
+ holder.participantAvatar.setAlpha(0.38f);
|
|
} else {
|
|
} else {
|
|
holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(
|
|
holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(
|
|
- holder.contactDisplayName.getContext().getResources(),
|
|
|
|
- R.color.high_emphasis_text,
|
|
|
|
- null)
|
|
|
|
- );
|
|
|
|
- holder.simpleDraweeView.setAlpha(1.0f);
|
|
|
|
|
|
+ holder.contactDisplayName.getContext().getResources(),
|
|
|
|
+ R.color.high_emphasis_text,
|
|
|
|
+ null)
|
|
|
|
+ );
|
|
|
|
+ holder.participantAvatar.setAlpha(1.0f);
|
|
}
|
|
}
|
|
|
|
|
|
if (adapter.hasFilter()) {
|
|
if (adapter.hasFilter()) {
|
|
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getDisplayName(),
|
|
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getDisplayName(),
|
|
- String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.Companion.getSharedApplication()
|
|
|
|
- .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.contactDisplayName.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) || participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
|
|
holder.contactDisplayName.setText(NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest));
|
|
holder.contactDisplayName.setText(NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest));
|
|
}
|
|
}
|
|
|
|
|
|
if (participant.getActorType() == Participant.ActorType.GROUPS ||
|
|
if (participant.getActorType() == Participant.ActorType.GROUPS ||
|
|
- "groups".equals(participant.getSource()) ||
|
|
|
|
- participant.getActorType() == Participant.ActorType.CIRCLES ||
|
|
|
|
- "circles".equals(participant.getSource())) {
|
|
|
|
- holder.simpleDraweeView.setImageResource(R.drawable.ic_circular_group);
|
|
|
|
|
|
+ "groups".equals(participant.getSource()) ||
|
|
|
|
+ participant.getActorType() == Participant.ActorType.CIRCLES ||
|
|
|
|
+ "circles".equals(participant.getSource())) {
|
|
|
|
+ holder.participantAvatar.setImageResource(R.drawable.ic_circular_group);
|
|
} else if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
|
} else if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
|
- holder.simpleDraweeView.setImageResource(R.drawable.ic_circular_mail);
|
|
|
|
|
|
+ holder.participantAvatar.setImageResource(R.drawable.ic_circular_mail);
|
|
} else if (participant.getActorType() == Participant.ActorType.GUESTS ||
|
|
} else if (participant.getActorType() == Participant.ActorType.GUESTS ||
|
|
- Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
|
|
|
- Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
if (!TextUtils.isEmpty(participant.getDisplayName())) {
|
|
if (!TextUtils.isEmpty(participant.getDisplayName())) {
|
|
displayName = participant.getDisplayName();
|
|
displayName = participant.getDisplayName();
|
|
}
|
|
}
|
|
|
|
|
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
|
- .setOldController(holder.simpleDraweeView.getController())
|
|
|
|
- .setAutoPlayAnimations(true)
|
|
|
|
- .setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithNameForGuests(userEntity.getBaseUrl(),
|
|
|
|
- displayName, R.dimen.avatar_size), null))
|
|
|
|
- .build();
|
|
|
|
- holder.simpleDraweeView.setController(draweeController);
|
|
|
|
|
|
+ .setOldController(holder.participantAvatar.getController())
|
|
|
|
+ .setAutoPlayAnimations(true)
|
|
|
|
+ .setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithNameForGuests(userEntity.getBaseUrl(),
|
|
|
|
+ displayName, R.dimen.avatar_size), null))
|
|
|
|
+ .build();
|
|
|
|
+ holder.participantAvatar.setController(draweeController);
|
|
|
|
|
|
} else if (participant.getActorType() == Participant.ActorType.USERS || participant.getSource().equals("users")) {
|
|
} else if (participant.getActorType() == Participant.ActorType.USERS || participant.getSource().equals("users")) {
|
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
|
- .setOldController(holder.simpleDraweeView.getController())
|
|
|
|
- .setAutoPlayAnimations(true)
|
|
|
|
- .setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
|
|
|
- participant.getActorId(), R.dimen.avatar_size), null))
|
|
|
|
- .build();
|
|
|
|
- holder.simpleDraweeView.setController(draweeController);
|
|
|
|
|
|
+ .setOldController(holder.participantAvatar.getController())
|
|
|
|
+ .setAutoPlayAnimations(true)
|
|
|
|
+ .setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
|
|
|
+ participant.getActorId(), R.dimen.avatar_size), null))
|
|
|
|
+ .build();
|
|
|
|
+ holder.participantAvatar.setController(draweeController);
|
|
}
|
|
}
|
|
|
|
|
|
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
|
|
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
|
|
@@ -195,17 +221,17 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|
holder.videoCallIconView.setImageResource(R.drawable.ic_call_grey_600_24dp);
|
|
holder.videoCallIconView.setImageResource(R.drawable.ic_call_grey_600_24dp);
|
|
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
holder.videoCallIconView.setContentDescription(
|
|
holder.videoCallIconView.setContentDescription(
|
|
- resources.getString(R.string.nc_call_state_with_phone, participant.displayName));
|
|
|
|
|
|
+ resources.getString(R.string.nc_call_state_with_phone, participant.displayName));
|
|
} else if ((inCallFlag & InCallFlags.WITH_VIDEO) > 0) {
|
|
} else if ((inCallFlag & InCallFlags.WITH_VIDEO) > 0) {
|
|
holder.videoCallIconView.setImageResource(R.drawable.ic_videocam_grey_600_24dp);
|
|
holder.videoCallIconView.setImageResource(R.drawable.ic_videocam_grey_600_24dp);
|
|
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
holder.videoCallIconView.setContentDescription(
|
|
holder.videoCallIconView.setContentDescription(
|
|
- resources.getString(R.string.nc_call_state_with_video, participant.displayName));
|
|
|
|
|
|
+ resources.getString(R.string.nc_call_state_with_video, participant.displayName));
|
|
} else if (inCallFlag > InCallFlags.DISCONNECTED) {
|
|
} else if (inCallFlag > InCallFlags.DISCONNECTED) {
|
|
holder.videoCallIconView.setImageResource(R.drawable.ic_mic_grey_600_24dp);
|
|
holder.videoCallIconView.setImageResource(R.drawable.ic_mic_grey_600_24dp);
|
|
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
holder.videoCallIconView.setVisibility(View.VISIBLE);
|
|
holder.videoCallIconView.setContentDescription(
|
|
holder.videoCallIconView.setContentDescription(
|
|
- resources.getString(R.string.nc_call_state_in_call, participant.displayName));
|
|
|
|
|
|
+ resources.getString(R.string.nc_call_state_in_call, participant.displayName));
|
|
} else {
|
|
} else {
|
|
holder.videoCallIconView.setVisibility(View.GONE);
|
|
holder.videoCallIconView.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
@@ -250,11 +276,17 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void setOnlineStateIcon(UserItem.UserItemViewHolder holder, int icon) {
|
|
|
|
+ holder.participantEmoji.setVisibility(View.GONE);
|
|
|
|
+ holder.participantOnlineStateImage.setVisibility(View.VISIBLE);
|
|
|
|
+ holder.participantOnlineStateImage.setImageDrawable(ContextCompat.getDrawable(context, icon));
|
|
|
|
+ }
|
|
|
|
+
|
|
@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).matcher(participant.getActorId().trim()).find());
|
|
|
|
|
|
+ (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());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -271,8 +303,8 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|
|
|
|
|
@BindView(R.id.name_text)
|
|
@BindView(R.id.name_text)
|
|
public EmojiTextView contactDisplayName;
|
|
public EmojiTextView contactDisplayName;
|
|
- @BindView(R.id.simple_drawee_view)
|
|
|
|
- public SimpleDraweeView simpleDraweeView;
|
|
|
|
|
|
+ @BindView(R.id.conversation_info_participant_avatar)
|
|
|
|
+ public SimpleDraweeView participantAvatar;
|
|
@Nullable
|
|
@Nullable
|
|
@BindView(R.id.secondary_text)
|
|
@BindView(R.id.secondary_text)
|
|
public EmojiTextView contactMentionId;
|
|
public EmojiTextView contactMentionId;
|
|
@@ -282,6 +314,12 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|
@Nullable
|
|
@Nullable
|
|
@BindView(R.id.checkedImageView)
|
|
@BindView(R.id.checkedImageView)
|
|
ImageView checkedImageView;
|
|
ImageView checkedImageView;
|
|
|
|
+ @BindView(R.id.conversation_info_participant_emoji)
|
|
|
|
+ com.vanniktech.emoji.EmojiEditText participantEmoji;
|
|
|
|
+ @BindView(R.id.conversation_info_participant_online_state)
|
|
|
|
+ ImageView participantOnlineStateImage;
|
|
|
|
+ @BindView(R.id.conversation_info_status_message)
|
|
|
|
+ EmojiTextView statusMessage;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Default constructor.
|
|
* Default constructor.
|