|
|
@ -98,6 +98,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
private EditText etPort;
|
|
|
|
private EditText etPort;
|
|
|
|
private EditText etUser;
|
|
|
|
private EditText etUser;
|
|
|
|
private TextInputLayout tilPassword;
|
|
|
|
private TextInputLayout tilPassword;
|
|
|
|
|
|
|
|
private EditText etRealm;
|
|
|
|
|
|
|
|
|
|
|
|
private EditText etName;
|
|
|
|
private EditText etName;
|
|
|
|
private Button btnColor;
|
|
|
|
private Button btnColor;
|
|
|
@ -168,6 +169,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
cbInsecure = view.findViewById(R.id.cbInsecure);
|
|
|
|
cbInsecure = view.findViewById(R.id.cbInsecure);
|
|
|
|
etUser = view.findViewById(R.id.etUser);
|
|
|
|
etUser = view.findViewById(R.id.etUser);
|
|
|
|
tilPassword = view.findViewById(R.id.tilPassword);
|
|
|
|
tilPassword = view.findViewById(R.id.tilPassword);
|
|
|
|
|
|
|
|
etRealm = view.findViewById(R.id.etRealm);
|
|
|
|
|
|
|
|
|
|
|
|
etName = view.findViewById(R.id.etName);
|
|
|
|
etName = view.findViewById(R.id.etName);
|
|
|
|
btnColor = view.findViewById(R.id.btnColor);
|
|
|
|
btnColor = view.findViewById(R.id.btnColor);
|
|
|
@ -233,6 +235,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
etUser.setText(null);
|
|
|
|
etUser.setText(null);
|
|
|
|
tilPassword.getEditText().setText(null);
|
|
|
|
tilPassword.getEditText().setText(null);
|
|
|
|
|
|
|
|
etRealm.setText(null);
|
|
|
|
|
|
|
|
|
|
|
|
etName.setText(position > 1 ? provider.name : null);
|
|
|
|
etName.setText(position > 1 ? provider.name : null);
|
|
|
|
etPrefix.setText(provider.prefix);
|
|
|
|
etPrefix.setText(provider.prefix);
|
|
|
@ -425,6 +428,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
args.putString("port", etPort.getText().toString());
|
|
|
|
args.putString("port", etPort.getText().toString());
|
|
|
|
args.putString("user", etUser.getText().toString());
|
|
|
|
args.putString("user", etUser.getText().toString());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
|
|
|
|
args.putString("realm", etRealm.getText().toString());
|
|
|
|
args.putInt("auth_type", authorized == null ? Helper.AUTH_TYPE_PASSWORD : provider.getAuthType());
|
|
|
|
args.putInt("auth_type", authorized == null ? Helper.AUTH_TYPE_PASSWORD : provider.getAuthType());
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<CheckResult>() {
|
|
|
|
new SimpleTask<CheckResult>() {
|
|
|
@ -457,6 +461,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
String port = args.getString("port");
|
|
|
|
String port = args.getString("port");
|
|
|
|
String user = args.getString("user");
|
|
|
|
String user = args.getString("user");
|
|
|
|
String password = args.getString("password");
|
|
|
|
String password = args.getString("password");
|
|
|
|
|
|
|
|
String realm = args.getString("realm");
|
|
|
|
int auth_type = args.getInt("auth_type");
|
|
|
|
int auth_type = args.getInt("auth_type");
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(host))
|
|
|
|
if (TextUtils.isEmpty(host))
|
|
|
@ -468,11 +473,14 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
if (TextUtils.isEmpty(password) && !insecure)
|
|
|
|
if (TextUtils.isEmpty(password) && !insecure)
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(realm))
|
|
|
|
|
|
|
|
realm = null;
|
|
|
|
|
|
|
|
|
|
|
|
CheckResult result = new CheckResult();
|
|
|
|
CheckResult result = new CheckResult();
|
|
|
|
result.folders = new ArrayList<>();
|
|
|
|
result.folders = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
// Check IMAP server / get folders
|
|
|
|
// Check IMAP server / get folders
|
|
|
|
Properties props = MessageHelper.getSessionProperties(auth_type, insecure);
|
|
|
|
Properties props = MessageHelper.getSessionProperties(auth_type, realm, insecure);
|
|
|
|
Session isession = Session.getInstance(props, null);
|
|
|
|
Session isession = Session.getInstance(props, null);
|
|
|
|
isession.setDebug(true);
|
|
|
|
isession.setDebug(true);
|
|
|
|
IMAPStore istore = null;
|
|
|
|
IMAPStore istore = null;
|
|
|
@ -651,6 +659,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
args.putString("port", etPort.getText().toString());
|
|
|
|
args.putString("port", etPort.getText().toString());
|
|
|
|
args.putString("user", etUser.getText().toString());
|
|
|
|
args.putString("user", etUser.getText().toString());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
|
|
|
|
args.putString("realm", etRealm.getText().toString());
|
|
|
|
|
|
|
|
|
|
|
|
args.putString("name", etName.getText().toString());
|
|
|
|
args.putString("name", etName.getText().toString());
|
|
|
|
args.putInt("color", color);
|
|
|
|
args.putInt("color", color);
|
|
|
@ -699,6 +708,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
String port = args.getString("port");
|
|
|
|
String port = args.getString("port");
|
|
|
|
String user = args.getString("user");
|
|
|
|
String user = args.getString("user");
|
|
|
|
String password = args.getString("password");
|
|
|
|
String password = args.getString("password");
|
|
|
|
|
|
|
|
String realm = args.getString("realm");
|
|
|
|
|
|
|
|
|
|
|
|
String name = args.getString("name");
|
|
|
|
String name = args.getString("name");
|
|
|
|
Integer color = args.getInt("color");
|
|
|
|
Integer color = args.getInt("color");
|
|
|
@ -729,6 +739,9 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
if (synchronize && drafts == null)
|
|
|
|
if (synchronize && drafts == null)
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_drafts));
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_drafts));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(realm))
|
|
|
|
|
|
|
|
realm = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (Color.TRANSPARENT == color)
|
|
|
|
if (Color.TRANSPARENT == color)
|
|
|
|
color = null;
|
|
|
|
color = null;
|
|
|
|
if (TextUtils.isEmpty(prefix))
|
|
|
|
if (TextUtils.isEmpty(prefix))
|
|
|
@ -742,7 +755,8 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
boolean check = (synchronize && (account == null ||
|
|
|
|
boolean check = (synchronize && (account == null ||
|
|
|
|
!host.equals(account.host) || Integer.parseInt(port) != account.port ||
|
|
|
|
!host.equals(account.host) || Integer.parseInt(port) != account.port ||
|
|
|
|
!user.equals(account.user) || !password.equals(account.password)));
|
|
|
|
!user.equals(account.user) || !password.equals(account.password) ||
|
|
|
|
|
|
|
|
realm == null ? account.realm != null : !realm.equals(account.realm)));
|
|
|
|
boolean reload = (check || account == null ||
|
|
|
|
boolean reload = (check || account == null ||
|
|
|
|
(account.prefix == null ? prefix != null : !account.prefix.equals(prefix)) ||
|
|
|
|
(account.prefix == null ? prefix != null : !account.prefix.equals(prefix)) ||
|
|
|
|
account.synchronize != synchronize ||
|
|
|
|
account.synchronize != synchronize ||
|
|
|
@ -750,7 +764,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
// Check IMAP server
|
|
|
|
// Check IMAP server
|
|
|
|
if (check) {
|
|
|
|
if (check) {
|
|
|
|
Properties props = MessageHelper.getSessionProperties(auth_type, insecure);
|
|
|
|
Properties props = MessageHelper.getSessionProperties(auth_type, realm, insecure);
|
|
|
|
Session isession = Session.getInstance(props, null);
|
|
|
|
Session isession = Session.getInstance(props, null);
|
|
|
|
isession.setDebug(true);
|
|
|
|
isession.setDebug(true);
|
|
|
|
|
|
|
|
|
|
|
@ -790,6 +804,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
account.port = Integer.parseInt(port);
|
|
|
|
account.port = Integer.parseInt(port);
|
|
|
|
account.user = user;
|
|
|
|
account.user = user;
|
|
|
|
account.password = password;
|
|
|
|
account.password = password;
|
|
|
|
|
|
|
|
account.realm = realm;
|
|
|
|
|
|
|
|
|
|
|
|
account.name = name;
|
|
|
|
account.name = name;
|
|
|
|
account.color = color;
|
|
|
|
account.color = color;
|
|
|
@ -1025,6 +1040,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
authorized = (account != null && account.auth_type != Helper.AUTH_TYPE_PASSWORD ? account.password : null);
|
|
|
|
authorized = (account != null && account.auth_type != Helper.AUTH_TYPE_PASSWORD ? account.password : null);
|
|
|
|
etUser.setText(account == null ? null : account.user);
|
|
|
|
etUser.setText(account == null ? null : account.user);
|
|
|
|
tilPassword.getEditText().setText(account == null ? null : account.password);
|
|
|
|
tilPassword.getEditText().setText(account == null ? null : account.password);
|
|
|
|
|
|
|
|
etRealm.setText(account == null ? null : account.realm);
|
|
|
|
|
|
|
|
|
|
|
|
etName.setText(account == null ? null : account.name);
|
|
|
|
etName.setText(account == null ? null : account.name);
|
|
|
|
etPrefix.setText(account == null ? null : account.prefix);
|
|
|
|
etPrefix.setText(account == null ? null : account.prefix);
|
|
|
@ -1192,6 +1208,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
etUser.setEnabled(false);
|
|
|
|
etUser.setEnabled(false);
|
|
|
|
tilPassword.setEnabled(false);
|
|
|
|
tilPassword.setEnabled(false);
|
|
|
|
|
|
|
|
etRealm.setEnabled(false);
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
btnSave.setEnabled(false);
|
|
|
|
btnSave.setEnabled(false);
|
|
|
|
final Snackbar snackbar = Snackbar.make(view, R.string.title_authorizing, Snackbar.LENGTH_SHORT);
|
|
|
|
final Snackbar snackbar = Snackbar.make(view, R.string.title_authorizing, Snackbar.LENGTH_SHORT);
|
|
|
@ -1213,6 +1230,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
authorized = token;
|
|
|
|
authorized = token;
|
|
|
|
etUser.setText(account.name);
|
|
|
|
etUser.setText(account.name);
|
|
|
|
tilPassword.getEditText().setText(token);
|
|
|
|
tilPassword.getEditText().setText(token);
|
|
|
|
|
|
|
|
etRealm.setText(null);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
|
if (ex instanceof OperationCanceledException ||
|
|
|
|
if (ex instanceof OperationCanceledException ||
|
|
|
@ -1225,6 +1243,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
etUser.setEnabled(true);
|
|
|
|
etUser.setEnabled(true);
|
|
|
|
tilPassword.setEnabled(true);
|
|
|
|
tilPassword.setEnabled(true);
|
|
|
|
|
|
|
|
etRealm.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
btnSave.setEnabled(true);
|
|
|
|
btnSave.setEnabled(true);
|
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
|