List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE
int SCREEN_ORIENTATION_LANDSCAPE
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.
Click Source Link
landscape
in the android.R.attr#screenOrientation attribute. From source file:org.connectbot.ConsoleActivity.java
/** * *///w w w. java2 s . com 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.aimfire.demo.CamcorderActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) Log.d(TAG, "create CamcorderActivity"); loadPrefs();/*from w w w. j a v a2s. c o m*/ /* * keep the screen on until we turn off the flag */ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); super.onCreate(savedInstanceState); setContentView(R.layout.activity_camcorder); /* * Obtain the FirebaseAnalytics instance. */ mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); /* * disable nfc push */ NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this); /* * get the natural orientation of this device. need to be called before * we fix the display orientation */ mNaturalOrientation = getDeviceDefaultOrientation(); /* * force CamcorderActivity in landscape because it is the natural * orientation of the camera sensor */ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); /* * get the orientation for SCREEN_ORIENTATION_LANDSCAPE mode. this is the * clockwise rotation of landscape mode from device natural orientation. * reverse landscape is 180 degrees different. call this *after* the * display orientation is fixed, because only then getDefaultDisplay(). * getRotation() will consistently return the value we require. */ mLandscapeOrientation = getDeviceLandscapeOrientation(); /* * apply the adapter to the spinner - for filter selection. */ /* ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.cameraFilterNames, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); */ mParentView = getActivity().getWindow().getDecorView(); mCaptureButton = (ImageButton) findViewById(R.id.toggle_recording_button); mView3DButton = (ImageButton) findViewById(R.id.view3D_button); mExitButton = (ImageButton) findViewById(R.id.exit_button); mPvButton = (ImageButton) findViewById(R.id.switch_photo_video_button); mFbButton = (ImageButton) findViewById(R.id.switch_front_back_button); mLevelButton = (Button) findViewById(R.id.level_button); mTimeCounter = (LinearLayout) findViewById(R.id.time_counter); mScanModeButton = (ImageButton) findViewById(R.id.mode_button); mCaptureButton.setOnClickListener(oclToggle); mView3DButton.setOnClickListener(oclView3D); mExitButton.setOnClickListener(oclExit); mPvButton.setOnClickListener(oclPV); mFbButton.setOnClickListener(oclFB); mScanModeButton.setOnClickListener(oclSwitchMode); mShutterLayout = (FrameLayout) findViewById(R.id.shutter_layout); mProgView = (ImageView) findViewById(R.id.circular_progress_view); mProgDrawable = new com.aimfire.utilities.CircularProgressDrawable.Builder().setRingWidth(10) .setRingColor(getResources().getColor(R.color.orange)).create(); mProgView.setImageDrawable(mProgDrawable); mScanProgView = (ImageView) findViewById(R.id.scan_circular_progress_view); mScanProgView.setOnClickListener(oclScan); int[] centerGradient = new int[] { getResources().getColor(R.color.start_button_start_color_pressed), getResources().getColor(R.color.start_button_end_color_pressed) }; mScanProgDrawable = new com.aimfire.utilities.CircularProgressDrawable.Builder().setRingWidth(10) .setInnerCircleScale(1.0f).setOutlineColor(getResources().getColor(R.color.dark_grey)) .setRingColor(getResources().getColor(R.color.white)) .setArcColor(getResources().getColor(android.R.color.holo_blue_dark)) .setCenterGradient(centerGradient).setWifiBarColor(getResources().getColor(R.color.blue)) .setMessageSize((int) (10/*sp*/ * getResources().getDisplayMetrics().density)) .setMessageColor(getResources().getColor(R.color.white)).create(); mScanProgView.setImageDrawable(mScanProgDrawable); /* * showing animation for searching remote device */ startScanAnim(); String startSound = null; String stopSound = null; for (String s : CAMERA_RECORDING_START_SOUND) { if ((new File(s)).exists()) { startSound = s; break; } } if (startSound != null) { mCamStartSoundPlayer = MediaPlayer.create(this, Uri.fromFile(new File(startSound))); } for (String s : CAMERA_RECORDING_STOP_SOUND) { if ((new File(s)).exists()) { stopSound = s; break; } } if (stopSound != null) { mCamStopSoundPlayer = MediaPlayer.create(this, Uri.fromFile(new File(stopSound))); } /* * file name prefix for solo mode. rest of the file name (date and time stamp) are * added when recording starts. */ mMpegPrefixSolo = MainConsts.MEDIA_3D_SAVE_PATH + "MPG_solo_"; /* * place UI controls at their initial, default orientation */ adjustUIControls(0); /* * load the thumbnail of the newest movie to the view3D button */ loadCurrThumbnail(); /* * attempt to open camera with desired dimension. the dimension may be * changed if camera doesn't support it, in which case the "preferred" * (by the camera) dimension will be used */ boolean success = openCamera(Camera.CameraInfo.CAMERA_FACING_BACK, mQualityPref); if (!success) { Toast.makeText(this, R.string.error_opening_camera, Toast.LENGTH_LONG).show(); finish(); return; } /* * define a handler that receives camera-control messages from other threads. * all calls to Camera must be made on the same thread. note we create this * before the renderer thread, so we know the fully-constructed object will * be visible. */ mCameraHandler = new CameraHandler(this); /* * configure the GLSurfaceView. this will start the Renderer thread, with an * appropriate EGL context. */ mGLView = (GLSurfaceView) findViewById(R.id.cameraPreview_surfaceView); mGLView.setEGLContextClientVersion(2); // select GLES 2.0 mRenderer = new CameraSurfaceRenderer(mCameraHandler, mMovieEncoder); mGLView.setRenderer(mRenderer); mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); mGLView.setOnTouchListener(otl); /* * bind to Aimfire service */ mAimfireServiceConn = new AimfireServiceConn(this); /* * binding doesn't happen until later. wait for it to happen in another * thread and connect to p2p peer if necessary */ (new Thread(mAimfireServiceInitTask)).start(); /* * register for AimfireService message broadcast */ LocalBroadcastManager.getInstance(this).registerReceiver(mAimfireServiceMsgReceiver, new IntentFilter(MainConsts.AIMFIRE_SERVICE_MESSAGE)); /* * register for intents sent by the media processor service */ LocalBroadcastManager.getInstance(this).registerReceiver(mMovieProcessorMsgReceiver, new IntentFilter(MainConsts.MOVIE_PROCESSOR_MESSAGE)); /* * register for intents sent by the media processor service */ LocalBroadcastManager.getInstance(this).registerReceiver(mMovieEncoderMsgReceiver, new IntentFilter(MainConsts.MOVIE_ENCODER_MESSAGE)); }
From source file:it.geosolutions.android.map.MapsActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig); // Checks the orientation of the screen for landscape and portrait and set portrait mode always if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }/*from ww w . ja v a 2 s . co m*/ }
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 w w w . j a v a 2 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.Beat.RingdroidEditActivity.java
private synchronized void updateDisplay() { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); if (mIsPlaying) { int now = mPlayer.getCurrentPosition() + mPlayStartOffset; int frames = mWaveformView.millisecsToPixels(now); mWaveformView.setPlayback(frames); setOffsetGoalNoUpdate(frames - mWidth / 2); if (now >= mPlayEndMsec) { handlePause();//www . j a v a 2s . c o m } } if (!mTouchDragging) { int offsetDelta; if (mFlingVelocity != 0) { float saveVel = mFlingVelocity; offsetDelta = mFlingVelocity / 30; if (mFlingVelocity > 80) { mFlingVelocity -= 80; } else if (mFlingVelocity < -80) { mFlingVelocity += 80; } else { mFlingVelocity = 0; } mOffset += offsetDelta; if (mOffset + mWidth / 2 > mMaxPos) { mOffset = mMaxPos - mWidth / 2; mFlingVelocity = 0; } if (mOffset < 0) { mOffset = 0; mFlingVelocity = 0; } mOffsetGoal = mOffset; } else { offsetDelta = mOffsetGoal - mOffset; if (offsetDelta > 10) offsetDelta = offsetDelta / 10; else if (offsetDelta > 0) offsetDelta = 1; else if (offsetDelta < -10) offsetDelta = offsetDelta / 10; else if (offsetDelta < 0) offsetDelta = -1; else offsetDelta = 0; mOffset += offsetDelta; } } mWaveformView.setParameters(mStartPos, mEndPos, mOffset); mWaveformView.invalidate(); mStartMarker .setContentDescription(getResources().getText(R.string.start_marker) + " " + formatTime(mStartPos)); mEndMarker.setContentDescription(getResources().getText(R.string.end_marker) + " " + formatTime(mEndPos)); int startX = mStartPos - mOffset - mMarkerLeftInset; if (startX + mStartMarker.getWidth() >= 0) { if (!mStartVisible) { // Delay this to avoid flicker mHandler.postDelayed(new Runnable() { public void run() { mStartVisible = true; mStartMarker.setAlpha(255); } }, 0); } } else { if (mStartVisible) { mStartMarker.setAlpha(0); mStartVisible = false; } startX = 0; } int endX = mEndPos - mOffset - mEndMarker.getWidth() + mMarkerRightInset; if (endX + mEndMarker.getWidth() >= 0) { if (!mEndVisible) { // Delay this to avoid flicker mHandler.postDelayed(new Runnable() { public void run() { mEndVisible = true; mEndMarker.setAlpha(255); } }, 0); } } else { if (mEndVisible) { mEndMarker.setAlpha(0); mEndVisible = false; } endX = 0; } mStartMarker.setLayoutParams(new AbsoluteLayout.LayoutParams(AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.WRAP_CONTENT, startX, mMarkerTopOffset)); mEndMarker.setLayoutParams(new AbsoluteLayout.LayoutParams(AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.WRAP_CONTENT, endX, mWaveformView.getMeasuredHeight() - mEndMarker.getHeight() - mMarkerBottomOffset)); }
From source file:androidx.media.widget.VideoView2.java
@Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (mIsMusicMediaType) { if (mPrevWidth != getMeasuredWidth() || mPrevHeight != getMeasuredHeight()) { int currWidth = getMeasuredWidth(); int currHeight = getMeasuredHeight(); Point screenSize = new Point(); mManager.getDefaultDisplay().getSize(screenSize); int screenWidth = screenSize.x; int screenHeight = screenSize.y; if (currWidth == screenWidth && currHeight == screenHeight) { int orientation = retrieveOrientation(); if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { inflateMusicView(R.layout.full_landscape_music); } else { inflateMusicView(R.layout.full_portrait_music); }/*from w w w . j a va2s .co m*/ if (mSizeType != SIZE_TYPE_FULL) { mSizeType = SIZE_TYPE_FULL; // Remove existing mFadeOut callback mMediaControlView.removeCallbacks(mFadeOut); mMediaControlView.setVisibility(View.VISIBLE); } } else { if (mSizeType != SIZE_TYPE_EMBEDDED) { mSizeType = SIZE_TYPE_EMBEDDED; inflateMusicView(R.layout.embedded_music); // Add new mFadeOut callback mMediaControlView.postDelayed(mFadeOut, mShowControllerIntervalMs); } } mPrevWidth = currWidth; mPrevHeight = currHeight; } } }
From source file:com.nbplus.vbroadlauncher.fragment.LauncherFragment.java
private void setContentViewByOrientation() { int orientation = DisplayUtils.getScreenOrientation(getActivity()); LinearLayout.LayoutParams lp;/*from w w w .jav a 2 s . c o m*/ float marginDp = 0f; float marginPx = 0f; if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { mMainViewLayout.setOrientation(LinearLayout.HORIZONTAL); lp = (LinearLayout.LayoutParams) mMainViewLeftPanel.getLayoutParams(); lp.weight = 0.6f; marginDp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_panel_margin); marginPx = DisplayUtils.pxFromDp(getActivity(), marginDp); lp.setMargins(0, 0, (int) marginPx, 0); mMainViewLeftPanel.setLayoutParams(lp); lp = (LinearLayout.LayoutParams) mMainViewRightPanel.getLayoutParams(); lp.weight = 0.4f; lp.setMargins(0, 0, 0, 0); mMainViewRightPanel.setLayoutParams(lp); } else { mMainViewLayout.setOrientation(LinearLayout.VERTICAL); lp = (LinearLayout.LayoutParams) mMainViewLeftPanel.getLayoutParams(); lp.weight = 1.0f; marginDp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_panel_margin); marginPx = DisplayUtils.pxFromDp(getActivity(), marginDp); lp.setMargins(0, 0, 0, (int) marginPx); mMainViewLeftPanel.setLayoutParams(lp); lp = (LinearLayout.LayoutParams) mMainViewRightPanel.getLayoutParams(); lp.weight = 1.0f; lp.setMargins(0, 0, 0, 0); mMainViewRightPanel.setLayoutParams(lp); } lp = (LinearLayout.LayoutParams) mMainViewLayout.getLayoutParams(); float heightDp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_main_view_margin_top); float px = DisplayUtils.pxFromDp(getActivity(), heightDp); float horizontalMarginDp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_main_view_margin_horizontal); float horizontalMarginPx = DisplayUtils.pxFromDp(getActivity(), horizontalMarginDp); lp.setMargins((int) horizontalMarginPx, (int) px, (int) horizontalMarginPx, lp.bottomMargin); mMainViewLayout.setLayoutParams(lp); float dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_clock_height); px = DisplayUtils.pxFromDp(getActivity(), dp); mTextClock.setTextSize(px); mWeatherView.onConfigurationChanged(orientation); // right shortcut menu dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_width); float widthPx = DisplayUtils.pxFromDp(getActivity(), dp); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_height); float heightPx = DisplayUtils.pxFromDp(getActivity(), dp); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_font_size); float mainShortcutFontPx = DisplayUtils.pxFromDp(getActivity(), dp); GridLayout.LayoutParams childlp; View child; for (int i = 0; i < mMainShortcutGridLayout.getChildCount(); i++) { /** * right shortcut panel */ child = mMainShortcutGridLayout.getChildAt(i); childlp = (GridLayout.LayoutParams) child.getLayoutParams(); childlp.width = (int) widthPx; childlp.height = (int) heightPx; child.setLayoutParams(childlp); } // add other shortcuts. dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_shortcut_width); float btnWidthPx = DisplayUtils.pxFromDp(getActivity(), dp); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_shortcut_height); float btnHeightPx = DisplayUtils.pxFromDp(getActivity(), dp); dp = DisplayUtils.getDimension(getActivity(), R.dimen.ic_nav_btn_drawable_padding); float drawablePadding = DisplayUtils.pxFromDp(getActivity(), dp); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_shortcut_font_size); float btnFontPx = DisplayUtils.pxFromDp(getActivity(), dp); for (int i = 0; i < mShorcutGridLayout.getChildCount(); i++) { /** * right shortcut panel */ child = mShorcutGridLayout.getChildAt(i); childlp = (GridLayout.LayoutParams) child.getLayoutParams(); childlp.width = (int) btnWidthPx; childlp.height = (int) btnHeightPx; child.setLayoutParams(childlp); } }
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 ww. j av a 2s.co 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.lewa.crazychapter11.MainActivity.java
private void ChangeOrientation() { Configuration cfg = getResources().getConfiguration(); if (cfg.orientation == Configuration.ORIENTATION_LANDSCAPE) { MainActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }//from www. j ava 2 s .co m if (cfg.orientation == Configuration.ORIENTATION_PORTRAIT) { MainActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } }