app: add RegisterFragment method on *Window for Android

RegisterFragment creates an instance of a Java class and registers
it as a Fragment in the window's Context.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
This commit is contained in:
Greg Pomerantz
2019-11-26 12:47:54 -05:00
committed by Elias Naur
parent ce76c2e996
commit 2ca2e5462f
8 changed files with 98 additions and 16 deletions
+10
View File
@@ -54,6 +54,7 @@ type window struct {
mhideTextInput C.jmethodID
mpostFrameCallback C.jmethodID
mpostFrameCallbackOnMainThread C.jmethodID
mRegisterFragment C.jmethodID
}
var dataDirChan = make(chan string, 1)
@@ -119,6 +120,7 @@ func onCreateView(env *C.JNIEnv, class C.jclass, view C.jobject) C.jlong {
mhideTextInput: jniGetMethodID(env, class, "hideTextInput", "()V"),
mpostFrameCallback: jniGetMethodID(env, class, "postFrameCallback", "()V"),
mpostFrameCallbackOnMainThread: jniGetMethodID(env, class, "postFrameCallbackOnMainThread", "()V"),
mRegisterFragment: jniGetMethodID(env, class, "registerFragment", "(Ljava/lang/String;)V"),
}
wopts := <-mainWindow.out
w.callbacks = wopts.window
@@ -443,6 +445,14 @@ func (w *window) ShowTextInput(show bool) {
})
}
func (w *window) RegisterFragment(del string) {
runInJVM(func(env *C.JNIEnv) {
cdel := C.CString(del)
defer C.free(unsafe.Pointer(cdel))
C.gio_jni_RegisterFragment(env, w.view, w.mRegisterFragment, cdel)
})
}
func Main() {
}