yuzu-emu
/
yuzu-mainline
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.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.yuzu.yuzu_emu.databinding.CardHomeOptionBinding 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>) : class HomeSettingAdapter(private val activity: AppCompatActivity, var options: List<HomeSetting>) :
RecyclerView.Adapter<HomeOptionAdapter.HomeOptionViewHolder>(), RecyclerView.Adapter<HomeSettingAdapter.HomeOptionViewHolder>(),
View.OnClickListener { View.OnClickListener {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeOptionViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeOptionViewHolder {
val binding = CardHomeOptionBinding.inflate(LayoutInflater.from(parent.context), parent, false) 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) : inner class HomeOptionViewHolder(val binding: CardHomeOptionBinding) :
RecyclerView.ViewHolder(binding.root) { RecyclerView.ViewHolder(binding.root) {
lateinit var option: HomeOption lateinit var option: HomeSetting
init { init {
itemView.tag = this itemView.tag = this
} }
fun bind(option: HomeOption) { fun bind(option: HomeSetting) {
this.option = option this.option = option
binding.optionTitle.text = activity.resources.getString(option.titleId) binding.optionTitle.text = activity.resources.getString(option.titleId)
binding.optionDescription.text = activity.resources.getString(option.descriptionId) 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 androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.adapters.HomeOptionAdapter import org.yuzu.yuzu_emu.adapters.HomeSettingAdapter
import org.yuzu.yuzu_emu.databinding.FragmentOptionsBinding import org.yuzu.yuzu_emu.databinding.FragmentHomeSettingsBinding
import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile 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.ui.main.MainActivity
import org.yuzu.yuzu_emu.utils.GpuDriverHelper import org.yuzu.yuzu_emu.utils.GpuDriverHelper
class OptionsFragment : Fragment() { class HomeSettingsFragment : Fragment() {
private var _binding: FragmentOptionsBinding? = null private var _binding: FragmentHomeSettingsBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private lateinit var mainActivity: MainActivity private lateinit var mainActivity: MainActivity
@ -36,44 +36,44 @@ class OptionsFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View { ): View {
_binding = FragmentOptionsBinding.inflate(layoutInflater) _binding = FragmentHomeSettingsBinding.inflate(layoutInflater)
return binding.root return binding.root
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
mainActivity = requireActivity() as MainActivity mainActivity = requireActivity() as MainActivity
val optionsList: List<HomeOption> = listOf( val optionsList: List<HomeSetting> = listOf(
HomeOption( HomeSetting(
R.string.add_games, R.string.advanced_settings,
R.string.add_games_description, R.string.settings_description,
R.drawable.ic_add R.drawable.ic_settings
) { mainActivity.getGamesDirectory.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data) }, ) { SettingsActivity.launch(requireContext(), SettingsFile.FILE_NAME_CONFIG, "") },
HomeOption( HomeSetting(
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(
R.string.install_gpu_driver, R.string.install_gpu_driver,
R.string.install_gpu_driver_description, R.string.install_gpu_driver_description,
R.drawable.ic_input R.drawable.ic_input
) { driverInstaller() }, ) { driverInstaller() },
HomeOption( HomeSetting(
R.string.settings, R.string.install_amiibo_keys,
R.string.settings_description, R.string.install_amiibo_keys_description,
R.drawable.ic_settings R.drawable.ic_nfc
) { SettingsActivity.launch(requireContext(), SettingsFile.FILE_NAME_CONFIG, "") } ) { 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()) layoutManager = LinearLayoutManager(requireContext())
adapter = HomeOptionAdapter(requireActivity() as AppCompatActivity, optionsList) adapter = HomeSettingAdapter(requireActivity() as AppCompatActivity, optionsList)
} }
setInsets() setInsets()
@ -110,7 +110,7 @@ class OptionsFragment : Fragment() {
} }
private fun setInsets() = 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()) val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
view.setPadding( view.setPadding(
insets.left, insets.left,

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@
<!-- Home strings --> <!-- Home strings -->
<string name="home_games">Games</string> <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">Add Games</string>
<string name="add_games_description">Select your games folder</string> <string name="add_games_description">Select your games folder</string>
<string name="home_search_games">Search Games</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_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">Install GPU Driver</string>
<string name="install_gpu_driver_description">Use a different driver for potentially better performance or accuracy</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> <string name="settings_description">Configure emulator settings</string>
<!-- General settings strings --> <!-- General settings strings -->