summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-04-18 10:10:28 +0200
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:52 +0200
commit766655fa4181f47da6a34250843e443331198a31 (patch)
treed15ccd62d355e9fabed505765d097d8811b2c34e /src
parentandroid: Abstract settings (diff)
downloadyuzu-766655fa4181f47da6a34250843e443331198a31.tar
yuzu-766655fa4181f47da6a34250843e443331198a31.tar.gz
yuzu-766655fa4181f47da6a34250843e443331198a31.tar.bz2
yuzu-766655fa4181f47da6a34250843e443331198a31.tar.lz
yuzu-766655fa4181f47da6a34250843e443331198a31.tar.xz
yuzu-766655fa4181f47da6a34250843e443331198a31.tar.zst
yuzu-766655fa4181f47da6a34250843e443331198a31.zip
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt7
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt8
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt16
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt8
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt10
5 files changed, 35 insertions, 14 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt
index 599da1380..c02848403 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt
@@ -3,6 +3,7 @@
package org.yuzu.yuzu_emu.features.settings.model.view
+import org.yuzu.yuzu_emu.NativeLibrary
import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting
/**
@@ -19,6 +20,12 @@ abstract class SettingsItem(
) {
abstract val type: Int
+ val isEditable: Boolean
+ get() {
+ if (!NativeLibrary.isRunning()) return true
+ return setting?.isRuntimeEditable ?: false
+ }
+
companion object {
const val TYPE_HEADER = 0
const val TYPE_SWITCH = 1
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt
index 5702fc0eb..e433373ed 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt
@@ -11,10 +11,10 @@ import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) :
SettingViewHolder(binding.root, adapter) {
- private lateinit var item: DateTimeSetting
+ private lateinit var setting: DateTimeSetting
override fun bind(item: SettingsItem) {
- this.item = item as DateTimeSetting
+ setting = item as DateTimeSetting
binding.textSettingName.setText(item.nameId)
if (item.descriptionId!! > 0) {
binding.textSettingDescription.setText(item.descriptionId)
@@ -25,6 +25,8 @@ class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA
}
override fun onClick(clicked: View) {
- adapter.onDateTimeClick(item, bindingAdapterPosition)
+ if (setting.isEditable) {
+ adapter.onDateTimeClick(setting, bindingAdapterPosition)
+ }
}
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt
index a82f49f44..b92334522 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt
@@ -12,10 +12,10 @@ import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) :
SettingViewHolder(binding.root, adapter) {
- private lateinit var item: SettingsItem
+ private lateinit var setting: SettingsItem
override fun bind(item: SettingsItem) {
- this.item = item
+ setting = item
binding.textSettingName.setText(item.nameId)
binding.textSettingDescription.visibility = View.VISIBLE
if (item.descriptionId!! > 0) {
@@ -34,14 +34,18 @@ class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: Setti
}
override fun onClick(clicked: View) {
- if (item is SingleChoiceSetting) {
+ if (!setting.isEditable) {
+ return
+ }
+
+ if (setting is SingleChoiceSetting) {
adapter.onSingleChoiceClick(
- (item as SingleChoiceSetting),
+ (setting as SingleChoiceSetting),
bindingAdapterPosition
)
- } else if (item is StringSingleChoiceSetting) {
+ } else if (setting is StringSingleChoiceSetting) {
adapter.onStringSingleChoiceClick(
- (item as StringSingleChoiceSetting),
+ (setting as StringSingleChoiceSetting),
bindingAdapterPosition
)
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt
index 2d9fd11f9..1c2f74d56 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt
@@ -11,10 +11,10 @@ import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) :
SettingViewHolder(binding.root, adapter) {
- private lateinit var item: SliderSetting
+ private lateinit var setting: SliderSetting
override fun bind(item: SettingsItem) {
- this.item = item as SliderSetting
+ setting = item as SliderSetting
binding.textSettingName.setText(item.nameId)
if (item.descriptionId!! > 0) {
binding.textSettingDescription.setText(item.descriptionId)
@@ -25,6 +25,8 @@ class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAda
}
override fun onClick(clicked: View) {
- adapter.onSliderClick(item, bindingAdapterPosition)
+ if (setting.isEditable) {
+ adapter.onSliderClick(setting, bindingAdapterPosition)
+ }
}
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt
index 3fedb4969..825e9d0d0 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt
@@ -13,8 +13,10 @@ import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter: SettingsAdapter) :
SettingViewHolder(binding.root, adapter) {
+ private lateinit var setting: SwitchSetting
+
override fun bind(item: SettingsItem) {
- val setting = item as SwitchSetting
+ setting = item as SwitchSetting
binding.textSettingName.setText(item.nameId)
if (item.descriptionId!! > 0) {
binding.textSettingDescription.setText(item.descriptionId)
@@ -27,9 +29,13 @@ class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter
binding.switchWidget.setOnCheckedChangeListener { _: CompoundButton, _: Boolean ->
adapter.onBooleanClick(item, bindingAdapterPosition, binding.switchWidget.isChecked)
}
+
+ binding.switchWidget.isEnabled = setting.isEditable
}
override fun onClick(clicked: View) {
- binding.switchWidget.toggle()
+ if (setting.isEditable) {
+ binding.switchWidget.toggle()
+ }
}
}