Skip to content

Commit

Permalink
#402 show warning that the Key Mapper keyboard can't be used to unloc…
Browse files Browse the repository at this point in the history
…k a Password screen lock
  • Loading branch information
sds100 committed Jul 22, 2020
1 parent 5dcde52 commit 2534268
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.github.sds100.keymapper.data.model.*
import io.github.sds100.keymapper.data.model.BehaviorOption.Companion.nullIfDefault
import io.github.sds100.keymapper.util.Event
import io.github.sds100.keymapper.util.dataExtraString
import io.github.sds100.keymapper.util.requiresIME
import io.github.sds100.keymapper.util.result.Failure
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
Expand All @@ -23,7 +24,6 @@ class ConfigKeymapViewModel internal constructor(

companion object {
const val NEW_KEYMAP_ID = -2L
const val EXTRA_USE_DEFAULT = -1
}

val triggerInParallel: MutableLiveData<Boolean> = MutableLiveData(false)
Expand Down Expand Up @@ -556,6 +556,14 @@ class ConfigKeymapViewModel internal constructor(
add(action)
}

if (action.requiresIME && !getShownPrompt(R.string.key_pref_shown_password_screen_lock_warning)) {
showPrompt(NotifyUserModel(
message = R.string.dialog_message_password_screen_lock_warning
) {
setShownPrompt(R.string.key_pref_shown_password_screen_lock_warning)
})
}

invalidateOptions()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ class KeymapListFragment : Fragment() {
lifecycleScope.launchWhenCreated {
val onboardingState = OnboardingState(requireContext())

if (!onboardingState.getShownPrompt(R.string.key_pref_shown_cant_use_virtual_keyboard_message)) {
if (!onboardingState.getShownPrompt(R.string.key_pref_shown_password_screen_lock_warning)) {
val approvedWarning = requireActivity().alertDialog {
messageResource = R.string.dialog_message_cant_use_virtual_keyboard
messageResource = R.string.dialog_message_password_screen_lock_warning
}.showAndAwait(okValue = true,
cancelValue = false,
dismissValue = false)

if (approvedWarning) {
onboardingState.setShownPrompt(R.string.key_pref_shown_cant_use_virtual_keyboard_message)
onboardingState.setShownPrompt(R.string.key_pref_shown_password_screen_lock_warning)

KeyboardUtils.enableKeyMapperIme()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ object NotificationUtils {
R.drawable.ic_notification_keyboard,
R.string.notification_toggle_keyboard_title,
R.string.notification_toggle_keyboard_text,
showOnLockscreen = true,
priority = NotificationCompat.PRIORITY_MIN,
onGoing = true
onGoing = true,
actions = *arrayOf(NotificationCompat.Action(0, ctx.str(R.string.toggle), pendingIntent))
)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<string name="key_pref_auto_change_ime_on_connection" translatable="false">pref_auto_change_ime_on_connect_disconnect</string>
<string name="key_pref_root_permission" translatable="false">pref_allow_root_features</string>
<string name="key_pref_debug" translatable="false">pref_debugging_mode</string>
<string name="key_pref_shown_cant_use_virtual_keyboard_message">pref_shown_cant_use_virtual_keyboard_message</string>
<string name="key_pref_dark_theme_mode" translatable="false">pref_dark_theme_mode</string>
<string name="key_pref_notification_settings">key_notification_settings</string>
<string name="key_pref_shown_double_press_restriction_warning">key_shown_double_press_restriction_warning</string>
Expand All @@ -44,6 +43,7 @@
<string name="key_pref_showcase_action_list">pref_showcase_action_list</string>
<string name="key_pref_shown_screen_off_triggers_explanation">pref_screen_off_triggers_explanation</string>
<string name="key_pref_hide_home_screen_alerts">pref_hide_home_screen_alerts</string>
<string name="key_pref_shown_password_screen_lock_warning">pref_shown_password_screen_lock_warning</string>

<string name="key_pref_category_notifications" translatable="false">pref_category_notifications</string>
<string name="key_pref_category_secure_settings" translatable="false">pref_category_secure_settings</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
<string name="dialog_message_downloading">Downloading…</string>
<string name="dialog_message_describe_your_issue_in_the_email">Can you please describe the issue you are having in the email, otherwise I can\'t help you. Thanks!</string>
<string name="dialog_message_long_press_warning">Long pressing only works for physical volume and navigation buttons. If you enable it for other keys, the keys won\'t work when they aren\'t long pressed.</string>
<string name="dialog_message_cant_use_virtual_keyboard">The Key Mapper keyboard is designed to be used with a hardware keyboard, which is why it doesn\'t have a GUI. You can\'t use your preferred virtual keyboard while the Key Mapper keyboard is chosen.</string>
<string name="dialog_message_write_secure_settings">To grant Key Mapper WRITE_SECURE_SETTINGS permission, enable "root features" in the settings if your device is rooted. If your device isn\'t rooted, go to the Help page and follow the guide on how to use a PC/Mac to grant permission.</string>
<string name="dialog_message_write_secure_settings_for_accessibility_service">To grant Key Mapper WRITE_SECURE_SETTINGS permission, enable "root features" in the settings if your device is rooted. If your device isn\'t rooted, go to the Help page and follow the guide on how to use a PC/Mac to grant permission.</string>
<string name="dialog_message_cant_find_accessibility_settings_page">Your device doesn\'t seem to have an accessibility services settings page. You can enable the accessibility service by giving the app WRITE_SECURE_SETTINGS permission. After you tap \'okay\' a popup will guide you how to do it.</string>
Expand All @@ -239,6 +238,7 @@
<string name="dialog_message_bt_constraint_limitation">Android doesn\'t allow apps to get a list of connected (not paired) Bluetooth devices. Apps can only detect when they are connected and disconnected. So if your Bluetooth device is already connected to your device when the accessibility service starts, you will have to reconnect it for the app to know it is connected.</string>
<string name="dialog_message_change_location_or_disable">Change location or turn off automatic backup?</string>
<string name="dialog_message_screen_constraints_limitation">Screen on/off constraints will only work if you have turned on the \"detect trigger when screen is off\" keymap option. This option will only show for some keys (e.g volume buttons) and if you are rooted. See a list of supported keys on the Help page.</string>
<string name="dialog_message_password_screen_lock_warning">If you have any other screen lock chosen, such as PIN or Pattern then you don\'t have to worry. But if you have a Password screen lock you will *NOT* be able to unlock your phone if you use the Key Mapper keyboard because it doesn\'t have a GUI yet. You can grant Key Mapper WRITE_SECURE_SETTINGS permission so it can show a notification to switch to and from the keyboard. There is a guide on how to do this if you tap the question mark at the bottom of the screen.</string>
<!-- Dialog messages -->

<!-- Dialog buttons -->
Expand Down Expand Up @@ -718,6 +718,7 @@
<string name="system_action_cat_other">Other</string>
<string name="system_action_cat_keyboard">Keyboard</string>
<string name="system_action_cat_airplane_mode">Airplane Mode</string>
<string name="toggle">Toggle</string>
<!-- System action category labels -->

</resources>

0 comments on commit 2534268

Please sign in to comment.