Bump gio version, use window.Do() instead of RegisterFragment().
This commit is contained in:
parent
f5cc27a30d
commit
b0b310a7b0
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
|
@ -19,6 +20,7 @@ import android.content.IntentFilter;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.Manifest;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.welie.blessed.BluetoothCentral;
|
||||
import com.welie.blessed.BluetoothCentralCallback;
|
||||
|
@ -36,6 +38,14 @@ public class BlessedConnect extends Fragment {
|
|||
Log.d("gio", "BlessedConnect()");
|
||||
}
|
||||
|
||||
public void register(View view) {
|
||||
Log.d("gio", "BlessedConnect: register()");
|
||||
Activity act = (Activity)view.getContext();
|
||||
FragmentTransaction ft = act.getFragmentManager().beginTransaction();
|
||||
ft.add(this, "BlessedConnect");
|
||||
ft.commitNow();
|
||||
}
|
||||
|
||||
@Override public void onAttach(Context ctx) {
|
||||
super.onAttach(ctx);
|
||||
Log.d("gio", "BlessedConnect: onAttach()");
|
||||
|
|
|
@ -225,7 +225,14 @@ func NewBLE() *BLE {
|
|||
//Enable
|
||||
func (b *BLE) Enable(w *app.Window) {
|
||||
log.Printf("ble.Enable()")
|
||||
w.RegisterFragment("st/wow/git/ble/BlessedConnect")
|
||||
setJVM(app.JavaVM())
|
||||
go w.Do(func(view uintptr) {
|
||||
log.Printf("ble.Enable(): inside w.Do()")
|
||||
runInJVM(func(env *C.JNIEnv) {
|
||||
log.Printf("ble.Enable(): inside runInJVM()")
|
||||
C.registerFragment(env, (C.jobject)(unsafe.Pointer(view)))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Go callbacks from Java
|
||||
|
@ -237,7 +244,6 @@ func Java_st_wow_git_ble_BlessedConnect_installComplete(env *C.JNIEnv, class C.j
|
|||
log.Printf("BlessedConnect object is nil!")
|
||||
}
|
||||
gBLE.handle.BlessedConnect = (C.NewGlobalRef)(env,b)
|
||||
setJVM(app.JavaVM())
|
||||
if C.enabled(env, gBLE.handle.BlessedConnect) == C.JNI_TRUE {
|
||||
gBLE.handle.state = STATE_ON
|
||||
gBLE.ready = true
|
||||
|
|
2
go.mod
2
go.mod
|
@ -2,4 +2,4 @@ module git.wow.st/gmp/ble
|
|||
|
||||
go 1.13
|
||||
|
||||
require gioui.org v0.0.0-20200612151431-2dc19a36959c
|
||||
require gioui.org v0.0.0-20200619121558-88ced59dad93
|
||||
|
|
3
go.sum
3
go.sum
|
@ -3,6 +3,8 @@ gioui.org v0.0.0-20191126175243-2ca2e5462f16 h1:p31rtmKm51xpj2QtqGNlljAyHEP1oStU
|
|||
gioui.org v0.0.0-20191126175243-2ca2e5462f16/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
|
||||
gioui.org v0.0.0-20200612151431-2dc19a36959c h1:sGUKyRMv2bbfbsRyG8ghOI12l+WCGta+PivmznjuLgo=
|
||||
gioui.org v0.0.0-20200612151431-2dc19a36959c/go.mod h1:AHI9rFr6AEEHCb8EPVtb/p5M+NMJRKH58IOp8O3Je04=
|
||||
gioui.org v0.0.0-20200619121558-88ced59dad93 h1:Llh4Tigdbu++FrRXL/KzqDHnH2Q5LPmAEk0djh6NLwk=
|
||||
gioui.org v0.0.0-20200619121558-88ced59dad93/go.mod h1:jiUwifN9cRl/zmco43aAqh0aV+s9GbhG13KcD+gEpkU=
|
||||
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=
|
||||
|
@ -11,6 +13,7 @@ golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL
|
|||
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
|
|
|
@ -3,6 +3,15 @@
|
|||
#include <android/log.h>
|
||||
#include "_cgo_export.h"
|
||||
|
||||
void
|
||||
registerFragment(JNIEnv *env, jobject view) {
|
||||
jclass cls = (*env)->FindClass(env, "st/wow/git/ble/BlessedConnect");
|
||||
jmethodID reg = (*env)->GetMethodID(env, cls, "register", "(Landroid/view/View;)V");
|
||||
jmethodID init = (*env)->GetMethodID(env, cls, "<init>", "()V");
|
||||
jobject inst = (*env)->NewObject(env, cls, init);
|
||||
(*env)->CallVoidMethod(env, inst, reg, view);
|
||||
}
|
||||
|
||||
jboolean
|
||||
enabled(JNIEnv *env, jobject b) {
|
||||
jclass cls = (*env)->GetObjectClass(env, b);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <jni.h>
|
||||
|
||||
void registerFragment(JNIEnv *env, jobject view);
|
||||
jboolean enabled(JNIEnv *env, jobject p);
|
||||
void scan(JNIEnv *env, jobject b);
|
||||
void stopScan(JNIEnv *env, jobject b);
|
||||
|
|
Loading…
Reference in New Issue
Block a user