summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-06-05 01:32:28 +0200
committerCharles Lombardo <clombardo169@gmail.com>2023-06-05 01:37:10 +0200
commit0078f972279a11507847c8c9f01439845951956b (patch)
tree89c51906428019a4898163f555e92da91bfa24bf /src/android
parentMerge pull request #10605 from 8bitDream/kotlin (diff)
downloadyuzu-0078f972279a11507847c8c9f01439845951956b.tar
yuzu-0078f972279a11507847c8c9f01439845951956b.tar.gz
yuzu-0078f972279a11507847c8c9f01439845951956b.tar.bz2
yuzu-0078f972279a11507847c8c9f01439845951956b.tar.lz
yuzu-0078f972279a11507847c8c9f01439845951956b.tar.xz
yuzu-0078f972279a11507847c8c9f01439845951956b.tar.zst
yuzu-0078f972279a11507847c8c9f01439845951956b.zip
Diffstat (limited to 'src/android')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt6
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt6
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt9
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt4
4 files changed, 19 insertions, 6 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 901a3978d..94d5156cf 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
@@ -21,6 +21,7 @@ import android.view.MotionEvent
import android.view.Surface
import android.view.View
import android.view.inputmethod.InputMethodManager
+import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.getSystemService
import androidx.core.view.WindowCompat
@@ -34,6 +35,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.yuzu.yuzu_emu.NativeLibrary
import org.yuzu.yuzu_emu.R
+import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel
import org.yuzu.yuzu_emu.fragments.EmulationFragment
import org.yuzu.yuzu_emu.model.Game
import org.yuzu.yuzu_emu.utils.ControllerMappingHelper
@@ -60,6 +62,8 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
private lateinit var game: Game
+ private val settingsViewModel: SettingsViewModel by viewModels()
+
override fun onDestroy() {
stopForegroundService(this)
super.onDestroy()
@@ -68,6 +72,8 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
override fun onCreate(savedInstanceState: Bundle?) {
ThemeHelper.setTheme(this)
+ settingsViewModel.settings.loadSettings()
+
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
// Get params we were passed
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt
index 23c31e13a..6d3db53c0 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt
@@ -39,7 +39,7 @@ class Settings {
val isEmpty: Boolean
get() = sections.isEmpty()
- fun loadSettings(view: SettingsActivityView) {
+ fun loadSettings(view: SettingsActivityView? = null) {
sections = SettingsSectionMap()
loadYuzuSettings(view)
if (!TextUtils.isEmpty(gameId)) {
@@ -48,13 +48,13 @@ class Settings {
isLoaded = true
}
- private fun loadYuzuSettings(view: SettingsActivityView) {
+ private fun loadYuzuSettings(view: SettingsActivityView?) {
for ((fileName) in configFileSectionsMap) {
sections.putAll(SettingsFile.readFile(fileName, view))
}
}
- private fun loadCustomGameSettings(gameId: String, view: SettingsActivityView) {
+ private fun loadCustomGameSettings(gameId: String, view: SettingsActivityView?) {
// Custom game settings
mergeSections(SettingsFile.readCustomGameSettings(gameId, view))
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt
index c502fdca0..e29bca11d 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt
@@ -37,7 +37,7 @@ object SettingsFile {
private fun readFile(
ini: File?,
isCustomGame: Boolean,
- view: SettingsActivityView?
+ view: SettingsActivityView? = null
): HashMap<String, SettingSection?> {
val sections: HashMap<String, SettingSection?> = SettingsSectionMap()
var reader: BufferedReader? = null
@@ -74,10 +74,13 @@ object SettingsFile {
return sections
}
- fun readFile(fileName: String, view: SettingsActivityView): HashMap<String, SettingSection?> {
+ fun readFile(fileName: String, view: SettingsActivityView?): HashMap<String, SettingSection?> {
return readFile(getSettingsFile(fileName), false, view)
}
+ fun readFile(fileName: String): HashMap<String, SettingSection?> =
+ readFile(getSettingsFile(fileName), false)
+
/**
* Reads a given .ini file from disk and returns it as a HashMap of SettingSections, themselves
* effectively a HashMap of key/value settings. If unsuccessful, outputs an error telling why it
@@ -88,7 +91,7 @@ object SettingsFile {
*/
fun readCustomGameSettings(
gameId: String,
- view: SettingsActivityView
+ view: SettingsActivityView?
): HashMap<String, SettingSection?> {
return readFile(getCustomGameSettingsFile(gameId), true, view)
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
index f8bca11bb..134085210 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
@@ -35,6 +35,7 @@ import org.yuzu.yuzu_emu.activities.EmulationActivity
import org.yuzu.yuzu_emu.databinding.ActivityMainBinding
import org.yuzu.yuzu_emu.databinding.DialogProgressBarBinding
import org.yuzu.yuzu_emu.features.settings.model.Settings
+import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel
import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
@@ -48,6 +49,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
private val homeViewModel: HomeViewModel by viewModels()
private val gamesViewModel: GamesViewModel by viewModels()
+ private val settingsViewModel: SettingsViewModel by viewModels()
override var themeId: Int = 0
@@ -55,6 +57,8 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { !DirectoryInitialization.areDirectoriesReady }
+ settingsViewModel.settings.loadSettings()
+
ThemeHelper.setTheme(this)
super.onCreate(savedInstanceState)