List of usage examples for android.view Surface ROTATION_0
int ROTATION_0
To view the source code for android.view Surface ROTATION_0.
Click Source Link
From source file:com.ezartech.ezar.videooverlay.ezAR.java
private boolean isPortraitOrientation() { int rotation = Util.getDisplayRotation(activity); return rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180; }
From source file:net.ddns.mlsoftlaberge.trycorder.TryviscamFragment.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 w ww . j a va2 s . com*/ 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) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. //ErrorDialog.newInstance(getString(R.string.camera_error)) // .show(getChildFragmentManager(), FRAGMENT_DIALOG); e.printStackTrace(); } }
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
public void onRotate() { Display display = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { orient = "portrait"; } else if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { orient = "landscape"; }/* ww w . ja v a 2 s . c o m*/ if (orient.equals("portrait")) { if (lang.equals("prilang")) { keyboard = prilang; } else if (lang.equals("seclang")) { keyboard = seclang; } slideAnimation(); kv.setKeyboard(keyboard); doubleUp = 1; screen = 1; caps = true; if (allCaps) { capsLock = false; } kv.invalidateAllKeys(); keyboard.setShifted(caps); kv.invalidateAllKeys(); } else if (orient.equals("landscape")) { switch (screen) { case 1: if (lang.equals("prilang")) { keyboard = prilang_landscape; } else if (lang.equals("seclang")) { keyboard = seclang_landscape; } break; case 2: if (number == 1) { keyboard = new Keyboard(this, R.xml.numeric_landscape); } else if (number == 2) { keyboard = new Keyboard(this, R.xml.symbols_landscape); } break; } slideAnimation(); kv.setKeyboard(keyboard); doubleUp = 1; screen = 1; caps = true; if (allCaps) { capsLock = false; } kv.invalidateAllKeys(); keyboard.setShifted(caps); kv.invalidateAllKeys(); } }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
@Override public void onFinishInflate() { rot0 = (FrameLayout) findViewById(R.id.rot0); rot90 = (FrameLayout) findViewById(R.id.rot90); mRotatedViews[Surface.ROTATION_0] = mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0); mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90); mRotatedViews[Surface.ROTATION_270] = NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270); for (View v : mRotatedViews) { // this helps avoid drawing artifacts with glowing navigation keys ViewGroup group = (ViewGroup) v.findViewById(R.id.nav_buttons); group.setMotionEventSplittingEnabled(false); }/*from www.j a v a 2 s. c om*/ updateColor(true); mCurrentView = mRotatedViews[Surface.ROTATION_0]; // this takes care of making the buttons SettingsObserver settingsObserver = new SettingsObserver(new Handler()); settingsObserver.observe(); }
From source file:com.frostwire.android.gui.adapters.FileListAdapter.java
public int getNumColumns() { if (getViewItemId() == R.layout.view_my_files_thumbnail_list_item) { return 1; }/*from w ww.j a v a 2 s. c om*/ int rotation = ((Activity) getContext()).getWindowManager().getDefaultDisplay().getRotation(); boolean vertical = Surface.ROTATION_0 == rotation || Surface.ROTATION_180 == rotation; if (vertical) { return 3; } return (int) UIUtils.getScreenInches((Activity) getContext()); }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
public void reorient() { final int rot = mDisplay.getRotation(); for (int i = 0; i < 4; i++) { mRotatedViews[i].setVisibility(View.GONE); }/*from w ww .java2s .c o m*/ if (mTablet_UI != 0) { // this is either a tablet of Phablet. Need to stay at Rot_0 mCurrentView = mRotatedViews[Surface.ROTATION_0]; } else { mCurrentView = mRotatedViews[rot]; } // mCurrentView = mRotatedViews[rot]; mCurrentView.setVisibility(View.VISIBLE); // force the low profile & disabled states into compliance setLowProfile(mLowProfile, false, true /* force */); setDisabledFlags(mDisabledFlags, true /* force */); setMenuVisibility(mShowMenu, true /* force */); if (DEBUG_DEADZONE) { mCurrentView.findViewById(R.id.deadzone).setBackgroundColor(0x808080FF); } if (DEBUG) { Slog.d(TAG, "reorient(): rot=" + mDisplay.getRotation()); } setNavigationIconHints(mNavigationIconHints, true); }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
public static Point getPreviewDimension() { // Taken from: http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels View v = ((Activity) mContext).findViewById(R.id.camera_controls_layout); WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from w w w .j av a2 s .com*/ Point dim = null; if (v != null) { if (getOrientation() == Surface.ROTATION_0 || getOrientation() == Surface.ROTATION_180) dim = new Point(size.x, size.y - v.getHeight()); // return size.y - v.getHeight(); else if (getOrientation() == Surface.ROTATION_90 || getOrientation() == Surface.ROTATION_270) dim = new Point(size.x - v.getWidth(), size.y); // return size.x - v.getWidth(); } return dim; }
From source file:com.example.aschere.cdhprototype2.Camera2RawFragment.java
/** * Send a capture request to the camera device that initiates a capture targeting the JPEG and * RAW outputs./* w w w. j ava2 s . co m*/ * <p/> * Call this only with {@link #mCameraStateLock} held. */ private void captureStillPictureLocked() { try { if (null == mCameraDevice) { return; } // This is the CaptureRequest.Builder that we use to take a picture. final CaptureRequest.Builder captureBuilder = mCameraDevice .createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE); captureBuilder.addTarget(mJpegImageReader.get().getSurface()); captureBuilder.addTarget(mRawImageReader.get().getSurface()); // Use the same AE and AF modes as the preview. setup3AControlsLocked(captureBuilder); // Set orientation. int rotation = Surface.ROTATION_0; captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, sensorToDeviceRotation(mCharacteristics, rotation)); // Set request tag to easily track results in callbacks. captureBuilder.setTag(mRequestCounter.getAndIncrement()); CaptureRequest request = captureBuilder.build(); // Create an ImageSaverBuilder in which to collect results, and add it to the queue // of active requests. ImageSaver.ImageSaverBuilder jpegBuilder = new ImageSaver.ImageSaverBuilder(appContext) .setCharacteristics(mCharacteristics); ImageSaver.ImageSaverBuilder rawBuilder = new ImageSaver.ImageSaverBuilder(appContext) .setCharacteristics(mCharacteristics); mJpegResultQueue.put((int) request.getTag(), jpegBuilder); mRawResultQueue.put((int) request.getTag(), rawBuilder); mCaptureSession.capture(request, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:com.Yamate.Camera.Camera.java
public void setCameraRotation() { if (!mInitialized) { return;//ww w. java 2 s. c o m } Point displaySize = new Point(); mActivity.getWindowManager().getDefaultDisplay().getSize(displaySize); int orientation = mActivity.getWindowManager().getDefaultDisplay().getRotation(); Util.PiCoreLog("orientation:" + orientation); boolean mIsPortraitDevice = false; switch (orientation) { case Surface.ROTATION_0: mCameraRotation = mIsPortraitDevice ? CameraRotation.ROTATION_270 : CameraRotation.ROTATION_0; break; case Surface.ROTATION_90: mCameraRotation = mIsPortraitDevice ? CameraRotation.ROTATION_0 : CameraRotation.ROTATION_90; break; case Surface.ROTATION_180: mCameraRotation = mIsPortraitDevice ? CameraRotation.ROTATION_90 : CameraRotation.ROTATION_180; break; case Surface.ROTATION_270: mCameraRotation = mIsPortraitDevice ? CameraRotation.ROTATION_180 : CameraRotation.ROTATION_270; break; } Util.PiCoreLog("orientation:" + orientation + ",mCameraRotation:" + mCameraRotation + ",mIsPortraitDevice:" + mIsPortraitDevice); }
From source file:com.aimfire.demo.CameraActivity.java
public int getDeviceDefaultOrientation() { WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Configuration config = getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && config.orientation == Configuration.ORIENTATION_LANDSCAPE) || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && config.orientation == Configuration.ORIENTATION_PORTRAIT)) { return Configuration.ORIENTATION_LANDSCAPE; } else {/*from w ww. j a va 2 s . c o m*/ return Configuration.ORIENTATION_PORTRAIT; } }