List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED
int SCREEN_ORIENTATION_UNSPECIFIED
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED.
Click Source Link
unspecified
in the android.R.attr#screenOrientation attribute. From source file:it.readbeyond.minstrel.commander.Commander.java
private void orient(final String option, final CallbackContext callbackContext) { try {/*www . jav a 2 s .c om*/ Activity activity = cordova.getActivity(); if (option.equals(ORIENT_OPTION_PORTRAIT)) { // portrait or reverse portrait activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else if (option.equals(ORIENT_OPTION_LANDSCAPE)) { // landscape or reverse portrait activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else if (option.equals(ORIENT_OPTION_AUTO)) { // unlock orientation activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else { // default: unlock orientation activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } callbackContext.success(""); } catch (Exception e) { // nop callbackContext.error("Exception " + e); } }
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;/* w w w. jav a 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:com.caseystalnaker.android.popinvideodemo.fragments.Camera2VideoFragment.java
private void stopRecordingVideo(final boolean startPreview) { mIsRecordingVideo = false;//from w ww. j av a 2 s.c o m closeCamera(); stopCountdownTimer(); if (null != mContext) { //reset button to "record" mButtonVideo.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.record_btn)); final Intent videoCompleteIntent = new Intent(Utils.PREVIEW_VIDEO_COMPLETE_INTENT); videoCompleteIntent.putExtra(Utils.PREVIEW_VIDEO_PATH_INTENT_KEY, mNextVideoAbsolutePath); //broadcast a local intent containing path to newly recorded video //This will ultimately launch a new activity to show the preview. LocalBroadcastManager.getInstance(mContext).sendBroadcast(videoCompleteIntent); } if (startPreview) openCamera(mTextureView.getWidth(), mTextureView.getHeight()); //unlock orientation getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); }
From source file:jackpal.androidterm.Term.java
private void updatePrefs() { ActivityCompat.invalidateOptionsMenu(this); mUseKeyboardShortcuts = mSettings.getUseKeyboardShortcutsFlag(); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); setFunctionKeyVisibility();/* www .j av a2 s.c om*/ mViewFlipper.updatePrefs(mSettings); for (View v : mViewFlipper) { ((EmulatorView) v).setDensity(metrics); ((TermView) v).updatePrefs(mSettings); setPreIMEShortsuts((EmulatorView) v); if (mSettings.useCookedIME() == false) { ((EmulatorView) v).setIMECtrlBeginBatchEditDisable(false); } } if (mTermSessions != null) { for (TermSession session : mTermSessions) { ((GenericTermSession) session).updatePrefs(mSettings); } } { Window win = getWindow(); WindowManager.LayoutParams params = win.getAttributes(); final int FULLSCREEN = WindowManager.LayoutParams.FLAG_FULLSCREEN; int desiredFlag = mSettings.showStatusBar() ? 0 : FULLSCREEN; if (desiredFlag != (params.flags & FULLSCREEN) || (AndroidCompat.SDK >= 11 && mActionBarMode != mSettings.actionBarMode())) { if (mAlreadyStarted) { // Can't switch to/from fullscreen after // starting the activity. restart(); } else { win.setFlags(desiredFlag, FULLSCREEN); if (mActionBarMode >= TermSettings.ACTION_BAR_MODE_HIDES) { if (mActionBar != null) { mActionBar.hide(); } } } } } int orientation = mSettings.getScreenOrientation(); int o = 0; if (orientation == 0) { o = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } else if (orientation == 1) { o = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (orientation == 2) { o = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else { /* Shouldn't be happened. */ } setRequestedOrientation(o); }
From source file:org.connectbot.ConsoleActivity.java
/** * *//*w w w.j a v a 2 s . c o m*/ private void configureOrientation() { String rotateDefault; if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) rotateDefault = PreferenceConstants.ROTATION_PORTRAIT; else rotateDefault = PreferenceConstants.ROTATION_LANDSCAPE; String rotate = prefs.getString(PreferenceConstants.ROTATION, rotateDefault); if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate)) rotate = rotateDefault; // request a forced orientation if requested by user if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); forcedOrientation = true; } else if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); forcedOrientation = true; } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); forcedOrientation = false; } }
From source file:com.vonglasow.michael.satstat.ui.MainActivity.java
/** * Called when a sensor's reading changes. Updates sensor display and rotates sky plot according * to bearing.//ww w . j a va 2s . c om */ public void onSensorChanged(SensorEvent event) { //to enforce sensor rate boolean isRateElapsed = false; switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: isRateElapsed = (event.timestamp / 1000) - mAccLast >= iSensorRate; // if Z acceleration is greater than X/Y combined, lock rotation, else unlock if (Math.pow(event.values[2], 2) > Math.pow(event.values[0], 2) + Math.pow(event.values[1], 2)) { // workaround (SCREEN_ORIENTATION_LOCK is unsupported on API < 18) if (isWideScreen) setRequestedOrientation( OR_FROM_ROT_WIDE[this.getWindowManager().getDefaultDisplay().getRotation()]); else setRequestedOrientation( OR_FROM_ROT_TALL[this.getWindowManager().getDefaultDisplay().getRotation()]); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } break; case Sensor.TYPE_ORIENTATION: isRateElapsed = (event.timestamp / 1000) - mOrLast >= iSensorRate; break; case Sensor.TYPE_GYROSCOPE: isRateElapsed = (event.timestamp / 1000) - mGyroLast >= iSensorRate; break; case Sensor.TYPE_MAGNETIC_FIELD: isRateElapsed = (event.timestamp / 1000) - mMagLast >= iSensorRate; break; case Sensor.TYPE_LIGHT: isRateElapsed = (event.timestamp / 1000) - mLightLast >= iSensorRate; break; case Sensor.TYPE_PROXIMITY: isRateElapsed = (event.timestamp / 1000) - mProximityLast >= iSensorRate; break; case Sensor.TYPE_PRESSURE: isRateElapsed = (event.timestamp / 1000) - mPressureLast >= iSensorRate; break; case Sensor.TYPE_RELATIVE_HUMIDITY: isRateElapsed = (event.timestamp / 1000) - mHumidityLast >= iSensorRate; break; case Sensor.TYPE_AMBIENT_TEMPERATURE: isRateElapsed = (event.timestamp / 1000) - mTempLast >= iSensorRate; break; } if (!isRateElapsed) return; switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: mAccLast = event.timestamp / 1000; break; case Sensor.TYPE_ORIENTATION: mOrLast = event.timestamp / 1000; break; case Sensor.TYPE_GYROSCOPE: mGyroLast = event.timestamp / 1000; break; case Sensor.TYPE_MAGNETIC_FIELD: mMagLast = event.timestamp / 1000; break; case Sensor.TYPE_LIGHT: mLightLast = event.timestamp / 1000; break; case Sensor.TYPE_PROXIMITY: mProximityLast = event.timestamp / 1000; break; case Sensor.TYPE_PRESSURE: mPressureLast = event.timestamp / 1000; break; case Sensor.TYPE_RELATIVE_HUMIDITY: mHumidityLast = event.timestamp / 1000; break; case Sensor.TYPE_AMBIENT_TEMPERATURE: mTempLast = event.timestamp / 1000; break; } if (sensorSectionFragment != null) { sensorSectionFragment.onSensorChanged(event); } if (gpsSectionFragment != null) { gpsSectionFragment.onSensorChanged(event); } }
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 www. j a v a2 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 w w w. ja va 2 s . c om 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.xmobileapp.rockplayer.RockPlayer.java
/******************************************* * //www.j ava2s. co m * OnActivityResult * *******************************************/ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { try { Log.i("BACKFROMPREFERENCES", "Activity Result Processing..."); /* * Coming back from preferences - check if stuff changed */ if (requestCode == new Constants().PREFERENCES_REQUEST) { Log.i("BACKFROMPREFERENCES", "...From Preferences Activity..."); RockOnPreferenceManager settings = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH); /* * Check for the recently added playlist period change */ // if(this.recentPlaylistPeriod != getSharedPreferences(PREFS_NAME, 0) if (this.recentPlaylistPeriod != settings.getInt(new Constants().PREF_KEY_RECENT_PERIOD, new Constants().RECENT_PERIOD_DEFAULT_IN_DAYS)) { Log.i("BACKFROMPREFERENCES", "Recent Playlist Period was changed..."); // this.recentPlaylistPeriod = getSharedPreferences(PREFS_NAME, 0) this.recentPlaylistPeriod = settings.getInt(new Constants().PREF_KEY_RECENT_PERIOD, new Constants().RECENT_PERIOD_DEFAULT_IN_DAYS); /* * Update value of the service component */ this.playerServiceIface.setRecentPeriod(this.recentPlaylistPeriod); /* * Update the UI if we are playing the recently added playlist */ if (this.playlist == new Constants().PLAYLIST_RECENT) { Log.i("BACKFROMPREFERENCES", "Reloading album navigator"); /* * Reinitialize the album and song cursors */ initializeAlbumCursor(); albumCursor.moveToFirst(); songCursor = initializeSongCursor(albumCursor .getString(albumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM))); /* * Reload Navigator List */ recycleNavigatorList(); albumAdapter = null; getAlbums(true); } } /* * Reload preferences that require modification */ readPreferences(); albumAdapter.showArtWhileScrolling = showArtWhileScrolling; albumAdapter.showFrame = showFrame; /* * Reload Orientation stuff */ if (alwaysLandscape) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else if (autoRotate) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); else setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); /* * Update background */ if (VIEW_STATE == NORMAL_VIEW) setBackground(); } } catch (Exception e) { } }
From source file:com.google.appinventor.components.runtime.Form.java
/** * The requested screen orientation. Commonly used values are unspecified (-1), landscape (0), portrait (1), sensor (4), and user (2). " + "See the Android developer documentation for ActivityInfo.Screen_Orientation for the " + "complete list of possible settings. * * ScreenOrientation property getter method. * * @return screen orientation/*from ww w . j av a 2s.c o m*/ */ @SimpleProperty(category = PropertyCategory.APPEARANCE, description = "The requested screen orientation, specified as a text value. " + "Commonly used values are " + "landscape, portrait, sensor, user and unspecified. " + "See the Android developer documentation for ActivityInfo.Screen_Orientation for the " + "complete list of possible settings.") public String ScreenOrientation() { switch (getRequestedOrientation()) { case ActivityInfo.SCREEN_ORIENTATION_BEHIND: return "behind"; case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: return "landscape"; case ActivityInfo.SCREEN_ORIENTATION_NOSENSOR: return "nosensor"; case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: return "portrait"; case ActivityInfo.SCREEN_ORIENTATION_SENSOR: return "sensor"; case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED: return "unspecified"; case ActivityInfo.SCREEN_ORIENTATION_USER: return "user"; case 10: // ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR return "fullSensor"; case 8: // ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE return "reverseLandscape"; case 9: // ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT return "reversePortrait"; case 6: // ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE return "sensorLandscape"; case 7: // ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT return "sensorPortrait"; } return "unspecified"; }