Merge "Add MoreKeysPanel argument to Controller methods"

main
Tadashi G. Takaoka 2013-07-25 11:00:24 +00:00 committed by Android (Google) Code Review
commit 21c6d23dcd
4 changed files with 18 additions and 15 deletions

View File

@ -1032,8 +1032,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
@Override @Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) { public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
locatePreviewPlacerView(); locatePreviewPlacerView();
if (isShowingMoreKeysPanel()) { // TODO: Remove this check
onDismissMoreKeysPanel(); if (panel.isShowingInParent()) {
panel.dismissMoreKeysPanel();
} }
mPreviewPlacerView.addView(panel.getContainerView()); mPreviewPlacerView.addView(panel.getContainerView());
mMoreKeysPanel = panel; mMoreKeysPanel = panel;
@ -1045,12 +1046,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
} }
@Override @Override
public void onCancelMoreKeysPanel() { public void onCancelMoreKeysPanel(final MoreKeysPanel panel) {
PointerTracker.dismissAllMoreKeysPanels(); PointerTracker.dismissAllMoreKeysPanels();
} }
@Override @Override
public void onDismissMoreKeysPanel() { public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {
dimEntireKeyboard(false /* dimmed */); dimEntireKeyboard(false /* dimmed */);
if (isShowingMoreKeysPanel()) { if (isShowingMoreKeysPanel()) {
mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView()); mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView());
@ -1213,7 +1214,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
public void closing() { public void closing() {
dismissAllKeyPreviews(); dismissAllKeyPreviews();
cancelAllMessages(); cancelAllMessages();
onDismissMoreKeysPanel(); PointerTracker.dismissAllMoreKeysPanels();
mMoreKeysKeyboardCache.clear(); mMoreKeysKeyboardCache.clear();
} }

View File

@ -119,7 +119,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
onMoveKeyInternal(x, y, pointerId); onMoveKeyInternal(x, y, pointerId);
if (hasOldKey && mCurrentKey == null) { if (hasOldKey && mCurrentKey == null) {
// If the pointer has moved too far away from any target then cancel the panel. // If the pointer has moved too far away from any target then cancel the panel.
mController.onCancelMoreKeysPanel(); mController.onCancelMoreKeysPanel(this);
} }
} }
@ -177,7 +177,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
if (!isShowingInParent()) { if (!isShowingInParent()) {
return; return;
} }
mController.onDismissMoreKeysPanel(); mController.onDismissMoreKeysPanel(this);
} }
@Override @Override

View File

@ -22,28 +22,30 @@ public interface MoreKeysPanel {
public interface Controller { public interface Controller {
/** /**
* Add the {@link MoreKeysPanel} to the target view. * Add the {@link MoreKeysPanel} to the target view.
* @param panel * @param panel the panel to be shown.
*/ */
public void onShowMoreKeysPanel(final MoreKeysPanel panel); public void onShowMoreKeysPanel(final MoreKeysPanel panel);
/** /**
* Remove the current {@link MoreKeysPanel} from the target view. * Remove the current {@link MoreKeysPanel} from the target view.
* @param panel the panel to be dismissed.
*/ */
public void onDismissMoreKeysPanel(); public void onDismissMoreKeysPanel(final MoreKeysPanel panel);
/** /**
* 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).
* @param panel the panel to be canceled.
*/ */
public void onCancelMoreKeysPanel(); public void onCancelMoreKeysPanel(final MoreKeysPanel panel);
} }
public static final Controller EMPTY_CONTROLLER = new Controller() { public static final Controller EMPTY_CONTROLLER = new Controller() {
@Override @Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {} public void onShowMoreKeysPanel(final MoreKeysPanel panel) {}
@Override @Override
public void onDismissMoreKeysPanel() {} public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {}
@Override @Override
public void onCancelMoreKeysPanel() {} public void onCancelMoreKeysPanel(final MoreKeysPanel panel) {}
}; };
/** /**

View File

@ -181,8 +181,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
private final MoreKeysPanel.Controller mMoreSuggestionsController = private final MoreKeysPanel.Controller mMoreSuggestionsController =
new MoreKeysPanel.Controller() { new MoreKeysPanel.Controller() {
@Override @Override
public void onDismissMoreKeysPanel() { public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {
mMainKeyboardView.onDismissMoreKeysPanel(); mMainKeyboardView.onDismissMoreKeysPanel(panel);
} }
@Override @Override
@ -191,7 +191,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
} }
@Override @Override
public void onCancelMoreKeysPanel() { public void onCancelMoreKeysPanel(final MoreKeysPanel panel) {
mMoreSuggestionsView.dismissMoreKeysPanel(); mMoreSuggestionsView.dismissMoreKeysPanel();
} }
}; };