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:de.spiritcroc.modular_remote.MainActivity.java
private String getSavedFragmentsKey() { String orientationPref = sharedPreferences.getString(Preferences.ORIENTATION, Preferences.ORIENTATION_SHARE_LAYOUT); boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && !Preferences.ORIENTATION_SHARE_LAYOUT.equals(orientationPref); if (landscape) { return Preferences.SAVED_FRAGMENTS_LANDSCAPE; } else {//from w w w. ja v a 2s .com return Preferences.SAVED_FRAGMENTS; } }
From source file:de.stkl.gbgvertretungsplan.fragments.MainFragment.java
private void fillTable(View view, SubstitutionTable.Table day) { NavigationDrawerFragment ndf = mCallback.getNavigationDrawerFragment(); NavigationListAdapter.SubItem o = (NavigationListAdapter.SubItem) ndf.getItemByCId(CId); TextView textPlaceholder = (TextView) view.findViewById(R.id.placeholder); TableFixHeaders tableFixHeaders = (TableFixHeaders) view.findViewById(R.id.table2); TextView updateTime = (TextView) view.findViewById(R.id.updateTime); // init values SubstitutionTable.Table newDay;/*from www . jav a2 s. c o m*/ // filter, if a particular class is selected if (o != null) newDay = Storage.filter(day, Storage.FilterType.FILTER_CLASS_TEACHER, o.text); else newDay = Storage.filter(day, Storage.FilterType.FILTER_NONE, null); // display substitution info only if display width is greater than treshold int width; int threshold = getResources().getDimensionPixelSize(R.dimen.table_substitutioninfo_threshold); // LayoutMeasureView.w is ALWAYS the width in portrait mode! if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) width = LayoutMeasureView.screenH; else width = LayoutMeasureView.screenW; if (width < threshold) newDay.generalData.flags.add(SubstitutionTable.GeneralData.Flags.HIDE_SUBSTITUTIONINFO); int columnWidth[] = new int[day.getHeaderCount()]; if (newDay.getEntryCount() > 0) { SubstitutionPlanAdapter adapter = new SubstitutionPlanAdapter(getActivity(), newDay, columnWidth); // initial calculation of column width for (int i = 0; i < day.getHeaderCount(); i++) { columnWidth[i] = calculateTableColWidth(newDay, adapter, i, tableFixHeaders); } // assign adapter tableFixHeaders.setAdapter(adapter); tableFixHeaders.setVisibility(View.VISIBLE); textPlaceholder.setVisibility(View.GONE); } else { tableFixHeaders.setVisibility(View.GONE); textPlaceholder.setVisibility(View.VISIBLE); } // set update time updateTime.setText(newDay.generalData.updateTime); ViewGroup container = (ViewGroup) view.findViewById(R.id.dailyInfos); container.removeAllViews(); // set daily infos int i = 0; int c = newDay.generalData.dailyInfos.size(); View v = null; for (SubstitutionTable.GeneralData.DailyInfo info : newDay.generalData.dailyInfos) { v = getActivity().getLayoutInflater().inflate(R.layout.table_dailyinfo, container, false); TextView tvTitle = (TextView) v.findViewById(R.id.title); TextView tvDescription = (TextView) v.findViewById(R.id.description); tvTitle.setText(info.title); if (info.description.equals("")) { ((ViewGroup) v).removeViewInLayout(tvDescription); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tvTitle.getLayoutParams(); params.weight = 1f; } else tvDescription.setText(info.description); container.addView(v); i++; } }
From source file:demo.camera.library.ui.CameraCaptureActivity.java
private void onResumeCameraSetup() { String previewFacts = mCameraManager.openCamera(mSessionConfig.getVideoResolutionWidth(), mSessionConfig.getVideoResolutionHeight()); // updates mCameraPreviewWidth/Height TextView text = (TextView) findViewById(R.id.cameraParams_text); text.setText(previewFacts);/*from ww w . j ava2s . c om*/ // Set the preview aspect ratio. AspectFrameLayout layout = (AspectFrameLayout) findViewById(R.id.cameraPreview_afl); int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { mCameraManager.getCamera().setDisplayOrientation(90); mCurrentAspectRatio = (double) mCameraManager.getCameraPreviewHeight() / mCameraManager.getCameraPreviewWidth(); layout.setAspectRatio(mCurrentAspectRatio); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mCameraManager.getCamera().setDisplayOrientation(0); mCurrentAspectRatio = (double) mCameraManager.getCameraPreviewWidth() / mCameraManager.getCameraPreviewHeight(); layout.setAspectRatio(mCurrentAspectRatio); } mGLView.onResume(); mGLView.queueEvent(new Runnable() { @Override public void run() { mRenderer.setCameraPreviewSize(mCameraManager.getCameraPreviewWidth(), mCameraManager.getCameraPreviewHeight()); } }); Log.d(TAG, "onResume complete: " + this); }
From source file:com.androzic.MapFragment.java
private void onUpdateNavigationState() { boolean isNavigating = application.navigationService != null && application.navigationService.isNavigating(); boolean isNavigatingViaRoute = isNavigating && application.navigationService.isNavigatingViaRoute(); View rootView = getView();/*from w ww. ja v a 2s . c o m*/ // waypoint panel rootView.findViewById(R.id.waypointinfo).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // route panel rootView.findViewById(R.id.routeinfo).setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); // distance distanceValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.distancelt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // bearing bearingValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.bearinglt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // turn turnValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.turnlt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // xtk xtkValue.setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.xtklt).setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); // we hide elevation in portrait mode due to lack of space if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { if (isNavigatingViaRoute && elevationValue.getVisibility() == View.VISIBLE) { elevationValue.setVisibility(View.GONE); rootView.findViewById(R.id.elevationlt).setVisibility(View.GONE); ViewGroup row = (ViewGroup) rootView.findViewById(R.id.movingrow); int pos = row.indexOfChild(elevationValue); View xtklt = rootView.findViewById(R.id.xtklt); row.removeView(xtkValue); row.removeView(xtklt); row.addView(xtklt, pos); row.addView(xtkValue, pos); row.getParent().requestLayout(); } else if (!isNavigatingViaRoute && elevationValue.getVisibility() == View.GONE) { elevationValue.setVisibility(View.VISIBLE); rootView.findViewById(R.id.elevationlt).setVisibility(View.VISIBLE); ViewGroup row = (ViewGroup) rootView.findViewById(R.id.movingrow); int pos = row.indexOfChild(xtkValue); View elevationlt = rootView.findViewById(R.id.elevationlt); row.removeView(elevationValue); row.removeView(elevationlt); row.addView(elevationlt, pos); row.addView(elevationValue, pos); row.getParent().requestLayout(); } } if (isNavigatingViaRoute) { routeName.setText("\u21d2 " + application.navigationService.navRoute.name); } if (isNavigating) { waypointName.setText("\u2192 " + application.navigationService.navWaypoint.name); } updateMapViewArea(); map.refreshMap(); }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartButtonsFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) { Fragment buttonsFragment = (Fragment) fm.findFragmentById(R.id.sample_replacer); buttonsFragment = ButtonsFragment.newInstance("Buttons"); fm.beginTransaction().replace(R.id.sample_replacer, buttonsFragment).commit(); } else {//from w w w. j a v a 2 s .co m ButtonsFragment buttonsFragment = ButtonsFragment.newInstance("Buttons"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), buttonsFragment).commit(); } }
From source file:com.tenth.space.ui.fragment.HomeFragment.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 *//*from ww w .java 2 s . c om*/ private void setUpCameraOutputs(int width, int height) { Activity activity = getActivity(); CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE); try { for (String cameraId : manager.getCameraIdList()) { CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; } StreamConfigurationMap map = characteristics .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // For still image captures, we use the largest available size. Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea()); // mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, /*maxImages*/2); // mImageReader.setOnImageAvailableListener(mOnImageAvailableListener, mBackgroundHandler); // Find out if we need to swap dimension to get the preview size relative to sensor // coordinate. int displayRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); //noinspection ConstantConditions 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(); activity.getWindowManager().getDefaultDisplay().getSize(displaySize); 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. mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, largest); // We fit the aspect ratio of TextureView to the size of preview we picked. int orientation = getResources().getConfiguration().orientation; 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; // mCameraId = cameraId; return; } } catch (CameraAccessException e) { e.printStackTrace(); } catch (NullPointerException e) { // ErrorDialog.newInstance("").show(getChildFragmentManager(), FRAGMENT_DIALOG); } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartButtonsFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {//w w w . j av a 2 s . c om Fragment buttonsFragment = (Fragment) fm .findFragmentById(R.id.sample_replacer); buttonsFragment = ButtonsFragment.newInstance("Buttons"); fm.beginTransaction() .replace(R.id.sample_replacer, buttonsFragment) .commit(); } else { ButtonsFragment buttonsFragment = ButtonsFragment .newInstance("Buttons"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), buttonsFragment) .commit(); } }
From source file:com.yahala.ui.LaunchActivity.java
@Override public void onConfigurationChanged(android.content.res.Configuration newConfig) { super.onConfigurationChanged(newConfig); OSUtilities.checkDisplaySize();//from w w w.ja v a 2 s .c o m fixLayout(); //if(XmppManager.getInstance().connectionState== ConnectionState.ONLINE) if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartCheckBoxesFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) { Fragment checkBoxesFragment = (Fragment) fm.findFragmentById(R.id.sample_replacer); checkBoxesFragment = CheckBoxesFragment.newInstance("CheckBoxes"); fm.beginTransaction().replace(R.id.sample_replacer, checkBoxesFragment).commit(); } else {/* ww w .ja v a2s . c o m*/ CheckBoxesFragment checkBoxesFragment = CheckBoxesFragment.newInstance("CheckBoxes"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), checkBoxesFragment).commit(); } }
From source file:dev.ronlemire.commoncontrols.MainActivity.java
public void StartCheckBoxesFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {/*from www. j av a2s .c o m*/ Fragment checkBoxesFragment = (Fragment) fm .findFragmentById(R.id.sample_replacer); checkBoxesFragment = CheckBoxesFragment.newInstance("CheckBoxes"); fm.beginTransaction() .replace(R.id.sample_replacer, checkBoxesFragment) .commit(); } else { CheckBoxesFragment checkBoxesFragment = CheckBoxesFragment .newInstance("CheckBoxes"); getSupportFragmentManager().beginTransaction() .replace(MainActivity.sampleListView.getId(), checkBoxesFragment) .commit(); } }