display.topStatusBarContentHeight fails on Nexus 6

Folks:

I had the chance to use a Nexus 6 over the holidays and found that display.topStatusBarContentHeight fails on that device.

More specifically, it returns a value that’s about half of what it should be. So if you rely on display.topStatusBarContentHeight to position your app’s content under the status bar, everything will be positioned improperly.

I can get the exact numbers this evening, but as a preliminary matter, I was wondering whether Corona staff was aware of this?

Thanks!

Hi @corona273,

Does this occur only and specifically on the Nexus 6? Do you have another Android device to test on? What version of Android are you running on the Nexus 6? Which content scale mode are you using (letterbox, zoomEven, adaptive?)

Thanks,

Brent

Brent: Thanks for your prompt response!

Yes, as far as I can tell, it occurs only and specifically on the Nexus 6. The display.topStatusBarContentHeight call works fine on other Android devices, including a Nexus 5 (both L and pre-L), a Nexus 4 (KitKat), an even older Nexus phone, and a Nexus 7. (I also successfully installed it on one of Corona Labs’ Android tablets when I visited your offices in Palo Alto a few months ago, but I can’t remember which one you had.)

The one caveat is that I installed a mid-November build of my app, using one of your then-contemporaneous daily builds, on the Nexus 6. So I’m not positive that the content scaling had been switched to adaptive. I’ll take a look at this again later today and test with your latest daily build and post the value returned by display.topStatusBarContentHeight on the Nexus 6.

Brent: I found some time to do some tests, and the results are below. All tests were done using the identical APK built with Corona version 2014.2528 (2014.12.30), your penultimate daily build. Status bar height was obtained via display.topStatusBarContentHeight. Content scaling was set to adaptive.

Nexus 6, running latest Android version (L, but didn’t record the exact version):

I/Corona  ( 5112): debug: main: status bar height: 8

Nexus 5, running 5.0.1:

I/Corona  ( 2449): debug: main: status bar height: 25

Nexus 4, running 4.4.3:

I/Corona  ( 2332): debug: main: status bar height: 25

Y’all do have a Nexus 6 in the office to test with, right?  :) Here’s a code snippet that apparently reliably obtains the status bar height: http://stackoverflow.com/questions/3407256/height-of-status-bar-in-android

On another note, it would be great to be able to make the status bar transparent on Android L. Corona does this on iOS but Android is translucent; the android:statusBarColor attribute @android:color/transparent available in L isn’t supported…

Hi @corona273,

Our engineers determined that this isn’t an issue with “adaptive” mode, but rather with the height returned by “xxxhdpi” devices. This issue will be fixed in Daily Build #2531.

Take care,

Brent

Thanks, Brent! Much obliged. And feel free to include the ability to set transparent status bars in Android in the next daily build while you’re at it. :slight_smile:

Hi again,

Regarding a translucent status bar, we added support for Android in the last release version (it’s in our release notes)… BUT, it’s only supported on Android 4.4 and newer devices. Older Android OS versions do not support a translucent status bar.

We also support dimming the bottom navigation bar (aka: low profile mode) and the ability to hide the top/bottom bars until the user taps/swipes the screen (aka: immersive mode). This is done via our “native.setProperty()” function:

http://docs.coronalabs.com/daily/api/library/native/setProperty.html

Best regards,

Brent

Brent: Thanks for your quick response! I’m aware that you implemented a translucent status bar for newer versions of Android; you generously did in response to this thread I started last July:

http://forums.coronalabs.com/topic/49846-corona-status-bar-bug-problem-implementing-material-design-for-android-l/

What I’m asking for is different. I’m asking for a transparent status bar. A transparent status bar is necessary to follow Google’s Material Design guidelines (they’re now half a year old, so it would be nice to be able to follow them).

Those guidelines say: “The status bar should be the darker 700 tint of your primary color.” Google lists, at some length, the exact RGB values for the status bar for each color. http://www.google.com/design/spec/style/color.html#color-ui-color-application

The problem is that when the status bar is set to translucent, the primary color + the translucent overlay does not equal the Google-specified 700 color. It’s typically darker and more washed out than it should be. The status bar alpha is dark enough that it’s impossible to get the right color by working backwards.

