Use app.DataDir() to get config directory on Android. Use an

Inset to stay inside the OS window insets.
This commit is contained in:
Greg 2019-09-19 17:28:15 -04:00
parent cdce91e0ba
commit c3d32f79a7
2 changed files with 17 additions and 12 deletions

View File

@ -4,24 +4,19 @@ package main
import (
"os"
"os/user"
"path"
"golang.org/x/image/font/gofont/goregular"
"golang.org/x/image/font/sfnt"
)
func init() {
log(Info, "Android start")
var err error
regular, err = sfnt.Parse(goregular.TTF)
if err != nil {
log(Fatal, "Cannot parse default font: ", err)
}
usr, err := user.Current()
if err != nil {
log(Fatal, "Cannot get current user: ", err)
}
confDir = path.Join(usr.HomeDir, ".config/passgo")
confDir = app.DataDir()
if _, err := os.Stat(confDir); os.IsNotExist(err) {
err = os.MkdirAll(confDir, 0700)
if err != nil {
@ -30,5 +25,7 @@ func init() {
} else {
log(Info, "Configuration directory created")
}
} else {
log(Info, "Configuration directory found")
}
}

View File

@ -49,10 +49,12 @@ func main() {
}
store.Dir = Config.StoreDir
log(Info, " StoreDir = ", store.Dir)
go func() {
err = passgo.GetStore(&store)
if err != nil {
log(Info, err)
}
}()
if Config.ClearDelay == 0 {
Config.ClearDelay = 45
}
@ -163,6 +165,7 @@ func eventLoop() {
var c1 layout.FlexChild // flex child for title bar
face := faces.For(regular, ui.Sp(16))
sysinset := &layout.Inset{}
margin := layout.UniformInset(ui.Dp(10))
title := &text.Label{Face: face, Text: "passgo"}
@ -629,6 +632,11 @@ func eventLoop() {
ops.Reset()
faces.Reset(c)
cs = layout.RigidConstraints(e.Size)
sysinset.Top = e.Insets.Top
sysinset.Bottom = e.Insets.Bottom
sysinset.Left = e.Insets.Left
sysinset.Right = e.Insets.Right
cs = sysinset.Begin(c, ops, cs)
cs = margin.Begin(c, ops, cs)
margincs = cs
flex.Init(ops, cs)
@ -645,7 +653,7 @@ func eventLoop() {
page()
margin.End(dims)
sysinset.End(margin.End(dims))
if dotsBtn.Clicked() {
log(Info, "Configure")