From c17a5cec1901dd23f4c39ec2ae47a060fbb06895 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 7 Nov 2019 08:57:59 +0100 Subject: Android: Implement MaximizeUsingFullscreenGeometryHint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This flag tells the app to use as much of the screen as possible while still keeping system UI visible, and can be supported on Android by using translucent system UI, similar to iOS. What this does: 1. It changes the current fullscreen/not-fullscreen logic to allow three states: fullscreen, fullscreen with translucent decorations and not-fullscreen. 2. In order for it to work, we have to send the actual screen geometry and available geometry, at least in the case where the user needs to know the available geometry to know the safe area of the window. So we get the real screen metrics and pass these to the QPA plugin (API level 17, so we can do that now that the minimum version is 21.) 3. Note that getting the insets and calculating the useable area does not work for non-fullscreen windows, since Android is quite inconsistent in this respect. So in this case we just use the window size and origin of 0,0 for the available geometry. 4. Since we are touching this code anyway, this patch also tries to use more consistent wording (calling it "available geometry" everywhere instead of desktop geometry in some places and just geometry in others, etc.) [ChangeLog][Android] Qt::MaximizeUsingFullscreenGeometryHint window flag is now supported, and will make the window fullscreen, but keep the system UI on-screen, with a translucent background color. Fixes: QTBUG-74202 Change-Id: I7a59a6c6fb51ebbdb86e7149e794726e67001279 Reviewed-by: Tor Arne Vestbø Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjnimain.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/android/androidjnimain.h') diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 17ae30a1be..63be5910f9 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -77,8 +77,8 @@ namespace QtAndroid void bringChildToBack(int surfaceId); QWindow *topLevelWindowAt(const QPoint &globalPos); - int desktopWidthPixels(); - int desktopHeightPixels(); + int availableWidthPixels(); + int availableHeightPixels(); double scaledDensity(); double pixelDensity(); JavaVM *javaVM(); @@ -88,8 +88,13 @@ namespace QtAndroid jobject activity(); jobject service(); - void showStatusBar(); - void hideStatusBar(); + // Keep synchronized with flags in ActivityDelegate.java + enum SystemUiVisibility { + SYSTEM_UI_VISIBILITY_NORMAL = 0, + SYSTEM_UI_VISIBILITY_FULLSCREEN = 1, + SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2 + }; + void setSystemUiVisibility(SystemUiVisibility uiVisibility); jobject createBitmap(QImage img, JNIEnv *env = 0); jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env); -- cgit v1.2.3