From e3be3bcebc11892b536fdf650f74bba21af13383 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 29 Aug 2011 19:09:56 +0900 Subject: [PATCH] Add KeyboardActionListener.Adapter Change-Id: If13df42efffc7cef746c09d5abfe7a8619452a0b --- .../keyboard/KeyboardActionListener.java | 17 +++++++++++++++++ .../inputmethod/keyboard/PointerTracker.java | 16 ++-------------- .../keyboard/PopupMiniKeyboardView.java | 5 ++--- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java index 864091289..6f5420882 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java @@ -76,4 +76,21 @@ public interface KeyboardActionListener { * @return true if the request has been consumed, false otherwise. */ public boolean onCustomRequest(int requestCode); + + public static class Adapter implements KeyboardActionListener { + @Override + public void onPress(int primaryCode, boolean withSliding) {} + @Override + public void onRelease(int primaryCode, boolean withSliding) {} + @Override + public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {} + @Override + public void onTextInput(CharSequence text) {} + @Override + public void onCancelInput() {} + @Override + public boolean onCustomRequest(int requestCode) { + return false; + } + } } diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 83bab67ba..066b75665 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -139,20 +139,8 @@ public class PointerTracker { private boolean mIgnoreModifierKey; // Empty {@link KeyboardActionListener} - private static final KeyboardActionListener EMPTY_LISTENER = new KeyboardActionListener() { - @Override - public void onPress(int primaryCode, boolean withSliding) {} - @Override - public void onRelease(int primaryCode, boolean withSliding) {} - @Override - public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {} - @Override - public void onTextInput(CharSequence text) {} - @Override - public void onCancelInput() {} - @Override - public boolean onCustomRequest(int requestCode) { return false; } - }; + private static final KeyboardActionListener EMPTY_LISTENER = + new KeyboardActionListener.Adapter(); public static void init(boolean hasDistinctMultitouch, Context context) { if (hasDistinctMultitouch) { diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java index 8b8b27b39..c4428dc60 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java @@ -101,7 +101,8 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { public void cancelKeyTimers() {} }; - private final KeyboardActionListener mMiniKeyboardListener = new KeyboardActionListener() { + private final KeyboardActionListener mMiniKeyboardListener = + new KeyboardActionListener.Adapter() { @Override public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) { mListener.onCodeInput(primaryCode, keyCodes, x, y); @@ -125,8 +126,6 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { public void onRelease(int primaryCode, boolean withSliding) { mListener.onRelease(primaryCode, withSliding); } - @Override - public boolean onCustomRequest(int requestCode) { return false; } }; public PopupMiniKeyboardView(Context context, AttributeSet attrs) {