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

Commit 0a317e91 authored by Adam Powell's avatar Adam Powell
Browse files

Show the default activity icon in the action bar if one is not supplied

Fix a regression where the system default activity icon was not used
in the action bar if neither the activity nor application supplied
one.

Bug 9409846

Change-Id: I80a95a0bee511f21cd326372edaf6af811272825
parent 6fbb5553
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -139,8 +139,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    private ActionMenuPresenterCallback mActionMenuPresenterCallback;
    private PanelMenuPresenterCallback mPanelMenuPresenterCallback;

    // The icon resource has been explicitly set elsewhere
    // and should not be overwritten with a default.
    static final int FLAG_RESOURCE_SET_ICON = 1 << 0;

    // The logo resource has been explicitly set elsewhere
    // and should not be overwritten with a default.
    static final int FLAG_RESOURCE_SET_LOGO = 1 << 1;

    // The icon resource is currently configured to use the system fallback
    // as no default was previously specified. Anything can override this.
    static final int FLAG_RESOURCE_SET_ICON_FALLBACK = 1 << 2;

    int mResourcesSetFlags;
    int mIconRes;
    int mLogoRes;
@@ -1403,6 +1413,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    public void setIcon(int resId) {
        mIconRes = resId;
        mResourcesSetFlags |= FLAG_RESOURCE_SET_ICON;
        mResourcesSetFlags &= ~FLAG_RESOURCE_SET_ICON_FALLBACK;
        if (mActionBar != null) {
            mActionBar.setIcon(resId);
        }
@@ -1414,8 +1425,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            return;
        }
        mIconRes = resId;
        if (mActionBar != null && !mActionBar.hasIcon()) {
        if (mActionBar != null && (!mActionBar.hasIcon() ||
                (mResourcesSetFlags & FLAG_RESOURCE_SET_ICON_FALLBACK) != 0)) {
            if (resId != 0) {
                mActionBar.setIcon(resId);
                mResourcesSetFlags &= ~FLAG_RESOURCE_SET_ICON_FALLBACK;
            } else {
                mActionBar.setIcon(getContext().getPackageManager().getDefaultActivityIcon());
                mResourcesSetFlags |= FLAG_RESOURCE_SET_ICON_FALLBACK;
            }
        }
    }

@@ -2995,6 +3013,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                    if ((mResourcesSetFlags & FLAG_RESOURCE_SET_ICON) != 0 ||
                            (mIconRes != 0 && !mActionBar.hasIcon())) {
                        mActionBar.setIcon(mIconRes);
                    } else if ((mResourcesSetFlags & FLAG_RESOURCE_SET_ICON) == 0 &&
                            mIconRes == 0 && !mActionBar.hasIcon()) {
                        mActionBar.setIcon(
                                getContext().getPackageManager().getDefaultActivityIcon());
                        mResourcesSetFlags |= FLAG_RESOURCE_SET_ICON_FALLBACK;
                    }
                    if ((mResourcesSetFlags & FLAG_RESOURCE_SET_LOGO) != 0 ||
                            (mLogoRes != 0 && !mActionBar.hasLogo())) {