Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ protected void onDraw(Canvas canvas) {
}
//The lines should be in front of the text (because that's how I want it).
if (mPinBackground == null) {
updateColorForLines(i <= textLength);
updateColorForLines(i < textLength, i == textLength);
canvas.drawLine(mLineCoords[i].left, mLineCoords[i].top, mLineCoords[i].right, mLineCoords[i].bottom, mLinesPaint);
}
}
Expand Down Expand Up @@ -416,33 +416,41 @@ private int getColorForState(int... states) {
}

/**
* @param hasTextOrIsNext Is the color for a character that has been typed or is
* the next character to be typed?
* @param hasText Whether this position has text
* @param isNext Whether this position is the next to be typed
*/
protected void updateColorForLines(boolean hasTextOrIsNext) {
protected void updateColorForLines(boolean hasText, boolean isNext) {
if (mHasError) {
mLinesPaint.setColor(getColorForState(android.R.attr.state_active));
} else if (isFocused()) {
mLinesPaint.setStrokeWidth(mLineStrokeSelected);
mLinesPaint.setColor(getColorForState(android.R.attr.state_focused));
if (hasTextOrIsNext) {
mLinesPaint.setColor(getColorForState(android.R.attr.state_selected));
if (isNext) {
mLinesPaint.setColor(getColorForState(android.R.attr.state_focused, android.R.attr.state_selected));
} else if (hasText) {
mLinesPaint.setColor(getColorForState(android.R.attr.state_focused, android.R.attr.state_checked));
} else {
mLinesPaint.setColor(getColorForState(android.R.attr.state_focused));
}
} else {
mLinesPaint.setStrokeWidth(mLineStroke);
mLinesPaint.setColor(getColorForState(-android.R.attr.state_focused));
if (hasText) {
mLinesPaint.setColor(getColorForState(-android.R.attr.state_focused, android.R.attr.state_checked));
} else {
mLinesPaint.setColor(getColorForState(-android.R.attr.state_focused));
}
}
}

protected void updateDrawableState(boolean hasText, boolean isNext) {
if (mHasError) {
mPinBackground.setState(new int[]{android.R.attr.state_active});
} else if (isFocused()) {
mPinBackground.setState(new int[]{android.R.attr.state_focused});
if (isNext) {
mPinBackground.setState(new int[]{android.R.attr.state_focused, android.R.attr.state_selected});
} else if (hasText) {
mPinBackground.setState(new int[]{android.R.attr.state_focused, android.R.attr.state_checked});
} else {
mPinBackground.setState(new int[]{android.R.attr.state_focused});
}
} else {
if (hasText) {
Expand Down