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:
commit
fde8c26268
4 changed files with 34 additions and 7 deletions
|
@ -137,6 +137,7 @@ class MessageListAdapter internal constructor(
|
||||||
val holder = MessageViewHolder(view, listItemListener)
|
val holder = MessageViewHolder(view, listItemListener)
|
||||||
|
|
||||||
holder.contactBadge.isVisible = appearance.showContactPicture
|
holder.contactBadge.isVisible = appearance.showContactPicture
|
||||||
|
holder.chip.isVisible = appearance.showAccountChip
|
||||||
|
|
||||||
appearance.fontSizes.setViewTextSize(holder.subject, subjectViewFontSize)
|
appearance.fontSizes.setViewTextSize(holder.subject, subjectViewFontSize)
|
||||||
|
|
||||||
|
@ -191,9 +192,11 @@ class MessageListAdapter internal constructor(
|
||||||
val uniqueId = cursor.getLong(uniqueIdColumn)
|
val uniqueId = cursor.getLong(uniqueIdColumn)
|
||||||
val selected = selected.contains(uniqueId)
|
val selected = selected.contains(uniqueId)
|
||||||
|
|
||||||
val accountChipDrawable = holder.chip.drawable.mutate()
|
if (appearance.showAccountChip) {
|
||||||
DrawableCompat.setTint(accountChipDrawable, account.chipColor)
|
val accountChipDrawable = holder.chip.drawable.mutate()
|
||||||
holder.chip.setImageDrawable(accountChipDrawable)
|
DrawableCompat.setTint(accountChipDrawable, account.chipColor)
|
||||||
|
holder.chip.setImageDrawable(accountChipDrawable)
|
||||||
|
}
|
||||||
|
|
||||||
if (appearance.stars) {
|
if (appearance.stars) {
|
||||||
holder.flagged.isChecked = flagged
|
holder.flagged.isChecked = flagged
|
||||||
|
|
|
@ -604,6 +604,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessageListAppearance getMessageListAppearance() {
|
private MessageListAppearance getMessageListAppearance() {
|
||||||
|
boolean showAccountChip = !isSingleAccountMode();
|
||||||
return new MessageListAppearance(
|
return new MessageListAppearance(
|
||||||
K9.getFontSizes(),
|
K9.getFontSizes(),
|
||||||
K9.getMessageListPreviewLines(),
|
K9.getMessageListPreviewLines(),
|
||||||
|
@ -611,7 +612,8 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
||||||
K9.isMessageListSenderAboveSubject(),
|
K9.isMessageListSenderAboveSubject(),
|
||||||
K9.isShowContactPicture(),
|
K9.isShowContactPicture(),
|
||||||
showingThreadedList,
|
showingThreadedList,
|
||||||
K9.isUseBackgroundAsUnreadIndicator()
|
K9.isUseBackgroundAsUnreadIndicator(),
|
||||||
|
showAccountChip
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,6 @@ data class MessageListAppearance(
|
||||||
val senderAboveSubject: Boolean,
|
val senderAboveSubject: Boolean,
|
||||||
val showContactPicture: Boolean,
|
val showContactPicture: Boolean,
|
||||||
val showingThreadedList: Boolean,
|
val showingThreadedList: Boolean,
|
||||||
val backGroundAsReadIndicator: Boolean
|
val backGroundAsReadIndicator: Boolean,
|
||||||
|
val showAccountChip: Boolean
|
||||||
)
|
)
|
||||||
|
|
|
@ -63,6 +63,24 @@ class MessageListAdapterTest : RobolectricTest() {
|
||||||
val listItemListener: MessageListItemActionListener = mock()
|
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
|
@Test
|
||||||
fun withoutStars_shouldHideStarCheckBox() {
|
fun withoutStars_shouldHideStarCheckBox() {
|
||||||
val adapter = createAdapter(stars = false)
|
val adapter = createAdapter(stars = false)
|
||||||
|
@ -429,7 +447,8 @@ class MessageListAdapterTest : RobolectricTest() {
|
||||||
senderAboveSubject: Boolean = false,
|
senderAboveSubject: Boolean = false,
|
||||||
showContactPicture: Boolean = true,
|
showContactPicture: Boolean = true,
|
||||||
showingThreadedList: Boolean = true,
|
showingThreadedList: Boolean = true,
|
||||||
backGroundAsReadIndicator: Boolean = false
|
backGroundAsReadIndicator: Boolean = false,
|
||||||
|
showAccountChip: Boolean = false
|
||||||
): MessageListAdapter {
|
): MessageListAdapter {
|
||||||
val appearance = MessageListAppearance(
|
val appearance = MessageListAppearance(
|
||||||
fontSizes,
|
fontSizes,
|
||||||
|
@ -438,7 +457,8 @@ class MessageListAdapterTest : RobolectricTest() {
|
||||||
senderAboveSubject,
|
senderAboveSubject,
|
||||||
showContactPicture,
|
showContactPicture,
|
||||||
showingThreadedList,
|
showingThreadedList,
|
||||||
backGroundAsReadIndicator
|
backGroundAsReadIndicator,
|
||||||
|
showAccountChip
|
||||||
)
|
)
|
||||||
|
|
||||||
return MessageListAdapter(
|
return MessageListAdapter(
|
||||||
|
@ -512,6 +532,7 @@ class MessageListAdapterTest : RobolectricTest() {
|
||||||
|
|
||||||
fun secondLine(senderOrSubject: String, preview: String)= "$senderOrSubject $preview"
|
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.starView: CheckBox get() = findViewById(R.id.star)
|
||||||
val View.contactPictureView: ContactBadge get() = findViewById(R.id.contact_badge)
|
val View.contactPictureView: ContactBadge get() = findViewById(R.id.contact_badge)
|
||||||
val View.threadCountView: TextView get() = findViewById(R.id.thread_count)
|
val View.threadCountView: TextView get() = findViewById(R.id.thread_count)
|
||||||
|
|
Loading…
Reference in a new issue