Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_LANDSCAPE

List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_LANDSCAPE.

Prototype

int SCREEN_ORIENTATION_REVERSE_LANDSCAPE

To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_LANDSCAPE.

Click Source Link

Document

Constant corresponding to reverseLandscape in the android.R.attr#screenOrientation attribute.

Usage

From source file:com.android.launcher2.Launcher.java

private int mapConfigurationOriActivityInfoOri(int configOri) {
    final Display d = getWindowManager().getDefaultDisplay();
    int naturalOri = Configuration.ORIENTATION_LANDSCAPE;
    switch (d.getRotation()) {
    case Surface.ROTATION_0:
    case Surface.ROTATION_180:
        // We are currently in the same basic orientation as the natural orientation
        naturalOri = configOri;/*from   w w  w  .j av  a  2 s . co m*/
        break;
    case Surface.ROTATION_90:
    case Surface.ROTATION_270:
        // We are currently in the other basic orientation to the natural orientation
        naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ? Configuration.ORIENTATION_PORTRAIT
                : Configuration.ORIENTATION_LANDSCAPE;
        break;
    }

    int[] oriMap = { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE };
    // Since the map starts at portrait, we need to offset if this device's natural orientation
    // is landscape.
    int indexOffset = 0;
    if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
        indexOffset = 1;
    }
    return oriMap[(d.getRotation() + indexOffset) % 4];
}