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

Commit 871bdb98 authored by Joe Onorato's avatar Joe Onorato
Browse files

Handle bad icon resources.

Change-Id: I87c5fe68ad8016596068ba7889f3b6d36da3386b
parent 20da8f8a
Loading
Loading
Loading
Loading
+30 −16
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public class StatusBarIconView extends AnimatedImageView {

    private StatusBarIcon mIcon;
    @ViewDebug.ExportedProperty private String mSlot;
    @ViewDebug.ExportedProperty private boolean mError;

    public StatusBarIconView(Context context, String slot) {
        super(context);
@@ -52,16 +53,25 @@ public class StatusBarIconView extends AnimatedImageView {
    }

    public void set(StatusBarIcon icon) {
        final boolean iconEquals = mIcon != null
        error: {
            final boolean iconEquals = !mError
                    && mIcon != null
                    && streq(mIcon.iconPackage, icon.iconPackage)
                    && mIcon.iconId == icon.iconId;
        final boolean levelEquals = iconEquals
            final boolean levelEquals = !mError
                    && iconEquals
                    && mIcon.iconLevel == icon.iconLevel;
        final boolean visibilityEquals = mIcon != null
            final boolean visibilityEquals = !mError
                    && mIcon != null
                    && mIcon.visible == icon.visible;
            mError = false;
            if (!iconEquals) {
            setImageDrawable(getIcon(icon));
            // TODO: What if getIcon returns null?
                Drawable drawable = getIcon(icon);
                if (drawable == null) {
                    mError = true;
                    break error;
                }
                setImageDrawable(drawable);
            }
            if (!levelEquals) {
                setImageLevel(icon.iconLevel);
@@ -71,6 +81,10 @@ public class StatusBarIconView extends AnimatedImageView {
            }
            mIcon = icon.clone();
        }
        if (mError) {
            setVisibility(GONE);
        }
    }

    /**
     * Returns the right icon to use for this item, respecting the iconId and
+10 −0
Original line number Diff line number Diff line
@@ -122,6 +122,16 @@ public class NotificationTestList extends TestActivity
            }
        },

        new Test("Bad Icon") {
            public void run() {
                mNM.notify(1, new Notification(NotificationTestList.this,
                            R.layout.chrono_notification, /* not a drawable! */
                            null, System.currentTimeMillis()-(1000*60*60*24),
                            "(453) 123-2328",
                            "", null));
            }
        },

        new Test("Bad resource #2") {
            public void run()
            {