am ac69ab40: Refactor more keys menu framework (part 3)

* commit 'ac69ab400d1ea4f90b4ca24486d62212decf1069':
  Refactor more keys menu framework (part 3)
main
Tom Ouyang 2012-12-13 23:32:31 -08:00 committed by Android Git Automerger
commit 7f0e083bef
6 changed files with 56 additions and 9 deletions

View File

@ -1013,7 +1013,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
public void closing() {
dismissAllKeyPreviews();
cancelAllMessages();
onCancelMoreKeysPanel();
mInvalidateAllKeys = true;
requestLayout();
}
@ -1031,11 +1031,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
return (mMoreKeysPanel != null);
}
public boolean dismissMoreKeysPanel() {
@Override
public void onCancelMoreKeysPanel() {
if (isShowingMoreKeysPanel()) {
return mMoreKeysPanel.dismissMoreKeysPanel();
mMoreKeysPanel.dismissMoreKeysPanel();
}
return false;
}
@Override

View File

@ -844,10 +844,16 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
@Override
public void closing() {
super.closing();
dismissMoreKeysPanel();
onCancelMoreKeysPanel();
mMoreKeysPanelCache.clear();
}
@Override
public void onCancelMoreKeysPanel() {
super.onCancelMoreKeysPanel();
PointerTracker.dismissAllMoreKeysPanels();
}
@Override
public boolean onDismissMoreKeysPanel() {
dimEntireKeyboard(false /* dimmed */);

View File

@ -120,7 +120,15 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
@Override
public void onMoveEvent(int x, int y, final int pointerId, long eventTime) {
if (mActivePointerId != pointerId) {
return;
}
final boolean hasOldKey = (mCurrentKey != null);
onMoveKeyInternal(x, y, pointerId);
if (hasOldKey && mCurrentKey == null) {
// If the pointer has moved too far away from any target then cancel the panel.
mController.onCancelMoreKeysPanel();
}
}
@Override

View File

@ -30,6 +30,11 @@ public interface MoreKeysPanel {
* Remove the current {@link MoreKeysPanel} from the target view.
*/
public boolean onDismissMoreKeysPanel();
/**
* Instructs the parent to cancel the panel (e.g., when entering a different input mode).
*/
public void onCancelMoreKeysPanel();
}
/**

View File

@ -412,6 +412,17 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
}
}
public static void dismissAllMoreKeysPanels() {
final int trackersSize = sTrackers.size();
for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i);
if (tracker.isShowingMoreKeysPanel()) {
tracker.mMoreKeysPanel.dismissMoreKeysPanel();
tracker.mMoreKeysPanel = null;
}
}
}
private PointerTracker(final int id, final KeyEventHandler handler) {
if (handler == null) {
throw new NullPointerException();
@ -715,6 +726,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
sLastRecognitionPointSize = 0;
sLastRecognitionTime = 0;
mListener.onStartBatchInput();
dismissAllMoreKeysPanels();
}
mTimerProxy.cancelLongPressTimer();
mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
@ -846,7 +858,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
}
// A gesture should start only from a non-modifier key.
mIsDetectingGesture = (mKeyboard != null) && mKeyboard.mId.isAlphabetKeyboard()
&& !isShowingMoreKeysPanel() && key != null && !key.isModifier();
&& key != null && !key.isModifier();
if (mIsDetectingGesture) {
if (getActivePointerTrackerCount() == 1) {
sGestureFirstDownTime = eventTime;
@ -907,6 +919,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
cancelBatchInput();
return;
}
// If the MoreKeysPanel is showing then do not attempt to enter gesture mode. However,
// the gestured touch points are still being recorded in case the panel is dismissed.
if (isShowingMoreKeysPanel()) {
return;
}
mayStartBatchInput(key);
if (sInGesture) {
mayUpdateBatchInput(eventTime, key);
@ -926,7 +943,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
final int translatedX = mMoreKeysPanel.translateX(x);
final int translatedY = mMoreKeysPanel.translateY(y);
mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
return;
}
if (sShouldHandleGesture && me != null) {
@ -941,6 +957,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
false /* isMajorEvent */, null);
}
}
if (isShowingMoreKeysPanel()) {
// Do not handle sliding keys (or show key pop-ups) when the MoreKeysPanel is visible.
return;
}
onMoveEventInternal(x, y, eventTime);
}
@ -1199,9 +1220,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
mTimerProxy.cancelKeyTimers();
setReleasedKeyGraphics(mCurrentKey);
resetSlidingKeyInput();
if (isShowingMoreKeysPanel()) {
mMoreKeysPanel.dismissMoreKeysPanel();
mMoreKeysPanel = null;
}
}
private void startRepeatKey(final Key key) {
if (key != null && key.isRepeatable() && !sInGesture) {

View File

@ -684,6 +684,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
public void onShowMoreKeysPanel(MoreKeysPanel panel) {
mKeyboardView.onShowMoreKeysPanel(panel);
}
@Override
public void onCancelMoreKeysPanel() {
dismissMoreSuggestions();
}
};
boolean dismissMoreSuggestions() {