知了 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): fix a misheard word yourself from the meeting record, confirm new names live, and keep your spellings in Settings › Word list
wquguru815a2bfa9525
diff --git a/README.en.md b/README.en.mdindex 809710d..c954746 100644--- a/README.en.md+++ b/README.en.md@@ -157,7 +157,7 @@ Requires the **Ubuntu 22.04 or 24.04 desktop** (x86_64 or arm64). Download `Cica### Android-Requires **Android 10** or later. Download `Cicada-<version>-Android.apk` on your phone, open it and allow installing unknown apps when asked; on Android 15 and later, the first time you turn on floating subtitles you also allow restricted settings in App info. Android also tells the other side's voices apart (Speaker 1, 2…) with the Mac's on-device voiceprint model, and fills in their names when a Ling key is set. Calls and meeting apps don't let other apps record their sound: put the call on speaker and switch to **In person**.+Requires **Android 10** or later. Download `Cicada-<version>-Android.apk` on your phone, open it and allow installing unknown apps when asked; on Android 15 and later, the first time you turn on floating subtitles you also allow restricted settings in App info. Android also tells the other side's voices apart (Speaker 1, 2…) with the Mac's on-device voiceprint model, and fills in their names when a Ling key is set. Misheard names and terms are fixed live as on the Mac (with an AI service), new names asked about once in the floating window or on Listening; in a meeting record, long-press a line for Edit line…, and the Word list is in Settings. Calls and meeting apps don't let other apps record their sound: put the call on speaker and switch to **In person**.Every platform's files can be checked against `checksums.txt` on the Releases page.diff --git a/README.ja.md b/README.ja.mdindex eca67c6..15b28c2 100644--- a/README.ja.md+++ b/README.ja.md@@ -159,7 +159,7 @@ ZenMux、OpenAI、または OpenAI 互換の任意のサービス(たとえば### Android-**Android 10** 以降が必要です。スマートフォンで `Cicada-<version>-Android.apk` をダウンロードして開き、求められたら不明なアプリのインストールを許可してください。Android 15 以降では、初めてフローティング字幕をオンにするときに、アプリ情報で制限付き設定も許可します。Android でも Mac と同じ端末内の声紋モデルで相手側の話者を声で聞き分け(話者 1、2…)、Ling キーがあれば名前も入ります。通話や会議のアプリは、ほかのアプリにその音声を録音させません。その場合は通話をスピーカーにして **対面** に切り替えてください。+**Android 10** 以降が必要です。スマートフォンで `Cicada-<version>-Android.apk` をダウンロードして開き、求められたら不明なアプリのインストールを許可してください。Android 15 以降では、初めてフローティング字幕をオンにするときに、アプリ情報で制限付き設定も許可します。Android でも Mac と同じ端末内の声紋モデルで相手側の話者を声で聞き分け(話者 1、2…)、Ling キーがあれば名前も入ります。聞き間違えた人名や用語も Mac と同じくその場で直り(AI サービスが必要)、初めての名前はフローティングウィンドウか「聞き取り中」の画面で一度だけ確認します。会議記録では行を長押しして「この行を修正…」、単語リストは設定にあります。通話や会議のアプリは、ほかのアプリにその音声を録音させません。その場合は通話をスピーカーにして **対面** に切り替えてください。どのプラットフォームのファイルも、Releases ページの `checksums.txt` で検証できます。diff --git a/README.ko.md b/README.ko.mdindex 00294ed..575483f 100644--- a/README.ko.md+++ b/README.ko.md@@ -157,7 +157,7 @@ Windows, Linux, Android 버전은 클라우드에서 음성을 인식합니다.### Android-**Android 10** 이상이 필요합니다. 휴대폰에서 `Cicada-<version>-Android.apk`를 내려받아 열고 안내에 따라 알 수 없는 앱 설치를 허용하세요. Android 15 이상에서는 플로팅 자막을 처음 켤 때 앱 정보에서 제한된 설정 허용이 먼저 필요합니다. Android에서도 Mac과 같은 기기 내 성문 모델로 상대방 화자를 목소리로 구분하고(화자 1, 2…), Ling 키가 있으면 이름도 채웁니다. 전화나 회의 앱의 소리는 시스템이 다른 앱에서 녹음하지 못하게 막으므로, 스피커폰을 켜고 **대면** 모드로 전환해 사용하세요.+**Android 10** 이상이 필요합니다. 휴대폰에서 `Cicada-<version>-Android.apk`를 내려받아 열고 안내에 따라 알 수 없는 앱 설치를 허용하세요. Android 15 이상에서는 플로팅 자막을 처음 켤 때 앱 정보에서 제한된 설정 허용이 먼저 필요합니다. Android에서도 Mac과 같은 기기 내 성문 모델로 상대방 화자를 목소리로 구분하고(화자 1, 2…), Ling 키가 있으면 이름도 채웁니다. 잘못 들린 이름과 용어도 Mac처럼 바로 고쳐지고(AI 서비스 필요), 처음 보는 이름은 플로팅 창이나 듣는 중 화면에서 한 번 묻습니다. 회의 기록에서 줄을 길게 눌러 이 줄 고치기…를 쓸 수 있고, 단어 목록은 설정에 있습니다. 전화나 회의 앱의 소리는 시스템이 다른 앱에서 녹음하지 못하게 막으므로, 스피커폰을 켜고 **대면** 모드로 전환해 사용하세요.모든 플랫폼의 설치 파일은 Releases 페이지의 `checksums.txt`로 SHA-256을 검증할 수 있습니다.diff --git a/README.md b/README.mdindex 13601aa..a547fb4 100644--- a/README.md+++ b/README.md@@ -146,7 +146,7 @@ Intel 版 Mac 以及 Windows、Linux 和 Android 版在云端识别:说话的### Android-需要 Android 10 或更新版本。在手机上下载 `Cicada-<版本>-Android.apk` 打开安装,按提示允许安装未知应用;第一次打开悬浮字幕时,Android 15 起要先在应用信息里允许受限制的设置。Android 也能用和 Mac 相同的本机声纹模型按声音区分对方的说话人(说话人 1、2…),填了 Ling key 时还会填上名字。微信通话和会议 app 的声音系统不让录,这时开外放、改选“面对面”。+需要 Android 10 或更新版本。在手机上下载 `Cicada-<版本>-Android.apk` 打开安装,按提示允许安装未知应用;第一次打开悬浮字幕时,Android 15 起要先在应用信息里允许受限制的设置。Android 也能用和 Mac 相同的本机声纹模型按声音区分对方的说话人(说话人 1、2…),填了 Ling key 时还会填上名字。听错的人名和术语也和 Mac 一样当场改对(需要 AI 服务),没见过的名字在悬浮窗或“正在听”里问一次;会议记录里长按一句可以“改这句…”,词表在设置里。微信通话和会议 app 的声音系统不让录,这时开外放、改选“面对面”。每个平台的安装包都能用 Releases 页面里的 `checksums.txt` 核对 SHA-256。diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xmlindex 0e2169f..2c50542 100644--- a/android/app/src/main/AndroidManifest.xml+++ b/android/app/src/main/AndroidManifest.xml@@ -37,6 +37,7 @@<activity android:name=".RecordActivity" android:exported="false" android:parentActivityName=".MainActivity" /><activity android:name=".SettingsActivity" android:exported="false" android:parentActivityName=".MainActivity" /><activity android:name=".AiServiceActivity" android:exported="false" android:parentActivityName=".SettingsActivity" />+ <activity android:name=".WordListActivity" android:exported="false" android:parentActivityName=".SettingsActivity" android:windowSoftInputMode="adjustResize" /><activity android:name=".OnboardingActivity" android:exported="false" /><!-- 导入录音或视频: from 首页, or another app's share sheet (分享到知了). --><activity android:name=".ImportActivity" android:exported="true" android:parentActivityName=".MainActivity"diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/AiServiceActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/AiServiceActivity.ktindex bdc3b3c..8d3e2f2 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/AiServiceActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/AiServiceActivity.kt@@ -135,7 +135,13 @@ class AiServiceActivity : Activity() {voice != null && ling.lastVoice?.first == true -> Triple(uses, 1, LF("%@ 的声音读给对方", voice) + " · " + L("上次同传时正常"))else -> Triple(uses, 1, if (voice != null) LF("%@ 的声音读给对方", voice) else L("手机的声音读给对方"))}- val rows = mutableListOf(L("听对方") to hear, L("实时纪要") to notes, L("我说 · 面对面") to say)+ // 改正听错的词 (AISettings.swift's row): a text request per finished line, switched in 词表.+ val fix = when {+ !on -> notReady+ !app.settings.fixMisheard -> Triple(L("已关"), 0, L("在“词表”里打开"))+ else -> Triple(uses, 1, L("随翻译一起发,几乎不多花"))+ }+ val rows = mutableListOf(L("听对方") to hear, L("实时纪要") to notes, L("改正听错的词") to fix, L("我说 · 面对面") to say)if (!c.isLing) rows.add(L("你自己的声音") to Triple(L("只有 Ling"), 0, L("换用 Ling 才有")))return rows.map { (title, u) ->val (tag, style, note) = udiff --git a/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt b/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.ktindex 798d66d..7192989 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/DebugReceiver.kt@@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit/// Android counterpart of the Mac's tools/lsctl and the Windows pipe. One command per broadcast,/// one JSON line back as the broadcast's result (never meeting text or the key)./// state | start [playback|mic] | stop | feed <wav in files/> | sample | view notes|subtitles-/// capture on|off | overlay show|hide | show main|live|records|settings|onboarding|record [id] | overlay collapse|expand | key reload+/// capture on|off | overlay show|hide | show main|live|records|settings|words|onboarding|record [id] | overlay collapse|expand | key reload/// hear|say <wav in files/> (面对面: the other side / me holding 我说) | tts <lang> <text>/// import <session.json in files/> | importfile <audio or video in files/> | face | onboarded on|off | target <code> | ui <lang> | clip <text>/// provider ling|openrouter|zenmux|custom | ai-model hear|text|voice <id> ("" back to the recommended) | show ai@@ -169,6 +169,7 @@ class DebugReceiver : BroadcastReceiver() {}"show" -> when (arg.substringBefore(' ')) {"settings" -> open(SettingsActivity::class.java)+ "words" -> open(WordListActivity::class.java)"ai" -> open(AiServiceActivity::class.java)"onboarding" -> open(OnboardingActivity::class.java)"record" -> open(RecordActivity::class.java, arg.substringAfter(' ', "").ifEmpty { app.store.all().firstOrNull { it.id != app.listen.sessionId || !app.listen.listening }?.id })diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/FixViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/FixViews.ktnew file mode 100644index 0000000..5c93e1a--- /dev/null+++ b/android/app/src/main/kotlin/com/wquguru/cicada/FixViews.kt@@ -0,0 +1,256 @@+package com.wquguru.cicada++import android.app.Activity+import android.graphics.Canvas+import android.graphics.Color+import android.graphics.DashPathEffect+import android.graphics.Paint+import android.text.SpannableString+import android.text.Spanned+import android.text.style.BackgroundColorSpan+import android.text.style.ForegroundColorSpan+import android.text.style.ReplacementSpan+import android.view.Gravity+import android.view.View+import android.widget.FrameLayout+import android.widget.LinearLayout+import android.widget.TextView+import cicada.Correction+import cicada.LineFix+import cicada.LiveFixes+import cicada.Languages+import cicada.Session+import cicada.Strings.L+import cicada.Strings.LF+import cicada.TranscriptLine++/// 改正听错的词 on screen (the Mac's FixViews.swift and the fixing parts of NotesViews.swift): the+/// fixed words dotted, what each was heard as with 改回, the 这样改对吗? card, the banner over a+/// finished meeting, 改这句… and the 撤销 message. A phone has no pointer to hover with: a line's+/// fixed words open with a long press (the record) or show under the newest line (正在听).+object FixViews {+ /// A fixed word: drawn as it is, with a dotted line under it (Android has no dotted underline).+ class Dotted(private val color: Int, private val dp: Float) : ReplacementSpan() {+ override fun getSize(paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?): Int {+ if (fm != null) paint.getFontMetricsInt(fm)+ return Math.round(paint.measureText(text, start, end))+ }++ override fun draw(canvas: Canvas, text: CharSequence, start: Int, end: Int, x: Float, top: Int, y: Int, bottom: Int, paint: Paint) {+ canvas.drawText(text, start, end, x, y.toFloat(), paint)+ val line = Paint(Paint.ANTI_ALIAS_FLAG).apply {+ color = [email protected]; style = Paint.Style.STROKE; strokeWidth = 1.3f * dp+ pathEffect = DashPathEffect(floatArrayOf(1.6f * dp, 2.2f * dp), 0f)+ }+ val at = y + 3.2f * dp+ canvas.drawLine(x, at, x + paint.measureText(text, start, end), at, line)+ }+ }++ /// The line as shown, each fixed word dotted, words waiting for the user (这样改对吗?) washed pale.+ fun text(ui: Ui, line: TranscriptLine, prefix: String = ""): CharSequence {+ val fixes = line.fixes ?: return prefix + line.src+ val a = Correction.apply(fixes, line.src)+ val s = SpannableString(prefix + a.text)+ val dp = ui.context.resources.displayMetrics.density+ for (m in a.marks) s.setSpan(Dotted(Palette.tertiary, dp), prefix.length + m.first, prefix.length + m.last + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)+ for (f in fixes) if (f.ask == true) {+ val i = a.text.indexOf(f.from)+ if (i >= 0) s.setSpan(BackgroundColorSpan(Palette.accentPale), prefix.length + i, prefix.length + i + f.from.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)+ }+ return s+ }++ /// "听成 莫拉 → Morpho" with the grey parts grey.+ private fun heardAs(from: String, to: String): CharSequence {+ val head = L("听成") + " "+ val arrow = " → "+ val s = SpannableString(head + from + arrow + to)+ s.setSpan(ForegroundColorSpan(Palette.tertiary), 0, head.length, 0)+ s.setSpan(ForegroundColorSpan(Palette.tertiary), head.length + from.length, head.length + from.length + arrow.length, 0)+ return s+ }++ /// Under a line: each applied fix, what it was heard as, and 改回.+ fun fixedWords(ui: Ui, lineId: String, fixes: List<LineFix>, onRevert: (String, LineFix) -> Unit): View? {+ val applied = fixes.filter { it.applied }+ if (applied.isEmpty()) return null+ val box = ui.stack(6)+ for (f in applied) {+ val (from, to) = Correction.core(f.from, f.to)+ box.addView(LinearLayout(ui.context).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ background = ui.rounded(Palette.ground, 8)+ setPadding(ui.dp(10), 0, ui.dp(2), 0)+ addView(ui.text(heardAs(from, to), 13f, Palette.ink, lines = 1))+ addView(ui.text(L("改回"), 13f, Palette.link, bold = true).apply {+ gravity = Gravity.CENTER+ minHeight = ui.dp(36)+ setPadding(ui.dp(10), 0, ui.dp(10), 0)+ ui.tappable(this, 8) { onRevert(lineId, f) }+ })+ }, LinearLayout.LayoutParams(-2, -2))+ }+ return box+ }++ /// 这样改对吗?: a name sound can't check, asked about once. 对 fixes every line waiting on it and+ /// adds it to the word list; × (稍后再看) asks again after the meeting.+ fun confirmCard(ui: Ui, a: LiveFixes.Asking, onAnswer: (Boolean) -> Unit, onLater: (() -> Unit)?): View {+ val (from, to) = Correction.core(a.fix.from, a.fix.to)+ val card = ui.stack(0)+ card.background = ui.rounded(Palette.card, 16, Palette.line, 1)+ card.setPadding(ui.dp(14), ui.dp(10), ui.dp(6), ui.dp(12))+ card.addView(LinearLayout(ui.context).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ addView(ui.text(L("这样改对吗?"), 15f, Palette.ink, bold = true), ui.weight())+ if (a.of > 1) addView(ui.text("1 / ${a.of}", 13f, Palette.tertiary).apply { fontFeatureSettings = "tnum" })+ if (onLater != null) addView(ui.iconButton(R.drawable.i_close, L("稍后再看"), Palette.tertiary, 18) { onLater() })+ else addView(View(ui.context), LinearLayout.LayoutParams(ui.dp(8), 1))+ })+ card.addView(ui.text(L("确认后整场一起改,以后也这样改"), 12f, Palette.tertiary).apply { setPadding(0, 0, ui.dp(8), 0) })+ val change = SpannableString("$from → $to")+ change.setSpan(ForegroundColorSpan(Palette.tertiary), from.length, from.length + 3, 0)+ change.setSpan(android.text.style.StyleSpan(android.graphics.Typeface.BOLD), from.length + 3, change.length, 0)+ card.addView(ui.text(change, 17f, Palette.ink), ui.lp(top = 8))+ card.addView(ui.text("${Languages.clock(a.line.t)} · ${a.line.src}", 12f, Palette.tertiary, lines = 1).apply {+ ellipsize = android.text.TextUtils.TruncateAt.END; setPadding(0, 0, ui.dp(8), 0)+ }, ui.lp(top = 2))+ card.addView(LinearLayout(ui.context).apply {+ orientation = LinearLayout.HORIZONTAL+ addView(ui.button(L("对"), "primary", height = 40) { onAnswer(true) }, ui.weight())+ addView(ui.button(L("不对"), "quiet", height = 40) { onAnswer(false) }, ui.weight().apply { leftMargin = ui.dp(8) })+ setPadding(0, 0, ui.dp(8), 0)+ }, ui.lp(top = 10))+ return card+ }++ /// Above a finished meeting's transcript: how many words were fixed, and the ones waiting for the+ /// user, one at a time (对 / 不对 / 改成…). Nothing when there was nothing to fix.+ fun reviewBanner(ui: Ui, fixes: LiveFixes, s: Session, onShow: (String) -> Unit, onEdit: (TranscriptLine, String) -> Unit): View? {+ val waiting = fixes.pending(s.id)+ val fixed = fixes.store.lines(s.id).sumOf { l -> (l.fixes ?: emptyList()).count { it.applied } }+ val first = waiting.firstOrNull()+ if (first == null) return if (fixed > 0) ui.text(LF("改了 %lld 处听错的词", fixed), 13f, Palette.tertiary) else null+ val (from, to) = Correction.core(first.fix.from, first.fix.to)+ val box = ui.stack(8)+ box.background = ui.rounded(Color.parseColor("#FEF6F2"), 16, Palette.accentPale, 1)+ box.setPadding(ui.dp(14), ui.dp(12), ui.dp(14), ui.dp(12))+ val head = ui.stack(2,+ ui.text(LF("改了 %lld 处听错的词,%lld 处等你确认", fixed, waiting.size), 14f, Palette.ink, medium = true),+ ui.text("$from → $to? · ${Languages.clock(first.line.t)}", 13f, Palette.secondary))+ ui.tappable(head, 8) { onShow(first.line.id) }+ box.addView(head)+ box.addView(LinearLayout(ui.context).apply {+ orientation = LinearLayout.HORIZONTAL+ addView(ui.button(L("对"), "primary", height = 40) { fixes.answer(first.fix, true, s.id) }, ui.weight())+ addView(ui.button(L("不对"), "white", height = 40) { fixes.answer(first.fix, false, s.id) }, ui.weight().apply { leftMargin = ui.dp(8) })+ addView(ui.button(L("改成…"), "white", height = 40) {+ onEdit(first.line, Correction.apply((first.line.fixes ?: emptyList()).filter { it.applied }, first.line.src).text)+ }, ui.weight().apply { leftMargin = ui.dp(8) })+ }, ui.lp(top = 4))+ return box+ }++ /// A long press on a line in the record: its fixed words with 改回, and 改这句….+ fun lineSheet(activity: Activity, ui: Ui, app: CicadaApp, sessionId: String, line: TranscriptLine) {+ lateinit var d: android.app.Dialog+ val box = ui.stack(10)+ box.addView(ui.text(text(ui, line), 16f, Palette.ink).apply { leading(1.5f); setPadding(ui.dp(8), 0, ui.dp(8), 0) })+ fixedWords(ui, line.id, line.fixes ?: emptyList()) { id, f -> d.dismiss(); app.fixes.revert(f, id, sessionId) }+ ?.let { box.addView(it, ui.lp().apply { leftMargin = ui.dp(8) }) }+ box.addView(ui.sheetAction(R.drawable.i_edit, L("改这句…")) { d.dismiss(); edit(activity, ui, app, sessionId, line, line.shown) })+ d = ui.sheet(activity, null, box)+ d.show()+ }++ /// 改这句…: the line as shown, to rewrite. What changed becomes the user's own fix, on every line+ /// heard the same way or only this one, and (made everywhere) joins the word list.+ fun edit(activity: Activity, ui: Ui, app: CicadaApp, sessionId: String, line: TranscriptLine, start: String) {+ lateinit var d: android.app.Dialog+ val field = android.widget.EditText(activity).apply {+ setText(start)+ setSelection(start.length)+ setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 16f)+ background = ui.rounded(Palette.ground, 16)+ setPadding(ui.dp(16), ui.dp(12), ui.dp(16), ui.dp(12))+ minHeight = ui.dp(52)+ }+ val heard = ui.text("", 13f, Palette.secondary)+ val everywhere = android.widget.RadioButton(activity).apply { id = View.generateViewId(); textSize = 14f; buttonTintList = android.content.res.ColorStateList.valueOf(Palette.ink); isChecked = true }+ val once = android.widget.RadioButton(activity).apply { id = View.generateViewId(); textSize = 14f; buttonTintList = android.content.res.ColorStateList.valueOf(Palette.ink); text = L("只改这一处") }+ val scope = android.widget.RadioGroup(activity).apply { addView(everywhere); addView(once) }+ val keep = android.widget.CheckBox(activity).apply { text = L("记进词表,以后自动改"); textSize = 14f; buttonTintList = android.content.res.ColorStateList.valueOf(Palette.ink); isChecked = true }+ fun update() {+ val same = app.fixes.sameHeard(line.id, sessionId, field.text.toString())+ heard.visibility = if (same == null) View.GONE else View.VISIBLE+ keep.visibility = heard.visibility+ scope.visibility = if (same != null && same.second > 1) View.VISIBLE else View.GONE+ if (same != null) {+ heard.text = LF("听成 %@", same.first)+ everywhere.text = LF("整场听成 %@ 的 %lld 处都改", same.first, same.second)+ }+ // Only a change made everywhere teaches the word list.+ keep.isEnabled = same == null || same.second <= 1 || everywhere.isChecked+ }+ field.addTextChangedListener(object : android.text.TextWatcher {+ override fun beforeTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}+ override fun onTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}+ override fun afterTextChanged(s: android.text.Editable?) = update()+ })+ scope.setOnCheckedChangeListener { _, _ -> update() }+ update()+ val body = ui.stack(8, field, heard, scope, keep)+ body.addView(LinearLayout(activity).apply {+ orientation = LinearLayout.HORIZONTAL+ addView(ui.button(L("取消"), "quiet") { d.dismiss() }, ui.weight())+ addView(ui.button(L("改成"), "primary") {+ d.dismiss()+ val same = app.fixes.sameHeard(line.id, sessionId, field.text.toString()) ?: return@button+ val all = same.second <= 1 || everywhere.isChecked+ app.background.execute { app.fixes.edit(line.id, sessionId, field.text.toString(), everywhere = all, keep = keep.isChecked && all) }+ }, ui.weight().apply { leftMargin = ui.dp(10) })+ }, ui.lp(top = 8))+ d = ui.sheet(activity, L("改这句"), body)+ d.window?.setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE or android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)+ d.show()+ field.requestFocus()+ }++ /// The last fix decision said back for a few seconds, with 撤销, over the bottom of a screen+ /// (Android's own toast can't carry a button).+ class Toast(private val activity: Activity, private val ui: Ui, private val app: CicadaApp, private val above: Int = 24) {+ private var view: View? = null+ private var shownAt = 0L+ private val again = Runnable { refresh() }++ fun refresh() {+ val t = app.fixes.toastNow()+ val root = activity.findViewById<FrameLayout>(android.R.id.content) ?: return+ if (t == null) { view?.let { root.removeView(it) }; view = null; shownAt = 0; return }+ if (view != null && shownAt == t.at) return+ view?.let { root.removeView(it) }+ shownAt = t.at+ val pill = LinearLayout(activity).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ background = ui.rounded(Palette.ink, 14)+ elevation = ui.dp(8).toFloat()+ setPadding(ui.dp(16), ui.dp(4), ui.dp(6), ui.dp(4))+ minimumHeight = ui.dp(52)+ addView(ui.text(t.text, 14f, Color.WHITE, lines = 2), ui.weight())+ if (app.fixes.canUndo) addView(ui.text(L("撤销"), 14f, Color.parseColor("#FFB59B"), bold = true).apply {+ gravity = Gravity.CENTER; minHeight = ui.dp(44); setPadding(ui.dp(12), 0, ui.dp(12), 0)+ ui.tappable(this, 10, dark = true) { app.background.execute { app.fixes.undo() } }+ })+ accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITE+ }+ root.addView(pill, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { setMargins(ui.dp(16), 0, ui.dp(16), ui.dp(above)) })+ view = pill+ root.removeCallbacks(again)+ root.postDelayed(again, LiveFixes.TOAST_MS - (System.currentTimeMillis() - t.at) + 50)+ }+ }+}diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/ListeningActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/ListeningActivity.ktindex 6439742..e72ce45 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/ListeningActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/ListeningActivity.kt@@ -32,6 +32,7 @@ class ListeningActivity : Activity() {private var tab = 0 // 0 实时纪要, 1 字幕private var shown: String? = nullprivate var unobserve: (() -> Unit)? = null+ private var toast: FixViews.Toast? = nullprivate val tick = object : Runnable {// The clock, and states that come without an event (20 s of silence): render() is keyed.override fun run() { badgeText.text = NotesViews.status(cicada); render(); NotesViews.tickEnding(content, cicada); cicada.main.postDelayed(this, 1000) }@@ -72,6 +73,7 @@ class ListeningActivity : Activity() {setContentView(ui.screen(this, null, back = true, ground = Palette.ground, center = badge, bottom = bottomHost, scroll = false, body = body,actions = listOf(actionHost)))buildAction()+ toast = FixViews.Toast(this, ui, cicada, above = 104)}private lateinit var actionHost: FrameLayout@@ -189,6 +191,7 @@ class ListeningActivity : Activity() {buildAction()updateSay()sourceText.text = NotesViews.sourceLine(app)+ toast?.refresh()val key = NotesViews.liveKey(app) + tab + app.listen.spokenif (key == shown) returnshown = key@@ -197,6 +200,10 @@ class ListeningActivity : Activity() {content.removeAllViews()NotesViews.endingStrip(ui, app)?.let { content.addView(it) }NotesViews.banner(ui, app) { switchToMic() }?.let { content.addView(it) }+ // 这样改对吗?: a name the service proposed, asked about once (× puts it off until after the meeting).+ app.listen.sessionId?.let { sid ->+ app.fixes.asking(sid)?.let { a -> content.addView(FixViews.confirmCard(ui, a, { yes -> app.fixes.answer(a.fix, yes, sid) }, { app.fixes.later(a.fix, sid) })) }+ }if (tab == 1) {content.addView(ui.spacer(), LinearLayout.LayoutParams(-1, 0, 1f))content.addView(NotesViews.bubbles(ui, app, 12))diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.ktindex 9093c41..70a9485 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt@@ -31,7 +31,9 @@ object NotesViews {val line = listen.sessionId?.let { app.store.lines(it).lastOrNull() }return listOf(listen.listening, listen.sourceKind, listen.sessionId, listen.pending > 0, listen.problem, app.startProblem, silent(app), app.micSilenced,line?.id, line?.shown, line?.dst, app.notes.status, app.notes.notes.updatedAt, app.notes.notes.covered,- app.ending?.deadline, app.ling.blocking, listen.problemKind, app.ling.provider.id, customOnlyUntranslated(app)).joinToString("|")+ app.ending?.deadline, app.ling.blocking, listen.problemKind, app.ling.provider.id, customOnlyUntranslated(app),+ // 改正听错的词: the newest line's fixes, the card and the 撤销 message.+ line?.fixes, listen.sessionId?.let { app.fixes.asking(it)?.fix }, app.fixes.toastNow()?.at, app.settings.showInCapture).joinToString("|")}/// "正在听 · 03:12" / "面对面 · 03:12".@@ -202,7 +204,8 @@ object NotesViews {/// One line as a white bubble: who and when, the original small and grey, the translation in/// ink. The newest is outlined in the accent while more may come.- fun bubble(ui: Ui, line: TranscriptLine, numbers: Map<String, Int>, names: Map<Int, String>, newest: Boolean, listening: Boolean): LinearLayout {+ fun bubble(ui: Ui, line: TranscriptLine, numbers: Map<String, Int>, names: Map<Int, String>, newest: Boolean, listening: Boolean,+ onRevert: ((String, cicada.LineFix) -> Unit)? = null): LinearLayout {val who = cicada.SpeakerLabels.speakerName(line, numbers, names)val card = ui.stack(6)card.background = if (newest && listening) ui.rounded(Palette.card, 22, android.graphics.Color.parseColor("#F2C3B2"), 1.5) else ui.rounded(Palette.card, 22)@@ -211,8 +214,10 @@ object NotesViews {val head = ui.text("$who · ${Languages.clock(line.t)}", 12f, Palette.secondary, lines = 1)card.addView(if (line.speaker == "me" || numbers[line.id] != null) ui.row(8, avatar(ui, line, numbers, who), head) else head)val translated = !line.dst.isNullOrEmpty() && line.dst != line.shown- if (translated) card.addView(ui.text(line.shown, Ui.Type.ORIGINAL, Palette.secondary).apply { leading(1.45f) })- card.addView(ui.text(line.dst?.takeIf { translated } ?: line.shown, Ui.Type.TRANSLATION, Palette.ink).apply { leading(1.5f) })+ if (translated) card.addView(ui.text(FixViews.text(ui, line), Ui.Type.ORIGINAL, Palette.secondary).apply { leading(1.45f) })+ card.addView(ui.text(line.dst?.takeIf { translated } ?: FixViews.text(ui, line), Ui.Type.TRANSLATION, Palette.ink).apply { leading(1.5f) })+ // The line being said shows its fixed words open (the Mac's notes window does too): nothing to hover with.+ if (onRevert != null) FixViews.fixedWords(ui, line.id, line.fixes ?: emptyList(), onRevert)?.let { card.addView(it, ui.lp(top = 4)) }if (newest) card.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITEreturn card}@@ -225,7 +230,11 @@ object NotesViews {val numbers = cicada.SpeakerLabels.numbers(lines)val names = app.listen.sessionId?.let { app.store.get(it) }?.let { cicada.SpeakerLabels.names(it) } ?: emptyMap()val shown = lines.takeLast(count)- shown.forEachIndexed { i, l -> box.addView(bubble(ui, l, numbers, names, i == shown.lastIndex, app.listen.listening)) }+ val id = app.listen.sessionId+ shown.forEachIndexed { i, l ->+ val revert: ((String, cicada.LineFix) -> Unit)? = if (i == shown.lastIndex && id != null) { lineId, f -> app.fixes.revert(f, lineId, id) } else null+ box.addView(bubble(ui, l, numbers, names, i == shown.lastIndex, app.listen.listening, revert))+ }if (app.listen.listening) box.addView(LinearLayout(ui.context).apply {orientation = LinearLayout.HORIZONTALgravity = Gravity.CENTER_VERTICAL@@ -274,8 +283,8 @@ object NotesViews {card.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITEval translated = !line.dst.isNullOrEmpty() && line.dst != line.shownif (!translated && line.speaker == "me") card.addView(ui.text(L("你 · 同传"), 14f, Palette.secondary))- if (translated) card.addView(ui.text(said(line), 14f, Palette.secondary, lines = if (lines > 0) lines - 1 else 0))- card.addView(ui.text(line.dst ?: line.shown, big, Palette.ink, bold = true, lines = lines).apply { leading(1.25f) }, ui.lp(top = if (translated || line.speaker == "me") 8 else 0))+ if (translated) card.addView(ui.text(if (line.speaker == "me") said(line) else FixViews.text(ui, line), 14f, Palette.secondary, lines = if (lines > 0) lines - 1 else 0))+ card.addView(ui.text(line.dst ?: FixViews.text(ui, line), big, Palette.ink, bold = true, lines = lines).apply { leading(1.25f) }, ui.lp(top = if (translated || line.speaker == "me") 8 else 0))if (dots && app.listen.listening) card.addView(LinearLayout(ui.context).apply {orientation = LinearLayout.HORIZONTALgravity = Gravity.CENTER_VERTICALdiff --git a/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.kt b/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.ktindex a6be199..0827ec6 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.kt@@ -36,6 +36,8 @@ class Overlay(private val app: CicadaApp) {private var live: LinearLayout? = nullprivate var notes: FrameLayout? = nullprivate var shownKey: String? = null+ /// The 这样改对吗? card is up (for the debug state: a secure window can't be screenshotted).+ private var asking = falseprivate val tick = object : Runnable {override fun run() { if (root != null) { clockText?.text = NotesViews.clock(app); render(); NotesViews.tickEnding(root, app); app.main.postDelayed(this, 1000) } }}@@ -339,6 +341,29 @@ class Overlay(private val app: CicadaApp) {}else -> box.addView(NotesViews.liveCard(ui, app, line, 18f, Palette.ground, lines = 3, dots = false).apply { setPadding(ui.dp(14), ui.dp(12), ui.dp(14), ui.dp(12)) })}+ // 这样改对吗? in the live notes, never while the window is shown to the other side (共享屏幕时+ // 让对方看到): names wait for after the meeting then. Taps reach it; it never takes focus.+ asking = false+ val sid = app.listen.sessionId+ if (!dark && sid != null) {+ if (!app.settings.showInCapture) app.fixes.asking(sid)?.let { a ->+ asking = true+ box.addView(FixViews.confirmCard(ui, a, { yes -> app.fixes.answer(a.fix, yes, sid) }, { app.fixes.later(a.fix, sid) }), ui.lp(top = 8))+ }+ app.fixes.toastNow()?.let { t ->+ box.addView(LinearLayout(app).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ background = ui.rounded(Palette.ink, 12)+ setPadding(ui.dp(12), 0, ui.dp(4), 0)+ addView(ui.text(t.text, 13f, Color.WHITE, lines = 2), ui.weight())+ if (app.fixes.canUndo) addView(ui.text(L("撤销"), 13f, Color.parseColor("#FFB59B"), bold = true).apply {+ gravity = Gravity.CENTER; minHeight = ui.dp(40); setPadding(ui.dp(10), 0, ui.dp(10), 0)+ ui.tappable(this, 10, dark = true) { app.background.execute { app.fixes.undo() } }+ })+ }, ui.lp(top = 8))+ }+ }}notes?.let { box ->box.removeAllViews()@@ -363,6 +388,7 @@ class Overlay(private val app: CicadaApp) {"secure" to params?.let { it.flags and WindowManager.LayoutParams.FLAG_SECURE != 0 },"focusable" to params?.let { it.flags and WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE == 0 },"view" to app.settings.view,+ "fixCard" to (root != null && asking),"x" to params?.x, "y" to params?.y,)}diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.ktindex 2d29b0e..3869d0c 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt@@ -147,6 +147,7 @@ class RecordActivity : Activity() {// The file is there but MediaPlayer can't open it: said as 找不到录音 instead of a dead bar.private var broken = falseprivate var playing: String? = null // the line at the playhead, for the highlight+ private var toast: FixViews.Toast? = nullprivate val tickPlayer = object : Runnable {override fun run() { updatePlayer(); if (player?.isPlaying == true) list.postDelayed(this, 250) }}@@ -167,6 +168,8 @@ class RecordActivity : Activity() {addFooterView(footer, null, false)adapter = [email protected]setOnItemClickListener { _, _, pos, _ -> (pos - headerViewsCount).takeIf { it in 0 until [email protected] }?.let { playFrom([email protected](it).t) } }+ // 改正听错的词: a long press shows what a line's fixed words were heard as (改回) and 改这句….+ setOnItemLongClickListener { _, _, pos, _ -> (pos - headerViewsCount).takeIf { it in 0 until [email protected] }?.let { FixViews.lineSheet(this@RecordActivity, ui, cicada, [email protected], [email protected](it)) } != null }setOnScrollListener(object : android.widget.AbsListView.OnScrollListener {override fun onScrollStateChanged(v: android.widget.AbsListView, state: Int) {}override fun onScroll(v: android.widget.AbsListView, first: Int, visible: Int, total: Int) = pin()@@ -195,10 +198,17 @@ class RecordActivity : Activity() {setContentView(ui.screen(this, null, back = true, ground = Palette.card, body = body, scroll = false, center = barTitle, actions = listOf(ui.roundButton(R.drawable.i_share, L("分享"), onWhite = true) { cicada.store.get(id)?.let(::share) },ui.roundButton(R.drawable.i_more, L("更多"), onWhite = true) { more() })))+ toast = FixViews.Toast(this, ui, cicada, above = 140)}private fun audio() = cicada.store.audioFile(id)+ /// The banner's line, in view: the transcript tab, scrolled to it.+ private fun show(lineId: String) {+ val i = adapter.indexOf(lineId)+ if (i >= 0) list.post { list.setSelectionFromTop(i + list.headerViewsCount, ui.dp(160)) }+ }+/// The title moves into the top bar once the big one is out of sight, and the tabs pin once/// theirs scroll under the top edge (the header leaves the list entirely far down a transcript).private fun pin() {@@ -224,13 +234,14 @@ class RecordActivity : Activity() {private fun render() {val app = cicadaval s = app.store.get(id) ?: run { if (app.store.loaded) finish(); return }+ toast?.refresh()val generating = app.notes.generating == idval live = app.listen.listening && app.listen.sessionId == idval file = !live && audio().isFileif (!file) releasePlayer() else if (player == null && !broken) broken = ensurePlayer() == nullval playable = file && !brokenval key = listOf(SessionStore.displayTitle(s), s.lines.size, s.notes?.updatedAt, generating, app.notes.status, tab, s.lines.lastOrNull()?.dst,- s.voiceNames, app.settings.speakerVoices, live, s.hasAudio, playable, app.settings.recordAudio).joinToString("|")+ s.voiceNames, app.settings.speakerVoices, live, s.hasAudio, playable, app.settings.recordAudio, app.store.lines(id).sumOf { it.fixes?.hashCode() ?: 0 }, app.fixes.pending(id).size).joinToString("|")if (key == shown) returnshown = keyval top = ui.stack(0).apply { setPadding(ui.dp(20), ui.dp(4), ui.dp(20), ui.dp(6)) }@@ -248,6 +259,9 @@ class RecordActivity : Activity() {val tabLabels = listOf(L("纪要"), "${L("文字记录")} · ${LF("%lld 句", s.lines.size)}")val tabs = ui.tabs(tabLabels, tab) { tab = it; render() }top.addView(tabs, ui.lp(top = 18))+ // Over a finished meeting's transcript: the words fixed, and those waiting for the user.+ if (tab == 1 && !live) FixViews.reviewBanner(ui, app.fixes, s, onShow = { show(it) }, onEdit = { l, start -> FixViews.edit(this, ui, app, id, l, start) })+ ?.let { top.addView(it, ui.lp(top = 14)) }headTabs = tabsheader.removeAllViews(); header.addView(top)pinnedTabs.removeAllViews()@@ -372,8 +386,8 @@ class RecordActivity : Activity() {setTextColor(if (l.speaker == "me") Palette.ink else NotesViews.voiceColor(numbers[l.id]).second.takeIf { numbers[l.id] != null } ?: Palette.secondary)}val translated = !l.dst.isNullOrEmpty() && l.dst != l.shown- (texts.getChildAt(1) as TextView).apply { text = l.shown; visibility = if (translated) View.VISIBLE else View.GONE }- (texts.getChildAt(2) as TextView).text = if (translated) l.dst else l.shown+ (texts.getChildAt(1) as TextView).apply { text = FixViews.text(ui, l); visibility = if (translated) View.VISIBLE else View.GONE }+ (texts.getChildAt(2) as TextView).text = if (translated) l.dst else FixViews.text(ui, l)return row}}diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/SettingsActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/SettingsActivity.ktindex 045c8d7..89f6e76 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/SettingsActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/SettingsActivity.kt@@ -43,7 +43,7 @@ class SettingsActivity : Activity() {private fun build() {val app = cicadaval s = app.settings- val key = listOf(app.ling.keyState, app.ling.currentKey()?.takeLast(4), app.ling.aiCheck.summary, s.toJson(), app.canOverlay, Strings.language, app.updates.available?.version, app.updates.manual).joinToString("|")+ val key = listOf(app.ling.keyState, app.ling.currentKey()?.takeLast(4), app.ling.aiCheck.summary, s.toJson(), app.canOverlay, Strings.language, app.updates.available?.version, app.updates.manual, app.vocabulary.terms.size).joinToString("|")if (key == shown) returnshown = keypage.removeAllViews()@@ -73,7 +73,12 @@ class SettingsActivity : Activity() {page.addView(ui.group(listOf(ui.switchRow(L("说话人识别"), if (voicesHere) L("按声音标出说话人 1、2…,只在这台手机上处理") else L("显示 Mac 和 Windows 上分出的说话人;这台手机还不能按声音分人"),s.speakerVoices) { s.speakerVoices = it; app.saveSettings() },- ui.switchRow(L("保存会议录音"), L("只存在这台手机上,会议记录里能回放原声"), s.recordAudio) { s.recordAudio = it; app.saveSettings() })))+ ui.switchRow(L("保存会议录音"), L("只存在这台手机上,会议记录里能回放原声"), s.recordAudio) { s.recordAudio = it; app.saveSettings() },+ // 改正听错的词: its switches and the word list (the Mac's 设置 › 词表).+ ui.listRow(L("词表"), if (s.fixMisheard && app.ling.usable) L("会中改正听错的词") else L("已关"),+ trailing = value(if (app.vocabulary.terms.isEmpty()) "" else "${app.vocabulary.terms.size}")) {+ startActivity(Intent(this, WordListActivity::class.java))+ })))page.addView(ui.sectionLabel(L("我说 · 面对面")))page.addView(ui.group(listOf(diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/WordListActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/WordListActivity.ktnew file mode 100644index 0000000..4e743ab--- /dev/null+++ b/android/app/src/main/kotlin/com/wquguru/cicada/WordListActivity.kt@@ -0,0 +1,247 @@+package com.wquguru.cicada++import android.app.Activity+import android.content.Intent+import android.os.Bundle+import android.text.SpannableString+import android.text.style.StyleSpan+import android.view.Gravity+import android.view.View+import android.widget.EditText+import android.widget.LinearLayout+import cicada.Strings.L+import cicada.Strings.LF+import cicada.Vocabulary++/// 设置 › 词表 (the Mac's WordListSettings.swift): the two switches of 改正听错的词, and the word list+/// itself: each word (tap to change its spelling), what it has been heard as (× takes one off, ++/// adds one), where it came from and how often it fixed a line. A deleted word comes back with+/// 撤销; 粘贴导入… takes many at once and says what it will do first.+class WordListActivity : Activity() {+ private lateinit var ui: Ui+ private lateinit var page: LinearLayout+ private var unobserve: (() -> Unit)? = null+ private var shown: String? = null+ private var query = ""+ private var search: EditText? = null+ /// A deleted word, shown in its place with 撤销 for a few seconds.+ private var deleted: Pair<Vocabulary.Term, Int>? = null+ private var deletedAt = 0L++ override fun onCreate(savedInstanceState: Bundle?) {+ super.onCreate(savedInstanceState)+ ui = Ui(this)+ page = ui.stack(0).apply { setPadding(ui.dp(16), ui.dp(4), ui.dp(16), ui.dp(32)) }+ setContentView(ui.screen(this, L("词表"), back = true, ground = Palette.ground, body = page))+ }++ override fun onResume() { super.onResume(); unobserve = cicada.observe(::build); shown = null; build() }+ override fun onPause() { super.onPause(); unobserve?.invoke(); unobserve = null }++ private fun build() {+ val app = cicada+ val s = app.settings+ val terms = app.vocabulary.terms+ val key = listOf(terms, s.fixMisheard, s.askNames, app.ling.usable, app.ling.provider.id, deleted?.first?.word, query).joinToString("|")+ if (key == shown) return+ shown = key+ page.removeAllViews()++ // The switches; without an AI service the first gives way to a way to set one up.+ val usable = app.ling.usable+ val fixRow = if (usable) ui.switchRow(L("会中改正听错的词"), LF("走 %@,只发文字", AiServiceActivity.name(app.ling.provider)), s.fixMisheard) {+ s.fixMisheard = it; app.saveSettings()+ } else ui.listRow(L("会中改正听错的词"), L("接上 AI 服务后才会改"), trailing = ui.text(L("去设置"), 15f, Palette.link, bold = true), chevron = false) {+ startActivity(Intent(this, AiServiceActivity::class.java))+ }+ val askRow = ui.switchRow(L("没见过的名字和专称先问我"), L("关掉就只改词表里的词和同音错字"), s.askNames) { s.askNames = it; app.saveSettings() }+ if (!s.fixMisheard || !usable) { askRow.alpha = 0.45f; askRow.isEnabled = false; disable(askRow) }+ page.addView(ui.group(listOf(fixRow, askRow)), ui.lp(top = 8))++ // 词 · N, and 粘贴导入….+ page.addView(LinearLayout(this).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ setPadding(ui.dp(4), ui.dp(22), 0, ui.dp(8))+ addView(ui.text(L("词"), 15f, Palette.secondary, bold = true))+ if (terms.isNotEmpty()) addView(ui.text("${terms.size}", 14f, Palette.tertiary).apply { fontFeatureSettings = "tnum" }, LinearLayout.LayoutParams(-2, -2).apply { leftMargin = ui.dp(8) })+ addView(ui.spacer())+ addView(ui.button(L("粘贴导入…"), "primary", height = 40) { importSheet() })+ })+ if (terms.size > 12) {+ val field = search ?: EditText(this).apply {+ hint = L("搜索词表"); setSingleLine(); textSize = 15f+ background = ui.rounded(Palette.card, 14); setPadding(ui.dp(14), 0, ui.dp(14), 0); minHeight = ui.dp(44)+ addTextChangedListener(object : android.text.TextWatcher {+ override fun beforeTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}+ override fun onTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}+ override fun afterTextChanged(e: android.text.Editable?) { query = e.toString(); build() }+ })+ }.also { search = it }+ (field.parent as? android.view.ViewGroup)?.removeView(field)+ page.addView(field, ui.lp().apply { bottomMargin = ui.dp(10) })+ }++ val d = deleted?.takeIf { System.currentTimeMillis() - deletedAt < 8000 }+ if (terms.isEmpty() && d == null) {+ page.addView(ui.helper(L("还没有词。把常用的人名、产品名贴进来,会中就照这些写法改"), Palette.tertiary).apply { setPadding(ui.dp(4), ui.dp(6), ui.dp(4), ui.dp(6)) })+ } else {+ val rows = mutableListOf<View>()+ if (d != null) rows.add(LinearLayout(this).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ minimumHeight = ui.dp(52)+ setPadding(ui.dp(16), 0, ui.dp(4), 0)+ val t = SpannableString(L("已删除") + " " + d.first.word)+ t.setSpan(StyleSpan(android.graphics.Typeface.BOLD), t.length - d.first.word.length, t.length, 0)+ addView(ui.text(t, 15f, Palette.secondary, lines = 1), ui.weight())+ addView(ui.textButton(L("撤销")) { app.vocabulary.insert(d.first, d.second); deleted = null; build() })+ })+ for (t in shownTerms(terms)) rows.add(wordRow(t))+ page.addView(ui.group(rows))+ }+ page.addView(ui.helper(LF("最多 %lld 个,满了优先用最近的。只存在这台手机上", Vocabulary.LIMIT), Palette.tertiary).apply { setPadding(ui.dp(4), ui.dp(12), ui.dp(4), 0) })+ }++ private fun disable(v: View) {+ v.isClickable = false+ v.setOnClickListener(null)+ }++ /// Most recently useful first, then the rest newest first; the search keeps words or heard forms that match.+ private fun shownTerms(terms: List<Vocabulary.Term>): List<Vocabulary.Term> {+ val all = terms.reversed().sortedByDescending { it.used ?: java.time.Instant.EPOCH }+ val q = Vocabulary.key(query)+ if (q.isEmpty()) return all+ return all.filter { t -> Vocabulary.key(t.word).contains(q) || t.heard.any { Vocabulary.key(it).contains(q) } }+ }++ private fun wordRow(t: Vocabulary.Term): View {+ val app = cicada+ val v = app.vocabulary+ val row = ui.stack(8)+ row.setPadding(ui.dp(16), ui.dp(12), ui.dp(4), ui.dp(12))+ row.addView(LinearLayout(this).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ // The word: a tap changes its spelling; what it was heard as stays with it.+ addView(ui.text(t.word, 17f, Palette.ink, bold = true, lines = 1).apply {+ contentDescription = "${t.word},${L("点一下改写法")}"+ minHeight = ui.dp(40); gravity = Gravity.CENTER_VERTICAL+ ui.tappable(this, 8) { ui.input(this@WordListActivity, L("词表"), t.word, helper = L("点一下改写法")) { v.rename(t.word, it) } }+ }, ui.weight())+ addView(ui.iconButton(R.drawable.i_trash, L("从词表里删掉"), Palette.tertiary, 20) { remove(t) })+ })+ // What it has been heard as: × takes one off; + adds one (asking whose it is when another word has it).+ val chips = LinearLayout(this).apply { orientation = LinearLayout.VERTICAL }+ var line = LinearLayout(this)+ var used = 0+ val width = resources.displayMetrics.widthPixels - ui.dp(80)+ fun place(chip: View) {+ chip.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)+ val w = chip.measuredWidth + ui.dp(6)+ if (line.childCount > 0 && used + w > width) { chips.addView(line); line = LinearLayout(this); used = 0 }+ line.addView(chip, LinearLayout.LayoutParams(-2, -2).apply { rightMargin = ui.dp(6); bottomMargin = ui.dp(6) })+ used += w+ }+ for (h in t.heard) place(LinearLayout(this).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.CENTER_VERTICAL+ background = ui.rounded(Palette.ground, 8)+ setPadding(ui.dp(10), 0, 0, 0)+ addView(ui.text(h, 14f, Palette.secondary, lines = 1))+ addView(ui.iconButton(R.drawable.i_close, L("删掉这个听错的词"), Palette.tertiary, 14) { v.forget(h, t.word) }, LinearLayout.LayoutParams(ui.dp(36), ui.dp(36)))+ })+ place(ui.text("+ " + L("加一个容易听错的词"), 13f, Palette.link, lines = 1).apply {+ gravity = Gravity.CENTER_VERTICAL+ minHeight = ui.dp(36)+ setPadding(ui.dp(10), 0, ui.dp(10), 0)+ background = ui.rounded(Palette.card, 8, Palette.outline, 1)+ ui.tappable(this, 8, background) { addHeard(t) }+ })+ if (line.childCount > 0) chips.addView(line)+ row.addView(chips)+ val live = t.source == "live"+ val meta = SpannableString((if (live) L("会中确认") else L("你加的")) + " · " + (if (t.fixes > 0) LF("改过 %lld 次", t.fixes) else L("还没用上")))+ if (live) meta.setSpan(android.text.style.ForegroundColorSpan(Palette.link), 0, L("会中确认").length, 0)+ row.addView(ui.text(meta, 13f, Palette.tertiary))+ return row+ }++ private fun addHeard(t: Vocabulary.Term) {+ val v = cicada.vocabulary+ ui.input(this, L("加一个容易听错的词"), "") { raw ->+ val h = raw.trim()+ if (h.isEmpty() || h.length > 40) return@input+ val owner = v.owners(h, t.word).firstOrNull()+ if (owner == null) { v.confirm(h, t.word, t.source); return@input }+ // Already another word's: whose should it be? Both kept is asked about each time, never fixed silently.+ lateinit var d: android.app.Dialog+ val body = ui.stack(10,+ ui.button(LF("改给 %@", t.word), "primary") { d.dismiss(); v.forget(h, owner); v.confirm(h, t.word, t.source) },+ ui.button(L("两个都留"), "quiet") { d.dismiss(); v.confirm(h, t.word, t.source) })+ d = ui.sheet(this, LF("“%@”已经记在 %@ 下", h, owner), body)+ d.show()+ }+ }++ private fun remove(t: Vocabulary.Term) {+ val v = cicada.vocabulary+ val index = v.terms.indexOf(t).coerceAtLeast(0)+ v.remove(t.word)+ deleted = t to index+ deletedAt = System.currentTimeMillis()+ page.postDelayed({ if (System.currentTimeMillis() - deletedAt >= 8000) { deleted = null; shown = null; build() } }, 8100)+ shown = null+ build()+ }++ /// 粘贴导入: one per line, heard forms after "="; the counts follow what is pasted, and the+ /// button says how many go in.+ private fun importSheet() {+ val v = cicada.vocabulary+ lateinit var d: android.app.Dialog+ val field = EditText(this).apply {+ hint = "Uniswap V3\nMorpho = 莫拉、莫法\n巡检"+ textSize = 15f+ gravity = Gravity.TOP+ minLines = 5; maxLines = 9+ background = ui.rounded(Palette.ground, 16)+ setPadding(ui.dp(14), ui.dp(12), ui.dp(14), ui.dp(12))+ }+ val counts = ui.text("", 13f, Palette.secondary)+ val result = ui.text("", 13f, Palette.link).apply { visibility = View.GONE }+ lateinit var go: LinearLayout+ val buttons = LinearLayout(this).apply { orientation = LinearLayout.HORIZONTAL }+ fun update() {+ val text = field.text.toString()+ val p = v.preview(text)+ counts.text = if (text.isBlank()) "" else LF("新增 %lld · 补充听成 %lld · 跳过 %lld", p.added, p.updated, p.skipped.size)+ val n = p.added + p.updated+ (go.getChildAt(0) as android.widget.TextView).text = LF("导入 %lld 个", n)+ go.isEnabled = n > 0; go.alpha = if (n > 0) 1f else 0.4f+ }+ go = ui.button(LF("导入 %lld 个", 0), "primary") {+ val r = v.importText(field.text.toString())+ field.setText(""); field.isEnabled = false+ counts.text = LF("新增 %lld · 补充听成 %lld · 跳过 %lld", r.added, r.updated, r.skipped.size)+ counts.setTextColor(Palette.ink)+ if (r.skipped.isNotEmpty()) { result.text = LF("第 %@ 行没加进去:超过 40 个字", r.skipped.joinToString("、")); result.visibility = View.VISIBLE }+ buttons.removeAllViews()+ buttons.addView(ui.button(L("完成"), "primary") { d.dismiss() }, ui.weight())+ }+ field.addTextChangedListener(object : android.text.TextWatcher {+ override fun beforeTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}+ override fun onTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}+ override fun afterTextChanged(e: android.text.Editable?) { if (field.isEnabled) update() }+ })+ buttons.addView(ui.button(L("取消"), "quiet") { d.dismiss() }, ui.weight())+ buttons.addView(go, ui.weight().apply { leftMargin = ui.dp(10) })+ update()+ val body = ui.stack(10, ui.helper(L("一行一个。常被听错的词,写在 = 后面")).apply { setPadding(ui.dp(8), 0, ui.dp(8), 0) }, field, counts, result, buttons)+ d = ui.sheet(this, L("粘贴导入"), body)+ d.window?.setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE or android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)+ d.show()+ field.requestFocus()+ }+}diff --git a/android/app/src/main/strings/en.lproj/Android.strings b/android/app/src/main/strings/en.lproj/Android.stringsindex ce7f400..68ea07a 100644--- a/android/app/src/main/strings/en.lproj/Android.strings+++ b/android/app/src/main/strings/en.lproj/Android.strings@@ -223,3 +223,4 @@"这句没说出去 · 连不上 %@" = "This line wasn't said · can't reach %@";"例如 kokoro" = "e.g. kokoro";"例如 af_heart" = "e.g. af_heart";+"最多 %lld 个,满了优先用最近的。只存在这台手机上" = "Up to %lld, recent ones first. Stored only on this phone";diff --git a/android/app/src/main/strings/ja.lproj/Android.strings b/android/app/src/main/strings/ja.lproj/Android.stringsindex 35124db..d492ea5 100644--- a/android/app/src/main/strings/ja.lproj/Android.strings+++ b/android/app/src/main/strings/ja.lproj/Android.strings@@ -223,3 +223,4 @@"这句没说出去 · 连不上 %@" = "この文は発話していません · %@ に接続できません";"例如 kokoro" = "例: kokoro";"例如 af_heart" = "例: af_heart";+"最多 %lld 个,满了优先用最近的。只存在这台手机上" = "最大 %lld 個、最近使ったものを優先。このスマホにだけ保存";diff --git a/android/app/src/main/strings/ko.lproj/Android.strings b/android/app/src/main/strings/ko.lproj/Android.stringsindex 3133328..aead084 100644--- a/android/app/src/main/strings/ko.lproj/Android.strings+++ b/android/app/src/main/strings/ko.lproj/Android.strings@@ -223,3 +223,4 @@"这句没说出去 · 连不上 %@" = "이 문장은 말하지 않았습니다 · %@에 연결할 수 없음";"例如 kokoro" = "예: kokoro";"例如 af_heart" = "예: af_heart";+"最多 %lld 个,满了优先用最近的。只存在这台手机上" = "최대 %lld개, 최근 것을 우선. 이 휴대전화에만 저장";diff --git a/site/changelog.json b/site/changelog.jsonindex 1c0a452..61905c3 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -61,6 +61,22 @@],"title": "Android 上开会时,听错的人名和术语在字幕和纪要里当场改对(需要 AI 服务)。","text": "每句话说完,AI 服务顺带找出听错的词:读音相近的错字(质压 → 质押)直接改,没见过的名字(莫福 → Morpho)先问一次,答“对”以后就自动改,词表里的写法也直接用上。Ming 已经翻好的句子会再发一次文字请求来改词,多花一点点。记录里仍留着原来听到的文字。"+ },+ {+ "kind": "new",+ "platforms": [+ "android"+ ],+ "title": "Android 的会议记录里可以自己改听错的词:长按一句选“改这句…”,整场同样听错的地方一起改,并记进词表;会后逐个确认还没定的改法,每次改动都能撤销。",+ "text": "长按一句能看到改过的词原来听成什么,点“改回”就恢复。会议结束后,文字记录顶部会逐个问还没确认的改法(对 / 不对 / 改成…)。“正在听”和悬浮窗里的“这样改对吗?”可以按 × 留到会后再问;共享屏幕时悬浮窗不问。"+ },+ {+ "kind": "new",+ "platforms": [+ "android"+ ],+ "title": "Android 设置里多了“词表”:常用的人名、产品名一次贴进来,写法和听错的形式都能就地改。",+ "text": "一行一个,常被听错的写法写在 = 后面(Morpho = 莫拉),导入前先显示会新增几个。会中答“对”的词也会记进来,标着“会中确认”和改过几次;删掉的词可以撤销。词表只存在这台手机上。"}]},