List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT
int SCREEN_ORIENTATION_PORTRAIT
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT.
Click Source Link
portrait
in the android.R.attr#screenOrientation attribute. From source file:com.youku.player.base.YoukuBasePlayerActivity.java
@Override public void onFullScreenPlayComplete() { if (null != orientationHelper) orientationHelper.disableListener(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) private int getScreenOrientation() { switch (getScreenRotation()) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_180: // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API Level 9+ return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); case Surface.ROTATION_270: // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API Level 9+ return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); default://from w w w . java 2s. c o m return 0; } }
From source file:com.ichi2.anki2.Reviewer.java
private SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mPrefWhiteboard = preferences.getBoolean("whiteboard", false); mPrefRecord = preferences.getBoolean("record", 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 w w w .j ava 2 s. c o m mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false); mshowNextReviewTime = preferences.getBoolean("showNextReviewTime", true); mZoomEnabled = preferences.getBoolean("zoom", false); mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mPrefFixArabic = preferences.getBoolean("fixArabicText", 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); 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); } } } return preferences; }
From source file:com.nit.vicky.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;/* ww w .ja v a 2s .c o 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", true); 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: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 w w w. j av a2s .c om*/ 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;/*from w ww. j a v a 2s . c o m*/ 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 ww . jav a2 s . c o m 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 a 2 s.c o m*/ 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;/*from w w w .j av a2s .co 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]; }