ANativeWindow_getHeight subtracts nav bar height sometimes - android

I have a C++ app that runs as the home app. I am testing on Android 5.0.2.
When I restart my app ANativeWindow_getHeight returns to me a height of 752. This is the screen height minus the nav bar at the bottom. This is the result even though the nav bar is not showing and the area of the window is indeed 800 pixels.
When I reboot the device and it launches my home app immediately, ANativeWindow_getHeight returns the actual window height of 800.
Is there anyway I can reliably get the actual window height in all scenarios?

Related

Notification bar is not a part of window

There is a thin bar at the top of the phone screen's that shows battery and clock and notifications.
When I try to run my app in fullscreen, this bar is purely black, meaning if I paint the whole window white with
SDL_RenderClear(renderer) the color of bar does not change. So it means it is not a part of the window right?
I found two similar threads in discourse.libsdl.org that are mentioning the exact same issue.
I tried the methods that both of them mentioned but It had no effect for me.
One thread was created by devvr and the other by Starg.
I created my window with SDL_WINDOW_FULLSCREEN and SDL_WINDOW_BORDERLESS flags.
And after that I did this SDL_SetWindowFullscreen(window,SDL_TRUE);
I tested the app only on Samsung Galaxy A22, but I'm not sure if it is a device related problem.
I tested the app on Samsung Galaxy J5, and the notification bar was totally hidden there (meaning i have no issue there).
I also tested the app on Samsung Galaxy A30 and I faced the same issue (notification bar is not a part of the window)
Another thing that I noticed is that the window height that SDL_GetCurrentDisplayMode is giving me on A22 and A30 is actually a little bit bigger than the actual size (meaning the objects at the bottom of the window can't be seen in the screen).
So i think that SDL_GetCurrentDisplayMode is actually doing okay and is giving me the right width and height but because the notification bar is not considered a part of the window, I am facing this issue too.

Status bar height on s8+ in full screen mode

I've previously used some of the solutions on this question to offset a PopUpWindow window directly underneath the status bar. This works fine on an S8+ (which reports a status bar height of 84 pixels) as long as the app has not been set as a "Full Screen App".
If the app has been set to be a "Full Screen App" under Settings -> Display -> Full Screen Apps, the PopUpWindow will not display directly beneath the (still visible) status bar. Although the system still reports a status bar height of 84 pixels, the correct offset at this point is 0.
I can work around this by calculating the aspect ratio of the screen and if it is 1.9388889, then the app is in full screen mode, so the PopUpWindow offset can be set to 0.
However, this feels fragile and I'm not sure how this will work on other devices that support tall aspect ratios (LG6, etc). Ideally I would have a way to detect if an app is running in full screen without relying on specific aspect ratios. This seemed ideal:
boolean fullScreen = (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
...but it returns false on an S8+ running an app set to be a Full Screen App. It appears Full Screen Mode and Full Screen App are two distinct concepts.
Rather than using specific aspect ratios, is there a better way to detect something is running as a Full Screen App? Or, a more robust way to calculate the status bar offset required, that will handle this Full Screen App scenario?

Hide Android browser bar for non-scrolling web page

I am creating a web page that should exactly fill the screen on a mobile phone. This means that the page will not scroll. If the page is not scrolled, the browser address bar remains on-screen, occupying screen real-estate and conflicting with the design of the page.
I use CSS to set the height of the body to 100% of the height of the window, but height of the window is the height of the mobile screen minus the height of the browser address bar, so even if I succeed in removing the address bar (by zooming the page, scrolling, then returning to the unzoomed size) there is now a gap at the bottom of the screen that is exactly the same height as the now-hidden address bar.
Is there a way to use CSS to set the height of the page to the full height of the screen, so that:
Scrolling becomes possible
The address bar can be made to hide
The page-minus-the-address-bar will fill the screen
?

Calling swipe() on navigation bar area causes appium error due to bounds

I am testing a program on Android with Appium v1.6.3 with an LG K7 and Samsung Galaxy S6 Edge+, on Linux with Python v2.7.
I am performing swipe gestures in my test program at different areas across the width of the screen. On the Galaxy, I have no issues whatsoever. However, with the LG, which has a navigation bar, I get errors from Appium.
In my test application, the navigation bar is fully hidden - so full screen mode. When I read the screen size, I get 480,782. This is not the full screen size. The height is minus the navigation bar. When I try to swipe the bottom of the screen, which is outside those bounds, Appium throws an error, and my try/except block fails. driver.swipe(1, 800, 479, 800). I know this is within the full screen size, but because it's outside what Appium thinks are the boundaries, it fails.
My question is, how can I change the bounds that Appium has automatically set. There doesn't seem to be any capability that I can set, and I have not found any commands to change it for each device - I am testing several. It's important that I perform a swipe gesture in this area, where the navigation bar sits, albeit hidden.
Does anyone know how I can manually set the display bounds?
From Appium:
.....[debug] Display bounds: [0,0][480,782]
.....Sending command to android....action:swipe,params:startx:1, starty:800, endx:479, endy:800, steps:22
.....Returning result: status:13....x=1.0, y=800.0 is outside of element rect: [0,0][480,782]

How can i know if system bars are visible?

I try to know on each devices (tablet and phone with or without physical button) if system bars are visible (status bar, navigation bar and system/combined bar).
How i can do that ???
François
edit: android:minSdkVersion=11 in my app
I need to know the height of my page in portrait mode in dp.
Then measure the height of the View that represents your "page".

Categories

Resources