From 4566a37e162d41158363478db1e8cbb225c9b5c4 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Mon, 23 Sep 2024 20:38:13 +0300 Subject: [PATCH] Add spoken description for numpad layout --- java/res/values/strings-talkback-descriptions.xml | 10 +++++++++- .../accessibility/KeyCodeDescriptionMapper.java | 4 ++++ .../accessibility/KeyboardAccessibilityDelegate.java | 11 ++++++++++- .../MainKeyboardAccessibilityDelegate.java | 6 +++--- .../src/org/futo/inputmethod/keyboard/KeyboardId.java | 1 - 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/java/res/values/strings-talkback-descriptions.xml b/java/res/values/strings-talkback-descriptions.xml index 307cd47a6..930051a89 100644 --- a/java/res/values/strings-talkback-descriptions.xml +++ b/java/res/values/strings-talkback-descriptions.xml @@ -53,7 +53,7 @@ Letters - Numbers + Digits Settings @@ -77,6 +77,12 @@ Previous + + + Page 1 + Page 2 + Page 3 + Shift enabled @@ -91,6 +97,8 @@ Phone mode Phone symbols mode + + Digits mode Keyboard hidden diff --git a/java/src/org/futo/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/org/futo/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 342042559..2a1bd40df 100644 --- a/java/src/org/futo/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/org/futo/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -62,6 +62,10 @@ final class KeyCodeDescriptionMapper { mKeyCodeMap.put(Constants.CODE_SHIFT, R.string.spoken_description_shift); mKeyCodeMap.put(Constants.CODE_SHORTCUT, R.string.spoken_description_mic); mKeyCodeMap.put(Constants.CODE_SWITCH_ALPHA_SYMBOL, R.string.spoken_description_to_symbol); + mKeyCodeMap.put(Constants.CODE_TO_NUMBER_LAYOUT, R.string.spoken_description_to_numeric); + mKeyCodeMap.put(Constants.CODE_TO_ALT_0_LAYOUT, R.string.spoken_description_to_alt_0); + mKeyCodeMap.put(Constants.CODE_TO_ALT_1_LAYOUT, R.string.spoken_description_to_alt_1); + mKeyCodeMap.put(Constants.CODE_TO_ALT_2_LAYOUT, R.string.spoken_description_to_alt_2); mKeyCodeMap.put(Constants.CODE_TAB, R.string.spoken_description_tab); mKeyCodeMap.put(Constants.CODE_LANGUAGE_SWITCH, R.string.spoken_description_language_switch); diff --git a/java/src/org/futo/inputmethod/accessibility/KeyboardAccessibilityDelegate.java b/java/src/org/futo/inputmethod/accessibility/KeyboardAccessibilityDelegate.java index a23870635..c74c085c8 100644 --- a/java/src/org/futo/inputmethod/accessibility/KeyboardAccessibilityDelegate.java +++ b/java/src/org/futo/inputmethod/accessibility/KeyboardAccessibilityDelegate.java @@ -181,7 +181,16 @@ public class KeyboardAccessibilityDelegate node.setFocusable(true); node.setScreenReaderFocusable(true); - if(k.isActionKey() || k.getCode() == Constants.CODE_SWITCH_ALPHA_SYMBOL || k.getCode() == Constants.CODE_EMOJI || k.getCode() == Constants.CODE_SYMBOL_SHIFT || (k.getCode() >= Constants.CODE_ACTION_0 && k.getCode() <= Constants.CODE_ACTION_MAX)) { + if(k.isActionKey() || + k.getCode() == Constants.CODE_SWITCH_ALPHA_SYMBOL || + k.getCode() == Constants.CODE_EMOJI || + k.getCode() == Constants.CODE_SYMBOL_SHIFT || + k.getCode() == Constants.CODE_TO_ALT_0_LAYOUT || + k.getCode() == Constants.CODE_TO_ALT_1_LAYOUT || + k.getCode() == Constants.CODE_TO_ALT_2_LAYOUT || + k.getCode() == Constants.CODE_TO_NUMBER_LAYOUT || + (k.getCode() >= Constants.CODE_ACTION_0 && k.getCode() <= Constants.CODE_ACTION_MAX) + ) { node.addAction(AccessibilityNodeInfoCompat.ACTION_CLICK); node.addAction(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK); node.setClickable(true); diff --git a/java/src/org/futo/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java b/java/src/org/futo/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java index 560459fc9..6c40911b0 100644 --- a/java/src/org/futo/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java +++ b/java/src/org/futo/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java @@ -18,10 +18,8 @@ package org.futo.inputmethod.accessibility; import android.content.Context; import android.graphics.Rect; -import android.os.SystemClock; import android.util.Log; import android.util.SparseIntArray; -import android.view.MotionEvent; import org.futo.inputmethod.keyboard.Key; import org.futo.inputmethod.keyboard.KeyDetector; @@ -30,7 +28,6 @@ import org.futo.inputmethod.keyboard.KeyboardId; import org.futo.inputmethod.keyboard.MainKeyboardView; import org.futo.inputmethod.keyboard.PointerTracker; import org.futo.inputmethod.latin.R; -import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils; /** * This class represents a delegate that can be registered in {@link MainKeyboardView} to enhance @@ -191,6 +188,9 @@ public final class MainKeyboardAccessibilityDelegate case KeyboardId.ELEMENT_PHONE_SYMBOLS: resId = R.string.spoken_description_mode_phone_shift; break; + case KeyboardId.ELEMENT_NUMBER: + resId = R.string.spoken_description_mode_digits; + break; default: return; } diff --git a/java/src/org/futo/inputmethod/keyboard/KeyboardId.java b/java/src/org/futo/inputmethod/keyboard/KeyboardId.java index d668840d8..7787921a8 100644 --- a/java/src/org/futo/inputmethod/keyboard/KeyboardId.java +++ b/java/src/org/futo/inputmethod/keyboard/KeyboardId.java @@ -23,7 +23,6 @@ import android.text.TextUtils; import android.view.inputmethod.EditorInfo; import org.futo.inputmethod.compat.EditorInfoCompatUtils; -import org.futo.inputmethod.latin.RichInputMethodSubtype; import org.futo.inputmethod.latin.settings.LongPressKeySettings; import org.futo.inputmethod.latin.utils.InputTypeUtils;