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(theme): a fresh install comes up light
booboosui2e24fc52b5c0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1f962ba..732b9c0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -54,6 +54,15 @@ hash into `versionName` at build time would close this hole; it is not implementfalse` on a page whose file the 100-page cap has taken is reported honestly rather than passedover: the title and date are still true, the contents are not there to read.+### Changed++- **The default appearance is light, not dark.** A fresh install now comes up with the light palette.+ A device that has touched the setting keeps whatever it chose — the rule reads only an explicit+ `night`, so nothing here can overrule a user who picked dark, and the dark palette stays one tap+ away in **Settings → Appearance**. Written this way round on purpose: the test is against the+ *non-default* value, which is what makes changing the default later a one-line edit rather than a+ migration.+## [0.4.0] - 2026-10-14Two new capabilities, both of them choices rather than defaults: **a second voice provider** (Google,diff --git a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.ktindex c356b56..4871137 100644--- a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt+++ b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt@@ -313,28 +313,47 @@ data class VoiceConfig(/*** Which palette the UI draws with. `true` = night, and false = day.*- * **Night is the default.** A fresh install comes up dark, and so does a- * device updating from a build that predates this setting — which is why the- * test is "not day" rather than "is night". Inverted here on request; the- * light palette is still one tap away in 设置 → 外观 and is remembered from- * then on.+ * **Day (light) is the default.** A fresh install comes up light, and so does+ * a device that has never touched the setting — which is why the test is+ * "is night" rather than "is not day". The dark palette is one tap away in+ * 设置 → 外观 and is remembered from then on.+ *+ * The inversion is on purpose and it is the whole content of this function.+ * The test is written against the *non-default* value rather than the default+ * one so that an explicit choice always wins and nothing else has to: only+ * the string the picker actually wrote can turn night on, so no rewrite of+ * the default can silently overrule a user who picked dark.** Read straight off disk rather than out of [current], and that matters here:* [net.kuafuai.andee.ui.Theme] reads this once at process start and again on* every change, so the answer has to be the file's, not a snapshot of the* other rows that happens to be in memory.*- * Only the two strings are meaningful; the "day" one is written by the picker- * as [net.kuafuai.andee.ui.Theme.DAY].+ * Only the two strings are meaningful; the "night" one is written by the+ * picker as [net.kuafuai.andee.ui.Theme.NIGHT].*/fun nightTheme(context: Context): Boolean {val saved = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)- .getString("theme", "").orEmpty().trim().lowercase()- // Only an explicit "day" turns night off. Absent or unrecognised reads as- // night, so the default cannot be lost by a build that never wrote it.- return saved != "day"+ .getString("theme", "").orEmpty()+ return nightFromSaved(saved)}+ /**+ * The rule [nightTheme] implements, separated so it can be tested without a+ * device — there is no Robolectric here, and the default this decides is not+ * observable until something is drawn.+ *+ * `internal` rather than private for that reason alone. A theme default is+ * exactly the kind of value that gets inverted by a later "make it dark again"+ * request, and the two things that must move together (this and `Theme.night`'s+ * initial value) are in different files.+ */+ internal fun nightFromSaved(saved: String): Boolean =+ // Only an explicit "night" turns night on; absent or unrecognised reads as+ // day, so the default cannot be lost by a build that never wrote it, and an+ // explicit choice can never be overruled by a change to the default.+ saved.trim().lowercase() == "night"+/** Whether to show the 云端 (hub) tab in the backend picker. Default off. */fun showHub(context: Context): Boolean =context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)diff --git a/app/src/main/java/net/kuafuai/andee/ui/Theme.kt b/app/src/main/java/net/kuafuai/andee/ui/Theme.ktindex c472632..2e700a0 100644--- a/app/src/main/java/net/kuafuai/andee/ui/Theme.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/Theme.kt@@ -45,14 +45,14 @@ object Theme {/*** The state of the switch. Set by [load] and [set]; read by [Glass].*- * **Initialised to night, because night is the default**- * ([VoiceConfig.nightTheme]). [load] is what makes that true from the saved- * preference, but this value is the one that must not be *wrong* in the window- * between process start and the service's first line: a surface drawn there would- * otherwise be light on a device whose answer is dark, and then flip.+ * **Initialised to day, because day is the default** ([VoiceConfig.nightTheme]).+ * [load] is what makes that true from the saved preference, but this value is the+ * one that must not be *wrong* in the window between process start and the+ * service's first line: a surface drawn there would otherwise be dark on a device+ * whose answer is light, and then flip.*/@Volatile- var night: Boolean = true+ var night: Boolean = falseprivate set/**diff --git a/app/src/test/java/net/kuafuai/andee/config/ThemeDefaultTest.kt b/app/src/test/java/net/kuafuai/andee/config/ThemeDefaultTest.ktnew file mode 100644index 0000000..b5fa636--- /dev/null+++ b/app/src/test/java/net/kuafuai/andee/config/ThemeDefaultTest.kt@@ -0,0 +1,67 @@+package net.kuafuai.andee.config++import org.junit.Assert.assertFalse+import org.junit.Assert.assertTrue+import org.junit.Test++/**+ * The theme default, which is a one-line rule with three ways to get it wrong.+ *+ * The default is **light**, and the test is written against the non-default value+ * on purpose: only the string the picker actually wrote may turn night on. That+ * shape is what makes "change the default" a one-line edit that cannot overrule a+ * user who chose otherwise, and it is the property worth pinning down — a rewrite+ * to `saved != "night"` would look equivalent and would flip every device that has+ * never opened the setting.+ *+ * `nightFromSaved` exists as a separate function precisely so this can run without+ * a device. There is no Robolectric in this project, and the alternative — testing+ * `nightTheme(Context)` — needs one.+ */+class ThemeDefaultTest {++ @Test+ fun `a device that has never chosen comes up light`() {+ // The absent key: a fresh install, and every device updating from a build+ // that predates the setting.+ assertFalse(VoiceConfig.nightFromSaved(""))+ }++ @Test+ fun `an explicit night is kept`() {+ assertTrue(VoiceConfig.nightFromSaved("night"))+ }++ @Test+ fun `an explicit day is kept`() {+ // Not the default any more, but still a real choice a user can have made+ // on a device that has since been updated.+ assertFalse(VoiceConfig.nightFromSaved("day"))+ }++ @Test+ fun `case and padding do not decide the theme`() {+ assertTrue(VoiceConfig.nightFromSaved(" NIGHT "))+ assertTrue(VoiceConfig.nightFromSaved("Night"))+ assertFalse(VoiceConfig.nightFromSaved(" DAY "))+ }++ @Test+ fun `an unrecognised value falls back to light rather than to night`() {+ // A key written by hand, or by a build that used a different vocabulary.+ // Reading it as night would be a value nobody chose, on the default a+ // user never saw.+ assertFalse(VoiceConfig.nightFromSaved("dark"))+ assertFalse(VoiceConfig.nightFromSaved("n"))+ assertFalse(VoiceConfig.nightFromSaved("1"))+ }++ @Test+ fun `the two strings the picker writes are the two that mean something`() {+ // `Theme.DAY` / `Theme.NIGHT` are what `Theme.set` puts on disk; this is+ // the other end of that wire, so the pair is asserted together rather+ // than one at a time.+ assertFalse(VoiceConfig.nightFromSaved("day"))+ assertTrue(VoiceConfig.nightFromSaved("night"))+ }+}