Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE

List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.

Prototype

int SCREEN_ORIENTATION_LANDSCAPE

To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.

Click Source Link

Document

Constant corresponding to landscape in the android.R.attr#screenOrientation attribute.

Usage

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

private SharedPreferences restorePreferences() {
    SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
    mPrefHideDueCount = preferences.getBoolean("hideDueCount", false);
    mPrefWhiteboard = preferences.getBoolean("whiteboard", false);
    mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true);
    mPrefTextSelection = preferences.getBoolean("textSelection", true);
    mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false);
    // mDeckFilename = preferences.getString("deckFilename", "");
    mNightMode = preferences.getBoolean("invertedColors", false);
    mInvertedColors = mNightMode;/*from  ww w  .  ja  v a 2  s . co m*/
    mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true);
    mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false);
    mZoomEnabled = preferences.getBoolean("zoom", false);
    mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO);
    mRelativeImageSize = preferences.getInt("relativeImageSize", 100);
    mRelativeButtonSize = preferences.getInt("answerButtonSize", 100);
    mInputWorkaround = preferences.getBoolean("inputWorkaround", false);
    mPrefFixArabic = preferences.getBoolean("fixArabicText", false);
    mPrefForceQuickUpdate = preferences.getBoolean("forceQuickUpdate", false);
    mSpeakText = preferences.getBoolean("tts", false);
    mShowProgressBars = preferences.getBoolean("progressBars", true);
    mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false);
    mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false);
    mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20);
    mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60);
    mScrollingButtons = preferences.getBoolean("scrolling_buttons", false);
    mDoubleScrolling = preferences.getBoolean("double_scrolling", false);
    mPrefCenterVertically = preferences.getBoolean("centerVertically", false);

    mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences);
    if (mGesturesEnabled) {
        mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0"));
        if (mGestureShake != 0) {
            mShakeEnabled = true;
        }
        mShakeIntensity = preferences.getInt("minShakeIntensity", 70);

        mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9"));
        mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0"));
        mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8"));
        mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17"));
        mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7"));
        mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3"));
        mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6"));
        mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12"));
        mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2"));
        mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11"));
    }
    if (mPrefTextSelection && mLongClickWorkaround) {
        mGestureLongclick = GESTURE_LOOKUP;
    }
    mShowAnimations = preferences.getBoolean("themeAnimations", false);
    if (mShowAnimations) {
        int animationDuration = preferences.getInt("animationDuration", 500);
        mAnimationDurationTurn = animationDuration;
        mAnimationDurationMove = animationDuration;
    }

    // allow screen orientation in reviewer only when fix preference is not set
    if (preferences.getBoolean("fixOrientation", false)) {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }

    if (preferences.getBoolean("keepScreenOn", false)) {
        this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    mSimpleInterface = preferences.getBoolean("simpleInterface", false);
    if (mSimpleInterface) {
        String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " ");
        mSimpleInterfaceExcludeTags = new ArrayList<String>();
        for (String t : tags.split(" ")) {
            if (t.length() > 0) {
                mSimpleInterfaceExcludeTags.add(t);
            }
        }
    }

    // These are preferences we pull out of the collection instead of SharedPreferences
    try {
        mShowNextReviewTime = AnkiDroidApp.getCol().getConf().getBoolean("estTimes");
        mShowRemainingCardCount = AnkiDroidApp.getCol().getConf().getBoolean("dueCounts");
    } catch (JSONException e) {
        throw new RuntimeException();
    }

    return preferences;
}

From source file:jmri.enginedriver.threaded_application.java

public boolean setActivityOrientation(Activity activity, Boolean webPref) {
    String to;// w  w w  . j  ava2  s .  c om
    to = prefs.getString("ThrottleOrientation", activity.getApplicationContext().getResources()
            .getString(R.string.prefThrottleOrientationDefaultValue));
    if (to.equals("Auto-Web")) {
        int orient = activity.getResources().getConfiguration().orientation;
        if ((webPref && orient == Configuration.ORIENTATION_PORTRAIT)
                || (!webPref && orient == Configuration.ORIENTATION_LANDSCAPE))
            return (false);
    } else if (webPref) {
        to = prefs.getString("WebOrientation", activity.getApplicationContext().getResources()
                .getString(R.string.prefWebOrientationDefaultValue));
    }

    int co = activity.getRequestedOrientation();
    if (to.equals("Landscape") && (co != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE))
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else if (to.equals("Auto-Rotate") && (co != ActivityInfo.SCREEN_ORIENTATION_SENSOR))
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    else if (to.equals("Portrait") && (co != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT))
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    return true;
}

From source file:com.ichi2.anki2.DeckPicker.java

