Added option to remove notifications on viewing message list

This commit is contained in:
M66B
2019-10-27 16:46:57 +01:00
parent 033a60b311
commit 0515c1b2cf
6 changed files with 56 additions and 5 deletions

View File

@@ -479,8 +479,10 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_ignored = 1" +
" WHERE (:account IS NULL OR account = :account)" +
" AND NOT ui_ignored" +
" AND folder IN (SELECT id FROM folder WHERE folder.unified)")
int ignoreAll(Long account);
" AND folder IN (" +
" SELECT id FROM folder" +
" WHERE (:folder IS NULL AND folder.unified) OR id = :folder)")
int ignoreAll(Long account, Long folder);
@Query("UPDATE message SET ui_found = 1" +
" WHERE account = :account" +

View File

@@ -2444,6 +2444,32 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
prefs.registerOnSharedPreferenceChangeListener(this);
onSharedPreferenceChanged(prefs, "pro");
if (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER) {
boolean notify_clear = prefs.getBoolean("notify_clear", false);
if (notify_clear) {
Bundle args = new Bundle();
args.putLong("folder", folder);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
Long folder = args.getLong("folder");
if (folder < 0)
folder = null;
DB db = DB.getInstance(context);
db.message().ignoreAll(null, folder);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "messages:ignore");
}
}
}
@Override

View File

@@ -55,6 +55,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swUnseenIgnored;
private SwitchCompat swNotifySummary;
private SwitchCompat swNotifyRemove;
private SwitchCompat swNotifyClear;
private SwitchCompat swNotifyPreview;
private SwitchCompat swWearablePreview;
private CheckBox cbNotifyActionTrash;
@@ -81,7 +82,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private final static String[] RESET_OPTIONS = new String[]{
"badge", "unseen_ignored",
"notify_summary", "notify_remove", "notify_preview", "wearable_preview",
"notify_summary", "notify_remove", "notify_clear", "notify_preview", "wearable_preview",
"notify_trash", "notify_junk", "notify_archive", "notify_move",
"notify_reply", "notify_reply_direct",
"notify_flag", "notify_seen", "notify_snooze",
@@ -103,6 +104,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored);
swNotifySummary = view.findViewById(R.id.swNotifySummary);
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
swNotifyClear = view.findViewById(R.id.swNotifyClear);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swWearablePreview = view.findViewById(R.id.swWearablePreview);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
@@ -165,6 +167,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swNotifyClear.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_clear", checked).apply();
}
});
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -363,6 +372,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false));
swNotifySummary.setChecked(prefs.getBoolean("notify_summary", false));
swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true));
swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", true));

View File

@@ -161,7 +161,7 @@ public class ServiceUI extends IntentService {
private void onClear(long group) {
DB db = DB.getInstance(this);
int cleared = db.message().ignoreAll(group == 0 ? null : group);
int cleared = db.message().ignoreAll(group == 0 ? null : group, null);
Log.i("Cleared=" + cleared);
}