Skip to content

Commit

Permalink
show url suggestions and stop suggesting if composed word is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
codokie committed Apr 10, 2024
1 parent 77cdf48 commit 19e4962
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMo

// TODO: Have a helper method in InputTypeUtils
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
mShouldShowSuggestions = !mIsPasswordField && !flagNoSuggestions;
mShouldShowSuggestions = !mIsPasswordField && !flagNoSuggestions || InputTypeUtils.isUriOrEmailType(inputType);
mMayOverrideShowingSuggestions = !mIsPasswordField;

mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ private TextUtils() {
// right for this.
public static final int MAX_CHARACTERS_FOR_RECAPITALIZATION = 1024 * 100;

// How many characters can a composed word have before it is assumed to be non-suggestible.
// The length of the lengthy word "internationalization" is 20.
public static final int MAX_CHARACTERS_FOR_SUGGESTIONS = 20;

// Key events coming any faster than this are long-presses.
public static final int LONG_PRESS_MILLISECONDS = 200;
// TODO: Set this value appropriately.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,8 @@ public void performUpdateSuggestionStripSync(final SettingsValues settingsValues
return;
}

if (!mWordComposer.isComposingWord() && !settingsValues.mBigramPredictionEnabled) {
if (!mWordComposer.isComposingWord() && !settingsValues.mBigramPredictionEnabled
|| mWordComposer.size() > Constants.MAX_CHARACTERS_FOR_SUGGESTIONS) {
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
return;
}
Expand Down Expand Up @@ -2336,6 +2337,11 @@ public boolean retryResetCachesAndReturnSuccess(final boolean tryResumeSuggestio
public void getSuggestedWords(final SettingsValues settingsValues,
final Keyboard keyboard, final int keyboardShiftMode, final int inputStyle,
final int sequenceNumber, final OnGetSuggestedWordsCallback callback) {
// don't get suggestions if composed word is very long
if (mWordComposer.size() > Constants.MAX_CHARACTERS_FOR_SUGGESTIONS) {
callback.onGetSuggestedWords(SuggestedWords.getEmptyInstance());
return;
}
mWordComposer.adviseCapitalizedModeBeforeFetchingSuggestions(
getActualCapsMode(settingsValues, keyboardShiftMode));
mSuggest.getSuggestedWords(mWordComposer,
Expand Down

0 comments on commit 19e4962

Please sign in to comment.