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.air.mobilebrowser.BrowserActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { //Update the device status with the new orientation, and notify int orientation = newConfig.orientation; String orientationString = "none"; if (orientation == Configuration.ORIENTATION_PORTRAIT) { orientationString = "portrait"; } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { orientationString = "landscape"; } else if (orientation == Configuration.ORIENTATION_UNDEFINED) { orientationString = "none"; }// w w w .j a v a2 s .c o m this.mDeviceStatus.orientation = orientationString; super.onConfigurationChanged(newConfig); handleOrientationChange(); }
From source file:it.mb.whatshare.PairOutboundActivity.java
private void showPairingLayout() { View view = getLayoutInflater().inflate(R.layout.activity_qrcode, null); setContentView(view);//from w ww .j av a 2 s. c om String paired = getOutboundPaired(); if (paired != null) { ((TextView) findViewById(R.id.qr_instructions)) .setText(getString(R.string.new_outbound_instructions, paired)); } inputCode = (EditText) findViewById(R.id.inputCode); inputCode.setFilters(new InputFilter[] { new InputFilter() { /* * (non- Javadoc ) * * @see android .text. InputFilter # filter( java .lang. * CharSequence , int, int, android .text. Spanned , int, int) */ @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { if (source instanceof SpannableStringBuilder) { SpannableStringBuilder sourceAsSpannableBuilder = (SpannableStringBuilder) source; for (int i = end - 1; i >= start; i--) { char currentChar = source.charAt(i); if (!Character.isLetterOrDigit(currentChar)) { sourceAsSpannableBuilder.delete(i, i + 1); } } return source; } else { StringBuilder filteredStringBuilder = new StringBuilder(); for (int i = 0; i < end; i++) { char currentChar = source.charAt(i); if (Character.isLetterOrDigit(currentChar)) { filteredStringBuilder.append(currentChar); } } return filteredStringBuilder.toString(); } } }, new InputFilter.LengthFilter(MAX_SHORTENED_URL_LENGTH) }); inputCode.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { onSubmitPressed(null); return keepKeyboardVisible; } return false; } }); final ImageView qrWrapper = (ImageView) findViewById(R.id.qr_code); qrWrapper.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { private boolean createdQRCode = false; @Override public void onGlobalLayout() { if (!createdQRCode) { try { Bitmap qrCode = generateQRCode(generateRandomSeed(), getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? qrWrapper.getHeight() : qrWrapper.getWidth()); if (qrCode != null) { qrWrapper.setImageBitmap(qrCode); } createdQRCode = true; } catch (WriterException e) { e.printStackTrace(); } } } }); }
From source file:com.miz.functions.MizLib.java
/** * Determines if the device is in portrait mode * @param c - Context of the application * @return True if portrait mode, false if landscape mode *//*from w w w . j a v a 2 s . c om*/ public static boolean isPortrait(Context c) { return c != null && (c.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); }
From source file:com.ferid.app.classroom.statistics.StatisticalListActivity.java
/** * Set status bar colour on graph visibility change *///from ww w .java 2 s . co m private void setStatusBarColour() { if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (graphLayout.getVisibility() == View.VISIBLE) { Configuration configuration = getResources().getConfiguration(); if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { window.setStatusBarColor(ContextCompat.getColor(this, R.color.materialLightGreen)); } else if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark)); } } else { window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark)); } } }
From source file:kr.wdream.storyshop.AndroidUtilities.java
public static void lockOrientation(Activity activity) { if (activity == null || prevOrientation != -10) { return;/*from w w w. j a v a 2s .c om*/ } try { prevOrientation = activity.getRequestedOrientation(); WindowManager manager = (WindowManager) activity.getSystemService(Activity.WINDOW_SERVICE); if (manager != null && manager.getDefaultDisplay() != null) { int rotation = manager.getDefaultDisplay().getRotation(); int orientation = activity.getResources().getConfiguration().orientation; if (rotation == Surface.ROTATION_270) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } } else if (rotation == Surface.ROTATION_90) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } else if (rotation == Surface.ROTATION_0) { if (orientation == Configuration.ORIENTATION_LANDSCAPE) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else { if (orientation == Configuration.ORIENTATION_LANDSCAPE) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } } } } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:com.koushikdutta.superuser.FragmentMain.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem mode = menu.add(Menu.NONE, Menu.NONE, 100, R.string.list_mode); mode.setTitle(pref.getBoolean("grid_mode", true) ? R.string.list_mode : R.string.grid_mode); mode.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mode.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//from w ww . j a va 2s. co m public boolean onMenuItemClick(MenuItem menuItem) { if (pref.edit().putBoolean("grid_mode", !pref.getBoolean("grid_mode", true)).commit()) getActivity().recreate(); return true; } }); if (!gridMode) return; MenuItem gridSize = menu.add(Menu.NONE, Menu.NONE, 101, R.string.grid_size); gridSize.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); gridSize.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { int sizePort = pref.getInt("grid_size_port", 3); int sizeLand = pref.getInt("grid_size_land", 4); final AlertDialog.Builder builder = new AlertDialog.Builder(context); View parent = LayoutInflater.from(context).inflate(R.layout.dialog_settings_grid_size, null); final AppCompatSeekBar seekPort = (AppCompatSeekBar) parent.findViewById(R.id.seek_port); seekPort.setProgress(sizePort - 3); final AppCompatSeekBar seekLand = (AppCompatSeekBar) parent.findViewById(R.id.seek_land); seekLand.setProgress(sizeLand - 3); builder.setView(parent); builder.setPositiveButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { SharedPreferences.Editor editor = pref.edit(); editor.putInt("grid_size_port", seekPort.getProgress() + 3); editor.putInt("grid_size_land", seekLand.getProgress() + 3).apply(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { int val = seekPort.getProgress() + 3; layoutManager.setSpanCount(val); callback.onGridSpanChanged(type, val); } else if (getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { int val = seekLand.getProgress() + 3; layoutManager.setSpanCount(val); callback.onGridSpanChanged(type, val); } } }); builder.show(); return true; } }); }
From source file:com.r.raul.tools.MainActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { }// w w w .java 2 s .c om }
From source file:com.farmerbb.secondscreen.util.U.java
public static boolean runSizeCommand(Context context, String requestedRes) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display disp = wm.getDefaultDisplay(); disp.getRealMetrics(metrics);/*from ww w . j a v a2s. c om*/ SharedPreferences prefMain = getPrefMain(context); String currentRes = " "; String nativeRes; if (prefMain.getBoolean("landscape", false)) nativeRes = Integer.toString(prefMain.getInt("height", 0)) + "x" + Integer.toString(prefMain.getInt("width", 0)); else nativeRes = Integer.toString(prefMain.getInt("width", 0)) + "x" + Integer.toString(prefMain.getInt("height", 0)); if (prefMain.getBoolean("debug_mode", false)) { SharedPreferences prefCurrent = getPrefCurrent(context); currentRes = prefCurrent.getString("size", "reset"); if ("reset".equals(currentRes)) currentRes = nativeRes; } else { if ((context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && !prefMain.getBoolean("landscape", false)) || (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && prefMain.getBoolean("landscape", false))) { currentRes = Integer.toString(metrics.widthPixels) + "x" + Integer.toString(metrics.heightPixels); } else if ((context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && !prefMain.getBoolean("landscape", false)) || (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && prefMain.getBoolean("landscape", false))) { currentRes = Integer.toString(metrics.heightPixels) + "x" + Integer.toString(metrics.widthPixels); } } if (requestedRes.equals("reset")) requestedRes = nativeRes; return !requestedRes.equals(currentRes); }
From source file:org.artifactly.client.Artifactly.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); switch (newConfig.orientation) { case Configuration.ORIENTATION_PORTRAIT: callJavaScriptFunction(SHOW_ORIENTATION_PORTRAIT_MODE); break;//from w w w . j a va2 s . c om case Configuration.ORIENTATION_LANDSCAPE: callJavaScriptFunction(SHOW_ORIENTATION_LANDSCAPE_MODE); break; } }
From source file:com.synox.android.ui.fragment.OCFileListFragment.java
/** * Cahnging the layout view , list or grid * * @param viewMode// w w w .j ava 2 s. c o m */ public void layoutView(int viewMode) { int layoutMode = 0; // save list position Parcelable s = getListView().getLayoutManager().onSaveInstanceState(); StorePosition.setParentPosition(mFile.getFileId(), s); switch (viewMode) { case 0: mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false); mAdapter.setResourceLayout(R.layout.list_item); layoutView.setIcon(R.drawable.ic_grid); layoutMode = R.drawable.ic_grid; break; case 1: if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mLayoutManager = new GridLayoutManager(getActivity(), NUMBER_OF_GRID_COLUMNS, GridLayoutManager.VERTICAL, false); } else { mLayoutManager = new GridLayoutManager(getActivity(), NUMBER_OF_GRID_COLUMNS_LANDSCAPE, GridLayoutManager.VERTICAL, false); } mAdapter.setResourceLayout(R.layout.grid_item); layoutView.setIcon(R.drawable.ic_list); layoutMode = R.drawable.ic_list; break; default: mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false); mAdapter.setResourceLayout(R.layout.list_item); layoutView.setIcon(R.drawable.ic_grid); layoutMode = R.drawable.ic_grid; break; } // update current layout mode SharedPreferences.Editor editor = mAppPreferences.edit(); editor.putInt("layoutMode", layoutMode); editor.apply(); mCurrentListView.setLayoutManager(mLayoutManager); // restore list position if (StorePosition.getListPositionList().containsKey(mFile.getFileId())) { Parcelable r = StorePosition.getParentPosition(mFile.getFileId()); getListView().getLayoutManager().onRestoreInstanceState(r); StorePosition.removeParentPosition(mFile.getFileId()); } }