mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-02 20:53:09 +00:00
rename canPostChatShareItemsDoReaction to hasChatPermission
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
7cf18923b5
commit
bae65ebbe9
@ -274,6 +274,8 @@ class ChatController(args: Bundle) :
|
|||||||
lateinit var mediaPlayerHandler: Handler
|
lateinit var mediaPlayerHandler: Handler
|
||||||
var currentlyPlayedVoiceMessage: ChatMessage? = null
|
var currentlyPlayedVoiceMessage: ChatMessage? = null
|
||||||
|
|
||||||
|
var hasChatPermission: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Log.d(TAG, "init ChatController: " + System.identityHashCode(this).toString())
|
Log.d(TAG, "init ChatController: " + System.identityHashCode(this).toString())
|
||||||
|
|
||||||
@ -307,6 +309,9 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.voiceOnly = args.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false)
|
this.voiceOnly = args.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false)
|
||||||
|
|
||||||
|
hasChatPermission =
|
||||||
|
AttendeePermissionsUtil(currentConversation!!.permissions).hasChatPermission(conversationUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRoomInfo() {
|
private fun getRoomInfo() {
|
||||||
@ -342,7 +347,8 @@ class ChatController(args: Bundle) :
|
|||||||
setTitle()
|
setTitle()
|
||||||
try {
|
try {
|
||||||
setupMentionAutocomplete()
|
setupMentionAutocomplete()
|
||||||
checkReadOnlyState()
|
checkShowCallButtons()
|
||||||
|
checkShowMessageInputView()
|
||||||
checkLobbyState()
|
checkLobbyState()
|
||||||
|
|
||||||
if (!inConversation) {
|
if (!inConversation) {
|
||||||
@ -1159,13 +1165,24 @@ class ChatController(args: Bundle) :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkReadOnlyState() {
|
private fun checkShowCallButtons() {
|
||||||
if (isAlive()) {
|
if (isAlive()) {
|
||||||
if (isReadOnlyConversation() || shouldShowLobby()) {
|
if (isReadOnlyConversation() || shouldShowLobby()) {
|
||||||
disableCallButtons()
|
disableCallButtons()
|
||||||
binding.messageInputView.visibility = View.GONE
|
|
||||||
} else {
|
} else {
|
||||||
enableCallButtons()
|
enableCallButtons()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkShowMessageInputView() {
|
||||||
|
if (isAlive()) {
|
||||||
|
if (isReadOnlyConversation()
|
||||||
|
|| shouldShowLobby()
|
||||||
|
|| !hasChatPermission
|
||||||
|
) {
|
||||||
|
binding.messageInputView.visibility = View.GONE
|
||||||
|
} else {
|
||||||
binding.messageInputView.visibility = View.VISIBLE
|
binding.messageInputView.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2350,7 +2367,7 @@ class ChatController(args: Bundle) :
|
|||||||
super.onPrepareOptionsMenu(menu)
|
super.onPrepareOptionsMenu(menu)
|
||||||
conversationUser?.let {
|
conversationUser?.let {
|
||||||
if (CapabilitiesUtil.hasSpreedFeatureCapability(it, "read-only-rooms")) {
|
if (CapabilitiesUtil.hasSpreedFeatureCapability(it, "read-only-rooms")) {
|
||||||
checkReadOnlyState()
|
checkShowCallButtons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2513,9 +2530,7 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun deleteMessage(message: IMessage?) {
|
fun deleteMessage(message: IMessage?) {
|
||||||
if (!AttendeePermissionsUtil(currentConversation!!.permissions)
|
if (!hasChatPermission) {
|
||||||
.canPostChatShareItemsDoReaction(conversationUser!!)
|
|
||||||
) {
|
|
||||||
Log.e(
|
Log.e(
|
||||||
TAG, "Deletion of message is skipped because of restrictions by permissions. " +
|
TAG, "Deletion of message is skipped because of restrictions by permissions. " +
|
||||||
"This method should not have been called!"
|
"This method should not have been called!"
|
||||||
@ -2842,7 +2857,7 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
if (!CapabilitiesUtil.hasSpreedFeatureCapability(conversationUser, "delete-messages")) return false
|
if (!CapabilitiesUtil.hasSpreedFeatureCapability(conversationUser, "delete-messages")) return false
|
||||||
|
|
||||||
if (AttendeePermissionsUtil(currentConversation!!.permissions).canPostChatShareItemsDoReaction(conversationUser)) return true
|
if (!hasChatPermission) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class AttendeePermissionsUtil(flag: Int) {
|
|||||||
var canPublishAudio: Boolean = false
|
var canPublishAudio: Boolean = false
|
||||||
var canPublishVideo: Boolean = false
|
var canPublishVideo: Boolean = false
|
||||||
var canPublishScreen: Boolean = false
|
var canPublishScreen: Boolean = false
|
||||||
private var canPostChatShareItemsDoReaction: Boolean = false
|
private var hasChatPermission: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
isDefault = (flag and DEFAULT) == DEFAULT
|
isDefault = (flag and DEFAULT) == DEFAULT
|
||||||
@ -26,13 +26,12 @@ class AttendeePermissionsUtil(flag: Int) {
|
|||||||
canPublishAudio = (flag and PUBLISH_AUDIO) == PUBLISH_AUDIO
|
canPublishAudio = (flag and PUBLISH_AUDIO) == PUBLISH_AUDIO
|
||||||
canPublishVideo = (flag and PUBLISH_VIDEO) == PUBLISH_VIDEO
|
canPublishVideo = (flag and PUBLISH_VIDEO) == PUBLISH_VIDEO
|
||||||
canPublishScreen = (flag and PUBLISH_SCREEN) == PUBLISH_SCREEN
|
canPublishScreen = (flag and PUBLISH_SCREEN) == PUBLISH_SCREEN
|
||||||
canPostChatShareItemsDoReaction =
|
hasChatPermission = (flag and CHAT) == CHAT
|
||||||
(flag and POST_CHAT_SHARE_ITEMS_DO_REACTIONS) == POST_CHAT_SHARE_ITEMS_DO_REACTIONS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canPostChatShareItemsDoReaction(user: UserEntity): Boolean {
|
fun hasChatPermission(user: UserEntity): Boolean {
|
||||||
if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "chat-permission")) {
|
if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "chat-permission")) {
|
||||||
return canPostChatShareItemsDoReaction
|
return hasChatPermission
|
||||||
}
|
}
|
||||||
// if capability is not available then the spreed version doesn't support to restrict this
|
// if capability is not available then the spreed version doesn't support to restrict this
|
||||||
return true
|
return true
|
||||||
@ -48,6 +47,6 @@ class AttendeePermissionsUtil(flag: Int) {
|
|||||||
const val PUBLISH_AUDIO = 16
|
const val PUBLISH_AUDIO = 16
|
||||||
const val PUBLISH_VIDEO = 32
|
const val PUBLISH_VIDEO = 32
|
||||||
const val PUBLISH_SCREEN = 64
|
const val PUBLISH_SCREEN = 64
|
||||||
const val POST_CHAT_SHARE_ITEMS_DO_REACTIONS = 128
|
const val CHAT = 128
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,6 +23,6 @@ class AttendeePermissionsUtilTest : TestCase() {
|
|||||||
assertFalse(attendeePermissionsUtil.canPublishAudio)
|
assertFalse(attendeePermissionsUtil.canPublishAudio)
|
||||||
assertFalse(attendeePermissionsUtil.canPublishVideo)
|
assertFalse(attendeePermissionsUtil.canPublishVideo)
|
||||||
|
|
||||||
// canPostChatShareItemsDoReaction() is not possible to test because userEntity is necessary
|
// hasChatPermission() is not possible to test because userEntity is necessary
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user