Status bar height issue

I’m running across a problem with the height of the status bar not being reported correctly on Android Samsung Galaxy S4.  The result is that the status bar hangs over part of my scene.  The height reports correctly on iOS devices and other android deivces I’ve tested on.  I filed a bug a few weeks ago  (Case 27276) but haven’t heard anything.

Has anyone else noticed this?  Any ideas of workarounds?

What build are you using?

Most recently with 1241, but I’ve tried several older builds including the latest public release.  I believe this is also a problem on Kindle but I’d just decided not to show the status bar on Kindle.  I’d really like it to be visible on all devices.

We’ve reviewed your report and determined that the status bar height is being reported correctly for the devices you’ve mentioned.  It’s not a bug.  It’s an issue in your code.  We’ve replied to you report and provided details there.

I’ve had exactly the same problem when I borrowed a S4 ( with Android 4.3 ) from a colleague.

I never had any issue with any other device so I guess that there’s something to it, my guess is that the height is reported wrong on some particular setups.

@roman85 It’s good to hear that it’s not just me.  As Joshua pointed out above, the bug report was closed as not a bug in corona but a bug in my code.  If that’s the case, it’s fine.  I’d just like to understand what the bug is in my code.  Can anyone tell me where the issue is?

Below is code and config to reproduce the issue.  It only fails to display correctly on a Samsung Galaxy G4, as far as I know.

main.lua

-- set background color so that the status bar is easier to see display.setDefault("background", 100,100,100) -- set status bar to show display.setStatusBar(display.DarkStatusBar) -- get status bar height local topStatusBarContentHeight = display.topStatusBarContentHeight -- calculate the screen origin y (the top of the scree), taking into consideration the status bar local screen\_origin\_with\_status\_bar = display.screenOriginY + topStatusBarContentHeight -- draw some numbers on the screen with the new screen origin as the reference for i=1,10 do     local text = display.newText(tostring(i), 0, screen\_origin\_with\_status\_bar + (i-1)\*20, native.systemFont, 22)     text:setTextColor(255, 255, 255) end -- Show the status bar height local myText = display.newText("status bar height: " .. tostring(topStatusBarContentHeight), 50, 150, native.systemFont, 18) myText:setTextColor(255, 255, 255) -- Show the status bar height contentScaleYText = display.newText("contentScaleY: " .. tostring(display.contentScaleY), 50, 190, native.systemFont, 18) myText:setTextColor(255, 255, 255)

config.lua

application = { content = { width = 320, height = 480, scale = "Letterbox", fps = 60, imageSuffix = { ["@2x"] = 2, } } }

