瀏覽代碼

Fix MaterialListPreference radio button on API 10

plusCubed 10 年之前
父節點
當前提交
5a2d91ada2

+ 3 - 6
library/src/main/java/com/afollestad/materialdialogs/internal/MDTintHelper.java

@@ -5,9 +5,6 @@ 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;
@@ -31,7 +28,7 @@ public class MDTintHelper {
         });
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             radioButton.setButtonTintList(sl);
-        } else if (radioButton instanceof TintRadioButton) {
+        } else {
             Drawable drawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
             DrawableWrapper d = new DrawableWrapper(drawable);
             d.setTintList(sl);
@@ -61,7 +58,7 @@ public class MDTintHelper {
         ColorStateList s1 = ColorStateList.valueOf(color);
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             editText.setBackgroundTintList(s1);
-        } else if (editText instanceof TintEditText) {
+        } else {
             Drawable drawable = ContextCompat.getDrawable(editText.getContext(), R.drawable.abc_edit_text_material);
             DrawableWrapper d = new DrawableWrapper(drawable);
             d.setTintList(s1);
@@ -79,7 +76,7 @@ public class MDTintHelper {
         });
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             box.setButtonTintList(sl);
-        } else if (box instanceof TintCheckBox) {
+        } else {
             Drawable drawable = ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material);
             DrawableWrapper d = new DrawableWrapper(drawable);
             d.setTintList(sl);

+ 7 - 7
library/src/main/java/com/afollestad/materialdialogs/prefs/MaterialEditTextPreference.java

@@ -2,9 +2,7 @@ package com.afollestad.materialdialogs.prefs;
 
 import android.app.Dialog;
 import android.content.Context;
-import android.graphics.PorterDuff;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
+import android.os.Build;
 import android.os.Bundle;
 import android.preference.EditTextPreference;
 import android.support.annotation.NonNull;
@@ -23,6 +21,7 @@ import com.afollestad.materialdialogs.MaterialDialog;
 import com.afollestad.materialdialogs.MaterialDialog.Builder;
 import com.afollestad.materialdialogs.MaterialDialog.ButtonCallback;
 import com.afollestad.materialdialogs.R;
+import com.afollestad.materialdialogs.internal.MDTintHelper;
 import com.afollestad.materialdialogs.util.DialogUtils;
 
 /**
@@ -34,8 +33,10 @@ public class MaterialEditTextPreference extends EditTextPreference {
 
     public MaterialEditTextPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
-        if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP)
-            mColor = DialogUtils.resolveColor(context, R.attr.colorAccent);
+        mColor = DialogUtils.resolveColor(context, R.attr.colorAccent);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            mColor = DialogUtils.resolveColor(context, android.R.attr.colorAccent, mColor);
+        }
     }
 
     public MaterialEditTextPreference(Context context) {
@@ -77,8 +78,7 @@ public class MaterialEditTextPreference extends EditTextPreference {
         View layout = LayoutInflater.from(getContext()).inflate(R.layout.md_stub_inputpref, null);
         onBindDialogView(layout);
 
-        if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP)
-            getEditText().getBackground().setColorFilter(mColor, PorterDuff.Mode.SRC_ATOP);
+        MDTintHelper.setEditTextTint(getEditText(), mColor);
 
         TextView message = (TextView) layout.findViewById(android.R.id.message);
         if (getDialogMessage() != null && getDialogMessage().toString().length() > 0) {