compose: leave uncompletable unparsable text as-is
This commit is contained in:
parent
ba9cd4bfb9
commit
02daf45c9a
5 changed files with 67 additions and 5 deletions
|
@ -1142,7 +1142,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||
|
||||
private void onSend() {
|
||||
|
||||
if (recipientPresenter.checkHasNoRecipients()) {
|
||||
if (recipientPresenter.checkRecipientsOkForSending()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,31 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
|
|||
}).start();
|
||||
}
|
||||
|
||||
public boolean recipientToHasUncompletedText() {
|
||||
return toView.hasUncompletedText();
|
||||
}
|
||||
|
||||
public boolean recipientCcHasUncompletedText() {
|
||||
return ccView.hasUncompletedText();
|
||||
}
|
||||
|
||||
public boolean recipientBccHasUncompletedText() {
|
||||
return bccView.hasUncompletedText();
|
||||
}
|
||||
|
||||
public void showToUncompletedError() {
|
||||
toView.setError(toView.getContext().getString(R.string.message_compose_error_incomplete_recipient));
|
||||
}
|
||||
|
||||
public void showCcUncompletedError() {
|
||||
ccView.setError(ccView.getContext().getString(R.string.message_compose_error_incomplete_recipient));
|
||||
}
|
||||
|
||||
public void showBccUncompletedError() {
|
||||
bccView.setError(bccView.getContext().getString(R.string.message_compose_error_incomplete_recipient));
|
||||
}
|
||||
|
||||
|
||||
public enum CryptoStatusType {
|
||||
DISABLED(4), SIGN_ONLY(3), OPPORTUNISTIC_NOKEY(0), OPPORTUNISTIC_UNTRUSTED(1), OPPORTUNISTIC_TRUSTED(2);
|
||||
final int childToDisplay;
|
||||
|
|
|
@ -81,7 +81,19 @@ public class RecipientPresenter {
|
|||
return result;
|
||||
}
|
||||
|
||||
public boolean checkHasNoRecipients() {
|
||||
public boolean checkRecipientsOkForSending() {
|
||||
if (recipientMvpView.recipientToHasUncompletedText()) {
|
||||
recipientMvpView.showToUncompletedError();
|
||||
return true;
|
||||
}
|
||||
if (recipientMvpView.recipientCcHasUncompletedText()) {
|
||||
recipientMvpView.showCcUncompletedError();
|
||||
return true;
|
||||
}
|
||||
if (recipientMvpView.recipientBccHasUncompletedText()) {
|
||||
recipientMvpView.showBccUncompletedError();
|
||||
return true;
|
||||
}
|
||||
if (getToAddresses().isEmpty() && getCcAddresses().isEmpty() && getBccAddresses().isEmpty()) {
|
||||
recipientMvpView.showNoRecipientsError();
|
||||
return true;
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
|
@ -63,7 +64,8 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
|
|||
// don't allow duplicates, based on equality of recipient objects, which is e-mail addresses
|
||||
allowDuplicates(false);
|
||||
|
||||
// if a token is completed, pick an entry based on best guess
|
||||
// if a token is completed, pick an entry based on best guess.
|
||||
// Note that we override performCompletion, so this doesn't actually do anything
|
||||
performBestGuess(true);
|
||||
|
||||
adapter = new RecipientAdapter(getContext());
|
||||
|
@ -116,8 +118,8 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
|
|||
|
||||
@Override
|
||||
protected Recipient defaultObject(String completionText) {
|
||||
Address[] parsedAddresses = Address.parseUnencoded(completionText);
|
||||
if (parsedAddresses.length == 0) {
|
||||
Address[] parsedAddresses = Address.parse(completionText);
|
||||
if (parsedAddresses.length == 0 || parsedAddresses[0].getAddress() == null) {
|
||||
return null;
|
||||
}
|
||||
return new Recipient(parsedAddresses[0]);
|
||||
|
@ -148,12 +150,30 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
|
|||
@Override
|
||||
public void onFocusChanged(boolean hasFocus, int direction, Rect previous) {
|
||||
super.onFocusChanged(hasFocus, direction, previous);
|
||||
|
||||
if (hasFocus) {
|
||||
((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
|
||||
.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performCompletion() {
|
||||
if (getListSelection() == ListView.INVALID_POSITION && enoughToFilter()) {
|
||||
Object bestGuess;
|
||||
if (getAdapter().getCount() > 0) {
|
||||
bestGuess = getAdapter().getItem(0);
|
||||
} else {
|
||||
bestGuess = defaultObject(currentCompletionText());
|
||||
}
|
||||
if (bestGuess != null) {
|
||||
replaceText(convertSelectionToString(bestGuess));
|
||||
}
|
||||
} else {
|
||||
super.performCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performFiltering(@NonNull CharSequence text, int start, int end, int keyCode) {
|
||||
String query = text.subSequence(start, end).toString();
|
||||
|
@ -205,6 +225,10 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
|
|||
adapter.setRecipients(null);
|
||||
}
|
||||
|
||||
public boolean hasUncompletedText() {
|
||||
return !TextUtils.isEmpty(currentCompletionText());
|
||||
}
|
||||
|
||||
public enum RecipientCryptoStatus {
|
||||
UNDEFINED, UNAVAILABLE, AVAILABLE_UNTRUSTED, AVAILABLE_TRUSTED;
|
||||
|
||||
|
|
|
@ -263,6 +263,7 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="message_compose_reply_header_fmt"><xliff:g id="sender">%s</xliff:g> wrote:</string>
|
||||
<string name="message_compose_reply_header_fmt_with_date">On <xliff:g id="sent_date">%1$s</xliff:g>, <xliff:g id="sender">%2$s</xliff:g> wrote:</string>
|
||||
<string name="message_compose_error_no_recipients">You must add at least one recipient.</string>
|
||||
<string name="message_compose_error_incomplete_recipient">Recipient field contains incomplete input!</string>
|
||||
<string name="error_contact_address_not_found">No email address could be found for this contact.</string>
|
||||
<string name="message_compose_attachments_skipped_toast">Some attachments cannot be forwarded because they have not been downloaded.</string>
|
||||
<string name="message_compose_show_quoted_text_action">Quote message</string>
|
||||
|
|
Loading…
Reference in a new issue