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

Commit 2ec1a33b authored by Clark Scheff's avatar Clark Scheff
Browse files

Themes: Add config change flag for font change

This patch adds a new flag that lets us know if the font actually
changed when a theme change occurs.  This way we can skip calling
Typeface.recreateDefaults() if the font did not change.

Change-Id: Idfaa0ae1fba99c8222d3607bd3864b7f1fa32b96
parent 9e2a6988
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4278,8 +4278,8 @@ public final class ActivityThread {
        if (configDiff != 0) {
            // Ask text layout engine to free its caches if there is a locale change
            boolean hasLocaleConfigChange = ((configDiff & ActivityInfo.CONFIG_LOCALE) != 0);
            boolean hasThemeConfigChange = ((configDiff & ActivityInfo.CONFIG_THEME_RESOURCE) != 0);
            if (hasLocaleConfigChange || hasThemeConfigChange) {
            boolean hasFontConfigChange = ((configDiff & ActivityInfo.CONFIG_THEME_FONT) != 0);
            if (hasLocaleConfigChange || hasFontConfigChange) {
                Canvas.freeTextLayoutCaches();
                Typeface.recreateDefaults();
                if (DEBUG_CONFIGURATION) Slog.v(TAG, "Cleared TextLayout Caches");
+10 −4
Original line number Diff line number Diff line
@@ -493,10 +493,6 @@ public class ActivityInfo extends ComponentInfo
     * {@link android.R.attr#configChanges} attribute.
     */
    public static final int CONFIG_ORIENTATION = 0x0080;
    /**
     * @hide
     */
    public static final int CONFIG_THEME_RESOURCE = 0x008000;
    /**
     * Bit in {@link #configChanges} that indicates that the activity
     * can itself handle changes to the screen layout.  Set from the
@@ -545,6 +541,16 @@ public class ActivityInfo extends ComponentInfo
     * {@link android.R.attr#configChanges} attribute.
     */
    public static final int CONFIG_LAYOUT_DIRECTION = 0x2000;
    /**
     * Bit in {@link #configChanges} that indicates a theme change occurred
     * @hide
     */
    public static final int CONFIG_THEME_RESOURCE = 0x100000;
    /**
     * Bit in {@link #configChanges} that indicates a font change occurred
     * @hide
     */
    public static final int CONFIG_THEME_FONT = 0x200000;
    /**
     * Bit in {@link #configChanges} that indicates that the activity
     * can itself handle changes to the font scaling factor.  Set from the
+4 −0
Original line number Diff line number Diff line
@@ -1033,6 +1033,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        if (delta.themeConfig != null
                && (themeConfig == null || !themeConfig.equals(delta.themeConfig))) {
            changed |= ActivityInfo.CONFIG_THEME_RESOURCE;
            if (themeConfig == null ||
                    !delta.themeConfig.getFontPkgName().equals(themeConfig.getFontPkgName())) {
                changed |= ActivityInfo.CONFIG_THEME_FONT;
            }
            themeConfig = (ThemeConfig)delta.themeConfig.clone();
        }