Aidan Follestad 10 years ago
parent
commit
35bcbfdf31

+ 10 - 5
README.md

@@ -381,28 +381,33 @@ or operating system. This behavior can be overridden in your Activity themes:
 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
 
     <!--
-        All dialogs will default to Theme.DARK
+        All dialogs will default to Theme.DARK.
     -->
     <item name="md_dark_theme">true</item>
 
     <!--
-        By default, the title text is pure black or pure white based on the theme
+        Applies an icon to all dialogs.
+    -->
+    <item name="md_dark_theme">true</item>
+
+    <!--
+        By default, the title text is pure black or pure white based on the theme.
     -->
     <item name="md_title_color">#E91E63</item>
 
     <!--
-        By default, the content text is derived from the ?android:textColorSecondary OS attribute
+        By default, the content text is derived from the ?android:textColorSecondary OS attribute.
     -->
     <item name="md_content_color">#9C27B0</item>
 
     <!--
         By default, the accent color is derived from the colorAccent attribute of AppCompat or
-        android:colorAccent attribute of the Material theme
+        android:colorAccent attribute of the Material theme.
     -->
     <item name="md_accent_color">#673AB7</item>
 
     <!--
-        By default, the list item text color is derived from the ?android:textColorSecondary OS attribute
+        By default, the list item text color is derived from the ?android:textColorSecondary OS attribute.
     -->
     <item name="md_item_color">#9C27B0</item>
 

+ 7 - 1
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -213,7 +213,13 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
             icon.setVisibility(View.VISIBLE);
             icon.setImageDrawable(builder.icon);
         } else {
-            icon.setVisibility(View.GONE);
+            Drawable d = DialogUtils.resolveDrawable(getContext(), R.attr.md_icon);
+            if (d != null) {
+                icon.setVisibility(View.VISIBLE);
+                icon.setImageDrawable(builder.icon);
+            } else {
+                icon.setVisibility(View.GONE);
+            }
         }
 
         // Title is set after it's determined whether to use first title or custom view title

+ 1 - 0
library/src/main/res/values/attrs.xml

@@ -10,5 +10,6 @@
     <attr name="md_content_color" format="color" />
     <attr name="md_accent_color" format="color" />
     <attr name="md_item_color" format="color" />
+    <attr name="md_icon" format="reference" />
 
 </resources>

+ 0 - 1
sample/src/main/java/com/afollestad/materialdialogssample/MainActivity.java

@@ -279,7 +279,6 @@ public class MainActivity extends ActionBarActivity implements FolderSelectorDia
 
     private void showSingleChoice() {
         new MaterialDialog.Builder(this)
-                .icon(R.drawable.ic_launcher)
                 .title(R.string.socialNetworks)
                 .items(R.array.socialNetworks)
                 .itemsCallbackSingleChoice(2, new MaterialDialog.ListCallback() {