diff options
Diffstat (limited to 'tools/dicttool/compat')
-rw-r--r-- | tools/dicttool/compat/android/test/MoreAsserts.java | 35 | ||||
-rw-r--r-- | tools/dicttool/compat/android/text/TextUtils.java | 16 | ||||
-rw-r--r-- | tools/dicttool/compat/android/util/Pair.java | 8 | ||||
-rw-r--r-- | tools/dicttool/compat/android/view/inputmethod/CompletionInfo.java | 1 | ||||
-rw-r--r-- | tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java | 54 | ||||
-rw-r--r-- | tools/dicttool/compat/com/android/inputmethod/keyboard/Key.java | 1 | ||||
-rw-r--r-- | tools/dicttool/compat/com/android/inputmethod/keyboard/Keyboard.java | 1 | ||||
-rw-r--r-- | tools/dicttool/compat/com/android/inputmethod/keyboard/ProximityInfo.java | 9 | ||||
-rw-r--r-- | tools/dicttool/compat/com/android/inputmethod/latin/utils/WordInputEventForPersonalization.java (renamed from tools/dicttool/compat/com/android/inputmethod/latin/utils/LanguageModelParam.java) | 2 |
9 files changed, 18 insertions, 109 deletions
diff --git a/tools/dicttool/compat/android/test/MoreAsserts.java b/tools/dicttool/compat/android/test/MoreAsserts.java deleted file mode 100644 index f56420b9c..000000000 --- a/tools/dicttool/compat/android/test/MoreAsserts.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.test; - -import junit.framework.Assert; - -/** - * This is a compatibility class that aims at emulating android.test.MoreAsserts from the - * Android library as simply as possible, and only to the extent that is used by the client classes. - * Its purpose is to provide compatibility without having to pull the whole Android library. - */ -public class MoreAsserts { - public static void assertNotEqual(Object unexpected, Object actual) { - if (equal(unexpected, actual)) { - Assert.fail("expected not to be:<" + unexpected + ">"); - } - } - private static boolean equal(Object a, Object b) { - return a == b || (a != null && a.equals(b)); - } -} diff --git a/tools/dicttool/compat/android/text/TextUtils.java b/tools/dicttool/compat/android/text/TextUtils.java index 5a94b7d4c..82483319e 100644 --- a/tools/dicttool/compat/android/text/TextUtils.java +++ b/tools/dicttool/compat/android/text/TextUtils.java @@ -25,10 +25,7 @@ public class TextUtils { * @return true if str is null or zero length */ public static boolean isEmpty(CharSequence str) { - if (str == null || str.length() == 0) - return true; - else - return false; + return (str == null || str.length() == 0); } /** @@ -45,12 +42,11 @@ public class TextUtils { if (a != null && b != null && (length = a.length()) == b.length()) { if (a instanceof String && b instanceof String) { return a.equals(b); - } else { - for (int i = 0; i < length; i++) { - if (a.charAt(i) != b.charAt(i)) return false; - } - return true; } + for (int i = 0; i < length; i++) { + if (a.charAt(i) != b.charAt(i)) return false; + } + return true; } return false; } @@ -90,7 +86,7 @@ public class TextUtils { * @param tokens an array objects to be joined. Strings will be formed from * the objects by calling object.toString(). */ - public static String join(CharSequence delimiter, Iterable tokens) { + public static String join(CharSequence delimiter, Iterable<?> tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token: tokens) { diff --git a/tools/dicttool/compat/android/util/Pair.java b/tools/dicttool/compat/android/util/Pair.java index 5bf34848d..e61e896b7 100644 --- a/tools/dicttool/compat/android/util/Pair.java +++ b/tools/dicttool/compat/android/util/Pair.java @@ -16,7 +16,7 @@ package android.util; -import java.util.Arrays; +import java.util.Objects; public class Pair<T1, T2> { public final T1 mFirst; @@ -29,7 +29,8 @@ public class Pair<T1, T2> { @Override public int hashCode() { - return Arrays.hashCode(new Object[] { mFirst, mSecond }); + return (mFirst == null ? 0 : mFirst.hashCode()) + ^ (mSecond == null ? 0 : mSecond.hashCode()); } @Override @@ -37,7 +38,6 @@ public class Pair<T1, T2> { if (o == this) return true; if (!(o instanceof Pair)) return false; Pair<?, ?> p = (Pair<?, ?>)o; - return ((mFirst == null && p.mFirst == null) || mFirst.equals(p.mFirst)) - && ((mSecond == null && p.mSecond == null) || mSecond.equals(p.mSecond)); + return Objects.equals(mFirst, p.mFirst) && Objects.equals(mSecond, p.mSecond); } } diff --git a/tools/dicttool/compat/android/view/inputmethod/CompletionInfo.java b/tools/dicttool/compat/android/view/inputmethod/CompletionInfo.java index fbce72556..e2f769ec8 100644 --- a/tools/dicttool/compat/android/view/inputmethod/CompletionInfo.java +++ b/tools/dicttool/compat/android/view/inputmethod/CompletionInfo.java @@ -16,6 +16,7 @@ package android.view.inputmethod; +@SuppressWarnings("static-method") public class CompletionInfo { public final String getText() { return ""; } } diff --git a/tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java b/tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java deleted file mode 100644 index c4457a1b7..000000000 --- a/tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.event; - -import java.util.ArrayList; - -/** - * Compatibility class that stands in for the combiner chain in LatinIME. - * - * This is not used by dicttool, it's just needed by the dependency chain. - */ -// TODO: there should not be a dependency to this in dicttool, so there -// should be a sensible way to separate them cleanly. -public class CombinerChain { - private StringBuilder mComposingWord; - public CombinerChain(final String initialText, final Combiner... combinerList) { - mComposingWord = new StringBuilder(initialText); - } - - public Event processEvent(final ArrayList<Event> previousEvents, final Event newEvent) { - return newEvent; - } - - public void applyProcessedEvent(final Event event) { - mComposingWord.append(event.getTextToCommit()); - } - - public CharSequence getComposingWordWithCombiningFeedback() { - return mComposingWord; - } - - public void reset() { - mComposingWord.setLength(0); - } - - public static Combiner[] createCombiners(final String spec) { - // Dicttool never uses a combiner at all, so we just return a zero-sized array. - return new Combiner[0]; - } -} diff --git a/tools/dicttool/compat/com/android/inputmethod/keyboard/Key.java b/tools/dicttool/compat/com/android/inputmethod/keyboard/Key.java index 1e63bb526..925940650 100644 --- a/tools/dicttool/compat/com/android/inputmethod/keyboard/Key.java +++ b/tools/dicttool/compat/com/android/inputmethod/keyboard/Key.java @@ -16,6 +16,7 @@ package com.android.inputmethod.keyboard; +@SuppressWarnings("static-method") public class Key { public final int getX() { return 0; } public final int getY() { return 0; } diff --git a/tools/dicttool/compat/com/android/inputmethod/keyboard/Keyboard.java b/tools/dicttool/compat/com/android/inputmethod/keyboard/Keyboard.java index 61b209f4d..3d6bfd0a9 100644 --- a/tools/dicttool/compat/com/android/inputmethod/keyboard/Keyboard.java +++ b/tools/dicttool/compat/com/android/inputmethod/keyboard/Keyboard.java @@ -16,6 +16,7 @@ package com.android.inputmethod.keyboard; +@SuppressWarnings("unused") public class Keyboard { private final Key KEY = new Key(); public final Key getKey(final int i) { return KEY; } diff --git a/tools/dicttool/compat/com/android/inputmethod/keyboard/ProximityInfo.java b/tools/dicttool/compat/com/android/inputmethod/keyboard/ProximityInfo.java index 561b6637c..3a068bd5a 100644 --- a/tools/dicttool/compat/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/tools/dicttool/compat/com/android/inputmethod/keyboard/ProximityInfo.java @@ -18,11 +18,10 @@ package com.android.inputmethod.keyboard; public class ProximityInfo { public long getNativeProximityInfo() { return 0l; } - private static native long setProximityInfoNative(String locale, - int displayWidth, int displayHeight, int gridWidth, int gridHeight, - int mostCommonKeyWidth, int mostCommonKeyHeight, int[] proximityCharsArray, - int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, int[] keyWidths, - int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterXs, + private static native long setProximityInfoNative(int displayWidth, int displayHeight, + int gridWidth, int gridHeight, int mostCommonKeyWidth, int mostCommonKeyHeight, + int[] proximityCharsArray, int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, + int[] keyWidths, int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterXs, float[] sweetSpotCenterYs, float[] sweetSpotRadii); private static native void releaseProximityInfoNative(long nativeProximityInfo); } diff --git a/tools/dicttool/compat/com/android/inputmethod/latin/utils/LanguageModelParam.java b/tools/dicttool/compat/com/android/inputmethod/latin/utils/WordInputEventForPersonalization.java index f4ca94a81..b5a729421 100644 --- a/tools/dicttool/compat/com/android/inputmethod/latin/utils/LanguageModelParam.java +++ b/tools/dicttool/compat/com/android/inputmethod/latin/utils/WordInputEventForPersonalization.java @@ -16,5 +16,5 @@ package com.android.inputmethod.latin.utils; -public final class LanguageModelParam { +public final class WordInputEventForPersonalization { } |