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

Commit e92ea347 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 2835056 - ActionBar doesn't update title properly when set in onCreate

Change-Id: I593315db8df0190c2702a87ebef293e5f798823d
parent 26dd7b3b
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,7 @@ public class ActionBarView extends ViewGroup {
    private View mCustomNavView;
    private View mCustomNavView;
    
    
    private boolean mShowMenu;
    private boolean mShowMenu;
    private boolean mUserTitle;


    private MenuBuilder mOptionsMenu;
    private MenuBuilder mOptionsMenu;
    private ActionMenuView mMenuView;
    private ActionMenuView mMenuView;
@@ -212,7 +213,30 @@ public class ActionBarView extends ViewGroup {
        return mTitle;
        return mTitle;
    }
    }


    /**
     * Set the action bar title. This will always replace or override window titles.
     * @param title Title to set
     *
     * @see #setWindowTitle(CharSequence)
     */
    public void setTitle(CharSequence title) {
    public void setTitle(CharSequence title) {
        mUserTitle = true;
        setTitleImpl(title);
    }

    /**
     * Set the window title. A window title will always be replaced or overridden by a user title.
     * @param title Title to set
     *
     * @see #setTitle(CharSequence)
     */
    public void setWindowTitle(CharSequence title) {
        if (!mUserTitle) {
            setTitleImpl(title);
        }
    }

    private void setTitleImpl(CharSequence title) {
        mTitle = title;
        mTitle = title;
        if (mTitleView != null) {
        if (mTitleView != null) {
            mTitleView.setText(title);
            mTitleView.setText(title);
+2 −2
Original line number Original line Diff line number Diff line
@@ -284,7 +284,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        if (mTitleView != null) {
        if (mTitleView != null) {
            mTitleView.setText(title);
            mTitleView.setText(title);
        } else if (mActionBar != null) {
        } else if (mActionBar != null) {
            mActionBar.setTitle(title);
            mActionBar.setWindowTitle(title);
        }
        }
        mTitle = title;
        mTitle = title;
    }
    }
@@ -2334,7 +2334,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            } else {
            } else {
                mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
                mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
                if (mActionBar != null && mActionBar.getTitle() == null) {
                if (mActionBar != null && mActionBar.getTitle() == null) {
                    mActionBar.setTitle(mTitle);
                    mActionBar.setWindowTitle(mTitle);
                }
                }
            }
            }
        }
        }