关于页源代码改为作者 Gitea 链接并新增开源许可页面

This commit is contained in:
2026-10-14 12:14:28 +08:00
parent 86cd6fb3dc
commit 1caf879d27
6 changed files with 173 additions and 9 deletions
@@ -216,6 +216,26 @@ fun AppNavigation(
}
) {
cn.airnan.a2fair.ui.settings.AboutScreen(
onNavigateBack = { appState.navController.popBackStack() },
onNavigateToLicenses = { appState.navController.navigate("licenses") }
)
}
composable(
route = "licenses",
enterTransition = {
slideInHorizontally(initialOffsetX = { it }, animationSpec = tween(animDuration))
},
exitTransition = {
slideOutHorizontally(targetOffsetX = { -it / 3 }, animationSpec = tween(animDuration))
},
popEnterTransition = {
slideInHorizontally(initialOffsetX = { -it / 3 }, animationSpec = tween(animDuration))
},
popExitTransition = {
slideOutHorizontally(targetOffsetX = { it }, animationSpec = tween(animDuration))
}
) {
cn.airnan.a2fair.ui.settings.OpenSourceLicensesScreen(
onNavigateBack = { appState.navController.popBackStack() }
)
}
@@ -34,7 +34,8 @@ import cn.airnan.a2fair.R
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AboutScreen(
onNavigateBack: () -> Unit
onNavigateBack: () -> Unit,
onNavigateToLicenses: () -> Unit = {}
) {
val context = LocalContext.current
@@ -87,18 +88,16 @@ fun AboutScreen(
ListItem(
headlineContent = { Text(stringResource(R.string.source_code)) },
supportingContent = { Text(stringResource(R.string.view_on_github)) },
supportingContent = { Text(stringResource(R.string.view_on_gitea)) },
modifier = Modifier.clickable {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/"))
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://git.airnan.cn/wangairnan/2FAir"))
context.startActivity(intent)
}
)
ListItem(
headlineContent = { Text(stringResource(R.string.open_source_licenses)) },
modifier = Modifier.clickable {
// TODO: Implement license viewer or navigation
}
modifier = Modifier.clickable { onNavigateToLicenses() }
)
Spacer(modifier = Modifier.weight(1f))
@@ -0,0 +1,142 @@
package cn.airnan.a2fair.ui.settings
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import cn.airnan.a2fair.R
private data class LibraryLicense(
val name: String,
val url: String
)
private data class LicenseGroup(
val license: String,
val licenseUrl: String,
val libraries: List<LibraryLicense>
)
private val APACHE_2_0_URL = "https://www.apache.org/licenses/LICENSE-2.0"
private val licenseGroups = listOf(
LicenseGroup(
license = "Apache License 2.0",
licenseUrl = APACHE_2_0_URL,
libraries = listOf(
LibraryLicense(
name = "AndroidX & Jetpack Compose",
url = "https://developer.android.com/jetpack"
),
LibraryLicense(
name = "Material Components for Android",
url = "https://github.com/material-components/material-components-android"
),
LibraryLicense(
name = "Kotlin & Coroutines",
url = "https://github.com/JetBrains/kotlin"
),
LibraryLicense(
name = "KSP (Kotlin Symbol Processing)",
url = "https://github.com/google/ksp"
),
LibraryLicense(
name = "ZXing Core",
url = "https://github.com/zxing/zxing"
),
LibraryLicense(
name = "Gson",
url = "https://github.com/google/gson"
)
)
),
LicenseGroup(
license = "ML Kit Terms of Service",
licenseUrl = "https://developers.google.com/ml-kit/terms",
libraries = listOf(
LibraryLicense(
name = "ML Kit Barcode Scanning",
url = "https://developers.google.com/ml-kit"
)
)
)
)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun OpenSourceLicensesScreen(
onNavigateBack: () -> Unit
) {
val context = LocalContext.current
val openUrl: (String) -> Unit = { url ->
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
}
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(R.string.open_source_licenses)) },
navigationIcon = {
IconButton(onClick = onNavigateBack) {
Icon(Icons.Default.ArrowBack, contentDescription = stringResource(R.string.back))
}
}
)
}
) { padding ->
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(padding)
) {
item {
Text(
text = stringResource(R.string.licenses_desc),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 8.dp)
)
}
licenseGroups.forEach { group ->
item(key = "license_${group.license}") {
ListItem(
headlineContent = { Text(group.license) },
supportingContent = { Text(group.licenseUrl, maxLines = 1, overflow = TextOverflow.Ellipsis) },
modifier = Modifier.clickable { openUrl(group.licenseUrl) }
)
HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
}
items(group.libraries, key = { "lib_${group.license}_${it.name}" }) { library ->
ListItem(
headlineContent = { Text(library.name) },
supportingContent = { Text(library.url, maxLines = 1, overflow = TextOverflow.Ellipsis) },
modifier = Modifier.clickable { openUrl(library.url) }
)
HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
}
}
}
}
}