Set to Unknown if name of lib is not define

This commit is contained in:
MrSluffy
2023-11-20 19:39:26 +08:00
parent e994660cb0
commit 71e6b28755
2 changed files with 12 additions and 7 deletions

View File

@@ -66,8 +66,11 @@ fun NavGraphBuilder.licensesGraph(route: String) {
fun Acknowledgements() {
val ossLibraries by LocalPreferenceInteractor.current.ossLibraries.collectAsState()
LoadingScreen(ossLibraries) { libraries ->
val filteredLibraries = libraries.map {
it.copy(name = it.name ?: "Unknown")
}
PreferenceLayoutLazyColumn(label = stringResource(id = R.string.acknowledgements)) {
preferenceGroupItems(libraries, isFirstChild = true) { index, library ->
preferenceGroupItems(filteredLibraries, isFirstChild = true) { index, library ->
OssLibraryItem(
ossLibrary = library,
index = index,
@@ -84,11 +87,13 @@ fun OssLibraryItem(ossLibrary: OssLibrary, index: Int) {
PreferenceTemplate(
title = {
Text(
text = ossLibrary.name,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
ossLibrary.name?.let {
Text(
text = it,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
},
modifier = Modifier
.clickable { navController.navigate(route = destination) },

View File

@@ -72,7 +72,7 @@ fun loadNotice(ossLibrary: OssLibrary): State<OssLibraryWithNotice?> {
data class OssLibrary(
val groupId: String,
val artifactId: String,
val name: String,
val name: String? = null,
val spdxLicenses: List<License>? = null,
val unknownLicenses: List<License>? = null,
) {