mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-07-23 11:39:15 +00:00
Replaced all onBackPressed
usages (bitfireAT/davx5#406)
* Replaced all `onBackPressed` usages Signed-off-by: Arnau Mora <arnyminerz@proton.me> * Added missing finish Signed-off-by: Arnau Mora <arnyminerz@proton.me> * Added more finish statements Signed-off-by: Arnau Mora <arnyminerz@proton.me> --------- Signed-off-by: Arnau Mora <arnyminerz@proton.me>
This commit is contained in:
parent
3da48ab3a2
commit
4ce6fcbf44
|
@ -12,6 +12,7 @@ import android.content.pm.ShortcutManager
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
@ -80,6 +81,14 @@ class AccountsActivity: AppCompatActivity(), NavigationView.OnNavigationItemSele
|
|||
binding.navView.setNavigationItemSelectedListener(this)
|
||||
binding.navView.itemIconTintList = null
|
||||
|
||||
onBackPressedDispatcher.addCallback(this) {
|
||||
if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
|
||||
binding.drawerLayout.closeDrawer(GravityCompat.START)
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
// handle "Sync all" intent from launcher shortcut
|
||||
if (savedInstanceState == null && intent.action == Intent.ACTION_SYNC)
|
||||
syncAllAccounts()
|
||||
|
@ -90,13 +99,6 @@ class AccountsActivity: AppCompatActivity(), NavigationView.OnNavigationItemSele
|
|||
accountsDrawerHandler.initMenu(this, binding.navView.menu)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (binding.drawerLayout.isDrawerOpen(GravityCompat.START))
|
||||
binding.drawerLayout.closeDrawer(GravityCompat.START)
|
||||
else
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onNavigationItemSelected(item: MenuItem): Boolean {
|
||||
accountsDrawerHandler.onNavigationItemSelected(this, item)
|
||||
binding.drawerLayout.closeDrawer(GravityCompat.START)
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import at.bitfire.davdroid.R
|
||||
|
@ -63,6 +64,15 @@ class IntroActivity: AppIntro2() {
|
|||
|
||||
setBarColor(ResourcesCompat.getColor(resources, R.color.primaryDarkColor, null))
|
||||
isSkipButtonEnabled = false
|
||||
|
||||
onBackPressedDispatcher.addCallback(this) {
|
||||
if (currentSlide == 0) {
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
} else {
|
||||
goToPreviousSlide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
|
@ -70,12 +80,6 @@ class IntroActivity: AppIntro2() {
|
|||
currentSlide = position
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (currentSlide == 0)
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onDonePressed(currentFragment: Fragment?) {
|
||||
super.onDonePressed(currentFragment)
|
||||
setResult(Activity.RESULT_OK)
|
||||
|
|
Loading…
Reference in a new issue