From a10a8cd8365f95e407fa8393518a20de20c08b0e Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Sat, 16 Feb 2019 16:58:36 -0600 Subject: [PATCH] Added the verification of the Pattern security lock option, before changing the current Security Lock or viewing the BrainKey in the Settings, when Pattern is the current security lock. --- .../fragments/PatternSecurityLockDialog.kt | 20 +++++++++++++++---- .../layout/dialog_pattern_security_lock.xml | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt index 5b7f38f..bb19ec2 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt @@ -42,15 +42,16 @@ class PatternSecurityLockDialog : BaseSecurityLockDialog() { private val mPatternLockViewListener = object : PatternLockViewListener { override fun onStarted() { // Make sure the button is hidden when the user starts a new pattern when it was incorrect - btnClear.visibility = View.INVISIBLE when (currentStep) { STEP_SECURITY_LOCK_VERIFY -> { - // Do something + tvMessage.text = "" } STEP_SECURITY_LOCK_CREATE -> { + btnClear.visibility = View.INVISIBLE tvMessage.text = getString(R.string.msg__release_finger) } STEP_SECURITY_LOCK_CONFIRM -> { + btnClear.visibility = View.INVISIBLE tvMessage.text = getString(R.string.msg__release_finger) } } @@ -62,7 +63,16 @@ class PatternSecurityLockDialog : BaseSecurityLockDialog() { override fun onComplete(pattern: List) { if (currentStep == STEP_SECURITY_LOCK_VERIFY) { - // Do something + context?.let { + val encryptedPattern = CryptoUtils.encrypt(it, getStringPattern(pattern)).trim() + if (encryptedPattern == currentEncryptedPINPattern) { + // Pattern is correct, proceed + dismiss() + mCallback?.onPINPatternEntered(actionIdentifier) + } else { + tvMessage.text = getString(R.string.error__wront_pattern) + } + } } else if (currentStep == STEP_SECURITY_LOCK_CREATE) { btnClear.visibility = View.VISIBLE if (pattern.size < 4) { @@ -128,7 +138,9 @@ class PatternSecurityLockDialog : BaseSecurityLockDialog() { STEP_SECURITY_LOCK_VERIFY -> { tvTitle.text = getString(R.string.title__re_enter_your_pattern) tvSubTitle.text = getString(R.string.msg__enter_your_pattern) - btnClear.visibility = View.INVISIBLE + btnClear.visibility = View.GONE + btnNext.visibility = View.GONE + patternLockView.isInStealthMode = true } STEP_SECURITY_LOCK_CREATE -> { tvTitle.text = getString(R.string.title__set_bitsy_screen_lock) diff --git a/app/src/main/res/layout/dialog_pattern_security_lock.xml b/app/src/main/res/layout/dialog_pattern_security_lock.xml index 0a67902..b74c3ae 100644 --- a/app/src/main/res/layout/dialog_pattern_security_lock.xml +++ b/app/src/main/res/layout/dialog_pattern_security_lock.xml @@ -59,6 +59,8 @@ app:normalStateColor="?android:textColorSecondary" app:correctStateColor="@color/colorPrimary" app:wrongStateColor="@color/colorSend" + app:dotNormalSize="12dp" + app:dotSelectedSize="16dp" app:layout_constraintDimensionRatio="h,1:1" app:layout_constraintTop_toBottomOf="@id/tvMessage" app:layout_constraintBottom_toTopOf="@id/btnClear"