Should or should not?

This commit is contained in:
M66B 2019-12-14 16:54:34 +01:00
parent 4988bf2efe
commit eaa2196716
2 changed files with 55 additions and 22 deletions

View File

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

View File

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