Skip to content

Commit

Permalink
PinEntryEditText has text button bug not focused added issue #33
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Muzaffar committed Oct 15, 2018
1 parent add221c commit a01ab20
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ attribute in the xml. If you want to specify the empty and filled states using y
you can set the `textColor` to transparent and setup your drawable as follows:

```xml
<!--
Please look at the sample app's bg_pin.xml
or bg_pin_round.xml for all available options
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Space contains text -->
<item android:state_focused="true" android:state_checked="true">
Expand Down Expand Up @@ -146,7 +150,7 @@ you can set the `textColor` to transparent and setup your drawable as follows:
</selector>
```

Note that in this setup, the size of the drawable will be determined by the `textSize` and and the `pinTextBottomPadding`
**Note** that in this setup, the size of the drawable will be determined by the `textSize` and and the `pinTextBottomPadding`
which is the space between the character and the line below (or the bottom of the `pinBackgroundDrawable`).
For good measure, set `pinAnimationType` to none as well.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,11 @@ protected void updateDrawableState(boolean hasText, boolean isNext) {
mPinBackground.setState(new int[]{android.R.attr.state_focused, android.R.attr.state_checked});
}
} else {
mPinBackground.setState(new int[]{-android.R.attr.state_focused});
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});
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions sample-app/src/main/res/drawable/bg_pin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
<solid android:color="@android:color/white" />
</shape>
</item>
<!--Space contains text and not focused -->
<item android:state_focused="false" android:state_checked="true">
<shape android:shape="oval">
<stroke android:width="2dp" android:color="@android:color/holo_green_light" />
<corners android:radius="8dp" />
<solid android:color="@android:color/darker_gray" />
</shape>
</item>
<!-- PinEntryEditText is focused -->
<item android:state_focused="true">
<shape android:shape="rectangle">
Expand Down
7 changes: 7 additions & 0 deletions sample-app/src/main/res/drawable/bg_pin_round.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
<solid android:color="@android:color/white" />
</shape>
</item>
<!--Space contains text and not focused -->
<item android:state_focused="false" android:state_checked="true">
<shape android:shape="oval">
<stroke android:width="1dp" android:color="@android:color/holo_green_light" />
<solid android:color="@android:color/white" />
</shape>
</item>
<!-- PinEntryEditText is focused -->
<item android:state_focused="true">
<shape android:shape="oval">
Expand Down

0 comments on commit a01ab20

Please sign in to comment.