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.cognizant.trumobi.PersonaLauncher.java

@Override
protected void onResume() {
    PersonaLog.d("PersonaLauncher", "onResume of PersonaLauncher");
    super.onResume();
    if (shouldRestart())
        return;/*from   www  .j ava 2 s .c  om*/
    //Badge
    updateBadgeCounts();
    // ADW: Use custom settings to set the rotation
    /*
     * this.setRequestedOrientation(
     * PersonaAlmostNexusSettingsHelper.getDesktopRotation(this)?
     * ActivityInfo.SCREEN_ORIENTATION_USER
     * :ActivityInfo.SCREEN_ORIENTATION_NOSENSOR );
     */
    // ADW: Use custom settings to change number of columns (and rows for
    // SlidingGrid) depending on phone rotation
    int orientation = getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        mAllAppsGrid.setNumColumns(PersonaAlmostNexusSettingsHelper.getColumnsPortrait(PersonaLauncher.this));
        mAllAppsGrid.setNumRows(PersonaAlmostNexusSettingsHelper.getRowsPortrait(PersonaLauncher.this));
        mAllAppsGrid.setPageHorizontalMargin(
                PersonaAlmostNexusSettingsHelper.getPageHorizontalMargin(PersonaLauncher.this));

    } else {
        mAllAppsGrid.setNumColumns(PersonaAlmostNexusSettingsHelper.getColumnsLandscape(PersonaLauncher.this));
        mAllAppsGrid.setNumRows(PersonaAlmostNexusSettingsHelper.getRowsLandscape(PersonaLauncher.this));
    }
    // mWorkspace.setWallpaper(false);
    if (mRestoring) {
        startLoaders();
    }

    // If this was a new intent (i.e., the mIsNewIntent flag got set to true
    // by
    // onNewIntent), then close the search dialog if needed, because it
    // probably
    // came from the user pressing 'home' (rather than, for example,
    // pressing 'back').
    if (mIsNewIntent) {
        // Post to a handler so that this happens after the search dialog
        // tries to open
        // itself again.
        mWorkspace.post(new Runnable() {
            public void run() {
                // ADW: changed from using ISearchManager to use
                // SearchManager (thanks to PersonaLauncher+ source code)
                SearchManager searchManagerService = (SearchManager) PersonaLauncher.this
                        .getSystemService(Context.SEARCH_SERVICE);
                try {
                    searchManagerService.stopSearch();
                } catch (Exception e) {
                    PersonaLog.e(LOG_TAG, "error stopping search", e);
                }
            }
        });
    }

    mIsNewIntent = false;
}

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);
    }//from  w w  w.  j a  v  a  2 s  .com

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

From source file:com.atwal.wakeup.battery.util.Utilities.java

public static int getNavigationBarHeight(Context context) {
    int result = 0;
    try {/*w  w w  .  j  a v a2s  . c  om*/
        final String NAV_BAR_HEIGHT_RES_NAME = "navigation_bar_height";
        final String NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME = "navigation_bar_height_landscape";

        Resources res = context.getResources();
        final boolean mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            if (hasNavBar(context)) {
                String key;
                if (mInPortrait) {
                    key = NAV_BAR_HEIGHT_RES_NAME;
                } else {
                    key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;
                }
                return getInternalDimensionSize(res, key);
            }
        }
    } catch (Exception e) {
        return 0;
    }
    return result;
}

From source file:org.zywx.wbpalmstar.engine.EBrowserWindow.java

protected void notifyScreenOrientationChange(Configuration newConfig) {
    if (null == mMainView) {
        return;//from  w w w  .  j  av  a 2 s. c  o m
    }
    int type = newConfig.orientation;
    if (type == Configuration.ORIENTATION_LANDSCAPE) {
        mMainView.loadUrl(EUExScript.F_UEX_SCRIPT_OC_LANDSCAPE);
    } else if (type == Configuration.ORIENTATION_PORTRAIT) {
        mMainView.loadUrl(EUExScript.F_UEX_SCRIPT_OC_PORTRAIT);
    }
}

From source file:com.android.mail.browse.ConversationContainer.java

private boolean isSnapEnabled() {
    if (mAccountController == null || mAccountController.getAccount() == null
            || mAccountController.getAccount().settings == null) {
        return true;
    }//from  w w  w.  j a v  a2  s  .  c  o m
    final int snap = mAccountController.getAccount().settings.snapHeaders;
    return snap == UIProvider.SnapHeaderValue.ALWAYS || (snap == UIProvider.SnapHeaderValue.PORTRAIT_ONLY
            && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
}

From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java

private void onOrientationChanged(final int orientation) {
    currentOrientation = orientation;//from w ww .ja  v a 2  s .co m

    if (!isFullscreen || !isBigScreen) {
        switch (orientation) {
        case Configuration.ORIENTATION_LANDSCAPE:
            goLandscape();
            break;
        case Configuration.ORIENTATION_PORTRAIT:
            goPortrait();
            break;
        default:
        }
    }
}

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 {/*from ww  w  .j a  v  a 2 s  . c  om*/
        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);
    }//  w ww  . j  av a  2 s. c  om
    // 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:com.aimfire.demo.CameraActivity.java

public int getDeviceDefaultOrientation() {
    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

    Configuration config = getResources().getConfiguration();

    int rotation = windowManager.getDefaultDisplay().getRotation();

    if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180)
            && config.orientation == Configuration.ORIENTATION_LANDSCAPE)
            || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
                    && config.orientation == Configuration.ORIENTATION_PORTRAIT)) {
        return Configuration.ORIENTATION_LANDSCAPE;
    } else {//from  w w  w  .j  ava 2 s  .c  o m
        return Configuration.ORIENTATION_PORTRAIT;
    }
}

From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    this.getMenuInflater().inflate(R.menu.toolbar_menu, menu);

    //clear button
    MenuItem item = menu.findItem(R.id.clear_btn);
    if (item != null) {
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override// w ww  . j a  v a2 s  .  co m
            public boolean onMenuItemClick(MenuItem item) {
                clearAdapter();
                return true;
            }
        });
    }

    //bluetoooth scan button
    item = menu.findItem(R.id.scan_btn);
    if (item != null) {
        item.setIcon(R.drawable.ic_action_scanning);
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                toggleScan(item);
                return true;
            }
        });
    }

    //bluetooth state button
    item = menu.findItem(R.id.state_bt_btn);
    if (item != null) {
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                toggleBtState();
                return true;
            }
        });
        if (mBluetoothAdapter.isEnabled()) {
            item.setIcon(R.drawable.ic_bluetooth);
        } else {
            item.setIcon(R.drawable.ic_bluetooth_disabled);
        }
    }

    //reset snoop file button
    if (Build.VERSION.SDK_INT <= 22) {
        item = menu.findItem(R.id.reset_snoop_file);
        item.setVisible(true);
        if (item != null) {
            item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    resetSnoopFile();
                    refresh();
                    return true;
                }
            });
        }
    }

    //filter button
    item = menu.findItem(R.id.filter_btn);
    if (item != null) {
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                filter();
                return true;
            }
        });
    }

    //refresh button
    item = menu.findItem(R.id.refresh);
    if (item != null) {
        if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT) {

            item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    refresh();
                    return true;
                }
            });
        } else {
            item.setVisible(false);
        }
    }

    item = menu.findItem(R.id.share);

    if (item != null) {
        // Fetch and store ShareActionProvider
        mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
        setSharedIntent();
    }

    return super.onCreateOptionsMenu(menu);
}