Merge "Move a couple classes to the utils package"
commit
a4c44654be
|
@ -77,6 +77,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.latin.suggestions.SuggestionStripView;
|
import com.android.inputmethod.latin.suggestions.SuggestionStripView;
|
||||||
import com.android.inputmethod.latin.utils.ApplicationUtils;
|
import com.android.inputmethod.latin.utils.ApplicationUtils;
|
||||||
|
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.CapsModeUtils;
|
import com.android.inputmethod.latin.utils.CapsModeUtils;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.CompletionInfoUtils;
|
import com.android.inputmethod.latin.utils.CompletionInfoUtils;
|
||||||
|
@ -2428,7 +2429,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|| SuggestedWordInfo.KIND_OOV_CORRECTION == suggestionInfo.mKind)
|
|| SuggestedWordInfo.KIND_OOV_CORRECTION == suggestionInfo.mKind)
|
||||||
&& mSuggest != null
|
&& mSuggest != null
|
||||||
// If the suggestion is not in the dictionary, the hint should be shown.
|
// If the suggestion is not in the dictionary, the hint should be shown.
|
||||||
&& !AutoCorrection.isValidWord(mSuggest, suggestion, true);
|
&& !AutoCorrectionUtils.isValidWord(mSuggest, suggestion, true);
|
||||||
|
|
||||||
if (mSettings.isInternal()) {
|
if (mSettings.isInternal()) {
|
||||||
LatinImeLoggerUtils.onSeparator((char)Constants.CODE_SPACE,
|
LatinImeLoggerUtils.onSeparator((char)Constants.CODE_SPACE,
|
||||||
|
@ -2496,7 +2497,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
// We demote unrecognized words (frequency < 0, below) by specifying them as "invalid".
|
// We demote unrecognized words (frequency < 0, below) by specifying them as "invalid".
|
||||||
// We don't add words with 0-frequency (assuming they would be profanity etc.).
|
// We don't add words with 0-frequency (assuming they would be profanity etc.).
|
||||||
final int maxFreq = AutoCorrection.getMaxFrequency(
|
final int maxFreq = AutoCorrectionUtils.getMaxFrequency(
|
||||||
suggest.getUnigramDictionaries(), suggestion);
|
suggest.getUnigramDictionaries(), suggestion);
|
||||||
if (maxFreq == 0) return null;
|
if (maxFreq == 0) return null;
|
||||||
userHistoryDictionary.addToUserHistory(prevWord, secondWord, maxFreq > 0);
|
userHistoryDictionary.addToUserHistory(prevWord, secondWord, maxFreq > 0);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.text.TextUtils;
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.BoundedTreeSet;
|
import com.android.inputmethod.latin.utils.BoundedTreeSet;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.StringUtils;
|
import com.android.inputmethod.latin.utils.StringUtils;
|
||||||
|
@ -231,7 +232,7 @@ public final class Suggest {
|
||||||
// or if it's a 2+ characters non-word (i.e. it's not in the dictionary).
|
// or if it's a 2+ characters non-word (i.e. it's not in the dictionary).
|
||||||
final boolean allowsToBeAutoCorrected = (null != whitelistedWord
|
final boolean allowsToBeAutoCorrected = (null != whitelistedWord
|
||||||
&& !whitelistedWord.equals(consideredWord))
|
&& !whitelistedWord.equals(consideredWord))
|
||||||
|| (consideredWord.length() > 1 && !AutoCorrection.isValidWord(this,
|
|| (consideredWord.length() > 1 && !AutoCorrectionUtils.isValidWord(this,
|
||||||
consideredWord, wordComposer.isFirstCharCapitalized()));
|
consideredWord, wordComposer.isFirstCharCapitalized()));
|
||||||
|
|
||||||
final boolean hasAutoCorrection;
|
final boolean hasAutoCorrection;
|
||||||
|
@ -252,7 +253,7 @@ public final class Suggest {
|
||||||
// auto-correct.
|
// auto-correct.
|
||||||
hasAutoCorrection = false;
|
hasAutoCorrection = false;
|
||||||
} else {
|
} else {
|
||||||
hasAutoCorrection = AutoCorrection.suggestionExceedsAutoCorrectionThreshold(
|
hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold(
|
||||||
suggestionsSet.first(), consideredWord, mAutoCorrectionThreshold);
|
suggestionsSet.first(), consideredWord, mAutoCorrectionThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
|
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
|
||||||
|
import com.android.inputmethod.latin.utils.ByteArrayWrapper;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils;
|
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils;
|
||||||
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface;
|
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface;
|
||||||
|
|
|
@ -45,10 +45,10 @@ import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.AutoCorrection;
|
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
|
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||||
import com.android.inputmethod.latin.utils.ViewLayoutUtils;
|
import com.android.inputmethod.latin.utils.ViewLayoutUtils;
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ final class SuggestionStripLayoutHelper {
|
||||||
// If we auto-correct, then the autocorrection is in slot 0 and the typed word
|
// If we auto-correct, then the autocorrection is in slot 0 and the typed word
|
||||||
// is in slot 1.
|
// is in slot 1.
|
||||||
if (positionInStrip == mCenterPositionInStrip
|
if (positionInStrip == mCenterPositionInStrip
|
||||||
&& AutoCorrection.shouldBlockAutoCorrectionBySafetyNet(
|
&& AutoCorrectionUtils.shouldBlockAutoCorrectionBySafetyNet(
|
||||||
suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION),
|
suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION),
|
||||||
suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD))) {
|
suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD))) {
|
||||||
return 0xFFFF0000;
|
return 0xFFFF0000;
|
||||||
|
|
|
@ -14,8 +14,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.BinaryDictionary;
|
||||||
|
import com.android.inputmethod.latin.Dictionary;
|
||||||
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
|
import com.android.inputmethod.latin.Suggest;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
@ -23,12 +27,12 @@ import android.util.Log;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public final class AutoCorrection {
|
public final class AutoCorrectionUtils {
|
||||||
private static final boolean DBG = LatinImeLogger.sDBG;
|
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||||
private static final String TAG = AutoCorrection.class.getSimpleName();
|
private static final String TAG = AutoCorrectionUtils.class.getSimpleName();
|
||||||
private static final int MINIMUM_SAFETY_NET_CHAR_LENGTH = 4;
|
private static final int MINIMUM_SAFETY_NET_CHAR_LENGTH = 4;
|
||||||
|
|
||||||
private AutoCorrection() {
|
private AutoCorrectionUtils() {
|
||||||
// Purely static class: can't instantiate.
|
// Purely static class: can't instantiate.
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;
|
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;
|
||||||
|
|
|
@ -22,12 +22,12 @@ import android.test.suitebuilder.annotation.LargeTest;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.ByteArrayWrapper;
|
|
||||||
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;
|
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;
|
||||||
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
|
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
|
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
|
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
|
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
|
||||||
|
import com.android.inputmethod.latin.utils.ByteArrayWrapper;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
|
@ -21,11 +21,11 @@ import android.test.AndroidTestCase;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.ByteArrayWrapper;
|
|
||||||
import com.android.inputmethod.latin.UserHistoryDictionaryBigramList;
|
import com.android.inputmethod.latin.UserHistoryDictionaryBigramList;
|
||||||
import com.android.inputmethod.latin.makedict.FormatSpec;
|
import com.android.inputmethod.latin.makedict.FormatSpec;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary;
|
import com.android.inputmethod.latin.makedict.FusionDictionary;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
|
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
|
||||||
|
import com.android.inputmethod.latin.utils.ByteArrayWrapper;
|
||||||
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface;
|
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface;
|
||||||
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.OnAddWordListener;
|
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.OnAddWordListener;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ DICTTOOL_ONDEVICE_TESTS_DIRECTORY := \
|
||||||
$(LATINIME_DIR)/tests/src/com/android/inputmethod/latin/makedict/
|
$(LATINIME_DIR)/tests/src/com/android/inputmethod/latin/makedict/
|
||||||
|
|
||||||
USED_TARGETTED_UTILS := \
|
USED_TARGETTED_UTILS := \
|
||||||
$(LATINIME_CORE_SOURCE_DIRECTORY)/ByteArrayWrapper.java \
|
$(LATINIME_CORE_SOURCE_DIRECTORY)/utils/ByteArrayWrapper.java \
|
||||||
$(LATINIME_CORE_SOURCE_DIRECTORY)/utils/CollectionUtils.java
|
$(LATINIME_CORE_SOURCE_DIRECTORY)/utils/CollectionUtils.java
|
||||||
|
|
||||||
LOCAL_MAIN_SRC_FILES := $(call all-java-files-under, $(MAKEDICT_CORE_SOURCE_DIRECTORY))
|
LOCAL_MAIN_SRC_FILES := $(call all-java-files-under, $(MAKEDICT_CORE_SOURCE_DIRECTORY))
|
||||||
|
|
Loading…
Reference in New Issue