diff options
Diffstat (limited to 'core/java/android/inputmethodservice')
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 35 | ||||
| -rwxr-xr-x | core/java/android/inputmethodservice/KeyboardView.java | 22 |
2 files changed, 40 insertions, 17 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 1a7547d..3a9b26a 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -498,7 +498,15 @@ public class InputMethodService extends AbstractInputMethodService { if (showingCandidates) { setCandidatesViewShown(true); } - showWindow(showingInput); + if (showingInput) { + // If we are showing the full soft keyboard, then go through + // this path to take care of current decisions about fullscreen + // etc. + onShowRequested(InputMethod.SHOW_EXPLICIT); + } else { + // Otherwise just put it back for its candidates. + showWindow(false); + } } } @@ -649,16 +657,14 @@ public class InputMethodService extends AbstractInputMethodService { /** * Override this to control when the input method should run in * fullscreen mode. The default implementation runs in fullsceen only - * when the screen is in landscape mode and the input view is being - * shown ({@link #onEvaluateInputViewShown} returns true). If you change what + * when the screen is in landscape mode. If you change what * this returns, you will need to call {@link #updateFullscreenMode()} * yourself whenever the returned value may have changed to have it * re-evaluated and applied. */ public boolean onEvaluateFullscreenMode() { Configuration config = getResources().getConfiguration(); - return config.orientation == Configuration.ORIENTATION_LANDSCAPE - && onEvaluateInputViewShown(); + return config.orientation == Configuration.ORIENTATION_LANDSCAPE; } /** @@ -870,7 +876,11 @@ public class InputMethodService extends AbstractInputMethodService { } /** - * Called when an input session is starting or restarting. + * Called when the input view is being shown and input has started on + * a new editor. This will always be called after {@link #onStartInput}, + * allowing you to do your general setup there and just view-specific + * setup here. You are guaranteed that {@link #onCreateInputView()} will + * have been called some time before this function is called. * * @param info Description of the type of text being edited. * @param restarting Set to true if we are restarting input on the @@ -892,6 +902,9 @@ public class InputMethodService extends AbstractInputMethodService { * as per {@link InputMethod#showSoftInput(int) InputMethod.showSoftInput(int)}. */ public void onShowRequested(int flags) { + if (!onEvaluateInputViewShown()) { + return; + } if ((flags&InputMethod.SHOW_EXPLICIT) == 0 && onEvaluateFullscreenMode()) { // Don't show if this is not explicit requested by the user and // the input method is fullscreen. That would be too disruptive. @@ -911,9 +924,11 @@ public class InputMethodService extends AbstractInputMethodService { boolean wasVisible = mWindowVisible; mWindowVisible = true; if (!mShowInputRequested) { - if (showInput) { - doShowInput = true; - mShowInputRequested = true; + if (mInputStarted) { + if (showInput) { + doShowInput = true; + mShowInputRequested = true; + } } } else { showInput = true; @@ -1001,7 +1016,7 @@ public class InputMethodService extends AbstractInputMethodService { mInputEditorInfo = attribute; onStartInput(attribute, restarting); if (mWindowVisible) { - if (mWindowCreated) { + if (mShowInputRequested) { onStartInputView(mInputEditorInfo, restarting); } startExtractingText(); diff --git a/core/java/android/inputmethodservice/KeyboardView.java b/core/java/android/inputmethodservice/KeyboardView.java index 6f044b6..2f3b54b 100755 --- a/core/java/android/inputmethodservice/KeyboardView.java +++ b/core/java/android/inputmethodservice/KeyboardView.java @@ -153,9 +153,10 @@ public class KeyboardView extends View implements View.OnClickListener { /** Listener for {@link OnKeyboardActionListener}. */ private OnKeyboardActionListener mKeyboardActionListener; - private static final int MSG_REMOVE_PREVIEW = 1; - private static final int MSG_REPEAT = 2; - private static final int MSG_LONGPRESS = 3; + private static final int MSG_SHOW_PREVIEW = 1; + private static final int MSG_REMOVE_PREVIEW = 2; + private static final int MSG_REPEAT = 3; + private static final int MSG_LONGPRESS = 4; private int mVerticalCorrection; private int mProximityThreshold; @@ -198,7 +199,8 @@ public class KeyboardView extends View implements View.OnClickListener { private static final int REPEAT_INTERVAL = 50; // ~20 keys per second private static final int REPEAT_START_DELAY = 400; - private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout(); + private static final int LONGPRESS_TIMEOUT = 800; + // Deemed to be too short : ViewConfiguration.getLongPressTimeout(); private static int MAX_NEARBY_KEYS = 12; private int[] mDistances = new int[MAX_NEARBY_KEYS]; @@ -215,6 +217,9 @@ public class KeyboardView extends View implements View.OnClickListener { @Override public void handleMessage(Message msg) { switch (msg.what) { + case MSG_SHOW_PREVIEW: + mPreviewText.setVisibility(VISIBLE); + break; case MSG_REMOVE_PREVIEW: mPreviewText.setVisibility(INVISIBLE); break; @@ -731,7 +736,7 @@ public class KeyboardView extends View implements View.OnClickListener { return adjustCase(key.label); } } - + private void showPreview(int keyIndex) { int oldKeyIndex = mCurrentKeyIndex; final PopupWindow previewPopup = mPreviewPopup; @@ -751,6 +756,7 @@ public class KeyboardView extends View implements View.OnClickListener { } // If key changed and preview is on ... if (oldKeyIndex != mCurrentKeyIndex && mShowPreview) { + mHandler.removeMessages(MSG_SHOW_PREVIEW); if (previewPopup.isShowing()) { if (keyIndex == NOT_A_KEY) { mHandler.sendMessageDelayed(mHandler @@ -803,7 +809,7 @@ public class KeyboardView extends View implements View.OnClickListener { mPreviewText.getBackground().setState( key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET); if (previewPopup.isShowing()) { - previewPopup.update(mPopupPreviewX + mOffsetInWindow[0], + previewPopup.update(mPopupParent, mPopupPreviewX + mOffsetInWindow[0], mPopupPreviewY + mOffsetInWindow[1], popupWidth, popupHeight); } else { @@ -811,7 +817,8 @@ public class KeyboardView extends View implements View.OnClickListener { mPopupPreviewX + mOffsetInWindow[0], mPopupPreviewY + mOffsetInWindow[1]); } - mPreviewText.setVisibility(VISIBLE); + mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SHOW_PREVIEW, keyIndex, 0), + ViewConfiguration.getTapTimeout()); } } } @@ -1014,6 +1021,7 @@ public class KeyboardView extends View implements View.OnClickListener { break; case MotionEvent.ACTION_UP: + mHandler.removeMessages(MSG_SHOW_PREVIEW); mHandler.removeMessages(MSG_REPEAT); mHandler.removeMessages(MSG_LONGPRESS); if (keyIndex == mCurrentKey) { |
