List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE
int ORIENTATION_LANDSCAPE
To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.
Click Source Link
From source file:com.repkap11.repcast.activities.LocalPlayerActivity.java
@SuppressLint("NewApi") @Override//from w w w .j ava 2 s. c o m public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { getSupportActionBar().hide(); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } updateMetadata(false); mContainer.setBackgroundColor(getResources().getColor(R.color.black)); } else { getSupportActionBar().show(); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } updateMetadata(true); mContainer.setBackgroundColor(getResources().getColor(R.color.white)); } }
From source file:com.example.igorklimov.popularmoviesdemo.fragments.DetailFragment.java
private void setMinSizes(View space) { int fragmentHeight; int fragmentWidth; if (!isTabletPreference(context)) { fragmentHeight = this.getResources().getDisplayMetrics().heightPixels; fragmentWidth = this.getResources().getDisplayMetrics().widthPixels; } else {/*w w w.ja v a2 s. co m*/ Bundle arguments = getArguments(); fragmentHeight = arguments.getInt("fragmentHeight"); fragmentWidth = arguments.getInt("fragmentWidth"); } int minHeight = fragmentHeight / 3; int minWidth = (int) (((double) minHeight / 278) * 185); int backdropHeight = (!Utility.isTabletPreference(context) && Configuration.ORIENTATION_LANDSCAPE == context.getResources().getConfiguration().orientation ? fragmentHeight - fragmentHeight / 3 : (int) (((double) fragmentWidth / 500) * 281)); mPosterView.setMinimumWidth(minWidth); mPosterView.setMinimumHeight(minHeight); mBack.setMinimumHeight(backdropHeight); if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && space != null) { space.setMinimumHeight(backdropHeight); } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartDateTimeFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) { Fragment dateTimeFragment = (Fragment) fm.findFragmentById(R.id.sample_replacer); dateTimeFragment = DateTimeFragment.newInstance("DateTime"); fm.beginTransaction().replace(R.id.sample_replacer, dateTimeFragment).commit(); } else {//from ww w . j a v a 2s . c o m DateTimeFragment dateTimeFragment = DateTimeFragment.newInstance("DateTime"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), dateTimeFragment).commit(); } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartDateTimeFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {/* www . java 2 s . c o m*/ Fragment dateTimeFragment = (Fragment) fm .findFragmentById(R.id.sample_replacer); dateTimeFragment = DateTimeFragment.newInstance("DateTime"); fm.beginTransaction() .replace(R.id.sample_replacer, dateTimeFragment) .commit(); } else { DateTimeFragment dateTimeFragment = DateTimeFragment .newInstance("DateTime"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), dateTimeFragment) .commit(); } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartEditTextFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) { Fragment editTextFragment = (Fragment) fm.findFragmentById(R.id.sample_replacer); editTextFragment = EditTextFragment.newInstance("EditText"); fm.beginTransaction().replace(R.id.sample_replacer, editTextFragment).commit(); } else {/* w w w . j av a2 s.com*/ EditTextFragment editTextFragment = EditTextFragment.newInstance("EditText"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), editTextFragment).commit(); } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartEditTextFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {// w ww.j av a 2 s.c o m Fragment editTextFragment = (Fragment) fm .findFragmentById(R.id.sample_replacer); editTextFragment = EditTextFragment.newInstance("EditText"); fm.beginTransaction() .replace(R.id.sample_replacer, editTextFragment) .commit(); } else { EditTextFragment editTextFragment = EditTextFragment .newInstance("EditText"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), editTextFragment) .commit(); } }
From source file:de.spiritcroc.modular_remote.MainActivity.java
private void restoreContentFromRecreationKey(String key) { String[] args = Util.split(key, separator, 0); int recreationVersion; try {//w w w. j a va 2s . com recreationVersion = Integer.parseInt(args[1]); if (DEBUG) Log.v(LOG_TAG, "RecreationVersion: " + recreationVersion); } catch (Exception e) { Log.w(LOG_TAG, "Got exception while trying to get recreationVersion for key " + key); Log.w(LOG_TAG, "Got exception: " + e); // Try using current version instead recreationVersion = Util.RECREATION_KEY_VERSION; } for (int i = 2; i < args.length; i++) { String[] subArgs = Util.split(args[i], Util.RK_ATTRIBUTE_SEPARATOR, 1); if (ModuleFragment.PAGE_CONTAINER_FRAGMENT.equals(subArgs[0])) { addPage(PageContainerFragment.recoverFromRecreationKey(args[i])); } else { Log.w(LOG_TAG, "restoreContentFromRecreationKey:" + " Only allowed to add PageContainers to MainActivity, you tried to add: " + subArgs[0]); } } if (pages.size() == 0) {// Not allowed to have no fragments addPage(PageContainerFragment.newInstance(getString(R.string.page_name_default), new Display.StaticTextSettings(getString(R.string.app_name)), false, null, null, null, null)); } // Select page if shortcut used and page is on current orientation: Intent intent = getIntent(); long pageId = intent.getLongExtra(EXTRA_SELECT_PAGE_ID, -1); boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; if (pageId != -1 && (forceOrientation == -1 || (landscape && forceOrientation == FORCE_ORIENTATION_LANDSCAPE) || (!landscape && forceOrientation == FORCE_ORIENTATION_PORTRAIT))) { for (int i = 0; i < pages.size(); i++) { if (pages.get(i).getPageId() == pageId) { shortcutPage = i; } } if (shortcutPage == -1) {// Could not find page if (!intent.getBooleanExtra(EXTRA_RESTARTED_FROM_EDIT_MODE, false)) Toast.makeText(this, R.string.error_page_not_available, Toast.LENGTH_LONG).show(); } } }
From source file:com.askjeffreyliu.camera2barcode.camera.CameraSource.java
/** * Sets up member variables related to camera. * * @param width The width of available size for camera preview * @param height The height of available size for camera preview *//* ww w. java 2 s . c o m*/ private void setUpCameraOutputs(int width, int height) { try { if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { return; } if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) { throw new RuntimeException("Time out waiting to lock camera opening."); } if (manager == null) manager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE); mCameraId = manager.getCameraIdList()[mFacing]; CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { return; } // For still image captures, we use the largest available size. Size largest = getBestAspectPictureSize(map.getOutputSizes(ImageFormat.JPEG)); // Find out if we need to swap dimension to get the preview size relative to sensor // coordinate. int displayRotation = mDisplayOrientation; //noinspection ConstantConditions int mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); boolean swappedDimensions = false; switch (displayRotation) { case Surface.ROTATION_0: case Surface.ROTATION_180: if (mSensorOrientation == 90 || mSensorOrientation == 270) { swappedDimensions = true; } break; case Surface.ROTATION_90: case Surface.ROTATION_270: if (mSensorOrientation == 0 || mSensorOrientation == 180) { swappedDimensions = true; } break; default: Log.e(TAG, "Display rotation is invalid: " + displayRotation); } Point displaySize = new Point(Utils.getScreenWidth(mContext), Utils.getScreenHeight(mContext)); int rotatedPreviewWidth = width; int rotatedPreviewHeight = height; int maxPreviewWidth = displaySize.x; int maxPreviewHeight = displaySize.y; if (swappedDimensions) { rotatedPreviewWidth = height; rotatedPreviewHeight = width; maxPreviewWidth = displaySize.y; maxPreviewHeight = displaySize.x; } if (maxPreviewWidth > MAX_PREVIEW_WIDTH) { maxPreviewWidth = MAX_PREVIEW_WIDTH; } if (maxPreviewHeight > MAX_PREVIEW_HEIGHT) { maxPreviewHeight = MAX_PREVIEW_HEIGHT; } // Danger, W.R.! Attempting to use too large a preview size could exceed the camera // bus' bandwidth limitation, resulting in gorgeous previews but the storage of // garbage capture data. Size[] outputSizes = Utils.sizeToSize(map.getOutputSizes(SurfaceTexture.class)); mPreviewSize = chooseOptimalSize(outputSizes, rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, largest); // We fit the aspect ratio of TextureView to the size of preview we picked. int orientation = mDisplayOrientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } else { mTextureView.setAspectRatio(mPreviewSize.getHeight(), mPreviewSize.getWidth()); } // Check if the flash is supported. Boolean available = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE); mFlashSupported = available == null ? false : available; // control.aeTargetFpsRange Range<Integer>[] availableFpsRange = characteristics .get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES); configureTransform(width, height); manager.openCamera(mCameraId, mStateCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } catch (InterruptedException e) { throw new RuntimeException("Interrupted while trying to lock camera opening.", e); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. Log.d(TAG, "Camera Error: " + e.getMessage()); } }
From source file:org.openremote.android.console.GroupActivity.java
/** * @param newOrientation// www . j a va 2 s. c o m */ private void manualRotateScreen(boolean newOrientation) { if (newOrientation) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); lastConfigurationOrientation = Configuration.ORIENTATION_LANDSCAPE; isLandscape = true; } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); lastConfigurationOrientation = Configuration.ORIENTATION_PORTRAIT; isLandscape = false; } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartGalleryFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) { Fragment galleryFragment = (Fragment) fm.findFragmentById(R.id.sample_replacer); galleryFragment = GalleryFragment.newInstance("Gallery"); fm.beginTransaction().replace(R.id.sample_replacer, galleryFragment).commit(); } else {/*from w w w. j av a 2 s . co m*/ GalleryFragment galleryFragment = GalleryFragment.newInstance("Gallery"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), galleryFragment).commit(); } }