Example usage for android.content.res Configuration ORIENTATION_LANDSCAPE

List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.res Configuration ORIENTATION_LANDSCAPE.

Prototype

int ORIENTATION_LANDSCAPE

To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.

Click Source Link

Document

Constant for #orientation , value corresponding to the land resource qualifier.

Usage

From source file:dev.ronlemire.validation.MainActivity.java

 private void ReturnToValidationList() {
   ClearMessageBox();/* w w w  .ja v a  2 s. co m*/
   PopFragmentBackStack();

   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
         && isTablet()) {
      StartValidationListFragment();
      StartEmptyFragment();
   } else {
      ValidationListFragment validationListFragment = ValidationListFragment
            .newInstance("List");
      getSupportFragmentManager()
            .beginTransaction()
            .replace(MainActivity.validationListView.getId(),
                  validationListFragment).commit();
   }
}

From source file:com.ferid.app.classroom.statistics.StatisticalListActivity.java

/**
 * Set status bar colour on graph visibility change
 *///www.ja  v a2 s. c om
private void setStatusBarColour() {
    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

        if (graphLayout.getVisibility() == View.VISIBLE) {
            Configuration configuration = getResources().getConfiguration();

            if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                window.setStatusBarColor(ContextCompat.getColor(this, R.color.materialLightGreen));
            } else if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
                window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark));
            }
        } else {
            window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark));
        }
    }
}

From source file:com.air.mobilebrowser.BrowserActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    //Update the device status with the new orientation, and notify
    int orientation = newConfig.orientation;
    String orientationString = "none";

    if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        orientationString = "portrait";
    } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        orientationString = "landscape";
    } else if (orientation == Configuration.ORIENTATION_UNDEFINED) {
        orientationString = "none";
    }/*from   ww  w .j a  v a  2s . c o  m*/

    this.mDeviceStatus.orientation = orientationString;

    super.onConfigurationChanged(newConfig);

    handleOrientationChange();
}

From source file:com.raulh82vlc.face_detection_sample.camera2.presentation.FDCamera2Presenter.java

/**
 * Sets up member variables related to camera.
 *
 * @param width  The width of available size for camera preview
 * @param height The height of available size for camera preview
 *//*from  w w w .  j  a  v a2  s .c  o m*/
private void setUpCameraOutputs(int width, int height) {
    if (isViewAvailable()) {
        CameraManager manager = (CameraManager) activityView.getSystemService(Context.CAMERA_SERVICE);
        try {
            for (String cameraId : manager.getCameraIdList()) {
                CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);

                // We don't use a front facing camera in this sample.
                Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
                if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) {
                    continue;
                }

                StreamConfigurationMap map = characteristics
                        .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
                if (map == null) {
                    continue;
                }

                imageDimension = map.getOutputSizes(SurfaceTexture.class)[0];

                // For still image captures, we use the largest available size.
                Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)),
                        new CompareSizesByArea());

                Point displaySize = new Point();
                activityView.getWindowManager().getDefaultDisplay().getSize(displaySize);
                int rotatedPreviewWidth = width;
                int rotatedPreviewHeight = height;
                int maxPreviewWidth = displaySize.x;
                int maxPreviewHeight = displaySize.y;

                if (maxPreviewWidth > MAX_PREVIEW_WIDTH) {
                    maxPreviewWidth = MAX_PREVIEW_WIDTH;
                }

                if (maxPreviewHeight > MAX_PREVIEW_HEIGHT) {
                    maxPreviewHeight = MAX_PREVIEW_HEIGHT;
                }

                // Danger, W.R.! Attempting to use too large a preview size could  exceed the camera
                // bus' bandwidth limitation, resulting in gorgeous previews but the storage of
                // garbage capture data.
                previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedPreviewWidth,
                        rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, largest);

                // We fit the aspect ratio of TextureView to the size of preview we picked.
                int orientation = activityView.getResources().getConfiguration().orientation;
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activityView.getTextureView().setAspectRatio(previewSize.getWidth(),
                            previewSize.getHeight());
                } else {
                    activityView.getTextureView().setAspectRatio(previewSize.getHeight(),
                            previewSize.getWidth());
                }
                return;
            }
        } catch (CameraAccessException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            // Currently an NPE is thrown when the Camera2API is used but not supported on the
            // device this code runs.
        }
    }
}

