mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-18 14:42:16 +03:00
Replaced EmojiPicker in MessageActionsDialog and CreateConversationDialog
Signed-off-by: Smarshal21 <lcb2021048@iiitl.ac.in>
This commit is contained in:
parent
33ff8c4276
commit
70e3ac3ec8
1 changed files with 19 additions and 30 deletions
|
@ -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<String> = ArrayList()
|
||||
private var groupsToInvite: ArrayList<String> = 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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue