Browse Source

Fix input dialog tinting and text handler color

plusCubed 10 years ago
parent
commit
e694d4096f

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

@@ -73,7 +73,7 @@ public class MaterialDialog extends DialogBase implements
     protected MaterialDialog(Builder builder) {
         super(builder.context, DialogInit.getTheme(builder));
         mBuilder = builder;
-        final LayoutInflater inflater = LayoutInflater.from(getContext());
+        final LayoutInflater inflater = LayoutInflater.from(builder.context);
         view = (MDRootLayout) inflater.inflate(DialogInit.getInflateLayout(builder), null);
         DialogInit.init(this);
     }

+ 12 - 5
library/src/main/java/com/afollestad/materialdialogs/internal/MDTintHelper.java

@@ -5,6 +5,9 @@ import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
 import android.os.Build;
 import android.support.v4.content.ContextCompat;
+import android.support.v7.internal.widget.TintCheckBox;
+import android.support.v7.internal.widget.TintEditText;
+import android.support.v7.internal.widget.TintRadioButton;
 import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.ProgressBar;
@@ -28,7 +31,7 @@ public class MDTintHelper {
         });
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             radioButton.setButtonTintList(sl);
-        } else {
+        } else if (radioButton instanceof TintRadioButton) {
             Drawable drawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
             DrawableWrapper d = new DrawableWrapper(drawable);
             d.setTintList(sl);
@@ -51,10 +54,14 @@ public class MDTintHelper {
     }
 
     public static void setEditTextTint(EditText editText, int color) {
+        ColorStateList s1 = ColorStateList.valueOf(color);
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-            editText.setBackgroundTintList(ColorStateList.valueOf(color));
-        } else {
-            editText.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
+            editText.setBackgroundTintList(s1);
+        } else if (editText instanceof TintEditText) {
+            Drawable drawable = ContextCompat.getDrawable(editText.getContext(), R.drawable.abc_edit_text_material);
+            DrawableWrapper d = new DrawableWrapper(drawable);
+            d.setTintList(s1);
+            editText.setBackgroundDrawable(d);
         }
     }
 
@@ -68,7 +75,7 @@ public class MDTintHelper {
         });
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             box.setButtonTintList(sl);
-        } else {
+        } else if (box instanceof TintCheckBox) {
             Drawable drawable = ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material);
             DrawableWrapper d = new DrawableWrapper(drawable);
             d.setTintList(sl);