From 6817f13235602704c84902294d836f2317338732 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 12 Oct 2020 17:38:23 +1100 Subject: [PATCH] WIP on making fullscreen button work for android client --- .../java/com/classicube/MainActivity.java | 16 +++++++++++++ src/Window.c | 24 ++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/com/classicube/MainActivity.java b/android/app/src/main/java/com/classicube/MainActivity.java index b960a1a1e..c8d081806 100644 --- a/android/app/src/main/java/com/classicube/MainActivity.java +++ b/android/app/src/main/java/com/classicube/MainActivity.java @@ -465,6 +465,22 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 { // wait for dialog to be closed // TODO: this fails because multiple dialog boxes show } + + public void enterFullscreen() { + runOnUiThread(new Runnable() { + public void run() { + curView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE); + } + }); + } + + public void exitFullscreen() { + runOnUiThread(new Runnable() { + public void run() { + curView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); + } + }); + } public String shareScreenshot(String path) { try { diff --git a/src/Window.c b/src/Window.c index 0b668ad60..101e53aba 100644 --- a/src/Window.c +++ b/src/Window.c @@ -3804,9 +3804,27 @@ void Clipboard_SetText(const String* value) { /* Always a fullscreen window */ void Window_Show(void) { } -int Window_GetWindowState(void) { return WINDOW_STATE_FULLSCREEN; } -cc_result Window_EnterFullscreen(void) { return 0; } -cc_result Window_ExitFullscreen(void) { return 0; } +cc_bool fullscreen; /* TODO: NOT TRACK IN OWN CODE */ +int Window_GetWindowState(void) { return fullscreen ? WINDOW_STATE_FULLSCREEN : WINDOW_STATE_NORMAL; } + +cc_result Window_EnterFullscreen(void) { + JNIEnv* env; + JavaGetCurrentEnv(env); + JavaCallVoid(env, "enterFullscreen", "()V", NULL); + + fullscreen = true; + return 0; +} + +cc_result Window_ExitFullscreen(void) { + JNIEnv* env; + JavaGetCurrentEnv(env); + JavaCallVoid(env, "exitFullscreen", "()V", NULL); + + fullscreen = false; + return 0; +} + void Window_SetSize(int width, int height) { } void Window_Close(void) {