Put another way, if other Android apps have the correct {red|blue|green|aqua|indigo} color app bar and the darker {red|blue|green|aqua|indigo} color status bar, Corona-built apps will stand out and look odd. This can be fixed with a few lines of code (the android:statusBarColor attribute @android:color/transparent) on your end. You already support a transparent status bar for iOS; perhaps you can for Android as well?

Hi @corona273,

Does this occur only and specifically on the Nexus 6? Do you have another Android device to test on? What version of Android are you running on the Nexus 6? Which content scale mode are you using (letterbox, zoomEven, adaptive?)

Thanks,

Brent

Brent: Thanks for your prompt response!

Yes, as far as I can tell, it occurs only and specifically on the Nexus 6. The display.topStatusBarContentHeight call works fine on other Android devices, including a Nexus 5 (both L and pre-L), a Nexus 4 (KitKat), an even older Nexus phone, and a Nexus 7. (I also successfully installed it on one of Corona Labs’ Android tablets when I visited your offices in Palo Alto a few months ago, but I can’t remember which one you had.)

The one caveat is that I installed a mid-November build of my app, using one of your then-contemporaneous daily builds, on the Nexus 6. So I’m not positive that the content scaling had been switched to adaptive. I’ll take a look at this again later today and test with your latest daily build and post the value returned by display.topStatusBarContentHeight on the Nexus 6.

Brent: I found some time to do some tests, and the results are below. All tests were done using the identical APK built with Corona version 2014.2528 (2014.12.30), your penultimate daily build. Status bar height was obtained via display.topStatusBarContentHeight. Content scaling was set to adaptive.

Nexus 6, running latest Android version (L, but didn’t record the exact version):

I/Corona  ( 5112): debug: main: status bar height: 8

Nexus 5, running 5.0.1:

I/Corona  ( 2449): debug: main: status bar height: 25

Nexus 4, running 4.4.3:

I/Corona  ( 2332): debug: main: status bar height: 25

Y’all do have a Nexus 6 in the office to test with, right?  :) Here’s a code snippet that apparently reliably obtains the status bar height: http://stackoverflow.com/questions/3407256/height-of-status-bar-in-android

On another note, it would be great to be able to make the status bar transparent on Android L. Corona does this on iOS but Android is translucent; the android:statusBarColor attribute @android:color/transparent available in L isn’t supported…

Hi @corona273,

Our engineers determined that this isn’t an issue with “adaptive” mode, but rather with the height returned by “xxxhdpi” devices. This issue will be fixed in Daily Build #2531.

Take care,

Brent

Thanks, Brent! Much obliged. And feel free to include the ability to set transparent status bars in Android in the next daily build while you’re at it. :slight_smile:

Hi again,

Regarding a translucent status bar, we added support for Android in the last release version (it’s in our release notes)… BUT, it’s only supported on Android 4.4 and newer devices. Older Android OS versions do not support a translucent status bar.

We also support dimming the bottom navigation bar (aka: low profile mode) and the ability to hide the top/bottom bars until the user taps/swipes the screen (aka: immersive mode). This is done via our “native.setProperty()” function:

http://docs.coronalabs.com/daily/api/library/native/setProperty.html

Best regards,

Brent

Brent: Thanks for your quick response! I’m aware that you implemented a translucent status bar for newer versions of Android; you generously did in response to this thread I started last July:

http://forums.coronalabs.com/topic/49846-corona-status-bar-bug-problem-implementing-material-design-for-android-l/

What I’m asking for is different. I’m asking for a transparent status bar. A transparent status bar is necessary to follow Google’s Material Design guidelines (they’re now half a year old, so it would be nice to be able to follow them).

Those guidelines say: “The status bar should be the darker 700 tint of your primary color.” Google lists, at some length, the exact RGB values for the status bar for each color. http://www.google.com/design/spec/style/color.html#color-ui-color-application

The problem is that when the status bar is set to translucent, the primary color + the translucent overlay does not equal the Google-specified 700 color. It’s typically darker and more washed out than it should be. The status bar alpha is dark enough that it’s impossible to get the right color by working backwards.

Put another way, if other Android apps have the correct {red|blue|green|aqua|indigo} color app bar and the darker {red|blue|green|aqua|indigo} color status bar, Corona-built apps will stand out and look odd. This can be fixed with a few lines of code (the android:statusBarColor attribute @android:color/transparent) on your end. You already support a transparent status bar for iOS; perhaps you can for Android as well?