Added option to ask what to do on swipe

pull/157/head
M66B 6 years ago
parent 8ba11789b3
commit 851ead228c

@ -743,8 +743,10 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
// Forward referenced
Long swipe_left = account.swipe_left;
Long swipe_right = account.swipe_right;
account.swipe_left = null;
account.swipe_right = null;
if (account.swipe_left != null && account.swipe_left > 0)
account.swipe_left = null;
if (account.swipe_right != null && account.swipe_right > 0)
account.swipe_right = null;
account.created = new Date().getTime();
account.id = db.account().insertAccount(account);

@ -91,7 +91,7 @@ public interface DaoAccount {
" WHERE account.synchronize) AS operations")
LiveData<TupleAccountStats> liveStats();
@Query("SELECT account.id, l.id AS swipe_left, l.type AS left_type, r.id AS swipe_right, r.type AS right_type" +
@Query("SELECT account.id, account.swipe_left, l.type AS left_type, account.swipe_right, r.type AS right_type" +
" FROM account" +
" LEFT JOIN folder l ON l.id = account.swipe_left" +
" LEFT JOIN folder r ON r.id = account.swipe_right")

@ -119,6 +119,8 @@ public class FragmentAccount extends FragmentBase {
private Spinner spArchive;
private Spinner spTrash;
private Spinner spJunk;
private ArrayAdapter<EntityFolder> adapterSwipe;
private Spinner spLeft;
private Spinner spRight;
@ -371,8 +373,12 @@ public class FragmentAccount extends FragmentBase {
spArchive.setAdapter(adapter);
spTrash.setAdapter(adapter);
spJunk.setAdapter(adapter);
spLeft.setAdapter(adapter);
spRight.setAdapter(adapter);
adapterSwipe = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, new ArrayList<EntityFolder>());
adapterSwipe.setDropDownViewResource(R.layout.spinner_item1_dropdown);
spLeft.setAdapter(adapterSwipe);
spRight.setAdapter(adapterSwipe);
addBackPressedListener(new ActivityBase.IBackPressedListener() {
@Override
@ -654,19 +660,20 @@ public class FragmentAccount extends FragmentBase {
EntityFolder left = (EntityFolder) spLeft.getSelectedItem();
EntityFolder right = (EntityFolder) spRight.getSelectedItem();
if (drafts != null && drafts.type == null)
if (drafts != null && drafts.id == 0L)
drafts = null;
if (sent != null && sent.type == null)
if (sent != null && sent.id == 0L)
sent = null;
if (archive != null && archive.type == null)
if (archive != null && archive.id == 0L)
archive = null;
if (trash != null && trash.type == null)
if (trash != null && trash.id == 0L)
trash = null;
if (junk != null && junk.type == null)
if (junk != null && junk.id == 0L)
junk = null;
if (left != null && left.type == null)
if (left != null && left.id == 0L)
left = null;
if (right != null && right.type == null)
if (right != null && right.id == 0L)
right = null;
Bundle args = new Bundle();
@ -828,9 +835,9 @@ public class FragmentAccount extends FragmentBase {
if (!Objects.equals(ejunk == null ? null : ejunk.id, junk == null ? null : junk.id))
return true;
if (!Objects.equals(account.swipe_left, left == null ? null : left.id == null ? -1L : left.id))
if (!Objects.equals(account.swipe_left, left == null ? null : left.id))
return true;
if (!Objects.equals(account.swipe_right, right == null ? null : right.id == null ? -1L : right.id))
if (!Objects.equals(account.swipe_right, right == null ? null : right.id))
return true;
if (account.error != null)
@ -973,7 +980,7 @@ public class FragmentAccount extends FragmentBase {
folders.add(junk);
}
if (left != null) {
if (left != null && left.id > 0) {
boolean found = false;
for (EntityFolder folder : folders)
if (left.name.equals(folder.name)) {
@ -986,7 +993,7 @@ public class FragmentAccount extends FragmentBase {
}
}
if (right != null) {
if (right != null && right.id > 0) {
boolean found = false;
for (EntityFolder folder : folders)
if (right.name.equals(folder.name)) {
@ -1323,24 +1330,13 @@ public class FragmentAccount extends FragmentBase {
folders.add(folder);
EntityFolder none = new EntityFolder();
none.id = -1L;
none.id = 0L;
none.name = "-";
folders.add(0, none);
adapter.clear();
adapter.addAll(folders);
Long left = (account == null ? null : account.swipe_left);
Long right = (account == null ? null : account.swipe_right);
String leftDefault = EntityFolder.TRASH;
String rightDefault = EntityFolder.TRASH;
for (EntityFolder folder : folders)
if (EntityFolder.ARCHIVE.equals(folder.type)) {
rightDefault = folder.type;
break;
}
for (int pos = 0; pos < folders.size(); pos++) {
EntityFolder folder = folders.get(pos);
@ -1354,6 +1350,29 @@ public class FragmentAccount extends FragmentBase {
spTrash.setSelection(pos);
else if (EntityFolder.JUNK.equals(folder.type))
spJunk.setSelection(pos);
}
EntityFolder ask = new EntityFolder();
ask.id = -1L;
ask.name = getString(R.string.title_ask_what);
folders.add(1, ask);
adapterSwipe.clear();
adapterSwipe.addAll(folders);
Long left = (account == null ? null : account.swipe_left);
Long right = (account == null ? null : account.swipe_right);
String leftDefault = EntityFolder.TRASH;
String rightDefault = EntityFolder.TRASH;
for (EntityFolder folder : folders)
if (EntityFolder.ARCHIVE.equals(folder.type)) {
rightDefault = folder.type;
break;
}
for (int pos = 0; pos < folders.size(); pos++) {
EntityFolder folder = folders.get(pos);
if (left == null ? (account == null && leftDefault.equals(folder.type)) : left.equals(folder.id))
spLeft.setSelection(pos);

@ -1120,9 +1120,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return 0;
int flags = 0;
if (swipes.swipe_left == null || !swipes.swipe_left.equals(message.folder))
if (swipes.swipe_left != null &&
(swipes.swipe_left < 0 || !swipes.swipe_left.equals(message.folder)))
flags |= ItemTouchHelper.LEFT;
if (swipes.swipe_right == null || !swipes.swipe_right.equals(message.folder))
if (swipes.swipe_right != null &&
(swipes.swipe_right < 0 || !swipes.swipe_right.equals(message.folder)))
flags |= ItemTouchHelper.RIGHT;
return makeMovementFlags(0, flags);
@ -1213,7 +1215,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Log.i("Swiped dir=" + direction + " message=" + message.id);
if (direction == ItemTouchHelper.LEFT ? swipes.swipe_left == null : swipes.swipe_right == null) {
if (direction == ItemTouchHelper.LEFT ? swipes.swipe_left < 0 : swipes.swipe_right < 0) {
adapter.notifyItemChanged(viewHolder.getAdapterPosition());
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), viewHolder.itemView);

@ -707,6 +707,7 @@
<string name="title_report">Report</string>
<string name="title_fix">Fix</string>
<string name="title_enable">Enable</string>
<string name="title_ask_what">Ask what to do</string>
<string name="title_no_ask_again">Do not ask this again</string>
<string name="title_no_body">No message text found</string>
<string name="title_no_charset">Unsupported encoding: %1$s</string>

Loading…
Cancel
Save