summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt47
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
6import android.app.Activity 6import android.app.Activity
7import android.content.Context 7import android.content.Context
8import android.content.DialogInterface
9import android.content.Intent 8import android.content.Intent
10import android.content.res.Configuration 9import android.content.res.Configuration
11import android.graphics.Rect 10import android.graphics.Rect
@@ -13,22 +12,22 @@ import android.hardware.Sensor
13import android.hardware.SensorEvent 12import android.hardware.SensorEvent
14import android.hardware.SensorEventListener 13import android.hardware.SensorEventListener
15import android.hardware.SensorManager 14import android.hardware.SensorManager
15import android.hardware.display.DisplayManager
16import android.os.Bundle 16import android.os.Bundle
17import android.view.Display
17import android.view.InputDevice 18import android.view.InputDevice
18import android.view.KeyEvent 19import android.view.KeyEvent
19import android.view.MotionEvent 20import android.view.MotionEvent
20import android.view.Surface 21import android.view.Surface
21import android.view.View 22import android.view.View
22import android.view.WindowManager
23import android.view.inputmethod.InputMethodManager 23import android.view.inputmethod.InputMethodManager
24import androidx.appcompat.app.AppCompatActivity 24import androidx.appcompat.app.AppCompatActivity
25import androidx.preference.PreferenceManager 25import androidx.core.content.getSystemService
26import com.google.android.material.dialog.MaterialAlertDialogBuilder 26import androidx.core.view.WindowCompat
27import com.google.android.material.slider.Slider.OnChangeListener 27import androidx.core.view.WindowInsetsCompat
28import androidx.core.view.WindowInsetsControllerCompat
28import org.yuzu.yuzu_emu.NativeLibrary 29import org.yuzu.yuzu_emu.NativeLibrary
29import org.yuzu.yuzu_emu.R 30import org.yuzu.yuzu_emu.R
30import org.yuzu.yuzu_emu.databinding.DialogSliderBinding
31import org.yuzu.yuzu_emu.features.settings.model.Settings
32import org.yuzu.yuzu_emu.fragments.EmulationFragment 31import org.yuzu.yuzu_emu.fragments.EmulationFragment
33import org.yuzu.yuzu_emu.model.Game 32import org.yuzu.yuzu_emu.model.Game
34import org.yuzu.yuzu_emu.utils.ControllerMappingHelper 33import 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() {