Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix(android): a custom AI service whose key fails is named by its address on the AI card and notification

wquguruba25b10bd5c9
diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/AiCheckViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/AiCheckViews.kt
index 5648aad..c735313 100644
--- a/android/app/src/main/kotlin/com/wquguru/cicada/AiCheckViews.kt
+++ b/android/app/src/main/kotlin/com/wquguru/cicada/AiCheckViews.kt
@@ -76,7 +76,7 @@ object AiCheckViews {
private fun problem(a: Activity, ui: Ui, into: LinearLayout, busy: Boolean, recheck: Boolean, changeKey: () -> Unit) {
val ling = a.cicada.ling
ling.checkMessage()?.let { into.addView(ui.text(it, 13f, if (busy) warn else Palette.link)) }
- ling.aiCheck.proxyLine(ling.serviceName, ling.serviceHost)?.let {
+ ling.aiCheck.proxyLine(ling.serviceLabel, ling.serviceHost)?.let {
into.addView(ui.text(it, 13f, Palette.body).apply {
background = ui.rounded(Palette.ground, 10)
setPadding(ui.dp(10), ui.dp(8), ui.dp(10), ui.dp(8))
@@ -163,7 +163,7 @@ object AiCheckViews {
val ling = app.ling
val c = ling.aiCheck
if (!ling.hasKey || !c.needsUser || c.running) return null
- val name = ling.serviceName
+ val name = ling.serviceLabel
val cfg = ling.config()
val f = c.failure ?: return c.balanceLine(name)?.let { it to L("用完后就听不了了") }
if (f.reason == Reason.Unreachable) return LF("连不上 %@", name) to L("修好之前听不了")
@@ -238,7 +238,7 @@ object AiCheckViews {
lateinit var d: android.app.Dialog
val body = ui.stack(10)
ling.checkMessage()?.let { body.addView(ui.text(it, 15f, Palette.secondary).apply { gravity = Gravity.CENTER }) }
- ling.aiCheck.proxyLine(ling.serviceName, ling.serviceHost)?.let {
+ ling.aiCheck.proxyLine(ling.serviceLabel, ling.serviceHost)?.let {
body.addView(ui.text(it, 14f, Palette.body).apply { background = ui.rounded(Palette.ground, 12); setPadding(ui.dp(12), ui.dp(10), ui.dp(12), ui.dp(10)) })
}
body.addView(ui.textButton(L("怎么设置代理")) { open(a, helpUrl()) }.apply {
diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt
index 21a097e..c9495b2 100644
--- a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt
+++ b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt
@@ -167,9 +167,7 @@ object NotesViews {
app.listen.listening && app.translator.googleOff && app.translator.sentencesUntranslated
/// Where this meeting's notes stop: the time of the last line they cover.
- /// Who the banner names: a custom service by its address, which says more than 这个服务.
- private fun serviceLabel(app: CicadaApp): String =
- app.ling.serviceHost.takeIf { app.ling.provider.id == "custom" && it.isNotEmpty() } ?: app.ling.serviceName
+ private fun serviceLabel(app: CicadaApp): String = app.ling.serviceLabel
/// An import's progress: the bar and "26:40 / 42:15".
fun progress(ui: Ui, file: FileSource): LinearLayout {
diff --git a/android/core/src/main/kotlin/cicada/Ling.kt b/android/core/src/main/kotlin/cicada/Ling.kt
index 1d7f0ed..a833cf2 100644
--- a/android/core/src/main/kotlin/cicada/Ling.kt
+++ b/android/core/src/main/kotlin/cicada/Ling.kt
@@ -299,6 +299,9 @@ class LingClient(
/// The service's name for messages ("这个服务" for a custom address, localized) and its host.
val serviceName: String get() = provider.let { if (it.id == "custom") Strings.L("这个服务") else it.name }
val serviceHost: String get() = host(config().base ?: provider.base)
+ /// Who a status line names: a custom service by its address, which says more than 这个服务
+ /// and reads right in "The … key doesn't work".
+ val serviceLabel: String get() = serviceHost.let { if (provider.id == "custom" && it.isNotEmpty()) it else serviceName }
/// Where the hear model is asked: the service's host unless a custom service names its own.
val hearHost: String get() = config().let { c -> if (c.hearsElsewhere) host(c.hearBase) else serviceHost }
/// Who a line about hearing names (连不上 …, … 的 key 无效): a custom service by the address it
@@ -311,7 +314,7 @@ class LingClient(
/// can't be reached names that server.
fun checkMessage(): String? = config().let {
val host = if (aiCheck.failure?.step == AICheck.StepID.Hear) hearHost else serviceHost
- aiCheck.message(serviceName, host, it.textModel, it.hearModel)
+ aiCheck.message(serviceLabel, host, it.textModel, it.hearModel)
}
/// The server that can't be reached is on this phone or the local network: a proxy has nothing
@@ -334,7 +337,7 @@ class LingClient(
/// listening notification and the live screens. Null without a key (onboarding asks for it).
val blocking: String? get() {
if (!hasKey) return null
- val (what, stops) = config().let { aiCheck.blocking(serviceName, it.textModel, it.hearModel) } ?: return null
+ val (what, stops) = config().let { aiCheck.blocking(serviceLabel, it.textModel, it.hearModel) } ?: return null
return what.trimEnd('。', '.') + " · " + stops
}