From 70e3ac3ec8bda297ac45019a16e03923c7026e7d Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Wed, 8 Nov 2023 22:07:57 +0530 Subject: [PATCH] Replaced EmojiPicker in MessageActionsDialog and CreateConversationDialog Signed-off-by: Smarshal21 --- .../CreateConversationDialogFragment.kt | 49 +++++++------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt index ff68dfdbe..1aefdd9f1 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt @@ -23,7 +23,6 @@ package com.nextcloud.talk.conversation import android.annotation.SuppressLint import android.app.Dialog import android.content.Intent -import android.content.res.ColorStateList import android.os.Bundle import android.os.Parcelable import android.text.Editable @@ -34,7 +33,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AlertDialog -import androidx.core.content.res.ResourcesCompat import androidx.fragment.app.DialogFragment import androidx.lifecycle.ViewModelProvider import androidx.work.Data @@ -44,7 +42,6 @@ import androidx.work.WorkManager import autodagger.AutoInjector import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar -import com.nextcloud.android.common.ui.theme.utils.ColorRole import com.nextcloud.talk.R import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.chat.ChatActivity @@ -55,7 +52,6 @@ import com.nextcloud.talk.models.json.conversations.Conversation import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.bundle.BundleKeys import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew -import com.vanniktech.emoji.EmojiPopup import org.greenrobot.eventbus.EventBus import org.parceler.Parcels import javax.inject.Inject @@ -77,9 +73,7 @@ class CreateConversationDialogFragment : DialogFragment() { private lateinit var binding: DialogCreateConversationBinding private lateinit var viewModel: ConversationViewModel - - private var emojiPopup: EmojiPopup? = null - + private var isEmojiPickerVisible = false private var conversationType: Conversation.ConversationType? = null private var usersToInvite: ArrayList = ArrayList() private var groupsToInvite: ArrayList = ArrayList() @@ -135,8 +129,6 @@ class CreateConversationDialogFragment : DialogFragment() { setupListeners() setupStateObserver() - - setupEmojiPopup() } override fun onStart() { @@ -162,31 +154,20 @@ class CreateConversationDialogFragment : DialogFragment() { } private fun setupEmojiPopup() { - emojiPopup = binding.let { - EmojiPopup( - rootView = requireView(), - editText = it.textEdit, - onEmojiPopupShownListener = { - viewThemeUtils.platform.colorImageView(it.smileyButton, ColorRole.PRIMARY) - }, - onEmojiPopupDismissListener = { - it.smileyButton.imageTintList = ColorStateList.valueOf( - ResourcesCompat.getColor( - resources, - R.color.medium_emphasis_text, - context?.theme - ) - ) - }, - onEmojiClickListener = { - binding.textEdit.editableText?.append(" ") - } - ) + if (!isEmojiPickerVisible) { + binding.emojiPicker.visibility = View.VISIBLE + isEmojiPickerVisible = true + } else { + binding.emojiPicker.visibility = View.GONE + isEmojiPickerVisible = false + } + binding.emojiPicker.setOnEmojiPickedListener() { + binding.textEdit.editableText?.append(it.emoji) } } private fun setupListeners() { - binding.smileyButton.setOnClickListener { emojiPopup?.toggle() } + binding.smileyButton.setOnClickListener { setupEmojiPopup() } binding.textEdit.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { // unused atm @@ -222,6 +203,7 @@ class CreateConversationDialogFragment : DialogFragment() { Log.e(TAG, "Failed to create conversation") showError() } + else -> {} } } @@ -286,6 +268,13 @@ class CreateConversationDialogFragment : DialogFragment() { Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show() } + override fun onResume() { + super.onResume() + dialog?.window?.setLayout( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT + ) + } + /** * Fragment creator */