From 3eb6822035214dcd4e5d1c3b15651c7e8933888a Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 3 Feb 2020 19:25:46 +0100 Subject: [PATCH] Added option to auto reset importance --- .../main/java/eu/faircode/email/DaoMessage.java | 2 +- .../java/eu/faircode/email/EntityOperation.java | 17 ++++++++++++++++- .../faircode/email/FragmentOptionsBehavior.java | 13 ++++++++++++- .../res/layout/fragment_options_behavior.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 9053e80e09..0c8aa3034c 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -301,7 +301,7 @@ public interface DaoMessage { @Query("SELECT * FROM message" + " WHERE account = :account" + - " AND (id = :id OR msgid = :msgid)") + " AND (id = :id OR msgid = :msgid)") List getMessagesBySimilarity(long account, long id, String msgid); @Query("SELECT COUNT(*) FROM message" + diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java index 2575b1d6f9..a0e7880f44 100644 --- a/app/src/main/java/eu/faircode/email/EntityOperation.java +++ b/app/src/main/java/eu/faircode/email/EntityOperation.java @@ -172,6 +172,7 @@ public class EntityOperation { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean autoread = prefs.getBoolean("autoread", false); boolean autounflag = prefs.getBoolean("autounflag", false); + boolean reset_importance = prefs.getBoolean("reset_importance", false); if (jargs.opt(1) != null) // rules autoread = jargs.getBoolean(1); @@ -188,12 +189,14 @@ public class EntityOperation { " target=" + target.id + ":" + target.name + " auto read=" + autoread + " flag=" + autounflag); - if (autoread || autounflag) + if (autoread || autounflag || reset_importance) for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid)) { if (autoread) db.message().setMessageUiSeen(similar.id, true); if (autounflag) db.message().setMessageUiFlagged(similar.id, false, null); + if (reset_importance) + db.message().setMessageImportance(similar.id, null); } @@ -220,8 +223,11 @@ public class EntityOperation { long uid = message.uid; int notifying = message.notifying; boolean fts = message.fts; + Integer importance = message.importance; boolean seen = message.seen; + boolean flagged = message.flagged; boolean ui_seen = message.ui_seen; + boolean ui_flagged = message.ui_flagged; Boolean ui_hide = message.ui_hide; boolean ui_browsed = message.ui_browsed; String error = message.error; @@ -233,10 +239,16 @@ public class EntityOperation { message.uid = null; message.notifying = 0; message.fts = false; + if (reset_importance) + message.importance = null; if (autoread) { message.seen = true; message.ui_seen = true; } + if (autounflag) { + message.flagged = false; + message.ui_flagged = false; + } message.ui_hide = false; message.ui_browsed = false; message.error = null; @@ -252,8 +264,11 @@ public class EntityOperation { message.uid = uid; message.notifying = notifying; message.fts = fts; + message.importance = importance; message.seen = seen; + message.flagged = flagged; message.ui_seen = ui_seen; + message.ui_flagged = ui_flagged; message.ui_hide = ui_hide; message.ui_browsed = ui_browsed; message.error = error; diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java index 5672e11ce8..4e15c5d33d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java @@ -58,6 +58,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe private SwitchCompat swCollapseMultiple; private SwitchCompat swAutoRead; private SwitchCompat swAutoUnflag; + private SwitchCompat swResetImportance; private SwitchCompat swAutoMove; private SwitchCompat swDiscardDelete; private NumberPicker npDefaultSnooze; @@ -65,7 +66,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe private final static String[] RESET_OPTIONS = new String[]{ "double_back", "pull", "autoscroll", "doubletap", "swipenav", "volumenav", "reversed", "autoexpand", "expand_all", "expand_one", "collapse_multiple", - "autoclose", "onclose", "quick_filter", "quick_scroll", "autoread", "autounflag", "automove", "discard_delete", + "autoclose", "onclose", "quick_filter", "quick_scroll", + "autoread", "autounflag", "reset_importance", "automove", "discard_delete", "default_snooze" }; @@ -96,6 +98,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swQuickScroll = view.findViewById(R.id.swQuickScroll); swAutoRead = view.findViewById(R.id.swAutoRead); swAutoUnflag = view.findViewById(R.id.swAutoUnflag); + swResetImportance = view.findViewById(R.id.swResetImportance); swAutoMove = view.findViewById(R.id.swAutoMove); swDiscardDelete = view.findViewById(R.id.swDiscardDelete); npDefaultSnooze = view.findViewById(R.id.npDefaultSnooze); @@ -242,6 +245,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe } }); + swResetImportance.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("reset_importance", checked).apply(); + } + }); + swAutoMove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -341,6 +351,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swAutoRead.setChecked(prefs.getBoolean("autoread", false)); swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false)); + swResetImportance.setChecked(prefs.getBoolean("reset_importance", false)); swAutoMove.setChecked(!prefs.getBoolean("automove", false)); swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false)); diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index 679d8edc53..4c58211adb 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -254,6 +254,17 @@ app:layout_constraintTop_toBottomOf="@id/swAutoRead" app:switchPadding="12dp" /> + + Show non-obtrusive quick scroll up/down icons Automatically mark messages read on moving messages Automatically remove stars from messages on moving messages + Reset importance on moving messages Confirm moving messages On discard draft permanently delete draft Default snooze time