Skip to content

Commit 10bd410

Browse files
Adam PowellAndroid Git Automerger
authored andcommitted
am baed0a8: am 56fd88d: am ab12f0f: Merge "Implement resolving of icon attributes to resIds in AlertController"
* commit 'baed0a8f0b43191c8f001e064ff42cf27a305d87': Implement resolving of icon attributes to resIds in AlertController
2 parents 072533e + baed0a8 commit 10bd410

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

core/java/com/android/internal/app/AlertController.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@ public void setIcon(Drawable icon) {
347347
}
348348
}
349349

350+
/**
351+
* @param attrId the attributeId of the theme-specific drawable
352+
* to resolve the resourceId for.
353+
*
354+
* @return resId the resourceId of the theme-specific drawable
355+
*/
356+
public int getIconAttributeResId(int attrId) {
357+
TypedValue out = new TypedValue();
358+
mContext.getTheme().resolveAttribute(attrId, out, true);
359+
return out.resourceId;
360+
}
361+
350362
public void setInverseBackgroundForced(boolean forceInverseBackground) {
351363
mForceInverseBackground = forceInverseBackground;
352364
}
@@ -740,6 +752,7 @@ public static class AlertParams {
740752

741753
public int mIconId = 0;
742754
public Drawable mIcon;
755+
public int mIconAttrId = 0;
743756
public CharSequence mTitle;
744757
public View mCustomTitleView;
745758
public CharSequence mMessage;
@@ -807,6 +820,9 @@ public void apply(AlertController dialog) {
807820
if (mIconId >= 0) {
808821
dialog.setIcon(mIconId);
809822
}
823+
if (mIconAttrId > 0) {
824+
dialog.setIcon(dialog.getIconAttributeResId(mIconAttrId));
825+
}
810826
}
811827
if (mMessage != null) {
812828
dialog.setMessage(mMessage);

0 commit comments

Comments
 (0)