From source file:com.nextgis.mobile.MapFragment.java

public void showInfoPane(boolean isShow) {

    if (isShow) {
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mChangeLocationListener);
        mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                mChangeLocationListener);
        mLocationManager.addGpsStatusListener(mGpsStatusListener);

        final RelativeLayout.LayoutParams RightParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        RightParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

        int nHeight = 0;

        if (mContext.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {

            TypedValue typeValue = new TypedValue();

            mContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, typeValue, true);
            nHeight = TypedValue.complexToDimensionPixelSize(typeValue.data,
                    mContext.getResources().getDisplayMetrics());

            //getTheme().resolveAttribute(android.R.attr.actionBarSize, typeValue, true);
            //nHeight = TypedValue.complexToDimensionPixelSize(
            //        typeValue.data,getResources().getDisplayMetrics());
        }/*from ww w. j  a  v  a 2  s .co  m*/

        RightParams.setMargins(0, 0, 0, nHeight);
        mMapRelativeLayout.addView(mInfoPane, RightParams);

    } else {
        mLocationManager.removeUpdates(mChangeLocationListener);
        mLocationManager.removeGpsStatusListener(mGpsStatusListener);
        mMapRelativeLayout.removeView(mInfoPane);
    }

    mIsInfoPaneShow = isShow;
}

