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: one face on both bodies — the same doors, the same ball, the same input, and friends that answer

booboosuif08a771b4877
diff --git a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
index 9a199e4..be6aa8d 100644
--- a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
+++ b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
@@ -124,11 +124,6 @@ class BodyCoreService : Service() {
private lateinit var dogSense: net.kuafuai.andee.dog.DogSense
private lateinit var peers: AndroidPeers
- /**
- * The one link to the user's other devices, for a screen that wants to show or pair them. One instance per
- * process: a second would start a second server on the same port and lose to the first.
- */
- fun peerLink(): AndroidPeers? = if (::peers.isInitialized) peers else null
private lateinit var dogMotion: net.kuafuai.andee.dog.DogMotion
/**
@@ -291,9 +286,18 @@ class BodyCoreService : Service() {
}
override fun onTextInputToggle() {
+ // Opening the field is a new request, like a tap: whatever is running or being read out stops
+ // first. Closing it (the field already up) stops nothing.
+ if (!net.kuafuai.andee.ui.TextInputActivity.isShowing && (dispatcher.isTaskActive() || audio.isStreamPlaying())) {
+ stopEverything()
+ }
toggleTyping()
}
+ override fun onTypeThen(what: String) {
+ toggleTyping(then = what)
+ }
+
override fun onLongPress() {
// Long-press the ball — folded or not — asks for the full card
// back: the scrollback and the control bar only exist at full
@@ -310,6 +314,17 @@ class BodyCoreService : Service() {
openScenes()
}
+ override fun onMuteToggle() {
+ val on = !net.kuafuai.andee.config.VoiceConfig.muted(this@BodyCoreService)
+ net.kuafuai.andee.config.VoiceConfig.setMuted(this@BodyCoreService, on)
+ if (on) tts.stopSpeaking()
+ window.setMuted(on)
+ }
+
+ override fun onNotebookClick() {
+ net.kuafuai.andee.ui.NotebookUi(this@BodyCoreService) {}.show()
+ }
+
override fun onFriendsClick() {
if (::peers.isInitialized) net.kuafuai.andee.ui.PeersUi(this@BodyCoreService, peers).show()
}
@@ -561,7 +576,8 @@ class BodyCoreService : Service() {
// And this is how the card knows where to stop: the field's own top
// edge, reported whenever the keyboard resizes it.
net.kuafuai.andee.ui.TextInputActivity.onTop = {
- android.util.Log.i("Body", "field top: $it px")
+ // Every frame while the keyboard slides: logged only when it settles at zero (the card is whole again).
+ if (it == 0) android.util.Log.i("Body", "field released the card")
window.setTypingTop(it)
}
asr = AsrController(
@@ -648,6 +664,7 @@ class BodyCoreService : Service() {
peers = AndroidPeers(this)
peers.onCount = { window.setFriendCount(it) }
window.setFriendCount(peers.store.all().size)
+ window.setMuted(net.kuafuai.andee.config.VoiceConfig.muted(this))
peers.startIfEnabled()
// Scanning the Mac's pairing QR from the Devices card: the unfolded card is an overlay above the camera,
// so it folds for the scan and comes back if it was open. See [net.kuafuai.andee.ui.StandAside].
@@ -1110,11 +1127,14 @@ class BodyCoreService : Service() {
* hidden card is whatever app the user was on, so typing looked like being
* thrown out of the assistant and then dropped back in.
*/
- private fun toggleTyping() {
- if (net.kuafuai.andee.ui.TextInputActivity.isShowing) {
+ private fun toggleTyping(then: String? = null) {
+ if (net.kuafuai.andee.ui.TextInputActivity.isShowing && then == null) {
net.kuafuai.andee.ui.TextInputActivity.dismiss()
return
}
+ // Typing is a conversation, and the conversation is the full card: unfold first, the way the Mac's
+ // double-click brings the chat window up with the cursor in the box.
+ if (window.isCompact()) dispatcher.expand()
// No keyboard to borrow and nothing to switch: the device's own IME is
// the user's, and this field types on it like any other app's would.
// The only way this fails is a tablet whose single IME is the headless
@@ -1126,8 +1146,8 @@ class BodyCoreService : Service() {
)
return
}
- typingFromFullscreen = !window.isCompact()
- net.kuafuai.andee.ui.TextInputActivity.start(this)
+ typingFromFullscreen = true
+ net.kuafuai.andee.ui.TextInputActivity.start(this, then)
}
/**
@@ -1894,7 +1914,6 @@ class BodyCoreService : Service() {
var rebuiltByReset = false
val s = SettingsUi(
context = this,
- peers = peers,
onDismiss = {
settings = null
voiceFailureReported = false
@@ -3077,7 +3096,10 @@ class BodyCoreService : Service() {
// same way it displaces the meeting recorder's. The
// scrollback row above is already the answer; the user
// reads it after they hang up.
- if (!meeting.isActive() && !net.kuafuai.andee.device.CallState.isActive) {
+ // And not when the user has muted answers (the card's 朗读 key): the row above is the answer.
+ if (!meeting.isActive() && !net.kuafuai.andee.device.CallState.isActive &&
+ !net.kuafuai.andee.config.VoiceConfig.muted(this)
+ ) {
tts.speak(plain, script.cues)
}
}
diff --git a/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt b/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt
index 6d43893..928fb9d 100644
--- a/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt
+++ b/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt
@@ -79,6 +79,8 @@ class AndroidBrainHost(
override fun gearIndex(): String = dispatcher.gearShelf.indexForPrompt()
+ override fun friendsIndex(): String = peers.tasks.indexForPrompt()
+
override fun topicsIndex(): String = ChatHistory.topicsForPrompt()
override fun foldTopic(title: String, summary: String, rows: List<ScrollRow>, text: String): FoldedTopic? {
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 2b37c11..887fe2b 100644
--- a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
+++ b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
@@ -766,6 +766,12 @@ object VoiceConfig {
* the card redraws in the new language and that redraw *is* the
* confirmation. Nothing else on this device is written eagerly.
*/
+ /** The user turned reading answers aloud off (the card's speaker key). Off by default, as on the Mac. */
+ fun muted(context: Context): Boolean =
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString("mute", "") == "1"
+
+ fun setMuted(context: Context, on: Boolean) = save(context, mapOf("mute" to if (on) "1" else "0"))
+
fun uiLanguage(context: Context): String {
val saved = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
.getString("lang", "").orEmpty().trim().lowercase()
@@ -898,6 +904,8 @@ object VoiceConfig {
// editable too, and is gone: the voice follows the ball's look, not a
// row — see [lookSpeaker].)
private val ALLOWED_KEYS = setOf(
+ // Answers read aloud or not — the card's 朗读 / 静音 key, the Mac header's twin.
+ "mute",
// Which palette the UI draws with — see [net.kuafuai.andee.ui.Theme].
// In this list because [save] drops anything that is not: a key missing
// here is a write that silently does nothing, which on a theme means the
diff --git a/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt b/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
index c0bb69e..0f8c0f5 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
@@ -162,6 +162,12 @@ class FloatingWindowUi(
/** The 产物 key — the pages the assistant has made. See [ArtifactsUi]. */
fun onArtifactsClick()
+ /** The speaker key beside the input pill: answers read aloud or not. */
+ fun onMuteToggle() {}
+
+ /** The 小本本 key — what it remembers. See [NotebookUi]. */
+ fun onNotebookClick() {}
+
/** The 朋友 key — the other Andees this one knows. See [PeersUi]. */
fun onFriendsClick() {}
@@ -204,6 +210,9 @@ class FloatingWindowUi(
*/
fun onTextInputToggle()
+ /** The resting pill's camera / album icon: open the field and go straight on to [what]. */
+ fun onTypeThen(what: String) {}
+
/**
* A page row in the scrollback, tapped to be shown again.
*
@@ -292,7 +301,26 @@ class FloatingWindowUi(
@Volatile private var sceneTitle: String? = null
/** The ball's gesture vocabulary, pinned along the bottom of the full card. */
+ /** The bottom block: the input pill above the gesture line. Hidden folded and while the real field is up. */
private var tipsView: View? = null
+ private var tipsText: TextView? = null
+ private var muteIcon: ImageView? = null
+ private var inputHint: TextView? = null
+ private var muteKey: View? = null
+ private var inputPill: View? = null
+ private var muteLabel: TextView? = null
+ private var mutedNow = false
+
+ /** Reflect the 朗读 / 静音 setting on the speaker key. Any thread. */
+ fun setMuted(on: Boolean) {
+ ui.post { mutedNow = on; paintMute() }
+ }
+
+ private fun paintMute() {
+ muteIcon?.setImageResource(if (mutedNow) R.drawable.ic_volume_off else R.drawable.ic_volume)
+ muteIcon?.setColorFilter(Color.parseColor(Glass.PHOTO_INK))
+ muteLabel?.text = AppLocale.str(context, if (mutedNow) R.string.window_muted else R.string.window_voice_on)
+ }
/**
* The top bar's icon views, kept only so a theme change can re-tint them.
@@ -841,7 +869,8 @@ class FloatingWindowUi(
typingGeometry = intArrayOf(p.x, p.y, p.width, p.height)
}
p.height = maxOf(dp(MIN_TYPING_CARD_DP), typingTop)
- android.util.Log.i("Body", "card steps aside: field top=$typingTop → height=${p.height}")
+ // The real field is up now, right under this edge: the pill would be a second, dead copy of it.
+ inputPill?.visibility = View.INVISIBLE
runCatching { wm.updateViewLayout(v, p) }
} else if (compact) {
// A fold in between owns the geometry now; just forget the snapshot.
@@ -855,6 +884,7 @@ class FloatingWindowUi(
/** Put back the geometry [setTypingBand] borrowed. */
private fun restoreTypingGeometry() {
+ inputPill?.visibility = View.VISIBLE
val g = typingGeometry ?: return
typingGeometry = null
val v = root ?: return
@@ -987,7 +1017,9 @@ class FloatingWindowUi(
*/
fun onLocaleChanged() {
ui.post {
- (tipsView as? TextView)?.text = AppLocale.str(context, R.string.window_tips)
+ tipsText?.text = AppLocale.str(context, R.string.window_tips)
+ inputHint?.text = AppLocale.str(context, R.string.window_input_hint)
+ paintMute()
historyView?.onLocaleChanged()
renderSceneChip()
}
@@ -1052,7 +1084,9 @@ class FloatingWindowUi(
topBarView?.background = Glass.well(context, topBarRadius)
for (v in barIcons) v.setColorFilter(ink)
// The tips sit on the photograph itself.
- (tipsView as? TextView)?.setTextColor(ink)
+ tipsText?.setTextColor(ink)
+ inputPill?.background = Glass.well(context, dp(24))
+ paintMute()
// The scene chip is a well too, and its two labels are the card's greys.
sceneChip?.background = Glass.well(context, dp(22))
val soft = Color.parseColor(Glass.SECONDARY)
@@ -1847,6 +1881,7 @@ class FloatingWindowUi(
backdrop?.visibility = View.GONE
topBarView?.visibility = View.GONE
sceneChip?.visibility = View.GONE
+ muteKey?.visibility = View.GONE
// Not just invisible — GONE, so the ball area has the whole window to
// itself. A scrollback left in the layout would cover most of a 168dp
// square and there would be nothing left to see the ball in.
@@ -1911,6 +1946,27 @@ class FloatingWindowUi(
val ty = ballDrop(bandH) + dp(BALL_NUDGE_DP)
ball?.translationY = ty.toFloat()
placeSceneChip(ballH, ty)
+ placeMuteKey(ballH, ty)
+ }
+
+ /** The speaker key just off the sphere's lower right, on the same radius [placeSceneChip] uses. */
+ private fun placeMuteKey(ballH: Int, ty: Int) {
+ val key = muteKey ?: return
+ val w = root?.width ?: return
+ val lp = key.layoutParams as? FrameLayout.LayoutParams ?: return
+ val r = SPHERE_RADIUS_FRACTION * ballH * BALL_SCALE
+ if (key.width == 0) key.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
+ val kw = if (key.width > 0) key.width else key.measuredWidth
+ val kh = if (key.height > 0) key.height else key.measuredHeight
+ // Just outside the sphere at its lower right (45°): it reads as the ball's own, without sitting on it.
+ val d = r + kw / 2f
+ val cx = w / 2f + d * 0.707f + dp(16)
+ val cy = ballH / 2f + ty + d * 0.707f
+ val left = (cx - kw / 2f).toInt()
+ val top = (cy - kh / 2f).toInt()
+ if (lp.leftMargin == left && lp.topMargin == top) return
+ lp.leftMargin = minOf(left, w - kw - dp(8)); lp.topMargin = top
+ key.layoutParams = lp
}
/**
@@ -2121,6 +2177,7 @@ class FloatingWindowUi(
// immediately after this, before the next frame.
topBarView?.visibility = View.VISIBLE
sceneChip?.visibility = if (sceneTitle != null) View.VISIBLE else View.GONE
+ muteKey?.visibility = View.VISIBLE
historyView?.visibility = View.VISIBLE
tipsView?.visibility = View.VISIBLE
backdrop?.visibility = View.VISIBLE
@@ -2411,7 +2468,7 @@ class FloatingWindowUi(
//
// Only in the full card. Folded, the window is a 168 dp square and the
// tips have nowhere to be; the gestures they describe work there anyway.
- val tips = TextView(context).apply {
+ val tipsLine = TextView(context).apply {
text = AppLocale.str(context, R.string.window_tips)
textSize = Glass.Type.CAPTION
// PHOTO_INK, not MUTED: this line sits on the photograph itself, and a
@@ -2423,7 +2480,39 @@ class FloatingWindowUi(
// scrollback's last row used to reserve for itself — this bar
// inherits that edge of the card.
setPadding(dp(14), dp(6), dp(14), dp(30))
+ }
+ tipsText = tipsLine
+ // The input pill, always there on the full card like the Mac's composer. It is not a field: an overlay
+ // cannot raise the keyboard on this ROM, so a tap opens the real one ([TextInputActivity]) in its place.
+ val inputRow = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ setPadding(dp(16), dp(4), dp(16), 0)
+ }
+ val hint = TextView(context).apply {
+ text = AppLocale.str(context, R.string.window_input_hint)
+ textSize = Glass.Type.BODY
+ // SECONDARY, not MUTED: the well is translucent over the photograph, and MUTED vanished into it.
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ gravity = Gravity.CENTER_VERTICAL
+ minHeight = dp(40)
+ isClickable = true
+ setOnClickListener { listeners.onTextInputToggle() }
+ }
+ // The same pill the open field draws ([InputPill]); here every part opens the field.
+ val pill = InputPill.build(
+ context, hint,
+ onCamera = { listeners.onTypeThen("camera") },
+ onAlbum = { listeners.onTypeThen("album") },
+ onSend = { listeners.onTextInputToggle() },
+ ).apply { setOnClickListener { listeners.onTextInputToggle() } }
+ inputHint = hint; inputPill = pill
+ inputRow.addView(pill, LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f))
+ val tips = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
visibility = View.GONE
+ addView(inputRow, LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT))
+ addView(tipsLine, LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT))
}
tipsView = tips
root.addView(
@@ -2435,6 +2524,25 @@ class FloatingWindowUi(
),
)
+ // ---- 朗读 / 静音, at the ball's lower right ----
+ // Beside the ball because it is about the ball's voice. Placed by [placeMuteKey], like the scene chip.
+ val mute = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ gravity = Gravity.CENTER
+ // No fill: a bare glyph beside the ball, like the ball's own horns — a pill read as a stray button.
+ setPadding(dp(6), dp(6), dp(6), dp(6))
+ isClickable = true
+ Glass.pressable(this)
+ setOnClickListener { listeners.onMuteToggle() }
+ visibility = View.GONE
+ }
+ val icon = ImageView(context)
+ mute.addView(icon, LinearLayout.LayoutParams(dp(22), dp(22)))
+ muteIcon = icon; muteKey = mute
+ mute.contentDescription = "朗读"
+ paintMute()
+ root.addView(mute, FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP or Gravity.START))
+
// ---- Top-right controls ----
//
// Added last so it is on top of both.
@@ -2561,6 +2669,8 @@ class FloatingWindowUi(
keys.addView(
barButton(R.drawable.ic_artifacts, Glass.PHOTO_INK, "产物") { listeners.onArtifactsClick() }
)
+ // 产物 · 小本本 · 情景 · 朋友 · 自检 · 设置 — the Mac's sidebar has the same doors in the same order.
+ keys.addView(barButton(R.drawable.ic_notebook, Glass.PHOTO_INK, "小本本") { listeners.onNotebookClick() })
keys.addView(barButton(R.drawable.ic_scene, Glass.PHOTO_INK, "情景") { listeners.onScenesClick() })
keys.addView(friendsKey())
// ✓ and not ■: the stop button used to sit here, and stop is the one
@@ -2928,7 +3038,8 @@ class FloatingWindowUi(
* shrink without leaving a band of dead space where it used to be. As
* set they draw ~510px, about twice the folded corner ball.
*/
- private const val BALL_SCALE = 1.05f
+ // 0.8 since 2026-10-23: the user asked for a smaller ball on both shapes of the card.
+ private const val BALL_SCALE = 0.8f
/**
* How much more sideways than vertical a drag on the ball must be
@@ -2963,7 +3074,7 @@ class FloatingWindowUi(
* Below about 0.40 the ball starts shrinking faster than the room it
* gains the list is worth.
*/
- private const val BALL_AREA_FRACTION = 0.40f
+ private const val BALL_AREA_FRACTION = 0.34f
/**
* Clearance between the sphere's top edge and the bottom of the control
@@ -3011,7 +3122,7 @@ class FloatingWindowUi(
* only knob for how big the corner ball reads — the rendered ball is
* roughly two thirds of it, and the circular hit test tracks it too.
*/
- private const val COMPACT_DP = 168
+ private const val COMPACT_DP = 136
private const val COMPACT_MARGIN_DP = 16
/** How long [parkForGesture] waits for the main-thread move to run. */
diff --git a/app/src/main/java/net/kuafuai/andee/ui/InputPill.kt b/app/src/main/java/net/kuafuai/andee/ui/InputPill.kt
new file mode 100644
index 0000000..56f75f3
--- /dev/null
+++ b/app/src/main/java/net/kuafuai/andee/ui/InputPill.kt
@@ -0,0 +1,64 @@
+package net.kuafuai.andee.ui
+
+import android.content.Context
+import android.graphics.Color
+import android.graphics.drawable.GradientDrawable
+import android.view.Gravity
+import android.view.View
+import android.widget.ImageView
+import android.widget.LinearLayout
+import androidx.core.content.ContextCompat
+import net.kuafuai.andee.R
+
+/**
+ * The input pill, drawn one way in two places: resting at the foot of the card (where it is not a field — an
+ * overlay cannot raise the keyboard — and every part opens [TextInputActivity]) and inside that activity, where
+ * [middle] is the real field. One builder, so the two cannot drift: the user should see the keyboard arrive and
+ * nothing else change.
+ */
+object InputPill {
+
+ fun build(
+ context: Context,
+ middle: View,
+ onCamera: () -> Unit,
+ onAlbum: () -> Unit,
+ onSend: () -> Unit,
+ ): LinearLayout {
+ fun dp(v: Int) = (v * context.resources.displayMetrics.density).toInt()
+ val pill = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ background = Glass.well(context, dp(24))
+ setPadding(dp(6), dp(4), dp(5), dp(4))
+ minimumHeight = dp(48)
+ }
+ fun icon(res: Int, desc: String, onClick: () -> Unit) = ImageView(context).apply {
+ setImageDrawable(ContextCompat.getDrawable(context, res)?.mutate())
+ setColorFilter(Color.parseColor(Glass.SECONDARY))
+ contentDescription = desc
+ setPadding(dp(7), dp(7), dp(7), dp(7))
+ isClickable = true
+ Glass.pressable(this)
+ setOnClickListener { onClick() }
+ }
+ pill.addView(icon(R.drawable.ic_camera, "拍照", onCamera), LinearLayout.LayoutParams(dp(36), dp(36)))
+ pill.addView(icon(R.drawable.ic_image, "相册", onAlbum), LinearLayout.LayoutParams(dp(36), dp(36)))
+ pill.addView(middle, LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f).apply { marginStart = dp(4) })
+ val send = ImageView(context).apply {
+ setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_send)?.mutate())
+ setColorFilter(Color.WHITE)
+ contentDescription = "发送"
+ setPadding(dp(8), dp(8), dp(8), dp(8))
+ background = GradientDrawable().apply {
+ shape = GradientDrawable.OVAL
+ setColor(Color.parseColor(Glass.ACCENT))
+ }
+ isClickable = true
+ Glass.pressable(this)
+ setOnClickListener { onSend() }
+ }
+ pill.addView(send, LinearLayout.LayoutParams(dp(36), dp(36)))
+ return pill
+ }
+}
diff --git a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt
index f5131a6..1cfcf44 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt
@@ -13,7 +13,6 @@ import net.kuafuai.andee.ScreenBodyService
import net.kuafuai.andee.config.FactoryReset
import net.kuafuai.andee.config.Notebook
import net.kuafuai.andee.config.VoiceConfig
-import net.kuafuai.andee.device.AndroidPeers
import net.kuafuai.andee.device.SelfCheck
import net.kuafuai.andee.i18n.AppLocale
@@ -539,7 +538,6 @@ class SelfCheckActivity : StageActivity() {
if (settings?.isShowing() == true) return
val s = SettingsUi(
context = this,
- peers = net.kuafuai.andee.BodyCoreService.get()?.peerLink() ?: AndroidPeers(this),
onDismiss = {
settings = null
paintedLang = VoiceConfig.uiLanguage(this)
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 3e3481a..fba7e81 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
@@ -22,7 +22,6 @@ import net.kuafuai.andee.config.FactoryReset
import net.kuafuai.andee.config.Notebook
import net.kuafuai.andee.config.Vault
import net.kuafuai.andee.config.VoiceConfig
-import net.kuafuai.andee.device.AndroidPeers
import net.kuafuai.andee.i18n.AppLocale
import net.kuafuai.andee.wake.WakeTemplates
import net.kuafuai.andee.wake.WakeWord
@@ -80,7 +79,6 @@ import net.kuafuai.andee.wake.WakeWord
*/
class SettingsUi(
private val context: Context,
- private val peers: AndroidPeers,
private val onDismiss: () -> Unit,
/**
* 恢复出厂设置, after the user has confirmed twice. Wired to
@@ -370,13 +368,16 @@ class SettingsUi(
// 外观 is the only appearance setting left up here: 形象与表情 moved into 高级,
// so the "these two are the same kind of setting" argument went with it. What is
// left in 常用 is what a person opens settings to change.
+ // The same order as the Mac's settings page. 形象与表情, 装备 and 保险箱 are opened from here on both bodies;
+ // 小本本 and 朋友 have their own keys on the top bar (and the Mac's sidebar), so this card only holds
+ // the notebook's review settings and no door to the friends list.
themeSection(form)
+ expressionsSection(form)
wakeSection(form)
notebookSection(form)
gearSection(form)
notifySection(form)
vaultSection(form)
- peersSection(form)
maxStepsSection(form)
advancedSection(form)
@@ -440,7 +441,6 @@ class SettingsUi(
// 形象与表情, moved down here from 常用. It is a door rather than a setting —
// see [expressionsSection] — and a door that most users never open belongs
// behind the disclosure rather than in the column everyone scrolls.
- expressionsSection(body)
showHubSection(body)
typingSection(body)
diagnosticsSection(body)
@@ -1019,25 +1019,6 @@ class SettingsUi(
}
- /**
- * Devices: pair, view, unpair. The list lives in [PeersUi]; this section is just the door and count.
- */
- private fun peersSection(form: LinearLayout) {
- val panel = group(form, lctx.getString(R.string.settings_section_peers))
- val state = TextView(context).apply {
- val n = peers.store.all().size
- text = if (n == 0) lctx.getString(R.string.settings_peers_note) else lctx.getString(R.string.settings_peers_count_note, n)
- textSize = Glass.Type.CAPTION
- setTextColor(Color.parseColor(Glass.LABEL))
- setLineSpacing(dp(3).toFloat(), 1f)
- }
- panel.addView(state, rowParams(0))
- val row = LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL }
- row.addView(button(lctx.getString(R.string.settings_peers_manage), filled = false) {
- PeersUi(context, peers).show()
- })
- panel.addView(row, rowParams(dp(12)))
- }
private fun diagnosticsSection(form: LinearLayout) {
val panel = group(form, lctx.getString(R.string.settings_section_diagnostics))
rowLabel(panel, lctx.getString(R.string.settings_grounding))
@@ -1264,27 +1245,12 @@ class SettingsUi(
// The bill, such as it is. These calls are paid for with the user's own
// key, so the count and the spend are shown rather than hidden.
- val stats = readOnly(
+ // Read-only, like the Mac's line. Browsing memories and scenes is the top bar's 小本本 and 情景 keys.
+ readOnly(
panel,
lctx.getString(R.string.settings_notebook_today),
notebookStats(),
)
- // 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() }.show()
- },
- LinearLayout.LayoutParams(WRAP, WRAP).apply { topMargin = dp(10) },
- )
- // Scenes are learned the same way memories are, so they are reached
- // from the same section — the control bar's 情景 key is the other door.
- panel.addView(
- button(lctx.getString(R.string.settings_scenes_browse), filled = false) {
- ScenesUi(context).show()
- },
- LinearLayout.LayoutParams(WRAP, WRAP).apply { topMargin = dp(10) },
- )
}
private fun notebookStats(): String = lctx.getString(
diff --git a/app/src/main/java/net/kuafuai/andee/ui/TextInputActivity.kt b/app/src/main/java/net/kuafuai/andee/ui/TextInputActivity.kt
index f124fb4..8d6ed88 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/TextInputActivity.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/TextInputActivity.kt
@@ -32,6 +32,7 @@ import android.widget.TextView
import androidx.core.content.FileProvider
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
+import androidx.core.view.WindowInsetsAnimationCompat
import androidx.core.view.WindowInsetsCompat
import net.kuafuai.andee.R
import net.kuafuai.andee.i18n.AppLocale
@@ -112,6 +113,9 @@ class TextInputActivity : Activity() {
/** Whether the card should follow the strip's top edge right now. */
private var trackTop = false
+ /** The keyboard is sliding; [onProgress] owns the strip's position and the card's edge until it stops. */
+ private var sliding = false
+
/**
* The user is in the camera, the photo picker or the permission dialog.
* While it is set, the keyboard going away and this activity stopping are
@@ -129,6 +133,9 @@ class TextInputActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ // No window animation in or out: the strip opens exactly where the card's identical pill already is,
+ // so the keyboard sliding is the only motion there should be.
+ @Suppress("DEPRECATION") overridePendingTransition(0, 0)
// Before the first `Glass.*` read below: [Theme] holds the *default* palette
// until something loads the saved one, and this page draws immediately.
Theme.load(this)
@@ -143,16 +150,16 @@ class TextInputActivity : Activity() {
// read at a glance: #5F6775 on the strip's near-black is ~3.6:1,
// which is the faint grey this whole change was about.
setHintTextColor(Color.parseColor(Glass.SECONDARY))
- // Recessed, so the strip reads as "type here" rather than as a
- // toolbar with two buttons and some floating text.
- background = Glass.well(this@TextInputActivity, dp(14))
+ // No fill of its own: the pill around it is the field (see [InputPill]), exactly as the card's
+ // resting pill draws it, so opening the keyboard changes nothing but the keyboard.
+ background = null
// Single line with the enter key turned into send. Deliberately not
// a multi-line box: with one, Enter inserts a newline and the only
// way to send is the button — a coin flip the user has to learn.
maxLines = 1
inputType = InputType.TYPE_CLASS_TEXT
imeOptions = EditorInfo.IME_ACTION_SEND
- setPadding(dp(12), dp(8), dp(12), dp(8))
+ setPadding(dp(4), 0, dp(4), 0)
setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEND) {
send()
@@ -163,15 +170,12 @@ class TextInputActivity : Activity() {
}
}
- val row = LinearLayout(this).apply {
- orientation = LinearLayout.HORIZONTAL
- gravity = Gravity.CENTER_VERTICAL
- }
- row.addView(iconButton(R.drawable.ic_camera, lctx.getString(R.string.input_take_photo)) { takePhoto() })
- row.addView(iconButton(R.drawable.ic_image, lctx.getString(R.string.input_pick_photos)) { pickPhotos() })
- row.addView(field, LinearLayout.LayoutParams(0, WRAP, 1f))
- row.addView(glyph(lctx.getString(R.string.input_send), Glass.ACCENT) { send() })
- row.addView(glyph("✕", Glass.LABEL) { finish() })
+ // The same pill as the card's resting one — camera, album, words, send — so the field opening is the
+ // keyboard arriving and nothing else. Closing is the keyboard going (or back): the pill has no ✕.
+ val row = InputPill.build(
+ this, field,
+ onCamera = { takePhoto() }, onAlbum = { pickPhotos() }, onSend = { send() },
+ )
thumbs = LinearLayout(this).apply {
orientation = LinearLayout.HORIZONTAL
@@ -259,6 +263,11 @@ class TextInputActivity : Activity() {
)
}
setContentView(root)
+ // Opened from the resting pill's camera or album icon: carry on to that.
+ when (intent?.getStringExtra(EXTRA_THEN)) {
+ "camera" -> root.post { takePhoto() }
+ "album" -> root.post { pickPhotos() }
+ }
// The keyboard is most of a phone screen, and it arrives **over** this
// window. A translucent window is never resized for the IME — measured:
@@ -274,7 +283,10 @@ class TextInputActivity : Activity() {
// On the column, not the root: the backdrop is full bleed and must
// slide under the status bar and the keys, while the strip itself
// steps around them.
- column.setPadding(dp(12), dp(4) + bars.top, dp(12), dp(12) + ime)
+ // While the keyboard slides, the animation callback below moves the strip frame by frame; this
+ // listener sees the *end* state first and would jump it there in one step — the stutter.
+ if (!sliding) column.setPadding(dp(12), dp(4) + bars.top, dp(12), dp(12) + ime)
+ else column.setPadding(dp(12), dp(4) + bars.top, dp(12), column.paddingBottom)
if (ime > 0) {
imeShown = true
cancelCloseWhenGone()
@@ -298,7 +310,23 @@ class TextInputActivity : Activity() {
// another app to collect, and losing them to a dropped keyboard
// is worse than a strip that waits at the bottom for 发送.
trackTop = false
- scheduleCloseWhenGone()
+ if (!sliding) scheduleCloseWhenGone()
+ return@setOnApplyWindowInsetsListener insets
+ }
+ // Before the keyboard has ever arrived the strip sits at the very bottom, under the card's own
+ // identical pill. Telling the card to end there would only make it jump twice.
+ if (!imeShown) return@setOnApplyWindowInsetsListener insets
+ if (sliding) {
+ // This listener sees where the keyboard will *end* before it starts moving. The card takes that
+ // edge once, now — resizing an overlay every frame is a relayout of the whole card per frame,
+ // which is what made the slide stutter (measured: 66 slow UI-thread frames in three opens).
+ // The gap it leaves above the rising strip is this window's own backdrop: the same picture.
+ trackTop = true
+ if (ime > 0 && strip.height > 0) {
+ val at = IntArray(2)
+ root.getLocationOnScreen(at)
+ onTop?.invoke(at[1] + root.height - (dp(12) + ime) - strip.height)
+ }
return@setOnApplyWindowInsetsListener insets
}
// Tell the card where our top edge is, in screen pixels, so it can
@@ -310,6 +338,36 @@ class TextInputActivity : Activity() {
root.post { reportTop() }
insets
}
+ // Follow the keyboard frame by frame: the strip rides on top of it. The card's edge moves once per
+ // slide (see the listener above); moving it every frame stuttered.
+ ViewCompat.setWindowInsetsAnimationCallback(root, object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) {
+ override fun onPrepare(a: WindowInsetsAnimationCompat) {
+ if (a.typeMask and WindowInsetsCompat.Type.ime() != 0) sliding = true
+ }
+
+ override fun onProgress(insets: WindowInsetsCompat, running: MutableList<WindowInsetsAnimationCompat>): WindowInsetsCompat {
+ if (!sliding || picking) return insets
+ val ime = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom
+ val bottom = dp(12) + ime
+ if (column.paddingBottom != bottom) column.setPadding(column.paddingLeft, column.paddingTop, column.paddingRight, bottom)
+ // Only the strip moves per frame; the card's edge was set once when the slide began.
+ return insets
+ }
+
+ override fun onEnd(a: WindowInsetsAnimationCompat) {
+ if (a.typeMask and WindowInsetsCompat.Type.ime() == 0) return
+ sliding = false
+ val now = ViewCompat.getRootWindowInsets(root)
+ val ime = now?.getInsets(WindowInsetsCompat.Type.ime())?.bottom ?: 0
+ if (ime > 0) { trackTop = true; return }
+ if (imeShown && photos.isEmpty() && !picking) {
+ // The keys are down: hand the card its full height back now — its own pill is the same
+ // picture as this strip, so the hand-over is invisible — and close.
+ onTop?.invoke(0)
+ scheduleCloseWhenGone()
+ }
+ }
+ })
// The strip also grows by itself, when the first photo arrives.
strip.addOnLayoutChangeListener { _, _, top, _, _, _, oldTop, _, _ ->
if (top != oldTop && trackTop) reportTop()
@@ -602,6 +660,11 @@ class TextInputActivity : Activity() {
field.removeCallbacks(r)
}
+ override fun finish() {
+ super.finish()
+ @Suppress("DEPRECATION") overridePendingTransition(0, 0)
+ }
+
private fun showKeyboard() {
runCatching { field.windowInsetsController?.show(android.view.WindowInsets.Type.ime()) }
runCatching {
@@ -710,15 +773,19 @@ class TextInputActivity : Activity() {
* so a second tap on ⌨ raises the field already up instead of stacking a
* second one behind it.
*/
- fun start(context: Context) {
+ /** [then] = "camera" / "album" to go straight on to that, as the resting pill's icons ask. */
+ fun start(context: Context, then: String? = null) {
runCatching {
context.startActivity(
Intent(context, TextInputActivity::class.java)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP),
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
+ .putExtra(EXTRA_THEN, then),
)
}
}
+ const val EXTRA_THEN = "then"
+
/** Close it if it is up. Safe to call from anywhere, including never-opened. */
fun dismiss() {
live?.get()?.finish()
diff --git a/app/src/main/res/drawable/ic_notebook.xml b/app/src/main/res/drawable/ic_notebook.xml
new file mode 100644
index 0000000..7e36f2d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_notebook.xml
@@ -0,0 +1,10 @@
+<!-- 小本本: a bound notebook with ring tabs down its spine — the Mac sidebar's NOTEBOOK icon, as a filled glyph. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M7,2h11a2,2 0,0 1,2 2v16a2,2 0,0 1,-2 2H7a2,2 0,0 1,-2 -2v-1H3.5a1,1 0,0 1,0 -2H5v-2H3.5a1,1 0,0 1,0 -2H5v-2H3.5a1,1 0,0 1,0 -2H5V9H3.5a1,1 0,0 1,0 -2H5V4a2,2 0,0 1,2 -2zM9.5,7.5a0.75,0.75 0,0 0,0 1.5h6a0.75,0.75 0,0 0,0 -1.5zM9.5,11.25a0.75,0.75 0,0 0,0 1.5h6a0.75,0.75 0,0 0,0 -1.5zM9.5,15a0.75,0.75 0,0 0,0 1.5h4a0.75,0.75 0,0 0,0 -1.5z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_send.xml b/app/src/main/res/drawable/ic_send.xml
new file mode 100644
index 0000000..70c7900
--- /dev/null
+++ b/app/src/main/res/drawable/ic_send.xml
@@ -0,0 +1,4 @@
+<!-- 发送: an arrow pointing up, the Mac composer's send glyph. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M12,4.5l6.5,6.5 -1.41,1.41L13,8.33V19.5h-2V8.33l-4.09,4.08L5.5,11z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_volume.xml b/app/src/main/res/drawable/ic_volume.xml
new file mode 100644
index 0000000..a51e755
--- /dev/null
+++ b/app/src/main/res/drawable/ic_volume.xml
@@ -0,0 +1,4 @@
+<!-- 朗读: a speaker with sound waves (Material "volume_up"). -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M3,9v6h4l5,5V4L7,9H3zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_volume_off.xml b/app/src/main/res/drawable/ic_volume_off.xml
new file mode 100644
index 0000000..c718098
--- /dev/null
+++ b/app/src/main/res/drawable/ic_volume_off.xml
@@ -0,0 +1,4 @@
+<!-- 静音: the speaker struck through (Material "volume_off"). -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9H3v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18V4z"/>
+</vector>
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index fe0e9ae..58b133d 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -228,7 +228,7 @@
style ("1tap: talk") is deliberate: the long-form sentence wrapped to
two lines on the card, and a hint the user has to scroll past is
longer than one they can read at a glance. -->
- <string name="window_tips">1tap: talk · 2tap: type · 3tap: stop · swipe: character</string>
+ <string name="window_tips">1tap: talk · 2tap: type · swipe: character</string>
<string name="artifacts_title">Made for you</string>
<string name="artifacts_subtitle">Pages it has built for you</string>
@@ -685,4 +685,7 @@
<string name="peer_allow">Allow</string>
<string name="peer_allow_always">Always allow</string>
<string name="peer_decline">Decline</string>
+ <string name="window_input_hint">Type to it…</string>
+ <string name="window_voice_on">Voice on</string>
+ <string name="window_muted">Muted</string>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5b8ee29..a07ade5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -202,7 +202,7 @@
<!-- The pinned gesture tips at the bottom of the full card. The swipe hint
is last because it is the one gesture that only exists unfolded — the
folded ball reads a horizontal flick as a move instead. -->
- <string name="window_tips">点小球说话 · 双击打字 · 三连击停止 · 滑动切换性格</string>
+ <string name="window_tips">点小球说话 · 双击打字 · 滑动切换性格</string>
<!-- 产物: the pages the assistant has made. See ui/ArtifactsUi.kt. -->
<string name="artifacts_title">产物</string>
@@ -766,4 +766,7 @@
<string name="peer_allow">允许</string>
<string name="peer_allow_always">总是允许</string>
<string name="peer_decline">拒绝</string>
+ <string name="window_input_hint">打字跟它说…</string>
+ <string name="window_voice_on">朗读</string>
+ <string name="window_muted">静音</string>
</resources>
diff --git a/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt b/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt
index 4f50bcb..548c45a 100644
--- a/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt
+++ b/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt
@@ -82,6 +82,12 @@ interface BrainHost {
*/
fun gearIndex(): String = ""
+ /**
+ * One line naming the other Andees this one can ask (see `PeerTasks`), empty when it has none. Without it the
+ * model answers "do you have friends" from nothing; a default, so a host without friends changes by not a byte.
+ */
+ fun friendsIndex(): String = ""
+
/**
* Archive [rows] as one finished topic. Returns null when nothing was
* written — the caller then keeps the conversation as it was.
diff --git a/core/src/main/kotlin/net/kuafuai/andee/brain/GuestHost.kt b/core/src/main/kotlin/net/kuafuai/andee/brain/GuestHost.kt
index 80a8deb..69ef36e 100644
--- a/core/src/main/kotlin/net/kuafuai/andee/brain/GuestHost.kt
+++ b/core/src/main/kotlin/net/kuafuai/andee/brain/GuestHost.kt
@@ -30,6 +30,7 @@ class GuestHost(private val inner: BrainHost) : BrainHost by inner {
override fun pagesIndex(): String = ""
override fun topicsIndex(): String = ""
override fun gearIndex(): String = ""
+ override fun friendsIndex(): String = ""
override fun foldTopic(title: String, summary: String, rows: List<ScrollRow>, text: String): FoldedTopic? = null
/** Not forwarded: the owner's own turn state (the Mac's command policy) must not be moved by a guest. */
diff --git a/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt b/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt
index a983f23..ad676c5 100644
--- a/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt
+++ b/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt
@@ -700,6 +700,7 @@ class LocalBrain(
// above: the shelf changes whenever an app is used or learned, and the system prompt is the one
// place that must never move. Empty until there is something worth a line.
val gear = host.gearIndex()
+ val friends = host.friendsIndex()
// Photos with no words: there is no sentence of the user's to take
// the language from, so the bracketed fallback comes back for it.
val wordless = userText.isEmpty()
@@ -779,6 +780,12 @@ class LocalBrain(
} else {
"\n\n(installed here and worth reaching for first, most used first — if one of these is built " +
"for the job, prefer handing it over to doing every step yourself; list_gear has the rest)\n$gear"
+ } +
+ // The other Andees it can ask. Same position, same reason: who is reachable changes all day.
+ if (friends.isEmpty()) {
+ ""
+ } else {
+ "\n\n(other Andees you can ask with ask_friend; list_friends has detail)\n$friends"
},
)
}
diff --git a/core/src/main/kotlin/net/kuafuai/andee/peer/PeerTasks.kt b/core/src/main/kotlin/net/kuafuai/andee/peer/PeerTasks.kt
index 6567f1f..c0164ce 100644
--- a/core/src/main/kotlin/net/kuafuai/andee/peer/PeerTasks.kt
+++ b/core/src/main/kotlin/net/kuafuai/andee/peer/PeerTasks.kt
@@ -167,6 +167,21 @@ class PeerTasks(private val net: Net) {
}
}
+ /** The line on each user message: `name (phone, your own device, here)`, or empty with no friends. */
+ fun indexForPrompt(): String {
+ val all = net.paired()
+ if (all.isEmpty()) return ""
+ return all.joinToString("; ") { p ->
+ val own = net.trust(p.id) == PeerStore.Trust.OWN
+ val parts = listOfNotNull(
+ abouts[p.id]?.platform,
+ if (own) "your own device" else "a friend's Andee",
+ if (net.enabled() && net.reachable(p.id)) "reachable" else "not reachable now",
+ )
+ "${p.name} (${parts.joinToString(", ")})"
+ }
+ }
+
// ---- the asking side: the two tools -----------------------------------------------------------------
fun dispatch(method: String, p: JSONObject): Any = when (method) {
@@ -261,7 +276,7 @@ class PeerTasks(private val net: Net) {
.put("parameters", JSONObject().put("type", "object").put("properties", props).put("required", JSONArray(required)))
JSONArray()
.put(tool("list_friends", "peer.list", """
- The other Andees this one is friends with, like a shelf of helpers you can ask. Each row says:
+ The other Andees this one is friends with, like a shelf of helpers you can ask. Call it when the user asks about friends or other devices, instead of answering from memory. Each row says:
- `relation`: **your own other device** (the same user — a phone or a Mac they also own; it shares your trust) or **a friend** (somebody else's Andee, working for its own owner).
- `is` (`phone` / `mac`) and `says_it_can`: what that body can do, in its own words — its claim, not a guarantee.
- `reachable` now, and `waiting_on`: requests you made that have not reported back.
@@ -270,7 +285,8 @@ class PeerTasks(private val net: Net) {
Ask another Andee to do something, where it is done by that Andee on its own body. Use it when the job belongs there: an app only the phone has, long work or code on the Mac, or something a friend's Andee offered to do. Doing it badly here, or telling the user to go and do it on the other device themselves, is worse.
- `task` is everything the other side needs, in one self-contained message: the goal, the details, what "done" looks like, what to report back. It cannot see this conversation and cannot ask you questions.
- - **To a friend** (not one of the user's own devices): that Andee works for somebody else. Its owner is asked first and may say no. Send only what the user asked you to share — never the user's memory, accounts, contacts, codes or anything else private unless they told you to pass that on. Never write that its owner has agreed or will agree: that is theirs to decide, and saying it only reads as an attempt to skip the question.
+ - **When the user asks you to ask a friend, ask.** Do not refuse, and do not make the user choose between options on the friend's behalf: whether to do it is the friend's owner's decision, and they are asked before anything happens — that card is the safeguard, not you. If something the user may not have thought of matters (whose account, address or money it would be), put it in the task or say it in one line *after* asking, not instead of asking.
+ - **To a friend** (not one of the user's own devices): that Andee works for somebody else. Send only what the user asked you to share — never the user's memory, accounts, contacts, codes or anything else private unless they told you to pass that on. Never write that its owner has agreed or will agree: that is theirs to decide. `relation` is how the user filed it; a device the user filed as a friend may still be theirs.
- It returns as soon as the other side has taken the request. The report arrives later as a message of its own; tell the user it has been asked, and do not wait for it, check on it, or also do it here.
- If the friend is not reachable, nothing was sent: say so plainly, never that it was asked.
""".trimIndent(),
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/App.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/App.kt
index 715b77a..52b3910 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/App.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/App.kt
@@ -28,7 +28,10 @@ fun AppRoot(nav: Nav) {
val card = if (screen == "chat") Modifier else Modifier.padding(14.dp).frostedCard()
Box(Modifier.widthIn(max = 900.dp).fillMaxHeight().then(card)) {
when {
- screen == "settings" -> SettingsScreen(onDone = { nav.back() }, onOpenGear = { nav.push("gear") })
+ screen == "settings" -> SettingsScreen(
+ onDone = { nav.back() }, onOpenGear = { nav.push("gear") },
+ onOpenVault = { nav.push("vault") }, onOpenExpressions = { nav.push("expressions") },
+ )
screen == "selfcheck" -> SelfCheckCard(onDone = { nav.back() }, onOpenSettings = { nav.push("settings") })
screen == "notebook" -> NotebookCard(onDone = { nav.back() })
screen == "vault" -> VaultCard(onDone = { nav.back() })
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
index 61f3a64..9eafb4a 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
@@ -1,5 +1,13 @@
package net.kuafuai.andee.desktop
+import androidx.compose.foundation.gestures.detectHorizontalDragGestures
+
+import androidx.compose.ui.input.pointer.pointerInput
+
+import androidx.compose.ui.graphics.graphicsLayer
+
+import androidx.compose.ui.draw.drawWithContent
+
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
@@ -114,7 +122,6 @@ fun ChatScreen(onOpenArtifacts: () -> Unit, onOpenTopic: (Long) -> Unit = {}, on
val attached = remember { androidx.compose.runtime.mutableStateListOf<Attachment>().apply { addAll(ChatPreview.attachments) } }
var dropping by remember { mutableStateOf(false) }
var muted by remember { mutableStateOf(Assistant.muted) }
- var artifacts by remember { mutableStateOf(Pages.artifacts()) }
var recording by remember { mutableStateOf(Meeting.isActive()) }
val list = rememberLazyListState()
// A folded stretch is one card standing where its messages stood — the phone's rule, so the
@@ -130,7 +137,6 @@ fun ChatScreen(onOpenArtifacts: () -> Unit, onOpenTopic: (Long) -> Unit = {}, on
}
LaunchedEffect(Unit) {
rows = Scrollback.snapshot()
- Pages.onChange = { artifacts = Pages.artifacts() }
Meeting.onRecordingChanged = { recording = it }
Assistant.onProgress = { progress = it }
Assistant.onFinal = { progress = "" }
@@ -215,23 +221,15 @@ fun ChatScreen(onOpenArtifacts: () -> Unit, onOpenTopic: (Long) -> Unit = {}, on
)
Column(Modifier.weight(1f).fillMaxWidth().padding(horizontal = 16.dp)) {
- if (artifacts.isNotEmpty()) {
- Row(
- Modifier.fillMaxWidth().glassSurface(12).clickable { onOpenArtifacts() }.padding(12.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Icon(AndeeIcon.DOCUMENT, Palette.accent, 16.dp)
- Spacer(Modifier.width(8.dp))
- Text(
- (if (Strings.lang() == "zh") "产物" else "Artifacts") + " (${artifacts.size})",
- color = Palette.accent, fontSize = 13.sp, modifier = Modifier.weight(1f),
- )
- Icon(AndeeIcon.CHEVRON, Palette.accent, 14.dp)
- }
- Spacer(Modifier.height(10.dp))
+ // The ball above the conversation, as on the phone's unfolded card: the same Andee as the floating
+ // one (it wears the same face, see MacBall), and a tap talks to it. 产物 has its own sidebar door.
+ // Same taps as the floating ball; sideways swipe switches character, like the full card's ball on the phone.
+ val chatBall = remember { ballActions(onType = { ComposerFocus.pending = true }, onNoVoice = { progress = noVoiceKey() }) }
+ Box(Modifier.fillMaxWidth().padding(bottom = 6.dp), contentAlignment = Alignment.Center) {
+ BallView(150.dp, onClick = null, modifier = Modifier.ballTaps(chatBall).lookSwipe())
}
LazyColumn(
- state = list, modifier = Modifier.weight(1f).fillMaxWidth(),
+ state = list, modifier = Modifier.weight(1f).fillMaxWidth().fadeTop(36.dp),
contentPadding = androidx.compose.foundation.layout.PaddingValues(top = 4.dp, bottom = 18.dp),
verticalArrangement = Arrangement.spacedBy(10.dp),
) {
@@ -292,11 +290,16 @@ fun ChatScreen(onOpenArtifacts: () -> Unit, onOpenTopic: (Long) -> Unit = {}, on
onRemove = { attached.remove(it) },
onAttach = { choose() },
onPaste = { pasteAttachment() },
- stoppable = recording || busy,
- onStop = { if (recording) Meeting.stopFromUser() else if (busy) Assistant.stop() },
onMic = { toggleMic() },
onSend = { send() },
)
+ // The ball's whole vocabulary, pinned where the eye ends up — the phone's line under its card.
+ Text(
+ if (Strings.lang() == "zh") "点小球说话 · 双击打字 · 左右拖动切换形象"
+ else "Tap the ball to talk · double-tap to type · drag sideways to switch character",
+ color = Palette.photoInk, fontSize = 11.sp, textAlign = androidx.compose.ui.text.style.TextAlign.Center,
+ modifier = Modifier.fillMaxWidth().padding(top = 2.dp, bottom = 8.dp),
+ )
}
if (dropping) {
Box(
@@ -348,7 +351,7 @@ private fun Header(status: String?, live: Boolean, muted: Boolean, onToggleMute:
private fun InputBar(
input: String, onInput: (String) -> Unit, listening: Boolean, canSend: Boolean,
attached: List<Attachment>, onRemove: (Attachment) -> Unit, onAttach: () -> Unit, onPaste: () -> Boolean,
- stoppable: Boolean, onStop: () -> Unit, onMic: () -> Unit, onSend: () -> Unit,
+ onMic: () -> Unit, onSend: () -> Unit,
) {
Column {
if (attached.isNotEmpty()) AttachmentStrip(attached, onRemove)
@@ -392,7 +395,6 @@ private fun InputBar(
)
}
}
- if (stoppable) RoundButton(true, onStop, AndeeIcon.STOP, danger = true)
RoundButton(canSend, onSend, AndeeIcon.SEND)
}
}
@@ -556,3 +558,33 @@ fun Pill(label: String, onClick: () -> Unit) {
.padding(horizontal = 12.dp, vertical = 6.dp),
)
}
+
+/**
+ * The top of the conversation dissolves instead of being cut off: the phone's scrollback does the same under its
+ * ball. A mask, not a coloured overlay, so it is right on any backdrop and in both themes.
+ */
+private fun Modifier.fadeTop(height: androidx.compose.ui.unit.Dp): Modifier = this
+ .graphicsLayer { compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen }
+ .drawWithContent {
+ drawContent()
+ val h = height.toPx()
+ drawRect(
+ brush = androidx.compose.ui.graphics.Brush.verticalGradient(0f to Color.Transparent, 1f to Color.Black, startY = 0f, endY = h),
+ size = androidx.compose.ui.geometry.Size(size.width, h),
+ blendMode = androidx.compose.ui.graphics.BlendMode.DstIn,
+ )
+ }
+
+/** A clearly sideways drag across the ball steps to the next or previous character, once per drag. */
+private fun Modifier.lookSwipe(): Modifier = this.pointerInput(Unit) {
+ var dx = 0f
+ var done = false
+ detectHorizontalDragGestures(
+ onDragStart = { dx = 0f; done = false },
+ onHorizontalDrag = { change, amount ->
+ change.consume()
+ dx += amount
+ if (!done && kotlin.math.abs(dx) > 48.dp.toPx()) { done = true; MacBall.stepLook(if (dx < 0) 1 else -1) }
+ },
+ )
+}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/DesktopBrainHost.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/DesktopBrainHost.kt
index 8f9fd3d..c3b8c35 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/DesktopBrainHost.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/DesktopBrainHost.kt
@@ -80,6 +80,8 @@ class DesktopBrainHost(
override fun gearIndex(): String = providers.filterIsInstance<net.kuafuai.andee.desktop.mac.MacGear>().firstOrNull()?.indexForPrompt().orEmpty()
override fun topicsIndex(): String = Scrollback.topicsIndex()
+ override fun friendsIndex(): String = Peers.tasks.indexForPrompt()
+
override fun foldTopic(title: String, summary: String, rows: List<ScrollRow>, text: String): FoldedTopic? {
val t = Scrollback.fold(title, summary, rows.mapNotNull { it.handle as? Long }, text) ?: return null
return FoldedTopic(t.id, t.title, t.summary)
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/FloatingBall.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/FloatingBall.kt
index 1b49292..73d9c66 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/FloatingBall.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/FloatingBall.kt
@@ -30,19 +30,14 @@ private val BALL_WINDOW = 112.dp
* over full-screen apps (that last part is the native `floatWindow`, because a
* JVM's "always on top" is only the floating level on the current Space).
*
- * While a task is running or being read out, any press stops it (see `working` / `onStop`).
- *
- * The phone's three gestures: tap talks, double-tap types (the chat window comes
- * up with the cursor in the input box), long-press opens the window. Quitting is
- * ⌘Q, since closing the chat only hides it. Drag moves it, and where it was left
- * is remembered. A tap waits out the double-tap interval before it fires, which
- * is what lets the two be told apart.
+ * The phone's gestures ([BallActions]): one tap talks — stopping whatever was running first — two type
+ * (the chat window comes up with the cursor in the box), three stop, a long press opens the window.
+ * Quitting is ⌘Q, since closing the chat only hides it. Drag moves it, and where it was left is
+ * remembered — like the phone's folded ball; switching character is the chat window's ball.
*/
@Composable
fun ApplicationScope.FloatingBall(
- onTap: () -> Unit, onDoubleTap: () -> Unit, onLongPress: () -> Unit, onWindow: (java.awt.Window) -> Unit,
- /** True while a task is running or being read out; a press then stops it at once. */
- working: () -> Boolean = { false }, onStop: () -> Unit = {},
+ actions: BallActions, onWindow: (java.awt.Window) -> Unit,
) {
val state = rememberWindowState(size = DpSize(BALL_WINDOW, BALL_WINDOW), position = savedPosition())
Window(
@@ -84,18 +79,7 @@ fun ApplicationScope.FloatingBall(
w.setLocation(origin.x + now.x - grab.x, origin.y + now.y - grab.y)
}
}
- .pointerInput(Unit) {
- // A tap waits out the double-tap interval before it fires, which is half a second of
- // "nothing happened" when the user is trying to make it stop. So while it is working
- // the stop happens on the press itself, and the rest of that gesture is ignored.
- var stopped = false
- detectTapGestures(
- onPress = { stopped = working(); if (stopped) onStop() },
- onTap = { if (!stopped) onTap() },
- onDoubleTap = { if (!stopped) onDoubleTap() },
- onLongPress = { if (!stopped) onLongPress() },
- )
- },
+ .ballTaps(actions),
contentAlignment = Alignment.Center,
) {
BallView(BALL_WINDOW, onClick = null)
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/MacBall.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/MacBall.kt
index de15ead..c4d14d2 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/MacBall.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/MacBall.kt
@@ -16,6 +16,9 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
+import androidx.compose.foundation.gestures.detectTapGestures
+import androidx.compose.ui.input.pointer.pointerInput
+import kotlinx.coroutines.launch
import net.kuafuai.andee.brain.SpeechMood
import net.kuafuai.andee.desktop.voice.MacVoice
import net.kuafuai.andee.ui.ball.Action
@@ -37,7 +40,11 @@ import org.jetbrains.skia.ImageInfo
*/
object MacBall {
- @Volatile private var renderer: BallRenderer? = null
+ /**
+ * Every ball on screen: the floating one, and the one above the conversation in the chat window. They are
+ * one Andee, so they wear one face — a set, not a single slot.
+ */
+ private val renderers = java.util.concurrent.CopyOnWriteArraySet<BallRenderer>()
@Volatile private var voice = MacVoice.State.IDLE
@Volatile private var busy = false
@Volatile private var recording = false
@@ -49,11 +56,18 @@ object MacBall {
/** Restores the saved look; by name, like the phone's `ball` key. */
fun restoreLook() = BallLooks.requestByName(Settings.get("ball").ifEmpty { null })
+ /** One character along, with a pop — the phone's sideways swipe across the full card's ball. */
+ fun stepLook(delta: Int) {
+ val look = BallLooks.step(delta)
+ Settings.save(mapOf("ball" to look.name))
+ renderers.forEach { it.trigger(Action.POP) }
+ }
+
/** Switch to another character and remember it. */
fun pickLook(name: String) {
BallLooks.requestByName(name)
Settings.save(mapOf("ball" to name))
- renderer?.trigger(Action.POP)
+ renderers.forEach { it.trigger(Action.POP) }
}
fun onVoice(s: MacVoice.State) {
@@ -61,7 +75,7 @@ object MacBall {
voice = s
// The model's face belongs to one utterance (see FloatingWindowUi.setState).
emotion = if (s == MacVoice.State.SPEAKING) nextEmotion else null
- if (s == MacVoice.State.LISTENING && was != s) renderer?.trigger(Action.HOP)
+ if (s == MacVoice.State.LISTENING && was != s) renderers.forEach { it.trigger(Action.HOP) }
apply()
}
@@ -77,7 +91,7 @@ object MacBall {
}
/** A tool ran: a nod, then back to the working face on its own. */
- fun onTool() { renderer?.pulseTool() }
+ fun onTool() { renderers.forEach { it.pulseTool() } }
/**
* An answer came back. The opening face it was written with is held for
@@ -87,20 +101,20 @@ object MacBall {
*/
fun onAnswer(raw: String) {
nextEmotion = SpeechMood.parse(raw).cues.firstOrNull()?.mood
- renderer?.signalOutcome(true)
+ renderers.forEach { it.signalOutcome(true) }
}
internal fun attach(r: BallRenderer) {
- renderer = r
+ renderers += r
apply()
}
internal fun detach(r: BallRenderer) {
- if (renderer === r) renderer = null
+ renderers -= r
}
private fun apply() {
- val r = renderer ?: return
+ if (renderers.isEmpty()) return
val mood = when {
recording -> Mood.LISTENING
voice == MacVoice.State.LISTENING -> Mood.LISTENING
@@ -108,8 +122,10 @@ object MacBall {
busy -> Mood.THINKING
else -> Mood.CALM
}
- r.setState(mood, listening = mood == Mood.LISTENING, emotion = emotion)
- r.setWorking(busy)
+ for (r in renderers) {
+ r.setState(mood, listening = mood == Mood.LISTENING, emotion = emotion)
+ r.setWorking(busy)
+ }
}
}
@@ -154,3 +170,47 @@ fun BallView(size: Dp, onClick: (() -> Unit)?, modifier: Modifier = Modifier) {
if (tick > 0) drawImage(image, dstOffset = IntOffset.Zero, dstSize = IntSize(this.size.width.toInt(), this.size.height.toInt()))
}
}
+
+/**
+ * What the ball's taps mean, the same on the phone and on both of the Mac's balls:
+ * one tap talks (and stops whatever was running first), two type, three stop, a long press opens the window.
+ */
+class BallActions(
+ val onTap: () -> Unit,
+ val onDoubleTap: () -> Unit,
+ val onTripleTap: () -> Unit,
+ val onLongPress: () -> Unit,
+)
+
+/** The gesture interval: a tap waits this long for a second one before it counts as one tap. */
+private const val MULTI_TAP_MS = 320L
+
+/**
+ * One, two or three taps, told apart by waiting out [MULTI_TAP_MS] after the last — Compose has no triple-tap,
+ * and its double-tap swallows the second tap of a third. A long press fires at once and ends the sequence.
+ */
+fun Modifier.ballTaps(a: BallActions): Modifier = this.pointerInput(a) {
+ val scope = this
+ var count = 0
+ var timer: kotlinx.coroutines.Job? = null
+ kotlinx.coroutines.coroutineScope {
+ val outer = this
+ scope.detectTapGestures(
+ onLongPress = { timer?.cancel(); count = 0; a.onLongPress() },
+ onTap = {
+ count++
+ timer?.cancel()
+ timer = outer.launch {
+ kotlinx.coroutines.delay(MULTI_TAP_MS)
+ val n = count
+ count = 0
+ when {
+ n >= 3 -> a.onTripleTap()
+ n == 2 -> a.onDoubleTap()
+ else -> a.onTap()
+ }
+ }
+ },
+ )
+ }
+}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
index 501866d..60c19ec 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
@@ -76,16 +76,8 @@ fun main() {
}
FloatingBall(
- // A press while it is working is a stop (handled in FloatingBall, on the press itself);
- // these run only when it was idle.
- working = { Assistant.working() },
- onStop = { Assistant.stop() },
- onTap = {
- if (Meeting.isActive()) Meeting.stopFromUser()
- else if (!net.kuafuai.andee.desktop.voice.MacVoice.toggle()) openChat("settings")
- },
- onDoubleTap = { openChat(typing = true) },
- onLongPress = { openChat() },
+ actions = ballActions(onType = { openChat(typing = true) }, onNoVoice = { openChat("settings") })
+ .let { a -> BallActions(a.onTap, a.onDoubleTap, a.onTripleTap) { openChat() } },
onWindow = { ballWindow = it },
)
BallCaptionWindow(ballWindow, suppressed = pending != null || ask != null)
@@ -95,7 +87,9 @@ fun main() {
onCloseRequest = { chat = false },
visible = chat,
title = "Andee",
- state = rememberWindowState(width = 1020.dp, height = 820.dp),
+ // Big enough that the conversation, the ball above it and the sidebar all breathe on a laptop; never
+ // past 90% of the screen it opens on.
+ state = rememberWindowState(width = defaultChatSize().first, height = defaultChatSize().second),
resizable = true,
) {
chatWindow = window
@@ -133,3 +127,34 @@ private fun installFileLog() {
}
}
}
+
+/** The chat window's first size: 1280×960 points, shrunk to 90% of the main screen when that is smaller. */
+private fun defaultChatSize(): Pair<androidx.compose.ui.unit.Dp, androidx.compose.ui.unit.Dp> {
+ val screen = runCatching { java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().maximumWindowBounds }.getOrNull()
+ val w = minOf(1280, ((screen?.width ?: 1280) * 0.9).toInt())
+ val h = minOf(960, ((screen?.height ?: 960) * 0.9).toInt())
+ return w.dp to h.dp
+}
+
+/**
+ * The ball's taps, shared by the floating ball and the one above the conversation. [onType] brings the chat up
+ * with the cursor in the box; a long press is the caller's (the floating ball opens the window, the chat's own
+ * ball has nothing to open).
+ */
+fun ballActions(onType: () -> Unit, onNoVoice: () -> Unit) = BallActions(
+ onTap = {
+ when {
+ Meeting.isActive() -> Meeting.stopFromUser()
+ else -> {
+ // The phone's rule: a tap is "listen to me now". Whatever was running or being read out stops
+ // first, and the mic opens in the same tap rather than needing a second one.
+ if (Assistant.working()) Assistant.stop()
+ if (!net.kuafuai.andee.desktop.voice.MacVoice.toggle()) onNoVoice()
+ }
+ }
+ },
+ // Typing is a new request too: whatever was running or being read out stops first, as the tap does.
+ onDoubleTap = { if (Assistant.working()) Assistant.stop(); onType() },
+ onTripleTap = { if (Meeting.isActive()) Meeting.stopFromUser() else Assistant.stop() },
+ onLongPress = {},
+)
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 da34bed..aba24cc 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
@@ -41,6 +41,8 @@ private fun st(key: String, vararg a: Any): String = Strings.get("s_$key").let {
fun SettingsScreen(
onDone: () -> Unit,
onOpenGear: () -> Unit = {},
+ onOpenVault: () -> Unit = {},
+ onOpenExpressions: () -> Unit = {},
) {
val zh = Strings.lang() == "zh"
fun t(a: String, b: String) = if (zh) a else b
@@ -140,6 +142,11 @@ fun SettingsScreen(
if (Palette.night) "night" else "day",
) { Palette.setNight(it == "night") }
+ // ---- 形象与表情: a door, like the phone's — the card is where looks are tried and picked ----
+ SectionTitle(st("settings_section_expr"))
+ Note(st("settings_expr_note"))
+ Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_expr_open")) { onOpenExpressions() } }
+
// ---- 小本本 ----
SectionTitle(st("settings_section_notebook"))
SegmentedPicker(listOf("on" to st("common_on"), "off" to st("common_off")), v["sweep"].orEmpty().ifEmpty { "on" }) { v["sweep"] = it }
@@ -153,6 +160,17 @@ fun SettingsScreen(
),
)
+ // ---- 装备: a summary here, the card is where it is read and edited ----
+ SectionTitle(st("settings_section_gear"))
+ val gearShelf = remember { Assistant.gear.gear }
+ val installed = remember { gearShelf.forCard() }
+ val learned = installed.count { (i, _) -> i.does.isNotBlank() }
+ Note(
+ if (installed.isEmpty()) st("settings_gear_empty_note")
+ else st("settings_gear_count_note", installed.size, learned),
+ )
+ Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_gear_manage")) { onOpenGear() } }
+
// ---- 消息提醒 ----
SectionTitle(st("settings_section_notify"))
SegmentedPicker(
@@ -168,21 +186,11 @@ fun SettingsScreen(
)
}
- // ---- 保险箱: a summary here, the card is in the sidebar ----
+ // ---- 保险箱: a summary here, and the door to the card ----
SectionTitle(st("settings_section_vault"))
val vaultN = remember { runCatching { net.kuafuai.andee.desktop.mac.MacVault.entries().size }.getOrDefault(0) }
Note(if (vaultN == 0) st("settings_vault_empty_note") else st("settings_vault_count_note", vaultN))
-
- // ---- 装备: a summary here, the card is where it is read and edited ----
- SectionTitle(st("settings_section_gear"))
- val gearShelf = remember { Assistant.gear.gear }
- val installed = remember { gearShelf.forCard() }
- val learned = installed.count { (i, _) -> i.does.isNotBlank() }
- Note(
- if (installed.isEmpty()) st("settings_gear_empty_note")
- else st("settings_gear_count_note", installed.size, learned),
- )
- Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_gear_manage")) { onOpenGear() } }
+ Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_vault_manage")) { onOpenVault() } }
// ---- 单次任务最多步数 ----
SectionTitle(st("settings_max_steps"))
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Sidebar.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Sidebar.kt
index e443337..ce7d0c6 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Sidebar.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Sidebar.kt
@@ -66,32 +66,19 @@ fun Sidebar(nav: Nav, width: androidx.compose.ui.unit.Dp = 228.dp) {
.border(1.dp, Palette.panelEdge)
.padding(horizontal = 10.dp, vertical = 12.dp),
) {
- // Brand row, and the one button that always means "start over".
+ // Brand row. No 新对话 button: the phone has none, and a stretch that is over is put away by the
+ // quiet-hour review (or 整理 below); the menu bar's Andee → 新对话 is still there for whoever wants it.
Row(Modifier.fillMaxWidth().padding(horizontal = 6.dp, vertical = 4.dp), verticalAlignment = Alignment.CenterVertically) {
Text("Andee", color = Palette.title, fontSize = 18.sp, fontWeight = FontWeight.SemiBold)
}
- Spacer(Modifier.height(10.dp))
- Row(
- Modifier.fillMaxWidth()
- .background(Palette.tint.copy(alpha = 0.55f), RoundedCornerShape(12.dp))
- .border(1.dp, Palette.accent.copy(alpha = 0.6f), RoundedCornerShape(12.dp))
- .clickable { Assistant.newConversation(); nav.go("chat") }
- .padding(horizontal = 12.dp, vertical = 9.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Icon(AndeeIcon.PLUS, Palette.title, 16.dp)
- Spacer(Modifier.width(8.dp))
- Text(t("新对话", "New chat"), color = Palette.title, fontSize = 14.sp, fontWeight = FontWeight.Medium)
- }
Spacer(Modifier.height(12.dp))
NavItem(AndeeIcon.CHAT, t("对话", "Chat"), here == "chat") { nav.go("chat") }
NavItem(AndeeIcon.DOCUMENT, t("产物", "Artifacts") + if (artifactCount > 0) " $artifactCount" else "", here == "artifacts") { nav.go("artifacts") }
+ // The same doors, in the same order, as the phone's top bar: 产物 · 小本本 · 情景 · 朋友 · 自检 · 设置.
+ // 形象与表情, 装备 and 保险箱 are opened from 设置 on both, so neither body has a door the other lacks.
NavItem(AndeeIcon.NOTEBOOK, t("小本本", "Notebook"), here == "notebook") { nav.go("notebook") }
NavItem(AndeeIcon.SPARKLE, t("情景", "Scenes"), here == "scenes") { nav.go("scenes") }
- NavItem(AndeeIcon.LOCK, t("保险箱", "Vault"), here == "vault") { nav.go("vault") }
- NavItem(AndeeIcon.FACE, t("形象与表情", "Look"), here == "expressions") { nav.go("expressions") }
- NavItem(AndeeIcon.GRID, t("装备", "Gear"), here == "gear") { nav.go("gear") }
NavItem(AndeeIcon.FRIENDS, t("朋友", "Friends"), here == "peers", badge = Peers.count.value) { nav.go("peers") }
Spacer(Modifier.height(14.dp))