Few changes

This commit is contained in:
Sylvain Berfini 2023-11-08 17:17:04 +01:00
parent dab462de35
commit 5eb53725fb
3 changed files with 33 additions and 27 deletions

View file

@ -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)
}
}
}

View file

@ -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) {

View file

@ -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" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/tertiary_button_label_style"
@ -255,7 +257,7 @@
android:ellipsize="end"
android:drawableStart="@drawable/plus_circle"
android:drawablePadding="8dp"
android:visibility="@{!viewModel.expandParticipants || !viewModel.isMyselfAdmin || !viewModel.isGroup || viewModel.isReadOnly ? View.GONE : View.VISIBLE}"
android:visibility="@{!viewModel.expandParticipants || !viewModel.isMyselfAdmin || !viewModel.isGroup || viewModel.isReadOnly ? View.GONE : View.VISIBLE, default=gone}"
app:drawableTint="@color/orange_main_500"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@ -284,7 +286,7 @@
app:layout_constraintVertical_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/participants_background"
app:layout_constraintTop_toBottomOf="@id/participants_anchor"
app:layout_constraintBottom_toTopOf="@id/actions_background"/>
<ImageView