From e96ff6ede217b056ce4ae861a121c0d346ab0cf1 Mon Sep 17 00:00:00 2001 From: sds100 Date: Sun, 22 Dec 2024 16:24:57 +0100 Subject: [PATCH] #1370 fix: warn the user about extra permissions being required for app actions --- .../actions/ChooseActionViewModel.kt | 28 +++++++++++++++++-- app/src/main/res/values/strings.xml | 6 +++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/github/sds100/keymapper/actions/ChooseActionViewModel.kt b/app/src/main/java/io/github/sds100/keymapper/actions/ChooseActionViewModel.kt index 6276707f95..89fd4a3fb3 100644 --- a/app/src/main/java/io/github/sds100/keymapper/actions/ChooseActionViewModel.kt +++ b/app/src/main/java/io/github/sds100/keymapper/actions/ChooseActionViewModel.kt @@ -1,6 +1,5 @@ package io.github.sds100.keymapper.actions -import androidx.annotation.StringRes import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope @@ -10,6 +9,7 @@ import io.github.sds100.keymapper.util.State import io.github.sds100.keymapper.util.containsQuery import io.github.sds100.keymapper.util.getFullMessage import io.github.sds100.keymapper.util.ui.DefaultSimpleListItem +import io.github.sds100.keymapper.util.ui.DialogResponse import io.github.sds100.keymapper.util.ui.IconInfo import io.github.sds100.keymapper.util.ui.ListItem import io.github.sds100.keymapper.util.ui.PopupUi @@ -163,7 +163,31 @@ class ChooseActionViewModel( * @return whether the user approved the message */ private suspend fun showMessageForAction(id: ActionId): Boolean { - @StringRes val messageToShow: Int? = when (id) { + // See issue #1379 + if (id == ActionId.APP) { + val response = showPopup( + "show_app_action_warning_dialog", + PopupUi.Dialog( + message = getString(R.string.action_open_app_dialog_message), + title = getString(R.string.action_open_app_dialog_title), + positiveButtonText = getString(R.string.action_open_app_dialog_read_more_button), + negativeButtonText = getString(R.string.action_open_app_dialog_ignore_button) + ), + ) + + if (response == DialogResponse.POSITIVE) { + showPopup( + "app_action_permission_info", + PopupUi.OpenUrl(getString(R.string.url_action_guide)) + ) + return false + + } else { + return response != null + } + } + + val messageToShow: Int? = when (id) { ActionId.FAST_FORWARD_PACKAGE, ActionId.FAST_FORWARD, -> R.string.action_fast_forward_message diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d8f483e38f..d40dcdf695 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1250,6 +1250,11 @@ Disable Airplane mode Launch app + Some devices require apps to have permission before they can launch apps in the background. Tap \"Read more\" to view the instructions on our website. + Read more + Ignore + + Warning! Launch app shortcut Input key code Input key event @@ -1374,7 +1379,6 @@ DarĂ­o B. C. (bydariogamer) https://github.com/bydariogamer Translator (Spanish) -