jianlinwei / panoramagl-android

Automatically exported from code.google.com/p/panoramagl-android
0 stars 0 forks source link

SensorialRotation is incorrect on devices that have landscape as their default orientation #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call startSensorialRotation or set it in the json
2. Run on a tablet

What is the expected output? What do you see instead?

You should see that the left and right actions are swapped. I.e. look up and 
view turns. Turn and view looks up/down.

What version of the product are you using? On what operating system?

0.2 beta
Android 4.0.4
Motorola Xoom

Please provide any additional information below.

Original issue reported on code.google.com by alanatbu...@gmail.com on 13 May 2014 at 11:35

GoogleCodeExporter commented 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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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