Loading java/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -188,6 +188,8 @@ <string name="spoken_description_smiley">Smiley face</string> <string name="spoken_description_smiley">Smiley face</string> <!-- Spoken description for the "Return" keyboard key. --> <!-- Spoken description for the "Return" keyboard key. --> <string name="spoken_description_return">Return</string> <string name="spoken_description_return">Return</string> <!-- Spoken description for the "Search" keyboard key. --> <string name="spoken_description_search">Search</string> <!-- Spoken description for the "U+2022" (BULLET) keyboard key. --> <!-- Spoken description for the "U+2022" (BULLET) keyboard key. --> <string name="spoken_description_dot">Dot</string> <string name="spoken_description_dot">Dot</string> Loading java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +51 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.inputmethod.accessibility; import android.content.Context; import android.content.Context; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.inputmethod.EditorInfo; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard; Loading Loading @@ -104,6 +105,10 @@ public class KeyCodeDescriptionMapper { return getDescriptionForShiftKey(context, keyboard); return getDescriptionForShiftKey(context, keyboard); } } if (code == Keyboard.CODE_ACTION_ENTER) { return getDescriptionForActionKey(context, keyboard, key); } if (!TextUtils.isEmpty(key.mLabel)) { if (!TextUtils.isEmpty(key.mLabel)) { final String label = key.mLabel.toString().trim(); final String label = key.mLabel.toString().trim(); Loading Loading @@ -191,6 +196,52 @@ public class KeyCodeDescriptionMapper { return context.getString(resId); return context.getString(resId); } } /** * Returns a context-sensitive description of the "Enter" action key. * * @param context The package's context. * @param keyboard The keyboard on which the key resides. * @param key The key to describe. * @return Returns a context-sensitive description of the "Enter" action * key. */ private String getDescriptionForActionKey(Context context, Keyboard keyboard, Key key) { final KeyboardId keyboardId = keyboard.mId; final int actionId = keyboardId.imeActionId(); final int resId; // Always use the label, if available. if (!TextUtils.isEmpty(key.mLabel)) { return key.mLabel.toString().trim(); } // Otherwise, use the action ID. switch (actionId) { case EditorInfo.IME_ACTION_SEARCH: resId = R.string.spoken_description_search; break; case EditorInfo.IME_ACTION_GO: resId = R.string.label_go_key; break; case EditorInfo.IME_ACTION_SEND: resId = R.string.label_send_key; break; case EditorInfo.IME_ACTION_NEXT: resId = R.string.label_next_key; break; case EditorInfo.IME_ACTION_DONE: resId = R.string.label_done_key; break; case EditorInfo.IME_ACTION_PREVIOUS: resId = R.string.label_previous_key; break; default: resId = R.string.spoken_description_return; } return context.getString(resId); } /** /** * Returns a localized character sequence describing what will happen when * Returns a localized character sequence describing what will happen when * the specified key is pressed based on its key code. * the specified key is pressed based on its key code. Loading Loading
java/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -188,6 +188,8 @@ <string name="spoken_description_smiley">Smiley face</string> <string name="spoken_description_smiley">Smiley face</string> <!-- Spoken description for the "Return" keyboard key. --> <!-- Spoken description for the "Return" keyboard key. --> <string name="spoken_description_return">Return</string> <string name="spoken_description_return">Return</string> <!-- Spoken description for the "Search" keyboard key. --> <string name="spoken_description_search">Search</string> <!-- Spoken description for the "U+2022" (BULLET) keyboard key. --> <!-- Spoken description for the "U+2022" (BULLET) keyboard key. --> <string name="spoken_description_dot">Dot</string> <string name="spoken_description_dot">Dot</string> Loading
java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +51 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.inputmethod.accessibility; import android.content.Context; import android.content.Context; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.inputmethod.EditorInfo; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard; Loading Loading @@ -104,6 +105,10 @@ public class KeyCodeDescriptionMapper { return getDescriptionForShiftKey(context, keyboard); return getDescriptionForShiftKey(context, keyboard); } } if (code == Keyboard.CODE_ACTION_ENTER) { return getDescriptionForActionKey(context, keyboard, key); } if (!TextUtils.isEmpty(key.mLabel)) { if (!TextUtils.isEmpty(key.mLabel)) { final String label = key.mLabel.toString().trim(); final String label = key.mLabel.toString().trim(); Loading Loading @@ -191,6 +196,52 @@ public class KeyCodeDescriptionMapper { return context.getString(resId); return context.getString(resId); } } /** * Returns a context-sensitive description of the "Enter" action key. * * @param context The package's context. * @param keyboard The keyboard on which the key resides. * @param key The key to describe. * @return Returns a context-sensitive description of the "Enter" action * key. */ private String getDescriptionForActionKey(Context context, Keyboard keyboard, Key key) { final KeyboardId keyboardId = keyboard.mId; final int actionId = keyboardId.imeActionId(); final int resId; // Always use the label, if available. if (!TextUtils.isEmpty(key.mLabel)) { return key.mLabel.toString().trim(); } // Otherwise, use the action ID. switch (actionId) { case EditorInfo.IME_ACTION_SEARCH: resId = R.string.spoken_description_search; break; case EditorInfo.IME_ACTION_GO: resId = R.string.label_go_key; break; case EditorInfo.IME_ACTION_SEND: resId = R.string.label_send_key; break; case EditorInfo.IME_ACTION_NEXT: resId = R.string.label_next_key; break; case EditorInfo.IME_ACTION_DONE: resId = R.string.label_done_key; break; case EditorInfo.IME_ACTION_PREVIOUS: resId = R.string.label_previous_key; break; default: resId = R.string.spoken_description_return; } return context.getString(resId); } /** /** * Returns a localized character sequence describing what will happen when * Returns a localized character sequence describing what will happen when * the specified key is pressed based on its key code. * the specified key is pressed based on its key code. Loading