From 3cfa4ea6d621f95c196f1b13e86c8e73283ed422 Mon Sep 17 00:00:00 2001 From: Tyff Date: Thu, 24 Aug 2023 06:05:21 +1200 Subject: [PATCH] feat: more info for the select from application screen (#81) --- .../manager/ui/screen/AppSelectorScreen.kt | 75 ++++++++++++++++--- app/src/main/res/values/plurals.xml | 4 +- app/src/main/res/values/strings.xml | 2 + 3 files changed, 67 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/app/revanced/manager/ui/screen/AppSelectorScreen.kt b/app/src/main/java/app/revanced/manager/ui/screen/AppSelectorScreen.kt index 14d5d08d..f1a71e59 100644 --- a/app/src/main/java/app/revanced/manager/ui/screen/AppSelectorScreen.kt +++ b/app/src/main/java/app/revanced/manager/ui/screen/AppSelectorScreen.kt @@ -49,7 +49,11 @@ fun AppSelectorScreen( val pickApkLauncher = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri -> uri?.let { apkUri -> - vm.loadSelectedFile(apkUri)?.let(onStorageClick) ?: context.toast(context.getString(R.string.failed_to_load_apk)) + vm.loadSelectedFile(apkUri)?.let(onStorageClick) ?: context.toast( + context.getString( + R.string.failed_to_load_apk + ) + ) } } @@ -85,28 +89,62 @@ fun AppSelectorScreen( } }, content = { - LazyColumn( - modifier = Modifier.fillMaxSize() - ) { - if (appList.isNotEmpty()) { + + if (appList.isNotEmpty() && filterText.isNotEmpty()) { + + LazyColumn( + modifier = Modifier.fillMaxSize() + ) { + items( items = filteredAppList, key = { it.packageName } ) { app -> - ListItem( modifier = Modifier.clickable { onAppClick(app.packageName) }, - leadingContent = { AppIcon(app.packageInfo, null, Modifier.size(36.dp)) }, + leadingContent = { + AppIcon( + app.packageInfo, + null, + Modifier.size(36.dp) + ) + }, headlineContent = { AppLabel(app.packageInfo) }, supportingContent = { Text(app.packageName) }, - trailingContent = app.patches?.let { { Text(pluralStringResource(R.plurals.patches_count, it, it)) } } + trailingContent = app.patches?.let { + { + Text( + pluralStringResource( + R.plurals.patches_count, + it, + it + ) + ) + } + } ) } - } else { - item { LoadingIndicator() } + } + } else { + Column( + modifier = Modifier.fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Icon( + imageVector = Icons.Outlined.Search, + contentDescription = stringResource(R.string.search), + modifier = Modifier.size(64.dp) + ) + + Text( + text = stringResource(R.string.type_anything), + style = MaterialTheme.typography.bodyLarge + ) } } + } ) } @@ -146,7 +184,10 @@ fun AppSelectorScreen( ) } }, - headlineContent = { Text(stringResource(R.string.select_from_storage)) } + headlineContent = { Text(stringResource(R.string.select_from_storage)) }, + supportingContent = { + Text(stringResource(R.string.select_from_storage_description)) + } ) Divider() } @@ -162,7 +203,17 @@ fun AppSelectorScreen( leadingContent = { AppIcon(app.packageInfo, null, Modifier.size(36.dp)) }, headlineContent = { AppLabel(app.packageInfo) }, supportingContent = { Text(app.packageName) }, - trailingContent = app.patches?.let { { Text(pluralStringResource(R.plurals.patches_count, it, it)) } } + trailingContent = app.patches?.let { + { + Text( + pluralStringResource( + R.plurals.patches_count, + it, + it + ) + ) + } + } ) } diff --git a/app/src/main/res/values/plurals.xml b/app/src/main/res/values/plurals.xml index 697bce97..c64f7d97 100644 --- a/app/src/main/res/values/plurals.xml +++ b/app/src/main/res/values/plurals.xml @@ -1,8 +1,8 @@ - %d Patch - %d Patches + %d patch + %d patches %d applied patch diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5517915f..73c2a734 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -93,6 +93,8 @@ Reset Patch Select from storage + Select an APK file from storage using file picker + Type anything to continue Search Apply Help