Java Code Examples for android.content.pm.activityinfo#SCREEN_ORIENTATION_SENSOR

The following examples show how to use android.content.pm.activityinfo#SCREEN_ORIENTATION_SENSOR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YouTubePlayerActivity.java    From SkyTube with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onStart() {
	super.onStart();

	// set the video player's orientation as what the user wants
	String  str = SkyTubeApp.getPreferenceManager().getString(getString(R.string.pref_key_screen_orientation), getString(R.string.pref_screen_auto_value));
	int     orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

	if (str.equals(getString(R.string.pref_screen_landscape_value)))
		orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
	if (str.equals(getString(R.string.pref_screen_portrait_value)))
		orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
	if (str.equals(getString(R.string.pref_screen_sensor_value)))
		orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;

	setRequestedOrientation(orientation);
}
 
Example 2
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    mSwitchingView = false;

    /*
     * Set listeners here to avoid NPE when activity is closing
     */
    mSeekbar.setOnSeekBarChangeListener(mSeekListener);
    mLock.setOnClickListener(mLockListener);
    mPlayPause.setOnClickListener(mPlayPauseListener);
    mPlayPause.setOnLongClickListener(mPlayPauseLongListener);
    mLength.setOnClickListener(mRemainingTimeListener);
    mTime.setOnClickListener(mRemainingTimeListener);
    mSize.setOnClickListener(mSizeListener);

    if (mIsLocked && mScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR)
        setRequestedOrientation(mScreenOrientationLock);
}
 
Example 3
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Lock screen rotation
 */
private void lockScreen() {
    if(mScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
            setRequestedOrientation(14 /* SCREEN_ORIENTATION_LOCKED */);
        else
            setRequestedOrientation(getScreenOrientation());
        mScreenOrientationLock = getScreenOrientation();
    }
    showInfo(R.string.locked, 1000);
    mLock.setImageResource(R.drawable.ic_locked_circle);
    mTime.setEnabled(false);
    mSeekbar.setEnabled(false);
    mLength.setEnabled(false);
    mSize.setEnabled(false);
    hideOverlay(true);
    mLockBackButton = true;
}
 
Example 4
Source File: Form.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * The requested screen orientation. Commonly used values are
    unspecified (-1), landscape (0), portrait (1), sensor (4), and user (2).  " +
    "See the Android developer documentation for ActivityInfo.Screen_Orientation for the " +
    "complete list of possible settings.
 *
 * ScreenOrientation property getter method.
 *
 * @return  screen orientation
 */
@SimpleProperty(category = PropertyCategory.APPEARANCE,
    description = "The requested screen orientation, specified as a text value.  " +
    "Commonly used values are " +
    "landscape, portrait, sensor, user and unspecified.  " +
    "See the Android developer documentation for ActivityInfo.Screen_Orientation for the " +
    "complete list of possible settings.")
public String ScreenOrientation() {
  switch (getRequestedOrientation()) {
    case ActivityInfo.SCREEN_ORIENTATION_BEHIND:
      return "behind";
    case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
      return "landscape";
    case ActivityInfo.SCREEN_ORIENTATION_NOSENSOR:
      return "nosensor";
    case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
      return "portrait";
    case ActivityInfo.SCREEN_ORIENTATION_SENSOR:
      return "sensor";
    case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED:
      return "unspecified";
    case ActivityInfo.SCREEN_ORIENTATION_USER:
      return "user";
    case 10: // ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
      return "fullSensor";
    case 8: // ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
      return "reverseLandscape";
    case 9: // ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
      return "reversePortrait";
    case 6: // ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
      return "sensorLandscape";
    case 7: // ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
      return "sensorPortrait";
  }

  return "unspecified";
}
 
Example 5
Source File: ScreenUtils.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
public static String screenOrientationDesc(int curScreenOr) {
    String oriDesc = curScreenOr + "";
    switch (curScreenOr) {
        case ActivityInfo.SCREEN_ORIENTATION_BEHIND:
            oriDesc = "在后面BEHIND";
            break;
        case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
            oriDesc = "竖屏";
            break;
        case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
            oriDesc = "横屏";
            break;
        case ActivityInfo.SCREEN_ORIENTATION_USER:
            oriDesc = "跟随用户";
            break;
        case ActivityInfo.SCREEN_ORIENTATION_SENSOR:
            oriDesc = "跟随传感器";
            break;
        case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED:
            oriDesc = "未指明的";
            break;
        case ActivityInfo.SCREEN_ORIENTATION_LOCKED:
            oriDesc = "locked";
            break;
    }
    return oriDesc;
}
 
Example 6
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Remove screen lock
 */
