Merge pull request #1536 from k9mail/compose-complete-on-send
Try performing recipient completion on send
This commit is contained in:
commit
a47e5bf3d2
3 changed files with 34 additions and 0 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue