Mobile Rotation Redux

J. Landman Gay jacque at hyperactivesw.com
Mon Sep 3 17:24:19 EDT 2018


I ran both stacks on my Pixel and they got exactly the same results you 
reported; in other words, everything worked just fine.

I decided to try my theory that we could combine fullscreenMode with 
individual object placement and we can. This will prevent the tiny image 
when the device is rotated to landscape. Basically, for a stack that is 
taller than it is wide, you want showAll in portrait and noBorder in 
landscape. All I had to do was revise your orientationChanged handler 
and add some logic to determine the correct fullscreenMode. I suspect 
mobileSetFullScreenRectForOrientations would do the same thing, but I 
wasn't focused on that.

So in the MobileDemo stack, revise orientationChanged and add the FSM 
function and it should work. The rest of the handlers can remain as-is. 
This particular revision only assumes we're using showAll and noBorder; 
it doesn't address any others. Those are the two that almost all mobile 
apps use.

on orientationChanged
   if the fullscreenmode of this stack is not empty then
     send "setBackground" to me in 200 milliseconds
     send "setFSM" to me in 250 milliseconds
     -- updateStatus "Orientation:" && mobileDeviceOrientation()
   end if
end orientationChanged

on setFSM
   if the fullscreenmode of this stack is not among the items of 
"showAll,noBorder" then exit setFSM
   set the rect of this stack to the effective working screenRect
   if mobileDeviceOrientation() contains "landscape" then
     set the fullscreenmode of this stack to "noBorder"
   else if mobileDeviceOrientation() contains "portrait" then
     set the fullscreenmode of this stack to "showAll"
   end if
   updateStatus "setFSM:" && the fullscreenmode of this stack
   set the backcolor of this cd to the backcolor of this cd
end setFSM

I had to use your "set the rect of this stack" method to force 
fullscreenMode to resolve, that's a nice trick. Setting the backcolor of 
the card to its existing color is a hack workaround that Panos 
discovered which forces a card redraw. That eliminates the issue where 
objects outside the card rect don't redraw properly, so now you don't 
need to lay the device flat to do it.

I did wonder why you need the math in the setBackground handler. Doesn't 
the working screenrect give the right measurements?


On 9/1/18 1:35 AM, Brian Milby via use-livecode wrote:
> As I like to do, I decided to really over-do the demo test stacks.  The one
> I mentioned initially is:
> 
> https://milby.us/lc/RotationDemo.livecode
> 
> The one I just finished working on does a bit more:
> 
> https://milby.us/lc/MobileDemo.livecode
> 
> I built both to test resizeStack and rotation on Android.  I only have a 5"
> Fire, so I only was able to test on one device. 

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list