diff options
46 files changed, 79 insertions, 154 deletions
diff --git a/java/res/drawable-hdpi/sym_keyboard_feedback_tab.png b/java/res/drawable-hdpi/sym_keyboard_feedback_tab.png Binary files differindex d75fcacd5..d85663bf3 100644 --- a/java/res/drawable-hdpi/sym_keyboard_feedback_tab.png +++ b/java/res/drawable-hdpi/sym_keyboard_feedback_tab.png diff --git a/java/res/drawable-hdpi/sym_keyboard_space.png b/java/res/drawable-hdpi/sym_keyboard_space.png Binary files differindex 780733ec5..78cd6b7bf 100644 --- a/java/res/drawable-hdpi/sym_keyboard_space.png +++ b/java/res/drawable-hdpi/sym_keyboard_space.png diff --git a/java/res/drawable-mdpi/more_keys_divider.png b/java/res/drawable-mdpi/more_keys_divider.png Binary files differindex a46284f21..0f71c6172 100644 --- a/java/res/drawable-mdpi/more_keys_divider.png +++ b/java/res/drawable-mdpi/more_keys_divider.png diff --git a/java/res/drawable-mdpi/more_suggestions_divider.png b/java/res/drawable-mdpi/more_suggestions_divider.png Binary files differindex a46284f21..0f71c6172 100644 --- a/java/res/drawable-mdpi/more_suggestions_divider.png +++ b/java/res/drawable-mdpi/more_suggestions_divider.png diff --git a/java/res/drawable-mdpi/sym_keyboard_feedback_tab.png b/java/res/drawable-mdpi/sym_keyboard_feedback_tab.png Binary files differindex a10dc8fa2..fee15807c 100644 --- a/java/res/drawable-mdpi/sym_keyboard_feedback_tab.png +++ b/java/res/drawable-mdpi/sym_keyboard_feedback_tab.png diff --git a/java/res/drawable-mdpi/sym_keyboard_space.png b/java/res/drawable-mdpi/sym_keyboard_space.png Binary files differindex cbe4a88d6..6d03e6347 100644 --- a/java/res/drawable-mdpi/sym_keyboard_space.png +++ b/java/res/drawable-mdpi/sym_keyboard_space.png diff --git a/java/res/drawable-xhdpi/sym_keyboard_feedback_tab.png b/java/res/drawable-xhdpi/sym_keyboard_feedback_tab.png Binary files differindex 0650e01cb..b0ee35d59 100644 --- a/java/res/drawable-xhdpi/sym_keyboard_feedback_tab.png +++ b/java/res/drawable-xhdpi/sym_keyboard_feedback_tab.png diff --git a/java/res/drawable-xhdpi/sym_keyboard_space.png b/java/res/drawable-xhdpi/sym_keyboard_space.png Binary files differindex 66fc3e9d3..3691280e3 100644 --- a/java/res/drawable-xhdpi/sym_keyboard_space.png +++ b/java/res/drawable-xhdpi/sym_keyboard_space.png diff --git a/java/res/drawable-xxhdpi/keyboard_key_feedback_left_background_klp.9.png b/java/res/drawable-xxhdpi/keyboard_key_feedback_left_background_klp.9.png Binary files differindex 2079e0462..3ab79007e 100644 --- a/java/res/drawable-xxhdpi/keyboard_key_feedback_left_background_klp.9.png +++ b/java/res/drawable-xxhdpi/keyboard_key_feedback_left_background_klp.9.png diff --git a/java/res/drawable-xxhdpi/keyboard_key_feedback_left_more_background_klp.9.png b/java/res/drawable-xxhdpi/keyboard_key_feedback_left_more_background_klp.9.png Binary files differindex c4178d9a8..99543a1e0 100644 --- a/java/res/drawable-xxhdpi/keyboard_key_feedback_left_more_background_klp.9.png +++ b/java/res/drawable-xxhdpi/keyboard_key_feedback_left_more_background_klp.9.png diff --git a/java/res/drawable-xxhdpi/keyboard_key_feedback_right_background_klp.9.png b/java/res/drawable-xxhdpi/keyboard_key_feedback_right_background_klp.9.png Binary files differindex d3d8733fd..e9e379287 100644 --- a/java/res/drawable-xxhdpi/keyboard_key_feedback_right_background_klp.9.png +++ b/java/res/drawable-xxhdpi/keyboard_key_feedback_right_background_klp.9.png diff --git a/java/res/drawable-xxhdpi/keyboard_key_feedback_right_more_background_klp.9.png b/java/res/drawable-xxhdpi/keyboard_key_feedback_right_more_background_klp.9.png Binary files differindex d7ec8bcb2..6c1143aeb 100644 --- a/java/res/drawable-xxhdpi/keyboard_key_feedback_right_more_background_klp.9.png +++ b/java/res/drawable-xxhdpi/keyboard_key_feedback_right_more_background_klp.9.png diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java index 7fff46aaf..7e2166769 100644 --- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java +++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java @@ -632,7 +632,9 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange } public void setHardwareAcceleratedDrawingEnabled(final boolean enabled) { - // TODO: + if (!enabled) return; + // TODO: Should use LAYER_TYPE_SOFTWARE when hardware acceleration is off? + setLayerType(LAYER_TYPE_HARDWARE, null); } private static void setupAlphabetKey(final TextView alphabetKey, final String label, diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java index 044cd119e..56acdde8d 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java @@ -31,7 +31,7 @@ import java.util.Locale; public final class KeyboardTextsSet { public static final String PREFIX_TEXT = "!text/"; - public static final String SWITCH_TO_ALPHA_KEY_LABEL = "label_to_alpha_key"; + public static final String SWITCH_TO_ALPHA_KEY_LABEL = "keylabel_to_alpha"; private static final char BACKSLASH = Constants.CODE_BACKSLASH; private static final int MAX_STRING_REFERENCE_INDIRECTION = 10; diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java index 8b8d5776e..ae2d7c9c6 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java @@ -480,6 +480,9 @@ public class DictionaryFacilitatorForSuggest { return false; } final Dictionaries dictionaries = mDictionaries; + if (dictionaries.mLocale == null) { + return false; + } final String lowerCasedWord = word.toLowerCase(dictionaries.mLocale); final Map<String, Dictionary> dictMap = dictionaries.mDictMap; for (final Dictionary dictionary : dictMap.values()) { diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java index 07217e48e..f25503488 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java @@ -18,9 +18,7 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.Constants; -import com.android.inputmethod.latin.makedict.DictDecoder.DictionaryBufferFactory; -import java.io.File; import java.util.Date; import java.util.HashMap; @@ -363,42 +361,6 @@ public final class FormatSpec { } } - /** - * Returns new dictionary decoder. - * - * @param dictFile the dictionary file. - * @param offset the offset in the file. - * @param length the length of the file, in bytes. - * @param bufferType The type of buffer, as one of USE_* in DictDecoder. - * @return new dictionary decoder if the dictionary file exists, otherwise null. - */ - public static DictDecoder getDictDecoder(final File dictFile, final long offset, - final long length, final int bufferType) { - if (dictFile.isDirectory()) { - return new Ver4DictDecoder(dictFile, bufferType); - } else if (dictFile.isFile()) { - return new Ver2DictDecoder(dictFile, offset, length, bufferType); - } - return null; - } - - @UsedForTesting - public static DictDecoder getDictDecoder(final File dictFile, final long offset, - final long length, final DictionaryBufferFactory factory) { - if (dictFile.isDirectory()) { - return new Ver4DictDecoder(dictFile, factory); - } else if (dictFile.isFile()) { - return new Ver2DictDecoder(dictFile, offset, length, factory); - } - return null; - } - - @UsedForTesting - public static DictDecoder getDictDecoder(final File dictFile, final long offset, - final long length) { - return getDictDecoder(dictFile, offset, length, DictDecoder.USE_READONLY_BYTEBUFFER); - } - private FormatSpec() { // This utility class is not publicly instantiable. } diff --git a/java/src/com/android/inputmethod/latin/makedict/MakedictLog.java b/java/src/com/android/inputmethod/latin/makedict/MakedictLog.java deleted file mode 100644 index cf07209d9..000000000 --- a/java/src/com/android/inputmethod/latin/makedict/MakedictLog.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2011 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.latin.makedict; - -import android.util.Log; - -/** - * Wrapper to redirect log events to the right output medium. - */ -public final class MakedictLog { - public static final boolean DBG = false; - private static final String TAG = MakedictLog.class.getSimpleName(); - - public static void d(String message) { - if (DBG) { - Log.d(TAG, message); - } - } - - public static void i(String message) { - if (DBG) { - Log.i(TAG, message); - } - } - - public static void w(String message) { - Log.w(TAG, message); - } - - public static void e(String message) { - Log.e(TAG, message); - } -} diff --git a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java index e531d4b09..315913e2f 100644 --- a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java @@ -23,12 +23,10 @@ import android.content.res.Resources; import android.text.TextUtils; import android.util.Log; -import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.AssetFileAddress; import com.android.inputmethod.latin.BinaryDictionaryGetter; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; import com.android.inputmethod.latin.makedict.DictionaryHeader; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import com.android.inputmethod.latin.settings.SpacingAndPunctuations; diff --git a/native/jni/jni_common.cpp b/native/jni/jni_common.cpp index 9fa7ef8f9..ce5e30c5d 100644 --- a/native/jni/jni_common.cpp +++ b/native/jni/jni_common.cpp @@ -67,7 +67,7 @@ int registerNativeMethods(JNIEnv *env, const char *const className, const JNINat AKLOGE("Native registration unable to find class '%s'", className); return JNI_FALSE; } - if (env->RegisterNatives(clazz, methods, numMethods) < 0) { + if (env->RegisterNatives(clazz, methods, numMethods) != 0) { AKLOGE("RegisterNatives failed for '%s'", className); env->DeleteLocalRef(clazz); return JNI_FALSE; diff --git a/native/jni/src/suggest/core/dicnode/dic_node.h b/native/jni/src/suggest/core/dicnode/dic_node.h index 865aab632..3118cdfa3 100644 --- a/native/jni/src/suggest/core/dicnode/dic_node.h +++ b/native/jni/src/suggest/core/dicnode/dic_node.h @@ -218,10 +218,6 @@ class DicNode { return CharUtils::isAsciiUpper(c); } - bool isFirstWord() const { - return mDicNodeProperties.getPrevWordTerminalPtNodePos() == NOT_A_DICT_POS; - } - bool isCompletion(const int inputSize) const { return mDicNodeState.mDicNodeStateInput.getInputIndex(0) >= inputSize; } @@ -292,7 +288,9 @@ class DicNode { // the one that corresponds to the last word of the suggestion, and all the previous words // are concatenated together in mDicNodeStateOutput. int getTotalNodeSpaceCount() const { - if (isFirstWord()) return 0; + if (!hasMultipleWords()) { + return 0; + } return CharUtils::getSpaceCount(mDicNodeState.mDicNodeStateOutput.getCodePointBuf(), mDicNodeState.mDicNodeStateOutput.getPrevWordsLength()); } diff --git a/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp b/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp index 48752f2cd..2d02a7d9c 100644 --- a/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp +++ b/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp @@ -16,8 +16,6 @@ #include "suggest/core/dicnode/dic_node_utils.h" -#include <cstring> - #include "suggest/core/dicnode/dic_node.h" #include "suggest/core/dicnode/dic_node_vector.h" #include "suggest/core/dictionary/multi_bigram_map.h" @@ -103,34 +101,4 @@ namespace latinime { NOT_A_PROBABILITY); } -//////////////// -// Char utils // -//////////////// - -// TODO: Move to char_utils? -/* static */ int DicNodeUtils::appendTwoWords(const int *const src0, const int16_t length0, - const int *const src1, const int16_t length1, int *const dest) { - int actualLength0 = 0; - for (int i = 0; i < length0; ++i) { - if (src0[i] == 0) { - break; - } - actualLength0 = i + 1; - } - actualLength0 = std::min(actualLength0, MAX_WORD_LENGTH); - memmove(dest, src0, actualLength0 * sizeof(dest[0])); - if (!src1 || length1 == 0) { - return actualLength0; - } - int actualLength1 = 0; - for (int i = 0; i < length1; ++i) { - if (src1[i] == 0) { - break; - } - actualLength1 = i + 1; - } - actualLength1 = std::min(actualLength1, MAX_WORD_LENGTH - actualLength0); - memmove(&dest[actualLength0], src1, actualLength1 * sizeof(dest[0])); - return actualLength0 + actualLength1; -} } // namespace latinime diff --git a/native/jni/src/suggest/core/dicnode/dic_node_utils.h b/native/jni/src/suggest/core/dicnode/dic_node_utils.h index 3f1514a52..4c0f1f15d 100644 --- a/native/jni/src/suggest/core/dicnode/dic_node_utils.h +++ b/native/jni/src/suggest/core/dicnode/dic_node_utils.h @@ -17,8 +17,6 @@ #ifndef LATINIME_DIC_NODE_UTILS_H #define LATINIME_DIC_NODE_UTILS_H -#include <stdint.h> - #include "defines.h" namespace latinime { @@ -30,8 +28,6 @@ class MultiBigramMap; class DicNodeUtils { public: - static int appendTwoWords(const int *src0, const int16_t length0, const int *src1, - const int16_t length1, int *const dest); static void initAsRoot( const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy, const int prevWordPtNodePos, DicNode *const newRootDicNode); diff --git a/native/jni/src/suggest/core/result/suggestions_output_utils.cpp b/native/jni/src/suggest/core/result/suggestions_output_utils.cpp index 19912f2ac..a27631510 100644 --- a/native/jni/src/suggest/core/result/suggestions_output_utils.cpp +++ b/native/jni/src/suggest/core/result/suggestions_output_utils.cpp @@ -254,8 +254,9 @@ const int SuggestionsOutputUtils::MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT = 16; outputScores[outputWordIndex] = shortcutScore; outputScores[outputWordIndex] = std::max(S_INT_MIN + 1, shortcutScore) - 1; const int startIndex2 = outputWordIndex * MAX_WORD_LENGTH; - DicNodeUtils::appendTwoWords(0, 0, shortcutTarget, shortcutTargetStringLength, - &outputCodePoints[startIndex2]); + // Copy shortcut target code points to the output buffer. + memmove(&outputCodePoints[startIndex2], shortcutTarget, + shortcutTargetStringLength * sizeof(shortcutTarget[0])); ++outputWordIndex; } return outputWordIndex; diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java index 918f09067..ae2205b36 100644 --- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java +++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java @@ -20,6 +20,7 @@ import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.util.Pair; +import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; import com.android.inputmethod.latin.makedict.CodePointUtils; import com.android.inputmethod.latin.makedict.DictDecoder; import com.android.inputmethod.latin.makedict.DictionaryHeader; @@ -151,7 +152,8 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { binaryDictionary.flushWithGC(); binaryDictionary.close(); - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(dictFile, 0, dictFile.length()); + final DictDecoder dictDecoder = + BinaryDictIOUtils.getDictDecoder(dictFile, 0, dictFile.length()); try { final FusionDictionary dict = dictDecoder.readDictionaryBinary(false /* deleteDictIfBroken */); diff --git a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java b/tests/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java index bc856f113..bc856f113 100644 --- a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java index 4bf61747c..f29fc21c1 100644 --- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java @@ -251,7 +251,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { FusionDictionary dict = null; try { - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(file, 0, file.length(), + final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length(), bufferType); now = System.currentTimeMillis(); dict = dictDecoder.readDictionaryBinary(false /* deleteDictIfBroken */); @@ -414,7 +414,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { long now = -1, diff = -1; try { - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(file, 0, file.length(), + final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length(), bufferType); now = System.currentTimeMillis(); dictDecoder.readUnigramsAndBigramsBinary(resultWords, resultFreqs, resultBigrams); @@ -539,7 +539,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { addBigrams(dict, words, bigrams); timeWritingDictToFile(file, dict, formatOptions); - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(file, 0, file.length(), + final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length(), DictDecoder.USE_BYTEARRAY); try { dictDecoder.openDictBuffer(); diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java index b534bcb09..6f8b07a34 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java @@ -28,7 +28,6 @@ import java.nio.ByteBuffer; * * All the methods in this class are static. * - * TODO: Remove calls from classes except Ver3DictDecoder * TODO: Move this file to makedict/internal. * TODO: Rename this class to DictDecoderUtils. */ @@ -356,7 +355,7 @@ public final class BinaryDictDecoderUtils { * @return true if it's a binary dictionary, false otherwise */ public static boolean isBinaryDictionary(final File file) { - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(file, 0, file.length()); + final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length()); if (dictDecoder == null) { return false; } diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java index 39bd98bad..39bd98bad 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index a180f1c29..42a50be66 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -18,7 +18,9 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.Constants; +import com.android.inputmethod.latin.makedict.DictDecoder.DictionaryBufferFactory; +import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; @@ -32,6 +34,38 @@ public final class BinaryDictIOUtils { // This utility class is not publicly instantiable. } + /** + * Returns new dictionary decoder. + * + * @param dictFile the dictionary file. + * @param bufferType The type of buffer, as one of USE_* in DictDecoder. + * @return new dictionary decoder if the dictionary file exists, otherwise null. + */ + public static DictDecoder getDictDecoder(final File dictFile, final long offset, + final long length, final int bufferType) { + if (dictFile.isDirectory()) { + return new Ver4DictDecoder(dictFile, bufferType); + } else if (dictFile.isFile()) { + return new Ver2DictDecoder(dictFile, offset, length, bufferType); + } + return null; + } + + public static DictDecoder getDictDecoder(final File dictFile, final long offset, + final long length, final DictionaryBufferFactory factory) { + if (dictFile.isDirectory()) { + return new Ver4DictDecoder(dictFile, factory); + } else if (dictFile.isFile()) { + return new Ver2DictDecoder(dictFile, offset, length, factory); + } + return null; + } + + public static DictDecoder getDictDecoder(final File dictFile, final long offset, + final long length) { + return getDictDecoder(dictFile, offset, length, DictDecoder.USE_READONLY_BYTEBUFFER); + } + private static final class Position { public static final int NOT_READ_PTNODE_COUNT = -1; diff --git a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java b/tests/src/com/android/inputmethod/latin/makedict/DictDecoder.java index a3b28a702..a3b28a702 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/DictDecoder.java diff --git a/java/src/com/android/inputmethod/latin/makedict/DictEncoder.java b/tests/src/com/android/inputmethod/latin/makedict/DictEncoder.java index 678c5ca6b..678c5ca6b 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DictEncoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/DictEncoder.java diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/tests/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index f60b3af4f..f60b3af4f 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/tests/src/com/android/inputmethod/latin/makedict/FusionDictionary.java diff --git a/tools/dicttool/src/com/android/inputmethod/latin/makedict/MakedictLog.java b/tests/src/com/android/inputmethod/latin/makedict/MakedictLog.java index 7eccff2b4..7eccff2b4 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/makedict/MakedictLog.java +++ b/tests/src/com/android/inputmethod/latin/makedict/MakedictLog.java diff --git a/java/src/com/android/inputmethod/latin/makedict/PendingAttribute.java b/tests/src/com/android/inputmethod/latin/makedict/PendingAttribute.java index 70e24cc98..70e24cc98 100644 --- a/java/src/com/android/inputmethod/latin/makedict/PendingAttribute.java +++ b/tests/src/com/android/inputmethod/latin/makedict/PendingAttribute.java diff --git a/java/src/com/android/inputmethod/latin/makedict/PtNodeInfo.java b/tests/src/com/android/inputmethod/latin/makedict/PtNodeInfo.java index 862e8c101..862e8c101 100644 --- a/java/src/com/android/inputmethod/latin/makedict/PtNodeInfo.java +++ b/tests/src/com/android/inputmethod/latin/makedict/PtNodeInfo.java diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java index 7091c119e..7091c119e 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java index a286190cb..a286190cb 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java index f3fad7e99..f3fad7e99 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java index dab9a4315..dab9a4315 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java diff --git a/java/src/com/android/inputmethod/latin/utils/ByteArrayDictBuffer.java b/tests/src/com/android/inputmethod/latin/utils/ByteArrayDictBuffer.java index 2028298f2..2028298f2 100644 --- a/java/src/com/android/inputmethod/latin/utils/ByteArrayDictBuffer.java +++ b/tests/src/com/android/inputmethod/latin/utils/ByteArrayDictBuffer.java diff --git a/tools/dicttool/Android.mk b/tools/dicttool/Android.mk index 0e9c14ee4..f49dee70f 100644 --- a/tools/dicttool/Android.mk +++ b/tools/dicttool/Android.mk @@ -30,11 +30,12 @@ LATINIME_LOCAL_DIR := ../.. LATINIME_BASE_SOURCE_DIRECTORY := $(LATINIME_LOCAL_DIR)/java/src/com/android/inputmethod LATINIME_ANNOTATIONS_SOURCE_DIRECTORY := $(LATINIME_BASE_SOURCE_DIRECTORY)/annotations MAKEDICT_CORE_SOURCE_DIRECTORY := $(LATINIME_BASE_SOURCE_DIRECTORY)/latin/makedict +LATINIME_TESTS_SOURCE_DIRECTORY := $(LATINIME_LOCAL_DIR)/tests/src/com/android/inputmethod/latin # Dependencies for Dicttool. Most of these files are needed by BinaryDictionary.java. Note that # a significant part of the dependencies are mocked in the compat/ directory, with empty or # nearly-empty implementations, for parts that we don't use in Dicttool. -LATINIME_SRCS_FOR_DICTTOOL := \ +LATINIME_SRC_FILES_FOR_DICTTOOL := \ event/Combiner.java \ event/Event.java \ latin/BinaryDictionary.java \ @@ -47,7 +48,6 @@ LATINIME_SRCS_FOR_DICTTOOL := \ latin/WordComposer.java \ latin/settings/NativeSuggestOptions.java \ latin/utils/BinaryDictionaryUtils.java \ - latin/utils/ByteArrayDictBuffer.java \ latin/utils/CollectionUtils.java \ latin/utils/CombinedFormatUtils.java \ latin/utils/CoordinateUtils.java \ @@ -56,8 +56,13 @@ LATINIME_SRCS_FOR_DICTTOOL := \ latin/utils/LocaleUtils.java \ latin/utils/ResizableIntArray.java \ latin/utils/StringUtils.java -USED_TARGETED_SRCS := $(addprefix $(LATINIME_BASE_SOURCE_DIRECTORY)/, \ - $(LATINIME_SRCS_FOR_DICTTOOL)) + +LATINIME_TEST_SRC_FILES_FOR_DICTTOOL := \ + utils/ByteArrayDictBuffer.java + +USED_TARGETED_SRCS := \ + $(addprefix $(LATINIME_BASE_SOURCE_DIRECTORY)/, $(LATINIME_SRC_FILES_FOR_DICTTOOL)) \ + $(addprefix $(LATINIME_TESTS_SOURCE_DIRECTORY)/, $(LATINIME_TEST_SRC_FILES_FOR_DICTTOOL)) DICTTOOL_ONDEVICE_TESTS_DIRECTORY := \ $(LATINIME_LOCAL_DIR)/tests/src/com/android/inputmethod/latin/makedict/ @@ -70,12 +75,11 @@ LOCAL_ANNOTATIONS_SRC_FILES := \ LOCAL_SRC_FILES := $(LOCAL_TOOL_SRC_FILES) \ $(filter-out $(addprefix %/, $(notdir $(LOCAL_TOOL_SRC_FILES))), $(LOCAL_MAIN_SRC_FILES)) \ - $(LOCAL_ANNOTATIONS_SRC_FILES) \ + $(call all-java-files-under, $(DICTTOOL_COMPAT_TESTS_DIRECTORY)) \ + $(LOCAL_ANNOTATIONS_SRC_FILES) $(USED_TARGETED_SRCS) \ $(LATINIME_BASE_SOURCE_DIRECTORY)/latin/Constants.java \ $(call all-java-files-under, tests) \ - $(call all-java-files-under, $(DICTTOOL_ONDEVICE_TESTS_DIRECTORY)) \ - $(call all-java-files-under, $(DICTTOOL_COMPAT_TESTS_DIRECTORY)) \ - $(USED_TARGETED_SRCS) + $(call all-java-files-under, $(DICTTOOL_ONDEVICE_TESTS_DIRECTORY)) LOCAL_JAVA_LIBRARIES := junit LOCAL_ADDITIONAL_DEPENDENCIES := $(LATINIME_HOST_NATIVE_LIBNAME) diff --git a/tools/dicttool/NativeLib.mk b/tools/dicttool/NativeLib.mk index 95f767dc9..0d3507be3 100644 --- a/tools/dicttool/NativeLib.mk +++ b/tools/dicttool/NativeLib.mk @@ -37,9 +37,9 @@ endif #HOST_JDK_IS_64BIT_VERSION LOCAL_CFLAGS += -DHOST_TOOL -fPIC -Wno-deprecated LOCAL_NO_DEFAULT_COMPILER_FLAGS := true +LOCAL_CLANG := true # For C++11 -# TODO: Change this to -std=c++11 -LOCAL_CFLAGS += -std=gnu++0x +LOCAL_CFLAGS += -std=c++11 LATINIME_NATIVE_JNI_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni LATINIME_NATIVE_SRC_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni/src diff --git a/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java b/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java index c68bdaabf..d6d5e2d61 100644 --- a/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java +++ b/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java @@ -21,5 +21,5 @@ public final class JniLibName { // This class is not publicly instantiable. } - public static final String JNI_LIB_NAME = "latinime-dicttool-host"; + public static final String JNI_LIB_NAME = "latinime-aosp-dicttool-host"; } diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java index e31ac2ab6..f9771c8dd 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java @@ -17,6 +17,7 @@ package com.android.inputmethod.latin.dicttool; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils; +import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; import com.android.inputmethod.latin.makedict.DictDecoder; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; @@ -191,8 +192,9 @@ public final class BinaryDictOffdeviceUtils { return CombinedInputOutput.readDictionaryCombined( new BufferedInputStream(new FileInputStream(decodedSpec.mFile))); } else { - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(decodedSpec.mFile, - 0, decodedSpec.mFile.length(), DictDecoder.USE_BYTEARRAY); + final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder( + decodedSpec.mFile, 0, decodedSpec.mFile.length(), + DictDecoder.USE_BYTEARRAY); if (report) { System.out.println("Format : Binary dictionary format"); System.out.println("Packaging : " + decodedSpec.describeChain()); diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java index 68d785044..8e8ab19e0 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java @@ -17,6 +17,7 @@ package com.android.inputmethod.latin.dicttool; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils; +import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; import com.android.inputmethod.latin.makedict.DictDecoder; import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec; @@ -264,7 +265,7 @@ public class DictionaryMaker { private static FusionDictionary readBinaryFile(final String binaryFilename) throws FileNotFoundException, IOException, UnsupportedFormatException { final File file = new File(binaryFilename); - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(file, 0, file.length()); + final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length()); return dictDecoder.readDictionaryBinary(false /* deleteDictIfBroken */); } diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java index a3095da8a..4f1273bdc 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java @@ -16,6 +16,8 @@ package com.android.inputmethod.latin.dicttool; +import com.android.inputmethod.latin.Dictionary; +import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; import com.android.inputmethod.latin.makedict.DictDecoder; import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.DictionaryHeader; @@ -77,7 +79,7 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase { assertEquals("Wrong decode spec", BinaryDictOffdeviceUtils.COMPRESSION, step); } assertEquals("Wrong decode spec", 3, decodeSpec.mDecoderSpec.size()); - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(decodeSpec.mFile, 0, + final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(decodeSpec.mFile, 0, decodeSpec.mFile.length()); final FusionDictionary resultDict = dictDecoder.readDictionaryBinary(false /* deleteDictIfBroken */); |