am 19dcd154: Merge "Offer to add any OOV typed word to the dictionary."
* commit '19dcd154932b8aef07f371bdda7f879a70c3c3c8': Offer to add any OOV typed word to the dictionary.main
commit
75618c3321
|
@ -72,6 +72,7 @@ import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
import com.android.inputmethod.keyboard.MainKeyboardView;
|
import com.android.inputmethod.keyboard.MainKeyboardView;
|
||||||
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.Utils.Stats;
|
import com.android.inputmethod.latin.Utils.Stats;
|
||||||
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;
|
||||||
|
@ -2173,8 +2174,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
|
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
|
||||||
// interface
|
// interface
|
||||||
@Override
|
@Override
|
||||||
public void pickSuggestionManually(final int index, final String suggestion) {
|
public void pickSuggestionManually(final int index, final SuggestedWordInfo suggestionInfo) {
|
||||||
final SuggestedWords suggestedWords = mSuggestedWords;
|
final SuggestedWords suggestedWords = mSuggestedWords;
|
||||||
|
final String suggestion = suggestionInfo.mWord;
|
||||||
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
|
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
|
||||||
if (suggestion.length() == 1 && isShowingPunctuationList()) {
|
if (suggestion.length() == 1 && isShowingPunctuationList()) {
|
||||||
// Word separators are suggested before the user inputs something.
|
// Word separators are suggested before the user inputs something.
|
||||||
|
@ -2240,7 +2242,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// AND it's in none of our current dictionaries (main, user or otherwise).
|
// AND it's in none of our current dictionaries (main, user or otherwise).
|
||||||
// Please note that if mSuggest is null, it means that everything is off: suggestion
|
// Please note that if mSuggest is null, it means that everything is off: suggestion
|
||||||
// and correction, so we shouldn't try to show the hint
|
// and correction, so we shouldn't try to show the hint
|
||||||
final boolean showingAddToDictionaryHint = index == 0 && mSuggest != null
|
final boolean showingAddToDictionaryHint =
|
||||||
|
SuggestedWordInfo.KIND_TYPED == suggestionInfo.mKind && 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.getUnigramDictionaries(), suggestion, true);
|
&& !AutoCorrection.isValidWord(mSuggest.getUnigramDictionaries(), suggestion, true);
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.ResourceUtils;
|
import com.android.inputmethod.latin.ResourceUtils;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.Utils;
|
import com.android.inputmethod.latin.Utils;
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
@ -72,7 +73,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
OnLongClickListener {
|
OnLongClickListener {
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
public void addWordToUserDictionary(String word);
|
public void addWordToUserDictionary(String word);
|
||||||
public void pickSuggestionManually(int index, String word);
|
public void pickSuggestionManually(int index, SuggestedWordInfo word);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}.
|
// The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}.
|
||||||
|
@ -656,8 +657,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
@Override
|
@Override
|
||||||
public boolean onCustomRequest(final int requestCode) {
|
public boolean onCustomRequest(final int requestCode) {
|
||||||
final int index = requestCode;
|
final int index = requestCode;
|
||||||
final String word = mSuggestedWords.getWord(index);
|
final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index);
|
||||||
mListener.pickSuggestionManually(index, word);
|
mListener.pickSuggestionManually(index, wordInfo);
|
||||||
dismissMoreSuggestions();
|
dismissMoreSuggestions();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -807,8 +808,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
if (index >= mSuggestedWords.size())
|
if (index >= mSuggestedWords.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final String word = mSuggestedWords.getWord(index);
|
final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index);
|
||||||
mListener.pickSuggestionManually(index, word);
|
mListener.pickSuggestionManually(index, wordInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,6 +36,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -255,7 +256,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void pickSuggestionManually(final int index, final String suggestion) {
|
protected void pickSuggestionManually(final int index, final String suggestion) {
|
||||||
mLatinIME.pickSuggestionManually(index, suggestion);
|
mLatinIME.pickSuggestionManually(index, new SuggestedWordInfo(suggestion, 1,
|
||||||
|
SuggestedWordInfo.KIND_CORRECTION, "main"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to avoid writing the try{}catch block each time
|
// Helper to avoid writing the try{}catch block each time
|
||||||
|
|
Loading…
Reference in New Issue