am 4baf767f: Merge "Improved shift key and symbol/alpha switch key accessibility feedback."
* commit '4baf767facb885bdbd271624e1c9d8cccc553bb4': Improved shift key and symbol/alpha switch key accessibility feedback.main
commit
207b7cd6ba
|
@ -156,12 +156,12 @@
|
||||||
|
|
||||||
<!-- Spoken description for unknown keyboard keys. -->
|
<!-- Spoken description for unknown keyboard keys. -->
|
||||||
<string name="spoken_description_unknown">Key code %d</string>
|
<string name="spoken_description_unknown">Key code %d</string>
|
||||||
<!-- Spoken description for the "Shift" keyboard key. -->
|
<!-- Spoken description for the "Shift" keyboard key when "Shift" is off. -->
|
||||||
<string name="spoken_description_shift">Shift</string>
|
<string name="spoken_description_shift">Shift</string>
|
||||||
<!-- Spoken description for the "Shift" keyboard key's pressed state. -->
|
<!-- Spoken description for the "Shift" keyboard key when "Shift" is on. -->
|
||||||
<string name="spoken_description_shift_shifted">Shift enabled</string>
|
<string name="spoken_description_shift_shifted">Shift on (tap to disable)</string>
|
||||||
<!-- Spoken description for the "Shift" keyboard key's pressed state. -->
|
<!-- Spoken description for the "Shift" keyboard key when "Caps lock" is on. -->
|
||||||
<string name="spoken_description_caps_lock">Caps lock enabled</string>
|
<string name="spoken_description_caps_lock">Caps lock on (tap to disable)</string>
|
||||||
<!-- Spoken description for the "Delete" keyboard key. -->
|
<!-- Spoken description for the "Delete" keyboard key. -->
|
||||||
<string name="spoken_description_delete">Delete</string>
|
<string name="spoken_description_delete">Delete</string>
|
||||||
<!-- Spoken description for the "To Symbol" keyboard key. -->
|
<!-- Spoken description for the "To Symbol" keyboard key. -->
|
||||||
|
@ -185,6 +185,22 @@
|
||||||
<!-- Spoken description for the "\u2022" (BULLET) keyboard key. -->
|
<!-- Spoken description for the "\u2022" (BULLET) keyboard key. -->
|
||||||
<string name="spoken_description_dot">Dot</string>
|
<string name="spoken_description_dot">Dot</string>
|
||||||
|
|
||||||
|
<!-- Spoken feedback after turning "Shift" mode on. -->
|
||||||
|
<string name="spoken_description_shiftmode_on">Shift enabled</string>
|
||||||
|
<!-- Spoken feedback after turning "Caps lock" mode on. -->
|
||||||
|
<string name="spoken_description_shiftmode_locked">Caps lock enabled</string>
|
||||||
|
<!-- Spoken feedback after turning "Shift" mode off. -->
|
||||||
|
<string name="spoken_description_shiftmode_off">Shift disabled</string>
|
||||||
|
|
||||||
|
<!-- Spoken feedback after changing to the symbols keyboard. -->
|
||||||
|
<string name="spoken_description_mode_symbol">Symbols mode</string>
|
||||||
|
<!-- Spoken feedback after changing to the alphanumeric keyboard. -->
|
||||||
|
<string name="spoken_description_mode_alpha">Letters mode</string>
|
||||||
|
<!-- Spoken feedback after changing to the phone dialer keyboard. -->
|
||||||
|
<string name="spoken_description_mode_phone">Phone mode</string>
|
||||||
|
<!-- Spoken feedback after changing to the shifted phone dialer (symbols) keyboard. -->
|
||||||
|
<string name="spoken_description_mode_phone_shift">Phone symbols mode</string>
|
||||||
|
|
||||||
<!-- Voice related labels -->
|
<!-- Voice related labels -->
|
||||||
|
|
||||||
<!-- Title of the warning dialog that shows when a user initiates voice input for
|
<!-- Title of the warning dialog that shows when a user initiates voice input for
|
||||||
|
|
|
@ -28,8 +28,11 @@ import android.view.inputmethod.EditorInfo;
|
||||||
import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
|
import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
|
||||||
import com.android.inputmethod.compat.MotionEventCompatUtils;
|
import com.android.inputmethod.compat.MotionEventCompatUtils;
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker;
|
import com.android.inputmethod.keyboard.PointerTracker;
|
||||||
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
public class AccessibleKeyboardViewProxy {
|
public class AccessibleKeyboardViewProxy {
|
||||||
private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();
|
private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();
|
||||||
|
@ -175,4 +178,71 @@ public class AccessibleKeyboardViewProxy {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the user of changes in the keyboard shift state.
|
||||||
|
*/
|
||||||
|
public void notifyShiftState() {
|
||||||
|
final Keyboard keyboard = mView.getKeyboard();
|
||||||
|
final KeyboardId keyboardId = keyboard.mId;
|
||||||
|
final int elementId = keyboardId.mElementId;
|
||||||
|
final Context context = mView.getContext();
|
||||||
|
final CharSequence text;
|
||||||
|
|
||||||
|
switch (elementId) {
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
|
||||||
|
text = context.getText(R.string.spoken_description_shiftmode_locked);
|
||||||
|
break;
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_SYMBOLS_SHIFTED:
|
||||||
|
text = context.getText(R.string.spoken_description_shiftmode_on);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
text = context.getText(R.string.spoken_description_shiftmode_off);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccessibilityUtils.getInstance().speak(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the user of changes in the keyboard symbols state.
|
||||||
|
*/
|
||||||
|
public void notifySymbolsState() {
|
||||||
|
final Keyboard keyboard = mView.getKeyboard();
|
||||||
|
final Context context = mView.getContext();
|
||||||
|
final KeyboardId keyboardId = keyboard.mId;
|
||||||
|
final int elementId = keyboardId.mElementId;
|
||||||
|
final int resId;
|
||||||
|
|
||||||
|
switch (elementId) {
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
|
||||||
|
resId = R.string.spoken_description_mode_alpha;
|
||||||
|
break;
|
||||||
|
case KeyboardId.ELEMENT_SYMBOLS:
|
||||||
|
case KeyboardId.ELEMENT_SYMBOLS_SHIFTED:
|
||||||
|
resId = R.string.spoken_description_mode_symbol;
|
||||||
|
break;
|
||||||
|
case KeyboardId.ELEMENT_PHONE:
|
||||||
|
resId = R.string.spoken_description_mode_phone;
|
||||||
|
break;
|
||||||
|
case KeyboardId.ELEMENT_PHONE_SYMBOLS:
|
||||||
|
resId = R.string.spoken_description_mode_phone_shift;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
resId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resId < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String text = context.getString(resId);
|
||||||
|
AccessibilityUtils.getInstance().speak(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,19 +129,37 @@ public class KeyCodeDescriptionMapper {
|
||||||
* the key
|
* the key
|
||||||
*/
|
*/
|
||||||
private CharSequence getDescriptionForSwitchAlphaSymbol(Context context, Keyboard keyboard) {
|
private CharSequence getDescriptionForSwitchAlphaSymbol(Context context, Keyboard keyboard) {
|
||||||
final KeyboardId id = keyboard.mId;
|
final KeyboardId keyboardId = keyboard.mId;
|
||||||
|
final int elementId = keyboardId.mElementId;
|
||||||
|
final int resId;
|
||||||
|
|
||||||
if (id.isAlphabetKeyboard()) {
|
switch (elementId) {
|
||||||
return context.getString(R.string.spoken_description_to_symbol);
|
case KeyboardId.ELEMENT_ALPHABET:
|
||||||
} else if (id.isSymbolsKeyboard()) {
|
case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
|
||||||
return context.getString(R.string.spoken_description_to_alpha);
|
case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
|
||||||
} else if (id.isPhoneShiftKeyboard()) {
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
|
||||||
return context.getString(R.string.spoken_description_to_numeric);
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
|
||||||
} else if (id.isPhoneKeyboard()) {
|
resId = R.string.spoken_description_to_symbol;
|
||||||
return context.getString(R.string.spoken_description_to_symbol);
|
break;
|
||||||
} else {
|
case KeyboardId.ELEMENT_SYMBOLS:
|
||||||
|
case KeyboardId.ELEMENT_SYMBOLS_SHIFTED:
|
||||||
|
resId = R.string.spoken_description_to_alpha;
|
||||||
|
break;
|
||||||
|
case KeyboardId.ELEMENT_PHONE:
|
||||||
|
resId = R.string.spoken_description_to_symbol;
|
||||||
|
break;
|
||||||
|
case KeyboardId.ELEMENT_PHONE_SYMBOLS:
|
||||||
|
resId = R.string.spoken_description_to_numeric;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
resId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resId < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return context.getString(resId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,13 +170,21 @@ public class KeyCodeDescriptionMapper {
|
||||||
* @return A context-sensitive description of the "Shift" key.
|
* @return A context-sensitive description of the "Shift" key.
|
||||||
*/
|
*/
|
||||||
private CharSequence getDescriptionForShiftKey(Context context, Keyboard keyboard) {
|
private CharSequence getDescriptionForShiftKey(Context context, Keyboard keyboard) {
|
||||||
|
final KeyboardId keyboardId = keyboard.mId;
|
||||||
|
final int elementId = keyboardId.mElementId;
|
||||||
final int resId;
|
final int resId;
|
||||||
|
|
||||||
if (keyboard.isShiftLocked()) {
|
switch (elementId) {
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
|
||||||
resId = R.string.spoken_description_caps_lock;
|
resId = R.string.spoken_description_caps_lock;
|
||||||
} else if (keyboard.isShiftedOrShiftLocked()) {
|
break;
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
|
||||||
|
case KeyboardId.ELEMENT_SYMBOLS_SHIFTED:
|
||||||
resId = R.string.spoken_description_shift_shifted;
|
resId = R.string.spoken_description_shift_shifted;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
resId = R.string.spoken_description_shift;
|
resId = R.string.spoken_description_shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ import android.view.inputmethod.ExtractedText;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
|
|
||||||
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
|
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
||||||
import com.android.inputmethod.compat.CompatUtils;
|
import com.android.inputmethod.compat.CompatUtils;
|
||||||
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
||||||
import com.android.inputmethod.compat.InputConnectionCompatUtils;
|
import com.android.inputmethod.compat.InputConnectionCompatUtils;
|
||||||
|
@ -2323,6 +2324,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
@Override
|
@Override
|
||||||
public void onReleaseKey(int primaryCode, boolean withSliding) {
|
public void onReleaseKey(int primaryCode, boolean withSliding) {
|
||||||
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding);
|
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding);
|
||||||
|
|
||||||
|
// If accessibility is on, ensure the user receives keyboard state updates.
|
||||||
|
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
||||||
|
switch (primaryCode) {
|
||||||
|
case Keyboard.CODE_SHIFT:
|
||||||
|
AccessibleKeyboardViewProxy.getInstance().notifyShiftState();
|
||||||
|
break;
|
||||||
|
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
||||||
|
AccessibleKeyboardViewProxy.getInstance().notifySymbolsState();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// receive ringer mode change and network state change.
|
// receive ringer mode change and network state change.
|
||||||
|
|
Loading…
Reference in New Issue