mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Added POP3 trash folder
This commit is contained in:
parent
ed40991e3c
commit
b637453ca7
6 changed files with 63 additions and 22 deletions
|
@ -1548,11 +1548,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
boolean move = !(message.folderReadOnly || message.uid == null);
|
||||
boolean archive = (move && (hasArchive && !inArchive));
|
||||
boolean trash = (move || outbox || debug);
|
||||
boolean trash = (move || outbox || debug ||
|
||||
message.accountProtocol == EntityAccount.TYPE_POP);
|
||||
boolean junk = (move && (hasJunk && !inJunk));
|
||||
boolean unjunk = (move && inJunk);
|
||||
|
||||
final boolean delete = (inTrash || !hasTrash || outbox || message.uid == null);
|
||||
final boolean delete = (inTrash || !hasTrash || outbox ||
|
||||
message.uid == null || message.accountProtocol == EntityAccount.TYPE_POP);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean button_archive_trash = prefs.getBoolean("button_archive_trash", true);
|
||||
|
|
|
@ -1050,15 +1050,53 @@ class Core {
|
|||
try {
|
||||
ifolder.close(true);
|
||||
ifolder.open(Folder.READ_WRITE);
|
||||
db.message().deleteMessage(folder.id, message.id);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
state.error(new FolderClosedException(ifolder, "POP"));
|
||||
}
|
||||
else
|
||||
db.message().deleteMessage(folder.id, message.id);
|
||||
} else {
|
||||
if (!EntityFolder.INBOX.equals(folder.type))
|
||||
db.message().deleteMessage(folder.id, message.id);
|
||||
}
|
||||
|
||||
} else
|
||||
db.message().deleteMessage(folder.id, message.id);
|
||||
if (!EntityFolder.TRASH.equals(folder.type)) {
|
||||
EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
|
||||
if (trash == null) {
|
||||
trash = new EntityFolder();
|
||||
trash.account = account.id;
|
||||
trash.name = context.getString(R.string.title_folder_trash);
|
||||
trash.type = EntityFolder.TRASH;
|
||||
trash.synchronize = false;
|
||||
trash.unified = false;
|
||||
trash.notify = false;
|
||||
trash.sync_days = Integer.MAX_VALUE;
|
||||
trash.keep_days = Integer.MAX_VALUE;
|
||||
trash.initialize = 0;
|
||||
trash.id = db.folder().insertFolder(trash);
|
||||
}
|
||||
|
||||
long id = message.id;
|
||||
|
||||
message.id = null;
|
||||
message.folder = trash.id;
|
||||
message.msgid = null;
|
||||
message.ui_hide = false;
|
||||
message.ui_seen = true;
|
||||
message.id = db.message().insertMessage(message);
|
||||
|
||||
try {
|
||||
File source = EntityMessage.getFile(context, id);
|
||||
File target = message.getFile(context);
|
||||
Helper.copy(source, target);
|
||||
} catch (IOException ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
|
||||
EntityAttachment.copy(context, id, message.id);
|
||||
}
|
||||
}
|
||||
|
||||
private static void onHeaders(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException {
|
||||
|
|
|
@ -104,7 +104,6 @@ public interface DaoAccount {
|
|||
@Query("SELECT account.id" +
|
||||
", account.swipe_left, l.type AS left_type, l.name AS left_name, l.color AS left_color" +
|
||||
", account.swipe_right, r.type AS right_type, r.name AS right_name, r.color AS right_color" +
|
||||
", account.leave_deleted" +
|
||||
" FROM account" +
|
||||
" LEFT JOIN folder l ON l.id = account.swipe_left" +
|
||||
" LEFT JOIN folder r ON r.id = account.swipe_right" +
|
||||
|
|
|
@ -1690,15 +1690,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
if (message.accountProtocol != EntityAccount.TYPE_IMAP) {
|
||||
swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN;
|
||||
if (swipes.leave_deleted) {
|
||||
if (message.ui_snoozed != null && message.ui_snoozed == Long.MAX_VALUE)
|
||||
swipes.swipe_left = FragmentAccount.SWIPE_ACTION_HIDE; // show
|
||||
else {
|
||||
swipes.swipe_left = 0L;
|
||||
swipes.left_type = EntityFolder.TRASH; // hide
|
||||
}
|
||||
} else
|
||||
swipes.swipe_left = FragmentAccount.SWIPE_ACTION_DELETE;
|
||||
swipes.swipe_left = FragmentAccount.SWIPE_ACTION_DELETE;
|
||||
}
|
||||
|
||||
Long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left);
|
||||
|
@ -1791,12 +1783,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
if (message.accountProtocol != EntityAccount.TYPE_IMAP) {
|
||||
if (direction == ItemTouchHelper.LEFT) {
|
||||
if (swipes.leave_deleted)
|
||||
onActionHide(message);
|
||||
else {
|
||||
adapter.notifyItemChanged(pos);
|
||||
onSwipeDelete(message);
|
||||
}
|
||||
adapter.notifyItemChanged(pos);
|
||||
onSwipeDelete(message);
|
||||
} else
|
||||
onActionSeenSelection(!message.ui_seen, message.id);
|
||||
return;
|
||||
|
@ -4174,7 +4162,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
|
||||
return new Boolean[]{
|
||||
trash == null,
|
||||
trash == null || account.protocol == EntityAccount.TYPE_POP,
|
||||
trashable,
|
||||
snoozable,
|
||||
archivable && archive != null};
|
||||
|
|
|
@ -454,6 +454,21 @@ public class FragmentPop extends FragmentBase {
|
|||
sent.id = db.folder().insertFolder(sent);
|
||||
}
|
||||
|
||||
EntityFolder trash = db.folder().getFolderByType(account.id, EntityFolder.TRASH);
|
||||
if (trash == null) {
|
||||
trash = new EntityFolder();
|
||||
trash.account = account.id;
|
||||
trash.name = context.getString(R.string.title_folder_trash);
|
||||
trash.type = EntityFolder.TRASH;
|
||||
trash.synchronize = false;
|
||||
trash.unified = false;
|
||||
trash.notify = false;
|
||||
trash.sync_days = Integer.MAX_VALUE;
|
||||
trash.keep_days = Integer.MAX_VALUE;
|
||||
trash.initialize = 0;
|
||||
trash.id = db.folder().insertFolder(trash);
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
|
|
|
@ -29,5 +29,4 @@ public class TupleAccountSwipes {
|
|||
public String right_type;
|
||||
public String right_name;
|
||||
public Integer right_color;
|
||||
public Boolean leave_deleted;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue