VERY experimental Nintendo Switch 2 emulator
C++
android: Replace deprecated and Java code
Abandoned Cartb360aa794e9b
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.ktindex 81474b8246..1382ae29f8 100644--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt@@ -5,7 +5,6 @@ package org.yuzu.yuzu_emu.activitiesimport android.app.Activityimport android.content.Context-import android.content.DialogInterfaceimport android.content.Intentimport android.content.res.Configurationimport android.graphics.Rect@@ -13,22 +12,22 @@ import android.hardware.Sensorimport android.hardware.SensorEventimport android.hardware.SensorEventListenerimport android.hardware.SensorManager+import android.hardware.display.DisplayManagerimport android.os.Bundle+import android.view.Displayimport android.view.InputDeviceimport android.view.KeyEventimport android.view.MotionEventimport android.view.Surfaceimport android.view.View-import android.view.WindowManagerimport android.view.inputmethod.InputMethodManagerimport androidx.appcompat.app.AppCompatActivity-import androidx.preference.PreferenceManager-import com.google.android.material.dialog.MaterialAlertDialogBuilder-import com.google.android.material.slider.Slider.OnChangeListener+import androidx.core.content.getSystemService+import androidx.core.view.WindowCompat+import androidx.core.view.WindowInsetsCompat+import androidx.core.view.WindowInsetsControllerCompatimport org.yuzu.yuzu_emu.NativeLibraryimport org.yuzu.yuzu_emu.R-import org.yuzu.yuzu_emu.databinding.DialogSliderBinding-import org.yuzu.yuzu_emu.features.settings.model.Settingsimport org.yuzu.yuzu_emu.fragments.EmulationFragmentimport org.yuzu.yuzu_emu.model.Gameimport org.yuzu.yuzu_emu.utils.ControllerMappingHelper@@ -44,7 +43,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {private var controllerMappingHelper: ControllerMappingHelper? = nullvar isActivityRecreated = false- private var menuVisible = falseprivate var emulationFragment: EmulationFragment? = nullprivate lateinit var nfcReader: NfcReaderprivate lateinit var inputHandler: InputHandler@@ -241,20 +239,20 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {override fun onAccuracyChanged(sensor: Sensor, i: Int) {}private fun getAdjustedRotation():Int {- val rotation = windowManager.defaultDisplay.rotation;+ val rotation = getSystemService<DisplayManager>()!!.getDisplay(Display.DEFAULT_DISPLAY).rotationval config: Configuration = resources.configurationif ((config.screenLayout and Configuration.SCREENLAYOUT_LONG_YES) != 0 ||(config.screenLayout and Configuration.SCREENLAYOUT_LONG_NO) == 0) {- return rotation;+ return rotation}when (rotation) {- Surface.ROTATION_0 -> return Surface.ROTATION_90;- Surface.ROTATION_90 -> return Surface.ROTATION_0;- Surface.ROTATION_180 -> return Surface.ROTATION_270;- Surface.ROTATION_270 -> return Surface.ROTATION_180;+ Surface.ROTATION_0 -> return Surface.ROTATION_90+ Surface.ROTATION_90 -> return Surface.ROTATION_0+ Surface.ROTATION_180 -> return Surface.ROTATION_270+ Surface.ROTATION_270 -> return Surface.ROTATION_180}- return rotation;+ return rotation}private fun restoreState(savedInstanceState: Bundle) {@@ -262,18 +260,13 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {}private fun enableFullscreenImmersive() {- window.attributes.layoutInDisplayCutoutMode =- WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES-- window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)-- // It would be nice to use IMMERSIVE_STICKY, but that doesn't show the toolbar.- window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or- View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or- View.SYSTEM_UI_FLAG_FULLSCREEN or- View.SYSTEM_UI_FLAG_IMMERSIVE+ WindowCompat.setDecorFitsSystemWindows(window, false)++ WindowInsetsControllerCompat(window, window.decorView).let { controller ->+ controller.hide(WindowInsetsCompat.Type.systemBars())+ controller.systemBarsBehavior =+ WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE+ }}private fun startMotionSensorListener() {