From 3ea9370cb2572eaac5bb59131022077fb7650e9c Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 14 Aug 2023 22:44:35 +0200 Subject: [PATCH] early-access version 3807 --- README.md | 2 +- .../yuzu/yuzu_emu/adapters/LicenseAdapter.kt | 1 + .../features/settings/ui/SettingsAdapter.kt | 17 ++--- .../ui/viewholder/DateTimeViewHolder.kt | 15 +++-- .../ui/viewholder/RunnableViewHolder.kt | 3 + .../ui/viewholder/SettingViewHolder.kt | 16 +++++ .../ui/viewholder/SingleChoiceViewHolder.kt | 23 ++++--- .../ui/viewholder/SliderViewHolder.kt | 9 +++ .../ui/viewholder/SubmenuViewHolder.kt | 1 + .../ui/viewholder/SwitchSettingViewHolder.kt | 4 +- .../app/src/main/res/layout/dialog_slider.xml | 13 +--- .../src/main/res/layout/list_item_setting.xml | 62 +++++++++++-------- .../app/src/main/res/values/strings.xml | 1 + 13 files changed, 107 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 7dfcbc7fe..7f6b02bde 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3806. +This is the source code for early-access 3807. ## Legal Notice diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/LicenseAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/LicenseAdapter.kt index 7006651d0..bc6ff1364 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/LicenseAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/LicenseAdapter.kt @@ -49,6 +49,7 @@ class LicenseAdapter(private val activity: AppCompatActivity, var licenses: List val context = YuzuApplication.appContext binding.textSettingName.text = context.getString(license.titleId) binding.textSettingDescription.text = context.getString(license.descriptionId) + binding.textSettingValue.visibility = View.GONE } } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt index ce0b92c90..9711e2c51 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt @@ -207,8 +207,11 @@ class SettingsAdapter( val sliderBinding = DialogSliderBinding.inflate(inflater) textSliderValue = sliderBinding.textValue - textSliderValue!!.text = sliderProgress.toString() - sliderBinding.textUnits.text = item.units + textSliderValue!!.text = String.format( + context.getString(R.string.value_with_units), + sliderProgress.toString(), + item.units + ) sliderBinding.slider.apply { valueFrom = item.min.toFloat() @@ -216,7 +219,11 @@ class SettingsAdapter( value = sliderProgress.toFloat() addOnChangeListener { _: Slider, value: Float, _: Boolean -> sliderProgress = value.toInt() - textSliderValue!!.text = sliderProgress.toString() + textSliderValue!!.text = String.format( + context.getString(R.string.value_with_units), + sliderProgress.toString(), + item.units + ) } } @@ -225,10 +232,6 @@ class SettingsAdapter( .setView(sliderBinding.root) .setPositiveButton(android.R.string.ok, this) .setNegativeButton(android.R.string.cancel, defaultCancelListener) - .setNeutralButton(R.string.slider_default) { dialog: DialogInterface, which: Int -> - sliderBinding.slider.value = item.defaultValue!!.toFloat() - onClick(dialog, which) - } .show() } 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 7955532ee..79572fc06 100755 --- 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 @@ -25,12 +25,17 @@ class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA binding.textSettingDescription.setText(item.descriptionId) binding.textSettingDescription.visibility = View.VISIBLE } else { - val epochTime = setting.value.toLong() - val instant = Instant.ofEpochMilli(epochTime * 1000) - val zonedTime = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC")) - val dateFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) - binding.textSettingDescription.text = dateFormatter.format(zonedTime) + binding.textSettingDescription.visibility = View.GONE } + + binding.textSettingValue.visibility = View.VISIBLE + val epochTime = setting.value.toLong() + val instant = Instant.ofEpochMilli(epochTime * 1000) + val zonedTime = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC")) + val dateFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) + binding.textSettingValue.text = dateFormatter.format(zonedTime) + + setStyle(setting.isEditable, binding) } override fun onClick(clicked: View) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/RunnableViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/RunnableViewHolder.kt index 5dad5945f..83a2e94f1 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/RunnableViewHolder.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/RunnableViewHolder.kt @@ -23,6 +23,9 @@ class RunnableViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA } else { binding.textSettingDescription.visibility = View.GONE } + binding.textSettingValue.visibility = View.GONE + + setStyle(setting.isEditable, binding) } override fun onClick(clicked: View) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SettingViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SettingViewHolder.kt index f56460893..0fd1d2eaa 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SettingViewHolder.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SettingViewHolder.kt @@ -5,6 +5,8 @@ package org.yuzu.yuzu_emu.features.settings.ui.viewholder import android.view.View import androidx.recyclerview.widget.RecyclerView +import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding +import org.yuzu.yuzu_emu.databinding.ListItemSettingSwitchBinding import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter @@ -33,4 +35,18 @@ abstract class SettingViewHolder(itemView: View, protected val adapter: Settings abstract override fun onClick(clicked: View) abstract override fun onLongClick(clicked: View): Boolean + + fun setStyle(isEditable: Boolean, binding: ListItemSettingBinding) { + val opacity = if (isEditable) 1.0f else 0.5f + binding.textSettingName.alpha = opacity + binding.textSettingDescription.alpha = opacity + binding.textSettingValue.alpha = opacity + } + + fun setStyle(isEditable: Boolean, binding: ListItemSettingSwitchBinding) { + binding.switchWidget.isEnabled = isEditable + val opacity = if (isEditable) 1.0f else 0.5f + binding.textSettingName.alpha = opacity + binding.textSettingDescription.alpha = opacity + } } 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 e4e321bd3..b42d955aa 100755 --- 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 @@ -17,28 +17,33 @@ class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: Setti override fun bind(item: SettingsItem) { setting = item binding.textSettingName.setText(item.nameId) - binding.textSettingDescription.visibility = View.VISIBLE if (item.descriptionId != 0) { binding.textSettingDescription.setText(item.descriptionId) - } else if (item is SingleChoiceSetting) { - val resMgr = binding.textSettingDescription.context.resources + binding.textSettingDescription.visibility = View.VISIBLE + } else { + binding.textSettingDescription.visibility = View.GONE + } + + binding.textSettingValue.visibility = View.VISIBLE + if (item is SingleChoiceSetting) { + val resMgr = binding.textSettingValue.context.resources val values = resMgr.getIntArray(item.valuesId) for (i in values.indices) { if (values[i] == item.selectedValue) { - binding.textSettingDescription.text = resMgr.getStringArray(item.choicesId)[i] - return + binding.textSettingValue.text = resMgr.getStringArray(item.choicesId)[i] + break } } } else if (item is StringSingleChoiceSetting) { for (i in item.values!!.indices) { if (item.values[i] == item.selectedValue) { - binding.textSettingDescription.text = item.choices[i] - return + binding.textSettingValue.text = item.choices[i] + break } } - } else { - binding.textSettingDescription.visibility = View.GONE } + + setStyle(setting.isEditable, binding) } override fun onClick(clicked: View) { 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 cc3f39aa5..a23b5d109 100755 --- 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 @@ -4,6 +4,7 @@ package org.yuzu.yuzu_emu.features.settings.ui.viewholder import android.view.View +import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem import org.yuzu.yuzu_emu.features.settings.model.view.SliderSetting @@ -22,6 +23,14 @@ class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAda } else { binding.textSettingDescription.visibility = View.GONE } + binding.textSettingValue.visibility = View.VISIBLE + binding.textSettingValue.text = String.format( + binding.textSettingValue.context.getString(R.string.value_with_units), + setting.selectedValue, + setting.units + ) + + setStyle(setting.isEditable, binding) } override fun onClick(clicked: View) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SubmenuViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SubmenuViewHolder.kt index c545b4174..1cf581a9d 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SubmenuViewHolder.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SubmenuViewHolder.kt @@ -22,6 +22,7 @@ class SubmenuViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAd } else { binding.textSettingDescription.visibility = View.GONE } + binding.textSettingValue.visibility = View.GONE } override fun onClick(clicked: View) { 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 54f531795..ef34bf5f4 100755 --- 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 @@ -25,12 +25,12 @@ class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter binding.textSettingDescription.text = "" binding.textSettingDescription.visibility = View.GONE } - binding.switchWidget.isChecked = setting.isChecked binding.switchWidget.setOnCheckedChangeListener { _: CompoundButton, _: Boolean -> adapter.onBooleanClick(item, bindingAdapterPosition, binding.switchWidget.isChecked) } + binding.switchWidget.isChecked = setting.isChecked - binding.switchWidget.isEnabled = setting.isEditable + setStyle(setting.isEditable, binding) } override fun onClick(clicked: View) { diff --git a/src/android/app/src/main/res/layout/dialog_slider.xml b/src/android/app/src/main/res/layout/dialog_slider.xml index 8c84cb606..d1cb31739 100755 --- a/src/android/app/src/main/res/layout/dialog_slider.xml +++ b/src/android/app/src/main/res/layout/dialog_slider.xml @@ -5,23 +5,16 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - + tools:text="75%" /> - - + android:orientation="vertical"> - + + + + + + + diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 02e25504d..82359f358 100755 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -149,6 +149,7 @@ Limit speed percent Specifies the percentage to limit emulation speed. 100% is the normal speed. Values higher or lower will increase or decrease the speed limit. CPU accuracy + %1$s%2$s Docked Mode