android.content.pm.ActivityInfo#SCREEN_ORIENTATION_SENSOR源码实例Demo

下面列出了android.content.pm.ActivityInfo#SCREEN_ORIENTATION_SENSOR 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SkyTube   文件: YouTubePlayerActivity.java
@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);
}
 
源代码2 项目: VCL-Android   文件: VideoPlayerActivity.java
@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);
}
 
源代码3 项目: VCL-Android   文件: VideoPlayerActivity.java
/**
 * 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;
}
 
源代码4 项目: appinventor-extensions   文件: Form.java
/**
 * 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";
}
 
源代码5 项目: BaseProject   文件: ScreenUtils.java
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;
}
 
源代码6 项目: VCL-Android   文件: VideoPlayerActivity.java
/**
 * 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;
}
 
源代码7 项目: Android-Applications-Info   文件: Utils.java
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";
    }
}
 
源代码8 项目: Simple-Dilbert   文件: DilbertPreferences.java
@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;
}
 
源代码9 项目: EhViewer   文件: GalleryActivity.java
@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();
    }
}