mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 00:24:14 +01:00
onBackPressed
-> onBackPressedDispatcher
This commit is contained in:
parent
bc3c49bc28
commit
b20c6e9fc4
@ -12,6 +12,7 @@
|
||||
|
||||
<application
|
||||
android:name=".SkylineApplication"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:allowBackup="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:fullBackupContent="@xml/backup_descriptor"
|
||||
|
@ -15,6 +15,7 @@ import android.os.*
|
||||
import android.util.Log
|
||||
import android.util.Rational
|
||||
import android.view.*
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.view.isGone
|
||||
@ -202,10 +203,6 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
emulationThread!!.start()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
returnFromEmulation()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
||||
override fun onCreate(savedInstanceState : Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -287,6 +284,16 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
changeAudioStatus(false)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
returnFromEmulation()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
@ -11,6 +11,7 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.DocumentsContract
|
||||
import android.view.View
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@ -308,6 +309,23 @@ class MainActivity : AppCompatActivity() {
|
||||
if (items.isEmpty()) adapter.setItems(listOf(HeaderViewItem(getString(R.string.no_rom))))
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
binding.searchBar.apply {
|
||||
if (hasFocus() && text.isNotEmpty()) {
|
||||
text = ""
|
||||
clearFocus()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
@ -330,15 +348,4 @@ class MainActivity : AppCompatActivity() {
|
||||
adapter.notifyItemRangeChanged(0, adapter.currentItems.size)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
binding.searchBar.apply {
|
||||
if (hasFocus() && text.isNotEmpty()) {
|
||||
text = ""
|
||||
clearFocus()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||
*/
|
||||
override fun onKeyUp(keyCode : Int, event : KeyEvent?) : Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BUTTON_B) {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ class ControllerActivity : AppCompatActivity() {
|
||||
*/
|
||||
override fun onKeyUp(keyCode : Int, event : KeyEvent?) : Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BUTTON_B) {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user