show asterisks at inserting pin
This commit is contained in:
parent
16a5637d71
commit
2684fde107
2 changed files with 27 additions and 13 deletions
|
@ -7,33 +7,45 @@ import com.simplemobiletools.commons.extensions.updateTextColors
|
|||
import kotlinx.android.synthetic.main.tab_pin.view.*
|
||||
|
||||
class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) {
|
||||
var pin = ""
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
context.updateTextColors(pin_lock_holder)
|
||||
|
||||
pin_0.setOnClickListener { addNumber(0) }
|
||||
pin_1.setOnClickListener { addNumber(1) }
|
||||
pin_2.setOnClickListener { addNumber(2) }
|
||||
pin_3.setOnClickListener { addNumber(3) }
|
||||
pin_4.setOnClickListener { addNumber(4) }
|
||||
pin_5.setOnClickListener { addNumber(5) }
|
||||
pin_6.setOnClickListener { addNumber(6) }
|
||||
pin_7.setOnClickListener { addNumber(7) }
|
||||
pin_8.setOnClickListener { addNumber(8) }
|
||||
pin_9.setOnClickListener { addNumber(9) }
|
||||
pin_0.setOnClickListener { addNumber("0") }
|
||||
pin_1.setOnClickListener { addNumber("1") }
|
||||
pin_2.setOnClickListener { addNumber("2") }
|
||||
pin_3.setOnClickListener { addNumber("3") }
|
||||
pin_4.setOnClickListener { addNumber("4") }
|
||||
pin_5.setOnClickListener { addNumber("5") }
|
||||
pin_6.setOnClickListener { addNumber("6") }
|
||||
pin_7.setOnClickListener { addNumber("7") }
|
||||
pin_8.setOnClickListener { addNumber("8") }
|
||||
pin_9.setOnClickListener { addNumber("9") }
|
||||
pin_c.setOnClickListener { clear() }
|
||||
pin_ok.setOnClickListener { confirmPIN() }
|
||||
}
|
||||
|
||||
private fun addNumber(number: Int) {
|
||||
|
||||
private fun addNumber(number: String) {
|
||||
if (pin.length < 10) {
|
||||
pin += number
|
||||
updatePinCode()
|
||||
}
|
||||
}
|
||||
|
||||
private fun clear() {
|
||||
|
||||
if (pin.isNotEmpty()) {
|
||||
pin = pin.substring(0, pin.length - 1)
|
||||
updatePinCode()
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirmPIN() {
|
||||
|
||||
}
|
||||
|
||||
private fun updatePinCode() {
|
||||
pin_lock_current_pin.text = "*".repeat(pin.length)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
android:layout_below="@+id/pin_lock_title"
|
||||
android:gravity="center"
|
||||
android:letterSpacing="1.05"
|
||||
android:lines="1"
|
||||
android:maxLength="10"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:textSize="@dimen/big_text_size"/>
|
||||
|
|
Loading…
Reference in a new issue