Skip to content

Commit

Permalink
add workaround to avoid emoji picker to take the full screen height
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mahibi committed Apr 22, 2022
1 parent f7dcf58 commit 2495c25
Showing 1 changed file with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2495c25

Please sign in to comment.