/** Handles item selections */
@Override/*from   w  w  w.  ja v a 2s.c om*/
public boolean onOptionsItemSelected(MenuItem item) {
    Resources res = getResources();

    switch (item.getItemId()) {

    case MENU_HELP:
        showDialog(DIALOG_SELECT_HELP);
        return true;

    case MENU_SYNC:
        sync();
        return true;

    case MENU_ADD_NOTE:
        addNote();
        return true;

    case MENU_STATISTICS:
        showDialog(DIALOG_SELECT_STATISTICS_TYPE);
        return true;

    case MENU_CARDBROWSER:
        openCardBrowser();
        return true;

    case MENU_CREATE_DECK:
        StyledDialog.Builder builder2 = new StyledDialog.Builder(DeckPicker.this);
        builder2.setTitle(res.getString(R.string.new_deck));

        mDialogEditText = (EditText) new EditText(DeckPicker.this);
        // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter });
        builder2.setView(mDialogEditText, false, false);
        builder2.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                String deckName = mDialogEditText.getText().toString().replaceAll("[\'\"\\n\\r\\[\\]\\(\\)]",
                        "");
                Log.i(AnkiDroidApp.TAG, "Creating deck: " + deckName);
                AnkiDroidApp.getCol().getDecks().id(deckName, true);
                loadCounts();
            }
        });
        builder2.setNegativeButton(res.getString(R.string.cancel), null);
        builder2.create().show();
        return true;

    case MENU_CREATE_DYNAMIC_DECK:
        StyledDialog.Builder builder3 = new StyledDialog.Builder(DeckPicker.this);
        builder3.setTitle(res.getString(R.string.new_deck));

        mDialogEditText = (EditText) new EditText(DeckPicker.this);
        ArrayList<String> names = AnkiDroidApp.getCol().getDecks().allNames();
        int n = 1;
        String cramDeckName = "Cram 1";
        while (names.contains(cramDeckName)) {
            n++;
            cramDeckName = "Cram " + n;
        }
        mDialogEditText.setText(cramDeckName);
        // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter });
        builder3.setView(mDialogEditText, false, false);
        builder3.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                long id = AnkiDroidApp.getCol().getDecks().newDyn(mDialogEditText.getText().toString());
                openStudyOptions(id, new Bundle());
            }
        });
        builder3.setNegativeButton(res.getString(R.string.cancel), null);
        builder3.create().show();
        return true;

    case MENU_ABOUT:
        startActivity(new Intent(DeckPicker.this, Info.class));
        if (AnkiDroidApp.SDK_VERSION > 4) {
            ActivityTransitionAnimation.slide(DeckPicker.this, ActivityTransitionAnimation.RIGHT);
        }
        return true;

    case MENU_ADD_SHARED_DECK:
        if (AnkiDroidApp.getCol() != null) {
            SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
            String hkey = preferences.getString("hkey", "");
            if (hkey.length() == 0) {
                showDialog(DIALOG_USER_NOT_LOGGED_IN_ADD_SHARED_DECK);
            } else {
                addSharedDeck();
            }
        }
        return true;

    case MENU_IMPORT:
        showDialog(DIALOG_IMPORT_HINT);
        return true;

    case MENU_PREFERENCES:
        startActivityForResult(new Intent(DeckPicker.this, Preferences.class), PREFERENCES_UPDATE);
        return true;

    case MENU_FEEDBACK:
        Intent i = new Intent(DeckPicker.this, Feedback.class);
        i.putExtra("request", REPORT_FEEDBACK);
        startActivityForResult(i, REPORT_FEEDBACK);
        if (AnkiDroidApp.SDK_VERSION > 4) {
            ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT);
        }
        return true;

    case CHECK_DATABASE:
        integrityCheck();
        return true;

    case StudyOptionsActivity.MENU_ROTATE:
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        return true;

    case StudyOptionsActivity.MENU_NIGHT:
        SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this);
        if (preferences.getBoolean("invertedColors", false)) {
            preferences.edit().putBoolean("invertedColors", false).commit();
            item.setIcon(R.drawable.ic_menu_night);
        } else {
            preferences.edit().putBoolean("invertedColors", true).commit();
            item.setIcon(R.drawable.ic_menu_night_checked);
        }
        return true;

    case MENU_REUPGRADE:
        restartUpgradeProcess();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.hichinaschool.flashcards.anki.DeckPicker.java

