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

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

Fix issue where non-themable app still had themed fonts

The previous logic made it possible for a non-themable app to retain
the applied font rather than use the system fonts as expected.

Change-Id: Ia2ff7ec7741681712f201ce85e52df1c0a6a0225
TICKET: CYNGNOS-939
parent 3ff4c9a6
Loading
Loading
Loading
Loading
+17 −18
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ public class ResourcesManager {
            Configuration overrideConfiguration, CompatibilityInfo compatInfo, Context context,
            boolean isThemeable) {
        final float scale = compatInfo.applicationScale;
        final ThemeConfig themeConfig = isThemeable ? getThemeConfig() : null;
        ThemeConfig themeConfig = getThemeConfig();
        Configuration overrideConfigCopy = (overrideConfiguration != null)
                ? new Configuration(overrideConfiguration) : null;
        ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfiguration, scale,
@@ -268,26 +268,28 @@ public class ResourcesManager {

        boolean iconsAttached = false;
        /* Attach theme information to the resulting AssetManager when appropriate. */
        if (isThemeable && config != null && !context.getPackageManager().isSafeMode()) {
            if (config.themeConfig == null) {
        if (config != null && !context.getPackageManager().isSafeMode()) {
            if (themeConfig == null) {
                try {
                    config.themeConfig = ThemeConfig.getBootTheme(context.getContentResolver());
                    themeConfig = ThemeConfig.getBootTheme(context.getContentResolver());
                } catch (Exception e) {
                    Slog.d(TAG, "ThemeConfig.getBootTheme failed, falling back to system theme", e);
                    config.themeConfig = ThemeConfig.getSystemTheme();
                    themeConfig = ThemeConfig.getSystemTheme();
                }
            }

            if (config.themeConfig != null) {
                attachThemeAssets(assets, config.themeConfig);
                attachCommonAssets(assets, config.themeConfig);
                iconsAttached = attachIconAssets(assets, config.themeConfig);
            if (isThemeable) {
                if (themeConfig != null) {
                    attachThemeAssets(assets, themeConfig);
                    attachCommonAssets(assets, themeConfig);
                    iconsAttached = attachIconAssets(assets, themeConfig);
                }
        } else if (!isThemeable && config.themeConfig != null &&
                !ThemeConfig.SYSTEM_DEFAULT.equals(config.themeConfig.getFontPkgName())) {
            } else if (themeConfig != null &&
                    !ThemeConfig.SYSTEM_DEFAULT.equals(themeConfig.getFontPkgName())) {
                // use system fonts if not themeable and a theme font is currently in use
                Typeface.recreateDefaults(true);
            }
        }

        r = new Resources(assets, dm, config, compatInfo);
        if (iconsAttached) setActivityIcons(r);
@@ -782,10 +784,7 @@ public class ResourcesManager {
    }

    private ThemeConfig getThemeConfig() {
        Configuration config = getConfiguration();
        if (config != null) {
            return config.themeConfig;
        }
        return null;
        final Configuration config = getConfiguration();
        return config != null ? config.themeConfig : null;
    }
}