diff --git a/src/main/java/com/gluonhq/substrate/Constants.java b/src/main/java/com/gluonhq/substrate/Constants.java index d77f17aa..2bbf8f6a 100644 --- a/src/main/java/com/gluonhq/substrate/Constants.java +++ b/src/main/java/com/gluonhq/substrate/Constants.java @@ -108,7 +108,7 @@ public enum Profile { public static final String DEFAULT_JAVA_STATIC_SDK_VERSION = "18-ea+prep18-8"; public static final String DEFAULT_JAVA_STATIC_SDK_VERSION11 = "11-ea+10"; - public static final String DEFAULT_JAVAFX_STATIC_SDK_VERSION = "19-ea+4"; + public static final String DEFAULT_JAVAFX_STATIC_SDK_VERSION = "19-ea+7"; public static final String DEFAULT_JAVAFX_JS_SDK_VERSION = "18-internal+0-2021-09-02-165800"; public static final String DEFAULT_SYSROOT_VERSION = "20210424"; public static final String DEFAULT_CLIBS_VERSION = "27"; diff --git a/src/main/resources/native/android/android_project/app/src/main/java/com/gluonhq/helloandroid/MainActivity.java b/src/main/resources/native/android/android_project/app/src/main/java/com/gluonhq/helloandroid/MainActivity.java index a521bb26..a7532abb 100644 --- a/src/main/resources/native/android/android_project/app/src/main/java/com/gluonhq/helloandroid/MainActivity.java +++ b/src/main/resources/native/android/android_project/app/src/main/java/com/gluonhq/helloandroid/MainActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Gluon + * Copyright (c) 2019, 2022, Gluon * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ import android.graphics.PixelFormat; import android.graphics.Rect; import android.os.Bundle; +import android.os.Handler; import android.os.SystemClock; import android.text.Editable; import android.text.InputType; @@ -149,7 +150,6 @@ public void surfaceCreated(SurfaceHolder holder) { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Log.v(TAG, "surfaceChanged start"); Log.v(TAG, "[MainActivity] surfaceChanged, format = "+format+", width = "+width+", height = "+height); nativeSetSurface(holder.getSurface()); DisplayMetrics metrics = new DisplayMetrics(); @@ -160,25 +160,22 @@ public void surfaceChanged(SurfaceHolder holder, int format, int width, @Override public void surfaceDestroyed(SurfaceHolder holder) { - System.err.println("[MainGraalActivity] surfaceDestroyed, ignore for now"); - // _surfaceChanged(null); + System.err.println("[MainGraalActivity] surfaceDestroyed"); + nativeSetSurface(null); } @Override public void surfaceRedrawNeeded(SurfaceHolder holder) { - Log.v(TAG, "SurfaceRedraw needed start"); - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - Log.v(TAG, "ask native graallayer to redraw surface"); + Log.v(TAG, "SurfaceRedraw needed: ask native graal layer to redraw surface"); nativeSurfaceRedrawNeeded(); - try { - Thread.sleep(500); - Log.v(TAG, "surfaceredraw needed part 1 done"); - nativeSurfaceRedrawNeeded(); - } catch (Exception e) { - e.printStackTrace(); - } - Log.v(TAG, "surfaceredraw needed (and wait) done"); + Log.v(TAG, "surfaceredraw needed part 1 done"); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + nativeSurfaceRedrawNeeded(); + Log.v(TAG, "surfaceredraw needed (and wait) done"); + } + }, 100); } @Override diff --git a/src/main/resources/native/android/c/javafx_adapter.c b/src/main/resources/native/android/c/javafx_adapter.c index 63ee0fe9..db91a327 100644 --- a/src/main/resources/native/android/c/javafx_adapter.c +++ b/src/main/resources/native/android/c/javafx_adapter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Gluon + * Copyright (c) 2020, 2022, Gluon * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,9 +70,14 @@ void registerJavaFXMethodHandles(JNIEnv *aenv) {} JNIEXPORT void JNICALL Java_com_gluonhq_helloandroid_MainActivity_nativeSetSurface(JNIEnv *env, jobject activity, jobject surface) { LOGE(stderr, "nativeSetSurface called, env at %p and size %ld, surface at %p\n", env, sizeof(JNIEnv), surface); - window = ANativeWindow_fromSurface(env, surface); - androidJfx_setNativeWindow(window); - LOGE(stderr, "native setSurface Ready, native window at %p\n", window); + if (surface != NULL) { + window = ANativeWindow_fromSurface(env, surface); + androidJfx_setNativeWindow(window); + LOGE(stderr, "native setSurface Ready, native window at %p\n", window); + } else { + androidJfx_setNativeWindow(NULL); + LOGE(stderr, "native setSurface was null"); + } } JNIEXPORT jlong JNICALL Java_com_gluonhq_helloandroid_MainActivity_surfaceReady(JNIEnv *env, jobject activity, jobject surface, jfloat mydensity)