• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Android immersive mode possible?

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
With regard to the previous post about mac fullscreen, I kind of got the opposite problem with Android?
How do I get rid of the softbuttons to get a true fullscreen?

Is there a way to get 50% transparency softbuttons or to shut them off completely?


,
Softbuttons.jpeg
 
That's awesome, thank you! Will try to integrate this into Cerberus.
 
You can use the code on https://developer.android.com/training/system-ui/immersive#EnableFullscreen

I used SYSTEM_UI_FLAG_IMMERSIVE_STICKY instead of SYSTEM_UI_FLAG_IMMERSIVE, else it doesn't auto hide after swiping.

Add it to /targets/android-original/modules/native/androidgame.java inside the AndroidGame class.

Code:
private void hideSystemUI() {
        if (Build.VERSION.SDK_INT >= 19) {
            View decorView = getWindow().getDecorView();
            decorView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                            // Set the content to appear under the system bars so that the
                            // content doesn't resize when the system bars hide and show.
                            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            // Hide the nav bar and status bar
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN);
        }
    }

Call hideSystemUI from onWindowFocusChanged when hasFocus is true.
Code:
public void onWindowFocusChanged( boolean hasFocus ){
        if( hasFocus ){
            hideSystemUI();
            _view.onResume();
            _game.ResumeGame();
        }else{
            _game.SuspendGame();
            _view.onPause();
        }
    }

I tried making it a third party module, but it crashes and says the views can't be messed with from a different thread. I don't know how to make this into a config.cxs setting... Although it could be nice to be able to change it at run time as well.

Edit: On my testing device that has a display cutout it just shows a black bar there, so you don't need to worry about safe areas.
 
Last edited:
Wow thank you so much, is there a reason to not make this permanent? I guess it's possible to just comment hideSystemUI() whenever you want to go back to normal. Gonna try it right away.
 
Hmm I got the same graphics, the only thing that changed was that the softbuttonarea is now black, isn't there a way to use the full screen?

It reacts to touch like the screen now but it seems that deviceheight() & devicewidth() reported the same resolution still as when there where buttons? Or maybe there is something else to consider to make use of the full screen area?
 
I wonder if android:fitsSystemWindows="true" is needed, could that be it?
 
My game project seems to report the correct size when using deviceheight()/devicewidth(), but not when I tested DisplayMode. I printed the output to the console and also the game is displaying correctly. Are you updating your game size on OnUpdate?

is there a reason to not make this permanent?

It may be nice to able change it while it's is running, because someone may want to change it at different sections of their game or app. I have a few games released that don't use immersive mode, but I haven't made any that change between both yet.
 
I also get the correct native resolution of the device which is 1920.

Still there's clearly x pixels used for the softbuttons. Very strange..

I'm avoiding all kinds of graphic-commands inside OnUpdate, I communicate graphical information to other parts using variables that are read-and-written-to from inside OnRender. DisplayMode command is new to me so I can't say anything about what it says.
android:fitsSystemWindows="true" did not work btw. (https://michiganlabs.com/android/design/development/2018/03/20/a-more-immersive-android-navbar)

If you allow rotation of the device, you'll see that the black area will get smudged with graphics. It's an unmanaged area, which is kind of interesting.
 
Last edited:
Oh yes, OnRender and not OnUpdate. I hadn't thought of the distinction. What I had meant to ask was is your game adjusting it's size when the window size changes after it first starts? My project is calling SetProjection2d when ever DeviceWidth() or DeviceHeight() change.
 
Sadly I do that already every frame whenever the width or height changes, so there's nothing that I can improve there.

Code:
canvas.SetViewport 0,0,awidth,aheight
canvas.SetScissor 0,0,awidth,aheight
canvas.SetProjection2d 0,awidth,0,aheight
 
Sadly I do that already every frame whenever the width or height changes, so there's nothing that I can improve there.

Code:
canvas.SetViewport 0,0,awidth,aheight
canvas.SetScissor 0,0,awidth,aheight
canvas.SetProjection2d 0,awidth,0,aheight
Did you ever figure this out? Are you recreating the canvas when the screen size changes? myCanvas = New Canvas(); is what I'm doing, but I'm not sure if there is a better way to resize the canvas.

I feel like this would be a really nice feature to put in Cerberus X.
 
Sadly no It's not solved yet but I hope to solve it soon. I'm learning Android more as we speak!

To change the size of the canvas I think you only need to do SetDisplay together with those commands mentioned above.
The canvas has no actual size and can be any size. It behaves more like a pointer to something. I might be wrong though but this is the impression I have because I never needed to change the size of the canvas.
 
Back
Top Bottom