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

Commit caca720b authored by Alan Viverette's avatar Alan Viverette
Browse files

Allow inner classes to be used as custom drawables

Bug: 22627299
Change-Id: I2f21927966470594f1b96feac6d5abaa397f2d15
parent 43c2091a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -112,6 +112,17 @@ public final class DrawableInflater {
    public Drawable inflateFromXml(@NonNull String name, @NonNull XmlPullParser parser,
            @NonNull AttributeSet attrs, @Nullable Theme theme)
            throws XmlPullParserException, IOException {
        // Inner classes must be referenced as Outer$Inner, but XML tag names
        // can't contain $, so the <drawable> tag allows developers to specify
        // the class in an attribute. We'll still run it through inflateFromTag
        // to stay consistent with how LayoutInflater works.
        if (name.equals("drawable")) {
            name = attrs.getAttributeValue(null, "class");
            if (name == null) {
                throw new InflateException("<drawable> tag must specify class attribute");
            }
        }

        Drawable drawable = inflateFromTag(name);
        if (drawable == null) {
            drawable = inflateFromClass(name);