diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt index 9ca9e8c..2fd461a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt @@ -165,17 +165,21 @@ fun Context.getKeyboardLanguages(): ArrayList { return arrayListOf( RadioItem(LANGUAGE_BENGALI, getKeyboardLanguageText(LANGUAGE_BENGALI)), RadioItem(LANGUAGE_BULGARIAN, getKeyboardLanguageText(LANGUAGE_BULGARIAN)), + RadioItem(LANGUAGE_DANISH, getKeyboardLanguageText(LANGUAGE_DANISH)), RadioItem(LANGUAGE_ENGLISH_QWERTY, getKeyboardLanguageText(LANGUAGE_ENGLISH_QWERTY)), RadioItem(LANGUAGE_ENGLISH_QWERTZ, getKeyboardLanguageText(LANGUAGE_ENGLISH_QWERTZ)), RadioItem(LANGUAGE_ENGLISH_DVORAK, getKeyboardLanguageText(LANGUAGE_ENGLISH_DVORAK)), - RadioItem(LANGUAGE_FRENCH, getKeyboardLanguageText(LANGUAGE_FRENCH)), + RadioItem(LANGUAGE_FRENCH_AZERTY, getKeyboardLanguageText(LANGUAGE_FRENCH_AZERTY)), + RadioItem(LANGUAGE_FRENCH_BEPO, getKeyboardLanguageText(LANGUAGE_FRENCH_BEPO)), RadioItem(LANGUAGE_GERMAN, getKeyboardLanguageText(LANGUAGE_GERMAN)), RadioItem(LANGUAGE_GREEK, getKeyboardLanguageText(LANGUAGE_GREEK)), RadioItem(LANGUAGE_LITHUANIAN, getKeyboardLanguageText(LANGUAGE_LITHUANIAN)), + RadioItem(LANGUAGE_NORWEGIAN, getKeyboardLanguageText(LANGUAGE_NORWEGIAN)), RadioItem(LANGUAGE_ROMANIAN, getKeyboardLanguageText(LANGUAGE_ROMANIAN)), RadioItem(LANGUAGE_RUSSIAN, getKeyboardLanguageText(LANGUAGE_RUSSIAN)), RadioItem(LANGUAGE_SLOVENIAN, getKeyboardLanguageText(LANGUAGE_SLOVENIAN)), RadioItem(LANGUAGE_SPANISH, getKeyboardLanguageText(LANGUAGE_SPANISH)), + RadioItem(LANGUAGE_SWEDISH, getKeyboardLanguageText(LANGUAGE_SWEDISH)), RadioItem(LANGUAGE_TURKISH_Q, getKeyboardLanguageText(LANGUAGE_TURKISH_Q)), ) } @@ -184,18 +188,23 @@ fun Context.getKeyboardLanguageText(language: Int): String { return when (language) { LANGUAGE_BENGALI -> getString(R.string.translation_bengali) LANGUAGE_BULGARIAN -> getString(R.string.translation_bulgarian) + LANGUAGE_DANISH -> getString(R.string.translation_danish) LANGUAGE_ENGLISH_DVORAK -> "${getString(R.string.translation_english)} (DVORAK)" LANGUAGE_ENGLISH_QWERTZ -> "${getString(R.string.translation_english)} (QWERTZ)" - LANGUAGE_FRENCH -> getString(R.string.translation_french) + LANGUAGE_FRENCH_AZERTY -> "${getString(R.string.translation_french)} (AZERTY)" + LANGUAGE_FRENCH_BEPO -> "${getString(R.string.translation_french)} (BEPO)" LANGUAGE_GERMAN -> getString(R.string.translation_german) LANGUAGE_GREEK -> getString(R.string.translation_greek) LANGUAGE_LITHUANIAN -> getString(R.string.translation_lithuanian) + LANGUAGE_NORWEGIAN -> getString(R.string.translation_norwegian) LANGUAGE_ROMANIAN -> getString(R.string.translation_romanian) LANGUAGE_RUSSIAN -> getString(R.string.translation_russian) LANGUAGE_SLOVENIAN -> getString(R.string.translation_slovenian) LANGUAGE_SPANISH -> getString(R.string.translation_spanish) + LANGUAGE_SWEDISH -> getString(R.string.translation_swedish) LANGUAGE_TURKISH_Q -> "${getString(R.string.translation_turkish)} (Q)" else -> "${getString(R.string.translation_english)} (QWERTY)" } } + diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/AccessHelper.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/AccessHelper.kt new file mode 100644 index 0000000..dd10066 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/AccessHelper.kt @@ -0,0 +1,69 @@ +package com.simplemobiletools.keyboard.helpers + +import android.graphics.Rect +import android.os.Bundle +import androidx.core.view.accessibility.AccessibilityNodeInfoCompat +import androidx.customview.widget.ExploreByTouchHelper +import com.simplemobiletools.keyboard.views.MyKeyboardView + +class AccessHelper( + private val keyboardView: MyKeyboardView, + private val keys: List +) : ExploreByTouchHelper(keyboardView) { + + /** + * We need to populate the list with the IDs of all of the visible virtual views (the intervals in the chart). + * In our case, all keys are always visible, so we’ll return a list of all IDs. + */ + override fun getVisibleVirtualViews(virtualViewIds: MutableList) { + val keysSize = keys.size + for (i in 0 until keysSize) { + virtualViewIds.add(i) + } + } + + /** + * For this function, we need to return the ID of the virtual view that’s under the x, y position, + * or ExploreByTouchHelper.HOST_ID if there’s no item at those coordinates. + */ + override fun getVirtualViewAt(x: Float, y: Float): Int { + val rects = keys.map { + Rect(it.x, it.y, it.x + it.width, it.y + it.height) + } + + return rects.firstOrNull { it.contains(x.toInt(), y.toInt()) }?.let { exactRect -> + rects.indexOf(exactRect) + } ?: HOST_ID + } + + /** + * This is where we provide all the metadata for our virtual view. + * We need to set the content description (or text, if it’s presented visually) and set the bounds in parent. + */ + override fun onPopulateNodeForVirtualView(virtualViewId: Int, node: AccessibilityNodeInfoCompat) { + node.className = keyboardView::class.simpleName + val key = keys.getOrNull(virtualViewId) + node.contentDescription = key?.getContentDescription(keyboardView.context) ?: "" + val bounds = updateBoundsForInterval(virtualViewId) + node.setBoundsInParent(bounds) + } + + /** + * We need to set the content description (or text, if it’s presented visually) and set the bounds in parent. + * The bounds in the parent should match the logic in the onDraw() function. + */ + private fun updateBoundsForInterval(index: Int): Rect { + val keys = keys + val key = keys.getOrNull(index) ?: return Rect() + return Rect().apply { + left = key.x + top = key.y + right = key.x + key.width + bottom = key.y + key.height + } + } + + override fun onPerformActionForVirtualView(virtualViewId: Int, action: Int, arguments: Bundle?): Boolean { + return false + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt index dfd33e7..f466092 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt @@ -27,7 +27,7 @@ const val ITEM_CLIP = 1 const val LANGUAGE_ENGLISH_QWERTY = 0 const val LANGUAGE_RUSSIAN = 1 -const val LANGUAGE_FRENCH = 2 +const val LANGUAGE_FRENCH_AZERTY = 2 const val LANGUAGE_ENGLISH_QWERTZ = 3 const val LANGUAGE_SPANISH = 4 const val LANGUAGE_GERMAN = 5 @@ -39,6 +39,10 @@ const val LANGUAGE_TURKISH_Q = 10 const val LANGUAGE_LITHUANIAN = 11 const val LANGUAGE_BENGALI = 12 const val LANGUAGE_GREEK = 13 +const val LANGUAGE_NORWEGIAN = 14 +const val LANGUAGE_SWEDISH = 15 +const val LANGUAGE_DANISH = 16 +const val LANGUAGE_FRENCH_BEPO = 17 // keyboard height multiplier options const val KEYBOARD_HEIGHT_MULTIPLIER_SMALL = 1 diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt index a8325d3..fb90bdf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -43,7 +43,7 @@ class MyKeyboard { var mMinWidth = 0 /** List of keys in this keyboard */ - var mKeys: MutableList? = null + var mKeys: MutableList? = null /** Width of the screen available to fit the keyboard */ private var mDisplayWidth = 0 @@ -225,6 +225,21 @@ class MyKeyboard { a.recycle() } + /** + * Content description for talkback functional + */ + fun getContentDescription(context: Context): CharSequence { + return when (code) { + KEYCODE_SHIFT -> context.getString(R.string.keycode_shift) + KEYCODE_MODE_CHANGE -> context.getString(R.string.keycode_mode_change) + KEYCODE_ENTER -> context.getString(R.string.keycode_enter) + KEYCODE_DELETE -> context.getString(R.string.keycode_delete) + KEYCODE_SPACE -> context.getString(R.string.keycode_space) + KEYCODE_EMOJI -> context.getString(R.string.emojis) + else -> label + } + } + /** Create an empty key with no attributes. */ init { height = parent.defaultHeight diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/interfaces/OnKeyboardActionListener.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/interfaces/OnKeyboardActionListener.kt new file mode 100644 index 0000000..8f9189a --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/interfaces/OnKeyboardActionListener.kt @@ -0,0 +1,41 @@ +package com.simplemobiletools.keyboard.interfaces + +interface OnKeyboardActionListener { + /** + * Called when the user presses a key. This is sent before the [.onKey] is called. For keys that repeat, this is only called once. + * @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key, the value will be zero. + */ + fun onPress(primaryCode: Int) + + /** + * Send a key press to the listener. + * @param code this is the key that was pressed + */ + fun onKey(code: Int) + + /** + * Called when the finger has been lifted after pressing a key + */ + fun onActionUp() + + /** + * Called when the user long presses Space and moves to the left + */ + fun moveCursorLeft() + + /** + * Called when the user long presses Space and moves to the right + */ + fun moveCursorRight() + + /** + * Sends a sequence of characters to the listener. + * @param text the string to be displayed. + */ + fun onText(text: String) + + /** + * Called to force the KeyboardView to reload the keyboard + */ + fun reloadKeyboard() +} diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt index 2b6777d..8306a85 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -16,11 +16,12 @@ import com.simplemobiletools.keyboard.R import com.simplemobiletools.keyboard.extensions.config import com.simplemobiletools.keyboard.extensions.safeStorageContext import com.simplemobiletools.keyboard.helpers.* +import com.simplemobiletools.keyboard.interfaces.OnKeyboardActionListener import com.simplemobiletools.keyboard.views.MyKeyboardView import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.* // based on https://www.androidauthority.com/lets-build-custom-keyboard-android-832362/ -class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionListener, SharedPreferences.OnSharedPreferenceChangeListener { +class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, SharedPreferences.OnSharedPreferenceChangeListener { private var SHIFT_PERM_TOGGLE_SPEED = 500 // how quickly do we have to doubletap shift to enable permanent caps lock private val KEYBOARD_LETTERS = 0 private val KEYBOARD_SYMBOLS = 1 @@ -283,15 +284,19 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL return when (baseContext.config.keyboardLanguage) { LANGUAGE_BENGALI -> R.xml.keys_letters_bengali LANGUAGE_BULGARIAN -> R.xml.keys_letters_bulgarian + LANGUAGE_DANISH -> R.xml.keys_letters_danish LANGUAGE_ENGLISH_DVORAK -> R.xml.keys_letters_english_dvorak LANGUAGE_ENGLISH_QWERTZ -> R.xml.keys_letters_english_qwertz - LANGUAGE_FRENCH -> R.xml.keys_letters_french + LANGUAGE_FRENCH_AZERTY -> R.xml.keys_letters_french_azerty + LANGUAGE_FRENCH_BEPO -> R.xml.keys_letters_french_bepo LANGUAGE_GERMAN -> R.xml.keys_letters_german LANGUAGE_GREEK -> R.xml.keys_letters_greek LANGUAGE_LITHUANIAN -> R.xml.keys_letters_lithuanian + LANGUAGE_NORWEGIAN -> R.xml.keys_letters_norwegian LANGUAGE_ROMANIAN -> R.xml.keys_letters_romanian LANGUAGE_RUSSIAN -> R.xml.keys_letters_russian LANGUAGE_SLOVENIAN -> R.xml.keys_letters_slovenian + LANGUAGE_SWEDISH -> R.xml.keys_letters_swedish LANGUAGE_SPANISH -> R.xml.keys_letters_spanish_qwerty LANGUAGE_TURKISH_Q -> R.xml.keys_letters_turkish_q else -> R.xml.keys_letters_english_qwerty 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 8bbcbc8..51f1c53 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -16,14 +16,13 @@ import android.os.Message import android.util.AttributeSet import android.util.TypedValue import android.view.* -import android.view.accessibility.AccessibilityEvent -import android.view.accessibility.AccessibilityManager import android.view.animation.AccelerateInterpolator import android.view.inputmethod.EditorInfo import android.widget.PopupWindow import android.widget.TextView import androidx.core.animation.doOnEnd import androidx.core.animation.doOnStart +import androidx.core.view.ViewCompat import androidx.emoji2.text.EmojiCompat import androidx.emoji2.text.EmojiCompat.EMOJI_SUPPORTED import com.simplemobiletools.commons.extensions.* @@ -43,6 +42,7 @@ import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_ENTER import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_MODE_CHANGE import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SHIFT import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SPACE +import com.simplemobiletools.keyboard.interfaces.OnKeyboardActionListener import com.simplemobiletools.keyboard.interfaces.RefreshClipsListener import com.simplemobiletools.keyboard.models.Clip import com.simplemobiletools.keyboard.models.ClipsSectionLabel @@ -52,49 +52,18 @@ import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.* import java.util.* @SuppressLint("UseCompatLoadingForDrawables", "ClickableViewAccessibility") -class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int = 0) : - View(context, attrs, defStyleRes) { +class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int = 0) : View(context, attrs, defStyleRes) { - interface OnKeyboardActionListener { - /** - * Called when the user presses a key. This is sent before the [.onKey] is called. For keys that repeat, this is only called once. - * @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key, the value will be zero. - */ - fun onPress(primaryCode: Int) - - /** - * Send a key press to the listener. - * @param code this is the key that was pressed - */ - fun onKey(code: Int) - - /** - * Called when the finger has been lifted after pressing a key - */ - fun onActionUp() - - /** - * Called when the user long presses Space and moves to the left - */ - fun moveCursorLeft() - - /** - * Called when the user long presses Space and moves to the right - */ - fun moveCursorRight() - - /** - * Sends a sequence of characters to the listener. - * @param text the string to be displayed. - */ - fun onText(text: String) - - /** - * Called to force the KeyboardView to reload the keyboard - */ - fun reloadKeyboard() + override fun dispatchHoverEvent(event: MotionEvent): Boolean { + return if (accessHelper?.dispatchHoverEvent(event) == true) { + true + } else { + super.dispatchHoverEvent(event) + } } + private var accessHelper: AccessHelper? = null + private var mKeyboard: MyKeyboard? = null private var mCurrentKeyIndex: Int = NOT_A_KEY @@ -184,9 +153,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut /** The canvas for the above mutable keyboard bitmap */ private var mCanvas: Canvas? = null - /** The accessibility manager for accessibility support */ - private val mAccessibilityManager: AccessibilityManager - private var mHandler: Handler? = null companion object { @@ -248,7 +214,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mPaint.textAlign = Align.CENTER mPaint.alpha = 255 mMiniKeyboardCache = HashMap() - mAccessibilityManager = (context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager) mPopupMaxMoveDistance = resources.getDimension(R.dimen.popup_max_move_distance) mTopSmallNumberSize = resources.getDimension(R.dimen.small_text_size) mTopSmallNumberMarginWidth = resources.getDimension(R.dimen.top_small_number_margin_width) @@ -304,6 +269,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut invalidateAllKeys() computeProximityThreshold(keyboard) mMiniKeyboardCache.clear() + + accessHelper = AccessHelper(this, mKeyboard?.mKeys.orEmpty()) + ViewCompat.setAccessibilityDelegate(this, accessHelper) + // Not really necessary to do every time, but will free up views // Switching to a different keyboard should abort any pending keys so that the key up // doesn't get delivered to the old or new keyboard @@ -486,7 +455,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut private fun adjustCase(label: CharSequence): CharSequence? { var newLabel: CharSequence? = label - if (newLabel != null && newLabel.isNotEmpty() && mKeyboard!!.mShiftState != ShiftState.OFF && newLabel.length < 3 && Character.isLowerCase(newLabel[0])) { + if (!newLabel.isNullOrEmpty() && mKeyboard!!.mShiftState != ShiftState.OFF && newLabel.length < 3 && Character.isLowerCase(newLabel[0])) { newLabel = newLabel.toString().uppercase(Locale.getDefault()) } return newLabel @@ -651,10 +620,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val secondaryIconBottom = secondaryIconTop + secondaryIconHeight secondaryIcon.setBounds( - secondaryIconLeft, - secondaryIconTop, - secondaryIconRight, - secondaryIconBottom + secondaryIconLeft, secondaryIconTop, secondaryIconRight, secondaryIconBottom ) secondaryIcon.draw(canvas) @@ -840,29 +806,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val oldKeyIndex = mCurrentKeyIndex val previewPopup = mPreviewPopup mCurrentKeyIndex = keyIndex - // Release the old key and press the new key - val keys = mKeys - if (oldKeyIndex != mCurrentKeyIndex) { - if (oldKeyIndex != NOT_A_KEY && keys.size > oldKeyIndex) { - val oldKey = keys[oldKeyIndex] - oldKey.pressed = false - invalidateKey(oldKeyIndex) - val keyCode = oldKey.code - sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, keyCode) - } - - if (mCurrentKeyIndex != NOT_A_KEY && keys.size > mCurrentKeyIndex) { - val newKey = keys[mCurrentKeyIndex] - - val code = newKey.code - if (context.config.showKeyBorders || (code == KEYCODE_SHIFT || code == KEYCODE_MODE_CHANGE || code == KEYCODE_DELETE || code == KEYCODE_ENTER || code == KEYCODE_SPACE)) { - newKey.pressed = true - } - - invalidateKey(mCurrentKeyIndex) - sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, code) - } - } if (!context.config.showPopupOnKeypress) { return @@ -873,8 +816,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut if (previewPopup.isShowing) { if (keyIndex == NOT_A_KEY) { mHandler!!.sendMessageDelayed( - mHandler!!.obtainMessage(MSG_REMOVE_PREVIEW), - DELAY_AFTER_PREVIEW.toLong() + mHandler!!.obtainMessage(MSG_REMOVE_PREVIEW), DELAY_AFTER_PREVIEW.toLong() ) } } @@ -967,22 +909,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } - private fun sendAccessibilityEventForUnicodeCharacter(eventType: Int, code: Int) { - if (mAccessibilityManager.isEnabled) { - val event = AccessibilityEvent.obtain(eventType) - onInitializeAccessibilityEvent(event) - val text: String = when (code) { - KEYCODE_DELETE -> context.getString(R.string.keycode_delete) - KEYCODE_ENTER -> context.getString(R.string.keycode_enter) - KEYCODE_MODE_CHANGE -> context.getString(R.string.keycode_mode_change) - KEYCODE_SHIFT -> context.getString(R.string.keycode_shift) - else -> code.toChar().toString() - } - event.text.add(text) - mAccessibilityManager.sendAccessibilityEvent(event) - } - } - /** * Requests a redraw of the entire keyboard. Calling [.invalidate] is not sufficient because the keyboard renders the keys to an off-screen buffer and * an invalidate() only draws the cached buffer. @@ -1097,8 +1023,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mMiniKeyboard!!.setKeyboard(keyboard) mPopupParent = this mMiniKeyboardContainer!!.measure( - MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), - MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST) + MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST) ) mMiniKeyboardCache[popupKey] = mMiniKeyboardContainer } else { @@ -1161,8 +1086,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut // fix a glitch with long pressing backspace, then clicking some letter if (mRepeatKeyIndex != NOT_A_KEY) { - val key = mKeys[mRepeatKeyIndex] - if (key.code == KEYCODE_DELETE) { + val key = mKeys.getOrNull(mRepeatKeyIndex) + if (key?.code == KEYCODE_DELETE) { mHandler?.removeMessages(MSG_REPEAT) mRepeatKeyIndex = NOT_A_KEY } @@ -1397,12 +1322,13 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } showPreview(NOT_A_KEY) Arrays.fill(mKeyIndices, NOT_A_KEY) + + val currentKeyCode = mKeys.getOrNull(mCurrentKey)?.code + // If we're not on a repeating key (which sends on a DOWN event) if (mRepeatKeyIndex == NOT_A_KEY && !mMiniKeyboardOnScreen && !mAbortKey) { detectAndSendKey(mCurrentKey, touchX, touchY, eventTime) - } - - if (mKeys.getOrNull(mCurrentKey)?.code == KEYCODE_SPACE && !mIsLongPressingSpace) { + } else if (currentKeyCode == KEYCODE_SPACE && !mIsLongPressingSpace) { detectAndSendKey(mCurrentKey, touchX, touchY, eventTime) } diff --git a/app/src/main/res/layout/keyboard_view_keyboard.xml b/app/src/main/res/layout/keyboard_view_keyboard.xml index ab15eae..16f5682 100644 --- a/app/src/main/res/layout/keyboard_view_keyboard.xml +++ b/app/src/main/res/layout/keyboard_view_keyboard.xml @@ -63,7 +63,7 @@ android:layout_height="@dimen/toolbar_icon_height" android:layout_marginEnd="@dimen/medium_margin" android:background="?android:attr/selectableItemBackgroundBorderless" - android:contentDescription="@string/settings" + android:contentDescription="@string/clipboard_pinned" android:padding="@dimen/small_margin" android:src="@drawable/ic_clipboard_vector" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 0a6ed84..77702f3 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -26,6 +26,7 @@ تغيير نوع لوحة المفاتيح Shift Enter + Spacebar إظهار محتوى الحافظة إذا كان متوفرا إظهار نافذة منبثقة عند الضغط على المفاتيح @@ -34,7 +35,7 @@ ارتفاع لوحة المفاتيح إظهار حدود المفاتيح إظهار الأرقام في صف منفصل - Start sentences with a capital letter + بدء الجمل بحرف كبير الرموز التعبيرية Паказаць змесціва буфера абмену, калі яно даступна Паказваць усплывальнае акно пры націску клавішы diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index cc35140..79c7c52 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -26,6 +26,7 @@ Промяна на типа клавиатура Shift Enter + Spacebar Показване на клипборд съдържанието, ако е налично Показване на изскачащ прозорец при натискане на клавиш diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 8ef4992..4bf9824 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -26,6 +26,7 @@ Canvia el tipus de teclat Majúscules Retorn + Spacebar Mostra el contingut del porta-retalls si està disponible Mostra una finestra emergent en prémer les tecles @@ -34,7 +35,7 @@ Alçada del teclat Mostra les vores de les tecles Mostra els números en una fila separada - Start sentences with a capital letter + Comença les frases amb una lletra majúscula Emojis پیشاندانی دوایین لەبەرگیراوە بچووککراوەی پیت diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index db987b0..0a89ba5 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -26,6 +26,7 @@ Změnit typ klávesnice Shift Enter + Spacebar Zobrazit obsah schránky, pokud je k dispozici Zobrazit vyskakovací okno při stisknutí klávesy @@ -34,7 +35,7 @@ Výška klávesnice Zobrazit ohraničení kláves Zobrazit čísla na samostatném řádku - Start sentences with a capital letter + Začínat věty velkým písmenem Emotikony Vis indhold i udklipsholder, hvis det er tilgængeligt Vis en popup ved tastetryk diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6c2fd98..7c2f78f 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -26,6 +26,7 @@ Tastaturtyp ändern Umschalttaste Eingabe + Spacebar Inhalt der Zwischenablage anzeigen, falls vorhanden Bei Tastendruck ein Popup anzeigen diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 7e2ac5a..2401ecf 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -26,6 +26,7 @@ Αλλαγή τύπου πληκτρολογίου Shift Enter + Spacebar Εμφάνιση περιεχομένου πρόχειρου εάν είναι διαθέσιμο Εμφάνιση ανάδυσης στο πάτημα πλήκτρων @@ -34,7 +35,7 @@ Ύψος πληκτρολογίου Εμφάνιση ορίων πλήκτρου Εμφάνιση αριθμών σε ξεχωριστή γραμμή - Start sentences with a capital letter + Αρχίστε τις προτάσεις με κεφαλαίο γράμμα Emojis Show clipboard content if available Show a popup on keypress diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f40bd12..93ba931 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -26,6 +26,7 @@ Cambiar el tipo de teclado Shift Enter + Spacebar Mostrar el contenido del portapapeles si está disponible Mostrar una ventana emergente al pulsar una tecla @@ -34,7 +35,7 @@ Altura del teclado Mostrar bordes de las teclas Mostrar los números en una fila separada - Start sentences with a capital letter + Empezar las frases con mayúsculas Emoticonos Näita lõikelaua kirjeid Klahvivajutusel näita hüpikakent @@ -34,7 +35,7 @@ Klaviatuuri kõrgus Näita klahvide ääriseid Näita numbreid eraldi real - Start sentences with a capital letter + Alusta lauseid suurtähega Emojid Näytä leikepöydän sisältö, jos saatavilla Näytä ponnahdus näppäinten painalluksesta diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b6d1b0f..13eebd6 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -26,6 +26,7 @@ Changer de type de clavier Majuscule Entrée + Spacebar Afficher le contenu du presse-papiers si disponible Afficher une fenêtre contextuelle en cas de pression sur une touche diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index 9446f78..659fc24 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -26,6 +26,7 @@ Cambialo tipo do teclado Shift Enter + Spacebar Mostralo contido do portapapeis se atopase dispoñible Mostra unha ventá emerxente ao premer nunha tecla diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 592ec63..4406b93 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -26,6 +26,7 @@ Promijeni vrstu tipkovnice Shift Enter + Spacebar Prikaži sadržaj međuspremnika ako postoji Prikaži skočni prozor prilikom pritiskanja tipke diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index e1821df..fb77295 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -26,6 +26,7 @@ Billentyűzet típusának módosítása Váltás Enter + Spacebar Vágólap tartalmának megjelenítése, ha rendelkezésre áll Felugró ablak megjelenítése billentyűleütéskor diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 705987e..fae512a 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -26,6 +26,7 @@ Ubah tipe keyboard Shift Enter + Spacebar Tampilkan konten papan klip jika tersedia Tampilkan sebuah popup pada penekanan tombol diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 267b3d6..28cf1c3 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -26,6 +26,7 @@ Cambia il tipo di tastiera Maiusc Invio + Spacebar Mostra il contenuto degli appunti se disponibile Mostra un popup alla pressione di un tasto diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index e7a984c..1a5bbad 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -26,6 +26,7 @@ שנה את סוג המקלדת Shift Enter + Spacebar הצג תוכן של לוח אם זמין הצג חלון קופץ בלחיצת מקש diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index b2edb3c..c0b72fb 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -26,6 +26,7 @@ キーボードの種類を変更する シフト エンター + Spacebar クリップボードの内容がある場合、それを表示する キー入力時にポップアップを表示する diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index ae49ca6..a89afdb 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -26,6 +26,7 @@ Keisti klaviatūros tipą Shift Enter + Spacebar Jei prieinama, rodyti iškarpinės turinį Show a popup on keypress diff --git a/app/src/main/res/values-ml/strings.xml b/app/src/main/res/values-ml/strings.xml index 8df0fe8..102038a 100644 --- a/app/src/main/res/values-ml/strings.xml +++ b/app/src/main/res/values-ml/strings.xml @@ -26,6 +26,7 @@ കീബോർഡ് തരം മാറ്റുക ഷിഫ്റ്റ് നൽകുക + Spacebar ക്ലിപ്പ്ബോർഡ് ഉള്ളടക്കം ലഭ്യമാണെങ്കിൽ കാണിക്കുക കീപ്രസ്സിൽ ഒരു പോപ്പ്അപ്പ് കാണിക്കുക diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 14ce48a..ee13235 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -26,6 +26,7 @@ Change keyboard type Shift Enter + Spacebar Show clipboard content if available Show a popup on keypress diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 41deffe..344c01b 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -26,6 +26,7 @@ Type toetsenbord veranderen Shift Enter + Spacebar Klembordinhoud tonen indien beschikbaar Pop-up tonen bij toetsaanslagen @@ -34,7 +35,7 @@ Hoogte toetsenbord Toetsen omranden Cijfers op een aparte rij - Start sentences with a capital letter + Zinnen met een hoofdletter beginnen Emoji\'s جے اُپلبدھ ہووے تاں کاپی کیتی لکھت ویکھو جدوں کنجی دباؤݨ کنجی تے وڈا اکھر ویکھو diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 47e09d3..8aab64e 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -26,6 +26,7 @@ Change keyboard type Shift Enter + Spacebar Show clipboard content if available Show a popup on keypress diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index ff6fedd..bc11a37 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -26,6 +26,7 @@ Zmień typ klawiatury Shift Enter + Spacebar Pokazuj zawartość schowka, jeśli jest dostępna Pokazuj wyskakujące okienko przy naciśnięciu klawisza diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index ee694ef..232e079 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -26,6 +26,7 @@ Mudar tipo de teclado Shift Enter + Spacebar Mostrar conteúdo da área de transferência se houver Mostrar pop-up ao digitar diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index e5a06b4..cf99140 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -26,6 +26,7 @@ Alterar tipo de teclado Shift Enter + Spacebar Mostrar conteúdo da área de transferência, se disponível Mostrar pop-up ao premir as teclas @@ -34,7 +35,7 @@ Altura do teclado Mostrar contorno das teclas Mostrar números em linha distinta - Start sentences with a capital letter + Iniciar frases com letra maiúscula Emojis Afișează conținutul clipboard-ului, dacă este disponibil Afișați o fereastră pop-up la apăsarea unei taste diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ffe904b..8750b6b 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -26,6 +26,7 @@ Изменить тип клавиатуры Shift Enter + Пробел Показывать содержимое буфера обмена при наличии Показывать ввод по нажатию diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 6332031..79dc658 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -26,6 +26,7 @@ Zmeniť typ klávesnice Shift Enter + Medzerník Zobraziť obsah schránky, ak je dostupná Zobraziť detail znaku pri stlačení diff --git a/app/src/main/res/values-sl/strings.xml b/app/src/main/res/values-sl/strings.xml index f4838c0..33b27c7 100644 --- a/app/src/main/res/values-sl/strings.xml +++ b/app/src/main/res/values-sl/strings.xml @@ -26,6 +26,7 @@ Spremeni vrsto tipkovnice Shift Enter + Spacebar Prikaži vsebino odložišča, če je na voljo Prikaži pojavno okno ob pritisku tipke diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 1a790f3..c2d89ed 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -26,6 +26,7 @@ Промените тип тастатуре Смена Унеси + Spacebar Прикажи садржај међуспремника ако је доступан Прикажи искачући прозор при притиску на тастер diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 9399c1c..9454853 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -15,7 +15,7 @@ Nuvarande Nålad Lägg till ett nytt objekt - Du kan hantera eller addera nya klipp här för snabb tillgänglighet. + Du kan hantera eller lägga till klipp här för snabb åtkomst. Klipp text Nåla text Text har blivit nålad @@ -26,6 +26,7 @@ Ändra tangentbordstyp Skift Enter + Spacebar Visa urklippets innehåll om tillgängligt Visa en popupp vid knapptryck @@ -34,7 +35,7 @@ Tangentbordshöjd Visa ramar runt tangenterna Visa siffror på en separat rad - Start sentences with a capital letter + Börja meningar med stor bokstav Emojier Show clipboard content if available Show a popup on keypress diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index d357e48..41b315e 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -26,6 +26,7 @@ Klavye türünü değiştir Shift Enter + Spacebar Varsa pano içeriğini göster Tuşa basıldığında bir açılır menü göster diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index dc8cb25..9ae5a85 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -26,6 +26,7 @@ Змінити тип клавіатури Shift Enter + Spacebar Показувати вміст буфера обміну, якщо він є Показувати popup при натисканні diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index cbc7f2c..8a203f4 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -26,6 +26,7 @@ 更改键盘类型 上档 输入 + Spacebar 如可用显示剪贴板内容 按键时显示弹框 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f9db284..d099b14 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -27,6 +27,7 @@ 變更鍵盤類型 Shift Enter + Spacebar 可以的話顯示剪貼簿內容 按下按鍵時顯示彈出效果 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 14ce48a..ee13235 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,6 +26,7 @@ Change keyboard type Shift Enter + Spacebar Show clipboard content if available Show a popup on keypress diff --git a/app/src/main/res/xml/keys_letters_danish.xml b/app/src/main/res/xml/keys_letters_danish.xml new file mode 100644 index 0000000..f0639a5 --- /dev/null +++ b/app/src/main/res/xml/keys_letters_danish.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/keys_letters_french.xml b/app/src/main/res/xml/keys_letters_french_azerty.xml similarity index 100% rename from app/src/main/res/xml/keys_letters_french.xml rename to app/src/main/res/xml/keys_letters_french_azerty.xml diff --git a/app/src/main/res/xml/keys_letters_french_bepo.xml b/app/src/main/res/xml/keys_letters_french_bepo.xml new file mode 100644 index 0000000..0df57fb --- /dev/null +++ b/app/src/main/res/xml/keys_letters_french_bepo.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/keys_letters_lithuanian.xml b/app/src/main/res/xml/keys_letters_lithuanian.xml index 6ac6345..f27a032 100644 --- a/app/src/main/res/xml/keys_letters_lithuanian.xml +++ b/app/src/main/res/xml/keys_letters_lithuanian.xml @@ -73,7 +73,7 @@ app:topSmallNumber="7" /> + app:keyWidth="10%p" + app:secondaryKeyIcon="@drawable/ic_language_outlined" /> + app:popupKeyboard="@xml/keyboard_popup_template" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/keys_letters_swedish.xml b/app/src/main/res/xml/keys_letters_swedish.xml new file mode 100644 index 0000000..8b2c74c --- /dev/null +++ b/app/src/main/res/xml/keys_letters_swedish.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/keys_letters_turkish_q.xml b/app/src/main/res/xml/keys_letters_turkish_q.xml index 64ec35d..4c801fa 100644 --- a/app/src/main/res/xml/keys_letters_turkish_q.xml +++ b/app/src/main/res/xml/keys_letters_turkish_q.xml @@ -73,12 +73,12 @@ app:topSmallNumber="7" /> + app:keyWidth="10%p" + app:secondaryKeyIcon="@drawable/ic_language_outlined" /> + app:popupKeyboard="@xml/keyboard_popup_template" />