From 1d6fd71adb66afd32a817a9dc485ecf48b321ec9 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Thu, 10 Sep 2020 12:01:54 +0200 Subject: [PATCH] Make unread-counter for non-notifications a setting Change-Id: I6e097ee4577868b1e82a0cd69bd67122cb57a4d4 --- .../core/resources/UserPreferencesProvider.kt | 4 ++++ .../home/room/list/RoomSummaryController.kt | 2 +- .../features/settings/VectorPreferences.kt | 6 +++++ vector/src/main/res/values-de/strings_sc.xml | 5 +++++ vector/src/main/res/values/strings_sc.xml | 5 +++++ .../res/xml/vector_settings_preferences.xml | 22 ++++++++++++++----- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/resources/UserPreferencesProvider.kt b/vector/src/main/java/im/vector/app/core/resources/UserPreferencesProvider.kt index 302e55d1e7..e8bf7a3c0c 100644 --- a/vector/src/main/java/im/vector/app/core/resources/UserPreferencesProvider.kt +++ b/vector/src/main/java/im/vector/app/core/resources/UserPreferencesProvider.kt @@ -40,4 +40,8 @@ class UserPreferencesProvider @Inject constructor(private val vectorPreferences: fun neverShowLongClickOnRoomHelpAgain() { vectorPreferences.neverShowLongClickOnRoomHelpAgain() } + + fun shouldShowUnimportantCounterBadge(): Boolean { + return vectorPreferences.shouldShowUnimportantCounterBadge() + } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryController.kt index 7648f5fc3b..ec5e764977 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryController.kt @@ -137,7 +137,7 @@ class RoomSummaryController @Inject constructor(private val stringProvider: Stri summaries.map { it.notificationCount }.sumBy { i -> i } } // SC addition - val unreadMessages = if (summaries.isEmpty()) { + val unreadMessages = if (summaries.isEmpty() || !userPreferencesProvider.shouldShowUnimportantCounterBadge()) { 0 } else { // TODO actual sum of events instead of sum of chats? diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 3d94cb4f97..8a2d30e825 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -177,6 +177,7 @@ class VectorPreferences @Inject constructor(private val context: Context) { // SC additions private const val SETTINGS_SINGLE_OVERVIEW = "SETTINGS_SINGLE_OVERVIEW" private const val SETTINGS_ROOM_UNREAD_KIND = "SETTINGS_ROOM_UNREAD_KIND" + private const val SETTINGS_UNIMPORTANT_COUNTER_BADGE = "SETTINGS_UNIMPORTANT_COUNTER_BADGE" private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH" @@ -844,6 +845,11 @@ class VectorPreferences @Inject constructor(private val context: Context) { } } + // SC addition + fun shouldShowUnimportantCounterBadge(): Boolean { + return defaultPrefs.getBoolean(SETTINGS_UNIMPORTANT_COUNTER_BADGE, true) + } + /** * The user enable protecting app access with pin code */ diff --git a/vector/src/main/res/values-de/strings_sc.xml b/vector/src/main/res/values-de/strings_sc.xml index 80a6981811..b6b8e4e65d 100644 --- a/vector/src/main/res/values-de/strings_sc.xml +++ b/vector/src/main/res/values-de/strings_sc.xml @@ -1,6 +1,8 @@ + Übersicht + Vereinte Chat-Übersicht Zeige sowohl Direktnachrichten als auch Gruppenchats in einer gemeinsamen Übersicht @@ -22,6 +24,9 @@ Selbe Seite Beide Seiten + Zähle unwichtige Chat-Ereignisse + Betrachte auch Chats ohne Benachrichtigung beim Zählen der ungelesenen Nachrichten pro Kategorie + SchildiChat Android Übersicht SchildiChat diff --git a/vector/src/main/res/values/strings_sc.xml b/vector/src/main/res/values/strings_sc.xml index 99b6359bbd..5bd06d7cd4 100644 --- a/vector/src/main/res/values/strings_sc.xml +++ b/vector/src/main/res/values/strings_sc.xml @@ -1,6 +1,8 @@ + Overview + Combined chat overview View both direct messages and rooms on one page @@ -22,6 +24,9 @@ Same side Both sides + Count unimportant chat events + Include chats without notifications in the category unread counter + SchildiChat Android Overview SchildiChat diff --git a/vector/src/main/res/xml/vector_settings_preferences.xml b/vector/src/main/res/xml/vector_settings_preferences.xml index d1fdb750e1..fac1e73b89 100644 --- a/vector/src/main/res/xml/vector_settings_preferences.xml +++ b/vector/src/main/res/xml/vector_settings_preferences.xml @@ -39,6 +39,18 @@ android:title="@string/bubble_style" app:iconSpaceReserved="false" /> + + + + + + - +