diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/views/PinTab.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/views/PinTab.kt index b8eef638e..a800834fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/views/PinTab.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/views/PinTab.kt @@ -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) + } } diff --git a/app/src/main/res/layout/tab_pin.xml b/app/src/main/res/layout/tab_pin.xml index 125bb7579..9645647ae 100644 --- a/app/src/main/res/layout/tab_pin.xml +++ b/app/src/main/res/layout/tab_pin.xml @@ -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"/>