Example usage for android.content.res Configuration ORIENTATION_PORTRAIT

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

Introduction

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

Prototype

int ORIENTATION_PORTRAIT

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

Click Source Link

Document

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

Usage

From source file:com.waz.zclient.MainActivity.java

@Override
@SuppressWarnings("PMD")
public void onCreate(final Bundle savedInstanceState) {
    Timber.i("onCreate");
    if (getActionBar() != null) {
        getActionBar().hide();//w  w  w  .  ja  v a  2s .  c om
    }
    super.onCreate(savedInstanceState);

    //Prevent drawing the default background to reduce overdraw
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    setContentView(R.layout.main);

    if (LayoutSpec.isPhone(this)) {
        ViewUtils.lockScreenOrientation(Configuration.ORIENTATION_PORTRAIT, this);
    }

    FragmentManager fragmentManager = getSupportFragmentManager();

    getStoreFactory().getZMessagingApiStore().getApi().getMediaManager();

    initializeControllers();

    if (!getControllerFactory().getUserPreferencesController().showStatusBar()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    if (savedInstanceState == null) {
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.fl__offline__container, ConnectivityFragment.newInstance(),
                ConnectivityFragment.TAG);

        if (BuildConfig.SHOW_GRIDOVERLAY) {
            fragmentTransaction.add(R.id.fl_main_grid, GridFragment.newInstance(), GridFragment.TAG);
        }
        fragmentTransaction.commit();
    } else {
        getControllerFactory().getNavigationController().onActivityCreated(savedInstanceState);
    }

    if (BuildConfigUtils.isHockeyUpdateEnabled() && !BuildConfigUtils.isLocalBuild(this)) {
        HockeyCrashReporting.checkForUpdates(this);
    }

    getControllerFactory().getTrackingController().appLaunched(getIntent());
    String appCrash = getControllerFactory().getUserPreferencesController().getCrashException();
    String appCrashDetails = getControllerFactory().getUserPreferencesController().getCrashDetails();
    if (appCrash != null) {
        Event exceptionEvent = ExceptionEvent.exception(appCrash, appCrashDetails);
        getControllerFactory().getTrackingController().tagEvent(exceptionEvent);
    }
    getControllerFactory().getLoadTimeLoggerController().appStart();
}

From source file:org.opensilk.video.tv.ui.playback.PlaybackActivity.java

private void changeSurfaceLayout() {

    // get screen size
    int sw = getWindow().getDecorView().getWidth();
    int sh = getWindow().getDecorView().getHeight();

    mPlayback.getVLCVout().setWindowSize(sw, sh);

    double dw = sw, dh = sh;
    boolean isPortrait;

    // getWindow().getDecorView() doesn't always take orientation into account, we have to correct the values
    isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    if (sw > sh && isPortrait || sw < sh && !isPortrait) {
        dw = sh;/*from w w  w.  j  a  v a 2  s .c om*/
        dh = sw;
    }

    // sanity check
    if (dw * dh == 0 || mVideoWidth * mVideoHeight == 0) {
        Timber.e("Invalid surface size");
        return;
    }

    // compute the aspect ratio
    double ar, vw;
    if (mSarDen == mSarNum) {
        /* No indication about the density, assuming 1:1 */
        vw = mVideoVisibleWidth;
        ar = (double) mVideoVisibleWidth / (double) mVideoVisibleHeight;
    } else {
        /* Use the specified aspect ratio */
        vw = mVideoVisibleWidth * (double) mSarNum / mSarDen;
        ar = vw / mVideoVisibleHeight;
    }

    // compute the display aspect ratio
    double dar = dw / dh;

    switch (mCurrentSize) {
    case SURFACE_BEST_FIT:
        if (dar < ar)
            dh = dw / ar;
        else
            dw = dh * ar;
        break;
    case SURFACE_FIT_HORIZONTAL:
        dh = dw / ar;
        break;
    case SURFACE_FIT_VERTICAL:
        dw = dh * ar;
        break;
    case SURFACE_FILL:
        break;
    case SURFACE_16_9:
        ar = 16.0 / 9.0;
        if (dar < ar)
            dh = dw / ar;
        else
            dw = dh * ar;
        break;
    case SURFACE_4_3:
        ar = 4.0 / 3.0;
        if (dar < ar)
            dh = dw / ar;
        else
            dw = dh * ar;
        break;
    case SURFACE_ORIGINAL:
        dh = mVideoVisibleHeight;
        dw = vw;
        break;
    }

    // set display size
    ViewGroup.LayoutParams lp = mBinding.playerSurface.getLayoutParams();
    lp.width = (int) Math.ceil(dw * mVideoWidth / mVideoVisibleWidth);
    lp.height = (int) Math.ceil(dh * mVideoHeight / mVideoVisibleHeight);
    mBinding.playerSurface.setLayoutParams(lp);
    if (mBinding.subtitlesSurface != null) {
        mBinding.subtitlesSurface.setLayoutParams(lp);
    }

    // set frame size (crop if necessary)
    lp = mBinding.playerSurfaceFrame.getLayoutParams();
    lp.width = (int) Math.floor(dw);
    lp.height = (int) Math.floor(dh);
    mBinding.playerSurfaceFrame.setLayoutParams(lp);

    mBinding.playerSurface.invalidate();
    if (mBinding.subtitlesSurface != null) {
        mBinding.subtitlesSurface.invalidate();
    }
}

