Bump gio version.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 (
|
||||
|
||||
+19
-11
@@ -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")
|
||||
}
|
||||
|
||||
+28
-10
@@ -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")
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
package main
|
||||
|
||||
func callJni() {
|
||||
import (
|
||||
"gioui.org/app"
|
||||
)
|
||||
|
||||
func callJni(w *app.Window) {
|
||||
}
|
||||
|
||||
func initPgp(w *app.Window) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user