diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:50 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:50 -0800 |
| commit | da996f390e17e16f2dfa60e972e7ebc4f868f37e (patch) | |
| tree | 00a0f15270d4c7b619fd34d8383257e1761082f4 /core/java/android/inputmethodservice | |
| parent | d24b8183b93e781080b2c16c487e60d51c12da31 (diff) | |
| download | frameworks_base-da996f390e17e16f2dfa60e972e7ebc4f868f37e.zip frameworks_base-da996f390e17e16f2dfa60e972e7ebc4f868f37e.tar.gz frameworks_base-da996f390e17e16f2dfa60e972e7ebc4f868f37e.tar.bz2 | |
auto import from //branches/cupcake/...@131421
Diffstat (limited to 'core/java/android/inputmethodservice')
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 85 | ||||
| -rwxr-xr-x | core/java/android/inputmethodservice/KeyboardView.java | 4 |
2 files changed, 54 insertions, 35 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index ea5f741..c884120 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -206,6 +206,8 @@ public class InputMethodService extends AbstractInputMethodService { static final String TAG = "InputMethodService"; static final boolean DEBUG = false; + InputMethodManager mImm; + LayoutInflater mInflater; View mRootView; SoftInputWindow mWindow; @@ -293,6 +295,8 @@ public class InputMethodService extends AbstractInputMethodService { mInputConnection = binding.getConnection(); if (DEBUG) Log.v(TAG, "bindInput(): binding=" + binding + " ic=" + mInputConnection); + InputConnection ic = getCurrentInputConnection(); + if (ic != null) ic.reportFullscreenMode(mIsFullscreen); initialize(); onBindInput(); } @@ -423,7 +427,7 @@ public class InputMethodService extends AbstractInputMethodService { * of the application behind. This value is relative to the top edge * of the input method window. */ - int contentTopInsets; + public int contentTopInsets; /** * This is the top part of the UI that is visibly covering the @@ -436,7 +440,7 @@ public class InputMethodService extends AbstractInputMethodService { * needed to make the focus visible. This value is relative to the top edge * of the input method window. */ - int visibleTopInsets; + public int visibleTopInsets; /** * Option for {@link #touchableInsets}: the entire window frame @@ -469,6 +473,7 @@ public class InputMethodService extends AbstractInputMethodService { @Override public void onCreate() { super.onCreate(); + mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); mInflater = (LayoutInflater)getSystemService( Context.LAYOUT_INFLATER_SERVICE); mWindow = new SoftInputWindow(this); @@ -554,7 +559,6 @@ public class InputMethodService extends AbstractInputMethodService { boolean visible = mWindowVisible; boolean showingInput = mShowInputRequested; boolean showingForced = mShowInputForced; - boolean showingCandidates = mCandidatesVisibility == View.VISIBLE; initViews(); mInputViewStarted = false; mCandidatesViewStarted = false; @@ -577,9 +581,6 @@ public class InputMethodService extends AbstractInputMethodService { // Otherwise just put it back for its candidates. showWindow(false); } - if (showingCandidates) { - setCandidatesViewShown(true); - } } } @@ -670,6 +671,8 @@ public class InputMethodService extends AbstractInputMethodService { if (mIsFullscreen != isFullscreen || !mFullscreenApplied) { changed = true; mIsFullscreen = isFullscreen; + InputConnection ic = getCurrentInputConnection(); + if (ic != null) ic.reportFullscreenMode(isFullscreen); mFullscreenApplied = true; initialize(); Drawable bg = onCreateBackgroundDrawable(); @@ -860,12 +863,14 @@ public class InputMethodService extends AbstractInputMethodService { return isFullscreenMode() ? View.GONE : View.INVISIBLE; } - public void setStatusIcon(int iconResId) { + public void showStatusIcon(int iconResId) { mStatusIcon = iconResId; - InputConnection ic = getCurrentInputConnection(); - if (ic != null && mWindowVisible) { - ic.showStatusIcon(getPackageName(), iconResId); - } + mImm.showStatusIcon(mToken, getPackageName(), iconResId); + } + + public void hideStatusIcon() { + mStatusIcon = 0; + mImm.hideStatusIcon(mToken); } /** @@ -876,8 +881,7 @@ public class InputMethodService extends AbstractInputMethodService { * @param id Unique identifier of the new input method ot start. */ public void switchInputMethod(String id) { - ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)) - .setInputMethod(mToken, id); + mImm.setInputMethod(mToken, id); } public void setExtractView(View view) { @@ -1149,15 +1153,9 @@ public class InputMethodService extends AbstractInputMethodService { if (!wasVisible) { if (DEBUG) Log.v(TAG, "showWindow: showing!"); + onWindowShown(); mWindow.show(); } - - if (!wasVisible || !wasCreated) { - InputConnection ic = getCurrentInputConnection(); - if (ic != null) { - ic.showStatusIcon(getPackageName(), mStatusIcon); - } - } } public void hideWindow() { @@ -1173,14 +1171,26 @@ public class InputMethodService extends AbstractInputMethodService { if (mWindowVisible) { mWindow.hide(); mWindowVisible = false; - InputConnection ic = getCurrentInputConnection(); - if (ic != null) { - ic.hideStatusIcon(); - } + onWindowHidden(); } } /** + * Called when the input method window has been shown to the user, after + * previously not being visible. This is done after all of the UI setup + * for the window has occurred (creating its views etc). + */ + public void onWindowShown() { + } + + /** + * Called when the input method window has been hidden from the user, + * after previously being visible. + */ + public void onWindowHidden() { + } + + /** * Called when a new client has bound to the input method. This * may be followed by a series of {@link #onStartInput(EditorInfo, boolean)} * and {@link #onFinishInput()} calls as the user navigates through its @@ -1341,8 +1351,7 @@ public class InputMethodService extends AbstractInputMethodService { * InputMethodManager.HIDE_IMPLICIT_ONLY} bit set. */ public void dismissSoftInput(int flags) { - ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)) - .hideSoftInputFromInputMethod(mToken, flags); + mImm.hideSoftInputFromInputMethod(mToken, flags); } /** @@ -1447,17 +1456,19 @@ public class InputMethodService extends AbstractInputMethodService { return true; } } else { - KeyEvent down = new KeyEvent(event, KeyEvent.ACTION_DOWN); - if (movement.onKeyDown(eet, - (Spannable)eet.getText(), keyCode, down)) { - KeyEvent up = new KeyEvent(event, KeyEvent.ACTION_UP); - movement.onKeyUp(eet, - (Spannable)eet.getText(), keyCode, up); - while (--count > 0) { - movement.onKeyDown(eet, - (Spannable)eet.getText(), keyCode, down); + if (!movement.onKeyOther(eet, (Spannable)eet.getText(), event)) { + KeyEvent down = new KeyEvent(event, KeyEvent.ACTION_DOWN); + if (movement.onKeyDown(eet, + (Spannable)eet.getText(), keyCode, down)) { + KeyEvent up = new KeyEvent(event, KeyEvent.ACTION_UP); movement.onKeyUp(eet, (Spannable)eet.getText(), keyCode, up); + while (--count > 0) { + movement.onKeyDown(eet, + (Spannable)eet.getText(), keyCode, down); + movement.onKeyUp(eet, + (Spannable)eet.getText(), keyCode, up); + } } } } @@ -1593,5 +1604,9 @@ public class InputMethodService extends AbstractInputMethodService { p.println(" mExtractedToken=" + mExtractedToken); p.println(" mIsInputViewShown=" + mIsInputViewShown + " mStatusIcon=" + mStatusIcon); + p.println("Last computed insets:"); + p.println(" contentTopInsets=" + mTmpInsets.contentTopInsets + + " visibleTopInsets=" + mTmpInsets.visibleTopInsets + + " touchableInsets=" + mTmpInsets.touchableInsets); } } diff --git a/core/java/android/inputmethodservice/KeyboardView.java b/core/java/android/inputmethodservice/KeyboardView.java index b2c74f2..b8bd10d 100755 --- a/core/java/android/inputmethodservice/KeyboardView.java +++ b/core/java/android/inputmethodservice/KeyboardView.java @@ -1084,6 +1084,10 @@ public class KeyboardView extends View implements View.OnClickListener { if (mPreviewPopup.isShowing()) { mPreviewPopup.dismiss(); } + mHandler.removeMessages(MSG_REPEAT); + mHandler.removeMessages(MSG_LONGPRESS); + mHandler.removeMessages(MSG_SHOW_PREVIEW); + dismissPopupKeyboard(); } |
