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

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

Merge pull request #6308 from thundernest/optional_account_chip

Message View Redesign - Optional account chip
parents 9d058e71 23689737
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@ open class MessageList :
    private var viewSwitcher: ViewSwitcher? = null
    private lateinit var recentChangesSnackbar: Snackbar

    private val isShowAccountChip: Boolean
        get() = messageListFragment?.isShowAccountChip ?: true

    public override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

@@ -1018,7 +1021,7 @@ open class MessageList :
        if (draftsFolderId != null && folderId == draftsFolderId) {
            MessageActions.actionEditDraft(this, messageReference)
        } else {
            val fragment = MessageViewContainerFragment.newInstance(messageReference)
            val fragment = MessageViewContainerFragment.newInstance(messageReference, isShowAccountChip)
            supportFragmentManager.commitNow {
                replace(R.id.message_view_container, fragment, FRAGMENT_TAG_MESSAGE_VIEW_CONTAINER)
            }
+4 −1
Original line number Diff line number Diff line
@@ -143,6 +143,9 @@ class MessageListFragment :
            invalidateMenu()
        }

    val isShowAccountChip: Boolean
        get() = !isSingleAccountMode

    override fun onAttach(context: Context) {
        super.onAttach(context)

@@ -475,7 +478,7 @@ class MessageListFragment :
            showContactPicture = K9.isShowContactPicture,
            showingThreadedList = showingThreadedList,
            backGroundAsReadIndicator = K9.isUseBackgroundAsUnreadIndicator,
            showAccountChip = !isSingleAccountMode
            showAccountChip = isShowAccountChip
        )

    private fun getFolderInfoHolder(folderId: Long, account: Account): FolderInfoHolder {
+7 −1
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ public class MessageTopView extends LinearLayout {
    private boolean isShowingProgress;
    private boolean showPicturesButtonClicked;

    private boolean showAccountChip;

    private MessageCryptoPresenter messageCryptoPresenter;


@@ -84,6 +86,10 @@ public class MessageTopView extends LinearLayout {
        hideHeaderView();
    }

    public void setShowAccountChip(boolean showAccountChip) {
        this.showAccountChip = showAccountChip;
    }

    private void setShowPicturesButtonListener() {
        showPicturesButton.setOnClickListener(new OnClickListener() {
            @Override
@@ -208,7 +214,7 @@ public class MessageTopView extends LinearLayout {
    }

    public void setHeaders(Message message, Account account, boolean showStar) {
        mHeaderContainer.populate(message, account, showStar);
        mHeaderContainer.populate(message, account, showStar, showAccountChip);
        mHeaderContainer.setVisibility(View.VISIBLE);
    }

+15 −5
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ class MessageViewContainerFragment : Fragment() {
            setMenuVisibility(value)
        }

    private var showAccountChip: Boolean = true

    lateinit var messageReference: MessageReference
        private set

@@ -72,7 +74,9 @@ class MessageViewContainerFragment : Fragment() {
            lastDirection = savedInstanceState.getSerializable(STATE_LAST_DIRECTION) as Direction?
        }

        adapter = MessageViewContainerAdapter(this)
        showAccountChip = arguments?.getBoolean(ARG_SHOW_ACCOUNT_CHIP) ?: showAccountChip

        adapter = MessageViewContainerAdapter(this, showAccountChip)
    }

    override fun onAttach(context: Context) {
@@ -234,7 +238,11 @@ class MessageViewContainerFragment : Fragment() {
        findMessageViewFragment().onPendingIntentResult(requestCode, resultCode, data)
    }

    private class MessageViewContainerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
    private class MessageViewContainerAdapter(
        fragment: Fragment,
        private val showAccountChip: Boolean
    ) : FragmentStateAdapter(fragment) {

        var messageList: List<MessageListItem> = emptyList()
            set(value) {
                val diffResult = DiffUtil.calculateDiff(
@@ -262,7 +270,7 @@ class MessageViewContainerFragment : Fragment() {
            check(position in messageList.indices)

            val messageReference = messageList[position].messageReference
            return MessageViewFragment.newInstance(messageReference)
            return MessageViewFragment.newInstance(messageReference, showAccountChip)
        }

        fun getMessageReference(position: Int): MessageReference {
@@ -305,13 +313,15 @@ class MessageViewContainerFragment : Fragment() {

    companion object {
        private const val ARG_REFERENCE = "reference"
        private const val ARG_SHOW_ACCOUNT_CHIP = "showAccountChip"

        private const val STATE_MESSAGE_REFERENCE = "messageReference"
        private const val STATE_LAST_DIRECTION = "lastDirection"

        fun newInstance(reference: MessageReference): MessageViewContainerFragment {
        fun newInstance(reference: MessageReference, showAccountChip: Boolean): MessageViewContainerFragment {
            return MessageViewContainerFragment().withArguments(
                ARG_REFERENCE to reference.toIdentityString()
                ARG_REFERENCE to reference.toIdentityString(),
                ARG_SHOW_ACCOUNT_CHIP to showAccountChip
            )
        }
    }
+10 −2
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ class MessageViewFragment :

    private lateinit var account: Account
    lateinit var messageReference: MessageReference
    private var showAccountChip: Boolean = true

    private var currentAttachmentViewInfo: AttachmentViewInfo? = null
    private var isDeleteMenuItemDisabled: Boolean = false
@@ -109,6 +110,9 @@ class MessageViewFragment :
        messageReference = MessageReference.parse(arguments?.getString(ARG_REFERENCE))
            ?: error("Invalid argument '$ARG_REFERENCE'")

        showAccountChip = arguments?.getBoolean(ARG_SHOW_ACCOUNT_CHIP)
            ?: error("Missing argument: '$ARG_SHOW_ACCOUNT_CHIP'")

        if (savedInstanceState != null) {
            wasMessageMarkedAsOpened = savedInstanceState.getBoolean(STATE_WAS_MESSAGE_MARKED_AS_OPENED)
        }
@@ -136,6 +140,8 @@ class MessageViewFragment :
    }

    private fun initializeMessageTopView(messageTopView: MessageTopView) {
        messageTopView.setShowAccountChip(showAccountChip)

        messageTopView.setAttachmentCallback(this)
        messageTopView.setMessageCryptoPresenter(messageCryptoPresenter)

@@ -940,6 +946,7 @@ class MessageViewFragment :
        const val PROGRESS_THRESHOLD_MILLIS = 500 * 1000

        private const val ARG_REFERENCE = "reference"
        private const val ARG_SHOW_ACCOUNT_CHIP = "showAccountChip"

        private const val STATE_WAS_MESSAGE_MARKED_AS_OPENED = "wasMessageMarkedAsOpened"

@@ -947,9 +954,10 @@ class MessageViewFragment :
        private const val ACTIVITY_CHOOSE_FOLDER_COPY = 2
        private const val REQUEST_CODE_CREATE_DOCUMENT = 3

        fun newInstance(reference: MessageReference): MessageViewFragment {
        fun newInstance(reference: MessageReference, showAccountChip: Boolean): MessageViewFragment {
            return MessageViewFragment().withArguments(
                ARG_REFERENCE to reference.toIdentityString()
                ARG_REFERENCE to reference.toIdentityString(),
                ARG_SHOW_ACCOUNT_CHIP to showAccountChip
            )
        }
    }
Loading