Added login before send option

pull/215/head
M66B 7 months ago
parent 562c6e51e6
commit 2a5e1685e0

File diff suppressed because it is too large Load Diff

@ -70,7 +70,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 293,
version = 294,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -3004,6 +3004,12 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `last_touched` INTEGER");
}
}).addMigrations(new Migration(293, 294) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `login` INTEGER NOT NULL DEFAULT 0");
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -88,6 +88,8 @@ public class EntityIdentity {
@NonNull
public String password;
@NonNull
public Boolean login;
@NonNull
public boolean certificate = false; // obsolete
public String certificate_alias;
public String realm;

@ -108,6 +108,7 @@ public class FragmentIdentity extends FragmentBase {
private EditText etUser;
private TextInputLayout tilPassword;
private TextView tvPasswordStorage;
private CheckBox cbLogin;
private Button btnCertificate;
private TextView tvCertificate;
private EditText etRealm;
@ -218,6 +219,7 @@ public class FragmentIdentity extends FragmentBase {
etUser = view.findViewById(R.id.etUser);
tilPassword = view.findViewById(R.id.tilPassword);
tvPasswordStorage = view.findViewById(R.id.tvPasswordStorage);
cbLogin = view.findViewById(R.id.cbLoginBeforeSend);
btnCertificate = view.findViewById(R.id.btnCertificate);
tvCertificate = view.findViewById(R.id.tvCertificate);
etRealm = view.findViewById(R.id.etRealm);
@ -799,6 +801,7 @@ public class FragmentIdentity extends FragmentBase {
args.putString("provider", provider);
args.putString("user", etUser.getText().toString().trim());
args.putString("password", tilPassword.getEditText().getText().toString());
args.putBoolean("login", cbLogin.isChecked());
args.putString("certificate", certificate);
args.putString("realm", etRealm.getText().toString());
args.putString("fingerprint", cbTrust.isChecked() ? (String) cbTrust.getTag() : null);
@ -854,6 +857,7 @@ public class FragmentIdentity extends FragmentBase {
String provider = args.getString("provider");
String user = args.getString("user").trim();
String password = args.getString("password");
boolean login = args.getBoolean("login");
String certificate = args.getString("certificate");
String realm = args.getString("realm");
String fingerprint = args.getString("fingerprint");
@ -1019,6 +1023,8 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.password, password))
return true;
if (!Objects.equals(identity.login, login))
return true;
if (!Objects.equals(identity.certificate_alias, certificate))
return true;
if (!Objects.equals(identity.realm, realm))
@ -1087,6 +1093,7 @@ public class FragmentIdentity extends FragmentBase {
Integer.parseInt(port) != identity.port ||
!user.equals(identity.user) ||
!password.equals(identity.password) ||
!Objects.equals(login, identity.login) ||
!Objects.equals(certificate, identity.certificate_alias) ||
!Objects.equals(realm, identityRealm) ||
!Objects.equals(fingerprint, identity.fingerprint) ||
@ -1103,6 +1110,14 @@ public class FragmentIdentity extends FragmentBase {
// Check SMTP server
Long server_max_size = null;
if (check) {
if (login) {
EntityAccount a = db.account().getAccount(account);
if (a != null)
try (EmailService iaccount = new EmailService(context, a, EmailService.PURPOSE_CHECK, true)) {
iaccount.connect(a);
}
}
// Create transport
String protocol = (encryption == EmailService.ENCRYPTION_SSL ? "smtps" : "smtp");
try (EmailService iservice = new EmailService(context,
@ -1148,6 +1163,7 @@ public class FragmentIdentity extends FragmentBase {
identity.auth_type = auth;
identity.user = user;
identity.password = password;
identity.login = login;
identity.certificate_alias = certificate;
identity.provider = provider;
identity.realm = realm;
@ -1331,6 +1347,7 @@ public class FragmentIdentity extends FragmentBase {
etPort.setText(identity == null ? null : Long.toString(identity.port));
etUser.setText(identity == null ? null : identity.user);
tilPassword.getEditText().setText(identity == null ? null : identity.password);
cbLogin.setChecked((identity != null && identity.login));
certificate = (identity == null ? null : identity.certificate_alias);
tvCertificate.setText(certificate == null ? getString(R.string.title_optional) : certificate);
etRealm.setText(identity == null ? null : identity.realm);

@ -800,6 +800,11 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
MicrosoftGraph.send(ServiceSend.this, ident, imessage);
end = new Date().getTime();
} else {
if (account != null)
try (EmailService iaccount = new EmailService(this, account, EmailService.PURPOSE_USE, debug)) {
iaccount.connect(account);
}
EmailService iservice = new EmailService(this, ident, EmailService.PURPOSE_USE, debug);
try {
if (ident.envelopeFrom != null)

@ -535,16 +535,25 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<CheckBox
android:id="@+id/cbLoginBeforeSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/title_login_before_send"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardServer" />
<Button
android:id="@+id/btnCertificate"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginTop="12dp"
android:tag="disable"
android:text="@string/title_client_certificate"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardServer" />
app:layout_constraintTop_toBottomOf="@id/cbLoginBeforeSend" />
<TextView
android:id="@+id/tvCertificate"
@ -1186,6 +1195,7 @@
tvProvider,spProvider,
tvDomain,tvDomainHint,etDomain,btnAutoConfig,
cardServer,
cbLoginBeforeSend,
btnCertificate,tvCertificate,
tvRealm,etRealm,
cbUseIp,tvUseIpHint,tvEhlo,etEhlo,ibEhlo,

@ -1245,6 +1245,7 @@
<string name="title_password">Password</string>
<string name="title_password_storage">How are passwords stored?</string>
<string name="title_case_sensitive">Usernames and passwords are usually case sensitive</string>
<string name="title_login_before_send">Login before sending</string>
<string name="title_client_certificate">Client certificate</string>
<string name="title_realm">Realm</string>
<string name="title_use_ip">Use local IP address instead of host name</string>

Loading…
Cancel
Save