Bump gio version.

This commit is contained in:
Greg 2020-06-11 10:42:43 -04:00
parent 0dc003bd57
commit 19194e36f4
11 changed files with 120 additions and 59 deletions

View File

@ -5,8 +5,9 @@ package main
import ( import (
"gioui.org/app" "gioui.org/app"
"gioui.org/layout"
"gioui.org/io/system" "gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/unit" "gioui.org/unit"
"gioui.org/widget/material" "gioui.org/widget/material"
@ -17,6 +18,11 @@ var (
labchan chan string labchan chan string
) )
type (
D = layout.Dimensions
C = layout.Context
)
func main() { func main() {
labchan = make(chan string) labchan = make(chan string)
go eventloop() go eventloop()
@ -24,14 +30,13 @@ func main() {
} }
func eventloop() { func eventloop() {
gofont.Register()
w := app.NewWindow(app.Title("Dex")) w := app.NewWindow(app.Title("Dex"))
th := material.NewTheme() th := material.NewTheme(gofont.Collection())
gtx := &layout.Context{Queue: w.Queue()} var ops op.Ops
sysinset := &layout.Inset{} sysinset := &layout.Inset{}
margin := layout.UniformInset(unit.Dp(10)) margin := layout.UniformInset(unit.Dp(10))
labels := []material.Label{} labels := []material.LabelStyle{}
list := &layout.List{Axis: layout.Vertical} list := &layout.List{Axis: layout.Vertical}
go func() { go func() {
@ -49,18 +54,18 @@ func eventloop() {
for { select { for { select {
case x := <-labchan: case x := <-labchan:
labels = append(labels, th.Body1(x)) labels = append(labels, material.Body1(th, x))
case e := <-w.Events(): case e := <-w.Events():
switch e := e.(type) { switch e := e.(type) {
case system.DestroyEvent: case system.DestroyEvent:
return return
case system.FrameEvent: case system.FrameEvent:
gtx.Reset(e.Config, e.Size) gtx := layout.NewContext(&ops, e)
resetSysinset(e.Insets) resetSysinset(e.Insets)
sysinset.Layout(gtx, func() { sysinset.Layout(gtx, func(gtx C) D {
margin.Layout(gtx, func() { return margin.Layout(gtx, func(gtx C) D {
list.Layout(gtx, len(labels), func(i int) { return list.Layout(gtx, len(labels), func(gtx C, i int) D {
labels[i].Layout(gtx) return labels[i].Layout(gtx)
}) })
}) })
}) })

View File

@ -8,6 +8,7 @@ import (
"gioui.org/app" "gioui.org/app"
"gioui.org/io/system" "gioui.org/io/system"
"gioui.org/layout" "gioui.org/layout"
"gioui.org/op"
"gioui.org/unit" "gioui.org/unit"
"gioui.org/widget/material" "gioui.org/widget/material"
@ -18,6 +19,11 @@ var (
labchan chan string labchan chan string
) )
type (
D = layout.Dimensions
C = layout.Context
)
func main() { func main() {
labchan = make(chan string) labchan = make(chan string)
log.Print("Staring event loop") log.Print("Staring event loop")
@ -27,16 +33,15 @@ func main() {
} }
func eventloop() { func eventloop() {
gofont.Register()
w := app.NewWindow( w := app.NewWindow(
app.Size(unit.Dp(400), unit.Dp(400)), app.Size(unit.Dp(400), unit.Dp(400)),
app.Title("Hello")) app.Title("Hello"))
th := material.NewTheme() th := material.NewTheme(gofont.Collection())
gtx := &layout.Context{Queue: w.Queue()} var ops op.Ops
sysinset := &layout.Inset{} sysinset := &layout.Inset{}
margin := layout.UniformInset(unit.Dp(10)) margin := layout.UniformInset(unit.Dp(10))
labels := []material.Label{} labels := []material.LabelStyle{}
list := &layout.List{Axis: layout.Vertical} list := &layout.List{Axis: layout.Vertical}
resetSysinset := func(x system.Insets) { resetSysinset := func(x system.Insets) {
@ -52,18 +57,18 @@ func eventloop() {
for { for {
select { select {
case x := <-labchan: case x := <-labchan:
labels = append(labels, th.Body1(x)) labels = append(labels, material.Body1(th, x))
case e := <-w.Events(): case e := <-w.Events():
switch e := e.(type) { switch e := e.(type) {
case system.DestroyEvent: case system.DestroyEvent:
return return
case system.FrameEvent: case system.FrameEvent:
gtx.Reset(e.Config, e.Size) gtx := layout.NewContext(&ops, e)
resetSysinset(e.Insets) resetSysinset(e.Insets)
sysinset.Layout(gtx, func() { sysinset.Layout(gtx, func(gtx C) D {
margin.Layout(gtx, func() { return margin.Layout(gtx, func(gtx C) D {
list.Layout(gtx, len(labels), func(i int) { return list.Layout(gtx, len(labels), func(gtx C, i int) D {
labels[i].Layout(gtx) return labels[i].Layout(gtx)
}) })
}) })
}) })

View File

@ -3,5 +3,6 @@
package main package main
func callJni() { func callJni() {
labchan <- "nothing to do"
} }

View File

@ -14,6 +14,8 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpServiceConnection; import org.openintents.openpgp.util.OpenPgpServiceConnection;
import android.content.Context; import android.content.Context;
import android.content.ClipboardManager;
import android.content.ClipData;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import android.app.Activity; import android.app.Activity;
@ -31,13 +33,12 @@ public class PgpConnect extends Fragment {
Context ctx; Context ctx;
Handler handler; Handler handler;
OpenPgpServiceConnection mServiceConnection; OpenPgpServiceConnection mServiceConnection;
ClipboardManager cb;
PgpConnect(Activity act) { PgpConnect(Activity act) {
act = act; act = act;
ctx = act.getApplicationContext(); ctx = act.getApplicationContext();
this.handler = new Handler(ctx.getMainLooper()); this.handler = new Handler(ctx.getMainLooper());
//this.mServiceConnection = new OpenPgpServiceConnection(ctx, "org.sufficientlysecure.keychain");
//this.mServiceConnection.bindToService();
final FragmentManager fm = act.getFragmentManager(); final FragmentManager fm = act.getFragmentManager();
final Fragment frag = this; final Fragment frag = this;
@ -57,8 +58,10 @@ public class PgpConnect extends Fragment {
this.handler = new Handler(ctx.getMainLooper()); this.handler = new Handler(ctx.getMainLooper());
mServiceConnection = new OpenPgpServiceConnection(ctx, "org.sufficientlysecure.keychain"); mServiceConnection = new OpenPgpServiceConnection(ctx, "org.sufficientlysecure.keychain");
mServiceConnection.bindToService(); mServiceConnection.bindToService();
cb = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
} }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("gio", "onActivityResult(" + requestCode + "): " + resultCode); Log.d("gio", "onActivityResult(" + requestCode + "): " + resultCode);
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
@ -85,6 +88,11 @@ public class PgpConnect extends Fragment {
} }
} }
public void Clip(byte []dat) {
ClipData clip = ClipData.newPlainText("PgpConnect", new String(dat));
cb.setPrimaryClip(clip);
}
public void Decrypt(byte []dat, int chint) { public void Decrypt(byte []dat, int chint) {
if (handler == null) { if (handler == null) {
return; return;

View File

@ -60,8 +60,8 @@ func CreateObject(env *C.JNIEnv, cls C.jclass) C.jobject {
type PGP C.jobject type PGP C.jobject
func NewPgpConnect(env *C.JNIEnv, act uintptr) PGP { func NewPgpConnect(env uintptr, act uintptr) PGP {
return (PGP)(C.NewPgpConnect(env, (C.jobject)(unsafe.Pointer(act)))) return (PGP)(C.NewPgpConnect((*C.JNIEnv)(unsafe.Pointer(env)), (C.jobject)(unsafe.Pointer(act))))
} }
var ( var (

View File

@ -8,6 +8,7 @@ import (
"gioui.org/app" "gioui.org/app"
"gioui.org/io/system" "gioui.org/io/system"
"gioui.org/layout" "gioui.org/layout"
"gioui.org/op"
"gioui.org/unit" "gioui.org/unit"
"gioui.org/widget/material" "gioui.org/widget/material"
@ -18,6 +19,11 @@ var (
labchan chan string labchan chan string
) )
type (
D = layout.Dimensions
C = layout.Context
)
func main() { func main() {
labchan = make(chan string) labchan = make(chan string)
log.Print("Staring event loop") log.Print("Staring event loop")
@ -27,16 +33,15 @@ func main() {
} }
func eventloop() { func eventloop() {
gofont.Register()
w := app.NewWindow( w := app.NewWindow(
app.Size(unit.Dp(400), unit.Dp(400)), app.Size(unit.Dp(400), unit.Dp(400)),
app.Title("Hello")) app.Title("Hello"))
th := material.NewTheme() th := material.NewTheme(gofont.Collection())
gtx := &layout.Context{Queue: w.Queue()} var ops op.Ops
sysinset := &layout.Inset{} sysinset := &layout.Inset{}
margin := layout.UniformInset(unit.Dp(10)) margin := layout.UniformInset(unit.Dp(10))
labels := []material.Label{} labels := []material.LabelStyle{}
list := &layout.List{Axis: layout.Vertical} list := &layout.List{Axis: layout.Vertical}
resetSysinset := func(x system.Insets) { resetSysinset := func(x system.Insets) {
@ -47,30 +52,33 @@ func eventloop() {
} }
go func() { go func() {
labchan <- "Starting" labchan <- "Starting"
callJni() callJni(w)
}() }()
for { for {
select { select {
case x := <-labchan: case x := <-labchan:
labels = append(labels, th.Body1(x)) labels = append(labels, material.Body1(th, x))
w.Invalidate() w.Invalidate()
case e := <-w.Events(): case e := <-w.Events():
switch e := e.(type) { switch e := e.(type) {
case system.DestroyEvent: case system.DestroyEvent:
return return
case system.FrameEvent: case system.FrameEvent:
gtx.Reset(e.Config, e.Size) gtx := layout.NewContext(&ops, e)
resetSysinset(e.Insets) resetSysinset(e.Insets)
sysinset.Layout(gtx, func() { sysinset.Layout(gtx, func(gtx C) D {
margin.Layout(gtx, func() { return margin.Layout(gtx, func(gtx C) D {
list.Layout(gtx, len(labels), func(i int) { return list.Layout(gtx, len(labels), func(gtx C, i int) D {
labels[i].Layout(gtx) return labels[i].Layout(gtx)
}) })
}) })
}) })
e.Frame(gtx.Ops) e.Frame(gtx.Ops)
case system.StageEvent: case system.StageEvent:
log.Printf("stage event -- %s", e.Stage) log.Printf("stage event -- %s", e.Stage)
if e.Stage == system.StageRunning {
initPgp(w)
}
case *system.CommandEvent: case *system.CommandEvent:
log.Print("command event") log.Print("command event")
} }

View File

@ -16,35 +16,53 @@ import (
var ( var (
h *app.Handle h *app.Handle
connected bool connected bool
ready bool
wch chan struct{}
w *app.Window
pgp PGP pgp PGP
) )
func init() {
wch = make(chan struct{})
}
func connect() { func initPgp(x *app.Window) {
w = x
close(wch)
}
func connect(w *app.Window) bool {
<-wch
if !connected { if !connected {
log.Print("PlatformHandle()") log.Print("PlatformHandle()")
h = app.PlatformHandle() h = app.PlatformHandle()
log.Print("SetJVM()") log.Print("SetJVM()")
SetJVM(h.JVM, h.Activity) SetJVM(h.JVM, h.Context)
log.Print("SetJVM() returned") log.Print("SetJVM() returned")
RunInJVM(func(env *JNIEnv) { log.Print("calling window.Run()()")
log.Print("NewPgpConnect()") w.Run(func(env app.JNIEnv, act app.Activity) {
pgp = NewPgpConnect(env, h.Activity) log.Print("in window.Run() -- NewPgpConnect()")
pgp = NewPgpConnect(env.JNIEnv, act.Activity)
}) })
connected = true connected = true
} }
return true
} }
func checkPermission() bool { func checkPermission(w *app.Window) bool {
connect() if !connect(w) {
return false
}
//return pgp.CheckPermission(env) //return pgp.CheckPermission(env)
return false return false
} }
func callJni() { func callJni(w *app.Window) {
connect() if !connect(w) {
return
}
labchan <- fmt.Sprintf("JVM = %d", h.JVM) labchan <- fmt.Sprintf("JVM = %d", h.JVM)
labchan <- fmt.Sprintf("Activity = %d", h.Activity) labchan <- fmt.Sprintf("Context = %d", h.Context)
time.Sleep(time.Second / 5) time.Sleep(time.Second / 5)
val, err := pgp.Encrypt("greg_pomerantz@yahoo.com", "hi there") val, err := pgp.Encrypt("greg_pomerantz@yahoo.com", "hi there")

View File

@ -2,6 +2,12 @@
package main package main
func callJni() { import (
"gioui.org/app"
)
func callJni(w *app.Window) {
} }
func initPgp(w *app.Window) {
}

View File

@ -8,6 +8,7 @@ import (
"gioui.org/app" "gioui.org/app"
"gioui.org/io/system" "gioui.org/io/system"
"gioui.org/layout" "gioui.org/layout"
"gioui.org/op"
"gioui.org/unit" "gioui.org/unit"
"gioui.org/widget/material" "gioui.org/widget/material"
@ -18,6 +19,11 @@ var (
labchan chan string labchan chan string
) )
type (
D = layout.Dimensions
C = layout.Context
)
func main() { func main() {
labchan = make(chan string) labchan = make(chan string)
log.Print("Staring event loop") log.Print("Staring event loop")
@ -34,16 +40,15 @@ func diffInsets(x, y system.Insets) bool {
} }
func eventloop() { func eventloop() {
gofont.Register()
w := app.NewWindow( w := app.NewWindow(
app.Size(unit.Dp(400), unit.Dp(400)), app.Size(unit.Dp(400), unit.Dp(400)),
app.Title("Hello")) app.Title("Hello"))
th := material.NewTheme() th := material.NewTheme(gofont.Collection())
gtx := &layout.Context{Queue: w.Queue()} var ops op.Ops
sysinset := &layout.Inset{} sysinset := &layout.Inset{}
margin := layout.UniformInset(unit.Dp(10)) margin := layout.UniformInset(unit.Dp(10))
labels := []material.Label{} labels := []material.LabelStyle{}
list := &layout.List{Axis: layout.Vertical} list := &layout.List{Axis: layout.Vertical}
resetSysinset := func(x system.Insets) { resetSysinset := func(x system.Insets) {
@ -59,18 +64,18 @@ func eventloop() {
for { for {
select { select {
case x := <-labchan: case x := <-labchan:
labels = append(labels, th.Body1(x)) labels = append(labels, material.Body1(th, x))
case e := <-w.Events(): case e := <-w.Events():
switch e := e.(type) { switch e := e.(type) {
case system.DestroyEvent: case system.DestroyEvent:
return return
case system.FrameEvent: case system.FrameEvent:
gtx.Reset(e.Config, e.Size) gtx := layout.NewContext(&ops, e)
resetSysinset(e.Insets) resetSysinset(e.Insets)
sysinset.Layout(gtx, func() { sysinset.Layout(gtx, func(gtx C) D {
margin.Layout(gtx, func() { return margin.Layout(gtx, func(gtx C) D {
list.Layout(gtx, len(labels), func(i int) { return list.Layout(gtx, len(labels), func(gtx C, i int) D {
labels[i].Layout(gtx) return labels[i].Layout(gtx)
}) })
}) })
}) })

4
go.mod
View File

@ -1,5 +1,5 @@
module git.wow.st/gmp/android-go module git.wow.st/gmp/android-go
go 1.13 go 1.14
require gioui.org v0.0.0-20191031200634-4e71f195ab51 require gioui.org v0.0.0-20200611133933-6d5fbcba3f21

5
go.sum
View File

@ -1,6 +1,10 @@
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20191031200634-4e71f195ab51 h1:Epxo/e6oPvbDMMB8rrpmUlBe6ELeDpRuLzFUGfT6kJM= gioui.org v0.0.0-20191031200634-4e71f195ab51 h1:Epxo/e6oPvbDMMB8rrpmUlBe6ELeDpRuLzFUGfT6kJM=
gioui.org v0.0.0-20191031200634-4e71f195ab51/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY= gioui.org v0.0.0-20191031200634-4e71f195ab51/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
gioui.org v0.0.0-20191112235626-1bf2c7ef293c h1:jhUehzf6xTCgEewbJyjd+WE2Kq5pvPIxq2MahDph0mg=
gioui.org v0.0.0-20191112235626-1bf2c7ef293c/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
gioui.org v0.0.0-20200611133933-6d5fbcba3f21 h1:VFB+0QxUPABMgEarfyJeHQvUNc++9TASnDVXcFgxLcA=
gioui.org v0.0.0-20200611133933-6d5fbcba3f21/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@ -20,6 +24,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=