2020-08-29 19:52:51 -04:00
|
|
|
//+build android
|
2019-09-06 11:43:14 -04:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2019-11-20 14:30:43 -05:00
|
|
|
"git.wow.st/gmp/passgo"
|
|
|
|
"gioui.org/app"
|
2020-08-29 19:52:51 -04:00
|
|
|
"gioui.org/io/event"
|
2019-09-06 11:43:14 -04:00
|
|
|
)
|
|
|
|
|
2019-11-20 15:48:56 -05:00
|
|
|
var (
|
|
|
|
noidLabelText = "Enter a GPG key ID above"
|
|
|
|
)
|
|
|
|
|
2019-09-06 11:43:14 -04:00
|
|
|
func init() {
|
2019-09-19 17:28:15 -04:00
|
|
|
log(Info, "Android start")
|
2019-11-20 14:30:43 -05:00
|
|
|
// Use a larger font on Android
|
|
|
|
fontSize = 24
|
|
|
|
}
|
|
|
|
|
2020-08-29 19:52:51 -04:00
|
|
|
func handleEvent(e event.Event) {
|
|
|
|
switch e := e.(type) {
|
|
|
|
case app.ViewEvent:
|
|
|
|
initPgp(e.View)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func initPgp(view uintptr) {
|
|
|
|
passgo.InitPgp(view)
|
2019-11-20 14:30:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func getConfDir() (string, error) {
|
|
|
|
ret, err := app.DataDir()
|
2019-09-06 11:43:14 -04:00
|
|
|
if err != nil {
|
2019-11-20 14:30:43 -05:00
|
|
|
log(Error, "Cannot get data directory:", err)
|
|
|
|
return "", err
|
2019-09-06 11:43:14 -04:00
|
|
|
}
|
2019-11-20 14:30:43 -05:00
|
|
|
if _, err := os.Stat(ret); os.IsNotExist(err) {
|
|
|
|
err = os.MkdirAll(ret, 0700)
|
2019-09-06 11:43:14 -04:00
|
|
|
if err != nil {
|
2019-11-20 14:30:43 -05:00
|
|
|
log(Error, "Cannot create configuration directory ", ret)
|
|
|
|
return "", err
|
2019-09-06 11:43:14 -04:00
|
|
|
} else {
|
|
|
|
log(Info, "Configuration directory created")
|
2019-11-20 14:30:43 -05:00
|
|
|
return ret, nil
|
2019-09-06 11:43:14 -04:00
|
|
|
}
|
2019-09-19 17:28:15 -04:00
|
|
|
} else {
|
|
|
|
log(Info, "Configuration directory found")
|
2019-11-20 14:30:43 -05:00
|
|
|
return ret, nil
|
2019-09-06 11:43:14 -04:00
|
|
|
}
|
|
|
|
}
|