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

Commit 1f5dddc8 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

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

parents 92db56f7 e92ea347
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class ActionBarView extends ViewGroup {
    private View mCustomNavView;
    
    private boolean mShowMenu;
    private boolean mUserTitle;

    private MenuBuilder mOptionsMenu;
    private ActionMenuView mMenuView;
@@ -212,7 +213,30 @@ public class ActionBarView extends ViewGroup {
        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) {
        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;
        if (mTitleView != null) {
            mTitleView.setText(title);
+2 −2
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        if (mTitleView != null) {
            mTitleView.setText(title);
        } else if (mActionBar != null) {
            mActionBar.setTitle(title);
            mActionBar.setWindowTitle(title);
        }
        mTitle = title;
    }
@@ -2334,7 +2334,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            } else {
                mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
                if (mActionBar != null && mActionBar.getTitle() == null) {
                    mActionBar.setTitle(mTitle);
                    mActionBar.setWindowTitle(mTitle);
                }
            }
        }