Small behavior improvement

pull/172/head
M66B 6 years ago
parent d8384dfbba
commit 4dfbda4393

@ -848,22 +848,13 @@ public class FragmentAccount extends FragmentBase {
host = h.getHost(); host = h.getHost();
} }
if (TextUtils.isEmpty(host)) if (TextUtils.isEmpty(host) && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_host)); throw new IllegalArgumentException(context.getString(R.string.title_no_host));
if (TextUtils.isEmpty(port)) if (TextUtils.isEmpty(port))
port = (starttls ? "143" : "993"); port = (starttls ? "143" : "993");
if (TextUtils.isEmpty(user)) if (TextUtils.isEmpty(user) && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_user)); throw new IllegalArgumentException(context.getString(R.string.title_no_user));
if (synchronize && TextUtils.isEmpty(password) && !insecure) if (synchronize && TextUtils.isEmpty(password) && !insecure && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_password)); throw new IllegalArgumentException(context.getString(R.string.title_no_password));
if (TextUtils.isEmpty(interval)) if (TextUtils.isEmpty(interval))
interval = Integer.toString(EntityAccount.DEFAULT_KEEP_ALIVE_INTERVAL); interval = Integer.toString(EntityAccount.DEFAULT_KEEP_ALIVE_INTERVAL);

@ -643,58 +643,34 @@ public class FragmentIdentity extends FragmentBase {
host = h.getHost(); host = h.getHost();
} }
if (TextUtils.isEmpty(name)) if (TextUtils.isEmpty(name) && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_name)); throw new IllegalArgumentException(context.getString(R.string.title_no_name));
if (TextUtils.isEmpty(email)) if (TextUtils.isEmpty(email) && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_email)); throw new IllegalArgumentException(context.getString(R.string.title_no_email));
if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) if (!Patterns.EMAIL_ADDRESS.matcher(email).matches() && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, email)); throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, email));
if (TextUtils.isEmpty(host)) if (TextUtils.isEmpty(host) && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_host)); throw new IllegalArgumentException(context.getString(R.string.title_no_host));
if (TextUtils.isEmpty(port)) if (TextUtils.isEmpty(port))
port = (starttls ? "587" : "465"); port = (starttls ? "587" : "465");
if (TextUtils.isEmpty(user)) if (TextUtils.isEmpty(user) && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_user)); throw new IllegalArgumentException(context.getString(R.string.title_no_user));
if (synchronize && TextUtils.isEmpty(password) && !insecure) if (synchronize && TextUtils.isEmpty(password) && !insecure && !should)
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_no_password)); throw new IllegalArgumentException(context.getString(R.string.title_no_password));
if (!TextUtils.isEmpty(replyto)) { if (!TextUtils.isEmpty(replyto) && !should) {
try { try {
InternetAddress[] addresses = InternetAddress.parse(replyto); InternetAddress[] addresses = InternetAddress.parse(replyto);
if (addresses.length != 1) if (addresses.length != 1)
throw new AddressException(); throw new AddressException();
} catch (AddressException ex) { } catch (AddressException ex) {
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, replyto)); throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, replyto));
} }
} }
if (!TextUtils.isEmpty(bcc)) if (!TextUtils.isEmpty(bcc) && !should)
try { try {
InternetAddress.parse(bcc); InternetAddress.parse(bcc);
} catch (AddressException ex) { } catch (AddressException ex) {
if (should)
return true;
else
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, bcc)); throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, bcc));
} }

Loading…
Cancel
Save