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

Commit 28dcdd77 authored by Michael Kolb's avatar Michael Kolb Committed by Android (Google) Code Review
Browse files

Merge "Add title bar gravity"

parents 62bf34c6 c4ca53fe
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);
        }