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:com.flipzu.flipzu.Recorder.java

private void initGATracker() {
    /* get analytics singleton */
    tracker = GoogleAnalyticsTracker.getInstance();

    /* start tracker. Dispatch every 60 seconds. */
    tracker.startNewSession("UA-20341887-1", 60, this);

    /* debug GA */
    tracker.setDebug(false);/*from   w  w w.ja  va  2s . c o  m*/
    tracker.setDryRun(false);

    // Determine the screen orientation and set it in a custom variable.
    String orientation = "unknown";
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        orientation = "landscape";
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        orientation = "portrait";
        break;
    }
    tracker.setCustomVar(3, "Screen Orientation", orientation, 2);
}

From source file:com.ushahidi.android.app.activities.BaseActivity.java

protected void startActivityWithDelay(final Intent i) {
    if (mXLargeDevice && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        startActivity(i);//from ww w .  j  ava2  s. c om
    } else {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(i);
            }
        }, 400);
    }

}

From source file:com.shipdream.lib.android.mvc.MvcFragment.java

private static Orientation parseOrientation(int androidOrientation) {
    if (androidOrientation == Configuration.ORIENTATION_PORTRAIT) {
        return Orientation.PORTRAIT;
    } else if (androidOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        return Orientation.LANDSCAPE;
    } else {/*ww w .  ja  va 2s  .c om*/
        return Orientation.UNSPECIFIED;
    }
}

From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java

private void lockScreenRotation() {
    if (getActivity() != null) {
        switch (getActivity().getResources().getConfiguration().orientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
            break;
        }/*from   ww w  . j a v  a  2s.co m*/
    }
}

From source file:com.custom.music.MusicBrowserActivity.java

/**
 * M: Create fake menu./*ww w.  j  a  v  a2  s .  c  om*/
 */
private void createFakeMenu() {
    if (mHasMenukey) {
        Log.w(TAG, "<createFakeMenu> Quit when there has Menu Key", Log.APP);
        return;
    }
    if (mOrientaiton == Configuration.ORIENTATION_LANDSCAPE) {
        mOverflowMenuButtonId = R.id.overflow_menu;
        mOverflowMenuButton = findViewById(R.id.overflow_menu);
    } else {
        mOverflowMenuButtonId = R.id.overflow_menu_nowplaying;
        mOverflowMenuButton = findViewById(R.id.overflow_menu_nowplaying);
        View parent = (View) mOverflowMenuButton.getParent();
        if (parent != null) {
            parent.setVisibility(View.VISIBLE);
        }
    }
    mOverflowMenuButton.setVisibility(View.VISIBLE);
    mOverflowMenuButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(TAG, "<createFakeMenu> onClick()", Log.APP);
            if (v.getId() == mOverflowMenuButtonId) {
                final PopupMenu popupMenu = new PopupMenu(MusicBrowserActivity.this, mOverflowMenuButton);
                mPopupMenu = popupMenu;
                final Menu menu = popupMenu.getMenu();
                onCreateOptionsMenu(menu);
                popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
                    public boolean onMenuItemClick(MenuItem item) {
                        return onOptionsItemSelected(item);
                    }
                });
                popupMenu.setOnDismissListener(new OnDismissListener() {
                    public void onDismiss(PopupMenu menu) {
                        mPopupMenuShowing = false;
                        Log.i(TAG, "<createFakeMenu> onDismiss() called", Log.APP);
                        return;
                    }
                });
                onPrepareOptionsMenu(menu);
                mPopupMenuShowing = true;
                if (popupMenu != null) {
                    Log.i(TAG, "<createFakeMenu> popupMenu.show()", Log.APP);
                    popupMenu.show();
                }
            }
        }
    });
}

