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

Commit 34a14f96 authored by Alan Viverette's avatar Alan Viverette
Browse files

Better handling of unresolved theme attributes

Also adds a (very obviously wrong) default color to RippleDrawable

Change-Id: I6d29b371f4e59accbebf25eb059b1f372b9184b0
parent a2897ea9
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -715,7 +715,13 @@ public class Resources {
     * @see #getDrawable(int, Theme)
     */
    public Drawable getDrawable(int id) throws NotFoundException {
        return getDrawable(id, null);
        final Drawable d = getDrawable(id, null);
        if (d.canApplyTheme()) {
            Log.w(TAG, "Drawable " + getResourceName(id) + " has unresolved theme "
                    + "attributes! Consider using Resources.getDrawable(int, Theme) or "
                    + "Context.getDrawable(int).", new RuntimeException());
        }
        return d;
    }

    /**
+7 −3
Original line number Diff line number Diff line
@@ -395,8 +395,12 @@ public class RippleDrawable extends LayerDrawable {
            mState.mColor = color;
        }

        // If we're not waiting on a theme, verify required attributes.
        if (state.mTouchThemeAttrs == null && mState.mColor == null) {
        verifyRequiredAttributes(a);
    }

    private void verifyRequiredAttributes(TypedArray a) throws XmlPullParserException {
        if (mState.mColor == null && (mState.mTouchThemeAttrs == null
                || mState.mTouchThemeAttrs[R.styleable.RippleDrawable_color] == 0)) {
            throw new XmlPullParserException(a.getPositionDescription() +
                    ": <ripple> requires a valid color attribute");
        }
@@ -891,7 +895,7 @@ public class RippleDrawable extends LayerDrawable {

    static class RippleState extends LayerState {
        int[] mTouchThemeAttrs;
        ColorStateList mColor = null;
        ColorStateList mColor = ColorStateList.valueOf(Color.MAGENTA);
        int mMaxRadius = RADIUS_AUTO;

        public RippleState(RippleState orig, RippleDrawable owner, Resources res) {