Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。
feat(ui): one door into the notebook, with the raw text a tap away
booboosuif9fcb60b1e1a
diff --git a/app/src/main/java/net/kuafuai/andee/ui/NotebookUi.kt b/app/src/main/java/net/kuafuai/andee/ui/NotebookUi.ktindex 67e7e1b..11f4b3f 100644--- a/app/src/main/java/net/kuafuai/andee/ui/NotebookUi.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/NotebookUi.kt@@ -1,6 +1,8 @@package net.kuafuai.andee.uiimport android.annotation.SuppressLint+import android.content.ClipData+import android.content.ClipboardManagerimport android.content.Contextimport android.graphics.Colorimport android.graphics.PixelFormat@@ -21,9 +23,9 @@ import java.util.Locale/*** 它记得的事: what the device remembers, browsable and deletable per item.*- * [Notebook.dumpText] is the other view into the book, and it is- * export-shaped — every field, as text, for copying out. This page answers a- * different question: "what is it allowed to remember about me".+ * The header's 复制全部 copies [Notebook.dumpText] — every field, untruncated,+ * export-shaped. That is the only route to the raw text; the rows here answer+ * a different question: "what is it allowed to remember about me".** **记忆** groups [Notebook.Memory] by type, most important first within each.* **待办** lists active and paused [Notebook.Todo]s, soonest first.@@ -156,10 +158,40 @@ class NotebookUi(},LinearLayout.LayoutParams(0, WRAP, 1f),)+ h.addView(copyButton())+ h.addView(View(context), LinearLayout.LayoutParams(dp(8), 1))h.addView(closeButton())return h}+ private fun copyButton(): TextView = TextView(context).apply {+ val label = lctx.getString(R.string.notebook_copy_all)+ text = label+ textSize = Glass.Type.CAPTION+ setTextColor(Color.parseColor(Glass.SECONDARY))+ gravity = Gravity.CENTER+ setPadding(dp(12), 0, dp(12), 0)+ background = Glass.panel(context, dp(16))+ isClickable = true+ Glass.pressable(this)+ setOnClickListener {+ val cm = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager+ val ok = runCatching {+ cm.setPrimaryClip(+ ClipData.newPlainText(lctx.getString(R.string.notebook_title), Notebook.dumpText(context)),+ )+ }.isSuccess+ if (!ok) return@setOnClickListener+ text = lctx.getString(R.string.notebook_copied)+ setTextColor(Color.parseColor(Glass.OK))+ postDelayed({+ text = label+ setTextColor(Color.parseColor(Glass.SECONDARY))+ }, 1500)+ }+ layoutParams = LinearLayout.LayoutParams(WRAP, dp(32))+ }+private fun closeButton(): TextView = TextView(context).apply {text = "✕"textSize = Glass.Type.CAPTIONdiff --git a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.ktindex 95826a2..114b236 100644--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt@@ -26,16 +26,6 @@ import net.kuafuai.andee.i18n.AppLocaleimport net.kuafuai.andee.wake.WakeTemplatesimport net.kuafuai.andee.wake.WakeWord-/**- * How much of the notebook the settings card prints.- *- * Bounded because it is a `TextView` inside a scroll view inside a floating- * card, laid out on every rebuild: a few thousand lines would be paid for on- * each open, and again on every language switch. The cut is announced in the- * last line — a silent truncation would read as "this is all of it".- */-private const val NOTEBOOK_DUMP_CHARS = 6_000-/*** Settings overlay for editing [VoiceConfig].*@@ -180,9 +170,6 @@ class SettingsUi(/** Same, for the 火山 panel. Kept apart from [advancedOpen] — see there. */private var voiceOpen = false- /** Same, for the notebook dump. Kept apart so opening one does not unfold the other. */- private var notebookOpen = false-/*** The 诊断 section is showing the factory-reset warning instead of its* three buttons. Survives a [rebuild] so a language switch mid-confirmation@@ -942,27 +929,14 @@ class SettingsUi(lctx.getString(R.string.settings_notebook_today),notebookStats(),)- val dumpView = notebookDumpView()// Refresh only what a delete can change, not the whole card: a rebuild// cross-fades the sheet the user is about to look at again.panel.addView(button(lctx.getString(R.string.settings_notebook_browse), filled = false) {- NotebookUi(context) {- stats.text = notebookStats()- dumpView.text = notebookDumpText()- }.show()+ NotebookUi(context) { stats.text = notebookStats() }.show()},LinearLayout.LayoutParams(WRAP, WRAP).apply { topMargin = dp(10) },)-- val dump = collapsible(- form,- lctx.getString(R.string.settings_notebook_dump),- lctx.getString(R.string.settings_notebook_dump_hint),- isOpen = { notebookOpen },- setOpen = { notebookOpen = it },- )- dump.addView(dumpView, matchWrap())}private fun notebookStats(): String = lctx.getString(@@ -1009,38 +983,6 @@ class SettingsUi()}- /**- * The book itself, as text.- *- * Truncated at [NOTEBOOK_DUMP_CHARS] rather than paginated: this is a- * TextView inside a scroll view inside a floating card, and a few thousand- * lines of text would make every layout pass of that card expensive. The- * truncation says so in the last line — a silent cut-off would read as "this- * is everything".- */- private fun notebookDumpView(): TextView = TextView(context).apply {- text = notebookDumpText()- textSize = Glass.Type.CAPTION- typeface = android.graphics.Typeface.MONOSPACE- setTextColor(Color.parseColor(Glass.SECONDARY))- setLineSpacing(dp(3).toFloat(), 1f)- setTextIsSelectable(true)- }-- private fun notebookDumpText(): String {- val full = Notebook.dumpText(context)- return if (full.length <= NOTEBOOK_DUMP_CHARS) {- full- } else {- full.take(NOTEBOOK_DUMP_CHARS) +- "\n\n" +- lctx.getString(- R.string.settings_notebook_dump_truncated,- full.length - NOTEBOOK_DUMP_CHARS,- )- }- }-// ---- Widgets ----/** Section title + its panel. Returns the panel; rows go in there. */diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xmlindex 35c44de..b9bd0fd 100644--- a/app/src/main/res/values-en/strings.xml+++ b/app/src/main/res/values-en/strings.xml@@ -123,9 +123,6 @@<string name="settings_notebook_daily_cap">Reviews per day, at most</string><string name="settings_notebook_today">Today / so far</string><string name="settings_notebook_stats">%1$d reviews (~%2$d tokens) · %3$d memories · %4$d promises open</string>- <string name="settings_notebook_dump">What is in the book</string>- <string name="settings_notebook_dump_hint">Read-only. Long-press to select and copy.</string>- <string name="settings_notebook_dump_truncated">… (%1$d more characters not shown)</string><string name="settings_notebook_browse">See what it remembers</string><string name="settings_section_notify">Notifications</string><string name="settings_notify_chat">Chat apps</string>@@ -284,6 +281,8 @@<string name="notebook_dump_last_error">" last error: "</string><string name="notebook_title">What it remembers</string>+ <string name="notebook_copy_all">Copy all</string>+ <string name="notebook_copied">Copied</string><string name="notebook_tab_memories">Memories</string><string name="notebook_tab_todos">Todos</string><string name="notebook_empty_memories">Nothing written down yet</string>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 462997c..0ff6d49 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -100,9 +100,6 @@<string name="settings_notebook_daily_cap">每天最多复盘几次</string><string name="settings_notebook_today">今天 / 攒到现在</string><string name="settings_notebook_stats">复盘 %1$d 次(约 %2$d tokens)· 记住 %3$d 条 · 还欠着 %4$d 件事</string>- <string name="settings_notebook_dump">本子里写了什么</string>- <string name="settings_notebook_dump_hint">只读。长按可以选中复制。</string>- <string name="settings_notebook_dump_truncated">…(还有 %1$d 个字符没显示)</string><string name="settings_notebook_browse">看它记得的事</string><string name="settings_section_notify">消息提醒</string><string name="settings_notify_chat">聊天类</string>@@ -301,6 +298,8 @@uses; 踩过的坑 is).--><string name="notebook_title">它记得的事</string>+ <string name="notebook_copy_all">复制全部</string>+ <string name="notebook_copied">已复制</string><string name="notebook_tab_memories">记忆</string><string name="notebook_tab_todos">待办</string><string name="notebook_empty_memories">还没记下什么</string>