mirror of https://github.com/M66B/FairEmail.git
Added POP3 option to actively delete messages after downloading
This commit is contained in:
parent
b1afe46468
commit
0f68c1ae13
File diff suppressed because it is too large
Load Diff
|
@ -3378,6 +3378,9 @@ class Core {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!account.leave_on_server && account.client_delete)
|
||||||
|
imessage.setFlag(Flags.Flag.DELETED, true);
|
||||||
|
|
||||||
EntityContact.received(context, account, folder, message);
|
EntityContact.received(context, account, folder, message);
|
||||||
} catch (FolderClosedException ex) {
|
} catch (FolderClosedException ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
|
|
|
@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
|
||||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 272,
|
version = 273,
|
||||||
entities = {
|
entities = {
|
||||||
EntityIdentity.class,
|
EntityIdentity.class,
|
||||||
EntityAccount.class,
|
EntityAccount.class,
|
||||||
|
@ -2768,6 +2768,12 @@ public abstract class DB extends RoomDatabase {
|
||||||
db.execSQL("UPDATE account SET partial_fetch = 1, raw_fetch = 0" +
|
db.execSQL("UPDATE account SET partial_fetch = 1, raw_fetch = 0" +
|
||||||
" WHERE host = 'imap.mail.yahoo.com' OR host = 'imap.aol.com'");
|
" 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) {
|
}).addMigrations(new Migration(998, 999) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||||
|
|
|
@ -116,6 +116,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
||||||
@NonNull
|
@NonNull
|
||||||
public Boolean leave_on_server = true;
|
public Boolean leave_on_server = true;
|
||||||
@NonNull
|
@NonNull
|
||||||
|
public Boolean client_delete = false;
|
||||||
|
@NonNull
|
||||||
public Boolean leave_deleted = false;
|
public Boolean leave_deleted = false;
|
||||||
@NonNull
|
@NonNull
|
||||||
public Boolean leave_on_device = false;
|
public Boolean leave_on_device = false;
|
||||||
|
@ -304,6 +306,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
||||||
json.put("notify", notify);
|
json.put("notify", notify);
|
||||||
json.put("browse", browse);
|
json.put("browse", browse);
|
||||||
json.put("leave_on_server", leave_on_server);
|
json.put("leave_on_server", leave_on_server);
|
||||||
|
json.put("client_delete", client_delete);
|
||||||
json.put("leave_deleted", leave_deleted);
|
json.put("leave_deleted", leave_deleted);
|
||||||
json.put("leave_on_device", leave_on_device);
|
json.put("leave_on_device", leave_on_device);
|
||||||
json.put("max_messages", max_messages);
|
json.put("max_messages", max_messages);
|
||||||
|
@ -391,6 +394,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
||||||
account.browse = json.getBoolean("browse");
|
account.browse = json.getBoolean("browse");
|
||||||
if (json.has("leave_on_server"))
|
if (json.has("leave_on_server"))
|
||||||
account.leave_on_server = json.getBoolean("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"))
|
if (json.has("leave_deleted"))
|
||||||
account.leave_deleted = json.getBoolean("leave_deleted");
|
account.leave_deleted = json.getBoolean("leave_deleted");
|
||||||
if (json.has("leave_on_device"))
|
if (json.has("leave_on_device"))
|
||||||
|
@ -459,6 +463,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
||||||
a1.notify.equals(other.notify) &&
|
a1.notify.equals(other.notify) &&
|
||||||
a1.browse.equals(other.browse) &&
|
a1.browse.equals(other.browse) &&
|
||||||
a1.leave_on_server.equals(other.leave_on_server) &&
|
a1.leave_on_server.equals(other.leave_on_server) &&
|
||||||
|
a1.client_delete.equals(other.client_delete) &&
|
||||||
Objects.equals(a1.leave_deleted, other.leave_deleted) &&
|
Objects.equals(a1.leave_deleted, other.leave_deleted) &&
|
||||||
a1.leave_on_device.equals(other.leave_on_device) &&
|
a1.leave_on_device.equals(other.leave_on_device) &&
|
||||||
Objects.equals(a1.max_messages, other.max_messages) &&
|
Objects.equals(a1.max_messages, other.max_messages) &&
|
||||||
|
|
|
@ -96,6 +96,7 @@ public class FragmentPop extends FragmentBase {
|
||||||
private TextView tvNotifyPro;
|
private TextView tvNotifyPro;
|
||||||
private CheckBox cbAutoSeen;
|
private CheckBox cbAutoSeen;
|
||||||
private CheckBox cbLeaveServer;
|
private CheckBox cbLeaveServer;
|
||||||
|
private CheckBox cbClientDelete;
|
||||||
private CheckBox cbLeaveDeleted;
|
private CheckBox cbLeaveDeleted;
|
||||||
private CheckBox cbLeaveDevice;
|
private CheckBox cbLeaveDevice;
|
||||||
private EditText etMax;
|
private EditText etMax;
|
||||||
|
@ -171,6 +172,7 @@ public class FragmentPop extends FragmentBase {
|
||||||
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
|
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
|
||||||
cbAutoSeen = view.findViewById(R.id.cbAutoSeen);
|
cbAutoSeen = view.findViewById(R.id.cbAutoSeen);
|
||||||
cbLeaveServer = view.findViewById(R.id.cbLeaveServer);
|
cbLeaveServer = view.findViewById(R.id.cbLeaveServer);
|
||||||
|
cbClientDelete = view.findViewById(R.id.cbClientDelete);
|
||||||
cbLeaveDeleted = view.findViewById(R.id.cbLeaveDeleted);
|
cbLeaveDeleted = view.findViewById(R.id.cbLeaveDeleted);
|
||||||
cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice);
|
cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice);
|
||||||
etMax = view.findViewById(R.id.etMax);
|
etMax = view.findViewById(R.id.etMax);
|
||||||
|
@ -291,6 +293,13 @@ public class FragmentPop extends FragmentBase {
|
||||||
|
|
||||||
Helper.linkPro(tvNotifyPro);
|
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));
|
etInterval.setHint(Integer.toString(EntityAccount.DEFAULT_POLL_INTERVAL));
|
||||||
|
|
||||||
adapterSwipe = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, getSwipeActions());
|
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("auto_seen", cbAutoSeen.isChecked());
|
||||||
|
|
||||||
args.putBoolean("leave_server", cbLeaveServer.isChecked());
|
args.putBoolean("leave_server", cbLeaveServer.isChecked());
|
||||||
|
args.putBoolean("client_delete", cbClientDelete.isChecked());
|
||||||
args.putBoolean("leave_deleted", cbLeaveDeleted.isChecked());
|
args.putBoolean("leave_deleted", cbLeaveDeleted.isChecked());
|
||||||
args.putBoolean("leave_device", cbLeaveDevice.isChecked());
|
args.putBoolean("leave_device", cbLeaveDevice.isChecked());
|
||||||
args.putString("max", etMax.getText().toString());
|
args.putString("max", etMax.getText().toString());
|
||||||
|
@ -417,6 +427,7 @@ public class FragmentPop extends FragmentBase {
|
||||||
boolean notify = args.getBoolean("notify");
|
boolean notify = args.getBoolean("notify");
|
||||||
boolean auto_seen = args.getBoolean("auto_seen");
|
boolean auto_seen = args.getBoolean("auto_seen");
|
||||||
boolean leave_server = args.getBoolean("leave_server");
|
boolean leave_server = args.getBoolean("leave_server");
|
||||||
|
boolean client_delete = args.getBoolean("client_delete");
|
||||||
boolean leave_deleted = args.getBoolean("leave_deleted");
|
boolean leave_deleted = args.getBoolean("leave_deleted");
|
||||||
boolean leave_device = args.getBoolean("leave_device");
|
boolean leave_device = args.getBoolean("leave_device");
|
||||||
String max = args.getString("max");
|
String max = args.getString("max");
|
||||||
|
@ -509,6 +520,8 @@ public class FragmentPop extends FragmentBase {
|
||||||
return true;
|
return true;
|
||||||
if (!Objects.equals(account.leave_on_server, leave_server))
|
if (!Objects.equals(account.leave_on_server, leave_server))
|
||||||
return true;
|
return true;
|
||||||
|
if (!Objects.equals(account.client_delete, client_delete))
|
||||||
|
return true;
|
||||||
if (!Objects.equals(account.leave_deleted, leave_deleted))
|
if (!Objects.equals(account.leave_deleted, leave_deleted))
|
||||||
return true;
|
return true;
|
||||||
if (!Objects.equals(account.leave_on_device, leave_device))
|
if (!Objects.equals(account.leave_on_device, leave_device))
|
||||||
|
@ -597,6 +610,7 @@ public class FragmentPop extends FragmentBase {
|
||||||
account.notify = notify;
|
account.notify = notify;
|
||||||
account.auto_seen = auto_seen;
|
account.auto_seen = auto_seen;
|
||||||
account.leave_on_server = leave_server;
|
account.leave_on_server = leave_server;
|
||||||
|
account.client_delete = client_delete;
|
||||||
account.leave_deleted = leave_deleted;
|
account.leave_deleted = leave_deleted;
|
||||||
account.leave_on_device = leave_device;
|
account.leave_on_device = leave_device;
|
||||||
account.max_messages = max_messages;
|
account.max_messages = max_messages;
|
||||||
|
@ -792,6 +806,8 @@ public class FragmentPop extends FragmentBase {
|
||||||
cbAutoSeen.setChecked(account == null ? true : account.auto_seen);
|
cbAutoSeen.setChecked(account == null ? true : account.auto_seen);
|
||||||
|
|
||||||
cbLeaveServer.setChecked(account == null ? true : account.leave_on_server);
|
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);
|
cbLeaveDeleted.setChecked(account == null ? true : account.leave_deleted);
|
||||||
cbLeaveDevice.setChecked(account == null ? false : account.leave_on_device);
|
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()) {
|
if (ifolder != null && ifolder.isOpen()) {
|
||||||
db.folder().setFolderState(folder.id, "closing");
|
db.folder().setFolderState(folder.id, "closing");
|
||||||
try {
|
try {
|
||||||
ifolder.close(false);
|
boolean expunge =
|
||||||
|
(account.protocol == EntityAccount.TYPE_POP &&
|
||||||
|
!account.leave_on_server && account.client_delete);
|
||||||
|
ifolder.close(expunge);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.w(folder.name, ex);
|
Log.w(folder.name, ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,6 +436,16 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/cbAutoSeen" />
|
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
|
<CheckBox
|
||||||
android:id="@+id/cbLeaveDeleted"
|
android:id="@+id/cbLeaveDeleted"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -443,7 +453,7 @@
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/title_leave_deleted"
|
android:text="@string/title_leave_deleted"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/cbLeaveServer" />
|
app:layout_constraintTop_toBottomOf="@id/cbClientDelete" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/cbLeaveDevice"
|
android:id="@+id/cbLeaveDevice"
|
||||||
|
|
|
@ -1111,6 +1111,7 @@
|
||||||
<string name="title_primary_identity">Primary (default identity)</string>
|
<string name="title_primary_identity">Primary (default identity)</string>
|
||||||
<string name="title_self_identity">Remove email address when replying</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_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_deleted">Leave deleted messages on server</string>
|
||||||
<string name="title_leave_on_device">Leave messages on device</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>
|
<string name="title_max_messages">Maximum number of messages to download (blank for all)</string>
|
||||||
|
|
Loading…
Reference in New Issue