From 116bef3c7110a38b9f8198dbdb85e8bc7eafffed Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Wed, 28 Aug 2024 15:25:03 +1000 Subject: [PATCH] For safety --- .../securesms/conversation/v2/messages/LinkPreviewView.kt | 4 ++-- .../conversation/v2/messages/VisibleMessageContentView.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 b35a1650b7..d064d02872 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 @@ -87,8 +87,8 @@ class LinkPreviewView : LinearLayout { // Method to show the open or copy URL dialog private fun openURL() { val url = this.url ?: return Log.w("LinkPreviewView", "Cannot open a null URL") - val activity = context as ConversationActivityV2 - activity.showOpenUrlDialog(url) + val activity = context as? ConversationActivityV2 + activity?.showOpenUrlDialog(url) } // endregion } \ No newline at end of file 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 48fa7a6093..d62cc532c4 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 @@ -287,8 +287,8 @@ class VisibleMessageContentView : ConstraintLayout { body.getSpans(0, body.length).toList().forEach { urlSpan -> val updatedUrl = urlSpan.url.let { it.toHttpUrlOrNull().toString() } val replacementSpan = ModalURLSpan(updatedUrl) { url -> - val activity = context as ConversationActivityV2 - activity.showOpenUrlDialog(url) + val activity = context as? ConversationActivityV2 + activity?.showOpenUrlDialog(url) } val start = body.getSpanStart(urlSpan) val end = body.getSpanEnd(urlSpan)