mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
Migrate participant to kotlin data class
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
20ba0e80f2
commit
a617f10473
@ -2240,8 +2240,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
String userId = "";
|
String userId = "";
|
||||||
if (hasMCU) {
|
if (hasMCU) {
|
||||||
userId = webSocketClient.getUserIdForSession(session);
|
userId = webSocketClient.getUserIdForSession(session);
|
||||||
} else if (participantMap.get(session).getActorType() == Participant.ActorType.USERS) {
|
} else if (participantMap.get(session).getCalculatedActorType() == Participant.ActorType.USERS) {
|
||||||
userId = participantMap.get(session).getActorId();
|
userId = participantMap.get(session).getCalculatedActorId();
|
||||||
}
|
}
|
||||||
|
|
||||||
String urlForAvatar;
|
String urlForAvatar;
|
||||||
|
@ -238,8 +238,8 @@ public class CallNotificationActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
if (hasParticipantsInCall) {
|
if (hasParticipantsInCall) {
|
||||||
for (Participant participant : participantList) {
|
for (Participant participant : participantList) {
|
||||||
if (participant.getActorType() == Participant.ActorType.USERS &&
|
if (participant.getCalculatedActorType() == Participant.ActorType.USERS &&
|
||||||
participant.getActorId().equals(userBeingCalled.getUserId())) {
|
participant.getCalculatedActorId().equals(userBeingCalled.getUserId())) {
|
||||||
inCallOnDifferentDevice = true;
|
inCallOnDifferentDevice = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
|
|||||||
DisplayUtils.getImageRequestForUrl(
|
DisplayUtils.getImageRequestForUrl(
|
||||||
ApiUtils.getUrlForAvatar(
|
ApiUtils.getUrlForAvatar(
|
||||||
userEntity.getBaseUrl(),
|
userEntity.getBaseUrl(),
|
||||||
participant.getActorId(),
|
participant.getCalculatedActorId(),
|
||||||
true),
|
true),
|
||||||
null))
|
null))
|
||||||
.build();
|
.build();
|
||||||
|
@ -73,8 +73,8 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof ContactItem) {
|
if (o instanceof ContactItem) {
|
||||||
ContactItem inItem = (ContactItem) o;
|
ContactItem inItem = (ContactItem) o;
|
||||||
return participant.getActorType() == inItem.getModel().getActorType() &&
|
return participant.getCalculatedActorType() == inItem.getModel().getCalculatedActorType() &&
|
||||||
participant.getActorId().equals(inItem.getModel().getActorId());
|
participant.getCalculatedActorId().equals(inItem.getModel().getCalculatedActorId());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||||||
public void bindViewHolder(FlexibleAdapter adapter, ContactItemViewHolder holder, int position, List payloads) {
|
public void bindViewHolder(FlexibleAdapter adapter, ContactItemViewHolder holder, int position, List payloads) {
|
||||||
holder.binding.avatarDraweeView.setController(null);
|
holder.binding.avatarDraweeView.setController(null);
|
||||||
|
|
||||||
if (participant.isSelected()) {
|
if (participant.getSelected()) {
|
||||||
holder.binding.checkedImageView.setVisibility(View.VISIBLE);
|
holder.binding.checkedImageView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.binding.checkedImageView.setVisibility(View.GONE);
|
holder.binding.checkedImageView.setVisibility(View.GONE);
|
||||||
@ -152,19 +152,19 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
participant.getActorType() == Participant.ActorType.GROUPS ||
|
participant.getCalculatedActorType() == Participant.ActorType.GROUPS ||
|
||||||
PARTICIPANT_SOURCE_GROUPS.equals(participant.getSource()) ||
|
PARTICIPANT_SOURCE_GROUPS.equals(participant.getSource()) ||
|
||||||
participant.getActorType() == Participant.ActorType.CIRCLES ||
|
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES ||
|
||||||
PARTICIPANT_SOURCE_CIRCLES.equals(participant.getSource())) {
|
PARTICIPANT_SOURCE_CIRCLES.equals(participant.getSource())) {
|
||||||
|
|
||||||
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
|
||||||
|
|
||||||
} else if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.EMAILS) {
|
||||||
|
|
||||||
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail);
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail);
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
participant.getActorType() == Participant.ActorType.GUESTS ||
|
participant.getCalculatedActorType() == Participant.ActorType.GUESTS ||
|
||||||
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
||||||
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
||||||
|
|
||||||
@ -186,14 +186,14 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||||||
.build();
|
.build();
|
||||||
holder.binding.avatarDraweeView.setController(draweeController);
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
|
|
||||||
} else if (participant.getActorType() == Participant.ActorType.USERS ||
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.USERS ||
|
||||||
PARTICIPANT_SOURCE_USERS.equals(participant.getSource())) {
|
PARTICIPANT_SOURCE_USERS.equals(participant.getSource())) {
|
||||||
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
.setOldController(holder.binding.avatarDraweeView.getController())
|
.setOldController(holder.binding.avatarDraweeView.getController())
|
||||||
.setAutoPlayAnimations(true)
|
.setAutoPlayAnimations(true)
|
||||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
||||||
ApiUtils.getUrlForAvatar(userEntity.getBaseUrl(),
|
ApiUtils.getUrlForAvatar(userEntity.getBaseUrl(),
|
||||||
participant.getActorId(),
|
participant.getCalculatedActorId(),
|
||||||
false),
|
false),
|
||||||
null))
|
null))
|
||||||
.build();
|
.build();
|
||||||
@ -208,7 +208,7 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||||||
.matcher(participant.getDisplayName().trim())
|
.matcher(participant.getDisplayName().trim())
|
||||||
.find() ||
|
.find() ||
|
||||||
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
.matcher(participant.getActorId().trim())
|
.matcher(participant.getCalculatedActorId().trim())
|
||||||
.find());
|
.find());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof ParticipantItem) {
|
if (o instanceof ParticipantItem) {
|
||||||
ParticipantItem inItem = (ParticipantItem) o;
|
ParticipantItem inItem = (ParticipantItem) o;
|
||||||
return participant.getActorType() == inItem.getModel().getActorType() &&
|
return participant.getCalculatedActorType() == inItem.getModel().getCalculatedActorType() &&
|
||||||
participant.getActorId().equals(inItem.getModel().getActorId());
|
participant.getCalculatedActorId().equals(inItem.getModel().getCalculatedActorId());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -146,14 +146,14 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
.getString(R.string.nc_guest));
|
.getString(R.string.nc_guest));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.getActorType() == Participant.ActorType.GROUPS ||
|
if (participant.getCalculatedActorType() == Participant.ActorType.GROUPS ||
|
||||||
"groups".equals(participant.getSource()) ||
|
"groups".equals(participant.getSource()) ||
|
||||||
participant.getActorType() == Participant.ActorType.CIRCLES ||
|
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES ||
|
||||||
"circles".equals(participant.getSource())) {
|
"circles".equals(participant.getSource())) {
|
||||||
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
|
||||||
} else if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.EMAILS) {
|
||||||
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail);
|
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail);
|
||||||
} else if (participant.getActorType() == Participant.ActorType.GUESTS ||
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.GUESTS ||
|
||||||
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
|
||||||
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
|
||||||
|
|
||||||
@ -173,36 +173,36 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
.build();
|
.build();
|
||||||
holder.binding.avatarDraweeView.setController(draweeController);
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
|
|
||||||
} else if (participant.getActorType() == Participant.ActorType.USERS ||
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.USERS ||
|
||||||
participant.getSource().equals("users")) {
|
participant.getSource().equals("users")) {
|
||||||
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
.setOldController(holder.binding.avatarDraweeView.getController())
|
.setOldController(holder.binding.avatarDraweeView.getController())
|
||||||
.setAutoPlayAnimations(true)
|
.setAutoPlayAnimations(true)
|
||||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
||||||
ApiUtils.getUrlForAvatar(userEntity.getBaseUrl(),
|
ApiUtils.getUrlForAvatar(userEntity.getBaseUrl(),
|
||||||
participant.getActorId(), false), null))
|
participant.getCalculatedActorId(), false), null))
|
||||||
.build();
|
.build();
|
||||||
holder.binding.avatarDraweeView.setController(draweeController);
|
holder.binding.avatarDraweeView.setController(draweeController);
|
||||||
}
|
}
|
||||||
|
|
||||||
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
|
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
|
||||||
|
|
||||||
Long inCallFlag = participant.getInCall();
|
long inCallFlag = participant.getInCall();
|
||||||
if ((inCallFlag & InCallFlags.WITH_PHONE) > 0) {
|
if ((inCallFlag & InCallFlags.WITH_PHONE) > 0) {
|
||||||
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_call_grey_600_24dp);
|
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_call_grey_600_24dp);
|
||||||
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
||||||
holder.binding.videoCallIcon.setContentDescription(
|
holder.binding.videoCallIcon.setContentDescription(
|
||||||
resources.getString(R.string.nc_call_state_with_phone, participant.displayName));
|
resources.getString(R.string.nc_call_state_with_phone, participant.getDisplayName()));
|
||||||
} else if ((inCallFlag & InCallFlags.WITH_VIDEO) > 0) {
|
} else if ((inCallFlag & InCallFlags.WITH_VIDEO) > 0) {
|
||||||
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_videocam_grey_600_24dp);
|
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_videocam_grey_600_24dp);
|
||||||
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
||||||
holder.binding.videoCallIcon.setContentDescription(
|
holder.binding.videoCallIcon.setContentDescription(
|
||||||
resources.getString(R.string.nc_call_state_with_video, participant.displayName));
|
resources.getString(R.string.nc_call_state_with_video, participant.getDisplayName()));
|
||||||
} else if (inCallFlag > InCallFlags.DISCONNECTED) {
|
} else if (inCallFlag > InCallFlags.DISCONNECTED) {
|
||||||
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_mic_grey_600_24dp);
|
holder.binding.videoCallIcon.setImageResource(R.drawable.ic_mic_grey_600_24dp);
|
||||||
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
holder.binding.videoCallIcon.setVisibility(View.VISIBLE);
|
||||||
holder.binding.videoCallIcon.setContentDescription(
|
holder.binding.videoCallIcon.setContentDescription(
|
||||||
resources.getString(R.string.nc_call_state_in_call, participant.displayName));
|
resources.getString(R.string.nc_call_state_in_call, participant.getDisplayName()));
|
||||||
} else {
|
} else {
|
||||||
holder.binding.videoCallIcon.setVisibility(View.GONE);
|
holder.binding.videoCallIcon.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@ -226,13 +226,13 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
.Companion
|
.Companion
|
||||||
.getSharedApplication()
|
.getSharedApplication()
|
||||||
.getString(R.string.nc_user);
|
.getString(R.string.nc_user);
|
||||||
if (participant.getActorType() == Participant.ActorType.GROUPS) {
|
if (participant.getCalculatedActorType() == Participant.ActorType.GROUPS) {
|
||||||
userType = NextcloudTalkApplication
|
userType = NextcloudTalkApplication
|
||||||
.Companion
|
.Companion
|
||||||
.getSharedApplication()
|
.getSharedApplication()
|
||||||
.getString(R.string.nc_group);
|
.getString(R.string.nc_group);
|
||||||
}
|
}
|
||||||
if (participant.getActorType() == Participant.ActorType.CIRCLES) {
|
if (participant.getCalculatedActorType() == Participant.ActorType.CIRCLES) {
|
||||||
userType = NextcloudTalkApplication
|
userType = NextcloudTalkApplication
|
||||||
.Companion
|
.Companion
|
||||||
.getSharedApplication()
|
.getSharedApplication()
|
||||||
@ -241,7 +241,7 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest);
|
userType = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest);
|
||||||
if (participant.getActorType() == Participant.ActorType.EMAILS) {
|
if (participant.getCalculatedActorType() == Participant.ActorType.EMAILS) {
|
||||||
userType = NextcloudTalkApplication
|
userType = NextcloudTalkApplication
|
||||||
.Companion
|
.Companion
|
||||||
.getSharedApplication()
|
.getSharedApplication()
|
||||||
@ -270,32 +270,32 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
private void drawStatus(ParticipantItemViewHolder holder) {
|
private void drawStatus(ParticipantItemViewHolder holder) {
|
||||||
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
|
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
|
||||||
holder.binding.userStatusImage.setImageDrawable(new StatusDrawable(
|
holder.binding.userStatusImage.setImageDrawable(new StatusDrawable(
|
||||||
participant.status,
|
participant.getStatus(),
|
||||||
NO_ICON,
|
NO_ICON,
|
||||||
size,
|
size,
|
||||||
context.getResources().getColor(R.color.bg_default),
|
context.getResources().getColor(R.color.bg_default),
|
||||||
context));
|
context));
|
||||||
|
|
||||||
if (participant.statusMessage != null) {
|
if (participant.getStatusMessage() != null) {
|
||||||
holder.binding.conversationInfoStatusMessage.setText(participant.statusMessage);
|
holder.binding.conversationInfoStatusMessage.setText(participant.getStatusMessage());
|
||||||
alignUsernameVertical(holder, 0);
|
alignUsernameVertical(holder, 0);
|
||||||
} else {
|
} else {
|
||||||
holder.binding.conversationInfoStatusMessage.setText("");
|
holder.binding.conversationInfoStatusMessage.setText("");
|
||||||
alignUsernameVertical(holder, 10);
|
alignUsernameVertical(holder, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
|
if (participant.getStatusIcon() != null && !participant.getStatusIcon().isEmpty()) {
|
||||||
holder.binding.participantStatusEmoji.setText(participant.statusIcon);
|
holder.binding.participantStatusEmoji.setText(participant.getStatusIcon());
|
||||||
} else {
|
} else {
|
||||||
holder.binding.participantStatusEmoji.setVisibility(View.GONE);
|
holder.binding.participantStatusEmoji.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.status != null && participant.status.equals(StatusType.DND.getString())) {
|
if (participant.getStatus() != null && participant.getStatus().equals(StatusType.DND.getString())) {
|
||||||
if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
|
if (participant.getStatusMessage() == null || participant.getStatusMessage().isEmpty()) {
|
||||||
holder.binding.conversationInfoStatusMessage.setText(R.string.dnd);
|
holder.binding.conversationInfoStatusMessage.setText(R.string.dnd);
|
||||||
}
|
}
|
||||||
} else if (participant.status != null && participant.status.equals(StatusType.AWAY.getString())) {
|
} else if (participant.getStatus() != null && participant.getStatus().equals(StatusType.AWAY.getString())) {
|
||||||
if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
|
if (participant.getStatusMessage() == null || participant.getStatusMessage().isEmpty()) {
|
||||||
holder.binding.conversationInfoStatusMessage.setText(R.string.away);
|
holder.binding.conversationInfoStatusMessage.setText(R.string.away);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
(Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
(Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||||
.matcher(participant.getDisplayName().trim()).find() ||
|
.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.getCalculatedActorId().trim()).find());
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ParticipantItemViewHolder extends FlexibleViewHolder {
|
static class ParticipantItemViewHolder extends FlexibleViewHolder {
|
||||||
|
@ -524,14 +524,14 @@ class ContactsController(args: Bundle) :
|
|||||||
|
|
||||||
private fun getHeaderTitle(participant: Participant): String {
|
private fun getHeaderTitle(participant: Participant): String {
|
||||||
return when {
|
return when {
|
||||||
participant.getActorType() == Participant.ActorType.GROUPS -> {
|
participant.calculatedActorType == Participant.ActorType.GROUPS -> {
|
||||||
resources!!.getString(R.string.nc_groups)
|
resources!!.getString(R.string.nc_groups)
|
||||||
}
|
}
|
||||||
participant.getActorType() == Participant.ActorType.CIRCLES -> {
|
participant.calculatedActorType == Participant.ActorType.CIRCLES -> {
|
||||||
resources!!.getString(R.string.nc_circles)
|
resources!!.getString(R.string.nc_circles)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
participant.getDisplayName().substring(0, 1).toUpperCase(Locale.getDefault())
|
participant.displayName!!.substring(0, 1).toUpperCase(Locale.getDefault())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,10 +541,10 @@ class ContactsController(args: Bundle) :
|
|||||||
actorTypeConverter: EnumActorTypeConverter
|
actorTypeConverter: EnumActorTypeConverter
|
||||||
): Participant {
|
): Participant {
|
||||||
val participant = Participant()
|
val participant = Participant()
|
||||||
participant.setActorId(autocompleteUser.id)
|
participant.actorId = autocompleteUser.id
|
||||||
participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.source))
|
participant.actorType = actorTypeConverter.getFromString(autocompleteUser.source)
|
||||||
participant.setDisplayName(autocompleteUser.label)
|
participant.displayName = autocompleteUser.label
|
||||||
participant.setSource(autocompleteUser.source)
|
participant.source = autocompleteUser.source
|
||||||
|
|
||||||
return participant
|
return participant
|
||||||
}
|
}
|
||||||
@ -554,18 +554,18 @@ class ContactsController(args: Bundle) :
|
|||||||
newUserItemList,
|
newUserItemList,
|
||||||
{ o1: AbstractFlexibleItem<*>, o2: AbstractFlexibleItem<*> ->
|
{ o1: AbstractFlexibleItem<*>, o2: AbstractFlexibleItem<*> ->
|
||||||
val firstName: String = if (o1 is ContactItem) {
|
val firstName: String = if (o1 is ContactItem) {
|
||||||
(o1 as ContactItem).model.getDisplayName()
|
(o1 as ContactItem).model.displayName!!
|
||||||
} else {
|
} else {
|
||||||
(o1 as GenericTextHeaderItem).model
|
(o1 as GenericTextHeaderItem).model
|
||||||
}
|
}
|
||||||
val secondName: String = if (o2 is ContactItem) {
|
val secondName: String = if (o2 is ContactItem) {
|
||||||
(o2 as ContactItem).model.getDisplayName()
|
(o2 as ContactItem).model.displayName!!
|
||||||
} else {
|
} else {
|
||||||
(o2 as GenericTextHeaderItem).model
|
(o2 as GenericTextHeaderItem).model
|
||||||
}
|
}
|
||||||
if (o1 is ContactItem && o2 is ContactItem) {
|
if (o1 is ContactItem && o2 is ContactItem) {
|
||||||
val firstSource: String = (o1 as ContactItem).model.getSource()
|
val firstSource: String = (o1 as ContactItem).model.source!!
|
||||||
val secondSource: String = (o2 as ContactItem).model.getSource()
|
val secondSource: String = (o2 as ContactItem).model.source!!
|
||||||
if (firstSource == secondSource) {
|
if (firstSource == secondSource) {
|
||||||
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
||||||
}
|
}
|
||||||
@ -602,23 +602,23 @@ class ContactsController(args: Bundle) :
|
|||||||
contactItems
|
contactItems
|
||||||
) { o1: AbstractFlexibleItem<*>, o2: AbstractFlexibleItem<*> ->
|
) { o1: AbstractFlexibleItem<*>, o2: AbstractFlexibleItem<*> ->
|
||||||
val firstName: String = if (o1 is ContactItem) {
|
val firstName: String = if (o1 is ContactItem) {
|
||||||
(o1 as ContactItem).model.getDisplayName()
|
(o1 as ContactItem).model.displayName!!
|
||||||
} else {
|
} else {
|
||||||
(o1 as GenericTextHeaderItem).model
|
(o1 as GenericTextHeaderItem).model
|
||||||
}
|
}
|
||||||
val secondName: String = if (o2 is ContactItem) {
|
val secondName: String = if (o2 is ContactItem) {
|
||||||
(o2 as ContactItem).model.getDisplayName()
|
(o2 as ContactItem).model.displayName!!
|
||||||
} else {
|
} else {
|
||||||
(o2 as GenericTextHeaderItem).model
|
(o2 as GenericTextHeaderItem).model
|
||||||
}
|
}
|
||||||
if (o1 is ContactItem && o2 is ContactItem) {
|
if (o1 is ContactItem && o2 is ContactItem) {
|
||||||
if ("groups" == (o1 as ContactItem).model.getSource() &&
|
if ("groups" == (o1 as ContactItem).model.source &&
|
||||||
"groups" == (o2 as ContactItem).model.getSource()
|
"groups" == (o2 as ContactItem).model.source
|
||||||
) {
|
) {
|
||||||
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
||||||
} else if ("groups" == (o1 as ContactItem).model.getSource()) {
|
} else if ("groups" == (o1 as ContactItem).model.source) {
|
||||||
return@sort -1
|
return@sort -1
|
||||||
} else if ("groups" == (o2 as ContactItem).model.getSource()) {
|
} else if ("groups" == (o2 as ContactItem).model.source) {
|
||||||
return@sort 1
|
return@sort 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -776,7 +776,7 @@ class ContactsController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSelection(contactItem: ContactItem) {
|
private fun updateSelection(contactItem: ContactItem) {
|
||||||
contactItem.model.isSelected = !contactItem.model.isSelected
|
contactItem.model.selected = !contactItem.model.selected
|
||||||
updateSelectionLists(contactItem.model)
|
updateSelectionLists(contactItem.model)
|
||||||
if (CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "last-room-activity") &&
|
if (CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "last-room-activity") &&
|
||||||
!CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "invite-groups-and-mails") &&
|
!CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "invite-groups-and-mails") &&
|
||||||
@ -786,12 +786,12 @@ class ContactsController(args: Bundle) :
|
|||||||
var internalParticipant: Participant
|
var internalParticipant: Participant
|
||||||
for (i in currentItems.indices) {
|
for (i in currentItems.indices) {
|
||||||
internalParticipant = currentItems[i].model
|
internalParticipant = currentItems[i].model
|
||||||
if (internalParticipant.getActorId() == contactItem.model.getActorId() &&
|
if (internalParticipant.calculatedActorId == contactItem.model.calculatedActorId &&
|
||||||
internalParticipant.getActorType() == Participant.ActorType.GROUPS &&
|
internalParticipant.calculatedActorType == Participant.ActorType.GROUPS &&
|
||||||
internalParticipant.isSelected
|
internalParticipant.selected
|
||||||
) {
|
) {
|
||||||
internalParticipant.isSelected = false
|
internalParticipant.selected = false
|
||||||
selectedGroupIds.remove(internalParticipant.getActorId())
|
selectedGroupIds.remove(internalParticipant.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -801,7 +801,7 @@ class ContactsController(args: Bundle) :
|
|||||||
|
|
||||||
private fun createRoom(contactItem: ContactItem) {
|
private fun createRoom(contactItem: ContactItem) {
|
||||||
var roomType = "1"
|
var roomType = "1"
|
||||||
if ("groups" == contactItem.model.getSource()) {
|
if ("groups" == contactItem.model.source) {
|
||||||
roomType = "2"
|
roomType = "2"
|
||||||
}
|
}
|
||||||
val apiVersion: Int = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, 1))
|
val apiVersion: Int = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||||
@ -810,7 +810,7 @@ class ContactsController(args: Bundle) :
|
|||||||
currentUser!!.baseUrl,
|
currentUser!!.baseUrl,
|
||||||
roomType,
|
roomType,
|
||||||
null,
|
null,
|
||||||
contactItem.model.getActorId(),
|
contactItem.model.calculatedActorId,
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
ncApi.createRoom(
|
ncApi.createRoom(
|
||||||
@ -853,29 +853,29 @@ class ContactsController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSelectionLists(participant: Participant) {
|
private fun updateSelectionLists(participant: Participant) {
|
||||||
if ("groups" == participant.getSource()) {
|
if ("groups" == participant.source) {
|
||||||
if (participant.isSelected) {
|
if (participant.selected) {
|
||||||
selectedGroupIds.add(participant.getActorId())
|
selectedGroupIds.add(participant.calculatedActorId!!)
|
||||||
} else {
|
} else {
|
||||||
selectedGroupIds.remove(participant.getActorId())
|
selectedGroupIds.remove(participant.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
} else if ("emails" == participant.getSource()) {
|
} else if ("emails" == participant.source) {
|
||||||
if (participant.isSelected) {
|
if (participant.selected) {
|
||||||
selectedEmails.add(participant.getActorId())
|
selectedEmails.add(participant.calculatedActorId!!)
|
||||||
} else {
|
} else {
|
||||||
selectedEmails.remove(participant.getActorId())
|
selectedEmails.remove(participant.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
} else if ("circles" == participant.getSource()) {
|
} else if ("circles" == participant.source) {
|
||||||
if (participant.isSelected) {
|
if (participant.selected) {
|
||||||
selectedCircleIds.add(participant.getActorId())
|
selectedCircleIds.add(participant.calculatedActorId!!)
|
||||||
} else {
|
} else {
|
||||||
selectedCircleIds.remove(participant.getActorId())
|
selectedCircleIds.remove(participant.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (participant.isSelected) {
|
if (participant.selected) {
|
||||||
selectedUserIds.add(participant.getActorId())
|
selectedUserIds.add(participant.calculatedActorId!!)
|
||||||
} else {
|
} else {
|
||||||
selectedUserIds.remove(participant.getActorId())
|
selectedUserIds.remove(participant.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -885,7 +885,7 @@ class ContactsController(args: Bundle) :
|
|||||||
participant: Participant,
|
participant: Participant,
|
||||||
adapter: FlexibleAdapter<*>?
|
adapter: FlexibleAdapter<*>?
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return "groups" == contactItem.model.getSource() && participant.isSelected && adapter?.selectedItemCount!! > 1
|
return "groups" == contactItem.model.source && participant.selected && adapter?.selectedItemCount!! > 1
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun joinConversationViaLink() {
|
private fun joinConversationViaLink() {
|
||||||
@ -917,11 +917,11 @@ class ContactsController(args: Bundle) :
|
|||||||
for (i in currentItems.indices) {
|
for (i in currentItems.indices) {
|
||||||
if (currentItems[i] is ContactItem) {
|
if (currentItems[i] is ContactItem) {
|
||||||
internalParticipant = (currentItems[i] as ContactItem).model
|
internalParticipant = (currentItems[i] as ContactItem).model
|
||||||
if (internalParticipant.getActorType() == Participant.ActorType.GROUPS &&
|
if (internalParticipant.calculatedActorType == Participant.ActorType.GROUPS &&
|
||||||
internalParticipant.isSelected
|
internalParticipant.selected
|
||||||
) {
|
) {
|
||||||
internalParticipant.isSelected = false
|
internalParticipant.selected = false
|
||||||
selectedGroupIds.remove(internalParticipant.getActorId())
|
selectedGroupIds.remove(internalParticipant.calculatedActorId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -931,7 +931,7 @@ class ContactsController(args: Bundle) :
|
|||||||
for (i in 0 until adapter!!.itemCount) {
|
for (i in 0 until adapter!!.itemCount) {
|
||||||
if (adapter?.getItem(i) is ContactItem) {
|
if (adapter?.getItem(i) is ContactItem) {
|
||||||
val contactItem: ContactItem = adapter?.getItem(i) as ContactItem
|
val contactItem: ContactItem = adapter?.getItem(i) as ContactItem
|
||||||
if ("groups" == contactItem.model.getSource()) {
|
if ("groups" == contactItem.model.source) {
|
||||||
contactItem.isEnabled = !isPublicCall
|
contactItem.isEnabled = !isPublicCall
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
userItem.isOnline = !participant.sessionIds!!.isEmpty()
|
userItem.isOnline = !participant.sessionIds!!.isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.getActorType() == USERS && participant.getActorId() == conversationUser!!.userId) {
|
if (participant.calculatedActorType == USERS && participant.calculatedActorId == conversationUser!!.userId) {
|
||||||
ownUserItem = userItem
|
ownUserItem = userItem
|
||||||
ownUserItem.model.sessionId = "-1"
|
ownUserItem.model.sessionId = "-1"
|
||||||
ownUserItem.isOnline = true
|
ownUserItem.isOnline = true
|
||||||
@ -494,8 +494,8 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
val existingParticipantsId = arrayListOf<String>()
|
val existingParticipantsId = arrayListOf<String>()
|
||||||
|
|
||||||
for (userItem in userItems) {
|
for (userItem in userItems) {
|
||||||
if (userItem.model.getActorType() == USERS) {
|
if (userItem.model.calculatedActorType == USERS) {
|
||||||
existingParticipantsId.add(userItem.model.getActorId())
|
existingParticipantsId.add(userItem.model.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -986,7 +986,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
|
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||||
|
|
||||||
if (participant.getActorType() == USERS && participant.getActorId() == conversationUser!!.userId) {
|
if (participant.calculatedActorType == USERS && participant.calculatedActorId == conversationUser!!.userId) {
|
||||||
if (participant.attendeePin?.isNotEmpty() == true) {
|
if (participant.attendeePin?.isNotEmpty() == true) {
|
||||||
val items = mutableListOf(
|
val items = mutableListOf(
|
||||||
BasicListItemWithImage(
|
BasicListItemWithImage(
|
||||||
@ -1013,7 +1013,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.getActorType() == GROUPS) {
|
if (participant.calculatedActorType == GROUPS) {
|
||||||
val items = mutableListOf(
|
val items = mutableListOf(
|
||||||
BasicListItemWithImage(
|
BasicListItemWithImage(
|
||||||
R.drawable.ic_delete_grey600_24dp,
|
R.drawable.ic_delete_grey600_24dp,
|
||||||
@ -1033,7 +1033,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.getActorType() == CIRCLES) {
|
if (participant.calculatedActorType == CIRCLES) {
|
||||||
val items = mutableListOf(
|
val items = mutableListOf(
|
||||||
BasicListItemWithImage(
|
BasicListItemWithImage(
|
||||||
R.drawable.ic_delete_grey600_24dp,
|
R.drawable.ic_delete_grey600_24dp,
|
||||||
@ -1086,7 +1086,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
items.removeAt(1)
|
items.removeAt(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.attendeePin == null || participant.attendeePin.isEmpty()) {
|
if (participant.attendeePin == null || participant.attendeePin!!.isEmpty()) {
|
||||||
items.removeAt(0)
|
items.removeAt(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,7 +1097,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
title(text = participant.displayName)
|
title(text = participant.displayName)
|
||||||
listItemsWithImage(items = items) { dialog, index, _ ->
|
listItemsWithImage(items = items) { dialog, index, _ ->
|
||||||
var actionToTrigger = index
|
var actionToTrigger = index
|
||||||
if (participant.attendeePin == null || participant.attendeePin.isEmpty()) {
|
if (participant.attendeePin == null || participant.attendeePin!!.isEmpty()) {
|
||||||
actionToTrigger++
|
actionToTrigger++
|
||||||
}
|
}
|
||||||
if (participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK) {
|
if (participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK) {
|
||||||
@ -1166,8 +1166,8 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
return left.model.displayName.toLowerCase(Locale.ROOT).compareTo(
|
return left.model.displayName!!.toLowerCase(Locale.ROOT).compareTo(
|
||||||
right.model.displayName.toLowerCase(Locale.ROOT)
|
right.model.displayName!!.toLowerCase(Locale.ROOT)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,9 +156,9 @@ class SwitchAccountController(args: Bundle? = null) :
|
|||||||
userEntity.username
|
userEntity.username
|
||||||
}
|
}
|
||||||
participant = Participant()
|
participant = Participant()
|
||||||
participant.setActorType(Participant.ActorType.USERS)
|
participant.actorType = Participant.ActorType.USERS
|
||||||
participant.setActorId(userId)
|
participant.actorId = userId
|
||||||
participant.setDisplayName(userEntity.displayName)
|
participant.displayName = userEntity.displayName
|
||||||
userItems.add(AdvancedUserItem(participant, userEntity, null))
|
userItems.add(AdvancedUserItem(participant, userEntity, null))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,9 +171,9 @@ class SwitchAccountController(args: Bundle? = null) :
|
|||||||
account = accountObject
|
account = accountObject
|
||||||
importAccount = getInformationFromAccount(account)
|
importAccount = getInformationFromAccount(account)
|
||||||
participant = Participant()
|
participant = Participant()
|
||||||
participant.setActorType(Participant.ActorType.USERS)
|
participant.actorType = Participant.ActorType.USERS
|
||||||
participant.setActorId(importAccount.getUsername())
|
participant.actorId = importAccount.getUsername()
|
||||||
participant.setDisplayName(importAccount.getUsername())
|
participant.displayName = importAccount.getUsername()
|
||||||
userEntity = UserEntity()
|
userEntity = UserEntity()
|
||||||
userEntity.baseUrl = importAccount.getBaseUrl()
|
userEntity.baseUrl = importAccount.getBaseUrl()
|
||||||
userItems.add(AdvancedUserItem(participant, userEntity, account))
|
userItems.add(AdvancedUserItem(participant, userEntity, account))
|
||||||
|
@ -1,341 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* 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.models.json.participants;
|
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
|
||||||
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter;
|
|
||||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
|
||||||
import com.nextcloud.talk.models.json.converters.ObjectParcelConverter;
|
|
||||||
|
|
||||||
import org.parceler.Parcel;
|
|
||||||
import org.parceler.ParcelPropertyConverter;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
@JsonObject
|
|
||||||
public class Participant {
|
|
||||||
@JsonField(name = "attendeeId")
|
|
||||||
public Long attendeeId;
|
|
||||||
|
|
||||||
@JsonField(name = "actorType", typeConverter = EnumActorTypeConverter.class)
|
|
||||||
public ActorType actorType;
|
|
||||||
|
|
||||||
@JsonField(name = "actorId")
|
|
||||||
public String actorId;
|
|
||||||
|
|
||||||
@JsonField(name = "attendeePin")
|
|
||||||
public String attendeePin;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@JsonField(name = "userId")
|
|
||||||
public String userId;
|
|
||||||
|
|
||||||
@JsonField(name = {"type", "participantType"}, typeConverter = EnumParticipantTypeConverter.class)
|
|
||||||
public ParticipantType type;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@JsonField(name = "name")
|
|
||||||
public String name;
|
|
||||||
|
|
||||||
@JsonField(name = "displayName")
|
|
||||||
public String displayName;
|
|
||||||
|
|
||||||
@JsonField(name = "lastPing")
|
|
||||||
public long lastPing;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@JsonField(name = "sessionId")
|
|
||||||
public String sessionId;
|
|
||||||
|
|
||||||
@JsonField(name = "sessionIds")
|
|
||||||
public String[] sessionIds;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@JsonField(name = "roomId")
|
|
||||||
public long roomId;
|
|
||||||
|
|
||||||
@ParcelPropertyConverter(ObjectParcelConverter.class)
|
|
||||||
@JsonField(name = "inCall")
|
|
||||||
public Object inCall;
|
|
||||||
|
|
||||||
@JsonField(name = "status")
|
|
||||||
public String status;
|
|
||||||
|
|
||||||
@JsonField(name = "statusIcon")
|
|
||||||
public String statusIcon;
|
|
||||||
|
|
||||||
@JsonField(name = "statusMessage")
|
|
||||||
public String statusMessage;
|
|
||||||
|
|
||||||
public String source;
|
|
||||||
|
|
||||||
public boolean selected;
|
|
||||||
|
|
||||||
public Long getAttendeeId() {
|
|
||||||
return attendeeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActorType getActorType() {
|
|
||||||
if (this.actorType == null) {
|
|
||||||
if (this.userId != null) {
|
|
||||||
return ActorType.USERS;
|
|
||||||
} else {
|
|
||||||
return ActorType.GUESTS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return actorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getActorId() {
|
|
||||||
if (this.actorId == null) {
|
|
||||||
return this.userId;
|
|
||||||
}
|
|
||||||
return actorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAttendeePin() {
|
|
||||||
return attendeePin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParticipantType getType() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayName() {
|
|
||||||
return this.displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLastPing() {
|
|
||||||
return this.lastPing;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public String getSessionId() {
|
|
||||||
return this.sessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getSessionIds() {
|
|
||||||
return sessionIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getInCall() {
|
|
||||||
if (inCall instanceof Long) {
|
|
||||||
return (Long) this.inCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.inCall instanceof Boolean) {
|
|
||||||
if ((boolean) inCall) {
|
|
||||||
return 1L;
|
|
||||||
} else {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSource() {
|
|
||||||
return this.source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSelected() {
|
|
||||||
return this.selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttendeeId(Long attendeeId) {
|
|
||||||
this.attendeeId = attendeeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActorType(ActorType actorType) {
|
|
||||||
this.actorType = actorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActorId(String actorId) {
|
|
||||||
this.actorId = actorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttendeePin(String attendeePin) {
|
|
||||||
this.attendeePin = attendeePin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(ParticipantType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplayName(String displayName) {
|
|
||||||
this.displayName = displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastPing(long lastPing) {
|
|
||||||
this.lastPing = lastPing;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setSessionId(String sessionId) {
|
|
||||||
this.sessionId = sessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInCall(Object inCall) {
|
|
||||||
this.inCall = inCall;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSource(String source) {
|
|
||||||
this.source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelected(boolean selected) {
|
|
||||||
this.selected = selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSessionIds(String[] sessionIds) {
|
|
||||||
this.sessionIds = sessionIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Participant that = (Participant) o;
|
|
||||||
|
|
||||||
if (lastPing != that.lastPing) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (roomId != that.roomId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (selected != that.selected) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!attendeeId.equals(that.attendeeId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!actorType.equals(that.actorType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!actorId.equals(that.actorId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!attendeePin.equals(that.attendeePin)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!userId.equals(that.userId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (type != that.type) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!name.equals(that.name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (displayName != null ? !displayName.equals(that.displayName) : that.displayName != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!sessionId.equals(that.sessionId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
|
||||||
if (!Arrays.equals(sessionIds, that.sessionIds)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (inCall != null ? !inCall.equals(that.inCall) : that.inCall != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return source != null ? source.equals(that.source) : that.source == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof Participant;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = (attendeeId != null ? attendeeId.hashCode() : 0);
|
|
||||||
result = 31 * result + (actorType != null ? actorType.hashCode() : 0);
|
|
||||||
result = 31 * result + (actorId != null ? actorId.hashCode() : 0);
|
|
||||||
result = 31 * result + (attendeePin != null ? attendeePin.hashCode() : 0);
|
|
||||||
result = 31 * result + (userId != null ? userId.hashCode() : 0);
|
|
||||||
result = 31 * result + (type != null ? type.hashCode() : 0);
|
|
||||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
|
||||||
result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
|
|
||||||
result = 31 * result + (int) (lastPing ^ (lastPing >>> 32));
|
|
||||||
result = 31 * result + (sessionId != null ? sessionId.hashCode() : 0);
|
|
||||||
result = 31 * result + Arrays.hashCode(sessionIds);
|
|
||||||
result = 31 * result + (int) (roomId ^ (roomId >>> 32));
|
|
||||||
result = 31 * result + (inCall != null ? inCall.hashCode() : 0);
|
|
||||||
result = 31 * result + (source != null ? source.hashCode() : 0);
|
|
||||||
result = 31 * result + (selected ? 1 : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Participant{" +
|
|
||||||
"attendeeId=" + attendeeId +
|
|
||||||
", actorType='" + actorType + '\'' +
|
|
||||||
", actorId='" + actorId + '\'' +
|
|
||||||
", attendeePin='" + attendeePin + '\'' +
|
|
||||||
", userId='" + userId + '\'' +
|
|
||||||
", type=" + type +
|
|
||||||
", name='" + name + '\'' +
|
|
||||||
", displayName='" + displayName + '\'' +
|
|
||||||
", lastPing=" + lastPing +
|
|
||||||
", sessionId='" + sessionId + '\'' +
|
|
||||||
", sessionIds=" + Arrays.toString(sessionIds) +
|
|
||||||
", roomId=" + roomId +
|
|
||||||
", inCall=" + inCall +
|
|
||||||
", source='" + source + '\'' +
|
|
||||||
", selected=" + selected +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ActorType {
|
|
||||||
DUMMY,
|
|
||||||
EMAILS,
|
|
||||||
GROUPS,
|
|
||||||
GUESTS,
|
|
||||||
USERS,
|
|
||||||
CIRCLES,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ParticipantType {
|
|
||||||
DUMMY,
|
|
||||||
OWNER,
|
|
||||||
MODERATOR,
|
|
||||||
USER,
|
|
||||||
GUEST,
|
|
||||||
USER_FOLLOWING_LINK,
|
|
||||||
GUEST_MODERATOR
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class InCallFlags {
|
|
||||||
public static final int DISCONNECTED = 0;
|
|
||||||
public static final int IN_CALL = 1;
|
|
||||||
public static final int WITH_AUDIO = 2;
|
|
||||||
public static final int WITH_VIDEO = 4;
|
|
||||||
public static final int WITH_PHONE = 8;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* @author Andy Scherzinger
|
||||||
|
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.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.models.json.participants
|
||||||
|
|
||||||
|
import android.os.Parcel
|
||||||
|
import android.os.Parcelable
|
||||||
|
import android.util.Log
|
||||||
|
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||||
|
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter
|
||||||
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessage
|
||||||
|
import kotlinx.android.parcel.Parceler
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
import kotlinx.android.parcel.WriteWith
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
@JsonObject
|
||||||
|
data class Participant(
|
||||||
|
@JsonField(name = ["attendeeId"])
|
||||||
|
var attendeeId: Long? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["actorType"], typeConverter = EnumActorTypeConverter::class)
|
||||||
|
var actorType: ActorType? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["actorId"])
|
||||||
|
var actorId: String? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["attendeePin"])
|
||||||
|
var attendeePin: String? = null,
|
||||||
|
|
||||||
|
@Deprecated("")
|
||||||
|
@JsonField(name = ["userId"])
|
||||||
|
var userId: String? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["type", "participantType"], typeConverter = EnumParticipantTypeConverter::class)
|
||||||
|
var type: ParticipantType? = null,
|
||||||
|
|
||||||
|
@Deprecated("")
|
||||||
|
@JsonField(name = ["name"])
|
||||||
|
var name: String? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["displayName"])
|
||||||
|
var displayName: String? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["lastPing"])
|
||||||
|
var lastPing: Long = 0,
|
||||||
|
|
||||||
|
@Deprecated("")
|
||||||
|
@JsonField(name = ["sessionId"])
|
||||||
|
var sessionId: String? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["sessionIds"])
|
||||||
|
var sessionIds: ArrayList<String> = ArrayList(0),
|
||||||
|
|
||||||
|
@Deprecated("")
|
||||||
|
@JsonField(name = ["roomId"])
|
||||||
|
var roomId: Long = 0,
|
||||||
|
|
||||||
|
@JsonField(name = ["inCall"])
|
||||||
|
var inCall: Long = 0,
|
||||||
|
|
||||||
|
@JsonField(name = ["status"])
|
||||||
|
var status: String? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["statusIcon"])
|
||||||
|
var statusIcon: String? = null,
|
||||||
|
|
||||||
|
@JsonField(name = ["statusMessage"])
|
||||||
|
var statusMessage: String? = null,
|
||||||
|
|
||||||
|
var source: String? = null,
|
||||||
|
|
||||||
|
var selected: Boolean = false
|
||||||
|
) : Parcelable {
|
||||||
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
|
constructor() : this(
|
||||||
|
null, null, null, null, null, null, null, null,
|
||||||
|
0, null, ArrayList(0), 0, 0, null,
|
||||||
|
null, null
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* actorType is only guaranteed in APIv3+ so use calculatedActorId
|
||||||
|
*
|
||||||
|
* https://github.com/nextcloud/spreed/blob/stable21/lib/Controller/RoomController.php#L1145-L1148
|
||||||
|
*/
|
||||||
|
val calculatedActorType: ActorType
|
||||||
|
get() = if (actorType == null) {
|
||||||
|
if (userId != null) {
|
||||||
|
ActorType.USERS
|
||||||
|
} else {
|
||||||
|
ActorType.GUESTS
|
||||||
|
}
|
||||||
|
} else actorType!!
|
||||||
|
|
||||||
|
/**
|
||||||
|
* actorId is only guaranteed in APIv3+ so use calculatedActorId.
|
||||||
|
*/
|
||||||
|
val calculatedActorId: String?
|
||||||
|
get() = if (actorId == null) {
|
||||||
|
userId
|
||||||
|
} else actorId
|
||||||
|
|
||||||
|
enum class ActorType {
|
||||||
|
DUMMY, EMAILS, GROUPS, GUESTS, USERS, CIRCLES
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class ParticipantType {
|
||||||
|
DUMMY, OWNER, MODERATOR, USER, GUEST, USER_FOLLOWING_LINK, GUEST_MODERATOR
|
||||||
|
}
|
||||||
|
|
||||||
|
object InCallFlags {
|
||||||
|
const val DISCONNECTED = 0
|
||||||
|
const val IN_CALL = 1
|
||||||
|
const val WITH_AUDIO = 2
|
||||||
|
const val WITH_VIDEO = 4
|
||||||
|
const val WITH_PHONE = 8
|
||||||
|
}
|
||||||
|
}
|
@ -457,8 +457,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
public String getUserIdForSession(String session) {
|
public String getUserIdForSession(String session) {
|
||||||
Participant participant = usersHashMap.get(session);
|
Participant participant = usersHashMap.get(session);
|
||||||
if (participant != null) {
|
if (participant != null) {
|
||||||
if (participant.getActorType() == USERS) {
|
if (participant.getCalculatedActorType() == USERS) {
|
||||||
return participant.getActorId();
|
return participant.getCalculatedActorId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user