Add an option to filter files parsed as invalid

This commit is contained in:
Abandoned Cart
2023-05-05 06:38:42 -04:00
committed by Niccolò Betto
parent d6252a946b
commit 4316d651eb
4 changed files with 12 additions and 1 deletions

View File

@ -216,7 +216,10 @@ class MainActivity : AppCompatActivity() {
private fun sortGameList(gameList : List<AppEntry>) : List<AppEntry> { private fun sortGameList(gameList : List<AppEntry>) : List<AppEntry> {
val sortedApps : MutableList<AppEntry> = mutableListOf() val sortedApps : MutableList<AppEntry> = mutableListOf()
gameList.forEach { entry -> sortedApps.add(entry) } gameList.forEach { entry ->
if (!appSettings.filterInvalidFiles || entry.loaderResult != LoaderResult.ParsingError)
sortedApps.add(entry)
}
when (appSettings.sortAppsBy) { when (appSettings.sortAppsBy) {
SortingOrder.AlphabeticalAsc.ordinal -> sortedApps.sortBy { it.name } SortingOrder.AlphabeticalAsc.ordinal -> sortedApps.sortBy { it.name }
SortingOrder.AlphabeticalDesc.ordinal -> sortedApps.sortByDescending { it.name } SortingOrder.AlphabeticalDesc.ordinal -> sortedApps.sortByDescending { it.name }

View File

@ -25,6 +25,7 @@ class AppSettings @Inject constructor(@ApplicationContext private val context :
var layoutType by sharedPreferences(context, 1) var layoutType by sharedPreferences(context, 1)
var sortAppsBy by sharedPreferences(context, 0) var sortAppsBy by sharedPreferences(context, 0)
var selectAction by sharedPreferences(context, false) var selectAction by sharedPreferences(context, false)
var filterInvalidFiles by sharedPreferences(context, false)
// Input // Input
var onScreenControl by sharedPreferences(context, true) var onScreenControl by sharedPreferences(context, true)

View File

@ -59,6 +59,8 @@
<string name="select_action">Always Show Game Information</string> <string name="select_action">Always Show Game Information</string>
<string name="select_action_desc_on">Game information will be shown on clicking a game</string> <string name="select_action_desc_on">Game information will be shown on clicking a game</string>
<string name="select_action_desc_off">Game information will only be shown on long-clicking a game</string> <string name="select_action_desc_off">Game information will only be shown on long-clicking a game</string>
<string name="filter_invalid_files_desc_off">Show files that have been parsed as invalid</string>
<string name="filter_invalid_files_desc_on">Hide files that have been parsed as invalid</string>
<!-- Settings - Game --> <!-- Settings - Game -->
<string name="game">Game</string> <string name="game">Game</string>
<string name="use_custom_settings">Enable Custom Settings</string> <string name="use_custom_settings">Enable Custom Settings</string>

View File

@ -57,5 +57,10 @@
android:summaryOn="@string/select_action_desc_on" android:summaryOn="@string/select_action_desc_on"
app:key="select_action" app:key="select_action"
app:title="@string/select_action" /> app:title="@string/select_action" />
<emu.skyline.preference.RefreshSwitchPreferenceCompat
android:defaultValue="false"
android:summaryOff="@string/filter_invalid_files_desc_off"
android:summaryOn="@string/filter_invalid_files_desc_on"
app:key="filter_invalid_files" />
</PreferenceCategory> </PreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>