Skip to content

Commit

Permalink
show emoji picker to send reaction (buggy)
Browse files Browse the repository at this point in the history
emoji picker SOMETIMES opens in full height.
this is a bug inside the emoji picker lib, see vanniktech/Emoji#474

Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Apr 6, 2022
1 parent 20e67c8 commit 80591fc
Show file tree
Hide file tree
Showing 2 changed files with 230 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@

package com.nextcloud.talk.ui.dialog

import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.annotation.NonNull
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
Expand All @@ -38,6 +42,7 @@ import com.nextcloud.talk.models.json.chat.ChatMessage
import com.nextcloud.talk.models.json.conversations.Conversation
import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.utils.ApiUtils
import com.vanniktech.emoji.EmojiPopup
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
Expand All @@ -50,10 +55,13 @@ class MessageActionsDialog(
private val currentConversation: Conversation?,
private val showMessageDeletionButton: Boolean,
private val ncApi: NcApi
) : BottomSheetDialog(chatController.activity!!) {
) : BottomSheetDialog(chatController.activity!!, R.style.BottomSheetDialogThemeNoFloating) {

private lateinit var dialogMessageActionsBinding: DialogMessageActionsBinding

private lateinit var popup: EmojiPopup

@SuppressLint("ClickableViewAccessibility")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
dialogMessageActionsBinding = DialogMessageActionsBinding.inflate(layoutInflater)
Expand All @@ -78,6 +86,39 @@ class MessageActionsDialog(
ChatMessage.MessageType.SYSTEM_MESSAGE != message.getMessageType() &&
BuildConfig.DEBUG
)

dialogMessageActionsBinding.emojiMore.setOnTouchListener { v, event ->
if (event.action == MotionEvent.ACTION_DOWN) {
if (popup.isShowing) {
popup.dismiss()
} else {
popup.show()
}
}
true
}

popup = EmojiPopup.Builder
.fromRootView(dialogMessageActionsBinding.root)
.setOnEmojiPopupShownListener {
dialogMessageActionsBinding.emojiMore.clearFocus()
dialogMessageActionsBinding.messageActions.visibility = View.GONE
}
.setOnEmojiClickListener { _, imageView ->
popup.dismiss()
sendReaction(message, imageView.unicode)
}
.setOnEmojiPopupDismissListener {
dialogMessageActionsBinding.emojiMore.clearFocus()
dialogMessageActionsBinding.messageActions.visibility = View.VISIBLE

val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as
InputMethodManager
imm.hideSoftInputFromWindow(dialogMessageActionsBinding.emojiMore.windowToken, 0)
}
.build(dialogMessageActionsBinding.emojiMore)
dialogMessageActionsBinding.emojiMore.disableKeyboardInput(popup)
dialogMessageActionsBinding.emojiMore.forceSingleEmoji()
}

private fun initEmojiBar() {
Expand Down
Loading

0 comments on commit 80591fc

Please sign in to comment.