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

Commit 6782b0e7 authored by Diego Perez's avatar Diego Perez
Browse files

Force animateFirstValue to false

This CL forces both animateFirstValue and animateLayoutChanges to false
in themes when running layoutlib. This helps with the rendering of some
widgets so they do not rely on animations.

Test: Test as part of testActivity
Change-Id: Ic9214929d3582bc3e0a196d198cc4fb36347c782
parent f31c1e98
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -113,6 +113,15 @@ import static com.android.layoutlib.bridge.android.RenderParamsFlags.FLAG_KEY_AP
public final class BridgeContext extends Context {
    private static final String PREFIX_THEME_APPCOMPAT = "Theme.AppCompat";

    private static final Map<String, ResourceValue> FRAMEWORK_PATCHED_VALUES = new HashMap<>(2);

    static {
        FRAMEWORK_PATCHED_VALUES.put("animateFirstView", new ResourceValue(
                ResourceType.BOOL, "animateFirstView", "false", false));
        FRAMEWORK_PATCHED_VALUES.put("animateLayoutChanges", new ResourceValue(
                ResourceType.BOOL, "animateFirstView", "false", false));
    };

    /** The map adds cookies to each view so that IDE can link xml tags to views. */
    private final HashMap<View, Object> mViewKeyMap = new HashMap<>();
    /**
@@ -909,6 +918,16 @@ public final class BridgeContext extends Context {
                // if there's no direct value for this attribute in the XML, we look for default
                // values in the widget defStyle, and then in the theme.
                if (value == null) {
                    if (frameworkAttr) {
                        // For some framework values, layoutlib patches the actual value in the
                        // theme when it helps to improve the final preview. In most cases
                        // we just disable animations.
                        ResourceValue patchedValue = FRAMEWORK_PATCHED_VALUES.get(attrName);
                        if (patchedValue != null) {
                            defaultValue = patchedValue;
                        }
                    }

                    // if we found a value, we make sure this doesn't reference another value.
                    // So we resolve it.
                    if (defaultValue != null) {
+0 −1
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
        <item name="myattr">@integer/ten</item>
        <item name="android:animateFirstView">false</item>
    </style>

</resources>