Merge remote branch 'goog/ics-mr1' into ics-aah
This commit is contained in:
commit
e3d45b3f92
4 changed files with 25 additions and 47 deletions
|
@ -23,7 +23,6 @@ import android.graphics.Paint;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewConfiguration;
|
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
|
@ -38,18 +37,12 @@ public class AccessibleKeyboardViewProxy {
|
||||||
private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();
|
private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();
|
||||||
private static final AccessibleKeyboardViewProxy sInstance = new AccessibleKeyboardViewProxy();
|
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 InputMethodService mInputMethod;
|
||||||
private FlickGestureDetector mGestureDetector;
|
private FlickGestureDetector mGestureDetector;
|
||||||
private LatinKeyboardView mView;
|
private LatinKeyboardView mView;
|
||||||
private AccessibleKeyboardActionListener mListener;
|
private AccessibleKeyboardActionListener mListener;
|
||||||
|
|
||||||
private int mScaledEdgeSlop;
|
|
||||||
private int mLastHoverKeyIndex = KeyDetector.NOT_A_KEY;
|
private int mLastHoverKeyIndex = KeyDetector.NOT_A_KEY;
|
||||||
private int mLastX = -1;
|
|
||||||
private int mLastY = -1;
|
|
||||||
|
|
||||||
public static void init(InputMethodService inputMethod, SharedPreferences prefs) {
|
public static void init(InputMethodService inputMethod, SharedPreferences prefs) {
|
||||||
sInstance.initInternal(inputMethod, prefs);
|
sInstance.initInternal(inputMethod, prefs);
|
||||||
|
@ -77,7 +70,6 @@ public class AccessibleKeyboardViewProxy {
|
||||||
|
|
||||||
mInputMethod = inputMethod;
|
mInputMethod = inputMethod;
|
||||||
mGestureDetector = new KeyboardFlickGestureDetector(inputMethod);
|
mGestureDetector = new KeyboardFlickGestureDetector(inputMethod);
|
||||||
mScaledEdgeSlop = ViewConfiguration.get(inputMethod).getScaledEdgeSlop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event,
|
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event,
|
||||||
|
@ -143,26 +135,9 @@ public class AccessibleKeyboardViewProxy {
|
||||||
if (keyIndex != mLastHoverKeyIndex) {
|
if (keyIndex != mLastHoverKeyIndex) {
|
||||||
fireKeyHoverEvent(tracker, mLastHoverKeyIndex, false);
|
fireKeyHoverEvent(tracker, mLastHoverKeyIndex, false);
|
||||||
mLastHoverKeyIndex = keyIndex;
|
mLastHoverKeyIndex = keyIndex;
|
||||||
mLastX = x;
|
|
||||||
mLastY = y;
|
|
||||||
fireKeyHoverEvent(tracker, mLastHoverKeyIndex, true);
|
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;
|
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 {
|
private class KeyboardFlickGestureDetector extends FlickGestureDetector {
|
||||||
public KeyboardFlickGestureDetector(Context context) {
|
public KeyboardFlickGestureDetector(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.inputmethod.compat;
|
package com.android.inputmethod.compat;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.SuggestionSpanPickedNotificationReceiver;
|
import com.android.inputmethod.latin.SuggestionSpanPickedNotificationReceiver;
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
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_AFTER = "after";
|
||||||
public static final String SUGGESTION_SPAN_PICKED_BEFORE = "before";
|
public static final String SUGGESTION_SPAN_PICKED_BEFORE = "before";
|
||||||
public static final String SUGGESTION_SPAN_PICKED_HASHCODE = "hashcode";
|
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;
|
public static final boolean SUGGESTION_SPAN_IS_SUPPORTED;
|
||||||
|
|
||||||
private static final Class<?> CLASS_SuggestionSpan = CompatUtils
|
private static final Class<?> CLASS_SuggestionSpan = CompatUtils
|
||||||
|
@ -49,20 +48,36 @@ public class SuggestionSpanUtils {
|
||||||
Context.class, Locale.class, String[].class, int.class, Class.class };
|
Context.class, Locale.class, String[].class, int.class, Class.class };
|
||||||
private static final Constructor<?> CONSTRUCTOR_SuggestionSpan = CompatUtils
|
private static final Constructor<?> CONSTRUCTOR_SuggestionSpan = CompatUtils
|
||||||
.getConstructor(CLASS_SuggestionSpan, INPUT_TYPE_SuggestionSpan);
|
.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 {
|
static {
|
||||||
SUGGESTION_SPAN_IS_SUPPORTED =
|
SUGGESTION_SPAN_IS_SUPPORTED =
|
||||||
CLASS_SuggestionSpan != null && CONSTRUCTOR_SuggestionSpan != null;
|
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(
|
public static CharSequence getTextWithAutoCorrectionIndicatorUnderline(
|
||||||
Context context, CharSequence text) {
|
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;
|
return text;
|
||||||
}
|
}
|
||||||
final Spannable spannable = text instanceof Spannable
|
final Spannable spannable = text instanceof Spannable
|
||||||
? (Spannable) text : new SpannableString(text);
|
? (Spannable) text : new SpannableString(text);
|
||||||
final Object[] args =
|
final Object[] args =
|
||||||
{ context, null, new String[] {}, FLAG_AUTO_CORRECTION,
|
{ context, null, new String[] {}, (int)OBJ_FLAG_AUTO_CORRECTION,
|
||||||
(Class<?>) SuggestionSpanPickedNotificationReceiver.class };
|
(Class<?>) SuggestionSpanPickedNotificationReceiver.class };
|
||||||
final Object ss = CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan, args);
|
final Object ss = CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan, args);
|
||||||
if (ss == null) {
|
if (ss == null) {
|
||||||
|
@ -78,7 +93,8 @@ public class SuggestionSpanUtils {
|
||||||
CharSequence pickedWord, SuggestedWords suggestedWords) {
|
CharSequence pickedWord, SuggestedWords suggestedWords) {
|
||||||
if (TextUtils.isEmpty(pickedWord) || CONSTRUCTOR_SuggestionSpan == null
|
if (TextUtils.isEmpty(pickedWord) || CONSTRUCTOR_SuggestionSpan == null
|
||||||
|| suggestedWords == null || suggestedWords.size() == 0
|
|| suggestedWords == null || suggestedWords.size() == 0
|
||||||
|| suggestedWords.getInfo(0).isObsoleteSuggestedWord()) {
|
|| suggestedWords.getInfo(0).isObsoleteSuggestedWord()
|
||||||
|
|| OBJ_SUGGESTION_MAX_SIZE == null) {
|
||||||
return pickedWord;
|
return pickedWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +106,7 @@ public class SuggestionSpanUtils {
|
||||||
}
|
}
|
||||||
final ArrayList<String> suggestionsList = new ArrayList<String>();
|
final ArrayList<String> suggestionsList = new ArrayList<String>();
|
||||||
for (int i = 0; i < suggestedWords.size(); ++i) {
|
for (int i = 0; i < suggestedWords.size(); ++i) {
|
||||||
if (suggestionsList.size() >= SUGGESTION_MAX_SIZE) {
|
if (suggestionsList.size() >= OBJ_SUGGESTION_MAX_SIZE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final CharSequence word = suggestedWords.getWord(i);
|
final CharSequence word = suggestedWords.getWord(i);
|
||||||
|
|
|
@ -623,16 +623,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
VoiceProxy.getInstance().onAttachedToWindow();
|
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
|
@Override
|
||||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||||
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
||||||
|
|
|
@ -372,6 +372,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
private boolean mHasPendingFinishInput;
|
private boolean mHasPendingFinishInput;
|
||||||
|
|
||||||
public void startOrientationChanging() {
|
public void startOrientationChanging() {
|
||||||
|
removeMessages(MSG_PENDING_IMS_CALLBACK);
|
||||||
|
resetPendingImsCallback();
|
||||||
mIsOrientationChanging = true;
|
mIsOrientationChanging = true;
|
||||||
final LatinIME latinIme = getOuterInstance();
|
final LatinIME latinIme = getOuterInstance();
|
||||||
latinIme.mKeyboardSwitcher.saveKeyboardState();
|
latinIme.mKeyboardSwitcher.saveKeyboardState();
|
||||||
|
|
Loading…
Reference in a new issue