From source file:com.kafilicious.popularmovies.ui.activity.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details_main);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.myToolbar);
    setSupportActionBar(toolbar);/*from  w  w  w  .j a v a 2 s . co m*/

    if (getSupportActionBar() != null) {
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    final Intent intent = this.getIntent();

    titleTextView = (TextView) findViewById(R.id.title_details);
    releaseDateTextView = (TextView) findViewById(R.id.year_details);
    ratingTextView = (TextView) findViewById(R.id.rating_score_detail);
    voteCountTextView = (TextView) findViewById(R.id.num_of_votes_detail);
    voteAverageTextView = (TextView) findViewById(R.id.vote_average_details);
    videoErrorTV = (TextView) findViewById(R.id.video_error_tv);
    reviewErrorTV = (TextView) findViewById(R.id.review_error_tv);
    ratingBar = (RatingBar) findViewById(R.id.rating_bar_detail);
    backDropImageView = (ImageView) findViewById(R.id.iv_backdrop);
    favoriteButton = (Button) findViewById(R.id.favorite);

    int orientation = this.getResources().getConfiguration().orientation;

    scrollView = (NestedScrollView) findViewById(R.id.nested_scrollView);
    if (scrollView != null) {
        scrollView.setFillViewport(true);
    }

    tabLayout = (TabLayout) findViewById(R.id.movie_details_tabLayout);
    viewPager = (ViewPager) findViewById(R.id.movie_details_container);

    dbHelper = new MovieDbHelper(this);

    sectionPagerAdapter = new SectionPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(sectionPagerAdapter);

    tabLayout.setupWithViewPager(viewPager);

    if (movieIsStored()) {
        favoriteButton.setText(R.string.button_text_marked);
    } else {
        favoriteButton.setText(R.string.button_text);
    }
    if (intent != null && intent.hasExtra(MOVIE_TITLE)) {

        movieTitle = intent.getStringExtra(MOVIE_TITLE);
        id = Integer.parseInt(intent.getStringExtra(MOVIE_ID));
        final String movieRelease = intent.getStringExtra(MOVIE_RELEASE);
        final String movieVoteCount = intent.getStringExtra(MOVIE_VOTE_COUNT);
        movieOverview = intent.getStringExtra(MOVIE_OVERVIEW);
        final String movieVoteAverage = intent.getStringExtra(MOVIE_VOTE_AVERAGE);
        final String moviePoster = intent.getStringExtra(MOVIE_POSTER);
        final String movieBackdrop = intent.getStringExtra(MOVIE_BACK_DROP);

        getSupportActionBar().setTitle(intent.getStringExtra(MOVIE_TITLE) + " ("
                + intent.getStringExtra(MOVIE_RELEASE).substring(0, 4) + ")");

        selectionArgs = new String[] { String.valueOf(id) };

        titleTextView.setText(movieTitle);
        releaseDateTextView.setText(movieRelease.substring(0, 4));
        voteAverageTextView.setText(movieVoteAverage + "/10");
        voteCountTextView.setText(movieVoteCount);
        String url2 = NetworkUtils.buildMovieUrl(movieBackdrop, 1).toString();
        Picasso.with(this).load(url2).into(backDropImageView);

        double voteAverage = Double.parseDouble(movieVoteAverage);
        voteAverage = (voteAverage / 10) * 5;
        String rating = String.format("%.1f", voteAverage);
        voteAverage = Double.parseDouble(rating);
        ratingTextView.setText(rating);
        ratingBar.setRating((float) voteAverage);
        ratingBar.setStepSize((float) 0.1);

        text = intent.getStringExtra(MOVIE_TITLE) + "(" + intent.getStringExtra(MOVIE_RELEASE).substring(0, 4)
                + ")";

        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            favoriteButton.setVisibility(View.GONE);
            fab = (FloatingActionButton) findViewById(R.id.fab);
            collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
            layoutDetail = (LinearLayout) findViewById(R.id.layout_detail_card);
            layoutDetail.setVisibility(View.GONE);
            posterDetailCard = (ImageView) findViewById(R.id.poster_detail_card);
            titleDetailCard = (TextView) findViewById(R.id.movie_title);
            releaseDetailCard = (TextView) findViewById(R.id.movie_release_date);
            ratingDetailCard = (TextView) findViewById(R.id.rating);
            ratingScoreDetailCard = (TextView) findViewById(R.id.rating_score_details);
            voteCountDetailCard = (TextView) findViewById(R.id.num_of_votes_details);
            ratingBarPortrait = (RatingBar) findViewById(R.id.rating_bar_details);
            myAppBarLayout = (AppBarLayout) findViewById(R.id.myAppbar);

            if (movieIsStored()) {
                fab.setImageResource(R.drawable.ic_star_black_24dp);
            } else {
                fab.setImageResource(R.drawable.ic_star_border_black_24dp);
            }

            myAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
                @Override
                public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
                    if (i == -collapsingToolbarLayout.getHeight() + toolbar.getHeight()) {
                        collapsingToolbarLayout
                                .setCollapsedTitleTextColor(getResources().getColor(android.R.color.white));
                        layoutDetail.setVisibility(View.VISIBLE);
                    } else {
                        layoutDetail.setVisibility(View.GONE);
                        collapsingToolbarLayout
                                .setExpandedTitleColor(getResources().getColor(R.color.transparent));
                    }
                }
            });

            titleDetailCard.setText(movieTitle);
            releaseDetailCard.setText(movieRelease);
            ratingDetailCard.setText(movieVoteAverage + "/10");
            voteCountDetailCard.setText(movieVoteCount);
            ratingScoreDetailCard.setText(rating);
            ratingBarPortrait.setRating((float) voteAverage);
            ratingBarPortrait.setStepSize((float) 0.1);
            ratingBarPortrait.setNumStars(5);
            String url = NetworkUtils.buildMovieUrl(moviePoster, 0).toString();
            Picasso.with(this).load(url).into(posterDetailCard);
            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    if (movieIsStored()) {
                        fab.setImageResource(R.drawable.ic_star_border_black_24dp);
                        int deletedMovie = getContentResolver().delete(MovieContract.MovieEntry.CONTENT_URI,
                                selection, selectionArgs);
                        Log.i("Movie deleted", String.valueOf(deletedMovie));
                        Toast.makeText(DetailActivity.this, movieTitle + " has being removed from My Favorites",
                                Toast.LENGTH_LONG).show();
                    } else {
                        fab.setImageResource(R.drawable.ic_star_black_24dp);
                        ContentValues values = new ContentValues();
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_TITLE, movieTitle);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_ID, String.valueOf(id));
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_OVERVIEW, movieOverview);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_COUNT, movieVoteCount);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_AVERAGE, movieVoteAverage);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_BACKDROP_PATH, movieBackdrop);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_POSTR_PATH, moviePoster);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_RELEASE_DATE, movieRelease);
                        Uri updatedMovie = getContentResolver().insert(MovieContract.MovieEntry.CONTENT_URI,
                                values);
                        Log.i("Movie Added ", String.valueOf(updatedMovie) + " | Title: " + movieTitle);
                        Toast.makeText(DetailActivity.this, movieTitle + " has being added to My Favorites",
                                Toast.LENGTH_LONG).show();
                    }

                }
            });

        } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            favoriteButton.setVisibility(View.VISIBLE);
            favoriteButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    if (movieIsStored()) {
                        favoriteButton.setText(R.string.button_text);
                        int deletedMovie = getContentResolver().delete(MovieContract.MovieEntry.CONTENT_URI,
                                selection, selectionArgs);
                        Log.i("Movie deleted", String.valueOf(deletedMovie));
                        Toast.makeText(DetailActivity.this, movieTitle + " has being removed from My Favorites",
                                Toast.LENGTH_LONG).show();
                    } else {
                        favoriteButton.setText(R.string.button_text_marked);
                        ContentValues values = new ContentValues();
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_TITLE, movieTitle);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_ID, String.valueOf(id));
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_OVERVIEW, movieOverview);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_COUNT, movieVoteCount);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_AVERAGE, movieVoteAverage);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_BACKDROP_PATH, movieBackdrop);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_POSTR_PATH, moviePoster);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_RELEASE_DATE, movieRelease);
                        Uri updatedMovie = getContentResolver().insert(MovieContract.MovieEntry.CONTENT_URI,
                                values);
                        Log.i("Movie Added", String.valueOf(updatedMovie) + " | Title: " + movieTitle);
                        Toast.makeText(DetailActivity.this, movieTitle + " has being added to My Favorites",
                                Toast.LENGTH_LONG).show();
                    }

                }
            });
        }

        Log.i("Results", "ID set successful");

    }
}

