compute display.screenOriginX natively in Android?

I’m trying to add sticky immersive to our Corona app through a native Enterprise build to get around some of the issues discussed here: https://forums.coronalabs.com/topic/53170-immersivesticky-and-displayscreenoriginx/

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.

  1. Is there any easy way to update display.screenOriginX within Corona api calls to reflect the correct values?

if 1 isn’t possible then

  1.  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?

Thanks,

Kenric

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.

Rob

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.

Rob

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.

kleung,

Can you share how you used getRealSize from Corona? An example would be great.

Thanks

Joe

@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.

Thanks for your replay. Unfortunately I don’t have access to the Enterprise version.

kleung,

Can you share how you used getRealSize from Corona? An example would be great.

Thanks

Joe

@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.

Thanks for your replay. Unfortunately I don’t have access to the Enterprise version.