aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-05-11 20:48:20 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-05-12 00:14:55 +0900
commit101a00e3d4b1c29ef2ecdecd1b72b43efde7791a (patch)
tree263b4a9ef75c661661dbd99c835ffd9e0b5bd2df /java/src
parent260fce0a2cb9c47bc6065402bf35d13d80e3e64b (diff)
downloadlatinime-101a00e3d4b1c29ef2ecdecd1b72b43efde7791a.tar.gz
latinime-101a00e3d4b1c29ef2ecdecd1b72b43efde7791a.tar.xz
latinime-101a00e3d4b1c29ef2ecdecd1b72b43efde7791a.zip
Revert "Added support for speaking keys through accessibility service."
This reverts commit dcade18113286a132a2f5fb508fdba836470c3fb. Bug: 4379983 Change-Id: I2448d8f03990a39a3e328a88904d82efc70241a2
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java22
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java40
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java28
-rw-r--r--java/src/com/android/inputmethod/latin/AccessibilityUtils.java211
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java14
6 files changed, 13 insertions, 306 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 4f1ad576d..333fbc779 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -340,8 +340,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
// state when shift key is pressed to go to normal mode.
// On the other hand, on distinct multi touch panel device, turning off the shift locked
// state with shift key pressing is handled by onReleaseShift().
- if ((!hasDistinctMultitouch() || isAccessibilityEnabled())
- && !shifted && latinKeyboard.isShiftLocked()) {
+ if (!hasDistinctMultitouch() && !shifted && latinKeyboard.isShiftLocked()) {
latinKeyboard.setShiftLocked(false);
}
if (latinKeyboard.setShifted(shifted)) {
@@ -439,9 +438,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
public void onPressShift(boolean withSliding) {
if (!isKeyboardAvailable())
return;
- // If accessibility is enabled, disable momentary shift lock.
- if (isAccessibilityEnabled())
- return;
ShiftKeyState shiftKeyState = mShiftKeyState;
if (DEBUG_STATE)
Log.d(TAG, "onPressShift:"
@@ -478,9 +474,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
public void onReleaseShift(boolean withSliding) {
if (!isKeyboardAvailable())
return;
- // If accessibility is enabled, disable momentary shift lock.
- if (isAccessibilityEnabled())
- return;
ShiftKeyState shiftKeyState = mShiftKeyState;
if (DEBUG_STATE)
Log.d(TAG, "onReleaseShift:"
@@ -518,9 +511,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
public void onPressSymbol() {
- // If accessibility is enabled, disable momentary symbol lock.
- if (isAccessibilityEnabled())
- return;
if (DEBUG_STATE)
Log.d(TAG, "onPressSymbol:"
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
@@ -531,9 +521,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
public void onReleaseSymbol() {
- // If accessibility is enabled, disable momentary symbol lock.
- if (isAccessibilityEnabled())
- return;
if (DEBUG_STATE)
Log.d(TAG, "onReleaseSymbol:"
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
@@ -547,9 +534,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
public void onOtherKeyPressed() {
- // If accessibility is enabled, disable momentary mode locking.
- if (isAccessibilityEnabled())
- return;
if (DEBUG_STATE)
Log.d(TAG, "onOtherKeyPressed:"
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
@@ -612,10 +596,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
}
- public boolean isAccessibilityEnabled() {
- return mInputView != null && mInputView.isAccessibilityEnabled();
- }
-
public boolean hasDistinctMultitouch() {
return mInputView != null && mInputView.hasDistinctMultitouch();
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 08e739d5a..c551ed49f 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -134,9 +134,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private int mOldPointerCount = 1;
private int mOldKeyIndex;
- // Accessibility
- private boolean mIsAccessibilityEnabled;
-
protected KeyDetector mKeyDetector = new KeyDetector();
// Swipe gesture detector
@@ -530,29 +527,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
}
/**
- * Enables or disables accessibility.
- * @param accessibilityEnabled whether or not to enable accessibility
- */
- public void setAccessibilityEnabled(boolean accessibilityEnabled) {
- mIsAccessibilityEnabled = accessibilityEnabled;
-
- // Propagate this change to all existing pointer trackers.
- for (PointerTracker tracker : mPointerTrackers) {
- tracker.setAccessibilityEnabled(accessibilityEnabled);
- }
- }
-
- /**
- * Returns whether the device has accessibility enabled.
- * @return true if the device has accessibility enabled.
- */
- @Override
- public boolean isAccessibilityEnabled() {
- return mIsAccessibilityEnabled;
- }
-
- /**
- * Enables or disables the key feedback preview. This is a preview that shows a magnified
+ * Enables or disables the key feedback popup. This is a popup that shows a magnified
* version of the depressed key. By default the preview is enabled.
* @param previewEnabled whether or not to enable the key feedback preview
* @see #isKeyPreviewEnabled()
@@ -1182,19 +1157,16 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// TODO: cleanup this code into a multi-touch to single-touch event converter class?
// If the device does not have distinct multi-touch support panel, ignore all multi-touch
// events except a transition from/to single-touch.
- if ((!mHasDistinctMultitouch || mIsAccessibilityEnabled)
- && pointerCount > 1 && oldPointerCount > 1) {
+ if (!mHasDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
return true;
}
// Track the last few movements to look for spurious swipes.
mSwipeTracker.addMovement(me);
- // Gesture detector must be enabled only when mini-keyboard is not on the screen and
- // accessibility is not enabled.
- // TODO: Reconcile gesture detection and accessibility features.
- if (mPopupMiniKeyboardPanel == null && !mIsAccessibilityEnabled
- && mGestureDetector != null && mGestureDetector.onTouchEvent(me)) {
+ // Gesture detector must be enabled only when mini-keyboard is not on the screen.
+ if (mPopupMiniKeyboardPanel == null && mGestureDetector != null
+ && mGestureDetector.onTouchEvent(me)) {
dismissAllKeyPreviews();
mHandler.cancelKeyTimers();
return true;
@@ -1225,7 +1197,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// TODO: cleanup this code into a multi-touch to single-touch event converter class?
// Translate mutli-touch event to single-touch events on the device that has no distinct
// multi-touch panel.
- if (!mHasDistinctMultitouch || mIsAccessibilityEnabled) {
+ if (!mHasDistinctMultitouch) {
// Use only main (id=0) pointer tracker.
PointerTracker tracker = getPointerTracker(0);
if (pointerCount == 1 && oldPointerCount == 2) {
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index efc446a0d..c98076f35 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -140,10 +140,6 @@ public class LatinKeyboardView extends KeyboardView {
// If device has distinct multi touch panel, there is no need to check sudden jump.
if (hasDistinctMultitouch())
return false;
- // If accessibiliy is enabled, stop looking for sudden jumps because it interferes
- // with touch exploration of the keyboard.
- if (isAccessibilityEnabled())
- return false;
final int action = me.getAction();
final int x = (int) me.getX();
final int y = (int) me.getY();
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index abd1ef286..953d487dc 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -41,7 +41,6 @@ public class PointerTracker {
public void showKeyPreview(int keyIndex, PointerTracker tracker);
public void dismissKeyPreview(PointerTracker tracker);
public boolean hasDistinctMultitouch();
- public boolean isAccessibilityEnabled();
}
public final int mPointerId;
@@ -70,9 +69,6 @@ public class PointerTracker {
private final PointerTrackerKeyState mKeyState;
- // true if accessibility is enabled in the parent keyboard
- private boolean mIsAccessibilityEnabled;
-
// true if keyboard layout has been changed.
private boolean mKeyboardLayoutHasBeenChanged;
@@ -124,7 +120,6 @@ public class PointerTracker {
mKeyDetector = keyDetector;
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
mKeyState = new PointerTrackerKeyState(keyDetector);
- mIsAccessibilityEnabled = proxy.isAccessibilityEnabled();
mHasDistinctMultitouch = proxy.hasDistinctMultitouch();
final Resources res = mKeyboardView.getResources();
mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled);
@@ -143,10 +138,6 @@ public class PointerTracker {
mListener = listener;
}
- public void setAccessibilityEnabled(boolean accessibilityEnabled) {
- mIsAccessibilityEnabled = accessibilityEnabled;
- }
-
// Returns true if keyboard has been changed by this callback.
private boolean callListenerOnPressAndCheckKeyboardLayoutChange(Key key, boolean withSliding) {
final boolean ignoreModifierKey = mIgnoreModifierKey && isModifierCode(key.mCode);
@@ -342,10 +333,9 @@ public class PointerTracker {
private void onDownEventInternal(int x, int y, long eventTime) {
int keyIndex = mKeyState.onDownKey(x, y, eventTime);
// Sliding key is allowed when 1) enabled by configuration, 2) this pointer starts sliding
- // from modifier key, 3) this pointer is on mini-keyboard, or 4) accessibility is enabled.
+ // from modifier key, or 3) this pointer is on mini-keyboard.
mIsAllowedSlidingKeyInput = mConfigSlidingKeyInputEnabled || isModifierInternal(keyIndex)
- || mKeyDetector instanceof MiniKeyboardKeyDetector
- || mIsAccessibilityEnabled;
+ || mKeyDetector instanceof MiniKeyboardKeyDetector;
mKeyboardLayoutHasBeenChanged = false;
mKeyAlreadyProcessed = false;
mIsRepeatableKey = false;
@@ -575,10 +565,8 @@ public class PointerTracker {
}
private void startRepeatKey(int keyIndex) {
- // Accessibility disables key repeat because users may need to pause on a key to hear
- // its spoken description.
final Key key = getKey(keyIndex);
- if (key != null && key.mRepeatable && !mIsAccessibilityEnabled) {
+ if (key != null && key.mRepeatable) {
dismissKeyPreview();
onRepeatKey(keyIndex);
mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
@@ -620,14 +608,11 @@ public class PointerTracker {
}
}
- // The modifier key, such as shift key, should not show its key preview. If accessibility is
- // turned on, the modifier key should show its key preview.
+ // The modifier key, such as shift key, should not show its key preview.
private boolean isKeyPreviewNotRequired(int keyIndex) {
final Key key = getKey(keyIndex);
if (!key.mEnabled)
return true;
- if (mIsAccessibilityEnabled)
- return false;
// Such as spacebar sliding language switch.
if (mKeyboard.needSpacebarPreview(keyIndex))
return false;
@@ -647,11 +632,6 @@ public class PointerTracker {
}
private void startLongPressTimer(int keyIndex) {
- // Accessibility disables long press because users are likely to need to pause on a key
- // for an unspecified duration in order to hear the key's spoken description.
- if (mIsAccessibilityEnabled) {
- return;
- }
Key key = getKey(keyIndex);
if (!key.mEnabled)
return;
diff --git a/java/src/com/android/inputmethod/latin/AccessibilityUtils.java b/java/src/com/android/inputmethod/latin/AccessibilityUtils.java
deleted file mode 100644
index cd3f9e0ad..000000000
--- a/java/src/com/android/inputmethod/latin/AccessibilityUtils.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.latin;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.res.TypedArray;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
-
-import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.keyboard.KeyboardSwitcher;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Utility functions for accessibility support.
- */
-public class AccessibilityUtils {
- /** Shared singleton instance. */
- private static final AccessibilityUtils sInstance = new AccessibilityUtils();
- private /* final */ LatinIME mService;
- private /* final */ AccessibilityManager mAccessibilityManager;
- private /* final */ Map<Integer, CharSequence> mDescriptions;
-
- /**
- * Returns a shared instance of AccessibilityUtils.
- *
- * @return A shared instance of AccessibilityUtils.
- */
- public static AccessibilityUtils getInstance() {
- return sInstance;
- }
-
- /**
- * Initializes (or re-initializes) the shared instance of AccessibilityUtils
- * with the specified parent service and preferences.
- *
- * @param service The parent input method service.
- * @param prefs The parent preferences.
- */
- public static void init(LatinIME service, SharedPreferences prefs) {
- sInstance.initialize(service, prefs);
- }
-
- private AccessibilityUtils() {
- // This class is not publicly instantiable.
- }
-
- /**
- * Initializes (or re-initializes) with the specified parent service and
- * preferences.
- *
- * @param service The parent input method service.
- * @param prefs The parent preferences.
- */
- private void initialize(LatinIME service, SharedPreferences prefs) {
- mService = service;
- mAccessibilityManager = (AccessibilityManager) service.getSystemService(
- Context.ACCESSIBILITY_SERVICE);
- mDescriptions = null;
- }
-
- /**
- * Returns true if accessibility is enabled.
- *
- * @return {@code true} if accessibility is enabled.
- */
- public boolean isAccessibilityEnabled() {
- return mAccessibilityManager.isEnabled();
- }
-
- /**
- * Speaks a key's action after it has been released. Does not speak letter
- * keys since typed keys are already spoken aloud by TalkBack.
- * <p>
- * No-op if accessibility is not enabled.
- * </p>
- *
- * @param primaryCode The primary code of the released key.
- * @param switcher The input method's {@link KeyboardSwitcher}.
- */
- public void onRelease(int primaryCode, KeyboardSwitcher switcher) {
- if (!isAccessibilityEnabled()) {
- return;
- }
-
- int resId = -1;
-
- switch (primaryCode) {
- case Keyboard.CODE_SHIFT: {
- if (switcher.isShiftedOrShiftLocked()) {
- resId = R.string.description_shift_on;
- } else {
- resId = R.string.description_shift_off;
- }
- break;
- }
-
- case Keyboard.CODE_SWITCH_ALPHA_SYMBOL: {
- if (switcher.isAlphabetMode()) {
- resId = R.string.description_symbols_off;
- } else {
- resId = R.string.description_symbols_on;
- }
- break;
- }
- }
-
- if (resId >= 0) {
- speakDescription(mService.getResources().getText(resId));
- }
- }
-
- /**
- * Speaks a key's description for accessibility. If a key has an explicit
- * description defined in keycodes.xml, that will be used. Otherwise, if the
- * key is a Unicode character, then its character will be used.
- * <p>
- * No-op if accessibility is not enabled.
- * </p>
- *
- * @param primaryCode The primary code of the pressed key.
- * @param switcher The input method's {@link KeyboardSwitcher}.
- */
- public void onPress(int primaryCode, KeyboardSwitcher switcher) {
- if (!isAccessibilityEnabled()) {
- return;
- }
-
- // TODO Use the current keyboard state to read "Switch to symbols"
- // instead of just "Symbols" (and similar for shift key).
- CharSequence description = describeKey(primaryCode);
- if (description == null && Character.isDefined((char) primaryCode)) {
- description = Character.toString((char) primaryCode);
- }
-
- if (description != null) {
- speakDescription(description);
- }
- }
-
- /**
- * Returns a text description for a given key code. If the key does not have
- * an explicit description, returns <code>null</code>.
- *
- * @param keyCode An integer key code.
- * @return A {@link CharSequence} describing the key or <code>null</code> if
- * no description is available.
- */
- private CharSequence describeKey(int keyCode) {
- // If not loaded yet, load key descriptions from XML file.
- if (mDescriptions == null) {
- mDescriptions = loadDescriptions();
- }
-
- return mDescriptions.get(keyCode);
- }
-
- /**
- * Loads key descriptions from resources.
- */
- private Map<Integer, CharSequence> loadDescriptions() {
- final Map<Integer, CharSequence> descriptions = new HashMap<Integer, CharSequence>();
- final TypedArray array = mService.getResources().obtainTypedArray(R.array.key_descriptions);
-
- // Key descriptions are stored as a key code followed by a string.
- for (int i = 0; i < array.length() - 1; i += 2) {
- int code = array.getInteger(i, 0);
- CharSequence desc = array.getText(i + 1);
-
- descriptions.put(code, desc);
- }
-
- array.recycle();
-
- return descriptions;
- }
-
- /**
- * Sends a character sequence to be read aloud.
- *
- * @param description The {@link CharSequence} to be read aloud.
- */
- private void speakDescription(CharSequence description) {
- // TODO We need to add an AccessibilityEvent type for IMEs.
- final AccessibilityEvent event = AccessibilityEvent.obtain(
- AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
- event.setPackageName(mService.getPackageName());
- event.setClassName(getClass().getName());
- event.setAddedCount(description.length());
- event.getText().add(description);
-
- mAccessibilityManager.sendAccessibilityEvent(event);
- }
-}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index d15fc36d9..8b130aecd 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -164,8 +164,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private boolean mIsSettingsSuggestionStripOn;
private boolean mApplicationSpecifiedCompletionOn;
- private AccessibilityUtils mAccessibilityUtils;
-
private final StringBuilder mComposing = new StringBuilder();
private WordComposer mWord = new WordComposer();
private CharSequence mBestWord;
@@ -350,7 +348,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
LanguageSwitcherProxy.init(this, prefs);
SubtypeSwitcher.init(this, prefs);
KeyboardSwitcher.init(this, prefs);
- AccessibilityUtils.init(this, prefs);
Recorrection.init(this, prefs);
super.onCreate();
@@ -359,7 +356,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mInputMethodId = Utils.getInputMethodId(mImm, getPackageName());
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
- mAccessibilityUtils = AccessibilityUtils.getInstance();
mRecorrection = Recorrection.getInstance();
loadSettings();
@@ -559,11 +555,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
updateCorrectionMode();
- final boolean accessibilityEnabled = mAccessibilityUtils.isAccessibilityEnabled();
-
inputView.setKeyPreviewEnabled(mSettingsValues.mPopupOn);
inputView.setProximityCorrectionEnabled(true);
- inputView.setAccessibilityEnabled(accessibilityEnabled);
// If we just entered a text field, maybe it has some old text that requires correction
mRecorrection.checkRecorrectionOnStart();
inputView.setForeground(true);
@@ -1046,7 +1039,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
mLastKeyTime = when;
KeyboardSwitcher switcher = mKeyboardSwitcher;
- final boolean accessibilityEnabled = switcher.isAccessibilityEnabled();
final boolean distinctMultiTouch = switcher.hasDistinctMultitouch();
switch (primaryCode) {
case Keyboard.CODE_DELETE:
@@ -1056,12 +1048,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
break;
case Keyboard.CODE_SHIFT:
// Shift key is handled in onPress() when device has distinct multi-touch panel.
- if (!distinctMultiTouch || accessibilityEnabled)
+ if (!distinctMultiTouch)
switcher.toggleShift();
break;
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
// Symbol key is handled in onPress() when device has distinct multi-touch panel.
- if (!distinctMultiTouch || accessibilityEnabled)
+ if (!distinctMultiTouch)
switcher.changeKeyboardMode();
break;
case Keyboard.CODE_CANCEL:
@@ -1838,7 +1830,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} else {
switcher.onOtherKeyPressed();
}
- mAccessibilityUtils.onPress(primaryCode, switcher);
}
@Override
@@ -1851,7 +1842,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} else if (distinctMultiTouch && primaryCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
switcher.onReleaseSymbol();
}
- mAccessibilityUtils.onRelease(primaryCode, switcher);
}