diff options
-rw-r--r-- | app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt b/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt index 508120ce..7c9d8e8b 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt @@ -7,6 +7,7 @@ package app.passwordstore.ui.settings import android.os.Bundle import android.view.MenuItem +import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity import androidx.core.os.BundleCompat import app.passwordstore.R @@ -80,9 +81,17 @@ class SettingsActivity : AppCompatActivity() { pgpSettings.provideSettings(this) } } + val backPressedCallback = + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + preferencesAdapter.goBack() + } + } + onBackPressedDispatcher.addCallback(backPressedCallback) val adapter = PreferencesAdapter(screen) adapter.onScreenChangeListener = PreferencesAdapter.OnScreenChangeListener { subScreen, entering -> + backPressedCallback.isEnabled = entering supportActionBar?.title = if (!entering) { getString(R.string.action_settings) @@ -117,10 +126,4 @@ class SettingsActivity : AppCompatActivity() { else -> super.onOptionsItemSelected(item) } } - - @Deprecated("Deprecated in Java") - @Suppress("DEPRECATION") - override fun onBackPressed() { - if (!preferencesAdapter.goBack()) super.onBackPressed() - } } |