Notify the facilitator on IME start/finish.
Allows the facilitator to flush language models without a recurring task.
Bug 19773937.
Change-Id: I01a3c10da26f9df38fee05df33387eb082e2ff33
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
index 5f981a0..6b49f9a 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
@@ -89,6 +89,24 @@
void onUpdateMainDictionaryAvailability(boolean isMainDictionaryAvailable);
}
+ /**
+ * Called every time {@link LatinIME} starts on a new text field.
+ * Dot not affect {@link AndroidSpellCheckerService}.
+ *
+ * WARNING: The service methods that call start/finish are very spammy.
+ */
+ void onStartInput();
+
+ /**
+ * Called every time the {@link LatinIME} finishes with the current text field.
+ * May be followed by {@link #onStartInput} again in another text field,
+ * or it may be done for a while.
+ * Dot not affect {@link AndroidSpellCheckerService}.
+ *
+ * WARNING: The service methods that call start/finish are very spammy.
+ */
+ void onFinishInput();
+
boolean isActive();
Locale getLocale();
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorImpl.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorImpl.java
index a59253a..e5d770a 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorImpl.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorImpl.java
@@ -202,6 +202,15 @@
public DictionaryFacilitatorImpl() {
}
+ @Override
+ public void onStartInput() {
+ }
+
+ @Override
+ public void onFinishInput() {
+ }
+
+ @Override
public boolean isActive() {
return mDictionaryGroup.mLocale != null;
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 71dc30b..790cd69 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -792,6 +792,8 @@
@SuppressWarnings("deprecation")
void onStartInputViewInternal(final EditorInfo editorInfo, final boolean restarting) {
super.onStartInputView(editorInfo, restarting);
+
+ mDictionaryFacilitator.onStartInput();
// Switch to the null consumer to handle cases leading to early exit below, for which we
// also wouldn't be consuming gesture data.
mGestureConsumer = GestureConsumer.NULL_GESTURE_CONSUMER;
@@ -970,6 +972,7 @@
void onFinishInputInternal() {
super.onFinishInput();
+ mDictionaryFacilitator.onFinishInput();
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
if (mainKeyboardView != null) {
mainKeyboardView.closing();