diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
3 files changed, 31 insertions, 58 deletions
diff --git a/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java b/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java index be54b669b..567087c81 100644 --- a/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java +++ b/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java @@ -20,8 +20,6 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; -import android.content.DialogInterface.OnDismissListener; -import android.content.DialogInterface.OnShowListener; import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.ImportantNoticeUtils; @@ -29,11 +27,10 @@ import com.android.inputmethod.latin.utils.ImportantNoticeUtils; /** * The dialog box that shows the important notice contents. */ -public final class ImportantNoticeDialog extends AlertDialog implements OnShowListener, - OnClickListener, OnDismissListener { +public final class ImportantNoticeDialog extends AlertDialog implements OnClickListener { public interface ImportantNoticeDialogListener { + public void onUserAcknowledgmentOfImportantNoticeDialog(final int nextVersion); public void onClickSettingsOfImportantNoticeDialog(final int nextVersion); - public void onDismissImportantNoticeDialog(final int nextVersion); } private final ImportantNoticeDialogListener mListener; @@ -50,9 +47,9 @@ public final class ImportantNoticeDialog extends AlertDialog implements OnShowLi if (shouldHaveSettingsButton()) { setButton(BUTTON_NEGATIVE, context.getString(R.string.go_to_settings), this); } - // Set listeners. - setOnShowListener(this); - setOnDismissListener(this); + // This dialog is cancelable by pressing back key. See {@link #onBackPress()}. + setCancelable(true /* cancelable */); + setCanceledOnTouchOutside(false /* cancelable */); } private boolean shouldHaveSettingsButton() { @@ -60,9 +57,9 @@ public final class ImportantNoticeDialog extends AlertDialog implements OnShowLi == ImportantNoticeUtils.VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS; } - @Override - public void onShow(final DialogInterface dialog) { + private void userAcknowledged() { ImportantNoticeUtils.updateLastImportantNoticeVersion(getContext()); + mListener.onUserAcknowledgmentOfImportantNoticeDialog(mNextImportantNoticeVersion); } @Override @@ -70,10 +67,12 @@ public final class ImportantNoticeDialog extends AlertDialog implements OnShowLi if (shouldHaveSettingsButton() && which == BUTTON_NEGATIVE) { mListener.onClickSettingsOfImportantNoticeDialog(mNextImportantNoticeVersion); } + userAcknowledged(); } @Override - public void onDismiss(final DialogInterface dialog) { - mListener.onDismissImportantNoticeDialog(mNextImportantNoticeVersion); + public void onBackPressed() { + super.onBackPressed(); + userAcknowledged(); } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 0594c68cc..84558ca24 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -367,6 +367,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (latinIme != null) { executePendingImsCallback(latinIme, editorInfo, restarting); latinIme.onStartInputInternal(editorInfo, restarting); + if (ProductionFlag.USES_CURSOR_ANCHOR_MONITOR) { + // Currently we need to call this every time when the IME is attached to + // new application. + // TODO: Consider if we can do this automatically in the framework. + InputMethodServiceCompatUtils.setCursorAnchorMonitorMode(latinIme, 1); + } } } } @@ -651,9 +657,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR); mInputLogic.mConnection.finishComposingText(); mInputLogic.mConnection.endBatchEdit(); - if (isShowingOptionDialog()) { - mOptionsDialog.dismiss(); - } } PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this, conf, mInputLogic.mSuggest.mDictionaryFacilitator); @@ -931,6 +934,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mSubtypeState.currentSubtypeUsed(); } + @Override + public void onUpdateCursor(Rect rect) { + if (DEBUG) { + Log.i(TAG, "onUpdateCursor:" + rect.toShortString()); + } + super.onUpdateCursor(rect); + } + /** * This is called when the user has clicked on the extracted text view, * when running in fullscreen mode. The default implementation hides @@ -976,7 +987,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } if (TRACE) Debug.stopMethodTracing(); - if (mOptionsDialog != null && mOptionsDialog.isShowing()) { + if (isShowingOptionDialog()) { mOptionsDialog.dismiss(); mOptionsDialog = null; } @@ -1172,7 +1183,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Implement {@link ImportantNoticeDialog.ImportantNoticeDialogListener} @Override - public void onDismissImportantNoticeDialog(final int nextVersion) { + public void onUserAcknowledgmentOfImportantNoticeDialog(final int nextVersion) { setNeutralSuggestionStrip(); } @@ -1680,7 +1691,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final AlertDialog.Builder builder = new AlertDialog.Builder( DialogUtils.getPlatformDialogThemeContext(this)); builder.setItems(items, listener).setTitle(title); - showOptionDialog(builder.create()); + final AlertDialog dialog = builder.create(); + dialog.setCancelable(true /* cancelable */); + dialog.setCanceledOnTouchOutside(true /* cancelable */); + showOptionDialog(dialog); } // TODO: Move this method out of {@link LatinIME}. @@ -1690,9 +1704,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return; } - dialog.setCancelable(true /* cancelable */); - dialog.setCanceledOnTouchOutside(true /* cancelable */); - final Window window = dialog.getWindow(); final WindowManager.LayoutParams lp = window.getAttributes(); lp.token = windowToken; diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 1ba92adb1..353b7463d 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -23,7 +23,6 @@ import android.content.res.Resources; import android.preference.PreferenceManager; import android.util.Log; -import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.InputAttributes; import com.android.inputmethod.latin.R; @@ -270,42 +269,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang return prefs.getBoolean(PREF_SHOW_LANGUAGE_SWITCH_KEY, true); } - public static int readKeyboardThemeIndex(final SharedPreferences prefs, final Resources res) { - final int defaultThemeIndex = readDefaultKeyboardThemeIndex(res); - final String themeIndexString = prefs.getString(PREF_KEYBOARD_LAYOUT, null); - if (themeIndexString == null) { - return defaultThemeIndex; - } - try { - return Integer.parseInt(themeIndexString); - } catch (final NumberFormatException e) { - // Format error, returns default keyboard theme index. - Log.e(TAG, "Illegal keyboard theme in preference: " + themeIndexString + ", default to " - + defaultThemeIndex, e); - } - return defaultThemeIndex; - } - - private static int readDefaultKeyboardThemeIndex(final Resources res) { - final String defaultThemeIndexString = res.getString( - R.string.config_default_keyboard_theme_index); - try { - return Integer.parseInt(defaultThemeIndexString); - } catch (final NumberFormatException e) { - final int defaultThemeIndex = KeyboardSwitcher.DEFAULT_THEME_INDEX; - Log.e(TAG, "Corrupted default keyoard theme in resource: " + defaultThemeIndexString - + ", default to " + defaultThemeIndex, e); - return defaultThemeIndex; - } - } - - public static int resetAndGetDefaultKeyboardThemeIndex(final SharedPreferences prefs, - final Resources res) { - final int defaultThemeIndex = readDefaultKeyboardThemeIndex(res); - prefs.edit().putString(PREF_KEYBOARD_LAYOUT, Integer.toString(defaultThemeIndex)).apply(); - return defaultThemeIndex; - } - public static String readPrefAdditionalSubtypes(final SharedPreferences prefs, final Resources res) { final String predefinedPrefSubtypes = AdditionalSubtypeUtils.createPrefSubtypes( |