From e210b19c4a4a5b1ca647058283308446d00b03ec Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 17 Sep 2019 12:07:14 +0200 Subject: [PATCH] Added option to leave new message notifications --- .../email/FragmentOptionsNotifications.java | 13 ++++++++- .../java/eu/faircode/email/ServiceUI.java | 5 ++++ .../layout/fragment_options_notifications.xml | 27 ++++++++++++++++++- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index c0eee34c1f..c5508ef702 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -61,6 +61,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private CheckBox cbNotifyActionFlag; private CheckBox cbNotifyActionSeen; private TextView tvNotifyActionsPro; + private SwitchCompat swNotifyRemove; private SwitchCompat swBiometricsNotify; private Button btnManage; private TextView tvManageHint; @@ -73,7 +74,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private final static String[] RESET_OPTIONS = new String[]{ "badge", "unseen_ignored", - "notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_reply_direct", "notify_flag", "notify_seen", "biometrics_notify", + "notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_reply_direct", "notify_flag", "notify_seen", "notify_remove", + "biometrics_notify", "light", "sound", "alert_once" }; @@ -97,6 +99,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared cbNotifyActionFlag = view.findViewById(R.id.cbNotifyActionFlag); cbNotifyActionSeen = view.findViewById(R.id.cbNotifyActionSeen); tvNotifyActionsPro = view.findViewById(R.id.tvNotifyActionsPro); + swNotifyRemove = view.findViewById(R.id.swNotifyRemove); swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify); btnManage = view.findViewById(R.id.btnManage); tvManageHint = view.findViewById(R.id.tvManageHint); @@ -181,6 +184,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared Helper.linkPro(tvNotifyActionsPro); + swNotifyRemove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("notify_remove", checked).apply(); + } + }); + swBiometricsNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -306,6 +316,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared cbNotifyActionFlag.setEnabled(pro); cbNotifyActionSeen.setEnabled(pro); + swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true)); swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false)); swLight.setChecked(prefs.getBoolean("light", false)); diff --git a/app/src/main/java/eu/faircode/email/ServiceUI.java b/app/src/main/java/eu/faircode/email/ServiceUI.java index a893d8b540..e4621c0e68 100644 --- a/app/src/main/java/eu/faircode/email/ServiceUI.java +++ b/app/src/main/java/eu/faircode/email/ServiceUI.java @@ -293,6 +293,11 @@ public class ServiceUI extends IntentService { } private void onIgnore(long id) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + boolean notify_remove = prefs.getBoolean("notify_remove", true); + if (!notify_remove) + return; + DB db = DB.getInstance(this); try { db.beginTransaction(); diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml index dc320c2bc8..082e516095 100644 --- a/app/src/main/res/layout/fragment_options_notifications.xml +++ b/app/src/main/res/layout/fragment_options_notifications.xml @@ -162,6 +162,31 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsHint" /> + + + +