Added POP3 option to actively delete messages after downloading

pull/212/head
M66B 2 years ago
parent b1afe46468
commit 0f68c1ae13

File diff suppressed because it is too large Load Diff

@ -3378,6 +3378,9 @@ class Core {
Log.w(ex);
}
if (!account.leave_on_server && account.client_delete)
imessage.setFlag(Flags.Flag.DELETED, true);
EntityContact.received(context, account, folder, message);
} catch (FolderClosedException ex) {
throw ex;

@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 272,
version = 273,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2768,6 +2768,12 @@ public abstract class DB extends RoomDatabase {
db.execSQL("UPDATE account SET partial_fetch = 1, raw_fetch = 0" +
" WHERE host = 'imap.mail.yahoo.com' OR host = 'imap.aol.com'");
}
}).addMigrations(new Migration(272, 273) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `client_delete` INTEGER NOT NULL DEFAULT 0");
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -116,6 +116,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
@NonNull
public Boolean leave_on_server = true;
@NonNull
public Boolean client_delete = false;
@NonNull
public Boolean leave_deleted = false;
@NonNull
public Boolean leave_on_device = false;
@ -304,6 +306,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
json.put("notify", notify);
json.put("browse", browse);
json.put("leave_on_server", leave_on_server);
json.put("client_delete", client_delete);
json.put("leave_deleted", leave_deleted);
json.put("leave_on_device", leave_on_device);
json.put("max_messages", max_messages);
@ -391,6 +394,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
account.browse = json.getBoolean("browse");
if (json.has("leave_on_server"))
account.leave_on_server = json.getBoolean("leave_on_server");
account.client_delete = json.optBoolean("client_delete", false);
if (json.has("leave_deleted"))
account.leave_deleted = json.getBoolean("leave_deleted");
if (json.has("leave_on_device"))
@ -459,6 +463,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
a1.notify.equals(other.notify) &&
a1.browse.equals(other.browse) &&
a1.leave_on_server.equals(other.leave_on_server) &&
a1.client_delete.equals(other.client_delete) &&
Objects.equals(a1.leave_deleted, other.leave_deleted) &&
a1.leave_on_device.equals(other.leave_on_device) &&
Objects.equals(a1.max_messages, other.max_messages) &&

@ -96,6 +96,7 @@ public class FragmentPop extends FragmentBase {
private TextView tvNotifyPro;
private CheckBox cbAutoSeen;
private CheckBox cbLeaveServer;
private CheckBox cbClientDelete;
private CheckBox cbLeaveDeleted;
private CheckBox cbLeaveDevice;
private EditText etMax;
@ -171,6 +172,7 @@ public class FragmentPop extends FragmentBase {
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
cbAutoSeen = view.findViewById(R.id.cbAutoSeen);
cbLeaveServer = view.findViewById(R.id.cbLeaveServer);
cbClientDelete = view.findViewById(R.id.cbClientDelete);
cbLeaveDeleted = view.findViewById(R.id.cbLeaveDeleted);
cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice);
etMax = view.findViewById(R.id.etMax);
@ -291,6 +293,13 @@ public class FragmentPop extends FragmentBase {
Helper.linkPro(tvNotifyPro);
cbLeaveServer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cbClientDelete.setEnabled(!isChecked);
}
});
etInterval.setHint(Integer.toString(EntityAccount.DEFAULT_POLL_INTERVAL));
adapterSwipe = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, getSwipeActions());
@ -363,6 +372,7 @@ public class FragmentPop extends FragmentBase {
args.putBoolean("auto_seen", cbAutoSeen.isChecked());
args.putBoolean("leave_server", cbLeaveServer.isChecked());
args.putBoolean("client_delete", cbClientDelete.isChecked());
args.putBoolean("leave_deleted", cbLeaveDeleted.isChecked());
args.putBoolean("leave_device", cbLeaveDevice.isChecked());
args.putString("max", etMax.getText().toString());
@ -417,6 +427,7 @@ public class FragmentPop extends FragmentBase {
boolean notify = args.getBoolean("notify");
boolean auto_seen = args.getBoolean("auto_seen");
boolean leave_server = args.getBoolean("leave_server");
boolean client_delete = args.getBoolean("client_delete");
boolean leave_deleted = args.getBoolean("leave_deleted");
boolean leave_device = args.getBoolean("leave_device");
String max = args.getString("max");
@ -509,6 +520,8 @@ public class FragmentPop extends FragmentBase {
return true;
if (!Objects.equals(account.leave_on_server, leave_server))
return true;
if (!Objects.equals(account.client_delete, client_delete))
return true;
if (!Objects.equals(account.leave_deleted, leave_deleted))
return true;
if (!Objects.equals(account.leave_on_device, leave_device))
@ -597,6 +610,7 @@ public class FragmentPop extends FragmentBase {
account.notify = notify;
account.auto_seen = auto_seen;
account.leave_on_server = leave_server;
account.client_delete = client_delete;
account.leave_deleted = leave_deleted;
account.leave_on_device = leave_device;
account.max_messages = max_messages;
@ -792,6 +806,8 @@ public class FragmentPop extends FragmentBase {
cbAutoSeen.setChecked(account == null ? true : account.auto_seen);
cbLeaveServer.setChecked(account == null ? true : account.leave_on_server);
cbClientDelete.setChecked(account == null ? false : account.client_delete);
cbClientDelete.setEnabled(!cbLeaveServer.isChecked());
cbLeaveDeleted.setChecked(account == null ? true : account.leave_deleted);
cbLeaveDevice.setChecked(account == null ? false : account.leave_on_device);

@ -2317,7 +2317,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (ifolder != null && ifolder.isOpen()) {
db.folder().setFolderState(folder.id, "closing");
try {
ifolder.close(false);
boolean expunge =
(account.protocol == EntityAccount.TYPE_POP &&
!account.leave_on_server && account.client_delete);
ifolder.close(expunge);
} catch (Throwable ex) {
Log.w(folder.name, ex);
}

@ -436,6 +436,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAutoSeen" />
<CheckBox
android:id="@+id/cbClientDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_client_delete"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLeaveServer" />
<CheckBox
android:id="@+id/cbLeaveDeleted"
android:layout_width="wrap_content"
@ -443,7 +453,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_leave_deleted"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLeaveServer" />
app:layout_constraintTop_toBottomOf="@id/cbClientDelete" />
<CheckBox
android:id="@+id/cbLeaveDevice"

@ -1111,6 +1111,7 @@
<string name="title_primary_identity">Primary (default identity)</string>
<string name="title_self_identity">Remove email address when replying</string>
<string name="title_leave_on_server">Leave messages on server</string>
<string name="title_client_delete">Actively delete messages after downloading</string>
<string name="title_leave_deleted">Leave deleted messages on server</string>
<string name="title_leave_on_device">Leave messages on device</string>
<string name="title_max_messages">Maximum number of messages to download (blank for all)</string>

Loading…
Cancel
Save