We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3937

Summary: SYSTEM_UI_FLAG_IMMERSIVE_STICKY Requires SDK Version 19
Product: SDL Reporter: Diego <diegoacevedo91>
Component: buildAssignee: Sam Lantinga <slouken>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: kraft.aria, olli.kallioinen, sylvain.becker
Version: HG 2.1   
Hardware: x86   
OS: Android (All)   
Attachments: Handling system UI visibility

Description Diego 2017-11-02 22:45:22 UTC
With the newest commit cf6fe791a6ee the Android Studio project would not compile until I set the targetSdkVersion to 19 because SYSTEM_UI_FLAG_IMMERSIVE_STICKY was unresolved.
Comment 1 Diego 2017-11-02 23:04:25 UTC
I also had to set the compileSdkVersion to 19
Comment 2 Sylvain 2017-11-03 08:47:41 UTC
Indeed commit https://hg.libsdl.org/SDL/rev/cf6fe791a6ee
see also bug 3445
Comment 3 Sylvain 2017-11-03 08:54:33 UTC
Copy paste the comment: 

* Per SDL_androidwindow.c, Android will only ever have one window, and that window 
* is always flagged SDL_WINDOW_FULLSCREEN.  Let's treat it as an immersive fullscreen 
* window for Android UI purposes, as a result.

I think there is an issue because, on device (Nexus 10) that have soft buttons. Activating the immersive mode, sticky or not, with this patch: 
- make the app use the totality of the screen (ok, make sense).
- then it draws the navigations (back, home, overview) on top of it, but it never hides like we could expect with a timeout.
Comment 4 Sam Lantinga 2017-11-05 05:07:50 UTC
I'm going to iterate on this, thanks!
Comment 5 AriaMoKr 2017-11-12 17:23:31 UTC
(In reply to Diego from comment #1)
> I also had to set the compileSdkVersion to 19

Just changing the compileSdkVersion to 19 in android-project/app/build.gradle fixed it for me. It doesn't look like targetSdkVersion needs to be changed.
Comment 6 Olli Kallioinen 2017-11-19 01:43:09 UTC
Created attachment 3092 [details]
Handling system UI visibility

Recently View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY was just commented out because it required API 19. Personally I think increasing compileSdkVersion should not be a problem and the reports were just coming because compileSdkVersion is 16 in the the sample project. So a better solution is to bump that version to 19. After all google recommends building with the newest SDK anyway, even if targetting older devices. Of course the version checks need to be added for API 19 in the Java code.

I did somewhat extensive testing on this (I only have one device but I tested with emulators with API levels 15,16,19,25) and here's what I found:

Hiding the status bar and the title bar works fine just by setting the theme in the app manifest for all the API levels I tested. On API >= 19 the status bar will hide and show automatically and on levels below that it will be permanently hidden. If we remove the code controlling the bars, the user can easily disable hiding them in the manifest.

However, the navigation buttons can be properly hidden only in code and only for devices that have api level >= 19. While older devices support a mode where the navigation is hidden, the bars will pop back if the screen is touched anywhere (instead of dragging from the edge) so it's really only useful for video player apps and not games and such.

So I think the best solution is to bump the compileSdkVersion to 19 and check for api 19 and hide navigation only then. Also I think hiding navigation should be optional too. So I created a patch where the hiding is a separate method that can be easily overridden by the user.
Comment 7 Olli Kallioinen 2017-11-19 14:57:16 UTC
I was also thinking that maybe there could be something like this in the top of the java class that would
Make the error clearer to anyone trying to build with a too low compile version:

// Your compileSdkVersion (in build.gradle) needs to be at least 19.
@SuppressWarnings("unused")
private static final int REQUIRED_MINIMUM_COMPILE_SDK_VERSION_IS_19 = Build.VERSION_CODES.KITKAT;

It's just an unused field that is set to a constant that is not defined before 19. Maybe there is a better way to do something like this, but I couldn't find one with a quick search.
Comment 8 Sylvain 2017-12-05 15:14:49 UTC
This break-compilation flags sounds a good idea ! I think it should be added!