summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuahui Wu <hwu@google.com>2011-03-09 15:37:56 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-03-09 15:37:56 -0800
commit37c2e3e55641e91dd0ec3dbd296bc6bc7c7641cf (patch)
tree83c03d011f82d088263def50ddd7ac8f22dde371
parent6167a390e34981ea92fc6d5458add2da04ee15bc (diff)
parentff6f4c2eff8a676187296b968388f80e744a9ce8 (diff)
downloadframeworks_base-37c2e3e55641e91dd0ec3dbd296bc6bc7c7641cf.zip
frameworks_base-37c2e3e55641e91dd0ec3dbd296bc6bc7c7641cf.tar.gz
frameworks_base-37c2e3e55641e91dd0ec3dbd296bc6bc7c7641cf.tar.bz2
Merge "b/4075349 Make the pinch to zoom more responsive after limits." into honeycomb-mr1
-rw-r--r--core/java/android/webkit/ZoomManager.java43
1 files changed, 29 insertions, 14 deletions
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index 716a215..1742a51 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -360,6 +360,10 @@ class ZoomManager {
return scale;
}
+ public final boolean isScaleOverLimits(float scale) {
+ return scale <= mMinZoomScale || scale >= mMaxZoomScale;
+ }
+
public final boolean isZoomScaleFixed() {
return mMinZoomScale >= mMaxZoomScale;
}
@@ -749,12 +753,9 @@ class ZoomManager {
return true;
}
- public boolean onScale(ScaleGestureDetector detector) {
- // Prevent scaling beyond overview scale.
- float scale = Math.max(
- computeScaleWithLimits(detector.getScaleFactor() * mActualScale),
- getZoomOverviewScale());
-
+ // If the user moves the fingers but keeps the same distance between them,
+ // we should do panning only.
+ public boolean isPanningOnly(ScaleGestureDetector detector) {
float prevFocusX = mFocusX;
float prevFocusY = mFocusY;
mFocusX = detector.getFocusX();
@@ -768,14 +769,19 @@ class ZoomManager {
mFocusMovementSum -= mFocusMovementQueue.remove();
}
float deltaSpan = Math.abs(detector.getCurrentSpan() - detector.getPreviousSpan());
+ return mFocusMovementSum > deltaSpan;
+ }
- // If the user moves the fingers but keeps the same distance between them,
- // we should do panning only.
- if (mFocusMovementSum > deltaSpan) {
- mFocusMovementSum = 0;
- mFocusMovementQueue.clear();
- return true;
- }
+ public boolean handleScale(ScaleGestureDetector detector) {
+ float scale = detector.getScaleFactor() * mActualScale;
+
+ // if scale is limited by any reason, don't zoom but do ask
+ // the detector to update the event.
+ boolean isScaleLimited =
+ isScaleOverLimits(scale) || scale < getZoomOverviewScale();
+
+ // Prevent scaling beyond overview scale.
+ scale = Math.max(computeScaleWithLimits(scale), getZoomOverviewScale());
if (mPinchToZoomAnimating || willScaleTriggerZoom(scale)) {
mPinchToZoomAnimating = true;
@@ -788,13 +794,22 @@ class ZoomManager {
scale = computeScaleWithLimits(scale);
// if the scale change is too small, regard it as jitter and skip it.
if (Math.abs(scale - mActualScale) < MINIMUM_SCALE_WITHOUT_JITTER) {
- return false;
+ return isScaleLimited;
}
setZoomCenter(detector.getFocusX(), detector.getFocusY());
setZoomScale(scale, false);
mWebView.invalidate();
return true;
}
+ return isScaleLimited;
+ }
+
+ public boolean onScale(ScaleGestureDetector detector) {
+ if (isPanningOnly(detector) || handleScale(detector)) {
+ mFocusMovementSum = 0;
+ mFocusMovementQueue.clear();
+ return true;
+ }
return false;
}