List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_LANDSCAPE
int SCREEN_ORIENTATION_REVERSE_LANDSCAPE
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_LANDSCAPE.
Click Source Link
reverseLandscape
in the android.R.attr#screenOrientation attribute. From source file:com.nbplus.vbroadlauncher.BroadcastWebViewActivity.java
private void setContentViewByOrientation() { int wallpapereId = LauncherSettings.getInstance(this).getWallpaperId(); int orientation = DisplayUtils.getScreenOrientation(this); if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { mWebViewClient.setBackgroundResource(LauncherSettings.landWallpaperResource[wallpapereId]); } else {//from w w w . j a va 2 s . c o m mWebViewClient.setBackgroundResource(LauncherSettings.portWallpaperResource[wallpapereId]); } }
From source file:com.mantz_it.rfanalyzer.SettingsFragment.java
/** * Will set the screen orientation of the hosting activity * * @param orientation auto, landscape, portrait, reverse_landscape or reverse_portrait *///from w w w . ja v a 2 s . c o m public void setScreenOrientation(String orientation) { if (orientation.equals("auto")) getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); else if (orientation.equals("landscape")) getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else if (orientation.equals("portrait")) getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); else if (orientation.equals("reverse_landscape")) getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); else if (orientation.equals("reverse_portrait")) getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.Utilities.java
@SuppressLint("NewApi") static int getScreenOrientation(Activity activity) { if (Build.VERSION.SDK_INT < 8) { switch (activity.getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_PORTRAIT: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; case Configuration.ORIENTATION_LANDSCAPE: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default://w w w . j av a 2s . c o m return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } } int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int height = dm.heightPixels; int orientation; // if the device's natural orientation is portrait: if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; default: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; } } // if the device's natural orientation is landscape or if the device // is square: else { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; default: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; } } return orientation; }
From source file:org.mklab.mikity.android.MainActivity.java
/** * ??????//w w w .j a va 2s . c o m */ public void controlRotation() { final Configuration configuration = getResources().getConfiguration(); final int rotation = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getRotation(); boolean isReverse = false; if (this.settingsFragment.rotationLockButton.isChecked()) { switch (rotation) { case Surface.ROTATION_180: case Surface.ROTATION_270: isReverse = true; break; default: isReverse = false; break; } if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { if (isReverse) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } else { if (isReverse) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } MainActivity.this.canvasFragment.objectRenderer.updateDisplay(); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } }
From source file:cz.tomsuch.lampicka.activities.LampActivity.java
private int getScreenOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int height = dm.heightPixels; int orientation; // if the device's natural orientation is portrait: if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; default:/*from ww w . j a va 2 s . com*/ Log.e("WTF", "Unknown screen orientation. Defaulting to " + "portrait."); orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; } } // if the device's natural orientation is landscape or if the device // is square: else { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; default: Log.e("WTF", "Unknown screen orientation. Defaulting to " + "landscape."); orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; } } return orientation; }
From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java
private int getOrientationForRotation() { int ori = ActivityInfo.SCREEN_ORIENTATION_USER; int rotation = this.getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_0) { ori = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else if (rotation == Surface.ROTATION_90) { ori = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (rotation == Surface.ROTATION_180) { ori = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } else if (rotation == Surface.ROTATION_270) { ori = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; }//from w ww . j av a 2s .c o m return ori; }
From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java
public final int intoOrientation(int flag) { int or = ActivityInfo.SCREEN_ORIENTATION_USER; if (flag == 1) {// portrait or = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else if (flag == 2) {// landscape or = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (flag == 4) {// reverse portrait or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } else if (flag == 8) {// reverse landscape or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } else if (flag == 15) {// sensor or = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; } else {/*from w ww .jav a2 s. c o m*/ ; } return or; }
From source file:com.android.purenexussettings.TinkerActivity.java
public static void lockCurrentOrientation(Activity activity) { int currentRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int orientation = activity.getResources().getConfiguration().orientation; int frozenRotation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; switch (currentRotation) { case Surface.ROTATION_0: frozenRotation = orientation == Configuration.ORIENTATION_LANDSCAPE ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break;/* www . jav a 2s . c o m*/ case Surface.ROTATION_90: frozenRotation = orientation == Configuration.ORIENTATION_PORTRAIT ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_180: frozenRotation = orientation == Configuration.ORIENTATION_LANDSCAPE ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; case Surface.ROTATION_270: frozenRotation = orientation == Configuration.ORIENTATION_PORTRAIT ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; } activity.setRequestedOrientation(frozenRotation); }
From source file:org.puder.trs80.EmulatorActivity.java
private void lockOrientation() { Display display = getWindowManager().getDefaultDisplay(); rotation = display.getRotation();/*w w w .jav a 2 s. c o m*/ int height; int width; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { height = display.getHeight(); width = display.getWidth(); } else { Point size = new Point(); display.getSize(size); height = size.y; width = size.x; } switch (rotation) { case Surface.ROTATION_90: if (width > height) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } break; case Surface.ROTATION_180: if (height > width) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } break; case Surface.ROTATION_270: if (width > height) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } break; default: if (height > width) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } }
From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java
/** * Lock the screen to the current orientation. * @return the previous orientation settings *///from w w w. j a va 2s.c om private int lockScreenOrientation() { int initialRequestedOrientation = getRequestedOrientation(); // Note: a surface rotation of 90 degrees means a physical device rotation of -90 degrees. int orientation = getResources().getConfiguration().orientation; int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: if (orientation == Configuration.ORIENTATION_PORTRAIT) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); else if (orientation == Configuration.ORIENTATION_LANDSCAPE) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_90: if (orientation == Configuration.ORIENTATION_PORTRAIT) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); else if (orientation == Configuration.ORIENTATION_LANDSCAPE) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_180: if (orientation == Configuration.ORIENTATION_PORTRAIT) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); else if (orientation == Configuration.ORIENTATION_LANDSCAPE) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; case Surface.ROTATION_270: if (orientation == Configuration.ORIENTATION_PORTRAIT) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); else if (orientation == Configuration.ORIENTATION_LANDSCAPE) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; } return initialRequestedOrientation; }