Browse Source

Check for host, port, user, password

Fixes #19
main
M66B 6 years ago
parent
commit
41504e8098
3 changed files with 28 additions and 9 deletions
  1. +11
    -4
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  2. +13
    -4
      app/src/main/java/eu/faircode/email/FragmentIdentity.java
  3. +4
    -1
      app/src/main/res/values/strings.xml

+ 11
- 4
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -49,7 +49,6 @@ import com.sun.mail.imap.IMAPStore;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.mail.Folder;
import javax.mail.MessagingException;
@ -191,11 +190,19 @@ public class FragmentAccount extends FragmentEx {
String host = args.getString("host");
String port = args.getString("port");
String user = args.getString("user");
String password = args.getString("password");
if (TextUtils.isEmpty(host))
throw new Throwable(getContext().getString(R.string.title_no_host));
if (TextUtils.isEmpty(port))
throw new Throwable(getContext().getString(R.string.title_no_port));
if (TextUtils.isEmpty(user))
throw new Throwable(getContext().getString(R.string.title_no_user));
if (TextUtils.isEmpty(password))
throw new Throwable(getContext().getString(R.string.title_no_password));
if (TextUtils.isEmpty(name))
name = host + "/" + user;
if (TextUtils.isEmpty(port))
port = "0";
DB db = DB.getInstance(getContext());
EntityAccount account = db.account().getAccount(args.getLong("id"));
@ -206,7 +213,7 @@ public class FragmentAccount extends FragmentEx {
account.host = host;
account.port = Integer.parseInt(port);
account.user = user;
account.password = Objects.requireNonNull(args.getString("password"));
account.password = password;
account.synchronize = args.getBoolean("synchronize");
account.primary = (account.synchronize && args.getBoolean("primary"));


+ 13
- 4
app/src/main/java/eu/faircode/email/FragmentIdentity.java View File

@ -215,11 +215,20 @@ public class FragmentIdentity extends FragmentEx {
String host = args.getString("host");
boolean starttls = args.getBoolean("starttls");
String port = args.getString("port");
String user = args.getString("user");
String password = args.getString("password");
if (TextUtils.isEmpty(host))
throw new Throwable(getContext().getString(R.string.title_no_host));
if (TextUtils.isEmpty(port))
throw new Throwable(getContext().getString(R.string.title_no_port));
if (TextUtils.isEmpty(user))
throw new Throwable(getContext().getString(R.string.title_no_user));
if (TextUtils.isEmpty(password))
throw new Throwable(getContext().getString(R.string.title_no_password));
if (TextUtils.isEmpty(replyto))
replyto = null;
if (TextUtils.isEmpty(port))
port = "0";
DB db = DB.getInstance(getContext());
EntityIdentity identity = db.identity().getIdentity(id);
@ -232,8 +241,8 @@ public class FragmentIdentity extends FragmentEx {
identity.host = Objects.requireNonNull(host);
identity.port = Integer.parseInt(port);
identity.starttls = starttls;
identity.user = Objects.requireNonNull(args.getString("user"));
identity.password = Objects.requireNonNull(args.getString("password"));
identity.user = user;
identity.password = password;
identity.synchronize = args.getBoolean("synchronize");
identity.primary = (identity.synchronize && args.getBoolean("primary"));


+ 4
- 1
app/src/main/res/values/strings.xml View File

@ -62,7 +62,10 @@
<string name="title_primary_identity">Primary (default identity)</string>
<string name="title_no_name">Name mandatory</string>
<string name="title_no_email">Email address mandatory</string>
<string name="title_no_idle">IDLE not supported</string>
<string name="title_no_host">Host name missing</string>
<string name="title_no_port">Port number missing</string>
<string name="title_no_user">User name missing</string>
<string name="title_no_password">Password missing</string>
<string name="title_local_drafts">Local drafts</string>
<string name="title_folder_unseen">%1$s (%2$d/%3$d)</string>


Loading…
Cancel
Save