mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-14 19:09:57 +01:00
Android: Fixed non-runtime settings sometimes not being changeable after closing a game
Co-Authored-By: Ishan09811 <156402647+ishan09811@users.noreply.github.com>
This commit is contained in:
parent
aa06b58523
commit
6f1d10264f
@ -55,6 +55,8 @@ class EmulationActivity : AppCompatActivity() {
|
|||||||
private lateinit var screenAdjustmentUtil: ScreenAdjustmentUtil
|
private lateinit var screenAdjustmentUtil: ScreenAdjustmentUtil
|
||||||
private lateinit var hotkeyUtility: HotkeyUtility
|
private lateinit var hotkeyUtility: HotkeyUtility
|
||||||
|
|
||||||
|
private var isEmulationRunning: Boolean = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
ThemeUtil.setTheme(this)
|
ThemeUtil.setTheme(this)
|
||||||
|
|
||||||
@ -84,6 +86,9 @@ class EmulationActivity : AppCompatActivity() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
EmulationLifecycleUtil.addShutdownHook(hook = { this.finish() })
|
EmulationLifecycleUtil.addShutdownHook(hook = { this.finish() })
|
||||||
|
|
||||||
|
isEmulationRunning = true
|
||||||
|
instance = this
|
||||||
}
|
}
|
||||||
|
|
||||||
// On some devices, the system bars will not disappear on first boot or after some
|
// On some devices, the system bars will not disappear on first boot or after some
|
||||||
@ -104,8 +109,20 @@ class EmulationActivity : AppCompatActivity() {
|
|||||||
NativeLibrary.reloadCameraDevices()
|
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() {
|
override fun onDestroy() {
|
||||||
EmulationLifecycleUtil.clear()
|
EmulationLifecycleUtil.clear()
|
||||||
|
isEmulationRunning = false
|
||||||
|
instance = null
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,4 +462,12 @@ class EmulationActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
OnFilePickerResult(result.toString())
|
OnFilePickerResult(result.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var instance: EmulationActivity? = null
|
||||||
|
|
||||||
|
fun isRunning(): Boolean {
|
||||||
|
return instance?.isEmulationRunning ?: false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
package org.citra.citra_emu.features.settings.model.view
|
package org.citra.citra_emu.features.settings.model.view
|
||||||
|
|
||||||
import org.citra.citra_emu.NativeLibrary
|
import org.citra.citra_emu.NativeLibrary
|
||||||
|
import org.citra.citra_emu.activities.EmulationActivity
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractSetting
|
import org.citra.citra_emu.features.settings.model.AbstractSetting
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +24,7 @@ abstract class SettingsItem(
|
|||||||
|
|
||||||
val isEditable: Boolean
|
val isEditable: Boolean
|
||||||
get() {
|
get() {
|
||||||
if (!NativeLibrary.isRunning()) return true
|
if (!EmulationActivity.isRunning()) return true
|
||||||
return setting?.isRuntimeEditable ?: false
|
return setting?.isRuntimeEditable ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ package org.citra.citra_emu.features.settings.ui.viewholder
|
|||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import org.citra.citra_emu.NativeLibrary
|
import org.citra.citra_emu.NativeLibrary
|
||||||
|
import org.citra.citra_emu.activities.EmulationActivity
|
||||||
import org.citra.citra_emu.databinding.ListItemSettingBinding
|
import org.citra.citra_emu.databinding.ListItemSettingBinding
|
||||||
import org.citra.citra_emu.features.settings.model.view.RunnableSetting
|
import org.citra.citra_emu.features.settings.model.view.RunnableSetting
|
||||||
import org.citra.citra_emu.features.settings.model.view.SettingsItem
|
import org.citra.citra_emu.features.settings.model.view.SettingsItem
|
||||||
@ -44,10 +45,10 @@ class RunnableViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(clicked: View) {
|
override fun onClick(clicked: View) {
|
||||||
if (!setting.isRuntimeRunnable && !NativeLibrary.isRunning()) {
|
if (!setting.isRuntimeRunnable && EmulationActivity.isRunning()) {
|
||||||
setting.runnable.invoke()
|
|
||||||
} else {
|
|
||||||
adapter.onClickDisabledSetting()
|
adapter.onClickDisabledSetting()
|
||||||
|
} else {
|
||||||
|
setting.runnable.invoke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user