summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblunden <blunden2@gmail.com>2012-09-10 23:29:04 +0200
committerBjörn Lundén <blunden2@gmail.com>2012-09-11 07:26:12 +0200
commit576e1dff3d40610377a763db6c9e6bf999e00987 (patch)
treeca0e0d87aefc6182837e11e5a6ebc6ad01cec748
parentbfe1ab825731d365fef169deab646d7ceeafc998 (diff)
downloadbase-576e1dff3d40610377a763db6c9e6bf999e00987.tar.gz
Implement resolving of icon attributes to resIds in AlertController
Platform code using AlertController directly currently has no way to set the correct theme-specific dialog icon in a generic way. This adds code to handle such usage. Change-Id: I48beafa1183e4edf6d5378b3985a7f9be5fcda8b
-rw-r--r--core/java/com/android/internal/app/AlertController.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java
index 2061c905ebb0..56b5937a0dea 100644
--- a/core/java/com/android/internal/app/AlertController.java
+++ b/core/java/com/android/internal/app/AlertController.java
@@ -347,6 +347,18 @@ public class AlertController {
}
}
+ /**
+ * @param attrId the attributeId of the theme-specific drawable
+ * to resolve the resourceId for.
+ *
+ * @return resId the resourceId of the theme-specific drawable
+ */
+ public int getIconAttributeResId(int attrId) {
+ TypedValue out = new TypedValue();
+ mContext.getTheme().resolveAttribute(attrId, out, true);
+ return out.resourceId;
+ }
+
public void setInverseBackgroundForced(boolean forceInverseBackground) {
mForceInverseBackground = forceInverseBackground;
}
@@ -740,6 +752,7 @@ public class AlertController {
public int mIconId = 0;
public Drawable mIcon;
+ public int mIconAttrId = 0;
public CharSequence mTitle;
public View mCustomTitleView;
public CharSequence mMessage;
@@ -806,6 +819,9 @@ public class AlertController {
if (mIconId >= 0) {
dialog.setIcon(mIconId);
}
+ if (mIconAttrId > 0) {
+ dialog.setIcon(dialog.getIconAttributeResId(mIconAttrId));
+ }
}
if (mMessage != null) {
dialog.setMessage(mMessage);