feat: port the client to MyGo native UI (0.3.0)

Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
This commit is contained in:
OpenChamber committed 2026-11-18 13:22:59 +08:00
1 parent 2fb4a8ea79
commit 6c0ee61750
2538 files changed
+675779 -4792

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
// Package location tells where the device is, on phones and tablets: Core
// Location on iOS, and LocationManager on Android, without Google's services.
// Importing it adds the permissions it needs to the app, with a usage
// description on iOS that ios.infoPlist in the app's configuration replaces:
//
// "NSLocationWhenInUseUsageDescription": "Shows nearby stores."
//
// Elsewhere its functions report errors.ErrUnsupported.
package location
import (
"context"
"encoding/json"
"time"
"github.com/egoist/mygo"
)
const pluginID = "location"
// Fix is a place the device was at.
type Fix struct {
// Latitude and Longitude are in degrees.
Latitude, Longitude float64
// Altitude is in meters above sea level, Speed in meters a second, and
// Heading in degrees clockwise from north; negative where not known.
Altitude, Speed, Heading float64
// Accuracy is how far off it may be, in meters.
Accuracy float64
// Time is when it was measured.
Time time.Time
}
type wireFix struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Altitude float64 `json:"altitude"`
Speed float64 `json:"speed"`
Heading float64 `json:"heading"`
Accuracy float64 `json:"accuracy"`
TimeMS int64 `json:"time"`
}
func (w wireFix) fix() Fix {
return Fix{w.Latitude, w.Longitude, w.Altitude, w.Speed, w.Heading, w.Accuracy, time.UnixMilli(w.TimeMS)}
}
// RequestPermission asks the user to let the app know where the device is,
// the first time, and reports whether it may. Call it off the main goroutine,
// as it waits for the user.
func RequestPermission(ctx context.Context) (bool, error) {
var r struct {
Granted bool `json:"granted"`
}
err := mygo.Native(pluginID).Call(ctx, "requestPermission", nil, &r)
return r.Granted, err
}
// Current finds where the device is now, asking for permission if it must.
func Current(ctx context.Context) (Fix, error) {
var w wireFix
if err := mygo.Native(pluginID).Call(ctx, "current", nil, &w); err != nil {
return Fix{}, err
}
return w.fix(), nil
}
// Watch calls fn on the main thread as the device moves, until stop is called.
func Watch(ctx context.Context, fn func(Fix)) (stop func(), err error) {
p := mygo.Native(pluginID)
off := p.On("fix", func(data []byte) {
var w wireFix
if json.Unmarshal(data, &w) == nil {
fn(w.fix())
}
})
if err := p.Call(ctx, "start", nil, nil); err != nil {
off()
return nil, err
}
return func() {
off()
go p.Call(context.Background(), "stop", nil, nil)
}, nil
}