Add MoreKeysPanel argument to Controller methods

Bug: 9334755
Change-Id: I5a7104f4c98982f11fb4e060fa83c21bfc360558
This commit is contained in:
Tadashi G. Takaoka 2013-07-25 18:07:46 +09:00
parent 09e4530ca7
commit 0e08d70fe5
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();
} }
}; };