Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_REVERSE_PORTRAIT

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

Introduction

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

Prototype

int SCREEN_ORIENTATION_REVERSE_PORTRAIT

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

Click Source Link

Document

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

Usage

From source file:net.yoik.cordova.plugins.screenorientation.YoikScreenOrientation.java

private boolean routeScreenOrientation(JSONArray args, CallbackContext callbackContext) {

    String action = args.optString(0);

    if (action.equals("set")) {

        String orientation = args.optString(1);

        Log.d(TAG, "Requested ScreenOrientation: " + orientation);

        Activity activity = cordova.getActivity();

        if (orientation.equals(UNLOCKED)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else if (orientation.equals(LANDSCAPE_PRIMARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT_PRIMARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else if (orientation.equals(LANDSCAPE)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
        } else if (orientation.equals(LANDSCAPE_SECONDARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT_SECONDARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        }//from w  w w.  ja  va 2 s .c  om

        callbackContext.success();
        return true;

    } else {
        callbackContext.error("ScreenOrientation not recognised");
        return false;
    }
}

From source file:piuk.blockchain.android.ui.zxing.CaptureActivity.java

private int getCurrentOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
    case Surface.ROTATION_0:
    case Surface.ROTATION_270:
        return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    default://  w ww  .  j a va2 s  .  c om
        return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;//reverse-mounted cameras on devices like the Nexus 5X
    }
}

From source file:de.limexcomputer.cordova.plugin.rotationlock.RotationLock.java

/**
 * Executes the request./*w ww  . j  ava  2 s.c o m*/
 *
 * This method is called from the WebView thread.
 * To do a non-trivial amount of work, use:
 *     cordova.getThreadPool().execute(runnable);
 *
 * To run on the UI thread, use:
 *     cordova.getActivity().runOnUiThread(runnable);
 *
 * @param action   The action to execute.
 * @param args     The exec() arguments in JSON form.
 * @param callback The callback context used when calling back into JavaScript.
 * @return         Whether the action was valid.
 */
@Override
public boolean execute(String action, JSONArray args, CallbackContext callback) throws JSONException {

    if (!action.equalsIgnoreCase("setOrientation")) {
        return false;
    }

    String orientation = args.optString(0);

    Activity activity = this.cordova.getActivity();

    // refer to https://github.com/their/pg-plugin-screen-orientation/blob/master/src/ScreenOrientation.java

    if (orientation.equals(UNSPECIFIED)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else if (orientation.equals(LANDSCAPE)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (orientation.equals(PORTRAIT)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (orientation.equals(USER)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
    } else if (orientation.equals(BEHIND)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_BEHIND);
    } else if (orientation.equals(SENSOR)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    } else if (orientation.equals(NOSENSOR)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    } else if (orientation.equals(SENSOR_LANDSCAPE)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else if (orientation.equals(SENSOR_PORTRAIT)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    } else if (orientation.equals(REVERSE_LANDSCAPE)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
    } else if (orientation.equals(REVERSE_PORTRAIT)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
    } else if (orientation.equals(FULL_SENSOR)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
    }

    callback.success(orientation);
    return true;
}

From source file:org.apache.cordova.screenorientation.ScreenOrientation.java

public int getOrientation(String orientation) {
    if (orientation.equals(UNSPECIFIED)) {
        return (ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else if (orientation.equals(LANDSCAPE)) {
        return (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (orientation.equals(PORTRAIT)) {
        return (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (orientation.equals(USER)) {
        return (ActivityInfo.SCREEN_ORIENTATION_USER);
    } else if (orientation.equals(BEHIND)) {
        return (ActivityInfo.SCREEN_ORIENTATION_BEHIND);
    } else if (orientation.equals(SENSOR)) {
        return (ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    } else if (orientation.equals(NOSENSOR)) {
        return (ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    } else if (orientation.equals(SENSOR_LANDSCAPE)) {
        return (ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else if (orientation.equals(SENSOR_PORTRAIT)) {
        return (ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    } else if (orientation.equals(REVERSE_LANDSCAPE)) {
        return (ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
    } else if (orientation.equals(REVERSE_PORTRAIT)) {
        return (ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
    } else if (orientation.equals(FULL_SENSOR)) {
        return (ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
    }/*w w  w .j a  v a2s .  com*/

    return (ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

From source file:org.kontalk.util.SystemUtils.java

/**
 * Returns the correct screen orientation based on the supposedly preferred
 * position of the device./*from   w w  w.  j a va  2 s .c  o  m*/
 * http://stackoverflow.com/a/16585072/1045199
 */
public static int getScreenOrientation(Activity activity) {
    WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
    Configuration configuration = activity.getResources().getConfiguration();
    int rotation = windowManager.getDefaultDisplay().getRotation();

    // Search for the natural position of the device
    if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180)
            || configuration.orientation == Configuration.ORIENTATION_PORTRAIT
                    && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) {
        // Natural position is Landscape
        switch (rotation) {
        case Surface.ROTATION_0:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        case Surface.ROTATION_180:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        case Surface.ROTATION_270:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        }
    } else {
        // Natural position is Portrait
        switch (rotation) {
        case Surface.ROTATION_0:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        case Surface.ROTATION_180:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        case Surface.ROTATION_270:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        }
    }

    return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}

From source file:io.github.msc42.masterthemaze.SearchDeviceActivity.java

private void lockScreenOrientation() {
    int orientation = getResources().getConfiguration().orientation;
    int rotation = getWindowManager().getDefaultDisplay().getRotation();

    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {//w  ww  .j  av  a  2s.  c  o  m
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        }
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        }
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}

From source file:com.jwork.spycamera.SpyCamActivity.java

private void getDefaultOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    //If Naturally landscape (tablets)
    log.v(this, "Display pixels: " + dm.widthPixels + "x" + dm.heightPixels + "|Rotation:" + rotation);
    if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180)
            && dm.widthPixels > dm.heightPixels)
            || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
                    && dm.widthPixels < dm.heightPixels)) {
        rotation += 1;/*  w ww . ja  va 2  s .co  m*/
        if (rotation > 3) {
            rotation = 0;
        }
    }
    switch (rotation) {
    case Surface.ROTATION_0:
        defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        break;
    case Surface.ROTATION_90:
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
            defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
        } else {
            defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            setRequestedOrientation(defaultOrientation);
        }
        break;
    case Surface.ROTATION_180:
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
            defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        } else {
            defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
            setRequestedOrientation(defaultOrientation);
        }
        break;
    case Surface.ROTATION_270:
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
            defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        } else {
            defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            setRequestedOrientation(defaultOrientation);
        }
        break;
    }
}

From source file:com.rfo.basic.Web.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void setOrientation(int orientation) { // Convert and apply orientation setting
    switch (orientation) {
    default://from   w  w  w .  j  ava2s. com
    case 1:
        orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        break;
    case 3:
        orientation = (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)
                ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
                : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        break;
    case 0:
        orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        break;
    case 2:
        orientation = (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)
                ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
                : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        break;
    case -1:
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
        break;
    }
    setRequestedOrientation(orientation);
}

From source file:org.LK8000.LK8000.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (serviceClass == null)
        serviceClass = MyService.class;

    super.onCreate(savedInstanceState);
    //    Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());

    Fabric fabric = new Fabric.Builder(this).debuggable(true).kits(new Crashlytics(), new CrashlyticsNdk())
            .build();//from  ww w .j av  a  2s.  c  o  m

    Fabric.with(fabric);

    Log.d(TAG, "ABI=" + Build.CPU_ABI);
    Log.d(TAG, "PRODUCT=" + Build.PRODUCT);
    Log.d(TAG, "MANUFACTURER=" + Build.MANUFACTURER);
    Log.d(TAG, "MODEL=" + Build.MODEL);
    Log.d(TAG, "DEVICE=" + Build.DEVICE);
    Log.d(TAG, "BOARD=" + Build.BOARD);
    Log.d(TAG, "FINGERPRINT=" + Build.FINGERPRINT);

    if (!Loader.loaded) {
        TextView tv = new TextView(this);
        tv.setText("Failed to load the native LK8000 libary.\n"
                + "Report this problem to us, and include the following information:\n" + "ABI=" + Build.CPU_ABI
                + "\n" + "PRODUCT=" + Build.PRODUCT + "\n" + "FINGERPRINT=" + Build.FINGERPRINT + "\n"
                + "error=" + Loader.error);
        setContentView(tv);
        return;
    }

    initialiseNative();

    NetUtil.initialise(this);
    InternalGPS.Initialize();
    NonGPSSensors.Initialize();

    IOIOHelper.onCreateContext(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR)
        // Bluetooth suppoert was added in Android 2.0 "Eclair"
        BluetoothHelper.Initialize(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
        // the DownloadManager was added in Android 2.3 "Gingerbread"
        DownloadUtil.Initialise(getApplicationContext());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        UsbSerialHelper.Initialise(this);
    }

    SoundUtil.Initialise();

    // fullscreen mode
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    /* Workaround for layout problems in Android KitKat with immersive full
       screen mode: Sometimes the content view was not initialized with the
       correct size, which caused graphics artifacts. */
    if (android.os.Build.VERSION.SDK_INT >= 19) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    enableImmersiveModeIfSupported();

    TextView tv = new TextView(this);
    tv.setText("Loading LK8000...");
    setContentView(tv);

    batteryReceiver = new BatteryReceiver();
    registerReceiver(batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    SharedPreferences settings = getSharedPreferences("LK8000", 0);
    int screenOrientation = settings.getInt("screenOrientation", 0);
    switch (screenOrientation) {
    case 0:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        break;
    case 1:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case 2:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case 3:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        break;
    case 4:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        break;
    default:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

}

From source file:com.brq.wallet.activity.ScanActivity.java

private int getScreenOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    int height = dm.heightPixels;
    int orientation;
    // if the device's natural orientation is portrait:
    if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width
            || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) {
        switch (rotation) {
        case Surface.ROTATION_0:
            orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
            break;
        case Surface.ROTATION_90:
            orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            break;
        case Surface.ROTATION_180:
            orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
            break;
        case Surface.ROTATION_270:
            orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
            break;
        default:/*  ww  w . j  av a  2  s.c  o m*/
            // Unknown screen orientation. Defaulting to portrait.
            orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
            break;
        }
    }
    // if the device's natural orientation is landscape or if the device is square:
    else {
        switch (rotation) {
        case Surface.ROTATION_0:
            orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            break;
        case Surface.ROTATION_90:
            orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
            break;
        case Surface.ROTATION_180:
            orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
            break;
        case Surface.ROTATION_270:
            orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
            break;
        default:
            // Unknown screen orientation. Defaulting to landscape.
            orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            break;
        }
    }
    return orientation;
}