fix primary color usages

This commit is contained in:
kosyak 2023-11-13 22:27:05 +01:00
parent 2b4b0b1212
commit abc42647ae
3 changed files with 15 additions and 7 deletions

View file

@ -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() {

View file

@ -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();

View file

@ -81,7 +81,7 @@
@drawable/message_bubble_received_non_last
</item>
<item name="unread_count">@color/green700_desaturated</item>
<item name="unread_count">?colorPrimaryDark</item>
<item name="conversations_overview_background">@color/green700</item>
@ -247,7 +247,7 @@
@drawable/message_bubble_received_dark_non_last
</item>
<item name="unread_count">@color/green900_desaturated</item>
<item name="unread_count">?colorPrimaryDark</item>
<item name="conversations_overview_background">@color/green900</item>