aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java23
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java3
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java10
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java28
8 files changed, 29 insertions, 53 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
index c76acd126..60d09d6fd 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
@@ -94,6 +94,8 @@ public interface KeyboardActionListener {
public boolean onCustomRequest(int requestCode);
public static class Adapter implements KeyboardActionListener {
+ public static final Adapter EMPTY_LISTENER = new Adapter();
+
@Override
public void onPressKey(int primaryCode) {}
@Override
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index ee8ee9a4f..aa27067bc 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -56,13 +56,8 @@ public final class KeyboardId {
public static final int ELEMENT_PHONE_SYMBOLS = 8;
public static final int ELEMENT_NUMBER = 9;
- public static final int FORM_FACTOR_PHONE = 0;
- public static final int FORM_FACTOR_TABLET7 = 1;
- public static final int FORM_FACTOR_TABLET10 = 2;
-
public final InputMethodSubtype mSubtype;
public final Locale mLocale;
- public final int mDeviceFormFactor;
// TODO: Remove this member. It is used only for logging purpose.
public final int mOrientation;
public final int mWidth;
@@ -82,7 +77,6 @@ public final class KeyboardId {
public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) {
mSubtype = params.mSubtype;
mLocale = SubtypeLocale.getSubtypeLocale(mSubtype);
- mDeviceFormFactor = params.mDeviceFormFactor;
mOrientation = params.mOrientation;
mWidth = params.mKeyboardWidth;
mHeight = params.mKeyboardHeight;
@@ -107,7 +101,6 @@ public final class KeyboardId {
private static int computeHashCode(final KeyboardId id) {
return Arrays.hashCode(new Object[] {
- id.mDeviceFormFactor,
id.mOrientation,
id.mElementId,
id.mMode,
@@ -130,8 +123,7 @@ public final class KeyboardId {
private boolean equals(final KeyboardId other) {
if (other == this)
return true;
- return other.mDeviceFormFactor == mDeviceFormFactor
- && other.mOrientation == mOrientation
+ return other.mOrientation == mOrientation
&& other.mElementId == mElementId
&& other.mMode == mMode
&& other.mWidth == mWidth
@@ -195,11 +187,11 @@ public final class KeyboardId {
public String toString() {
final String orientation = (mOrientation == Configuration.ORIENTATION_PORTRAIT)
? "port" : "land";
- return String.format("[%s %s:%s %s-%s:%dx%d %s %s %s%s%s%s%s%s%s%s%s]",
+ return String.format("[%s %s:%s %s:%dx%d %s %s %s%s%s%s%s%s%s%s%s]",
elementIdToName(mElementId),
mLocale,
mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
- deviceFormFactor(mDeviceFormFactor), orientation, mWidth, mHeight,
+ orientation, mWidth, mHeight,
modeName(mMode),
imeAction(),
(navigateNext() ? "navigateNext" : ""),
@@ -238,15 +230,6 @@ public final class KeyboardId {
}
}
- public static String deviceFormFactor(final int deviceFormFactor) {
- switch (deviceFormFactor) {
- case FORM_FACTOR_PHONE: return "phone";
- case FORM_FACTOR_TABLET7: return "tablet7";
- case FORM_FACTOR_TABLET10: return "tablet10";
- default: return null;
- }
- }
-
public static String modeName(final int mode) {
switch (mode) {
case MODE_TEXT: return "text";
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index 5e68c7067..bc9e8cdd4 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -106,7 +106,6 @@ public final class KeyboardLayoutSet {
boolean mNoSettingsKey;
boolean mLanguageSwitchKeyEnabled;
InputMethodSubtype mSubtype;
- int mDeviceFormFactor;
int mOrientation;
int mKeyboardWidth;
int mKeyboardHeight;
@@ -217,10 +216,8 @@ public final class KeyboardLayoutSet {
mPackageName, NO_SETTINGS_KEY, mEditorInfo);
}
- public Builder setScreenGeometry(final int deviceFormFactor, final int widthPixels,
- final int heightPixels) {
+ public Builder setScreenGeometry(final int widthPixels, final int heightPixels) {
final Params params = mParams;
- params.mDeviceFormFactor = deviceFormFactor;
params.mOrientation = (heightPixels > widthPixels)
? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
setDefaultKeyboardSize(widthPixels, heightPixels);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 4e41b77ce..39afe9072 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -142,8 +142,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mThemeContext, editorInfo);
final Resources res = mThemeContext.getResources();
final DisplayMetrics dm = res.getDisplayMetrics();
- builder.setScreenGeometry(res.getInteger(R.integer.config_device_form_factor),
- dm.widthPixels, dm.heightPixels);
+ builder.setScreenGeometry(dm.widthPixels, dm.heightPixels);
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
builder.setOptions(
settingsValues.isVoiceKeyEnabled(editorInfo),
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index c1b148dbf..0556fddd3 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -176,7 +176,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
private DrawingProxy mDrawingProxy;
private TimerProxy mTimerProxy;
private KeyDetector mKeyDetector;
- private KeyboardActionListener mListener = EMPTY_LISTENER;
+ private KeyboardActionListener mListener = KeyboardActionListener.Adapter.EMPTY_LISTENER;
private Keyboard mKeyboard;
private int mPhantonSuddenMoveThreshold;
@@ -333,10 +333,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
// true if a sliding key input is allowed.
private boolean mIsAllowedSlidingKeyInput;
- // Empty {@link KeyboardActionListener}
- private static final KeyboardActionListener EMPTY_LISTENER =
- new KeyboardActionListener.Adapter();
-
private final GestureStrokeWithPreviewPoints mGestureStrokeWithPreviewPoints;
public static void init(final boolean needsPhantomSuddenMoveEventHack) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
index 53da47c52..93ff26466 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
@@ -83,9 +83,8 @@ public class GestureStroke {
public final int mRecognitionMinimumTime; // msec
public final float mRecognitionSpeedThreshold; // keyWidth/sec
- // Default GestureStroke parameters for test.
- public static final GestureStrokeParams FOR_TEST = new GestureStrokeParams();
- public static final GestureStrokeParams DEFAULT = FOR_TEST;
+ // Default GestureStroke parameters.
+ public static final GestureStrokeParams DEFAULT = new GestureStrokeParams();
private GestureStrokeParams() {
// These parameter values are default and intended for testing.
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
index 477b36e10..235bcd7a5 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
@@ -65,15 +65,15 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
@Override
public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
super.setKeyboardGeometry(keyWidth, keyboardHeight);
- final float samplingRatioToKeyWidth = MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
- mMinPreviewSamplingDistance = keyWidth * samplingRatioToKeyWidth;
+ mMinPreviewSamplingDistance = keyWidth * MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
}
- private boolean needsSampling(final int x, final int y, final boolean isMajorEvent) {
+ private boolean needsSampling(final int x, final int y) {
mDistanceFromLastSample += Math.hypot(x - mLastX, y - mLastY);
mLastX = x;
mLastY = y;
- if (mDistanceFromLastSample >= mMinPreviewSamplingDistance) {
+ final boolean isDownEvent = (mPreviewEventTimes.getLength() == 0);
+ if (mDistanceFromLastSample >= mMinPreviewSamplingDistance || isDownEvent) {
mDistanceFromLastSample = 0.0d;
return true;
}
@@ -83,7 +83,7 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
@Override
public boolean addPointOnKeyboard(final int x, final int y, final int time,
final boolean isMajorEvent) {
- if (needsSampling(x, y, isMajorEvent)) {
+ if (needsSampling(x, y)) {
mPreviewEventTimes.add(time);
mPreviewXCoordinates.add(x);
mPreviewYCoordinates.add(y);
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
index c03b77d98..61850e42e 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
@@ -283,20 +283,6 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
//suggestionsLimit);
final SuggestionsGatherer suggestionsGatherer = mService.newSuggestionsGatherer(
text, suggestionsLimit);
- final WordComposer composer = new WordComposer();
- final int length = text.length();
- for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
- final int codePoint = text.codePointAt(i);
- // The getXYForCodePointAndScript method returns (Y << 16) + X
- final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
- codePoint, mScript);
- if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
- composer.add(codePoint,
- Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
- } else {
- composer.add(codePoint, xy & 0xFFFF, xy >> 16);
- }
- }
final int capitalizeType = StringUtils.getCapitalizationType(text);
boolean isInDict = true;
@@ -306,6 +292,20 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
if (!DictionaryPool.isAValidDictionary(dictInfo)) {
return AndroidSpellCheckerService.getNotInDictEmptySuggestions();
}
+ final WordComposer composer = new WordComposer();
+ final int length = text.length();
+ for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
+ final int codePoint = text.codePointAt(i);
+ // The getXYForCodePointAndScript method returns (Y << 16) + X
+ final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
+ codePoint, mScript);
+ if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
+ composer.add(codePoint,
+ Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
+ } else {
+ composer.add(codePoint, xy & 0xFFFF, xy >> 16);
+ }
+ }
// TODO: make a spell checker option to block offensive words or not
final ArrayList<SuggestedWordInfo> suggestions =
dictInfo.mDictionary.getSuggestions(composer, prevWord,