Add spoken description for numpad layout

This commit is contained in:
Aleksandras Kostarevas 2024-09-23 20:38:13 +03:00
parent 2c632bd4bd
commit 4566a37e16
5 changed files with 26 additions and 6 deletions

View File

@ -53,7 +53,7 @@
<!-- Spoken description for the "To Alpha" keyboard key. --> <!-- Spoken description for the "To Alpha" keyboard key. -->
<string name="spoken_description_to_alpha">Letters</string> <string name="spoken_description_to_alpha">Letters</string>
<!-- Spoken description for the "To Numbers" keyboard key. --> <!-- Spoken description for the "To Numbers" keyboard key. -->
<string name="spoken_description_to_numeric">Numbers</string> <string name="spoken_description_to_numeric">Digits</string>
<!-- Spoken description for the "Settings" keyboard key. --> <!-- Spoken description for the "Settings" keyboard key. -->
<string name="spoken_description_settings">Settings</string> <string name="spoken_description_settings">Settings</string>
<!-- Spoken description for the "Tab" keyboard key. --> <!-- Spoken description for the "Tab" keyboard key. -->
@ -77,6 +77,12 @@
<!-- Spoken description for the "Previous" action keyboard key. --> <!-- Spoken description for the "Previous" action keyboard key. -->
<string name="spoken_description_action_previous">Previous</string> <string name="spoken_description_action_previous">Previous</string>
<!-- Spoken description for the "To Numbers" keyboard key. -->
<string name="spoken_description_to_alt_0">Page 1</string>
<string name="spoken_description_to_alt_1">Page 2</string>
<string name="spoken_description_to_alt_2">Page 3</string>
<!-- Spoken feedback after turning "Shift" mode on. --> <!-- Spoken feedback after turning "Shift" mode on. -->
<string name="spoken_description_shiftmode_on">Shift enabled</string> <string name="spoken_description_shiftmode_on">Shift enabled</string>
<!-- Spoken feedback after turning "Caps lock" mode on. --> <!-- Spoken feedback after turning "Caps lock" mode on. -->
@ -91,6 +97,8 @@
<string name="spoken_description_mode_phone">Phone mode</string> <string name="spoken_description_mode_phone">Phone mode</string>
<!-- Spoken feedback after changing to the shifted phone dialer (symbols) keyboard. --> <!-- Spoken feedback after changing to the shifted phone dialer (symbols) keyboard. -->
<string name="spoken_description_mode_phone_shift">Phone symbols mode</string> <string name="spoken_description_mode_phone_shift">Phone symbols mode</string>
<!-- Spoken feedback after changing to the digits keyboard. -->
<string name="spoken_description_mode_digits">Digits mode</string>
<!-- Spoken feedback when the keyboard is hidden. --> <!-- Spoken feedback when the keyboard is hidden. -->
<string name="announce_keyboard_hidden">Keyboard hidden</string> <string name="announce_keyboard_hidden">Keyboard hidden</string>

View File

@ -62,6 +62,10 @@ final class KeyCodeDescriptionMapper {
mKeyCodeMap.put(Constants.CODE_SHIFT, R.string.spoken_description_shift); mKeyCodeMap.put(Constants.CODE_SHIFT, R.string.spoken_description_shift);
mKeyCodeMap.put(Constants.CODE_SHORTCUT, R.string.spoken_description_mic); 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_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_TAB, R.string.spoken_description_tab);
mKeyCodeMap.put(Constants.CODE_LANGUAGE_SWITCH, mKeyCodeMap.put(Constants.CODE_LANGUAGE_SWITCH,
R.string.spoken_description_language_switch); R.string.spoken_description_language_switch);

View File

@ -181,7 +181,16 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
node.setFocusable(true); node.setFocusable(true);
node.setScreenReaderFocusable(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_CLICK);
node.addAction(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK); node.addAction(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK);
node.setClickable(true); node.setClickable(true);

View File

@ -18,10 +18,8 @@ package org.futo.inputmethod.accessibility;
import android.content.Context; import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.SystemClock;
import android.util.Log; import android.util.Log;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.view.MotionEvent;
import org.futo.inputmethod.keyboard.Key; import org.futo.inputmethod.keyboard.Key;
import org.futo.inputmethod.keyboard.KeyDetector; 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.MainKeyboardView;
import org.futo.inputmethod.keyboard.PointerTracker; import org.futo.inputmethod.keyboard.PointerTracker;
import org.futo.inputmethod.latin.R; 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 * 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: case KeyboardId.ELEMENT_PHONE_SYMBOLS:
resId = R.string.spoken_description_mode_phone_shift; resId = R.string.spoken_description_mode_phone_shift;
break; break;
case KeyboardId.ELEMENT_NUMBER:
resId = R.string.spoken_description_mode_digits;
break;
default: default:
return; return;
} }

View File

@ -23,7 +23,6 @@ import android.text.TextUtils;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import org.futo.inputmethod.compat.EditorInfoCompatUtils; import org.futo.inputmethod.compat.EditorInfoCompatUtils;
import org.futo.inputmethod.latin.RichInputMethodSubtype;
import org.futo.inputmethod.latin.settings.LongPressKeySettings; import org.futo.inputmethod.latin.settings.LongPressKeySettings;
import org.futo.inputmethod.latin.utils.InputTypeUtils; import org.futo.inputmethod.latin.utils.InputTypeUtils;