From f22571e2d9756294fa2fa332a395c06010f54d92 Mon Sep 17 00:00:00 2001 From: Dan Zivkovic Date: Fri, 1 May 2015 12:45:07 -0700 Subject: Delete history on upgrade in LatinIME. Bug 20733902. Change-Id: Ibe27e6cafe4db87ba62d7df708229e0d8564ffa8 --- .../inputmethod/latin/SystemBroadcastReceiver.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java') diff --git a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java index a093ec6db..26c5e0034 100644 --- a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java +++ b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java @@ -29,13 +29,14 @@ import android.util.Log; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; -import com.android.inputmethod.dictionarypack.CommonPreferences; import com.android.inputmethod.dictionarypack.DictionaryPackConstants; import com.android.inputmethod.keyboard.KeyboardLayoutSet; import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.setup.SetupActivity; import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils; +import java.util.Locale; + /** * This class detects the {@link Intent#ACTION_MY_PACKAGE_REPLACED} broadcast intent when this IME * package has been replaced by a newer version of the same package. This class also detects @@ -76,6 +77,22 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver { richImm.setAdditionalInputMethodSubtypes(additionalSubtypes); toggleAppIcon(context); downloadLatestDictionaries(context); + // TODO: This is only for dogfood builds. Remove this from the final release. + DictionaryFacilitator keyboardFacilitator = + DictionaryFacilitatorProvider.getDictionaryFacilitator(false); + boolean historyCleared = keyboardFacilitator.clearUserHistoryDictionary(context); + Locale keyboardLocale = keyboardFacilitator.getLocale(); + if (historyCleared && keyboardLocale != null) { + keyboardFacilitator.resetDictionaries( + context, + keyboardLocale, + keyboardFacilitator.usesContacts(), + true /* history */, + true /* force */, + keyboardFacilitator.getAccount(), + "" /* prefix */, + null /* listener */); + } } else if (Intent.ACTION_BOOT_COMPLETED.equals(intentAction)) { Log.i(TAG, "Boot has been completed"); toggleAppIcon(context); -- cgit v1.2.3-83-g751a