diff --git a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt index 820641ccb..8916e1f4c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt @@ -28,6 +28,7 @@ import com.hippo.ehviewer.client.execute import com.hippo.ehviewer.ui.LICENSE_SCREEN import com.hippo.ehviewer.ui.LocalNavController import com.hippo.ehviewer.ui.tools.toAnnotatedString +import com.hippo.ehviewer.util.iter import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.json.JSONArray @@ -65,8 +66,8 @@ fun AboutScreen() { ) }, snackbarHost = { SnackbarHost(snackbarHostState) }, - ) { - Column(modifier = Modifier.padding(it).nestedScroll(scrollBehavior.nestedScrollConnection)) { + ) { paddingValues -> + Column(modifier = Modifier.padding(paddingValues).nestedScroll(scrollBehavior.nestedScrollConnection)) { Preference( title = stringResource(id = R.string.settings_about_declaration), summary = stringResource(id = R.string.settings_about_declaration_summary), @@ -105,6 +106,13 @@ fun AboutScreen() { JSONObject(body.string()).getJSONObject("commit").getString("sha") }.take(7) if (commitSha != curSha) launchSnackBar(commitSha) + val workflowUrl = ehRequest("$API_URL/actions/workflows").execute { + val r = JSONObject(body.string()).getJSONArray("workflows").iter().find { + it.getString("name") == "CI" + } + requireNotNull(r) { "No CI workflow found!!!" } + }.getString("url") + launchSnackBar(workflowUrl) } else { val curVersion = BuildConfig.VERSION_NAME val releaseUrl = "$API_URL/releases" diff --git a/app/src/main/java/com/hippo/ehviewer/util/JSONUtils.kt b/app/src/main/java/com/hippo/ehviewer/util/JSONUtils.kt new file mode 100644 index 000000000..36aaee6cd --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/util/JSONUtils.kt @@ -0,0 +1,13 @@ +package com.hippo.ehviewer.util + +import org.json.JSONArray + +fun JSONArray.iter() = object : Iterable { + override fun iterator() = object : Iterator { + var index = 0 + override fun hasNext() = index != length() + + @Suppress("UNCHECKED_CAST") + override fun next() = get(index) as T + } +}