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

Commit fea0a82a 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.

BACON-4301
NIGHTLIES-1967

Change-Id: Iab75b0310298c46d66a469c50669f9c2f013a3ec
parent e49d5ea0
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -858,7 +858,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);
@@ -1702,7 +1702,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(
@@ -4066,10 +4066,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            addHeadsUpView();
        }

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

        // recreate StatusBarIconViews.
        for (int i = 0; i < nIcons; i++) {
            StatusBarIcon icon = icons.get(i);
@@ -4128,6 +4124,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) {
            recreateStatusBar();
@@ -4155,7 +4152,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }

        if (mNavigationBarView != null)  {
            mNavigationBarView.updateResources(getNavbarThemedResources());
            if (updateNavBar) mNavigationBarView.updateResources(getNavbarThemedResources());
            updateSearchPanel();
        }
    }
@@ -4184,6 +4181,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);
    }

    private void updateClockSize() {
        if (mStatusBarView == null) return;
        TextView clock = (TextView) mStatusBarView.findViewById(R.id.clock);