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.cw.litenote.util.video.UtilVideo.java
public static void setVideoViewDimensions(BitmapDrawable bitmapDrawable) { int screenHeight = UtilImage.getScreenHeight(mAct); int screenWidth = UtilImage.getScreenWidth(mAct); // System.out.println("UtilVideo / _setVideoViewDimensions / screenHeight = " + screenHeight + ", screenWidth = " + screenWidth); int bitmapHeight = 0, bitmapWidth = 0; int config_orientation = mAct.getResources().getConfiguration().orientation; Bitmap bitmap = bitmapDrawable.getBitmap(); boolean bitmapIsLandScape = false; boolean bitmapIsPortrait = false; if (bitmap != null) { bitmapHeight = bitmap.getHeight(); bitmapWidth = bitmap.getWidth(); System.out.println("UtilVideo / _setVideoViewDimensions / bitmapHeight = " + bitmapHeight + ", bitmapWidth = " + bitmapWidth); bitmapIsLandScape = (bitmapWidth > bitmapHeight) ? true : false; bitmapIsPortrait = (bitmapHeight > bitmapWidth) ? true : false; // System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsLandScape 1 = " + bitmapIsLandScape); // System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsPortrait 1 = " + bitmapIsPortrait); } else {//from w ww .ja v a2s . c o m // for remote video which there is no way to get bitmap yet // default dimension bitmapWidth = screenWidth; bitmapHeight = screenHeight / 2; // default orientation is landscape AsyncTaskVideoBitmapPager.mRotationStr = "0"; // } String rotDeg = AsyncTaskVideoBitmapPager.mRotationStr; if (rotDeg != null) { System.out.println("UtilVideo / _setVideoViewDimensions / rotDeg = " + rotDeg); if (rotDeg.equalsIgnoreCase("0")) { bitmapIsLandScape = true; bitmapIsPortrait = false; } else if (rotDeg.equalsIgnoreCase("90")) { bitmapIsLandScape = false; bitmapIsPortrait = true; } } // System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsLandScape 2 = " + bitmapIsLandScape); // System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsPortrait 2 = " + bitmapIsPortrait); int dimWidth = 0; int dimHeight = 0; // for landscape screen if (config_orientation == Configuration.ORIENTATION_LANDSCAPE) { // for landscape bitmap if (bitmapIsLandScape) { System.out.println("UtilVideo / _setVideoViewDimensions / L_scr L_bmp"); dimWidth = screenWidth; dimHeight = screenHeight; } // for portrait bitmap else if (bitmapIsPortrait) { System.out.println("UtilVideo / _setVideoViewDimensions / L_scr P_bmp"); // set screen height to be constant, and set screen width by proportional int propotionalWidth = 0; if (bitmap != null) { propotionalWidth = (bitmapWidth > bitmapHeight) ? Math.round(screenHeight * bitmapHeight / bitmapWidth) : Math.round(screenHeight * bitmapWidth / bitmapHeight); } else propotionalWidth = Math.round(screenHeight * screenHeight / screenWidth); dimWidth = propotionalWidth; dimHeight = screenHeight; } } // for portrait screen else if (config_orientation == Configuration.ORIENTATION_PORTRAIT) { // for landscape bitmap if (bitmapIsLandScape) { System.out.println("UtilVideo / _setVideoViewDimensions / P_scr L_bmp"); // set screen width to be constant, and set screen height by proportional int propotiaonalHeight = 0; if (bitmap != null) { propotiaonalHeight = (bitmapWidth > bitmapHeight) ? Math.round(screenWidth * bitmapHeight / bitmapWidth) : Math.round(screenWidth * bitmapWidth / bitmapHeight); } else propotiaonalHeight = Math.round(screenWidth * screenWidth / screenHeight); dimWidth = screenWidth; dimHeight = propotiaonalHeight; } // for portrait bitmap else if (bitmapIsPortrait) { System.out.println("UtilVideo / _setVideoViewDimensions / P_scr P_bmp"); dimWidth = screenWidth; dimHeight = screenHeight; } } // set dimensions if (UtilVideo.mVideoView != null) { UtilVideo.mVideoView.setDimensions(dimWidth, dimHeight); UtilVideo.mVideoView.getHolder().setFixedSize(dimWidth, dimHeight); System.out.println("UtilVideo / _setVideoViewDimensions / dim Width = " + dimWidth + ", dim Height = " + dimHeight); } }
From source file:dev.ronlemire.validation.MainActivity.java
public void StartHintsFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) { Fragment hintsFragment = (Fragment) fm.findFragmentById(R.id.detail_replacer); hintsFragment = HintsFragment.newInstance("Hints"); FragmentTransaction transaction = fm.beginTransaction().replace(R.id.detail_replacer, hintsFragment); transaction.addToBackStack(null); transaction.commit();/*www . j a v a2 s . co m*/ } else { HintsFragment hintsFragment = HintsFragment.newInstance("Hints"); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction() .replace(MainActivity.validationListView.getId(), hintsFragment); transaction.addToBackStack(null); transaction.commit(); } }
From source file:dev.ronlemire.validation.MainActivity.java
public void StartHintsFragment() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {/* ww w . j a v a 2s . c om*/ Fragment hintsFragment = (Fragment) fm .findFragmentById(R.id.detail_replacer); hintsFragment = HintsFragment.newInstance("Hints"); FragmentTransaction transaction = fm.beginTransaction() .replace(R.id.detail_replacer, hintsFragment); transaction.addToBackStack(null); transaction.commit(); } else { HintsFragment hintsFragment = HintsFragment .newInstance("Hints"); FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction() .replace(MainActivity.validationListView.getId(), hintsFragment); transaction.addToBackStack(null); transaction.commit(); } }
From source file:com.tdispatch.passenger.core.TDApplication.java
@SuppressWarnings("deprecation") protected void initEnvInfo() { DisplayMetrics dm = getResources().getDisplayMetrics(); String orientation = "???"; switch (getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_LANDSCAPE: orientation = "Landscape"; break;/*from w w w .ja v a2s. c o m*/ case Configuration.ORIENTATION_PORTRAIT: orientation = "Portrait"; break; case Configuration.ORIENTATION_SQUARE: orientation = "Square"; break; case Configuration.ORIENTATION_UNDEFINED: orientation = "Undef"; break; default: orientation = "Unknown"; break; } try { mEnvInfoJson.put("type", isTablet() ? "tablet" : "phone"); mEnvInfoJson.put("build_manufacturer", Build.MANUFACTURER); mEnvInfoJson.put("build_model", Build.MODEL); mEnvInfoJson.put("build_board", Build.BOARD); mEnvInfoJson.put("build_device", Build.DEVICE); mEnvInfoJson.put("build_product", Build.PRODUCT); mEnvInfoJson.put("api", Build.VERSION.SDK_INT + " (" + Build.VERSION.RELEASE + ")"); mEnvInfoJson.put("screen", dm.widthPixels + "x" + dm.heightPixels + " (" + dm.densityDpi + "DPI) " + orientation); mEnvInfoJson.put("locale", Locale.getDefault()); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.landenlabs.all_devtool.DevToolActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (GlobalInfo.s_globalInfo.isLockedOrientation) { setRequestedOrientation(GlobalInfo.s_globalInfo.lockedOrientation); }/* w w w.j a v a2 s . co m*/ // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Toast.makeText(this, "Landscape", Toast.LENGTH_SHORT).show(); // GlobalInfo.s_globalInfo.tabAdapter.m_actionBar.hide(); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { Toast.makeText(this, "Portrait", Toast.LENGTH_SHORT).show(); // GlobalInfo.s_globalInfo.tabAdapter.m_actionBar.show(); } }
From source file:com.jinfukeji.jinyihuiup.indexBannerClick.ZhiboActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); this.setContentView(R.layout.activity_zhibo); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); screen_direction = SCREEN_LAND;/*from ww w . j a v a 2 s .c o m*/ initLandView(); setLandOnClick(); isShowLayout = true; if (isPlayed) { player.leave(); player.setGSVideoView(mGSzhiboLand); initplayer(); mivPlayLand.setVisibility(View.GONE); } } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); this.setContentView(R.layout.activity_zhibo); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); screen_direction = SCREEN_PORT; initView(); zhibo_viewpager.addOnPageChangeListener(new ZhiboOnPageChangeListener()); initClickListener(); zhiboVPAdapter = new ZhiboVPAdapter(getSupportFragmentManager(), mFragments); zhibo_viewpager.setAdapter(zhiboVPAdapter); setOnClick(); isShowLayout = true; if (isPlayed) { mIvplayer.setVisibility(View.GONE); player.leave(); player.setGSVideoView(mGSzhibo); initplayer(); } } }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device orientation. *///from w w w . j a va 2 s . c o m static String getOrientation(Context context) { int orientation = context.getResources().getConfiguration().orientation; switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: return "Landscape"; case Configuration.ORIENTATION_PORTRAIT: return "Portrait"; case Configuration.ORIENTATION_SQUARE: return "Square"; case Configuration.ORIENTATION_UNDEFINED: return "Unknown"; default: return null; } }
From source file:com.deltadna.android.sdk.ImageMessage.java
/** * Recalculates the layouts, assumes that the larger dimension will be * portrait vertical.//www .j av a 2 s . co m */ void init(int orientation, int screenWidth, int screenHeight) { // calculate landscape/portrait based on given widths and heights final int realWidth = screenWidth < screenHeight ? screenWidth : screenHeight; final int realHeight = screenHeight > screenWidth ? screenHeight : screenWidth; // pass screen width and height to background background.init(orientation, realWidth, realHeight); for (int i = 0; i < buttons.size(); i++) { buttons.get(i).init(orientation, background.layout(Configuration.ORIENTATION_PORTRAIT), background.layout(Configuration.ORIENTATION_LANDSCAPE)); } }
From source file:com.farmerbb.taskbar.service.DashboardService.java
@SuppressLint("RtlHardcoded") private void drawDashboard() { windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT);/* w ww. java 2s.com*/ // Initialize views layout = new LinearLayout(this); layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.setVisibility(View.GONE); layout.setAlpha(0); SharedPreferences pref = U.getSharedPreferences(this); int width = pref.getInt("dashboard_width", getApplicationContext().getResources().getInteger(R.integer.dashboard_width)); int height = pref.getInt("dashboard_height", getApplicationContext().getResources().getInteger(R.integer.dashboard_height)); boolean isPortrait = getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isLandscape = getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; if (isPortrait) { columns = height; rows = width; } if (isLandscape) { columns = width; rows = height; } maxSize = columns * rows; int backgroundTint = U.getBackgroundTint(this); int accentColor = U.getAccentColor(this); int accentColorAlt = accentColor; accentColorAlt = ColorUtils.setAlphaComponent(accentColorAlt, Color.alpha(accentColorAlt) / 2); int cellCount = 0; for (int i = 0; i < columns; i++) { LinearLayout layout2 = new LinearLayout(this); layout2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1)); layout2.setOrientation(LinearLayout.VERTICAL); for (int j = 0; j < rows; j++) { DashboardCell cellLayout = (DashboardCell) View.inflate(this, R.layout.dashboard, null); cellLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1)); cellLayout.setBackgroundColor(backgroundTint); cellLayout.setOnClickListener(cellOcl); cellLayout.setOnHoverListener(cellOhl); TextView empty = (TextView) cellLayout.findViewById(R.id.empty); empty.setBackgroundColor(accentColorAlt); empty.setTextColor(accentColor); Bundle bundle = new Bundle(); bundle.putInt("cellId", cellCount); cellLayout.setTag(bundle); cells.put(cellCount, cellLayout); cellCount++; layout2.addView(cellLayout); } layout.addView(layout2); } mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID); mAppWidgetHost.startListening(); for (int i = 0; i < maxSize; i++) { int appWidgetId = pref.getInt("dashboard_widget_" + Integer.toString(i), -1); if (appWidgetId != -1) addWidget(appWidgetId, i, false); else if (pref.getBoolean("dashboard_widget_" + Integer.toString(i) + "_placeholder", false)) addPlaceholder(i); } mAppWidgetHost.stopListening(); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(addWidgetReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(removeWidgetReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver, new IntentFilter("com.farmerbb.taskbar.TOGGLE_DASHBOARD")); LocalBroadcastManager.getInstance(this).registerReceiver(addWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.ADD_WIDGET_COMPLETED")); LocalBroadcastManager.getInstance(this).registerReceiver(removeWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.REMOVE_WIDGET_COMPLETED")); LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_DASHBOARD")); windowManager.addView(layout, params); new Handler().postDelayed(() -> { int paddingSize = getResources().getDimensionPixelSize(R.dimen.icon_size); switch (U.getTaskbarPosition(DashboardService.this)) { case "top_vertical_left": case "bottom_vertical_left": layout.setPadding(paddingSize, 0, 0, 0); break; case "top_left": case "top_right": layout.setPadding(0, paddingSize, 0, 0); break; case "top_vertical_right": case "bottom_vertical_right": layout.setPadding(0, 0, paddingSize, 0); break; case "bottom_left": case "bottom_right": layout.setPadding(0, 0, 0, paddingSize); break; } }, 100); }
From source file:ca.frozen.curlingtv.activities.VideoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_video, container, false); view.setOnTouchListener(new View.OnTouchListener() { @Override// w w w . j a va 2 s. c om public boolean onTouch(View v, MotionEvent event) { simpleDetector.onTouchEvent(event); scaleDetector.onTouchEvent(event); return true; } }); // configure the name nameView = (TextView) view.findViewById(R.id.video_name); nameView.setText(camera.name); // initialize the message messageView = (TextView) view.findViewById(R.id.video_message); messageView.setTextColor(App.getClr(R.color.good_text)); messageView.setText(R.string.initializing_video); // set the texture listener textureView = (TextureView) view.findViewById(R.id.video_surface); textureView.setSurfaceTextureListener(this); // create the snapshot button snapshotButton = (Button) view.findViewById(R.id.video_snapshot); snapshotButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Bitmap image = textureView.getBitmap(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String name = camera.network + "_" + camera.name.replaceAll("\\s+", "") + "_" + sdf.format(new Date()) + ".jpg"; String url = Utils.saveImage(getActivity().getContentResolver(), image, name, null); MediaActionSound sound = new MediaActionSound(); sound.play(MediaActionSound.SHUTTER_CLICK); } }); // move the snapshot button over to account for the navigation bar if (fullScreen) { float scale = getContext().getResources().getDisplayMetrics().density; int margin = (int) (5 * scale + 0.5f); int extra = Utils.getNavigationBarHeight(getContext(), Configuration.ORIENTATION_LANDSCAPE); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) snapshotButton.getLayoutParams(); lp.setMargins(margin, margin, margin + extra, margin); } return view; }