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 1 commit 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
22 changes: 18 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 @@ -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(
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="intent_automatic">false</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_intent_automatic">Automatically show intent URLs</string>
<string name="setting_key_intent_automatic">intent_automatic</string>
<string name="setting_summary_intent_automatic">Always automatically show/activate intent URLs. Only do this when you trust the source!</string>
<string name="push_message">Push message</string>
<string name="appListDescription">App:</string>
<string name="priorityDescription">Priority:</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<SwitchPreferenceCompat
android:key="@string/setting_key_intent_automatic"
android:title="@string/setting_intent_automatic"
tools:summary="@string/setting_summary_intent_automatic" />
</PreferenceCategory>

</PreferenceScreen>