diff options
Diffstat (limited to 'java')
6 files changed, 76 insertions, 19 deletions
diff --git a/java/res/values-ru/strings.xml b/java/res/values-ru/strings.xml index ad1f1410c..1eacb44d8 100644 --- a/java/res/values-ru/strings.xml +++ b/java/res/values-ru/strings.xml @@ -121,7 +121,7 @@ <string name="subtype_with_layout_en_GB" msgid="2179097748724725906">"Английская (Великобр.) (<xliff:g id="LAYOUT">%s</xliff:g>)"</string> <string name="subtype_with_layout_en_US" msgid="1362581347576714579">"Английская (США) (<xliff:g id="LAYOUT">%s</xliff:g>)"</string> <string name="subtype_no_language" msgid="141420857808801746">"Язык не указан"</string> - <string name="subtype_no_language_qwerty" msgid="2956121451616633133">"Язык не указан (QWERTY)"</string> + <string name="subtype_no_language_qwerty" msgid="2956121451616633133">"QWERTY-клавиатура"</string> <string name="subtype_no_language_qwertz" msgid="1177848172397202890">"Язык не задан (QWERTZ)"</string> <string name="subtype_no_language_azerty" msgid="8721460968141187394">"Язык не задан (AZERTY)"</string> <string name="subtype_no_language_dvorak" msgid="3122976737669823935">"Язык не задан (Dvorak)"</string> diff --git a/java/res/values-zh-rCN/strings.xml b/java/res/values-zh-rCN/strings.xml index 06728cc05..c1479b634 100644 --- a/java/res/values-zh-rCN/strings.xml +++ b/java/res/values-zh-rCN/strings.xml @@ -134,10 +134,10 @@ <string name="save" msgid="7646738597196767214">"保存"</string> <string name="subtype_locale" msgid="8576443440738143764">"语言"</string> <string name="keyboard_layout_set" msgid="4309233698194565609">"布局"</string> - <string name="custom_input_style_note_message" msgid="8826731320846363423">"您需要先启用自定义输入样式,然后才能开始使用。要立即启用该样式吗?"</string> + <string name="custom_input_style_note_message" msgid="8826731320846363423">"您需要先启用自定义输入风格,然后才能开始使用。要立即启用该风格吗?"</string> <string name="enable" msgid="5031294444630523247">"启用"</string> <string name="not_now" msgid="6172462888202790482">"以后再说"</string> - <string name="custom_input_style_already_exists" msgid="8008728952215449707">"已经存在相同的输入样式:<xliff:g id="INPUT_STYLE_NAME">%s</xliff:g>"</string> + <string name="custom_input_style_already_exists" msgid="8008728952215449707">"已经存在相同的输入风格:<xliff:g id="INPUT_STYLE_NAME">%s</xliff:g>"</string> <string name="prefs_usability_study_mode" msgid="1261130555134595254">"可用性研究模式"</string> <string name="prefs_keypress_vibration_duration_settings" msgid="1829950405285211668">"按键振动持续时间设置"</string> <string name="prefs_keypress_sound_volume_settings" msgid="5875933757082305040">"按键音量设置"</string> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index e1f03714a..d51d3789a 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -188,6 +188,8 @@ <string name="spoken_description_smiley">Smiley face</string> <!-- Spoken description for the "Return" keyboard key. --> <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. --> <string name="spoken_description_dot">Dot</string> diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java index 8bc789317..9986f6ec0 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java @@ -29,7 +29,6 @@ import android.util.Log; import android.util.SparseArray; import android.view.MotionEvent; import android.view.View; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.accessibility.AccessibilityEvent; import android.view.inputmethod.EditorInfo; @@ -51,7 +50,6 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat private static final String TAG = AccessibilityEntityProvider.class.getSimpleName(); private static final int UNDEFINED = Integer.MIN_VALUE; - private final KeyboardView mKeyboardView; private final InputMethodService mInputMethodService; private final KeyCodeDescriptionMapper mKeyCodeDescriptionMapper; private final AccessibilityUtils mAccessibilityUtils; @@ -68,18 +66,28 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat /** The virtual view identifier for the focused node. */ private int mAccessibilityFocusedView = UNDEFINED; + /** The current keyboard view. */ + private KeyboardView mKeyboardView; + public AccessibilityEntityProvider(KeyboardView keyboardView, InputMethodService inputMethod) { - mKeyboardView = keyboardView; mInputMethodService = inputMethod; mKeyCodeDescriptionMapper = KeyCodeDescriptionMapper.getInstance(); mAccessibilityUtils = AccessibilityUtils.getInstance(); + setView(keyboardView); + } + + /** + * Sets the keyboard view represented by this node provider. + * + * @param keyboardView The keyboard view to represent. + */ + public void setView(KeyboardView keyboardView) { + mKeyboardView = keyboardView; + assignVirtualViewIds(); updateParentLocation(); - - // Ensure that the on-screen bounds are cleared when the layout changes. - mKeyboardView.getViewTreeObserver().addOnGlobalLayoutListener(mGlobalLayoutListener); } /** @@ -196,8 +204,8 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat * @param key The key to press. */ void simulateKeyPress(Key key) { - final int x = key.mX + (key.mWidth / 2); - final int y = key.mY + (key.mHeight / 2); + final int x = key.mHitBox.centerX(); + final int y = key.mHitBox.centerY(); final long downTime = SystemClock.uptimeMillis(); final MotionEvent downEvent = MotionEvent.obtain( downTime, downTime, MotionEvent.ACTION_DOWN, x, y, 0); @@ -331,12 +339,4 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat // left-half of the integer and OR'ing with the y-coordinate. return ((0xFFFF & key.mX) << (Integer.SIZE / 2)) | (0xFFFF & key.mY); } - - private final OnGlobalLayoutListener mGlobalLayoutListener = new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - assignVirtualViewIds(); - updateParentLocation(); - } - }; } diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index 2623dcc03..59f1eec04 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -80,6 +80,10 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat { // Ensure that the view has an accessibility delegate. ViewCompat.setAccessibilityDelegate(view, this); + + if (mAccessibilityNodeProvider != null) { + mAccessibilityNodeProvider.setView(view); + } } /** 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> |