List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE
int ORIENTATION_LANDSCAPE
To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.
Click Source Link
From source file:com.vest.album.fragment.CameraVideoFragment.java
/** * Tries to open a {@link CameraDevice}. The result is listened by `mStateCallback`. *///from w w w . jav a2 s . c o m private void openCamera(int width, int height) { if (!hasPermissionsGranted(VIDEO_PERMISSIONS)) { requestVideoPermissions(); return; } final Activity activity = getActivity(); if (null == activity || activity.isFinishing()) { return; } CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE); try { Log.d(TAG, "tryAcquire"); if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) { throw new RuntimeException("Time out waiting to lock camera opening."); } String cameraId = manager.getCameraIdList()[0]; // Choose the sizes for camera preview and video recording CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); mVideoSize = chooseVideoSize(map.getOutputSizes(MediaRecorder.class)); mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height, mVideoSize); int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } else { mTextureView.setAspectRatio(mPreviewSize.getHeight(), mPreviewSize.getWidth()); } configureTransform(width, height); mMediaRecorder = new MediaRecorder(); manager.openCamera(cameraId, mStateCallback, null); } catch (CameraAccessException e) { callback.onVideoError("!"); activity.finish(); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. ErrorDialog.newInstance(getString(R.string.camera_error)).show(getChildFragmentManager(), FRAGMENT_DIALOG); } catch (InterruptedException e) { throw new RuntimeException("Interrupted while trying to lock camera opening."); } catch (SecurityException e) { } }
From source file:com.vnapnic.streamgames.ui.TDActivity.java
private void onOrientationChange(int orientation) { if (orientation == Configuration.ORIENTATION_LANDSCAPE) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getSupportActionBar().hide();/*from w ww.java2 s.co m*/ } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getSupportActionBar().show(); } }
From source file:com.grarak.kerneladiutor.fragments.RecyclerViewFragment.java
public int getSpanCount() { Activity activity;//from w w w .j av a 2s .co m if ((activity = getActivity()) != null) { int span = Utils.isTablet(activity) ? Utils.getOrientation(activity) == Configuration.ORIENTATION_LANDSCAPE ? 3 : 2 : Utils.getOrientation(activity) == Configuration.ORIENTATION_LANDSCAPE ? 2 : 1; if (itemsSize() != 0 && span > itemsSize()) { span = itemsSize(); } return span; } return 1; }
From source file:com.secbro.qark.filebrowser.FileBrowserFragment.java
public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Log.d(LOGTAG, "ORIENTATION_LANDSCAPE"); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d(LOGTAG, "ORIENTATION_PORTRAIT"); }//from w ww . jav a2 s .com // Layout apparently changes itself, only have to provide good onMeasure // in custom components // TODO: check with keyboard // if(newConfig.keyboard == Configuration.KEYBOARDHIDDEN_YES) }
From source file:com.doctoror.fuckoffmusicplayer.presentation.queue.QueueActivity.java
private void prepareViewsAndExit(@NonNull final Runnable exitAction) { if (!TransitionUtils.supportsActivityTransitions() || (fab.getScaleX() == 0f && albumArtDim.getAlpha() == 0f)) { exitAction.run();/* w ww .j ava 2 s . c o m*/ } else { final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; // Landscape Now Playing has a dim, so dim the ImageView and send it if (isLandscape) { albumArtDim.setAlpha(0f); albumArt.setColorFilter(ContextCompat.getColor(this, R.color.translucentBackground), PorterDuff.Mode.SRC_ATOP); } else { // Portrait NowPlaying does not have a dim. Fade out the dim before animating. albumArtDim.animate().alpha(0f).setDuration(mShortAnimTime).start(); } fab.animate().scaleX(0f).scaleY(0f).setDuration(mShortAnimTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { exitAction.run(); } }).start(); } }
From source file:com.duinopeak.balanbot.BalanbotActivity.java
@Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { if (D)/*from w w w.j a va2s . co m*/ Log.d(TAG, "onTabSelected: " + tab.getPosition()); currentTabSelected = tab.getPosition(); Resources mResources = getResources(); if (mResources.getBoolean(R.bool.isTablet) && mResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && currentTabSelected == ViewPagerAdapter.INFO_FRAGMENT) { // Check if the last tab is selected in landscape mode currentTabSelected -= 1; // If so don't go any further ActionBar bar = getSupportActionBar(); bar.selectTab(bar.getTabAt(currentTabSelected)); } mUnderlinePageIndicator.setCurrentItem(currentTabSelected); // When the given tab is selected, switch to the corresponding page in the ViewPager CustomViewPager.setPagingEnabled(true); if (checkTab(ViewPagerAdapter.GRAPH_FRAGMENT) && mChatService != null) { if (mChatService.getState() == BluetoothChatService.STATE_CONNECTED) { mChatService.write(getKalman); if (GraphFragment.mToggleButton != null) { if (GraphFragment.mToggleButton.isChecked()) mChatService.write(imuBegin); // Request data else mChatService.write(imuStop); // Stop sending data } } } else if (checkTab(ViewPagerAdapter.INFO_FRAGMENT) && mChatService != null) { if (mChatService.getState() == BluetoothChatService.STATE_CONNECTED) { mChatService.write(getInfo); // Update info if (InfoFragment.mToggleButton != null) { if (InfoFragment.mToggleButton.isChecked()) mChatService.write(statusBegin); // Request data else mChatService.write(statusStop); // Stop sending data } } } if (!checkTab(ViewPagerAdapter.GRAPH_FRAGMENT)) { // Needed when the user rotates the screen InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Hide the keyboard imm.hideSoftInputFromWindow(getWindow().getDecorView().getApplicationWindowToken(), 0); } }
From source file:com.android.launcher2.AsyncTaskCallback.java
protected void onDataReady(int width, int height) { // Note that we transpose the counts in portrait so that we get a similar layout boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; int maxCellCountX = Integer.MAX_VALUE; int maxCellCountY = Integer.MAX_VALUE; if (LauncherApplication.isScreenLarge()) { maxCellCountX = (isLandscape ? LauncherModel.getCellCountX() : LauncherModel.getCellCountY()); maxCellCountY = (isLandscape ? LauncherModel.getCellCountY() : LauncherModel.getCellCountX()); }/*w w w . j a v a 2 s. co m*/ if (mMaxAppCellCountX > -1) { maxCellCountX = Math.min(maxCellCountX, mMaxAppCellCountX); } // Temp hack for now: only use the max cell count Y for widget layout int maxWidgetCellCountY = maxCellCountY; if (mMaxAppCellCountY > -1) { maxWidgetCellCountY = Math.min(maxWidgetCellCountY, mMaxAppCellCountY); } // Now that the data is ready, we can calculate the content width, the number of cells to // use for each page mWidgetSpacingLayout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap); mWidgetSpacingLayout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight, mPageLayoutPaddingBottom); mWidgetSpacingLayout.calculateCellCount(width, height, maxCellCountX, maxCellCountY); mCellCountX = mWidgetSpacingLayout.getCellCountX(); mCellCountY = mWidgetSpacingLayout.getCellCountY(); updatePageCounts(); // Force a measure to update recalculate the gaps int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST); int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST); mWidgetSpacingLayout.calculateCellCount(width, height, maxCellCountX, maxWidgetCellCountY); mWidgetSpacingLayout.measure(widthSpec, heightSpec); mContentWidth = mWidgetSpacingLayout.getContentWidth(); AppsCustomizeTabHost host = getTabHost(); final boolean hostIsTransitioning = host.isTransitioning(); // Restore the page int page = getPageForComponent(mSaveInstanceStateItemIndex); invalidatePageData(Math.max(0, page), hostIsTransitioning); // Show All Apps cling if we are finished transitioning, otherwise, we will try again when // the transition completes in AppsCustomizeTabHost (otherwise the wrong offsets will be // returned while animating) if (!hostIsTransitioning) { post(new Runnable() { @Override public void run() { showAllAppsCling(); } }); } }
From source file:com.android.dialer.DialtactsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Trace.beginSection(TAG + " onCreate"); super.onCreate(savedInstanceState); mFirstLaunch = true;/*w w w . ja v a 2 s .co m*/ final Resources resources = getResources(); mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large); Trace.beginSection(TAG + " setContentView"); setContentView(R.layout.dialtacts_activity); Trace.endSection(); getWindow().setBackgroundDrawable(null); Trace.beginSection(TAG + " setup Views"); final ActionBar actionBar = getSupportActionBar(); actionBar.setCustomView(R.layout.search_edittext); actionBar.setDisplayShowCustomEnabled(true); actionBar.setBackgroundDrawable(null); SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView() .findViewById(R.id.search_view_container); searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener); mActionBarController = new ActionBarController(this, searchEditTextLayout); mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button); searchEditTextLayout.findViewById(R.id.search_magnifying_glass) .setOnClickListener(mSearchViewOnClickListener); searchEditTextLayout.findViewById(R.id.search_box_start_search) .setOnClickListener(mSearchViewOnClickListener); searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener); searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() { @Override public void onBackButtonClicked() { onBackPressed(); } @Override public void onSearchViewClicked() { // Hide FAB, as the keyboard is shown. mFloatingActionButtonController.scaleOut(); } }); mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; mPreviouslySelectedTabIndex = ListsFragment.TAB_INDEX_SPEED_DIAL; final View floatingActionButtonContainer = findViewById(R.id.floating_action_button_container); ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button); floatingActionButton.setOnClickListener(this); mFloatingActionButtonController = new FloatingActionButtonController(this, floatingActionButtonContainer, floatingActionButton); ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout .findViewById(R.id.dialtacts_options_menu_button); optionsMenuButton.setOnClickListener(this); mOverflowMenu = buildOptionsMenu(searchEditTextLayout); optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); // Add the favorites fragment but only if savedInstanceState is null. Otherwise the // fragment manager is responsible for recreating it. if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT).commit(); } else { mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY); mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI); mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI); mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH); mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN); mActionBarController.restoreInstanceState(savedInstanceState); } final boolean isLayoutRtl = DialerUtils.isRtl(); if (mIsLandscape) { mSlideIn = AnimationUtils.loadAnimation(this, isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right); mSlideOut = AnimationUtils.loadAnimation(this, isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right); } else { mSlideIn = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_in_bottom); mSlideOut = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_out_bottom); } mSlideIn.setInterpolator(AnimUtils.EASE_IN); mSlideOut.setInterpolator(AnimUtils.EASE_OUT); mSlideIn.setAnimationListener(mSlideInListener); mSlideOut.setAnimationListener(mSlideOutListener); mParentLayout = (CoordinatorLayout) findViewById(R.id.dialtacts_mainlayout); mParentLayout.setOnDragListener(new LayoutOnDragListener()); floatingActionButtonContainer.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { final ViewTreeObserver observer = floatingActionButtonContainer.getViewTreeObserver(); if (!observer.isAlive()) { return; } observer.removeOnGlobalLayoutListener(this); int screenWidth = mParentLayout.getWidth(); mFloatingActionButtonController.setScreenWidth(screenWidth); mFloatingActionButtonController.align(getFabAlignment(), false /* animate */); } }); Trace.endSection(); Trace.beginSection(TAG + " initialize smart dialing"); mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this); SmartDialPrefix.initializeNanpSettings(this); Trace.endSection(); Trace.endSection(); }
From source file:com.example.zhang1ks.testbottombar.Camera2VideoFragment.java
/** * Tries to open a {@link CameraDevice}. The result is listened by `mStateCallback`. *///ww w .j a va 2s . c o m private void openCamera(int width, int height) { if (!hasPermissionsGranted(VIDEO_PERMISSIONS)) { requestVideoPermissions(); return; } final Activity activity = getActivity(); if (null == activity || activity.isFinishing()) { return; } CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE); try { Log.d(TAG, "tryAcquire"); if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) { throw new RuntimeException("Time out waiting to lock camera opening."); } String cameraId = mCameraId; // Choose the sizes for camera preview and video recording CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); mVideoSize = chooseVideoSize(map.getOutputSizes(MediaRecorder.class)); mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height, mVideoSize); int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } else { mTextureView.setAspectRatio(mPreviewSize.getHeight(), mPreviewSize.getWidth()); } configureTransform(width, height); mMediaRecorder = new MediaRecorder(); manager.openCamera(cameraId, mStateCallback, null); } catch (CameraAccessException e) { Toast.makeText(activity, "Cannot access the camera.", Toast.LENGTH_SHORT).show(); activity.finish(); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. ErrorDialog.newInstance(getString(R.string.camera_error)).show(getChildFragmentManager(), FRAGMENT_DIALOG); } catch (InterruptedException e) { throw new RuntimeException("Interrupted while trying to lock camera opening."); } }
From source file:com.tzutalin.vision.demo.Camera2BasicFragment.java
/** * Sets up member variables related to camera. * * @param width The width of available size for camera preview * @param height The height of available size for camera preview *//*from w w w . ja v a 2 s.c o m*/ private void setUpCameraOutputs(int width, int height) { Activity activity = getActivity(); CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE); try { for (String cameraId : manager.getCameraIdList()) { CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; } StreamConfigurationMap map = characteristics .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // For still image captures, we use the largest available size. Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea()); mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, /*maxImages*/2); mImageReader.setOnImageAvailableListener(mOnImageAvailableListener, mBackgroundHandler); // Danger, W.R.! Attempting to use too large a preview size could exceed the camera // bus' bandwidth limitation, resulting in gorgeous previews but the storage of // garbage capture data. mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height, largest); // We fit the aspect ratio of TextureView to the size of preview we picked. int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } else { mTextureView.setAspectRatio(mPreviewSize.getHeight(), mPreviewSize.getWidth()); } mCameraId = cameraId; return; } } catch (CameraAccessException e) { e.printStackTrace(); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. ErrorDialog.newInstance(getString(R.string.camera_error)).show(getChildFragmentManager(), FRAGMENT_DIALOG); } }