Merge "Remove boolean return value of dismissing more keys panel"

main
Tadashi G. Takaoka 2013-07-25 10:45:05 +00:00 committed by Android (Google) Code Review
commit 15c41a61ad
4 changed files with 25 additions and 20 deletions

View File

@ -1050,14 +1050,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
} }
@Override @Override
public boolean onDismissMoreKeysPanel() { public void onDismissMoreKeysPanel() {
dimEntireKeyboard(false /* dimmed */); dimEntireKeyboard(false /* dimmed */);
if (isShowingMoreKeysPanel()) { if (isShowingMoreKeysPanel()) {
mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView()); mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView());
mMoreKeysPanel = null; mMoreKeysPanel = null;
return true;
} }
return false;
} }
@Override @Override

View File

@ -34,7 +34,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
private final int[] mCoordinates = CoordinateUtils.newInstance(); private final int[] mCoordinates = CoordinateUtils.newInstance();
protected final KeyDetector mKeyDetector; protected final KeyDetector mKeyDetector;
private Controller mController; private Controller mController = EMPTY_CONTROLLER;
protected KeyboardActionListener mListener; protected KeyboardActionListener mListener;
private int mOriginX; private int mOriginX;
private int mOriginY; private int mOriginY;
@ -173,9 +173,11 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
} }
@Override @Override
public boolean dismissMoreKeysPanel() { public void dismissMoreKeysPanel() {
if (mController == null) return false; if (!isShowingInParent()) {
return mController.onDismissMoreKeysPanel(); return;
}
mController.onDismissMoreKeysPanel();
} }
@Override @Override

View File

@ -29,7 +29,7 @@ public interface MoreKeysPanel {
/** /**
* Remove the current {@link MoreKeysPanel} from the target view. * 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). * 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 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 * Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the
* controller's onShowMoreKeysPanel to add the panel's container view. * 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 * Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove
* the panel's container view. * the panel's container view.
*/ */
public boolean dismissMoreKeysPanel(); public void dismissMoreKeysPanel();
/** /**
* Process a move event on the more keys panel. * Process a move event on the more keys panel.

View File

@ -162,27 +162,27 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mSuggestionsStrip.removeAllViews(); mSuggestionsStrip.removeAllViews();
removeAllViews(); removeAllViews();
addView(mSuggestionsStrip); addView(mSuggestionsStrip);
dismissMoreSuggestions(); mMoreSuggestionsView.dismissMoreKeysPanel();
} }
private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() { private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() {
@Override @Override
public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) { public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) {
mListener.pickSuggestionManually(index, wordInfo); mListener.pickSuggestionManually(index, wordInfo);
dismissMoreSuggestions(); mMoreSuggestionsView.dismissMoreKeysPanel();
} }
@Override @Override
public void onCancelInput() { public void onCancelInput() {
dismissMoreSuggestions(); mMoreSuggestionsView.dismissMoreKeysPanel();
} }
}; };
private final MoreKeysPanel.Controller mMoreSuggestionsController = private final MoreKeysPanel.Controller mMoreSuggestionsController =
new MoreKeysPanel.Controller() { new MoreKeysPanel.Controller() {
@Override @Override
public boolean onDismissMoreKeysPanel() { public void onDismissMoreKeysPanel() {
return mMainKeyboardView.onDismissMoreKeysPanel(); mMainKeyboardView.onDismissMoreKeysPanel();
} }
@Override @Override
@ -192,14 +192,10 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
@Override @Override
public void onCancelMoreKeysPanel() { public void onCancelMoreKeysPanel() {
dismissMoreSuggestions(); mMoreSuggestionsView.dismissMoreKeysPanel();
} }
}; };
boolean dismissMoreSuggestions() {
return mMoreSuggestionsView.dismissMoreKeysPanel();
}
@Override @Override
public boolean onLongClick(final View view) { public boolean onLongClick(final View view) {
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback( AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(
@ -330,6 +326,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
dismissMoreSuggestions(); mMoreSuggestionsView.dismissMoreKeysPanel();
} }
} }