Move InputPointers and ResizableIntArray to common

Bug: 18108776
Change-Id: Ie5c0430aa41a8d6c58bf510a10173223d7dfe9fe
This commit is contained in:
Jean Chalard 2014-10-29 11:37:21 +09:00
parent 80980574ac
commit 36799b2aa2
19 changed files with 22 additions and 53 deletions

View File

@ -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;
}
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.inputmethod.latin.utils;
package com.android.inputmethod.latin.common;
import java.util.Arrays;

View File

@ -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;

View File

@ -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 {
/**

View File

@ -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;

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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