Experiment: leave on device for IMAP

pull/209/head
M66B 2 years ago
parent 859e7da4c6
commit 75f1af1c98

@ -1847,8 +1847,14 @@ class Core {
}
}
if (BuildConfig.DEBUG && account.leave_on_device) {
EntityMessage message = db.message().getMessageByUid(folder.id, uid);
if (message != null)
db.message().setMessageUiDeleted(message.id, true);
} else {
int count = db.message().deleteMessage(folder.id, uid);
Log.i(folder.name + " delete local uid=" + uid + " count=" + count);
}
} else
throw ex;
} finally {
@ -3890,9 +3896,15 @@ class Core {
// Delete local messages not at remote
Log.i(folder.name + " delete=" + uids.size());
for (Long uid : uids) {
if (BuildConfig.DEBUG && account.leave_on_device) {
EntityMessage message = db.message().getMessageByUid(folder.id, uid);
if (message != null)
db.message().setMessageUiDeleted(message.id, true);
} else {
int count = db.message().deleteMessage(folder.id, uid);
Log.i(folder.name + " delete local uid=" + uid + " count=" + count);
}
}
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);

@ -125,6 +125,7 @@ public class FragmentAccount extends FragmentBase {
private TextView tvNotifyPro;
private CheckBox cbBrowse;
private CheckBox cbAutoSeen;
private CheckBox cbLeaveDevice;
private EditText etInterval;
private CheckBox cbNoop;
private CheckBox cbPartialFetch;
@ -244,6 +245,7 @@ public class FragmentAccount extends FragmentBase {
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
cbBrowse = view.findViewById(R.id.cbBrowse);
cbAutoSeen = view.findViewById(R.id.cbAutoSeen);
cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice);
etInterval = view.findViewById(R.id.etInterval);
cbNoop = view.findViewById(R.id.cbNoop);
cbPartialFetch = view.findViewById(R.id.cbPartialFetch);
@ -511,6 +513,9 @@ public class FragmentAccount extends FragmentBase {
etInterval.setHint(Integer.toString(EntityAccount.DEFAULT_KEEP_ALIVE_INTERVAL));
if (!BuildConfig.DEBUG)
Helper.hide(cbLeaveDevice);
btnCheck.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -933,6 +938,7 @@ public class FragmentAccount extends FragmentBase {
args.putBoolean("notify", cbNotify.isChecked());
args.putBoolean("browse", cbBrowse.isChecked());
args.putBoolean("auto_seen", cbAutoSeen.isChecked());
args.putBoolean("leave_device", cbLeaveDevice.isChecked());
args.putString("interval", etInterval.getText().toString());
args.putBoolean("noop", cbNoop.isChecked());
args.putBoolean("partial_fetch", cbPartialFetch.isChecked());
@ -1008,6 +1014,7 @@ public class FragmentAccount extends FragmentBase {
boolean notify = args.getBoolean("notify");
boolean browse = args.getBoolean("browse");
boolean auto_seen = args.getBoolean("auto_seen");
boolean leave_device = args.getBoolean("leave_device");
String interval = args.getString("interval");
boolean noop = args.getBoolean("noop");
boolean partial_fetch = args.getBoolean("partial_fetch");
@ -1115,6 +1122,8 @@ public class FragmentAccount extends FragmentBase {
return true;
if (!Objects.equals(account.auto_seen, auto_seen))
return true;
if (!Objects.equals(account.leave_on_device, leave_device))
return true;
if (!Objects.equals(account.poll_interval, poll_interval))
return true;
if (!Objects.equals(account.keep_alive_noop, noop))
@ -1262,6 +1271,7 @@ public class FragmentAccount extends FragmentBase {
account.notify = notify;
account.browse = browse;
account.auto_seen = auto_seen;
account.leave_on_device = leave_device;
if (account.poll_interval != poll_interval) {
account.keep_alive_ok = false;
@ -1636,6 +1646,7 @@ public class FragmentAccount extends FragmentBase {
cbPrimary.setChecked(account == null ? false : account.primary);
cbBrowse.setChecked(account == null ? true : account.browse);
cbAutoSeen.setChecked(account == null ? true : account.auto_seen);
cbLeaveDevice.setChecked(account == null ? true : account.leave_on_device);
etInterval.setText(account == null ? "" : Long.toString(account.poll_interval));
cbNoop.setChecked(account == null ? true : account.keep_alive_noop);
cbPartialFetch.setChecked(account == null ? true : account.partial_fetch);

@ -5312,7 +5312,7 @@ public class FragmentMessages extends FragmentBase
menu.findItem(R.id.menu_filter_unflagged).setVisible(folder);
menu.findItem(R.id.menu_filter_unknown).setVisible(folder && !drafts && !sent);
menu.findItem(R.id.menu_filter_snoozed).setVisible(folder && !drafts);
menu.findItem(R.id.menu_filter_deleted).setVisible(folder && !perform_expunge);
menu.findItem(R.id.menu_filter_deleted).setVisible(folder && (!perform_expunge || BuildConfig.DEBUG));
menu.findItem(R.id.menu_filter_duplicates).setVisible(viewType == AdapterMessage.ViewType.THREAD);
menu.findItem(R.id.menu_filter_trash).setVisible(viewType == AdapterMessage.ViewType.THREAD);

@ -611,6 +611,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBrowseHint" />
<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/cbAutoSeen" />
<!-- keep alive -->
<TextView
@ -621,7 +630,7 @@
android:text="@string/title_keep_alive_interval"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAutoSeen" />
app:layout_constraintTop_toBottomOf="@id/cbLeaveDevice" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etInterval"
@ -1159,7 +1168,7 @@
cbNotify,tvNotifyRemark,tvNotifyPro,
cbSynchronize,cbIgnoreSchedule,cbOnDemand,tvLeave,cbPrimary,
cbBrowse,tvBrowseHint,
cbAutoSeen,
cbAutoSeen,cbLeaveDevice,
tvInterval,etInterval,tvIntervalRemark,cbNoop,tvNoopRemark,
cbPartialFetch,tvPartialFetchRemark,cbIgnoreSize,rgDate,tvDateRemark,
cbUnicode,cbUnmeteredOnly,cbVpnOnly" />

Loading…
Cancel
Save