List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_PORTRAIT
int SCREEN_ORIENTATION_REVERSE_PORTRAIT
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_PORTRAIT.
Click Source Link
reversePortrait
in the android.R.attr#screenOrientation attribute. 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 {/* w ww . ja v a 2 s . c om*/ ; } 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;//from ww w . j a va 2 s . 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();//from w ww. j av a 2s .co 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 *//* www . j av a 2 s . co m*/ 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; }
From source file:com.mantz_it.rfanalyzer.ui.activity.MainActivity.java
/** * Will check if any preference conflicts with the current state of the app and fix it *//*from ww w . j a va2 s.c om*/ public void checkForChangedPreferences() { int sourceType = Integer.parseInt(preferences.getString(getString(R.string.pref_sourceType), "1")); /* todo: rework settings repository, so we could use reflection to instantiate source instead of hardcoded switch */ /* todo dependency injection*/ if (source != null) { switch (sourceType) { case FILE_SOURCE: updateSourcePreferences(FileIQSource.class); break; case HACKRF_SOURCE: updateSourcePreferences(HackrfSource.class); break; case RTLSDR_SOURCE: updateSourcePreferences(RtlsdrSource.class); break; case HIQSDR_SOURCE: updateSourcePreferences(HiqsdrSource.class); break; default: Log.e(LOGTAG, "checkForChangedPreferences: selected source type (" + sourceType + "is not supported"); } } if (analyzerSurface != null) { onPreferencesChanged(analyzerSurface, preferences); } // Screen Orientation: String screenOrientation = preferences.getString(getString(R.string.pref_screenOrientation), "auto") .toLowerCase(); int orientation; switch (screenOrientation) { case "landscape": orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case "portrait": orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case "reverse_landscape": orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case "reverse_portrait": orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; default: case "auto": orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; break; } setRequestedOrientation(orientation); }
From source file:com.mantz_it.rfanalyzer.MainActivity.java
/** * Will check if any preference conflicts with the current state of the app and fix it *//*from ww w.j a va 2 s . c o m*/ public void checkForChangedPreferences() { // Source Type (this is pretty complex as we have to check each type individually): int sourceType = Integer.valueOf(preferences.getString(getString(R.string.pref_sourceType), "1")); if (source != null) { switch (sourceType) { case FILE_SOURCE: if (!(source instanceof FileIQSource)) { source.close(); createSource(); } else { long freq = Integer.valueOf( preferences.getString(getString(R.string.pref_filesource_frequency), "97000000")); int sampRate = Integer.valueOf( preferences.getString(getString(R.string.pref_filesource_sampleRate), "2000000")); String fileName = preferences.getString(getString(R.string.pref_filesource_file), ""); int fileFormat = Integer .valueOf(preferences.getString(getString(R.string.pref_filesource_format), "0")); boolean repeat = preferences.getBoolean(getString(R.string.pref_filesource_repeat), false); if (freq != source.getFrequency() || sampRate != source.getSampleRate() || !fileName.equals(((FileIQSource) source).getFilename()) || repeat != ((FileIQSource) source).isRepeat() || fileFormat != ((FileIQSource) source).getFileFormat()) { source.close(); createSource(); } } break; case HACKRF_SOURCE: if (!(source instanceof HackrfSource)) { source.close(); createSource(); } else { // overwrite hackrf source settings if changed: boolean amp = preferences.getBoolean(getString(R.string.pref_hackrf_amplifier), false); boolean antennaPower = preferences.getBoolean(getString(R.string.pref_hackrf_antennaPower), false); int frequencyOffset = Integer .valueOf(preferences.getString(getString(R.string.pref_hackrf_frequencyOffset), "0")); if (((HackrfSource) source).isAmplifierOn() != amp) ((HackrfSource) source).setAmplifier(amp); if (((HackrfSource) source).isAntennaPowerOn() != antennaPower) ((HackrfSource) source).setAntennaPower(antennaPower); if (((HackrfSource) source).getFrequencyOffset() != frequencyOffset) ((HackrfSource) source).setFrequencyOffset(frequencyOffset); } break; case RTLSDR_SOURCE: if (!(source instanceof RtlsdrSource)) { source.close(); createSource(); } else { // Check if ip or port has changed and recreate source if necessary: String ip = preferences.getString(getString(R.string.pref_rtlsdr_ip), ""); int port = Integer.valueOf(preferences.getString(getString(R.string.pref_rtlsdr_port), "1234")); boolean externalServer = preferences.getBoolean(getString(R.string.pref_rtlsdr_externalServer), false); if (externalServer) { if (!ip.equals(((RtlsdrSource) source).getIpAddress()) || port != ((RtlsdrSource) source).getPort()) { source.close(); createSource(); return; } } else { if (!((RtlsdrSource) source).getIpAddress().equals("127.0.0.1") || 1234 != ((RtlsdrSource) source).getPort()) { source.close(); createSource(); return; } } // otherwise just overwrite rtl-sdr source settings if changed: int frequencyCorrection = Integer.valueOf( preferences.getString(getString(R.string.pref_rtlsdr_frequencyCorrection), "0")); int frequencyOffset = Integer .valueOf(preferences.getString(getString(R.string.pref_rtlsdr_frequencyOffset), "0")); if (frequencyCorrection != ((RtlsdrSource) source).getFrequencyCorrection()) ((RtlsdrSource) source).setFrequencyCorrection(frequencyCorrection); if (((RtlsdrSource) source).getFrequencyOffset() != frequencyOffset) ((RtlsdrSource) source).setFrequencyOffset(frequencyOffset); ((RtlsdrSource) source).setDirectSampling(Integer .valueOf(preferences.getString(getString(R.string.pref_rtlsdr_directSamp), "0"))); } break; default: } } if (analyzerSurface != null) { // All GUI settings will just be overwritten: analyzerSurface .setVerticalScrollEnabled(preferences.getBoolean(getString(R.string.pref_scrollDB), true)); analyzerSurface.setVerticalZoomEnabled(preferences.getBoolean(getString(R.string.pref_zoomDB), true)); analyzerSurface.setDecoupledAxis(preferences.getBoolean(getString(R.string.pref_decoupledAxis), false)); analyzerSurface.setDisplayRelativeFrequencies( preferences.getBoolean(getString(R.string.pref_relativeFrequencies), false)); analyzerSurface.setWaterfallColorMapType( Integer.valueOf(preferences.getString(getString(R.string.pref_colorMapType), "4"))); analyzerSurface.setFftDrawingType( Integer.valueOf(preferences.getString(getString(R.string.pref_fftDrawingType), "2"))); analyzerSurface.setAverageLength( Integer.valueOf(preferences.getString(getString(R.string.pref_averaging), "0"))); analyzerSurface.setPeakHoldEnabled(preferences.getBoolean(getString(R.string.pref_peakHold), false)); analyzerSurface.setFftRatio( Float.valueOf(preferences.getString(getString(R.string.pref_spectrumWaterfallRatio), "0.5"))); analyzerSurface .setFontSize(Integer.valueOf(preferences.getString(getString(R.string.pref_fontSize), "2"))); analyzerSurface.setShowDebugInformation( preferences.getBoolean(getString(R.string.pref_showDebugInformation), false)); analyzerSurface.setDisplayFrequencyUnit( Integer.valueOf(preferences.getString(getString(R.string.pref_surface_unit), "1000000"))); } // Screen Orientation: String screenOrientation = preferences.getString(getString(R.string.pref_screenOrientation), "auto"); if (screenOrientation.equals("auto")) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); else if (screenOrientation.equals("landscape")) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else if (screenOrientation.equals("portrait")) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); else if (screenOrientation.equals("reverse_landscape")) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); else if (screenOrientation.equals("reverse_portrait")) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); }
From source file:com.aimfire.main.MainActivity.java
public int getScreenOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_270) { return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else {/*from www .j a va 2 s. c o m*/ return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } } if (orientation == Configuration.ORIENTATION_LANDSCAPE) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else { return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } } return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; }
From source file:net.zorgblub.typhon.fragment.ReadingFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void updateFromPrefs() { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity == null) { return;/* www.j a v a 2 s. c o m*/ } bookView.setTextSize(config.getTextSize()); int marginH = config.getHorizontalMargin(); int marginV = config.getVerticalMargin(); this.textLoader.setFontFamily(config.getDefaultFontFamily()); this.bookView.setFontFamily(config.getDefaultFontFamily()); this.textLoader.setSansSerifFontFamily(config.getSansSerifFontFamily()); this.textLoader.setSerifFontFamily(config.getSerifFontFamily()); bookView.setHorizontalMargin(marginH); bookView.setVerticalMargin(marginV); if (!isAnimating()) { bookView.setEnableScrolling(config.isScrollingEnabled()); } textLoader.setStripWhiteSpace(config.isStripWhiteSpaceEnabled()); textLoader.setAllowStyling(config.isAllowStyling()); textLoader.setUseColoursFromCSS(config.isUseColoursFromCSS()); bookView.setLineSpacing(config.getLineSpacing()); if (config.isFullScreenEnabled()) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); activity.getSupportActionBar().hide(); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); activity.getSupportActionBar().show(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (config.isFullScreenEnabled()) { activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } if (config.isDimSystemUI()) { activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } } if (config.isKeepScreenOn()) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } restoreColorProfile(); // Check if we need a restart if (config.isFullScreenEnabled() != savedConfigState.fullscreen || config.isShowPageNumbers() != savedConfigState.usePageNum || config.isBrightnessControlEnabled() != savedConfigState.brightness || config.isStripWhiteSpaceEnabled() != savedConfigState.stripWhiteSpace || !config.getDefaultFontFamily().getName().equalsIgnoreCase(savedConfigState.fontName) || !config.getSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.serifFontName) || !config.getSansSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.sansSerifFontName) || config.getHorizontalMargin() != savedConfigState.hMargin || config.getVerticalMargin() != savedConfigState.vMargin || config.getTextSize() != savedConfigState.textSize || config.isScrollingEnabled() != savedConfigState.scrolling || config.isAllowStyling() != savedConfigState.allowStyling || config.isUseColoursFromCSS() != savedConfigState.allowColoursFromCSS || config.isRikaiEnabled() != savedConfigState.rikaiEnabled || dictionaryService.getLastUpdateTimestamp() > this.dictionaryLastUpdate) { DictionaryServiceImpl.reset(); textLoader.invalidateCachedText(); restartActivity(); } Configuration.OrientationLock orientation = config.getScreenOrientation(); switch (orientation) { case PORTRAIT: getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case LANDSCAPE: getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case REVERSE_LANDSCAPE: getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); // Android 2.3+ value break; case REVERSE_PORTRAIT: getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); // Android 2.3+ value break; default: getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }
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:// w w w .j av a2 s . c om return 0; } }