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

Commit b6444c43 authored by Deepanshu Gupta's avatar Deepanshu Gupta
Browse files

Fix multiple styles case in resource resolution.

When multiple styles are applied to a theme, we only remembered the last
one. This change fixes the issue.

Change-Id: I46490e882edc3eabe522a641c83366234b5bb25d
parent 4a605c6f
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -38,8 +38,4 @@ public class AssetManager_Delegate {
        Resources_Theme_Delegate.getDelegateManager().removeJavaReferenceFor(theme);
    }

    @LayoutlibDelegate
    /*package*/ static void applyThemeStyle(long theme, int styleRes, boolean force) {
        Resources_Theme_Delegate.getDelegateManager().getDelegate(theme).force = force;
    }
}
+22 −10
Original line number Diff line number Diff line
@@ -39,9 +39,6 @@ import android.util.TypedValue;
 */
public class Resources_Theme_Delegate {

    // Whether to use the Theme.mThemeResId as primary theme.
    boolean force;

    // ---- delegate manager ----

    private static final DelegateManager<Resources_Theme_Delegate> sManager =
@@ -111,14 +108,29 @@ public class Resources_Theme_Delegate {
    // ---- private helper methods ----

    private static boolean setupResources(Theme thisTheme) {
        Resources_Theme_Delegate themeDelegate = sManager.getDelegate(thisTheme.getNativeTheme());
        StyleResourceValue style = resolveStyle(thisTheme.getAppliedStyleResId());
        // Key is a space-separated list of theme ids applied that have been merged into the
        // BridgeContext's theme to make thisTheme.
        String[] appliedStyles = thisTheme.getKey().split(" ");
        boolean changed = false;
        for (String s : appliedStyles) {
            if (s.isEmpty()) {
                continue;
            }
            // See the definition of force parameter in Theme.applyStyle().
            boolean force = false;
            if (s.charAt(s.length() - 1) == '!') {
                force = true;
                s = s.substring(0, s.length() - 1);
            }
            int styleId = Integer.parseInt(s, 16);
            StyleResourceValue style = resolveStyle(styleId);
            if (style != null) {
            RenderSessionImpl.getCurrentContext().getRenderResources()
                    .applyStyle(style, themeDelegate.force);
            return true;
                RenderSessionImpl.getCurrentContext().getRenderResources().applyStyle(style, force);
                changed = true;
            }

        }
        return false;
        return changed;
    }

    private static void restoreResources(boolean changed) {
+0 −1
Original line number Diff line number Diff line
@@ -143,7 +143,6 @@ public final class CreateInfo implements ICreateInfo {
        "android.content.res.Resources$Theme#resolveAttributes",
        "android.content.res.AssetManager#newTheme",
        "android.content.res.AssetManager#deleteTheme",
        "android.content.res.AssetManager#applyThemeStyle",
        "android.content.res.TypedArray#getValueAt",
        "android.content.res.TypedArray#obtain",
        "android.graphics.BitmapFactory#finishDecode",