mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-24 14:09:44 +01: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
@ -35,10 +35,6 @@ import eu.davidea.viewholders.FlexibleViewHolder;
|
|||||||
public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemViewHolder> implements
|
public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemViewHolder> implements
|
||||||
ISectionable<ContactItem.ContactItemViewHolder, GenericTextHeaderItem>, IFilterable<String> {
|
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 Participant participant;
|
||||||
private final User user;
|
private final User user;
|
||||||
private GenericTextHeaderItem header;
|
private GenericTextHeaderItem header;
|
||||||
@ -133,9 +129,7 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
participant.getCalculatedActorType() == Participant.ActorType.GROUPS ||
|
participant.getCalculatedActorType() == Participant.ActorType.GROUPS ||
|
||||||
PARTICIPANT_SOURCE_GROUPS.equals(participant.getSource()) ||
|
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES) {
|
||||||
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES ||
|
|
||||||
PARTICIPANT_SOURCE_CIRCLES.equals(participant.getSource())) {
|
|
||||||
|
|
||||||
setGenericAvatar(holder, R.drawable.ic_avatar_group, R.drawable.ic_circular_group);
|
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);
|
ImageViewExtensionsKt.loadUserAvatar(holder.binding.avatarView, user, displayName, true, false);
|
||||||
} else if (participant.getCalculatedActorType() == Participant.ActorType.USERS ||
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.USERS) {
|
||||||
PARTICIPANT_SOURCE_USERS.equals(participant.getSource())) {
|
ImageViewExtensionsKt.loadUserAvatar(holder.binding.avatarView,
|
||||||
ImageViewExtensionsKt.loadUserAvatar(holder.binding.avatarView, user, participant.getCalculatedActorId(),
|
user,
|
||||||
true, false);
|
participant.getCalculatedActorId(),
|
||||||
|
true,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +114,13 @@ class ParticipantItem(
|
|||||||
) {
|
) {
|
||||||
holder.binding.nameText.text = sharedApplication!!.getString(R.string.nc_guest)
|
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)
|
holder.binding.avatarView.loadDefaultGroupCallAvatar(viewThemeUtils)
|
||||||
} else if (model.calculatedActorType == Participant.ActorType.EMAILS) {
|
} else if (model.calculatedActorType == Participant.ActorType.EMAILS) {
|
||||||
@ -129,10 +134,11 @@ class ParticipantItem(
|
|||||||
displayName = model.displayName
|
displayName = model.displayName
|
||||||
}
|
}
|
||||||
holder.binding.avatarView.loadGuestAvatar(user, displayName!!, false)
|
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
|
holder.binding.avatarView
|
||||||
.loadUserAvatar(user, model.calculatedActorId!!, true, false)
|
.loadUserAvatar(user, model.calculatedActorId!!, true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val resources = sharedApplication!!.resources
|
val resources = sharedApplication!!.resources
|
||||||
val inCallFlag = model.inCall
|
val inCallFlag = model.inCall
|
||||||
if (inCallFlag and InCallFlags.WITH_PHONE.toLong() > 0) {
|
if (inCallFlag and InCallFlags.WITH_PHONE.toLong() > 0) {
|
||||||
|
@ -574,7 +574,6 @@ class ContactsActivity :
|
|||||||
participant.actorId = autocompleteUser.id
|
participant.actorId = autocompleteUser.id
|
||||||
participant.actorType = actorTypeConverter.getFromString(autocompleteUser.source)
|
participant.actorType = actorTypeConverter.getFromString(autocompleteUser.source)
|
||||||
participant.displayName = autocompleteUser.label
|
participant.displayName = autocompleteUser.label
|
||||||
participant.source = autocompleteUser.source
|
|
||||||
|
|
||||||
return participant
|
return participant
|
||||||
}
|
}
|
||||||
@ -593,30 +592,30 @@ class ContactsActivity :
|
|||||||
(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.model.source!!
|
val firstSource: Participant.ActorType = o1.model.actorType!!
|
||||||
val secondSource: String = o2.model.source!!
|
val secondSource: Participant.ActorType = o2.model.actorType!!
|
||||||
if (firstSource == secondSource) {
|
if (firstSource == secondSource) {
|
||||||
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// First users
|
// First users
|
||||||
if ("users" == firstSource) {
|
if (Participant.ActorType.USERS == firstSource) {
|
||||||
return@sort -1
|
return@sort -1
|
||||||
} else if ("users" == secondSource) {
|
} else if (Participant.ActorType.USERS == secondSource) {
|
||||||
return@sort 1
|
return@sort 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then groups
|
// Then groups
|
||||||
if ("groups" == firstSource) {
|
if (Participant.ActorType.GROUPS == firstSource) {
|
||||||
return@sort -1
|
return@sort -1
|
||||||
} else if ("groups" == secondSource) {
|
} else if (Participant.ActorType.GROUPS == secondSource) {
|
||||||
return@sort 1
|
return@sort 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then circles
|
// Then circles
|
||||||
if ("circles" == firstSource) {
|
if (Participant.ActorType.CIRCLES == firstSource) {
|
||||||
return@sort -1
|
return@sort -1
|
||||||
} else if ("circles" == secondSource) {
|
} else if (Participant.ActorType.CIRCLES == secondSource) {
|
||||||
return@sort 1
|
return@sort 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,13 +637,13 @@ class ContactsActivity :
|
|||||||
(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.model.source &&
|
if (Participant.ActorType.GROUPS == o1.model.actorType &&
|
||||||
"groups" == o2.model.source
|
Participant.ActorType.GROUPS == o2.model.actorType
|
||||||
) {
|
) {
|
||||||
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
return@sort firstName.compareTo(secondName, ignoreCase = true)
|
||||||
} else if ("groups" == o1.model.source) {
|
} else if (Participant.ActorType.GROUPS == o1.model.actorType) {
|
||||||
return@sort -1
|
return@sort -1
|
||||||
} else if ("groups" == o2.model.source) {
|
} else if (Participant.ActorType.GROUPS == o2.model.actorType) {
|
||||||
return@sort 1
|
return@sort 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -775,7 +774,7 @@ class ContactsActivity :
|
|||||||
|
|
||||||
private fun createRoom(contactItem: ContactItem) {
|
private fun createRoom(contactItem: ContactItem) {
|
||||||
var roomType = "1"
|
var roomType = "1"
|
||||||
if ("groups" == contactItem.model.source) {
|
if (Participant.ActorType.GROUPS == contactItem.model.actorType) {
|
||||||
roomType = "2"
|
roomType = "2"
|
||||||
}
|
}
|
||||||
val apiVersion: Int = ApiUtils.getConversationApiVersion(currentUser!!, intArrayOf(ApiUtils.API_V4, 1))
|
val apiVersion: Int = ApiUtils.getConversationApiVersion(currentUser!!, intArrayOf(ApiUtils.API_V4, 1))
|
||||||
@ -817,19 +816,19 @@ class ContactsActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSelectionLists(participant: Participant) {
|
private fun updateSelectionLists(participant: Participant) {
|
||||||
if ("groups" == participant.source) {
|
if (Participant.ActorType.GROUPS == participant.actorType) {
|
||||||
if (participant.selected) {
|
if (participant.selected) {
|
||||||
selectedGroupIds.add(participant.calculatedActorId!!)
|
selectedGroupIds.add(participant.calculatedActorId!!)
|
||||||
} else {
|
} else {
|
||||||
selectedGroupIds.remove(participant.calculatedActorId!!)
|
selectedGroupIds.remove(participant.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
} else if ("emails" == participant.source) {
|
} else if (Participant.ActorType.EMAILS == participant.actorType) {
|
||||||
if (participant.selected) {
|
if (participant.selected) {
|
||||||
selectedEmails.add(participant.calculatedActorId!!)
|
selectedEmails.add(participant.calculatedActorId!!)
|
||||||
} else {
|
} else {
|
||||||
selectedEmails.remove(participant.calculatedActorId!!)
|
selectedEmails.remove(participant.calculatedActorId!!)
|
||||||
}
|
}
|
||||||
} else if ("circles" == participant.source) {
|
} else if (Participant.ActorType.CIRCLES == participant.actorType) {
|
||||||
if (participant.selected) {
|
if (participant.selected) {
|
||||||
selectedCircleIds.add(participant.calculatedActorId!!)
|
selectedCircleIds.add(participant.calculatedActorId!!)
|
||||||
} else {
|
} else {
|
||||||
@ -849,7 +848,8 @@ class ContactsActivity :
|
|||||||
participant: Participant,
|
participant: Participant,
|
||||||
adapter: FlexibleAdapter<*>?
|
adapter: FlexibleAdapter<*>?
|
||||||
): Boolean {
|
): 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() {
|
private fun listOpenConversations() {
|
||||||
@ -869,7 +869,7 @@ class ContactsActivity :
|
|||||||
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.source) {
|
if (Participant.ActorType.GROUPS == contactItem.model.actorType) {
|
||||||
contactItem.isEnabled = !isPublicCall
|
contactItem.isEnabled = !isPublicCall
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,6 @@ data class Participant(
|
|||||||
@JsonField(name = ["statusMessage"])
|
@JsonField(name = ["statusMessage"])
|
||||||
var statusMessage: String? = null,
|
var statusMessage: String? = null,
|
||||||
|
|
||||||
var source: String? = null,
|
|
||||||
|
|
||||||
var selected: Boolean = false
|
var selected: Boolean = false
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// 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
|
* https://github.com/nextcloud/spreed/blob/stable21/lib/Controller/RoomController.php#L1145-L1148
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user