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、支持任意模型,记忆和密码绝不离开设备。
refactor(backend): fold voice into a 后端 section with a CodeFlying tab
booboosui8a12dc23fb51
diff --git a/app/build.gradle b/app/build.gradleindex 3f643e5..d328f57 100644--- a/app/build.gradle+++ b/app/build.gradle@@ -15,6 +15,11 @@ static def escapeStringLiteral(String value) {def buildConfigString = { String key ->escapeStringLiteral(localProps.getProperty(key, ''))}+// Boolean config: anything case-insensitive-matching "true"/"1"/"yes" counts.+def buildConfigBool = { String key ->+ def raw = localProps.getProperty(key, '').trim().toLowerCase()+ (raw == 'true' || raw == '1' || raw == 'yes') ? 'true' : 'false'+}android {namespace 'net.kuafuai.andee'@@ -34,12 +39,17 @@ android {testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"- buildConfigField "String", "ASR_ENDPOINT", buildConfigString('ASR_ENDPOINT')- buildConfigField "String", "TTS_ENDPOINT", buildConfigString('TTS_ENDPOINT')- buildConfigField "String", "API_KEY", buildConfigString('API_KEY')- buildConfigField "String", "LLM_BASE_URL", buildConfigString('LLM_BASE_URL')- buildConfigField "String", "DEFAULT_LANG", buildConfigString('DEFAULT_LANG')- buildConfigField "String", "DEFAULT_THINKING", buildConfigString('DEFAULT_THINKING')+ // The CodeFlying mode: a hosted backend that proxies LLM, ASR and TTS+ // from one domain. When ENABLED and DOMAIN is set, "codeflying" is the+ // out-of-box backend choice; URL scheme follows SSL_ENABLED+ // (ws/wss, http/https). Everything is derived at runtime from these+ // four fields — the user does not configure the endpoints themselves.+ buildConfigField "boolean", "CODEFLYING_ENABLED", buildConfigBool('CODEFLYING_ENABLED')+ buildConfigField "String", "CODEFLYING_KEY", buildConfigString('CODEFLYING_KEY')+ buildConfigField "String", "CODEFLYING_DOMAIN", buildConfigString('CODEFLYING_DOMAIN')+ buildConfigField "boolean", "CODEFLYING_SSL_ENABLED", buildConfigBool('CODEFLYING_SSL_ENABLED')+ buildConfigField "String", "DEFAULT_LANG", buildConfigString('DEFAULT_LANG')+ buildConfigField "String", "DEFAULT_THINKING", buildConfigString('DEFAULT_THINKING')}buildTypes {diff --git a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.ktindex b8201fc..9576ccd 100644--- a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt+++ b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt@@ -17,21 +17,16 @@ data class VoiceConfig() {companion object {/**- * The 火山 (Volcengine Speech) account the voice pipeline runs on.+ * The 火山 (Volcengine Speech) account the voice pipeline runs on when+ * the user is on the **本机** backend. On [BRAIN_CODEFLYING], the key+ * is derived from [BuildConfig.CODEFLYING_KEY] and this field is not+ * read.*- * **Empty on purpose, and it must stay empty in the repository.** This- * used to hold a real key so that a fresh install could hear and speak- * without setup. That trade is only available to a build nobody else- * reads: a key in public source is a key in a search index, and a bare- * UUID is not a shape GitHub's secret scanning recognises, so nothing- * would warn anyone it had leaked. Whoever ships a private build can- * put their own key back here; in this tree it is the user's to supply.- *- * The user supplies it in ⚙ (`api_key`). Blank in prefs falls back to- * this constant — see [load] — so with both empty the voice pipeline- * has no credential and ASR/TTS fail at connect time. That is reported- * *before* it happens by [net.kuafuai.andee.device.SelfCheck]'s- * `voice_key` row rather than being left to look like a network fault.+ * **Empty on purpose, and it must stay empty in the repository.** A key+ * in public source is a key in a search index, and a bare UUID is not a+ * shape GitHub's secret scanning recognises. Whoever ships a private+ * build either puts the key behind CodeFlying or asks the user to type+ * it in ⚙ (`api_key`).** On storage: the key lands in `voice_prefs.xml` in plaintext, like* `llm_api_key`. Neither leaves the device: `allowBackup` is off and@@ -68,14 +63,54 @@ data class VoiceConfig(* than "hub_url is blank ⇒ go local": [save] drops blank values, so a* URL that has ever been saved cannot be cleared from the UI, and* inferring the mode from it would leave the user with no way back.+ *+ * [BRAIN_CODEFLYING] is a hosted backend that proxies the LLM, ASR+ * and TTS from one domain. In this mode every endpoint and credential+ * is derived from `BuildConfig.CODEFLYING_*` and the user does not+ * fill in any voice / LLM fields.*/const val BRAIN_HUB = "hub"const val BRAIN_LOCAL = "local"+ const val BRAIN_CODEFLYING = "codeflying"const val DEFAULT_LLM_BASE_URL = "https://api.deepseek.com"const val DEFAULT_LLM_MODEL = "deepseek-flash"const val DEFAULT_REASONING_EFFORT = "high"+ /**+ * CodeFlying is available iff the build was configured with ENABLED and+ * a non-empty DOMAIN. ENABLED alone with no DOMAIN silently falls back+ * to [BRAIN_LOCAL] — the picker hides the CodeFlying tab and the+ * default brain reads as local.+ */+ fun isCodeFlyingAvailable(): Boolean =+ BuildConfig.CODEFLYING_ENABLED && BuildConfig.CODEFLYING_DOMAIN.isNotBlank()++ /** `wss` / `ws` for WebSocket URLs, chosen by `CODEFLYING_SSL_ENABLED`. */+ private fun codeFlyingWsScheme(): String =+ if (BuildConfig.CODEFLYING_SSL_ENABLED) "wss" else "ws"++ /** `https` / `http` for the LLM REST base URL. */+ private fun codeFlyingHttpScheme(): String =+ if (BuildConfig.CODEFLYING_SSL_ENABLED) "https" else "http"++ /** Full LLM REST base URL for CodeFlying, e.g. `https://foo.net/voice/llm`. */+ fun codeFlyingLlmBaseUrl(): String =+ "${codeFlyingHttpScheme()}://${BuildConfig.CODEFLYING_DOMAIN.trim().trimEnd('/')}/voice/llm"++ /** Full ASR WebSocket URL for CodeFlying. */+ fun codeFlyingAsrEndpoint(): String =+ "${codeFlyingWsScheme()}://${BuildConfig.CODEFLYING_DOMAIN.trim().trimEnd('/')}/voice/asr/bigmodel_async"++ /** Full TTS WebSocket URL for CodeFlying. */+ fun codeFlyingTtsEndpoint(): String =+ "${codeFlyingWsScheme()}://${BuildConfig.CODEFLYING_DOMAIN.trim().trimEnd('/')}/voice/tts/bidirection"++ /** Whether to show the 云端 (hub) tab in the backend picker. Default off. */+ fun showHub(context: Context): Boolean =+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)+ .getString("show_hub", "")?.trim()?.lowercase() == "on"+/*** Hub connection settings. Not part of the voice pipeline but stored* in the same SharedPreferences file to keep the settings UI simple.@@ -109,37 +144,67 @@ data class VoiceConfig(* device reads as [BRAIN_LOCAL], which is the out-of-box default.*/data class BrainConfig(- /** [BRAIN_HUB] or [BRAIN_LOCAL]. */+ /** [BRAIN_HUB], [BRAIN_LOCAL] or [BRAIN_CODEFLYING]. */val mode: String,- val apiKey: String, // empty = local brain cannot run+ val apiKey: String, // empty = on-device brain cannot runval baseUrl: String,val model: String,val thinking: Boolean,val reasoningEffort: String,) {- val isLocal: Boolean get() = mode == BRAIN_LOCAL+ /**+ * The agent loop runs on this device (local DeepSeek or CodeFlying+ * — both are "the brain is here", only the backend differs). Only+ * [BRAIN_HUB] is "run elsewhere, listen on a socket".+ */+ val isLocal: Boolean get() = mode == BRAIN_LOCAL || mode == BRAIN_CODEFLYING+ }++ /**+ * The brain mode in effect, with CodeFlying availability already+ * reconciled. Reads the saved `brain` pref; falls back to CodeFlying+ * if the build enables it and otherwise to local. Unknown saved values+ * fail closed to local — same rule as [groundingEnabled].+ */+ fun brainMode(context: Context): String {+ val p = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)+ val saved = p.getString("brain", "")?.trim()?.lowercase().orEmpty()+ return when (saved) {+ BRAIN_HUB -> BRAIN_HUB+ BRAIN_LOCAL -> BRAIN_LOCAL+ BRAIN_CODEFLYING -> if (isCodeFlyingAvailable()) BRAIN_CODEFLYING else BRAIN_LOCAL+ "" -> if (isCodeFlyingAvailable()) BRAIN_CODEFLYING else BRAIN_LOCAL+ else -> BRAIN_LOCAL+ }}fun brainConfig(context: Context): BrainConfig {val p = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)- // Anything other than the exact string "hub" is the local brain,- // so a typo fails closed onto the out-of-box default — same rule- // as [groundingEnabled]. It used to fail onto the hub, back when- // the hub was the default; the default moved, so the direction- // moved with it, and the picker's leftmost option (the fallback- // when the saved value matches nothing) had to move too.- val mode = if (p.getString("brain", BRAIN_LOCAL)?.trim()?.lowercase() == BRAIN_HUB) {- BRAIN_HUB- } else {- BRAIN_LOCAL+ val mode = brainMode(context)+ // CodeFlying derives everything from the build — the user does not+ // see or edit the endpoints. llm_model / thinking / effort are+ // deliberately *still* read from prefs so the same picker in+ // [SettingsUi] applies to both local and CodeFlying.+ if (mode == BRAIN_CODEFLYING) {+ return BrainConfig(+ mode = BRAIN_CODEFLYING,+ apiKey = BuildConfig.CODEFLYING_KEY,+ baseUrl = codeFlyingLlmBaseUrl(),+ model = p.getString("llm_model", DEFAULT_LLM_MODEL)+ .orEmpty().trim().ifEmpty { DEFAULT_LLM_MODEL },+ thinking = p.getString("llm_thinking", defaultThinking())+ ?.trim()?.lowercase() != "disabled",+ reasoningEffort = p.getString("llm_reasoning_effort", DEFAULT_REASONING_EFFORT)+ .orEmpty().trim().ifEmpty { DEFAULT_REASONING_EFFORT },+ )}return BrainConfig(mode = mode,- apiKey = p.getString("llm_api_key", "").orEmpty().trim().ifEmpty { BuildConfig.API_KEY },+ apiKey = p.getString("llm_api_key", "").orEmpty().trim(),// trimEnd('/') because the client appends "/chat/completions"// and a trailing slash from the settings field would produce a// double slash, which some gateways 404 on.- baseUrl = p.getString("llm_base_url", BuildConfig.LLM_BASE_URL)+ baseUrl = p.getString("llm_base_url", "").orEmpty().trim().trimEnd('/').ifEmpty { DEFAULT_LLM_BASE_URL },model = p.getString("llm_model", DEFAULT_LLM_MODEL).orEmpty().trim().ifEmpty { DEFAULT_LLM_MODEL },@@ -242,25 +307,23 @@ data class VoiceConfig(uid = "tablet-body-${UUID.randomUUID().toString().take(8)}"p.edit().putString("uid", uid).apply()}+ // On CodeFlying every endpoint and credential is derived from the+ // build — the user never sees these fields. On 本机 the prefs rule+ // (user's own 火山 account); 云端 shares the same prefs because+ // ASR/TTS still run on this device whichever brain answers.+ val codeFlying = brainMode(context) == BRAIN_CODEFLYINGreturn VoiceConfig(- // Empty in prefs → [API_KEY], which is itself empty in the- // public source. Trim before the fallback so a field cleared to- // spaces behaves like a cleared field.- apiKey = p.getString("api_key", "").orEmpty().trim().ifEmpty { BuildConfig.API_KEY },- // asr/tts endpoints: prefs (if set) > BuildConfig (if non-empty)- // > official address. The BuildConfig step is how local.properties- // can override the default, and it sits ABOVE the official fallback- // so a custom endpoint survives even when the user clears the- // settings field (which removes the pref).- asrEndpoint = p.getString("asr_endpoint", null)+ apiKey = if (codeFlying) BuildConfig.CODEFLYING_KEY+ else p.getString("api_key", "").orEmpty().trim().ifEmpty { API_KEY },+ asrEndpoint = if (codeFlying) codeFlyingAsrEndpoint()+ else p.getString("asr_endpoint", null)?.takeIf { it.isNotEmpty() }- ?: BuildConfig.ASR_ENDPOINT.takeIf { it.isNotEmpty() }?: DEFAULT_ASR_ENDPOINT,asrResourceId = p.getString("asr_resource_id", DEFAULT_ASR_RESOURCE)!!,asrUid = uid,- ttsEndpoint = p.getString("tts_endpoint", null)+ ttsEndpoint = if (codeFlying) codeFlyingTtsEndpoint()+ else p.getString("tts_endpoint", null)?.takeIf { it.isNotEmpty() }- ?: BuildConfig.TTS_ENDPOINT.takeIf { it.isNotEmpty() }?: DEFAULT_TTS_ENDPOINT,ttsResourceId = p.getString("tts_resource_id", DEFAULT_TTS_RESOURCE)!!,// The voice follows the ball's look; [TTS_SPEAKER] is the@@ -317,8 +380,16 @@ data class VoiceConfig("device_id" to hc.deviceId,"device_name" to hc.deviceName,"brain" to bc.mode,- "llm_api_key" to bc.apiKey,- "llm_base_url" to bc.baseUrl,+ "show_hub" to if (showHub(context)) "on" else "off",+ // llm_api_key / llm_base_url are the 本机 tab's rows — the+ // user's own DeepSeek credentials. They stay visible no matter+ // which backend is active, because switching to CodeFlying and+ // back must not look like the local-tab fields were wiped. The+ // compiled CodeFlying key never flows through these prefs; it+ // comes from BuildConfig at [brainConfig] time, so showing the+ // saved values here cannot leak it.+ "llm_api_key" to p.getString("llm_api_key", "").orEmpty(),+ "llm_base_url" to p.getString("llm_base_url", "").orEmpty(),"llm_model" to bc.model,// Round-tripped as the wire words rather than a boolean: this map// feeds SettingsUi's pickers and the picker's value is what comes@@ -479,6 +550,7 @@ data class VoiceConfig("tts_endpoint", "tts_resource_id", "tts_sample_rate","hub_url", "device_name","brain",+ "show_hub","llm_api_key", "llm_base_url", "llm_model","llm_thinking", "llm_reasoning_effort","grounding",diff --git a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.ktindex 7b22420..b89cc67 100644--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt@@ -158,18 +158,9 @@ class SettingsUi(*/private var lctx: Context = context- /**- * Survives a [rebuild], so switching language doesn't re-hide the group.- *- * This is now 高级's flag: it was the 火山 panel's, and the panel moved- * inside 高级 when the card split. One flag would have unfolded both, which- * is why [voiceOpen] exists.- */+ /** Survives a [rebuild], so switching language doesn't re-hide the group. */private var advancedOpen = false- /** Same, for the 火山 panel. Kept apart from [advancedOpen] — see there. */- private var voiceOpen = false-/*** The 诊断 section is showing the factory-reset warning instead of its* three buttons. Survives a [rebuild] so a language switch mid-confirmation@@ -369,7 +360,6 @@ class SettingsUi(// the credentials it can spend. 大脑 stays first because it is the one// setting that changes what the rest of the card means.brainSection(form)- voiceKeySection(form)wakeSection(form)notebookSection(form)notifySection(form)@@ -392,14 +382,11 @@ class SettingsUi(* panels and putting a panel around them would nest one inside another. That* is what `bare = true` is for; see [collapsible].*- * It is closed by default, which is the point: 火山's endpoints, the- * keyboard report and the factory-reset button are all things the user goes- * looking for deliberately. Nothing it hides is needed to make the device- * work out of the box, and the one item that *would* have been an exception- * — the 火山 key, which a fresh install genuinely needs — is deliberately- * **not** in here. It sits in 常用 under 语音 as [voiceKeySection], because- * the setup wizard sends the user to it and a wizard that then asks them to- * unfold 高级 is a wizard with a fold in the middle of it.+ * It is closed by default, which is the point: nothing it hides is needed+ * to make the device work out of the box. The 火山 key and endpoints+ * (which used to live here) are now rows of the 本机 tab under 后端, next+ * to the LLM they power; this disclosure now carries show-cloud-option,+ * typing diagnostics and the factory-reset button.** The note under the heading is not decoration and is not optional: a* collapsed disclosure gives no account of itself, so a user who has lost@@ -412,13 +399,37 @@ class SettingsUi(lctx.getString(R.string.settings_advanced_note),bare = true,)- // The three go in the bare container directly, so their own section- // titles and panels land at the form's own width and rhythm.- voiceSection(body)+ // 火山 (the voice section) used to live here. It is now a sub-panel+ // of 后端 → 本机, so a user looking for its rows finds them next to+ // the backend they belong to — see [brainSection].+ showHubSection(body)typingSection(body)diagnosticsSection(body)}+ /**+ * 显示云端选项: lives in 高级 rather than beside the backend picker because+ * it is a knob a user turns once (if ever) to reveal a tab they want. It+ * writes eagerly and rebuilds the whole card, so flipping it on and+ * scrolling back up finds the 云端 tab already in the backend picker.+ */+ private fun showHubSection(form: LinearLayout) {+ val panel = group(+ form,+ lctx.getString(R.string.settings_show_hub),+ lctx.getString(R.string.settings_show_hub_note),+ )+ val row = segments(+ options = listOf("off" to lctx.getString(R.string.common_off), "on" to lctx.getString(R.string.common_on)),+ picked = if (VoiceConfig.showHub(context)) "on" else "off",+ radius = dp(13),+ ) { v ->+ VoiceConfig.save(context, mapOf("show_hub" to v))+ rebuild()+ }+ panel.addView(row, rowParams(dp(7)))+ }+@SuppressLint("SetTextI18n")private fun header(): View {val row = LinearLayout(context).apply {@@ -522,6 +533,26 @@ class SettingsUi(* (`ScreenBodyService.startBrain` builds one brain or the other), so the* picker folds away the half that is not in play.*/+ /**+ * The backend section. Three tabs — 本机 / CodeFlying / 云端 — only one is+ * ever in play, and the picker folds away the two that are not.+ *+ * Visibility rules:+ * * **CodeFlying** is only in the picker when the build enables it with a+ * non-empty domain (see [VoiceConfig.isCodeFlyingAvailable]). The tab+ * itself has no editable rows — endpoints and credential are compiled+ * in — just a note describing what the hosted backend offers.+ * * **云端** is only in the picker when the user has turned the "显示+ * 云端选项" toggle on (`show_hub`, saved eagerly so the picker rebuilds+ * at once). It is off by default: a device nobody has configured for a+ * hub is better off not seeing an option it has nothing to fill in.+ *+ * Voice (`asr_endpoint` / `tts_endpoint` / `api_key` and the resource IDs)+ * used to live inside 高级 → 火山. It now lives inside the **本机** tab,+ * because voice runs on this device whichever backend answers, but a+ * CodeFlying device never touches these fields and a 云端 device cares+ * about hub plumbing instead.+ */private fun brainSection(form: LinearLayout) {val panel = group(form,@@ -529,21 +560,27 @@ class SettingsUi(lctx.getString(R.string.settings_brain_panel_note),)- // Assigned below, once both blocks exist; the picker's callback runs- // only on a tap, so the null window closes before anyone can tap.+ // Tab picker. 本机 and CodeFlying are always visible — CodeFlying stays+ // in the row even when the build didn't configure it, so the user is+ // told what it is and how to turn it on. 云端 is still gated on the+ // user's own show_hub toggle: it is the only tab that is pure extra+ // configuration surface, so nobody who hasn't asked for it needs to+ // see it. If the user picks CodeFlying without a configured build,+ // [VoiceConfig.brainMode] silently falls back to local at runtime —+ // the saved value sticks, so the picker rebuilds correctly, and+ // installing a configured build later flips the behaviour on without+ // the user having to re-pick.+ val options = buildList {+ add(VoiceConfig.BRAIN_LOCAL to lctx.getString(R.string.settings_brain_local))+ add(VoiceConfig.BRAIN_CODEFLYING to lctx.getString(R.string.settings_brain_codeflying))+ if (VoiceConfig.showHub(context)) {+ add(VoiceConfig.BRAIN_HUB to lctx.getString(R.string.settings_brain_cloud))+ }+ }var applyMode: ((String, Boolean) -> Unit)? = null- val mode = segmented(- panel,- "brain",- listOf(- // Local leftmost because the leftmost option is the fallback- // when the saved value matches nothing, and local is the- // out-of-box default — see [VoiceConfig.brainConfig].- VoiceConfig.BRAIN_LOCAL to lctx.getString(R.string.settings_brain_local),- VoiceConfig.BRAIN_HUB to lctx.getString(R.string.settings_brain_cloud),- ),- ) { applyMode?.invoke(it, true) }+ val mode = segmented(panel, "brain", options) { applyMode?.invoke(it, true) }+ // ---- 云端 tab ----val hubBlock = block(panel)field(hubBlock,@@ -557,11 +594,21 @@ class SettingsUi(lctx.getString(R.string.settings_device_name),hint = lctx.getString(R.string.settings_device_name_hint),)- note(- hubBlock,- lctx.getString(R.string.settings_brain_cloud_note),- )+ note(hubBlock, lctx.getString(R.string.settings_brain_cloud_note))++ // ---- CodeFlying tab (description only) ----+ // Which note depends on whether this build was configured for+ // CodeFlying: configured says "what this is, you may be billed",+ // unconfigured says "it's not set up on this APK, go to the website".+ val cfBlock = block(panel)+ val cfNoteKey = if (VoiceConfig.isCodeFlyingAvailable()) {+ R.string.settings_brain_codeflying_note+ } else {+ R.string.settings_brain_codeflying_unconfigured+ }+ note(cfBlock, lctx.getString(cfNoteKey))+ // ---- 本机 tab: LLM + 火山 voice rows ----val localBlock = block(panel)field(localBlock, "llm_api_key", "DeepSeek Key", hint = "sk-…", secret = true)field(localBlock, "llm_model", lctx.getString(R.string.settings_llm_model), hint = VoiceConfig.DEFAULT_LLM_MODEL)@@ -591,18 +638,29 @@ class SettingsUi("low" to lctx.getString(R.string.common_low),),)- note(+ note(localBlock, lctx.getString(R.string.settings_brain_local_note))++ // 火山: previously in 高级 → 火山. Rows copy that section's labels,+ // which still describe exactly these keys.+ field(localBlock,- lctx.getString(R.string.settings_brain_local_note),+ "api_key",+ lctx.getString(R.string.settings_voice_api_key),+ hint = lctx.getString(R.string.settings_voice_api_key_hint),+ secret = true,)-+ field(localBlock, "asr_endpoint", lctx.getString(R.string.settings_voice_asr_endpoint))+ field(localBlock, "asr_resource_id", lctx.getString(R.string.settings_voice_asr_resource_id))+ field(localBlock, "tts_endpoint", lctx.getString(R.string.settings_voice_tts_endpoint))+ field(localBlock, "tts_resource_id", lctx.getString(R.string.settings_voice_tts_resource_id))+ field(localBlock, "tts_sample_rate", lctx.getString(R.string.settings_voice_tts_sample_rate), numeric = true)++ // One block visible at a time. Simultaneous flips so the card's total+ // height barely moves — see the old comment, still true.applyMode = { m, animate ->- val local = m == VoiceConfig.BRAIN_LOCAL- // Both at once, not one after the other: one block shrinking while- // the other grows keeps the card's total height almost still, and- // sequencing them makes the whole form jump twice.- Glass.setVisible(hubBlock, !local, animate)- Glass.setVisible(localBlock, local, animate)+ Glass.setVisible(hubBlock, m == VoiceConfig.BRAIN_HUB, animate)+ Glass.setVisible(cfBlock, m == VoiceConfig.BRAIN_CODEFLYING, animate)+ Glass.setVisible(localBlock, m == VoiceConfig.BRAIN_LOCAL, animate)}applyMode(mode, false)applyThinking = { th, animate ->@@ -646,40 +704,6 @@ class SettingsUi(panel.addView(row, rowParams(dp(12)))}- /**- * 语音 *without* an engine in the name: the one row here is the key.- *- * 火山's endpoints are three more rows about a service the user did not know- * they were using, so they live in [advancedSection] under their own heading- * — which is why this exists as a separate method from [voiceSection] and- * why the two carry different titles. What matters here is the key: a fresh- * install has none, `VoiceConfig.API_KEY` ships empty on purpose, and- * without it the device is mute. A key behind a 高级 disclosure is a key the- * setup flow hides mid-setup, so it stays out in 常用.- */- private fun voiceKeySection(form: LinearLayout) {- val panel = group(form, lctx.getString(R.string.settings_section_voice_key))- // Blank means *factory*, which is what an untouched box shows — see- // VoiceConfig.save / OVERRIDE_KEYS. Masked like any other credential.- field(- panel, "api_key",- lctx.getString(R.string.settings_voice_api_key),- hint = lctx.getString(R.string.settings_voice_api_key_hint),- secret = true,- )- // Feedback for the row above. Without it, "did my key actually take- // effect?" is only answerable by reading shared_prefs over adb.- readOnly(- panel,- lctx.getString(R.string.settings_voice_in_use),- if (VoiceConfig.usingOwnCredentials(context)) {- lctx.getString(R.string.settings_voice_in_use_own)- } else {- lctx.getString(R.string.settings_voice_in_use_factory)- },- )- }-/*** Same shape as [wakeSection], and for the same reason: the real screen is* its own overlay ([VaultUi]) because the list grows and this card is@@ -711,28 +735,6 @@ class SettingsUi(panel.addView(row, rowParams(dp(12)))}- /**- * 火山 endpoints. Collapsed, because they ship working and rarely move.- *- * The key is **not** in here — it is the one row in this group that a fresh- * device actually needs, so it lives in [voiceKeySection] out in 常用 and- * only the endpoints fold away. See there.- */- private fun voiceSection(form: LinearLayout) {- val panel = collapsible(- form,- lctx.getString(R.string.settings_section_voice),- lctx.getString(R.string.settings_voice_factory_note),- isOpen = { voiceOpen },- setOpen = { voiceOpen = it },- )- field(panel, "asr_endpoint", lctx.getString(R.string.settings_voice_asr_endpoint))- field(panel, "asr_resource_id", lctx.getString(R.string.settings_voice_asr_resource_id))- field(panel, "tts_endpoint", lctx.getString(R.string.settings_voice_tts_endpoint))- field(panel, "tts_resource_id", lctx.getString(R.string.settings_voice_tts_resource_id))- field(panel, "tts_sample_rate", lctx.getString(R.string.settings_voice_tts_sample_rate), numeric = true)- }-private fun diagnosticsSection(form: LinearLayout) {val panel = group(form, lctx.getString(R.string.settings_section_diagnostics))rowLabel(panel, lctx.getString(R.string.settings_grounding))diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xmlindex 392ce4f..4539452 100644--- a/app/src/main/res/values-en/strings.xml+++ b/app/src/main/res/values-en/strings.xml@@ -67,10 +67,15 @@<string name="settings_clear_notes_confirm_title">Clear the notebook?</string><string name="settings_clear_notes_confirm_body">Everything it noted down, your preferences, and any reminder not yet due are deleted, with no way back. The current chat history is untouched.</string><string name="settings_clear_notes_confirm">Clear it</string>- <string name="settings_section_brain">Brain</string>+ <string name="settings_section_brain">Backend</string><string name="settings_brain_panel_note">Takes effect when you close this panel — no need to restart the accessibility service.</string><string name="settings_brain_cloud">Cloud</string><string name="settings_brain_local">On-device</string>+ <string name="settings_brain_codeflying">CodeFlying</string>+ <string name="settings_show_hub">Show cloud option</string>+ <string name="settings_show_hub_note">Adds a Cloud backend tab for connecting to a hub you host yourself.</string>+ <string name="settings_brain_codeflying_note">Powered by your backend hosted on CodeFlying.app: ships models and voice services by default, plus a per-device database for CRUD-style business logic, and a long tail of third-party API integrations — AI image / video / music generation, geolocation, weather, PDF conversion, search, news, stocks, and more.\n\nNote: using CodeFlying backend services may incur charges.</string>+ <string name="settings_brain_codeflying_unconfigured">CodeFlying is not configured on this Andee. From a computer, visit CodeFlying.app and have it build an Andee install package wired to your own backend — install it over this app and you get the default models, voice services, a per-device database and a long list of third-party API integrations (AI image / video / music generation, weather, location, PDF, search, news, stocks, and more).\n\nNote: using CodeFlying backend services may incur charges.</string><string name="settings_hub_url">Hub URL</string><!-- The hub URL box is empty on a fresh install — the hint is what theuser sees in that empty box, so it is the pitch, not the format. -->@@ -113,7 +118,7 @@<string name="settings_voice_tts_sample_rate">TTS sample rate</string><string name="settings_section_diagnostics">Diagnostics</string><string name="settings_section_advanced">Advanced</string>- <string name="settings_advanced_note">Volcengine endpoints, typing, diagnostics and factory reset. Nothing here for day-to-day use.</string>+ <string name="settings_advanced_note">Show the cloud option, typing, diagnostics and factory reset. Nothing here for day-to-day use.</string><string name="settings_grounding">Grounding capture</string><string name="settings_grounding_note">Records coordinate taps and screenshots to files/grounding for offline analysis — it photographs whatever you are doing. Needs the accessibility service restarted to take effect.</string><string name="settings_device_id">Device ID</string>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 15a9965..c5aebb9 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -44,10 +44,15 @@<string name="settings_clear_notes_confirm_title">清空小本本?</string><string name="settings_clear_notes_confirm_body">它记下的事、你的偏好、还没到点的提醒,都会删掉,找不回来。这场聊天记录不受影响。</string><string name="settings_clear_notes_confirm">确认清空</string>- <string name="settings_section_brain">大脑</string>+ <string name="settings_section_brain">后端</string><string name="settings_brain_panel_note">关掉这个面板就生效,不用重开无障碍服务。</string><string name="settings_brain_cloud">云端</string><string name="settings_brain_local">本机</string>+ <string name="settings_brain_codeflying">CodeFlying</string>+ <string name="settings_show_hub">显示云端选项</string>+ <string name="settings_show_hub_note">把「云端」加到后端选项里,用来连你自己搭的 Hub。</string>+ <string name="settings_brain_codeflying_note">由您在 CodeFlying.net 平台托管的后端服务提供支持:默认提供模型和语音服务,并支持独立数据库能力实现数据持久化(增删改查等业务逻辑),以及海量第三方 API 集成——AI 图片/视频/音乐生成,地理位置、天气、PDF 转换、搜索、新闻、股票等等。\n\n注意:使用 CodeFlying 的后端服务可能会产生费用。</string>+ <string name="settings_brain_codeflying_unconfigured">这台 Andee 没有配置 CodeFlying。到电脑上访问 CodeFlying.net,用它一键生成带有您专属后端的 Andee 安装包并替换当前应用,就能用上默认模型、语音、持久化数据库和海量第三方 API(AI 图片/视频/音乐生成、天气、位置、PDF、搜索、新闻、股票等等)。\n\n注意:使用 CodeFlying 的后端服务可能会产生费用。</string><string name="settings_hub_url">Hub 地址</string><!-- The hub URL box is empty on a fresh install — the hint is what theuser sees in that empty box, so it is the pitch, not the format. -->@@ -90,7 +95,7 @@<string name="settings_voice_tts_sample_rate">合成采样率</string><string name="settings_section_diagnostics">诊断</string><string name="settings_section_advanced">高级</string>- <string name="settings_advanced_note">火山地址、打字、诊断和恢复出厂设置。日常用不到,都藏在这里。</string>+ <string name="settings_advanced_note">显示云端选项、打字、诊断和恢复出厂设置。日常用不到,都藏在这里。</string><string name="settings_grounding">接地采集</string><string name="settings_grounding_note">把坐标点击和截图记到 files/grounding 供离线分析 —— 它会拍下你当时在做的事。改完要重开无障碍服务才生效。</string><string name="settings_device_id">设备 ID</string>