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

Commit 82314c01 authored by Xavier Ducrohet's avatar Xavier Ducrohet Committed by Android (Google) Code Review
Browse files

Merge "LayoutLib: support defStyleRes in obtainStyledAttributes."

parents 250da4bb 3e87bfa1
Loading
Loading
Loading
Loading
+60 −24
Original line number Diff line number Diff line
@@ -425,7 +425,8 @@ public final class BridgeContext extends Activity {
            }
        }

        if (defStyleValues == null && defStyleAttr != 0) {
        if (defStyleValues == null) {
            if (defStyleAttr != 0) {
                // get the name from the int.
                String defStyleName = searchAttr(defStyleAttr);

@@ -450,11 +451,46 @@ public final class BridgeContext extends Activity {
                                    "Failed to find style '%s' in current theme", defStyleName),
                            null /*data*/);
                }
            } else if (defStyleRes != 0) {
                Pair<ResourceType, String> value = Bridge.resolveResourceId(defStyleRes);
                if (value == null) {
                    value = mProjectCallback.resolveResourceId(defStyleRes);
                }

        if (defStyleRes != 0) {
            // FIXME: See what we need to do with this.
            throw new UnsupportedOperationException();
                if (value != null) {
                    if (value.getFirst() == ResourceType.STYLE) {
                        // look for the style in the current theme, and its parent:
                        ResourceValue item = mRenderResources.findItemInTheme(value.getSecond());
                        if (item != null) {
                            if (item instanceof StyleResourceValue) {
                                if (defaultPropMap != null) {
                                    defaultPropMap.put("style", item.getName());
                                }

                                defStyleValues = (StyleResourceValue)item;
                            }
                        } else {
                            Bridge.getLog().error(null,
                                    String.format(
                                            "Style with id 0x%x (resolved to '%s') does not exist.",
                                            defStyleRes, value.getSecond()),
                                    null /*data*/);
                        }
                    } else {
                        Bridge.getLog().error(null,
                                String.format(
                                        "Resouce id 0x%x is not of type STYLE (instead %s)",
                                        defStyleRes, value.getFirst().toString()),
                                null /*data*/);
                    }
                } else {
                    Bridge.getLog().error(null,
                            String.format(
                                    "Failed to find style with id 0x%x in current theme",
                                    defStyleRes),
                            null /*data*/);
                }
            }
        }

        String namespace = BridgeConstants.NS_RESOURCES;