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

Commit f58ffac2 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Hide the title bar when zoomed in.

parent a8dfe24d
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ class CallbackProxy extends Handler {
    private final WebBackForwardList mBackForwardList;
    // Used to call startActivity during url override.
    private final Context mContext;
    // Stores the URL being loaded and the viewing mode to switch into when
    // the URL finishes loading.
    private ChangeViewModeOnFinishedLoad mChange;

    // Message Ids
    private static final int PAGE_STARTED                        = 100;
@@ -176,6 +179,37 @@ class CallbackProxy extends Handler {
        return mBackForwardList;
    }

    /**
     * Tell the host application that the WebView has changed viewing modes.
     * @param toZoomedOut If true, the WebView has zoomed out so that the page
     *          fits the screen.  If false, it is zoomed to the setting
     *          specified by the user.
     */
    /* package */ void uiOnChangeViewingMode(boolean toZoomOverview) {
        if (mWebChromeClient != null) {
            mWebChromeClient.onChangeViewingMode(toZoomOverview);
        }
    }

    private static class ChangeViewModeOnFinishedLoad {
        boolean mToZoomOverView;
        String mOriginalUrl;
        ChangeViewModeOnFinishedLoad(boolean toZoomOverview,
                String originalUrl) {
            mToZoomOverView = toZoomOverview;
            mOriginalUrl = originalUrl;
        }
    }

    /**
     * Keep track of the url and the viewing mode to change into.  If/when that
     * url finishes loading, this will change the viewing mode.
     */
    /* package */ void uiChangeViewingModeOnFinishedLoad(
            boolean toZoomOverview, String originalUrl) {
        if (mWebChromeClient == null) return;
        mChange = new ChangeViewModeOnFinishedLoad(toZoomOverview, originalUrl);
    }
    /**
     * Called by the UI side.  Calling overrideUrlLoading from the WebCore
     * side will post a message to call this method.
@@ -237,6 +271,15 @@ class CallbackProxy extends Handler {
                if (mWebViewClient != null) {
                    mWebViewClient.onPageFinished(mWebView, (String) msg.obj);
                }
                if (mChange != null) {
                    if (mWebView.getOriginalUrl().equals(mChange.mOriginalUrl)) {
                        uiOnChangeViewingMode(mChange.mToZoomOverView);
                    } else {
                        // The user has gone to a different page, so there is
                        // no need to hang on to the old object.
                        mChange = null;
                    }
                }
                break;
                
            case RECEIVED_ICON:
+9 −0
Original line number Diff line number Diff line
@@ -22,6 +22,15 @@ import android.view.View;

public class WebChromeClient {

    /**
     * Tell the host application that the WebView has changed viewing modes.
     * @param toZoomedOut If true, the WebView has zoomed out so that the page
     *          fits the screen.  If false, it is zoomed to the setting
     *          specified by the user.
     * @hide
     */
    public void onChangeViewingMode(boolean toZoomedOut) {}

    /**
     * Tell the host application the current progress of loading a page.
     * @param view The WebView that initiated the callback.
+10 −0
Original line number Diff line number Diff line
@@ -521,6 +521,7 @@ public class WebView extends AbsoluteLayout
    // follow the links. Double tap will toggle between zoom overview mode and
    // the last zoom scale.
    boolean mInZoomOverview = false;

    // ideally mZoomOverviewWidth should be mContentWidth. But sites like espn,
    // engadget always have wider mContentWidth no matter what viewport size is.
    int mZoomOverviewWidth = WebViewCore.DEFAULT_VIEWPORT_WIDTH;
@@ -4687,6 +4688,7 @@ public class WebView extends AbsoluteLayout
        mZoomCenterX = mLastTouchX;
        mZoomCenterY = mLastTouchY;
        mInZoomOverview = !mInZoomOverview;
        mCallbackProxy.uiOnChangeViewingMode(mInZoomOverview);
        if (mInZoomOverview) {
            if (getSettings().getBuiltInZoomControls()) {
                if (mZoomButtonsController.isVisible()) {
@@ -5034,6 +5036,14 @@ public class WebView extends AbsoluteLayout
                            mInZoomOverview = ENABLE_DOUBLETAP_ZOOM
                                    && settings.getLoadWithOverviewMode();
                        }
                        mCallbackProxy.uiOnChangeViewingMode(true);
                        if (!mInZoomOverview) {
                            // We are going to start zoomed in.  However, we
                            // truly want to show the title bar, and then hide
                            // it once the page has loaded
                            mCallbackProxy.uiChangeViewingModeOnFinishedLoad(
                                    false, getOriginalUrl());
                        }
                        setNewZoomScale(mLastScale, false);
                        setContentScrollTo(restoreState.mScrollX,
                                restoreState.mScrollY);