alphamu / PinEntryEditText

An EditText that looks like a pin entry field. It is highly customisable and even animated text.
Apache License 2.0
669 stars 137 forks source link

Improvement: add state "Has text but not focused" #33

Closed ildar2 closed 6 years ago

ildar2 commented 6 years ago

In updateDrawableState change:

mPinBackground.setState(new int[]{-android.R.attr.state_focused});

to:

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});
}

in bottom else statement. It will allow "Has text but not focused" background drawable state like this:

     <!--Space contains text and not focused -->
    <item android:state_checked="true" android:state_focused="false">
        <shape android:shape="oval">
            <padding android:bottom="@dimen/sms_padding" android:left="@dimen/sms_padding" android:right="@dimen/sms_padding" android:top="@dimen/sms_padding" />
            <solid android:color="@color/transparent" />
        </shape>
    </item>

For now we have to override PinEntryEditText and modify updateDrawableState() method

alphamu commented 6 years ago

I'll add it to the next release.