mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
parent
7f0131d324
commit
ae8ff9d1e5
@ -301,4 +301,9 @@ public interface NcApi {
|
||||
@FormUrlEncoded
|
||||
@POST
|
||||
Observable<GenericOverall> setNotificationLevel(@Header("Authorization") String authorization, @Url String url, @Field("level") int level);
|
||||
|
||||
@FormUrlEncoded
|
||||
@PUT
|
||||
Observable<GenericOverall> setReadOnlyState(@Header("Authorization") String authorization, @Url String url, @Field("state") int state);
|
||||
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
private UserEntity conversationUser;
|
||||
private String roomPassword;
|
||||
private String credentials;
|
||||
private Conversation currentConversation;
|
||||
private Call currentCall;
|
||||
private boolean inChat = false;
|
||||
private boolean historyRead = false;
|
||||
@ -162,18 +163,25 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
|
||||
private CharSequence myFirstMessage;
|
||||
|
||||
private MenuItem conversationInfoMenuItem;
|
||||
private MenuItem conversationVoiceCallMenuItem;
|
||||
private MenuItem conversationVideoMenuItem;
|
||||
|
||||
private boolean readOnlyCheckPerformed;
|
||||
public ChatController(Bundle args) {
|
||||
super(args);
|
||||
setHasOptionsMenu(true);
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
this.conversationName = args.getString(BundleKeys.KEY_CONVERSATION_NAME, "");
|
||||
this.conversationUser = args.getParcelable(BundleKeys.KEY_USER_ENTITY);
|
||||
this.roomId = args.getString(BundleKeys.KEY_ROOM_ID, "");
|
||||
this.roomToken = args.getString(BundleKeys.KEY_ROOM_TOKEN, "");
|
||||
|
||||
if (args.containsKey(BundleKeys.KEY_ACTIVE_CONVERSATION)) {
|
||||
this.currentCall = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION));
|
||||
this.currentConversation = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION));
|
||||
if (currentConversation != null) {
|
||||
conversationName = currentConversation.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
this.roomPassword = args.getString(BundleKeys.KEY_CONVERSATION_PASSWORD, "");
|
||||
@ -203,8 +211,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
|
||||
@Override
|
||||
public void onNext(RoomOverall roomOverall) {
|
||||
|
||||
conversationName = roomOverall.getOcs().getData().getDisplayName();
|
||||
currentConversation = roomOverall.getOcs().getData();
|
||||
conversationName = currentConversation.getDisplayName();
|
||||
setTitle();
|
||||
|
||||
setupMentionAutocomplete();
|
||||
@ -239,6 +247,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
for (Conversation conversation : roomsOverall.getOcs().getData()) {
|
||||
if (roomId.equals(conversation.getRoomId())) {
|
||||
roomToken = conversation.getToken();
|
||||
currentConversation = conversation;
|
||||
conversationName = conversation.getDisplayName();
|
||||
setTitle();
|
||||
break;
|
||||
@ -416,6 +425,53 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
}
|
||||
}
|
||||
|
||||
private void checkReadOnlyState() {
|
||||
if (currentConversation != null && !readOnlyCheckPerformed) {
|
||||
|
||||
readOnlyCheckPerformed = true;
|
||||
if (currentConversation.getConversationReadOnlyState() != null &&
|
||||
!currentConversation.getConversationReadOnlyState().equals(Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY)) {
|
||||
messageInput.setHint(R.string.nc_readonly_hint);
|
||||
|
||||
conversationVoiceCallMenuItem.getIcon().setAlpha(99);
|
||||
conversationVoiceCallMenuItem.setEnabled(false);
|
||||
conversationVideoMenuItem.getIcon().setAlpha(99);
|
||||
conversationVideoMenuItem.setEnabled(false);
|
||||
|
||||
setChildrenState(messageInputView, false);
|
||||
} else {
|
||||
messageInput.setHint("");
|
||||
|
||||
conversationVoiceCallMenuItem.getIcon().setAlpha(255);
|
||||
conversationVoiceCallMenuItem.setEnabled(true);
|
||||
conversationVideoMenuItem.getIcon().setAlpha(255);
|
||||
conversationVideoMenuItem.setEnabled(true);
|
||||
|
||||
setChildrenState(messageInputView, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setChildrenState(View view, boolean enabled) {
|
||||
if (view.getId() != R.id.messageSendButton) {
|
||||
view.setEnabled(enabled);
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
view.setAlpha(1.0f);
|
||||
} else {
|
||||
view.setAlpha(0.38f);
|
||||
}
|
||||
|
||||
if (view instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup) view;
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
View child = viewGroup.getChildAt(i);
|
||||
setChildrenState(child, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void showConversationInfoScreen() {
|
||||
Bundle bundle = new Bundle();
|
||||
@ -602,6 +658,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
} else {
|
||||
pullChatMessages(1);
|
||||
}
|
||||
|
||||
if (startCallFromNotification != null && startCallFromNotification) {
|
||||
startCallFromNotification = false;
|
||||
startACall(voiceOnly);
|
||||
@ -627,7 +684,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
} else {
|
||||
pullChatMessages(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void leaveRoom() {
|
||||
@ -645,7 +702,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
@Override
|
||||
public void onNext(GenericOverall genericOverall) {
|
||||
dispose();
|
||||
currentCall = null;
|
||||
currentConversation = null;
|
||||
if (!isDestroyed() && !isBeingDestroyed() && !wasDetached) {
|
||||
getRouter().popCurrentController();
|
||||
}
|
||||
@ -997,7 +1054,13 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
inflater.inflate(R.menu.menu_conversation, menu);
|
||||
if (conversationUser.getUserId().equals("?")) {
|
||||
menu.removeItem(R.id.conversation_info);
|
||||
} else {
|
||||
conversationInfoMenuItem = menu.findItem(R.id.conversation_info);
|
||||
conversationVoiceCallMenuItem = menu.findItem(R.id.conversation_voice_call);
|
||||
conversationVideoMenuItem = menu.findItem(R.id.conversation_video_call);
|
||||
}
|
||||
|
||||
checkReadOnlyState();
|
||||
}
|
||||
|
||||
|
||||
@ -1037,7 +1100,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
}
|
||||
|
||||
private Intent getIntentForCall(boolean isVoiceOnlyCall) {
|
||||
if (currentCall != null) {
|
||||
if (currentConversation != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, roomId);
|
||||
|
@ -275,8 +275,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.getOcs().getData().getRoomId());
|
||||
|
||||
if (currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
||||
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME,
|
||||
roomOverall.getOcs().getData().getDisplayName());
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.getOcs().getData()));
|
||||
conversationIntent.putExtras(bundle);
|
||||
getRouter().replaceTopController((RouterTransaction.with(new ChatController(bundle))
|
||||
.pushChangeHandler(new HorizontalChangeHandler())
|
||||
@ -888,8 +888,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
conversationIntent.putExtras(bundle);
|
||||
|
||||
if (currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
||||
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME,
|
||||
roomOverall.getOcs().getData().getDisplayName());
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.getOcs().getData()));
|
||||
getRouter().replaceTopController((RouterTransaction.with(new ChatController(bundle))
|
||||
.pushChangeHandler(new HorizontalChangeHandler())
|
||||
.popChangeHandler(new HorizontalChangeHandler())));
|
||||
|
@ -668,7 +668,7 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
currentUser = userUtils.getCurrentUser();
|
||||
|
||||
if (currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
||||
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME, conversation.getDisplayName());
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(conversation));
|
||||
getRouter().pushController((RouterTransaction.with(new ChatController(bundle))
|
||||
.pushChangeHandler(new HorizontalChangeHandler())
|
||||
.popChangeHandler(new HorizontalChangeHandler())));
|
||||
|
@ -624,7 +624,7 @@ public class OperationsMenuController extends BaseController {
|
||||
}
|
||||
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, conversationUser);
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(call));
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(conversation));
|
||||
bundle.putString(BundleKeys.KEY_CONVERSATION_PASSWORD, callPassword);
|
||||
|
||||
conversationIntent.putExtras(bundle);
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.models.json.converters;
|
||||
|
||||
import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter;
|
||||
import com.nextcloud.talk.models.json.rooms.Conversation;
|
||||
|
||||
public class EnumReadOnlyConversationConverter extends IntBasedTypeConverter<Conversation.ConversationReadOnlyState> {
|
||||
@Override
|
||||
public Conversation.ConversationReadOnlyState getFromInt(int i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return Conversation.ConversationReadOnlyState.CONVERSATION_READ_WRITE;
|
||||
case 1:
|
||||
return Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY;
|
||||
default:
|
||||
return Conversation.ConversationReadOnlyState.CONVERSATION_READ_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int convertToInt(Conversation.ConversationReadOnlyState object) {
|
||||
switch (object) {
|
||||
case CONVERSATION_READ_WRITE:
|
||||
return 0;
|
||||
case CONVERSATION_READ_ONLY:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -29,6 +29,7 @@ import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.nextcloud.talk.models.json.converters.EnumNotificationLevelConverter;
|
||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||
import com.nextcloud.talk.models.json.converters.EnumReadOnlyConversationConverter;
|
||||
import com.nextcloud.talk.models.json.converters.EnumRoomTypeConverter;
|
||||
import com.nextcloud.talk.models.json.participants.Participant;
|
||||
import lombok.Data;
|
||||
@ -81,6 +82,9 @@ public class Conversation {
|
||||
String objectType;
|
||||
@JsonField(name = "notificationLevel", typeConverter = EnumNotificationLevelConverter.class)
|
||||
NotificationLevel notificationLevel;
|
||||
@JsonField(name = "readOnly", typeConverter = EnumReadOnlyConversationConverter.class)
|
||||
ConversationReadOnlyState conversationReadOnlyState;
|
||||
|
||||
|
||||
public boolean isPublic() {
|
||||
return (ConversationType.ROOM_PUBLIC_CALL.equals(type));
|
||||
@ -129,6 +133,11 @@ public class Conversation {
|
||||
NEVER
|
||||
}
|
||||
|
||||
public enum ConversationReadOnlyState {
|
||||
CONVERSATION_READ_WRITE,
|
||||
CONVERSATION_READ_ONLY
|
||||
}
|
||||
|
||||
@Parcel
|
||||
public enum ConversationType {
|
||||
DUMMY,
|
||||
|
@ -232,4 +232,8 @@ public class ApiUtils {
|
||||
public static String getUrlForNotificationWithId(String baseUrl, String notificationId) {
|
||||
return baseUrl + ocsApiVersion + "/apps/notifications/api/v2/notifications/" + notificationId;
|
||||
}
|
||||
|
||||
public static String getUrlForReadOnlyState(String baseUrl, String roomToken) {
|
||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + roomToken + "/read-only";
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
android:id="@+id/conversation_voice_call"
|
||||
android:icon="@drawable/ic_call_white_24dp"
|
||||
android:orderInCategory="0"
|
||||
android:enabled="false"
|
||||
android:title="@string/nc_conversation_menu_voice_call"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
@ -33,6 +34,7 @@
|
||||
android:icon="@drawable/ic_videocam_white_24px"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/nc_conversation_menu_video_call"
|
||||
android:enabled="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
|
@ -259,4 +259,5 @@
|
||||
<string name="nc_user">User</string>
|
||||
<string name="nc_guest">Guest</string>
|
||||
<string name="nc_following_link">User following a public link</string>
|
||||
<string name="nc_readonly_hint">This conversation is locked</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user