Swipe to permanently delete

pull/164/head
M66B 5 years ago
parent 4765209dd5
commit d66f9dc967

@ -1375,11 +1375,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
int flags = 0; int flags = 0;
if (swipes.swipe_left != null && if (swipes.swipe_left != null &&
(swipes.swipe_left < 0 || (swipes.swipe_left < 0 ||
(swipes.left_type != null && !swipes.swipe_left.equals(message.folder)))) (swipes.swipe_left.equals(message.folder)
? EntityFolder.TRASH.equals(swipes.left_type) : swipes.left_type != null)))
flags |= ItemTouchHelper.LEFT; flags |= ItemTouchHelper.LEFT;
if (swipes.swipe_right != null && if (swipes.swipe_right != null &&
(swipes.swipe_right < 0 || (swipes.swipe_right < 0 ||
(swipes.right_type != null && !swipes.swipe_right.equals(message.folder)))) (swipes.swipe_right.equals(message.folder)
? EntityFolder.TRASH.equals(swipes.right_type) : swipes.right_type != null)))
flags |= ItemTouchHelper.RIGHT; flags |= ItemTouchHelper.RIGHT;
return makeMovementFlags(0, flags); return makeMovementFlags(0, flags);
@ -1515,6 +1517,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
else if (FragmentAccount.SWIPE_ACTION_MOVE.equals(action)) { else if (FragmentAccount.SWIPE_ACTION_MOVE.equals(action)) {
adapter.notifyItemChanged(pos); adapter.notifyItemChanged(pos);
onSwipeMove(message); onSwipeMove(message);
} else if (action.equals(message.folder) && EntityFolder.TRASH.equals(message.folderType)) {
adapter.notifyItemChanged(pos);
onSwipeDelete(message);
} else } else
swipeFolder(message, action); swipeFolder(message, action);
} }
@ -1636,6 +1641,17 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fragment.show(getParentFragmentManager(), "message:move"); fragment.show(getParentFragmentManager(), "message:move");
} }
private void onSwipeDelete(@NonNull TupleMessageEx message) {
Bundle args = new Bundle();
args.putString("question", getString(R.string.title_ask_delete));
args.putLong("id", message.id);
FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(args);
ask.setTargetFragment(FragmentMessages.this, FragmentMessages.REQUEST_MESSAGE_DELETE);
ask.show(getParentFragmentManager(), "message:delete");
}
private void swipeFolder(@NonNull TupleMessageEx message, @NonNull Long target) { private void swipeFolder(@NonNull TupleMessageEx message, @NonNull Long target) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", message.id); args.putLong("id", message.id);

Loading…
Cancel
Save