private void unlockScreen() {
    if(mScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    showInfo(R.string.unlocked, 1000);
    mLock.setImageResource(R.drawable.ic_lock_circle);
    mTime.setEnabled(true);
    mSeekbar.setEnabled(mService == null || mService.isSeekable());
    mLength.setEnabled(true);
    mSize.setEnabled(true);
    mShowing = false;
    showOverlay();
    mLockBackButton = false;
}
 
Example 7
Source File: Utils.java    From Android-Applications-Info with Apache License 2.0 5 votes vote down vote up
public static String getOrientationString(int orientation) {
    switch (orientation) {
        case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED:
            return "Unspecified";
        case ActivityInfo.SCREEN_ORIENTATION_BEHIND:
            return "Behind";
        case ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR:
            return "Full sensor";
        case ActivityInfo.SCREEN_ORIENTATION_FULL_USER:
            return "Full user";
        case ActivityInfo.SCREEN_ORIENTATION_LOCKED:
            return "Locked";
        case ActivityInfo.SCREEN_ORIENTATION_NOSENSOR:
            return "No sensor";
        case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
            return "Landscape";
        case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
            return "Portrait";
        case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:
            return "Reverse portrait";
        case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
            return "Reverse landscape";
        case ActivityInfo.SCREEN_ORIENTATION_USER:
            return "User";
        case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
            return "Sensor landscape";
        case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:
            return "Sensor portrait";
        case ActivityInfo.SCREEN_ORIENTATION_SENSOR:
            return "Sensor";
        case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE:
            return "User landscape";
        case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT:
            return "User portrait";
        default:
            return "null";
    }
}
 
Example 8
Source File: DilbertPreferences.java    From Simple-Dilbert with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@MagicConstant(intValues = {ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_SENSOR, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE})
public int getLandscapeOrientation() {
    return isForceLandscape() ?
            isReversedLandscape() ?
                    ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
            : ActivityInfo.SCREEN_ORIENTATION_SENSOR;
}
 
Example 9
Source File: GalleryActivity.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {
    if (mGalleryView == null) {
        return;
    }

    int screenRotation = mScreenRotation.getSelectedItemPosition();
    int layoutMode = GalleryView.sanitizeLayoutMode(mReadingDirection.getSelectedItemPosition());
    int scaleMode = GalleryView.sanitizeScaleMode(mScaleMode.getSelectedItemPosition());
    int startPosition = GalleryView.sanitizeStartPosition(mStartPosition.getSelectedItemPosition());
    boolean keepScreenOn = mKeepScreenOn.isChecked();
    boolean showClock = mShowClock.isChecked();
    boolean showProgress = mShowProgress.isChecked();
    boolean showBattery = mShowBattery.isChecked();
    boolean showPageInterval = mShowPageInterval.isChecked();
    boolean volumePage = mVolumePage.isChecked();
    boolean readingFullscreen = mReadingFullscreen.isChecked();
    boolean customScreenLightness = mCustomScreenLightness.isChecked();
    int screenLightness = mScreenLightness.getProgress();

    boolean oldReadingFullscreen = Settings.getReadingFullscreen();

    Settings.putScreenRotation(screenRotation);
    Settings.putReadingDirection(layoutMode);
    Settings.putPageScaling(scaleMode);
    Settings.putStartPosition(startPosition);
    Settings.putKeepScreenOn(keepScreenOn);
    Settings.putShowClock(showClock);
    Settings.putShowProgress(showProgress);
    Settings.putShowBattery(showBattery);
    Settings.putShowPageInterval(showPageInterval);
    Settings.putVolumePage(volumePage);
    Settings.putReadingFullscreen(readingFullscreen);
    Settings.putCustomScreenLightness(customScreenLightness);
    Settings.putScreenLightness(screenLightness);

    int orientation;
    switch (screenRotation) {
        default:
        case 0:
            orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
            break;
        case 1:
            orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
            break;
        case 2:
            orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
            break;
        case 3:
            orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
            break;
    }
    setRequestedOrientation(orientation);
    mGalleryView.setLayoutMode(layoutMode);
    mGalleryView.setScaleMode(scaleMode);
    mGalleryView.setStartPosition(startPosition);
    if (keepScreenOn) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
    if (mClock != null) {
        mClock.setVisibility(showClock ? View.VISIBLE : View.GONE);
    }
    if (mProgress != null) {
        mProgress.setVisibility(showProgress ? View.VISIBLE : View.GONE);
    }
    if (mBattery != null) {
        mBattery.setVisibility(showBattery ? View.VISIBLE : View.GONE);
    }
    mGalleryView.setPagerInterval(showPageInterval ? getResources().getDimensionPixelOffset(R.dimen.gallery_pager_interval) : 0);
    mGalleryView.setScrollInterval(showPageInterval ? getResources().getDimensionPixelOffset(R.dimen.gallery_scroll_interval) : 0);
    setScreenLightness(customScreenLightness, screenLightness);

    // Update slider
    mLayoutMode = layoutMode;
    updateSlider();

    if (oldReadingFullscreen != readingFullscreen) {
        recreate();
    }
}