From abc42647aedc42b3c2d092797c683218f0cdaf2a Mon Sep 17 00:00:00 2001 From: kosyak Date: Mon, 13 Nov 2023 22:27:05 +0100 Subject: [PATCH] fix primary color usages --- .../conversations/services/NotificationService.java | 5 ++++- .../eu/siacs/conversations/utils/ThemeHelper.java | 13 +++++++++---- src/main/res/values/themes.xml | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index cbaecf444..c261f5219 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -36,6 +36,7 @@ import androidx.core.app.RemoteInput; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.IconCompat; +import com.google.android.material.color.MaterialColors; import com.google.common.base.Joiner; import com.google.common.base.Strings; import com.google.common.collect.Iterables; @@ -74,6 +75,7 @@ import eu.siacs.conversations.ui.TimePreference; import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.Compatibility; import eu.siacs.conversations.utils.GeoHelper; +import eu.siacs.conversations.utils.ThemeHelper; import eu.siacs.conversations.utils.TorServiceUtils; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xmpp.XmppConnection; @@ -805,7 +807,8 @@ public class NotificationService { } private void setNotificationColor(final Builder mBuilder) { - mBuilder.setColor(ContextCompat.getColor(mXmppConnectionService, R.color.green600)); + Integer primaryColorOverride = ThemeHelper.getOverriddenPrimaryColor(mXmppConnectionService); + mBuilder.setColor(primaryColorOverride == null ? ContextCompat.getColor(mXmppConnectionService, R.color.green600) : primaryColorOverride); } public void updateNotification() { diff --git a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java index 28a3716bd..8a141a507 100644 --- a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java @@ -51,10 +51,6 @@ import eu.siacs.conversations.R; import eu.siacs.conversations.ui.SettingsActivity; public class ThemeHelper { - - @ColorInt - private static Integer currentColorOverride = null; - public static int find(final Context context) { final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); final Resources resources = context.getResources(); @@ -110,6 +106,15 @@ public class ThemeHelper { } } + @Nullable + @ColorInt + public static Integer getOverriddenPrimaryColor(final Context context) { + final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + int currentColorOverride = sharedPreferences.getInt(SettingsActivity.THEME_OVERRIDE_COLOR, -1); + + return currentColorOverride == -1 ? null : currentColorOverride; + } + public static int findDialog(Context context) { final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); final Resources resources = context.getResources(); diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 15c3eba92..61bc266ce 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -81,7 +81,7 @@ @drawable/message_bubble_received_non_last - @color/green700_desaturated + ?colorPrimaryDark @color/green700 @@ -247,7 +247,7 @@ @drawable/message_bubble_received_dark_non_last - @color/green900_desaturated + ?colorPrimaryDark @color/green900