mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-17 04:20:00 +03:00
Login screens: fix regression on Back press
This commit is contained in:
parent
bb1c988a49
commit
29f32cf8eb
1 changed files with 8 additions and 5 deletions
|
@ -39,6 +39,9 @@ abstract class AbstractLoginFragment : VectorBaseFragment(), OnBackPressed {
|
||||||
|
|
||||||
private var isResetPasswordStarted = false
|
private var isResetPasswordStarted = false
|
||||||
|
|
||||||
|
// Due to async, we keep a boolean to avoid displaying twice the cancellation dialog
|
||||||
|
private var displayCancelDialog = true
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
@ -84,13 +87,13 @@ abstract class AbstractLoginFragment : VectorBaseFragment(), OnBackPressed {
|
||||||
|
|
||||||
override fun onBackPressed(toolbarButton: Boolean): Boolean {
|
override fun onBackPressed(toolbarButton: Boolean): Boolean {
|
||||||
return when {
|
return when {
|
||||||
loginViewModel.isRegistrationStarted -> {
|
displayCancelDialog && loginViewModel.isRegistrationStarted -> {
|
||||||
// Ask for confirmation before cancelling the registration
|
// Ask for confirmation before cancelling the registration
|
||||||
AlertDialog.Builder(requireActivity())
|
AlertDialog.Builder(requireActivity())
|
||||||
.setTitle(R.string.login_signup_cancel_confirmation_title)
|
.setTitle(R.string.login_signup_cancel_confirmation_title)
|
||||||
.setMessage(R.string.login_signup_cancel_confirmation_content)
|
.setMessage(R.string.login_signup_cancel_confirmation_content)
|
||||||
.setPositiveButton(R.string.yes) { _, _ ->
|
.setPositiveButton(R.string.yes) { _, _ ->
|
||||||
resetViewModel()
|
displayCancelDialog = false
|
||||||
vectorBaseActivity.onBackPressed()
|
vectorBaseActivity.onBackPressed()
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.no, null)
|
.setNegativeButton(R.string.no, null)
|
||||||
|
@ -98,13 +101,13 @@ abstract class AbstractLoginFragment : VectorBaseFragment(), OnBackPressed {
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
isResetPasswordStarted -> {
|
displayCancelDialog && isResetPasswordStarted -> {
|
||||||
// Ask for confirmation before cancelling the reset password
|
// Ask for confirmation before cancelling the reset password
|
||||||
AlertDialog.Builder(requireActivity())
|
AlertDialog.Builder(requireActivity())
|
||||||
.setTitle(R.string.login_reset_password_cancel_confirmation_title)
|
.setTitle(R.string.login_reset_password_cancel_confirmation_title)
|
||||||
.setMessage(R.string.login_reset_password_cancel_confirmation_content)
|
.setMessage(R.string.login_reset_password_cancel_confirmation_content)
|
||||||
.setPositiveButton(R.string.yes) { _, _ ->
|
.setPositiveButton(R.string.yes) { _, _ ->
|
||||||
resetViewModel()
|
displayCancelDialog = false
|
||||||
vectorBaseActivity.onBackPressed()
|
vectorBaseActivity.onBackPressed()
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.no, null)
|
.setNegativeButton(R.string.no, null)
|
||||||
|
@ -112,7 +115,7 @@ abstract class AbstractLoginFragment : VectorBaseFragment(), OnBackPressed {
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
resetViewModel()
|
resetViewModel()
|
||||||
// Do not consume the Back event
|
// Do not consume the Back event
|
||||||
false
|
false
|
||||||
|
|
Loading…
Add table
Reference in a new issue