mukeshsolanki / android-otpview-pinview

A custom view to enter otp of different sizes used usually in cases of authentication.
MIT License
699 stars 207 forks source link

Box state does not reflect full EditText state #123

Closed lsuski closed 2 years ago

lsuski commented 3 years ago

Subject of the issue

currently there is no way to achieve this (or I can't do this)

  <item android:color="@color/text_input_box_active_color" app:OtpState_filled="true" android:state_selected="true"/>
    <item android:color="@color/text_input_box_inactive_color" app:OtpState_filled="true" android:state_selected="false"/>

or

  <item android:color="@color/text_input_box_active_color" app:OtpState_filled="true" android:state_focused="true"/>
    <item android:color="@color/text_input_box_inactive_color" app:OtpState_filled="true" android:state_focused="false"/>

I just want to differentiate box state based on focused/selected state - when user is writing to the box and when the entire otp input is not focused but

Steps to reproduce

Tell us how to reproduce this issue. Please provide a working demo.

Expected behaviour

 boolean itemSelected = isFocused() && nextItemToFill == i;
      boolean itemFilled = i < nextItemToFill;
      int[] itemState = null;
      if (itemFilled) {
        itemState = FILLED_STATE;
      } else if (itemSelected) {
        itemState = SELECTED_STATE;
      }
      paint.setColor(itemState != null ? getLineColorForState(itemState) : cursorLineColor);

this code should also consider entire input state

mukeshsolanki commented 2 years ago

This is something that we dont currently support. But feel free to create a pr for this.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.