cordova-plugin-screen-orientation icon indicating copy to clipboard operation
cordova-plugin-screen-orientation copied to clipboard

Fix unlock

Open aszmyd opened this issue 8 years ago • 15 comments

Platforms affected

iOS and Android

What does this PR do?

After unlock is made on iOS it sets orientation to UIInterfaceOrientationUnknown so that phone decides by its own to which orientation change or not after unlocking.

Additionaly it fixes cordova warning on Android:

THREAD WARNING: exec() call to CDVOrientation.screenOrientation blocked the main thread for 94ms. Plugin should use CordovaInterface.getThreadPool()

What testing has been done on this change?

Manual testing on Android and iOS devices

Checklist

https://issues.apache.org/jira/browse/CB-13983

aszmyd avatar Mar 16 '18 10:03 aszmyd

I actually dont know why Travis had failed. The environment you requested was unavailable error looks like missing something during test. Is it possible that my changes caused something like this?

aszmyd avatar Mar 16 '18 11:03 aszmyd

I restarted the run that failed. Let's see if this fixes things.

PS: This PR is on a different plugin than the JIRA issue.

janpio avatar Mar 16 '18 11:03 janpio

@janpio i see the tests succeed. Can you merge this?

aszmyd avatar Apr 11 '18 09:04 aszmyd

Unfortunately not as I have no idea about Obj-C of this specific plugin. (Might want to send an email to the dev mailing list of Slack to get additional reviews)

janpio avatar Apr 11 '18 15:04 janpio

As far as i've checked, iOS part of this does not have this "unlock" issue. We have an app that uses this approach on both iOS and Android and making this change has been driven by the bug just on Android side

aszmyd avatar Apr 12 '18 03:04 aszmyd

These changes fix the behavior when unlock is called on iOS so it would be nice if they were merged, at least the iOS fix since I haven't tested it on android.

cvetkovskin avatar May 08 '18 03:05 cvetkovskin

Please merge the ios fix as soon as possible, would be really helpful :)

AlexanderEverett avatar May 21 '18 12:05 AlexanderEverett

With the phone in landscape if I run

window.screen.orientation.lock('portrait');
window.screen.orientation.unlock();

It remains in portrait, so looks like the fix is not working or I didn't understand it well.

jcesarmobile avatar Jul 01 '18 12:07 jcesarmobile

@aszmyd Rebase needed. I'm happy to help and get this verified on IOS and Android. Done similar change in separate PR, but your PR is also improving Android API so I vote for it :D

wtrocki avatar Jul 02 '18 11:07 wtrocki

@jcesarmobile please see the steps described in jira ticket - https://issues.apache.org/jira/browse/CB-13983

Steps you describe does not automatically gets back "landscape" as after unlocking its up to phone to make the detection. Not sure why but the line [[UIDevice currentDevice] setValue:[NSNumber numberWithInt:UIInterfaceOrientationUnknown] forKey:@"orientation"]; followed by [UINavigationController attemptRotationToDeviceOrientation]; should in theory do the job.

Original plugin covers you'r case because it keeps orientation "before lock" in local variable. So it forces phone to use it instead of allow it to recalculate. And because "last orientation" is being hard saved and restored, steps described in jira does not work.

aszmyd avatar Jul 04 '18 05:07 aszmyd

IMHO current code on master is causing more issues than resolves and this fix could be temporary until orientation will be included into cordova-ios as mentioned here: https://github.com/apache/cordova-plugin-screen-orientation/pull/32

wtrocki avatar Jul 04 '18 08:07 wtrocki

I have tried the solution but it doesn't work as expected. :heavy_check_mark: Android :heavy_multiplication_x: iOS:

  • Lock landscape on vertical orientation -> locks screen as secondary-landscape instead primary-landscape, KO.
  • Lock landscape on landscape orientation -> locks screen in landscape, OK.
  • Lock landscape on landscape-secondary orientation -> locks screen in landscape-secondary, OK.
  • Unlock landscape on landscape orientation -> maintains landscape mode, OK.
  • Unlock landscape on vertical orientation -> maintains landscape instead turn to portrait, KO.

jonastg avatar Jan 17 '19 14:01 jonastg

Is this PR going to be merged? The problem on iOS devices persist today:

https://github.com/apache/cordova-plugin-screen-orientation/issues/80

Hanzofm avatar Apr 22 '21 08:04 Hanzofm

some news about this? @aszmyd

Hanzofm avatar May 19 '21 14:05 Hanzofm

Unfortunately @Hanzofm I don't have time to deal with this these days. We depreacted project that relied on cordova some time ago and I'm not up to date with it. Feel free to fork this and handle it by yourself with probably new Pull Request - not ideal but I honestly won't find time to get back to troubleshoot this anytime soon.

aszmyd avatar May 21 '21 12:05 aszmyd

Is this solved with #102 ?

NiklasMerz avatar Feb 17 '23 14:02 NiklasMerz

Please comment or open this again if it's still relevant.

NiklasMerz avatar Feb 21 '23 19:02 NiklasMerz