From ee601bb59045e586a9a58b9db28bce810ea285bb Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Wed, 8 Nov 2023 18:06:56 +0530 Subject: [PATCH 01/17] Replaced EmojiPicker in SetStatusDialogFragment Signed-off-by: Smarshal21 --- app/build.gradle | 1 + .../talk/ui/dialog/SetStatusDialogFragment.kt | 98 +++++++++---------- app/src/main/res/layout/dialog_set_status.xml | 9 +- 3 files changed, 53 insertions(+), 55 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 742eece698..fc0f4456c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -180,6 +180,7 @@ dependencies { implementation "androidx.emoji2:emoji2-bundled:${emojiVersion}" implementation "androidx.emoji2:emoji2-views:${emojiVersion}" implementation "androidx.emoji2:emoji2-views-helper:${emojiVersion}" + implementation "androidx.emoji2:emoji2-emojipicker:${emojiVersion}" implementation 'org.michaelevans.colorart:library:0.0.3' implementation "androidx.work:work-runtime:${workVersion}" implementation "androidx.work:work-rxjava2:${workVersion}" diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index e92ae94b10..523e2c068c 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -29,6 +29,8 @@ import android.os.Bundle import android.util.Log import android.view.LayoutInflater import android.view.View +import android.view.View.GONE +import android.view.View.VISIBLE import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.AdapterView @@ -62,8 +64,6 @@ import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew import com.vanniktech.emoji.EmojiPopup -import com.vanniktech.emoji.installDisableKeyboardInput -import com.vanniktech.emoji.installForceSingleEmoji import io.reactivex.Observer import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -90,10 +90,10 @@ private const val FOUR_HOURS = 4 private const val LAST_HOUR_OF_DAY = 23 private const val LAST_MINUTE_OF_HOUR = 59 private const val LAST_SECOND_OF_MINUTE = 59 +private var isEmojiPickerVisible = false @AutoInjector(NextcloudTalkApplication::class) -class SetStatusDialogFragment : - DialogFragment(), PredefinedStatusClickListener { +class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener { private var selectedPredefinedStatus: PredefinedStatus? = null @@ -130,8 +130,7 @@ class SetStatusDialogFragment : credentials = ApiUtils.getCredentials(currentUser?.username, currentUser?.token) ncApi.getPredefinedStatuses(credentials, ApiUtils.getUrlForPredefinedStatuses(currentUser?.baseUrl)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(object : Observer { override fun onSubscribe(d: Disposable) { @@ -140,15 +139,11 @@ class SetStatusDialogFragment : override fun onNext(responseBody: ResponseBody) { val predefinedStatusOverall: PredefinedStatusOverall = LoganSquare.parse( - responseBody - .string(), - PredefinedStatusOverall::class.java + responseBody.string(), PredefinedStatusOverall::class.java ) predefinedStatusOverall.ocs?.data?.let { it1 -> predefinedStatusesList.addAll(it1) } - if (currentStatus?.messageIsPredefined == true && - currentStatus?.messageId?.isNotEmpty() == true - ) { + if (currentStatus?.messageIsPredefined == true && currentStatus?.messageId?.isNotEmpty() == true) { val messageId = currentStatus!!.messageId selectedPredefinedStatus = predefinedStatusesList.firstOrNull { ps -> messageId == ps.id } } @@ -193,22 +188,13 @@ class SetStatusDialogFragment : binding.clearStatus.setOnClickListener { clearStatus() } binding.setStatus.setOnClickListener { setStatusMessage() } - binding.emoji.setOnClickListener { openEmojiPopup() } - - popup = EmojiPopup( - rootView = view, - editText = binding.emoji, - onEmojiClickListener = { - popup.dismiss() - binding.emoji.clearFocus() - val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as - InputMethodManager - imm.hideSoftInputFromWindow(binding.emoji.windowToken, 0) - } - ) - binding.emoji.installDisableKeyboardInput(popup) - binding.emoji.installForceSingleEmoji() - + binding.emojiPicker.setOnEmojiPickedListener() { + binding.emoji.text = (it.emoji) + binding.emojiPicker.visibility = GONE + isEmojiPickerVisible = false + val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(binding.emoji.windowToken, 0) + } binding.clearStatusAfterSpinner.apply { this.adapter = createClearTimesArrayAdapter() onItemSelectedListener = object : OnItemSelectedListener { @@ -247,9 +233,9 @@ class SetStatusDialogFragment : binding.remainingClearTime.apply { binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message) visibility = View.VISIBLE - text = DisplayUtils.getRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true) - .toString() - .decapitalize(Locale.getDefault()) + text = + DisplayUtils.getRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true).toString() + .decapitalize(Locale.getDefault()) setOnClickListener { visibility = View.GONE binding.clearStatusAfterSpinner.visibility = View.VISIBLE @@ -365,15 +351,23 @@ class SetStatusDialogFragment : return returnValue } - private fun openEmojiPopup() { - popup.show() + private fun toggleEmojiPicker() { + if (!isEmojiPickerVisible) { + val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(binding.emoji.windowToken, 0) + binding.emojiPicker.visibility = VISIBLE + isEmojiPickerVisible = true + } else { + binding.emojiPicker.visibility = GONE + isEmojiPickerVisible = false + } } private fun clearStatus() { val credentials = ApiUtils.getCredentials(currentUser?.username, currentUser?.token) ncApi.statusDeleteMessage(credentials, ApiUtils.getUrlForStatusMessage(currentUser?.baseUrl)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()).subscribe(object : Observer { + .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + .subscribe(object : Observer { override fun onSubscribe(d: Disposable) { // unused atm } @@ -397,10 +391,8 @@ class SetStatusDialogFragment : ncApi.setStatusType(credentials, ApiUtils.getUrlForSetStatusType(currentUser?.baseUrl), statusType.string) .subscribeOn( - Schedulers - .io() - ) - .observeOn(AndroidSchedulers.mainThread()).subscribe(object : Observer { + Schedulers.io() + ).observeOn(AndroidSchedulers.mainThread()).subscribe(object : Observer { override fun onSubscribe(d: Disposable) { // unused atm } @@ -464,19 +456,10 @@ class SetStatusDialogFragment : // The endpoint '/message/custom' expects a valid emoji as string or null val statusIcon = binding.emoji.text.toString().ifEmpty { null } - if (selectedPredefinedStatus == null || - selectedPredefinedStatus!!.message != inputText || - selectedPredefinedStatus!!.icon != binding.emoji.text.toString() - ) { + if (selectedPredefinedStatus == null || selectedPredefinedStatus!!.message != inputText || selectedPredefinedStatus!!.icon != binding.emoji.text.toString()) { ncApi.setCustomStatusMessage( - credentials, - ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl), - statusIcon, - inputText, - clearAt - ) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + credentials, ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl), statusIcon, inputText, clearAt + ).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer { override fun onSubscribe(d: Disposable) { @@ -504,9 +487,8 @@ class SetStatusDialogFragment : ApiUtils.getUrlForSetPredefinedStatus(currentUser?.baseUrl), selectedPredefinedStatus!!.id, if (clearAt == -1L) null else clearAt - ) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread())?.subscribe(object : Observer { + ).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer { override fun onSubscribe(d: Disposable) = Unit override fun onNext(t: GenericOverall) { @@ -524,6 +506,7 @@ class SetStatusDialogFragment : } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + binding.emoji.setOnClickListener { toggleEmojiPicker() } return binding.root } @@ -564,6 +547,13 @@ class SetStatusDialogFragment : } } + override fun onResume() { + super.onResume() + dialog?.window?.setLayout( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT + ) + } + /** * Fragment creator */ diff --git a/app/src/main/res/layout/dialog_set_status.xml b/app/src/main/res/layout/dialog_set_status.xml index f083b87bb8..6d7a93a34c 100644 --- a/app/src/main/res/layout/dialog_set_status.xml +++ b/app/src/main/res/layout/dialog_set_status.xml @@ -364,7 +364,7 @@ app:cardCornerRadius="24dp" app:cardElevation="0dp"> - + + From 33ff8c4276576535f77768ba341faff57507b0df Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Wed, 8 Nov 2023 22:06:26 +0530 Subject: [PATCH 02/17] Replaced EmojiPicker in MessageActionsDialog and CreateConversationDialog Signed-off-by: Smarshal21 --- .../talk/adapters/messages/Reaction.kt | 2 +- .../nextcloud/talk/call/ReactionAnimator.kt | 3 +- .../talk/ui/dialog/MessageActionsDialog.kt | 51 ++++--------------- .../talk/ui/dialog/MoreCallActionsDialog.kt | 2 +- .../talk/ui/dialog/SetStatusDialogFragment.kt | 2 - .../ui/theme/TalkSpecificViewThemeUtils.kt | 2 +- .../res/layout/dialog_create_conversation.xml | 9 ++++ .../res/layout/dialog_message_actions.xml | 23 ++++++--- .../rv_item_conversation_info_participant.xml | 2 +- 9 files changed, 41 insertions(+), 55 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt index 2e38b9bb3d..15ab418975 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt @@ -25,11 +25,11 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView +import androidx.emoji2.widget.EmojiTextView import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding import com.nextcloud.talk.models.json.chat.ChatMessage import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.DisplayUtils -import com.vanniktech.emoji.EmojiTextView class Reaction { diff --git a/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt b/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt index 746644b8c6..3db27ece3b 100644 --- a/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt +++ b/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt @@ -35,9 +35,10 @@ import android.widget.TextView import androidx.appcompat.content.res.AppCompatResources import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.DrawableCompat +import androidx.emoji2.widget.EmojiTextView import com.nextcloud.talk.R import com.nextcloud.talk.ui.theme.ViewThemeUtils -import com.vanniktech.emoji.EmojiTextView + class ReactionAnimator( val context: Context, diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index 1cd258656f..38d1ebea19 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -25,13 +25,12 @@ 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 import android.view.ViewGroup import android.view.inputmethod.InputMethodManager +import androidx.emoji2.widget.EmojiTextView import autodagger.AutoInjector import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog @@ -49,10 +48,6 @@ import com.nextcloud.talk.models.json.chat.ChatMessage import com.nextcloud.talk.repositories.reactions.ReactionsRepository import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew -import com.vanniktech.emoji.EmojiPopup -import com.vanniktech.emoji.EmojiTextView -import com.vanniktech.emoji.installDisableKeyboardInput -import com.vanniktech.emoji.installForceSingleEmoji import io.reactivex.Observer import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -78,7 +73,7 @@ class MessageActionsDialog( private lateinit var dialogMessageActionsBinding: DialogMessageActionsBinding - private lateinit var popup: EmojiPopup + // private lateinit var popup: EmojiPopup override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -146,28 +141,10 @@ class MessageActionsDialog( true } - popup = EmojiPopup( - rootView = dialogMessageActionsBinding.root, - editText = dialogMessageActionsBinding.emojiMore, - onEmojiPopupShownListener = { - dialogMessageActionsBinding.emojiMore.clearFocus() - dialogMessageActionsBinding.messageActions.visibility = View.GONE - }, - onEmojiClickListener = { - popup.dismiss() - clickOnEmoji(message, it.unicode) - }, - onEmojiPopupDismissListener = { - 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) - } - ) - dialogMessageActionsBinding.emojiMore.installDisableKeyboardInput(popup) - dialogMessageActionsBinding.emojiMore.installForceSingleEmoji() + dialogMessageActionsBinding.emojiMore.setOnClickListener { toggleEmojiPopup()} + dialogMessageActionsBinding.emojiPicker.setOnEmojiPickedListener(){ + clickOnEmoji(message, it.emoji) + } } /* @@ -176,18 +153,9 @@ class MessageActionsDialog( 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 - ) - } + val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(dialogMessageActionsBinding.emojiMore.windowToken, 0) + dialogMessageActionsBinding.emojiPicker.visibility = View.VISIBLE } private fun initEmojiBar(hasChatPermission: Boolean) { @@ -431,6 +399,7 @@ class MessageActionsDialog( } } + companion object { private val TAG = MessageActionsDialog::class.java.simpleName private const val ACTOR_LENGTH = 6 diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt index 73f4a6cbb9..dd6ab70947 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt @@ -26,6 +26,7 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import androidx.core.content.ContextCompat +import androidx.emoji2.widget.EmojiTextView import autodagger.AutoInjector import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog @@ -37,7 +38,6 @@ import com.nextcloud.talk.raisehand.viewmodel.RaiseHandViewModel import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew import com.nextcloud.talk.viewmodels.CallRecordingViewModel -import com.vanniktech.emoji.EmojiTextView import javax.inject.Inject @AutoInjector(NextcloudTalkApplication::class) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index 523e2c068c..51fa074c9b 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -63,7 +63,6 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew -import com.vanniktech.emoji.EmojiPopup import io.reactivex.Observer import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -106,7 +105,6 @@ class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener private lateinit var adapter: PredefinedStatusListAdapter private var clearAt: Long? = null - private lateinit var popup: EmojiPopup @Inject lateinit var ncApi: NcApi diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt index 5a06acef8c..99faa5efce 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt @@ -48,6 +48,7 @@ import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.ColorUtils import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.ViewCompat +import androidx.emoji2.widget.EmojiTextView import com.google.android.material.button.MaterialButton import com.google.android.material.card.MaterialCardView import com.google.android.material.materialswitch.MaterialSwitch @@ -62,7 +63,6 @@ import com.nextcloud.talk.ui.WaveformSeekBar import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.DrawableUtils import com.nextcloud.talk.utils.message.MessageUtils -import com.vanniktech.emoji.EmojiTextView import com.wooplr.spotlight.SpotlightView import eu.davidea.flexibleadapter.utils.FlexibleUtils import javax.inject.Inject diff --git a/app/src/main/res/layout/dialog_create_conversation.xml b/app/src/main/res/layout/dialog_create_conversation.xml index 7fa93ac9e3..4fce6dcee3 100644 --- a/app/src/main/res/layout/dialog_create_conversation.xml +++ b/app/src/main/res/layout/dialog_create_conversation.xml @@ -65,4 +65,13 @@ app:tint="@color/medium_emphasis_text" tools:visibility="visible" /> + + + diff --git a/app/src/main/res/layout/dialog_message_actions.xml b/app/src/main/res/layout/dialog_message_actions.xml index b34b75a741..c7a79e13b9 100644 --- a/app/src/main/res/layout/dialog_message_actions.xml +++ b/app/src/main/res/layout/dialog_message_actions.xml @@ -26,6 +26,15 @@ android:orientation="vertical" android:paddingBottom="@dimen/standard_half_padding"> + + + + - - - - - - - - Date: Wed, 8 Nov 2023 22:07:57 +0530 Subject: [PATCH 03/17] 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 ff68dfdbeb..1aefdd9f17 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 */ From ed3117bc9ff3e73c410407ff7dcc79f2f0283193 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Wed, 8 Nov 2023 22:20:32 +0530 Subject: [PATCH 04/17] Replaced EmojiPicker in RenameConversationDialogFragment Signed-off-by: Smarshal21 --- .../RenameConversationDialogFragment.kt | 45 +++++++------------ .../res/layout/dialog_rename_conversation.xml | 8 ++++ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt index 653455a64a..f18e0f5e25 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt @@ -22,7 +22,6 @@ package com.nextcloud.talk.conversation import android.annotation.SuppressLint import android.app.Dialog -import android.content.res.ColorStateList import android.os.Bundle import android.text.Editable import android.text.TextUtils @@ -32,13 +31,11 @@ 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 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.conversation.viewmodel.RenameConversationViewModel @@ -46,7 +43,6 @@ import com.nextcloud.talk.conversationlist.ConversationsListActivity import com.nextcloud.talk.databinding.DialogRenameConversationBinding import com.nextcloud.talk.events.ConversationsListFetchDataEvent import com.nextcloud.talk.ui.theme.ViewThemeUtils -import com.vanniktech.emoji.EmojiPopup import org.greenrobot.eventbus.EventBus import javax.inject.Inject @@ -64,8 +60,8 @@ class RenameConversationDialogFragment : DialogFragment() { private lateinit var binding: DialogRenameConversationBinding private lateinit var viewModel: RenameConversationViewModel + private var isEmojiPickerVisible = false - private var emojiPopup: EmojiPopup? = null private var roomToken = "" private var initialName = "" @@ -106,7 +102,6 @@ class RenameConversationDialogFragment : DialogFragment() { setupListeners() setupStateObserver() - setupEmojiPopup() } override fun onStart() { @@ -130,31 +125,20 @@ class RenameConversationDialogFragment : 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 @@ -216,7 +200,12 @@ class RenameConversationDialogFragment : DialogFragment() { Log.e(TAG, "Failed to rename conversation") 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 */ diff --git a/app/src/main/res/layout/dialog_rename_conversation.xml b/app/src/main/res/layout/dialog_rename_conversation.xml index dcbef3114a..b30642d8dd 100644 --- a/app/src/main/res/layout/dialog_rename_conversation.xml +++ b/app/src/main/res/layout/dialog_rename_conversation.xml @@ -67,4 +67,12 @@ app:tint="@color/medium_emphasis_text" tools:visibility="visible" /> + + From d6ff39a8fad948c7377358a1da2b5aafdf6886c8 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Wed, 8 Nov 2023 23:57:49 +0530 Subject: [PATCH 05/17] Replaced EmojiPicker in ChatActivity Signed-off-by: Smarshal21 --- .../com/nextcloud/talk/chat/ChatActivity.kt | 40 ++++++------------- .../main/res/layout/view_message_input.xml | 9 ++++- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 22a88a8429..5a5eda9ce9 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -94,6 +94,7 @@ import androidx.core.content.PermissionChecker.PERMISSION_GRANTED import androidx.core.graphics.drawable.toBitmap import androidx.core.text.bold import androidx.core.widget.doAfterTextChanged +import androidx.emoji2.emojipicker.EmojiPickerView import androidx.emoji2.text.EmojiCompat import androidx.emoji2.widget.EmojiTextView import androidx.fragment.app.DialogFragment @@ -237,7 +238,6 @@ import com.stfalcon.chatkit.messages.MessageHolders import com.stfalcon.chatkit.messages.MessageHolders.ContentChecker import com.stfalcon.chatkit.messages.MessagesListAdapter import com.stfalcon.chatkit.utils.DateFormatter -import com.vanniktech.emoji.EmojiPopup import io.reactivex.Observer import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -322,7 +322,6 @@ class ChatActivity : lateinit var roomId: String var voiceOnly: Boolean = true var isFirstMessagesProcessing = true - private var emojiPopup: EmojiPopup? = null private lateinit var path: String var myFirstMessage: CharSequence? = null @@ -351,6 +350,7 @@ class ChatActivity : private var voicePreviewObjectAnimator: ObjectAnimator? = null var mediaPlayer: MediaPlayer? = null lateinit var mediaPlayerHandler: Handler + private var isEmojiPickerVisible = false private var currentlyPlayedVoiceMessage: ChatMessage? = null private lateinit var micInputAudioRecorder: AudioRecord private var micInputAudioRecordThread: Thread? = null @@ -452,7 +452,6 @@ class ChatActivity : binding.progressBar.visibility = View.VISIBLE onBackPressedDispatcher.addCallback(this, onBackPressedCallback) - initObservers() } @@ -644,7 +643,6 @@ class ChatActivity : logConversationInfos("onResume") pullChatMessagesPending = false - setupWebsocket() webSocketInstance?.getSignalingMessageReceiver()?.addListener(localParticipantMessageListener) webSocketInstance?.getSignalingMessageReceiver()?.addListener(conversationMessageListener) @@ -1429,30 +1427,18 @@ class ChatActivity : private fun initSmileyKeyboardToggler() { val smileyButton = binding.messageInputView.findViewById(R.id.smileyButton) - emojiPopup = binding.messageInputView.inputEditText?.let { - EmojiPopup( - rootView = binding.root, - editText = it, - onEmojiPopupShownListener = { - if (resources != null) { - smileyButton?.setImageDrawable( - ContextCompat.getDrawable(context, R.drawable.ic_baseline_keyboard_24) - ) - } - }, - onEmojiPopupDismissListener = { - smileyButton?.setImageDrawable( - ContextCompat.getDrawable(context, R.drawable.ic_insert_emoticon_black_24dp) - ) - }, - onEmojiClickListener = { - binding.messageInputView.inputEditText?.editableText?.append(" ") - } - ) - } - smileyButton?.setOnClickListener { - emojiPopup?.toggle() + + if (!isEmojiPickerVisible) { + binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.VISIBLE + isEmojiPickerVisible = true + } else { + binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.GONE + isEmojiPickerVisible = false + } + binding.messageInputView.findViewById(R.id.emoji_picker).setOnEmojiPickedListener() { + binding.messageInputView.inputEditText.editableText?.append(it.emoji) + } } } diff --git a/app/src/main/res/layout/view_message_input.xml b/app/src/main/res/layout/view_message_input.xml index 319724c8eb..0265807e44 100644 --- a/app/src/main/res/layout/view_message_input.xml +++ b/app/src/main/res/layout/view_message_input.xml @@ -78,9 +78,16 @@ android:lineSpacingMultiplier="1.2" android:minHeight="48dp" android:textAlignment="viewStart" - android:layoutDirection="locale" tools:hint="@string/nc_hint_enter_a_message" /> + + Date: Sat, 11 Nov 2023 01:24:43 +0530 Subject: [PATCH 06/17] removed the instances of vanniktech Signed-off-by: Smarshal21 --- app/build.gradle | 1 - .../messages/IncomingTextMessageViewHolder.kt | 4 +- .../OutcomingTextMessageViewHolder.kt | 4 +- .../application/NextcloudTalkApplication.kt | 6 +-- .../MentionAutocompleteCallback.java | 8 ---- .../nextcloud/talk/utils/TextMatchers.java | 40 ------------------- 6 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java diff --git a/app/build.gradle b/app/build.gradle index fc0f4456c1..c9b873e503 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -175,7 +175,6 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.10.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation "com.vanniktech:emoji-google:0.17.0" implementation "androidx.emoji2:emoji2:${emojiVersion}" implementation "androidx.emoji2:emoji2-bundled:${emojiVersion}" implementation "androidx.emoji2:emoji2-views:${emojiVersion}" diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt index 17333d452d..061f8196a9 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt @@ -45,7 +45,6 @@ import com.nextcloud.talk.models.json.chat.ChatMessage import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.DateUtils -import com.nextcloud.talk.utils.TextMatchers import com.nextcloud.talk.utils.message.MessageUtils import com.nextcloud.talk.utils.preferences.AppPreferences import com.stfalcon.chatkit.messages.MessageHolders @@ -103,8 +102,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : val messageParameters = message.messageParameters if ( - (messageParameters == null || messageParameters.size <= 0) && - TextMatchers.isMessageWithSingleEmoticonOnly(message.text) + (messageParameters == null || messageParameters.size <= 0) ) { textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat() itemView.isSelected = true diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt index 680af44a61..f9dfa95bce 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt @@ -41,7 +41,6 @@ import com.nextcloud.talk.models.json.chat.ReadStatus import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.DateUtils -import com.nextcloud.talk.utils.TextMatchers import com.nextcloud.talk.utils.message.MessageUtils import com.stfalcon.chatkit.messages.MessageHolders.OutcomingTextMessageViewHolder import javax.inject.Inject @@ -89,8 +88,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH val messageParameters = message.messageParameters if ( - (messageParameters == null || messageParameters.size <= 0) && - TextMatchers.isMessageWithSingleEmoticonOnly(message.text) + (messageParameters == null || messageParameters.size <= 0) ) { textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat() layoutParams.isWrapBefore = true diff --git a/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt b/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt index 5697474094..fd09ffda65 100644 --- a/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt +++ b/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt @@ -70,8 +70,6 @@ import com.nextcloud.talk.utils.database.arbitrarystorage.ArbitraryStorageModule import com.nextcloud.talk.utils.database.user.UserModule import com.nextcloud.talk.utils.preferences.AppPreferences import com.nextcloud.talk.webrtc.MagicWebRTCUtils -import com.vanniktech.emoji.EmojiManager -import com.vanniktech.emoji.google.GoogleEmojiProvider import de.cotech.hw.SecurityKeyManager import de.cotech.hw.SecurityKeyManagerConfig import net.sqlcipher.database.SQLiteDatabase @@ -181,9 +179,7 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver { val config = BundledEmojiCompatConfig(this) config.setReplaceAll(true) - val emojiCompat = EmojiCompat.init(config) - - EmojiManager.install(GoogleEmojiProvider()) + EmojiCompat.init(config) NotificationUtils.registerNotificationChannels(applicationContext, appPreferences) } diff --git a/app/src/main/java/com/nextcloud/talk/callbacks/MentionAutocompleteCallback.java b/app/src/main/java/com/nextcloud/talk/callbacks/MentionAutocompleteCallback.java index fe84343934..f29cde2740 100644 --- a/app/src/main/java/com/nextcloud/talk/callbacks/MentionAutocompleteCallback.java +++ b/app/src/main/java/com/nextcloud/talk/callbacks/MentionAutocompleteCallback.java @@ -26,7 +26,6 @@ import android.text.Editable; import android.text.Spanned; import android.widget.EditText; - import third.parties.fresco.BetterImageSpan; import com.nextcloud.talk.R; import com.nextcloud.talk.data.user.model.User; @@ -36,9 +35,6 @@ import com.nextcloud.talk.utils.MagicCharPolicy; import com.nextcloud.talk.utils.text.Spans; import com.otaliastudios.autocomplete.AutocompleteCallback; -import com.vanniktech.emoji.EmojiRange; -import com.vanniktech.emoji.Emojis; - import kotlin.OptIn; public class MentionAutocompleteCallback implements AutocompleteCallback { @@ -64,12 +60,8 @@ public boolean onPopupItemClicked(Editable editable, Mention item) { if (range == null) { return false; } - String replacement = item.getLabel(); StringBuilder replacementStringBuilder = new StringBuilder(item.getLabel()); - for (EmojiRange emojiRange : Emojis.emojis(replacement)) { - replacementStringBuilder.delete(emojiRange.range.getStart(), emojiRange.range.getEndInclusive()); - } editable.replace(range.getStart(), range.getEnd(), replacementStringBuilder + " "); Spans.MentionChipSpan mentionChipSpan = diff --git a/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java b/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java deleted file mode 100644 index a881852362..0000000000 --- a/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * @author Tim Krüger - * @author Andy Scherzinger - * Copyright (C) 2022 Andy Scherzinger - * Copyright (C) 2021 Tim Krüger - * Copyright (C) 2017-2018 Mario Danic - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Partly based on https://github.com/kevalpatel2106/EmoticonGIFKeyboard/blob/master/emoticongifkeyboard/src/main/java/com/kevalpatel2106/emoticongifkeyboard/internal/emoticon/EmoticonUtils.java - */ - -package com.nextcloud.talk.utils; - -import com.vanniktech.emoji.EmojiInformation; -import com.vanniktech.emoji.Emojis; - -import androidx.annotation.Nullable; - -public final class TextMatchers { - - public static boolean isMessageWithSingleEmoticonOnly(@Nullable final String text) { - final EmojiInformation emojiInformation = Emojis.emojiInformation(text); - return (emojiInformation.isOnlyEmojis && emojiInformation.emojis.size() == 1); - } -} From c173c70bd731215a7d50ff67c7dd65d77adf5c9f Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Tue, 14 Nov 2023 14:23:57 +0530 Subject: [PATCH 07/17] Fixed Codacy errors Signed-off-by: Smarshal21 --- .../java/com/nextcloud/talk/call/ReactionAnimator.kt | 4 +--- .../com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt | 8 +++----- .../nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt | 9 +++++++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt b/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt index 3db27ece3b..336cbced21 100644 --- a/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt +++ b/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt @@ -39,7 +39,6 @@ import androidx.emoji2.widget.EmojiTextView import com.nextcloud.talk.R import com.nextcloud.talk.ui.theme.ViewThemeUtils - class ReactionAnimator( val context: Context, private val startPointView: RelativeLayout, @@ -63,7 +62,6 @@ class ReactionAnimator( callReaction: CallReaction ) { val reactionWrapper = getReactionWrapperView(callReaction) - val params = RelativeLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT @@ -100,7 +98,6 @@ class ReactionAnimator( val animatorWithFullAlpha = AnimatorSet() animatorWithFullAlpha.play(moveWithFullAlpha) - animatorWithFullAlpha.addListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { reactionsList.remove(callReaction) @@ -183,6 +180,7 @@ class ReactionAnimator( private const val BOTTOM_MARGIN: Int = 5 } } + data class CallReaction( var emoji: String, var userName: String diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index 38d1ebea19..1280283649 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -73,8 +73,6 @@ class MessageActionsDialog( private lateinit var dialogMessageActionsBinding: DialogMessageActionsBinding - // private lateinit var popup: EmojiPopup - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this) @@ -141,8 +139,8 @@ class MessageActionsDialog( true } - dialogMessageActionsBinding.emojiMore.setOnClickListener { toggleEmojiPopup()} - dialogMessageActionsBinding.emojiPicker.setOnEmojiPickedListener(){ + dialogMessageActionsBinding.emojiMore.setOnClickListener { toggleEmojiPopup() } + dialogMessageActionsBinding.emojiPicker.setOnEmojiPickedListener() { clickOnEmoji(message, it.emoji) } } @@ -300,6 +298,7 @@ class MessageActionsDialog( dialogMessageActionsBinding.menuTranslateMessage.visibility = getVisibility(visible) } + private fun initMenuShare(visible: Boolean) { if (visible) { dialogMessageActionsBinding.menuShare.setOnClickListener { @@ -399,7 +398,6 @@ class MessageActionsDialog( } } - companion object { private val TAG = MessageActionsDialog::class.java.simpleName private const val ACTOR_LENGTH = 6 diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index 51fa074c9b..734306f822 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -141,7 +141,9 @@ class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener ) predefinedStatusOverall.ocs?.data?.let { it1 -> predefinedStatusesList.addAll(it1) } - if (currentStatus?.messageIsPredefined == true && currentStatus?.messageId?.isNotEmpty() == true) { + if (currentStatus?.messageIsPredefined == true && + currentStatus?.messageId?.isNotEmpty() == true + ) { val messageId = currentStatus!!.messageId selectedPredefinedStatus = predefinedStatusesList.firstOrNull { ps -> messageId == ps.id } } @@ -454,7 +456,10 @@ class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener // The endpoint '/message/custom' expects a valid emoji as string or null val statusIcon = binding.emoji.text.toString().ifEmpty { null } - if (selectedPredefinedStatus == null || selectedPredefinedStatus!!.message != inputText || selectedPredefinedStatus!!.icon != binding.emoji.text.toString()) { + if (selectedPredefinedStatus == null || + selectedPredefinedStatus!!.message != inputText || + selectedPredefinedStatus!!.icon != binding.emoji.text.toString() + ) { ncApi.setCustomStatusMessage( credentials, ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl), statusIcon, inputText, clearAt ).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) From ac030a22a88017f804fb5a62efc40b9acc325cd5 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Tue, 14 Nov 2023 14:33:28 +0530 Subject: [PATCH 08/17] Fixed ktlintCheck Signed-off-by: Smarshal21 --- .../java/com/nextcloud/talk/chat/ChatActivity.kt | 1 - .../conversation/CreateConversationDialogFragment.kt | 3 ++- .../conversation/RenameConversationDialogFragment.kt | 9 ++++----- .../talk/ui/dialog/SetStatusDialogFragment.kt | 12 +++++++++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 5a5eda9ce9..1d59ba86c2 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -1428,7 +1428,6 @@ class ChatActivity : val smileyButton = binding.messageInputView.findViewById(R.id.smileyButton) smileyButton?.setOnClickListener { - if (!isEmojiPickerVisible) { binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.VISIBLE isEmojiPickerVisible = true 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 1aefdd9f17..6bdde2b969 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt @@ -271,7 +271,8 @@ class CreateConversationDialogFragment : DialogFragment() { override fun onResume() { super.onResume() dialog?.window?.setLayout( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT ) } diff --git a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt index f18e0f5e25..7cdfcad535 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt @@ -61,8 +61,6 @@ class RenameConversationDialogFragment : DialogFragment() { private lateinit var binding: DialogRenameConversationBinding private lateinit var viewModel: RenameConversationViewModel private var isEmojiPickerVisible = false - - private var roomToken = "" private var initialName = "" @@ -98,10 +96,8 @@ class RenameConversationDialogFragment : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - setupListeners() setupStateObserver() - } override fun onStart() { @@ -200,12 +196,15 @@ class RenameConversationDialogFragment : DialogFragment() { Log.e(TAG, "Failed to rename conversation") 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 + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT ) } + /** * Fragment creator */ diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index 734306f822..1900a49252 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -137,7 +137,8 @@ class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener override fun onNext(responseBody: ResponseBody) { val predefinedStatusOverall: PredefinedStatusOverall = LoganSquare.parse( - responseBody.string(), PredefinedStatusOverall::class.java + responseBody.string(), + PredefinedStatusOverall::class.java ) predefinedStatusOverall.ocs?.data?.let { it1 -> predefinedStatusesList.addAll(it1) } @@ -461,7 +462,11 @@ class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener selectedPredefinedStatus!!.icon != binding.emoji.text.toString() ) { ncApi.setCustomStatusMessage( - credentials, ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl), statusIcon, inputText, clearAt + credentials, + ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl), + statusIcon, + inputText, + clearAt ).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer { @@ -553,7 +558,8 @@ class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener override fun onResume() { super.onResume() dialog?.window?.setLayout( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT ) } From f79db0b6b2f54e62e37e477785273cda5f23b264 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Sat, 18 Nov 2023 18:23:21 +0530 Subject: [PATCH 09/17] Refactored isMessageWithSingleEmoticonOnly in TextMatchers to use regex for single emoji check Signed-off-by: Smarshal21 --- .../messages/IncomingTextMessageViewHolder.kt | 4 ++- .../OutcomingTextMessageViewHolder.kt | 4 ++- .../nextcloud/talk/utils/TextMatchers.java | 25 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt index 061f8196a9..17333d452d 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt @@ -45,6 +45,7 @@ import com.nextcloud.talk.models.json.chat.ChatMessage import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.DateUtils +import com.nextcloud.talk.utils.TextMatchers import com.nextcloud.talk.utils.message.MessageUtils import com.nextcloud.talk.utils.preferences.AppPreferences import com.stfalcon.chatkit.messages.MessageHolders @@ -102,7 +103,8 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : val messageParameters = message.messageParameters if ( - (messageParameters == null || messageParameters.size <= 0) + (messageParameters == null || messageParameters.size <= 0) && + TextMatchers.isMessageWithSingleEmoticonOnly(message.text) ) { textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat() itemView.isSelected = true diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt index f9dfa95bce..680af44a61 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingTextMessageViewHolder.kt @@ -41,6 +41,7 @@ import com.nextcloud.talk.models.json.chat.ReadStatus import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.DateUtils +import com.nextcloud.talk.utils.TextMatchers import com.nextcloud.talk.utils.message.MessageUtils import com.stfalcon.chatkit.messages.MessageHolders.OutcomingTextMessageViewHolder import javax.inject.Inject @@ -88,7 +89,8 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH val messageParameters = message.messageParameters if ( - (messageParameters == null || messageParameters.size <= 0) + (messageParameters == null || messageParameters.size <= 0) && + TextMatchers.isMessageWithSingleEmoticonOnly(message.text) ) { textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat() layoutParams.isWrapBefore = true diff --git a/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java b/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java new file mode 100644 index 0000000000..d04f657baa --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java @@ -0,0 +1,25 @@ +package com.nextcloud.talk.utils; + + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import androidx.annotation.Nullable; + +public final class TextMatchers { + + public static boolean isMessageWithSingleEmoticonOnly(@Nullable final String text) { + if (text == null || text.isEmpty()) { + return false; + } + String emojiRegex = "([\\p{So}\\p{Sk}])"; + Pattern pattern = Pattern.compile(emojiRegex); + Matcher matcher = pattern.matcher(text); + + int emojiCount = 0; + while (matcher.find()) { + emojiCount++; + } + return emojiCount == 1; + } +} From 348de75b2b63a00e8e4868bedd6f6ff1aeb101fc Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Sat, 18 Nov 2023 18:53:32 +0530 Subject: [PATCH 10/17] updated license header Signed-off-by: Smarshal21 --- .../nextcloud/talk/utils/TextMatchers.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java b/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java index d04f657baa..bf2e17a48d 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java +++ b/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java @@ -1,5 +1,32 @@ -package com.nextcloud.talk.utils; +/* + * Nextcloud Talk application + * + * @author Mario Danic + * @author Tim Krüger + * @author Andy Scherzinger + * @author Samanwith KSN + * Copyright (C) 2023 Samanwith KSN + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2021 Tim Krüger + * Copyright (C) 2017-2018 Mario Danic + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Partly based on https://github.com/kevalpatel2106/EmoticonGIFKeyboard/blob/master/emoticongifkeyboard/src/main/java/com/kevalpatel2106/emoticongifkeyboard/internal/emoticon/EmoticonUtils.java + */ +package com.nextcloud.talk.utils; import java.util.regex.Matcher; import java.util.regex.Pattern; From 895ad528225ee00d09c66c233fe6067f6abbb06c Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Sat, 18 Nov 2023 18:53:32 +0530 Subject: [PATCH 11/17] updated license header Signed-off-by: Smarshal21 updated license header Signed-off-by: Smarshal21 --- app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java b/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java index bf2e17a48d..0099c8ed29 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java +++ b/app/src/main/java/com/nextcloud/talk/utils/TextMatchers.java @@ -5,7 +5,7 @@ * @author Tim Krüger * @author Andy Scherzinger * @author Samanwith KSN - * Copyright (C) 2023 Samanwith KSN + * Copyright (C) 2023 Samanwith KSN * Copyright (C) 2022 Andy Scherzinger * Copyright (C) 2021 Tim Krüger * Copyright (C) 2017-2018 Mario Danic From c4f3d88cac591fc0701394dc6b8b37f361566f65 Mon Sep 17 00:00:00 2001 From: Smarshall <99678760+Smarshal21@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:43:11 +0530 Subject: [PATCH 12/17] Update dialog_create_conversation.xml Signed-off-by: Smarshall <99678760+Smarshal21@users.noreply.github.com> --- app/src/main/res/layout/dialog_create_conversation.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/dialog_create_conversation.xml b/app/src/main/res/layout/dialog_create_conversation.xml index 4fce6dcee3..62cabb9620 100644 --- a/app/src/main/res/layout/dialog_create_conversation.xml +++ b/app/src/main/res/layout/dialog_create_conversation.xml @@ -71,7 +71,7 @@ android:layout_below="@id/text_input_layout" android:visibility="gone" android:layout_height="match_parent" - app:emojiGridColumns="9" /> + app:emojiGridColumns="7" /> From 2a2870f6258993b976efed959631aab7e261d2d6 Mon Sep 17 00:00:00 2001 From: Smarshall <99678760+Smarshal21@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:44:00 +0530 Subject: [PATCH 13/17] Update dialog_create_conversation.xml Signed-off-by: Smarshall <99678760+Smarshal21@users.noreply.github.com> --- app/src/main/res/layout/dialog_create_conversation.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/dialog_create_conversation.xml b/app/src/main/res/layout/dialog_create_conversation.xml index 62cabb9620..4fce6dcee3 100644 --- a/app/src/main/res/layout/dialog_create_conversation.xml +++ b/app/src/main/res/layout/dialog_create_conversation.xml @@ -71,7 +71,7 @@ android:layout_below="@id/text_input_layout" android:visibility="gone" android:layout_height="match_parent" - app:emojiGridColumns="7" /> + app:emojiGridColumns="9" /> From 1f9ad705a9ec0c2d4fb6ad3e6a284f866963c32c Mon Sep 17 00:00:00 2001 From: Smarshall <99678760+Smarshal21@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:44:40 +0530 Subject: [PATCH 14/17] Update dialog_set_status.xml Signed-off-by: Smarshall <99678760+Smarshal21@users.noreply.github.com> --- app/src/main/res/layout/dialog_set_status.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/dialog_set_status.xml b/app/src/main/res/layout/dialog_set_status.xml index 6d7a93a34c..89d4967b72 100644 --- a/app/src/main/res/layout/dialog_set_status.xml +++ b/app/src/main/res/layout/dialog_set_status.xml @@ -467,6 +467,6 @@ android:layout_width="match_parent" android:visibility="gone" android:layout_height="match_parent" - app:emojiGridColumns="9" /> + app:emojiGridColumns="7" /> From 83402abaf100401db81ec13eed7d11c53d168962 Mon Sep 17 00:00:00 2001 From: Smarshall <99678760+Smarshal21@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:43:11 +0530 Subject: [PATCH 15/17] Update dialog_set_status.xml Signed-off-by: Smarshall <99678760+Smarshal21@users.noreply.github.com> Update dialog_create_conversation.xml Signed-off-by: Smarshall <99678760+Smarshal21@users.noreply.github.com> Update dialog_create_conversation.xml Signed-off-by: Smarshall <99678760+Smarshal21@users.noreply.github.com> --- app/src/main/res/layout/dialog_set_status.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/dialog_set_status.xml b/app/src/main/res/layout/dialog_set_status.xml index 6d7a93a34c..89d4967b72 100644 --- a/app/src/main/res/layout/dialog_set_status.xml +++ b/app/src/main/res/layout/dialog_set_status.xml @@ -467,6 +467,6 @@ android:layout_width="match_parent" android:visibility="gone" android:layout_height="match_parent" - app:emojiGridColumns="9" /> + app:emojiGridColumns="7" /> From 9eaa9bfbf5723e5660caae37679bcc7836479058 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Sat, 16 Dec 2023 18:52:19 +0530 Subject: [PATCH 16/17] Fixed Keyboard Toggler Signed-off-by: Smarshal21 --- .../com/nextcloud/talk/chat/ChatActivity.kt | 27 +++++++++++++++++-- .../CreateConversationDialogFragment.kt | 19 +++++++++++++ .../RenameConversationDialogFragment.kt | 19 +++++++++++++ .../main/res/layout/view_message_input.xml | 2 +- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 1d59ba86c2..10a69b2ff2 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -73,6 +73,7 @@ import android.view.animation.AccelerateInterpolator import android.view.animation.AlphaAnimation import android.view.animation.Animation import android.view.animation.LinearInterpolator +import android.view.inputmethod.InputMethodManager import android.widget.AbsListView import android.widget.FrameLayout import android.widget.ImageButton @@ -654,7 +655,7 @@ class ChatActivity : } initSmileyKeyboardToggler() - + initMessageInputToggler() themeMessageInputView() cancelNotificationsForCurrentConversation() @@ -1424,13 +1425,30 @@ class ChatActivity : } } + private fun initMessageInputToggler() { + val messageInput = binding.messageInputView.findViewById(R.id.messageInput) + messageInput.setOnFocusChangeListener { _, hasFocus -> + if (hasFocus) { + KeyboardToggle() + } + } + messageInput.setOnClickListener { + KeyboardToggle() + } + } + + private fun KeyboardToggle() { + binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.GONE + isEmojiPickerVisible = false + } + private fun initSmileyKeyboardToggler() { val smileyButton = binding.messageInputView.findViewById(R.id.smileyButton) - smileyButton?.setOnClickListener { if (!isEmojiPickerVisible) { binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.VISIBLE isEmojiPickerVisible = true + hideKeyboard() } else { binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.GONE isEmojiPickerVisible = false @@ -1441,6 +1459,11 @@ class ChatActivity : } } + private fun hideKeyboard() { + val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0) + } + @Suppress("MagicNumber", "LongMethod") private fun updateTypingIndicator() { fun ellipsize(text: String): String { 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 6bdde2b969..c99bb144ae 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt @@ -22,6 +22,7 @@ package com.nextcloud.talk.conversation import android.annotation.SuppressLint import android.app.Dialog +import android.content.Context import android.content.Intent import android.os.Bundle import android.os.Parcelable @@ -32,6 +33,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.inputmethod.InputMethodManager import androidx.appcompat.app.AlertDialog import androidx.fragment.app.DialogFragment import androidx.lifecycle.ViewModelProvider @@ -153,10 +155,21 @@ class CreateConversationDialogFragment : DialogFragment() { viewThemeUtils.material.colorTextInputLayout(binding.textInputLayout) } + private fun hideKeyboard() { + val imm = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(binding.textEdit.windowToken, 0) + } + + private fun KeyboardToggle() { + binding.emojiPicker.visibility = View.GONE + isEmojiPickerVisible = false + } + private fun setupEmojiPopup() { if (!isEmojiPickerVisible) { binding.emojiPicker.visibility = View.VISIBLE isEmojiPickerVisible = true + hideKeyboard() } else { binding.emojiPicker.visibility = View.GONE isEmojiPickerVisible = false @@ -168,6 +181,12 @@ class CreateConversationDialogFragment : DialogFragment() { private fun setupListeners() { binding.smileyButton.setOnClickListener { setupEmojiPopup() } + binding.textEdit.setOnFocusChangeListener { _, hasFocus -> + if (hasFocus) { + KeyboardToggle() + } + } + binding.textEdit.setOnClickListener { KeyboardToggle() } binding.textEdit.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { // unused atm diff --git a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt index 7cdfcad535..9d72276a02 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt @@ -22,6 +22,7 @@ package com.nextcloud.talk.conversation import android.annotation.SuppressLint import android.app.Dialog +import android.content.Context import android.os.Bundle import android.text.Editable import android.text.TextUtils @@ -30,6 +31,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.inputmethod.InputMethodManager import androidx.appcompat.app.AlertDialog import androidx.fragment.app.DialogFragment import androidx.lifecycle.ViewModelProvider @@ -120,10 +122,21 @@ class RenameConversationDialogFragment : DialogFragment() { viewThemeUtils.material.colorTextInputLayout(binding.textInputLayout) } + private fun hideKeyboard() { + val imm = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(binding.textEdit.windowToken, 0) + } + + private fun KeyboardToggle() { + binding.emojiPicker.visibility = View.GONE + isEmojiPickerVisible = false + } + private fun setupEmojiPopup() { if (!isEmojiPickerVisible) { binding.emojiPicker.visibility = View.VISIBLE isEmojiPickerVisible = true + hideKeyboard() } else { binding.emojiPicker.visibility = View.GONE isEmojiPickerVisible = false @@ -135,6 +148,12 @@ class RenameConversationDialogFragment : DialogFragment() { private fun setupListeners() { binding.smileyButton.setOnClickListener { setupEmojiPopup() } + binding.textEdit.setOnFocusChangeListener { _, hasFocus -> + if (hasFocus) { + KeyboardToggle() + } + } + binding.textEdit.setOnClickListener { KeyboardToggle() } binding.textEdit.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { // unused atm diff --git a/app/src/main/res/layout/view_message_input.xml b/app/src/main/res/layout/view_message_input.xml index 0265807e44..d743fcafa4 100644 --- a/app/src/main/res/layout/view_message_input.xml +++ b/app/src/main/res/layout/view_message_input.xml @@ -85,7 +85,7 @@ android:layout_width="match_parent" android:layout_below="@id/messageInput" android:visibility="gone" - android:layout_height="350dp" + android:layout_height="300dp" app:emojiGridColumns="9" /> Date: Sat, 16 Dec 2023 20:47:21 +0530 Subject: [PATCH 17/17] Fixed ktlintCheck and Codacy Static Code Analysis Errors Signed-off-by: Smarshal21 --- app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt | 8 ++++---- .../talk/conversation/CreateConversationDialogFragment.kt | 8 ++++---- .../talk/conversation/RenameConversationDialogFragment.kt | 8 ++++---- .../com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt | 2 +- .../nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index ee3ea69628..1a53434f73 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -1447,15 +1447,15 @@ class ChatActivity : val messageInput = binding.messageInputView.findViewById(R.id.messageInput) messageInput.setOnFocusChangeListener { _, hasFocus -> if (hasFocus) { - KeyboardToggle() + keyboardtoggle() } } messageInput.setOnClickListener { - KeyboardToggle() + keyboardtoggle() } } - private fun KeyboardToggle() { + private fun keyboardtoggle() { binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.GONE isEmojiPickerVisible = false } @@ -1471,7 +1471,7 @@ class ChatActivity : binding.messageInputView.findViewById(R.id.emoji_picker).visibility = View.GONE isEmojiPickerVisible = false } - binding.messageInputView.findViewById(R.id.emoji_picker).setOnEmojiPickedListener() { + binding.messageInputView.findViewById(R.id.emoji_picker).setOnEmojiPickedListener { binding.messageInputView.inputEditText.editableText?.append(it.emoji) } } 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 c99bb144ae..9c054cd6d7 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/CreateConversationDialogFragment.kt @@ -160,7 +160,7 @@ class CreateConversationDialogFragment : DialogFragment() { imm.hideSoftInputFromWindow(binding.textEdit.windowToken, 0) } - private fun KeyboardToggle() { + private fun keyboardtoggle() { binding.emojiPicker.visibility = View.GONE isEmojiPickerVisible = false } @@ -174,7 +174,7 @@ class CreateConversationDialogFragment : DialogFragment() { binding.emojiPicker.visibility = View.GONE isEmojiPickerVisible = false } - binding.emojiPicker.setOnEmojiPickedListener() { + binding.emojiPicker.setOnEmojiPickedListener { binding.textEdit.editableText?.append(it.emoji) } } @@ -183,10 +183,10 @@ class CreateConversationDialogFragment : DialogFragment() { binding.smileyButton.setOnClickListener { setupEmojiPopup() } binding.textEdit.setOnFocusChangeListener { _, hasFocus -> if (hasFocus) { - KeyboardToggle() + keyboardtoggle() } } - binding.textEdit.setOnClickListener { KeyboardToggle() } + binding.textEdit.setOnClickListener { keyboardtoggle() } binding.textEdit.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { // unused atm diff --git a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt index 9d72276a02..21d7fccc28 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/RenameConversationDialogFragment.kt @@ -127,7 +127,7 @@ class RenameConversationDialogFragment : DialogFragment() { imm.hideSoftInputFromWindow(binding.textEdit.windowToken, 0) } - private fun KeyboardToggle() { + private fun keyboardtoggle() { binding.emojiPicker.visibility = View.GONE isEmojiPickerVisible = false } @@ -141,7 +141,7 @@ class RenameConversationDialogFragment : DialogFragment() { binding.emojiPicker.visibility = View.GONE isEmojiPickerVisible = false } - binding.emojiPicker.setOnEmojiPickedListener() { + binding.emojiPicker.setOnEmojiPickedListener { binding.textEdit.editableText?.append(it.emoji) } } @@ -150,10 +150,10 @@ class RenameConversationDialogFragment : DialogFragment() { binding.smileyButton.setOnClickListener { setupEmojiPopup() } binding.textEdit.setOnFocusChangeListener { _, hasFocus -> if (hasFocus) { - KeyboardToggle() + keyboardtoggle() } } - binding.textEdit.setOnClickListener { KeyboardToggle() } + binding.textEdit.setOnClickListener { keyboardtoggle() } binding.textEdit.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { // unused atm diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index 4860ff00b2..56166ab2a5 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -138,7 +138,7 @@ class MessageActionsDialog( } dialogMessageActionsBinding.emojiMore.setOnClickListener { toggleEmojiPopup() } - dialogMessageActionsBinding.emojiPicker.setOnEmojiPickedListener() { + dialogMessageActionsBinding.emojiPicker.setOnEmojiPickedListener { clickOnEmoji(message, it.emoji) } } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index a7ae172a2a..48d505bfb8 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -189,7 +189,7 @@ class SetStatusDialogFragment : DialogFragment(), PredefinedStatusClickListener binding.clearStatus.setOnClickListener { clearStatus() } binding.setStatus.setOnClickListener { setStatusMessage() } - binding.emojiPicker.setOnEmojiPickedListener() { + binding.emojiPicker.setOnEmojiPickedListener { binding.emoji.text = (it.emoji) binding.emojiPicker.visibility = GONE isEmojiPickerVisible = false