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.
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
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 }
|