yuzu-emu
/
yuzu
Archived
1
0
Fork 0

android: Change organization of the settings tab in the home screen

This commit is contained in:
Charles Lombardo 2023-04-27 22:59:01 -04:00 committed by bunnei
parent c29f14fa0f
commit c070a588b9
7 changed files with 47 additions and 47 deletions

View File

@ -7,10 +7,10 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.RecyclerView
import org.yuzu.yuzu_emu.databinding.CardHomeOptionBinding
import org.yuzu.yuzu_emu.model.HomeOption
import org.yuzu.yuzu_emu.model.HomeSetting
class HomeOptionAdapter(private val activity: AppCompatActivity, var options: List<HomeOption>) :
RecyclerView.Adapter<HomeOptionAdapter.HomeOptionViewHolder>(),
class HomeSettingAdapter(private val activity: AppCompatActivity, var options: List<HomeSetting>) :
RecyclerView.Adapter<HomeSettingAdapter.HomeOptionViewHolder>(),
View.OnClickListener {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeOptionViewHolder {
val binding = CardHomeOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
@ -33,13 +33,13 @@ class HomeOptionAdapter(private val activity: AppCompatActivity, var options: Li
inner class HomeOptionViewHolder(val binding: CardHomeOptionBinding) :
RecyclerView.ViewHolder(binding.root) {
lateinit var option: HomeOption
lateinit var option: HomeSetting
init {
itemView.tag = this
}
fun bind(option: HomeOption) {
fun bind(option: HomeSetting) {
this.option = option
binding.optionTitle.text = activity.resources.getString(option.titleId)
binding.optionDescription.text = activity.resources.getString(option.descriptionId)

View File

@ -17,16 +17,16 @@ import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.adapters.HomeOptionAdapter
import org.yuzu.yuzu_emu.databinding.FragmentOptionsBinding
import org.yuzu.yuzu_emu.adapters.HomeSettingAdapter
import org.yuzu.yuzu_emu.databinding.FragmentHomeSettingsBinding
import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
import org.yuzu.yuzu_emu.model.HomeOption
import org.yuzu.yuzu_emu.model.HomeSetting
import org.yuzu.yuzu_emu.ui.main.MainActivity
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
class OptionsFragment : Fragment() {
private var _binding: FragmentOptionsBinding? = null
class HomeSettingsFragment : Fragment() {
private var _binding: FragmentHomeSettingsBinding? = null
private val binding get() = _binding!!
private lateinit var mainActivity: MainActivity
@ -36,44 +36,44 @@ class OptionsFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentOptionsBinding.inflate(layoutInflater)
_binding = FragmentHomeSettingsBinding.inflate(layoutInflater)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
mainActivity = requireActivity() as MainActivity
val optionsList: List<HomeOption> = listOf(
HomeOption(
R.string.add_games,
R.string.add_games_description,
R.drawable.ic_add
) { mainActivity.getGamesDirectory.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data) },
HomeOption(
R.string.install_prod_keys,
R.string.install_prod_keys_description,
R.drawable.ic_unlock
) { mainActivity.getProdKey.launch(arrayOf("*/*")) },
HomeOption(
R.string.install_amiibo_keys,
R.string.install_amiibo_keys_description,
R.drawable.ic_nfc
) { mainActivity.getAmiiboKey.launch(arrayOf("*/*")) },
HomeOption(
val optionsList: List<HomeSetting> = listOf(
HomeSetting(
R.string.advanced_settings,
R.string.settings_description,
R.drawable.ic_settings
) { SettingsActivity.launch(requireContext(), SettingsFile.FILE_NAME_CONFIG, "") },
HomeSetting(
R.string.install_gpu_driver,
R.string.install_gpu_driver_description,
R.drawable.ic_input
) { driverInstaller() },
HomeOption(
R.string.settings,
R.string.settings_description,
R.drawable.ic_settings
) { SettingsActivity.launch(requireContext(), SettingsFile.FILE_NAME_CONFIG, "") }
HomeSetting(
R.string.install_amiibo_keys,
R.string.install_amiibo_keys_description,
R.drawable.ic_nfc
) { mainActivity.getAmiiboKey.launch(arrayOf("*/*")) },
HomeSetting(
R.string.add_games,
R.string.add_games_description,
R.drawable.ic_add
) { mainActivity.getGamesDirectory.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data) },
HomeSetting(
R.string.install_prod_keys,
R.string.install_prod_keys_description,
R.drawable.ic_unlock
) { mainActivity.getProdKey.launch(arrayOf("*/*")) }
)
binding.optionsList.apply {
binding.homeSettingsList.apply {
layoutManager = LinearLayoutManager(requireContext())
adapter = HomeOptionAdapter(requireActivity() as AppCompatActivity, optionsList)
adapter = HomeSettingAdapter(requireActivity() as AppCompatActivity, optionsList)
}
setInsets()
@ -110,7 +110,7 @@ class OptionsFragment : Fragment() {
}
private fun setInsets() =
ViewCompat.setOnApplyWindowInsetsListener(binding.scrollViewOptions) { view: View, windowInsets: WindowInsetsCompat ->
ViewCompat.setOnApplyWindowInsetsListener(binding.scrollViewSettings) { view: View, windowInsets: WindowInsetsCompat ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
view.setPadding(
insets.left,

View File

@ -3,7 +3,7 @@
package org.yuzu.yuzu_emu.model
data class HomeOption(
data class HomeSetting(
val titleId: Int,
val descriptionId: Int,
val iconId: Int,

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_view_options"
android:id="@+id/scroll_view_settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
@ -21,7 +21,7 @@
android:src="@drawable/ic_yuzu_full" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/options_list"
android:id="@+id/home_settings_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -7,8 +7,8 @@
android:title="@string/home_games" />
<item
android:id="@+id/optionsFragment"
android:icon="@drawable/ic_options"
android:title="@string/home_options" />
android:id="@+id/homeSettingsFragment"
android:icon="@drawable/ic_settings"
android:title="@string/home_settings" />
</menu>

View File

@ -10,9 +10,9 @@
android:label="PlatformGamesFragment" />
<fragment
android:id="@+id/optionsFragment"
android:name="org.yuzu.yuzu_emu.fragments.OptionsFragment"
android:label="OptionsFragment" />
android:id="@+id/homeSettingsFragment"
android:name="org.yuzu.yuzu_emu.fragments.HomeSettingsFragment"
android:label="HomeSettingsFragment" />
<fragment
android:id="@+id/firstTimeSetupFragment"

View File

@ -26,7 +26,7 @@
<!-- Home strings -->
<string name="home_games">Games</string>
<string name="home_options">Options</string>
<string name="home_settings">Settings</string>
<string name="add_games">Add Games</string>
<string name="add_games_description">Select your games folder</string>
<string name="home_search_games">Search Games</string>
@ -41,7 +41,7 @@
<string name="install_amiibo_keys_failure">Keys file (key_retail.bin) is invalid</string>
<string name="install_gpu_driver">Install GPU Driver</string>
<string name="install_gpu_driver_description">Use a different driver for potentially better performance or accuracy</string>
<string name="settings">Settings</string>
<string name="advanced_settings">Advanced Settings</string>
<string name="settings_description">Configure emulator settings</string>
<!-- General settings strings -->