diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-09-11 18:15:17 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-09-11 18:15:17 -0700 |
commit | 3e1476a697ad94e638867361a6caba0ede77cb33 (patch) | |
tree | 0dc0e161a55fcbfe9c39f70a6db8845035ea2dd6 /services/java/com/android/server/accessibility/ScreenMagnifier.java | |
parent | d420e3ac94afea65173fd0ae43e13dfa6948bff9 (diff) | |
download | frameworks_base-3e1476a697ad94e638867361a6caba0ede77cb33.zip frameworks_base-3e1476a697ad94e638867361a6caba0ede77cb33.tar.gz frameworks_base-3e1476a697ad94e638867361a6caba0ede77cb33.tar.bz2 |
Adding a scaling threshold in ScreenMagnifier
Change-Id: I1fdd7c93de571a61d88d7386c5c2a423a6b83fb9
Diffstat (limited to 'services/java/com/android/server/accessibility/ScreenMagnifier.java')
-rw-r--r-- | services/java/com/android/server/accessibility/ScreenMagnifier.java | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/services/java/com/android/server/accessibility/ScreenMagnifier.java b/services/java/com/android/server/accessibility/ScreenMagnifier.java index ffd4adb..48781ac 100644 --- a/services/java/com/android/server/accessibility/ScreenMagnifier.java +++ b/services/java/com/android/server/accessibility/ScreenMagnifier.java @@ -353,11 +353,13 @@ public final class ScreenMagnifier implements EventStreamTransformation { private static final float MIN_SCALE = 1.3f; private static final float MAX_SCALE = 5.0f; + private static final float SCALING_THRESHOLD = 0.3f; + private final ScaleGestureDetector mScaleGestureDetector; private final GestureDetector mGestureDetector; - private float mScaleFocusX = -1; - private float mScaleFocusY = -1; + private float mInitialScaleFactor = -1; + private boolean mScaling; public MagnifiedContentInteractonStateHandler(Context context) { mScaleGestureDetector = new ScaleGestureDetector(context, this); @@ -405,8 +407,17 @@ public final class ScreenMagnifier implements EventStreamTransformation { @Override public boolean onScale(ScaleGestureDetector detector) { - if (mCurrentState != STATE_MAGNIFIED_INTERACTION) { - return true; + if (!mScaling) { + if (mInitialScaleFactor < 0) { + mInitialScaleFactor = detector.getScaleFactor(); + } else { + final float deltaScale = detector.getScaleFactor() - mInitialScaleFactor; + if (Math.abs(deltaScale) > SCALING_THRESHOLD) { + mScaling = true; + return true; + } + } + return false; } final float newScale = mMagnificationController.getScale() * detector.getScaleFactor(); @@ -414,12 +425,8 @@ public final class ScreenMagnifier implements EventStreamTransformation { if (DEBUG_SCALING) { Slog.i(LOG_TAG, "normalizedNewScale: " + normalizedNewScale); } - if (mScaleFocusX < 0 && mScaleFocusY < 0) { - mScaleFocusX = detector.getFocusX(); - mScaleFocusY = detector.getFocusY(); - } - mMagnificationController.setScale(normalizedNewScale, mScaleFocusX, - mScaleFocusY, false); + mMagnificationController.setScale(normalizedNewScale, detector.getFocusX(), + detector.getFocusY(), false); return true; } @@ -434,8 +441,8 @@ public final class ScreenMagnifier implements EventStreamTransformation { } private void clear() { - mScaleFocusX = -1; - mScaleFocusY = -1; + mInitialScaleFactor = -1; + mScaling = false; } } |