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