alphamu / PinEntryEditText

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

textVisiblePassword inputType #69

Open adelpuva opened 4 years ago

adelpuva commented 4 years ago
android:inputType="textVisiblePassword"

doesn't work, the characters remain hidden.I need them for a keyboard with characters and numbers.

I fixed it this way:

package com.mypackage

import android.content.Context
import android.util.AttributeSet

class PinEntryEditText : com.alimuzaffar.lib.pin.PinEntryEditText {
    constructor(context: Context?) : super(context)
    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    override fun setInputType(type: Int) {
        super.setInputType(type)
        setMask(null)
    }

}
    <com.mypackage.PinEntryEditText
        android:id="@+id/code"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:cursorVisible="false"
        android:layoutDirection="ltr"
        android:maxLength="10"
        android:textIsSelectable="false"
        app:pinBackgroundDrawable="@drawable/pin_code"
        app:pinCharacterSpacing="4dp"/>
class MyFragment : Fragment() {
       override fun onActivityCreated(state: Bundle?) {
             super.onActivityCreated(savedInstanceState)
             code.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
      }
}