Merge pull request #11613 from t895/fragment-exception-change
android: Various play store fixes
This commit is contained in:
commit
882859bc78
@ -17,6 +17,7 @@ import android.os.Handler
|
|||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
@ -53,6 +54,7 @@ import org.yuzu.yuzu_emu.model.Game
|
|||||||
import org.yuzu.yuzu_emu.model.EmulationViewModel
|
import org.yuzu.yuzu_emu.model.EmulationViewModel
|
||||||
import org.yuzu.yuzu_emu.overlay.InputOverlay
|
import org.yuzu.yuzu_emu.overlay.InputOverlay
|
||||||
import org.yuzu.yuzu_emu.utils.*
|
import org.yuzu.yuzu_emu.utils.*
|
||||||
|
import java.lang.NullPointerException
|
||||||
|
|
||||||
class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
private lateinit var preferences: SharedPreferences
|
private lateinit var preferences: SharedPreferences
|
||||||
@ -104,10 +106,21 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
game = if (args.game != null) {
|
game = if (args.game != null) {
|
||||||
args.game!!
|
args.game!!
|
||||||
} else {
|
} else {
|
||||||
intentGame ?: error("[EmulationFragment] No bootable game present!")
|
intentGame!!
|
||||||
|
}
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
R.string.no_game_present,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
requireActivity().finish()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// So this fragment doesn't restart on configuration changes; i.e. rotation.
|
// So this fragment doesn't restart on configuration changes; i.e. rotation.
|
||||||
@ -131,6 +144,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||||||
// This is using the correct scope, lint is just acting up
|
// This is using the correct scope, lint is just acting up
|
||||||
@SuppressLint("UnsafeRepeatOnLifecycleDetector")
|
@SuppressLint("UnsafeRepeatOnLifecycleDetector")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
if (requireActivity().isFinishing) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
binding.surfaceEmulation.holder.addCallback(this)
|
binding.surfaceEmulation.holder.addCallback(this)
|
||||||
binding.showFpsText.setTextColor(Color.YELLOW)
|
binding.showFpsText.setTextColor(Color.YELLOW)
|
||||||
binding.doneControlConfig.setOnClickListener { stopConfiguringControls() }
|
binding.doneControlConfig.setOnClickListener { stopConfiguringControls() }
|
||||||
@ -286,26 +304,24 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
|
if (_binding == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
updateScreenLayout()
|
updateScreenLayout()
|
||||||
if (emulationActivity?.isInPictureInPictureMode == true) {
|
if (emulationActivity?.isInPictureInPictureMode == true) {
|
||||||
if (binding.drawerLayout.isOpen) {
|
if (binding.drawerLayout.isOpen) {
|
||||||
binding.drawerLayout.close()
|
binding.drawerLayout.close()
|
||||||
}
|
}
|
||||||
if (EmulationMenuSettings.showOverlay) {
|
if (EmulationMenuSettings.showOverlay) {
|
||||||
binding.surfaceInputOverlay.post {
|
|
||||||
binding.surfaceInputOverlay.visibility = View.INVISIBLE
|
binding.surfaceInputOverlay.visibility = View.INVISIBLE
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (EmulationMenuSettings.showOverlay && emulationViewModel.emulationStarted.value) {
|
if (EmulationMenuSettings.showOverlay && emulationViewModel.emulationStarted.value) {
|
||||||
binding.surfaceInputOverlay.post {
|
|
||||||
binding.surfaceInputOverlay.visibility = View.VISIBLE
|
binding.surfaceInputOverlay.visibility = View.VISIBLE
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
binding.surfaceInputOverlay.post {
|
|
||||||
binding.surfaceInputOverlay.visibility = View.INVISIBLE
|
binding.surfaceInputOverlay.visibility = View.INVISIBLE
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!isInFoldableLayout) {
|
if (!isInFoldableLayout) {
|
||||||
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
binding.surfaceInputOverlay.layout = InputOverlay.PORTRAIT
|
binding.surfaceInputOverlay.layout = InputOverlay.PORTRAIT
|
||||||
|
@ -295,8 +295,10 @@ class SetupFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
|
if (_binding != null) {
|
||||||
outState.putBoolean(KEY_NEXT_VISIBILITY, binding.buttonNext.isVisible)
|
outState.putBoolean(KEY_NEXT_VISIBILITY, binding.buttonNext.isVisible)
|
||||||
outState.putBoolean(KEY_BACK_VISIBILITY, binding.buttonBack.isVisible)
|
outState.putBoolean(KEY_BACK_VISIBILITY, binding.buttonBack.isVisible)
|
||||||
|
}
|
||||||
outState.putBooleanArray(KEY_HAS_BEEN_WARNED, hasBeenWarned)
|
outState.putBooleanArray(KEY_HAS_BEEN_WARNED, hasBeenWarned)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,11 +355,15 @@ class SetupFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun pageForward() {
|
fun pageForward() {
|
||||||
binding.viewPager2.currentItem = binding.viewPager2.currentItem + 1
|
if (_binding != null) {
|
||||||
|
binding.viewPager2.currentItem += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pageBackward() {
|
fun pageBackward() {
|
||||||
binding.viewPager2.currentItem = binding.viewPager2.currentItem - 1
|
if (_binding != null) {
|
||||||
|
binding.viewPager2.currentItem -= 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPageWarned(page: Int) {
|
fun setPageWarned(page: Int) {
|
||||||
|
@ -300,6 +300,7 @@
|
|||||||
<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>
|
<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>
|
||||||
<string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string>
|
<string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string>
|
||||||
<string name="memory_formatted">%1$s %2$s</string>
|
<string name="memory_formatted">%1$s %2$s</string>
|
||||||
|
<string name="no_game_present">No bootable game present!</string>
|
||||||
|
|
||||||
<!-- Region Names -->
|
<!-- Region Names -->
|
||||||
<string name="region_japan">Japan</string>
|
<string name="region_japan">Japan</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user