diff options
15 files changed, 173 insertions, 171 deletions
diff --git a/java/src/com/android/inputmethod/latin/define/ProductionFlag.java b/java/src/com/android/inputmethod/latin/define/ProductionFlag.java index 52c066a44..a14398f64 100644 --- a/java/src/com/android/inputmethod/latin/define/ProductionFlag.java +++ b/java/src/com/android/inputmethod/latin/define/ProductionFlag.java @@ -23,4 +23,9 @@ public final class ProductionFlag { public static final boolean IS_EXPERIMENTAL = false; public static final boolean IS_INTERNAL = false; + + // When false, IS_EXPERIMENTAL_DEBUG suggests that all guarded class-private DEBUG flags should + // be false, and any privacy controls should be enforced. IS_EXPERIMENTAL_DEBUG should be false + // for any released build. + public static final boolean IS_EXPERIMENTAL_DEBUG = false; } diff --git a/java/src/com/android/inputmethod/research/MainLogBuffer.java b/java/src/com/android/inputmethod/research/MainLogBuffer.java index b027643a1..0185e5fc0 100644 --- a/java/src/com/android/inputmethod/research/MainLogBuffer.java +++ b/java/src/com/android/inputmethod/research/MainLogBuffer.java @@ -20,18 +20,19 @@ import android.util.Log; import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.Suggest; +import com.android.inputmethod.latin.define.ProductionFlag; import java.util.Random; public class MainLogBuffer extends LogBuffer { private static final String TAG = MainLogBuffer.class.getSimpleName(); - // For privacy reasons, be sure to set to "false" for production code. - private static final boolean DEBUG = false; + private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG; // The size of the n-grams logged. E.g. N_GRAM_SIZE = 2 means to sample bigrams. private static final int N_GRAM_SIZE = 2; // The number of words between n-grams to omit from the log. - private static final int DEFAULT_NUMBER_OF_WORDS_BETWEEN_SAMPLES = DEBUG ? 2 : 18; + private static final int DEFAULT_NUMBER_OF_WORDS_BETWEEN_SAMPLES = + ProductionFlag.IS_EXPERIMENTAL_DEBUG ? 2 : 18; private final ResearchLog mResearchLog; private Suggest mSuggest; diff --git a/java/src/com/android/inputmethod/research/ResearchLog.java b/java/src/com/android/inputmethod/research/ResearchLog.java index f0a1317b2..3c8731995 100644 --- a/java/src/com/android/inputmethod/research/ResearchLog.java +++ b/java/src/com/android/inputmethod/research/ResearchLog.java @@ -52,7 +52,7 @@ import java.util.concurrent.TimeUnit; */ public class ResearchLog { private static final String TAG = ResearchLog.class.getSimpleName(); - private static final boolean DEBUG = false; + private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG; private static final long FLUSH_DELAY_IN_MS = 1000 * 5; private static final int ABORT_TIMEOUT_IN_MS = 1000 * 4; diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index c8e1b8c32..7f2d24efa 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -83,7 +83,7 @@ import java.util.UUID; */ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = ResearchLogger.class.getSimpleName(); - private static final boolean DEBUG = false; + private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG; private static final boolean LOG_EVERYTHING = false; // true will disclose private info public static final boolean DEFAULT_USABILITY_STUDY_MODE = false; /* package */ static boolean sIsLogging = false; @@ -94,8 +94,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private static final String FILENAME_SUFFIX = ".txt"; private static final SimpleDateFormat TIMESTAMP_DATEFORMAT = new SimpleDateFormat("yyyyMMddHHmmssS", Locale.US); + // Whether to show an indicator on the screen that logging is on. Currently a very small red + // dot in the lower right hand corner. Most users should not notice it. private static final boolean IS_SHOWING_INDICATOR = true; - private static final boolean IS_SHOWING_INDICATOR_CLEARLY = false; + // Change the default indicator to something very visible. Currently two red vertical bars on + // either side of they keyboard. + private static final boolean IS_SHOWING_INDICATOR_CLEARLY = false || LOG_EVERYTHING; public static final int FEEDBACK_WORD_BUFFER_SIZE = 5; // constants related to specific log points @@ -682,7 +686,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang if (!mCurrentLogUnit.isEmpty()) { if (mMainLogBuffer != null) { mMainLogBuffer.shiftIn(mCurrentLogUnit); - if (mMainLogBuffer.isSafeToLog() && mMainResearchLog != null) { + if ((mMainLogBuffer.isSafeToLog() || LOG_EVERYTHING) && mMainResearchLog != null) { publishLogBuffer(mMainLogBuffer, mMainResearchLog, true /* isIncludingPrivateData */); mMainLogBuffer.resetWordCounter(); @@ -805,7 +809,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private static final LogStatement LOGSTATEMENT_LATIN_IME_ON_START_INPUT_VIEW_INTERNAL = new LogStatement("LatinImeOnStartInputViewInternal", false, false, "uuid", "packageName", "inputType", "imeOptions", "fieldId", "display", "model", - "prefs", "versionCode", "versionName", "outputFormatVersion", "logEverything"); + "prefs", "versionCode", "versionName", "outputFormatVersion", "logEverything", + "isExperimentalDebug"); public static void latinIME_onStartInputViewInternal(final EditorInfo editorInfo, final SharedPreferences prefs) { final ResearchLogger researchLogger = getInstance(); @@ -826,7 +831,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang Integer.toHexString(editorInfo.inputType), Integer.toHexString(editorInfo.imeOptions), editorInfo.fieldId, Build.DISPLAY, Build.MODEL, prefs, versionCode, versionName, - OUTPUT_FORMAT_VERSION, LOG_EVERYTHING); + OUTPUT_FORMAT_VERSION, LOG_EVERYTHING, + ProductionFlag.IS_EXPERIMENTAL_DEBUG); } catch (NameNotFoundException e) { e.printStackTrace(); } diff --git a/java/src/com/android/inputmethod/research/Statistics.java b/java/src/com/android/inputmethod/research/Statistics.java index 90d7f38b3..23d1050cb 100644 --- a/java/src/com/android/inputmethod/research/Statistics.java +++ b/java/src/com/android/inputmethod/research/Statistics.java @@ -19,10 +19,11 @@ package com.android.inputmethod.research; import android.util.Log; import com.android.inputmethod.latin.Constants; +import com.android.inputmethod.latin.define.ProductionFlag; public class Statistics { private static final String TAG = Statistics.class.getSimpleName(); - private static final boolean DEBUG = false; + private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG; // Number of characters entered during a typing session int mCharCount; diff --git a/native/jni/Android.mk b/native/jni/Android.mk index c616be56e..a8a88712a 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -26,7 +26,7 @@ include $(CLEAR_VARS) LATIN_IME_SRC_DIR := src LATIN_IME_SRC_FULLPATH_DIR := $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR) -LOCAL_C_INCLUDES += $(LATIN_IME_SRC_FULLPATH_DIR) $(LATIN_IME_SRC_FULLPATH_DIR)/gesture +LOCAL_C_INCLUDES += $(LATIN_IME_SRC_FULLPATH_DIR) $(LATIN_IME_SRC_FULLPATH_DIR)/suggest LOCAL_CFLAGS += -Werror -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \ -Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls -Wno-system-headers @@ -57,8 +57,8 @@ LATIN_IME_CORE_SRC_FILES := \ proximity_info_state.cpp \ unigram_dictionary.cpp \ words_priority_queue.cpp \ - gesture/gesture_decoder_wrapper.cpp \ - gesture/incremental_decoder_wrapper.cpp + suggest/gesture_suggest.cpp \ + suggest/typing_suggest.cpp LOCAL_SRC_FILES := \ $(LATIN_IME_JNI_SRC_FILES) \ diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp index 8210aa0ff..167b36f11 100644 --- a/native/jni/src/dictionary.cpp +++ b/native/jni/src/dictionary.cpp @@ -23,7 +23,7 @@ #include "defines.h" #include "dictionary.h" #include "dic_traverse_wrapper.h" -#include "gesture_decoder_wrapper.h" +#include "gesture_suggest.h" #include "unigram_dictionary.h" namespace latinime { @@ -36,7 +36,7 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, mUnigramDictionary(new UnigramDictionary(mOffsetDict, maxWordLength, maxWords, BinaryFormat::getFlags(mDict))), mBigramDictionary(new BigramDictionary(mOffsetDict, maxWordLength, maxPredictions)), - mGestureDecoder(new GestureDecoderWrapper(maxWordLength, maxWords)) { + mGestureSuggest(new GestureSuggest(maxWordLength, maxWords)) { if (DEBUG_DICT) { if (MAX_WORD_LENGTH_INTERNAL < maxWordLength) { AKLOGI("Max word length (%d) is greater than %d", @@ -49,7 +49,7 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, Dictionary::~Dictionary() { delete mUnigramDictionary; delete mBigramDictionary; - delete mGestureDecoder; + delete mGestureSuggest; } int Dictionary::getSuggestions(ProximityInfo *proximityInfo, void *traverseSession, @@ -61,7 +61,7 @@ int Dictionary::getSuggestions(ProximityInfo *proximityInfo, void *traverseSessi if (isGesture) { DicTraverseWrapper::initDicTraverseSession( traverseSession, this, prevWordChars, prevWordLength); - result = mGestureDecoder->getSuggestions(proximityInfo, traverseSession, + result = mGestureSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates, ycoordinates, times, pointerIds, codes, codesSize, commitPoint, outWords, frequencies, spaceIndices, outputTypes); if (DEBUG_DICT) { diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h index e9660002e..26edc4f2f 100644 --- a/native/jni/src/dictionary.h +++ b/native/jni/src/dictionary.h @@ -24,8 +24,8 @@ namespace latinime { class BigramDictionary; -class IncrementalDecoderInterface; class ProximityInfo; +class SuggestInterface; class UnigramDictionary; class Dictionary { @@ -83,7 +83,7 @@ class Dictionary { const UnigramDictionary *mUnigramDictionary; const BigramDictionary *mBigramDictionary; - IncrementalDecoderInterface *mGestureDecoder; + SuggestInterface *mGestureSuggest; }; // public static utility methods diff --git a/native/jni/src/gesture/gesture_decoder_wrapper.h b/native/jni/src/gesture/gesture_decoder_wrapper.h deleted file mode 100644 index b96814907..000000000 --- a/native/jni/src/gesture/gesture_decoder_wrapper.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef LATINIME_GESTURE_DECODER_WRAPPER_H -#define LATINIME_GESTURE_DECODER_WRAPPER_H - -#include "defines.h" -#include "incremental_decoder_interface.h" - -namespace latinime { - -class UnigramDictionary; -class BigramDictionary; -class ProximityInfo; - -class GestureDecoderWrapper : public IncrementalDecoderInterface { - public: - GestureDecoderWrapper(const int maxWordLength, const int maxWords) - : mIncrementalDecoderInterface(getGestureDecoderInstance(maxWordLength, maxWords)) { - } - - virtual ~GestureDecoderWrapper(); - - int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, - int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords, - int *frequencies, int *outputIndices, int *outputTypes) const { - if (!mIncrementalDecoderInterface) { - return 0; - } - return mIncrementalDecoderInterface->getSuggestions(pInfo, traverseSession, inputXs, - inputYs, times, pointerIds, codes, inputSize, commitPoint, outWords, frequencies, - outputIndices, outputTypes); - } - - static void setGestureDecoderFactoryMethod( - IncrementalDecoderInterface *(*factoryMethod)(int, int)) { - sGestureDecoderFactoryMethod = factoryMethod; - } - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(GestureDecoderWrapper); - static IncrementalDecoderInterface *getGestureDecoderInstance(int maxWordLength, int maxWords) { - if (sGestureDecoderFactoryMethod) { - return sGestureDecoderFactoryMethod(maxWordLength, maxWords); - } - return 0; - } - - static IncrementalDecoderInterface *(*sGestureDecoderFactoryMethod)(int, int); - IncrementalDecoderInterface *mIncrementalDecoderInterface; -}; -} // namespace latinime -#endif // LATINIME_GESTURE_DECODER_WRAPPER_H diff --git a/native/jni/src/gesture/incremental_decoder_wrapper.h b/native/jni/src/gesture/incremental_decoder_wrapper.h deleted file mode 100644 index c15b439fa..000000000 --- a/native/jni/src/gesture/incremental_decoder_wrapper.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef LATINIME_INCREMENTAL_DECODER_WRAPPER_H -#define LATINIME_INCREMENTAL_DECODER_WRAPPER_H - -#include "defines.h" -#include "incremental_decoder_interface.h" - -namespace latinime { - -class UnigramDictionary; -class BigramDictionary; -class ProximityInfo; - -class IncrementalDecoderWrapper : public IncrementalDecoderInterface { - public: - IncrementalDecoderWrapper(const int maxWordLength, const int maxWords) - : mIncrementalDecoderInterface(getIncrementalDecoderInstance(maxWordLength, maxWords)) { - } - - virtual ~IncrementalDecoderWrapper(); - - int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, - int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords, - int *frequencies, int *outputIndices, int *outputTypes) const { - if (!mIncrementalDecoderInterface) { - return 0; - } - return mIncrementalDecoderInterface->getSuggestions(pInfo, traverseSession, inputXs, - inputYs, times, pointerIds, codes, inputSize, commitPoint, outWords, frequencies, - outputIndices, outputTypes); - } - - static void setIncrementalDecoderFactoryMethod( - IncrementalDecoderInterface *(*factoryMethod)(int, int)) { - sIncrementalDecoderFactoryMethod = factoryMethod; - } - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalDecoderWrapper); - static IncrementalDecoderInterface *getIncrementalDecoderInstance(int maxWordLength, - int maxWords) { - if (sIncrementalDecoderFactoryMethod) { - return sIncrementalDecoderFactoryMethod(maxWordLength, maxWords); - } - return 0; - } - - static IncrementalDecoderInterface *(*sIncrementalDecoderFactoryMethod)(int, int); - IncrementalDecoderInterface *mIncrementalDecoderInterface; -}; -} // namespace latinime -#endif // LATINIME_INCREMENTAL_DECODER_WRAPPER_H diff --git a/native/jni/src/gesture/gesture_decoder_wrapper.cpp b/native/jni/src/suggest/gesture_suggest.cpp index 20ad4a58c..2a604b8ab 100644 --- a/native/jni/src/gesture/gesture_decoder_wrapper.cpp +++ b/native/jni/src/suggest/gesture_suggest.cpp @@ -14,13 +14,12 @@ * limitations under the License. */ -#include "gesture_decoder_wrapper.h" +#include "gesture_suggest.h" namespace latinime { - IncrementalDecoderInterface * - (*GestureDecoderWrapper::sGestureDecoderFactoryMethod)(int, int) = 0; + SuggestInterface *(*GestureSuggest::sGestureSuggestFactoryMethod)(int, int) = 0; - GestureDecoderWrapper::~GestureDecoderWrapper() { - delete mIncrementalDecoderInterface; + GestureSuggest::~GestureSuggest() { + delete mSuggestInterface; } } // namespace latinime diff --git a/native/jni/src/suggest/gesture_suggest.h b/native/jni/src/suggest/gesture_suggest.h new file mode 100644 index 000000000..e4af03fb8 --- /dev/null +++ b/native/jni/src/suggest/gesture_suggest.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012 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. + */ + +#ifndef LATINIME_GESTURE_SUGGEST_H +#define LATINIME_GESTURE_SUGGEST_H + +#include "defines.h" +#include "suggest_interface.h" + +namespace latinime { + +class ProximityInfo; + +class GestureSuggest : public SuggestInterface { + public: + GestureSuggest(const int maxWordLength, const int maxWords) + : mSuggestInterface(getGestureSuggestInstance(maxWordLength, maxWords)) { + } + + virtual ~GestureSuggest(); + + int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, + int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords, + int *frequencies, int *outputIndices, int *outputTypes) const { + if (!mSuggestInterface) { + return 0; + } + return mSuggestInterface->getSuggestions(pInfo, traverseSession, inputXs, inputYs, times, + pointerIds, codes, inputSize, commitPoint, outWords, frequencies, outputIndices, + outputTypes); + } + + static void setGestureSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int, int)) { + sGestureSuggestFactoryMethod = factoryMethod; + } + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(GestureSuggest); + static SuggestInterface *getGestureSuggestInstance(int maxWordLength, int maxWords) { + if (!sGestureSuggestFactoryMethod) { + return 0; + } + return sGestureSuggestFactoryMethod(maxWordLength, maxWords); + } + + static SuggestInterface *(*sGestureSuggestFactoryMethod)(int, int); + SuggestInterface *mSuggestInterface; +}; +} // namespace latinime +#endif // LATINIME_GESTURE_SUGGEST_H diff --git a/native/jni/src/gesture/incremental_decoder_interface.h b/native/jni/src/suggest/suggest_interface.h index ff85adc61..de58e7918 100644 --- a/native/jni/src/gesture/incremental_decoder_interface.h +++ b/native/jni/src/suggest/suggest_interface.h @@ -14,26 +14,24 @@ * limitations under the License. */ -#ifndef LATINIME_INCREMENTAL_DECODER_INTERFACE_H -#define LATINIME_INCREMENTAL_DECODER_INTERFACE_H +#ifndef LATINIME_SUGGEST_INTERFACE_H +#define LATINIME_SUGGEST_INTERFACE_H #include "defines.h" namespace latinime { -class UnigramDictionary; -class BigramDictionary; class ProximityInfo; -class IncrementalDecoderInterface { +class SuggestInterface { public: virtual int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords, int *frequencies, int *outputIndices, int *outputTypes) const = 0; - IncrementalDecoderInterface() { }; - virtual ~IncrementalDecoderInterface() { }; + SuggestInterface() {}; + virtual ~SuggestInterface() {}; private: - DISALLOW_COPY_AND_ASSIGN(IncrementalDecoderInterface); + DISALLOW_COPY_AND_ASSIGN(SuggestInterface); }; } // namespace latinime -#endif // LATINIME_INCREMENTAL_DECODER_INTERFACE_H +#endif // LATINIME_SUGGEST_INTERFACE_H diff --git a/native/jni/src/gesture/incremental_decoder_wrapper.cpp b/native/jni/src/suggest/typing_suggest.cpp index f6e45623a..40d4a98b0 100644 --- a/native/jni/src/gesture/incremental_decoder_wrapper.cpp +++ b/native/jni/src/suggest/typing_suggest.cpp @@ -14,13 +14,12 @@ * limitations under the License. */ -#include "incremental_decoder_wrapper.h" +#include "typing_suggest.h" namespace latinime { - IncrementalDecoderInterface * - (*IncrementalDecoderWrapper::sIncrementalDecoderFactoryMethod)(int, int) = 0; + SuggestInterface *(*TypingSuggest::sTypingSuggestFactoryMethod)(int, int) = 0; - IncrementalDecoderWrapper::~IncrementalDecoderWrapper() { - delete mIncrementalDecoderInterface; + TypingSuggest::~TypingSuggest() { + delete mSuggestInterface; } } // namespace latinime diff --git a/native/jni/src/suggest/typing_suggest.h b/native/jni/src/suggest/typing_suggest.h new file mode 100644 index 000000000..9de4158f5 --- /dev/null +++ b/native/jni/src/suggest/typing_suggest.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012 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. + */ + +#ifndef LATINIME_TYPING_SUGGEST_H +#define LATINIME_TYPING_SUGGEST_H + +#include "defines.h" +#include "suggest_interface.h" + +namespace latinime { + +class ProximityInfo; + +class TypingSuggest : public SuggestInterface { + public: + TypingSuggest(const int maxWordLength, const int maxWords) + : mSuggestInterface(getTypingSuggestInstance(maxWordLength, maxWords)) { + } + + virtual ~TypingSuggest(); + + int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, + int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords, + int *frequencies, int *outputIndices, int *outputTypes) const { + if (!mSuggestInterface) { + return 0; + } + return mSuggestInterface->getSuggestions(pInfo, traverseSession, inputXs, inputYs, times, + pointerIds, codes, inputSize, commitPoint, outWords, frequencies, outputIndices, + outputTypes); + } + + static void setTypingSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int, int)) { + sTypingSuggestFactoryMethod = factoryMethod; + } + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(TypingSuggest); + static SuggestInterface *getTypingSuggestInstance(int maxWordLength, int maxWords) { + if (!sTypingSuggestFactoryMethod) { + return 0; + } + return sTypingSuggestFactoryMethod(maxWordLength, maxWords); + } + + static SuggestInterface *(*sTypingSuggestFactoryMethod)(int, int); + SuggestInterface *mSuggestInterface; +}; +} // namespace latinime +#endif // LATINIME_TYPING_SUGGEST_H |