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

feat: a way out of the key rows on both settings cards — switch to CodeFlying

booboosui87c7932faf52
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 fba7e81..5dd1799 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
@@ -617,7 +617,11 @@ class SettingsUi(
}
}
var applyMode: ((String, Boolean) -> Unit)? = null
- val mode = segmented(panel, "brain", options) { applyMode?.invoke(it, true) }
+ // Filled in by the picker itself: the "no key?" line below has to move the
+ // tab the same way a tap on the cell would, or the card would keep showing
+ // 本机 while saving CodeFlying.
+ var pickBrain: (String) -> Unit = {}
+ val mode = segmented(panel, "brain", options, setterRef = { pickBrain = it }) { applyMode?.invoke(it, true) }
// ---- 云端 tab ----
val hubBlock = block(panel)
@@ -694,6 +698,15 @@ class SettingsUi(
),
)
note(localBlock, lctx.getString(R.string.settings_brain_local_note))
+ // The rows above ask for two keys a person may simply not have, and for
+ // them the answer is a different tab — not a third thing to fill in. So
+ // it is one tap here, and the tab moves under their finger rather than
+ // sending them back up to the picker to find which cell that was.
+ //
+ // It only moves the pick; 保存 still commits it, like every other row.
+ linkNote(localBlock, lctx.getString(R.string.settings_no_key_use_codeflying)) {
+ pickBrain(VoiceConfig.BRAIN_CODEFLYING)
+ }
// ---- Which service hears and speaks ----
//
@@ -1437,6 +1450,17 @@ class SettingsUi(
parent.addView(noteView(text), rowParams(dp(10)))
}
+ /** [note], tinted and tappable: an explanation that is also the way out of it. */
+ private fun linkNote(parent: LinearLayout, text: String, onClick: () -> Unit) {
+ parent.addView(noteView(text).apply {
+ setTextColor(Color.parseColor(Glass.ACCENT))
+ isClickable = true
+ isFocusable = true
+ Glass.pressable(this)
+ setOnClickListener { onClick() }
+ }, rowParams(dp(10)))
+ }
+
private fun noteView(text: String): TextView = TextView(context).apply {
this.text = text
// Same reason as [rowLabel]. Notes are the longest strings in the card
@@ -1544,12 +1568,14 @@ class SettingsUi(
parent: LinearLayout,
key: String,
options: List<Pair<String, String>>,
+ /** Handed the picker's own select, so a link can pick a value for the user. */
+ setterRef: (((String) -> Unit) -> Unit)? = null,
onPick: (String) -> Unit = {},
): String {
val current = saved[key].orEmpty().trim().lowercase()
val start = options.firstOrNull { it.first == current }?.first ?: options.first().first
var picked = start
- val track = segments(options, start, dp(13)) { picked = it; onPick(it) }
+ val track = segments(options, start, dp(13), setterRef = setterRef) { picked = it; onPick(it) }
picks[key] = { picked }
parent.addView(track, rowParams(dp(7)))
return start
@@ -1576,6 +1602,18 @@ class SettingsUi(
picked: String,
radius: Int,
compact: Boolean = false,
+ /**
+ * Handed [select], for a value to be picked from code rather than by
+ * tapping a cell — a link under a row that offers another tab has to
+ * move the thumb too, or the card shows one thing and saves another.
+ *
+ * It is handed the picker's own *select*, so its argument is that
+ * function, not a value: the caller stores it and calls it later.
+ *
+ * Named before [onPick] so that every caller's trailing lambda still
+ * lands on [onPick], where it always has.
+ */
+ setterRef: (((String) -> Unit) -> Unit)? = null,
onPick: (String) -> Unit,
): View {
val inset = dp(3)
@@ -1656,6 +1694,18 @@ class SettingsUi(
}
}
+ // The one path a pick takes, whether it came from a tap or from code.
+ // The thumb, the two label colours and [onPick] are a single change, and
+ // a caller that moved only some of them would leave the card saving a
+ // value it is not showing.
+ fun select(value: String) {
+ val i = options.indexOfFirst { it.first == value }.coerceAtLeast(0)
+ if (index == i) return
+ index = i
+ place(i, animate = true)
+ onPick(value)
+ }
+
for ((i, option) in options.withIndex()) {
val (value, label) = option
val cell = TextView(context).apply {
@@ -1666,12 +1716,7 @@ class SettingsUi(
if (compact) setPadding(dp(12), dp(6), dp(12), dp(6))
else setPadding(dp(6), dp(10), dp(6), dp(10))
isClickable = true
- setOnClickListener {
- if (index == i) return@setOnClickListener
- index = i
- place(i, animate = true)
- onPick(value)
- }
+ setOnClickListener { select(value) }
}
cells += cell
if (compact) cellRow.addView(cell)
@@ -1682,6 +1727,7 @@ class SettingsUi(
if (!sliding) place(index, animate = false)
}
place(index, animate = false)
+ setterRef?.invoke { select(it) }
return track
}
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index cb4236c..4c05163 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -94,6 +94,7 @@
<string name="common_medium">Medium</string>
<string name="common_low">Low</string>
<string name="settings_brain_local_note">The device runs the agent loop itself, with no hub. Without a key it will not take over.</string>
+ <string name="settings_no_key_use_codeflying">No key? Tap here to switch to CodeFlying</string>
<string name="settings_section_wake">Wake word</string>
<string name="settings_wake_enrolled">Enrolled — say your wake word and it wakes up</string>
<string name="settings_wake_not_enrolled">Not enrolled — pick a phrase and say it 3 times to wake me by voice, e.g. “Hey Andee”</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5daaa1d..b923051 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -71,6 +71,7 @@
<string name="common_medium">中</string>
<string name="common_low">低</string>
<string name="settings_brain_local_note">设备自己跑 agent loop,不连 Hub。没有 Key 就不会接管。</string>
+ <string name="settings_no_key_use_codeflying">没有密钥?点这里切换到 CodeFlying 配置</string>
<string name="settings_section_wake">语音唤醒</string>
<string name="settings_wake_enrolled">已录入 —— 说出你录的唤醒词就行</string>
<string name="settings_wake_not_enrolled">未录入 —— 自己选个词录 3 遍就能语音唤醒,例如「嘿 Andee」</string>
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
index aba24cc..ad49a5a 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
@@ -105,6 +105,16 @@ fun SettingsScreen(
) { v["llm_reasoning_effort"] = it }
}
Note(st("settings_brain_local_note"))
+ // The rows above ask for two keys a person may simply not have.
+ // Switching the tab for them is the whole answer, so it is one tap
+ // here rather than a trip back to the picker at the top — and it is
+ // written into the form's own map, so 保存 is what commits it, like
+ // every other row on this card.
+ Text(
+ st("settings_no_key_use_codeflying"),
+ color = Palette.accent, fontSize = 12.sp,
+ modifier = Modifier.padding(top = 8.dp).clickable { v["brain"] = "codeflying" },
+ )
}
}
diff --git a/desktop/src/main/resources/strings_en.properties b/desktop/src/main/resources/strings_en.properties
index 0f21e0e..1959110 100644
--- a/desktop/src/main/resources/strings_en.properties
+++ b/desktop/src/main/resources/strings_en.properties
@@ -82,6 +82,7 @@ s_common_high=High
s_common_medium=Medium
s_common_low=Low
s_settings_brain_local_note=The device runs the agent loop itself, with no hub. Without a key it will not take over.
+s_settings_no_key_use_codeflying=No key? Click here to switch to CodeFlying
s_settings_section_wake=Wake word
s_settings_wake_enrolled=Enrolled — say your wake word and it wakes up
s_settings_wake_not_enrolled=Not enrolled — pick a phrase and say it 3 times to wake me by voice, e.g. “Hey Andee”
diff --git a/desktop/src/main/resources/strings_zh.properties b/desktop/src/main/resources/strings_zh.properties
index 4daf2d5..0908495 100644
--- a/desktop/src/main/resources/strings_zh.properties
+++ b/desktop/src/main/resources/strings_zh.properties
@@ -82,6 +82,7 @@ s_common_high=高
s_common_medium=中
s_common_low=低
s_settings_brain_local_note=设备自己跑 agent loop,不连 Hub。没有 Key 就不会接管。
+s_settings_no_key_use_codeflying=没有密钥?点这里切换到 CodeFlying 配置
s_settings_section_wake=语音唤醒
s_settings_wake_enrolled=已录入 —— 说出你录的唤醒词就行
s_settings_wake_not_enrolled=未录入 —— 自己选个词录 3 遍就能语音唤醒,例如「嘿 Andee」