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

Commit bbf2ddf4 authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

SysUI: Fix navbar theme changing with status bar

This addresses an issue where the navbar would change to use the same
theme as the status bar even when a different theme is applied to
the navbar.

Change-Id: I3f4cdc05975caf550fd2ce7251807f8f96828a76
parent 968fd190
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -792,7 +792,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        if (currentTheme != null) {
            mCurrentTheme = (ThemeConfig)currentTheme.clone();
        } else {
            mCurrentTheme = ThemeConfig.getSystemTheme();
            mCurrentTheme = ThemeConfig.getBootTheme(mContext.getContentResolver());
        }

        mStatusBarWindow = new StatusBarWindowView(mContext, null);
@@ -1441,7 +1441,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    }

    private Resources getNavbarThemedResources() {
        String pkgName = mCurrentTheme.getOverlayPkgNameForApp(ThemeConfig.SYSTEMUI_NAVBAR_PKG);
        String pkgName = mCurrentTheme.getOverlayForNavBar();
        Resources res = null;
        try {
            res = mContext.getPackageManager().getThemedResourcesForApplication(
@@ -3546,9 +3546,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

        makeStatusBarView();
        repositionNavigationBar();
        if (mNavigationBarView != null) {
            mNavigationBarView.updateResources(getNavbarThemedResources());
        }

        // recreate StatusBarIconViews.
        /*
@@ -3616,6 +3613,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        // detect theme change.
        ThemeConfig newTheme = newConfig != null ? newConfig.themeConfig : null;
        final boolean updateStatusBar = shouldUpdateStatusbar(mCurrentTheme, newTheme);
        final boolean updateNavBar = shouldUpdateNavbar(mCurrentTheme, newTheme);
        if (newTheme != null) mCurrentTheme = (ThemeConfig) newTheme.clone();
        if (updateStatusBar) {
            mContext.recreateTheme();
@@ -3638,7 +3636,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mBrightnessMirrorController.updateResources();
        }

        if (mNavigationBarView != null)  {
        if (mNavigationBarView != null && updateNavBar)  {
            mNavigationBarView.updateResources(getNavbarThemedResources());
        }
    }
@@ -3667,6 +3665,25 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                newTheme.getLastThemeChangeRequestType() == RequestType.THEME_UPDATED);
    }

    /**
     * Determines if we need to update the navbar resources due to a theme change.  We currently
     * check if the overlay for the navbar, or request type is {@link RequestType.THEME_UPDATED}.
     *
     * @param oldTheme
     * @param newTheme
     * @return True if we should update the navbar
     */
    private boolean shouldUpdateNavbar(ThemeConfig oldTheme, ThemeConfig newTheme) {
        // no newTheme, so no need to update navbar
        if (newTheme == null) return false;

        final String overlay = newTheme.getOverlayForNavBar();

        return oldTheme == null ||
                (overlay != null && !overlay.equals(oldTheme.getOverlayForNavBar()) ||
                        newTheme.getLastThemeChangeRequestType() == RequestType.THEME_UPDATED);
    }

    protected void loadDimens() {
        final Resources res = mContext.getResources();