diff options
| author | 2023-10-05 01:21:36 +0000 | |
|---|---|---|
| committer | 2023-10-05 01:21:36 +0000 | |
| commit | 84a42c8fa4e09ccea16aefb9dfee1e587142a561 (patch) | |
| tree | f3744056ac6ec572656a77113137f9bea5f5e992 | |
| parent | 0e9104a6c95d6eb824cdd8bf15583276c988c864 (diff) | |
| parent | 6d939f9ec13384c7f90be883e0c8a78f5556599f (diff) | |
Merge "Fix pinch zoom with partial magnification window not very responsive" into main
3 files changed, 41 insertions, 5 deletions
diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index a0a172d366cc..5a28d5f7fc01 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -199,12 +199,33 @@ public class ScaleGestureDetector { * @throws NullPointerException if {@code listener} is null. */ public ScaleGestureDetector(@NonNull Context context, @NonNull OnScaleGestureListener listener, - @Nullable Handler handler) { + @Nullable Handler handler) { + this(context, ViewConfiguration.get(context).getScaledTouchSlop() * 2, + ViewConfiguration.get(context).getScaledMinimumScalingSpan(), handler, listener); + } + + /** + * Creates a ScaleGestureDetector with span slop and min span. + * + * @param context the application's context. + * @param spanSlop the threshold for interpreting a touch movement as scaling. + * @param minSpan the minimum threshold of scaling span. The span could be + * overridden by other usages to specify a different scaling span, for instance, + * if you need pinch gestures to continue closer together than the default. + * @param listener the listener invoked for all the callbacks, this must not be null. + * @param handler the handler to use for running deferred listener events. + * + * @throws NullPointerException if {@code listener} is null. + * + * @hide + */ + public ScaleGestureDetector(@NonNull Context context, @NonNull int spanSlop, + @NonNull int minSpan, @Nullable Handler handler, + @NonNull OnScaleGestureListener listener) { mContext = context; mListener = listener; - final ViewConfiguration viewConfiguration = ViewConfiguration.get(context); - mSpanSlop = viewConfiguration.getScaledTouchSlop() * 2; - mMinSpan = viewConfiguration.getScaledMinimumScalingSpan(); + mSpanSlop = spanSlop; + mMinSpan = minSpan; mHandler = handler; // Quick scale is enabled by default after JB_MR2 final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; diff --git a/services/accessibility/accessibility.aconfig b/services/accessibility/accessibility.aconfig index 11189cf9e39c..6fa9c0809f75 100644 --- a/services/accessibility/accessibility.aconfig +++ b/services/accessibility/accessibility.aconfig @@ -34,3 +34,10 @@ flag { description: "Calls WMS.addWindowToken without holding A11yManagerService#mLock" bug: "297972548" } + +flag { + name: "pinch_zoom_zero_min_span" + namespace: "accessibility" + description: "Whether to set min span of ScaleGestureDetector to zero." + bug: "295327792" +}
\ No newline at end of file diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/PanningScalingHandler.java b/services/accessibility/java/com/android/server/accessibility/magnification/PanningScalingHandler.java index c5495d98226e..94556282d0d3 100644 --- a/services/accessibility/java/com/android/server/accessibility/magnification/PanningScalingHandler.java +++ b/services/accessibility/java/com/android/server/accessibility/magnification/PanningScalingHandler.java @@ -28,8 +28,10 @@ import android.util.TypedValue; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.ScaleGestureDetector; +import android.view.ViewConfiguration; import com.android.internal.R; +import com.android.server.accessibility.Flags; /** * Handles the behavior while receiving scaling and panning gestures if it's enabled. @@ -70,7 +72,13 @@ class PanningScalingHandler extends mMaxScale = maxScale; mMinScale = minScale; mBlockScroll = blockScroll; - mScaleGestureDetector = new ScaleGestureDetector(context, this, Handler.getMain()); + if (Flags.pinchZoomZeroMinSpan()) { + mScaleGestureDetector = new ScaleGestureDetector(context, + ViewConfiguration.get(context).getScaledTouchSlop() * 2, + /* minSpan= */ 0, Handler.getMain(), this); + } else { + mScaleGestureDetector = new ScaleGestureDetector(context, this, Handler.getMain()); + } mScrollGestureDetector = new GestureDetector(context, this, Handler.getMain()); mScaleGestureDetector.setQuickScaleEnabled(false); mMagnificationDelegate = magnificationDelegate; |