passgo/cmd/passgo-gui/impl_android.go
Greg Pomerantz e7218b1efd Complete the Gio v0.10.2 GUI migration (working on Android).
- Event loop: call w.Event() and FrameEvent.Frame() on the same
  goroutine; no channel bridge (the bridge broke frame rendering).
- clip: use clip.UniformRRect(...).Push(gtx.Ops) / Pop() for real
  clipping in layoutRRect (old .Add(ops) painted unclipped).
- Window clear color is white in v0.10.2.
- Fonts: always provide gofont; on Android use
  WithCollection(gofont.Collection()).
- Button labels: explicitly set Color (zero-value NRGBA has A=0,
  i.e. transparent, so labels were invisible).
- Filter: detect changes by comparing the editor text, since
  material.Editor.Layout consumes the editor's input events
  internally and a later FilterEd.Update(gtx) never sees them.
- idPage: persist the manually entered ID with store.SetID (on
  Android nativeIdentities is unimplemented, so there are no id
  buttons to click).
- Use U+2026 (gofont) instead of U+22EE (not in gofont) for the
  menu button.
- Split getConfDir/noidLabelText out into impl_linux.go for the
  Linux build.
2026-08-21 13:00:35 -04:00

60 lines
1.1 KiB
Go

//go:build android
package main
import (
"os"
"gioui.org/app"
"gioui.org/io/event"
"git.wow.st/gmp/passgo"
)
var (
noidLabelText = "Enter a GPG key ID above"
)
func init() {
log(Info, "Android start")
// Use a larger font on Android
fontSize = 24
}
func handleEvent(e event.Event) {
switch e := e.(type) {
case app.AndroidViewEvent:
// A zero View means the view is detached (e.g. the activity going
// away on a recents-wipe); there is nothing to register for a
// detached view. A re-attach arrives as a fresh event with a live
// view.
if e.View != 0 {
initPgp(e.View)
}
}
}
func initPgp(view uintptr) {
passgo.InitPgp(view)
}
func getConfDir() (string, error) {
ret, err := app.DataDir()
if err != nil {
log(Error, "Cannot get data directory:", err)
return "", err
}
if _, err := os.Stat(ret); os.IsNotExist(err) {
err = os.MkdirAll(ret, 0700)
if err != nil {
log(Error, "Cannot create configuration directory ", ret)
return "", err
} else {
log(Info, "Configuration directory created")
return ret, nil
}
} else {
log(Info, "Configuration directory found")
return ret, nil
}
}