mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 19:34:15 +01:00
Move store sent option to identy
This commit is contained in:
@@ -45,7 +45,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 2,
|
||||
version = 3,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -118,6 +118,13 @@ public abstract class DB extends RoomDatabase {
|
||||
db.execSQL("ALTER TABLE `account` ADD COLUMN `poll_interval` INTEGER NOT NULL DEFAULT 9");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(2, 3) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase db) {
|
||||
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `identity` ADD COLUMN `store_sent` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class EntityAccount {
|
||||
@NonNull
|
||||
public Boolean synchronize;
|
||||
@NonNull
|
||||
public Boolean store_sent;
|
||||
public Boolean store_sent; // obsolete
|
||||
@NonNull
|
||||
public Integer poll_interval;
|
||||
public Long seen_until;
|
||||
@@ -65,6 +65,7 @@ public class EntityAccount {
|
||||
this.password.equals(other.password) &&
|
||||
this.primary.equals(other.primary) &&
|
||||
this.synchronize.equals(other.synchronize) &&
|
||||
this.poll_interval.equals(other.poll_interval) &&
|
||||
(this.seen_until == null ? other.seen_until == null : this.seen_until.equals(other.seen_until)) &&
|
||||
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
|
||||
(this.error == null ? other.error == null : this.error.equals(other.error)));
|
||||
|
||||
@@ -62,6 +62,8 @@ public class EntityIdentity {
|
||||
public Boolean primary;
|
||||
@NonNull
|
||||
public Boolean synchronize;
|
||||
@NonNull
|
||||
public Boolean store_sent;
|
||||
public String state;
|
||||
public String error;
|
||||
|
||||
@@ -80,6 +82,7 @@ public class EntityIdentity {
|
||||
this.password.equals(other.password) &&
|
||||
this.primary.equals(other.primary) &&
|
||||
this.synchronize.equals(other.synchronize) &&
|
||||
this.store_sent.equals(other.store_sent) &&
|
||||
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
|
||||
(this.error == null ? other.error == null : this.error.equals(other.error)));
|
||||
} else
|
||||
|
||||
@@ -75,7 +75,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
private TextView tvLink;
|
||||
private CheckBox cbSynchronize;
|
||||
private CheckBox cbPrimary;
|
||||
private CheckBox cbStoreSent;
|
||||
private EditText etInterval;
|
||||
private Button btnCheck;
|
||||
private ProgressBar pbCheck;
|
||||
@@ -113,7 +112,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
tvLink = view.findViewById(R.id.tvLink);
|
||||
cbSynchronize = view.findViewById(R.id.cbSynchronize);
|
||||
cbPrimary = view.findViewById(R.id.cbPrimary);
|
||||
cbStoreSent = view.findViewById(R.id.cbStoreSent);
|
||||
etInterval = view.findViewById(R.id.etInterval);
|
||||
btnCheck = view.findViewById(R.id.btnCheck);
|
||||
pbCheck = view.findViewById(R.id.pbCheck);
|
||||
@@ -383,7 +381,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
args.putString("password", tilPassword.getEditText().getText().toString());
|
||||
args.putBoolean("synchronize", cbSynchronize.isChecked());
|
||||
args.putBoolean("primary", cbPrimary.isChecked());
|
||||
args.putBoolean("store_sent", cbStoreSent.isChecked());
|
||||
args.putString("poll_interval", etInterval.getText().toString());
|
||||
args.putParcelable("drafts", drafts);
|
||||
args.putParcelable("sent", sent);
|
||||
@@ -401,7 +398,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
String password = args.getString("password");
|
||||
boolean synchronize = args.getBoolean("synchronize");
|
||||
boolean primary = args.getBoolean("primary");
|
||||
boolean store_sent = args.getBoolean("store_sent");
|
||||
String poll_interval = args.getString("poll_interval");
|
||||
EntityFolder drafts = args.getParcelable("drafts");
|
||||
EntityFolder sent = args.getParcelable("sent");
|
||||
@@ -457,7 +453,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
account.password = password;
|
||||
account.synchronize = synchronize;
|
||||
account.primary = (account.synchronize && primary);
|
||||
account.store_sent = store_sent;
|
||||
account.poll_interval = Integer.parseInt(poll_interval);
|
||||
|
||||
if (!synchronize)
|
||||
@@ -642,7 +637,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
tilPassword.getEditText().setText(account == null ? null : account.password);
|
||||
cbSynchronize.setChecked(account == null ? true : account.synchronize);
|
||||
cbPrimary.setChecked(account == null ? true : account.primary);
|
||||
cbStoreSent.setChecked(account == null ? false : account.store_sent);
|
||||
etInterval.setText(account == null ? "9" : Integer.toString(account.poll_interval));
|
||||
} else {
|
||||
int provider = savedInstanceState.getInt("provider");
|
||||
|
||||
@@ -72,6 +72,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
private TextView tvLink;
|
||||
private CheckBox cbSynchronize;
|
||||
private CheckBox cbPrimary;
|
||||
private CheckBox cbStoreSent;
|
||||
private Button btnSave;
|
||||
private ProgressBar pbSave;
|
||||
private ImageButton ibDelete;
|
||||
@@ -103,6 +104,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
tvLink = view.findViewById(R.id.tvLink);
|
||||
cbSynchronize = view.findViewById(R.id.cbSynchronize);
|
||||
cbPrimary = view.findViewById(R.id.cbPrimary);
|
||||
cbStoreSent = view.findViewById(R.id.cbStoreSent);
|
||||
btnSave = view.findViewById(R.id.btnSave);
|
||||
pbSave = view.findViewById(R.id.pbSave);
|
||||
ibDelete = view.findViewById(R.id.ibDelete);
|
||||
@@ -219,6 +221,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
args.putString("password", tilPassword.getEditText().getText().toString());
|
||||
args.putBoolean("synchronize", cbSynchronize.isChecked());
|
||||
args.putBoolean("primary", cbPrimary.isChecked());
|
||||
args.putBoolean("store_sent", cbStoreSent.isChecked());
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
@@ -234,6 +237,8 @@ public class FragmentIdentity extends FragmentEx {
|
||||
String user = args.getString("user");
|
||||
String password = args.getString("password");
|
||||
boolean synchronize = args.getBoolean("synchronize");
|
||||
boolean primary = args.getBoolean("primary");
|
||||
boolean store_sent = args.getBoolean("store_sent");
|
||||
|
||||
if (TextUtils.isEmpty(name))
|
||||
throw new IllegalArgumentException(getContext().getString(R.string.title_no_name));
|
||||
@@ -283,7 +288,8 @@ public class FragmentIdentity extends FragmentEx {
|
||||
identity.user = user;
|
||||
identity.password = password;
|
||||
identity.synchronize = synchronize;
|
||||
identity.primary = (identity.synchronize && args.getBoolean("primary"));
|
||||
identity.primary = (identity.synchronize && primary);
|
||||
identity.store_sent = store_sent;
|
||||
|
||||
if (!identity.synchronize)
|
||||
identity.error = null;
|
||||
@@ -311,7 +317,6 @@ public class FragmentIdentity extends FragmentEx {
|
||||
getFragmentManager().popBackStack();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
@@ -417,6 +422,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
tilPassword.getEditText().setText(identity == null ? null : identity.password);
|
||||
cbSynchronize.setChecked(identity == null ? true : identity.synchronize);
|
||||
cbPrimary.setChecked(identity == null ? true : identity.primary);
|
||||
cbStoreSent.setChecked(identity == null ? false : identity.store_sent);
|
||||
|
||||
etName.requestFocus();
|
||||
} else {
|
||||
|
||||
@@ -953,7 +953,6 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
|
||||
private void doSend(Session isession, EntityMessage message, DB db) throws MessagingException, IOException {
|
||||
// Send message
|
||||
EntityAccount account = db.account().getAccount(message.account);
|
||||
EntityIdentity ident = db.identity().getIdentity(message.identity);
|
||||
EntityMessage reply = (message.replying == null ? null : db.message().getMessage(message.replying));
|
||||
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
|
||||
@@ -998,7 +997,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
message.ui_seen = true;
|
||||
db.message().updateMessage(message);
|
||||
|
||||
if (account.store_sent) {
|
||||
if (ident.store_sent) {
|
||||
EntityFolder sent = db.folder().getFolderByType(ident.account, EntityFolder.SENT);
|
||||
if (sent != null) {
|
||||
message.folder = sent.id;
|
||||
|
||||
Reference in New Issue
Block a user