Skip to content

Commit

Permalink
feat: add InputSubsLinkOption docs link
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Dec 15, 2024
1 parent 7c8191b commit d07bcb0
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/li/songe/gkd/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private fun ShizukuErrorDialog(stateFlow: MutableStateFlow<Boolean>) {
} else {
TextButton(onClick = {
stateFlow.value = false
app.openUri("https://gkd.li?r=4")
openUri("https://gkd.li?r=4")
}) {
Text(text = "去下载")
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -240,7 +240,7 @@ fun AboutPage() {
Column(
modifier = Modifier
.clickable {
context.openUri(REPOSITORY_URL)
openUri(REPOSITORY_URL)
}
.fillMaxWidth()
.itemPadding()
Expand All @@ -259,7 +259,7 @@ fun AboutPage() {
Column(
modifier = Modifier
.clickable {
context.openUri(ISSUES_URL)
openUri(ISSUES_URL)
}
.fillMaxWidth()
.itemPadding()
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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}")
})
)
}
Expand Down Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/li/songe/gkd/ui/AuthA11yPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/kotlin/li/songe/gkd/ui/ImagePreviewPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private fun SubsMenuItem(
},
onClick = {
onExpandedChange(false)
context.openUri(supportUri)
openUri(supportUri)
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/li/songe/gkd/ui/home/ControlPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/kotlin/li/songe/gkd/util/Github.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -160,7 +159,7 @@ fun EditGithubCookieDlg(showEditCookieDlgFlow: MutableStateFlow<Boolean>) {
) {
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,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/li/songe/gkd/util/IntentExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit d07bcb0

Please sign in to comment.