mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-19 15:14:28 +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.annotation.SuppressLint
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.ColorStateList
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
|
@ -34,7 +33,6 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.content.res.ResourcesCompat
|
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.work.Data
|
import androidx.work.Data
|
||||||
|
@ -44,7 +42,6 @@ import androidx.work.WorkManager
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.google.android.material.snackbar.Snackbar
|
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.R
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||||
import com.nextcloud.talk.chat.ChatActivity
|
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.ui.theme.ViewThemeUtils
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||||
import com.vanniktech.emoji.EmojiPopup
|
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.parceler.Parcels
|
import org.parceler.Parcels
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -77,9 +73,7 @@ class CreateConversationDialogFragment : DialogFragment() {
|
||||||
|
|
||||||
private lateinit var binding: DialogCreateConversationBinding
|
private lateinit var binding: DialogCreateConversationBinding
|
||||||
private lateinit var viewModel: ConversationViewModel
|
private lateinit var viewModel: ConversationViewModel
|
||||||
|
private var isEmojiPickerVisible = false
|
||||||
private var emojiPopup: EmojiPopup? = null
|
|
||||||
|
|
||||||
private var conversationType: Conversation.ConversationType? = null
|
private var conversationType: Conversation.ConversationType? = null
|
||||||
private var usersToInvite: ArrayList<String> = ArrayList()
|
private var usersToInvite: ArrayList<String> = ArrayList()
|
||||||
private var groupsToInvite: ArrayList<String> = ArrayList()
|
private var groupsToInvite: ArrayList<String> = ArrayList()
|
||||||
|
@ -135,8 +129,6 @@ class CreateConversationDialogFragment : DialogFragment() {
|
||||||
|
|
||||||
setupListeners()
|
setupListeners()
|
||||||
setupStateObserver()
|
setupStateObserver()
|
||||||
|
|
||||||
setupEmojiPopup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -162,31 +154,20 @@ class CreateConversationDialogFragment : DialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEmojiPopup() {
|
private fun setupEmojiPopup() {
|
||||||
emojiPopup = binding.let {
|
if (!isEmojiPickerVisible) {
|
||||||
EmojiPopup(
|
binding.emojiPicker.visibility = View.VISIBLE
|
||||||
rootView = requireView(),
|
isEmojiPickerVisible = true
|
||||||
editText = it.textEdit,
|
} else {
|
||||||
onEmojiPopupShownListener = {
|
binding.emojiPicker.visibility = View.GONE
|
||||||
viewThemeUtils.platform.colorImageView(it.smileyButton, ColorRole.PRIMARY)
|
isEmojiPickerVisible = false
|
||||||
},
|
|
||||||
onEmojiPopupDismissListener = {
|
|
||||||
it.smileyButton.imageTintList = ColorStateList.valueOf(
|
|
||||||
ResourcesCompat.getColor(
|
|
||||||
resources,
|
|
||||||
R.color.medium_emphasis_text,
|
|
||||||
context?.theme
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onEmojiClickListener = {
|
|
||||||
binding.textEdit.editableText?.append(" ")
|
|
||||||
}
|
}
|
||||||
)
|
binding.emojiPicker.setOnEmojiPickedListener() {
|
||||||
|
binding.textEdit.editableText?.append(it.emoji)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListeners() {
|
private fun setupListeners() {
|
||||||
binding.smileyButton.setOnClickListener { emojiPopup?.toggle() }
|
binding.smileyButton.setOnClickListener { setupEmojiPopup() }
|
||||||
binding.textEdit.addTextChangedListener(object : TextWatcher {
|
binding.textEdit.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||||
// unused atm
|
// unused atm
|
||||||
|
@ -222,6 +203,7 @@ class CreateConversationDialogFragment : DialogFragment() {
|
||||||
Log.e(TAG, "Failed to create conversation")
|
Log.e(TAG, "Failed to create conversation")
|
||||||
showError()
|
showError()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,6 +268,13 @@ class CreateConversationDialogFragment : DialogFragment() {
|
||||||
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
|
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
|
* Fragment creator
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue