Full Screen Immersive Mode

Wonderful! :slight_smile:

I’m really curious because no matter what I tried in config, it doesn’t seem to work…

@nugett,

I do believe the solution is active, not passive.

i.e You can’t just set some values and forget it.Ā  Ā You need to actively detect when the on-screen controls are shown and hidden, then adjust.

I’ll confirm or debunk this recollection when I can.

Yes, what I tried (among other) was to detect the resolution change with onResize event and change all the globals about the content areas etc. Then redraw the whole scene. But it didn’t work. So, I guessed it was a good idea to first ask whether others are indeed achieving this (100% fullscreen) or it is a Corona limitation…

So far, my Nexus is a brick.Ā  I am still recharging with the hope it will wake up.

Till then, the best I can do is share my initial test:
Ā 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/05/fullScreenImmersive.zip

If I’m right, this should re-apply ā€œimmersiveā€ when you are finished with the buttons, but I may have made a mistake.

I’ll know more if I ever get to test.

OK, that is not quite right.Ā Ā 

My device just woke up and this solution is not quite right.Ā  Please hold a few.

This is starting to feel like a bug.

I’ve tried some things and I keep getting this black bar at the bottom that covers all content.Ā  The aspect ratio is right, but Corona is simply covered.

I did notice, when using ā€œimmersiveStickyā€ I get these results:

  • swipe up shows back menu and top bar as translucent entities.Ā  Aspect ratio of Corona content is unmodified
    • Waiting a moment causes bars to self-hide.Ā  No negative visual effects
    • Clicking back button activates my back catcher and slides Corona content up.
      • Clicking NO hides bars and slides content back down.Ā  No negative visual effects
    • Clicking ā€˜square’ button pops up list of running apps.
      • Re-selecting current app shows it again and hides bars.
      • I then get the black bar at the bottom

Updated code:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/05/fullScreenImmersive.zip

This should work for all devices (it’s what I use)

local function onResize( event ) if \_isAndroid then if (system.getInfo("androidApiLevel") or 0) \>= 19 then native.setProperty("androidSystemUiVisibility", "immersiveSticky") else native.setProperty("androidSystemUiVisibility", "lowProfile") end end --recalculate our new screen constants \_originX, \_originY = display.screenOriginX, display.screenOriginY \_W, \_H = display.actualContentWidth, display.actualContentHeight \_centreX, \_centreY = originX + \_W/2, \_originY +\_H/2 --move the UI if isDisplayObject(uiTopButtons) then uiTopButtons.y = \_originY end if isDisplayObject(uiBottomButtons) then uiBottomButtons.y = \_originY + \_H end end

@roaminggamer, your issue:Ā  BBABFRFTLRI (black bar at bottom following resume from task list restoring immersive) has been a bug since day one of immersive:Ā Ā https://forums.coronalabs.com/topic/53170-immersivesticky-and-displayscreenoriginx/

…but, I’m not sure that’s the OP’s issue.Ā  having ā€œblack barsā€ at BOTH top and bottom sounds like just not properly responding to the resize event, and a letterbox setup with yAlign=ā€œcenterā€.Ā  fe, something created to exactly fill the screen PRE-immersive, won’t fill the screen POST-immersive, unless you specifically do something to change it (or use zoomStretch) because screen dimensions (obviously?) CHANGE following immersive.Ā  also, fwiw, yAlign=ā€œtopā€ can be slightly more intuitive to use when planning for immersive.

This is what I get with @roaminggamer’s github code on a LG G6 (soft navigation buttons, Android 7). Same black bars on top and bottom as with my (dozens) variations of code. Do you guys get a full screen immersive with the same code?

https://ibb.co/kiA7fd

@davebollinger

You are right. The problem is that the onResize() event seems to be never fired get in my code. I have also tried SGS’s version, with same results.

Are you sure onResize() is actually getting called?Ā  Did you declare it as Runtime and put it into main.lua?

Next thing to try is to delay my code by a few seconds and see if it is a timing issue - screen metrics checking too fast and soft bar is still on screen.

All I can say is this works for me black bar free on everything from a tiny S3 to an S9 in max resolution. FWIW, I use xAlign and yAlign of center.

BTW, Ed’s code works fine for me.

Finally I found out that the issue I had was related to the mobile OS. Thanks for your help!

Just to return something to the community: I think that it is way better to separate the immersive setter from the onResize() listener.

The onResize event is triggered both after a resume event and after a set immersive command. So after a resume event you get 2 runs of onResize (this only happens on device, not on simulator, test it with some onscreen prints etc). So, I ended up abandoning the onResize and handling the immersion, resize check and redraw solely on the appstart and resume events. Now, on resume the scene doesn’t need to be redrawn at all, compared to 2 consecutive and redudant redraws when using the onResize.