/** Handles item selections */
@Override/*  ww  w. j a v  a2s.c om*/
public boolean onOptionsItemSelected(MenuItem item) {
    Resources res = getResources();

    switch (item.getItemId()) {

    case MENU_HELP:
        showDialog(DIALOG_SELECT_HELP);
        return true;

    case MENU_SYNC:
        sync();
        return true;

    case MENU_ADD_NOTE:
        addNote();
        return true;

    case MENU_STATISTICS:
        showDialog(DIALOG_SELECT_STATISTICS_TYPE);
        return true;

    case MENU_CARDBROWSER:
        openCardBrowser();
        return true;

    case MENU_CREATE_DECK:
        StyledDialog.Builder builder2 = new StyledDialog.Builder(DeckPicker.this);
        builder2.setTitle(res.getString(R.string.new_deck));

        mDialogEditText = (EditText) new EditText(DeckPicker.this);
        // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter });
        builder2.setView(mDialogEditText, false, false);
        builder2.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                String deckName = mDialogEditText.getText().toString().replaceAll("[\'\"\\n\\r\\[\\]\\(\\)]",
                        "");
                // Log.i(AnkiDroidApp.TAG, "Creating deck: " + deckName);
                AnkiDroidApp.getCol().getDecks().id(deckName, true);
                loadCounts();
            }
        });
        builder2.setNegativeButton(res.getString(R.string.cancel), null);
        builder2.create().show();
        return true;

    case MENU_CREATE_DYNAMIC_DECK:
        StyledDialog.Builder builder3 = new StyledDialog.Builder(DeckPicker.this);
        builder3.setTitle(res.getString(R.string.new_deck));

        mDialogEditText = (EditText) new EditText(DeckPicker.this);
        ArrayList<String> names = AnkiDroidApp.getCol().getDecks().allNames();
        int n = 1;
        String cramDeckName = "Cram 1";
        while (names.contains(cramDeckName)) {
            n++;
            cramDeckName = "Cram " + n;
        }
        mDialogEditText.setText(cramDeckName);
        // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter });
        builder3.setView(mDialogEditText, false, false);
        builder3.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                long id = AnkiDroidApp.getCol().getDecks().newDyn(mDialogEditText.getText().toString());
                openStudyOptions(id, new Bundle());
            }
        });
        builder3.setNegativeButton(res.getString(R.string.cancel), null);
        builder3.create().show();
        return true;

    case MENU_ABOUT:
        startActivity(new Intent(DeckPicker.this, Info.class));
        if (AnkiDroidApp.SDK_VERSION > 4) {
            ActivityTransitionAnimation.slide(DeckPicker.this, ActivityTransitionAnimation.RIGHT);
        }
        return true;

    case MENU_ADD_SHARED_DECK:
        if (AnkiDroidApp.getCol() != null) {
            SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
            String hkey = preferences.getString("hkey", "");
            if (hkey.length() == 0) {
                showDialog(DIALOG_USER_NOT_LOGGED_IN_ADD_SHARED_DECK);
            } else {
                addSharedDeck();
            }
        }
        return true;

    case MENU_IMPORT:
        showDialog(DIALOG_IMPORT_HINT);
        return true;

    case MENU_PREFERENCES:
        startActivityForResult(new Intent(DeckPicker.this, Preferences.class), PREFERENCES_UPDATE);
        return true;

    case MENU_FEEDBACK:
        Intent i = new Intent(DeckPicker.this, Feedback.class);
        i.putExtra("request", REPORT_FEEDBACK);
        startActivityForResult(i, REPORT_FEEDBACK);
        if (AnkiDroidApp.SDK_VERSION > 4) {
            ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT);
        }
        return true;

    case CHECK_DATABASE:
        integrityCheck();
        return true;

    case StudyOptionsActivity.MENU_ROTATE:
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        return true;

    case StudyOptionsActivity.MENU_NIGHT:
        SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this);
        if (preferences.getBoolean("invertedColors", false)) {
            preferences.edit().putBoolean("invertedColors", false).commit();
            item.setIcon(R.drawable.ic_menu_night);
        } else {
            preferences.edit().putBoolean("invertedColors", true).commit();
            item.setIcon(R.drawable.ic_menu_night_checked);
        }
        return true;

    case MENU_REUPGRADE:
        restartUpgradeProcess();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.android.launcher2.Launcher.java

private int mapConfigurationOriActivityInfoOri(int configOri) {
    final Display d = getWindowManager().getDefaultDisplay();
    int naturalOri = Configuration.ORIENTATION_LANDSCAPE;
    switch (d.getRotation()) {
    case Surface.ROTATION_0:
    case Surface.ROTATION_180:
        // We are currently in the same basic orientation as the natural orientation
        naturalOri = configOri;/*  ww  w  . ja  v  a 2  s .  c o  m*/
        break;
    case Surface.ROTATION_90:
    case Surface.ROTATION_270:
        // We are currently in the other basic orientation to the natural orientation
        naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ? Configuration.ORIENTATION_PORTRAIT
                : Configuration.ORIENTATION_LANDSCAPE;
        break;
    }

    int[] oriMap = { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE };
    // Since the map starts at portrait, we need to offset if this device's natural orientation
    // is landscape.
    int indexOffset = 0;
    if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
        indexOffset = 1;
    }
    return oriMap[(d.getRotation() + indexOffset) % 4];
}

From source file:com.codename1.impl.android.AndroidImplementation.java

public void lockOrientation(boolean portrait) {
    if (getActivity() == null) {
        return;/*ww w.  j av a 2s . co m*/
    }
    if (portrait) {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

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://from w  w w . j av a2 s  .co m
            break;
        }
    } else {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}