Merge remote branch 'goog/ics-mr1' into ics-aah

This commit is contained in:
Ed Heyl 2011-10-31 05:54:48 -07:00
commit e3d45b3f92
4 changed files with 25 additions and 47 deletions

View file

@ -23,7 +23,6 @@ import android.graphics.Paint;
import android.inputmethodservice.InputMethodService;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.EditorInfo;
@ -38,18 +37,12 @@ public class AccessibleKeyboardViewProxy {
private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();
private static final AccessibleKeyboardViewProxy sInstance = new AccessibleKeyboardViewProxy();
// Delay in milliseconds between key press DOWN and UP events
private static final long DELAY_KEY_PRESS = 10;
private InputMethodService mInputMethod;
private FlickGestureDetector mGestureDetector;
private LatinKeyboardView mView;
private AccessibleKeyboardActionListener mListener;
private int mScaledEdgeSlop;
private int mLastHoverKeyIndex = KeyDetector.NOT_A_KEY;
private int mLastX = -1;
private int mLastY = -1;
public static void init(InputMethodService inputMethod, SharedPreferences prefs) {
sInstance.initInternal(inputMethod, prefs);
@ -77,7 +70,6 @@ public class AccessibleKeyboardViewProxy {
mInputMethod = inputMethod;
mGestureDetector = new KeyboardFlickGestureDetector(inputMethod);
mScaledEdgeSlop = ViewConfiguration.get(inputMethod).getScaledEdgeSlop();
}
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event,
@ -143,26 +135,9 @@ public class AccessibleKeyboardViewProxy {
if (keyIndex != mLastHoverKeyIndex) {
fireKeyHoverEvent(tracker, mLastHoverKeyIndex, false);
mLastHoverKeyIndex = keyIndex;
mLastX = x;
mLastY = y;
fireKeyHoverEvent(tracker, mLastHoverKeyIndex, true);
}
return true;
case MotionEventCompatUtils.ACTION_HOVER_EXIT:
final int width = mView.getWidth();
final int height = mView.getHeight();
if (x < mScaledEdgeSlop || y < mScaledEdgeSlop || x >= (width - mScaledEdgeSlop)
|| y >= (height - mScaledEdgeSlop)) {
fireKeyHoverEvent(tracker, mLastHoverKeyIndex, false);
mLastHoverKeyIndex = KeyDetector.NOT_A_KEY;
mLastX = -1;
mLastY = -1;
} else if (mLastHoverKeyIndex != KeyDetector.NOT_A_KEY) {
fireKeyPressEvent(tracker, mLastX, mLastY, event.getEventTime());
}
return true;
}
@ -197,11 +172,6 @@ public class AccessibleKeyboardViewProxy {
}
}
private void fireKeyPressEvent(PointerTracker tracker, int x, int y, long eventTime) {
tracker.onDownEvent(x, y, eventTime, mView);
tracker.onUpEvent(x, y, eventTime + DELAY_KEY_PRESS);
}
private class KeyboardFlickGestureDetector extends FlickGestureDetector {
public KeyboardFlickGestureDetector(Context context) {
super(context);

View file

@ -16,6 +16,7 @@
package com.android.inputmethod.compat;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestionSpanPickedNotificationReceiver;
@ -27,6 +28,7 @@ import android.text.TextUtils;
import android.util.Log;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Locale;
@ -38,9 +40,6 @@ public class SuggestionSpanUtils {
public static final String SUGGESTION_SPAN_PICKED_AFTER = "after";
public static final String SUGGESTION_SPAN_PICKED_BEFORE = "before";
public static final String SUGGESTION_SPAN_PICKED_HASHCODE = "hashcode";
// TODO: Use the API constant after it gets public.
public static final int FLAG_AUTO_CORRECTION = 0x0004;
public static final int SUGGESTION_MAX_SIZE = 5;
public static final boolean SUGGESTION_SPAN_IS_SUPPORTED;
private static final Class<?> CLASS_SuggestionSpan = CompatUtils
@ -49,20 +48,36 @@ public class SuggestionSpanUtils {
Context.class, Locale.class, String[].class, int.class, Class.class };
private static final Constructor<?> CONSTRUCTOR_SuggestionSpan = CompatUtils
.getConstructor(CLASS_SuggestionSpan, INPUT_TYPE_SuggestionSpan);
public static final Field FIELD_FLAG_AUTO_CORRECTION
= CompatUtils.getField(CLASS_SuggestionSpan, "FLAG_AUTO_CORRECTION");
public static final Field FIELD_SUGGESTION_MAX_SIZE
= CompatUtils.getField(CLASS_SuggestionSpan, "SUGGESTION_MAX_SIZE");
public static final Integer OBJ_FLAG_AUTO_CORRECTION = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_FLAG_AUTO_CORRECTION);;
public static final Integer OBJ_SUGGESTION_MAX_SIZE = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_SUGGESTION_MAX_SIZE);;
static {
SUGGESTION_SPAN_IS_SUPPORTED =
CLASS_SuggestionSpan != null && CONSTRUCTOR_SuggestionSpan != null;
if (LatinImeLogger.sDBG) {
if (SUGGESTION_SPAN_IS_SUPPORTED
&& (OBJ_FLAG_AUTO_CORRECTION == null || OBJ_SUGGESTION_MAX_SIZE == null)) {
Log.e(TAG, "Field is accidentially null.");
}
}
}
public static CharSequence getTextWithAutoCorrectionIndicatorUnderline(
Context context, CharSequence text) {
if (TextUtils.isEmpty(text) || CONSTRUCTOR_SuggestionSpan == null) {
if (TextUtils.isEmpty(text) || CONSTRUCTOR_SuggestionSpan == null
|| OBJ_FLAG_AUTO_CORRECTION == null) {
return text;
}
final Spannable spannable = text instanceof Spannable
? (Spannable) text : new SpannableString(text);
final Object[] args =
{ context, null, new String[] {}, FLAG_AUTO_CORRECTION,
{ context, null, new String[] {}, (int)OBJ_FLAG_AUTO_CORRECTION,
(Class<?>) SuggestionSpanPickedNotificationReceiver.class };
final Object ss = CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan, args);
if (ss == null) {
@ -78,7 +93,8 @@ public class SuggestionSpanUtils {
CharSequence pickedWord, SuggestedWords suggestedWords) {
if (TextUtils.isEmpty(pickedWord) || CONSTRUCTOR_SuggestionSpan == null
|| suggestedWords == null || suggestedWords.size() == 0
|| suggestedWords.getInfo(0).isObsoleteSuggestedWord()) {
|| suggestedWords.getInfo(0).isObsoleteSuggestedWord()
|| OBJ_SUGGESTION_MAX_SIZE == null) {
return pickedWord;
}
@ -90,7 +106,7 @@ public class SuggestionSpanUtils {
}
final ArrayList<String> suggestionsList = new ArrayList<String>();
for (int i = 0; i < suggestedWords.size(); ++i) {
if (suggestionsList.size() >= SUGGESTION_MAX_SIZE) {
if (suggestionsList.size() >= OBJ_SUGGESTION_MAX_SIZE) {
break;
}
final CharSequence word = suggestedWords.getWord(i);

View file

@ -623,16 +623,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
VoiceProxy.getInstance().onAttachedToWindow();
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
// Drop non-hover touch events when touch exploration is enabled.
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
return false;
}
return super.dispatchTouchEvent(event);
}
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {

View file

@ -372,6 +372,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private boolean mHasPendingFinishInput;
public void startOrientationChanging() {
removeMessages(MSG_PENDING_IMS_CALLBACK);
resetPendingImsCallback();
mIsOrientationChanging = true;
final LatinIME latinIme = getOuterInstance();
latinIme.mKeyboardSwitcher.saveKeyboardState();