Merge pull request #4181 from k9mail/hide_account_chip

Don't show account chip in message list when showing single account
This commit is contained in:
cketti 2019-09-05 12:39:20 +02:00 committed by GitHub
commit fde8c26268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 7 deletions

View file

@ -137,6 +137,7 @@ class MessageListAdapter internal constructor(
val holder = MessageViewHolder(view, listItemListener)
holder.contactBadge.isVisible = appearance.showContactPicture
holder.chip.isVisible = appearance.showAccountChip
appearance.fontSizes.setViewTextSize(holder.subject, subjectViewFontSize)
@ -191,9 +192,11 @@ class MessageListAdapter internal constructor(
val uniqueId = cursor.getLong(uniqueIdColumn)
val selected = selected.contains(uniqueId)
val accountChipDrawable = holder.chip.drawable.mutate()
DrawableCompat.setTint(accountChipDrawable, account.chipColor)
holder.chip.setImageDrawable(accountChipDrawable)
if (appearance.showAccountChip) {
val accountChipDrawable = holder.chip.drawable.mutate()
DrawableCompat.setTint(accountChipDrawable, account.chipColor)
holder.chip.setImageDrawable(accountChipDrawable)
}
if (appearance.stars) {
holder.flagged.isChecked = flagged

View file

@ -604,6 +604,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
}
private MessageListAppearance getMessageListAppearance() {
boolean showAccountChip = !isSingleAccountMode();
return new MessageListAppearance(
K9.getFontSizes(),
K9.getMessageListPreviewLines(),
@ -611,7 +612,8 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
K9.isMessageListSenderAboveSubject(),
K9.isShowContactPicture(),
showingThreadedList,
K9.isUseBackgroundAsUnreadIndicator()
K9.isUseBackgroundAsUnreadIndicator(),
showAccountChip
);
}

View file

@ -9,5 +9,6 @@ data class MessageListAppearance(
val senderAboveSubject: Boolean,
val showContactPicture: Boolean,
val showingThreadedList: Boolean,
val backGroundAsReadIndicator: Boolean
val backGroundAsReadIndicator: Boolean,
val showAccountChip: Boolean
)

View file

@ -63,6 +63,24 @@ class MessageListAdapterTest : RobolectricTest() {
val listItemListener: MessageListItemActionListener = mock()
@Test
fun withShowAccountChip_shouldShowAccountChip() {
val adapter = createAdapter(showAccountChip = true)
val view = adapter.createAndBindView()
assertTrue(view.accountChipView.isVisible)
}
@Test
fun withoutShowAccountChip_shouldHideAccountChip() {
val adapter = createAdapter(showAccountChip = false)
val view = adapter.createAndBindView()
assertTrue(view.accountChipView.isGone)
}
@Test
fun withoutStars_shouldHideStarCheckBox() {
val adapter = createAdapter(stars = false)
@ -429,7 +447,8 @@ class MessageListAdapterTest : RobolectricTest() {
senderAboveSubject: Boolean = false,
showContactPicture: Boolean = true,
showingThreadedList: Boolean = true,
backGroundAsReadIndicator: Boolean = false
backGroundAsReadIndicator: Boolean = false,
showAccountChip: Boolean = false
): MessageListAdapter {
val appearance = MessageListAppearance(
fontSizes,
@ -438,7 +457,8 @@ class MessageListAdapterTest : RobolectricTest() {
senderAboveSubject,
showContactPicture,
showingThreadedList,
backGroundAsReadIndicator
backGroundAsReadIndicator,
showAccountChip
)
return MessageListAdapter(
@ -512,6 +532,7 @@ class MessageListAdapterTest : RobolectricTest() {
fun secondLine(senderOrSubject: String, preview: String)= "$senderOrSubject $preview"
val View.accountChipView: View get() = findViewById(R.id.account_color_chip)
val View.starView: CheckBox get() = findViewById(R.id.star)
val View.contactPictureView: ContactBadge get() = findViewById(R.id.contact_badge)
val View.threadCountView: TextView get() = findViewById(R.id.thread_count)