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..eac9ca14 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 1c424097..113e78fc 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 d0e4e2c4..d96bb587 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 d6d4ad0a..89cac847 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" /> + +