关于页源代码改为作者 Gitea 链接并新增开源许可页面
This commit is contained in:
@@ -216,6 +216,26 @@ fun AppNavigation(
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
cn.airnan.a2fair.ui.settings.AboutScreen(
|
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() }
|
onNavigateBack = { appState.navController.popBackStack() }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ import cn.airnan.a2fair.R
|
|||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun AboutScreen(
|
fun AboutScreen(
|
||||||
onNavigateBack: () -> Unit
|
onNavigateBack: () -> Unit,
|
||||||
|
onNavigateToLicenses: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
@@ -87,18 +88,16 @@ fun AboutScreen(
|
|||||||
|
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(R.string.source_code)) },
|
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 {
|
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)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(R.string.open_source_licenses)) },
|
headlineContent = { Text(stringResource(R.string.open_source_licenses)) },
|
||||||
modifier = Modifier.clickable {
|
modifier = Modifier.clickable { onNavigateToLicenses() }
|
||||||
// TODO: Implement license viewer or navigation
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -152,7 +152,8 @@
|
|||||||
<string name="app_icon">应用图标</string>
|
<string name="app_icon">应用图标</string>
|
||||||
<string name="version_format">版本 %s</string>
|
<string name="version_format">版本 %s</string>
|
||||||
<string name="source_code">源代码</string>
|
<string name="source_code">源代码</string>
|
||||||
<string name="view_on_github">在 GitHub 上查看</string>
|
<string name="view_on_gitea">在作者的 Gitea 上查看</string>
|
||||||
|
<string name="licenses_desc">本应用使用了以下开源项目。</string>
|
||||||
<string name="open_source_licenses">开源许可</string>
|
<string name="open_source_licenses">开源许可</string>
|
||||||
<string name="copyright">© 2026 2FAir</string>
|
<string name="copyright">© 2026 2FAir</string>
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,8 @@
|
|||||||
<string name="app_icon">應用程式圖示</string>
|
<string name="app_icon">應用程式圖示</string>
|
||||||
<string name="version_format">版本 %s</string>
|
<string name="version_format">版本 %s</string>
|
||||||
<string name="source_code">原始碼</string>
|
<string name="source_code">原始碼</string>
|
||||||
<string name="view_on_github">在 GitHub 上檢視</string>
|
<string name="view_on_gitea">在作者的 Gitea 上檢視</string>
|
||||||
|
<string name="licenses_desc">本應用程式使用了以下開放原始碼專案。</string>
|
||||||
<string name="open_source_licenses">開放原始碼授權</string>
|
<string name="open_source_licenses">開放原始碼授權</string>
|
||||||
<string name="copyright">© 2026 2FAir</string>
|
<string name="copyright">© 2026 2FAir</string>
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,8 @@
|
|||||||
<string name="app_icon">App Icon</string>
|
<string name="app_icon">App Icon</string>
|
||||||
<string name="version_format">Version %s</string>
|
<string name="version_format">Version %s</string>
|
||||||
<string name="source_code">Source Code</string>
|
<string name="source_code">Source Code</string>
|
||||||
<string name="view_on_github">View on GitHub</string>
|
<string name="view_on_gitea">View on author\'s Gitea</string>
|
||||||
|
<string name="licenses_desc">This app is built with the help of the following open source projects.</string>
|
||||||
<string name="open_source_licenses">Open Source Licenses</string>
|
<string name="open_source_licenses">Open Source Licenses</string>
|
||||||
<string name="copyright">© 2026 2FAir</string>
|
<string name="copyright">© 2026 2FAir</string>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user