From source file:com.tzutalin.dlibtest.CameraConnectionFragment.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 ww  . j  a  v a 2 s .c o m*/
@DebugLog
@SuppressLint("LongLogTag")
private void setUpCameraOutputs(final int width, final int height) {
    final Activity activity = getActivity();
    final CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
    try {
        SparseArray<Integer> cameraFaceTypeMap = new SparseArray<>();
        // Check the facing types of camera devices
        for (final String cameraId : manager.getCameraIdList()) {
            final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
            final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
            if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) {
                if (cameraFaceTypeMap.get(CameraCharacteristics.LENS_FACING_FRONT) != null) {
                    cameraFaceTypeMap.append(CameraCharacteristics.LENS_FACING_FRONT,
                            cameraFaceTypeMap.get(CameraCharacteristics.LENS_FACING_FRONT) + 1);
                } else {
                    cameraFaceTypeMap.append(CameraCharacteristics.LENS_FACING_FRONT, 1);
                }
            }

            if (facing != null && facing == CameraCharacteristics.LENS_FACING_BACK) {
                if (cameraFaceTypeMap.get(CameraCharacteristics.LENS_FACING_FRONT) != null) {
                    cameraFaceTypeMap.append(CameraCharacteristics.LENS_FACING_BACK,
                            cameraFaceTypeMap.get(CameraCharacteristics.LENS_FACING_BACK) + 1);
                } else {
                    cameraFaceTypeMap.append(CameraCharacteristics.LENS_FACING_BACK, 1);
                }
            }
        }

        Integer num_facing_back_camera = cameraFaceTypeMap.get(CameraCharacteristics.LENS_FACING_BACK);
        for (final String cameraId : manager.getCameraIdList()) {
            final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
            final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
            // If facing back camera or facing external camera exist, we won't use facing front camera
            if (num_facing_back_camera != null && num_facing_back_camera > 0) {
                // We don't use a front facing camera in this sample if there are other camera device facing types
                if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) {
                    continue;
                }
            }

            final StreamConfigurationMap map = characteristics
                    .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

            if (map == null) {
                continue;
            }

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

            // 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), width, height, largest);

            // We fit the aspect ratio of TextureView to the size of preview we picked.
            final int orientation = getResources().getConfiguration().orientation;
            if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                textureView.setAspectRatio(previewSize.getWidth(), previewSize.getHeight());
            } else {
                textureView.setAspectRatio(previewSize.getHeight(), previewSize.getWidth());
            }

            CameraConnectionFragment.this.cameraId = cameraId;
            return;
        }
    } catch (final CameraAccessException e) {
        Timber.tag(TAG).e("Exception!", e);
    } catch (final NullPointerException e) {
        // Currently an NPE is thrown when the Camera2API is used but not supported on the
        // device this code runs.
        ErrorDialog.newInstance(getString(R.string.camera_error)).show(getChildFragmentManager(),
                FRAGMENT_DIALOG);
    }
}

From source file:com.flipzu.flipzu.Player.java

private void initGATracker() {
    /* get analytics singleton */
    tracker = GoogleAnalyticsTracker.getInstance();

    /* start tracker. Dispatch every 30 seconds. */
    tracker.startNewSession("UA-20341887-1", 30, this);

    /* debug GA */
    tracker.setDebug(false);//from  w  w w  .  j  a  v a 2s. co  m
    tracker.setDryRun(false);

    // Determine the screen orientation and set it in a custom variable.
    String orientation = "unknown";
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        orientation = "landscape";
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        orientation = "portrait";
        break;
    }
    tracker.setCustomVar(3, "Screen Orientation", orientation, 2);
}

From source file:com.cypress.cysmart.BLEServiceFragments.RGBFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        LayoutInflater inflater = (LayoutInflater) getActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rootView = inflater.inflate(R.layout.rgb_view_landscape, null);
        ViewGroup rootViewG = (ViewGroup) getView();
        // Remove all the existing views from the root view.
        rootViewG.removeAllViews();//from  w  ww  .  j  ava2s .c  o  m
        rootViewG.addView(rootView);
        setUpControls();
        setDefaultColorPickerPositionColor();

    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        LayoutInflater inflater = (LayoutInflater) getActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rootView = inflater.inflate(R.layout.rgb_view_portrait, null);
        ViewGroup rootViewG = (ViewGroup) getView();
        // Remove all the existing views from the root view.
        rootViewG.removeAllViews();
        rootViewG.addView(rootView);
        setUpControls();
        setDefaultColorPickerPositionColor();

    }

}

From source file:com.cssweb.android.quote.KLine2Activity.java

@Override
public void onConfigurationChanged(Configuration config) {
    super.onConfigurationChanged(config);
    if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setToolbarByScreen(2);//from  w  ww .  java  2 s .  c o  m
    } else {
        setToolbarByScreen(1);
    }
    //klineView.refresh();
}

From source file:com.xandy.calendar.AllInOneActivity.java

@Override
protected void onCreate(Bundle icicle) {
    if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
        setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    }// ww w  .  ja  v  a2  s .  com
    super.onCreate(icicle);

    if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) {
        mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS);
    }
    // Launch add google account if this is first time and there are no
    // accounts yet
    if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) {

        mHandler = new QueryHandler(this.getContentResolver());
        mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null,
                null /* selection args */, null /* sort order */);
    }

    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);

    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }

        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }

    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);

    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }

    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100,
                (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth,
                (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }

    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);

    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);

    // setContentView must be called before configureActionBar
    setContentView(R.layout.all_in_one);

    if (mIsTabletConfig) {
        mDateRange = (TextView) findViewById(R.id.date_bar);
        mWeekTextView = (TextView) findViewById(R.id.week_num);
    } else {
        mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
    }

    // configureActionBar auto-selects the first tab you add, so we need to
    // call it before we set up our own fragments to make sure it doesn't
    // overwrite us
    configureActionBar(viewType);

    mHomeTime = (TextView) findViewById(R.id.home_time);
    mMiniMonth = findViewById(R.id.mini_month);
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(
                new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = findViewById(R.id.calendar_list);
    mMiniMonthContainer = findViewById(R.id.mini_month_container);
    mSecondaryPane = findViewById(R.id.secondary_pane);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    initFragments(timeMillis, viewType, icicle);

    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mContentResolver = getContentResolver();
}