From source file:com.sourceallies.android.zonebeacon.activity.MainActivity.java

/**
 * Get the number of columns in the grid.
 *
 * @return integer for the number of columns used in the grid
 *//* w w  w . jav  a  2 s  .c o m*/
@VisibleForTesting
protected int getColumnCount() {
    Resources res = getResources();

    if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
        return 2;
    if (res.getBoolean(R.bool.tablet))
        return 2;

    return 1;
}

From source file:com.mozilla.SUTAgentAndroid.SUTAgentAndroid.java

public void fixScreenOrientation() {
    setRequestedOrientation(//w  ww .j  a  va  2  s.  c o m
            (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                    ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
                    : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

From source file:com.r.raul.tools.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {

    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {

    }/*  w  w  w . j  a v  a2s .  co  m*/
}

From source file:com.brandroidtools.filemanager.activities.PickerActivity.java

/**
 * Method that measure the height needed to avoid resizing when
 * change to a new directory. This method fixed the height of the window
 * @hide/*from  w w  w .ja  v  a 2s. com*/
 */
void measureHeight() {
    // Calculate the dialog size based on the window height
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    final int height = displaymetrics.heightPixels;

    Configuration config = getResources().getConfiguration();
    int percent = config.orientation == Configuration.ORIENTATION_LANDSCAPE ? 55 : 70;

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            (height * percent) / 100);
    this.mRootView.setLayoutParams(params);
}