From 073a445a6dedb96f5bc88f4e4cb4812701eaf07f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 29 Apr 2024 08:26:25 +0200 Subject: [PATCH] use onSurface as link color --- .../ui/adapter/MessageAdapter.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 f3cba4f3d..c33e77655 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -79,6 +79,8 @@ import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.mam.MamReference; import java.net.URI; +import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; @@ -565,10 +567,10 @@ public class MessageAdapter extends ArrayAdapter { } StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor()); + MyLinkify.addLinks(body, true); if (highlightedTerm != null) { StylingHelper.highlight(viewHolder.messageBody, body, highlightedTerm); } - MyLinkify.addLinks(body, true); viewHolder.messageBody.setAutoLinkMask(0); viewHolder.messageBody.setText(body); viewHolder.messageBody.setMovementMethod(ClickableMovementMethod.getInstance()); @@ -1169,7 +1171,15 @@ public class MessageAdapter extends ArrayAdapter { } public static void setTextColor(final TextView textView, final BubbleColor bubbleColor) { - textView.setTextColor(bubbleToOnSurfaceColor(textView, bubbleColor)); + final var color = bubbleToOnSurfaceColor(textView, bubbleColor); + textView.setTextColor(color); + if (BubbleColor.SURFACES.contains(bubbleColor)) { + textView.setLinkTextColor( + MaterialColors.getColor( + textView, com.google.android.material.R.attr.colorPrimary)); + } else { + textView.setLinkTextColor(color); + } } private static void setTextSize(final TextView textView, final boolean largeFont) { @@ -1185,7 +1195,7 @@ public class MessageAdapter extends ArrayAdapter { private static @ColorInt int bubbleToOnSurfaceVariant( final View view, final BubbleColor bubbleColor) { final @AttrRes int colorAttributeResId; - if (bubbleColor == BubbleColor.SURFACE_HIGH || bubbleColor == BubbleColor.SURFACE) { + if (BubbleColor.SURFACES.contains(bubbleColor)) { colorAttributeResId = com.google.android.material.R.attr.colorOnSurfaceVariant; } else { colorAttributeResId = bubbleToOnSurface(bubbleColor); @@ -1219,7 +1229,10 @@ public class MessageAdapter extends ArrayAdapter { PRIMARY, SECONDARY, TERTIARY, - WARNING + WARNING; + + private static final Collection SURFACES = + Arrays.asList(BubbleColor.SURFACE, BubbleColor.SURFACE_HIGH); } private static class BubbleDesign {