From 5a76f3a3d33911103d76f7451db55cb7495a3f0a Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 9 May 2022 16:46:16 +0200 Subject: [PATCH] extract checks to separate methods Signed-off-by: Andy Scherzinger --- .../talk/ui/dialog/MessageActionsDialog.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index e6832f8e5..da085c583 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -76,10 +76,8 @@ class MessageActionsDialog( initMenuReplyToMessage(message.replyable) initMenuReplyPrivately( message.replyable && - user?.userId?.isNotEmpty() == true && - user?.userId != "?" && - message.user.id.startsWith("users/") && - message.user.id.substring(ACTOR_LENGTH) != currentConversation?.actorId && + hasUserId(user) && + hasUserActorId(message) && currentConversation?.type != Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL ) initMenuDeleteMessage(showMessageDeletionButton) @@ -101,6 +99,15 @@ class MessageActionsDialog( behavior.state = BottomSheetBehavior.STATE_EXPANDED } + private fun hasUserId(user: UserEntity?): Boolean { + return user?.userId?.isNotEmpty() == true && user?.userId != "?" + } + + private fun hasUserActorId(message: ChatMessage): Boolean { + return message.user.id.startsWith("users/") && + message.user.id.substring(ACTOR_LENGTH) != currentConversation?.actorId + } + @SuppressLint("ClickableViewAccessibility") private fun initEmojiMore() { dialogMessageActionsBinding.emojiMore.setOnTouchListener { v, event ->