Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74521b17 authored by Shimeng (Simon) Wang's avatar Shimeng (Simon) Wang Committed by Android (Google) Code Review
Browse files

Merge "Change scale for large screen reading when double tapped."

parents 8e7b1f75 dde858cb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3557,11 +3557,11 @@ public class WebView extends AbsoluteLayout
        InputMethodManager imm = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

        // bring it back to the default scale so that user can enter text
        boolean zoom = mZoomManager.getScale() < mZoomManager.getDefaultScale();
        // bring it back to the reading level scale so that user can enter text
        boolean zoom = mZoomManager.getScale() < mZoomManager.getReadingLevelScale();
        if (zoom) {
            mZoomManager.setZoomCenter(mLastTouchX, mLastTouchY);
            mZoomManager.setZoomScale(mZoomManager.getDefaultScale(), false);
            mZoomManager.setZoomScale(mZoomManager.getReadingLevelScale(), false);
        }
        if (isTextView) {
            rebuildWebTextView();
+19 −7
Original line number Diff line number Diff line
@@ -55,6 +55,13 @@ class ZoomManager {
    private ZoomControlEmbedded mEmbeddedZoomControl;
    private ZoomControlExternal mExternalZoomControl;

    /*
     * For large screen devices, the defaultScale usually set to 1.0 and
     * equal to the overview scale, to differentiate the zoom level for double tapping,
     * a minimum reading level scale is used.
     */
    private static final float MIN_READING_LEVEL_SCALE = 1.5f;

    /*
     * The scale factors that determine the upper and lower bounds for the
     * default zoom scale.
@@ -245,6 +252,10 @@ class ZoomManager {
        return mDefaultScale;
    }

    public final float getReadingLevelScale() {
      return Math.max(mDefaultScale, MIN_READING_LEVEL_SCALE);
    }

    public final float getInvDefaultScale() {
        return mInvDefaultScale;
    }
@@ -337,9 +348,9 @@ class ZoomManager {
        mInitialScrollX = mWebView.getScrollX();
        mInitialScrollY = mWebView.getScrollY();

        // snap to DEFAULT_SCALE if it is close
        if (!exceedsMinScaleIncrement(scale, mDefaultScale)) {
            scale = mDefaultScale;
        // snap to reading level scale if it is close
        if (!exceedsMinScaleIncrement(scale, getReadingLevelScale())) {
            scale = getReadingLevelScale();
        }

        setZoomScale(scale, reflowText);
@@ -535,7 +546,7 @@ class ZoomManager {
        } else if (!mInZoomOverview) {
            zoomToOverview();
        } else {
            zoomToDefaultLevel();
            zoomToReadingLevel();
        }
    }

@@ -563,7 +574,8 @@ class ZoomManager {
        startZoomAnimation(getZoomOverviewScale(), true);
    }

    private void zoomToDefaultLevel() {
    private void zoomToReadingLevel() {
        final float readingScale = getReadingLevelScale();
        int left = mWebView.nativeGetBlockLeftEdge(mAnchorX, mAnchorY, mActualScale);
        if (left != WebView.NO_LEFTEDGE) {
            // add a 5pt padding to the left edge.
@@ -572,13 +584,13 @@ class ZoomManager {
            // Re-calculate the zoom center so that the new scroll x will be
            // on the left edge.
            if (viewLeft > 0) {
                mZoomCenterX = viewLeft * mDefaultScale / (mDefaultScale - mActualScale);
                mZoomCenterX = viewLeft * readingScale / (readingScale - mActualScale);
            } else {
                mWebView.scrollBy(viewLeft, 0);
                mZoomCenterX = 0;
            }
        }
        startZoomAnimation(mDefaultScale, true);
        startZoomAnimation(readingScale, true);
    }

    public void updateMultiTouchSupport(Context context) {