Begin working on improved leave & delete

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-03-04 09:06:22 +01:00
parent 119e684f8d
commit f9a14c4a92
9 changed files with 26 additions and 25 deletions

View File

@ -176,7 +176,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
context.getResources().getColor(R.color.nc_grey));
holder.dialogLastMessageUserAvatar.setImageDrawable(drawable);
} else if (!conversation.getLastMessage().getActorId().equals(userEntity.getUserId())
&& !conversation.getType().equals(Conversation.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL)) {
&& !conversation.getType().equals(Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL)) {
holder.dialogLastMessageUserAvatar.setVisibility(View.VISIBLE);
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
conversation.getLastMessage().getActorId(), R.dimen.small_item_height), new LazyHeaders.Builder()

View File

@ -308,11 +308,11 @@ public class ContactsController extends BaseController implements SearchView.OnQ
} else {
Bundle bundle = new Bundle();
Conversation.RoomType roomType;
Conversation.ConversationType roomType;
if (isPublicCall) {
roomType = Conversation.RoomType.ROOM_PUBLIC_CALL;
roomType = Conversation.ConversationType.ROOM_PUBLIC_CALL;
} else {
roomType = Conversation.RoomType.ROOM_GROUP_CALL;
roomType = Conversation.ConversationType.ROOM_GROUP_CALL;
}
bundle.putParcelable(BundleKeys.KEY_CONVERSATION_TYPE, Parcels.wrap(roomType));

View File

@ -372,7 +372,7 @@ public class ConversationInfoController extends BaseController {
private void setProperNotificationValue(Conversation conversation) {
if (messageNotificationLevel != null) {
if (conversation.getType().equals(Conversation.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL)) {
if (conversation.getType().equals(Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL)) {
// hack to see if we get mentioned always or just on mention
if (conversationUser.hasSpreedCapabilityWithName("mention-flag")) {
messageNotificationLevel.setValue("always");

View File

@ -169,7 +169,7 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
}
}
if (conversation.isDeletable()) {
if (conversation.canLeave()) {
menuItems.add(new MenuItem(getResources().getString(R.string.nc_delete_call), 9, getResources().getDrawable(R.drawable
.ic_delete_grey600_24dp)));
}

View File

@ -116,7 +116,7 @@ public class OperationsMenuController extends BaseController {
private Disposable disposable;
private Conversation.RoomType conversationType;
private Conversation.ConversationType conversationType;
private ArrayList<String> invitedUsers = new ArrayList<>();
private ArrayList<String> invitedGroups = new ArrayList<>();
@ -278,7 +278,7 @@ public class OperationsMenuController extends BaseController {
invite = invitedGroups.get(0);
}
if (conversationType.equals(Conversation.RoomType.ROOM_PUBLIC_CALL) ||
if (conversationType.equals(Conversation.ConversationType.ROOM_PUBLIC_CALL) ||
!currentUser.hasSpreedCapabilityWithName("empty-group-room")) {
retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(currentUser.getBaseUrl(),
"3", invite, null);
@ -307,7 +307,7 @@ public class OperationsMenuController extends BaseController {
@Override
public void onNext(RoomOverall roomOverall) {
conversation = roomOverall.getOcs().getData();
if (conversationType.equals(Conversation.RoomType.ROOM_PUBLIC_CALL) && isGroupCallWorkaroundFinal) {
if (conversationType.equals(Conversation.ConversationType.ROOM_PUBLIC_CALL) && isGroupCallWorkaroundFinal) {
performGroupCallWorkaround(credentials);
} else {
inviteUsersToAConversation();

View File

@ -140,12 +140,12 @@ public class NotificationWorker extends Worker {
Conversation conversation = roomOverall.getOcs().getData();
intent.putExtra(BundleKeys.KEY_ROOM, Parcels.wrap(conversation));
if (conversation.getType().equals(Conversation.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL) ||
if (conversation.getType().equals(Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) ||
(!TextUtils.isEmpty(conversation.getObjectType()) && "share:password".equals
(conversation.getObjectType()))) {
context.startActivity(intent);
} else {
if (conversation.getType().equals(Conversation.RoomType.ROOM_GROUP_CALL)) {
if (conversation.getType().equals(Conversation.ConversationType.ROOM_GROUP_CALL)) {
conversationType = "group";
} else {
conversationType = "public";

View File

@ -23,23 +23,23 @@ package com.nextcloud.talk.models.json.converters;
import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter;
import com.nextcloud.talk.models.json.rooms.Conversation;
public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.RoomType> {
public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.ConversationType> {
@Override
public Conversation.RoomType getFromInt(int i) {
public Conversation.ConversationType getFromInt(int i) {
switch (i) {
case 1:
return Conversation.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL;
return Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL;
case 2:
return Conversation.RoomType.ROOM_GROUP_CALL;
return Conversation.ConversationType.ROOM_GROUP_CALL;
case 3:
return Conversation.RoomType.ROOM_PUBLIC_CALL;
return Conversation.ConversationType.ROOM_PUBLIC_CALL;
default:
return Conversation.RoomType.DUMMY;
return Conversation.ConversationType.DUMMY;
}
}
@Override
public int convertToInt(Conversation.RoomType object) {
public int convertToInt(Conversation.ConversationType object) {
switch (object) {
case DUMMY:
return 0;

View File

@ -45,7 +45,7 @@ public class Conversation {
@JsonField(name = "displayName")
public String displayName;
@JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
public RoomType type;
public ConversationType type;
@JsonField(name = "count")
public long count;
@JsonField(name = "lastPing")
@ -79,7 +79,7 @@ public class Conversation {
NotificationLevel notificationLevel;
public boolean isPublic() {
return (RoomType.ROOM_PUBLIC_CALL.equals(type));
return (ConversationType.ROOM_PUBLIC_CALL.equals(type));
}
public boolean isGuest() {
@ -93,11 +93,12 @@ public class Conversation {
}
public boolean isNameEditable() {
return (canModerate() && !RoomType.ROOM_TYPE_ONE_TO_ONE_CALL.equals(type));
return (canModerate() && !ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL.equals(type));
}
public boolean isDeletable() {
return (canModerate() && ((participants != null && participants.size() > 2) || numberOfGuests > 0));
public boolean canLeave() {
return !canModerate() || (getType() != ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL && getCount() > 1);
}
public enum NotificationLevel {
@ -108,7 +109,7 @@ public class Conversation {
}
@Parcel
public enum RoomType {
public enum ConversationType {
DUMMY,
ROOM_TYPE_ONE_TO_ONE_CALL,
ROOM_GROUP_CALL,

View File

@ -35,5 +35,5 @@ public class RoomPropertiesWebSocketMessage {
String name;
@JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
Conversation.RoomType roomType;
Conversation.ConversationType roomType;
}