From 5eb53725fb3791f3b6923ab40fd54b2c07573d03 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 8 Nov 2023 17:17:04 +0100 Subject: [PATCH] Few changes --- .../chat/fragment/ConversationFragment.kt | 40 +++++++++++-------- .../chat/fragment/ConversationInfoFragment.kt | 8 ++-- .../main/res/layout/chat_info_fragment.xml | 12 +++--- 3 files changed, 33 insertions(+), 27 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 8d4484dcd..5de4415b7 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 @@ -202,13 +202,6 @@ class ConversationFragment : GenericFragment() { binding.eventsList.setHasFixedSize(true) binding.eventsList.layoutManager = LinearLayoutManager(requireContext()) - bottomSheetAdapter = ChatMessageBottomSheetAdapter(viewLifecycleOwner) - binding.messageBottomSheet.bottomSheetList.setHasFixedSize(true) - binding.messageBottomSheet.bottomSheetList.adapter = bottomSheetAdapter - - val bottomSheetLayoutManager = LinearLayoutManager(requireContext()) - binding.messageBottomSheet.bottomSheetList.layoutManager = bottomSheetLayoutManager - viewModel.events.observe(viewLifecycleOwner) { items -> val currentCount = adapter.itemCount adapter.submitList(items) @@ -228,6 +221,13 @@ class ConversationFragment : GenericFragment() { } } + bottomSheetAdapter = ChatMessageBottomSheetAdapter(viewLifecycleOwner) + binding.messageBottomSheet.bottomSheetList.setHasFixedSize(true) + binding.messageBottomSheet.bottomSheetList.adapter = bottomSheetAdapter + + val bottomSheetLayoutManager = LinearLayoutManager(requireContext()) + binding.messageBottomSheet.bottomSheetList.layoutManager = bottomSheetLayoutManager + val emojisBottomSheetBehavior = BottomSheetBehavior.from(binding.sendArea.root) emojisBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED emojisBottomSheetBehavior.isDraggable = false // To allow scrolling through the emojis @@ -278,11 +278,14 @@ class ConversationFragment : GenericFragment() { } binding.setGoToInfoClickListener { - val action = ConversationFragmentDirections.actionConversationFragmentToConversationInfoFragment( - localSipUri, - remoteSipUri - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.conversationFragment) { + val action = + ConversationFragmentDirections.actionConversationFragmentToConversationInfoFragment( + localSipUri, + remoteSipUri + ) + findNavController().navigate(action) + } } viewModel.participantUsernameToAddEvent.observe(viewLifecycleOwner) { @@ -316,11 +319,14 @@ class ConversationFragment : GenericFragment() { viewModel.fileToDisplayEvent.observe(viewLifecycleOwner) { it.consume { file -> - Log.i("$TAG User clicked on file [$file], let's display it in file viewer") - val action = ConversationFragmentDirections.actionConversationFragmentToFileViewerFragment( - file - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.conversationFragment) { + Log.i("$TAG User clicked on file [$file], let's display it in file viewer") + val action = + ConversationFragmentDirections.actionConversationFragmentToFileViewerFragment( + file + ) + findNavController().navigate(action) + } } } diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt index 5ffffaf92..c0600e122 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt @@ -101,6 +101,9 @@ class ConversationInfoFragment : GenericFragment() { Log.i( "$TAG Found matching chat room for local SIP URI [$localSipUri] and remote SIP URI [$remoteSipUri]" ) + (view.parent as? ViewGroup)?.doOnPreDraw { + startPostponedEnterTransition() + } } else { (view.parent as? ViewGroup)?.doOnPreDraw { Log.e("$TAG Failed to find chat room, going back") @@ -109,14 +112,9 @@ class ConversationInfoFragment : GenericFragment() { } } } - viewModel.participants.observe(viewLifecycleOwner) { items -> adapter.submitList(items) Log.i("$TAG Participants list updated with [${items.size}] items") - - (view.parent as? ViewGroup)?.doOnPreDraw { - startPostponedEnterTransition() - } } viewModel.groupLeftEvent.observe(viewLifecycleOwner) { diff --git a/app/src/main/res/layout/chat_info_fragment.xml b/app/src/main/res/layout/chat_info_fragment.xml index 7cbb2c060..532c1c9e1 100644 --- a/app/src/main/res/layout/chat_info_fragment.xml +++ b/app/src/main/res/layout/chat_info_fragment.xml @@ -74,6 +74,7 @@ android:layout_width="@dimen/avatar_big_size" android:layout_height="@dimen/avatar_big_size" android:layout_marginTop="8dp" + android:src="@drawable/inset_users_three" coilBigAvatar="@{viewModel.avatarModel}" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -215,7 +216,6 @@ android:layout_height="0dp" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" - android:src="@drawable/shape_squircle_white_background" android:visibility="@{viewModel.isGroup ? View.VISIBLE : View.GONE}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -226,16 +226,18 @@ android:id="@+id/participants" android:visibility="@{viewModel.expandParticipants && viewModel.isGroup ? View.VISIBLE : View.GONE}" android:layout_width="0dp" - android:layout_height="wrap_content" + android:layout_height="0dp" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="8dp" android:layout_marginBottom="16dp" + android:nestedScrollingEnabled="true" app:layout_constraintHeight_max="300dp" + app:layout_constrainedHeight="true" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/participants_label" - app:layout_constraintBottom_toTopOf="@id/add_participants"/> + app:layout_constraintBottom_toTopOf="@id/add_participants" />