Skip to content

Commit f04b620

Browse files
committed
refactor: migrate away from deprecated onBackPressed()
1 parent de599de commit f04b620

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ class MainActivity : SimpleActivity() {
341341
}
342342
}
343343

344-
override fun onBackPressed() {
345-
if (!config.autosaveNotes && mAdapter?.anyHasUnsavedChanges() == true) {
344+
override fun onBackPressedCompat(): Boolean {
345+
return if (!config.autosaveNotes && mAdapter?.anyHasUnsavedChanges() == true) {
346346
ConfirmationAdvancedDialog(
347347
activity = this,
348348
message = "",
@@ -354,13 +354,15 @@ class MainActivity : SimpleActivity() {
354354
mAdapter?.saveAllFragmentTexts()
355355
}
356356
appLockManager.lock()
357-
super.onBackPressed()
357+
performDefaultBack()
358358
}
359+
true
359360
} else if (isSearchActive) {
360361
closeSearch()
362+
true
361363
} else {
362364
appLockManager.lock()
363-
super.onBackPressed()
365+
false
364366
}
365367
}
366368

0 commit comments

Comments
 (0)