Skip to content

Commit 56fd88d

Browse files
Adam PowellAndroid Git Automerger
authored andcommitted
am ab12f0f: Merge "Implement resolving of icon attributes to resIds in AlertController"
* commit 'ab12f0f72c22143523e2bce7d58d9f1021abde5c': Implement resolving of icon attributes to resIds in AlertController
2 parents 945080b + ab12f0f commit 56fd88d

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;
@@ -806,6 +819,9 @@ public void apply(AlertController dialog) {
806819
if (mIconId >= 0) {
807820
dialog.setIcon(mIconId);
808821
}
822+
if (mIconAttrId > 0) {
823+
dialog.setIcon(dialog.getIconAttributeResId(mIconAttrId));
824+
}
809825
}
810826
if (mMessage != null) {
811827
dialog.setMessage(mMessage);

0 commit comments

Comments
 (0)