diff --git a/app/internal/wm/GioActivity.java b/app/internal/wm/GioActivity.java index 260d4b69..4565e380 100644 --- a/app/internal/wm/GioActivity.java +++ b/app/internal/wm/GioActivity.java @@ -3,12 +3,8 @@ package org.gioui; import android.app.Activity; -import android.content.res.Configuration; -import android.os.Build; import android.os.Bundle; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; +import android.content.res.Configuration; public final class GioActivity extends Activity { private GioView view; @@ -16,13 +12,8 @@ public final class GioActivity extends Activity { @Override public void onCreate(Bundle state) { super.onCreate(state); - Window w = getWindow(); - this.view = new GioView(this); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - this.view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); - } - this.view.setLayoutParams(new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT)); + setContentView(view); } @@ -48,7 +39,7 @@ public final class GioActivity extends Activity { @Override public void onLowMemory() { super.onLowMemory(); - view.lowMemory(); + GioView.onLowMemory(); } @Override public void onBackPressed() { diff --git a/app/internal/wm/GioView.java b/app/internal/wm/GioView.java index 4dc842e4..42e5c531 100644 --- a/app/internal/wm/GioView.java +++ b/app/internal/wm/GioView.java @@ -31,6 +31,7 @@ import android.view.SurfaceView; import android.view.SurfaceHolder; import android.view.Window; import android.view.WindowInsetsController; +import android.view.WindowManager; import android.view.inputmethod.BaseInputConnection; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; @@ -55,6 +56,10 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal public GioView(Context context, AttributeSet attrs) { super(context, attrs); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + setLayoutParams(new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT)); // Late initialization of the Go runtime to wait for a valid context. Gio.init(context.getApplicationContext()); @@ -277,30 +282,26 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal return getResources().getConfiguration().fontScale; } - void start() { + public void start() { onStartView(nhandle); } - void stop() { + public void stop() { onStopView(nhandle); } - void destroy() { + public void destroy() { setOnFocusChangeListener(null); getHolder().removeCallback(surfCallbacks); onDestroyView(nhandle); nhandle = 0; } - void configurationChanged() { + public void configurationChanged() { onConfigurationChanged(nhandle); } - void lowMemory() { - onLowMemory(); - } - - boolean backPressed() { + public boolean backPressed() { return onBack(nhandle); } @@ -312,7 +313,7 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal static private native void onSurfaceChanged(long handle, Surface surface); static private native void onConfigurationChanged(long handle); static private native void onWindowInsets(long handle, int top, int right, int bottom, int left); - static private native void onLowMemory(); + static public native void onLowMemory(); static private native void onTouchEvent(long handle, int action, int pointerID, int tool, float x, float y, float scrollX, float scrollY, int buttons, long time); static private native void onKeyEvent(long handle, int code, int character, long time); static private native void onFrameCallback(long handle, long nanos); diff --git a/app/internal/wm/os_android.go b/app/internal/wm/os_android.go index 080f67b2..b3e2d57a 100644 --- a/app/internal/wm/os_android.go +++ b/app/internal/wm/os_android.go @@ -283,7 +283,7 @@ func Java_org_gioui_GioView_onSurfaceChanged(env *C.JNIEnv, class C.jclass, hand } //export Java_org_gioui_GioView_onLowMemory -func Java_org_gioui_GioView_onLowMemory() { +func Java_org_gioui_GioView_onLowMemory(env *C.JNIEnv, class C.jclass) { runtime.GC() debug.FreeOSMemory() }