Browse Source

Merge remote-tracking branch 'origin/master'

Aidan Follestad 10 years ago
parent
commit
5ccf81dff5

+ 22 - 0
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -94,6 +94,14 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
         super(getTheme(builder));
         super(getTheme(builder));
         mBuilder = builder;
         mBuilder = builder;
 
 
+        if (!mBuilder.useCustomFonts && mBuilder.mediumFont == null) {
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+                mBuilder.mediumFont = Typeface.create("sans-serif-medium", Typeface.NORMAL);
+            } else {
+                mBuilder.mediumFont = Typeface.create("sans-serif", Typeface.BOLD);
+            }
+        }
+
         this.view = LayoutInflater.from(getContext()).inflate(R.layout.md_dialog, null);
         this.view = LayoutInflater.from(getContext()).inflate(R.layout.md_dialog, null);
         this.setCancelable(builder.cancelable);
         this.setCancelable(builder.cancelable);
 
 
@@ -866,6 +874,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
         protected boolean autoDismiss = true;
         protected boolean autoDismiss = true;
         protected Typeface regularFont;
         protected Typeface regularFont;
         protected Typeface mediumFont;
         protected Typeface mediumFont;
+        protected boolean useCustomFonts;
         protected Drawable icon;
         protected Drawable icon;
         protected ListAdapter adapter;
         protected ListAdapter adapter;
         protected OnDismissListener dismissListener;
         protected OnDismissListener dismissListener;
@@ -986,6 +995,17 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
             return this;
             return this;
         }
         }
 
 
+        /**
+         * Disable usage of the default fonts. This is automatically set by
+         * {@link #typeface(String, String)} and {@link #typeface(Typeface, Typeface)}.
+         *
+         * @return The Builder instance so you can chain calls to it.
+         */
+        public Builder disableDefaultFonts() {
+            this.useCustomFonts = true;
+            return this;
+        }
+
         /**
         /**
          * Sets the fonts used in the dialog. It's recommended that you use {@link #typeface(String, String)} instead,
          * Sets the fonts used in the dialog. It's recommended that you use {@link #typeface(String, String)} instead,
          * to avoid duplicate Typeface allocations and high memory usage.
          * to avoid duplicate Typeface allocations and high memory usage.
@@ -999,6 +1019,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
         public Builder typeface(Typeface medium, Typeface regular) {
         public Builder typeface(Typeface medium, Typeface regular) {
             this.mediumFont = medium;
             this.mediumFont = medium;
             this.regularFont = regular;
             this.regularFont = regular;
+            this.useCustomFonts = true;
             return this;
             return this;
         }
         }
 
 
@@ -1015,6 +1036,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
                 this.mediumFont = TypefaceHelper.get(this.context, medium);
                 this.mediumFont = TypefaceHelper.get(this.context, medium);
             if (regular != null)
             if (regular != null)
                 this.regularFont = TypefaceHelper.get(this.context, regular);
                 this.regularFont = TypefaceHelper.get(this.context, regular);
+            this.useCustomFonts = true;
             return this;
             return this;
         }
         }