diff options
Diffstat (limited to 'src')
3 files changed, 40 insertions, 17 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 750638bc9..e6ad2aa77 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -17,6 +17,7 @@ import android.os.Handler | |||
| 17 | import android.os.Looper | 17 | import android.os.Looper |
| 18 | import android.view.* | 18 | import android.view.* |
| 19 | import android.widget.TextView | 19 | import android.widget.TextView |
| 20 | import android.widget.Toast | ||
| 20 | import androidx.activity.OnBackPressedCallback | 21 | import androidx.activity.OnBackPressedCallback |
| 21 | import androidx.appcompat.widget.PopupMenu | 22 | import androidx.appcompat.widget.PopupMenu |
| 22 | import androidx.core.content.res.ResourcesCompat | 23 | import androidx.core.content.res.ResourcesCompat |
| @@ -53,6 +54,7 @@ import org.yuzu.yuzu_emu.model.Game | |||
| 53 | import org.yuzu.yuzu_emu.model.EmulationViewModel | 54 | import org.yuzu.yuzu_emu.model.EmulationViewModel |
| 54 | import org.yuzu.yuzu_emu.overlay.InputOverlay | 55 | import org.yuzu.yuzu_emu.overlay.InputOverlay |
| 55 | import org.yuzu.yuzu_emu.utils.* | 56 | import org.yuzu.yuzu_emu.utils.* |
| 57 | import java.lang.NullPointerException | ||
| 56 | 58 | ||
| 57 | class EmulationFragment : Fragment(), SurfaceHolder.Callback { | 59 | class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
| 58 | private lateinit var preferences: SharedPreferences | 60 | private lateinit var preferences: SharedPreferences |
| @@ -104,10 +106,21 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 104 | null | 106 | null |
| 105 | } | 107 | } |
| 106 | } | 108 | } |
| 107 | game = if (args.game != null) { | 109 | |
| 108 | args.game!! | 110 | try { |
| 109 | } else { | 111 | game = if (args.game != null) { |
| 110 | intentGame ?: error("[EmulationFragment] No bootable game present!") | 112 | args.game!! |
| 113 | } else { | ||
| 114 | intentGame!! | ||
| 115 | } | ||
| 116 | } catch (e: NullPointerException) { | ||
| 117 | Toast.makeText( | ||
| 118 | requireContext(), | ||
| 119 | R.string.no_game_present, | ||
| 120 | Toast.LENGTH_SHORT | ||
| 121 | ).show() | ||
| 122 | requireActivity().finish() | ||
| 123 | return | ||
| 111 | } | 124 | } |
| 112 | 125 | ||
| 113 | // So this fragment doesn't restart on configuration changes; i.e. rotation. | 126 | // So this fragment doesn't restart on configuration changes; i.e. rotation. |
| @@ -131,6 +144,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 131 | // This is using the correct scope, lint is just acting up | 144 | // This is using the correct scope, lint is just acting up |
| 132 | @SuppressLint("UnsafeRepeatOnLifecycleDetector") | 145 | @SuppressLint("UnsafeRepeatOnLifecycleDetector") |
| 133 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | 146 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| 147 | super.onViewCreated(view, savedInstanceState) | ||
| 148 | if (requireActivity().isFinishing) { | ||
| 149 | return | ||
| 150 | } | ||
| 151 | |||
| 134 | binding.surfaceEmulation.holder.addCallback(this) | 152 | binding.surfaceEmulation.holder.addCallback(this) |
| 135 | binding.showFpsText.setTextColor(Color.YELLOW) | 153 | binding.showFpsText.setTextColor(Color.YELLOW) |
| 136 | binding.doneControlConfig.setOnClickListener { stopConfiguringControls() } | 154 | binding.doneControlConfig.setOnClickListener { stopConfiguringControls() } |
| @@ -286,25 +304,23 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 286 | 304 | ||
| 287 | override fun onConfigurationChanged(newConfig: Configuration) { | 305 | override fun onConfigurationChanged(newConfig: Configuration) { |
| 288 | super.onConfigurationChanged(newConfig) | 306 | super.onConfigurationChanged(newConfig) |
| 307 | if (_binding == null) { | ||
| 308 | return | ||
| 309 | } | ||
| 310 | |||
| 289 | updateScreenLayout() | 311 | updateScreenLayout() |
| 290 | if (emulationActivity?.isInPictureInPictureMode == true) { | 312 | if (emulationActivity?.isInPictureInPictureMode == true) { |
| 291 | if (binding.drawerLayout.isOpen) { | 313 | if (binding.drawerLayout.isOpen) { |
| 292 | binding.drawerLayout.close() | 314 | binding.drawerLayout.close() |
| 293 | } | 315 | } |
| 294 | if (EmulationMenuSettings.showOverlay) { | 316 | if (EmulationMenuSettings.showOverlay) { |
| 295 | binding.surfaceInputOverlay.post { | 317 | binding.surfaceInputOverlay.visibility = View.INVISIBLE |
| 296 | binding.surfaceInputOverlay.visibility = View.INVISIBLE | ||
| 297 | } | ||
| 298 | } | 318 | } |
| 299 | } else { | 319 | } else { |
| 300 | if (EmulationMenuSettings.showOverlay && emulationViewModel.emulationStarted.value) { | 320 | if (EmulationMenuSettings.showOverlay && emulationViewModel.emulationStarted.value) { |
| 301 | binding.surfaceInputOverlay.post { | 321 | binding.surfaceInputOverlay.visibility = View.VISIBLE |
| 302 | binding.surfaceInputOverlay.visibility = View.VISIBLE | ||
| 303 | } | ||
| 304 | } else { | 322 | } else { |
| 305 | binding.surfaceInputOverlay.post { | 323 | binding.surfaceInputOverlay.visibility = View.INVISIBLE |
| 306 | binding.surfaceInputOverlay.visibility = View.INVISIBLE | ||
| 307 | } | ||
| 308 | } | 324 | } |
| 309 | if (!isInFoldableLayout) { | 325 | if (!isInFoldableLayout) { |
| 310 | if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { | 326 | if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt index fbb2f6e18..c66bb635a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt | |||
| @@ -295,8 +295,10 @@ class SetupFragment : Fragment() { | |||
| 295 | 295 | ||
| 296 | override fun onSaveInstanceState(outState: Bundle) { | 296 | override fun onSaveInstanceState(outState: Bundle) { |
| 297 | super.onSaveInstanceState(outState) | 297 | super.onSaveInstanceState(outState) |
| 298 | outState.putBoolean(KEY_NEXT_VISIBILITY, binding.buttonNext.isVisible) | 298 | if (_binding != null) { |
| 299 | outState.putBoolean(KEY_BACK_VISIBILITY, binding.buttonBack.isVisible) | 299 | outState.putBoolean(KEY_NEXT_VISIBILITY, binding.buttonNext.isVisible) |
| 300 | outState.putBoolean(KEY_BACK_VISIBILITY, binding.buttonBack.isVisible) | ||
| 301 | } | ||
| 300 | outState.putBooleanArray(KEY_HAS_BEEN_WARNED, hasBeenWarned) | 302 | outState.putBooleanArray(KEY_HAS_BEEN_WARNED, hasBeenWarned) |
| 301 | } | 303 | } |
| 302 | 304 | ||
| @@ -353,11 +355,15 @@ class SetupFragment : Fragment() { | |||
| 353 | } | 355 | } |
| 354 | 356 | ||
| 355 | fun pageForward() { | 357 | fun pageForward() { |
| 356 | binding.viewPager2.currentItem = binding.viewPager2.currentItem + 1 | 358 | if (_binding != null) { |
| 359 | binding.viewPager2.currentItem += 1 | ||
| 360 | } | ||
| 357 | } | 361 | } |
| 358 | 362 | ||
| 359 | fun pageBackward() { | 363 | fun pageBackward() { |
| 360 | binding.viewPager2.currentItem = binding.viewPager2.currentItem - 1 | 364 | if (_binding != null) { |
| 365 | binding.viewPager2.currentItem -= 1 | ||
| 366 | } | ||
| 361 | } | 367 | } |
| 362 | 368 | ||
| 363 | fun setPageWarned(page: Int) { | 369 | fun setPageWarned(page: Int) { |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 21a40238c..e51edf872 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -300,6 +300,7 @@ | |||
| 300 | <string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string> | 300 | <string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string> |
| 301 | <string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string> | 301 | <string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string> |
| 302 | <string name="memory_formatted">%1$s %2$s</string> | 302 | <string name="memory_formatted">%1$s %2$s</string> |
| 303 | <string name="no_game_present">No bootable game present!</string> | ||
| 303 | 304 | ||
| 304 | <!-- Region Names --> | 305 | <!-- Region Names --> |
| 305 | <string name="region_japan">Japan</string> | 306 | <string name="region_japan">Japan</string> |