Skip to content

Commit

Permalink
Add other folder name view for compact mode and expand mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tevincent committed Feb 15, 2024
1 parent 938f091 commit 50c9107
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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<Thread>,
Expand Down
25 changes: 20 additions & 5 deletions app/src/main/res/layout/cardview_thread_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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]" />

<TextView
android:id="@+id/folderNameView"
android:id="@+id/folderNameCompactMode"
style="@style/BodySmall.Secondary"
android:layout_width="wrap_content"
android:layout_height="0dp"
Expand All @@ -254,7 +253,7 @@
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/mailSubject"
app:layout_constraintEnd_toStartOf="@id/iconCalendar"
app:layout_constraintStart_toEndOf="@id/folderNameView"
app:layout_constraintStart_toEndOf="@id/folderNameCompactMode"
app:layout_constraintTop_toTopOf="@id/mailSubject"
app:tint="@color/iconColorPrimaryText"
tools:visibility="visible" />
Expand Down Expand Up @@ -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" />

<TextView
android:id="@+id/folderNameExpandMode"
style="@style/BodySmall.Secondary"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/mailBodyPreview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintTop_toTopOf="@id/mailBodyPreview"
tools:background="@color/grey_background"
tools:gravity="center"
tools:text="Folder name"
tools:visibility="gone" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
Expand Down

0 comments on commit 50c9107

Please sign in to comment.