mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-17 11:57:32 +01:00
android: Refactor CheckBoxSetting to SwitchSetting
This commit is contained in:
parent
b5b4e50c32
commit
4de3abdd5a
@ -23,7 +23,7 @@ abstract class SettingsItem(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TYPE_HEADER = 0
|
const val TYPE_HEADER = 0
|
||||||
const val TYPE_CHECKBOX = 1
|
const val TYPE_SWITCH = 1
|
||||||
const val TYPE_SINGLE_CHOICE = 2
|
const val TYPE_SINGLE_CHOICE = 2
|
||||||
const val TYPE_SLIDER = 3
|
const val TYPE_SLIDER = 3
|
||||||
const val TYPE_SUBMENU = 4
|
const val TYPE_SUBMENU = 4
|
||||||
|
@ -10,8 +10,8 @@ import org.yuzu.yuzu_emu.features.settings.model.IntSetting
|
|||||||
import org.yuzu.yuzu_emu.features.settings.model.Setting
|
import org.yuzu.yuzu_emu.features.settings.model.Setting
|
||||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsFragmentView
|
import org.yuzu.yuzu_emu.features.settings.ui.SettingsFragmentView
|
||||||
|
|
||||||
class CheckBoxSetting : SettingsItem {
|
class SwitchSetting : SettingsItem {
|
||||||
override val type = TYPE_CHECKBOX
|
override val type = TYPE_SWITCH
|
||||||
|
|
||||||
private var defaultValue: Boolean
|
private var defaultValue: Boolean
|
||||||
private var showPerformanceWarning: Boolean
|
private var showPerformanceWarning: Boolean
|
@ -52,7 +52,7 @@ class SettingsAdapter(
|
|||||||
}
|
}
|
||||||
SettingsItem.TYPE_CHECKBOX -> {
|
SettingsItem.TYPE_CHECKBOX -> {
|
||||||
view = inflater.inflate(R.layout.list_item_setting_switch, parent, false)
|
view = inflater.inflate(R.layout.list_item_setting_switch, parent, false)
|
||||||
CheckBoxSettingViewHolder(view, this)
|
SwitchSettingViewHolder(view, this)
|
||||||
}
|
}
|
||||||
SettingsItem.TYPE_SINGLE_CHOICE, SettingsItem.TYPE_STRING_SINGLE_CHOICE -> {
|
SettingsItem.TYPE_SINGLE_CHOICE, SettingsItem.TYPE_STRING_SINGLE_CHOICE -> {
|
||||||
view = inflater.inflate(R.layout.list_item_setting, parent, false)
|
view = inflater.inflate(R.layout.list_item_setting, parent, false)
|
||||||
@ -103,7 +103,7 @@ class SettingsAdapter(
|
|||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onBooleanClick(item: CheckBoxSetting, position: Int, checked: Boolean) {
|
fun onBooleanClick(item: SwitchSetting, position: Int, checked: Boolean) {
|
||||||
val setting = item.setChecked(checked)
|
val setting = item.setChecked(checked)
|
||||||
if (setting != null) {
|
if (setting != null) {
|
||||||
fragmentView.putSetting(setting)
|
fragmentView.putSetting(setting)
|
||||||
|
@ -139,7 +139,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||||||
val cpuAccuracy = cpuSection!!.getSetting(SettingsFile.KEY_CPU_ACCURACY)
|
val cpuAccuracy = cpuSection!!.getSetting(SettingsFile.KEY_CPU_ACCURACY)
|
||||||
sl.apply {
|
sl.apply {
|
||||||
add(
|
add(
|
||||||
CheckBoxSetting(
|
SwitchSetting(
|
||||||
SettingsFile.KEY_RENDERER_USE_SPEED_LIMIT,
|
SettingsFile.KEY_RENDERER_USE_SPEED_LIMIT,
|
||||||
Settings.SECTION_RENDERER,
|
Settings.SECTION_RENDERER,
|
||||||
frameLimitEnable,
|
frameLimitEnable,
|
||||||
@ -184,7 +184,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||||||
val language = systemSection.getSetting(SettingsFile.KEY_LANGUAGE_INDEX)
|
val language = systemSection.getSetting(SettingsFile.KEY_LANGUAGE_INDEX)
|
||||||
sl.apply {
|
sl.apply {
|
||||||
add(
|
add(
|
||||||
CheckBoxSetting(
|
SwitchSetting(
|
||||||
SettingsFile.KEY_USE_DOCKED_MODE,
|
SettingsFile.KEY_USE_DOCKED_MODE,
|
||||||
Settings.SECTION_SYSTEM,
|
Settings.SECTION_SYSTEM,
|
||||||
dockedMode,
|
dockedMode,
|
||||||
@ -283,7 +283,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
add(
|
add(
|
||||||
CheckBoxSetting(
|
SwitchSetting(
|
||||||
SettingsFile.KEY_RENDERER_FORCE_MAX_CLOCK,
|
SettingsFile.KEY_RENDERER_FORCE_MAX_CLOCK,
|
||||||
Settings.SECTION_RENDERER,
|
Settings.SECTION_RENDERER,
|
||||||
rendererForceMaxClocks,
|
rendererForceMaxClocks,
|
||||||
@ -293,7 +293,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
add(
|
add(
|
||||||
CheckBoxSetting(
|
SwitchSetting(
|
||||||
SettingsFile.KEY_RENDERER_ASYNCHRONOUS_SHADERS,
|
SettingsFile.KEY_RENDERER_ASYNCHRONOUS_SHADERS,
|
||||||
Settings.SECTION_RENDERER,
|
Settings.SECTION_RENDERER,
|
||||||
rendererAsynchronousShaders,
|
rendererAsynchronousShaders,
|
||||||
@ -303,7 +303,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
add(
|
add(
|
||||||
CheckBoxSetting(
|
SwitchSetting(
|
||||||
SettingsFile.KEY_RENDERER_DEBUG,
|
SettingsFile.KEY_RENDERER_DEBUG,
|
||||||
Settings.SECTION_RENDERER,
|
Settings.SECTION_RENDERER,
|
||||||
rendererDebug,
|
rendererDebug,
|
||||||
|
@ -8,13 +8,13 @@ import android.widget.CompoundButton
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.google.android.material.materialswitch.MaterialSwitch
|
import com.google.android.material.materialswitch.MaterialSwitch
|
||||||
import org.yuzu.yuzu_emu.R
|
import org.yuzu.yuzu_emu.R
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.view.CheckBoxSetting
|
import org.yuzu.yuzu_emu.features.settings.model.view.SwitchSetting
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem
|
||||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
|
import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter
|
||||||
|
|
||||||
class CheckBoxSettingViewHolder(itemView: View, adapter: SettingsAdapter) :
|
class SwitchSettingViewHolder(itemView: View, adapter: SettingsAdapter) :
|
||||||
SettingViewHolder(itemView, adapter) {
|
SettingViewHolder(itemView, adapter) {
|
||||||
private lateinit var item: CheckBoxSetting
|
private lateinit var item: SwitchSetting
|
||||||
private lateinit var textSettingName: TextView
|
private lateinit var textSettingName: TextView
|
||||||
private lateinit var textSettingDescription: TextView
|
private lateinit var textSettingDescription: TextView
|
||||||
private lateinit var switch: MaterialSwitch
|
private lateinit var switch: MaterialSwitch
|
||||||
@ -26,7 +26,7 @@ class CheckBoxSettingViewHolder(itemView: View, adapter: SettingsAdapter) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(item: SettingsItem) {
|
override fun bind(item: SettingsItem) {
|
||||||
this.item = item as CheckBoxSetting
|
this.item = item as SwitchSetting
|
||||||
textSettingName.setText(item.nameId)
|
textSettingName.setText(item.nameId)
|
||||||
if (item.descriptionId!! > 0) {
|
if (item.descriptionId!! > 0) {
|
||||||
textSettingDescription.setText(item.descriptionId)
|
textSettingDescription.setText(item.descriptionId)
|
Loading…
Reference in New Issue
Block a user