Skip to content

feat: add automatic intent URL display option #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>