List of usage examples for android.view Surface ROTATION_180
int ROTATION_180
To view the source code for android.view Surface ROTATION_180.
Click Source Link
From source file:net.zorgblub.typhon.fragment.ReadingFragment.java
@TargetApi(Build.VERSION_CODES.FROYO) private boolean handleVolumeButtonEvent(KeyEvent event) { //Disable volume button handling during TTS if (!config.isVolumeKeyNavEnabled() || ttsIsRunning()) { return false; }//from w ww .j av a 2 s . c o m Activity activity = getActivity(); if (activity == null) { return false; } boolean invert = false; int rotation = Surface.ROTATION_0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { Display display = activity.getWindowManager().getDefaultDisplay(); rotation = display.getRotation(); } switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: invert = false; break; case Surface.ROTATION_180: case Surface.ROTATION_270: invert = true; break; } if (event.getAction() != KeyEvent.ACTION_DOWN) { return true; } if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) { if (config.isVolumeKeyNavChaptersEnabled()) { if (invert) { bookView.navigateForward(); } else { bookView.navigateBack(); } } else { if (invert) { pageDown(Orientation.HORIZONTAL); } else { pageUp(Orientation.HORIZONTAL); } } } else if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) { if (config.isVolumeKeyNavChaptersEnabled()) { if (invert) { bookView.navigateBack(); } else { bookView.navigateForward(); } } else { if (invert) { pageUp(Orientation.HORIZONTAL); } else { pageDown(Orientation.HORIZONTAL); } } } return true; }
From source file:com.aimfire.demo.CamcorderActivity.java
/** * get the default/natural device orientation. this should be PORTRAIT * for phones and LANDSCAPE for tablets//from w w w.j a v a 2 s . c o m */ public int getDeviceDefaultOrientation() { WindowManager windowManager = (WindowManager) getSystemService(Context.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; } }
From source file:com.aimfire.demo.CamcorderActivity.java
/** * we fixed display to SCREEN_ORIENTATION_LANDSCAPE. but we don't know * how it is related to device's natural orientation. fortunately, * getDefaultDisplay().getRotation() tells us the information but with * a slight twist://from ww w.j a v a2s . co m * * Documentation for Display.getRotation: * Returns the rotation of the screen from its "natural" orientation. The * returned value may be Surface.ROTATION_0 (no rotation), * Surface.ROTATION_90, Surface.ROTATION_180, or Surface.ROTATION_270. * For example, if a device has a naturally tall screen, and the user has * turned it on its side to go into a landscape orientation, the value * returned here may be either Surface.ROTATION_90 or Surface.ROTATION_270 * depending on the direction it was turned. The angle is the rotation of * the drawn graphics on the screen, which is the opposite direction of the * physical rotation of the device. For example, if the device is rotated 90 * degrees counter-clockwise, to compensate rendering will be rotated by 90 * degrees clockwise and thus the returned value here will be * Surface.ROTATION_90. * * if we fix the display orientation, getRotation is going to tell us what the * fixed orientation is, relative to device natural orientation, regardless of * what the device's current, actual orientation is. and based on above, we need * to reverse the result from getRotation to get clockwise rotation */ public int getDeviceLandscapeOrientation() { int degrees = 0; int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; // this is not possible case Surface.ROTATION_270: degrees = 270; break; } // reverse the sign to get clockwise rotation return (360 - degrees) % 360; }
From source file:com.aimfire.demo.CamcorderActivity.java
public void setCameraPreviewOrientation() { if (BuildConfig.DEBUG) Log.d(TAG, "setCameraPreviewOrientation"); Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(mCameraId, info); int rotation = getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0;/* www .j a v a2 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; } int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { // front-facing result = (info.orientation + degrees) % 360; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (info.orientation - degrees + 360) % 360; } mCamera.setDisplayOrientation(result); }
From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) private int getScreenOrientation() { switch (getScreenRotation()) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_180: // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API Level 9+ return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); case Surface.ROTATION_270: // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API Level 9+ return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); default:/*from w w w .ja v a2 s . co m*/ return 0; } }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String GetRotationInfo() { WindowManager wMgr = (WindowManager) contextWrapper.getSystemService(Context.WINDOW_SERVICE); int nRotationDegrees = 0; // default switch (wMgr.getDefaultDisplay().getRotation()) { case Surface.ROTATION_90: nRotationDegrees = 90;//from w w w . j a v a2 s .c o m break; case Surface.ROTATION_180: nRotationDegrees = 180; break; case Surface.ROTATION_270: nRotationDegrees = 270; break; } return "ROTATION:" + nRotationDegrees; }
From source file:com.android.launcher2.Launcher.java
private int mapConfigurationOriActivityInfoOri(int configOri) { final Display d = getWindowManager().getDefaultDisplay(); int naturalOri = Configuration.ORIENTATION_LANDSCAPE; switch (d.getRotation()) { case Surface.ROTATION_0: case Surface.ROTATION_180: // We are currently in the same basic orientation as the natural orientation naturalOri = configOri;/*from w w w. j ava 2s . com*/ break; case Surface.ROTATION_90: case Surface.ROTATION_270: // We are currently in the other basic orientation to the natural orientation naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE; break; } int[] oriMap = { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE }; // Since the map starts at portrait, we need to offset if this device's natural orientation // is landscape. int indexOffset = 0; if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) { indexOffset = 1; } return oriMap[(d.getRotation() + indexOffset) % 4]; }