List of usage examples for android.view Surface ROTATION_90
int ROTATION_90
To view the source code for android.view Surface ROTATION_90.
Click Source Link
From source file:org.ormma.controller.OrmmaDisplayController.java
/** * Gets the orientation.// ww w .ja v a 2 s . c o m * * @return the orientation */ public int getOrientation() { int orientation = mWindowManager.getDefaultDisplay().getOrientation(); int ret = -1; switch (orientation) { case Surface.ROTATION_0: ret = 0; break; case Surface.ROTATION_90: ret = 90; break; case Surface.ROTATION_180: ret = 180; break; case Surface.ROTATION_270: ret = 270; break; } Log.d(LOG_TAG, "getOrientation: " + ret); return ret; }
From source file:com.jasompeter.openalpr.CameraActivity.java
public void setCorrectOrientation(Camera camera) { int displayRotation = getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (displayRotation) { case Surface.ROTATION_0: degrees = 0;/*from w ww.java 2 s . c o m*/ break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } Camera.CameraInfo cameraInfo = getCurrentCameraInfo(); int resultDegrees; if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { resultDegrees = (cameraInfo.orientation + degrees) % 360; resultDegrees = (360 - resultDegrees) % 360; } else { resultDegrees = (cameraInfo.orientation - degrees + 360) % 360; } camera.setDisplayOrientation(resultDegrees); Camera.Parameters parameters = camera.getParameters(); parameters.setRotation(resultDegrees); camera.setParameters(parameters); }
From source file:com.almalence.util.Util.java
public static int getDisplayRotation(Activity activity) { int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: return 0; case Surface.ROTATION_90: return 90; case Surface.ROTATION_180: return 180; case Surface.ROTATION_270: return 270; default://from ww w . j a v a2 s .co m break; } return 0; }
From source file:com.coact.kochzap.CaptureActivity.java
private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default:// w w w.ja v a 2 s .co m return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } } else { switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; default: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } } }
From source file:com.nextgis.maplibui.util.ControlHelper.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public static void lockScreenOrientation(Activity activity) { WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); Configuration configuration = activity.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); // Search for the natural position of the device if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) || configuration.orientation == Configuration.ORIENTATION_PORTRAIT && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) { // Natural position is Landscape switch (rotation) { case Surface.ROTATION_0: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_90: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); break; case Surface.ROTATION_180: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; case Surface.ROTATION_270: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; }/* w w w .j av a2 s. c o m*/ } else { // Natural position is Portrait switch (rotation) { case Surface.ROTATION_0: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case Surface.ROTATION_90: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_180: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); break; case Surface.ROTATION_270: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; } } }
From source file:com.metinkale.prayerapp.compass.Main.java
@Override public void onRotationUpdate(float[] newMatrix) { if (mMode == Mode.Map) { return;// w w w . j a v a2 s .co m } // remap matrix values according to display rotation, as in // SensorManager documentation. switch (mDisplayRotation) { case Surface.ROTATION_0: case Surface.ROTATION_180: break; case Surface.ROTATION_90: SensorManager.remapCoordinateSystem(newMatrix, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, newMatrix); break; case Surface.ROTATION_270: SensorManager.remapCoordinateSystem(newMatrix, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_X, newMatrix); break; default: break; } mRotationMatrix.set(newMatrix); mOrientationCalculator.getOrientation(mRotationMatrix, mDisplayRotation, mDerivedDeviceOrientation); updateFrag((mDerivedDeviceOrientation[1] > -55f) ? Mode.ThreeDim : Mode.TwoDim); mList.onUpdateSensors(mDerivedDeviceOrientation); }
From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java
private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default:/*from w w w . j a va 2 s . c o m*/ return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } }
From source file:com.tritop.androsense2.fragments.GpsFragment.java
@Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { mAccel = event.values;//from w ww.ja v a2 s . c o m } if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { mMag = event.values; } if ((mAccel != null) && (mMag != null)) { float R[] = new float[9]; float I[] = new float[9]; float Rot[] = new float[9]; if (SensorManager.getRotationMatrix(R, I, mAccel, mMag)) { float orientation[] = new float[3]; int axisX = 0, axisY = 0; switch (display.getRotation()) { case Surface.ROTATION_0: axisX = SensorManager.AXIS_X; axisY = SensorManager.AXIS_Y; break; case Surface.ROTATION_90: axisX = SensorManager.AXIS_Y; axisY = SensorManager.AXIS_MINUS_X; break; case Surface.ROTATION_180: axisX = SensorManager.AXIS_MINUS_X; axisY = SensorManager.AXIS_MINUS_Y; break; case Surface.ROTATION_270: axisX = SensorManager.AXIS_MINUS_Y; axisY = SensorManager.AXIS_X; break; default: break; } SensorManager.remapCoordinateSystem(R, axisX, axisY, Rot); SensorManager.getOrientation(Rot, orientation); aRotation = orientation[0]; aRotation = (int) Math.toDegrees(aRotation); satView.setAzimutRotation(-aRotation); satView.invalidate(); } } }
From source file:net.oschina.app.v2.activity.zxing.CaptureActivity.java
@Deprecated private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default:/*from ww w.jav a 2 s . c o m*/ return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } }
From source file:com.nextgis.mobile.forms.CompassFragment.java
public int getDeviceRotation() { Display display = getActivity().getWindowManager().getDefaultDisplay(); final int rotation = display.getRotation(); if (rotation == Surface.ROTATION_90) { return 90; } else if (rotation == Surface.ROTATION_180) { return 180; } else if (rotation == Surface.ROTATION_270) { return 270; }/*ww w . j av a 2 s. c om*/ return 0; }