List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT
int ORIENTATION_PORTRAIT
To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.
Click Source Link
From source file:com.hichinaschool.flashcards.anki.DeckPicker.java
/** Handles item selections */ @Override//from www . 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.skytree.epubtest.BookViewActivity.java
public boolean isPortrait() { int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) return true; else//from w ww . j a v a 2s . c om return false; }
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 www . j a v a 2s .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]; }
From source file:com.codename1.impl.android.AndroidImplementation.java
public boolean isPortrait() { int orientation = getContext().getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_UNDEFINED || orientation == Configuration.ORIENTATION_SQUARE) { return super.isPortrait(); }// w w w . java 2 s . c om return orientation == Configuration.ORIENTATION_PORTRAIT; }
From source file:kr.wdream.ui.ChatActivity.java
private boolean fixLayoutInternal() { if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { selectedMessagesCountTextView.setTextSize(18); } else {/*from w w w.j a va2s. co m*/ selectedMessagesCountTextView.setTextSize(20); } if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isSmallTablet() && ApplicationLoader.applicationContext.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { actionBar.setBackButtonDrawable(new BackDrawable(false)); if (playerView != null && playerView.getParent() == null) { ((ViewGroup) fragmentView).addView(playerView, LayoutHelper .createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); } } else { actionBar.setBackButtonDrawable( new BackDrawable(parentLayout == null || parentLayout.fragmentsStack.isEmpty() || parentLayout.fragmentsStack.get(0) == ChatActivity.this || parentLayout.fragmentsStack.size() == 1)); if (playerView != null && playerView.getParent() != null) { fragmentView.setPadding(0, 0, 0, 0); ((ViewGroup) fragmentView).removeView(playerView); } } return false; } return true; }
From source file:com.zoffcc.applications.zanavi.Navit.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (last_orientation != newConfig.orientation) { // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { // setContentView(R.layout.main_layout); // -- bottom bar -- int h = NavitGraphics.mCanvasHeight; try { int h001; android.view.ViewGroup.LayoutParams lp001; View v003 = (View) findViewById(R.id.osd_nextturn_new); h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height); lp001 = v003.getLayoutParams(); lp001.height = h001;// w ww . j a v a2 s .co m v003.requestLayout(); v003 = (View) findViewById(R.id.bottom_bar); h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height); lp001 = v003.getLayoutParams(); lp001.height = h001; v003.requestLayout(); LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view); h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height); lp001 = v002.getLayoutParams(); lp001.height = h001; v002.requestLayout(); v003 = (View) findViewById(R.id.osd_timetodest_new); h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height); lp001 = v003.getLayoutParams(); lp001.height = h001; v003.requestLayout(); v002 = (LinearLayout) findViewById(R.id.bottom_line_container); h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height); lp001 = v002.getLayoutParams(); lp001.height = h001; v002.requestLayout(); RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container); h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height); lp001 = v001.getLayoutParams(); lp001.height = h001; v001.requestLayout(); int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding); int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding); v003 = (View) findViewById(R.id.view_speeding); RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003 .getLayoutParams(); relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom v003.setLayoutParams(relativeParams_001); v003.requestLayout(); smaller_top_bar(true); // Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show(); bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height); bottom_bar_slider_shadow_px = (int) getResources() .getDimension(R.dimen.bottom_slide_view_shadow_compat_height); Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom } catch (Exception e) { Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom } Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch; // -- bottom bar -- } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { // setContentView(R.layout.main_layout); // -- bottom bar -- int h = NavitGraphics.mCanvasHeight; try { int h001; android.view.ViewGroup.LayoutParams lp001; View v003 = (View) findViewById(R.id.osd_nextturn_new); h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height); lp001 = v003.getLayoutParams(); lp001.height = h001; v003.requestLayout(); v003 = (View) findViewById(R.id.bottom_bar); h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height); lp001 = v003.getLayoutParams(); lp001.height = h001; v003.requestLayout(); LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view); h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height); lp001 = v002.getLayoutParams(); lp001.height = h001; v002.requestLayout(); v003 = (View) findViewById(R.id.osd_timetodest_new); h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height); lp001 = v003.getLayoutParams(); lp001.height = h001; v003.requestLayout(); v002 = (LinearLayout) findViewById(R.id.bottom_line_container); h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height); lp001 = v002.getLayoutParams(); lp001.height = h001; v002.requestLayout(); RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container); h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height); lp001 = v001.getLayoutParams(); lp001.height = h001; v001.requestLayout(); int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding); int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding); v003 = (View) findViewById(R.id.view_speeding); RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003 .getLayoutParams(); relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom v003.setLayoutParams(relativeParams_001); v003.requestLayout(); smaller_top_bar(false); // Toast.makeText(this, "protrait", Toast.LENGTH_SHORT).show(); bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height); bottom_bar_slider_shadow_px = (int) getResources() .getDimension(R.dimen.bottom_slide_view_shadow_compat_height); Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom } catch (Exception e) { Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom } Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch; // -- bottom bar -- } last_orientation = newConfig.orientation; } }