From source file:com.poinsart.votar.VotarMain.java

private void adjustLayoutForOrientation(int orientation) {
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mainLayout.setOrientation(LinearLayout.HORIZONTAL);
        controlLayout/*from w w  w. j  a v a2 s  .c  om*/
                .setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1));
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        mainLayout.setOrientation(LinearLayout.VERTICAL);
        controlLayout
                .setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1));
    }
}

From source file:info.rti.tabsswipe.TemperatureFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    if (Configuration.ORIENTATION_PORTRAIT == getResources().getConfiguration().orientation) {

        mYAxisPadding = 9;//from ww  w. j a v  a  2s  .c  o m
        mRenderer.setYLabels(30);

    }

    final LinearLayout view = (LinearLayout) inflater.inflate(R.layout.fragment_temperature, container, false);

    mChartView = ChartFactory.getTimeChartView(getActivity(), mDataset, mRenderer, TIME);
    mChartView.addZoomListener(mZoomListener1, true, false);
    view.addView(mChartView, new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

    return view;
}

From source file:org.wheelmap.android.fragment.POIsOsmdroidFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_osmdroid, container, false);

    txtOutOfZoom = (LinearLayout) v.findViewById(R.id.my_outofzoom_text_smartphone);

    if (UtilsMisc.isTablet(getActivity().getApplication())) {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            txtOutOfZoom.setVisibility(View.GONE);
            txtOutOfZoom = (LinearLayout) getActivity().findViewById(R.id.my_outofzoom_text_tablet_portrait);
            try {
                setAlphaForView(txtOutOfZoom, (float) 0.5);
            } catch (NullPointerException npex) {
                Log.d("Tag:POIsOsmdroidFragment", "NullPointException occurred");

                Toast.makeText(this.getActivity().getApplicationContext(),
                        getResources().getString(R.string.error_internal_error), Toast.LENGTH_LONG).show();
            }/*from www  .  j  a  v a 2  s . c o m*/
        }
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            txtOutOfZoom.setVisibility(View.GONE);
            txtOutOfZoom = (LinearLayout) getActivity().findViewById(R.id.my_outofzoom_text_tablet_landscape);

            try {
                setAlphaForView(txtOutOfZoom, (float) 0.5);
            } catch (NullPointerException npex) {
                Log.d("Tag:POIsOsmdroidFragment", "NullPointException occurred");

                Toast.makeText(this.getActivity().getApplicationContext(),
                        getResources().getString(R.string.error_internal_error), Toast.LENGTH_LONG).show();
            }
        }
    }

    try {
        txtOutOfZoom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                txtOutOfZoom.setVisibility(View.GONE);
                zoomInToMax();
            }
        });
    } catch (NullPointerException npex) {
        Log.d("Tag:POIsOsmdroidFragment", "NullPointException occurred");

        Toast.makeText(this.getActivity().getApplicationContext(),
                getResources().getString(R.string.error_internal_error), Toast.LENGTH_LONG).show();
    }

    mMapView = (MapView) v.findViewById(R.id.map);
    mMapView.setTileSource(mMapBoxTileSource);
    setHardwareAccelerationOff();
    mMapView.setBuiltInZoomControls(true);
    mMapView.setMultiTouchControls(true);
    mMapView.postDelayed(new Runnable() {
        @Override
        public void run() {
            requestUpdate();
        }
    }, 1000);

    mMapController = mMapView.getController();

    // overlays
    mPoisItemizedOverlay = new POIsCursorOsmdroidOverlay(getActivity(), this);
    mCurrLocationOverlay = new MyLocationNewOverlay(getActivity(), mMyLocationProvider, mMapView);

    mCurrLocationOverlay.enableMyLocation();

    markItemOverlay = new MarkItemOverlay(getActivity(), mMapView);

    mMapView.getOverlays().add(markItemOverlay);

    mMapView.getOverlays().add(mPoisItemizedOverlay);

    MyLocationNewOverlayFixed a = new MyLocationNewOverlayFixed(getActivity(), mMyLocationProvider, mMapView);
    a.enableMyLocation();
    mMyLocationProvider.startLocationProvider(a);
    mMapView.getOverlays().add(a);

    mMapView.setMapListener(this);

    mBtnLocate = (ImageButton) v.findViewById(R.id.map_btn_locate);
    mBtnLocate.setOnTouchListener(new PressSelector());
    mBtnLocate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            centerMap(mCurrentLocationGeoPoint, true);
            setZoomIntern(17);
            requestUpdate();
        }
    });

    onRestoreInstanceState(savedInstanceState);

    return v;
}

