From 5f22eaf00cd507bcf64c151b5e7cc635ff718639 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 9 Jan 2022 13:34:19 +0100 Subject: [PATCH] do not show the popup preview at caps lock, space, clear and enter --- .../keyboard/views/MyKeyboardView.kt | 34 +++++++------------ app/src/main/res/xml/keys_layout.xml | 1 - 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index acb8a4b..cf94a54 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -742,14 +742,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut oldKey.onReleased(mCurrentKeyIndex == NOT_A_KEY) invalidateKey(oldKeyIndex) val keyCode = oldKey.codes[0] - sendAccessibilityEventForUnicodeCharacter( - AccessibilityEvent.TYPE_VIEW_HOVER_EXIT, - keyCode - ) - // TODO: We need to implement AccessibilityNodeProvider for this view. - sendAccessibilityEventForUnicodeCharacter( - AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, keyCode - ) + sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT, keyCode) + sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, keyCode) } if (mCurrentKeyIndex != NOT_A_KEY && keys.size > mCurrentKeyIndex) { @@ -758,10 +752,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut invalidateKey(mCurrentKeyIndex) val keyCode = newKey.codes[0] sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER, keyCode) - // TODO: We need to implement AccessibilityNodeProvider for this view. - sendAccessibilityEventForUnicodeCharacter( - AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, keyCode - ) + sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, keyCode) } } @@ -863,17 +854,16 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mPopupPreviewY += popupHeight } - if (previewPopup.isShowing) { - previewPopup.update( - mPopupPreviewX, mPopupPreviewY, - popupWidth, popupHeight - ) - } else { - previewPopup.width = popupWidth - previewPopup.height = popupHeight - previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, mPopupPreviewX, mPopupPreviewY) + if (key.label.isNotEmpty()) { + if (previewPopup.isShowing) { + previewPopup.update(mPopupPreviewX, mPopupPreviewY, popupWidth, popupHeight) + } else { + previewPopup.width = popupWidth + previewPopup.height = popupHeight + previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, mPopupPreviewX, mPopupPreviewY) + } + mPreviewText!!.visibility = VISIBLE } - mPreviewText!!.visibility = VISIBLE } private fun sendAccessibilityEventForUnicodeCharacter(eventType: Int, code: Int) { diff --git a/app/src/main/res/xml/keys_layout.xml b/app/src/main/res/xml/keys_layout.xml index a74f05d..873236a 100644 --- a/app/src/main/res/xml/keys_layout.xml +++ b/app/src/main/res/xml/keys_layout.xml @@ -115,7 +115,6 @@ app:codes="32" app:iconPreview="@null" app:isRepeatable="true" - app:keyLabel="" app:keyWidth="60%p" />