From b7a5a6820038824568dc5251ae5080b34a4933b8 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 17 May 2012 14:46:10 +0900 Subject: [PATCH] Fix stale key drawing Bug: 6509479 Change-Id: I49988ac951f6b37b14192ef1113a0d668a84f1a2 --- .../com/android/inputmethod/keyboard/Keyboard.java | 14 ++++++++++++++ .../android/inputmethod/keyboard/KeyboardView.java | 3 +++ 2 files changed, 17 insertions(+) diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index bd3b0e114..0be4cf3a7 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -197,6 +197,20 @@ public class Keyboard { return null; } + public boolean hasKey(Key aKey) { + if (mKeyCache.containsKey(aKey)) { + return true; + } + + for (final Key key : mKeys) { + if (key == aKey) { + mKeyCache.put(key.mCode, key); + return true; + } + } + return false; + } + public static boolean isLetterCode(int code) { return code >= MINIMUM_LETTER_CODE; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index c0d5b6772..cc0a1fb10 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -487,6 +487,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } else { // Draw invalidated keys. for (final Key key : mInvalidatedKeys) { + if (!mKeyboard.hasKey(key)) { + continue; + } final int x = key.mX + getPaddingLeft(); final int y = key.mY + getPaddingTop(); mInvalidatedKeysRect.set(x, y, x + key.mWidth, y + key.mHeight);