POP3: added leave on device option

pull/172/head
M66B 5 years ago
parent 3a25a5f668
commit 7d5784dc43

File diff suppressed because it is too large Load Diff

@ -1016,7 +1016,7 @@ class Core {
// Delete message
DB db = DB.getInstance(context);
if (!account.browse && EntityFolder.INBOX.equals(folder.type)) {
if (!account.leave_on_server && EntityFolder.INBOX.equals(folder.type)) {
Map<String, String> caps = istore.capabilities();
Message[] imessages = ifolder.getMessages();
@ -1589,10 +1589,11 @@ class Core {
((POP3Message) imessage).invalidate(true);
}
for (String msgid : existing) {
Log.i(folder.name + " POP deleted=" + msgid);
db.message().deleteMessage(folder.id, msgid);
}
if (!account.leave_on_device)
for (String msgid : existing) {
Log.i(folder.name + " POP deleted=" + msgid);
db.message().deleteMessage(folder.id, msgid);
}
Log.i(folder.name + " done");
} finally {

@ -58,7 +58,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 132,
version = 133,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1271,6 +1271,15 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_encrypt` INTEGER");
db.execSQL("UPDATE `message` SET `ui_encrypt` = `encrypt`");
}
})
.addMigrations(new Migration(132, 133) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `leave_on_server` INTEGER NOT NULL DEFAULT 1");
db.execSQL("ALTER TABLE `account` ADD COLUMN `leave_on_device` INTEGER NOT NULL DEFAULT 0");
db.execSQL("UPDATE `account` SET `leave_on_server` = `browse` WHERE `pop` = " + EntityAccount.TYPE_POP);
}
});
}

@ -95,7 +95,11 @@ public class EntityAccount extends EntityOrder implements Serializable {
@NonNull
public Boolean notify = false;
@NonNull
public Boolean browse = true; // POP3: Leave messages on server
public Boolean browse = true;
@NonNull
public Boolean leave_on_server = true;
@NonNull
public Boolean leave_on_device = false;
@NonNull
public Boolean auto_seen = true;
public Character separator;
@ -203,6 +207,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
json.put("primary", primary);
json.put("notify", notify);
json.put("browse", browse);
json.put("leave_on_server", leave_on_server);
json.put("leave_on_device", leave_on_device);
json.put("auto_seen", auto_seen);
// not separator
@ -267,6 +273,10 @@ public class EntityAccount extends EntityOrder implements Serializable {
account.notify = json.getBoolean("notify");
if (json.has("browse"))
account.browse = json.getBoolean("browse");
if (json.has("leave_on_server"))
account.leave_on_server = json.getBoolean("leave_on_server");
if (json.has("leave_on_device"))
account.leave_on_device = json.getBoolean("leave_on_device");
if (json.has("auto_seen"))
account.auto_seen = json.getBoolean("auto_seen");
@ -307,6 +317,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
this.primary.equals(other.primary) &&
this.notify.equals(other.notify) &&
this.browse.equals(other.browse) &&
this.leave_on_server.equals(other.leave_on_server) &&
this.leave_on_device.equals(other.leave_on_device) &&
this.auto_seen.equals(other.auto_seen) &&
Objects.equals(this.swipe_left, other.swipe_left) &&
Objects.equals(this.swipe_right, other.swipe_right) &&

@ -75,7 +75,8 @@ public class FragmentPop extends FragmentBase {
private CheckBox cbSynchronize;
private CheckBox cbOnDemand;
private CheckBox cbPrimary;
private CheckBox cbLeave;
private CheckBox cbLeaveServer;
private CheckBox cbLeaveDevice;
private EditText etInterval;
private Button btnSave;
@ -125,7 +126,8 @@ public class FragmentPop extends FragmentBase {
cbSynchronize = view.findViewById(R.id.cbSynchronize);
cbOnDemand = view.findViewById(R.id.cbOnDemand);
cbPrimary = view.findViewById(R.id.cbPrimary);
cbLeave = view.findViewById(R.id.cbLeave);
cbLeaveServer = view.findViewById(R.id.cbLeaveServer);
cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice);
etInterval = view.findViewById(R.id.etInterval);
btnSave = view.findViewById(R.id.btnSave);
@ -219,7 +221,8 @@ public class FragmentPop extends FragmentBase {
args.putBoolean("synchronize", cbSynchronize.isChecked());
args.putBoolean("ondemand", cbOnDemand.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
args.putBoolean("leave", cbLeave.isChecked());
args.putBoolean("leave_server", cbLeaveServer.isChecked());
args.putBoolean("leave_device", cbLeaveDevice.isChecked());
args.putString("interval", etInterval.getText().toString());
new SimpleTask<Boolean>() {
@ -256,7 +259,8 @@ public class FragmentPop extends FragmentBase {
boolean synchronize = args.getBoolean("synchronize");
boolean ondemand = args.getBoolean("ondemand");
boolean primary = args.getBoolean("primary");
boolean leave = args.getBoolean("leave");
boolean leave_server = args.getBoolean("leave_server");
boolean leave_device = args.getBoolean("leave_device");
String interval = args.getString("interval");
boolean pro = ActivityBilling.isPro(context);
@ -339,7 +343,8 @@ public class FragmentPop extends FragmentBase {
account.synchronize = synchronize;
account.ondemand = ondemand;
account.primary = (account.synchronize && primary);
account.browse = leave;
account.leave_on_server = leave_server;
account.leave_on_device = leave_device;
account.poll_interval = Integer.parseInt(interval);
if (!update)
@ -484,7 +489,8 @@ public class FragmentPop extends FragmentBase {
cbSynchronize.setChecked(account == null ? true : account.synchronize);
cbOnDemand.setChecked(account == null ? false : account.ondemand);
cbPrimary.setChecked(account == null ? false : account.primary);
cbLeave.setChecked(account == null ? true : account.browse);
cbLeaveServer.setChecked(account == null ? true : account.leave_on_server);
cbLeaveDevice.setChecked(account == null ? false : account.leave_on_device);
etInterval.setText(account == null ? "" : Long.toString(account.poll_interval));
new SimpleTask<EntityAccount>() {

@ -797,7 +797,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
iservice.setPartialFetch(account.partial_fetch);
iservice.setIgnoreBodyStructureSize(account.ignore_size);
if (account.protocol != EntityAccount.TYPE_IMAP)
iservice.setLeaveOnServer(account.browse);
iservice.setLeaveOnServer(account.leave_on_server);
iservice.setListener(new StoreListener() {
@Override
public void notification(StoreEvent e) {

@ -281,7 +281,7 @@
app:layout_constraintTop_toBottomOf="@id/cbOnDemand" />
<CheckBox
android:id="@+id/cbLeave"
android:id="@+id/cbLeaveServer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
@ -289,6 +289,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPrimary" />
<CheckBox
android:id="@+id/cbLeaveDevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_leave_on_device"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLeaveServer" />
<!-- keep alive -->
<TextView
@ -299,7 +308,7 @@
android:text="@string/title_keep_alive_interval"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLeave" />
app:layout_constraintTop_toBottomOf="@id/cbLeaveDevice" />
<EditText
android:id="@+id/etInterval"

@ -503,6 +503,7 @@
<string name="title_primary_account">Primary (default account)</string>
<string name="title_primary_identity">Primary (default identity)</string>
<string name="title_leave_on_server">Leave messages on server</string>
<string name="title_leave_on_device">Leave messages on device</string>
<string name="title_keep_alive_interval">Keep-alive/poll interval (minutes)</string>
<string name="title_partial_fetch" translatable="false">Partial fetch</string>
<string name="title_ignore_size" translatable="false">Ignore bodystructure size</string>

Loading…
Cancel
Save