Skip to content

Commit

Permalink
Merge pull request #1942 from nextcloud/bugfix/1914/fixEmojiPickerHeight
Browse files Browse the repository at this point in the history
add workaround to avoid emoji picker to take the full screen height
  • Loading branch information
AndyScherzinger authored Apr 23, 2022
2 parents f7dcf58 + e43c838 commit 942a2c0
Showing 1 changed file with 31 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()
},
DELAY
)
}
}

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 Expand Up @@ -328,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
}
}

0 comments on commit 942a2c0

Please sign in to comment.