feat: add automatic intent URL display option (#416)

Co-authored-by: Jannis Mattheis <contact@jmattheis.de>
This commit is contained in:
Xyndra
2025-07-19 18:46:20 +02:00
committed by GitHub
parent 6ac5f69568
commit cd7ac5595b
4 changed files with 27 additions and 5 deletions

View File

@@ -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(

View File

@@ -36,4 +36,5 @@
<string name="time_format_value_relative">time_format_relative</string>
<bool name="notification_channels">false</bool>
<bool name="exclude_from_recent">false</bool>
<bool name="prompt_onreceive_intent">true</bool>
</resources>

View File

@@ -96,6 +96,9 @@
<string name="setting_key_intent_dialog_permission">intent_dialog_permission</string>
<string name="setting_summary_intent_dialog_permission">To always show incoming intent URLs, give permission to show this app on top of other apps.</string>
<string name="setting_summary_intent_dialog_permission_granted">Permission granted.</string>
<string name="setting_prompt_onreceive_intent">Confirm onReceive intents</string>
<string name="setting_key_prompt_onreceive_intent">prompt_onreceive_intent</string>
<string name="setting_summary_prompt_onreceive_intent">If enabled, a dialog is shown before onReceive.intentUrl is executed.</string>
<string name="push_message">Push message</string>
<string name="appListDescription">App:</string>
<string name="priorityDescription">Priority:</string>

View File

@@ -42,7 +42,13 @@
<SwitchPreferenceCompat
android:key="@string/setting_key_intent_dialog_permission"
android:title="@string/setting_intent_dialog_permission"
tools:summary="@string/setting_summary_intent_dialog_permission" />
android:summary="@string/setting_summary_intent_dialog_permission" />
<SwitchPreferenceCompat
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" />
</PreferenceCategory>
</PreferenceScreen>