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

Commit a47e5bf3 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #1536 from k9mail/compose-complete-on-send

Try performing recipient completion on send
parents 9fd2cf3b b3f29749
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -258,6 +258,18 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
        return bccView.hasUncompletedText();
    }

    public boolean recipientToTryPerformCompletion() {
        return toView.tryPerformCompletion();
    }

    public boolean recipientCcTryPerformCompletion() {
        return ccView.tryPerformCompletion();
    }

    public boolean recipientBccTryPerformCompletion() {
        return bccView.tryPerformCompletion();
    }

    public void showToUncompletedError() {
        toView.setError(toView.getContext().getString(R.string.compose_error_incomplete_recipient));
    }
+7 −0
Original line number Diff line number Diff line
@@ -116,6 +116,13 @@ public class RecipientPresenter implements PermissionPingCallback {
    }

    public boolean checkRecipientsOkForSending() {
        boolean performedAnyCompletion = recipientMvpView.recipientToTryPerformCompletion() ||
                recipientMvpView.recipientCcTryPerformCompletion() ||
                recipientMvpView.recipientBccTryPerformCompletion();
        if (performedAnyCompletion) {
            return true;
        }

        if (recipientMvpView.recipientToHasUncompletedText()) {
            recipientMvpView.showToUncompletedError();
            return true;
+15 −0
Original line number Diff line number Diff line
@@ -370,6 +370,21 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
        }
    }

    public boolean tryPerformCompletion() {
        if (!hasUncompletedText()) {
            return false;
        }
        int previousNumRecipients = getTokenCount();
        performCompletion();
        int numRecipients = getTokenCount();

        return previousNumRecipients != numRecipients;
    }

    private int getTokenCount() {
        return getObjects().size();
    }

    public boolean hasUncompletedText() {
        String currentCompletionText = currentCompletionText();
        return !TextUtils.isEmpty(currentCompletionText) && !isPlaceholderText(currentCompletionText);