Added POP3 trash folder

pull/178/head
M66B 5 years ago
parent ed40991e3c
commit b637453ca7

@ -1548,11 +1548,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean move = !(message.folderReadOnly || message.uid == null); boolean move = !(message.folderReadOnly || message.uid == null);
boolean archive = (move && (hasArchive && !inArchive)); 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 junk = (move && (hasJunk && !inJunk));
boolean unjunk = (move && 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); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean button_archive_trash = prefs.getBoolean("button_archive_trash", true); boolean button_archive_trash = prefs.getBoolean("button_archive_trash", true);

@ -1050,15 +1050,53 @@ class Core {
try { try {
ifolder.close(true); ifolder.close(true);
ifolder.open(Folder.READ_WRITE); ifolder.open(Folder.READ_WRITE);
db.message().deleteMessage(folder.id, message.id);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
state.error(new FolderClosedException(ifolder, "POP")); state.error(new FolderClosedException(ifolder, "POP"));
} }
else else
db.message().deleteMessage(folder.id, message.id); db.message().deleteMessage(folder.id, message.id);
} else {
if (!EntityFolder.INBOX.equals(folder.type))
db.message().deleteMessage(folder.id, message.id);
}
} else if (!EntityFolder.TRASH.equals(folder.type)) {
db.message().deleteMessage(folder.id, message.id); 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 { 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" + @Query("SELECT account.id" +
", account.swipe_left, l.type AS left_type, l.name AS left_name, l.color AS left_color" + ", 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.swipe_right, r.type AS right_type, r.name AS right_name, r.color AS right_color" +
", account.leave_deleted" +
" FROM account" + " FROM account" +
" LEFT JOIN folder l ON l.id = account.swipe_left" + " LEFT JOIN folder l ON l.id = account.swipe_left" +
" LEFT JOIN folder r ON r.id = account.swipe_right" + " 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) { if (message.accountProtocol != EntityAccount.TYPE_IMAP) {
swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN; swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN;
if (swipes.leave_deleted) { swipes.swipe_left = FragmentAccount.SWIPE_ACTION_DELETE;
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;
} }
Long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left); 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 (message.accountProtocol != EntityAccount.TYPE_IMAP) {
if (direction == ItemTouchHelper.LEFT) { if (direction == ItemTouchHelper.LEFT) {
if (swipes.leave_deleted) adapter.notifyItemChanged(pos);
onActionHide(message); onSwipeDelete(message);
else {
adapter.notifyItemChanged(pos);
onSwipeDelete(message);
}
} else } else
onActionSeenSelection(!message.ui_seen, message.id); onActionSeenSelection(!message.ui_seen, message.id);
return; return;
@ -4174,7 +4162,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
return new Boolean[]{ return new Boolean[]{
trash == null, trash == null || account.protocol == EntityAccount.TYPE_POP,
trashable, trashable,
snoozable, snoozable,
archivable && archive != null}; archivable && archive != null};

@ -454,6 +454,21 @@ public class FragmentPop extends FragmentBase {
sent.id = db.folder().insertFolder(sent); 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(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();

@ -29,5 +29,4 @@ public class TupleAccountSwipes {
public String right_type; public String right_type;
public String right_name; public String right_name;
public Integer right_color; public Integer right_color;
public Boolean leave_deleted;
} }

Loading…
Cancel
Save