diff --git a/manager/app/build.gradle.kts b/manager/app/build.gradle.kts index d92e22ae..4849d872 100644 --- a/manager/app/build.gradle.kts +++ b/manager/app/build.gradle.kts @@ -88,6 +88,8 @@ dependencies { implementation("com.github.alorma:compose-settings-ui-m3:0.22.0") + implementation("com.github.ireward:compose-html:1.0.2") + ksp("io.github.raamcosta.compose-destinations:ksp:$composeDestinationsVersion") testImplementation("junit:junit:4.13.2") diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/component/AboutCard.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/component/AboutCard.kt new file mode 100644 index 00000000..0dde70b3 --- /dev/null +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/component/AboutCard.kt @@ -0,0 +1,107 @@ +package me.weishu.kernelsu.ui.component + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.ElevatedCard +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.* +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalUriHandler +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.window.Dialog +import androidx.core.content.res.ResourcesCompat +import com.google.accompanist.drawablepainter.rememberDrawablePainter +import com.ireward.htmlcompose.HtmlText +import me.weishu.kernelsu.BuildConfig +import me.weishu.kernelsu.R + +@Preview +@Composable +fun AboutCard() { + ElevatedCard( + modifier = Modifier + .fillMaxWidth(), + shape = RoundedCornerShape(8.dp), + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(24.dp) + ) { + AboutCardContent() + } + } +} + +@Composable +fun AboutDialog(showAboutDialog: MutableState) { + if (showAboutDialog.value) { + Dialog(onDismissRequest = { showAboutDialog.value = false }) { + AboutCard() + } + } +} + +@Composable +private fun AboutCardContent() { + Column( + modifier = Modifier + .fillMaxWidth() + ) { + CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyMedium) { + + val drawable = ResourcesCompat.getDrawable( + LocalContext.current.resources, + R.mipmap.ic_launcher, + LocalContext.current.theme + ) + + Row { + Image( + painter = rememberDrawablePainter(drawable), + contentDescription = "icon", + modifier = Modifier.size(40.dp) + ) + + Spacer(modifier = Modifier.width(12.dp)) + + Column { + + Text( + stringResource(id = R.string.app_name), + style = MaterialTheme.typography.titleSmall, + fontSize = 18.sp + ) + Text( + BuildConfig.VERSION_NAME, + style = MaterialTheme.typography.bodySmall, + fontSize = 14.sp + ) + + Spacer(modifier = Modifier.height(8.dp)) + + val uriHandler = LocalUriHandler.current + HtmlText( + text = stringResource( + id = R.string.about_source_code, + "GitHub", + "Telegram" + ), + linkClicked = { + uriHandler.openUri(it) + }, + style = MaterialTheme.typography.bodyMedium, + fontSize = 16.sp, + ) + } + } + } + } +} \ No newline at end of file diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt index 87833160..e458ed3b 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt @@ -62,7 +62,7 @@ fun HomeScreen(navigator: DestinationsNavigator) { StatusCard(kernelVersion, ksuVersion) InfoCard() DonateCard() - AboutCard() + LearnMoreCard() Spacer(Modifier) } } @@ -205,7 +205,7 @@ private fun StatusCard(kernelVersion: KernelVersion, ksuVersion: Int?) { } @Composable -fun AboutCard() { +fun LearnMoreCard() { val uriHandler = LocalUriHandler.current ElevatedCard { diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt index 88ce0c3d..e3176ef7 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt @@ -14,7 +14,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color.Companion.White import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties @@ -27,8 +26,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import me.weishu.kernelsu.BuildConfig import me.weishu.kernelsu.R -import me.weishu.kernelsu.ui.component.SimpleDialog -import me.weishu.kernelsu.ui.util.LinkifyText +import me.weishu.kernelsu.ui.component.AboutDialog import me.weishu.kernelsu.ui.util.LocalDialogHost import me.weishu.kernelsu.ui.util.getBugreportFile @@ -49,9 +47,8 @@ fun SettingScreen(navigator: DestinationsNavigator) { } ) { paddingValues -> - SimpleDialog { - SupportCard() - } + val showAboutDialog = remember { mutableStateOf(false) } + AboutDialog(showAboutDialog) var showLoadingDialog by remember { mutableStateOf(false) } LoadingDialog(showLoadingDialog) @@ -98,15 +95,12 @@ fun SettingScreen(navigator: DestinationsNavigator) { ) val about = stringResource(id = R.string.about) - val ok = stringResource(id = android.R.string.ok) SettingsMenuLink( title = { Text(about) }, onClick = { - scope.launch { - dialogHost.showDialog(about, content = "unused", confirm = ok) - } + showAboutDialog.value = true } ) } @@ -145,20 +139,4 @@ fun LoadingDialog(showLoadingDialog: Boolean) { CircularProgressIndicator() } } -} - -@Preview -@Composable -private fun SupportCard() { - Column( - modifier = Modifier - .fillMaxWidth() - ) { - CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyMedium) { - LinkifyText("Author: weishu") - LinkifyText("Github: https://github.com/tiann/KernelSU") - LinkifyText("Telegram: https://t.me/KernelSU") - LinkifyText("QQ: https://pd.qq.com/s/8lipl1brp") - } - } } \ No newline at end of file diff --git a/manager/app/src/main/res/values-zh-rCN/strings.xml b/manager/app/src/main/res/values-zh-rCN/strings.xml index c12c9de8..f8263edc 100644 --- a/manager/app/src/main/res/values-zh-rCN/strings.xml +++ b/manager/app/src/main/res/values-zh-rCN/strings.xml @@ -59,4 +59,5 @@ 了解如何安装 KernelSU 以及如何开发模块 支持开发 KernelSU 将保持免费和开源,向开发者捐赠以表示支持。 + 加入我们的 %2$s 频道
加入我们的 QQ 频道]]>
diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml index 3e652f4f..7f9325df 100644 --- a/manager/app/src/main/res/values/strings.xml +++ b/manager/app/src/main/res/values/strings.xml @@ -63,4 +63,5 @@ Learn how to install KernelSU and use modules Support Us KernelSU is, and always will be, free, and open source. You can however show us that you care by making a donation. + Join our %2$s channel]]>