Example usage for android.view Surface ROTATION_90

List of usage examples for android.view Surface ROTATION_90

Introduction

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

Prototype

int ROTATION_90

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

Click Source Link

Document

Rotation constant: 90 degree rotation.

Usage

From source file:org.telegram.ui.IdenticonActivity.java

private void fixLayout() {
    ViewTreeObserver obs = fragmentView.getViewTreeObserver();
    obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override//ww  w .  j a  v  a 2 s . c o  m
        public boolean onPreDraw() {
            if (fragmentView == null) {
                return true;
            }
            fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
            LinearLayout layout = (LinearLayout) fragmentView;
            WindowManager manager = (WindowManager) ApplicationLoader.applicationContext
                    .getSystemService(Context.WINDOW_SERVICE);
            int rotation = manager.getDefaultDisplay().getRotation();

            if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
                layout.setOrientation(LinearLayout.HORIZONTAL);
            } else {
                layout.setOrientation(LinearLayout.VERTICAL);
            }

            fragmentView.setPadding(fragmentView.getPaddingLeft(), 0, fragmentView.getPaddingRight(),
                    fragmentView.getPaddingBottom());
            return true;
        }
    });
}

From source file:zxing.util.CaptureActivity.java

License:asdf

private int getCurrentOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
    case Surface.ROTATION_0:
        return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
    case Surface.ROTATION_90:
        return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    default:/*from  w ww . j  av  a2s  . c om*/
        return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
    }
}

From source file:edu.pdx.its.portal.routelandia.ListStat.java

public int getRotation(Context context) {
    final int rotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
            .getOrientation();//ww w.j  a  v  a 2s  . c om
    switch (rotation) {
    case Surface.ROTATION_0:
        return 1; //portrait
    case Surface.ROTATION_90:
        return 0;//landscape
    case Surface.ROTATION_180:
        return 1;//reverse portrait
    default:
        return 0;//reverse landscape
    }
}

From source file:com.horaapps.leafpic.PlayerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case R.id.action_share:
        Intent share = new Intent(Intent.ACTION_SEND);
        Media m = new Media(ContentHelper.getPath(getApplicationContext(), getIntent().getData()));
        share.setType(m.getMIME());//from   w ww.j av  a2 s  . c  om
        share.putExtra(Intent.EXTRA_STREAM, getIntent().getData());
        startActivity(Intent.createChooser(share, getString(R.string.send_to)));
        return true;

    case R.id.action_settings:
        startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
        return true;

    case R.id.rotate_layout:
        int rotation = (((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay()).getRotation();
        if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        else
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        showControls();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.horaapps.leafpic.activities.PlayerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case org.horaapps.leafpic.R.id.action_share:
        Intent share = new Intent(Intent.ACTION_SEND);
        Media m = new Media(ContentHelper.getMediaPath(getApplicationContext(), getIntent().getData()));
        share.setType(m.getMimeType());//from www .  jav a2s  .c  o  m
        share.putExtra(Intent.EXTRA_STREAM, getIntent().getData());
        startActivity(Intent.createChooser(share, getString(org.horaapps.leafpic.R.string.send_to)));
        return true;

    case org.horaapps.leafpic.R.id.action_settings:
        startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
        return true;

    case org.horaapps.leafpic.R.id.rotate_layout:
        int rotation = (((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay()).getRotation();
        if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        else
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        showControls();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.fossasia.phimpme.leafpic.activities.PlayerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case R.id.action_share:
        Intent share = new Intent(Intent.ACTION_SEND);
        Media m = new Media(ContentHelper.getMediaPath(getApplicationContext(), getIntent().getData()));
        share.setType(m.getMimeType());/* ww w.  j a v a 2s .co m*/
        share.putExtra(Intent.EXTRA_STREAM, getIntent().getData());
        startActivity(Intent.createChooser(share, getString(R.string.send_to)));
        return true;

    case R.id.action_settings:
        startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
        return true;

    case R.id.rotate_layout:
        int rotation = (((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay()).getRotation();
        if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        else
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        showControls();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.artoolkit.ar.base.camera.CaptureCameraPreview.java

private void setCameraDisplayOrientation(int cameraId, android.hardware.Camera camera) {
    android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
    android.hardware.Camera.getCameraInfo(cameraId, info);

    WindowManager wMgr = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);

    int rotation = wMgr.getDefaultDisplay().getRotation();

    int degrees = 0;
    switch (rotation) {
    case Surface.ROTATION_0:
        degrees = 0;//  w w w. j  a v a  2  s  . c om
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }

    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        result = (360 - result) % 360; // compensate the mirror
    } else { // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }
    camera.setDisplayOrientation(result);
}

From source file:ch.jeda.platform.android.Main.java

private int getScreenOrientation(final ViewRequest request) {
    if (request.getFeatures().contains(WindowFeature.ORIENTATION_LANDSCAPE)) {
        return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    } else if (request.getFeatures().contains(WindowFeature.ORIENTATION_PORTRAIT)) {
        return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    } else {/* www .j a v  a2 s  .c om*/
        final int rotation = this.getWindowManager().getDefaultDisplay().getRotation();
        if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
                return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            } else {
                return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
            }
        } else {
            if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
                return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
            } else {
                return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
            }
        }
    }
}

From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Checks whether the main display is in landscape.
 *
 * @param context The context to check with.
 * @return <code>true</code> if the main display is in landscape, else <code>false</code>.
 *///from ww  w . j a v a 2s .c  o  m
public static boolean isMainDisplayInLandscape(Context context) {
    int rotation = DisplayManagerCompat.getInstance(context).getDisplay(0).getRotation();
    return rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270;
}

From source file:org.hw.parlance.ParlanceActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!LinphoneManager.isInstanciated()) {
        Log.e("No service running: avoid crash by starting the launcher", this.getClass().getName());
        // super.onCreate called earlier
        finish();//from  w  ww  . j a  v a2  s .c o m
        startActivity(getIntent().setClass(this, ParlanceLauncherActivity.class));
        return;
    }

    boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_wizard_at_first_start);
    if (useFirstLoginActivity && LinphonePreferences.instance().isFirstLaunch()) {
        if (LinphonePreferences.instance().getAccountCount() > 0) {
            LinphonePreferences.instance().firstLaunchSuccessful();
        } else {
            startActivityForResult(new Intent().setClass(this, SetupActivity.class), FIRST_LOGIN_ACTIVITY);
        }
    }

    setContentView(R.layout.main);
    instance = this;
    initButtons();
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
    case Surface.ROTATION_0:
        rotation = 0;
        break;
    case Surface.ROTATION_90:
        rotation = 90;
        break;
    case Surface.ROTATION_180:
        rotation = 180;
        break;
    case Surface.ROTATION_270:
        rotation = 270;
        break;
    }

    LinphoneManager.getLc().setDeviceRotation(rotation);
    mAlwaysChangingPhoneAngle = rotation;
    updateAnimationsState();
}