Move a couple classes to the utils package

Change-Id: Ia14a2011d79bad7cd02697b9254705f6e2099442
main
Ken Wakasa 2013-07-18 22:59:26 +09:00
parent 03a76a07e2
commit b03447e1af
9 changed files with 21 additions and 14 deletions

View File

@ -77,6 +77,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.suggestions.SuggestionStripView;
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.CollectionUtils;
import com.android.inputmethod.latin.utils.CompletionInfoUtils;
@ -2428,7 +2429,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|| SuggestedWordInfo.KIND_OOV_CORRECTION == suggestionInfo.mKind)
&& mSuggest != null
// 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()) {
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 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);
if (maxFreq == 0) return null;
userHistoryDictionary.addToUserHistory(prevWord, secondWord, maxFreq > 0);

View File

@ -22,6 +22,7 @@ import android.text.TextUtils;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.ProximityInfo;
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.CollectionUtils;
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).
final boolean allowsToBeAutoCorrected = (null != whitelistedWord
&& !whitelistedWord.equals(consideredWord))
|| (consideredWord.length() > 1 && !AutoCorrection.isValidWord(this,
|| (consideredWord.length() > 1 && !AutoCorrectionUtils.isValidWord(this,
consideredWord, wordComposer.isFirstCharCapitalized()));
final boolean hasAutoCorrection;
@ -252,7 +253,7 @@ public final class Suggest {
// auto-correct.
hasAutoCorrection = false;
} else {
hasAutoCorrection = AutoCorrection.suggestionExceedsAutoCorrectionThreshold(
hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold(
suggestionsSet.first(), consideredWord, mAutoCorrectionThreshold);
}

View File

@ -25,6 +25,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.makedict.FormatSpec.FormatOptions;
import com.android.inputmethod.latin.utils.ByteArrayWrapper;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils;
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface;

View File

@ -45,10 +45,10 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.inputmethod.latin.AutoCorrection;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
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.ViewLayoutUtils;
@ -279,7 +279,7 @@ final class SuggestionStripLayoutHelper {
// If we auto-correct, then the autocorrection is in slot 0 and the typed word
// is in slot 1.
if (positionInStrip == mCenterPositionInStrip
&& AutoCorrection.shouldBlockAutoCorrectionBySafetyNet(
&& AutoCorrectionUtils.shouldBlockAutoCorrectionBySafetyNet(
suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION),
suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD))) {
return 0xFFFF0000;

View File

@ -14,8 +14,12 @@
* 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 android.text.TextUtils;
@ -23,12 +27,12 @@ import android.util.Log;
import java.util.concurrent.ConcurrentHashMap;
public final class AutoCorrection {
public final class AutoCorrectionUtils {
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 AutoCorrection() {
private AutoCorrectionUtils() {
// Purely static class: can't instantiate.
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.inputmethod.latin;
package com.android.inputmethod.latin.utils;
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;

View File

@ -22,12 +22,12 @@ import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import android.util.SparseArray;
import com.android.inputmethod.latin.ByteArrayWrapper;
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
import com.android.inputmethod.latin.utils.ByteArrayWrapper;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.io.File;

View File

@ -21,11 +21,11 @@ import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import com.android.inputmethod.latin.ByteArrayWrapper;
import com.android.inputmethod.latin.UserHistoryDictionaryBigramList;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FusionDictionary;
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.OnAddWordListener;

View File

@ -27,7 +27,7 @@ DICTTOOL_ONDEVICE_TESTS_DIRECTORY := \
$(LATINIME_DIR)/tests/src/com/android/inputmethod/latin/makedict/
USED_TARGETTED_UTILS := \
$(LATINIME_CORE_SOURCE_DIRECTORY)/ByteArrayWrapper.java \
$(LATINIME_CORE_SOURCE_DIRECTORY)/utils/ByteArrayWrapper.java \
$(LATINIME_CORE_SOURCE_DIRECTORY)/utils/CollectionUtils.java
LOCAL_MAIN_SRC_FILES := $(call all-java-files-under, $(MAKEDICT_CORE_SOURCE_DIRECTORY))