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

Commit a6d29069 authored by Josh Guilfoyle's avatar Josh Guilfoyle Committed by Josh Guilfoyle
Browse files

Properly refresh cached drawables on theme change.

Now that the resources drawable cache is not wiped on every config
change we need to be sure that theme change triggers a wipe.

Change-Id: I6622dcfb2551618f3c7b48ee6496930095e8ce9f
parent b58e5ae9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -528,7 +528,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     * @return Return true if the resource needs to be loaded, else false.
     */
    public static boolean needNewResources(int configChanges, int interestingChanges) {
        return (configChanges & (interestingChanges|ActivityInfo.CONFIG_FONT_SCALE)) != 0;
        return (configChanges & (interestingChanges |
                ActivityInfo.CONFIG_FONT_SCALE |
                ActivityInfo.CONFIG_THEME_RESOURCE)) != 0;
    }
    
    /**
+12 −0
Original line number Diff line number Diff line
@@ -1324,6 +1324,18 @@ public class Resources {
    private void drawableCacheClear(
            LongSparseArray<WeakReference<ConstantState>> cache,
            int configChanges) {
        /*
         * Quick test to find out if the config change that occurred should
         * trigger a full cache wipe.
         */
        if (Configuration.needNewResources(configChanges, 0)) {
            if (DEBUG_CONFIG) {
                Log.d(TAG, "Clear drawable cache from config changes: 0x"
                        + Integer.toHexString(configChanges));
            }
            cache.clear();
            return;
        }
        int N = cache.size();
        if (DEBUG_CONFIG) {
            Log.d(TAG, "Cleaning up drawables config changes: 0x"