restrict to start a call when permission is missing

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-01-11 11:46:18 +01:00 committed by Marcel Hibbe (Rebase PR Action)
parent 65e002fe98
commit 54552cdd87
4 changed files with 40 additions and 4 deletions

View file

@ -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)
}
}
}

View file

@ -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 +

View file

@ -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"

View file

@ -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>