From 1244ee472da44658927eca957daa527807d63229 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 25 Feb 2021 09:12:18 +0100 Subject: [PATCH] Clear badge count --- .../eu/faircode/email/FragmentOptionsNotifications.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index 09917306bb..008a03f2d0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -51,6 +51,8 @@ import androidx.constraintlayout.widget.Group; import androidx.lifecycle.Lifecycle; import androidx.preference.PreferenceManager; +import me.leolin.shortcutbadger.ShortcutBadger; + import static android.app.Activity.RESULT_OK; public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -331,6 +333,11 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("badge", checked).apply(); + try { + ShortcutBadger.removeCount(compoundButton.getContext()); + } catch (Throwable ex) { + Log.w(ex); + } ServiceSynchronize.restart(compoundButton.getContext()); } });