mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 06:55:42 +03:00
remove 'source' variable from Participant
As far i could see this is identical to actorType, so 'source' was removed and actorType is now used. This makes checks in ParticipantItem etc more clean Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
8216811e99
commit
1553cdf107
4 changed files with 36 additions and 36 deletions
|
@ -35,10 +35,6 @@ import eu.davidea.viewholders.FlexibleViewHolder;
|
|||
public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemViewHolder> implements
|
||||
ISectionable<ContactItem.ContactItemViewHolder, GenericTextHeaderItem>, IFilterable<String> {
|
||||
|
||||
public static final String PARTICIPANT_SOURCE_CIRCLES = "circles";
|
||||
public static final String PARTICIPANT_SOURCE_GROUPS = "groups";
|
||||
public static final String PARTICIPANT_SOURCE_USERS = "users";
|
||||
|
||||
private final Participant participant;
|
||||
private final User user;
|
||||
private GenericTextHeaderItem header;
|
||||
|
@ -133,9 +129,7 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||
|
||||
if (
|
||||
participant.getCalculatedActorType() == Participant.ActorType.GROUPS ||
|
||||
PARTICIPANT_SOURCE_GROUPS.equals(participant.getSource()) ||
|
||||
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES ||
|
||||
PARTICIPANT_SOURCE_CIRCLES.equals(participant.getSource())) {
|
||||
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES) {
|
||||
|
||||
setGenericAvatar(holder, R.drawable.ic_avatar_group, R.drawable.ic_circular_group);
|
||||
|
||||
|
@ -163,10 +157,12 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||
}
|
||||
|
||||
ImageViewExtensionsKt.loadUserAvatar(holder.binding.avatarView, user, displayName, true, false);
|
||||
} else if (participant.getCalculatedActorType() == Participant.ActorType.USERS ||
|
||||
PARTICIPANT_SOURCE_USERS.equals(participant.getSource())) {
|
||||
ImageViewExtensionsKt.loadUserAvatar(holder.binding.avatarView, user, participant.getCalculatedActorId(),
|
||||
true, false);
|
||||
} else if (participant.getCalculatedActorType() == Participant.ActorType.USERS) {
|
||||
ImageViewExtensionsKt.loadUserAvatar(holder.binding.avatarView,
|
||||
user,
|
||||
participant.getCalculatedActorId(),
|
||||
true,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,8 +114,13 @@ class ParticipantItem(
|
|||
) {
|
||||
holder.binding.nameText.text = sharedApplication!!.getString(R.string.nc_guest)
|
||||
}
|
||||
if (model.calculatedActorType == Participant.ActorType.GROUPS || "groups" == model.source ||
|
||||
model.calculatedActorType == Participant.ActorType.CIRCLES || "circles" == model.source
|
||||
|
||||
// when(){ // check if model.source can be removed!
|
||||
//
|
||||
// }
|
||||
|
||||
if (model.calculatedActorType == Participant.ActorType.GROUPS ||
|
||||
model.calculatedActorType == Participant.ActorType.CIRCLES
|
||||
) {
|
||||
holder.binding.avatarView.loadDefaultGroupCallAvatar(viewThemeUtils)
|
||||
} else if (model.calculatedActorType == Participant.ActorType.EMAILS) {
|
||||
|
@ -129,10 +134,11 @@ class ParticipantItem(
|
|||
displayName = model.displayName
|
||||
}
|
||||
holder.binding.avatarView.loadGuestAvatar(user, displayName!!, false)
|
||||
} else if (model.calculatedActorType == Participant.ActorType.USERS || "users" == model.source) {
|
||||
} else if (model.calculatedActorType == Participant.ActorType.USERS) {
|
||||
holder.binding.avatarView
|
||||
.loadUserAvatar(user, model.calculatedActorId!!, true, false)
|
||||
}
|
||||
|
||||
val resources = sharedApplication!!.resources
|
||||
val inCallFlag = model.inCall
|
||||
if (inCallFlag and InCallFlags.WITH_PHONE.toLong() > 0) {
|
||||
|
|
|
@ -574,7 +574,6 @@ class ContactsActivity :
|
|||
participant.actorId = autocompleteUser.id
|
||||
participant.actorType = actorTypeConverter.getFromString(autocompleteUser.source)
|
||||
participant.displayName = autocompleteUser.label
|
||||
participant.source = autocompleteUser.source
|
||||
|
||||
return participant
|
||||
}
|
||||
|
@ -593,30 +592,30 @@ class ContactsActivity :
|
|||
(o2 as GenericTextHeaderItem).model
|
||||
}
|
||||
if (o1 is ContactItem && o2 is ContactItem) {
|
||||
val firstSource: String = o1.model.source!!
|
||||
val secondSource: String = o2.model.source!!
|
||||
val firstSource: Participant.ActorType = o1.model.actorType!!
|
||||
val secondSource: Participant.ActorType = o2.model.actorType!!
|
||||
if (firstSource == secondSource) {
|
||||
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
||||
}
|
||||
|
||||
// First users
|
||||
if ("users" == firstSource) {
|
||||
if (Participant.ActorType.USERS == firstSource) {
|
||||
return@sort -1
|
||||
} else if ("users" == secondSource) {
|
||||
} else if (Participant.ActorType.USERS == secondSource) {
|
||||
return@sort 1
|
||||
}
|
||||
|
||||
// Then groups
|
||||
if ("groups" == firstSource) {
|
||||
if (Participant.ActorType.GROUPS == firstSource) {
|
||||
return@sort -1
|
||||
} else if ("groups" == secondSource) {
|
||||
} else if (Participant.ActorType.GROUPS == secondSource) {
|
||||
return@sort 1
|
||||
}
|
||||
|
||||
// Then circles
|
||||
if ("circles" == firstSource) {
|
||||
if (Participant.ActorType.CIRCLES == firstSource) {
|
||||
return@sort -1
|
||||
} else if ("circles" == secondSource) {
|
||||
} else if (Participant.ActorType.CIRCLES == secondSource) {
|
||||
return@sort 1
|
||||
}
|
||||
|
||||
|
@ -638,13 +637,13 @@ class ContactsActivity :
|
|||
(o2 as GenericTextHeaderItem).model
|
||||
}
|
||||
if (o1 is ContactItem && o2 is ContactItem) {
|
||||
if ("groups" == o1.model.source &&
|
||||
"groups" == o2.model.source
|
||||
if (Participant.ActorType.GROUPS == o1.model.actorType &&
|
||||
Participant.ActorType.GROUPS == o2.model.actorType
|
||||
) {
|
||||
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
||||
} else if ("groups" == o1.model.source) {
|
||||
} else if (Participant.ActorType.GROUPS == o1.model.actorType) {
|
||||
return@sort -1
|
||||
} else if ("groups" == o2.model.source) {
|
||||
} else if (Participant.ActorType.GROUPS == o2.model.actorType) {
|
||||
return@sort 1
|
||||
}
|
||||
}
|
||||
|
@ -775,7 +774,7 @@ class ContactsActivity :
|
|||
|
||||
private fun createRoom(contactItem: ContactItem) {
|
||||
var roomType = "1"
|
||||
if ("groups" == contactItem.model.source) {
|
||||
if (Participant.ActorType.GROUPS == contactItem.model.actorType) {
|
||||
roomType = "2"
|
||||
}
|
||||
val apiVersion: Int = ApiUtils.getConversationApiVersion(currentUser!!, intArrayOf(ApiUtils.API_V4, 1))
|
||||
|
@ -817,19 +816,19 @@ class ContactsActivity :
|
|||
}
|
||||
|
||||
private fun updateSelectionLists(participant: Participant) {
|
||||
if ("groups" == participant.source) {
|
||||
if (Participant.ActorType.GROUPS == participant.actorType) {
|
||||
if (participant.selected) {
|
||||
selectedGroupIds.add(participant.calculatedActorId!!)
|
||||
} else {
|
||||
selectedGroupIds.remove(participant.calculatedActorId!!)
|
||||
}
|
||||
} else if ("emails" == participant.source) {
|
||||
} else if (Participant.ActorType.EMAILS == participant.actorType) {
|
||||
if (participant.selected) {
|
||||
selectedEmails.add(participant.calculatedActorId!!)
|
||||
} else {
|
||||
selectedEmails.remove(participant.calculatedActorId!!)
|
||||
}
|
||||
} else if ("circles" == participant.source) {
|
||||
} else if (Participant.ActorType.CIRCLES == participant.actorType) {
|
||||
if (participant.selected) {
|
||||
selectedCircleIds.add(participant.calculatedActorId!!)
|
||||
} else {
|
||||
|
@ -849,7 +848,8 @@ class ContactsActivity :
|
|||
participant: Participant,
|
||||
adapter: FlexibleAdapter<*>?
|
||||
): Boolean {
|
||||
return "groups" == contactItem.model.source && participant.selected && adapter?.selectedItemCount!! > 1
|
||||
return Participant.ActorType.GROUPS == contactItem.model.actorType &&
|
||||
participant.selected && adapter?.selectedItemCount!! > 1
|
||||
}
|
||||
|
||||
private fun listOpenConversations() {
|
||||
|
@ -869,7 +869,7 @@ class ContactsActivity :
|
|||
for (i in 0 until adapter!!.itemCount) {
|
||||
if (adapter?.getItem(i) is ContactItem) {
|
||||
val contactItem: ContactItem = adapter?.getItem(i) as ContactItem
|
||||
if ("groups" == contactItem.model.source) {
|
||||
if (Participant.ActorType.GROUPS == contactItem.model.actorType) {
|
||||
contactItem.isEnabled = !isPublicCall
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,6 @@ data class Participant(
|
|||
@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'
|
||||
|
@ -84,7 +82,7 @@ data class Participant(
|
|||
)
|
||||
|
||||
/**
|
||||
* actorType is only guaranteed in APIv3+ so use calculatedActorId
|
||||
* actorType is only guaranteed in APIv3+ so use calculatedActorType
|
||||
*
|
||||
* https://github.com/nextcloud/spreed/blob/stable21/lib/Controller/RoomController.php#L1145-L1148
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue