Skip to content

Commit 9171db0

Browse files
committed
Add other folder name view for compact mode and expand mode
1 parent 56ee451 commit 9171db0

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapter.kt

+20-13
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,8 @@ class ThreadListAdapter @Inject constructor(
190190
private fun shouldDisplayFolderName(folderName: String) = isFolderNameVisible && folderName.isNotEmpty()
191191

192192
private fun CardviewThreadItemBinding.displayThread(thread: Thread, position: Int) {
193-
if (shouldDisplayFolderName(thread.folderName)) {
194-
folderNameView.isVisible = true
195-
folderNameView.text = context.postfixWithTag(
196-
tag = thread.folderName,
197-
tagColor = TagColor(R.color.folderNameBackground, R.color.folderNameTextColor),
198-
ellipsizeConfiguration = SubjectFormatter.EllipsizeConfiguration(
199-
maxWidth = context.resources.getDimension(R.dimen.subjectTagMaxSize).toInt(),
200-
truncateAt = TextUtils.TruncateAt.END
201-
),
202-
)
203-
} else {
204-
folderNameView.isVisible = false
205-
}
193+
194+
displayFolderName(thread)
206195

207196
refreshCachedSelectedPosition(thread.uid, position) // If item changed position, update cached position.
208197
setupThreadDensityDependentUi()
@@ -246,6 +235,24 @@ class ThreadListAdapter @Inject constructor(
246235
updateSelectedUi(thread)
247236
}
248237

238+
private fun CardviewThreadItemBinding.displayFolderName(thread: Thread) {
239+
val folderNameView = if (localSettings.threadDensity == COMPACT) folderNameCompactMode else folderNameExpandMode
240+
if (shouldDisplayFolderName(thread.folderName)) {
241+
folderNameView.isVisible = true
242+
folderNameView.text = context.postfixWithTag(
243+
tag = thread.folderName,
244+
tagColor = TagColor(R.color.folderNameBackground, R.color.folderNameTextColor),
245+
ellipsizeConfiguration = SubjectFormatter.EllipsizeConfiguration(
246+
maxWidth = context.resources.getDimension(R.dimen.subjectTagMaxSize).toInt(),
247+
truncateAt = TextUtils.TruncateAt.END
248+
),
249+
)
250+
} else {
251+
folderNameExpandMode.isVisible = false
252+
folderNameCompactMode.isVisible = false
253+
}
254+
}
255+
249256
private fun CardviewThreadItemBinding.onThreadClickWithAbilityToOpenMultiSelection(
250257
thread: Thread,
251258
listener: MultiSelectionListener<Thread>,

app/src/main/res/layout/cardview_thread_item.xml

+20-5
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,15 @@
219219
android:layout_width="0dp"
220220
android:layout_height="wrap_content"
221221
android:layout_marginTop="@dimen/marginStandardVerySmall"
222-
android:layout_marginEnd="@dimen/marginStandardSmall"
223222
android:ellipsize="end"
224223
android:lines="1"
225-
app:layout_constraintEnd_toStartOf="@id/folderNameView"
224+
app:layout_constraintEnd_toStartOf="@id/folderNameCompactMode"
226225
app:layout_constraintStart_toStartOf="parent"
227226
app:layout_constraintTop_toBottomOf="@id/expeditor"
228227
tools:text="@tools:sample/lorem[10]" />
229228

230229
<TextView
231-
android:id="@+id/folderNameView"
230+
android:id="@+id/folderNameCompactMode"
232231
style="@style/BodySmall.Secondary"
233232
android:layout_width="wrap_content"
234233
android:layout_height="0dp"
@@ -254,7 +253,7 @@
254253
android:visibility="gone"
255254
app:layout_constraintBottom_toBottomOf="@id/mailSubject"
256255
app:layout_constraintEnd_toStartOf="@id/iconCalendar"
257-
app:layout_constraintStart_toEndOf="@id/folderNameView"
256+
app:layout_constraintStart_toEndOf="@id/folderNameCompactMode"
258257
app:layout_constraintTop_toTopOf="@id/mailSubject"
259258
app:tint="@color/iconColorPrimaryText"
260259
tools:visibility="visible" />
@@ -297,11 +296,27 @@
297296
android:ellipsize="end"
298297
android:lines="1"
299298
app:layout_constrainedWidth="true"
300-
app:layout_constraintEnd_toEndOf="parent"
299+
app:layout_constraintEnd_toStartOf="@id/folderNameExpandMode"
301300
app:layout_constraintStart_toStartOf="parent"
302301
app:layout_constraintTop_toBottomOf="@id/mailSubject"
303302
tools:text="@tools:sample/lorem/random" />
304303

304+
<TextView
305+
android:id="@+id/folderNameExpandMode"
306+
style="@style/BodySmall.Secondary"
307+
android:layout_width="wrap_content"
308+
android:layout_height="0dp"
309+
android:visibility="gone"
310+
app:layout_constraintBottom_toBottomOf="@id/mailBodyPreview"
311+
app:layout_constraintEnd_toEndOf="parent"
312+
app:layout_constraintHorizontal_bias="1"
313+
app:layout_constraintHorizontal_chainStyle="packed"
314+
app:layout_constraintTop_toTopOf="@id/mailBodyPreview"
315+
tools:background="@color/grey_background"
316+
tools:gravity="center"
317+
tools:text="Folder name"
318+
tools:visibility="gone" />
319+
305320
</androidx.constraintlayout.widget.ConstraintLayout>
306321
</androidx.constraintlayout.widget.ConstraintLayout>
307322
</com.google.android.material.card.MaterialCardView>

0 commit comments

Comments
 (0)