diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 76 |
1 files changed, 48 insertions, 28 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 847038fee..84415ecee 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -84,8 +84,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = "LatinIME"; private static final boolean PERF_DEBUG = false; - private static final boolean DEBUG = LatinImeLogger.sDBG; private static final boolean TRACE = false; + private static boolean DEBUG = LatinImeLogger.sDBG; private static final int DELAY_UPDATE_SUGGESTIONS = 180; private static final int DELAY_UPDATE_OLD_SUGGESTIONS = 300; @@ -97,10 +97,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Key events coming any faster than this are long-presses. private static final int QUICK_PRESS = 200; - // Contextual menu positions - private static final int POS_METHOD = 0; - private static final int POS_SETTINGS = 1; - private int mSuggestionVisibility; private static final int SUGGESTION_VISIBILILTY_SHOW_VALUE = R.string.prefs_suggestion_visibility_show_value; @@ -161,6 +157,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private int mConfigDelayBeforeFadeoutLanguageOnSpacebar; private int mConfigDurationOfFadeoutLanguageOnSpacebar; private float mConfigFinalFadeoutFactorOfLanguageOnSpacebar; + // For example, to deal with status bar on tablet. + private int mKeyboardBottomRowVerticalCorrection; private int mCorrectionMode; private int mCommittedLength; @@ -377,6 +375,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen R.integer.config_duration_of_fadeout_language_on_spacebar); mConfigFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger( R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f; + mKeyboardBottomRowVerticalCorrection = (int)res.getDimension( + R.dimen.keyboard_bottom_row_vertical_correction); Utils.GCUtils.getInstance().reset(); boolean tryGC = true; @@ -514,6 +514,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final KeyboardSwitcher switcher = mKeyboardSwitcher; LatinKeyboardView inputView = switcher.getInputView(); + if(DEBUG) { + Log.d(TAG, "onStartInputView: " + inputView); + } // In landscape mode, this method gets called without the input view being created. if (inputView == null) { return; @@ -566,6 +569,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mVoiceConnector.onStartInputView(inputView.getWindowToken()); + if (mKeyboardBottomRowVerticalCorrection > 0) { + final Window window = getWindow().getWindow(); + if (!(window.getCallback() instanceof ClipTouchEventWindowCallback)) { + window.setCallback(new ClipTouchEventWindowCallback( + window, mKeyboardBottomRowVerticalCorrection)); + } + } + if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } @@ -880,15 +891,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mCandidateViewContainer != null) { ViewParent candidateParent = mCandidateViewContainer.getParent(); if (candidateParent instanceof FrameLayout) { - FrameLayout fl = (FrameLayout) candidateParent; - if (fl != null) { - // Check frame layout's visibility - if (fl.getVisibility() == View.INVISIBLE) { - y = fl.getHeight(); - height += y; - } else if (fl.getVisibility() == View.VISIBLE) { - height += fl.getHeight(); - } + final FrameLayout fl = (FrameLayout) candidateParent; + // Check frame layout's visibility + if (fl.getVisibility() == View.INVISIBLE) { + y = fl.getHeight(); + height += y; + } else if (fl.getVisibility() == View.VISIBLE) { + height += fl.getHeight(); } } } @@ -2213,15 +2222,21 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } private void showSubtypeSelectorAndSettings() { - showOptionsMenuInternal(new DialogInterface.OnClickListener() { + final CharSequence title = getString(R.string.english_ime_input_options); + final CharSequence[] items = new CharSequence[] { + // TODO: Should use new string "Select active input modes". + getString(R.string.language_selection_title), + getString(R.string.english_ime_settings), + }; + final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int position) { di.dismiss(); switch (position) { - case POS_SETTINGS: + case 0: launchSettings(); break; - case POS_METHOD: + case 1: Intent intent = new Intent( android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK @@ -2233,36 +2248,41 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen break; } } - }); + }; + showOptionsMenuInternal(title, items, listener); } private void showOptionsMenu() { - showOptionsMenuInternal(new DialogInterface.OnClickListener() { + final CharSequence title = getString(R.string.english_ime_input_options); + final CharSequence[] items = new CharSequence[] { + getString(R.string.selectInputMethod), + getString(R.string.english_ime_settings), + }; + final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int position) { di.dismiss(); switch (position) { - case POS_SETTINGS: + case 0: launchSettings(); break; - case POS_METHOD: + case 1: mImm.showInputMethodPicker(); break; } } - }); + }; + showOptionsMenuInternal(title, items, listener); } - private void showOptionsMenuInternal(DialogInterface.OnClickListener listener) { + private void showOptionsMenuInternal(CharSequence title, CharSequence[] items, + DialogInterface.OnClickListener listener) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setIcon(R.drawable.ic_dialog_keyboard); builder.setNegativeButton(android.R.string.cancel, null); - CharSequence itemSettings = getString(R.string.english_ime_settings); - CharSequence itemInputMethod = getString(R.string.selectInputMethod); - builder.setItems(new CharSequence[] { - itemInputMethod, itemSettings}, listener); - builder.setTitle(mResources.getString(R.string.english_ime_input_options)); + builder.setItems(items, listener); + builder.setTitle(title); mOptionsDialog = builder.create(); mOptionsDialog.setCanceledOnTouchOutside(true); Window window = mOptionsDialog.getWindow(); |