While doing this, I ran into the same issues with display.screenOriginX mentioned in the above post. i.e. The dimensions that the Corona code sees is the dimensions of the app when the navigation bar is visible. Not the new dimensions when the navigation bar is hidden when in sticky immersive mode.
Is there any easy way to update display.screenOriginX within Corona api calls to reflect the correct values?
if 1 isn’t possible then
Is there any way to compute the correct value for display.screenOriginX using native Android api calls which I could pass to my Corona app?
I don’t have the answer for #2, since I’m far from an Android native programmer expert, but there isn’t a good way to update display.screenOriginX, (and Y) from native space.
FWIW, I managed to solve my issues by accessing the getRealSize function off of the Display object natively to get the appropriate screen dimensions and then apply that to override the incorrect screenOriginX value.
I don’t have the answer for #2, since I’m far from an Android native programmer expert, but there isn’t a good way to update display.screenOriginX, (and Y) from native space.
FWIW, I managed to solve my issues by accessing the getRealSize function off of the Display object natively to get the appropriate screen dimensions and then apply that to override the incorrect screenOriginX value.
@flowcrow : I used Corona Enterprise and made a native Android call to access the getRealSize Android function. Here’s the relevant java code:
public int invoke(LuaState L) { // Corona application context Context coronaApplicationContext = CoronaEnvironment.getApplicationContext(); Point size = new Point(); Display display = ((WindowManager)coronaApplicationContext.getSystemService(Context.WINDOW\_SERVICE)).getDefaultDisplay(); // If we are running on KitKat or above if (isKitKatOrGreater()) { display.getRealSize(size); } else { size.x = display.getWidth(); size.y = display.getHeight(); } // Push size x L.pushInteger(size.x); // Push size y L.pushInteger(size.y); return 2; }
and then you just do the regular native code call as the tutorials show.
@flowcrow : I used Corona Enterprise and made a native Android call to access the getRealSize Android function. Here’s the relevant java code:
public int invoke(LuaState L) { // Corona application context Context coronaApplicationContext = CoronaEnvironment.getApplicationContext(); Point size = new Point(); Display display = ((WindowManager)coronaApplicationContext.getSystemService(Context.WINDOW\_SERVICE)).getDefaultDisplay(); // If we are running on KitKat or above if (isKitKatOrGreater()) { display.getRealSize(size); } else { size.x = display.getWidth(); size.y = display.getHeight(); } // Push size x L.pushInteger(size.x); // Push size y L.pushInteger(size.y); return 2; }
and then you just do the regular native code call as the tutorials show.