Less deprecated usage

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-07 22:58:43 +02:00 committed by Andy Scherzinger
parent 875c66ea8a
commit 21093282f9
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
5 changed files with 38 additions and 30 deletions

View File

@ -106,11 +106,11 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
holder.avatarImageView.setController(null); holder.avatarImageView.setController(null);
if (adapter.hasFilter()) { if (adapter.hasFilter()) {
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getName(), FlexibleUtils.highlightText(holder.contactDisplayName, participant.getDisplayName(),
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.Companion.getSharedApplication() String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.Companion.getSharedApplication()
.getResources().getColor(R.color.colorPrimary)); .getResources().getColor(R.color.colorPrimary));
} else { } else {
holder.contactDisplayName.setText(participant.getName()); holder.contactDisplayName.setText(participant.getDisplayName());
} }
holder.serverUrl.setText(userEntity.getBaseUrl()); holder.serverUrl.setText(userEntity.getBaseUrl());
@ -122,7 +122,7 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
.setOldController(holder.avatarImageView.getController()) .setOldController(holder.avatarImageView.getController())
.setAutoPlayAnimations(true) .setAutoPlayAnimations(true)
.setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(), .setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
participant.getUserId(), R.dimen.avatar_size), null)) participant.getActorId(), R.dimen.avatar_size), null))
.build(); .build();
holder.avatarImageView.setController(draweeController); holder.avatarImageView.setController(draweeController);
@ -138,8 +138,8 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
@Override @Override
public boolean filter(String constraint) { public boolean filter(String constraint) {
return participant.getName() != null && return participant.getDisplayName() != null &&
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL).matcher(participant.getName().trim()).find(); Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL).matcher(participant.getDisplayName().trim()).find();
} }

View File

