知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
feat(android): Share… copies the link and password together as one message in the app's language
wquguru3ba32437b893
diff --git a/android/README.md b/android/README.mdindex 49cae10..8940c64 100644--- a/android/README.md+++ b/android/README.md@@ -46,7 +46,7 @@ scripts/shot.sh # 截图:悬浮窗应是黑块;capture oscripts/tap.sh "开始听" # 按屏幕上的文字点(系统对话框也行),用来走真实界面```-`cicadactl.sh` 的命令见 `app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt`(state、start、stop、feed、sample、view、capture、overlay show|hide|collapse|expand、target、ui、show main|live|records|record|settings|ai|onboarding、import、provider、ai-model、ai-custom-only on|off、key import、voice-try、updatefeed、update check|download|job|notify,以及改正听错的词的 fixes on|off、asknames on|off、silent、heard、vocab add|remove|state、fixstate、fixanswer yes|no、fixrevert、fixlater、fixundo、fixedit、pinyin,分享链接的 share <id>[,full][,pw]、unshare、shares、shareSheet、delete)。`share` 用正式的 cicada.indaloop.app,设备只注册一次(files/share-device.json,别删);测试只用合成的会议记录,用完 unshare。`silent` 开一场没有声音的会,`heard <一句话>` 当作听到一整句,翻译和改词都走当前的 AI 服务,不用放声音。只有开发版有,且只接受 adb。开发版默认不检查更新(点设置里的“检查更新”或用下面的命令后才查):`cicadactl.sh push feed.json && cicadactl.sh updatefeed feed.json` 指向一份测试用的 release JSON(不带参数就是 GitHub),`adb shell cmd jobscheduler run -f com.wquguru.cicada.dev 7` 立刻跑一次后台检查。+`cicadactl.sh` 的命令见 `app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt`(state、start、stop、feed、sample、view、capture、overlay show|hide|collapse|expand、target、ui、show main|live|records|record|settings|ai|onboarding、import、provider、ai-model、ai-custom-only on|off、key import、voice-try、updatefeed、update check|download|job|notify,以及改正听错的词的 fixes on|off、asknames on|off、silent、heard、vocab add|remove|state、fixstate、fixanswer yes|no、fixrevert、fixlater、fixundo、fixedit、pinyin,分享链接的 share <id>[,full][,pw]、unshare、shares、shareSheet、delete、shareserver、clipboard)。`share` 用正式的 cicada.indaloop.app(`adb reverse tcp:<端口> tcp:<端口>` 后 `shareserver http://127.0.0.1:<端口>` 改指本机的 wrangler dev(模拟器走代理时 10.0.2.2 连不上),另用 files/share-device-local.json),设备只注册一次(files/share-device.json,别删);测试只用合成的会议记录,用完 unshare。`silent` 开一场没有声音的会,`heard <一句话>` 当作听到一整句,翻译和改词都走当前的 AI 服务,不用放声音。只有开发版有,且只接受 adb。开发版默认不检查更新(点设置里的“检查更新”或用下面的命令后才查):`cicadactl.sh push feed.json && cicadactl.sh updatefeed feed.json` 指向一份测试用的 release JSON(不带参数就是 GitHub),`adb shell cmd jobscheduler run -f com.wquguru.cicada.dev 7` 立刻跑一次后台检查。界面按 claude.ai 上的设计画布实现:首页、正在听、悬浮窗(纪要卡片 / 字幕条 / 小圆点)、三步引导、会议记录、会议详情、设置。文案用 Gemini(`google/gemini-4-argon`)审过一遍,与 Mac 共用的文案沿用 Mac 的译法。diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt b/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.ktindex e3db05e..ad4ccd4 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit/// 改正听错的词: fixes on|off · asknames on|off · silent (a meeting with no audio) · heard <text> · vocab add|remove|state/// fixstate · fixanswer yes|no · fixrevert <line> · fixlater · fixundo · fixedit <line>=<text>[|one][|keep0] · pinyin <text>/// 分享…: share <id>[,full][,pw] · unshare <id> · shares · shareSheet <id> (no id: closes it) · delete <id>+/// shareserver [url] (a local Worker; none: cicada.indaloop.app) · clipboardclass DebugReceiver : BroadcastReceiver() {override fun onReceive(context: Context, intent: Intent) {if (!BuildConfig.DEBUG) return@@ -191,6 +192,16 @@ class DebugReceiver : BroadcastReceiver() {app.background.execute { Log.d("debug: share revoked ${app.share.revoke(r, arg)}") }return mapOf("unsharing" to arg)}+ // `shareserver http://127.0.0.1:8790` (after adb reverse) points 分享… at a local Worker (wrangler dev), with its+ // own device file so the real one stays registered; no argument goes back to cicada.indaloop.app.+ "shareserver" -> {+ app.share.base = arg.ifEmpty { "https://cicada.indaloop.app" }.trimEnd('/')+ app.share.deviceFile = if (arg.isEmpty()) null else File(cicada.Paths.root, "share-device-local.json")+ return mapOf("shareserver" to app.share.base)+ }+ // What is on the clipboard (the app must be in front to read it).+ "clipboard" -> return mapOf("clipboard" to app.getSystemService(android.content.ClipboardManager::class.java)+ .primaryClip?.takeIf { it.itemCount > 0 }?.getItemAt(0)?.text?.toString())"shares" -> return mapOf("shares" to cicada.ShareStore.all().mapValues { (_, r) ->mapOf("id" to r.id, "url" to r.url, "scope" to r.scope, "password" to r.password, "expiresAt" to cicada.Iso8601.write(r.expiresAt))})diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/ShareViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/ShareViews.ktindex 15ddf1f..ee60aee 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/ShareViews.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/ShareViews.kt@@ -54,6 +54,7 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private valprivate var views: Int? = nullprivate var confirmRevoke = falseprivate var copied: String? = null+ private var showOptions = falseprivate val box = ui.stack(0).apply { setPadding(ui.dp(8), 0, ui.dp(8), 0) }private lateinit var dialog: android.app.Dialog@@ -120,13 +121,37 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private valelse { alpha = 0.4f; isEnabled = false }}, ui.lp(top = 4))}- box.addView(label(L("有效期")), ui.lp(top = 16))- box.addView(ui.segmented(listOf("7" to L("7 天"), "30" to L("30 天"), "365" to L("1 年")), days.toString()) { days = it.toInt(); render() }, ui.lp(top = 8))+ lateinit var go: View+ if (!showOptions) {+ // The choices already made, in one line; 更改 opens them.+ box.addView(LinearLayout(activity).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ setPadding(ui.dp(12), 0, 0, 0)+ addView(ui.text(summary(), 14f, Palette.secondary, lines = 1).apply { ellipsize = android.text.TextUtils.TruncateAt.END }, ui.weight())+ addView(ui.textButton(L("更改")) { showOptions = true; render() })+ }, ui.lp(top = 10))+ } else {+ options { go }+ }+ if (!usePassword) box.addView(ui.text(L("内容将上传至 cicada.indaloop.app,拿到链接的人都能看。"), 13f, Palette.tertiary), ui.lp(top = 10))+ go = ui.button(L("生成并复制"), "primary") { if (!usePassword || password.length >= 6) go() }+ if (usePassword && password.length < 6) { go.alpha = 0.4f; go.isEnabled = false }+ box.addView(buttons(ui.button(L("取消"), "quiet") { dialog.dismiss() }, go), ui.lp(top = 18))+ }++ private fun summary() = listOf(+ if (usePassword) L("密码保护") else L("无密码"),+ if (days == 365) L("1 年有效") else LF("%lld 天有效", days),+ if (names) L("显示名字") else L("不显示名字"),+ ).joinToString(" · ")++ /// Password, expiry, names and the preview, opened by 更改 (in the Mac's order). `go` is the+ /// primary button, made after these rows: the password field turns it off under six characters.+ private fun options(go: () -> View) {val toggles = ui.stack(0).apply { setPadding(0, ui.dp(8), 0, 0) }- toggles.addView(ui.switchRow(L("显示说话人名字"), null, names, titleLines = 2) { names = it }.apply { setPadding(ui.dp(4), paddingTop, ui.dp(4), paddingBottom) })toggles.addView(ui.switchRow(L("用密码保护"), null, usePassword, titleLines = 2) { usePassword = it; render() }.apply { setPadding(ui.dp(4), paddingTop, ui.dp(4), paddingBottom) })box.addView(toggles)- lateinit var go: Viewif (usePassword) {val field = EditText(activity).apply {setText(password)@@ -141,8 +166,8 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private valoverride fun onTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}override fun afterTextChanged(s: Editable?) {password = s.toString()- go.alpha = if (password.length < 6) 0.4f else 1f- go.isEnabled = password.length >= 6+ go().alpha = if (password.length < 6) 0.4f else 1f+ go().isEnabled = password.length >= 6}})}@@ -152,13 +177,14 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private valaddView(field, ui.weight())addView(ui.textButton(L("换一个")) { password = SharePassword.make(); field.setText(password) })}, ui.lp(top = 4))- } else if (hasNotes) {- box.addView(ui.switchRow(L("预览卡显示摘要"), null, summaryInPreview, titleLines = 2) { summaryInPreview = it }.apply { setPadding(ui.dp(4), paddingTop, ui.dp(4), paddingBottom) })}- box.addView(ui.text(if (usePassword) L("建议把链接和密码分两条消息发送。") else L("内容将上传至 cicada.indaloop.app,拿到链接的人都能看。"), 13f, Palette.tertiary), ui.lp(top = 10))- go = ui.button(L("生成链接"), "primary") { if (!usePassword || password.length >= 6) go() }- if (usePassword && password.length < 6) { go.alpha = 0.4f; go.isEnabled = false }- box.addView(buttons(ui.button(L("取消"), "quiet") { dialog.dismiss() }, go), ui.lp(top = 18))+ box.addView(label(L("有效期")), ui.lp(top = 16))+ box.addView(ui.segmented(listOf("7" to L("7 天"), "30" to L("30 天"), "365" to L("1 年")), days.toString()) { days = it.toInt(); render() }, ui.lp(top = 8))+ val more = ui.stack(0).apply { setPadding(0, ui.dp(8), 0, 0) }+ more.addView(ui.switchRow(L("显示说话人名字"), null, names, titleLines = 2) { names = it }.apply { setPadding(ui.dp(4), paddingTop, ui.dp(4), paddingBottom) })+ if (!usePassword && hasNotes)+ more.addView(ui.switchRow(L("预览卡显示摘要"), null, summaryInPreview, titleLines = 2) { summaryInPreview = it }.apply { setPadding(ui.dp(4), paddingTop, ui.dp(4), paddingBottom) })+ box.addView(more)}private fun options() = ShareClient.Options(@@ -172,7 +198,7 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private valval out = app.share.share(session, o)app.main.post {when (out) {- is ShareClient.Outcome.Shared -> { copy(out.record.url, "link"); views = 0; set(Step.Done(out.record)) }+ is ShareClient.Outcome.Shared -> { copy(clipboardText(out.record), "all"); views = 0; set(Step.Done(out.record)) }is ShareClient.Outcome.Blocked -> set(Step.Blocked(out.hits, out.kept))is ShareClient.Outcome.Failed -> set(Step.Failed(message(out.code)))}@@ -245,23 +271,20 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private val// MARK: Doneprivate fun done(r: ShareRecord) {- header(if (copied == "link") L("链接已复制") else L("已分享"))- box.addView(field(r.url), ui.lp(top = 16))+ header(if (copied == "all") (if (r.password == null) L("链接已复制") else L("链接和密码已复制")) else L("已分享"))+ // One grey box: the link, and the password under it.+ box.addView(ui.stack(4, field(r.url)).apply {+ r.password?.let { addView(field(LF("密码:%@", it), Palette.secondary)) }+ background = ui.rounded(Palette.ground, 12)+ setPadding(ui.dp(12), ui.dp(10), ui.dp(12), ui.dp(10))+ }, ui.lp(top = 16))box.addView(buttons(- ui.button(if (copied == "link") L("已复制") else L("复制链接"), "quiet", height = 48) { copy(r.url, "link"); render() },+ copyButton(r),ui.button(L("分享"), "primary", height = 48) {- // The link alone: the password goes in a message of its own.+ // The same message 复制 copies: title, link, password and how long it stays open.activity.startActivity(Intent.createChooser(Intent(Intent.ACTION_SEND).setType("text/plain")- .putExtra(Intent.EXTRA_SUBJECT, SessionStore.displayTitle(session)).putExtra(Intent.EXTRA_TEXT, r.url), L("分享")))+ .putExtra(Intent.EXTRA_SUBJECT, SessionStore.displayTitle(session)).putExtra(Intent.EXTRA_TEXT, clipboardText(r)), L("分享")))}), ui.lp(top = 10))- r.password?.let { pw ->- box.addView(LinearLayout(activity).apply {- orientation = LinearLayout.HORIZONTAL- gravity = Gravity.CENTER_VERTICAL- addView(field(pw), ui.weight())- addView(ui.textButton(if (copied == "password") L("已复制") else L("复制密码")) { copy(pw, "password"); render() })- }, ui.lp(top = 12))- }box.addView(ui.text(status(r), 13f, Palette.secondary), ui.lp(top = 12))box.addView(View(activity).apply { setBackgroundColor(Palette.divider) }, LinearLayout.LayoutParams(-1, 1).apply { topMargin = ui.dp(14) })if (confirmRevoke) {@@ -288,18 +311,48 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private val}// One line, the middle left out when long (selectable text would wrap instead); 复制 copies it whole.- private fun field(text: String) = ui.text(text, 14f, Palette.ink).apply {+ private fun field(text: String, color: Int = Palette.ink) = ui.text(text, 14f, color).apply {typeface = Typeface.MONOSPACEisSingleLine = trueellipsize = android.text.TextUtils.TruncateAt.MIDDLE- background = ui.rounded(Palette.ground, 12)- setPadding(ui.dp(12), ui.dp(10), ui.dp(12), ui.dp(10))+ }++ private fun clipboardText(r: ShareRecord) = r.message(SessionStore.displayTitle(session))++ /// 复制 copies the whole message. With a password its arrow (or a long press) offers the link or+ /// the password alone, for whoever sends them apart (the Mac's Menu with a primary action).+ private fun copyButton(r: ShareRecord): View {+ val all = { copy(clipboardText(r), "all"); render() }+ val pw = r.password+ val title = if (copied == null) L("复制") else L("已复制")+ if (pw == null) return ui.button(title, "quiet", height = 48) { all() }+ lateinit var pill: LinearLayout+ fun alone(anchor: View) = android.widget.PopupMenu(activity, anchor).apply {+ menu.add(L("只复制链接")).setOnMenuItemClickListener { copy(r.url, "link"); render(); true }+ menu.add(L("只复制密码")).setOnMenuItemClickListener { copy(pw, "password"); render(); true }+ show()+ }+ pill = LinearLayout(activity).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ minimumHeight = ui.dp(48)+ background = ui.rounded(Palette.ground, 24)+ addView(ui.text(title, 15f, Palette.ink, bold = true, lines = 1).apply {+ gravity = Gravity.CENTER+ minHeight = ui.dp(48)+ contentDescription = title+ ui.tappable(this, 24, onClick = all)+ setOnLongClickListener { alone(pill); true }+ }, ui.weight())+ addView(View(activity).apply { setBackgroundColor(Palette.divider) }, LinearLayout.LayoutParams(1, ui.dp(20)))+ addView(ui.iconButton(R.drawable.i_chevron_down, L("只复制链接") + "、" + L("只复制密码"), size = 18) { alone(pill) },+ LinearLayout.LayoutParams(ui.dp(44), ui.dp(48)))+ }+ return pill}private fun status(r: ShareRecord): String {- // Ten minutes of slack: the server's clock, not the phone's, set the expiry.- val left = maxOf(1L, Math.ceil((r.expiresAt.epochSecond - Instant.now().epochSecond - 600) / 86400.0).toLong())- val expiry = LF("%lld 天后失效", left)+ val expiry = LF("%lld 天后失效", r.daysLeft())return views?.let { expiry + " · " + LF("打开 %lld 次", it) } ?: expiry}@@ -321,7 +374,7 @@ class ShareSheet(private val activity: Activity, private val ui: Ui, private valprivate fun copy(text: String, what: String) {activity.getSystemService(android.content.ClipboardManager::class.java)- .setPrimaryClip(android.content.ClipData.newPlainText(if (what == "link") "link" else "password", text))+ .setPrimaryClip(android.content.ClipData.newPlainText(what, text))copied = what}diff --git a/android/cli/src/main/kotlin/cicada/cli/ShareTests.kt b/android/cli/src/main/kotlin/cicada/cli/ShareTests.ktindex 68d84e0..b6bb422 100644--- a/android/cli/src/main/kotlin/cicada/cli/ShareTests.kt+++ b/android/cli/src/main/kotlin/cicada/cli/ShareTests.kt@@ -22,8 +22,26 @@ object ShareTests {"ed25519MatchesRfc8032" to ::ed25519Vectors,"ed25519VerifiesWithTheJdk" to ::ed25519Jdk,"shareClientRegistersOnceAndSigns" to ::clientSigns,+ "shareMessageInTheUiLanguage" to ::message,)+ /// 生成并复制's clipboard: title, link, password with how long it stays open (the Mac's clipboardText).+ private fun message() {+ val now = java.time.Instant.parse("2026-11-08T10:00:00Z")+ fun record(days: Long, pw: String?) =+ ShareRecord("A", "https://test/s/A", "tok", now.plusSeconds(days * 86400 - 5), "notes", pw, now)+ try {+ loadStrings("zh-Hans")+ equal("「周会」会议记录\nhttps://test/s/A\n密码:ruby-41-lake(7 天内有效)", record(7, "ruby-41-lake").message("周会", now), "zh, password")+ equal("「周会」会议记录\nhttps://test/s/A\n1 年内有效", record(365, null).message("周会", now), "zh, a year, no password")+ loadStrings("en")+ equal("Meeting record: Weekly\nhttps://test/s/A\nPassword: ruby-41-lake (valid for 30 days)", record(30, "ruby-41-lake").message("Weekly", now), "en, password")+ equal("Meeting record: Weekly\nhttps://test/s/A\nvalid for 7 days", record(7, null).message("Weekly", now), "en, no password")+ loadStrings("ja")+ equal("会議記録:週例\nhttps://test/s/A\nパスワード:pw-pw-pw(1 年間有効)", record(365, "pw-pw-pw").message("週例", now), "ja")+ } finally { loadStrings("zh-Hans") }+ }+private fun check(ok: Boolean, what: String) { if (!ok) throw AssertionError(what) }private fun <T> equal(expected: T, actual: T, what: String) { if (expected != actual) throw AssertionError("$what: expected «$expected», got «$actual»") }diff --git a/android/core/src/main/kotlin/cicada/Share.kt b/android/core/src/main/kotlin/cicada/Share.ktindex 51e1a08..d902ce5 100644--- a/android/core/src/main/kotlin/cicada/Share.kt+++ b/android/core/src/main/kotlin/cicada/Share.kt@@ -133,6 +133,21 @@ data class ShareRecord("scope" to scope, "password" to password, "createdAt" to Iso8601.write(createdAt),)+ /// Whole days the link stays open, rounded up. Ten minutes of slack: the server's clock, not+ /// the phone's, set the expiry.+ fun daysLeft(now: Instant = Instant.now()): Long =+ maxOf(1L, Math.ceil((expiresAt.epochSecond - now.epochSecond - 600) / 86400.0).toLong())++ /// What 生成并复制 and 复制 put on the clipboard (and 分享 sends), in the UI's language: the+ /// title, the link on a line of its own (chat apps then make it a link), the password and how+ /// long it stays open (ShareSheet.clipboardText on the Mac).+ fun message(title: String, now: Instant = Instant.now()): String {+ val left = daysLeft(now)+ val valid = if (left >= 365) Strings.L("1 年内有效") else Strings.LF("%lld 天内有效", left)+ val last = password?.let { Strings.LF("密码:%@(%@)", it, valid) } ?: valid+ return listOf(Strings.LF("「%@」会议记录", title), url, last).joinToString("\n")+ }+companion object {fun from(o: Map<String, Any?>): ShareRecord? {val id = o["id"].str() ?: return null@@ -186,6 +201,11 @@ class ShareClient(/// The dev build can point at a local Worker.var base: String = "https://cicada.indaloop.app",) {+ /// Where this phone's key and registration live; the dev build gives a local Worker its own+ /// file so switching back never re-registers with cicada.indaloop.app.+ var deviceFile: File? = null+ private val keyFile get() = deviceFile ?: ShareStore.deviceFile+sealed class Outcome {class Shared(val record: ShareRecord) : Outcome()class Blocked(val hits: List<ShareHit>, val kept: List<Int>) : Outcome()@@ -208,7 +228,7 @@ class ShareClient(private class Device(val seed: ByteArray, val pub: ByteArray, val id: String?, val server: String?)private fun loadDevice(): Device {- val o = try { Json.parseObject(ShareStore.deviceFile.readText()) } catch (_: Exception) { null }+ val o = try { Json.parseObject(keyFile.readText()) } catch (_: Exception) { null }val seed = try { o?.get("key").str()?.let { Base64.getDecoder().decode(it) } } catch (_: Exception) { null }if (o != null && seed != null && seed.size == 32) return Device(seed, Ed25519.publicKey(seed), o["device"].str(), o["server"].str())val fresh = ByteArray(32).also(random::nextBytes)@@ -217,7 +237,7 @@ class ShareClient(}private fun saveDevice(seed: ByteArray, id: String?, server: String?) {- ShareStore.writePrivate(ShareStore.deviceFile, Json.write(mapOf("key" to Base64.getEncoder().encodeToString(seed), "device" to id, "server" to server)))+ ShareStore.writePrivate(keyFile, Json.write(mapOf("key" to Base64.getEncoder().encodeToString(seed), "device" to id, "server" to server)))}/// The device, registering this phone with the server first if needed (one at a time).