Hide Debug preferences from search on release builds and remove settings that don't support per-game configuration instead of hiding them

This commit is contained in:
PabloG02 2023-03-24 15:08:54 +01:00 committed by Billy Laws
parent 44cbf26b72
commit ef5456f939
2 changed files with 11 additions and 4 deletions

View File

@ -73,8 +73,10 @@ class GameSettingsFragment : PreferenceFragmentCompat() {
findPreference<GpuDriverPreference>("gpu_driver")?.item = item findPreference<GpuDriverPreference>("gpu_driver")?.item = item
// Hide settings that don't support per-game configuration // Hide settings that don't support per-game configuration
findPreference<Preference>("profile_picture_value")?.isVisible = false var prefToRemove = findPreference<Preference>("profile_picture_value")
findPreference<Preference>("log_level")?.isVisible = false prefToRemove?.parent?.removePreference(prefToRemove)
prefToRemove = findPreference<Preference>("log_level")
prefToRemove?.parent?.removePreference(prefToRemove)
// TODO: remove this once we have more settings under the debug category // TODO: remove this once we have more settings under the debug category
// Avoid showing the debug category if no settings under it are visible // Avoid showing the debug category if no settings under it are visible

View File

@ -24,6 +24,7 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.forEach import androidx.preference.forEach
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.internal.ToolbarUtils import com.google.android.material.internal.ToolbarUtils
import emu.skyline.BuildConfig
import emu.skyline.R import emu.skyline.R
import emu.skyline.data.AppItemTag import emu.skyline.data.AppItemTag
import emu.skyline.databinding.SettingsActivityBinding import emu.skyline.databinding.SettingsActivityBinding
@ -37,7 +38,11 @@ private const val PREFERENCE_DIALOG_FRAGMENT_TAG = "androidx.preference.Preferen
class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback { class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback {
val binding by lazy { SettingsActivityBinding.inflate(layoutInflater) } val binding by lazy { SettingsActivityBinding.inflate(layoutInflater) }
val creditsCategories = arrayOf("category_credits", "category_licenses") val hiddenCategoriesFromSearch = if (BuildConfig.BUILD_TYPE == "release") {
arrayOf("category_debug", "category_credits", "category_licenses")
} else {
arrayOf("category_credits", "category_licenses")
}
/** /**
* The instance of [PreferenceFragmentCompat] that is shown inside [R.id.settings] * The instance of [PreferenceFragmentCompat] that is shown inside [R.id.settings]
@ -141,7 +146,7 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
val queries = newText.split(",") val queries = newText.split(",")
if (newText.isNotEmpty()) { if (newText.isNotEmpty()) {
preferenceFragment.preferenceScreen.forEach { preferenceCategory -> preferenceFragment.preferenceScreen.forEach { preferenceCategory ->
if (creditsCategories.contains(preferenceCategory.key)) { if (hiddenCategoriesFromSearch.contains(preferenceCategory.key)) {
preferenceCategory.isVisible = false preferenceCategory.isVisible = false
return@forEach return@forEach
} }