@ -61,6 +61,8 @@ import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall;
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser; import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser;
import com.nextcloud.talk.models.json.conversations.Conversation; import com.nextcloud.talk.models.json.conversations.Conversation;
import com.nextcloud.talk.models.json.conversations.RoomOverall; import com.nextcloud.talk.models.json.conversations.RoomOverall;
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter;
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.utils.ApiUtils; import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.ConductorRemapping; import com.nextcloud.talk.utils.ConductorRemapping;
@ -508,6 +510,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
Participant participant; Participant participant;
List<AbstractFlexibleItem> newUserItemList = new ArrayList<>(); List<AbstractFlexibleItem> newUserItemList = new ArrayList<>();
EnumActorTypeConverter actorTypeConverter = new EnumActorTypeConverter();
try { try {
AutocompleteOverall autocompleteOverall = LoganSquare.parse(responseBody.string(), AutocompleteOverall.class); AutocompleteOverall autocompleteOverall = LoganSquare.parse(responseBody.string(), AutocompleteOverall.class);
@ -516,13 +519,14 @@ public class ContactsController extends BaseController implements SearchView.OnQ
for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) { for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) {
if (!autocompleteUser.getId().equals(currentUser.getUserId()) && !existingParticipants.contains(autocompleteUser.getId())) { if (!autocompleteUser.getId().equals(currentUser.getUserId()) && !existingParticipants.contains(autocompleteUser.getId())) {
participant = new Participant(); participant = new Participant();
participant.setUserId(autocompleteUser.getId()); participant.setActorId(autocompleteUser.getId());
participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.getSource()));
participant.setDisplayName(autocompleteUser.getLabel()); participant.setDisplayName(autocompleteUser.getLabel());
participant.setSource(autocompleteUser.getSource()); participant.setSource(autocompleteUser.getSource());
String headerTitle; String headerTitle;
if (!autocompleteUser.getSource().equals("groups")) { if (participant.getActorType() != Participant.ActorType.GROUPS) {
headerTitle = participant.getDisplayName().substring(0, 1).toUpperCase(); headerTitle = participant.getDisplayName().substring(0, 1).toUpperCase();
} else { } else {
headerTitle = getResources().getString(R.string.nc_groups); headerTitle = getResources().getString(R.string.nc_groups);

View File

@ -419,12 +419,8 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
} else { } else {
userItem.isOnline = !participant.sessionIds!!.isEmpty() userItem.isOnline = !participant.sessionIds!!.isEmpty()
} }
if (!TextUtils.isEmpty(participant.userId) && participant.userId == conversationUser!!.userId) {
ownUserItem = userItem if (participant.getActorType() == USERS && participant.getActorId() == conversationUser!!.userId) {
ownUserItem.model.sessionId = "-1"
ownUserItem.isOnline = true
} else if (participant.actorType != null && participant.actorType == USERS
&& !TextUtils.isEmpty(participant.actorId) && participant.actorId == conversationUser!!.userId) {
ownUserItem = userItem ownUserItem = userItem
ownUserItem.model.sessionId = "-1" ownUserItem.model.sessionId = "-1"
ownUserItem.isOnline = true ownUserItem.isOnline = true
@ -491,7 +487,9 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
recyclerViewItems.forEach { recyclerViewItems.forEach {
val userItem = it as UserItem val userItem = it as UserItem
existingParticipantsId.add(userItem.model.userId) if (userItem.model.getActorType() == USERS) {
existingParticipantsId.add(userItem.model.getActorId())
}
} }
bundle.putBoolean(BundleKeys.KEY_ADD_PARTICIPANTS, true) bundle.putBoolean(BundleKeys.KEY_ADD_PARTICIPANTS, true)
@ -920,7 +918,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1)) val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
if (participant.getUserId() == conversationUser!!.userId) { if (participant.getActorType() == USERS && participant.getActorId() == conversationUser!!.userId) {
if (participant.attendeePin.isNotEmpty()) { if (participant.attendeePin.isNotEmpty()) {
val items = mutableListOf( val items = mutableListOf(
BasicListItemWithImage( BasicListItemWithImage(
@ -980,11 +978,13 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
) )
) )
if (participant.type == Participant.ParticipantType.MODERATOR if (participant.type == Participant.ParticipantType.MODERATOR ||
|| participant.type == Participant.ParticipantType.GUEST_MODERATOR) { participant.type == Participant.ParticipantType.GUEST_MODERATOR
) {
items.removeAt(1) items.removeAt(1)
} else if (participant.type == Participant.ParticipantType.USER } else if (participant.type == Participant.ParticipantType.USER ||
|| participant.type == Participant.ParticipantType.GUEST) { participant.type == Participant.ParticipantType.GUEST
) {
items.removeAt(2) items.removeAt(2)
} else { } else {
// Self joined users can not be promoted nor demoted // Self joined users can not be promoted nor demoted
@ -1054,7 +1054,6 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
moderatorTypes.add(Participant.ParticipantType.OWNER) moderatorTypes.add(Participant.ParticipantType.OWNER)
moderatorTypes.add(Participant.ParticipantType.GUEST_MODERATOR) moderatorTypes.add(Participant.ParticipantType.GUEST_MODERATOR)
if (moderatorTypes.contains(left.model.type) && !moderatorTypes.contains(right.model.type)) { if (moderatorTypes.contains(left.model.type) && !moderatorTypes.contains(right.model.type)) {
return -1 return -1
} else if (!moderatorTypes.contains(left.model.type) && moderatorTypes.contains(right.model.type)) { } else if (!moderatorTypes.contains(left.model.type) && moderatorTypes.contains(right.model.type)) {

View File

@ -178,17 +178,17 @@ public class SwitchAccountController extends BaseController {
for (Object userEntityObject : userUtils.getUsers()) { for (Object userEntityObject : userUtils.getUsers()) {
userEntity = (UserEntity) userEntityObject; userEntity = (UserEntity) userEntityObject;
if (!userEntity.getCurrent()) { if (!userEntity.getCurrent()) {
participant = new Participant();
participant.setName(userEntity.getDisplayName());
String userId; String userId;
if (userEntity.getUserId() != null) { if (userEntity.getUserId() != null) {
userId = userEntity.getUserId(); userId = userEntity.getUserId();
} else { } else {
userId = userEntity.getUsername(); userId = userEntity.getUsername();
} }
participant.setUserId(userId);
participant = new Participant();
participant.setActorType(Participant.ActorType.USERS);
participant.setActorId(userId);
participant.setDisplayName(userEntity.getDisplayName());
userItems.add(new AdvancedUserItem(participant, userEntity, null)); userItems.add(new AdvancedUserItem(participant, userEntity, null));
} }
} }
@ -203,8 +203,9 @@ public class SwitchAccountController extends BaseController {
importAccount = AccountUtils.INSTANCE.getInformationFromAccount(account); importAccount = AccountUtils.INSTANCE.getInformationFromAccount(account);
participant = new Participant(); participant = new Participant();
participant.setName(importAccount.getUsername()); participant.setActorType(Participant.ActorType.USERS);
participant.setUserId(importAccount.getUsername()); participant.setActorId(importAccount.getUsername());
participant.setDisplayName(importAccount.getUsername());
userEntity = new UserEntity(); userEntity = new UserEntity();
userEntity.setBaseUrl(importAccount.getBaseUrl()); userEntity.setBaseUrl(importAccount.getBaseUrl());
userItems.add(new AdvancedUserItem(participant, userEntity, account)); userItems.add(new AdvancedUserItem(participant, userEntity, account));

View File

@ -105,14 +105,18 @@ public class Participant {
} }
public ActorType getActorType() { public ActorType getActorType() {
if (this.userId != null) { if (this.actorType == null) {
return ActorType.USERS; if (this.userId != null) {
return ActorType.USERS;
} else {
return ActorType.GUESTS;
}
} }
return actorType; return actorType;
} }
public String getActorId() { public String getActorId() {
if (this.userId != null) { if (this.actorId == null) {
return this.userId; return this.userId;
} }
return actorId; return actorId;