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:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
+84
@@ -0,0 +1,84 @@
|
||||
package mobile
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/egoist/mygo/internal/mobile/wire"
|
||||
"github.com/egoist/mygo/internal/platform"
|
||||
)
|
||||
|
||||
// What phones and tablets have that desktops don't (platform.DeviceBackend).
|
||||
|
||||
func (b *Backend) Haptic(kind string) { b.call(&wire.Haptic{Kind: kind}, nil) }
|
||||
|
||||
func (b *Backend) SetSystemBars(style string, hidden bool) {
|
||||
b.call(&wire.SetSystemBars{Style: style, Hidden: hidden}, nil)
|
||||
}
|
||||
|
||||
func (b *Backend) SetOrientations(mask uint32) { b.call(&wire.SetOrientations{Mask: int(mask)}, nil) }
|
||||
|
||||
func (b *Backend) Share(s platform.ShareRequest, done func(error)) {
|
||||
req := b.request(func(r wire.Reader) {
|
||||
var e wire.ShareResultEvent
|
||||
e.Decode(&r)
|
||||
done(errorOf(e.Error))
|
||||
})
|
||||
b.call(&wire.Share{Req: req, Text: s.Text, URL: s.URL, Paths: s.Paths, X: s.X, Y: s.Y}, nil)
|
||||
}
|
||||
|
||||
func (b *Backend) SaveFile(path, name string, done func(string, error)) {
|
||||
req := b.request(func(r wire.Reader) {
|
||||
var e wire.FilesResultEvent
|
||||
e.Decode(&r)
|
||||
saved := ""
|
||||
if len(e.Paths) > 0 {
|
||||
saved = e.Paths[0]
|
||||
}
|
||||
done(saved, errorOf(e.Error))
|
||||
})
|
||||
b.call(&wire.SaveFile{Req: req, Path: path, Name: name}, nil)
|
||||
}
|
||||
|
||||
func (b *Backend) Battery() platform.BatteryStatus {
|
||||
var r wire.BatteryReply
|
||||
b.call(&wire.Battery{}, &r)
|
||||
return platform.BatteryStatus{Level: r.Level, Charging: r.Charging, LowPower: r.LowPower}
|
||||
}
|
||||
|
||||
func (b *Backend) SetBarItems(pw platform.Window, items []platform.BarItem) {
|
||||
w, ok := pw.(*window)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
w.barItems = items
|
||||
m := wire.SetBarItems{ID: w.id}
|
||||
for _, it := range items {
|
||||
m.Titles = append(m.Titles, it.Title)
|
||||
m.Symbols = append(m.Symbols, it.Symbol)
|
||||
m.Icons = append(m.Icons, base64.StdEncoding.EncodeToString(it.Icon))
|
||||
}
|
||||
b.call(&m, nil)
|
||||
}
|
||||
|
||||
func (b *Backend) PluginCall(plugin, method string, args []byte, done func([]byte, error)) {
|
||||
req := b.request(func(r wire.Reader) {
|
||||
var e wire.PluginResultEvent
|
||||
e.Decode(&r)
|
||||
if e.Error != "" || e.Code != "" {
|
||||
done(nil, &platform.PluginError{Code: e.Code, Message: e.Error})
|
||||
return
|
||||
}
|
||||
done([]byte(e.Result), nil)
|
||||
})
|
||||
b.call(&wire.PluginCall{Req: req, Plugin: plugin, Method: method, Args: string(args)}, nil)
|
||||
}
|
||||
|
||||
func (b *Backend) OnPluginEvent(fn func(plugin, name string, data []byte)) { b.pluginEvents = fn }
|
||||
|
||||
// StartedHidden reports whether the system started the app for something in the
|
||||
// background, and it hasn't shown yet.
|
||||
func (b *Backend) StartedHidden() bool { return b.startedHidden }
|
||||
|
||||
// WasEndedBySystem reports whether this launch follows the system ending the
|
||||
// app, rather than the user.
|
||||
func (b *Backend) WasEndedBySystem() bool { return b.appInfo().Restoring }
|
||||
Reference in new issue
Block a user