From 50c9107d84e87a7dd66ccc7d68f9cdaf6167d19c Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Wed, 14 Feb 2024 12:44:35 +0100 Subject: [PATCH] Add other folder name view for compact mode and expand mode --- .../mail/ui/main/folder/ThreadListAdapter.kt | 33 +++++++++++-------- .../main/res/layout/cardview_thread_item.xml | 25 +++++++++++--- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapter.kt b/app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapter.kt index c0752d795f8..95bf801ff9f 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapter.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapter.kt @@ -190,19 +190,8 @@ class ThreadListAdapter @Inject constructor( private fun shouldDisplayFolderName(folderName: String) = isFolderNameVisible && folderName.isNotEmpty() private fun CardviewThreadItemBinding.displayThread(thread: Thread, position: Int) { - if (shouldDisplayFolderName(thread.folderName)) { - folderNameView.isVisible = true - folderNameView.text = context.postfixWithTag( - tag = thread.folderName, - tagColor = TagColor(R.color.folderNameBackground, R.color.folderNameTextColor), - ellipsizeConfiguration = SubjectFormatter.EllipsizeConfiguration( - maxWidth = context.resources.getDimension(R.dimen.subjectTagMaxSize).toInt(), - truncateAt = TextUtils.TruncateAt.END - ), - ) - } else { - folderNameView.isVisible = false - } + + displayFolderName(thread) refreshCachedSelectedPosition(thread.uid, position) // If item changed position, update cached position. setupThreadDensityDependentUi() @@ -246,6 +235,24 @@ class ThreadListAdapter @Inject constructor( updateSelectedUi(thread) } + private fun CardviewThreadItemBinding.displayFolderName(thread: Thread) { + val folderNameView = if (localSettings.threadDensity == COMPACT) folderNameCompactMode else folderNameExpandMode + if (shouldDisplayFolderName(thread.folderName)) { + folderNameView.isVisible = true + folderNameView.text = context.postfixWithTag( + tag = thread.folderName, + tagColor = TagColor(R.color.folderNameBackground, R.color.folderNameTextColor), + ellipsizeConfiguration = SubjectFormatter.EllipsizeConfiguration( + maxWidth = context.resources.getDimension(R.dimen.subjectTagMaxSize).toInt(), + truncateAt = TextUtils.TruncateAt.END + ), + ) + } else { + folderNameExpandMode.isVisible = false + folderNameCompactMode.isVisible = false + } + } + private fun CardviewThreadItemBinding.onThreadClickWithAbilityToOpenMultiSelection( thread: Thread, listener: MultiSelectionListener, diff --git a/app/src/main/res/layout/cardview_thread_item.xml b/app/src/main/res/layout/cardview_thread_item.xml index 0fa62461d45..5b37f903797 100644 --- a/app/src/main/res/layout/cardview_thread_item.xml +++ b/app/src/main/res/layout/cardview_thread_item.xml @@ -219,16 +219,15 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="@dimen/marginStandardVerySmall" - android:layout_marginEnd="@dimen/marginStandardSmall" android:ellipsize="end" android:lines="1" - app:layout_constraintEnd_toStartOf="@id/folderNameView" + app:layout_constraintEnd_toStartOf="@id/folderNameCompactMode" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/expeditor" tools:text="@tools:sample/lorem[10]" /> @@ -297,11 +296,27 @@ android:ellipsize="end" android:lines="1" app:layout_constrainedWidth="true" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toStartOf="@id/folderNameExpandMode" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/mailSubject" tools:text="@tools:sample/lorem/random" /> + +