From source file:es.curso.android.streamingVLC.VideoActivity.java

private void setSize(int width, int height) {
    mVideoWidth = width;//from  w  w  w  .java2 s . c  o m
    mVideoHeight = height;
    if (mVideoWidth * mVideoHeight <= 1)
        return;

    // get screen size
    int w = getWindow().getDecorView().getWidth();
    int h = getWindow().getDecorView().getHeight();

    // getWindow().getDecorView() doesn't always take orientation into
    // account, we have to correct the values
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (w > h && isPortrait || w < h && !isPortrait) {
        int i = w;
        w = h;
        h = i;
    }

    float videoAR = (float) mVideoWidth / (float) mVideoHeight;
    float screenAR = (float) w / (float) h;

    if (screenAR < videoAR)
        h = (int) (w / videoAR);
    else
        w = (int) (h * videoAR);

    // force surface buffer size
    holder.setFixedSize(mVideoWidth, mVideoHeight);

    // set display size
    LayoutParams lp = mSurface.getLayoutParams();
    lp.width = w;
    lp.height = h;
    mSurface.setLayoutParams(lp);
    mSurface.invalidate();
}

From source file:com.gnufabio.costituzione.DetailedActivity.java

@SuppressWarnings("deprecation")
public void heuristicSetTytle(Configuration config) {
    if (mIsTablet) {
        setTitle(R.string.app_name);/*from w ww  .  j a  va  2s.com*/
    } else {
        int orientation = config.orientation;
        switch (orientation) {
        case Configuration.ORIENTATION_LANDSCAPE:
        case Configuration.ORIENTATION_SQUARE:
            setTitle(R.string.app_name);
            break;
        case Configuration.ORIENTATION_PORTRAIT:
            setTitle(null);
            break;
        default:
            setTitle(R.string.app_name);
            break;
        }
    }
}

From source file:com.inovex.zabbixmobile.activities.ChecksActivity.java

protected void showApplicationsFragment() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        // portrait
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.hide(mHostListFragment);/*w w  w .ja va 2 s.c o m*/
        ft.show(mApplicationsFragment);
        ft.commit();
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        mDrawerToggle.setDrawerIndicatorEnabled(false);
        // details fragment becomes visible -> enable menu
        mItemDetailsFragment.setHasOptionsMenu(false);
    }
    // nothing to do for landscape: applications are always visible
}

From source file:org.mariotaku.twidere.activity.support.DualPaneActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    super.onCreate(savedInstanceState);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    final int layout;
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, is_large_screen);
    mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, is_large_screen);
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        layout = mDualPaneInLandscape || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();//from  www . ja  v  a 2  s.  co m
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        layout = mDualPaneInPortrait || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();
        break;
    default:
        layout = getNormalLayoutRes();
        break;
    }
    setContentView(layout);
    if (mSlidingPane != null) {
        mSlidingPane.setRightPaneBackground(getPaneBackground());
    }
    final FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(this);
    if (savedInstanceState != null) {
        updateMainViewVisibility();
    }
}

From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java

/**
 *
 * @return horizontal screen orientation
 *//*from   w  w  w . j av  a2  s.c  o m*/
public boolean createRootLayout(LinearLayout l) {
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setOrientation(LinearLayout.VERTICAL);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        l.setPadding(toPixels(55), toPixels(4), toPixels(55), toPixels(4));
        return true;
    } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        l.setPadding(toPixels(4), toPixels(4), toPixels(4), toPixels(4));
    }
    return false;
}