From a869d634f7716c406e9d301da3af6128f789d979 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 6 Mar 2021 21:51:19 +0100 Subject: [PATCH] improve background for colored nick names --- .../ui/adapter/MessageAdapter.java | 2 +- .../conversations/utils/ThemeHelper.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 13eb857f1..26314064b 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -298,7 +298,7 @@ public class MessageAdapter extends ArrayAdapter { final int shadowSize = 10; viewHolder.username.setVisibility(View.VISIBLE); viewHolder.username.setText(UIHelper.getColoredUsername(activity.xmppConnectionService, message)); - if (activity.xmppConnectionService.colored_muc_names()) { + if (activity.xmppConnectionService.colored_muc_names() && ThemeHelper.showColoredUsernameBackGround(activity, darkBackground)) { viewHolder.username.setPadding(4, 2, 4, 2); viewHolder.username.setBackground(ContextCompat.getDrawable(activity, R.drawable.duration_background)); } diff --git a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java index 41d91fc48..393bb9816 100644 --- a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java @@ -540,4 +540,24 @@ public class ThemeHelper { } } } + + public static boolean showColoredUsernameBackGround(Context context, boolean dark) { + final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + final Resources resources = context.getResources(); + final String themeColor = sharedPreferences.getString("theme_color", resources.getString(R.string.theme_color)); + switch (themeColor) { + case "blue": + return dark ? false : false; + case "blabber": + return dark ? true : false; + case "orange": + return dark ? true : false; + case "grey": + return dark ? false : false; + case "pink": + return dark ? true : false; + default: + return dark ? true : false; + } + } } \ No newline at end of file