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.codename1.impl.android.AndroidImplementation.java

public void lockOrientation(boolean portrait) {
    if (getActivity() == null) {
        return;//from   w  w w . j a  v  a2 s  .  com
    }
    if (portrait) {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
    // ADW: Try to add the restart flag here instead on preferences activity
    if (PersonaAlmostNexusSettingsHelper.needsRestart(key)) {
        // 290778 Commented for Higher SDK version
        // setPersistent(false);
        mShouldRestart = false;/*from  ww  w .  j a va  2 s  .  c  o m*/
    } else {
        // TODO: ADW Move here all the updates instead on
        // updateAlmostNexusUI()
        if (key.equals("homeOrientation")) {
            if (!mMessWithPersistence) {
                changeOrientation(PersonaAlmostNexusSettingsHelper.getDesktopOrientation(this), false);
            } else {
                // ADW: If a user changes between different orientation
                // modes
                // we temporarily disable persistence to change the app
                // orientation
                // it will be re-enabled on the next onCreate
                // setPersistent(false);
                changeOrientation(PersonaAlmostNexusSettingsHelper.getDesktopOrientation(this), true);
            }
        } else if (key.equals("systemPersistent")) {
            mMessWithPersistence = PersonaAlmostNexusSettingsHelper.getSystemPersistent(this);
            if (mMessWithPersistence) {
                changeOrientation(PersonaAlmostNexusSettingsHelper.getDesktopOrientation(this), true);
                // ADW: If previously in portrait, set persistent
                // else, it will call the setPersistent on the next onCreate
                // caused by the orientation change
                if (savedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
                    // setPersistent(true);
                }

            } else {
                // setPersistent(false);
                changeOrientation(PersonaAlmostNexusSettingsHelper.getDesktopOrientation(this), false);
            }
        } else if (key.equals("notif_receiver")) {
            boolean useNotifReceiver = PersonaAlmostNexusSettingsHelper.getNotifReceiver(this);
            if (!useNotifReceiver) {
                if (mCounterReceiver != null)
                    unregisterReceiver(mCounterReceiver);
                mCounterReceiver = null;
            } else {
                if (mCounterReceiver == null) {
                    mCounterReceiver = new PersonaCounterReceiver(this);
                    mCounterReceiver.setCounterListener(new PersonaCounterReceiver.OnCounterChangedListener() {
                        public void onTrigger(String pname, int counter, int color) {
                            PersonaLog.d("personalauncher",
                                    "updateCountersForPackage called from onSharedPreferenceChanged");
                            //                              updateCountersForPackage(pname,
                            //                                    counter, color, 0);

                            Bundle b = new Bundle();

                            b.putString("package", "com.cognizant.trumobi");
                            b.putInt("counter", counter);
                            b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR);
                            b.putInt("updateCountFor", 0);
                            Message m = new Message();
                            m.setData(b);
                            UiHandler.sendMessage(m);
                        }
                    });
                }
                registerReceiver(mCounterReceiver, mCounterReceiver.getFilter());
            }
        } else if (key.equals("main_dock_style")) {
            int dockstyle = PersonaAlmostNexusSettingsHelper.getmainDockStyle(this);
            if (dockstyle == DOCK_STYLE_NONE) {
                // mShouldRestart=true;
            } else if (mDockStyle == DOCK_STYLE_NONE) {
                // mShouldRestart=true;
            }
        } else if (key.equals("deletezone_style")) {
            int dz = PersonaAlmostNexusSettingsHelper.getDeletezoneStyle(this);
            if (mDeleteZone != null)
                mDeleteZone.setPosition(dz);
        }
        updateAlmostNexusUI();
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

private void changeOrientation(int type, boolean persistence) {
    if (!persistence) {
        switch (type) {
        case PersonaAlmostNexusSettingsHelper.ORIENTATION_SENSOR:
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
            break;
        case PersonaAlmostNexusSettingsHelper.ORIENTATION_PORTRAIT:
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
            break;
        case PersonaAlmostNexusSettingsHelper.ORIENTATION_LANDSCAPE:
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        default:/* www. j av a 2 s  .  c  o  m*/
            break;
        }
    } else {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}