From 5957daf956ae4fb4689be9d98b9312b67276b06b Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 8 Oct 2022 17:46:25 +0200 Subject: [PATCH] Allow to disable counters in settings --- .../java/app/fedilab/android/BaseMainActivity.java | 12 ++++++++++++ app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_interface.xml | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index cabfd5aa3..0588dd117 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -1103,6 +1103,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt public void onUpdateConversation(int count) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); + boolean displayCounters = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_COUNTERS), true); + if (!displayCounters) { + return; + } if (!singleBar) { if (count > 0) { binding.bottomNavView.getOrCreateBadge(R.id.nav_privates).setNumber(count); @@ -1119,6 +1123,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt public void onUpdateNotification(int count) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); + boolean displayCounters = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_COUNTERS), true); + if (!displayCounters) { + return; + } if (!singleBar) { if (count > 0) { binding.bottomNavView.getOrCreateBadge(R.id.nav_notifications).setNumber(count); @@ -1178,6 +1186,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt @Override public void onUpdate(int count, Timeline.TimeLineEnum type, String slug) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); + boolean displayCounters = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_COUNTERS), true); + if (!displayCounters) { + return; + } boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); if (!singleBar) { switch (type) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d2178f1e2..94b9396c5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -888,6 +888,7 @@ SET_LONG_PRESS_STORE_MEDIA SET_UNFOLLOW_VALIDATION SET_USE_SINGLE_TOPBAR + SET_DISPLAY_COUNTERS SET_TIMELINES_IN_A_LIST SET_DISPLAY_ADMIN_STATUSES SET_LED_COLOUR_VAL @@ -1475,4 +1476,6 @@ Reply Display options Fetch notifications + Display counters + Will display a bubble counter in tab timelines for new messages diff --git a/app/src/main/res/xml/pref_interface.xml b/app/src/main/res/xml/pref_interface.xml index e8bf5c20a..1691ff1d2 100644 --- a/app/src/main/res/xml/pref_interface.xml +++ b/app/src/main/res/xml/pref_interface.xml @@ -28,6 +28,13 @@ app:summary="@string/set_unfollow_validation" app:title="@string/set_unfollow_validation_title" /> +