Merge "Move phrase gesture from additional features to public."
commit
3b8f2ece40
|
@ -103,6 +103,13 @@
|
||||||
android:title="@string/gesture_preview_trail"
|
android:title="@string/gesture_preview_trail"
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:persistent="true" />
|
android:persistent="true" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="pref_gesture_space_aware"
|
||||||
|
android:dependency="gesture_input"
|
||||||
|
android:title="@string/gesture_space_aware"
|
||||||
|
android:summary="@string/gesture_space_aware_summary"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:persistent="true" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/settings_screen_correction"
|
android:title="@string/settings_screen_correction"
|
||||||
|
|
|
@ -28,6 +28,7 @@ import com.android.inputmethod.latin.makedict.FormatSpec;
|
||||||
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
|
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
|
||||||
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
|
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
|
||||||
import com.android.inputmethod.latin.makedict.WordProperty;
|
import com.android.inputmethod.latin.makedict.WordProperty;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
||||||
import com.android.inputmethod.latin.utils.FileUtils;
|
import com.android.inputmethod.latin.utils.FileUtils;
|
||||||
import com.android.inputmethod.latin.utils.JniUtils;
|
import com.android.inputmethod.latin.utils.JniUtils;
|
||||||
|
@ -256,7 +257,7 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final int sessionId, final float[] inOutLanguageWeight) {
|
||||||
if (!isValidDictionary()) {
|
if (!isValidDictionary()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -279,8 +280,12 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
session.mNativeSuggestOptions.setUseFullEditDistance(mUseFullEditDistance);
|
session.mNativeSuggestOptions.setUseFullEditDistance(mUseFullEditDistance);
|
||||||
session.mNativeSuggestOptions.setIsGesture(isGesture);
|
session.mNativeSuggestOptions.setIsGesture(isGesture);
|
||||||
session.mNativeSuggestOptions.setBlockOffensiveWords(blockOffensiveWords);
|
session.mNativeSuggestOptions.setBlockOffensiveWords(
|
||||||
session.mNativeSuggestOptions.setAdditionalFeaturesOptions(additionalFeaturesOptions);
|
settingsValuesForSuggestion.mBlockPotentiallyOffensive);
|
||||||
|
session.mNativeSuggestOptions.setSpaceAwareGestureEnabled(
|
||||||
|
settingsValuesForSuggestion.mSpaceAwareGestureEnabled);
|
||||||
|
session.mNativeSuggestOptions.setAdditionalFeaturesOptions(
|
||||||
|
settingsValuesForSuggestion.mAdditionalFeaturesSettingValues);
|
||||||
if (inOutLanguageWeight != null) {
|
if (inOutLanguageWeight != null) {
|
||||||
session.mInputOutputLanguageWeight[0] = inOutLanguageWeight[0];
|
session.mInputOutputLanguageWeight[0] = inOutLanguageWeight[0];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
|
||||||
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.settings.SettingsValuesForSuggestion;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -72,8 +73,7 @@ public abstract class Dictionary {
|
||||||
* @param composer the key sequence to match with coordinate info, as a WordComposer
|
* @param composer the key sequence to match with coordinate info, as a WordComposer
|
||||||
* @param prevWordsInfo the information of previous words.
|
* @param prevWordsInfo the information of previous words.
|
||||||
* @param proximityInfo the object for key proximity. May be ignored by some implementations.
|
* @param proximityInfo the object for key proximity. May be ignored by some implementations.
|
||||||
* @param blockOffensiveWords whether to block potentially offensive words
|
* @param settingsValuesForSuggestion the settings values used for the suggestion.
|
||||||
* @param additionalFeaturesOptions options about additional features used for the suggestion.
|
|
||||||
* @param sessionId the session id.
|
* @param sessionId the session id.
|
||||||
* @param inOutLanguageWeight the language weight used for generating suggestions.
|
* @param inOutLanguageWeight the language weight used for generating suggestions.
|
||||||
* inOutLanguageWeight is a float array that has only one element. This can be updated when the
|
* inOutLanguageWeight is a float array that has only one element. This can be updated when the
|
||||||
|
@ -82,7 +82,7 @@ public abstract class Dictionary {
|
||||||
*/
|
*/
|
||||||
abstract public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
abstract public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight);
|
final int sessionId, final float[] inOutLanguageWeight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +168,7 @@ public abstract class Dictionary {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final int sessionId, final float[] inOutLanguageWeight) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.util.Log;
|
||||||
|
|
||||||
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.settings.SettingsValuesForSuggestion;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -57,21 +58,21 @@ public final class DictionaryCollection extends Dictionary {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final int sessionId, final float[] inOutLanguageWeight) {
|
||||||
final CopyOnWriteArrayList<Dictionary> dictionaries = mDictionaries;
|
final CopyOnWriteArrayList<Dictionary> dictionaries = mDictionaries;
|
||||||
if (dictionaries.isEmpty()) return null;
|
if (dictionaries.isEmpty()) return null;
|
||||||
// To avoid creating unnecessary objects, we get the list out of the first
|
// To avoid creating unnecessary objects, we get the list out of the first
|
||||||
// dictionary and add the rest to it if not null, hence the get(0)
|
// dictionary and add the rest to it if not null, hence the get(0)
|
||||||
ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composer,
|
ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composer,
|
||||||
prevWordsInfo, proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
|
prevWordsInfo, proximityInfo, settingsValuesForSuggestion, sessionId,
|
||||||
sessionId, inOutLanguageWeight);
|
inOutLanguageWeight);
|
||||||
if (null == suggestions) suggestions = new ArrayList<>();
|
if (null == suggestions) suggestions = new ArrayList<>();
|
||||||
final int length = dictionaries.size();
|
final int length = dictionaries.size();
|
||||||
for (int i = 1; i < length; ++ i) {
|
for (int i = 1; i < length; ++ i) {
|
||||||
final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(composer,
|
final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(composer,
|
||||||
prevWordsInfo, proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
|
prevWordsInfo, proximityInfo, settingsValuesForSuggestion, sessionId,
|
||||||
sessionId, inOutLanguageWeight);
|
inOutLanguageWeight);
|
||||||
if (null != sugg) suggestions.addAll(sugg);
|
if (null != sugg) suggestions.addAll(sugg);
|
||||||
}
|
}
|
||||||
return suggestions;
|
return suggestions;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.android.inputmethod.latin.personalization.ContextualDictionary;
|
||||||
import com.android.inputmethod.latin.personalization.PersonalizationDataChunk;
|
import com.android.inputmethod.latin.personalization.PersonalizationDataChunk;
|
||||||
import com.android.inputmethod.latin.personalization.PersonalizationDictionary;
|
import com.android.inputmethod.latin.personalization.PersonalizationDictionary;
|
||||||
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
|
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||||
import com.android.inputmethod.latin.utils.DistracterFilter;
|
import com.android.inputmethod.latin.utils.DistracterFilter;
|
||||||
import com.android.inputmethod.latin.utils.DistracterFilterCheckingIsInDictionary;
|
import com.android.inputmethod.latin.utils.DistracterFilterCheckingIsInDictionary;
|
||||||
|
@ -486,8 +487,7 @@ public class DictionaryFacilitator {
|
||||||
// TODO: Revise the way to fusion suggestion results.
|
// TODO: Revise the way to fusion suggestion results.
|
||||||
public SuggestionResults getSuggestionResults(final WordComposer composer,
|
public SuggestionResults getSuggestionResults(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion, final int sessionId) {
|
||||||
final int sessionId) {
|
|
||||||
final Dictionaries dictionaries = mDictionaries;
|
final Dictionaries dictionaries = mDictionaries;
|
||||||
final SuggestionResults suggestionResults =
|
final SuggestionResults suggestionResults =
|
||||||
new SuggestionResults(dictionaries.mLocale, SuggestedWords.MAX_SUGGESTIONS);
|
new SuggestionResults(dictionaries.mLocale, SuggestedWords.MAX_SUGGESTIONS);
|
||||||
|
@ -497,8 +497,7 @@ public class DictionaryFacilitator {
|
||||||
if (null == dictionary) continue;
|
if (null == dictionary) continue;
|
||||||
final ArrayList<SuggestedWordInfo> dictionarySuggestions =
|
final ArrayList<SuggestedWordInfo> dictionarySuggestions =
|
||||||
dictionary.getSuggestions(composer, prevWordsInfo, proximityInfo,
|
dictionary.getSuggestions(composer, prevWordsInfo, proximityInfo,
|
||||||
blockOffensiveWords, additionalFeaturesOptions, sessionId,
|
settingsValuesForSuggestion, sessionId, languageWeight);
|
||||||
languageWeight);
|
|
||||||
if (null == dictionarySuggestions) continue;
|
if (null == dictionarySuggestions) continue;
|
||||||
suggestionResults.addAll(dictionarySuggestions);
|
suggestionResults.addAll(dictionarySuggestions);
|
||||||
if (null != suggestionResults.mRawSuggestions) {
|
if (null != suggestionResults.mRawSuggestions) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import com.android.inputmethod.latin.makedict.FormatSpec;
|
||||||
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
|
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
|
||||||
import com.android.inputmethod.latin.makedict.WordProperty;
|
import com.android.inputmethod.latin.makedict.WordProperty;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.utils.CombinedFormatUtils;
|
import com.android.inputmethod.latin.utils.CombinedFormatUtils;
|
||||||
import com.android.inputmethod.latin.utils.DistracterFilter;
|
import com.android.inputmethod.latin.utils.DistracterFilter;
|
||||||
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
||||||
|
@ -409,8 +410,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion, final int sessionId,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final float[] inOutLanguageWeight) {
|
||||||
reloadDictionaryIfRequired();
|
reloadDictionaryIfRequired();
|
||||||
boolean lockAcquired = false;
|
boolean lockAcquired = false;
|
||||||
try {
|
try {
|
||||||
|
@ -422,8 +423,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
final ArrayList<SuggestedWordInfo> suggestions =
|
final ArrayList<SuggestedWordInfo> suggestions =
|
||||||
mBinaryDictionary.getSuggestions(composer, prevWordsInfo, proximityInfo,
|
mBinaryDictionary.getSuggestions(composer, prevWordsInfo, proximityInfo,
|
||||||
blockOffensiveWords, additionalFeaturesOptions, sessionId,
|
settingsValuesForSuggestion, sessionId, inOutLanguageWeight);
|
||||||
inOutLanguageWeight);
|
|
||||||
if (mBinaryDictionary.isCorrupted()) {
|
if (mBinaryDictionary.isCorrupted()) {
|
||||||
Log.i(TAG, "Dictionary (" + mDictName +") is corrupted. "
|
Log.i(TAG, "Dictionary (" + mDictName +") is corrupted. "
|
||||||
+ "Remove and regenerate it.");
|
+ "Remove and regenerate it.");
|
||||||
|
|
|
@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
|
||||||
|
|
||||||
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.settings.SettingsValuesForSuggestion;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -51,13 +52,12 @@ public final class ReadOnlyBinaryDictionary extends Dictionary {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final int sessionId, final float[] inOutLanguageWeight) {
|
||||||
if (mLock.readLock().tryLock()) {
|
if (mLock.readLock().tryLock()) {
|
||||||
try {
|
try {
|
||||||
return mBinaryDictionary.getSuggestions(composer, prevWordsInfo, proximityInfo,
|
return mBinaryDictionary.getSuggestions(composer, prevWordsInfo, proximityInfo,
|
||||||
blockOffensiveWords, additionalFeaturesOptions, sessionId,
|
settingsValuesForSuggestion, sessionId, inOutLanguageWeight);
|
||||||
inOutLanguageWeight);
|
|
||||||
} finally {
|
} finally {
|
||||||
mLock.readLock().unlock();
|
mLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.text.TextUtils;
|
||||||
|
|
||||||
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.define.ProductionFlag;
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
||||||
import com.android.inputmethod.latin.utils.StringUtils;
|
import com.android.inputmethod.latin.utils.StringUtils;
|
||||||
|
@ -73,17 +73,15 @@ public final class Suggest {
|
||||||
|
|
||||||
public void getSuggestedWords(final WordComposer wordComposer,
|
public void getSuggestedWords(final WordComposer wordComposer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final boolean isCorrectionEnabled,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int[] additionalFeaturesOptions, final int sessionId, final int sequenceNumber,
|
final boolean isCorrectionEnabled, final int sessionId, final int sequenceNumber,
|
||||||
final OnGetSuggestedWordsCallback callback) {
|
final OnGetSuggestedWordsCallback callback) {
|
||||||
if (wordComposer.isBatchMode()) {
|
if (wordComposer.isBatchMode()) {
|
||||||
getSuggestedWordsForBatchInput(wordComposer, prevWordsInfo, proximityInfo,
|
getSuggestedWordsForBatchInput(wordComposer, prevWordsInfo, proximityInfo,
|
||||||
blockOffensiveWords, additionalFeaturesOptions, sessionId, sequenceNumber,
|
settingsValuesForSuggestion, sessionId, sequenceNumber, callback);
|
||||||
callback);
|
|
||||||
} else {
|
} else {
|
||||||
getSuggestedWordsForTypingInput(wordComposer, prevWordsInfo, proximityInfo,
|
getSuggestedWordsForTypingInput(wordComposer, prevWordsInfo, proximityInfo,
|
||||||
blockOffensiveWords, isCorrectionEnabled, additionalFeaturesOptions,
|
settingsValuesForSuggestion, isCorrectionEnabled, sequenceNumber, callback);
|
||||||
sequenceNumber, callback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +123,8 @@ public final class Suggest {
|
||||||
// and calls the callback function with the suggestions.
|
// and calls the callback function with the suggestions.
|
||||||
private void getSuggestedWordsForTypingInput(final WordComposer wordComposer,
|
private void getSuggestedWordsForTypingInput(final WordComposer wordComposer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final boolean isCorrectionEnabled,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int[] additionalFeaturesOptions, final int sequenceNumber,
|
final boolean isCorrectionEnabled, final int sequenceNumber,
|
||||||
final OnGetSuggestedWordsCallback callback) {
|
final OnGetSuggestedWordsCallback callback) {
|
||||||
final String typedWord = wordComposer.getTypedWord();
|
final String typedWord = wordComposer.getTypedWord();
|
||||||
final int trailingSingleQuotesCount = StringUtils.getTrailingSingleQuotesCount(typedWord);
|
final int trailingSingleQuotesCount = StringUtils.getTrailingSingleQuotesCount(typedWord);
|
||||||
|
@ -135,8 +133,8 @@ public final class Suggest {
|
||||||
: typedWord;
|
: typedWord;
|
||||||
|
|
||||||
final SuggestionResults suggestionResults = mDictionaryFacilitator.getSuggestionResults(
|
final SuggestionResults suggestionResults = mDictionaryFacilitator.getSuggestionResults(
|
||||||
wordComposer, prevWordsInfo, proximityInfo, blockOffensiveWords,
|
wordComposer, prevWordsInfo, proximityInfo, settingsValuesForSuggestion,
|
||||||
additionalFeaturesOptions, SESSION_TYPING);
|
SESSION_TYPING);
|
||||||
final ArrayList<SuggestedWordInfo> suggestionsContainer =
|
final ArrayList<SuggestedWordInfo> suggestionsContainer =
|
||||||
getTransformedSuggestedWordInfoList(wordComposer, suggestionResults,
|
getTransformedSuggestedWordInfoList(wordComposer, suggestionResults,
|
||||||
trailingSingleQuotesCount);
|
trailingSingleQuotesCount);
|
||||||
|
@ -205,12 +203,11 @@ public final class Suggest {
|
||||||
// and calls the callback function with the suggestions.
|
// and calls the callback function with the suggestions.
|
||||||
private void getSuggestedWordsForBatchInput(final WordComposer wordComposer,
|
private void getSuggestedWordsForBatchInput(final WordComposer wordComposer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final int sequenceNumber,
|
final int sessionId, final int sequenceNumber,
|
||||||
final OnGetSuggestedWordsCallback callback) {
|
final OnGetSuggestedWordsCallback callback) {
|
||||||
final SuggestionResults suggestionResults = mDictionaryFacilitator.getSuggestionResults(
|
final SuggestionResults suggestionResults = mDictionaryFacilitator.getSuggestionResults(
|
||||||
wordComposer, prevWordsInfo, proximityInfo, blockOffensiveWords,
|
wordComposer, prevWordsInfo, proximityInfo, settingsValuesForSuggestion, sessionId);
|
||||||
additionalFeaturesOptions, sessionId);
|
|
||||||
final ArrayList<SuggestedWordInfo> suggestionsContainer =
|
final ArrayList<SuggestedWordInfo> suggestionsContainer =
|
||||||
new ArrayList<>(suggestionResults);
|
new ArrayList<>(suggestionResults);
|
||||||
final int suggestionsCount = suggestionsContainer.size();
|
final int suggestionsCount = suggestionsContainer.size();
|
||||||
|
|
|
@ -46,6 +46,7 @@ import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||||
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
|
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
|
||||||
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
||||||
|
@ -1998,9 +1999,11 @@ public final class InputLogic {
|
||||||
// a word, it's whatever is *before* the half-committed word in the buffer,
|
// a word, it's whatever is *before* the half-committed word in the buffer,
|
||||||
// hence 2; if we aren't, we should just skip whitespace if any, so 1.
|
// hence 2; if we aren't, we should just skip whitespace if any, so 1.
|
||||||
mWordComposer.isComposingWord() ? 2 : 1),
|
mWordComposer.isComposingWord() ? 2 : 1),
|
||||||
proximityInfo, settingsValues.mBlockPotentiallyOffensive,
|
proximityInfo,
|
||||||
|
new SettingsValuesForSuggestion(settingsValues.mBlockPotentiallyOffensive,
|
||||||
|
settingsValues.mPhraseGestureEnabled,
|
||||||
|
settingsValues.mAdditionalFeaturesSettingValues),
|
||||||
settingsValues.mAutoCorrectionEnabled,
|
settingsValues.mAutoCorrectionEnabled,
|
||||||
settingsValues.mAdditionalFeaturesSettingValues,
|
|
||||||
sessionId, sequenceNumber, callback);
|
sessionId, sequenceNumber, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ public class NativeSuggestOptions {
|
||||||
private static final int IS_GESTURE = 0;
|
private static final int IS_GESTURE = 0;
|
||||||
private static final int USE_FULL_EDIT_DISTANCE = 1;
|
private static final int USE_FULL_EDIT_DISTANCE = 1;
|
||||||
private static final int BLOCK_OFFENSIVE_WORDS = 2;
|
private static final int BLOCK_OFFENSIVE_WORDS = 2;
|
||||||
private static final int OPTIONS_SIZE = 3;
|
private static final int SPACE_AWARE_GESTURE_ENABLED = 3;
|
||||||
|
private static final int OPTIONS_SIZE = 4;
|
||||||
|
|
||||||
private final int[] mOptions = new int[OPTIONS_SIZE
|
private final int[] mOptions = new int[OPTIONS_SIZE
|
||||||
+ AdditionalFeaturesSettingUtils.ADDITIONAL_FEATURES_SETTINGS_SIZE];
|
+ AdditionalFeaturesSettingUtils.ADDITIONAL_FEATURES_SETTINGS_SIZE];
|
||||||
|
@ -38,6 +39,10 @@ public class NativeSuggestOptions {
|
||||||
setBooleanOption(BLOCK_OFFENSIVE_WORDS, value);
|
setBooleanOption(BLOCK_OFFENSIVE_WORDS, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSpaceAwareGestureEnabled(final boolean value) {
|
||||||
|
setBooleanOption(SPACE_AWARE_GESTURE_ENABLED, value);
|
||||||
|
}
|
||||||
|
|
||||||
public void setAdditionalFeaturesOptions(final int[] additionalOptions) {
|
public void setAdditionalFeaturesOptions(final int[] additionalOptions) {
|
||||||
if (additionalOptions == null) {
|
if (additionalOptions == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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.latin.settings;
|
||||||
|
|
||||||
|
public class SettingsValuesForSuggestion {
|
||||||
|
public final boolean mBlockPotentiallyOffensive;
|
||||||
|
public final boolean mSpaceAwareGestureEnabled;
|
||||||
|
public final int[] mAdditionalFeaturesSettingValues;
|
||||||
|
|
||||||
|
public SettingsValuesForSuggestion(final boolean blockPotentiallyOffensive,
|
||||||
|
final boolean spaceAwareGestureEnabled, final int[] additionalFeaturesSettingValues) {
|
||||||
|
mBlockPotentiallyOffensive = blockPotentiallyOffensive;
|
||||||
|
mSpaceAwareGestureEnabled = spaceAwareGestureEnabled;
|
||||||
|
mAdditionalFeaturesSettingValues = additionalFeaturesSettingValues;
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ import com.android.inputmethod.latin.Dictionary;
|
||||||
import com.android.inputmethod.latin.PrevWordsInfo;
|
import com.android.inputmethod.latin.PrevWordsInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService.SuggestionsGatherer;
|
import com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService.SuggestionsGatherer;
|
||||||
import com.android.inputmethod.latin.utils.CoordinateUtils;
|
import com.android.inputmethod.latin.utils.CoordinateUtils;
|
||||||
import com.android.inputmethod.latin.utils.LocaleUtils;
|
import com.android.inputmethod.latin.utils.LocaleUtils;
|
||||||
|
@ -308,8 +309,12 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
|
||||||
// TODO: make a spell checker option to block offensive words or not
|
// TODO: make a spell checker option to block offensive words or not
|
||||||
final ArrayList<SuggestedWordInfo> suggestions =
|
final ArrayList<SuggestedWordInfo> suggestions =
|
||||||
dictInfo.mDictionary.getSuggestions(composer, prevWordsInfo,
|
dictInfo.mDictionary.getSuggestions(composer, prevWordsInfo,
|
||||||
dictInfo.getProximityInfo(), true /* blockOffensiveWords */,
|
dictInfo.getProximityInfo(),
|
||||||
null /* additionalFeaturesOptions */, 0 /* sessionId */,
|
new SettingsValuesForSuggestion(
|
||||||
|
true /* blockPotentiallyOffensive */,
|
||||||
|
true /* spaceAwareGestureEnabled */,
|
||||||
|
null /* additionalFeaturesSettingValues */),
|
||||||
|
0 /* sessionId */,
|
||||||
null /* inOutLanguageWeight */);
|
null /* inOutLanguageWeight */);
|
||||||
if (suggestions != null) {
|
if (suggestions != null) {
|
||||||
for (final SuggestedWordInfo suggestion : suggestions) {
|
for (final SuggestedWordInfo suggestion : suggestions) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.Dictionary;
|
import com.android.inputmethod.latin.Dictionary;
|
||||||
import com.android.inputmethod.latin.PrevWordsInfo;
|
import com.android.inputmethod.latin.PrevWordsInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -53,7 +54,7 @@ public final class DictionaryPool extends LinkedBlockingQueue<DictAndKeyboard> {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final int sessionId, final float[] inOutLanguageWeight) {
|
||||||
return noSuggestions;
|
return noSuggestions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.ContactsBinaryDictionary;
|
import com.android.inputmethod.latin.ContactsBinaryDictionary;
|
||||||
import com.android.inputmethod.latin.PrevWordsInfo;
|
import com.android.inputmethod.latin.PrevWordsInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -38,11 +39,11 @@ public final class SynchronouslyLoadedContactsBinaryDictionary extends ContactsB
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final int sessionId, final float[] inOutLanguageWeight) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return super.getSuggestions(codes, prevWordsInfo, proximityInfo,
|
return super.getSuggestions(codes, prevWordsInfo, proximityInfo,
|
||||||
blockOffensiveWords, additionalFeaturesOptions, sessionId, inOutLanguageWeight);
|
settingsValuesForSuggestion, sessionId, inOutLanguageWeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.content.Context;
|
||||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||||
import com.android.inputmethod.latin.PrevWordsInfo;
|
import com.android.inputmethod.latin.PrevWordsInfo;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.UserBinaryDictionary;
|
import com.android.inputmethod.latin.UserBinaryDictionary;
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
|
|
||||||
|
@ -43,11 +44,11 @@ public final class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDic
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
||||||
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
final PrevWordsInfo prevWordsInfo, final ProximityInfo proximityInfo,
|
||||||
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
|
final SettingsValuesForSuggestion settingsValuesForSuggestion,
|
||||||
final int sessionId, final float[] inOutLanguageWeight) {
|
final int sessionId, final float[] inOutLanguageWeight) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return super.getSuggestions(codes, prevWordsInfo, proximityInfo,
|
return super.getSuggestions(codes, prevWordsInfo, proximityInfo,
|
||||||
blockOffensiveWords, additionalFeaturesOptions, sessionId, inOutLanguageWeight);
|
settingsValuesForSuggestion, sessionId, inOutLanguageWeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@ class SuggestOptions{
|
||||||
return getBoolOption(BLOCK_OFFENSIVE_WORDS);
|
return getBoolOption(BLOCK_OFFENSIVE_WORDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AK_FORCE_INLINE bool enableSpaceAwareGesture() const {
|
||||||
|
return getBoolOption(SPACE_AWARE_GESTURE_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
AK_FORCE_INLINE bool getAdditionalFeaturesBoolOption(const int key) const {
|
AK_FORCE_INLINE bool getAdditionalFeaturesBoolOption(const int key) const {
|
||||||
return getBoolOption(key + ADDITIONAL_FEATURES_OPTIONS);
|
return getBoolOption(key + ADDITIONAL_FEATURES_OPTIONS);
|
||||||
}
|
}
|
||||||
|
@ -50,9 +54,10 @@ class SuggestOptions{
|
||||||
static const int IS_GESTURE = 0;
|
static const int IS_GESTURE = 0;
|
||||||
static const int USE_FULL_EDIT_DISTANCE = 1;
|
static const int USE_FULL_EDIT_DISTANCE = 1;
|
||||||
static const int BLOCK_OFFENSIVE_WORDS = 2;
|
static const int BLOCK_OFFENSIVE_WORDS = 2;
|
||||||
|
static const int SPACE_AWARE_GESTURE_ENABLED = 3;
|
||||||
// Additional features options are stored after the other options and used as setting values of
|
// Additional features options are stored after the other options and used as setting values of
|
||||||
// experimental features.
|
// experimental features.
|
||||||
static const int ADDITIONAL_FEATURES_OPTIONS = 3;
|
static const int ADDITIONAL_FEATURES_OPTIONS = 4;
|
||||||
|
|
||||||
const int *const mOptions;
|
const int *const mOptions;
|
||||||
const int mLength;
|
const int mLength;
|
||||||
|
|
|
@ -50,6 +50,7 @@ LATINIME_SRC_FILES_FOR_DICTTOOL := \
|
||||||
latin/SuggestedWords.java \
|
latin/SuggestedWords.java \
|
||||||
latin/WordComposer.java \
|
latin/WordComposer.java \
|
||||||
latin/settings/NativeSuggestOptions.java \
|
latin/settings/NativeSuggestOptions.java \
|
||||||
|
latin/settings/SettingsValuesForSuggestion.java \
|
||||||
latin/utils/BinaryDictionaryUtils.java \
|
latin/utils/BinaryDictionaryUtils.java \
|
||||||
latin/utils/CombinedFormatUtils.java \
|
latin/utils/CombinedFormatUtils.java \
|
||||||
latin/utils/CoordinateUtils.java \
|
latin/utils/CoordinateUtils.java \
|
||||||
|
|
Loading…
Reference in New Issue