Confirm sending messages

pull/147/head
M66B 6 years ago
parent 7ad2f81d7d
commit c60ce9e002

@ -275,15 +275,39 @@ public class FragmentCompose extends FragmentEx {
bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) { public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int action = item.getItemId(); final int action = item.getItemId();
switch (action) { switch (action) {
case R.id.action_delete: case R.id.action_delete:
onDelete(); onDelete();
break; break;
case R.id.action_send:
try {
String to = etTo.getText().toString();
InternetAddress ato[] = (TextUtils.isEmpty(to) ? new InternetAddress[0] : InternetAddress.parse(to));
if (ato.length == 0)
throw new IllegalArgumentException(getString(R.string.title_to_missing));
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(getString(R.string.title_ask_send,
MessageHelper.getFormattedAddresses(ato, false)))
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onAction(action);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
} catch (Throwable ex) {
onAction(action);
}
break;
default: default:
onAction(action); onAction(action);
} }
return false;
return true;
} }
}); });
@ -1584,9 +1608,9 @@ public class FragmentCompose extends FragmentEx {
new Handler().post(new Runnable() { new Handler().post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (TextUtils.isEmpty(etTo.getText())) if (TextUtils.isEmpty(etTo.getText().toString().trim()))
etTo.requestFocus(); etTo.requestFocus();
else if (TextUtils.isEmpty(etSubject.getText())) else if (TextUtils.isEmpty(etSubject.getText().toString()))
etSubject.requestFocus(); etSubject.requestFocus();
else else
etBody.requestFocus(); etBody.requestFocus();

@ -324,6 +324,7 @@
<string name="title_attachments_missing">Attachments still loading</string> <string name="title_attachments_missing">Attachments still loading</string>
<string name="title_draft_deleted">Draft discarded</string> <string name="title_draft_deleted">Draft discarded</string>
<string name="title_draft_saved">Draft saved</string> <string name="title_draft_saved">Draft saved</string>
<string name="title_ask_send">Send message to %1$s?</string>
<string name="title_queued">Sending message</string> <string name="title_queued">Sending message</string>
<string name="title_encrypt">Encrypt</string> <string name="title_encrypt">Encrypt</string>

Loading…
Cancel
Save