List of usage examples for android.view Surface ROTATION_270
int ROTATION_270
To view the source code for android.view Surface ROTATION_270.
Click Source Link
From source file:Main.java
/** * Calculates the clockwise rotation applied to the camera such that the picture will be aligned with the screen * orientation.//ww w.j a v a2 s . c o m * * @param activity the {@link Activity}. * @param cameraId id of the camera. * @return the clockwise rotation in degrees. */ public static int getCameraScreenOrientation(Activity activity, int cameraId) { int cameraScreenOrientation = CAMERA_SCREEN_ORIENTATION_0; // Get camera info. CameraInfo info = new CameraInfo(); Camera.getCameraInfo(cameraId, info); // Get screen orientation. int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = SCREEN_ROTATION_0; switch (rotation) { case Surface.ROTATION_0: degrees = SCREEN_ROTATION_0; break; case Surface.ROTATION_90: degrees = SCREEN_ROTATION_90; break; case Surface.ROTATION_180: degrees = SCREEN_ROTATION_180; break; case Surface.ROTATION_270: degrees = SCREEN_ROTATION_270; break; } /* * Calculate result based on camera and screen orientation. */ if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { // Calculate relative rotation between camera and screen. cameraScreenOrientation = (info.orientation + degrees) % 360; // Account for mirroring. cameraScreenOrientation = (360 - cameraScreenOrientation) % 360; } else { // Calculate relative rotation between camera and screen. cameraScreenOrientation = (info.orientation - degrees + 360) % 360; } return cameraScreenOrientation; }
From source file:org.chromium.ChromeSystemDisplay.java
private int getRotation(final Display display) { final int rotation = display.getRotation(); final int DEFAULT_ROTATION = 0; if (rotation == Surface.ROTATION_0) { return 0; } else if (rotation == Surface.ROTATION_90) { return 90; } else if (rotation == Surface.ROTATION_180) { return 180; } else if (rotation == Surface.ROTATION_270) { return 270; }/* ww w . j av a2s. c o m*/ return DEFAULT_ROTATION; }
From source file:com.mruddy.devdataviewer.DevDataListFragment.java
@SuppressLint("InlinedApi") private static void initMaps() { DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_LOW, "LDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_MEDIUM, "MDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_HIGH, "HDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XHIGH, "XHDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXHIGH, "XXHDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXXHIGH, "XXXHDPI"); DevDataListFragment.ROTATION.append(Surface.ROTATION_0, "0"); DevDataListFragment.ROTATION.append(Surface.ROTATION_90, "90"); DevDataListFragment.ROTATION.append(Surface.ROTATION_180, "180"); DevDataListFragment.ROTATION.append(Surface.ROTATION_270, "270"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_UNDEFINED, "undefined"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_PORTRAIT, "portrait"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_LANDSCAPE, "landscape"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_UNDEFINED, "undefined"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_SMALL, "small"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_NORMAL, "normal"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_LARGE, "large"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_XLARGE, "xlarge"); }
From source file:org.jitsi.android.gui.chat.ChatActivity.java
/** * Called when the activity is starting. Initializes the corresponding * call interface.//from w w w . j a v a 2 s . c om * * @param savedInstanceState If the activity is being re-initialized after * previously being shut down then this Bundle contains the data it most * recently supplied in onSaveInstanceState(Bundle). * Note: Otherwise it is null. */ @Override protected void onCreate(Bundle savedInstanceState) { // Use SOFT_INPUT_ADJUST_PAN mode only in horizontal orientation, which // doesn't provide enough space to write messages comfortably. // Adjust pan is causing copy-paste options not being displayed as well // as the action bar which contains few useful options. int rotation = getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } super.onCreate(savedInstanceState); setContentView(R.layout.chat); // If chat notification has been clicked and OSGi service // has been killed in the meantime then we have to start it and // restore this activity if (postRestoreIntent()) { return; } // Instantiate a ViewPager and a PagerAdapter. chatPager = (ViewPager) findViewById(R.id.chatPager); chatPagerAdapter = new ChatPagerAdapter(getSupportFragmentManager(), this); chatPager.setAdapter(chatPagerAdapter); chatPager.setOffscreenPageLimit(4); chatPager.setOnPageChangeListener(this); if (savedInstanceState == null) { // OTR menu padlock getSupportFragmentManager().beginTransaction().add(new OtrFragment(), "otr_fragment").commit(); } handleIntent(getIntent(), savedInstanceState); }
From source file:me.wimanacra.collector.DisplayManagerCollector.java
@NonNull private static String rotationToString(int rotation) { switch (rotation) { case Surface.ROTATION_0: return "ROTATION_0"; case Surface.ROTATION_90: return "ROTATION_90"; case Surface.ROTATION_180: return "ROTATION_180"; case Surface.ROTATION_270: return "ROTATION_270"; default://from w w w . j av a 2 s . co m return String.valueOf(rotation); } }
From source file:com.thelastcrusade.soundstream.components.ConnectFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_connect, container, false); ((CoreActivity) getActivity()).hidePlaybar(); int rotation = getActivity().getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { ((LinearLayout) v).setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams clickableParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1); clickableParams.setMargins(5, 10, 10, 10); v.findViewById(R.id.join).setLayoutParams(clickableParams); clickableParams.setMargins(10, 10, 5, 10); v.findViewById(R.id.create).setLayoutParams(clickableParams); } else {/*from w w w. j ava 2 s . com*/ ((LinearLayout) v).setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams clickableParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1); clickableParams.setMargins(10, 5, 10, 10); v.findViewById(R.id.join).setLayoutParams(clickableParams); clickableParams.setMargins(10, 10, 10, 5); v.findViewById(R.id.create).setLayoutParams(clickableParams); } View create = v.findViewById(R.id.create); create.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Transitions.transitionToHome((CoreActivity) getActivity()); ((CoreActivity) getActivity()).enableSlidingMenu(); //add the playbar fragment onto the active content view ((CoreActivity) getActivity()).showPlaybar(); } }); create.setContentDescription(ContentDescriptionUtils.CREATE); this.joinView = v.findViewById(R.id.join); this.joinView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new WithBluetoothEnabled(getActivity(), getConnectionService()).run(new Runnable() { @Override public void run() { getConnectionService().broadcastSelfAsGuest(getActivity()); } }); } }); joinView.setContentDescription(ContentDescriptionUtils.CONNECT); TextView joinText = (TextView) v.findViewById(R.id.join_network_id); joinText.setText(String.format(getString(R.string.join_network), BluetoothUtils.getLocalBluetoothName())); if (savedInstanceState != null) { isSearching = savedInstanceState.getBoolean(SEARCHING_TAG); if (isSearching) setJoinToSearchingState(); } return v; }
From source file:com.poloure.simplerss.FeedsActivity.java
/** * Checks to see if the default Display in the WindowManager is rotated horizontally. * * @return true if the display is currently rotated horizontally, false otherwise. */// www . jav a 2 s . c o m private static boolean isDisplayHorizontal() { Display display = s_windowManager.getDefaultDisplay(); int rotation = display.getRotation(); return Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation; }
From source file:piuk.blockchain.android.ui.zxing.CaptureActivity.java
private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; default://from w w w .j a va 2s. co m return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;//reverse-mounted cameras on devices like the Nexus 5X } }
From source file:com.jwork.spycamera.SpyCamActivity.java
private void getDefaultOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); //If Naturally landscape (tablets) log.v(this, "Display pixels: " + dm.widthPixels + "x" + dm.heightPixels + "|Rotation:" + rotation); if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && dm.widthPixels > dm.heightPixels) || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && dm.widthPixels < dm.heightPixels)) { rotation += 1;//from w w w. j a va 2 s . c om if (rotation > 3) { rotation = 0; } } switch (rotation) { case Surface.ROTATION_0: defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_90: if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; } else { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; setRequestedOrientation(defaultOrientation); } break; case Surface.ROTATION_180: if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } else { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; setRequestedOrientation(defaultOrientation); } break; case Surface.ROTATION_270: if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } else { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; setRequestedOrientation(defaultOrientation); } break; } }
From source file:org.kontalk.util.SystemUtils.java
/** * Returns the correct screen orientation based on the supposedly preferred * position of the device.// w w w .ja va 2 s . c o m * http://stackoverflow.com/a/16585072/1045199 */ public static int getScreenOrientation(Activity activity) { WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); Configuration configuration = activity.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); // Search for the natural position of the device if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) || configuration.orientation == Configuration.ORIENTATION_PORTRAIT && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) { // Natural position is Landscape switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; case Surface.ROTATION_180: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } } else { // Natural position is Portrait switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_180: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } } return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; }