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

Commit 5c2d8f7d authored by Alan Viverette's avatar Alan Viverette
Browse files

Don't override dialog icon drawable unless valid resource ID was set

Fixes a regression where Builder.setIcon(Drawable) would get overridden
even when Builder.setIcon(int) had never been called and was still 0.
Fixes attribute id to respect all valid resource IDs (e.g. non-zero).
Updates documentation to reflect the long-standing override behavior.

BUG: 18904762
Change-Id: I905703993a59910555d5a858e0aaecab63221a02
parent dd508581
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -466,6 +466,8 @@ public class AlertDialog extends Dialog implements DialogInterface {
        
        /**
         * Set the resource id of the {@link Drawable} to be used in the title.
         * <p>
         * Takes precedence over values set using {@link #setIcon(Drawable)}.
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
@@ -485,7 +487,11 @@ public class AlertDialog extends Dialog implements DialogInterface {
        }

        /**
         * Set an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon
         * Set an icon as supplied by a theme attribute. e.g.
         * {@link android.R.attr#alertDialogIcon}.
         * <p>
         * Takes precedence over values set using {@link #setIcon(int)} or
         * {@link #setIcon(Drawable)}.
         *
         * @param attrId ID of a theme attribute that points to a drawable resource.
         */
+2 −2
Original line number Diff line number Diff line
@@ -955,10 +955,10 @@ public class AlertController {
                if (mIcon != null) {
                    dialog.setIcon(mIcon);
                }
                if (mIconId >= 0) {
                if (mIconId != 0) {
                    dialog.setIcon(mIconId);
                }
                if (mIconAttrId > 0) {
                if (mIconAttrId != 0) {
                    dialog.setIcon(dialog.getIconAttributeResId(mIconAttrId));
                }
            }