Skip to content

Commit

Permalink
Merge pull request #12127 from nextcloud/bugfix/add-account-back-butt…
Browse files Browse the repository at this point in the history
…on-crash

Fix Crash When User Tap Back Button From Add Account Page
  • Loading branch information
AndyScherzinger authored Nov 9, 2023
2 parents 7b546e3 + 81f6531 commit 051c36a
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,21 @@ class FirstRunActivity : BaseActivity(), ViewPager.OnPageChangeListener, Injecta
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
onFinish()
val isFromAddAccount = intent.getBooleanExtra(EXTRA_ALLOW_CLOSE, false)

if (intent.getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
onBackPressedDispatcher.onBackPressed()
val destination: Intent = if (isFromAddAccount) {
Intent(applicationContext, FileDisplayActivity::class.java)
} else {
val intent = Intent(applicationContext, AuthenticatorActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
intent.putExtra(EXTRA_EXIT, true)
startActivity(intent)
finish()
Intent(applicationContext, AuthenticatorActivity::class.java)
}

if (!isFromAddAccount) {
destination.putExtra(EXTRA_EXIT, true)
}

destination.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(destination)
finish()
}
}
)
Expand Down

0 comments on commit 051c36a

Please sign in to comment.