Added option to remove notifications on viewing message list

pull/164/head
M66B 5 years ago
parent 033a60b311
commit 0515c1b2cf

@ -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" +

@ -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

@ -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));

@ -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);
}

@ -82,6 +82,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyRemove" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyClear"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_notify_clear"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyRemoveHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="0dp"
@ -91,7 +103,7 @@
android:text="@string/title_advanced_notify_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyRemoveHint"
app:layout_constraintTop_toBottomOf="@id/swNotifyClear"
app:switchPadding="12dp" />
<TextView

@ -311,6 +311,7 @@
<string name="title_advanced_notify_action_seen">Read</string>
<string name="title_advanced_notify_action_snooze">Snooze</string>
<string name="title_advanced_notify_remove">Remove new message notification on tapping on notification</string>
<string name="title_advanced_notify_clear">Remove new message notifications on viewing message list</string>
<string name="title_advanced_wearable_preview">Only send notifications with a message preview to wearables</string>
<string name="title_advanced_biometrics_notify">Show notification content when using biometric authentication</string>
<string name="title_advanced_light">Use notification light</string>

Loading…
Cancel
Save