From 2495c25f22d42eeec939eed579d49505c3adeaa3 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 22 Apr 2022 18:03:56 +0200 Subject: [PATCH 1/2] add workaround to avoid emoji picker to take the full screen height The toggleEmojiPopup method is a hacky workaround to avoid bug #1914 As the bug happens only for the very first time when the popup is opened, it is closed after some milliseconds and opened again. 200 milliseconds seems to be a good value to initialize the popup correctly with the desired size downside: there is even some flickering when opening the "more emojis" window Signed-off-by: Marcel Hibbe --- .../talk/ui/dialog/MessageActionsDialog.kt | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 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 2bb6fc1320..f1ab4d46ac 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 @@ -23,6 +23,8 @@ package com.nextcloud.talk.ui.dialog import android.annotation.SuppressLint import android.content.Context import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.util.Log import android.view.MotionEvent import android.view.View @@ -91,11 +93,18 @@ class MessageActionsDialog( initEmojiMore() } + override fun onStart() { + super.onStart() + val bottomSheet = findViewById(R.id.design_bottom_sheet) + val behavior = BottomSheetBehavior.from(bottomSheet as View) + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + @SuppressLint("ClickableViewAccessibility") private fun initEmojiMore() { dialogMessageActionsBinding.emojiMore.setOnTouchListener { v, event -> if (event.action == MotionEvent.ACTION_DOWN) { - popup.toggle() + toggleEmojiPopup() } true } @@ -123,6 +132,26 @@ class MessageActionsDialog( dialogMessageActionsBinding.emojiMore.forceSingleEmoji() } + /* + This method is a hacky workaround to avoid bug #1914 + As the bug happens only for the very first time when the popup is opened, + it is closed after some milliseconds and opened again. + */ + private fun toggleEmojiPopup() { + if (popup.isShowing) { + popup.dismiss() + } else { + popup.show() + Handler(Looper.getMainLooper()).postDelayed( + { + popup.dismiss() + popup.show() + }, + 200 + ) + } + } + private fun initEmojiBar() { if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "reactions")) { checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiThumbsUp) @@ -231,13 +260,6 @@ class MessageActionsDialog( dialogMessageActionsBinding.menuCopyMessage.visibility = getVisibility(visible) } - override fun onStart() { - super.onStart() - val bottomSheet = findViewById(R.id.design_bottom_sheet) - val behavior = BottomSheetBehavior.from(bottomSheet as View) - behavior.state = BottomSheetBehavior.STATE_EXPANDED - } - private fun getVisibility(visible: Boolean): Int { return if (visible) { View.VISIBLE From e43c838fe75f4402e4e2936eba81bbf2856d9f01 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 23 Apr 2022 13:22:25 +0200 Subject: [PATCH 2/2] convert into constant Signed-off-by: Andy Scherzinger --- .../java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 f1ab4d46ac..b114dc0c92 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 @@ -147,7 +147,7 @@ class MessageActionsDialog( popup.dismiss() popup.show() }, - 200 + DELAY ) } } @@ -350,5 +350,6 @@ class MessageActionsDialog( private const val ACTOR_LENGTH = 6 private const val NO_PREVIOUS_MESSAGE_ID: Int = -1 private const val HTTP_CREATED: Int = 201 + private const val DELAY: Long = 200 } }