Skip to content

armgit / andee

Public Imported from GitHub
0

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、支持任意模型,记忆和密码绝不离开设备。

fix(config): actually clear overridable endpoints when user blanks them

booboosuia1e0ae3c487b
diff --git a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
index 645dd3e..b8201fc 100644
--- a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
+++ b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
@@ -54,7 +54,7 @@ data class VoiceConfig(
* Keys whose blank value means "go back to the compiled default"
* rather than "the user didn't touch this row". See [save].
*/
- private val OVERRIDE_KEYS = setOf("api_key", "asr_endpoint", "tts_endpoint")
+ internal val OVERRIDE_KEYS = setOf("api_key", "asr_endpoint", "tts_endpoint")
const val DEFAULT_ASR_ENDPOINT = "wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async"
const val DEFAULT_ASR_RESOURCE = "volc.bigasr.sauc.duration"
diff --git a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
index 950dc8c..7b22420 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
@@ -1416,7 +1416,14 @@ class SettingsUi(
val updates = mutableMapOf<String, String>()
for ((k, et) in fields) {
val v = et.text?.toString()?.trim().orEmpty()
- if (v.isNotEmpty()) updates[k] = v
+ // Overridable keys go in even when blank: blank is how the user
+ // says "go back to the compiled default", and VoiceConfig.save()
+ // deletes the pref when it sees one. Non-overridable keys only go
+ // in when non-empty, so an untouched field doesn't wipe a saved
+ // value.
+ if (v.isNotEmpty() || k in VoiceConfig.OVERRIDE_KEYS) {
+ updates[k] = v
+ }
}
// Pickers go in unconditionally: their value is never blank, which is
// what lets a setting actually be turned back off — VoiceConfig.save()