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 =
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 = {
if (appList.isNotEmpty() && filterText.isNotEmpty()) {
LazyColumn(
modifier = Modifier.fillMaxSize()
) {
if (appList.isNotEmpty()) {
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() }
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
)
)
}
}
)
}

View File

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

View File

@ -93,6 +93,8 @@
<string name="reset">Reset</string>
<string name="patch">Patch</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="apply">Apply</string>
<string name="help">Help</string>