show asterisks at inserting pin

This commit is contained in:
tibbi 2017-08-01 22:18:12 +02:00
parent 16a5637d71
commit 2684fde107
2 changed files with 27 additions and 13 deletions

View file

@ -7,33 +7,45 @@ import com.simplemobiletools.commons.extensions.updateTextColors
import kotlinx.android.synthetic.main.tab_pin.view.* import kotlinx.android.synthetic.main.tab_pin.view.*
class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) { class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) {
var pin = ""
override fun onFinishInflate() { override fun onFinishInflate() {
super.onFinishInflate() super.onFinishInflate()
context.updateTextColors(pin_lock_holder) context.updateTextColors(pin_lock_holder)
pin_0.setOnClickListener { addNumber(0) } pin_0.setOnClickListener { addNumber("0") }
pin_1.setOnClickListener { addNumber(1) } pin_1.setOnClickListener { addNumber("1") }
pin_2.setOnClickListener { addNumber(2) } pin_2.setOnClickListener { addNumber("2") }
pin_3.setOnClickListener { addNumber(3) } pin_3.setOnClickListener { addNumber("3") }
pin_4.setOnClickListener { addNumber(4) } pin_4.setOnClickListener { addNumber("4") }
pin_5.setOnClickListener { addNumber(5) } pin_5.setOnClickListener { addNumber("5") }
pin_6.setOnClickListener { addNumber(6) } pin_6.setOnClickListener { addNumber("6") }
pin_7.setOnClickListener { addNumber(7) } pin_7.setOnClickListener { addNumber("7") }
pin_8.setOnClickListener { addNumber(8) } pin_8.setOnClickListener { addNumber("8") }
pin_9.setOnClickListener { addNumber(9) } pin_9.setOnClickListener { addNumber("9") }
pin_c.setOnClickListener { clear() } pin_c.setOnClickListener { clear() }
pin_ok.setOnClickListener { confirmPIN() } pin_ok.setOnClickListener { confirmPIN() }
} }
private fun addNumber(number: Int) { private fun addNumber(number: String) {
if (pin.length < 10) {
pin += number
updatePinCode()
}
} }
private fun clear() { private fun clear() {
if (pin.isNotEmpty()) {
pin = pin.substring(0, pin.length - 1)
updatePinCode()
}
} }
private fun confirmPIN() { private fun confirmPIN() {
} }
private fun updatePinCode() {
pin_lock_current_pin.text = "*".repeat(pin.length)
}
} }

View file

@ -22,6 +22,8 @@
android:layout_below="@+id/pin_lock_title" android:layout_below="@+id/pin_lock_title"
android:gravity="center" android:gravity="center"
android:letterSpacing="1.05" android:letterSpacing="1.05"
android:lines="1"
android:maxLength="10"
android:paddingBottom="@dimen/small_margin" android:paddingBottom="@dimen/small_margin"
android:paddingTop="@dimen/small_margin" android:paddingTop="@dimen/small_margin"
android:textSize="@dimen/big_text_size"/> android:textSize="@dimen/big_text_size"/>