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

Commit 078c52c5 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Clean up from earlier changes to place title bar at top of WebView

Rename addTitleBar to setEmbeddedTitleBar.  This requires a change
to packages/apps/Browser.  Also remove mTitleBar if there already
was one.

In ViewManager, call contentToViewDimension where appropriate.

Change-Id: If4d378fad192990253411924a9a80bee96e63ff2
parent 3c72fff0
Loading
Loading
Loading
Loading
+13 −5
Original line number Original line Diff line number Diff line
@@ -50,7 +50,7 @@ class ViewManager {
            }
            }
            setBounds(x, y, width, height);
            setBounds(x, y, width, height);
            final AbsoluteLayout.LayoutParams lp =
            final AbsoluteLayout.LayoutParams lp =
                    new AbsoluteLayout.LayoutParams(ctvX(width), ctvX(height),
                    new AbsoluteLayout.LayoutParams(ctvD(width), ctvD(height),
                            ctvX(x), ctvY(y));
                            ctvX(x), ctvY(y));
            mWebView.mPrivateHandler.post(new Runnable() {
            mWebView.mPrivateHandler.post(new Runnable() {
                public void run() {
                public void run() {
@@ -97,10 +97,18 @@ class ViewManager {
        return new ChildView();
        return new ChildView();
    }
    }


    /**
     * Shorthand for calling mWebView.contentToViewDimension.  Used when
     * obtaining a view dimension from a content dimension, whether it be in x
     * or y.
     */
    private int ctvD(int val) {
        return mWebView.contentToViewDimension(val);
    }

    /**
    /**
     * Shorthand for calling mWebView.contentToViewX.  Used when obtaining a
     * Shorthand for calling mWebView.contentToViewX.  Used when obtaining a
     * view x coordinate from a content x coordinate, or when getting a
     * view x coordinate from a content x coordinate.
     * view dimension from a content dimension, whether it be in x or y.
     */
     */
    private int ctvX(int val) {
    private int ctvX(int val) {
        return mWebView.contentToViewX(val);
        return mWebView.contentToViewX(val);
@@ -119,8 +127,8 @@ class ViewManager {
            View view = v.mView;
            View view = v.mView;
            AbsoluteLayout.LayoutParams lp =
            AbsoluteLayout.LayoutParams lp =
                    (AbsoluteLayout.LayoutParams) view.getLayoutParams();
                    (AbsoluteLayout.LayoutParams) view.getLayoutParams();
            lp.width = ctvX(v.width);
            lp.width = ctvD(v.width);
            lp.height = ctvX(v.height);
            lp.height = ctvD(v.height);
            lp.x = ctvX(v.x);
            lp.x = ctvX(v.x);
            lp.y = ctvY(v.y);
            lp.y = ctvY(v.y);
            view.setLayoutParams(lp);
            view.setLayoutParams(lp);
+6 −4
Original line number Original line Diff line number Diff line
@@ -1776,13 +1776,15 @@ public class WebView extends AbsoluteLayout
     * the WebView normally without translating to account for the title bar.
     * the WebView normally without translating to account for the title bar.
     * @hide
     * @hide
     */
     */
    public void addTitleBar(View v) {
    public void setEmbeddedTitleBar(View v) {
        if (null == v) {
        if (mTitleBar == v) return;
        if (mTitleBar != null) {
            removeView(mTitleBar);
            removeView(mTitleBar);
        } else {
        }
        if (null != v) {
            addView(v, new AbsoluteLayout.LayoutParams(
            addView(v, new AbsoluteLayout.LayoutParams(
                    ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT, mScrollX, 0));
                    ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0));
        }
        }
        mTitleBar = v;
        mTitleBar = v;
    }
    }