accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[System UI Controller] Provide way to set layoutInDisplayCutoutMode

Open giaesp opened this issue 3 years ago • 26 comments

Actually calling

val systemUiController = rememberSystemUiController()
SideEffect {
     systemUiController.isStatusBarVisible = false
}

hides correctly the status bar, but content doesn't fit the status bar empty space. I have this weird behavior with all version 0.20.0+ (including alphas and RCs)

Compose version is 1.1.0-rc01 Tested on Samsung SM G780G

giaesp avatar Jan 21 '22 17:01 giaesp

Hi, could you share a bit more info? Are you using WindowCompat.setDecorFitsSystemWindows(window, false)?

alexvanyo avatar Jan 27 '22 00:01 alexvanyo

Same issue here. I use WindowCompat.setDecorFitsSystemWindows(window, false)

DalilaSilva avatar Feb 05 '22 17:02 DalilaSilva

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Mar 08 '22 03:03 github-actions[bot]

Hi, querying for a bit more info here.

Are you using SystemUiController in combination with insets (either the deprecated accompanist/insets, or the new version built into androidx.foundation)?

alexvanyo avatar Apr 01 '22 21:04 alexvanyo

Facing the same issue.

                val systemUiController = rememberSystemUiController()
                SideEffect {
                    systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = false)
                }

Works and have the content draw under the status bar.

                val systemUiController = rememberSystemUiController()
                SideEffect {
                    systemUiController.isSystemBarsVisible = false
                    systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = false)
                }

or

                val systemUiController = rememberSystemUiController()
                SideEffect {
                    systemUiController.isSystemBarsVisible = false
                }

Does not work the status bar content is hidden but the insets for the status bar are now at 0 and nothing is drawn under the status bar.

Tolriq avatar Apr 09 '22 10:04 Tolriq

I think I might have a lead. It looks like OP's device has a pinhole cutout, is that true for others in this thread as well?

alexvanyo avatar Apr 11 '22 03:04 alexvanyo

The thread I'm pulling at is layoutInDisplayCutoutMode

If you change that via window.attributes.layoutInDisplayCutoutMode, does that change the behavior you're seeing?

alexvanyo avatar Apr 11 '22 03:04 alexvanyo

Yes P6 Pro and all my emulator images have it too. I'll test later the option and report back.

Tolriq avatar Apr 11 '22 05:04 Tolriq

So after quite a few tests, for whatever reason layoutInDisplayCutoutMode only works when set via the theme.xml not by code. (Android 12 P6 pro)

When setting layoutInDisplayCutoutMode to always in theme and systemUiController.isStatusBarVisible = false it will recompose 3 to 4 times the screen by moving up and down the content below / under / below / under / below / under the status bar. Please note that I have migrated to Compose 1.2 alpha 7 insets handling.

Tolriq avatar Apr 11 '22 07:04 Tolriq

Could you attach a video of that and provide a sample? In my testing I wasn't seeing the jumping behavior.

This could be something worth adding to accompanist, or at the least exposing the correct Window to change.

alexvanyo avatar Apr 12 '22 17:04 alexvanyo

Here's the video.

Theme

<resources>
    <!-- Base application theme. -->
    <style name="Theme.Symfonium" parent="android:Theme.Material">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowLayoutInDisplayCutoutMode">always</item>
    </style>

</resources>

Code is relatively simple

setContent {
CustomTheme { 
                SideEffect {
                    systemUiController.isStatusBarVisible = false
                    systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = useDarkIcons)
                }

The theme is an M3 theme that wrap an M2 theme

https://user-images.githubusercontent.com/932609/163030594-7a07de02-3727-4504-b8d6-a93407adbac7.mp4

The app is huge and private, and currently fighting with Android Auto validation team that refuse the app because it does not work when they don't purchase a paid app .... So tons of loose energy and time preventing me to try to build a full small repro.

Tolriq avatar Apr 12 '22 18:04 Tolriq

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar May 13 '22 03:05 github-actions[bot]

Unstale, still need a way to hide status bar properly as request by my users :(

Tolriq avatar May 13 '22 05:05 Tolriq

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 13 '22 03:06 github-actions[bot]

Another one :) Is there a workaround / ugly way to get the proper window for layoutInDisplayCutoutMode?

For my use case asked by users the need to hide the the status bar fully is only for one screen.

Tolriq avatar Jun 13 '22 06:06 Tolriq

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 15 '22 03:07 github-actions[bot]

Unstale we still need a way to do layoutInDisplayCutoutMode from code.

Tolriq avatar Jul 15 '22 05:07 Tolriq

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 15 '22 03:08 github-actions[bot]

Another one :) The need for me at least, is that the user can enable a setting to have a part of the app full screen.

Tolriq avatar Aug 15 '22 08:08 Tolriq

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 15 '22 04:09 github-actions[bot]

Is there anyway to add some kind of label to this issue to avoid the stale ?

Tolriq avatar Sep 15 '22 05:09 Tolriq

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 16 '22 04:10 github-actions[bot]

Unstale :)

Tolriq avatar Oct 16 '22 06:10 Tolriq

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 17 '22 03:11 github-actions[bot]

Unstale :)

Tolriq avatar Nov 17 '22 06:11 Tolriq

I am facing the same issue. As described above, I am setting WindowCompat.setDecorFitsSystemWindows(window, false) in My Activity. Setting the status bar color to Transparent allows content to be visible through the status bar, but systemUiController.isStatusBarVisible = false leaves a black bar at the top of my screen through which content cannot be viewed. I am using a Galaxy Z Fold 4. The issue occurs on my outer screen which has the so-called "Pinhole" cutout (though I had always heard "hole-punch" to refer to that style of camera cutout) but not on my inner screen which has an under-display camera and therefore no cutout.

moretanjames avatar Nov 28 '22 22:11 moretanjames

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jan 13 '23 03:01 github-actions[bot]

Unstale :)

Tolriq avatar Jan 13 '23 06:01 Tolriq

Seriously though, unless this part of accompanist is going to be deprecated and replaced by something in one of the standard compose libraries soon, I think this issue deserves some love.

moretanjames avatar Jan 13 '23 17:01 moretanjames

As a direct solution, you can manually set layoutInDisplayCutoutMode via setting the window attributes, either from an Activity where you have the Window already, or using the same method to find the window that systemuicontroller.

alexvanyo avatar Jan 26 '23 22:01 alexvanyo