Skip to content

Commit 6625389

Browse files
committed
Scaling in viewport moving state locks into a magnified state.
1. If the user changes the magnification level while moving the viewport the magnification is locked. The gesture handle has to put device back into a viewport moving state if this was the last state. bug:7139363 Change-Id: I24992b973bb15624580114353b004efdb35c2faa
1 parent bdf8fa0 commit 6625389

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

services/java/com/android/server/accessibility/ScreenMagnifier.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ public final class ScreenMagnifier implements EventStreamTransformation {
114114
private static final boolean DEBUG_VIEWPORT_WINDOW = false;
115115
private static final boolean DEBUG_WINDOW_TRANSITIONS = false;
116116
private static final boolean DEBUG_ROTATION = false;
117-
private static final boolean DEBUG_SCALE_GESTURE_DETECTOR = false;
117+
private static final boolean DEBUG_GESTURE_DETECTOR = false;
118118
private static final boolean DEBUG_MAGNIFICATION_CONTROLLER = false;
119119

120120
private static final String LOG_TAG = ScreenMagnifier.class.getSimpleName();
121121

122122
private static final int STATE_DELEGATING = 1;
123123
private static final int STATE_DETECTING = 2;
124-
private static final int STATE_VIEWPORT_DRAGGING = 4;
125-
private static final int STATE_MAGNIFIED_INTERACTION = 6;
124+
private static final int STATE_VIEWPORT_DRAGGING = 3;
125+
private static final int STATE_MAGNIFIED_INTERACTION = 4;
126126

127127
private static final float DEFAULT_MAGNIFICATION_SCALE = 2.0f;
128128
private static final int DEFAULT_SCREEN_MAGNIFICATION_AUTO_UPDATE = 1;
@@ -158,6 +158,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
158158
private EventStreamTransformation mNext;
159159

160160
private int mCurrentState;
161+
private int mPreviousState;
161162
private boolean mTranslationEnabledBeforePan;
162163

163164
private PointerCoords[] mTempPointerCoords;
@@ -191,6 +192,7 @@ public ScreenMagnifier(Context context) {
191192

192193
@Override
193194
public void onMotionEvent(MotionEvent event, int policyFlags) {
195+
mGestureDetector.onMotionEvent(event);
194196
switch (mCurrentState) {
195197
case STATE_DELEGATING: {
196198
handleMotionEventStateDelegating(event, policyFlags);
@@ -210,7 +212,6 @@ public void onMotionEvent(MotionEvent event, int policyFlags) {
210212
throw new IllegalStateException("Unknown state: " + mCurrentState);
211213
}
212214
}
213-
mGestureDetector.onMotionEvent(event);
214215
}
215216

216217
@Override
@@ -330,6 +331,7 @@ private void transitionToState(int state) {
330331
}
331332
}
332333
}
334+
mPreviousState = mCurrentState;
333335
mCurrentState = state;
334336
}
335337

@@ -380,7 +382,11 @@ public void onMotionEvent(MotionEvent event) {
380382
if (scale != getPersistedScale()) {
381383
persistScale(scale);
382384
}
383-
transitionToState(STATE_DETECTING);
385+
if (mPreviousState == STATE_VIEWPORT_DRAGGING) {
386+
transitionToState(STATE_VIEWPORT_DRAGGING);
387+
} else {
388+
transitionToState(STATE_DETECTING);
389+
}
384390
}
385391
}
386392

@@ -395,7 +401,7 @@ public boolean onScale(ScaleGestureDetector detector) {
395401
case STATE_MAGNIFIED_INTERACTION: {
396402
mCurrScaleFactor = mScaleGestureDetector.getScaleFactor();
397403
final float scaleDelta = Math.abs(1.0f - mCurrScaleFactor * mPrevScaleFactor);
398-
if (DEBUG_SCALE_GESTURE_DETECTOR) {
404+
if (DEBUG_GESTURE_DETECTOR) {
399405
Slog.i(LOG_TAG, "scaleDelta: " + scaleDelta);
400406
}
401407
if (!mScaling && scaleDelta > DETECT_SCALING_THRESHOLD) {
@@ -411,7 +417,7 @@ public boolean onScale(ScaleGestureDetector detector) {
411417
mScaleGestureDetector.getFocusY(),
412418
mInitialFocus.x, mInitialFocus.y);
413419
final float panDelta = mCurrPan + mPrevPan;
414-
if (DEBUG_SCALE_GESTURE_DETECTOR) {
420+
if (DEBUG_GESTURE_DETECTOR) {
415421
Slog.i(LOG_TAG, "panDelta: " + panDelta);
416422
}
417423
if (!mPanning && panDelta > mScaledDetectPanningThreshold) {

0 commit comments

Comments
 (0)