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

View File

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