diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 346ba8523..44282a492 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -26,8 +26,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; -import android.content.DialogInterface.OnDismissListener; -import android.content.DialogInterface.OnShowListener; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; @@ -100,7 +98,8 @@ import java.util.concurrent.TimeUnit; */ public class LatinIME extends InputMethodService implements KeyboardActionListener, SuggestionStripView.Listener, SuggestionStripViewAccessor, - DictionaryFacilitatorForSuggest.DictionaryInitializationListener { + DictionaryFacilitatorForSuggest.DictionaryInitializationListener, + ImportantNoticeDialog.ImportantNoticeDialogListener { private static final String TAG = LatinIME.class.getSimpleName(); private static final boolean TRACE = false; private static boolean DEBUG = false; @@ -751,6 +750,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen + ", word caps = " + ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_WORDS) != 0)); } + Log.i(TAG, "Starting input. Cursor position = " + + editorInfo.initialSelStart + "," + editorInfo.initialSelEnd); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); ResearchLogger.latinIME_onStartInputViewInternal(editorInfo, prefs); @@ -799,19 +800,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen suggest = mInputLogic.mSuggest; } - // Sometimes, while rotating, for some reason the framework tells the app we are not - // connected to it and that means we can't refresh the cache. In this case, schedule a - // refresh later. // TODO[IL]: Can the following be moved to InputLogic#startInput? final boolean canReachInputConnection; if (!mInputLogic.mConnection.resetCachesUponCursorMoveAndReturnSuccess( editorInfo.initialSelStart, editorInfo.initialSelEnd, false /* shouldFinishComposition */)) { + // Sometimes, while rotating, for some reason the framework tells the app we are not + // connected to it and that means we can't refresh the cache. In this case, schedule a + // refresh later. // We try resetting the caches up to 5 times before giving up. mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */); // mLastSelection{Start,End} are reset later in this method, don't need to do it here canReachInputConnection = false; } else { + // When rotating, initialSelStart and initialSelEnd sometimes are lying. Make a best + // effort to work around this bug. + mInputLogic.mConnection.tryFixLyingCursorPosition(); if (isDifferentTextField) { mHandler.postResumeSuggestions(); } @@ -1177,39 +1181,23 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.mSuggest.mDictionaryFacilitator.addWordToUserDictionary(wordToEdit); } - // TODO: Move this method out of {@link LatinIME}. // Callback for the {@link SuggestionStripView}, to call when the important notice strip is // pressed. @Override public void showImportantNoticeContents() { - final Context context = this; - final AlertDialog.Builder builder = - new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_DARK); - builder.setMessage(ImportantNoticeUtils.getNextImportantNoticeContents(context)); - builder.setPositiveButton(android.R.string.ok, null /* listener */); - final OnClickListener onClickListener = new OnClickListener() { - @Override - public void onClick(final DialogInterface dialog, final int position) { - if (position == DialogInterface.BUTTON_NEGATIVE) { - launchSettings(); - } - } - }; - builder.setNegativeButton(R.string.go_to_settings, onClickListener); - final AlertDialog importantNoticeDialog = builder.create(); - importantNoticeDialog.setOnShowListener(new OnShowListener() { - @Override - public void onShow(final DialogInterface dialog) { - ImportantNoticeUtils.updateLastImportantNoticeVersion(context); - } - }); - importantNoticeDialog.setOnDismissListener(new OnDismissListener() { - @Override - public void onDismiss(final DialogInterface dialog) { - setNeutralSuggestionStrip(); - } - }); - showOptionDialog(importantNoticeDialog); + showOptionDialog(new ImportantNoticeDialog(this /* context */, this /* listener */)); + } + + // Implement {@link ImportantNoticeDialog.ImportantNoticeDialogListener} + @Override + public void onClickSettingsOfImportantNoticeDialog(final int nextVersion) { + launchSettings(); + } + + // Implement {@link ImportantNoticeDialog.ImportantNoticeDialogListener} + @Override + public void onDismissImportantNoticeDialog(final int nextVersion) { + setNeutralSuggestionStrip(); } public void displaySettingsDialog() { @@ -1717,9 +1705,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // DO NOT USE THIS for any other purpose than testing. This is information private to LatinIME. @UsedForTesting - /* package for test */ void waitForMainDictionary(final long timeout, final TimeUnit unit) + /* package for test */ void waitForLoadingDictionaries(final long timeout, final TimeUnit unit) throws InterruptedException { - mInputLogic.mSuggest.mDictionaryFacilitator.waitForLoadingMainDictionary(timeout, unit); + mInputLogic.mSuggest.mDictionaryFacilitator.waitForLoadingDictionariesForTesting( + timeout, unit); } // DO NOT USE THIS for any other purpose than testing. This can break the keyboard badly. @@ -1733,6 +1722,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen resetSuggest(new Suggest(locale, dictionaryFacilitator)); } + // DO NOT USE THIS for any other purpose than testing. + @UsedForTesting + /* package for test */ void clearPersonalizedDictionariesForTest() { + mInputLogic.mSuggest.mDictionaryFacilitator.clearUserHistoryDictionary(); + mInputLogic.mSuggest.mDictionaryFacilitator.clearPersonalizationDictionary(); + } + public void dumpDictionaryForDebug(final String dictName) { if (mInputLogic.mSuggest == null) { initSuggest(); |