Skip to content

Commit e96ff6e

Browse files
committed
#1370 fix: warn the user about extra permissions being required for app actions
1 parent 368c168 commit e96ff6e

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

app/src/main/java/io/github/sds100/keymapper/actions/ChooseActionViewModel.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.github.sds100.keymapper.actions
22

3-
import androidx.annotation.StringRes
43
import androidx.lifecycle.ViewModel
54
import androidx.lifecycle.ViewModelProvider
65
import androidx.lifecycle.viewModelScope
@@ -10,6 +9,7 @@ import io.github.sds100.keymapper.util.State
109
import io.github.sds100.keymapper.util.containsQuery
1110
import io.github.sds100.keymapper.util.getFullMessage
1211
import io.github.sds100.keymapper.util.ui.DefaultSimpleListItem
12+
import io.github.sds100.keymapper.util.ui.DialogResponse
1313
import io.github.sds100.keymapper.util.ui.IconInfo
1414
import io.github.sds100.keymapper.util.ui.ListItem
1515
import io.github.sds100.keymapper.util.ui.PopupUi
@@ -163,7 +163,31 @@ class ChooseActionViewModel(
163163
* @return whether the user approved the message
164164
*/
165165
private suspend fun showMessageForAction(id: ActionId): Boolean {
166-
@StringRes val messageToShow: Int? = when (id) {
166+
// See issue #1379
167+
if (id == ActionId.APP) {
168+
val response = showPopup(
169+
"show_app_action_warning_dialog",
170+
PopupUi.Dialog(
171+
message = getString(R.string.action_open_app_dialog_message),
172+
title = getString(R.string.action_open_app_dialog_title),
173+
positiveButtonText = getString(R.string.action_open_app_dialog_read_more_button),
174+
negativeButtonText = getString(R.string.action_open_app_dialog_ignore_button)
175+
),
176+
)
177+
178+
if (response == DialogResponse.POSITIVE) {
179+
showPopup(
180+
"app_action_permission_info",
181+
PopupUi.OpenUrl(getString(R.string.url_action_guide))
182+
)
183+
return false
184+
185+
} else {
186+
return response != null
187+
}
188+
}
189+
190+
val messageToShow: Int? = when (id) {
167191
ActionId.FAST_FORWARD_PACKAGE,
168192
ActionId.FAST_FORWARD,
169193
-> R.string.action_fast_forward_message

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,11 @@
12501250
<string name="action_disable_airplane_mode">Disable Airplane mode</string>
12511251

12521252
<string name="action_open_app">Launch app</string>
1253+
<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>
1254+
<string name="action_open_app_dialog_read_more_button">Read more</string>
1255+
<string name="action_open_app_dialog_ignore_button">Ignore</string>
1256+
1257+
<string name="action_open_app_dialog_title">Warning!</string>
12531258
<string name="action_open_app_shortcut">Launch app shortcut</string>
12541259
<string name="action_input_key_code">Input key code</string>
12551260
<string name="action_input_key_event">Input key event</string>
@@ -1374,7 +1379,6 @@
13741379
<string name="about_team_bydario_name" translatable="false">Darío B. C. (bydariogamer)</string>
13751380
<string name="about_team_bydario_url" translatable="false">https://github.com/bydariogamer</string>
13761381
<string name="about_team_bydario_role">Translator (Spanish)</string>
1377-
13781382
<!-- About -->
13791383

13801384
<!-- Advanced triggers -->

0 commit comments

Comments
 (0)