diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | 47 |
1 files changed, 20 insertions, 27 deletions
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.kt index 81474b824..1382ae29f 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.activities | |||
| 5 | 5 | ||
| 6 | import android.app.Activity | 6 | import android.app.Activity |
| 7 | import android.content.Context | 7 | import android.content.Context |
| 8 | import android.content.DialogInterface | ||
| 9 | import android.content.Intent | 8 | import android.content.Intent |
| 10 | import android.content.res.Configuration | 9 | import android.content.res.Configuration |
| 11 | import android.graphics.Rect | 10 | import android.graphics.Rect |
| @@ -13,22 +12,22 @@ import android.hardware.Sensor | |||
| 13 | import android.hardware.SensorEvent | 12 | import android.hardware.SensorEvent |
| 14 | import android.hardware.SensorEventListener | 13 | import android.hardware.SensorEventListener |
| 15 | import android.hardware.SensorManager | 14 | import android.hardware.SensorManager |
| 15 | import android.hardware.display.DisplayManager | ||
| 16 | import android.os.Bundle | 16 | import android.os.Bundle |
| 17 | import android.view.Display | ||
| 17 | import android.view.InputDevice | 18 | import android.view.InputDevice |
| 18 | import android.view.KeyEvent | 19 | import android.view.KeyEvent |
| 19 | import android.view.MotionEvent | 20 | import android.view.MotionEvent |
| 20 | import android.view.Surface | 21 | import android.view.Surface |
| 21 | import android.view.View | 22 | import android.view.View |
| 22 | import android.view.WindowManager | ||
| 23 | import android.view.inputmethod.InputMethodManager | 23 | import android.view.inputmethod.InputMethodManager |
| 24 | import androidx.appcompat.app.AppCompatActivity | 24 | import androidx.appcompat.app.AppCompatActivity |
| 25 | import androidx.preference.PreferenceManager | 25 | import androidx.core.content.getSystemService |
| 26 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | 26 | import androidx.core.view.WindowCompat |
| 27 | import com.google.android.material.slider.Slider.OnChangeListener | 27 | import androidx.core.view.WindowInsetsCompat |
| 28 | import androidx.core.view.WindowInsetsControllerCompat | ||
| 28 | import org.yuzu.yuzu_emu.NativeLibrary | 29 | import org.yuzu.yuzu_emu.NativeLibrary |
| 29 | import org.yuzu.yuzu_emu.R | 30 | import org.yuzu.yuzu_emu.R |
| 30 | import org.yuzu.yuzu_emu.databinding.DialogSliderBinding | ||
| 31 | import org.yuzu.yuzu_emu.features.settings.model.Settings | ||
| 32 | import org.yuzu.yuzu_emu.fragments.EmulationFragment | 31 | import org.yuzu.yuzu_emu.fragments.EmulationFragment |
| 33 | import org.yuzu.yuzu_emu.model.Game | 32 | import org.yuzu.yuzu_emu.model.Game |
| 34 | import org.yuzu.yuzu_emu.utils.ControllerMappingHelper | 33 | import org.yuzu.yuzu_emu.utils.ControllerMappingHelper |
| @@ -44,7 +43,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 44 | private var controllerMappingHelper: ControllerMappingHelper? = null | 43 | private var controllerMappingHelper: ControllerMappingHelper? = null |
| 45 | 44 | ||
| 46 | var isActivityRecreated = false | 45 | var isActivityRecreated = false |
| 47 | private var menuVisible = false | ||
| 48 | private var emulationFragment: EmulationFragment? = null | 46 | private var emulationFragment: EmulationFragment? = null |
| 49 | private lateinit var nfcReader: NfcReader | 47 | private lateinit var nfcReader: NfcReader |
| 50 | private lateinit var inputHandler: InputHandler | 48 | private lateinit var inputHandler: InputHandler |
| @@ -241,20 +239,20 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 241 | override fun onAccuracyChanged(sensor: Sensor, i: Int) {} | 239 | override fun onAccuracyChanged(sensor: Sensor, i: Int) {} |
| 242 | 240 | ||
| 243 | private fun getAdjustedRotation():Int { | 241 | private fun getAdjustedRotation():Int { |
| 244 | val rotation = windowManager.defaultDisplay.rotation; | 242 | val rotation = getSystemService<DisplayManager>()!!.getDisplay(Display.DEFAULT_DISPLAY).rotation |
| 245 | val config: Configuration = resources.configuration | 243 | val config: Configuration = resources.configuration |
| 246 | 244 | ||
| 247 | if ((config.screenLayout and Configuration.SCREENLAYOUT_LONG_YES) != 0 || | 245 | if ((config.screenLayout and Configuration.SCREENLAYOUT_LONG_YES) != 0 || |
| 248 | (config.screenLayout and Configuration.SCREENLAYOUT_LONG_NO) == 0) { | 246 | (config.screenLayout and Configuration.SCREENLAYOUT_LONG_NO) == 0) { |
| 249 | return rotation; | 247 | return rotation |
| 250 | } | 248 | } |
| 251 | when (rotation) { | 249 | when (rotation) { |
| 252 | Surface.ROTATION_0 -> return Surface.ROTATION_90; | 250 | Surface.ROTATION_0 -> return Surface.ROTATION_90 |
| 253 | Surface.ROTATION_90 -> return Surface.ROTATION_0; | 251 | Surface.ROTATION_90 -> return Surface.ROTATION_0 |
| 254 | Surface.ROTATION_180 -> return Surface.ROTATION_270; | 252 | Surface.ROTATION_180 -> return Surface.ROTATION_270 |
| 255 | Surface.ROTATION_270 -> return Surface.ROTATION_180; | 253 | Surface.ROTATION_270 -> return Surface.ROTATION_180 |
| 256 | } | 254 | } |
| 257 | return rotation; | 255 | return rotation |
| 258 | } | 256 | } |
| 259 | 257 | ||
| 260 | private fun restoreState(savedInstanceState: Bundle) { | 258 | private fun restoreState(savedInstanceState: Bundle) { |
| @@ -262,18 +260,13 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 262 | } | 260 | } |
| 263 | 261 | ||
| 264 | private fun enableFullscreenImmersive() { | 262 | private fun enableFullscreenImmersive() { |
| 265 | window.attributes.layoutInDisplayCutoutMode = | 263 | WindowCompat.setDecorFitsSystemWindows(window, false) |
| 266 | WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES | 264 | |
| 267 | 265 | WindowInsetsControllerCompat(window, window.decorView).let { controller -> | |
| 268 | window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) | 266 | controller.hide(WindowInsetsCompat.Type.systemBars()) |
| 269 | 267 | controller.systemBarsBehavior = | |
| 270 | // It would be nice to use IMMERSIVE_STICKY, but that doesn't show the toolbar. | 268 | WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE |
| 271 | window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or | 269 | } |
| 272 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or | ||
| 273 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or | ||
| 274 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or | ||
| 275 | View.SYSTEM_UI_FLAG_FULLSCREEN or | ||
| 276 | View.SYSTEM_UI_FLAG_IMMERSIVE | ||
| 277 | } | 270 | } |
| 278 | 271 | ||
| 279 | private fun startMotionSensorListener() { | 272 | private fun startMotionSensorListener() { |