Эх сурвалжийг харах

restrict to start a call when permission is missing

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 жил өмнө
parent
commit
54552cdd87

+ 8 - 4
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -2298,10 +2298,14 @@ class ChatController(args: Bundle) :
     }
 
     private fun startACall(isVoiceOnlyCall: Boolean) {
-        ApplicationWideCurrentRoomHolder.getInstance().isDialing = true
-        val callIntent = getIntentForCall(isVoiceOnlyCall)
-        if (callIntent != null) {
-            startActivity(callIntent)
+        if (currentConversation?.canStartCall == false && currentConversation?.hasCall == false) {
+            Toast.makeText(context, R.string.startCallForbidden, Toast.LENGTH_LONG).show()
+        } else {
+            ApplicationWideCurrentRoomHolder.getInstance().isDialing = true
+            val callIntent = getIntentForCall(isVoiceOnlyCall)
+            if (callIntent != null) {
+                startActivity(callIntent)
+            }
         }
     }
 

+ 30 - 0
app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java

@@ -92,8 +92,12 @@ public class Conversation {
     public Long lobbyTimer;
     @JsonField(name = "lastReadMessage")
     public int lastReadMessage;
+    @JsonField(name = "hasCall")
+    public boolean hasCall;
     @JsonField(name = "callFlag")
     public int callFlag;
+    @JsonField(name = "canStartCall")
+    public boolean canStartCall;
 
     @JsonField(name = "canLeaveConversation")
     public Boolean canLeaveConversation;
@@ -259,10 +263,18 @@ public class Conversation {
         return this.lastReadMessage;
     }
 
+    public boolean getHasCall() {
+        return hasCall;
+    }
+
     public int getCallFlag() {
         return this.callFlag;
     }
 
+    public boolean getCanStartCall() {
+        return canStartCall;
+    }
+
     public Boolean getUnreadMentionDirect() {
         return unreadMentionDirect;
     }
@@ -370,10 +382,18 @@ public class Conversation {
         this.lastReadMessage = lastReadMessage;
     }
 
+    public void setHasCall(boolean hasCall) {
+        this.hasCall = hasCall;
+    }
+
     public void setCallFlag(int callFlag) {
         this.callFlag = callFlag;
     }
 
+    public void setCanStartCall(boolean canStartCall) {
+        this.canStartCall = canStartCall;
+    }
+
     public void setUnreadMentionDirect(Boolean unreadMentionDirect) {
         this.unreadMentionDirect = unreadMentionDirect;
     }
@@ -411,9 +431,15 @@ public class Conversation {
         if (lastReadMessage != that.lastReadMessage) {
             return false;
         }
+        if (hasCall != that.hasCall) {
+            return false;
+        }
         if (callFlag != that.callFlag) {
             return false;
         }
+        if (canStartCall != that.canStartCall) {
+            return false;
+        }
         if (!Objects.equals(roomId, that.roomId)) {
             return false;
         }
@@ -508,7 +534,9 @@ public class Conversation {
         result = 31 * result + (lobbyState != null ? lobbyState.hashCode() : 0);
         result = 31 * result + (lobbyTimer != null ? lobbyTimer.hashCode() : 0);
         result = 31 * result + lastReadMessage;
+        result = 31 * result + (hasCall ? 1 : 0);
         result = 31 * result + callFlag;
+        result = 31 * result + (canStartCall ? 1 : 0);
         result = 31 * result + (canLeaveConversation != null ? canLeaveConversation.hashCode() : 0);
         result = 31 * result + (canDeleteConversation != null ? canDeleteConversation.hashCode() : 0);
         result = 31 * result + (notificationCalls != null ? notificationCalls.hashCode() : 0);
@@ -543,7 +571,9 @@ public class Conversation {
                 ", lobbyState=" + lobbyState +
                 ", lobbyTimer=" + lobbyTimer +
                 ", lastReadMessage=" + lastReadMessage +
+                ", hasCall=" + hasCall +
                 ", callFlag=" + callFlag +
+                ", canStartCall=" + canStartCall +
                 ", canLeaveConversation=" + canLeaveConversation +
                 ", canDeleteConversation=" + canDeleteConversation +
                 ", notificationCalls=" + notificationCalls +

+ 1 - 0
app/src/main/res/layout/controller_chat.xml

@@ -23,6 +23,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/chat_container"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:animateLayoutChanges="true"

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -383,6 +383,7 @@
     <string name="nc_reply_privately">Reply privately</string>
     <string name="nc_delete_message">Delete</string>
     <string name="nc_delete_message_leaked_to_matterbridge">Message deleted successfully, but it might have been leaked to other services</string>
+    <string name="startCallForbidden">You are not allowed to start a call</string>
 
     <string name="share">Share</string>
     <string name="send_to">Send to</string>