Really have no idea as I don’t own a phone of that class, but what happens if you change your config to a 9:16 ratio? (The G4 is a 1920x1080 device, but your config is using iPhone oldschool standard 2:3 resolution.

Jeremy,

It’s definitely a bug in your code.  It’s caused by your usage of the “display.screenOriginY” property which provides the y component of the top-left coordinate of the screen in “content coordinates”.  Since your app is set up to be letterboxed, this property will provide a negative y value if a letterbox bar is shown at the top of the screen… which will be the case for the vast majority of Android devices.  Your code is not compensating for this negative value, causing it to place your text objects higher up on the screen than you expect.

It’s easy to prove.  Just print the screen origin to the log.  You’ll see that it’s a negative value.

   print("Screen Origin Y = " … tostring(display.screenOriginY))

The reason you’re not seeing this issue on an iPhone 5 is because your app is running in backward compatibility mode.  In order for your app to support “tall mode”, you need to add a “Default-568@2x.png” to your app folder as documented in the link below.  That will cause your app to use the entire screen, force Corona to letterbox the app itself (which iOS was doing for you in backward compatibility mode), and then you’ll see this same issue happening on your iPhone 5.

   http://docs.coronalabs.com/daily/guide/distribution/buildSettings/index.html#launch-images

I don’t know much about Jeremys issue, but in my case I’m always trying to position things like that:

rect.y = display.screenOriginY + display.topStatusBarContentHeight

and despite the fact that I’m doing this I was having this problem on a s4 recently.

of course I would need to do further testing ( which I currently don’t have the chance to) before pointing out where the bug is…

I’m having a Default-568@2x.png

maybe I’m getting it all wrong…

Hold on.  I see what’s going on.  You’re right.  The status bar height is being returned wrong for “xxhdpi” Android devices.

You can work-around it by doing this…

if (system.getInfo("androidDisplayDensityName") == "xxhdpi") then statusBarHeight = 75 \* display.contentScaleY else statusBarHeight = display.topStatusBarContentHeight end

The above will work on all platforms.  It checks if you’re running on an xxhdpi Android device, in which case the status bar height is supposed to be 75 pixels tall.  Multiplying pixels with “display.contentScaleY” will convert it to content coordinates.

Thanks Joshua.  That’s what I needed.  I’ll give that a try tonight.  I appreciate your help.

Thanks for work-around Joshua.

So I understand that it is in fact a bug and Corona will fix that in incoming daily build, right?

Renato

Yes, it’s confirmed to be a bug in Corona on xxhdpi Android devices.  We’ll fix it in a daily build in about 1-2 weeks.  Daily builds are currently on hold since we’re in the middle of pushing out a new release version of Corona.

@Joshua Quick

Wow what a great timing! Gonna submit my app to the store tomorrow.

Thanks a lot.

Roman

What build are you using?

Most recently with 1241, but I’ve tried several older builds including the latest public release.  I believe this is also a problem on Kindle but I’d just decided not to show the status bar on Kindle.  I’d really like it to be visible on all devices.

We’ve reviewed your report and determined that the status bar height is being reported correctly for the devices you’ve mentioned.  It’s not a bug.  It’s an issue in your code.  We’ve replied to you report and provided details there.

I’ve had exactly the same problem when I borrowed a S4 ( with Android 4.3 ) from a colleague.

I never had any issue with any other device so I guess that there’s something to it, my guess is that the height is reported wrong on some particular setups.

@roman85 It’s good to hear that it’s not just me.  As Joshua pointed out above, the bug report was closed as not a bug in corona but a bug in my code.  If that’s the case, it’s fine.  I’d just like to understand what the bug is in my code.  Can anyone tell me where the issue is?

Below is code and config to reproduce the issue.  It only fails to display correctly on a Samsung Galaxy G4, as far as I know.

main.lua

-- set background color so that the status bar is easier to see display.setDefault("background", 100,100,100) -- set status bar to show display.setStatusBar(display.DarkStatusBar) -- get status bar height local topStatusBarContentHeight = display.topStatusBarContentHeight -- calculate the screen origin y (the top of the scree), taking into consideration the status bar local screen\_origin\_with\_status\_bar = display.screenOriginY + topStatusBarContentHeight -- draw some numbers on the screen with the new screen origin as the reference for i=1,10 do     local text = display.newText(tostring(i), 0, screen\_origin\_with\_status\_bar + (i-1)\*20, native.systemFont, 22)     text:setTextColor(255, 255, 255) end -- Show the status bar height local myText = display.newText("status bar height: " .. tostring(topStatusBarContentHeight), 50, 150, native.systemFont, 18) myText:setTextColor(255, 255, 255) -- Show the status bar height contentScaleYText = display.newText("contentScaleY: " .. tostring(display.contentScaleY), 50, 190, native.systemFont, 18) myText:setTextColor(255, 255, 255)

config.lua

application = { content = { width = 320, height = 480, scale = "Letterbox", fps = 60, imageSuffix = { ["@2x"] = 2, } } }

Really have no idea as I don’t own a phone of that class, but what happens if you change your config to a 9:16 ratio? (The G4 is a 1920x1080 device, but your config is using iPhone oldschool standard 2:3 resolution.