From c070a588b9ee286d2b5844b615e53026e8e5bd5a Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Thu, 27 Apr 2023 22:59:01 -0400 Subject: [PATCH] android: Change organization of the settings tab in the home screen --- ...OptionAdapter.kt => HomeSettingAdapter.kt} | 10 +-- ...onsFragment.kt => HomeSettingsFragment.kt} | 62 +++++++++---------- .../model/{HomeOption.kt => HomeSetting.kt} | 2 +- ...options.xml => fragment_home_settings.xml} | 4 +- .../app/src/main/res/menu/menu_navigation.xml | 6 +- .../main/res/navigation/home_navigation.xml | 6 +- .../app/src/main/res/values/strings.xml | 4 +- 7 files changed, 47 insertions(+), 47 deletions(-) rename src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/{HomeOptionAdapter.kt => HomeSettingAdapter.kt} (84%) rename src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/{OptionsFragment.kt => HomeSettingsFragment.kt} (83%) rename src/android/app/src/main/java/org/yuzu/yuzu_emu/model/{HomeOption.kt => HomeSetting.kt} (90%) rename src/android/app/src/main/res/layout/{fragment_options.xml => fragment_home_settings.xml} (91%) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeOptionAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt similarity index 84% rename from src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeOptionAdapter.kt rename to src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt index 2bec2de87..2b3956e6d 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeOptionAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt @@ -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) : - RecyclerView.Adapter(), +class HomeSettingAdapter(private val activity: AppCompatActivity, var options: List) : + RecyclerView.Adapter(), 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) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/OptionsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt similarity index 83% rename from src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/OptionsFragment.kt rename to src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt index 1cf0d0f52..aba2a188e 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/OptionsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt @@ -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 = 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 = 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, diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeOption.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt similarity index 90% rename from src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeOption.kt rename to src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt index c995ff12c..7049f2fa5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeOption.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt @@ -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, diff --git a/src/android/app/src/main/res/layout/fragment_options.xml b/src/android/app/src/main/res/layout/fragment_home_settings.xml similarity index 91% rename from src/android/app/src/main/res/layout/fragment_options.xml rename to src/android/app/src/main/res/layout/fragment_home_settings.xml index 3bae8b0c4..e0c609309 100644 --- a/src/android/app/src/main/res/layout/fragment_options.xml +++ b/src/android/app/src/main/res/layout/fragment_home_settings.xml @@ -1,7 +1,7 @@ diff --git a/src/android/app/src/main/res/menu/menu_navigation.xml b/src/android/app/src/main/res/menu/menu_navigation.xml index ca5a656a6..e46133604 100644 --- a/src/android/app/src/main/res/menu/menu_navigation.xml +++ b/src/android/app/src/main/res/menu/menu_navigation.xml @@ -7,8 +7,8 @@ android:title="@string/home_games" /> + android:id="@+id/homeSettingsFragment" + android:icon="@drawable/ic_settings" + android:title="@string/home_settings" /> diff --git a/src/android/app/src/main/res/navigation/home_navigation.xml b/src/android/app/src/main/res/navigation/home_navigation.xml index d0077bbea..d500d165b 100644 --- a/src/android/app/src/main/res/navigation/home_navigation.xml +++ b/src/android/app/src/main/res/navigation/home_navigation.xml @@ -10,9 +10,9 @@ android:label="PlatformGamesFragment" /> + android:id="@+id/homeSettingsFragment" + android:name="org.yuzu.yuzu_emu.fragments.HomeSettingsFragment" + android:label="HomeSettingsFragment" /> Games - Options + Settings Add Games Select your games folder Search Games @@ -41,7 +41,7 @@ Keys file (key_retail.bin) is invalid Install GPU Driver Use a different driver for potentially better performance or accuracy - Settings + Advanced Settings Configure emulator settings