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(ui): one visual system, a stepped first run, and a notebook the user can prune

booboosui1ab5747ab206
diff --git a/app/src/main/java/net/kuafuai/andee/ScreenBodyService.kt b/app/src/main/java/net/kuafuai/andee/ScreenBodyService.kt
index 3d0d5e6..816ca54 100644
--- a/app/src/main/java/net/kuafuai/andee/ScreenBodyService.kt
+++ b/app/src/main/java/net/kuafuai/andee/ScreenBodyService.kt
@@ -44,6 +44,18 @@ class ScreenBodyService : AccessibilityService() {
* can be on screen at once — see [openSelfCheck].
*/
private var selfCheck: net.kuafuai.andee.ui.SelfCheckUi? = null
+
+ /**
+ * The first-run wizard, when it is up.
+ *
+ * Separate from [selfCheck] for the same reason [selfCheck] is separate from
+ * [settings]: they can be on screen at once. The one route between them is
+ * the self-check card's 重新设置 — see [openWizard] — and it closes the card
+ * it came from, so two of them are never both visible; the field exists so a
+ * second entry point could not leak a window.
+ */
+ private var wizard: net.kuafuai.andee.ui.FirstRunUi? = null
+
private lateinit var audio: AudioIO
private lateinit var asr: AsrController
private lateinit var tts: TtsController
@@ -441,6 +453,10 @@ class ScreenBodyService : AccessibilityService() {
startBrain(announce = false)
startWakeWord()
runStartupSelfCheck()
+ // After the check, in both senses: it is scheduled after
+ // [runStartupSelfCheck] has started, and it declines to run if that
+ // thread won the race and put a card up. See [maybeOfferWizard].
+ maybeOfferWizard()
}
/**
@@ -1170,6 +1186,14 @@ class ScreenBodyService : AccessibilityService() {
// in this service and have to be told the same way [openSettings]
// tells them.
onLocaleChanged = { window.onLocaleChanged() },
+ // The manual door into the wizard. [SelfCheckUi.hide] runs first and
+ // its onDismiss clears [selfCheck] from [Glass.exit]'s completion,
+ // which is a fifth of a second later — so the wizard goes up while
+ // this card is still fading out, deliberately: [maybeOfferWizard]'s
+ // guards would otherwise have to wait out a fade they cannot see.
+ // The two never overlap on screen for longer than that fade, and both
+ // are counted by OwnCard.
+ onRerunWizard = { openWizard() },
)
selfCheck = s
s.show()
@@ -1178,6 +1202,132 @@ class ScreenBodyService : AccessibilityService() {
s.start()
}
+ /**
+ * The first-run wizard, in a window of its own.
+ *
+ * [net.kuafuai.andee.ui.FirstRunUi] draws it; this is only the wiring, and
+ * it mirrors [openSelfCheck] deliberately — same host, same yield, same
+ * language callback, because the two cards are reached from one another and
+ * two ways of putting up a card is how they drift apart.
+ *
+ * **Three doors, and each one is a different errand:**
+ * * [maybeOfferWizard], on the service's own start, when nothing has been
+ * configured yet. That is the only automatic one, and it is a question
+ * rather than a takeover.
+ * * [openSelfCheck]'s card, for a device already in use: 重新设置. Reachable
+ * from the list rather than from the bar, because re-running the wizard
+ * on a configured device means redoing six steps.
+ * * Nothing else. In particular the launcher Activity is *not* one: it is
+ * the door for the state where no overlay exists, and the wizard needs
+ * overlays to show the very permissions it is about to ask for.
+ *
+ * Each of the three callbacks hands over to a surface this service already
+ * owns rather than reimplementing it: the wake recorder is
+ * [net.kuafuai.andee.ui.WakeEnrollUi] (the same one ⚙ opens), the camera is
+ * [net.kuafuai.andee.device.LookActivity] (the same one `device.look` opens,
+ * so the shutter flash and the exposure ramp are the shared ones), and the
+ * last step is [startTurn] — literally the ball's own tap.
+ */
+ private fun openWizard() {
+ if (wizard?.isShowing() == true) return
+ val w = net.kuafuai.andee.ui.FirstRunUi(
+ context = this,
+ onDismiss = { wizard = null },
+ // Marked done so a device that has been through it is not offered it
+ // again on the next start. Written on 开始使用 and not on 完成设置,
+ // because the last step is a sentence the user may well say later —
+ // the config is already complete by the time they see it, and a
+ // wizard that will not stop asking is worse than one that stops one
+ // screen early.
+ onComplete = { markWizardDone() },
+ onOpenSettings = { openSettings() },
+ onOpenWakeEnroll = {
+ // The wizard stays up underneath: that is the point of the card
+ // being an overlay, and the user comes back to 下一步 with the
+ // recorder's own 完成. Same relationship the settings sheet has
+ // to this card.
+ net.kuafuai.andee.ui.WakeEnrollUi(this) { }.show()
+ },
+ onOpenLook = {
+ // Fold first: this card is a fullscreen overlay and an Activity
+ // comes up *underneath* one. Same reason SelfCheckUi yields, and
+ // the fold is the gesture the whole app already uses for "give
+ // the screen back".
+ dispatcher.compactForUser()
+ net.kuafuai.andee.device.LookActivity.open(this, false)
+ },
+ // The last step is the ball's own tap, so the user learns the gesture
+ // by using it rather than by reading about it. The wizard closes
+ // first, or it would sit over the conversation it just started.
+ onOpenMic = { hideWizard(); startTurn() },
+ onLocaleChanged = { window.onLocaleChanged() },
+ onYieldScreen = {
+ dispatcher.compactForUser()
+ wizard?.hide()
+ },
+ )
+ wizard = w
+ w.show()
+ }
+
+ /** [openWizard]'s bookkeeping, in one place so the two call sites agree. */
+ private fun hideWizard() {
+ wizard?.hide()
+ wizard = null
+ }
+
+ /**
+ * Whether the device has already been through the wizard.
+ *
+ * Its own preference, not a read of the config: "is anything configured" is
+ * the wrong question — a user who deliberately runs with no 火山 key (the
+ * brain, the screen tools and the notebook all work mute) would be offered
+ * the wizard on every single start, and a card that comes back however many
+ * times you decline it is nagware. What this records is that it was
+ * *offered and taken*, which is a fact about the user rather than about the
+ * config.
+ */
+ private fun wizardDone(): Boolean =
+ getSharedPreferences(SELF_CHECK_PREFS, MODE_PRIVATE).getBoolean(WIZARD_DONE, false)
+
+ private fun markWizardDone() {
+ getSharedPreferences(SELF_CHECK_PREFS, MODE_PRIVATE)
+ .edit().putBoolean(WIZARD_DONE, true).apply()
+ }
+
+ /**
+ * Offer the wizard once, on a device that has never been through it.
+ *
+ * **A question, not a takeover.** The welcome card lists what is about to
+ * happen and has 取消 beside 开始; nothing is written until the user taps
+ * 开始使用 at the far end. A wizard that seized the screen on first start
+ * with no way past it is the other half of the failure this app already has
+ * — every failure here is silent, and the answer is not to make the working
+ * case loud.
+ *
+ * **It waits for the self-check.** [runStartupSelfCheck] and this both want
+ * to put a card up, and two cards arguing about the same missing permission
+ * is exactly what `startBrain(announce = false)` exists to prevent. So it
+ * yields to the check's card when there is one: a device with a broken
+ * permission gets the list, and the wizard comes back on the next start
+ * once that is dealt with. On a clean device there is no card and this runs
+ * immediately — which is the out-of-box case, the only one it is for.
+ */
+ private fun maybeOfferWizard() {
+ if (wizardDone()) return
+ if (!::window.isInitialized || !window.isShown()) return
+ if (selfCheck?.isShowing() == true) return
+ // Long enough for the ball's own enter animation and for the self-check
+ // thread to have decided. Not a race that matters — see the doc above:
+ // losing to the check's card is a correct outcome, not a bug.
+ ui.postDelayed({
+ if (wizardDone() || wizard?.isShowing() == true) return@postDelayed
+ if (selfCheck?.isShowing() == true) return@postDelayed
+ if (!::window.isInitialized || !window.isShown()) return@postDelayed
+ openWizard()
+ }, 1200)
+ }
+
/**
* 恢复出厂设置: wipe everything this app owns, then rebuild out of nothing.
*
@@ -1300,7 +1450,7 @@ class ScreenBodyService : AccessibilityService() {
* Result is echoed to the floating window subtitle.
*/
private fun runTool(tool: FloatingWindowUi.Tool) {
- window.setSubtitle("${tool.name.lowercase()}…", FloatingWindowUi.SubtitleKind.PARTIAL)
+ window.setSubtitle("${AppLocale.str(this, tool.label)}…", FloatingWindowUi.SubtitleKind.PARTIAL)
toolExec.execute {
try {
val result = when (tool) {
@@ -1321,12 +1471,12 @@ class ScreenBodyService : AccessibilityService() {
saveScreenshot(dispatcher.dispatch("screen.screenshot", null) as JSONObject)
}
window.setSubtitle(
- "${tool.name.lowercase()} · $result",
+ "${AppLocale.str(this, tool.label)} · $result",
FloatingWindowUi.SubtitleKind.FINAL,
)
} catch (t: Throwable) {
net.kuafuai.andee.ui.CardUi.error(
- "${tool.name.lowercase()} · ${t.message ?: t.javaClass.simpleName}"
+ "${AppLocale.str(this, tool.label)} · ${t.message ?: t.javaClass.simpleName}"
)
}
}
@@ -1956,6 +2106,16 @@ class ScreenBodyService : AccessibilityService() {
* immediately, because the signature is compared, not the clock.
*/
private const val REPEAT_AFTER_MS = 6 * 60 * 60 * 1000L
+
+ /**
+ * Whether the first-run wizard has been taken to the end.
+ *
+ * Lives beside the self-check's own bookkeeping because it is the same
+ * file for the same reason — both are "what has this device already been
+ * told", neither is configuration the user edits. See [wizardDone] for
+ * why this is not derived from the config.
+ */
+ private const val WIZARD_DONE = "wizard_done"
}
/**
diff --git a/app/src/main/java/net/kuafuai/andee/ui/CameraChrome.kt b/app/src/main/java/net/kuafuai/andee/ui/CameraChrome.kt
index 5fdb8af..29a4ca4 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/CameraChrome.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/CameraChrome.kt
@@ -128,7 +128,7 @@ class StatusPill(context: Context) : LinearLayout(context) {
marginEnd = context.dpI(9)
})
label.apply {
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(PILL_TEXT)
}
addView(label)
@@ -165,7 +165,7 @@ class StatusPill(context: Context) : LinearLayout(context) {
fun closePill(context: Context, onClose: () -> Unit): TextView =
TextView(context).apply {
text = AppLocale.str(context, R.string.cam_close)
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(PILL_TEXT)
gravity = Gravity.CENTER
setPadding(context.dpI(18), context.dpI(8), context.dpI(18), context.dpI(8))
diff --git a/app/src/main/java/net/kuafuai/andee/ui/CardUi.kt b/app/src/main/java/net/kuafuai/andee/ui/CardUi.kt
index 07862e0..675a4fb 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/CardUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/CardUi.kt
@@ -227,7 +227,7 @@ object CardUi {
val title = TextView(context).apply {
this.text = text
setTextColor(Color.parseColor(Glass.TITLE))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.TITLE)
typeface = Typeface.DEFAULT_BOLD
setLineSpacing(dp(3).toFloat(), 1f)
maxLines = 4
@@ -250,7 +250,7 @@ object CardUi {
val isPrimary = label == buttons.first()
val btn = TextView(context).apply {
this.text = label
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
typeface = Typeface.DEFAULT_BOLD
setPadding(dp(18), dp(9), dp(18), dp(9))
gravity = Gravity.CENTER
diff --git a/app/src/main/java/net/kuafuai/andee/ui/FirstRunUi.kt b/app/src/main/java/net/kuafuai/andee/ui/FirstRunUi.kt
new file mode 100644
index 0000000..87453d4
--- /dev/null
+++ b/app/src/main/java/net/kuafuai/andee/ui/FirstRunUi.kt
@@ -0,0 +1,711 @@
+package net.kuafuai.andee.ui
+
+import android.content.Context
+import android.content.Intent
+import android.graphics.Color
+import android.graphics.Typeface
+import android.net.Uri
+import android.os.Handler
+import android.os.Looper
+import android.util.Log
+import android.util.TypedValue
+import android.view.Gravity
+import android.view.View
+import android.view.WindowManager
+import android.widget.FrameLayout
+import android.widget.LinearLayout
+import android.widget.ScrollView
+import android.widget.TextView
+import android.widget.Toast
+import net.kuafuai.andee.R
+import net.kuafuai.andee.config.VoiceConfig
+import net.kuafuai.andee.device.PermissionRequestActivity
+import net.kuafuai.andee.device.SelfCheck
+import net.kuafuai.andee.i18n.AppLocale
+import java.util.concurrent.Executors
+
+/**
+ * First-run onboarding wizard: a stepped flow that turns a blank device into
+ * one ready to use.
+ *
+ * ### What this is not
+ *
+ * Not a second hand-written checklist. This reuses [SelfCheck.Finding] as its
+ * only data source — [SelfCheck.kt]'s own KDoc warns that a second list would
+ * drift from the first within a week, and the whole point of having one source
+ * of truth is that nothing can contradict it. The wizard *filters* and
+ * *reorders* the findings; it does not invent its own.
+ *
+ * ### The steps, and why they are in this order
+ *
+ * Six: accessibility → overlay → key → wake → look → first sentence. That is
+ * dependency order — each uses the ones before it — and it is also the
+ * ascending cost: the cheapest steps come first, so a user who bails out still
+ * has the easier half done. The first three are [SelfCheck] rows; the last
+ * three are instructions + a pill that opens something this service already
+ * owns ([net.kuafuai.andee.wake.WakeEnrollUi], [net.kuafuai.andee.device.LookActivity],
+ * and [net.kuafuai.andee.ui.FloatingWindowUi]'s mic).
+ *
+ * ### Two doors in
+ *
+ * - **Auto**, from [net.kuafuai.andee.ScreenBodyService.onServiceConnected]
+ * when the config is blank: this is a device nobody has touched, so the
+ * wizard is a better first screen than a mute ball with no explanation.
+ * - **Manual**, from the existing self-check card (long-press ✓ on the card,
+ * not the button — a second deliberate step, so a stray tap on the check
+ * list does not blow the existing config away).
+ *
+ * Either way, it is only an *offer* — the first card asks whether to begin, and
+ * 取消 lands you at the ball with no config lost. No auto-advancing; the user
+ * taps 下一步 on each step once the Android permission screen they just came
+ * back from is green or their settings field is filled.
+ *
+ * ### The two hosts
+ *
+ * Like [SelfCheckUi] and [SettingsUi], this is built for both: [host] null
+ * means the service creates a window, non-null means the caller places it. The
+ * hosted path is unreachable at the moment — the launcher Activity opens the
+ * self-check list, not this — but the split is kept because the Activity is
+ * where an interrupted wizard would land if service restarts ever resume it,
+ * and because "cards match self-check" was the whole item 4 design.
+ *
+ * ### Yielding
+ *
+ * [onYieldScreen] is the same contract [SelfCheckUi] uses, and for the same
+ * reason: the window host is an overlay, so Android Settings screens come up
+ * behind the card unless we get out of the way. See [SelfCheckUi.apply].
+ *
+ * ### Language
+ *
+ * [LangToggle] in the header, same place the settings card and the self-check
+ * card put theirs. [onLocaleChanged] announces the change to the service, and
+ * [repaintForLanguage] is how the service tells this card to redraw itself
+ * (because the scrollback and the ball are also on screen and need to follow).
+ */
+class FirstRunUi(
+ private val context: Context,
+ private val onDismiss: () -> Unit,
+ private val onComplete: () -> Unit,
+ /**
+ * The 大脑 / 语音密钥 rows open *our* settings sheet, which is an overlay the
+ * service owns — exactly as [SelfCheckUi] does. Null when there is no sheet
+ * to open, in which case those rows get no button rather than a dead one.
+ */
+ private val onOpenSettings: (() -> Unit)? = null,
+ private val onOpenWakeEnroll: (() -> Unit)? = null,
+ private val onOpenLook: (() -> Unit)? = null,
+ private val onOpenMic: (() -> Unit)? = null,
+ private val onLocaleChanged: () -> Unit = {},
+ private val onYieldScreen: () -> Unit = {},
+ private val host: FrameLayout? = null,
+) {
+
+ private companion object {
+ const val TAG = "Body"
+ const val GUTTER_DP = 20
+ const val CARD_RADIUS_DP = 28
+
+ const val MATCH = LinearLayout.LayoutParams.MATCH_PARENT
+ const val WRAP = LinearLayout.LayoutParams.WRAP_CONTENT
+
+ /** The steps, in order. Only the first three are SelfCheck rows. */
+ private val STEP_IDS = listOf(
+ "accessibility",
+ "overlay",
+ "voice_key",
+ "wake",
+ "look",
+ "first_sentence",
+ )
+ }
+
+ private val wm: WindowManager? =
+ if (host == null) context.getSystemService(Context.WINDOW_SERVICE) as WindowManager else null
+
+ private val main = Handler(Looper.getMainLooper())
+ private val prober = Executors.newSingleThreadExecutor { r ->
+ Thread(r, "wizard-probe").apply { isDaemon = true }
+ }
+
+ private var root: View? = null
+ private var closing: View? = null
+ private var frosted = false
+ private var lctx: Context = context
+
+ private var stepIndex = -1 // -1 = welcome, 0..5 = steps, 6 = complete
+ private var body: LinearLayout? = null
+
+ /**
+ * The last full list, kept so repaint can draw the current step from it.
+ * See [SelfCheckUi.last] for why this is correct rather than a shortcut.
+ */
+ private var findings: List<SelfCheck.Finding>? = null
+
+ fun isShowing(): Boolean = root != null
+
+ // ---- Lifecycle ----
+
+ fun show() {
+ if (host == null) showInWindow() else showInHost()
+ }
+
+ private fun showInHost() {
+ val stage = host ?: return
+ if (root != null) return
+ lctx = AppLocale.wrap(context)
+ frosted = true
+ val v = build()
+ stage.addView(v, FrameLayout.LayoutParams(cardWidth(), cardHeight(), Gravity.CENTER))
+ root = v
+ OwnCard.shown()
+ renderWelcome()
+ }
+
+ private fun showInWindow() {
+ val wm = wm ?: return
+ closing?.let { runCatching { wm.removeView(it) }; OwnCard.hidden() }
+ closing = null
+ if (root != null) return
+
+ lctx = AppLocale.wrap(context)
+ val p = WindowManager.LayoutParams(
+ cardWidth(), cardHeight(),
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
+ 0,
+ android.graphics.PixelFormat.TRANSLUCENT,
+ ).apply {
+ gravity = Gravity.CENTER
+ }
+ frosted = Glass.frost(context, wm, p)
+ val v = build()
+ try {
+ v.hideFromAccessibility()
+ wm.addView(v, p)
+ root = v
+ OwnCard.shown()
+ Glass.enter(v)
+ renderWelcome()
+ } catch (t: Throwable) {
+ Log.w(TAG, "wizard refused", t)
+ }
+ }
+
+ fun hide() {
+ val v = root ?: return
+ root = null
+ val stage = host
+ if (stage != null) {
+ runCatching { stage.removeView(v) }
+ OwnCard.hidden()
+ onDismiss()
+ return
+ }
+ val wm = wm ?: return
+ closing = v
+ Glass.exit(v) {
+ if (closing === v) {
+ runCatching { wm.removeView(v) }
+ closing = null
+ OwnCard.hidden()
+ onDismiss()
+ }
+ }
+ }
+
+ fun destroy() {
+ prober.shutdownNow()
+ if (root != null) {
+ root = null
+ OwnCard.hidden()
+ }
+ }
+
+ // ---- Navigation ----
+
+ /** The welcome card: do you want to begin? */
+ private fun renderWelcome() {
+ stepIndex = -1
+ body?.removeAllViews()
+ body?.addView(heroText(
+ lctx.getString(R.string.wizard_welcome_title),
+ lctx.getString(R.string.wizard_welcome_body),
+ ))
+ }
+
+ /** A step from the list. */
+ private fun renderStep(index: Int) {
+ if (index < 0 || index >= STEP_IDS.size) return
+ stepIndex = index
+ val id = STEP_IDS[index]
+ body?.removeAllViews()
+
+ when (id) {
+ "accessibility", "overlay", "voice_key" -> {
+ // SelfCheck rows: show the finding.
+ val f = findings?.firstOrNull { it.id == id }
+ if (f != null) {
+ body?.addView(stepTitle(index))
+ body?.addView(findingCard(f))
+ }
+ }
+ "wake" -> {
+ body?.addView(stepTitle(index))
+ body?.addView(instructionCard(
+ lctx.getString(R.string.wizard_wake_body),
+ lctx.getString(R.string.wizard_wake_button),
+ ) {
+ onOpenWakeEnroll?.invoke()
+ })
+ }
+ "look" -> {
+ body?.addView(stepTitle(index))
+ body?.addView(instructionCard(
+ lctx.getString(R.string.wizard_look_body),
+ lctx.getString(R.string.wizard_look_button),
+ ) {
+ onOpenLook?.invoke()
+ })
+ }
+ "first_sentence" -> {
+ body?.addView(stepTitle(index))
+ body?.addView(instructionCard(
+ lctx.getString(R.string.wizard_sentence_body),
+ lctx.getString(R.string.wizard_sentence_button),
+ ) {
+ onOpenMic?.invoke()
+ })
+ }
+ }
+ }
+
+ /** The final card: you're done. */
+ private fun renderComplete() {
+ stepIndex = STEP_IDS.size
+ body?.removeAllViews()
+ body?.addView(heroText(
+ lctx.getString(R.string.wizard_complete_title),
+ lctx.getString(R.string.wizard_complete_body),
+ ))
+ }
+
+ private fun advance() {
+ if (stepIndex == -1) {
+ // Welcome → step 0: load findings first.
+ probe { renderStep(0) }
+ } else if (stepIndex < STEP_IDS.size - 1) {
+ renderStep(stepIndex + 1)
+ } else {
+ renderComplete()
+ }
+ }
+
+ private fun retreat() {
+ if (stepIndex == 0) {
+ renderWelcome()
+ } else if (stepIndex > 0) {
+ renderStep(stepIndex - 1)
+ }
+ }
+
+ private fun probe(then: () -> Unit) {
+ val app = context.applicationContext
+ prober.execute {
+ val found = runCatching { SelfCheck.run(app) }.getOrNull() ?: return@execute
+ main.post {
+ if (root == null) return@post
+ findings = found
+ then()
+ }
+ }
+ }
+
+ // ---- Language ----
+
+ private fun onLanguageChanged() {
+ repaintForLanguage()
+ onLocaleChanged()
+ }
+
+ fun repaintForLanguage() {
+ if (root == null) return
+ lctx = AppLocale.wrap(context)
+ rebuild()
+ }
+
+ private fun rebuild() {
+ val old = root ?: return
+ val stage = host
+ if (stage != null) {
+ val v = build()
+ val i = stage.indexOfChild(old)
+ runCatching { stage.removeView(old) }
+ if (i >= 0) stage.addView(v, i, old.layoutParams) else stage.addView(v, old.layoutParams)
+ root = v
+ repaintCurrentStep()
+ return
+ }
+ val wm = wm ?: return
+ Glass.fadeOut(old) {
+ if (root !== old) return@fadeOut
+ val v = build()
+ runCatching {
+ v.hideFromAccessibility()
+ val p = old.layoutParams as WindowManager.LayoutParams
+ wm.removeView(old)
+ wm.addView(v, p)
+ root = v
+ Glass.fadeIn(v)
+ repaintCurrentStep()
+ }
+ }
+ }
+
+ private fun repaintCurrentStep() {
+ when (stepIndex) {
+ -1 -> renderWelcome()
+ in 0 until STEP_IDS.size -> renderStep(stepIndex)
+ else -> renderComplete()
+ }
+ }
+
+ // ---- Build ----
+
+ private fun build(): View {
+ val card = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ background = Glass.card(context, dp(CARD_RADIUS_DP), frosted)
+ clipToOutline = true
+ }
+
+ card.addView(header(), matchWrap())
+
+ val scroll = ScrollView(context).apply {
+ isFillViewport = true
+ isVerticalScrollBarEnabled = false
+ }
+ body = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ setPadding(dp(24), dp(4), dp(24), dp(24))
+ }
+ scroll.addView(body, matchWrap())
+ card.addView(scroll, LinearLayout.LayoutParams(MATCH, 0, 1f))
+
+ card.addView(footer(), matchWrap())
+ return card
+ }
+
+ private fun header(): View {
+ val row = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ setPadding(dp(28), dp(22), dp(18), dp(14))
+ }
+ val titles = LinearLayout(context).apply { orientation = LinearLayout.VERTICAL }
+ titles.addView(TextView(context).apply {
+ text = lctx.getString(R.string.wizard_title)
+ textSize = Glass.Type.DISPLAY
+ setTextColor(Color.parseColor(Glass.TITLE))
+ letterSpacing = 0.01f
+ })
+ titles.addView(TextView(context).apply {
+ text = progressLabel()
+ textSize = Glass.Type.CAPTION
+ setTextColor(Color.parseColor(Glass.MUTED))
+ setPadding(0, dp(4), 0, 0)
+ })
+ row.addView(titles, LinearLayout.LayoutParams(0, WRAP, 1f))
+ row.addView(
+ LangToggle(context) { onLanguageChanged() },
+ LinearLayout.LayoutParams(WRAP, WRAP).apply { marginEnd = dp(12) },
+ )
+ row.addView(closeButton(), LinearLayout.LayoutParams(dp(36), dp(36)))
+ return row
+ }
+
+ private fun progressLabel(): String = when (stepIndex) {
+ -1 -> lctx.getString(R.string.wizard_progress_welcome)
+ in 0 until STEP_IDS.size -> lctx.getString(
+ R.string.wizard_progress_step,
+ stepIndex + 1,
+ STEP_IDS.size,
+ )
+ else -> lctx.getString(R.string.wizard_progress_done)
+ }
+
+ private fun closeButton(): View = TextView(context).apply {
+ text = "✕"
+ textSize = Glass.Type.BODY
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ gravity = Gravity.CENTER
+ background = Glass.panel(context, dp(18))
+ isClickable = true
+ isFocusable = true
+ Glass.pressable(this)
+ contentDescription = lctx.getString(R.string.wizard_cancel)
+ setOnClickListener { hide() }
+ }
+
+ private fun footer(): View {
+ val row = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ setPadding(dp(18), dp(10), dp(18), dp(18))
+ }
+
+ val leftLabel = when (stepIndex) {
+ -1 -> lctx.getString(R.string.wizard_cancel)
+ in 0 until STEP_IDS.size -> lctx.getString(R.string.wizard_back)
+ else -> null
+ }
+ if (leftLabel != null) {
+ row.addView(
+ textButton(leftLabel, Glass.SECONDARY) {
+ if (stepIndex == -1) hide() else retreat()
+ },
+ LinearLayout.LayoutParams(0, WRAP, 1f),
+ )
+ } else {
+ row.addView(View(context), LinearLayout.LayoutParams(0, WRAP, 1f))
+ }
+
+ val rightLabel = when (stepIndex) {
+ -1 -> lctx.getString(R.string.wizard_begin)
+ in 0 until STEP_IDS.size - 1 -> lctx.getString(R.string.wizard_next)
+ STEP_IDS.size - 1 -> lctx.getString(R.string.wizard_finish)
+ else -> lctx.getString(R.string.wizard_done)
+ }
+ row.addView(button(rightLabel, filled = true) {
+ if (stepIndex == STEP_IDS.size) {
+ onComplete()
+ hide()
+ } else {
+ advance()
+ }
+ })
+ return row
+ }
+
+ private fun textButton(label: String, tint: String, onClick: () -> Unit): TextView =
+ TextView(context).apply {
+ text = label
+ textSize = Glass.Type.BODY
+ setTextColor(Color.parseColor(tint))
+ gravity = Gravity.START or Gravity.CENTER_VERTICAL
+ setPadding(dp(4), dp(13), dp(4), dp(13))
+ isClickable = true
+ isFocusable = true
+ Glass.pressable(this)
+ setOnClickListener { onClick() }
+ }
+
+ private fun button(label: String, filled: Boolean, onClick: () -> Unit): TextView {
+ val radius = dp(24)
+ return TextView(context).apply {
+ text = label
+ textSize = Glass.Type.BODY
+ setTextColor(Color.parseColor(if (filled) Glass.TITLE else Glass.LABEL))
+ gravity = Gravity.CENTER
+ background =
+ if (filled) Glass.tinted(context, radius) else Glass.panel(context, radius)
+ setPadding(dp(26), dp(13), dp(26), dp(13))
+ isClickable = true
+ isFocusable = true
+ Glass.pressable(this)
+ setOnClickListener { onClick() }
+ }
+ }
+
+ // ---- Step parts ----
+
+ private fun heroText(title: String, body: String): View {
+ val card = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ setPadding(0, dp(20), 0, 0)
+ }
+ card.addView(TextView(context).apply {
+ text = title
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.HEADLINE)
+ setTypeface(typeface, Typeface.BOLD)
+ setTextColor(Color.parseColor(Glass.TITLE))
+ gravity = Gravity.CENTER
+ })
+ card.addView(TextView(context).apply {
+ text = body
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ gravity = Gravity.CENTER
+ setPadding(dp(12), dp(12), dp(12), 0)
+ })
+ return card
+ }
+
+ private fun stepTitle(index: Int): View = TextView(context).apply {
+ val id = STEP_IDS.getOrNull(index) ?: ""
+ text = when (id) {
+ "accessibility" -> lctx.getString(R.string.check_title_accessibility)
+ "overlay" -> lctx.getString(R.string.check_title_overlay)
+ "voice_key" -> lctx.getString(R.string.check_title_voice_key)
+ "wake" -> lctx.getString(R.string.wizard_wake_title)
+ "look" -> lctx.getString(R.string.wizard_look_title)
+ "first_sentence" -> lctx.getString(R.string.wizard_sentence_title)
+ else -> ""
+ }
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.HEADLINE)
+ setTypeface(typeface, Typeface.BOLD)
+ setTextColor(Color.parseColor(Glass.TITLE))
+ setPadding(0, dp(8), 0, dp(12))
+ }
+
+ private fun findingCard(f: SelfCheck.Finding): View {
+ val card = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ background = Glass.panel(context, dp(14))
+ setPadding(dp(14), dp(14), dp(14), dp(14))
+ }
+ card.addView(TextView(context).apply {
+ text = AppLocale.str(context, f.detail, *f.detailArgs.toTypedArray())
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
+ })
+ fixButton(f)?.let {
+ card.addView(it.apply {
+ val lp = layoutParams as? LinearLayout.LayoutParams
+ lp?.topMargin = dp(10)
+ layoutParams = lp
+ })
+ }
+ return card
+ }
+
+ private fun instructionCard(body: String, buttonLabel: String, onClick: () -> Unit): View {
+ val card = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ background = Glass.panel(context, dp(14))
+ setPadding(dp(14), dp(14), dp(14), dp(14))
+ }
+ card.addView(TextView(context).apply {
+ text = body
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
+ })
+ card.addView(button(buttonLabel, filled = false, onClick).apply {
+ val lp = LinearLayout.LayoutParams(WRAP, WRAP).apply { topMargin = dp(10) }
+ layoutParams = lp
+ })
+ return card
+ }
+
+ /**
+ * The way out for a step that is a [SelfCheck] row, or nothing when there is
+ * not one.
+ *
+ * The [SelfCheck.Fix.OurSettings] guard is the same rule [SelfCheckUi] uses:
+ * our sheet is an overlay the service owns, so with the service not there to
+ * raise it the row must not offer a button that would do nothing. The wizard
+ * is only ever raised by the service today, so this is currently unreachable
+ * — it is here because the row and the button would otherwise be able to
+ * disagree the day a host without overlays raises this card.
+ */
+ private fun fixButton(f: SelfCheck.Finding): View? {
+ if (f.fix is SelfCheck.Fix.OurSettings && onOpenSettings == null) return null
+ val label = when (val fix = f.fix) {
+ is SelfCheck.Fix.Screen ->
+ if (fix.label != 0) fix.label else R.string.check_fix_settings
+ is SelfCheck.Fix.Link -> R.string.check_fix_download
+ is SelfCheck.Fix.Grant -> R.string.check_fix_allow
+ is SelfCheck.Fix.OurSettings -> R.string.check_fix_app_settings
+ else -> return null
+ }
+ return button(lctx.getString(label), filled = false) { apply(f) }
+ }
+
+ // ---- Doors ----
+
+ /**
+ * Every fix is a `startActivity`, exactly as [SelfCheckUi.apply] — and the
+ * yield matters here for the same reason it does there: this card is a
+ * fullscreen `TYPE_APPLICATION_OVERLAY` in the window host, so the system
+ * Settings page it opens comes up *behind* it unless we get out of the way.
+ *
+ * [SelfCheck.Fix.OurSettings] is the one exception: our own sheet is
+ * supposed to come up over this card so the wizard is still behind it to
+ * return to. And it is the one door that can be missing — see
+ * [onOpenSettings] — in which case the row gets no button at all rather
+ * than a button that does nothing.
+ */
+ private fun apply(f: SelfCheck.Finding) {
+ val fix = f.fix
+ if (fix !is SelfCheck.Fix.OurSettings) {
+ if (!openable(fix)) {
+ toastNoScreen()
+ return
+ }
+ onYieldScreen()
+ }
+ when (fix) {
+ is SelfCheck.Fix.Screen, is SelfCheck.Fix.Link -> launch(intentFor(fix))
+ is SelfCheck.Fix.Grant -> launch(
+ Intent(context, PermissionRequestActivity::class.java)
+ .putExtra("permissions", fix.permissions.toTypedArray())
+ )
+ is SelfCheck.Fix.OurSettings -> onOpenSettings?.invoke()
+ is SelfCheck.Fix.Adb, SelfCheck.Fix.Nothing -> Unit
+ }
+ }
+
+ private fun openable(fix: SelfCheck.Fix): Boolean = when (fix) {
+ is SelfCheck.Fix.Screen, is SelfCheck.Fix.Link ->
+ runCatching {
+ context.packageManager
+ .queryIntentActivities(intentFor(fix), 0)
+ .isNotEmpty()
+ }.getOrDefault(true)
+ else -> true
+ }
+
+ private fun intentFor(fix: SelfCheck.Fix): Intent = when (fix) {
+ is SelfCheck.Fix.Screen -> Intent(fix.action).apply {
+ fix.data?.let { data = Uri.parse(it) }
+ fix.extras.forEach { (name, value) -> putExtra(name, value) }
+ }
+ is SelfCheck.Fix.Link -> Intent(Intent.ACTION_VIEW, Uri.parse(fix.url))
+ else -> Intent()
+ }
+
+ private fun toastNoScreen() {
+ runCatching {
+ Toast.makeText(context, lctx.getString(R.string.check_fix_no_screen), Toast.LENGTH_LONG)
+ .show()
+ }
+ }
+
+ private fun launch(intent: Intent) {
+ if (host == null) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ val ok = runCatching { context.startActivity(intent) }.onFailure {
+ Log.w(TAG, "wizard: no activity for ${intent.action}", it)
+ }.isSuccess
+ if (!ok) toastNoScreen()
+ }
+
+ // ---- Helpers ----
+
+ private fun matchWrap() = LinearLayout.LayoutParams(MATCH, WRAP)
+
+ private fun dp(v: Int): Int = Glass.dp(context, v)
+
+ private fun cardWidth(): Int {
+ val screen = screenW()
+ return minOf(screen - dp(2 * GUTTER_DP), (screen * 0.98f).toInt())
+ }
+
+ private fun cardHeight(): Int {
+ val screen = screenH()
+ return minOf(screen - dp(2 * GUTTER_DP), (screen * 0.96f).toInt())
+ }
+
+ private fun screenW(): Int = wm?.currentWindowMetrics?.bounds?.width()
+ ?: context.resources.displayMetrics.widthPixels
+
+ private fun screenH(): Int = wm?.currentWindowMetrics?.bounds?.height()
+ ?: context.resources.displayMetrics.heightPixels
+}
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 09e3053..47c8d8c 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
@@ -3,16 +3,13 @@ package net.kuafuai.andee.ui
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Context
-import android.graphics.Canvas
import android.graphics.Color
-import android.graphics.Paint
import android.graphics.PixelFormat
-import android.graphics.Rect
import android.graphics.drawable.ColorDrawable
import android.os.Handler
import android.os.Looper
-import android.util.TypedValue
import android.view.Gravity
+import android.view.HapticFeedbackConstants
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
@@ -23,6 +20,9 @@ import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
+import androidx.annotation.DrawableRes
+import androidx.annotation.StringRes
+import androidx.core.content.ContextCompat
import net.kuafuai.andee.R
import net.kuafuai.andee.audio.Earcon
import net.kuafuai.andee.config.VoiceConfig
@@ -121,15 +121,18 @@ class FloatingWindowUi(
enum class SubtitleKind { PARTIAL, FINAL }
/** Screen tools shown as a row of small buttons in the top-right corner. */
- enum class Tool(val glyph: String) {
- SWIPE_UP("↑"),
- SWIPE_DOWN("↓"),
- SWIPE_LEFT("←"),
- SWIPE_RIGHT("→"),
- BACK("⌫"),
- HOME("⌂"),
- UI_TREE("☰"),
- SCREENSHOT("◉"),
+ enum class Tool(
+ @param:DrawableRes val icon: Int,
+ @param:StringRes val label: Int,
+ ) {
+ SWIPE_UP(R.drawable.ic_swipe_up, R.string.tool_swipe_up),
+ SWIPE_DOWN(R.drawable.ic_swipe_down, R.string.tool_swipe_down),
+ SWIPE_LEFT(R.drawable.ic_swipe_left, R.string.tool_swipe_left),
+ SWIPE_RIGHT(R.drawable.ic_swipe_right, R.string.tool_swipe_right),
+ BACK(R.drawable.ic_back, R.string.tool_back),
+ HOME(R.drawable.ic_home, R.string.tool_home),
+ UI_TREE(R.drawable.ic_tree, R.string.tool_ui_tree),
+ SCREENSHOT(R.drawable.ic_screenshot, R.string.tool_screenshot),
}
interface Listeners {
@@ -728,6 +731,17 @@ class FloatingWindowUi(
// gets none — it announces itself — and errors get none either, now
// that they arrive as a card. See [Earcon].
if (s != lastState) {
+ // A haptic for the hand that just touched the ball. Through the
+ // view, not a Vibrator: no permission, it honours the system's
+ // touch-feedback switch, and — unlike a tone — it cannot take
+ // audio focus from a meeting or a call.
+ val haptic = when {
+ s == State.RECORDING -> HapticFeedbackConstants.CONFIRM
+ lastState == State.RECORDING -> HapticFeedbackConstants.GESTURE_END
+ s == State.ERROR -> HapticFeedbackConstants.REJECT
+ else -> null
+ }
+ if (haptic != null) root?.performHapticFeedback(haptic)
when (s) {
State.RECORDING -> {
ball?.trigger(Action.NOD)
@@ -2000,7 +2014,7 @@ class FloatingWindowUi(
// tips have nowhere to be; the gestures they describe work there anyway.
val tips = TextView(context).apply {
text = AppLocale.str(context, R.string.window_tips)
- textSize = 12f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.SECONDARY))
gravity = Gravity.CENTER
// The bottom padding clears the gesture bar, the same 30 dp the
@@ -2103,27 +2117,22 @@ class FloatingWindowUi(
toolsView = tools
keys.addView(
- barButton("⋯", Glass.LABEL, 20f) {
+ barButton(R.drawable.ic_more, Glass.LABEL, "更多工具") {
tools.visibility = if (tools.visibility == View.VISIBLE) View.GONE else View.VISIBLE
}
)
// ✓ and not ■: the stop button used to sit here, and stop is the one
// action in this bar the ball can already perform — see onStopClick.
- // A check mark for 自检, and it is a glyph rather than an icon set for
- // the same reason as the rest of the bar: one Paint, one font, and it
- // inherits the ink-centred drawing in GlyphButton.
- keys.addView(barButton("✓", Glass.LABEL, 17f, label = "自检") { listeners.onSelfCheckClick() })
+ keys.addView(barButton(R.drawable.ic_check, Glass.LABEL, "自检") { listeners.onSelfCheckClick() })
// No ⌨ here. Typing moved onto the ball's double-tap, and the bar is
// the wrong place for it twice over: it only exists while the card is
// unfolded (so the way to type vanished with the fold — the same fault
// that made "点右上角的 ⌨" a lie in a failure message), and it put a
// second meaning on the one control the user already had to learn.
- keys.addView(barButton("⚙", Glass.LABEL, 18f) { listeners.onSettingsClick() })
+ keys.addView(barButton(R.drawable.ic_settings, Glass.LABEL, "设置") { listeners.onSettingsClick() })
// Reads as close, not as resize: the card is a thing you dismiss, and the
- // corner ball it folds into stays on screen either way. It used to sit
- // alone in the bottom-right of the subtitle band, diagonally opposite
- // every other control in the card.
- keys.addView(barButton("✕", Glass.LABEL, 17f) { listeners.onMinimizeClick() })
+ // corner ball it folds into stays on screen either way.
+ keys.addView(barButton(R.drawable.ic_close, Glass.LABEL, "收起") { listeners.onMinimizeClick() })
bar.addView(keys)
bar.addView(tools)
@@ -2131,57 +2140,41 @@ class FloatingWindowUi(
}
/**
- * A glyph centred on the ink it actually draws, rather than on the line box
- * its font reserves.
- *
- * `TextView` with `gravity = CENTER` centres the *line* — ascent to descent,
- * the same box for every character in the font. These glyphs come from all
- * over Unicode (`⋯` hangs at the baseline, `■` is a full-height block, `⚙`
- * and the arrows sit somewhere else again), so a row of them centred that way
- * is a row of characters at four different heights, which is what the bar
- * looked like. Measuring each glyph's own bounds and centring on that is the
- * only way they line up, and it costs one [Paint.getTextBounds] at build time.
+ * One of the four permanent keys: a vector icon, tinted, centred in a 36 dp
+ * square with 6 dp of air on each side.
+ *
+ * These were Unicode glyphs (`⋯ ✓ ⚙ ✕`) drawn by a custom View that measured
+ * each character's ink to centre it. That worked around one problem — every
+ * glyph sits at a different height in its font's line box — and could not
+ * work around the other: the weight, size and shape of `⚙` is whatever the
+ * ROM's font says it is, so the bar looked different on every tablet and
+ * never quite matched itself. Vectors are drawn the same everywhere.
+ *
+ * `mutate()` before `setTint`, because drawables from one resource share
+ * constant state and this bar is rebuilt with the card.
+ *
+ * A bare View draws an image without telling anyone it is there, so the
+ * description is not optional: without it the whole control bar drops out
+ * of `get_screen_element` and out of TalkBack alike. Deliberately not
+ * localised — rebuilding the bar on a language change for four content
+ * descriptions nobody reads is the wrong trade.
*/
- private class GlyphButton(
- ctx: Context,
- private val glyph: String,
+ private fun barButton(
+ @DrawableRes icon: Int,
color: String,
- sizeSp: Float,
- ) : View(ctx) {
- private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
- this.color = Color.parseColor(color)
- textSize = TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_SP, sizeSp, ctx.resources.displayMetrics,
- )
- }
- private val ink = Rect()
-
- init {
- paint.getTextBounds(glyph, 0, glyph.length, ink)
- // A bare View draws text without ever telling anyone it is there, so
- // the whole control bar dropped out of `get_screen_element` the moment these
- // stopped being TextViews — invisible to the brain and to TalkBack
- // alike. The glyph is the label it had as a TextView; keep it one.
- //
- // Set by the caller when the glyph is not a word in any language:
- // `⋯` and `■` are punctuation, and TalkBack reading "✓" out as
- // "check mark" beside a button that opens the self-check page is a
- // worse label than the two characters the page is called by.
- contentDescription = glyph
- }
-
- override fun onDraw(canvas: Canvas) {
- canvas.drawText(
- glyph,
- width / 2f - ink.exactCenterX(),
- height / 2f - ink.exactCenterY(),
- paint,
+ description: String,
+ onClick: () -> Unit,
+ ): View {
+ val pad = dp(6)
+ return ImageView(context).apply {
+ setImageDrawable(
+ ContextCompat.getDrawable(context, icon)?.mutate()?.apply {
+ setTint(Color.parseColor(color))
+ }
)
- }
- }
-
- private fun barButton(glyph: String, color: String, size: Float, onClick: () -> Unit): View =
- GlyphButton(context, glyph, color, size).apply {
+ scaleType = ImageView.ScaleType.FIT_CENTER
+ setPadding(pad, pad, pad, pad)
+ contentDescription = description
isClickable = true
isFocusable = true
Glass.pressable(this)
@@ -2190,23 +2183,6 @@ class FloatingWindowUi(
leftMargin = dp(2)
}
}
-
- /**
- * The same button, with a spoken name for a glyph that is not one.
- *
- * Deliberately not localised. "自检" is the name of this page in the one
- * language it has a name in, and the alternative — a `@StringRes` picked by
- * [AppLocale] — would mean rebuilding the whole control bar on a language
- * change for one content description nobody reads.
- */
- private fun barButton(
- glyph: String,
- color: String,
- size: Float,
- label: String,
- onClick: () -> Unit,
- ): View = (barButton(glyph, color, size, onClick) as GlyphButton).apply {
- contentDescription = label
}
// ---- Tap / drag / long-press on the ball ----
@@ -2269,9 +2245,13 @@ class FloatingWindowUi(
ui.removeCallbacks(tapRunnable)
if (tapCount >= TAPS_FOR_STOP) {
tapCount = 0
+ performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
listeners.onStopClick()
return
}
+ // Felt on the touch, not ~300 ms later when the run resolves: the
+ // multi-tap wait is otherwise a tap that seemed not to land.
+ performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
ui.postDelayed(tapRunnable, multiTapMs)
}
@@ -2312,6 +2292,7 @@ class FloatingWindowUi(
private val longPressRunnable = Runnable {
if (tracking && !moved) {
longPressed = true
+ performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
listeners.onLongPress()
}
}
@@ -2466,18 +2447,54 @@ class FloatingWindowUi(
// ---- Colors / units ----
+ /**
+ * One tool in the `⋯` drawer: its icon, then its name.
+ *
+ * The name is new and it is the point. These were eight unlabelled
+ * monochrome glyphs — `↑ ↓ ← → ⌫ ⌂ ☰ ◉` — behind a `⋯`, which meant the
+ * drawer was a row of symbols a user had to decode by tapping, and the two
+ * that are also Android idioms (`⌂` home, `⌫` back) are not the two whose
+ * meaning is obvious from the others. A word beside each costs the row its
+ * compactness and buys the whole drawer its legibility; the labels are
+ * localised, unlike the glyphs they replace.
+ */
private fun buildToolButton(tool: Tool): View {
// Dimmer than the four permanent keys on purpose: these are developer
- // instruments hidden behind `⋯`, and they sat at the same weight as ■
- // and ⚙ when they were all one colour.
- return GlyphButton(context, tool.glyph, Glass.SECONDARY, 15f).apply {
+ // instruments hidden behind `⋯`, and they sat at the same weight as the
+ // permanent keys when they were all one colour.
+ val tint = Color.parseColor(Glass.SECONDARY)
+ val icon = ContextCompat.getDrawable(context, tool.icon)?.mutate()?.apply { setTint(tint) }
+ return LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ setPadding(dp(6), 0, dp(6), 0)
isClickable = true
isFocusable = true
+ background = Glass.well(context, dp(14))
+ contentDescription = AppLocale.str(context, tool.label)
Glass.pressable(this)
setOnClickListener { listeners.onToolClick(tool) }
- layoutParams = LinearLayout.LayoutParams(dp(32), dp(36)).apply {
- leftMargin = dp(1)
- }
+
+ addView(
+ View(context).apply {
+ background = icon
+ layoutParams = LinearLayout.LayoutParams(dp(16), dp(16))
+ }
+ )
+ addView(
+ TextView(context).apply {
+ text = AppLocale.str(context, tool.label)
+ textSize = Glass.Type.MICRO
+ setTextColor(tint)
+ setPadding(dp(4), 0, 0, 0)
+ includeFontPadding = false
+ }
+ )
+
+ layoutParams = LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ dp(32),
+ ).apply { leftMargin = dp(4) }
}
}
diff --git a/app/src/main/java/net/kuafuai/andee/ui/Glass.kt b/app/src/main/java/net/kuafuai/andee/ui/Glass.kt
index f49e32e..b433815 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/Glass.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/Glass.kt
@@ -150,6 +150,45 @@ object Glass {
const val DANGER = "#FF6B6B"
+ /** Done, granted, reachable — the self-check's green and nothing else's. */
+ const val OK = "#4ADE80"
+
+ /** Works, but degrades silently. */
+ const val WARN = "#FBBF24"
+
+ // ---- Type ----
+
+ /**
+ * The only text sizes a card may use, in sp.
+ *
+ * The cards grew sixteen different sizes between them — 9.5, 10, 11, 11.5,
+ * 12, 12.5, 13, 14, 14.5, 15, 16, 17, 19, 20, 26 — each a reasonable local
+ * choice and together the reason the surfaces read as assembled rather
+ * than designed: a 14 beside a 14.5 is not a hierarchy, it is a rounding
+ * error the eye notices without being able to name. Six steps, each far
+ * enough from its neighbours to mean something. A new size is a new rung
+ * here, not a literal at the call site.
+ */
+ object Type {
+ /** A card's own title. */
+ const val DISPLAY = 26f
+
+ /** The title of a card stacked on another card, or of a step. */
+ const val HEADLINE = 20f
+
+ /** A dialog's title, a row that is the point of its panel. */
+ const val TITLE = 17f
+
+ /** What the user reads: rows, fields, buttons, answers. */
+ const val BODY = 15f
+
+ /** What explains the body: subtitles, notes, section heads, hints. */
+ const val CAPTION = 13f
+
+ /** Timestamps, badges, the pinned gesture tips. */
+ const val MICRO = 11f
+ }
+
// ---- Motion ----
/** Fast out of the gate, long tail. The house easing. */
@@ -462,9 +501,15 @@ object Glass {
android.view.MotionEvent.ACTION_UP,
android.view.MotionEvent.ACTION_CANCEL,
- ->
+ -> {
+ // On UP only: a scroll that began on a button arrives as
+ // CANCEL, and ticking for it would buzz through every list.
+ if (ev.actionMasked == android.view.MotionEvent.ACTION_UP) {
+ view.performHapticFeedback(android.view.HapticFeedbackConstants.VIRTUAL_KEY)
+ }
view.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(200).setInterpolator(OvershootInterpolator(2f)).start()
+ }
}
false
}
diff --git a/app/src/main/java/net/kuafuai/andee/ui/HistoryListView.kt b/app/src/main/java/net/kuafuai/andee/ui/HistoryListView.kt
index 37bbbc5..705e205 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/HistoryListView.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/HistoryListView.kt
@@ -104,7 +104,7 @@ class HistoryListView(private val context: Context) : ScrollView(context) {
private val empty = TextView(context).apply {
text = lctx.getString(R.string.history_empty)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.MUTED))
gravity = Gravity.CENTER
setPadding(0, dp(28), 0, 0)
@@ -120,7 +120,7 @@ class HistoryListView(private val context: Context) : ScrollView(context) {
* settle *behind* the live line, which is by definition still in progress.
*/
private val live = TextView(context).apply {
- textSize = 15f
+ textSize = Glass.Type.BODY
visibility = View.GONE
setPadding(dp(4), dp(8), dp(4), dp(2))
maxLines = 4
@@ -277,7 +277,7 @@ class HistoryListView(private val context: Context) : ScrollView(context) {
lctx.getString(R.string.history_role_page_cleared, clock.format(Date(e.ts)))
}
}
- textSize = 10f
+ textSize = Glass.Type.MICRO
letterSpacing = 0.05f
setTextColor(
when (e.role) {
@@ -294,7 +294,7 @@ class HistoryListView(private val context: Context) : ScrollView(context) {
val body = TextView(context).apply {
text = e.text
- textSize = 14f
+ textSize = Glass.Type.BODY
setLineSpacing(dp(3).toFloat(), 1f)
setTextColor(Color.parseColor(if (bad) Glass.DANGER else Glass.LABEL))
setPadding(0, dp(3), 0, 0)
diff --git a/app/src/main/java/net/kuafuai/andee/ui/LangToggle.kt b/app/src/main/java/net/kuafuai/andee/ui/LangToggle.kt
index 5f8b3be..5536b77 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/LangToggle.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/LangToggle.kt
@@ -90,7 +90,7 @@ class LangToggle(
OPTIONS.forEach { (tag, label) ->
val cell = TextView(context).apply {
text = label
- textSize = 14f
+ textSize = Glass.Type.BODY
setTypeface(typeface, Typeface.BOLD)
gravity = Gravity.CENTER
minWidth = context.dpI(CELL_MIN_W_DP)
diff --git a/app/src/main/java/net/kuafuai/andee/ui/NotebookUi.kt b/app/src/main/java/net/kuafuai/andee/ui/NotebookUi.kt
new file mode 100644
index 0000000..67e7e1b
--- /dev/null
+++ b/app/src/main/java/net/kuafuai/andee/ui/NotebookUi.kt
@@ -0,0 +1,423 @@
+package net.kuafuai.andee.ui
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.graphics.Color
+import android.graphics.PixelFormat
+import android.text.format.DateUtils
+import android.view.Gravity
+import android.view.View
+import android.view.WindowManager
+import android.widget.LinearLayout
+import android.widget.ScrollView
+import android.widget.TextView
+import net.kuafuai.andee.R
+import net.kuafuai.andee.config.Notebook
+import net.kuafuai.andee.config.Scheduler
+import net.kuafuai.andee.i18n.AppLocale
+import java.text.SimpleDateFormat
+import java.util.Locale
+
+/**
+ * 它记得的事: what the device remembers, browsable and deletable per item.
+ *
+ * [Notebook.dumpText] is the other view into the book, and it is
+ * export-shaped — every field, as text, for copying out. This page answers a
+ * different question: "what is it allowed to remember about me".
+ *
+ * **记忆** groups [Notebook.Memory] by type, most important first within each.
+ * **待办** lists active and paused [Notebook.Todo]s, soonest first.
+ *
+ * No editing: the brain writes these, not the person. Delete is the only
+ * mutation, and it is **destructive** — gone from the encrypted blob, not
+ * archived — because a delete that merely hides something does not answer the
+ * question this page exists for.
+ *
+ * Same window shape as [VaultUi], its sibling on top of the settings card:
+ * focusable, hidden from accessibility, counted by [OwnCard] — a focused
+ * window that dumps as zero nodes is exactly what [OwnCard] explains.
+ */
+class NotebookUi(
+ private val context: Context,
+ private val onDismiss: () -> Unit = {},
+) {
+
+ private val wm: WindowManager =
+ context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
+
+ private var root: View? = null
+
+ /** 0 = memories, 1 = todos. */
+ private var tab = 0
+
+ /** Whether the compositor agreed to blur. See [Glass.frost]. */
+ private var frosted = false
+
+ /**
+ * Strings in the user's language, refreshed at the top of [build].
+ *
+ * Refreshed there and not in [show] on purpose: [rebuild] goes straight to
+ * [build] without passing through [show], so rewrapping in the one function
+ * that consumes it means no future caller has to remember to do it.
+ *
+ * Views are still built on [context]; only text comes from here. See
+ * [AppLocale] for why those two are deliberately different Contexts.
+ */
+ private var lctx: Context = context
+
+ fun show() {
+ if (root != null) return
+ val p = WindowManager.LayoutParams(
+ cardWidth(), cardHeight(),
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
+ 0,
+ PixelFormat.TRANSLUCENT,
+ ).apply {
+ gravity = Gravity.CENTER
+ }
+ frosted = Glass.frost(context, wm, p)
+ val v = build()
+ runCatching {
+ v.hideFromAccessibility()
+ wm.addView(v, p)
+ root = v
+ OwnCard.shown()
+ Glass.enter(v)
+ }
+ }
+
+ fun hide() {
+ val v = root ?: return
+ root = null
+ Glass.exit(v) {
+ runCatching { wm.removeView(v) }
+ OwnCard.hidden()
+ onDismiss()
+ }
+ }
+
+ private fun rebuild() {
+ val old = root ?: return
+ val v = build()
+ runCatching {
+ v.hideFromAccessibility()
+ val p = old.layoutParams as WindowManager.LayoutParams
+ wm.removeView(old)
+ wm.addView(v, p)
+ root = v
+ Glass.fadeIn(v)
+ }
+ }
+
+ private fun cardWidth(): Int =
+ minOf(dp(560), (wm.currentWindowMetrics.bounds.width() * 0.96f).toInt())
+
+ private fun cardHeight(): Int =
+ minOf(dp(720), (wm.currentWindowMetrics.bounds.height() * 0.90f).toInt())
+
+ // ---- build ----
+
+ @SuppressLint("SetTextI18n")
+ private fun build(): View {
+ lctx = AppLocale.wrap(context)
+ val card = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ background = Glass.card(context, dp(28), frosted)
+ clipToOutline = true
+ }
+
+ card.addView(header(), matchWrap())
+ divider(card)
+ card.addView(tabBar(), matchWrap())
+
+ val scroll = ScrollView(context)
+ val body = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ setPadding(dp(20), dp(16), dp(20), dp(16))
+ }
+ if (tab == 0) buildMemories(body) else buildTodos(body)
+ scroll.addView(body, matchWrap())
+ card.addView(scroll, LinearLayout.LayoutParams(MATCH, 0, 1f))
+
+ return card
+ }
+
+ private fun header(): LinearLayout {
+ val h = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ setPadding(dp(22), dp(18), dp(14), dp(12))
+ }
+ h.addView(
+ TextView(context).apply {
+ text = lctx.getString(R.string.notebook_title)
+ textSize = Glass.Type.HEADLINE
+ setTextColor(Color.parseColor(Glass.TITLE))
+ },
+ LinearLayout.LayoutParams(0, WRAP, 1f),
+ )
+ h.addView(closeButton())
+ return h
+ }
+
+ private fun closeButton(): TextView = TextView(context).apply {
+ text = "✕"
+ textSize = Glass.Type.CAPTION
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ gravity = Gravity.CENTER
+ background = Glass.panel(context, dp(16))
+ isClickable = true
+ Glass.pressable(this)
+ setOnClickListener { hide() }
+ layoutParams = LinearLayout.LayoutParams(dp(32), dp(32))
+ }
+
+ private fun tabBar(): LinearLayout {
+ val bar = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ setPadding(dp(8), dp(8), dp(8), dp(8))
+ }
+ bar.addView(tabButton(0, lctx.getString(R.string.notebook_tab_memories)))
+ bar.addView(View(context).apply {
+ layoutParams = LinearLayout.LayoutParams(dp(8), 1)
+ })
+ bar.addView(tabButton(1, lctx.getString(R.string.notebook_tab_todos)))
+ return bar
+ }
+
+ private fun tabButton(index: Int, label: String): TextView =
+ TextView(context).apply {
+ text = label
+ textSize = Glass.Type.BODY
+ gravity = Gravity.CENTER
+ setPadding(dp(16), dp(10), dp(16), dp(10))
+ val active = tab == index
+ setTextColor(
+ Color.parseColor(if (active) Glass.TITLE else Glass.SECONDARY),
+ )
+ background = if (active) {
+ Glass.panel(context, dp(12))
+ } else {
+ null
+ }
+ isClickable = !active
+ if (!active) {
+ Glass.pressable(this)
+ setOnClickListener { tab = index; rebuild() }
+ }
+ layoutParams = LinearLayout.LayoutParams(0, WRAP, 1f)
+ }
+
+ @SuppressLint("SetTextI18n")
+ private fun buildMemories(body: LinearLayout) {
+ val all = Notebook.memories(context).filter { !it.expired() }
+ if (all.isEmpty()) {
+ body.addView(emptyState(lctx.getString(R.string.notebook_empty_memories)))
+ return
+ }
+
+ val byType = all.groupBy { it.type }
+ body.addView(TextView(context).apply {
+ text = lctx.getString(R.string.notebook_delete_note)
+ textSize = Glass.Type.MICRO
+ setTextColor(Color.parseColor(Glass.MUTED))
+ }, matchWrap())
+ for (type in Notebook.TYPES) {
+ val group = byType[type] ?: continue
+ val sorted = group.sortedWith(
+ compareByDescending<Notebook.Memory> { it.importance }
+ .thenByDescending { it.updatedAt },
+ )
+ body.addView(sectionHeader(typeLabel(type)))
+ for (m in sorted) {
+ body.addView(memoryRow(m), matchWrap().apply { bottomMargin = dp(10) })
+ }
+ }
+ }
+
+ private fun typeLabel(type: String): String = when (type) {
+ "user" -> lctx.getString(R.string.notebook_type_user)
+ "feedback" -> lctx.getString(R.string.notebook_type_feedback)
+ "way" -> lctx.getString(R.string.notebook_type_way)
+ "reference" -> lctx.getString(R.string.notebook_type_reference)
+ "failure" -> lctx.getString(R.string.notebook_type_failure)
+ else -> type
+ }
+
+ @SuppressLint("SetTextI18n")
+ private fun memoryRow(m: Notebook.Memory): View {
+ val row = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ setPadding(dp(14), dp(12), dp(14), dp(12))
+ background = Glass.panel(context, dp(14))
+ }
+
+ val title = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ }
+ title.addView(
+ TextView(context).apply {
+ text = m.name
+ textSize = Glass.Type.BODY
+ setTextColor(Color.parseColor(Glass.TITLE))
+ },
+ LinearLayout.LayoutParams(0, WRAP, 1f),
+ )
+ title.addView(deleteButton {
+ Notebook.forget(context, m.name)
+ rebuild()
+ })
+ row.addView(title, matchWrap())
+
+ if (m.description.isNotBlank()) {
+ row.addView(
+ TextView(context).apply {
+ text = m.description
+ textSize = Glass.Type.CAPTION
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ setPadding(0, dp(4), 0, 0)
+ },
+ matchWrap(),
+ )
+ }
+
+ val meta = buildString {
+ val stamp = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(m.updatedAt)
+ append(stamp)
+ if (m.hits > 0) {
+ append(" · ")
+ append(lctx.getString(R.string.notebook_hits, m.hits))
+ }
+ }
+ row.addView(
+ TextView(context).apply {
+ text = meta
+ textSize = Glass.Type.MICRO
+ setTextColor(Color.parseColor(Glass.MUTED))
+ setPadding(0, dp(6), 0, 0)
+ },
+ matchWrap(),
+ )
+
+ return row
+ }
+
+ @SuppressLint("SetTextI18n")
+ private fun buildTodos(body: LinearLayout) {
+ val active = Notebook.todos(context, "active")
+ if (active.isEmpty()) {
+ body.addView(emptyState(lctx.getString(R.string.notebook_empty_todos)))
+ return
+ }
+
+ val sorted = active.sortedBy { it.nextRunAt }
+ for (t in sorted) {
+ body.addView(todoRow(t), matchWrap().apply { bottomMargin = dp(10) })
+ }
+ }
+
+ @SuppressLint("SetTextI18n")
+ private fun todoRow(t: Notebook.Todo): View {
+ val row = LinearLayout(context).apply {
+ orientation = LinearLayout.VERTICAL
+ setPadding(dp(14), dp(12), dp(14), dp(12))
+ background = Glass.panel(context, dp(14))
+ }
+
+ val title = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER_VERTICAL
+ }
+ title.addView(
+ TextView(context).apply {
+ text = t.what
+ textSize = Glass.Type.BODY
+ setTextColor(Color.parseColor(Glass.TITLE))
+ },
+ LinearLayout.LayoutParams(0, WRAP, 1f),
+ )
+ title.addView(deleteButton {
+ // Same three steps as the brain's own `todo drop`: without the
+ // cancel, the alarm still fires for a row the user just deleted.
+ Notebook.patchTodo(context, t.id, status = "dropped", nextRunAt = 0L)
+ Scheduler.cancelTodo(context, t.id)
+ rebuild()
+ })
+ row.addView(title, matchWrap())
+
+ val detail = buildString {
+ if (t.mode == "cron") {
+ append(lctx.getString(R.string.notebook_todo_cron, t.cronExpr))
+ } else {
+ val rel = DateUtils.getRelativeTimeSpanString(
+ t.at,
+ System.currentTimeMillis(),
+ DateUtils.MINUTE_IN_MILLIS,
+ )
+ append(rel)
+ }
+ if (t.status == "paused") {
+ append(" · ")
+ append(lctx.getString(R.string.notebook_todo_paused))
+ }
+ }
+ row.addView(
+ TextView(context).apply {
+ text = detail
+ textSize = Glass.Type.CAPTION
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ setPadding(0, dp(4), 0, 0)
+ },
+ matchWrap(),
+ )
+
+ return row
+ }
+
+ private fun sectionHeader(label: String): TextView = TextView(context).apply {
+ text = label
+ textSize = Glass.Type.CAPTION
+ setTextColor(Color.parseColor(Glass.MUTED))
+ setPadding(0, dp(16), 0, dp(8))
+ layoutParams = matchWrap()
+ }
+
+ private fun emptyState(msg: String): TextView = TextView(context).apply {
+ text = msg
+ textSize = Glass.Type.BODY
+ setTextColor(Color.parseColor(Glass.MUTED))
+ gravity = Gravity.CENTER
+ setPadding(dp(20), dp(40), dp(20), dp(40))
+ layoutParams = matchWrap()
+ }
+
+ private fun deleteButton(onClick: () -> Unit): TextView = TextView(context).apply {
+ text = lctx.getString(R.string.common_delete)
+ textSize = Glass.Type.CAPTION
+ setTextColor(Color.parseColor(Glass.DANGER))
+ gravity = Gravity.CENTER
+ setPadding(dp(12), dp(6), dp(12), dp(6))
+ background = Glass.panel(context, dp(10))
+ isClickable = true
+ Glass.pressable(this)
+ setOnClickListener { onClick() }
+ layoutParams = LinearLayout.LayoutParams(WRAP, WRAP)
+ }
+
+ private fun divider(parent: LinearLayout) {
+ parent.addView(
+ View(context).apply { setBackgroundColor(Color.parseColor(Glass.PANEL_EDGE)) },
+ LinearLayout.LayoutParams(MATCH, dp(1)),
+ )
+ }
+
+ private fun dp(value: Int): Int = (value * context.resources.displayMetrics.density).toInt()
+
+ private fun matchWrap() = LinearLayout.LayoutParams(MATCH, WRAP)
+
+ private companion object {
+ const val MATCH = LinearLayout.LayoutParams.MATCH_PARENT
+ const val WRAP = LinearLayout.LayoutParams.WRAP_CONTENT
+ }
+}
diff --git a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckUi.kt b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckUi.kt
index 8a02b54..628744d 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckUi.kt
@@ -110,6 +110,12 @@ class SelfCheckUi(
* has anything to do, and it is the only host that passes this.
*/
private val onYieldScreen: () -> Unit = {},
+ /**
+ * Fired when the user taps 重新设置 — the manual entry point into the wizard.
+ * Null ⇒ the button is not drawn. Default null, because `SelfCheckActivity`
+ * has no service to ask and therefore cannot open it.
+ */
+ private val onRerunWizard: (() -> Unit)? = null,
/** Non-null ⇒ that host places the card and this class owns no window. */
private val host: FrameLayout? = null,
) {
@@ -121,8 +127,8 @@ class SelfCheckUi(
const val GUTTER_DP = 20
const val CARD_RADIUS_DP = 28
- val OK_GREEN = 0xFF4ADE80.toInt()
- val WARN_AMBER = 0xFFFBBF24.toInt()
+ val OK_GREEN = android.graphics.Color.parseColor(Glass.OK)
+ val WARN_AMBER = android.graphics.Color.parseColor(Glass.WARN)
const val MATCH = LinearLayout.LayoutParams.MATCH_PARENT
const val WRAP = LinearLayout.LayoutParams.WRAP_CONTENT
@@ -505,13 +511,13 @@ class SelfCheckUi(
titles.addView(TextView(context).apply {
text = lctx.getString(R.string.check_page_title)
// Settings' 26sp, so the two cards' titles are the same size.
- textSize = 26f
+ textSize = Glass.Type.DISPLAY
setTextColor(Color.parseColor(Glass.TITLE))
letterSpacing = 0.01f
})
titles.addView(TextView(context).apply {
text = lctx.getString(R.string.check_page_lead)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.MUTED))
setPadding(0, dp(4), 0, 0)
})
@@ -526,7 +532,7 @@ class SelfCheckUi(
private fun closeButton(): View = TextView(context).apply {
text = "✕"
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(Glass.SECONDARY))
gravity = Gravity.CENTER
background = Glass.panel(context, dp(18))
@@ -557,6 +563,20 @@ class SelfCheckUi(
},
LinearLayout.LayoutParams(0, WRAP, 1f),
)
+ // 重新设置 sits beside 重新检查 and not in a row of its own, because the
+ // two are the same shape of thing — the one door here that is *not* a fix
+ // for a listed failure has to look like the door that is. It is
+ // deliberately not a filled button either: 完成 is the way out of this
+ // card and must stay the only one that looks like a way out.
+ if (onRerunWizard != null) {
+ row.addView(
+ textButton(lctx.getString(R.string.check_page_rerun_wizard), Glass.LABEL) {
+ hide()
+ onRerunWizard.invoke()
+ },
+ LinearLayout.LayoutParams(WRAP, WRAP).apply { marginEnd = dp(16) },
+ )
+ }
row.addView(button(lctx.getString(R.string.check_page_done), filled = true) { hide() })
return row
}
@@ -573,7 +593,7 @@ class SelfCheckUi(
private fun textButton(label: String, tint: String, onClick: () -> Unit): TextView =
TextView(context).apply {
text = label
- textSize = 14f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(tint))
gravity = Gravity.START or Gravity.CENTER_VERTICAL
setPadding(dp(4), dp(13), dp(4), dp(13))
@@ -587,7 +607,7 @@ class SelfCheckUi(
val radius = dp(24)
return TextView(context).apply {
text = label
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(if (filled) Glass.TITLE else Glass.LABEL))
gravity = Gravity.CENTER
background =
@@ -634,7 +654,7 @@ class SelfCheckUi(
head.addView(TextView(context).apply {
text = lctx.getString(f.title)
setTextColor(Color.parseColor(Glass.TITLE))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.TITLE)
setTypeface(typeface, Typeface.BOLD)
maxLines = 1
ellipsize = TextUtils.TruncateAt.END
@@ -646,7 +666,7 @@ class SelfCheckUi(
card.addView(TextView(context).apply {
text = AppLocale.str(context, f.detail, *f.detailArgs.toTypedArray())
setTextColor(Color.parseColor(Glass.SECONDARY))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
setPadding(0, dp(6), 0, 0)
})
@@ -658,13 +678,13 @@ class SelfCheckUi(
card.addView(TextView(context).apply {
text = lctx.getString(R.string.check_fix_adb_lead)
setTextColor(Color.parseColor(Glass.MUTED))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.CAPTION)
setPadding(0, dp(10), 0, dp(4))
})
card.addView(TextView(context).apply {
text = adb.command
setTextColor(Color.parseColor(Glass.LABEL))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.CAPTION)
typeface = Typeface.MONOSPACE
// Direct call, not `isTextSelectable = true`: TextView's setter
// is `setTextIsSelectable` and its getter `isTextSelectable`,
@@ -712,7 +732,7 @@ class SelfCheckUi(
return TextView(context).apply {
text = lctx.getString(label)
setTextColor(Color.parseColor(Glass.ACCENT))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
setTypeface(typeface, Typeface.BOLD)
setPadding(dp(10), dp(6), 0, dp(6))
isClickable = true
@@ -880,9 +900,9 @@ class SelfCheckUi(
} else {
lctx.getString(R.string.check_page_issues, problems)
}
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 17f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.TITLE)
setTypeface(typeface, Typeface.BOLD)
- setTextColor(Color.parseColor(if (problems == 0) "#4ADE80" else Glass.DANGER))
+ setTextColor(Color.parseColor(if (problems == 0) Glass.OK else Glass.DANGER))
})
// Only in the clean case: a green headline with no sentence under it
// leaves the user wondering whether the list below is part of the
@@ -891,7 +911,7 @@ class SelfCheckUi(
addView(TextView(context).apply {
text = lctx.getString(R.string.check_page_ok_note)
setTextColor(Color.parseColor(Glass.SECONDARY))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
setPadding(0, dp(4), 0, dp(12))
})
}
@@ -900,14 +920,14 @@ class SelfCheckUi(
private fun sectionHeading(id: Int): TextView = TextView(context).apply {
text = lctx.getString(id)
setTextColor(Color.parseColor(Glass.MUTED))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.CAPTION)
setPadding(0, dp(4), 0, dp(8))
}
private fun note(text: String): TextView = TextView(context).apply {
this.text = text
setTextColor(Color.parseColor(Glass.SECONDARY))
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, Glass.Type.BODY)
background = Glass.panel(context, dp(12))
setPadding(dp(14), dp(12), dp(14), dp(12))
layoutParams = LinearLayout.LayoutParams(MATCH, WRAP).apply { topMargin = dp(10) }
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 09c4914..6ab763e 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
@@ -168,9 +168,18 @@ class SettingsUi(
*/
private var lctx: Context = context
- /** Survives a [rebuild], so switching language doesn't re-hide the group. */
+ /**
+ * 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.
+ */
private var advancedOpen = false
+ /** Same, for the 火山 panel. Kept apart from [advancedOpen] — see there. */
+ private var voiceOpen = false
+
/** Same, for the notebook dump. Kept apart so opening one does not unfold the other. */
private var notebookOpen = false
@@ -360,14 +369,26 @@ class SettingsUi(
setPadding(dp(24), dp(4), dp(24), dp(24))
}
+ // Split in two, and the split is the whole of item 5 of the review: the
+ // card used to be eleven sections in one flat column, in which the
+ // question "what can I actually set here" took a full scroll to answer
+ // because the answer was interleaved with endpoints and a factory-reset
+ // button. 常用 is what a person opens settings for; 高级 is everything
+ // that answers a question they have not asked yet.
+ //
+ // Order inside 常用 is by how early the errand comes up, not
+ // alphabetically: who does the thinking, then how it hears you, then
+ // what it is allowed to keep, then what it may interrupt you for, then
+ // the credentials it can spend. 大脑 stays first because it is the one
+ // setting that changes what the rest of the card means.
brainSection(form)
- voiceSection(form)
+ voiceKeySection(form)
+ wakeSection(form)
notebookSection(form)
notifySection(form)
- wakeSection(form)
- typingSection(form)
vaultSection(form)
- diagnosticsSection(form)
+
+ advancedSection(form)
sv.addView(form, matchWrap())
card.addView(sv, LinearLayout.LayoutParams(MATCH, 0, 1f))
@@ -376,6 +397,41 @@ class SettingsUi(
return card
}
+ /**
+ * 高级: the three sections a configured device never opens.
+ *
+ * A foldable *group of sections* rather than one more collapsible section —
+ * the only one in the card — because its members draw their own headings and
+ * 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.
+ *
+ * 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
+ * 恢复出厂设置 has no way to know it is behind this chevron and not gone.
+ */
+ private fun advancedSection(form: LinearLayout) {
+ val body = collapsible(
+ form,
+ lctx.getString(R.string.settings_section_advanced),
+ 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)
+ typingSection(body)
+ diagnosticsSection(body)
+ }
+
@SuppressLint("SetTextI18n")
private fun header(): View {
val row = LinearLayout(context).apply {
@@ -389,13 +445,13 @@ class SettingsUi(
// 21 was sized against the old, smaller card. On a card this wide
// a 21sp title is the first thing that reads as undersized, and it
// is the one line that has to carry the sheet's identity.
- textSize = 26f
+ textSize = Glass.Type.DISPLAY
setTextColor(Color.parseColor(Glass.TITLE))
letterSpacing = 0.01f
})
titles.addView(TextView(context).apply {
text = saved["device_name"].orEmpty().ifEmpty { lctx.getString(R.string.settings_default_device_name) }
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.MUTED))
setPadding(0, dp(4), 0, 0)
})
@@ -413,7 +469,7 @@ class SettingsUi(
// 13dp of glyph in a 36dp circle, on a card the user can now see
// properly. It was 13 in a 32dp circle, which is a target you have to
// aim at; 15 in 36 is one you can hit without looking.
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(Glass.SECONDARY))
gravity = Gravity.CENTER
// A circle, so it reads as a button at a size where a bare glyph would
@@ -584,7 +640,7 @@ class SettingsUi(
val state = TextView(context).apply {
text = summary()
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.LABEL))
setLineSpacing(dp(3).toFloat(), 1f)
}
@@ -603,6 +659,40 @@ 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
@@ -621,7 +711,7 @@ class SettingsUi(
val state = TextView(context).apply {
text = summary()
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.LABEL))
setLineSpacing(dp(3).toFloat(), 1f)
}
@@ -634,32 +724,20 @@ class SettingsUi(
panel.addView(row, rowParams(dp(12)))
}
- /** 火山 endpoints. Collapsed, because they ship working and rarely move. */
+ /**
+ * 火山 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),
- )
- // The one overridable credential. Blank means *factory*, which is what
- // an untouched box shows — see VoiceConfig.save / OVERRIDE_KEYS. The key
- // is 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)
- },
+ 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))
@@ -781,7 +859,7 @@ class SettingsUi(
/** The bold red line at the head of a destructive confirm. */
private fun confirmTitle(text: String): TextView = TextView(context).apply {
this.text = text
- textSize = 14f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(Glass.DANGER))
letterSpacing = 0.02f
}
@@ -789,7 +867,7 @@ class SettingsUi(
/** The grey explanation under it. [text] is pre-joined by the caller. */
private fun confirmBody(text: String): TextView = TextView(context).apply {
this.text = text
- textSize = 12f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.MUTED))
setLineSpacing(dp(4).toFloat(), 1f)
setPadding(0, dp(8), 0, 0)
@@ -859,17 +937,22 @@ 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 used = Notebook.sweepCountToday(context)
- val spent = Notebook.sweepTokensToday(context)
- val remembered = Notebook.memories(context).size
- val open = Notebook.todos(context, "pending").size
- readOnly(
+ val stats = readOnly(
panel,
lctx.getString(R.string.settings_notebook_today),
- lctx.getString(
- R.string.settings_notebook_stats,
- used, spent, remembered, open,
- ),
+ notebookStats(),
+ )
+ val dumpView = notebookDumpView()
+ // 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()
+ dumpView.text = notebookDumpText()
+ }.show()
+ },
+ LinearLayout.LayoutParams(WRAP, WRAP).apply { topMargin = dp(10) },
)
val dump = collapsible(
@@ -879,9 +962,17 @@ class SettingsUi(
isOpen = { notebookOpen },
setOpen = { notebookOpen = it },
)
- dump.addView(notebookDumpView(), matchWrap())
+ dump.addView(dumpView, matchWrap())
}
+ private fun notebookStats(): String = lctx.getString(
+ R.string.settings_notebook_stats,
+ Notebook.sweepCountToday(context),
+ Notebook.sweepTokensToday(context),
+ Notebook.memories(context).size,
+ Notebook.todos(context, "pending").size,
+ )
+
/**
* Which notifications the device may think about by itself.
*
@@ -927,9 +1018,18 @@ class SettingsUi(
* truncation says so in the last line — a silent cut-off would read as "this
* is everything".
*/
- private fun notebookDumpView(): TextView {
+ private fun notebookDumpView(): TextView = TextView(context).apply {
+ text = notebookDumpText()
+ textSize = Glass.Type.CAPTION
+ typeface = android.graphics.Typeface.MONOSPACE
+ setTextColor(Color.parseColor(Glass.SECONDARY))
+ setLineSpacing(dp(3).toFloat(), 1f)
+ setTextIsSelectable(true)
+ }
+
+ private fun notebookDumpText(): String {
val full = Notebook.dumpText(context)
- val body = if (full.length <= NOTEBOOK_DUMP_CHARS) {
+ return if (full.length <= NOTEBOOK_DUMP_CHARS) {
full
} else {
full.take(NOTEBOOK_DUMP_CHARS) +
@@ -939,14 +1039,6 @@ class SettingsUi(
full.length - NOTEBOOK_DUMP_CHARS,
)
}
- return TextView(context).apply {
- text = body
- textSize = 12f
- typeface = android.graphics.Typeface.MONOSPACE
- setTextColor(Color.parseColor(Glass.SECONDARY))
- setLineSpacing(dp(3).toFloat(), 1f)
- setTextIsSelectable(true)
- }
}
// ---- Widgets ----
@@ -1001,6 +1093,11 @@ class SettingsUi(
*
* @param isOpen / @param setOpen which flag remembers the state. Parameterised
* so two foldable panels can exist without one unfolding the other.
+ * @param bare the returned container carries no fill of its own, so the
+ * sections that go inside it stay flush with the ones above rather than
+ * sitting in a panel inside a panel. Used by 高级, which is a *group of
+ * sections* rather than a section — the only disclosure here whose
+ * children draw their own headings and panels. See [advancedSection].
*/
private fun collapsible(
form: LinearLayout,
@@ -1008,6 +1105,7 @@ class SettingsUi(
note: String,
isOpen: () -> Boolean = { advancedOpen },
setOpen: (Boolean) -> Unit = { advancedOpen = it },
+ bare: Boolean = false,
): LinearLayout {
val head = LinearLayout(context).apply {
orientation = LinearLayout.HORIZONTAL
@@ -1017,7 +1115,7 @@ class SettingsUi(
head.addView(sectionTitle(title), LinearLayout.LayoutParams(0, WRAP, 1f))
val chevron = TextView(context).apply {
text = "›"
- textSize = 17f
+ textSize = Glass.Type.TITLE
setTextColor(Color.parseColor(Glass.ACCENT))
gravity = Gravity.CENTER
setPadding(dp(10), 0, dp(4), 0)
@@ -1029,6 +1127,10 @@ class SettingsUi(
val panel = panel().apply {
visibility = if (isOpen()) View.VISIBLE else View.GONE
+ if (bare) {
+ setPadding(0, 0, 0, 0)
+ background = null
+ }
}
form.addView(panel, rowParams(dp(10)))
head.setOnClickListener {
@@ -1046,7 +1148,7 @@ class SettingsUi(
private fun sectionTitle(title: String): TextView = TextView(context).apply {
text = title
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.ACCENT))
letterSpacing = 0.08f
setPadding(0, dp(22), 0, dp(8))
@@ -1070,7 +1172,7 @@ class SettingsUi(
this.text = text
// 12 was legible only because the card was small enough to read at
// a glance. It is now the smallest thing on a much larger surface.
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.LABEL))
}, rowParams(dp(16)))
}
@@ -1086,18 +1188,20 @@ class SettingsUi(
// least of all — but at 11sp on a 690dp-wide card they end up as one
// line each, which is both harder to read and denser-looking than the
// rows they sit between.
- textSize = 12.5f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.MUTED))
setLineSpacing(dp(4).toFloat(), 1f)
}
- private fun readOnly(parent: LinearLayout, title: String, value: String) {
+ private fun readOnly(parent: LinearLayout, title: String, value: String): TextView {
rowLabel(parent, title)
- parent.addView(TextView(context).apply {
+ val v = TextView(context).apply {
text = value
- textSize = 14.5f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(Glass.SECONDARY))
- }, rowParams(dp(4)))
+ }
+ parent.addView(v, rowParams(dp(4)))
+ return v
}
/**
@@ -1125,7 +1229,7 @@ class SettingsUi(
// full-width well on a 690dp card is a lot of empty space holding
// one line of text. Sizing the field up is what fills that space
// with something rather than just making it emptier.
- textSize = 15f
+ textSize = Glass.Type.BODY
if (hint != null) setHint(hint)
// isSingleLine before the mask, as in VaultUi: the other order lets
// it undo the password transformation and the dots come out as text.
@@ -1152,7 +1256,7 @@ class SettingsUi(
var shown = false
row.addView(TextView(context).apply {
text = lctx.getString(R.string.common_show)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.ACCENT))
setPadding(dp(14), dp(8), dp(2), dp(8))
isClickable = true
@@ -1296,7 +1400,7 @@ class SettingsUi(
val (value, label) = option
val cell = TextView(context).apply {
text = label
- textSize = if (compact) 12f else 13f
+ textSize = if (compact) Glass.Type.MICRO else Glass.Type.CAPTION
gravity = Gravity.CENTER
setTextColor(if (i == index) onColor else offColor)
if (compact) setPadding(dp(12), dp(6), dp(12), dp(6))
@@ -1331,7 +1435,7 @@ class SettingsUi(
// sized for a card narrower than this one. Larger type and more
// padding is what makes 保存 / 取消 hit-or-miss avoidable on a
// tablet held in two hands, which is how it is actually used.
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(
Color.parseColor(
if (danger) Glass.DANGER else if (filled) Glass.TITLE else Glass.LABEL,
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 8bd670b..38915b8 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/TextInputActivity.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/TextInputActivity.kt
@@ -90,7 +90,7 @@ class TextInputActivity : Activity() {
field = EditText(this).apply {
hint = lctx.getString(R.string.input_hint)
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(Glass.TITLE))
// SECONDARY, not MUTED. The hint is the only thing in here until
// somebody types, so it is the one string that has to survive being
@@ -331,7 +331,7 @@ class TextInputActivity : Activity() {
private fun glyph(label: String, color: String, onClick: () -> Unit): TextView =
TextView(this).apply {
text = label
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(color))
gravity = Gravity.CENTER
setPadding(dp(14), dp(10), dp(14), dp(10))
diff --git a/app/src/main/java/net/kuafuai/andee/ui/VaultUi.kt b/app/src/main/java/net/kuafuai/andee/ui/VaultUi.kt
index b5d38e9..a82d1ba 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/VaultUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/VaultUi.kt
@@ -133,7 +133,7 @@ class VaultUi(
} else {
lctx.getString(R.string.vault_edit_title)
}
- textSize = 20f
+ textSize = Glass.Type.HEADLINE
setTextColor(Color.parseColor(Glass.TITLE))
},
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f),
@@ -141,7 +141,7 @@ class VaultUi(
header.addView(
TextView(context).apply {
text = "✕"
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.SECONDARY))
gravity = Gravity.CENTER
background = Glass.panel(context, dp(16))
@@ -201,7 +201,7 @@ class VaultUi(
private fun buildList(body: LinearLayout): LinearLayout {
body.addView(TextView(context).apply {
text = lctx.getString(R.string.vault_intro)
- textSize = 12f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.SECONDARY))
setPadding(0, 0, 0, dp(10))
})
@@ -210,7 +210,7 @@ class VaultUi(
if (all.isEmpty()) {
body.addView(TextView(context).apply {
text = lctx.getString(R.string.vault_empty)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.MUTED))
setPadding(0, dp(12), 0, dp(12))
})
@@ -247,7 +247,7 @@ class VaultUi(
val column = LinearLayout(context).apply { orientation = LinearLayout.VERTICAL }
column.addView(TextView(context).apply {
text = entry.label.ifBlank { entry.id }
- textSize = 15f
+ textSize = Glass.Type.BODY
setTextColor(Color.WHITE)
})
// [Vault.Entry.masked] rather than masking here: `card_last4` is four
@@ -260,14 +260,14 @@ class VaultUi(
}.joinToString(" · ")
column.addView(TextView(context).apply {
text = summary.ifBlank { lctx.getString(R.string.vault_summary_empty) }
- textSize = 12f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.SECONDARY))
setPadding(0, dp(2), 0, 0)
})
row.addView(column, LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f))
row.addView(TextView(context).apply {
text = lctx.getString(R.string.vault_delete)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.DANGER))
setPadding(dp(12), dp(6), dp(4), dp(6))
isClickable = true
@@ -288,7 +288,7 @@ class VaultUi(
val password = field(body, lctx.getString(R.string.vault_field_password), entry.password, password = true)
body.addView(TextView(context).apply {
text = lctx.getString(R.string.vault_password_note)
- textSize = 11f
+ textSize = Glass.Type.MICRO
setTextColor(Color.parseColor(Glass.MUTED))
setPadding(0, dp(4), 0, 0)
})
@@ -302,13 +302,13 @@ class VaultUi(
// blank card rows reads as four things the user forgot to fill in.
body.addView(TextView(context).apply {
text = lctx.getString(R.string.vault_section_card)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.LABEL))
setPadding(0, dp(18), 0, dp(2))
})
body.addView(TextView(context).apply {
text = lctx.getString(R.string.vault_card_note)
- textSize = 11f
+ textSize = Glass.Type.MICRO
setTextColor(Color.parseColor(Glass.MUTED))
})
val cardHolder = field(
@@ -394,7 +394,7 @@ class VaultUi(
): EditText {
parent.addView(TextView(context).apply {
text = label
- textSize = 12f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.LABEL))
setPadding(0, dp(8), 0, dp(4))
})
@@ -403,7 +403,7 @@ class VaultUi(
setPadding(dp(12), dp(11), dp(12), dp(11))
setTextColor(Color.parseColor(Glass.TITLE))
setHintTextColor(Color.parseColor(Glass.MUTED))
- textSize = 14f
+ textSize = Glass.Type.BODY
if (hint != null) setHint(hint)
// Order matters: setSingleLine installs its own transformation and
// would strip the password dots right back off again.
@@ -427,7 +427,7 @@ class VaultUi(
var shown = false
row.addView(TextView(context).apply {
text = lctx.getString(R.string.common_show)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.ACCENT))
gravity = Gravity.CENTER
setPadding(dp(12), dp(10), dp(4), dp(10))
@@ -465,7 +465,7 @@ class VaultUi(
private fun button(label: String, filled: Boolean, onClick: () -> Unit): TextView =
TextView(context).apply {
text = label
- textSize = 14f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(if (filled) Glass.TITLE else Glass.LABEL))
gravity = Gravity.CENTER
background =
diff --git a/app/src/main/java/net/kuafuai/andee/ui/WakeEnrollUi.kt b/app/src/main/java/net/kuafuai/andee/ui/WakeEnrollUi.kt
index b6b3aa0..c6d37e2 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/WakeEnrollUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/WakeEnrollUi.kt
@@ -118,13 +118,13 @@ class WakeEnrollUi(
card.addView(TextView(context).apply {
text = lctx.getString(R.string.wake_title)
- textSize = 19f
+ textSize = Glass.Type.HEADLINE
setTextColor(Color.parseColor(Glass.TITLE))
})
card.addView(TextView(context).apply {
text = lctx.getString(R.string.wake_instructions, WakeTemplates.ENROLL_COUNT)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.SECONDARY))
setLineSpacing(dp(3).toFloat(), 1f)
setPadding(0, dp(10), 0, dp(14))
@@ -132,7 +132,7 @@ class WakeEnrollUi(
progress = TextView(context).apply {
text = lctx.getString(R.string.wake_progress, 0, WakeTemplates.ENROLL_COUNT)
- textSize = 13f
+ textSize = Glass.Type.CAPTION
setTextColor(Color.parseColor(Glass.MUTED))
}
card.addView(progress)
@@ -143,7 +143,7 @@ class WakeEnrollUi(
} else {
lctx.getString(R.string.wake_status_not_enrolled)
}
- textSize = 14f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(Glass.LABEL))
setPadding(0, dp(8), 0, dp(16))
}
@@ -170,7 +170,7 @@ class WakeEnrollUi(
private fun button(label: String, filled: Boolean, onClick: () -> Unit): TextView =
TextView(context).apply {
text = label
- textSize = 14f
+ textSize = Glass.Type.BODY
setTextColor(Color.parseColor(if (filled) Glass.TITLE else Glass.LABEL))
gravity = Gravity.CENTER
background =
diff --git a/app/src/main/res/drawable/ic_back.xml b/app/src/main/res/drawable/ic_back.xml
new file mode 100644
index 0000000..2a0bdbf
--- /dev/null
+++ b/app/src/main/res/drawable/ic_back.xml
@@ -0,0 +1,9 @@
+<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="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_check.xml b/app/src/main/res/drawable/ic_check.xml
new file mode 100644
index 0000000..a82e4ad
--- /dev/null
+++ b/app/src/main/res/drawable/ic_check.xml
@@ -0,0 +1,9 @@
+<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="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_close.xml b/app/src/main/res/drawable/ic_close.xml
new file mode 100644
index 0000000..7e89e06
--- /dev/null
+++ b/app/src/main/res/drawable/ic_close.xml
@@ -0,0 +1,9 @@
+<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="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_home.xml b/app/src/main/res/drawable/ic_home.xml
new file mode 100644
index 0000000..8f8c192
--- /dev/null
+++ b/app/src/main/res/drawable/ic_home.xml
@@ -0,0 +1,9 @@
+<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="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_info.xml b/app/src/main/res/drawable/ic_info.xml
new file mode 100644
index 0000000..da334c8
--- /dev/null
+++ b/app/src/main/res/drawable/ic_info.xml
@@ -0,0 +1,9 @@
+<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,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_more.xml b/app/src/main/res/drawable/ic_more.xml
new file mode 100644
index 0000000..6420bbf
--- /dev/null
+++ b/app/src/main/res/drawable/ic_more.xml
@@ -0,0 +1,9 @@
+<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="M6,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_screenshot.xml b/app/src/main/res/drawable/ic_screenshot.xml
new file mode 100644
index 0000000..46b7eab
--- /dev/null
+++ b/app/src/main/res/drawable/ic_screenshot.xml
@@ -0,0 +1,9 @@
+<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="M9,3L7.17,5H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V7c0,-1.1 -0.9,-2 -2,-2h-3.17L15,3H9zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml
new file mode 100644
index 0000000..b861251
--- /dev/null
+++ b/app/src/main/res/drawable/ic_settings.xml
@@ -0,0 +1,9 @@
+<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="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94 0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6 3.6,1.62 3.6,3.6 -1.62,3.6 -3.6,3.6z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_swipe_down.xml b/app/src/main/res/drawable/ic_swipe_down.xml
new file mode 100644
index 0000000..f46af24
--- /dev/null
+++ b/app/src/main/res/drawable/ic_swipe_down.xml
@@ -0,0 +1,9 @@
+<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,20l6,-6h-4L14,6h-4v8L6,14z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_swipe_left.xml b/app/src/main/res/drawable/ic_swipe_left.xml
new file mode 100644
index 0000000..4f15d41
--- /dev/null
+++ b/app/src/main/res/drawable/ic_swipe_left.xml
@@ -0,0 +1,9 @@
+<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="M4,12l6,6v-4h8v-4h-8L10,6z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_swipe_right.xml b/app/src/main/res/drawable/ic_swipe_right.xml
new file mode 100644
index 0000000..62e33cc
--- /dev/null
+++ b/app/src/main/res/drawable/ic_swipe_right.xml
@@ -0,0 +1,9 @@
+<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="M20,12l-6,-6v4h-8v4h8v4z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_swipe_up.xml b/app/src/main/res/drawable/ic_swipe_up.xml
new file mode 100644
index 0000000..9eb7693
--- /dev/null
+++ b/app/src/main/res/drawable/ic_swipe_up.xml
@@ -0,0 +1,9 @@
+<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,4l-6,6h4v8h4v-8h4z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_tree.xml b/app/src/main/res/drawable/ic_tree.xml
new file mode 100644
index 0000000..09939dd
--- /dev/null
+++ b/app/src/main/res/drawable/ic_tree.xml
@@ -0,0 +1,9 @@
+<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="M4,4h6v2L6,6v4L4,10zM4,14h2v4h4v2L4,20zM14,4h6v6h-2L18,6h-4zM18,14h2v6h-6v-2h4z"/>
+</vector>
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index fc31d37..35c44de 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -89,15 +89,17 @@
<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_section_wake">Wake word</string>
- <string name="settings_wake_enrolled">Enrolled — just say “Hey Andee” while the screen is on</string>
+ <string name="settings_wake_enrolled">Enrolled — say “Hey Andee” while the screen is on</string>
<string name="settings_wake_not_enrolled">Not enrolled — record it once to wake me by voice</string>
<string name="settings_wake_record">Record</string>
<string name="common_clear">Clear</string>
+ <string name="common_delete">Delete</string>
<string name="settings_section_vault">Vault</string>
<string name="settings_vault_empty_note">No accounts yet — once saved, Andee can log in as you when a task needs it</string>
<string name="settings_vault_count_note">%1$d saved — the brain may read the phone and email, but only this device types the password</string>
<string name="settings_vault_manage">Manage</string>
- <string name="settings_section_voice">Speech (Volcengine)</string>
+ <string name="settings_section_voice">Volcengine endpoints</string>
+ <string name="settings_section_voice_key">Speech</string>
<string name="settings_voice_factory_note">The source ships without a key. Enter your own to hear and speak; leave the rows below blank for the default endpoints.</string>
<string name="settings_voice_api_key">Volcengine API key</string>
<string name="settings_voice_api_key_hint">Volcengine Speech key — hearing and speaking both need it</string>
@@ -110,6 +112,8 @@
<string name="settings_voice_tts_resource_id">TTS resource ID</string>
<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_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>
@@ -122,6 +126,7 @@
<string name="settings_notebook_dump">What is in the book</string>
<string name="settings_notebook_dump_hint">Read-only. Long-press to select and copy.</string>
<string name="settings_notebook_dump_truncated">… (%1$d more characters not shown)</string>
+ <string name="settings_notebook_browse">See what it remembers</string>
<string name="settings_section_notify">Notifications</string>
<string name="settings_notify_chat">Chat apps</string>
<string name="settings_notify_all">Everything</string>
@@ -141,6 +146,15 @@
longer than one they can read at a glance. -->
<string name="window_tips">1tap: talk · 2tap: type · 3tap: stop · swipe: character</string>
+ <string name="tool_swipe_up">Up</string>
+ <string name="tool_swipe_down">Down</string>
+ <string name="tool_swipe_left">Left</string>
+ <string name="tool_swipe_right">Right</string>
+ <string name="tool_back">Back</string>
+ <string name="tool_home">Home</string>
+ <string name="tool_ui_tree">Tree</string>
+ <string name="tool_screenshot">Shot</string>
+
<!-- The factory-reset confirmation list; see config/FactoryReset.kt. -->
<string name="factory_reset_target_keys">the Volcano and DeepSeek keys, and every speech and brain setting</string>
<string name="factory_reset_target_notebook">the notebook: what it remembers and what it promised</string>
@@ -268,6 +282,21 @@
<string name="notebook_dump_recurring">every %1$s</string>
<string name="notebook_dump_next">" · next "</string>
<string name="notebook_dump_last_error">" last error: "</string>
+
+ <string name="notebook_title">What it remembers</string>
+ <string name="notebook_tab_memories">Memories</string>
+ <string name="notebook_tab_todos">Todos</string>
+ <string name="notebook_empty_memories">Nothing written down yet</string>
+ <string name="notebook_empty_todos">Nothing queued up</string>
+ <string name="notebook_type_user">About you</string>
+ <string name="notebook_type_feedback">Your preferences</string>
+ <string name="notebook_type_way">How things get done</string>
+ <string name="notebook_type_reference">Reference</string>
+ <string name="notebook_type_failure">Past mistakes</string>
+ <string name="notebook_hits">recalled %1$d times</string>
+ <string name="notebook_delete_note">Deleting means gone — not hidden.</string>
+ <string name="notebook_todo_cron">every %1$s</string>
+ <string name="notebook_todo_paused">paused</string>
<string name="sched_channel_name">Promises</string>
<string name="sched_channel_desc">When the time comes but I can\'t wake up, at least say it clearly</string>
<string name="sched_notify_recurring">Recurring todo: %1$s</string>
@@ -409,4 +438,38 @@
<string name="ball_look_rabbit">Rascal</string>
<string name="ball_look_bear">Bear</string>
<string name="ball_look_imp">Imp</string>
+
+
+ <!-- First-run wizard -->
+ <string name="wizard_title">First-run setup</string>
+ <string name="wizard_progress_welcome">Welcome</string>
+ <string name="wizard_progress_step">Step %1$d of %2$d</string>
+ <string name="wizard_progress_done">Done</string>
+ <string name="wizard_cancel">Cancel</string>
+ <string name="wizard_back">Back</string>
+ <string name="wizard_begin">Begin</string>
+ <string name="wizard_next">Next</string>
+ <string name="wizard_finish">Finish setup</string>
+ <string name="wizard_done">Start using</string>
+
+ <string name="wizard_welcome_title">Welcome</string>
+ <string name="wizard_welcome_body">A few steps to get this device ready. Each one asks you to grant a permission or fill a setting. Tap Next when you\'re done.</string>
+
+ <string name="wizard_wake_title">Wake phrase</string>
+ <string name="wizard_wake_body">Record a wake phrase — you can call it by voice when the screen is on. Works without one too; you\'d just tap the ball instead.</string>
+ <string name="wizard_wake_button">Record</string>
+
+ <string name="wizard_look_title">Take a look around</string>
+ <string name="wizard_look_body">Let it see where you are now so it remembers this place. Later when you ask "where am I" it can answer.</string>
+ <string name="wizard_look_button">Open camera</string>
+
+ <string name="wizard_sentence_title">Say your first sentence</string>
+ <string name="wizard_sentence_body">Tap the ball, say something — it\'ll answer, and setup is done.</string>
+ <string name="wizard_sentence_button">Tap to talk</string>
+
+ <string name="wizard_complete_title">All set</string>
+ <string name="wizard_complete_body">Go tap the ball and talk. Long-press it to unfold the card, ⚙ opens settings.</string>
+
+ <string name="check_page_rerun_wizard">Set up again</string>
+
</resources>
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
index 2ef60e9..071d5d5 100644
--- a/app/src/main/res/values-night/themes.xml
+++ b/app/src/main/res/values-night/themes.xml
@@ -1,16 +1,22 @@
<resources xmlns:tools="http://schemas.android.com/tools">
- <!-- Base application theme. -->
+ <!--
+ The night half of Theme.Body. It exists only to keep the platform from
+ swapping in Material's light defaults after dark; the colours are the
+ same as values/themes.xml on purpose, because this app has exactly one
+ palette — Glass' black-and-white stack — and it does not have a light
+ mode. Anything that differs between these two files is a bug.
+ -->
<style name="Theme.Body" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
- <item name="colorPrimary">@color/purple_200</item>
- <item name="colorPrimaryVariant">@color/purple_700</item>
+ <item name="colorPrimary">@color/glass_tint</item>
+ <item name="colorPrimaryVariant">@color/glass_base</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
- <item name="colorSecondary">@color/teal_200</item>
- <item name="colorSecondaryVariant">@color/teal_200</item>
+ <item name="colorSecondary">@color/glass_accent</item>
+ <item name="colorSecondaryVariant">@color/glass_accent</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
- <item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
+ <item name="android:statusBarColor">@color/glass_base</item>
<!-- Customize your theme here. -->
</style>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index f8c6127..ea84f6f 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -1,10 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <color name="purple_200">#FFBB86FC</color>
- <color name="purple_500">#FF6200EE</color>
- <color name="purple_700">#FF3700B3</color>
- <color name="teal_200">#FF03DAC5</color>
- <color name="teal_700">#FF018786</color>
+ <!--
+ The theme's view of ui/Glass.kt. Every surface this app draws takes its
+ colours from Glass in code; these exist only for the few places the
+ platform paints for us from the theme (status bar, any stock widget an
+ Activity inflates). Keep them in step with Glass rather than inventing
+ a second palette.
+ -->
+ <color name="glass_base">#FF000000</color>
+ <color name="glass_tint">#FF4C6FFF</color>
+ <color name="glass_accent">#FF7FA5FF</color>
+ <color name="glass_label">#FFDCE1EA</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8b019ec..462997c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -70,11 +70,13 @@
<string name="settings_wake_not_enrolled">未录入 —— 录一次才能语音唤醒</string>
<string name="settings_wake_record">录入</string>
<string name="common_clear">清除</string>
+ <string name="common_delete">删除</string>
<string name="settings_section_vault">保险箱</string>
<string name="settings_vault_empty_note">还没有存账号 —— 存了之后,Andee 办事时可以直接用它们登录</string>
<string name="settings_vault_count_note">已存 %1$d 个账号 —— 手机号邮箱大脑读得到,密码只由设备替你敲进输入框</string>
<string name="settings_vault_manage">管理</string>
- <string name="settings_section_voice">语音(火山引擎)</string>
+ <string name="settings_section_voice">火山接口地址</string>
+ <string name="settings_section_voice_key">语音</string>
<string name="settings_voice_factory_note">源码不带密钥。填上自己的 Key 才听得见、说得出;下面几行留空用默认地址即可。</string>
<string name="settings_voice_api_key">火山 API Key</string>
<string name="settings_voice_api_key_hint">火山引擎语音服务的 Key,听和说都靠它</string>
@@ -87,6 +89,8 @@
<string name="settings_voice_tts_resource_id">合成资源 ID</string>
<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_grounding">接地采集</string>
<string name="settings_grounding_note">把坐标点击和截图记到 files/grounding 供离线分析 —— 它会拍下你当时在做的事。改完要重开无障碍服务才生效。</string>
<string name="settings_device_id">设备 ID</string>
@@ -99,6 +103,7 @@
<string name="settings_notebook_dump">本子里写了什么</string>
<string name="settings_notebook_dump_hint">只读。长按可以选中复制。</string>
<string name="settings_notebook_dump_truncated">…(还有 %1$d 个字符没显示)</string>
+ <string name="settings_notebook_browse">看它记得的事</string>
<string name="settings_section_notify">消息提醒</string>
<string name="settings_notify_chat">聊天类</string>
<string name="settings_notify_all">全部</string>
@@ -115,6 +120,16 @@
folded ball reads a horizontal flick as a move instead. -->
<string name="window_tips">点小球说话 · 双击打字 · 三连击停止 · 滑动切换性格</string>
+ <!-- The ⋯ drawer's tool names, under each icon. -->
+ <string name="tool_swipe_up">上滑</string>
+ <string name="tool_swipe_down">下滑</string>
+ <string name="tool_swipe_left">左滑</string>
+ <string name="tool_swipe_right">右滑</string>
+ <string name="tool_back">返回</string>
+ <string name="tool_home">桌面</string>
+ <string name="tool_ui_tree">元素树</string>
+ <string name="tool_screenshot">截图</string>
+
<!-- The 恢复出厂设置 confirmation list: one line per thing wiped.
Kept beside config/FactoryReset.kt, which walks them in this order. -->
<string name="factory_reset_target_keys">火山 key、DeepSeek key,以及所有语音与大脑的设置</string>
@@ -278,6 +293,28 @@
<string name="notebook_dump_next">" · 下次 "</string>
<string name="notebook_dump_last_error">" 上次出错:"</string>
+ <!--
+ ui/NotebookUi.kt — the browse-and-delete page, as opposed to the
+ export-shaped dump above. Unlike the dump these are read by the *user*,
+ so they are translated like any other chrome, and the type names are
+ words rather than the raw enum values ("没接住" is not a word a person
+ uses; 踩过的坑 is).
+ -->
+ <string name="notebook_title">它记得的事</string>
+ <string name="notebook_tab_memories">记忆</string>
+ <string name="notebook_tab_todos">待办</string>
+ <string name="notebook_empty_memories">还没记下什么</string>
+ <string name="notebook_empty_todos">没有排着的待办</string>
+ <string name="notebook_type_user">关于你</string>
+ <string name="notebook_type_feedback">你的偏好</string>
+ <string name="notebook_type_way">做事的方式</string>
+ <string name="notebook_type_reference">资料</string>
+ <string name="notebook_type_failure">踩过的坑</string>
+ <string name="notebook_hits">被查过 %1$d 次</string>
+ <string name="notebook_delete_note">删掉就没了,不会只是藏起来。</string>
+ <string name="notebook_todo_cron">周期 %1$s</string>
+ <string name="notebook_todo_paused">已暂停</string>
+
<!--
config/Scheduler.kt. `sched_channel_name` and `sched_channel_desc` are
the notification channel; see the KDoc on `channelName` for why a
@@ -462,4 +499,38 @@
<string name="ball_look_rabbit">贱贱兔</string>
<string name="ball_look_bear">憨憨熊</string>
<string name="ball_look_imp">小恶魔</string>
+
+
+ <!-- 首次引导向导 -->
+ <string name="wizard_title">首次设置</string>
+ <string name="wizard_progress_welcome">欢迎</string>
+ <string name="wizard_progress_step">第 %1$d 步,共 %2$d 步</string>
+ <string name="wizard_progress_done">完成</string>
+ <string name="wizard_cancel">取消</string>
+ <string name="wizard_back">上一步</string>
+ <string name="wizard_begin">开始</string>
+ <string name="wizard_next">下一步</string>
+ <string name="wizard_finish">完成设置</string>
+ <string name="wizard_done">开始使用</string>
+
+ <string name="wizard_welcome_title">欢迎</string>
+ <string name="wizard_welcome_body">接下来几步,把这台设备配好就能用了。每一步都需要你去开一个权限或填个设置,做完点「下一步」就行。</string>
+
+ <string name="wizard_wake_title">唤醒词</string>
+ <string name="wizard_wake_body">录一个唤醒词,亮屏时喊得醒。不录也能用,只是得点球。</string>
+ <string name="wizard_wake_button">去录</string>
+
+ <string name="wizard_look_title">看一眼周围</string>
+ <string name="wizard_look_body">让它看看你现在在哪儿,记住这个地方。之后问「我在哪」它就能答上来。</string>
+ <string name="wizard_look_button">打开摄像头</string>
+
+ <string name="wizard_sentence_title">说第一句话</string>
+ <string name="wizard_sentence_body">点球,说点什么 — 它会答你,配置就算完成了。</string>
+ <string name="wizard_sentence_button">点球说话</string>
+
+ <string name="wizard_complete_title">都配好了</string>
+ <string name="wizard_complete_body">去点球说话吧。长按球能回到全屏卡片,⚙ 里能改设置。</string>
+
+ <string name="check_page_rerun_wizard">重新设置</string>
+
</resources>
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 0f2794c..464a1d2 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -2,15 +2,15 @@
<!-- Base application theme. -->
<style name="Theme.Body" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
- <item name="colorPrimary">@color/purple_500</item>
- <item name="colorPrimaryVariant">@color/purple_700</item>
+ <item name="colorPrimary">@color/glass_tint</item>
+ <item name="colorPrimaryVariant">@color/glass_base</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
- <item name="colorSecondary">@color/teal_200</item>
- <item name="colorSecondaryVariant">@color/teal_700</item>
+ <item name="colorSecondary">@color/glass_accent</item>
+ <item name="colorSecondaryVariant">@color/glass_accent</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
- <item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
+ <item name="android:statusBarColor">@color/glass_base</item>
<!-- Customize your theme here. -->
</style>