@@ -353,11 +353,13 @@ private final class MagnifiedContentInteractonStateHandler
353353 private static final float MIN_SCALE = 1.3f ;
354354 private static final float MAX_SCALE = 5.0f ;
355355
356+ private static final float SCALING_THRESHOLD = 0.3f ;
357+
356358 private final ScaleGestureDetector mScaleGestureDetector ;
357359 private final GestureDetector mGestureDetector ;
358360
359- private float mScaleFocusX = -1 ;
360- private float mScaleFocusY = - 1 ;
361+ private float mInitialScaleFactor = -1 ;
362+ private boolean mScaling ;
361363
362364 public MagnifiedContentInteractonStateHandler (Context context ) {
363365 mScaleGestureDetector = new ScaleGestureDetector (context , this );
@@ -405,21 +407,26 @@ public boolean onScroll(MotionEvent first, MotionEvent second, float distanceX,
405407
406408 @ Override
407409 public boolean onScale (ScaleGestureDetector detector ) {
408- if (mCurrentState != STATE_MAGNIFIED_INTERACTION ) {
409- return true ;
410+ if (!mScaling ) {
411+ if (mInitialScaleFactor < 0 ) {
412+ mInitialScaleFactor = detector .getScaleFactor ();
413+ } else {
414+ final float deltaScale = detector .getScaleFactor () - mInitialScaleFactor ;
415+ if (Math .abs (deltaScale ) > SCALING_THRESHOLD ) {
416+ mScaling = true ;
417+ return true ;
418+ }
419+ }
420+ return false ;
410421 }
411422 final float newScale = mMagnificationController .getScale ()
412423 * detector .getScaleFactor ();
413424 final float normalizedNewScale = Math .min (Math .max (newScale , MIN_SCALE ), MAX_SCALE );
414425 if (DEBUG_SCALING ) {
415426 Slog .i (LOG_TAG , "normalizedNewScale: " + normalizedNewScale );
416427 }
417- if (mScaleFocusX < 0 && mScaleFocusY < 0 ) {
418- mScaleFocusX = detector .getFocusX ();
419- mScaleFocusY = detector .getFocusY ();
420- }
421- mMagnificationController .setScale (normalizedNewScale , mScaleFocusX ,
422- mScaleFocusY , false );
428+ mMagnificationController .setScale (normalizedNewScale , detector .getFocusX (),
429+ detector .getFocusY (), false );
423430 return true ;
424431 }
425432
@@ -434,8 +441,8 @@ public void onScaleEnd(ScaleGestureDetector detector) {
434441 }
435442
436443 private void clear () {
437- mScaleFocusX = -1 ;
438- mScaleFocusY = - 1 ;
444+ mInitialScaleFactor = -1 ;
445+ mScaling = false ;
439446 }
440447 }
441448
0 commit comments