am f7d49397: Merge "[IL18] Move and rename updateSuggestionStrip"
* commit 'f7d493979a5693ba155a8bddab8b2e26a4192640': [IL18] Move and rename updateSuggestionStripmain
commit
ec471baa39
|
@ -158,6 +158,8 @@ public final class Constants {
|
||||||
|
|
||||||
// Key events coming any faster than this are long-presses.
|
// Key events coming any faster than this are long-presses.
|
||||||
public static final int LONG_PRESS_MILLISECONDS = 200;
|
public static final int LONG_PRESS_MILLISECONDS = 200;
|
||||||
|
// TODO: Set this value appropriately.
|
||||||
|
public static final int GET_SUGGESTED_WORDS_TIMEOUT = 200;
|
||||||
// How many continuous deletes at which to start deleting at a higher speed.
|
// How many continuous deletes at which to start deleting at a higher speed.
|
||||||
public static final int DELETE_ACCELERATE_AT = 20;
|
public static final int DELETE_ACCELERATE_AT = 20;
|
||||||
|
|
||||||
|
|
|
@ -49,14 +49,12 @@ import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.util.PrintWriterPrinter;
|
import android.util.PrintWriterPrinter;
|
||||||
import android.util.Printer;
|
import android.util.Printer;
|
||||||
import android.view.KeyCharacterMap;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.CompletionInfo;
|
import android.view.inputmethod.CompletionInfo;
|
||||||
import android.view.inputmethod.CorrectionInfo;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
|
@ -65,9 +63,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.compat.AppWorkaroundsUtils;
|
import com.android.inputmethod.compat.AppWorkaroundsUtils;
|
||||||
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
||||||
import com.android.inputmethod.compat.SuggestionSpanUtils;
|
|
||||||
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
||||||
import com.android.inputmethod.event.EventInterpreter;
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
|
@ -80,24 +76,19 @@ import com.android.inputmethod.latin.inputlogic.InputLogic;
|
||||||
import com.android.inputmethod.latin.inputlogic.SpaceState;
|
import com.android.inputmethod.latin.inputlogic.SpaceState;
|
||||||
import com.android.inputmethod.latin.personalization.DictionaryDecayBroadcastReciever;
|
import com.android.inputmethod.latin.personalization.DictionaryDecayBroadcastReciever;
|
||||||
import com.android.inputmethod.latin.personalization.PersonalizationDictionarySessionRegister;
|
import com.android.inputmethod.latin.personalization.PersonalizationDictionarySessionRegister;
|
||||||
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
|
|
||||||
import com.android.inputmethod.latin.settings.Settings;
|
import com.android.inputmethod.latin.settings.Settings;
|
||||||
import com.android.inputmethod.latin.settings.SettingsActivity;
|
import com.android.inputmethod.latin.settings.SettingsActivity;
|
||||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
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.AsyncResultHolder;
|
|
||||||
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
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;
|
||||||
import com.android.inputmethod.latin.utils.InputTypeUtils;
|
|
||||||
import com.android.inputmethod.latin.utils.IntentUtils;
|
import com.android.inputmethod.latin.utils.IntentUtils;
|
||||||
import com.android.inputmethod.latin.utils.JniUtils;
|
import com.android.inputmethod.latin.utils.JniUtils;
|
||||||
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
|
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
|
||||||
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
||||||
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
|
||||||
import com.android.inputmethod.latin.utils.StringUtils;
|
|
||||||
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||||
import com.android.inputmethod.latin.utils.TextRange;
|
import com.android.inputmethod.latin.utils.TextRange;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
@ -106,8 +97,6 @@ import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input method implementation for Qwerty'ish keyboard.
|
* Input method implementation for Qwerty'ish keyboard.
|
||||||
|
@ -126,9 +115,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
private static final int PERIOD_FOR_AUDIO_AND_HAPTIC_FEEDBACK_IN_KEY_REPEAT = 2;
|
private static final int PERIOD_FOR_AUDIO_AND_HAPTIC_FEEDBACK_IN_KEY_REPEAT = 2;
|
||||||
|
|
||||||
// TODO: Set this value appropriately.
|
|
||||||
private static final int GET_SUGGESTED_WORDS_TIMEOUT = 200;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the scheme used by the Package Manager to warn of a new package installation,
|
* The name of the scheme used by the Package Manager to warn of a new package installation,
|
||||||
* replacement or removal.
|
* replacement or removal.
|
||||||
|
@ -216,7 +202,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final KeyboardSwitcher switcher = latinIme.mKeyboardSwitcher;
|
final KeyboardSwitcher switcher = latinIme.mKeyboardSwitcher;
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_UPDATE_SUGGESTION_STRIP:
|
case MSG_UPDATE_SUGGESTION_STRIP:
|
||||||
latinIme.updateSuggestionStrip();
|
latinIme.mInputLogic.performUpdateSuggestionStripSync(
|
||||||
|
latinIme.mSettings.getCurrent(), this);
|
||||||
break;
|
break;
|
||||||
case MSG_UPDATE_SHIFT_STATE:
|
case MSG_UPDATE_SHIFT_STATE:
|
||||||
switcher.updateShiftState();
|
switcher.updateShiftState();
|
||||||
|
@ -1756,44 +1743,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO[IL]: Move this to InputLogic and make private again
|
|
||||||
public void updateSuggestionStrip() {
|
|
||||||
mHandler.cancelUpdateSuggestionStrip();
|
|
||||||
final SettingsValues currentSettings = mSettings.getCurrent();
|
|
||||||
|
|
||||||
// Check if we have a suggestion engine attached.
|
|
||||||
if (mInputLogic.mSuggest == null
|
|
||||||
|| !currentSettings.isSuggestionsRequested(mDisplayOrientation)) {
|
|
||||||
if (mInputLogic.mWordComposer.isComposingWord()) {
|
|
||||||
Log.w(TAG, "Called updateSuggestionsOrPredictions but suggestions were not "
|
|
||||||
+ "requested!");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mInputLogic.mWordComposer.isComposingWord()
|
|
||||||
&& !currentSettings.mBigramPredictionEnabled) {
|
|
||||||
setPunctuationSuggestions();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<SuggestedWords>();
|
|
||||||
getSuggestedWordsOrOlderSuggestionsAsync(Suggest.SESSION_TYPING,
|
|
||||||
SuggestedWords.NOT_A_SEQUENCE_NUMBER, new OnGetSuggestedWordsCallback() {
|
|
||||||
@Override
|
|
||||||
public void onGetSuggestedWords(final SuggestedWords suggestedWords) {
|
|
||||||
holder.set(suggestedWords);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// This line may cause the current thread to wait.
|
|
||||||
final SuggestedWords suggestedWords = holder.get(null, GET_SUGGESTED_WORDS_TIMEOUT);
|
|
||||||
if (suggestedWords != null) {
|
|
||||||
showSuggestionStrip(suggestedWords);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getSuggestedWords(final int sessionId, final int sequenceNumber,
|
private void getSuggestedWords(final int sessionId, final int sequenceNumber,
|
||||||
final OnGetSuggestedWordsCallback callback) {
|
final OnGetSuggestedWordsCallback callback) {
|
||||||
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||||
|
@ -1833,7 +1782,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
additionalFeaturesOptions, sessionId, sequenceNumber, callback);
|
additionalFeaturesOptions, sessionId, sequenceNumber, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getSuggestedWordsOrOlderSuggestionsAsync(final int sessionId,
|
// TODO[IL]: Move this to InputLogic?
|
||||||
|
public void getSuggestedWordsOrOlderSuggestionsAsync(final int sessionId,
|
||||||
final int sequenceNumber, final OnGetSuggestedWordsCallback callback) {
|
final int sequenceNumber, final OnGetSuggestedWordsCallback callback) {
|
||||||
mInputUpdater.getSuggestedWords(sessionId, sequenceNumber,
|
mInputUpdater.getSuggestedWords(sessionId, sequenceNumber,
|
||||||
new OnGetSuggestedWordsCallback() {
|
new OnGetSuggestedWordsCallback() {
|
||||||
|
@ -1913,7 +1863,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords, typedWord);
|
AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords, typedWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSuggestionStrip(final SuggestedWords suggestedWords) {
|
// TODO[IL]: Define a clean interface for this
|
||||||
|
public void showSuggestionStrip(final SuggestedWords suggestedWords) {
|
||||||
if (suggestedWords.isEmpty()) {
|
if (suggestedWords.isEmpty()) {
|
||||||
clearSuggestionStrip();
|
clearSuggestionStrip();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -36,12 +36,14 @@ import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.RichInputConnection;
|
import com.android.inputmethod.latin.RichInputConnection;
|
||||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
import com.android.inputmethod.latin.SubtypeSwitcher;
|
||||||
import com.android.inputmethod.latin.Suggest;
|
import com.android.inputmethod.latin.Suggest;
|
||||||
|
import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
|
import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
|
||||||
import com.android.inputmethod.latin.settings.Settings;
|
import com.android.inputmethod.latin.settings.Settings;
|
||||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
||||||
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.InputTypeUtils;
|
import com.android.inputmethod.latin.utils.InputTypeUtils;
|
||||||
|
@ -50,7 +52,6 @@ import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
||||||
import com.android.inputmethod.latin.utils.StringUtils;
|
import com.android.inputmethod.latin.utils.StringUtils;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -846,6 +847,43 @@ public final class InputLogic {
|
||||||
return prevWord;
|
return prevWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void performUpdateSuggestionStripSync(final SettingsValues settingsValues,
|
||||||
|
// TODO: Remove this variable
|
||||||
|
final LatinIME.UIHandler handler) {
|
||||||
|
handler.cancelUpdateSuggestionStrip();
|
||||||
|
|
||||||
|
// Check if we have a suggestion engine attached.
|
||||||
|
if (mSuggest == null
|
||||||
|
|| !settingsValues.isSuggestionsRequested(mLatinIME.mDisplayOrientation)) {
|
||||||
|
if (mWordComposer.isComposingWord()) {
|
||||||
|
Log.w(TAG, "Called updateSuggestionsOrPredictions but suggestions were not "
|
||||||
|
+ "requested!");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mWordComposer.isComposingWord() && !settingsValues.mBigramPredictionEnabled) {
|
||||||
|
mLatinIME.setPunctuationSuggestions();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<SuggestedWords>();
|
||||||
|
mLatinIME.getSuggestedWordsOrOlderSuggestionsAsync(Suggest.SESSION_TYPING,
|
||||||
|
SuggestedWords.NOT_A_SEQUENCE_NUMBER, new OnGetSuggestedWordsCallback() {
|
||||||
|
@Override
|
||||||
|
public void onGetSuggestedWords(final SuggestedWords suggestedWords) {
|
||||||
|
holder.set(suggestedWords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// This line may cause the current thread to wait.
|
||||||
|
final SuggestedWords suggestedWords = holder.get(null,
|
||||||
|
Constants.GET_SUGGESTED_WORDS_TIMEOUT);
|
||||||
|
if (suggestedWords != null) {
|
||||||
|
mLatinIME.showSuggestionStrip(suggestedWords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the cursor is actually at the end of a word. If so, restart suggestions on this
|
* Check if the cursor is actually at the end of a word. If so, restart suggestions on this
|
||||||
|
@ -1226,7 +1264,7 @@ public final class InputLogic {
|
||||||
final LatinIME.UIHandler handler) {
|
final LatinIME.UIHandler handler) {
|
||||||
// Complete any pending suggestions query first
|
// Complete any pending suggestions query first
|
||||||
if (handler.hasPendingUpdateSuggestions()) {
|
if (handler.hasPendingUpdateSuggestions()) {
|
||||||
mLatinIME.updateSuggestionStrip();
|
performUpdateSuggestionStripSync(settingsValues, handler);
|
||||||
}
|
}
|
||||||
final String typedAutoCorrection = mWordComposer.getAutoCorrectionOrNull();
|
final String typedAutoCorrection = mWordComposer.getAutoCorrectionOrNull();
|
||||||
final String typedWord = mWordComposer.getTypedWord();
|
final String typedWord = mWordComposer.getTypedWord();
|
||||||
|
|
Loading…
Reference in New Issue