|
|
@ -91,7 +91,8 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
private EditText etUser;
|
|
|
|
private EditText etUser;
|
|
|
|
private TextInputLayout tilPassword;
|
|
|
|
private TextInputLayout tilPassword;
|
|
|
|
private TextView tvCharacters;
|
|
|
|
private TextView tvCharacters;
|
|
|
|
private CheckBox cbCertificate;
|
|
|
|
private Button btnCertificate;
|
|
|
|
|
|
|
|
private TextView tvCertificate;
|
|
|
|
private Button btnOAuth;
|
|
|
|
private Button btnOAuth;
|
|
|
|
private TextView tvOAuthSupport;
|
|
|
|
private TextView tvOAuthSupport;
|
|
|
|
private EditText etRealm;
|
|
|
|
private EditText etRealm;
|
|
|
@ -152,6 +153,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
private long copy = -1;
|
|
|
|
private long copy = -1;
|
|
|
|
private int auth = EmailService.AUTH_TYPE_PASSWORD;
|
|
|
|
private int auth = EmailService.AUTH_TYPE_PASSWORD;
|
|
|
|
private String provider = null;
|
|
|
|
private String provider = null;
|
|
|
|
|
|
|
|
private String certificate = null;
|
|
|
|
private boolean saving = false;
|
|
|
|
private boolean saving = false;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
@ -200,7 +202,8 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
etUser = view.findViewById(R.id.etUser);
|
|
|
|
etUser = view.findViewById(R.id.etUser);
|
|
|
|
tilPassword = view.findViewById(R.id.tilPassword);
|
|
|
|
tilPassword = view.findViewById(R.id.tilPassword);
|
|
|
|
tvCharacters = view.findViewById(R.id.tvCharacters);
|
|
|
|
tvCharacters = view.findViewById(R.id.tvCharacters);
|
|
|
|
cbCertificate = view.findViewById(R.id.cbCertificate);
|
|
|
|
btnCertificate = view.findViewById(R.id.btnCertificate);
|
|
|
|
|
|
|
|
tvCertificate = view.findViewById(R.id.tvCertificate);
|
|
|
|
btnOAuth = view.findViewById(R.id.btnOAuth);
|
|
|
|
btnOAuth = view.findViewById(R.id.btnOAuth);
|
|
|
|
tvOAuthSupport = view.findViewById(R.id.tvOAuthSupport);
|
|
|
|
tvOAuthSupport = view.findViewById(R.id.tvOAuthSupport);
|
|
|
|
etRealm = view.findViewById(R.id.etRealm);
|
|
|
|
etRealm = view.findViewById(R.id.etRealm);
|
|
|
@ -284,7 +287,8 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
etUser.setTag(null);
|
|
|
|
etUser.setTag(null);
|
|
|
|
etUser.setText(null);
|
|
|
|
etUser.setText(null);
|
|
|
|
tilPassword.getEditText().setText(null);
|
|
|
|
tilPassword.getEditText().setText(null);
|
|
|
|
cbCertificate.setChecked(false);
|
|
|
|
certificate = null;
|
|
|
|
|
|
|
|
tvCertificate.setText(R.string.title_optional);
|
|
|
|
btnOAuth.setEnabled(false);
|
|
|
|
btnOAuth.setEnabled(false);
|
|
|
|
etRealm.setText(null);
|
|
|
|
etRealm.setText(null);
|
|
|
|
cbTrust.setChecked(false);
|
|
|
|
cbTrust.setChecked(false);
|
|
|
@ -339,6 +343,25 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnCertificate.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
Helper.selectKeyAlias(getActivity(), getViewLifecycleOwner(), null, new Helper.IKeyAlias() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSelected(String alias) {
|
|
|
|
|
|
|
|
certificate = alias;
|
|
|
|
|
|
|
|
tvCertificate.setText(alias);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onNothingSelected() {
|
|
|
|
|
|
|
|
certificate = null;
|
|
|
|
|
|
|
|
tvCertificate.setText(getString(R.string.title_optional));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
btnOAuth.setOnClickListener(new View.OnClickListener() {
|
|
|
|
btnOAuth.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
@ -552,7 +575,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
args.putString("provider", provider);
|
|
|
|
args.putString("provider", provider);
|
|
|
|
args.putString("user", etUser.getText().toString().trim());
|
|
|
|
args.putString("user", etUser.getText().toString().trim());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
args.putBoolean("certificate", cbCertificate.isChecked());
|
|
|
|
args.putString("certificate", certificate);
|
|
|
|
args.putString("realm", etRealm.getText().toString());
|
|
|
|
args.putString("realm", etRealm.getText().toString());
|
|
|
|
args.putString("fingerprint", cbTrust.isChecked() ? (String) cbTrust.getTag() : null);
|
|
|
|
args.putString("fingerprint", cbTrust.isChecked() ? (String) cbTrust.getTag() : null);
|
|
|
|
|
|
|
|
|
|
|
@ -591,7 +614,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
String provider = args.getString("provider");
|
|
|
|
String provider = args.getString("provider");
|
|
|
|
String user = args.getString("user");
|
|
|
|
String user = args.getString("user");
|
|
|
|
String password = args.getString("password");
|
|
|
|
String password = args.getString("password");
|
|
|
|
boolean certificate = args.getBoolean("certificate'");
|
|
|
|
String certificate = args.getString("certificate");
|
|
|
|
String realm = args.getString("realm");
|
|
|
|
String realm = args.getString("realm");
|
|
|
|
String fingerprint = args.getString("fingerprint");
|
|
|
|
String fingerprint = args.getString("fingerprint");
|
|
|
|
|
|
|
|
|
|
|
@ -606,7 +629,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
port = (starttls ? "143" : "993");
|
|
|
|
port = (starttls ? "143" : "993");
|
|
|
|
if (TextUtils.isEmpty(user))
|
|
|
|
if (TextUtils.isEmpty(user))
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_user));
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_user));
|
|
|
|
if (TextUtils.isEmpty(password) && !insecure && !certificate)
|
|
|
|
if (TextUtils.isEmpty(password) && !insecure && certificate == null)
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(realm))
|
|
|
|
if (TextUtils.isEmpty(realm))
|
|
|
@ -769,7 +792,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
args.putString("provider", provider);
|
|
|
|
args.putString("provider", provider);
|
|
|
|
args.putString("user", etUser.getText().toString().trim());
|
|
|
|
args.putString("user", etUser.getText().toString().trim());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
args.putString("password", tilPassword.getEditText().getText().toString());
|
|
|
|
args.putBoolean("certificate", cbCertificate.isChecked());
|
|
|
|
args.putString("certificate", certificate);
|
|
|
|
args.putString("realm", etRealm.getText().toString());
|
|
|
|
args.putString("realm", etRealm.getText().toString());
|
|
|
|
args.putString("fingerprint", cbTrust.isChecked() ? (String) cbTrust.getTag() : null);
|
|
|
|
args.putString("fingerprint", cbTrust.isChecked() ? (String) cbTrust.getTag() : null);
|
|
|
|
|
|
|
|
|
|
|
@ -831,7 +854,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
String provider = args.getString("provider");
|
|
|
|
String provider = args.getString("provider");
|
|
|
|
String user = args.getString("user").trim();
|
|
|
|
String user = args.getString("user").trim();
|
|
|
|
String password = args.getString("password");
|
|
|
|
String password = args.getString("password");
|
|
|
|
boolean certificate = args.getBoolean("certificate");
|
|
|
|
String certificate = args.getString("certificate");
|
|
|
|
String realm = args.getString("realm");
|
|
|
|
String realm = args.getString("realm");
|
|
|
|
String fingerprint = args.getString("fingerprint");
|
|
|
|
String fingerprint = args.getString("fingerprint");
|
|
|
|
|
|
|
|
|
|
|
@ -872,7 +895,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
port = (starttls ? "143" : "993");
|
|
|
|
port = (starttls ? "143" : "993");
|
|
|
|
if (TextUtils.isEmpty(user) && !should)
|
|
|
|
if (TextUtils.isEmpty(user) && !should)
|
|
|
|
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 && !certificate && !should)
|
|
|
|
if (synchronize && TextUtils.isEmpty(password) && !insecure && certificate == null && !should)
|
|
|
|
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);
|
|
|
@ -909,7 +932,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
if (!Objects.equals(account.password, password))
|
|
|
|
if (!Objects.equals(account.password, password))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
if (!Objects.equals(account.certificate, certificate))
|
|
|
|
if (!Objects.equals(account.certificate_alias, certificate))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
if (!Objects.equals(account.realm, realm))
|
|
|
|
if (!Objects.equals(account.realm, realm))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -982,7 +1005,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
!account.port.equals(Integer.parseInt(port)) ||
|
|
|
|
!account.port.equals(Integer.parseInt(port)) ||
|
|
|
|
!account.user.equals(user) ||
|
|
|
|
!account.user.equals(user) ||
|
|
|
|
!account.password.equals(password) ||
|
|
|
|
!account.password.equals(password) ||
|
|
|
|
!account.certificate.equals(certificate) ||
|
|
|
|
!Objects.equals(account.certificate_alias, certificate) ||
|
|
|
|
!Objects.equals(realm, accountRealm) ||
|
|
|
|
!Objects.equals(realm, accountRealm) ||
|
|
|
|
!Objects.equals(account.fingerprint, fingerprint)));
|
|
|
|
!Objects.equals(account.fingerprint, fingerprint)));
|
|
|
|
Log.i("Account check=" + check);
|
|
|
|
Log.i("Account check=" + check);
|
|
|
@ -1045,7 +1068,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
account.auth_type = auth;
|
|
|
|
account.auth_type = auth;
|
|
|
|
account.user = user;
|
|
|
|
account.user = user;
|
|
|
|
account.password = password;
|
|
|
|
account.password = password;
|
|
|
|
account.certificate = certificate;
|
|
|
|
account.certificate_alias = certificate;
|
|
|
|
account.provider = provider;
|
|
|
|
account.provider = provider;
|
|
|
|
account.realm = realm;
|
|
|
|
account.realm = realm;
|
|
|
|
account.fingerprint = fingerprint;
|
|
|
|
account.fingerprint = fingerprint;
|
|
|
@ -1382,7 +1405,8 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
cbCertificate.setChecked(account == null ? false : account.certificate);
|
|
|
|
certificate = (account == null ? null : account.certificate_alias);
|
|
|
|
|
|
|
|
tvCertificate.setText(certificate == null ? getString(R.string.title_optional) : certificate);
|
|
|
|
etRealm.setText(account == null ? null : account.realm);
|
|
|
|
etRealm.setText(account == null ? null : account.realm);
|
|
|
|
|
|
|
|
|
|
|
|
if (account == null || account.fingerprint == null) {
|
|
|
|
if (account == null || account.fingerprint == null) {
|
|
|
@ -1447,7 +1471,7 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
if (auth != EmailService.AUTH_TYPE_PASSWORD) {
|
|
|
|
if (auth != EmailService.AUTH_TYPE_PASSWORD) {
|
|
|
|
etUser.setEnabled(false);
|
|
|
|
etUser.setEnabled(false);
|
|
|
|
tilPassword.setEnabled(false);
|
|
|
|
tilPassword.setEnabled(false);
|
|
|
|
cbCertificate.setEnabled(false);
|
|
|
|
btnCertificate.setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (account == null || account.auth_type != EmailService.AUTH_TYPE_GMAIL)
|
|
|
|
if (account == null || account.auth_type != EmailService.AUTH_TYPE_GMAIL)
|
|
|
|