Improve handling of missing user-IDs.
This commit is contained in:
parent
47ffd8f160
commit
a1d9ffa6c6
|
@ -9,6 +9,10 @@ import (
|
|||
"gioui.org/app"
|
||||
)
|
||||
|
||||
var (
|
||||
noidLabelText = "Enter a GPG key ID above"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log(Info, "Android start")
|
||||
// Use a larger font on Android
|
||||
|
|
|
@ -10,6 +10,10 @@ import (
|
|||
"gioui.org/app"
|
||||
)
|
||||
|
||||
var (
|
||||
noidLabelText = "No GPG ids available. Please create a private key or enter a key ID above"
|
||||
)
|
||||
|
||||
/*func setFont() error {
|
||||
f, err := os.Open("/System/Library/Fonts/AppleSDGothicNeo.ttc")
|
||||
if err != nil {
|
||||
|
|
|
@ -126,7 +126,7 @@ var (
|
|||
)
|
||||
|
||||
func Updater() {
|
||||
time.Sleep(time.Second * 2)
|
||||
//time.Sleep(time.Second * 2)
|
||||
update := func() {
|
||||
fmt.Printf("update()\n")
|
||||
ltmp, err := store.List()
|
||||
|
@ -197,7 +197,7 @@ func eventLoop() {
|
|||
app.Size(unit.Dp(250), unit.Dp(500)),
|
||||
app.Title("passgo"))
|
||||
gtx := &layout.Context{Queue: w.Queue()}
|
||||
time.Sleep(time.Second/5)
|
||||
//time.Sleep(time.Second/5)
|
||||
|
||||
var margincs layout.Constraints
|
||||
|
||||
|
@ -254,12 +254,10 @@ func eventLoop() {
|
|||
}
|
||||
mux.Unlock()
|
||||
}
|
||||
updateBtns()
|
||||
|
||||
idBtns := make([]*Button, 0)
|
||||
|
||||
updateIdBtns := func() {
|
||||
//return
|
||||
log(Info,"passgo.Identities()")
|
||||
ids, err := passgo.Identities()
|
||||
if err != nil {
|
||||
|
@ -339,7 +337,7 @@ func eventLoop() {
|
|||
passvalLabel := th.Label(unit.Sp(fontSize), "password value:")
|
||||
passvalEd := &widget.Editor{ SingleLine: true, Submit: true }
|
||||
|
||||
noidLabel := th.Label(unit.Sp(fontSize), "No GPG ids available. Please create a private key")
|
||||
noidLabel := th.Label(unit.Sp(fontSize), noidLabelText)
|
||||
idLabel := th.Label(unit.Sp(fontSize), "Select ID")
|
||||
|
||||
anim := &time.Ticker{}
|
||||
|
@ -385,10 +383,10 @@ func eventLoop() {
|
|||
w.Invalidate()
|
||||
page = confPage
|
||||
}
|
||||
//case store.Id == "":
|
||||
// idLabel.Layout(gtx)
|
||||
// w.Invalidate()
|
||||
// //page = idPage
|
||||
case store.Id == "":
|
||||
idLabel.Layout(gtx)
|
||||
w.Invalidate()
|
||||
page = idPage
|
||||
default:
|
||||
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
|
||||
lst.Layout(gtx, len(passBtns), func(i int) {
|
||||
|
@ -479,21 +477,71 @@ func eventLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
updateBtn := &Button{
|
||||
Size: unit.Sp(fontSize),
|
||||
Label: "Update",
|
||||
Alignment: text.Middle,
|
||||
Color: black,
|
||||
Background: gray,
|
||||
}
|
||||
idEd := &widget.Editor{SingleLine: true, Submit: true}
|
||||
idSubmitBtn := &Button{
|
||||
Size: unit.Sp(fontSize),
|
||||
Label: "Submit",
|
||||
Alignment: text.Middle,
|
||||
Color: black,
|
||||
Background: gray,
|
||||
}
|
||||
|
||||
idPage = func() {
|
||||
log(Info,"idPage()")
|
||||
if !animating {
|
||||
animOn()
|
||||
}
|
||||
c2 := flex.Rigid(gtx, func() {
|
||||
idLabel.Layout(gtx)
|
||||
})
|
||||
//if len(idBtns) == 0 {
|
||||
updateIdBtns()
|
||||
//}
|
||||
c3 := flex.Rigid(gtx, func() {
|
||||
if len(idBtns) == 0 { // still zero after update
|
||||
var c3 layout.FlexChild
|
||||
var c4 layout.FlexChild
|
||||
var c5 layout.FlexChild
|
||||
var c6 layout.FlexChild
|
||||
var c7 layout.FlexChild
|
||||
if len(idBtns) == 0 {
|
||||
c3 = flex.Rigid(gtx, func() {
|
||||
updateBtn.Layout(gtx)
|
||||
})
|
||||
if updateBtn.Clicked() {
|
||||
updateIdBtns()
|
||||
w.Invalidate()
|
||||
}
|
||||
c4 = flex.Rigid(gtx, func() {
|
||||
th.Editor("id").Layout(gtx, idEd)
|
||||
})
|
||||
for _, e := range idEd.Events(gtx) {
|
||||
switch e.(type) {
|
||||
case widget.SubmitEvent:
|
||||
log(Info, "Submit")
|
||||
store.Id = idEd.Text()
|
||||
page = listPage
|
||||
}
|
||||
}
|
||||
c5 = flex.Rigid(gtx, func() {
|
||||
idSubmitBtn.Layout(gtx)
|
||||
})
|
||||
if idSubmitBtn.Clicked() {
|
||||
store.Id = idEd.Text()
|
||||
page = listPage
|
||||
}
|
||||
c6 = flex.Rigid(gtx, func() {
|
||||
noidLabel.Layout(gtx)
|
||||
} else {
|
||||
})
|
||||
} else {
|
||||
c3 = flex.Rigid(gtx, func() { })
|
||||
c4 = flex.Rigid(gtx, func() { })
|
||||
c5 = flex.Rigid(gtx, func() { })
|
||||
c6 = flex.Rigid(gtx, func() { })
|
||||
}
|
||||
c7 = flex.Rigid(gtx, func() {
|
||||
if len(idBtns) > 0 { // still zero after update
|
||||
for i := 0; i < len(idBtns); i++ {
|
||||
lst.Layout(gtx, len(idBtns), func(i int) {
|
||||
idBtns[i].Layout(gtx)
|
||||
|
@ -510,7 +558,7 @@ func eventLoop() {
|
|||
}
|
||||
}
|
||||
})
|
||||
flex.Layout(gtx, c1, c2, c3)
|
||||
flex.Layout(gtx, c1, c2, c3, c4, c5, c6, c7)
|
||||
}
|
||||
|
||||
var insName, insValue string
|
||||
|
@ -629,7 +677,12 @@ func eventLoop() {
|
|||
}
|
||||
}
|
||||
//Do not block the UI thread.
|
||||
go store.Insert(passnameEd.Text(), passvalEd.Text())
|
||||
go func() {
|
||||
err := store.Insert(passnameEd.Text(), passvalEd.Text())
|
||||
if err != nil {
|
||||
page = idPage
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,7 +709,12 @@ func eventLoop() {
|
|||
if yesBtn.Clicked() {
|
||||
w.Invalidate()
|
||||
page = listPage
|
||||
go store.Insert(insName, insValue)
|
||||
go func() {
|
||||
err := store.Insert(insName, insValue)
|
||||
if err != nil {
|
||||
page = idPage
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,6 +829,9 @@ func eventLoop() {
|
|||
if e.Stage == system.StageRunning {
|
||||
initPgp(w)
|
||||
}
|
||||
go func() {
|
||||
updateIdBtns()
|
||||
}()
|
||||
case system.FrameEvent:
|
||||
gtx.Reset(e.Config, e.Size)
|
||||
|
||||
|
|
14
go.mod
14
go.mod
|
@ -1,14 +0,0 @@
|
|||
module git.wow.st/gmp/passgo
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
gioui.org/ui v0.0.0-20190918172808-816f0e901fc6
|
||||
git.wow.st/gmp/clip v0.0.0-20191001134149-1458ba6a7cf5
|
||||
git.wow.st/gmp/rand v0.0.0-20191001220155-a81bebfaf8b0
|
||||
github.com/fsnotify/fsnotify v1.4.7
|
||||
github.com/jcmdev0/gpgagent v0.0.0-20180509014935-5601b32d936c
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7
|
||||
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
)
|
29
go.sum
29
go.sum
|
@ -1,29 +0,0 @@
|
|||
gioui.org/ui v0.0.0-20190918172808-816f0e901fc6 h1:LvHEYxyOW7g+PhOiAm8Delc3AUv9EH219oDvaUMeKBw=
|
||||
gioui.org/ui v0.0.0-20190918172808-816f0e901fc6/go.mod h1:PssKPKlqVIeyaed+0w492Xc2NgX5M3n6oZKOAj5rxoE=
|
||||
git.wow.st/gmp/clip v0.0.0-20191001134149-1458ba6a7cf5 h1:OKeTjZST+/TKvtdA258NXJH+/gIx/xwyZxKrAezNFvk=
|
||||
git.wow.st/gmp/clip v0.0.0-20191001134149-1458ba6a7cf5/go.mod h1:NLdpaBoMQNFqncwP8OVRNWUDw1Kt9XWm3snfT7cXu24=
|
||||
git.wow.st/gmp/rand v0.0.0-20191001220006-66bfa936ad6b h1:yu3SnygEUgkNJ3xBXLkWHws7tki5qveZ6Kk7ybWj1GQ=
|
||||
git.wow.st/gmp/rand v0.0.0-20191001220006-66bfa936ad6b/go.mod h1:8+2Gwnrpc5yuk8Wp6cBhxvGcNLumYiPbQ7n0SQ8h29A=
|
||||
git.wow.st/gmp/rand v0.0.0-20191001220155-a81bebfaf8b0 h1:08wP00wvbDINsct1fzKV1xGGLvvtNsSb2X4CtIdpBzM=
|
||||
git.wow.st/gmp/rand v0.0.0-20191001220155-a81bebfaf8b0/go.mod h1:8+2Gwnrpc5yuk8Wp6cBhxvGcNLumYiPbQ7n0SQ8h29A=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/jcmdev0/gpgagent v0.0.0-20180509014935-5601b32d936c h1:DCnjNrPDSEslcqqBgcZBxlLUIhk2elQVyf2V+HkyxJI=
|
||||
github.com/jcmdev0/gpgagent v0.0.0-20180509014935-5601b32d936c/go.mod h1:vdJ2op9pzpbH8CbpYKYBD6zjURqDY13PmnVn2I/uYBs=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU=
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0=
|
||||
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
Loading…
Reference in New Issue
Block a user