[UI/Login] Fix back button not working on Login Chooser.

This commit is contained in:
Kuba Szczodrzyński 2020-01-06 15:56:23 +01:00
parent 5a77c481a2
commit 45753583ee

View File

@ -39,22 +39,22 @@ class LoginActivity : AppCompatActivity(), CoroutineScope {
val loginStores = mutableListOf<LoginStore>() val loginStores = mutableListOf<LoginStore>()
override fun onBackPressed() { override fun onBackPressed() {
val destination = nav.currentDestination val destination = nav.currentDestination ?: run {
if (destination != null && destination.id == R.id.loginSyncErrorFragment) { nav.navigateUp()
return return
} }
if (destination != null && destination.id == R.id.loginProgressFragment) { if (destination.id == R.id.loginSyncErrorFragment)
return return
} if (destination.id == R.id.loginProgressFragment)
if (destination != null && destination.id == R.id.loginSyncFragment) {
return return
} if (destination.id == R.id.loginSyncFragment)
if (destination != null && destination.id == R.id.loginChooserFragment && !app.config.loginFinished) { return
if (destination.id == R.id.loginChooserFragment) {
setResult(Activity.RESULT_CANCELED) setResult(Activity.RESULT_CANCELED)
finish() finish()
return return
} }
if (destination != null && destination.id == R.id.loginSummaryFragment) { if (destination.id == R.id.loginSummaryFragment) {
MaterialAlertDialogBuilder(this) MaterialAlertDialogBuilder(this)
.setTitle(R.string.are_you_sure) .setTitle(R.string.are_you_sure)
.setMessage(R.string.login_cancel_confirmation) .setMessage(R.string.login_cancel_confirmation)