From 34e511e0032eba03ca6fc64278daf748228244e3 Mon Sep 17 00:00:00 2001
From: Xyndra <71836523+Xyndra@users.noreply.github.com>
Date: Tue, 8 Jul 2025 16:10:01 +0200
Subject: [PATCH 1/2] feat: add automatic intent URL display option
---
.../github/gotify/service/WebSocketService.kt | 22 +++++++++++++++----
app/src/main/res/values/arrays.xml | 1 +
app/src/main/res/values/strings.xml | 3 +++
app/src/main/res/xml/root_preferences.xml | 5 +++++
4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt
index 719d7c97..acfb62d6 100644
--- a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt
+++ b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt
@@ -16,6 +16,7 @@ import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
+import androidx.preference.PreferenceManager
import com.github.gotify.BuildConfig
import com.github.gotify.CoilInstance
import com.github.gotify.MarkwonFactory
@@ -313,12 +314,25 @@ internal class WebSocketService : Service() {
"intentUrl"
)
+ val shouldInstantlyOpen = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
+ getString(R.string.setting_key_intent_automatic),
+ resources.getBoolean(R.bool.intent_automatic)
+ )
+
if (intentUrl != null) {
- intent = Intent(this, IntentUrlDialogActivity::class.java).apply {
- putExtra(IntentUrlDialogActivity.EXTRA_KEY_URL, intentUrl)
- flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ if (shouldInstantlyOpen) {
+ Intent(Intent.ACTION_VIEW).apply {
+ data = intentUrl.toUri()
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ startActivity(this)
+ }
+ } else {
+ intent = Intent(this, IntentUrlDialogActivity::class.java).apply {
+ putExtra(IntentUrlDialogActivity.EXTRA_KEY_URL, intentUrl)
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ }
+ startActivity(intent)
}
- startActivity(intent)
}
val url = Extras.getNestedValue(
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 1c424097..52b19da5 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -36,4 +36,5 @@
time_format_relative
false
false
+ false
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d0e4e2c4..6a26edec 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -96,6 +96,9 @@
intent_dialog_permission
To always show incoming intent URLs, give permission to show this app on top of other apps.
Permission granted.
+ Automatically show intent URLs
+ intent_automatic
+ Always automatically show/activate intent URLs. Only do this when you trust the source!
Push message
App:
Priority:
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index d6d4ad0a..903c1ac7 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -43,6 +43,11 @@
android:key="@string/setting_key_intent_dialog_permission"
android:title="@string/setting_intent_dialog_permission"
tools:summary="@string/setting_summary_intent_dialog_permission" />
+
+
From e5978d97b717943b0f853045650ddf1f47fbfe82 Mon Sep 17 00:00:00 2001
From: Jannis Mattheis
Date: Sun, 13 Jul 2025 17:19:11 +0200
Subject: [PATCH 2/2] fixup! feat: add automatic intent URL display option
---
.../github/gotify/service/WebSocketService.kt | 22 +++++++++----------
app/src/main/res/values/arrays.xml | 2 +-
app/src/main/res/values/strings.xml | 6 ++---
app/src/main/res/xml/root_preferences.xml | 9 ++++----
4 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt
index acfb62d6..eac9ca14 100644
--- a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt
+++ b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt
@@ -314,25 +314,23 @@ internal class WebSocketService : Service() {
"intentUrl"
)
- val shouldInstantlyOpen = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
- getString(R.string.setting_key_intent_automatic),
- resources.getBoolean(R.bool.intent_automatic)
- )
-
if (intentUrl != null) {
- if (shouldInstantlyOpen) {
- Intent(Intent.ACTION_VIEW).apply {
- data = intentUrl.toUri()
+ val prompt = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
+ getString(R.string.setting_key_prompt_onreceive_intent),
+ resources.getBoolean(R.bool.prompt_onreceive_intent)
+ )
+ val onReceiveIntent = if (prompt) {
+ Intent(this, IntentUrlDialogActivity::class.java).apply {
+ putExtra(IntentUrlDialogActivity.EXTRA_KEY_URL, intentUrl)
flags = Intent.FLAG_ACTIVITY_NEW_TASK
- startActivity(this)
}
} else {
- intent = Intent(this, IntentUrlDialogActivity::class.java).apply {
- putExtra(IntentUrlDialogActivity.EXTRA_KEY_URL, intentUrl)
+ Intent(Intent.ACTION_VIEW).apply {
+ data = intentUrl.toUri()
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
- startActivity(intent)
}
+ startActivity(onReceiveIntent)
}
val url = Extras.getNestedValue(
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 52b19da5..113e78fc 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -36,5 +36,5 @@
time_format_relative
false
false
- false
+ true
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6a26edec..d96bb587 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -96,9 +96,9 @@
intent_dialog_permission
To always show incoming intent URLs, give permission to show this app on top of other apps.
Permission granted.
- Automatically show intent URLs
- intent_automatic
- Always automatically show/activate intent URLs. Only do this when you trust the source!
+ Confirm onReceive intents
+ prompt_onreceive_intent
+ If enabled, a dialog is shown before onReceive.intentUrl is executed.
Push message
App:
Priority:
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index 903c1ac7..89cac847 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -42,12 +42,13 @@
+ android:summary="@string/setting_summary_intent_dialog_permission" />
+ android:key="@string/setting_key_prompt_onreceive_intent"
+ android:title="@string/setting_prompt_onreceive_intent"
+ android:defaultValue="@bool/prompt_onreceive_intent"
+ android:summary="@string/setting_summary_prompt_onreceive_intent" />