diff options
author | 2012-05-31 18:06:03 -0700 | |
---|---|---|
committer | 2012-05-31 18:06:03 -0700 | |
commit | 6fd153e5542adea4af15f91bea8a9ae0bf093ebe (patch) | |
tree | 6b1d9ed5fcc19e6cd33e88502b8090fa318637b8 /java/src | |
parent | 76dbab8eb8e3fcece356801338f48e4c2d0a233e (diff) | |
parent | d30cfee577228873902a16791cd8c3ad3fad4a4c (diff) | |
download | latinime-6fd153e5542adea4af15f91bea8a9ae0bf093ebe.tar.gz latinime-6fd153e5542adea4af15f91bea8a9ae0bf093ebe.tar.xz latinime-6fd153e5542adea4af15f91bea8a9ae0bf093ebe.zip |
am d30cfee5: am 40e5f403: Merge "Add special case for speaking ACTION_ENTER keys." into jb-dev
* commit 'd30cfee577228873902a16791cd8c3ad3fad4a4c':
Add special case for speaking ACTION_ENTER keys.
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 7e1889a74..23acb8b74 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -19,6 +19,7 @@ package com.android.inputmethod.accessibility; import android.content.Context; import android.text.TextUtils; import android.util.Log; +import android.view.inputmethod.EditorInfo; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; @@ -104,6 +105,10 @@ public class KeyCodeDescriptionMapper { return getDescriptionForShiftKey(context, keyboard); } + if (code == Keyboard.CODE_ACTION_ENTER) { + return getDescriptionForActionKey(context, keyboard, key); + } + if (!TextUtils.isEmpty(key.mLabel)) { final String label = key.mLabel.toString().trim(); @@ -192,6 +197,52 @@ public class KeyCodeDescriptionMapper { } /** + * 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 * the specified key is pressed based on its key code. * <p> |