From 3a3e0a8e47dcce7718a07a73b9d83de7c08f1957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=94=E7=89=A9=E7=BA=BF?= Date: Mon, 12 Jan 2015 00:39:34 +0800 Subject: [PATCH] Bug fixed: focusable, focusableInTouchMode, clickable can't be set in the XML. --- .../MaterialAutoCompleteTextView.java | 25 ++++++++++--------- .../materialedittext/MaterialEditText.java | 25 ++++++++++--------- .../MaterialMultiAutoCompleteTextView.java | 25 ++++++++++--------- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java index b3d91943..484ab1a4 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java @@ -93,7 +93,7 @@ public class MaterialAutoCompleteTextView extends AutoCompleteTextView { /** * the spacing between the main text and the bottom components (bottom ellipsis, helper/error text, characters counter). */ - private final int bottomSpacing; + private int bottomSpacing; /** * whether the floating label should be shown. default is false. @@ -158,7 +158,7 @@ public class MaterialAutoCompleteTextView extends AutoCompleteTextView { /** * bottom ellipsis's height */ - private final int bottomEllipsisSize; + private int bottomEllipsisSize; /** * min bottom lines count. @@ -245,10 +245,10 @@ public class MaterialAutoCompleteTextView extends AutoCompleteTextView { */ private Bitmap[] iconRightBitmaps; - private final int iconSize; - private final int iconOuterWidth; - private final int iconOuterHeight; - private final int iconPadding; + private int iconSize; + private int iconOuterWidth; + private int iconOuterHeight; + private int iconPadding; private ArgbEvaluator focusEvaluator = new ArgbEvaluator(); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); @@ -261,21 +261,22 @@ public class MaterialAutoCompleteTextView extends AutoCompleteTextView { private ArrayList validators = new ArrayList<>(); public MaterialAutoCompleteTextView(Context context) { - this(context, null); + super(context); + init(context, null); } public MaterialAutoCompleteTextView(Context context, AttributeSet attrs) { - this(context, attrs, 0); + super(context, attrs); + init(context, attrs); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public MaterialAutoCompleteTextView(Context context, AttributeSet attrs, int style) { super(context, attrs, style); + init(context, attrs); + } - setFocusable(true); - setFocusableInTouchMode(true); - setClickable(true); - + private void init(Context context, AttributeSet attrs) { iconSize = getPixel(32); iconOuterWidth = getPixel(48); iconOuterHeight = getPixel(32); diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 18a8991a..9ac43305 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -93,7 +93,7 @@ public class MaterialEditText extends EditText { /** * the spacing between the main text and the bottom components (bottom ellipsis, helper/error text, characters counter). */ - private final int bottomSpacing; + private int bottomSpacing; /** * whether the floating label should be shown. default is false. @@ -158,7 +158,7 @@ public class MaterialEditText extends EditText { /** * bottom ellipsis's height */ - private final int bottomEllipsisSize; + private int bottomEllipsisSize; /** * min bottom lines count. @@ -245,10 +245,10 @@ public class MaterialEditText extends EditText { */ private Bitmap[] iconRightBitmaps; - private final int iconSize; - private final int iconOuterWidth; - private final int iconOuterHeight; - private final int iconPadding; + private int iconSize; + private int iconOuterWidth; + private int iconOuterHeight; + private int iconPadding; private ArgbEvaluator focusEvaluator = new ArgbEvaluator(); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); @@ -261,21 +261,22 @@ public class MaterialEditText extends EditText { private ArrayList validators = new ArrayList<>(); public MaterialEditText(Context context) { - this(context, null); + super(context); + init(context, null); } public MaterialEditText(Context context, AttributeSet attrs) { - this(context, attrs, 0); + super(context, attrs); + init(context, attrs); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public MaterialEditText(Context context, AttributeSet attrs, int style) { super(context, attrs, style); + init(context, attrs); + } - setFocusable(true); - setFocusableInTouchMode(true); - setClickable(true); - + private void init(Context context, AttributeSet attrs) { iconSize = getPixel(32); iconOuterWidth = getPixel(48); iconOuterHeight = getPixel(32); diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java index d365ee14..39631d24 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java @@ -90,7 +90,7 @@ public class MaterialMultiAutoCompleteTextView extends MultiAutoCompleteTextView /** * the spacing between the main text and the bottom components (bottom ellipsis, helper/error text, characters counter). */ - private final int bottomSpacing; + private int bottomSpacing; /** * whether the floating label should be shown. default is false. @@ -155,7 +155,7 @@ public class MaterialMultiAutoCompleteTextView extends MultiAutoCompleteTextView /** * bottom ellipsis's height */ - private final int bottomEllipsisSize; + private int bottomEllipsisSize; /** * min bottom lines count. @@ -242,10 +242,10 @@ public class MaterialMultiAutoCompleteTextView extends MultiAutoCompleteTextView */ private Bitmap[] iconRightBitmaps; - private final int iconSize; - private final int iconOuterWidth; - private final int iconOuterHeight; - private final int iconPadding; + private int iconSize; + private int iconOuterWidth; + private int iconOuterHeight; + private int iconPadding; private ArgbEvaluator focusEvaluator = new ArgbEvaluator(); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); @@ -258,21 +258,22 @@ public class MaterialMultiAutoCompleteTextView extends MultiAutoCompleteTextView private ArrayList validators = new ArrayList<>(); public MaterialMultiAutoCompleteTextView(Context context) { - this(context, null); + super(context); + init(context, null); } public MaterialMultiAutoCompleteTextView(Context context, AttributeSet attrs) { - this(context, attrs, 0); + super(context, attrs); + init(context, attrs); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public MaterialMultiAutoCompleteTextView(Context context, AttributeSet attrs, int style) { super(context, attrs, style); + init(context, attrs); + } - setFocusable(true); - setFocusableInTouchMode(true); - setClickable(true); - + private void init(Context context, AttributeSet attrs) { iconSize = getPixel(32); iconOuterWidth = getPixel(48); iconOuterHeight = getPixel(32);