Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-#2104-Unable-to-login-after-clicking-on-the-cancel-button #2232

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why TODO() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because earlier the show dialogue box logic was written in this method, so I moved that logic to button click listener and may be in future we could write some appropriate functionality in this overwritten method therefore I mentioned TODO in it

}

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