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: GitHub and Discord link from the gesture line, and the Mac builds for Intel

booboosui3247285d36f6
diff --git a/.gitignore b/.gitignore
index dd561a4..ac5a610 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,6 @@ __pycache__/
# 而它和源页面几乎一样、很容易被误提交。两种后缀都要挡:
andee-website/*.probe.html
andee-website/*.degraded.html
+
+# JVM 崩溃日志(本地跑 Mac 版崩溃时落在仓库根目录的 hs_err_pid*.log),是临时产物不是源码。
+hs_err_pid*.log
diff --git a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
index 57cb938..78ca35c 100644
--- a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
+++ b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
@@ -327,6 +327,21 @@ class BodyCoreService : Service() {
window.setMuted(on)
}
+ override fun onOpenCommunityLink(url: String) {
+ // A link out of the card (GitHub, Discord). The overlay cannot
+ // open a browser itself — the background-launch restriction, and
+ // it would cover the browser anyway — so fold the card, park the
+ // ball, and hand the trip to SelfCheckActivity, which launches it
+ // from an Activity that can come back. Same shape as the
+ // self-check card's onErrand.
+ val there = android.content.Intent(
+ android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url),
+ )
+ window.setPagePerched(true)
+ net.kuafuai.andee.ui.SelfCheckActivity.showForErrand(this@BodyCoreService, there)
+ dispatcher.compactForUser()
+ }
+
override fun onNotebookClick() {
net.kuafuai.andee.ui.NotebookUi(this@BodyCoreService) {}.show()
}
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 0f8c0f5..22aabdb 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
@@ -165,6 +165,14 @@ class FloatingWindowUi(
/** The speaker key beside the input pill: answers read aloud or not. */
fun onMuteToggle() {}
+ /**
+ * A community link at the foot of the card (GitHub, Discord). Handed out
+ * rather than opened here for the same reason every outbound trip is:
+ * the card is an overlay and cannot start a browser Activity itself —
+ * the host folds the card and sends it through SelfCheckActivity.
+ */
+ fun onOpenCommunityLink(url: String) {}
+
/** The 小本本 key — what it remembers. See [NotebookUi]. */
fun onNotebookClick() {}
@@ -322,6 +330,29 @@ class FloatingWindowUi(
muteLabel?.text = AppLocale.str(context, if (mutedNow) R.string.window_muted else R.string.window_voice_on)
}
+ /**
+ * One small community glyph (GitHub, Discord) at the foot of the card. A
+ * padded hit target around a 16 dp vector, tinted like the gesture line it
+ * sits after; the tap hands the URL out through
+ * [Listeners.onOpenCommunityLink], which is the host's trip to make.
+ */
+ private fun communityLink(res: Int, url: String, label: String): View {
+ val icon = ImageView(context).apply {
+ setImageResource(res)
+ setColorFilter(Color.parseColor(Glass.PHOTO_INK))
+ contentDescription = label
+ }
+ return LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER
+ setPadding(dp(7), dp(4), dp(7), dp(4))
+ isClickable = true
+ Glass.pressable(this)
+ setOnClickListener { listeners.onOpenCommunityLink(url) }
+ addView(icon, LinearLayout.LayoutParams(dp(16), dp(16)))
+ }
+ }
+
/**
* The top bar's icon views, kept only so a theme change can re-tint them.
*
@@ -2476,12 +2507,21 @@ class FloatingWindowUi(
// 1:1, which is why it disappeared. See [Glass.PHOTO_INK].
setTextColor(Color.parseColor(Glass.PHOTO_INK))
gravity = Gravity.CENTER
- // The bottom padding clears the gesture bar, the same 30 dp the
- // scrollback's last row used to reserve for itself — this bar
- // inherits that edge of the card.
- setPadding(dp(14), dp(6), dp(14), dp(30))
}
tipsText = tipsLine
+ // GitHub and Discord, small glyphs after the gesture line — the project's
+ // home, where a person looking for "about this thing" expects it, not a
+ // knob buried in 设置. The bottom padding (clearing the gesture bar, the
+ // same 30 dp the scrollback's last row used to reserve) moves onto this
+ // row so the glyphs share the line's edge.
+ val communityRow = LinearLayout(context).apply {
+ orientation = LinearLayout.HORIZONTAL
+ gravity = Gravity.CENTER
+ setPadding(dp(14), dp(6), dp(14), dp(30))
+ }
+ communityRow.addView(tipsLine)
+ communityRow.addView(communityLink(R.drawable.ic_github, GITHUB_URL, "GitHub"))
+ communityRow.addView(communityLink(R.drawable.ic_discord, DISCORD_URL, "Discord"))
// The input pill, always there on the full card like the Mac's composer. It is not a field: an overlay
// cannot raise the keyboard on this ROM, so a tap opens the real one ([TextInputActivity]) in its place.
val inputRow = LinearLayout(context).apply {
@@ -2512,7 +2552,7 @@ class FloatingWindowUi(
orientation = LinearLayout.VERTICAL
visibility = View.GONE
addView(inputRow, LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT))
- addView(tipsLine, LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT))
+ addView(communityRow, LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT))
}
tipsView = tips
root.addView(
@@ -3013,6 +3053,10 @@ class FloatingWindowUi(
}
companion object {
+ /** The project's public home, opened from the foot of the card. */
+ private const val GITHUB_URL = "https://github.com/kuafuai/andee"
+ private const val DISCORD_URL = "https://discord.gg/PYujCQyqu"
+
/**
* Taps in a row that mean "stop". The ball's whole vocabulary, in one
* place: one tap asks, two type, three stop. Long-press is not part of
diff --git a/app/src/main/res/drawable/ic_discord.xml b/app/src/main/res/drawable/ic_discord.xml
new file mode 100644
index 0000000..96c42aa
--- /dev/null
+++ b/app/src/main/res/drawable/ic_discord.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.317,4.37a19.791,19.791 0,0 0,-4.885 -1.515,0.074 0.074,0 0,0 -0.079,0.037c-0.21,0.375 -0.444,0.864 -0.608,1.25a18.27,18.27 0,0 0,-5.487 0,12.64 12.64,0 0,0 -0.617,-1.25 0.077,0.077 0,0 0,-0.079 -0.037A19.736,19.736 0,0 0,3.677 4.37a0.07,0.07 0,0 0,-0.032 0.027C0.533,9.046 -0.32,13.58 0.099,18.057a0.082,0.082 0,0 0,0.031 0.057,19.9 19.9,0 0,0 5.993,3.03 0.078,0.078 0,0 0,0.084 -0.028c0.462,-0.63 0.874,-1.295 1.226,-1.994a0.076,0.076 0,0 0,-0.041 -0.106,13.107 13.107,0 0,1 -1.872,-0.892 0.077,0.077 0,0 1,-0.008 -0.128c0.126,-0.094 0.252,-0.192 0.372,-0.291a0.074,0.074 0,0 1,0.077 -0.01c3.928,1.793 8.18,1.793 12.062,0a0.074,0.074 0,0 1,0.078 0.01c0.12,0.098 0.246,0.198 0.373,0.292a0.077,0.077 0,0 1,-0.006 0.127,12.3 12.3,0 0,1 -1.873,0.892 0.077,0.077 0,0 0,-0.041 0.107c0.36,0.698 0.772,1.362 1.225,1.993a0.076,0.076 0,0 0,0.084 0.028,19.84 19.84,0 0,0 6.002,-3.03 0.077,0.077 0,0 0,0.032 -0.054c0.5,-5.177 -0.838,-9.674 -3.549,-13.66a0.061,0.061 0,0 0,-0.031 -0.03zM8.02,15.33c-1.183,0 -2.157,-1.085 -2.157,-2.419 0,-1.333 0.956,-2.419 2.157,-2.419 1.21,0 2.176,1.096 2.157,2.42 0,1.333 -0.956,2.418 -2.157,2.418zM15.98,15.33c-1.183,0 -2.157,-1.085 -2.157,-2.419 0,-1.333 0.955,-2.419 2.157,-2.419 1.21,0 2.176,1.096 2.157,2.42 0,1.333 -0.946,2.418 -2.157,2.418z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_github.xml b/app/src/main/res/drawable/ic_github.xml
new file mode 100644
index 0000000..eb8e849
--- /dev/null
+++ b/app/src/main/res/drawable/ic_github.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,0C5.37,0 0,5.37 0,12c0,5.31 3.435,9.795 8.205,11.385c0.6,0.105 0.825,-0.255 0.825,-0.57c0,-0.285 -0.015,-1.23 -0.015,-2.235c-3.015,0.555 -3.795,-0.735 -4.035,-1.41c-0.135,-0.345 -0.72,-1.41 -1.23,-1.695c-0.42,-0.225 -1.02,-0.78 -0.015,-0.795c0.945,-0.015 1.62,0.87 1.845,1.23c1.08,1.815 2.805,1.305 3.495,0.99c0.105,-0.78 0.42,-1.305 0.765,-1.605c-2.67,-0.3 -5.46,-1.335 -5.46,-5.925c0,-1.305 0.465,-2.385 1.23,-3.225c-0.12,-0.3 -0.54,-1.53 0.12,-3.18c0,0 1.005,-0.315 3.3,1.23c0.96,-0.27 1.98,-0.405 3,-0.405s2.04,0.135 3,0.405c2.295,-1.56 3.3,-1.23 3.3,-1.23c0.66,1.65 0.24,2.88 0.12,3.18c0.765,0.84 1.23,1.905 1.23,3.225c0,4.605 -2.805,5.625 -5.475,5.925c0.435,0.375 0.81,1.095 0.81,2.22c0,1.605 -0.015,2.895 -0.015,3.3c0,0.315 0.225,0.69 0.825,0.57C20.565,21.795 24,17.31 24,12c0,-6.63 -5.37,-12 -12,-12z"/>
+</vector>
diff --git a/desktop/build.gradle b/desktop/build.gradle
index cacc48f..d50c89b 100644
--- a/desktop/build.gradle
+++ b/desktop/build.gradle
@@ -13,7 +13,17 @@ kotlin {
jvmToolchain(17)
}
-// Native helpers, compiled with the Command Line Tools' swiftc (arm64).
+// Native helpers, compiled with the Command Line Tools' swiftc.
+//
+// The Mac this is built for: x86_64 (Intel) or arm64 (Apple Silicon). The Swift
+// bridge and the LWJGL natives must both match it, or the app fails to start
+// with "incompatible architecture". `os.arch` is 'x86_64' on Intel and
+// 'aarch64' on Apple Silicon.
+def osArch = System.getProperty('os.arch')
+def swiftTarget = (osArch == 'aarch64') ? 'arm64-apple-macos14' : 'x86_64-apple-macos14'
+// LWJGL's Intel macOS classifier is plain 'natives-macos' (no x64 suffix); only
+// arm64 gets the '-arm64' suffix.
+def lwjglNatives = (osArch == 'aarch64') ? 'natives-macos-arm64' : 'natives-macos'
def nativeOut = layout.buildDirectory.dir('native')
tasks.register('buildTrashTool', Exec) {
def src = file('native/trash.swift')
@@ -21,7 +31,7 @@ tasks.register('buildTrashTool', Exec) {
inputs.file(src)
outputs.file(out)
doFirst { out.parentFile.mkdirs() }
- commandLine 'swiftc', '-O', '-target', 'arm64-apple-macos14', src.path, '-o', out.path
+ commandLine 'swiftc', '-O', '-target', swiftTarget, src.path, '-o', out.path
}
// The bridge JNA loads: accessibility tree, input events, ScreenCaptureKit, workspace.
tasks.register('buildBridge', Exec) {
@@ -30,7 +40,7 @@ tasks.register('buildBridge', Exec) {
inputs.file(src)
outputs.file(out)
doFirst { out.parentFile.mkdirs() }
- commandLine 'swiftc', '-O', '-target', 'arm64-apple-macos14', '-emit-library', '-framework', 'CoreDisplay', '-framework', 'CoreLocation', src.path, '-o', out.path
+ commandLine 'swiftc', '-O', '-target', swiftTarget, '-emit-library', '-framework', 'CoreDisplay', '-framework', 'CoreLocation', src.path, '-o', out.path
}
tasks.register('buildNative') { dependsOn('buildTrashTool', 'buildBridge') }
sourceSets.main.resources.srcDir(nativeOut)
@@ -52,8 +62,8 @@ dependencies {
// LWJGL: OpenGL and CGL for the ball's offscreen renderer (no GLFW — see BallRenderer).
implementation 'org.lwjgl:lwjgl:3.3.4'
implementation 'org.lwjgl:lwjgl-opengl:3.3.4'
- implementation "org.lwjgl:lwjgl:3.3.4:natives-macos-arm64"
- implementation "org.lwjgl:lwjgl-opengl:3.3.4:natives-macos-arm64"
+ implementation "org.lwjgl:lwjgl:3.3.4:${lwjglNatives}"
+ implementation "org.lwjgl:lwjgl-opengl:3.3.4:${lwjglNatives}"
testImplementation libs.junit
}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
index 9eafb4a..fadc67d 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
@@ -109,6 +109,14 @@ object Palette {
val card get() = cardSolid
}
+/** The project's public home, opened from the gesture line under the composer. */
+private const val GITHUB_URL = "https://github.com/kuafuai/andee"
+private const val DISCORD_URL = "https://discord.gg/PYujCQyqu"
+
+private fun openLink(url: String) {
+ runCatching { net.kuafuai.andee.desktop.mac.Bridge.open(url) }
+}
+
@OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class)
@Composable
fun ChatScreen(onOpenArtifacts: () -> Unit, onOpenTopic: (Long) -> Unit = {}, onContinueTopic: (Scrollback.Topic) -> Unit = {}) {
@@ -294,12 +302,20 @@ fun ChatScreen(onOpenArtifacts: () -> Unit, onOpenTopic: (Long) -> Unit = {}, on
onSend = { send() },
)
// The ball's whole vocabulary, pinned where the eye ends up — the phone's line under its card.
- Text(
- if (Strings.lang() == "zh") "点小球说话 · 双击打字 · 左右拖动切换形象"
- else "Tap the ball to talk · double-tap to type · drag sideways to switch character",
- color = Palette.photoInk, fontSize = 11.sp, textAlign = androidx.compose.ui.text.style.TextAlign.Center,
- modifier = Modifier.fillMaxWidth().padding(top = 2.dp, bottom = 8.dp),
- )
+ // GitHub and Discord sit after it, the same place the phone puts them: the project's home.
+ Row(
+ Modifier.fillMaxWidth().padding(top = 2.dp, bottom = 8.dp),
+ horizontalArrangement = Arrangement.Center,
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(
+ if (Strings.lang() == "zh") "点小球说话 · 双击打字 · 左右拖动切换形象"
+ else "Tap the ball to talk · double-tap to type · drag sideways to switch character",
+ color = Palette.photoInk, fontSize = 11.sp,
+ )
+ Box(Modifier.clickable { openLink(GITHUB_URL) }.padding(horizontal = 5.dp, vertical = 2.dp)) { Icon(AndeeIcon.GITHUB, Palette.photoInk, 13.dp) }
+ Box(Modifier.clickable { openLink(DISCORD_URL) }.padding(horizontal = 5.dp, vertical = 2.dp)) { Icon(AndeeIcon.DISCORD, Palette.photoInk, 13.dp) }
+ }
}
if (dropping) {
Box(
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Icons.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Icons.kt
index d5c98dd..245abc3 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Icons.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Icons.kt
@@ -52,6 +52,10 @@ enum class AndeeIcon(val d: String, val filled: Boolean = false) {
CLOSE("M18 6 6 18 M0 0m6 6 12 12"),
CHEVRON("m9 18 6-6-6-6"),
CHECK("M20 6 9 17l-5-5"),
+ /** GitHub mark (octocat), filled. */
+ GITHUB("M12,0C5.37,0 0,5.37 0,12c0,5.31 3.435,9.795 8.205,11.385c0.6,0.105 0.825,-0.255 0.825,-0.57c0,-0.285 -0.015,-1.23 -0.015,-2.235c-3.015,0.555 -3.795,-0.735 -4.035,-1.41c-0.135,-0.345 -0.72,-1.41 -1.23,-1.695c-0.42,-0.225 -1.02,-0.78 -0.015,-0.795c0.945,-0.015 1.62,0.87 1.845,1.23c1.08,1.815 2.805,1.305 3.495,0.99c0.105,-0.78 0.42,-1.305 0.765,-1.605c-2.67,-0.3 -5.46,-1.335 -5.46,-5.925c0,-1.305 0.465,-2.385 1.23,-3.225c-0.12,-0.3 -0.54,-1.53 0.12,-3.18c0,0 1.005,-0.315 3.3,1.23c0.96,-0.27 1.98,-0.405 3,-0.405s2.04,0.135 3,0.405c2.295,-1.56 3.3,-1.23 3.3,-1.23c0.66,1.65 0.24,2.88 0.12,3.18c0.765,0.84 1.23,1.905 1.23,3.225c0,4.605 -2.805,5.625 -5.475,5.925c0.435,0.375 0.81,1.095 0.81,2.22c0,1.605 -0.015,2.895 -0.015,3.3c0,0.315 0.225,0.69 0.825,0.57C20.565,21.795 24,17.31 24,12c0,-6.63 -5.37,-12 -12,-12z", filled = true),
+ /** Discord mark, filled. */
+ DISCORD("M20.317,4.37a19.791,19.791 0,0 0,-4.885 -1.515,0.074 0.074,0 0,0 -0.079,0.037c-0.21,0.375 -0.444,0.864 -0.608,1.25a18.27,18.27 0,0 0,-5.487 0,12.64 12.64,0 0,0 -0.617,-1.25 0.077,0.077 0,0 0,-0.079 -0.037A19.736,19.736 0,0 0,3.677 4.37a0.07,0.07 0,0 0,-0.032 0.027C0.533,9.046 -0.32,13.58 0.099,18.057a0.082,0.082 0,0 0,0.031 0.057,19.9 19.9,0 0,0 5.993,3.03 0.078,0.078 0,0 0,0.084 -0.028c0.462,-0.63 0.874,-1.295 1.226,-1.994a0.076,0.076 0,0 0,-0.041 -0.106,13.107 13.107,0 0,1 -1.872,-0.892 0.077,0.077 0,0 1,-0.008 -0.128c0.126,-0.094 0.252,-0.192 0.372,-0.291a0.074,0.074 0,0 1,0.077 -0.01c3.928,1.793 8.18,1.793 12.062,0a0.074,0.074 0,0 1,0.078 0.01c0.12,0.098 0.246,0.198 0.373,0.292a0.077,0.077 0,0 1,-0.006 0.127,12.3 12.3,0 0,1 -1.873,0.892 0.077,0.077 0,0 0,-0.041 0.107c0.36,0.698 0.772,1.362 1.225,1.993a0.076,0.076 0,0 0,0.084 0.028,19.84 19.84,0 0,0 6.002,-3.03 0.077,0.077 0,0 0,0.032 -0.054c0.5,-5.177 -0.838,-9.674 -3.549,-13.66a0.061,0.061 0,0 0,-0.031 -0.03zM8.02,15.33c-1.183,0 -2.157,-1.085 -2.157,-2.419 0,-1.333 0.956,-2.419 2.157,-2.419 1.21,0 2.176,1.096 2.157,2.42 0,1.333 -0.956,2.418 -2.157,2.418zM15.98,15.33c-1.183,0 -2.157,-1.085 -2.157,-2.419 0,-1.333 0.955,-2.419 2.157,-2.419 1.21,0 2.176,1.096 2.157,2.42 0,1.333 -0.946,2.418 -2.157,2.418z", filled = true),
;
}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
index 60c19ec..e1fd865 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Main.kt
@@ -21,6 +21,13 @@ import java.util.Date
import java.util.Locale
fun main() {
+ // Intel Mac: skiko's Metal renderer crashes (SIGILL in
+ // MetalRedrawer.createMetalDevice) on these machines, so fall back to
+ // software rendering. Apple Silicon keeps the hardware Metal path. Must run
+ // before any SkiaLayer is created, so before `application { }` below.
+ if (System.getProperty("os.arch") in setOf("x86_64", "amd64")) {
+ System.setProperty("skiko.renderApi", "SOFTWARE")
+ }
installFileLog()
net.kuafuai.andee.util.Log.i("Andee", "starting, data in ${AppDirs.root}")
Assistant.askApproval = { ApprovalGate.request(it) }