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

Commit a6708c6a authored by Mangesh Ghiware's avatar Mangesh Ghiware Committed by Android (Google) Code Review
Browse files

Merge "Add setting for configuring zoom level on double-tap." into ics-mr0

parents 0c265c88 edb528ef
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ public class WebSettings {
    private ZoomDensity     mDefaultZoom = ZoomDensity.MEDIUM;
    private RenderPriority  mRenderPriority = RenderPriority.NORMAL;
    private int             mOverrideCacheMode = LOAD_DEFAULT;
    private int             mDoubleTapZoom = 100;
    private boolean         mSaveFormData = true;
    private boolean         mAutoFillEnabled = false;
    private boolean         mSavePassword = true;
@@ -768,6 +769,27 @@ public class WebSettings {
        return closestSize != null ? closestSize : TextSize.NORMAL;
    }

    /**
     * Set the double-tap zoom of the page in percent. Default is 100.
     * @param doubleTapZoom A percent value for increasing or decreasing the double-tap zoom.
     * @hide
     */
    public void setDoubleTapZoom(int doubleTapZoom) {
        if (mDoubleTapZoom != doubleTapZoom) {
            mDoubleTapZoom = doubleTapZoom;
            mWebView.updateDoubleTapZoom();
        }
    }

    /**
     * Get the double-tap zoom of the page in percent.
     * @return A percent value describing the double-tap zoom.
     * @hide
     */
    public int getDoubleTapZoom() {
        return mDoubleTapZoom;
    }

    /**
     * Set the default zoom density of the page. This should be called from UI
     * thread.
+7 −0
Original line number Diff line number Diff line
@@ -2986,6 +2986,13 @@ public class WebView extends AbsoluteLayout
        return false;
    }

    /**
     * Update the double-tap zoom.
     */
    /* package */ void updateDoubleTapZoom() {
        mZoomManager.updateDoubleTapZoom();
    }

    private int computeRealHorizontalScrollRange() {
        if (mDrawHistory) {
            return mHistoryWidth;
+17 −7
Original line number Diff line number Diff line
@@ -145,11 +145,11 @@ class ZoomManager {
    private float mInvDefaultScale;

    /*
     * The scale factor that is used to determine the zoom level for reading text.
     * The value is initially set to equal the display density.
     * TODO: Support changing this in WebSettings
     * The logical density of the display. This is a scaling factor for the
     * Density Independent Pixel unit, where one DIP is one pixel on an
     * approximately 160 dpi screen (see android.util.DisplayMetrics.density)
     */
    private float mReadingLevelScale;
    private float mDisplayDensity;

    /*
     * The scale factor that is used as the minimum increment when going from
@@ -233,11 +233,11 @@ class ZoomManager {
    public void init(float density) {
        assert density > 0;

        mDisplayDensity = density;
        setDefaultZoomScale(density);
        mActualScale = density;
        mInvActualScale = 1 / density;
        mReadingLevelScale = density;
        mTextWrapScale = density;
        mTextWrapScale = getReadingLevelScale();
    }

    /**
@@ -310,8 +310,11 @@ class ZoomManager {
        return mInitialScale > 0 ? mInitialScale : mDefaultScale;
    }

    /**
     * Returns the zoom scale used for reading text on a double-tap.
     */
    public final float getReadingLevelScale() {
        return mReadingLevelScale;
        return mDisplayDensity * mWebView.getSettings().getDoubleTapZoom() / 100.0f;
    }

    public final float getInvDefaultScale() {
@@ -510,6 +513,13 @@ class ZoomManager {
        return mZoomScale != 0 || mInHWAcceleratedZoom;
    }

    public void updateDoubleTapZoom() {
        if (mInZoomOverview) {
            mTextWrapScale = getReadingLevelScale();
            refreshZoomScale(true);
        }
    }

    public void refreshZoomScale(boolean reflowText) {
        setZoomScale(mActualScale, reflowText, true);
    }