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

Commit c4ca53fe authored by Michael Kolb's avatar Michael Kolb
Browse files

Add title bar gravity

    Enable rendering of the embedded title bar
    at the top of the page or
    at the top of the screen

Change-Id: Ic979b641c8cc80acb83eeab49c4f700fc5c50e72
parent ed6d936e
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -2322,6 +2322,11 @@ public class WebView extends AbsoluteLayout
     */
    private View mTitleBar;

    /**
     * the title bar rendering gravity
     */
    private int mTitleGravity;

    /**
     * Add or remove a title bar to be embedded into the WebView, and scroll
     * along with it vertically, while remaining in view horizontally. Pass
@@ -2342,6 +2347,16 @@ public class WebView extends AbsoluteLayout
        mTitleBar = v;
    }

    /**
     * Set where to render the embedded title bar
     * NO_GRAVITY at the top of the page
     * TOP        at the top of the screen
     * @hide
     */
    public void setTitleBarGravity(int gravity) {
        mTitleGravity = gravity;
    }

    /**
     * Given a distance in view space, convert it to content space. Note: this
     * does not reflect translation, just scaling, so this should not be called
@@ -3683,7 +3698,12 @@ public class WebView extends AbsoluteLayout
            // When drawing the title bar, move it horizontally to always show
            // at the top of the WebView.
            mTitleBar.offsetLeftAndRight(mScrollX - mTitleBar.getLeft());
            int newTop = Math.min(0, mScrollY);
            int newTop = 0;
            if (mTitleGravity == Gravity.NO_GRAVITY) {
                newTop = Math.min(0, mScrollY);
            } else if (mTitleGravity == Gravity.TOP) {
                newTop = mScrollY;
            }
            mTitleBar.setBottom(newTop + getTitleHeight());
            mTitleBar.setTop(newTop);
        }