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 <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-04-22 18:03:56 +02:00
parent f7dcf58d3c
commit 2495c25f22
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

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