Fix unlock
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
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?
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 i see the tests succeed. Can you merge this?
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)
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
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.
Please merge the ios fix as soon as possible, would be really helpful :)
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.
@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
@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.
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
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.
Is this PR going to be merged? The problem on iOS devices persist today:
https://github.com/apache/cordova-plugin-screen-orientation/issues/80
some news about this? @aszmyd
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.
Is this solved with #102 ?
Please comment or open this again if it's still relevant.