From 09e4530ca75d4664eb72708face83b466839c522 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 25 Jul 2013 17:03:16 +0900 Subject: [PATCH] Remove boolean return value of dismissing more keys panel Bug: 9334755 Change-Id: Ic29ab69cfbf9007e98fe67695f1854b4876eb976 --- .../inputmethod/keyboard/MainKeyboardView.java | 4 +--- .../keyboard/MoreKeysKeyboardView.java | 10 ++++++---- .../inputmethod/keyboard/MoreKeysPanel.java | 13 +++++++++++-- .../latin/suggestions/SuggestionStripView.java | 18 +++++++----------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 212338021..2d40e819e 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -1050,14 +1050,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack } @Override - public boolean onDismissMoreKeysPanel() { + public void onDismissMoreKeysPanel() { dimEntireKeyboard(false /* dimmed */); if (isShowingMoreKeysPanel()) { mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView()); mMoreKeysPanel = null; - return true; } - return false; } @Override diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java index 897ad1d13..ad4b2d86f 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java @@ -34,7 +34,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel private final int[] mCoordinates = CoordinateUtils.newInstance(); protected final KeyDetector mKeyDetector; - private Controller mController; + private Controller mController = EMPTY_CONTROLLER; protected KeyboardActionListener mListener; private int mOriginX; private int mOriginY; @@ -173,9 +173,11 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel } @Override - public boolean dismissMoreKeysPanel() { - if (mController == null) return false; - return mController.onDismissMoreKeysPanel(); + public void dismissMoreKeysPanel() { + if (!isShowingInParent()) { + return; + } + mController.onDismissMoreKeysPanel(); } @Override diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java b/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java index 9c677e5c8..1d3e18fd4 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java @@ -29,7 +29,7 @@ public interface MoreKeysPanel { /** * Remove the current {@link MoreKeysPanel} from the target view. */ - public boolean onDismissMoreKeysPanel(); + public void onDismissMoreKeysPanel(); /** * Instructs the parent to cancel the panel (e.g., when entering a different input mode). @@ -37,6 +37,15 @@ public interface MoreKeysPanel { public void onCancelMoreKeysPanel(); } + public static final Controller EMPTY_CONTROLLER = new Controller() { + @Override + public void onShowMoreKeysPanel(final MoreKeysPanel panel) {} + @Override + public void onDismissMoreKeysPanel() {} + @Override + public void onCancelMoreKeysPanel() {} + }; + /** * Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the * controller's onShowMoreKeysPanel to add the panel's container view. @@ -57,7 +66,7 @@ public interface MoreKeysPanel { * Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove * the panel's container view. */ - public boolean dismissMoreKeysPanel(); + public void dismissMoreKeysPanel(); /** * Process a move event on the more keys panel. diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index fcebdd457..81fb1963f 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -162,27 +162,27 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mSuggestionsStrip.removeAllViews(); removeAllViews(); addView(mSuggestionsStrip); - dismissMoreSuggestions(); + mMoreSuggestionsView.dismissMoreKeysPanel(); } private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() { @Override public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) { mListener.pickSuggestionManually(index, wordInfo); - dismissMoreSuggestions(); + mMoreSuggestionsView.dismissMoreKeysPanel(); } @Override public void onCancelInput() { - dismissMoreSuggestions(); + mMoreSuggestionsView.dismissMoreKeysPanel(); } }; private final MoreKeysPanel.Controller mMoreSuggestionsController = new MoreKeysPanel.Controller() { @Override - public boolean onDismissMoreKeysPanel() { - return mMainKeyboardView.onDismissMoreKeysPanel(); + public void onDismissMoreKeysPanel() { + mMainKeyboardView.onDismissMoreKeysPanel(); } @Override @@ -192,14 +192,10 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick @Override public void onCancelMoreKeysPanel() { - dismissMoreSuggestions(); + mMoreSuggestionsView.dismissMoreKeysPanel(); } }; - boolean dismissMoreSuggestions() { - return mMoreSuggestionsView.dismissMoreKeysPanel(); - } - @Override public boolean onLongClick(final View view) { AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback( @@ -330,6 +326,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - dismissMoreSuggestions(); + mMoreSuggestionsView.dismissMoreKeysPanel(); } }