Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT

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

Introduction

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

Prototype

int SCREEN_ORIENTATION_PORTRAIT

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

Click Source Link

Document

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

Usage

From source file:com.lewa.crazychapter11.MainActivity.java

private void ChangeOrientation() {
    Configuration cfg = getResources().getConfiguration();
    if (cfg.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        MainActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }/*w w  w . j  av a  2  s  .  c o  m*/

    if (cfg.orientation == Configuration.ORIENTATION_PORTRAIT) {
        MainActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

From source file:com.fsm.storybook.launcher.WebViewActivity.java

private void lockScreenRotation() {
    //lock screen rotation, so that user can't disturb the calculation of page count
    if (currentOrientation == String.valueOf(Configuration.ORIENTATION_PORTRAIT)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {// w ww.ja  v a2s  . com
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

From source file:it.geosolutions.geocollect.android.map.GeoCollectMapActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (mDrawerToggle != null) {
        mDrawerToggle.onConfigurationChanged(newConfig);
    }//from w  w  w  .  j  ava 2 s. c  o  m
    // Checks the orientation of the screen for landscape and portrait and set portrait mode always
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }
}

From source file:de.sourcestream.movieDB.controller.CastDetails.java

/**
 * Fired when are restoring from backState or orientation has changed.
 *
 * @param args our bundle with saved state.
 *///from w ww  .  j av  a2 s  .co  m
private void onOrientationChange(Bundle args) {
    // Home page
    homeIconCheck = args.getInt("homeIconCheck");
    if (homeIconCheck == 0)
        homeIconUrl = args.getString("homepage");

    // Gallery
    galleryIconCheck = args.getInt("galleryIconCheck");
    if (galleryIconCheck == 0) {
        galleryList = new ArrayList<>();
        galleryList = args.getStringArrayList("galleryList");
        if (galleryList.size() == 0)
            activity.hideView(galleryIcon);
    }

    // More icon
    moreIconCheck = args.getInt("moreIconCheck");

    if (homeIconCheck == 1 && galleryIconCheck == 1) {
        moreIconCheck = 1;
        moreIcon.setVisibility(View.GONE);
    } else
        moreIconCheck = 0;

    mSlidingTabLayout.setOnPageChangeListener(onPageChangeSelected);
    activity.setCastDetailsInfoBundle(save);
    activity.setCastDetailsCreditsBundle(save);
    activity.setCastDetailsBiographyBundle(save);

    moviesList = save.getParcelableArrayList("moviesList");
    if (moviesList != null && moviesList.size() == 0) {
        noCredits = true;
        mSlidingTabLayout.disableTabClickListener(1);
    }

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            castDetailsInfo = (CastDetailsInfo) castDetailsSlideAdapter.getRegisteredFragment(0);
            castDetailsCredits = (CastDetailsCredits) castDetailsSlideAdapter.getRegisteredFragment(1);
            if (currPos == 0) {
                moreIcon.setVisibility(View.INVISIBLE);
            } else if (moreIconCheck == 0) {
                castDetailsInfo.getMoreIcon().setVisibility(View.INVISIBLE);
                updateDownPos();
            }
            if (moreIconCheck == 1)
                castDetailsInfo.getMoreIcon().setVisibility(View.GONE);
            else {
                // set listener on backdrop click to open gallery
                if (galleryIconCheck == 0 && galleryList.size() > 0)
                    castDetailsInfo.getProfilePath().setOnClickListener(onGalleryIconClick);
                adjustIconsPos(homeIcon, galleryIcon);
                adjustIconsPos(castDetailsInfo.getHomeIcon(), castDetailsInfo.getGalleryIcon());
            }

            // disable orientation changing, enable nav drawer sliding, show toolbar
            if (galleryIconCheck == 0 && galleryList.size() == 1) {
                activity.getWindow().getDecorView().setBackgroundColor(
                        ContextCompat.getColor(activity, R.color.background_material_light));
                if (activity.getSupportActionBar() != null)
                    activity.getSupportActionBar().show();
                activity.getMDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
                activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
                if (Build.VERSION.SDK_INT >= 19)
                    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                            | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                // Check orientation and lock to portrait if we are on phone
                if (getResources().getBoolean(R.bool.portrait_only))
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            }

            if (castDetailsCredits.getMoviesList().size() < 7)
                activity.hideView(castDetailsInfo.getShowMoreButton());

        }
    });

}

From source file:com.google.appinventor.components.runtime.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//from  w  ww. ja v  a2 s  .  c om
 */
@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";
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionLivestreamActivity.java

/**
 * Adjusts phone layouts for full screen video.
 */// ww  w.j  a  v  a2  s.  c  om
