Skip to content

Commit 3041bdf

Browse files
committed
refactor: migrate away from deprecated onBackPressed()
1 parent 53166b6 commit 3041bdf

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,21 @@ class CallActivity : SimpleActivity() {
108108
}
109109
}
110110

111-
override fun onBackPressed() {
111+
override fun onBackPressedCompat(): Boolean {
112112
if (binding.dialpadWrapper.isVisible()) {
113113
hideDialpad()
114-
return
115-
} else {
116-
super.onBackPressed()
114+
return true
117115
}
118116

119117
val callState = CallManager.getState()
120118
if (callState == Call.STATE_CONNECTING || callState == Call.STATE_DIALING) {
121119
toast(R.string.call_is_being_connected)
120+
// Allow user to go back but show toast - they can return to call via notification
121+
return false
122122
}
123+
124+
// Allow minimizing active call - user can return via notification
125+
return false
123126
}
124127

125128
private fun initButtons() = binding.apply {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ class MainActivity : SimpleActivity() {
174174
refreshItems()
175175
}
176176

177-
override fun onBackPressed() {
178-
if (binding.mainMenu.isSearchOpen) {
177+
override fun onBackPressedCompat(): Boolean {
178+
return if (binding.mainMenu.isSearchOpen) {
179179
binding.mainMenu.closeSearch()
180+
true
180181
} else {
181-
super.onBackPressed()
182+
false
182183
}
183184
}
184185

0 commit comments

Comments
 (0)