Open GoogleCodeExporter opened 9 years ago
This is a non-ideal fix in PLView:
private int getDeviceDefaultOrientation() {
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
Configuration config = getResources().getConfiguration();
int rotation = windowManager.getDefaultDisplay().getRotation();
if ( ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE)
|| ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) &&
config.orientation == Configuration.ORIENTATION_PORTRAIT))
return Configuration.ORIENTATION_LANDSCAPE;
else
return Configuration.ORIENTATION_PORTRAIT;
}
onSensorChanged/case Sensor.TYPE_ORIENTATION:
After the orientation is detected, correct it.
if (Configuration.ORIENTATION_LANDSCAPE == getDeviceDefaultOrientation())
switch (newOrientation) {
case UIDeviceOrientationPortrait: {
newOrientation = UIDeviceOrientation.UIDeviceOrientationLandscapeLeft;
break;
}
case UIDeviceOrientationPortraitUpsideDown: {
newOrientation = UIDeviceOrientation.UIDeviceOrientationLandscapeRight;
break;
}
case UIDeviceOrientationLandscapeLeft: {
newOrientation = UIDeviceOrientation.UIDeviceOrientationPortrait;
break;
}
case UIDeviceOrientationLandscapeRight: {
newOrientation = UIDeviceOrientation.UIDeviceOrientationPortraitUpsideDown;
break;
}
}
Original comment by alanatbu...@gmail.com
on 13 May 2014 at 11:37
trying the same solution for a Acer A-810 .. in this case I get the problem
highlighted in the issue both using the original PLView, both trying this
solution.
The "new" issue is that defaultOrientation is ORIENTATION_UNDEFINED and all
positions bring to Portrait.
Example:
printing rotation and config.orientation variables we get:
in portrait positition --> rotation=0 (so 0 degrees) + orient=1 (portrait) =
Configuration.ORIENTATION_PORTRAIT
in "landscape left" positition --> rotation=3 (so 270 degrees) + orient=2
(landscape) = Configuration.ORIENTATION_PORTRAIT
in "upsideDown portrait" positition --> rotation=2 (so 180 degrees) + orient=1
(portrait) = Configuration.ORIENTATION_PORTRAIT
in "landscape right" positition --> rotation=1 (so 90 degrees) + orient=2
(landscape) = Configuration.ORIENTATION_PORTRAIT
Original comment by belardin...@gmail.com
on 6 Jun 2014 at 7:23
showing toasts during exectution .. I discovered that in my case in method
onSensorChanged the exectution goes directly to case Sensor.TYPE_GYROSCOPE
without passing through Sensor.TYPE_ORIENTATION ..so maybe this part should be
edited too to solve this mismatch of sceen orientation and movement of
sensorialRotation..
Original comment by belardin...@gmail.com
on 6 Jun 2014 at 7:59
Original issue reported on code.google.com by
alanatbu...@gmail.com
on 13 May 2014 at 11:35