aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt14
-rw-r--r--app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt12
2 files changed, 11 insertions, 15 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt b/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt
index 24cd8bbd..5a7b9dc6 100644
--- a/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt
+++ b/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt
@@ -13,6 +13,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.MenuItem.OnActionExpandListener
import android.view.WindowManager
+import androidx.activity.addCallback
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
import androidx.activity.viewModels
import androidx.appcompat.widget.SearchView
@@ -214,6 +215,9 @@ class PasswordStore : BaseGitActivity() {
override fun onStart() {
super.onStart()
refreshPasswordList()
+ onBackPressedDispatcher.addCallback {
+ isEnabled = getPasswordFragment()?.onBackPressedInActivity() == true
+ }
}
override fun onResume() {
@@ -315,20 +319,12 @@ class PasswordStore : BaseGitActivity() {
}
}
R.id.refresh -> refreshPasswordList()
- android.R.id.home -> {
- @Suppress("DEPRECATION") onBackPressed()
- }
+ android.R.id.home -> onBackPressedDispatcher.onBackPressed()
else -> return super.onOptionsItemSelected(item)
}
return true
}
- @Deprecated("Deprecated in Java")
- @Suppress("DEPRECATION")
- override fun onBackPressed() {
- if (getPasswordFragment()?.onBackPressedInActivity() != true) super.onBackPressed()
- }
-
private fun getPasswordFragment(): PasswordFragment? {
return supportFragmentManager.findFragmentByTag(PASSWORD_FRAGMENT_TAG) as? PasswordFragment
}
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 30e2b1b0..a2b078e0 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.addCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.BundleCompat
import app.passwordstore.R
@@ -95,6 +96,11 @@ class SettingsActivity : AppCompatActivity() {
binding.preferenceRecyclerView.adapter = adapter
}
+ override fun onStart() {
+ super.onStart()
+ onBackPressedDispatcher.addCallback { isEnabled = !preferencesAdapter.goBack() }
+ }
+
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelable("adapter", preferencesAdapter.getSavedState())
@@ -111,10 +117,4 @@ class SettingsActivity : AppCompatActivity() {
else -> super.onOptionsItemSelected(item)
}
}
-
- @Deprecated("Deprecated in Java")
- @Suppress("DEPRECATION")
- override fun onBackPressed() {
- if (!preferencesAdapter.goBack()) super.onBackPressed()
- }
}