From 36799b2aa2982ec17341cd2c5ed81e608bcee8c6 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 29 Oct 2014 11:37:21 +0900 Subject: [PATCH] Move InputPointers and ResizableIntArray to common Bug: 18108776 Change-Id: Ie5c0430aa41a8d6c58bf510a10173223d7dfe9fe --- .../latin/common}/InputPointers.java | 38 ++----------------- .../latin/common}/ResizableIntArray.java | 2 +- .../touchinputconsumer/GestureConsumer.java | 2 +- .../keyboard/KeyboardActionListener.java | 2 +- .../inputmethod/keyboard/PointerTracker.java | 2 +- .../keyboard/internal/BatchInputArbiter.java | 2 +- .../internal/GestureStrokeDrawingPoints.java | 2 +- .../GestureStrokeRecognitionPoints.java | 4 +- .../internal/GestureTrailDrawingPoints.java | 2 +- .../inputmethod/latin/BinaryDictionary.java | 1 + .../inputmethod/latin/LastComposedWord.java | 1 + .../android/inputmethod/latin/LatinIME.java | 1 + .../inputmethod/latin/WordComposer.java | 1 + .../latin/inputlogic/InputLogic.java | 2 +- .../latin/inputlogic/InputLogicHandler.java | 2 +- .../inputmethod/latin/InputTestsBase.java | 1 + .../{ => common}/InputPointersTests.java | 4 +- .../ResizableIntArrayTests.java | 2 +- tools/dicttool/Android.mk | 4 +- 19 files changed, 22 insertions(+), 53 deletions(-) rename {java/src/com/android/inputmethod/latin => common/src/com/android/inputmethod/latin/common}/InputPointers.java (79%) rename {java/src/com/android/inputmethod/latin/utils => common/src/com/android/inputmethod/latin/common}/ResizableIntArray.java (99%) rename tests/src/com/android/inputmethod/latin/{ => common}/InputPointersTests.java (99%) rename tests/src/com/android/inputmethod/latin/{utils => common}/ResizableIntArrayTests.java (99%) diff --git a/java/src/com/android/inputmethod/latin/InputPointers.java b/common/src/com/android/inputmethod/latin/common/InputPointers.java similarity index 79% rename from java/src/com/android/inputmethod/latin/InputPointers.java rename to common/src/com/android/inputmethod/latin/common/InputPointers.java index d57a881c0..40131aca4 100644 --- a/java/src/com/android/inputmethod/latin/InputPointers.java +++ b/common/src/com/android/inputmethod/latin/common/InputPointers.java @@ -14,18 +14,12 @@ * limitations under the License. */ -package com.android.inputmethod.latin; - -import android.util.Log; -import android.util.SparseIntArray; +package com.android.inputmethod.latin.common; import com.android.inputmethod.annotations.UsedForTesting; -import com.android.inputmethod.latin.define.DebugFlags; -import com.android.inputmethod.latin.utils.ResizableIntArray; // TODO: This class is not thread-safe. public final class InputPointers { - private static final String TAG = InputPointers.class.getSimpleName(); private static final boolean DEBUG_TIME = false; private final int mDefaultCapacity; @@ -61,14 +55,14 @@ public final class InputPointers { mXCoordinates.addAt(index, x); mYCoordinates.addAt(index, y); mPointerIds.addAt(index, pointerId); - if (DebugFlags.DEBUG_ENABLED || DEBUG_TIME) { + if (DEBUG_TIME) { fillWithLastTimeUntil(index); } mTimes.addAt(index, time); } @UsedForTesting - void addPointer(int x, int y, int pointerId, int time) { + public void addPointer(int x, int y, int pointerId, int time) { mXCoordinates.add(x); mYCoordinates.add(y); mPointerIds.add(pointerId); @@ -152,11 +146,6 @@ public final class InputPointers { * the sequence. */ public int[] getTimes() { - if (DebugFlags.DEBUG_ENABLED || DEBUG_TIME) { - if (!isValidTimeStamps()) { - throw new RuntimeException("Time stamps are invalid."); - } - } return mTimes.getPrimitiveArray(); } @@ -165,25 +154,4 @@ public final class InputPointers { return "size=" + getPointerSize() + " id=" + mPointerIds + " time=" + mTimes + " x=" + mXCoordinates + " y=" + mYCoordinates; } - - private boolean isValidTimeStamps() { - final int[] times = mTimes.getPrimitiveArray(); - final int[] pointerIds = mPointerIds.getPrimitiveArray(); - final SparseIntArray lastTimeOfPointers = new SparseIntArray(); - final int size = getPointerSize(); - for (int i = 0; i < size; ++i) { - final int pointerId = pointerIds[i]; - final int time = times[i]; - final int lastTime = lastTimeOfPointers.get(pointerId, time); - if (time < lastTime) { - // dump - for (int j = 0; j < size; ++j) { - Log.d(TAG, "--- (" + j + ") " + times[j]); - } - return false; - } - lastTimeOfPointers.put(pointerId, time); - } - return true; - } } diff --git a/java/src/com/android/inputmethod/latin/utils/ResizableIntArray.java b/common/src/com/android/inputmethod/latin/common/ResizableIntArray.java similarity index 99% rename from java/src/com/android/inputmethod/latin/utils/ResizableIntArray.java rename to common/src/com/android/inputmethod/latin/common/ResizableIntArray.java index 64c9e2cff..ea23d8a33 100644 --- a/java/src/com/android/inputmethod/latin/utils/ResizableIntArray.java +++ b/common/src/com/android/inputmethod/latin/common/ResizableIntArray.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.inputmethod.latin.utils; +package com.android.inputmethod.latin.common; import java.util.Arrays; diff --git a/java-overridable/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java b/java-overridable/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java index 1d60e0cf5..4a44aaa94 100644 --- a/java-overridable/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java +++ b/java-overridable/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java @@ -19,8 +19,8 @@ package com.android.inputmethod.latin.touchinputconsumer; import android.view.inputmethod.EditorInfo; import com.android.inputmethod.keyboard.Keyboard; -import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.SuggestedWords; +import com.android.inputmethod.latin.common.InputPointers; import com.android.inputmethod.latin.inputlogic.PrivateCommandPerformer; import java.util.List; diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java index ac66f7c6a..cdd632bc8 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java @@ -16,8 +16,8 @@ package com.android.inputmethod.keyboard; -import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; public interface KeyboardActionListener { /** diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index fe6270fb5..5a540ff17 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -31,9 +31,9 @@ import com.android.inputmethod.keyboard.internal.GestureStrokeDrawingPoints; import com.android.inputmethod.keyboard.internal.GestureStrokeRecognitionParams; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.keyboard.internal.TypingTimeRecorder; -import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; import com.android.inputmethod.latin.define.DebugFlags; import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.utils.CoordinateUtils; diff --git a/java/src/com/android/inputmethod/keyboard/internal/BatchInputArbiter.java b/java/src/com/android/inputmethod/keyboard/internal/BatchInputArbiter.java index efb365e42..77d0e7a90 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/BatchInputArbiter.java +++ b/java/src/com/android/inputmethod/keyboard/internal/BatchInputArbiter.java @@ -16,8 +16,8 @@ package com.android.inputmethod.keyboard.internal; -import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; /** * This class arbitrates batch input. diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeDrawingPoints.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeDrawingPoints.java index 7d09e9d2f..07ef00924 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeDrawingPoints.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeDrawingPoints.java @@ -16,7 +16,7 @@ package com.android.inputmethod.keyboard.internal; -import com.android.inputmethod.latin.utils.ResizableIntArray; +import com.android.inputmethod.latin.common.ResizableIntArray; /** * This class holds drawing points to represent a gesture stroke on the screen. diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeRecognitionPoints.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeRecognitionPoints.java index 99ec18f4d..3e901114a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeRecognitionPoints.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeRecognitionPoints.java @@ -18,9 +18,9 @@ package com.android.inputmethod.keyboard.internal; import android.util.Log; -import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.common.Constants; -import com.android.inputmethod.latin.utils.ResizableIntArray; +import com.android.inputmethod.latin.common.InputPointers; +import com.android.inputmethod.latin.common.ResizableIntArray; /** * This class holds event points to recognize a gesture stroke. diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureTrailDrawingPoints.java b/java/src/com/android/inputmethod/keyboard/internal/GestureTrailDrawingPoints.java index 67683e247..4d998e443 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureTrailDrawingPoints.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureTrailDrawingPoints.java @@ -24,7 +24,7 @@ import android.graphics.Rect; import android.os.SystemClock; import com.android.inputmethod.latin.common.Constants; -import com.android.inputmethod.latin.utils.ResizableIntArray; +import com.android.inputmethod.latin.common.ResizableIntArray; /** * This class holds drawing points to represent a gesture trail. The gesture trail may contain diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 1c4ff9659..8e9b5c6f6 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -24,6 +24,7 @@ import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.makedict.DictionaryHeader; import com.android.inputmethod.latin.makedict.FormatSpec; diff --git a/java/src/com/android/inputmethod/latin/LastComposedWord.java b/java/src/com/android/inputmethod/latin/LastComposedWord.java index c4c389411..9fcdb2229 100644 --- a/java/src/com/android/inputmethod/latin/LastComposedWord.java +++ b/java/src/com/android/inputmethod/latin/LastComposedWord.java @@ -20,6 +20,7 @@ import android.text.TextUtils; import com.android.inputmethod.event.Event; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; import java.util.ArrayList; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index ff82087ae..5fa28d571 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -77,6 +77,7 @@ import com.android.inputmethod.keyboard.TextDecoratorUi; import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; import com.android.inputmethod.latin.define.DebugFlags; import com.android.inputmethod.latin.define.ProductionFlags; import com.android.inputmethod.latin.inputlogic.InputLogic; diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 35436f59c..0b77f2ce3 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -20,6 +20,7 @@ import com.android.inputmethod.event.CombinerChain; import com.android.inputmethod.event.Event; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.define.DebugFlags; import com.android.inputmethod.latin.utils.CoordinateUtils; diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index f3a287320..bafea178e 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -41,7 +41,6 @@ import com.android.inputmethod.keyboard.TextDecorator; import com.android.inputmethod.keyboard.TextDecoratorUiOperator; import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.DictionaryFacilitator; -import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.LastComposedWord; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.NgramContext; @@ -52,6 +51,7 @@ import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.WordComposer; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.define.DebugFlags; import com.android.inputmethod.latin.settings.SettingsValues; diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java index 5f391dd9b..ddc4ad99c 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java @@ -21,10 +21,10 @@ import android.os.HandlerThread; import android.os.Message; import com.android.inputmethod.compat.LooperCompatUtils; -import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback; +import com.android.inputmethod.latin.common.InputPointers; /** * A helper to manage deferred tasks for the input logic. diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index 161336aa6..926a2d3e1 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -43,6 +43,7 @@ import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.latin.Dictionary.PhonyDictionary; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.common.Constants; +import com.android.inputmethod.latin.common.InputPointers; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.settings.DebugSettings; import com.android.inputmethod.latin.settings.Settings; diff --git a/tests/src/com/android/inputmethod/latin/InputPointersTests.java b/tests/src/com/android/inputmethod/latin/common/InputPointersTests.java similarity index 99% rename from tests/src/com/android/inputmethod/latin/InputPointersTests.java rename to tests/src/com/android/inputmethod/latin/common/InputPointersTests.java index 1a47cddf4..6b3490de8 100644 --- a/tests/src/com/android/inputmethod/latin/InputPointersTests.java +++ b/tests/src/com/android/inputmethod/latin/common/InputPointersTests.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package com.android.inputmethod.latin; +package com.android.inputmethod.latin.common; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; -import com.android.inputmethod.latin.utils.ResizableIntArray; - import java.util.Arrays; @SmallTest diff --git a/tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java b/tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java similarity index 99% rename from tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java rename to tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java index 7519becbc..bd1629faf 100644 --- a/tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java +++ b/tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.inputmethod.latin.utils; +package com.android.inputmethod.latin.common; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; diff --git a/tools/dicttool/Android.mk b/tools/dicttool/Android.mk index 90be411ec..81c0706c1 100644 --- a/tools/dicttool/Android.mk +++ b/tools/dicttool/Android.mk @@ -47,7 +47,6 @@ LATINIME_SRC_FILES_FOR_DICTTOOL := \ latin/BinaryDictionary.java \ latin/DicTraverseSession.java \ latin/Dictionary.java \ - latin/InputPointers.java \ latin/LastComposedWord.java \ latin/NgramContext.java \ latin/SuggestedWords.java \ @@ -59,8 +58,7 @@ LATINIME_SRC_FILES_FOR_DICTTOOL := \ latin/utils/CoordinateUtils.java \ latin/utils/FileUtils.java \ latin/utils/JniUtils.java \ - latin/utils/LocaleUtils.java \ - latin/utils/ResizableIntArray.java + latin/utils/LocaleUtils.java LATINIME_OVERRIDABLE_SRC_FILES_FOR_DICTTOOL := \ latin/define/DebugFlags.java