use onSurface as link color

This commit is contained in:
Daniel Gultsch 2024-04-29 08:26:25 +02:00
parent 8856c048d6
commit 073a445a6d
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -79,6 +79,8 @@ import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.mam.MamReference; import eu.siacs.conversations.xmpp.mam.MamReference;
import java.net.URI; import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -565,10 +567,10 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} }
StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor()); StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor());
MyLinkify.addLinks(body, true);
if (highlightedTerm != null) { if (highlightedTerm != null) {
StylingHelper.highlight(viewHolder.messageBody, body, highlightedTerm); StylingHelper.highlight(viewHolder.messageBody, body, highlightedTerm);
} }
MyLinkify.addLinks(body, true);
viewHolder.messageBody.setAutoLinkMask(0); viewHolder.messageBody.setAutoLinkMask(0);
viewHolder.messageBody.setText(body); viewHolder.messageBody.setText(body);
viewHolder.messageBody.setMovementMethod(ClickableMovementMethod.getInstance()); viewHolder.messageBody.setMovementMethod(ClickableMovementMethod.getInstance());
@ -1169,7 +1171,15 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} }
public static void setTextColor(final TextView textView, final BubbleColor bubbleColor) { 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) { private static void setTextSize(final TextView textView, final boolean largeFont) {
@ -1185,7 +1195,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
private static @ColorInt int bubbleToOnSurfaceVariant( private static @ColorInt int bubbleToOnSurfaceVariant(
final View view, final BubbleColor bubbleColor) { final View view, final BubbleColor bubbleColor) {
final @AttrRes int colorAttributeResId; 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; colorAttributeResId = com.google.android.material.R.attr.colorOnSurfaceVariant;
} else { } else {
colorAttributeResId = bubbleToOnSurface(bubbleColor); colorAttributeResId = bubbleToOnSurface(bubbleColor);
@ -1219,7 +1229,10 @@ public class MessageAdapter extends ArrayAdapter<Message> {
PRIMARY, PRIMARY,
SECONDARY, SECONDARY,
TERTIARY, TERTIARY,
WARNING WARNING;
private static final Collection<BubbleColor> SURFACES =
Arrays.asList(BubbleColor.SURFACE, BubbleColor.SURFACE_HIGH);
} }
private static class BubbleDesign { private static class BubbleDesign {