From 74697b0be7e3be8e33a3d38b4c5006110aaba609 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 23 Jun 2021 14:08:17 +1000 Subject: [PATCH] Linkify URLs --- .../securesms/conversation/v2/messages/LinkPreviewView.kt | 3 ++- .../conversation/v2/messages/VisibleMessageContentView.kt | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt index 26c85be8f9..356745328a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt @@ -52,7 +52,8 @@ class LinkPreviewView : LinearLayout { } titleTextView.setTextColor(ResourcesCompat.getColor(resources, textColorID, context.theme)) // Body - mainLinkPreviewContainer.addView(VisibleMessageContentView.getBodyTextView(context, message)) + val bodyTextView = VisibleMessageContentView.getBodyTextView(context, message) + mainLinkPreviewContainer.addView(bodyTextView) } fun recycle() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt index 1fd77eae43..b085171a0d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt @@ -1,7 +1,9 @@ package org.thoughtcrime.securesms.conversation.v2.messages import android.content.Context +import android.content.res.ColorStateList import android.graphics.drawable.Drawable +import android.text.util.Linkify import android.util.AttributeSet import android.util.Log import android.util.TypedValue @@ -132,6 +134,8 @@ class VisibleMessageContentView : LinearLayout { result.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.resources.getDimension(R.dimen.small_font_size)) val color = getTextColor(context, message) result.setTextColor(color) + result.setLinkTextColor(color) + Linkify.addLinks(result, Linkify.WEB_URLS) return result }