From 7a4d1bfe654fa54454968dd7bbde5de82d3cb927 Mon Sep 17 00:00:00 2001 From: Antoan Angelov Date: Fri, 20 Mar 2026 01:32:34 -0400 Subject: [PATCH] When sharing a link, automatically set it as the click URL This is a simple change in `ShareActivity` in which the message is checked for the `WEB_URL` regex pattern. If it matches, the `click` parameter of the `publish` API is set to the same URL so that it can be easily opened from the desktop notification. --- app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt index a7a627f37..0632bbc62 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt @@ -6,6 +6,7 @@ import android.os.Bundle import android.os.Parcelable import android.text.Editable import android.text.TextWatcher +import android.util.Patterns import android.view.* import android.widget.* import androidx.activity.enableEdgeToEdge @@ -305,6 +306,8 @@ class ShareActivity : AppCompatActivity() { } else { Pair("", null) } + val isLink = filename.isEmpty() && body == null && message.isNotEmpty() && Patterns.WEB_URL.matcher(message).matches() + val click = if (isLink) message else "" api.publish( baseUrl = baseUrl, topic = topic, @@ -312,6 +315,7 @@ class ShareActivity : AppCompatActivity() { message = message, body = body, // May be null filename = filename, // May be empty + click = click, // May be empty ) runOnUiThread { repository.addLastShareTopic(topicUrl(baseUrl, topic))