From b2dff29baa760ca51082f28e3515165bedf6b195 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Wed, 29 Jan 2020 14:13:13 +0100 Subject: [PATCH] Auto performed "Go" key in Magikeyboard --- CHANGELOG | 1 + .../kunzisoft/keepass/magikeyboard/MagikIME.kt | 15 ++++++++++++--- .../kunzisoft/keepass/settings/PreferencesUtil.kt | 6 ++++++ app/src/main/res/values/donottranslate.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/preferences_keyboard.xml | 5 +++++ fastlane/metadata/android/en-US/changelogs/26.txt | 1 + fastlane/metadata/android/fr-FR/changelogs/26.txt | 1 + 8 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 86fe01327..788290af1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ KeepassDX (2.5.0.0beta26) * Download attachments * Change file size string format * Prevent screenshot for all screen + * Auto performed "Go" key in Magikeyboard * Fix crash when clearing clipboard * Fix attachments compressions * Fix dates diff --git a/app/src/main/java/com/kunzisoft/keepass/magikeyboard/MagikIME.kt b/app/src/main/java/com/kunzisoft/keepass/magikeyboard/MagikIME.kt index 5954d203e..1963ccf50 100644 --- a/app/src/main/java/com/kunzisoft/keepass/magikeyboard/MagikIME.kt +++ b/app/src/main/java/com/kunzisoft/keepass/magikeyboard/MagikIME.kt @@ -114,6 +114,7 @@ class MagikIME : InputMethodService(), KeyboardView.OnKeyboardActionListener { fieldsAdapter?.onItemClickListener = object : FieldsAdapter.OnItemClickListener { override fun onItemClick(item: Field) { currentInputConnection.commitText(entryInfoKey?.getGeneratedFieldValue(item.name) , 1) + goNextAutomatically() } } recyclerView.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this, androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL, true) @@ -235,18 +236,21 @@ class MagikIME : InputMethodService(), KeyboardView.OnKeyboardActionListener { } KEY_USERNAME -> { if (entryInfoKey != null) { - inputConnection.commitText(entryInfoKey!!.username, 1) + currentInputConnection.commitText(entryInfoKey!!.username, 1) } + goNextAutomatically() } KEY_PASSWORD -> { if (entryInfoKey != null) { - inputConnection.commitText(entryInfoKey!!.password, 1) + currentInputConnection.commitText(entryInfoKey!!.password, 1) } + goNextAutomatically() } KEY_URL -> { if (entryInfoKey != null) { - inputConnection.commitText(entryInfoKey!!.url, 1) + currentInputConnection.commitText(entryInfoKey!!.url, 1) } + goNextAutomatically() } KEY_FIELDS -> { if (entryInfoKey != null) { @@ -260,6 +264,11 @@ class MagikIME : InputMethodService(), KeyboardView.OnKeyboardActionListener { }// TODO Unlock key } + private fun goNextAutomatically() { + if (PreferencesUtil.isAutoGoActionEnable(this)) + currentInputConnection.performEditorAction(EditorInfo.IME_ACTION_GO) + } + override fun onPress(primaryCode: Int) { val audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager? if (audioManager != null) diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt index 6bdaa6e2d..75f51e690 100644 --- a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt +++ b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt @@ -267,6 +267,12 @@ object PreferencesUtil { context.resources.getBoolean(R.bool.keyboard_notification_entry_default)) } + fun isAutoGoActionEnable(context: Context): Boolean { + val prefs = PreferenceManager.getDefaultSharedPreferences(context) + return prefs.getBoolean(context.getString(R.string.keyboard_auto_go_action_key), + context.resources.getBoolean(R.bool.keyboard_auto_go_action_default)) + } + fun isKeyboardVibrationEnable(context: Context): Boolean { val prefs = PreferenceManager.getDefaultSharedPreferences(context) return prefs.getBoolean(context.getString(R.string.keyboard_key_vibrate_key), diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 84f57911d..ae1f1d74f 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -119,6 +119,8 @@ true keyboard_entry_timeout_key 300000 + keyboard_auto_go_action_key + true keyboard_key_vibrate_key true keyboard_key_sound_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba3607ce3..6e34fb9b6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -363,6 +363,8 @@ Appearance Keyboard theme Keys + Auto key action + Action of the "Go" key performed automatically after pressing a "Field" key Vibrate on keypress Sound on keypress Allow no master key diff --git a/app/src/main/res/xml/preferences_keyboard.xml b/app/src/main/res/xml/preferences_keyboard.xml index 510baea60..dbdc51d9c 100644 --- a/app/src/main/res/xml/preferences_keyboard.xml +++ b/app/src/main/res/xml/preferences_keyboard.xml @@ -48,6 +48,11 @@ +