private void layoutPhoneFullscreen(boolean fullscreen) {
    if (fullscreen) {
        mTabHost.setVisibility(View.GONE);
        if (mYouTubePlayer != null) {
            mYouTubePlayer.setFullscreen(true);
        }
    } else {
        mTabHost.setVisibility(View.VISIBLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}

From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void updateFromPrefs() {

    SherlockFragmentActivity activity = getSherlockActivity();

    if (activity == null) {
        return;//from  www.  j  a  va 2 s  .  co m
    }

    bookView.setTextSize(config.getTextSize());

    int marginH = config.getHorizontalMargin();
    int marginV = config.getVerticalMargin();

    this.textLoader.setFontFamily(config.getDefaultFontFamily());
    this.bookView.setFontFamily(config.getDefaultFontFamily());
    this.textLoader.setSansSerifFontFamily(config.getSansSerifFontFamily());
    this.textLoader.setSerifFontFamily(config.getSerifFontFamily());

    bookView.setHorizontalMargin(marginH);
    bookView.setVerticalMargin(marginV);

    if (!isAnimating()) {
        bookView.setEnableScrolling(config.isScrollingEnabled());
    }

    textLoader.setStripWhiteSpace(config.isStripWhiteSpaceEnabled());
    textLoader.setAllowStyling(config.isAllowStyling());
    textLoader.setUseColoursFromCSS(config.isUseColoursFromCSS());

    bookView.setLineSpacing(config.getLineSpacing());

    if (config.isFullScreenEnabled()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getSupportActionBar().hide();

    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getSupportActionBar().show();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (config.isFullScreenEnabled()) {
            bookView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);

        }
        if (config.isDimSystemUI()) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        }
    }

    if (config.isKeepScreenOn()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    restoreColorProfile();

    // Check if we need a restart
    if (config.isFullScreenEnabled() != savedConfigState.fullscreen
            || config.isShowPageNumbers() != savedConfigState.usePageNum
            || config.isBrightnessControlEnabled() != savedConfigState.brightness
            || config.isStripWhiteSpaceEnabled() != savedConfigState.stripWhiteSpace
            || !config.getDefaultFontFamily().getName().equalsIgnoreCase(savedConfigState.fontName)
            || !config.getSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.serifFontName)
            || !config.getSansSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.sansSerifFontName)
            || config.getHorizontalMargin() != savedConfigState.hMargin
            || config.getVerticalMargin() != savedConfigState.vMargin
            || config.getTextSize() != savedConfigState.textSize
            || config.isScrollingEnabled() != savedConfigState.scrolling
            || config.isAllowStyling() != savedConfigState.allowStyling
            || config.isUseColoursFromCSS() != savedConfigState.allowColoursFromCSS) {

        textLoader.invalidateCachedText();
        restartActivity();
    }

    Configuration.OrientationLock orientation = config.getScreenOrientation();

    switch (orientation) {
    case PORTRAIT:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case LANDSCAPE:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case REVERSE_LANDSCAPE:
        getActivity().setRequestedOrientation(8); // Android 2.3+ value
        break;
    case REVERSE_PORTRAIT:
        getActivity().setRequestedOrientation(9); // Android 2.3+ value
        break;
    default:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

private void updateFromPrefs() {

    SherlockFragmentActivity activity = getSherlockActivity();

    if (activity == null) {
        return;// w w  w .  j  a  va  2 s.  co  m
    }

    bookView.setTextSize(config.getTextSize());

    int marginH = config.getHorizontalMargin();
    int marginV = config.getVerticalMargin();

    this.textLoader.setFontFamily(config.getDefaultFontFamily());
    this.bookView.setFontFamily(config.getDefaultFontFamily());
    this.textLoader.setSansSerifFontFamily(config.getSansSerifFontFamily());
    this.textLoader.setSerifFontFamily(config.getSerifFontFamily());

    bookView.setHorizontalMargin(marginH);
    bookView.setVerticalMargin(marginV);

    if (!isAnimating()) {
        bookView.setEnableScrolling(config.isScrollingEnabled());
    }

    textLoader.setStripWhiteSpace(config.isStripWhiteSpaceEnabled());
    textLoader.setAllowStyling(config.isAllowStyling());
    textLoader.setUseColoursFromCSS(config.isUseColoursFromCSS());

    bookView.setLineSpacing(config.getLineSpacing());

    if (config.isFullScreenEnabled()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getSupportActionBar().hide();
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getSupportActionBar().show();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && config.isDimSystemUI()) {
        activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    }

    if (config.isKeepScreenOn()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    restoreColorProfile();

    // Check if we need a restart
    if (config.isFullScreenEnabled() != savedConfigState.fullscreen
            || config.isShowPageNumbers() != savedConfigState.usePageNum
            || config.isBrightnessControlEnabled() != savedConfigState.brightness
            || config.isStripWhiteSpaceEnabled() != savedConfigState.stripWhiteSpace
            || !config.getDefaultFontFamily().getName().equalsIgnoreCase(savedConfigState.fontName)
            || !config.getSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.serifFontName)
            || !config.getSansSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.sansSerifFontName)
            || config.getHorizontalMargin() != savedConfigState.hMargin
            || config.getVerticalMargin() != savedConfigState.vMargin
            || config.getTextSize() != savedConfigState.textSize
            || config.isScrollingEnabled() != savedConfigState.scrolling
            || config.isAllowStyling() != savedConfigState.allowStyling
            || config.isUseColoursFromCSS() != savedConfigState.allowColoursFromCSS) {

        textLoader.invalidateCachedText();
        restartActivity();
    }

    Configuration.OrientationLock orientation = config.getScreenOrientation();

    switch (orientation) {
    case PORTRAIT:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case LANDSCAPE:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case REVERSE_LANDSCAPE:
        getActivity().setRequestedOrientation(8); // Android 2.3+ value
        break;
    case REVERSE_PORTRAIT:
        getActivity().setRequestedOrientation(9); // Android 2.3+ value
        break;
    default:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:com.processing.core.PApplet.java

public void orientation(int which) {
    if (which == PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (which == LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }/*from  w w  w .  j a va2s.  c o  m*/
}