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:ca.nehil.rter.streamingapp.StreamingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_streaming);

    poilist = new ArrayList<POI>();

    /* Retrieve server URL from stored app values */
    storedValues = getSharedPreferences(getString(R.string.sharedPreferences_filename), MODE_PRIVATE);
    server_url = storedValues.getString("server_url", "not-set");

    /* Orientation listenever implementation to orient video */
    myOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) {
        @Override// w ww.ja  va 2s . c o m
        public void onOrientationChanged(int orientation) {
            int rotation = getWindowManager().getDefaultDisplay().getRotation();
            if (rotation == Surface.ROTATION_270) {
                flipVideo = true;
            } else {
                flipVideo = false;
            }
        }
    };
    myOrientationEventListener.enable();

    /* Retrieve user auth data from cookie */
    cookies = getSharedPreferences("RterUserCreds", MODE_PRIVATE);
    cookieEditor = cookies.edit();
    setUsername = cookies.getString("Username", "not-set");
    setRterCredentials = cookies.getString("RterCreds", "not-set");
    if (setRterCredentials.equalsIgnoreCase("not-set") || setRterCredentials == null) {
        Log.e("PREFS", "Login Not successful, please restart");
    }
    Log.d("PREFS", "Prefs ==> rter_Creds:" + setRterCredentials);

    URL serverURL = null;
    try {
        serverURL = new URL(server_url);
        CookieStore myCookieStore = new BasicCookieStore();
        client.setCookieStore(myCookieStore);
        String[] credentials = setRterCredentials.split("=", 2);
        BasicClientCookie newCookie = new BasicClientCookie(credentials[0], credentials[1]);
        newCookie.setDomain(serverURL.getHost());
        newCookie.setPath("/");
        myCookieStore.addCookie(newCookie);
        mSensorSource = SensorSource.getInstance(this, GET_LOCATION_FROM_SERVER, serverURL, setRterCredentials,
                setUsername);
        POIs = new POIList(this, serverURL, setRterCredentials, mSensorSource);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    overlay = new OverlayController(this, POIs, mSensorSource); // OpenGL overlay 

    /* Get location */

    Location location = mSensorSource.getLocation();
    if (location != null) {
        lati = (float) (location.getLatitude());
        longi = (float) (location.getLongitude());
    } else {
        Toast toast = Toast.makeText(this, "Location not available", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.TOP, 0, 0);
        toast.show();
        lati = (float) (45.505958f); // Hard coded location for testing purposes.
        longi = (float) (-73.576254f);
    }

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, CLASS_LABEL);
    mWakeLock.acquire();

    /* Test, set desired orienation to north */
    overlay.setDesiredOrientation(0.0f);
}

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  w  w. j a v a2 s  .c  o 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.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());//  w w w . java  2s  .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());/*  www . ja  v  a2  s .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;//from  ww  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: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>.
 *//* w  w  w  . j  av  a2 s .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.ormma.controller.OrmmaDisplayController.java

/**
 * Gets the orientation./*from   w w w.j a  va  2 s.c o  m*/
 *
 * @return the orientation
 */
public int getOrientation() {
    int orientation = mWindowManager.getDefaultDisplay().getOrientation();
    int ret = -1;
    switch (orientation) {
    case Surface.ROTATION_0:
        ret = 0;
        break;

    case Surface.ROTATION_90:
        ret = 90;
        break;

    case Surface.ROTATION_180:
        ret = 180;
        break;

    case Surface.ROTATION_270:
        ret = 270;
        break;
    }
    Log.d(LOG_TAG, "getOrientation: " + ret);
    return ret;
}

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 . java  2 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();
}

From source file:com.jasompeter.openalpr.CameraActivity.java

public void setCorrectOrientation(Camera camera) {
    int displayRotation = getWindowManager().getDefaultDisplay().getRotation();

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

    Camera.CameraInfo cameraInfo = getCurrentCameraInfo();
    int resultDegrees;
    if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        resultDegrees = (cameraInfo.orientation + degrees) % 360;
        resultDegrees = (360 - resultDegrees) % 360;
    } else {
        resultDegrees = (cameraInfo.orientation - degrees + 360) % 360;
    }

    camera.setDisplayOrientation(resultDegrees);

    Camera.Parameters parameters = camera.getParameters();
    parameters.setRotation(resultDegrees);
    camera.setParameters(parameters);
}

From source file:com.almalence.util.Util.java

public static int getDisplayRotation(Activity activity) {
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
    case Surface.ROTATION_0:
        return 0;
    case Surface.ROTATION_90:
        return 90;
    case Surface.ROTATION_180:
        return 180;
    case Surface.ROTATION_270:
        return 270;
    default:/*from w  ww .  jav  a 2 s .  c  o m*/
        break;
    }
    return 0;
}