feat: more info for the select from application screen (#81)

This commit is contained in:
Tyff 2023-08-24 06:05:21 +12:00 committed by GitHub
parent f01adf5eb0
commit 3cfa4ea6d6
3 changed files with 67 additions and 14 deletions

View File

@ -49,7 +49,11 @@ fun AppSelectorScreen(
val pickApkLauncher = val pickApkLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri -> rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri ->
uri?.let { apkUri -> 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 = { content = {
LazyColumn(
modifier = Modifier.fillMaxSize() if (appList.isNotEmpty() && filterText.isNotEmpty()) {
) {
if (appList.isNotEmpty()) { LazyColumn(
modifier = Modifier.fillMaxSize()
) {
items( items(
items = filteredAppList, items = filteredAppList,
key = { it.packageName } key = { it.packageName }
) { app -> ) { app ->
ListItem( ListItem(
modifier = Modifier.clickable { onAppClick(app.packageName) }, 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) }, headlineContent = { AppLabel(app.packageInfo) },
supportingContent = { Text(app.packageName) }, 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() Divider()
} }
@ -162,7 +203,17 @@ fun AppSelectorScreen(
leadingContent = { AppIcon(app.packageInfo, null, Modifier.size(36.dp)) }, leadingContent = { AppIcon(app.packageInfo, null, Modifier.size(36.dp)) },
headlineContent = { AppLabel(app.packageInfo) }, headlineContent = { AppLabel(app.packageInfo) },
supportingContent = { Text(app.packageName) }, 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
)
)
}
}
) )
} }

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<plurals name="patches_count"> <plurals name="patches_count">
<item quantity="one">%d Patch</item> <item quantity="one">%d patch</item>
<item quantity="other">%d Patches</item> <item quantity="other">%d patches</item>
</plurals> </plurals>
<plurals name="applied_patches"> <plurals name="applied_patches">
<item quantity="one">%d applied patch</item> <item quantity="one">%d applied patch</item>

View File

@ -93,6 +93,8 @@
<string name="reset">Reset</string> <string name="reset">Reset</string>
<string name="patch">Patch</string> <string name="patch">Patch</string>
<string name="select_from_storage">Select from storage</string> <string name="select_from_storage">Select from storage</string>
<string name="select_from_storage_description">Select an APK file from storage using file picker</string>
<string name="type_anything">Type anything to continue</string>
<string name="search">Search</string> <string name="search">Search</string>
<string name="apply">Apply</string> <string name="apply">Apply</string>
<string name="help">Help</string> <string name="help">Help</string>