From 2086fbad668b7a9cc149bd4f399ca82e9e6773ff Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 15 Jul 2024 13:38:46 +0200 Subject: [PATCH] Fixed chat bubble long press layout issue in full-screen mode --- .../chat/fragment/ConversationFragment.kt | 48 ++++++++++++------- .../layout/chat_bubble_long_press_menu.xml | 10 ++-- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt index 8a9ea67a8..a2c551a75 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt @@ -48,7 +48,10 @@ import androidx.activity.result.contract.ActivityResultContracts import androidx.annotation.UiThread import androidx.core.app.ActivityCompat import androidx.core.content.FileProvider +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.core.view.doOnPreDraw +import androidx.core.view.updatePadding import androidx.databinding.DataBindingUtil import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope @@ -1013,9 +1016,6 @@ class ConversationFragment : SlidingPaneChildFragment() { private fun showChatMessageLongPressMenu(chatMessageModel: MessageModel) { Compatibility.setBlurRenderEffect(binding.root) - val dialog = Dialog(requireContext(), R.style.Theme_LinphoneDialog) - dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) - val layout: ChatBubbleLongPressMenuBinding = DataBindingUtil.inflate( LayoutInflater.from(context), R.layout.chat_bubble_long_press_menu, @@ -1085,21 +1085,37 @@ class ConversationFragment : SlidingPaneChildFragment() { dismissDialog() } - dialog.setContentView(layout.root) - dialog.setOnDismissListener { - Compatibility.removeBlurRenderEffect(binding.root) + val dialog = Dialog(requireContext(), R.style.Theme_LinphoneDialog) + dialog.apply { + setOnDismissListener { + Compatibility.removeBlurRenderEffect(binding.root) + } + requestWindowFeature(Window.FEATURE_NO_TITLE) + + window?.apply { + setLayout( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.MATCH_PARENT + ) + + setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) + + val d: Drawable = ColorDrawable( + requireContext().getColor(R.color.grey_300) + ) + d.alpha = 102 + setBackgroundDrawable(d) + } + + setContentView(layout.root) + + ViewCompat.setOnApplyWindowInsetsListener(layout.root) { v, windowInsets -> + val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.updatePadding(0, 0, 0, insets.bottom) + WindowInsetsCompat.CONSUMED + } } - dialog.window - ?.setLayout( - WindowManager.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.MATCH_PARENT - ) - val d: Drawable = ColorDrawable( - requireContext().getColor(R.color.grey_300) - ) - d.alpha = 102 - dialog.window?.setBackgroundDrawable(d) dialog.show() messageLongPressDialog = dialog } diff --git a/app/src/main/res/layout/chat_bubble_long_press_menu.xml b/app/src/main/res/layout/chat_bubble_long_press_menu.xml index b2ed68098..d22ff6645 100644 --- a/app/src/main/res/layout/chat_bubble_long_press_menu.xml +++ b/app/src/main/res/layout/chat_bubble_long_press_menu.xml @@ -113,9 +113,9 @@ android:onClick="@{resendClickListener}" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginBottom="1dp" android:text="@string/menu_resend_chat_message" android:background="@drawable/menu_item_background" - android:layout_marginBottom="1dp" android:drawableStart="@drawable/paper_plane_right" android:visibility="@{model.isInError && model.isOutgoing ? View.VISIBLE : View.GONE, default=gone}" app:layout_constraintBottom_toTopOf="@id/action_reply" @@ -128,10 +128,10 @@ android:onClick="@{replyClickListener}" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginBottom="1dp" android:text="@string/menu_reply_to_chat_message" android:visibility="@{model.chatRoomIsReadOnly ? View.GONE : View.VISIBLE}" android:background="@drawable/menu_item_background" - android:layout_marginBottom="1dp" android:drawableStart="@drawable/reply" app:layout_constraintBottom_toTopOf="@id/action_copy" app:layout_constraintStart_toStartOf="parent" @@ -143,9 +143,9 @@ android:onClick="@{copyClickListener}" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginBottom="1dp" android:text="@string/menu_copy_chat_message" android:background="@drawable/menu_item_background" - android:layout_marginBottom="1dp" android:drawableStart="@drawable/copy" app:layout_constraintBottom_toTopOf="@id/action_forward" app:layout_constraintStart_toStartOf="parent" @@ -157,9 +157,9 @@ android:onClick="@{forwardClickListener}" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginBottom="1dp" android:text="@string/menu_forward_chat_message" android:background="@drawable/menu_item_background" - android:layout_marginBottom="1dp" android:drawableStart="@drawable/forward" android:visibility="@{hideForward ? View.GONE : View.VISIBLE}" app:layout_constraintBottom_toTopOf="@id/action_delete" @@ -172,9 +172,9 @@ android:onClick="@{deleteClickListener}" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginBottom="1dp" android:text="@string/menu_delete_selected_item" android:background="@drawable/menu_item_background" - android:layout_marginBottom="1dp" android:drawableStart="@drawable/trash_simple" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"