Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit fde8c262 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #4181 from k9mail/hide_account_chip

Don't show account chip in message list when showing single account
parents 59237ef3 a4d2079c
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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)

        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
+3 −1
Original line number Diff line number Diff line
@@ -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
        );
    }

+2 −1
Original line number Diff line number Diff line
@@ -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
)
+23 −2
Original line number Diff line number Diff line
@@ -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)