From cd7ac5595b7bf9947fa52d526120cb0d5777c9dc Mon Sep 17 00:00:00 2001 From: Xyndra <71836523+Xyndra@users.noreply.github.com> Date: Sat, 19 Jul 2025 18:46:20 +0200 Subject: [PATCH] feat: add automatic intent URL display option (#416) Co-authored-by: Jannis Mattheis --- .../github/gotify/service/WebSocketService.kt | 20 +++++++++++++++---- app/src/main/res/values/arrays.xml | 1 + app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/root_preferences.xml | 8 +++++++- 4 files changed, 27 insertions(+), 5 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 719d7c9..eac9ca1 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 @@ -314,11 +315,22 @@ internal class WebSocketService : Service() { ) if (intentUrl != null) { - intent = Intent(this, IntentUrlDialogActivity::class.java).apply { - putExtra(IntentUrlDialogActivity.EXTRA_KEY_URL, intentUrl) - flags = Intent.FLAG_ACTIVITY_NEW_TASK + 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 + } + } else { + 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 1c42409..113e78f 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 + true diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d0e4e2c..d96bb58 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. + 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 d6d4ad0..89cac84 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -42,7 +42,13 @@ + android:summary="@string/setting_summary_intent_dialog_permission" /> + +