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

View File

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

View File

@ -3,5 +3,6 @@
package main
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.OpenPgpServiceConnection;
import android.content.Context;
import android.content.ClipboardManager;
import android.content.ClipData;
import android.content.Intent;
import android.util.Log;
import android.app.Activity;
@ -31,13 +33,12 @@ public class PgpConnect extends Fragment {
Context ctx;
Handler handler;
OpenPgpServiceConnection mServiceConnection;
ClipboardManager cb;
PgpConnect(Activity act) {
act = act;
ctx = act.getApplicationContext();
this.handler = new Handler(ctx.getMainLooper());
//this.mServiceConnection = new OpenPgpServiceConnection(ctx, "org.sufficientlysecure.keychain");
//this.mServiceConnection.bindToService();
final FragmentManager fm = act.getFragmentManager();
final Fragment frag = this;
@ -57,8 +58,10 @@ public class PgpConnect extends Fragment {
this.handler = new Handler(ctx.getMainLooper());
mServiceConnection = new OpenPgpServiceConnection(ctx, "org.sufficientlysecure.keychain");
mServiceConnection.bindToService();
cb = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
}
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("gio", "onActivityResult(" + requestCode + "): " + resultCode);
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) {
if (handler == null) {
return;

View File

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

View File

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

View File

@ -16,35 +16,53 @@ import (
var (
h *app.Handle
connected bool
ready bool
wch chan struct{}
w *app.Window
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 {
log.Print("PlatformHandle()")
h = app.PlatformHandle()
log.Print("SetJVM()")
SetJVM(h.JVM, h.Activity)
SetJVM(h.JVM, h.Context)
log.Print("SetJVM() returned")
RunInJVM(func(env *JNIEnv) {
log.Print("NewPgpConnect()")
pgp = NewPgpConnect(env, h.Activity)
log.Print("calling window.Run()()")
w.Run(func(env app.JNIEnv, act app.Activity) {
log.Print("in window.Run() -- NewPgpConnect()")
pgp = NewPgpConnect(env.JNIEnv, act.Activity)
})
connected = true
}
return true
}
func checkPermission() bool {
connect()
func checkPermission(w *app.Window) bool {
if !connect(w) {
return false
}
//return pgp.CheckPermission(env)
return false
}
func callJni() {
connect()
func callJni(w *app.Window) {
if !connect(w) {
return
}
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)
val, err := pgp.Encrypt("greg_pomerantz@yahoo.com", "hi there")

View File

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

4
go.mod
View File

@ -1,5 +1,5 @@
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=
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-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/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=
@ -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-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-20200124204421-9fbb57f87de9/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=
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=