diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2009-05-20 11:28:04 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2009-05-20 11:28:04 -0700 |
commit | 843ef36f7b96cc19ea7d2996b7c8661b41ec3452 (patch) | |
tree | 560e1648c99a93986f8b7deef851ef8bb8029db7 /core/java/android/inputmethodservice/KeyboardView.java | |
parent | 358d23017d0d6c4636eb7599ae7a9b48108899a3 (diff) | |
download | frameworks_base-843ef36f7b96cc19ea7d2996b7c8661b41ec3452.zip frameworks_base-843ef36f7b96cc19ea7d2996b7c8661b41ec3452.tar.gz frameworks_base-843ef36f7b96cc19ea7d2996b7c8661b41ec3452.tar.bz2 |
donut snapshot
Diffstat (limited to 'core/java/android/inputmethodservice/KeyboardView.java')
-rwxr-xr-x | core/java/android/inputmethodservice/KeyboardView.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/core/java/android/inputmethodservice/KeyboardView.java b/core/java/android/inputmethodservice/KeyboardView.java index 65c9893..8b474d5 100755 --- a/core/java/android/inputmethodservice/KeyboardView.java +++ b/core/java/android/inputmethodservice/KeyboardView.java @@ -407,7 +407,7 @@ public class KeyboardView extends View implements View.OnClickListener { // Release buffer, just in case the new keyboard has a different size. // It will be reallocated on the next draw. mBuffer = null; - invalidateAll(); + invalidateAllKeys(); computeProximityThreshold(keyboard); mMiniKeyboardCache.clear(); // Not really necessary to do every time, but will free up views } @@ -431,7 +431,7 @@ public class KeyboardView extends View implements View.OnClickListener { if (mKeyboard != null) { if (mKeyboard.setShifted(shifted)) { // The whole keyboard probably needs to be redrawn - invalidateAll(); + invalidateAllKeys(); return true; } } @@ -573,7 +573,7 @@ public class KeyboardView extends View implements View.OnClickListener { if (mBuffer == null) { mBuffer = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); mCanvas = new Canvas(mBuffer); - invalidateAll(); + invalidateAllKeys(); } final Canvas canvas = mCanvas; canvas.clipRect(mDirtyRect, Op.REPLACE); @@ -874,13 +874,27 @@ public class KeyboardView extends View implements View.OnClickListener { mPreviewText.setVisibility(VISIBLE); } - private void invalidateAll() { + /** + * Requests a redraw of the entire keyboard. Calling {@link #invalidate} is not sufficient + * because the keyboard renders the keys to an off-screen buffer and an invalidate() only + * draws the cached buffer. + * @see #invalidateKey(int) + */ + public void invalidateAllKeys() { mDirtyRect.union(0, 0, getWidth(), getHeight()); mDrawPending = true; invalidate(); } - - private void invalidateKey(int keyIndex) { + + /** + * Invalidates a key so that it will be redrawn on the next repaint. Use this method if only + * one key is changing it's content. Any changes that affect the position or size of the key + * may not be honored. + * @param keyIndex the index of the key in the attached {@link Keyboard}. + * @see #invalidateAllKeys + */ + public void invalidateKey(int keyIndex) { + if (mKeys == null) return; if (keyIndex < 0 || keyIndex >= mKeys.length) { return; } @@ -991,7 +1005,7 @@ public class KeyboardView extends View implements View.OnClickListener { mPopupKeyboard.showAtLocation(this, Gravity.NO_GRAVITY, x, y); mMiniKeyboardOnScreen = true; //mMiniKeyboard.onTouchEvent(getTranslatedEvent(me)); - invalidateAll(); + invalidateAllKeys(); return true; } return false; @@ -1164,7 +1178,7 @@ public class KeyboardView extends View implements View.OnClickListener { if (mPopupKeyboard.isShowing()) { mPopupKeyboard.dismiss(); mMiniKeyboardOnScreen = false; - invalidateAll(); + invalidateAllKeys(); } } |