From c3d32f79a7b1bc65d7e5e947fbe6ab4c3539f613 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 19 Sep 2019 17:28:15 -0400 Subject: [PATCH] Use app.DataDir() to get config directory on Android. Use an Inset to stay inside the OS window insets. --- cmd/passgo-gui/impl_android.go | 11 ++++------- cmd/passgo-gui/main.go | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cmd/passgo-gui/impl_android.go b/cmd/passgo-gui/impl_android.go index ea4742d..84c9f41 100644 --- a/cmd/passgo-gui/impl_android.go +++ b/cmd/passgo-gui/impl_android.go @@ -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") } } diff --git a/cmd/passgo-gui/main.go b/cmd/passgo-gui/main.go index 4f47e6a..bfb43b0 100644 --- a/cmd/passgo-gui/main.go +++ b/cmd/passgo-gui/main.go @@ -49,10 +49,12 @@ func main() { } store.Dir = Config.StoreDir log(Info, " StoreDir = ", store.Dir) - err = passgo.GetStore(&store) - if err != nil { - log(Info, err) - } + 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")