Skip to content

Commit

Permalink
#1370 fix: warn the user about extra permissions being required for a…
Browse files Browse the repository at this point in the history
…pp actions
  • Loading branch information
sds100 committed Dec 22, 2024
1 parent 368c168 commit e96ff6e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,11 @@
<string name="action_disable_airplane_mode">Disable Airplane mode</string>

<string name="action_open_app">Launch app</string>
<string name="action_open_app_dialog_message">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.</string>
<string name="action_open_app_dialog_read_more_button">Read more</string>
<string name="action_open_app_dialog_ignore_button">Ignore</string>

<string name="action_open_app_dialog_title">Warning!</string>
<string name="action_open_app_shortcut">Launch app shortcut</string>
<string name="action_input_key_code">Input key code</string>
<string name="action_input_key_event">Input key event</string>
Expand Down Expand Up @@ -1374,7 +1379,6 @@
<string name="about_team_bydario_name" translatable="false">Darío B. C. (bydariogamer)</string>
<string name="about_team_bydario_url" translatable="false">https://github.com/bydariogamer</string>
<string name="about_team_bydario_role">Translator (Spanish)</string>

<!-- About -->

<!-- Advanced triggers -->
Expand Down

0 comments on commit e96ff6e

Please sign in to comment.