Skip to content

Commit 1a2acc6

Browse files
committed
refactor: migrate away from deprecated onBackPressed()
1 parent 6e4a3f0 commit 1a2acc6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class MainActivity : SimpleActivity(), CanvasListener {
238238
}
239239
}
240240

241-
override fun onBackPressed() {
241+
override fun onBackPressedCompat(): Boolean {
242242
val hasUnsavedChanges = savedPathsHash != binding.myCanvas.getDrawingHashCode()
243243
if (hasUnsavedChanges && System.currentTimeMillis() - lastSavePromptTS > SAVE_DISCARD_PROMPT_INTERVAL) {
244244
lastSavePromptTS = System.currentTimeMillis()
@@ -252,12 +252,12 @@ class MainActivity : SimpleActivity(), CanvasListener {
252252
if (it) {
253253
trySaveImage()
254254
} else {
255-
super.onBackPressed()
255+
performDefaultBack()
256256
}
257257
}
258-
} else {
259-
super.onBackPressed()
258+
return true
260259
}
260+
return false
261261
}
262262

263263
private fun launchSettings() {

0 commit comments

Comments
 (0)