mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-19 10:45:13 +01:00
Begin working on improved leave & delete
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
119e684f8d
commit
f9a14c4a92
@ -176,7 +176,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
|
|||||||
context.getResources().getColor(R.color.nc_grey));
|
context.getResources().getColor(R.color.nc_grey));
|
||||||
holder.dialogLastMessageUserAvatar.setImageDrawable(drawable);
|
holder.dialogLastMessageUserAvatar.setImageDrawable(drawable);
|
||||||
} else if (!conversation.getLastMessage().getActorId().equals(userEntity.getUserId())
|
} 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);
|
holder.dialogLastMessageUserAvatar.setVisibility(View.VISIBLE);
|
||||||
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||||
conversation.getLastMessage().getActorId(), R.dimen.small_item_height), new LazyHeaders.Builder()
|
conversation.getLastMessage().getActorId(), R.dimen.small_item_height), new LazyHeaders.Builder()
|
||||||
|
@ -308,11 +308,11 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
Conversation.RoomType roomType;
|
Conversation.ConversationType roomType;
|
||||||
if (isPublicCall) {
|
if (isPublicCall) {
|
||||||
roomType = Conversation.RoomType.ROOM_PUBLIC_CALL;
|
roomType = Conversation.ConversationType.ROOM_PUBLIC_CALL;
|
||||||
} else {
|
} else {
|
||||||
roomType = Conversation.RoomType.ROOM_GROUP_CALL;
|
roomType = Conversation.ConversationType.ROOM_GROUP_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle.putParcelable(BundleKeys.KEY_CONVERSATION_TYPE, Parcels.wrap(roomType));
|
bundle.putParcelable(BundleKeys.KEY_CONVERSATION_TYPE, Parcels.wrap(roomType));
|
||||||
|
@ -372,7 +372,7 @@ public class ConversationInfoController extends BaseController {
|
|||||||
|
|
||||||
private void setProperNotificationValue(Conversation conversation) {
|
private void setProperNotificationValue(Conversation conversation) {
|
||||||
if (messageNotificationLevel != null) {
|
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
|
// hack to see if we get mentioned always or just on mention
|
||||||
if (conversationUser.hasSpreedCapabilityWithName("mention-flag")) {
|
if (conversationUser.hasSpreedCapabilityWithName("mention-flag")) {
|
||||||
messageNotificationLevel.setValue("always");
|
messageNotificationLevel.setValue("always");
|
||||||
|
@ -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
|
menuItems.add(new MenuItem(getResources().getString(R.string.nc_delete_call), 9, getResources().getDrawable(R.drawable
|
||||||
.ic_delete_grey600_24dp)));
|
.ic_delete_grey600_24dp)));
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
|
|
||||||
private Disposable disposable;
|
private Disposable disposable;
|
||||||
|
|
||||||
private Conversation.RoomType conversationType;
|
private Conversation.ConversationType conversationType;
|
||||||
private ArrayList<String> invitedUsers = new ArrayList<>();
|
private ArrayList<String> invitedUsers = new ArrayList<>();
|
||||||
private ArrayList<String> invitedGroups = new ArrayList<>();
|
private ArrayList<String> invitedGroups = new ArrayList<>();
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
invite = invitedGroups.get(0);
|
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")) {
|
!currentUser.hasSpreedCapabilityWithName("empty-group-room")) {
|
||||||
retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(currentUser.getBaseUrl(),
|
retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(currentUser.getBaseUrl(),
|
||||||
"3", invite, null);
|
"3", invite, null);
|
||||||
@ -307,7 +307,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(RoomOverall roomOverall) {
|
public void onNext(RoomOverall roomOverall) {
|
||||||
conversation = roomOverall.getOcs().getData();
|
conversation = roomOverall.getOcs().getData();
|
||||||
if (conversationType.equals(Conversation.RoomType.ROOM_PUBLIC_CALL) && isGroupCallWorkaroundFinal) {
|
if (conversationType.equals(Conversation.ConversationType.ROOM_PUBLIC_CALL) && isGroupCallWorkaroundFinal) {
|
||||||
performGroupCallWorkaround(credentials);
|
performGroupCallWorkaround(credentials);
|
||||||
} else {
|
} else {
|
||||||
inviteUsersToAConversation();
|
inviteUsersToAConversation();
|
||||||
|
@ -140,12 +140,12 @@ public class NotificationWorker extends Worker {
|
|||||||
Conversation conversation = roomOverall.getOcs().getData();
|
Conversation conversation = roomOverall.getOcs().getData();
|
||||||
|
|
||||||
intent.putExtra(BundleKeys.KEY_ROOM, Parcels.wrap(conversation));
|
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
|
(!TextUtils.isEmpty(conversation.getObjectType()) && "share:password".equals
|
||||||
(conversation.getObjectType()))) {
|
(conversation.getObjectType()))) {
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
if (conversation.getType().equals(Conversation.RoomType.ROOM_GROUP_CALL)) {
|
if (conversation.getType().equals(Conversation.ConversationType.ROOM_GROUP_CALL)) {
|
||||||
conversationType = "group";
|
conversationType = "group";
|
||||||
} else {
|
} else {
|
||||||
conversationType = "public";
|
conversationType = "public";
|
||||||
|
@ -23,23 +23,23 @@ package com.nextcloud.talk.models.json.converters;
|
|||||||
import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter;
|
import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter;
|
||||||
import com.nextcloud.talk.models.json.rooms.Conversation;
|
import com.nextcloud.talk.models.json.rooms.Conversation;
|
||||||
|
|
||||||
public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.RoomType> {
|
public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.ConversationType> {
|
||||||
@Override
|
@Override
|
||||||
public Conversation.RoomType getFromInt(int i) {
|
public Conversation.ConversationType getFromInt(int i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 1:
|
case 1:
|
||||||
return Conversation.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL;
|
return Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL;
|
||||||
case 2:
|
case 2:
|
||||||
return Conversation.RoomType.ROOM_GROUP_CALL;
|
return Conversation.ConversationType.ROOM_GROUP_CALL;
|
||||||
case 3:
|
case 3:
|
||||||
return Conversation.RoomType.ROOM_PUBLIC_CALL;
|
return Conversation.ConversationType.ROOM_PUBLIC_CALL;
|
||||||
default:
|
default:
|
||||||
return Conversation.RoomType.DUMMY;
|
return Conversation.ConversationType.DUMMY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int convertToInt(Conversation.RoomType object) {
|
public int convertToInt(Conversation.ConversationType object) {
|
||||||
switch (object) {
|
switch (object) {
|
||||||
case DUMMY:
|
case DUMMY:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -45,7 +45,7 @@ public class Conversation {
|
|||||||
@JsonField(name = "displayName")
|
@JsonField(name = "displayName")
|
||||||
public String displayName;
|
public String displayName;
|
||||||
@JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
|
@JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
|
||||||
public RoomType type;
|
public ConversationType type;
|
||||||
@JsonField(name = "count")
|
@JsonField(name = "count")
|
||||||
public long count;
|
public long count;
|
||||||
@JsonField(name = "lastPing")
|
@JsonField(name = "lastPing")
|
||||||
@ -79,7 +79,7 @@ public class Conversation {
|
|||||||
NotificationLevel notificationLevel;
|
NotificationLevel notificationLevel;
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return (RoomType.ROOM_PUBLIC_CALL.equals(type));
|
return (ConversationType.ROOM_PUBLIC_CALL.equals(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGuest() {
|
public boolean isGuest() {
|
||||||
@ -93,11 +93,12 @@ public class Conversation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNameEditable() {
|
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() {
|
public boolean canLeave() {
|
||||||
return (canModerate() && ((participants != null && participants.size() > 2) || numberOfGuests > 0));
|
return !canModerate() || (getType() != ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL && getCount() > 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum NotificationLevel {
|
public enum NotificationLevel {
|
||||||
@ -108,7 +109,7 @@ public class Conversation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parcel
|
@Parcel
|
||||||
public enum RoomType {
|
public enum ConversationType {
|
||||||
DUMMY,
|
DUMMY,
|
||||||
ROOM_TYPE_ONE_TO_ONE_CALL,
|
ROOM_TYPE_ONE_TO_ONE_CALL,
|
||||||
ROOM_GROUP_CALL,
|
ROOM_GROUP_CALL,
|
||||||
|
@ -35,5 +35,5 @@ public class RoomPropertiesWebSocketMessage {
|
|||||||
String name;
|
String name;
|
||||||
|
|
||||||
@JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
|
@JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
|
||||||
Conversation.RoomType roomType;
|
Conversation.ConversationType roomType;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user