Skip to content

Commit

Permalink
Merge pull request rengwuxian#203 from Ron-Cai/floatingLabel
Browse files Browse the repository at this point in the history
Fix a bug where the focused floating label would keep the highlighted color even if the EditText is disabled
  • Loading branch information
rengwuxian committed Dec 30, 2015
2 parents 85da594 + a75c149 commit 826ff8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand Down

0 comments on commit 826ff8e

Please sign in to comment.