diff --git a/app/src/main/kotlin/li/songe/gkd/MainActivity.kt b/app/src/main/kotlin/li/songe/gkd/MainActivity.kt index 643b9c9d4..a80892744 100644 --- a/app/src/main/kotlin/li/songe/gkd/MainActivity.kt +++ b/app/src/main/kotlin/li/songe/gkd/MainActivity.kt @@ -258,7 +258,7 @@ private fun ShizukuErrorDialog(stateFlow: MutableStateFlow) { } else { TextButton(onClick = { stateFlow.value = false - app.openUri("https://gkd.li?r=4") + openUri("https://gkd.li?r=4") }) { Text(text = "去下载") } diff --git a/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt index 8bc4ff290..714f13ed0 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt @@ -113,7 +113,7 @@ fun AboutPage() { Column { Text(text = "代码记录") Text( - modifier = Modifier.clickable { context.openUri(META.commitUrl) }, + modifier = Modifier.clickable { openUri(META.commitUrl) }, text = META.commitId.substring(0, 16), color = MaterialTheme.colorScheme.primary, style = LocalTextStyle.current.copy(textDecoration = TextDecoration.Underline), @@ -240,7 +240,7 @@ fun AboutPage() { Column( modifier = Modifier .clickable { - context.openUri(REPOSITORY_URL) + openUri(REPOSITORY_URL) } .fillMaxWidth() .itemPadding() @@ -259,7 +259,7 @@ fun AboutPage() { Column( modifier = Modifier .clickable { - context.openUri(ISSUES_URL) + openUri(ISSUES_URL) } .fillMaxWidth() .itemPadding() diff --git a/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt index ce7dcc781..222850b06 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt @@ -237,7 +237,7 @@ fun AdvancedPage() { color = MaterialTheme.colorScheme.primary, style = LocalTextStyle.current.copy(textDecoration = TextDecoration.Underline), modifier = Modifier.clickable(onClick = throttle { - context.openUri("http://127.0.0.1:${store.httpServerPort}") + openUri("http://127.0.0.1:${store.httpServerPort}") }), ) Spacer(modifier = Modifier.width(2.dp)) @@ -249,7 +249,7 @@ fun AdvancedPage() { color = MaterialTheme.colorScheme.primary, style = LocalTextStyle.current.copy(textDecoration = TextDecoration.Underline), modifier = Modifier.clickable(onClick = throttle { - context.openUri("http://${host}:${store.httpServerPort}") + openUri("http://${host}:${store.httpServerPort}") }) ) } @@ -396,7 +396,7 @@ fun AdvancedPage() { subtitle = "生成快照/日志链接", suffix = "获取教程", onSuffixClick = { - context.openUri("https://gkd.li/?r=1") + openUri("https://gkd.li?r=1") }, imageVector = Icons.Default.Edit, onClick = { diff --git a/app/src/main/kotlin/li/songe/gkd/ui/AuthA11yPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/AuthA11yPage.kt index c96dc5a09..620420dee 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/AuthA11yPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/AuthA11yPage.kt @@ -133,7 +133,7 @@ fun AuthA11yPage() { modifier = Modifier .padding(cardHorizontalPadding, 0.dp) .clickable { - context.openUri("https://gkd.li/?r=2") + openUri("https://gkd.li?r=2") }, text = "无法开启无障碍?", style = MaterialTheme.typography.bodySmall, @@ -220,7 +220,7 @@ fun AuthA11yPage() { modifier = Modifier .padding(cardHorizontalPadding, 0.dp) .clickable { - context.openUri("https://gkd.li/?r=2") + openUri("https://gkd.li?r=2") }, text = "其他方式解除限制", style = MaterialTheme.typography.bodySmall, @@ -253,7 +253,7 @@ fun AuthA11yPage() { Text( modifier = Modifier .clickable { - context.openUri("https://gkd.li/?r=3") + openUri("https://gkd.li?r=3") }, text = "运行后授权失败?", style = MaterialTheme.typography.bodySmall, diff --git a/app/src/main/kotlin/li/songe/gkd/ui/ImagePreviewPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/ImagePreviewPage.kt index 4cdb6e79c..4df56192c 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/ImagePreviewPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/ImagePreviewPage.kt @@ -42,7 +42,6 @@ import coil3.request.ImageRequest import coil3.request.crossfade import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.RootGraph -import li.songe.gkd.app import li.songe.gkd.util.LocalNavController import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.imageLoader @@ -87,7 +86,7 @@ fun ImagePreviewPage( val currentUri = showUri ?: uris.getOrNull(state.currentPage) if (currentUri != null && URLUtil.isNetworkUrl(currentUri)) { IconButton(onClick = throttle(fn = { - app.openUri(currentUri) + openUri(currentUri) })) { Icon( imageVector = Icons.AutoMirrored.Outlined.OpenInNew, diff --git a/app/src/main/kotlin/li/songe/gkd/ui/component/InputSubsLinkOption.kt b/app/src/main/kotlin/li/songe/gkd/ui/component/InputSubsLinkOption.kt index 3edaa0053..38815ac9d 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/component/InputSubsLinkOption.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/component/InputSubsLinkOption.kt @@ -1,16 +1,24 @@ package li.songe.gkd.ui.component import android.webkit.URLUtil +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.outlined.HelpOutline import androidx.compose.material3.AlertDialog +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import kotlinx.coroutines.flow.MutableStateFlow +import li.songe.gkd.util.openUri import li.songe.gkd.util.subsItemsFlow import li.songe.gkd.util.throttle import li.songe.gkd.util.toast @@ -71,7 +79,21 @@ class InputSubsLinkOption { val initValue by initValueFlow.collectAsState() AlertDialog( title = { - Text(text = if (initValue.isNotEmpty()) "修改订阅" else "添加订阅") + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier.fillMaxWidth(), + ) { + Text(text = if (initValue.isNotEmpty()) "修改订阅" else "添加订阅") + IconButton(onClick = throttle { + openUri("https://gkd.li?r=5") + }) { + Icon( + imageVector = Icons.AutoMirrored.Outlined.HelpOutline, + contentDescription = null, + ) + } + } }, text = { OutlinedTextField( diff --git a/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt b/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt index 849f6dbcc..35872b4fb 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt @@ -285,7 +285,7 @@ private fun SubsMenuItem( }, onClick = { onExpandedChange(false) - context.openUri(supportUri) + openUri(supportUri) } ) } diff --git a/app/src/main/kotlin/li/songe/gkd/ui/home/ControlPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/home/ControlPage.kt index cfeb0caf6..3e47a33c0 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/home/ControlPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/home/ControlPage.kt @@ -82,7 +82,7 @@ fun useControlPage(): ScaffoldExt { contentDescription = null, ) } - IconButton(onClick = throttle { context.openUri(HOME_PAGE_URL) }) { + IconButton(onClick = throttle { openUri(HOME_PAGE_URL) }) { Icon( imageVector = Icons.AutoMirrored.Outlined.HelpOutline, contentDescription = null, diff --git a/app/src/main/kotlin/li/songe/gkd/util/Github.kt b/app/src/main/kotlin/li/songe/gkd/util/Github.kt index 0b1c4fcf4..838f64732 100644 --- a/app/src/main/kotlin/li/songe/gkd/util/Github.kt +++ b/app/src/main/kotlin/li/songe/gkd/util/Github.kt @@ -35,7 +35,6 @@ import io.ktor.http.HttpMessageBuilder import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import kotlinx.serialization.Serializable -import li.songe.gkd.app import li.songe.gkd.data.GithubPoliciesAsset import java.io.File @@ -160,7 +159,7 @@ fun EditGithubCookieDlg(showEditCookieDlgFlow: MutableStateFlow) { ) { Text(text = "Github Cookie") IconButton(onClick = throttle { - app.openUri("https://gkd.li/?r=1") + openUri("https://gkd.li?r=1") }) { Icon( imageVector = Icons.AutoMirrored.Outlined.HelpOutline, diff --git a/app/src/main/kotlin/li/songe/gkd/util/IntentExt.kt b/app/src/main/kotlin/li/songe/gkd/util/IntentExt.kt index fd280f4cf..2de70e5d2 100644 --- a/app/src/main/kotlin/li/songe/gkd/util/IntentExt.kt +++ b/app/src/main/kotlin/li/songe/gkd/util/IntentExt.kt @@ -79,7 +79,7 @@ fun openA11ySettings() { app.tryStartActivity(intent) } -fun Context.openUri(uri: String) { +fun openUri(uri: String) { val u = try { Uri.parse(uri) } catch (e: Exception) { @@ -89,7 +89,7 @@ fun Context.openUri(uri: String) { } val intent = Intent(Intent.ACTION_VIEW, u) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - tryStartActivity(intent) + app.tryStartActivity(intent) } fun Context.openApp(appId: String) {