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

Unverified Commit 18e8b31f authored by Nuno Ferreira's avatar Nuno Ferreira Committed by GitHub
Browse files

Add long-press action to copy subject text to clipboard (#5296)

parent ec8efc63
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
        mCcView.setOnClickListener(this);
        mBccView.setOnClickListener(this);

        mSubjectView.setOnLongClickListener(this);
        mFromView.setOnLongClickListener(this);
        mToView.setOnLongClickListener(this);
        mCcView.setOnLongClickListener(this);
@@ -167,7 +168,10 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
    @Override
    public boolean onLongClick(View view) {
        int id = view.getId();
        if (id == R.id.from) {

        if (id == R.id.subject) {
            onAddSubjectToClipboard(mSubjectView.getText().toString());
        } else if (id == R.id.from) {
            onAddAddressesToClipboard(mMessage.getFrom());
        } else if (id == R.id.to) {
            onAddRecipientsToClipboard(Message.RecipientType.TO);
@@ -186,6 +190,12 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
        }
    }

    private void onAddSubjectToClipboard(String subject) {
        clipboardManager.setText("subject", subject);

        Toast.makeText(mContext, createMessageForSubject(), Toast.LENGTH_LONG).show();
    }

    private void onAddSenderToContacts() {
        if (mMessage != null) {
            try {
@@ -197,6 +207,10 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
        }
    }

    public String createMessageForSubject() {
        return  mContext.getResources().getString(R.string.copy_subject_to_clipboard);
    }

    public String createMessage(int addressesCount) {
        return mContext.getResources().getQuantityString(R.plurals.copy_address_to_clipboard, addressesCount);
    }
+1 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ Please submit bug reports, contribute new features and ask questions at
        <item quantity="one">Address copied to clipboard</item>
        <item quantity="other">Addresses copied to clipboard</item>
    </plurals>
    <string name="copy_subject_to_clipboard">Subject text copied to clipboard</string>

    <string name="message_view_theme_action_dark">Switch to dark theme</string>
    <string name="message_view_theme_action_light">Switch to light theme</string>