Example usage for android.view Surface ROTATION_270

List of usage examples for android.view Surface ROTATION_270

Introduction

In this page you can find the example usage for android.view Surface ROTATION_270.

Prototype

int ROTATION_270

To view the source code for android.view Surface ROTATION_270.

Click Source Link

Document

Rotation constant: 270 degree rotation.

Usage

From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void lockOrientation() {
    Display display = POIMapActivity.this.getWindowManager().getDefaultDisplay();
    int rotation = display.getRotation();
    int height;/* w w  w  .  j a  va  2s .c om*/
    int width;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        height = display.getHeight();
        width = display.getWidth();
    } else {
        Point size = new Point();
        display.getSize(size);
        height = size.y;
        width = size.x;
    }
    switch (rotation) {
    case Surface.ROTATION_90:
        if (width > height)
            POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        else
            POIMapActivity.this.setRequestedOrientation(9/* reversePortait */);
        break;
    case Surface.ROTATION_180:
        if (height > width)
            POIMapActivity.this.setRequestedOrientation(9/* reversePortait */);
        else
            POIMapActivity.this.setRequestedOrientation(8/* reverseLandscape */);
        break;
    case Surface.ROTATION_270:
        if (width > height)
            POIMapActivity.this.setRequestedOrientation(8/* reverseLandscape */);
        else
            POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    default:
        if (height > width)
            POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        else
            POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

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);
    }/* 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.Yamate.Camera.Camera.java

/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 *///from  w  w w.  j  av a  2  s. c om
private void configureTransform(int viewWidth, int viewHeight) {
    Activity activity = mActivity;
    if (null == mPreviewSize || null == activity) {
        return;
    }
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max((float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    //mTextureView.setTransform(matrix);
}

From source file:com.mysampleapp.camera.Camera2BasicFragment.java

/**
 * Configures the necessary {@link Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 *//*from  www  . j a v  a  2 s  . c om*/
private void configureTransform(int viewWidth, int viewHeight) {
    Activity activity = getActivity();
    if (null == mTextureView || null == mPreviewSize || null == activity) {
        return;
    }
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max((float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    mTextureView.setTransform(matrix);

}

From source file:com.tenth.space.ui.fragment.HomeFragment.java

private void configureTransform(int viewWidth, int viewHeight) {
    Activity activity = getActivity();//  w w  w  . j av a 2 s. co  m
    if (null == mTextureView || null == mPreviewSize || null == activity) {
        return;
    }
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max((float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    mTextureView.setTransform(matrix);
}

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);//  ww  w .j ava  2s  .c  o m

    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:org.telegram.ui.LaunchActivity.java

private void fixLayout() {
    if (containerView != null) {
        ViewTreeObserver obs = containerView.getViewTreeObserver();
        obs.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override//w  w w  .  jav  a 2s .c o  m
            public void onGlobalLayout() {
                WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
                int rotation = manager.getDefaultDisplay().getRotation();

                int height;
                int currentActionBarHeight = getSupportActionBar().getHeight();
                if (currentActionBarHeight != Utilities.dp(48) && currentActionBarHeight != Utilities.dp(40)) {
                    height = currentActionBarHeight;
                } else {
                    height = Utilities.dp(48);
                    if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
                        height = Utilities.dp(40);
                    }
                }

                if (notificationView != null) {
                    notificationView.applyOrientationPaddings(
                            rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, height);
                }

                if (Build.VERSION.SDK_INT < 16) {
                    containerView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                } else {
                    containerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                }
            }
        });
    }
}

From source file:com.Yamate.Camera.Camera.java

public void setCameraRotation() {
    if (!mInitialized) {
        return;//from   w w  w .  ja  v  a 2  s  . co  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 {/*  w w w  .  j  a  v a  2s  .  co  m*/
        return Configuration.ORIENTATION_PORTRAIT;
    }
}

From source file:com.aimfire.demo.CameraActivity.java

public int getDeviceLandscapeOrientation() {
    int degrees = 0;
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
    case Surface.ROTATION_0:
        degrees = 0;/* w w  w  .j  a va2 s.  c o m*/
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break; // this is not possible
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }
    // reverse the sign to get clockwise rotation
    return (360 - degrees) % 360;
}