From 96d01e7a4213cab0bcd49a0d8e81d5912fc2b43c Mon Sep 17 00:00:00 2001 From: Ron Cai Date: Fri, 5 Jun 2015 00:19:07 -0400 Subject: [PATCH 1/2] Fix a bug where the focused floating label would keep the highlighted color even if the EditText is disabled --- .../com/rengwuxian/materialedittext/MaterialEditText.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 06a8bf6f..dc9ec37d 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -1357,7 +1357,7 @@ protected void onDraw(@NonNull Canvas canvas) { if (floatingLabelEnabled && !TextUtils.isEmpty(floatingLabelText)) { textPaint.setTextSize(floatingLabelTextSize); // calculate the text color - textPaint.setColor((Integer) focusEvaluator.evaluate(focusFraction, floatingLabelTextColor != -1 ? floatingLabelTextColor : (baseColor & 0x00ffffff | 0x44000000), primaryColor)); + textPaint.setColor((Integer) focusEvaluator.evaluate(focusFraction * (isEnabled() ? 1 : 0), floatingLabelTextColor != -1 ? floatingLabelTextColor : (baseColor & 0x00ffffff | 0x44000000), primaryColor)); // calculate the horizontal position float floatingLabelWidth = textPaint.measureText(floatingLabelText.toString()); @@ -1375,7 +1375,7 @@ protected void onDraw(@NonNull Canvas canvas) { int floatingLabelStartY = (int) (innerPaddingTop + floatingLabelTextSize + floatingLabelPadding - distance * (floatingLabelAlwaysShown ? 1 : floatingLabelFraction) + getScrollY()); // calculate the alpha - int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * focusFraction + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); + int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * focusFraction * (isEnabled() ? 1 : 0) + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); textPaint.setAlpha(alpha); // draw the floating label From a75c1491648022771cc7b0e29505d3d7be0287a3 Mon Sep 17 00:00:00 2001 From: Ron Cai Date: Sun, 7 Jun 2015 17:32:26 -0400 Subject: [PATCH 2/2] Add fix for AutoComplete & MultiAutoComplete TextView --- .../materialedittext/MaterialAutoCompleteTextView.java | 4 ++-- .../materialedittext/MaterialMultiAutoCompleteTextView.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java index 42ed6960..6674f565 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java @@ -1357,7 +1357,7 @@ protected void onDraw(@NonNull Canvas canvas) { if (floatingLabelEnabled && !TextUtils.isEmpty(floatingLabelText)) { textPaint.setTextSize(floatingLabelTextSize); // calculate the text color - textPaint.setColor((Integer) focusEvaluator.evaluate(focusFraction, floatingLabelTextColor != -1 ? floatingLabelTextColor : (baseColor & 0x00ffffff | 0x44000000), primaryColor)); + textPaint.setColor((Integer) focusEvaluator.evaluate(focusFraction * (isEnabled() ? 1 : 0), floatingLabelTextColor != -1 ? floatingLabelTextColor : (baseColor & 0x00ffffff | 0x44000000), primaryColor)); // calculate the horizontal position float floatingLabelWidth = textPaint.measureText(floatingLabelText.toString()); @@ -1375,7 +1375,7 @@ protected void onDraw(@NonNull Canvas canvas) { int floatingLabelStartY = (int) (innerPaddingTop + floatingLabelTextSize + floatingLabelPadding - distance * (floatingLabelAlwaysShown ? 1 : floatingLabelFraction) + getScrollY()); // calculate the alpha - int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * focusFraction + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); + int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * focusFraction * (isEnabled() ? 1 : 0) + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); textPaint.setAlpha(alpha); // draw the floating label diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java index 9311924c..71f6ca67 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java @@ -1354,7 +1354,7 @@ protected void onDraw(@NonNull Canvas canvas) { if (floatingLabelEnabled && !TextUtils.isEmpty(floatingLabelText)) { textPaint.setTextSize(floatingLabelTextSize); // calculate the text color - textPaint.setColor((Integer) focusEvaluator.evaluate(focusFraction, floatingLabelTextColor != -1 ? floatingLabelTextColor : (baseColor & 0x00ffffff | 0x44000000), primaryColor)); + textPaint.setColor((Integer) focusEvaluator.evaluate(focusFraction * (isEnabled() ? 1 : 0), floatingLabelTextColor != -1 ? floatingLabelTextColor : (baseColor & 0x00ffffff | 0x44000000), primaryColor)); // calculate the horizontal position float floatingLabelWidth = textPaint.measureText(floatingLabelText.toString()); @@ -1372,7 +1372,7 @@ protected void onDraw(@NonNull Canvas canvas) { int floatingLabelStartY = (int) (innerPaddingTop + floatingLabelTextSize + floatingLabelPadding - distance * (floatingLabelAlwaysShown ? 1 : floatingLabelFraction) + getScrollY()); // calculate the alpha - int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * focusFraction + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); + int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * focusFraction * (isEnabled() ? 1 : 0) + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); textPaint.setAlpha(alpha); // draw the floating label