mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-01 16:05:07 +01:00
android: Re-fixed runtime settings not being editable after closing game
This commit is contained in:
parent
849a3046ac
commit
c5472c3a9c
@ -57,6 +57,8 @@ class EmulationActivity : AppCompatActivity() {
|
||||
private lateinit var screenAdjustmentUtil: ScreenAdjustmentUtil
|
||||
private lateinit var hotkeyUtility: HotkeyUtility
|
||||
|
||||
private var isEmulationRunning: Boolean = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
ThemeUtil.setTheme(this)
|
||||
|
||||
@ -86,6 +88,9 @@ class EmulationActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
EmulationLifecycleUtil.addShutdownHook(hook = { this.finish() })
|
||||
|
||||
isEmulationRunning = true
|
||||
instance = this
|
||||
}
|
||||
|
||||
// On some devices, the system bars will not disappear on first boot or after some
|
||||
@ -106,8 +111,20 @@ class EmulationActivity : AppCompatActivity() {
|
||||
NativeLibrary.reloadCameraDevices()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putBoolean("isEmulationRunning", isEmulationRunning)
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
isEmulationRunning = savedInstanceState.getBoolean("isEmulationRunning", false)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
EmulationLifecycleUtil.clear()
|
||||
isEmulationRunning = false
|
||||
instance = null
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@ -450,6 +467,12 @@ class EmulationActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var instance: EmulationActivity? = null
|
||||
|
||||
fun isRunning(): Boolean {
|
||||
return instance?.isEmulationRunning ?: false
|
||||
}
|
||||
|
||||
fun stopForegroundService(activity: Activity) {
|
||||
val startIntent = Intent(activity, ForegroundService::class.java)
|
||||
startIntent.action = ForegroundService.ACTION_STOP
|
||||
|
@ -6,6 +6,7 @@ package io.github.lime3ds.android.features.settings.model.view
|
||||
|
||||
import io.github.lime3ds.android.NativeLibrary
|
||||
import io.github.lime3ds.android.features.settings.model.AbstractSetting
|
||||
import io.github.lime3ds.android.activities.EmulationActivity
|
||||
|
||||
/**
|
||||
* ViewModel abstraction for an Item in the RecyclerView powering SettingsFragments.
|
||||
@ -23,7 +24,7 @@ abstract class SettingsItem(
|
||||
|
||||
val isEditable: Boolean
|
||||
get() {
|
||||
if (!NativeLibrary.isRunning()) return true
|
||||
if (!EmulationActivity.isRunning()) return true
|
||||
return setting?.isRuntimeEditable ?: false
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import io.github.lime3ds.android.databinding.ListItemSettingBinding
|
||||
import io.github.lime3ds.android.features.settings.model.view.RunnableSetting
|
||||
import io.github.lime3ds.android.features.settings.model.view.SettingsItem
|
||||
import io.github.lime3ds.android.features.settings.ui.SettingsAdapter
|
||||
import io.github.lime3ds.android.activities.EmulationActivity
|
||||
|
||||
class RunnableViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) :
|
||||
SettingViewHolder(binding.root, adapter) {
|
||||
@ -44,7 +45,7 @@ class RunnableViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA
|
||||
}
|
||||
|
||||
override fun onClick(clicked: View) {
|
||||
if (!setting.isRuntimeRunnable && NativeLibrary.isRunning()) {
|
||||
if (!setting.isRuntimeRunnable && EmulationActivity.isRunning()) {
|
||||
adapter.onClickDisabledSetting()
|
||||
} else {
|
||||
setting.runnable.invoke()
|
||||
|
Loading…
Reference in New Issue
Block a user