Skip to content

Commit

Permalink
fix-#2104-Unable-to-login-after-clicking-on-the-cancel-button
Browse files Browse the repository at this point in the history
  • Loading branch information
vyukti13 committed Jul 28, 2023
1 parent d85a0de commit b2d6166
Showing 1 changed file with 35 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import androidx.core.widget.NestedScrollView
import butterknife.BindView
import butterknife.ButterKnife
import com.mifos.mobile.passcode.MifosPassCodeActivity
import com.mifos.mobile.passcode.MifosPassCodeView
import com.mifos.mobile.passcode.utils.EncryptionUtil
import com.mifos.mobile.passcode.utils.PasscodePreferencesHelper
import org.mifos.mobile.R
import org.mifos.mobile.ui.enums.BiometricCapability
import org.mifos.mobile.utils.CheckSelfPermissionAndRequest
Expand All @@ -24,6 +26,11 @@ class PassCodeActivity : MifosPassCodeActivity() {
private var currPassCode: String? = null
private var isToUpdatePassCode: Boolean = false


@JvmField
@BindView(R.id.btn_forgot_passcode)
var forgetPasswordButton: AppCompatButton? = null

@JvmField
@BindView(R.id.btn_save)
var btnSave: AppCompatButton? = null
Expand All @@ -48,6 +55,32 @@ class PassCodeActivity : MifosPassCodeActivity() {
}
setBackgroundColor()

forgetPasswordButton?.setOnClickListener {
MaterialDialog.Builder().init(this@PassCodeActivity)
.setCancelable(false)
.setMessage(R.string.login_using_password_confirmation)
.setPositiveButton(
getString(R.string.logout),
DialogInterface.OnClickListener { _, _ ->
clearTokenPreferences()
val i = Intent(
this@PassCodeActivity,
LoginActivity::class.java,
)
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(i)
finish()
},
)
.setNegativeButton(
getString(R.string.cancel),
) { dialog, _ ->
dialog.dismiss()
}
.createMaterialDialog()
.show()
}

if (btnSave?.text?.equals(getString(R.string.use_touch_id)) == true) {
biometricAuthentication?.authenticateWithBiometrics()
}
Expand All @@ -67,6 +100,7 @@ class PassCodeActivity : MifosPassCodeActivity() {
currPassCode = it.getStringExtra(Constants.CURR_PASSWORD)
isToUpdatePassCode = it.getBooleanExtra(Constants.IS_TO_UPDATE_PASS_CODE, false)
}

}

/**
Expand Down Expand Up @@ -100,27 +134,7 @@ class PassCodeActivity : MifosPassCodeActivity() {
}

override fun startLoginActivity() {
MaterialDialog.Builder().init(this@PassCodeActivity)
.setCancelable(false)
.setMessage(R.string.login_using_password_confirmation)
.setPositiveButton(
getString(R.string.logout),
DialogInterface.OnClickListener { _, _ ->
val i = Intent(
this@PassCodeActivity,
LoginActivity::class.java,
)
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(i)
finish()
},
)
.setNegativeButton(
getString(R.string.cancel),
DialogInterface.OnClickListener { dialog, _ -> dialog.dismiss() },
)
.createMaterialDialog()
.show()
TODO()
}

override fun showToaster(view: View, msg: Int) {
Expand Down

0 comments on commit b2d6166

Please sign in to comment.