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:info.rti.tabsswipe.PressureFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { if (Configuration.ORIENTATION_PORTRAIT == getResources().getConfiguration().orientation) { mYAxisPadding = 9;//from w w w. j a v a 2s. c o m mRenderer.setYLabels(30); } final LinearLayout view = (LinearLayout) inflater.inflate(R.layout.fragment_pressure, container, false); mChartView = ChartFactory.getTimeChartView(getActivity(), mDataset, mRenderer, TIME); mChartView.addZoomListener(mZoomListener2, true, false); view.addView(mChartView, new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); return view; }
From source file:com.example.app_2.utils.Utils.java
public static void setWallpaper(android.view.ViewGroup vg, int reqWidth, int reqHeight, Bitmap wallpaper, ScalingLogic sl) {/* w w w . java2 s . c o m*/ if (wallpaper == null) { WallpaperManager wallpaperManager = WallpaperManager.getInstance(App_2.getAppContext()); Drawable wallpaperDrawable = wallpaperManager.getDrawable(); wallpaper = BitmapCalc.drawableToBitmap(wallpaperDrawable); } if (reqHeight == 0 || reqWidth == 0) { reqHeight = App_2.getMaxHeight(); reqWidth = App_2.getMaxWidth(); } Resources r = App_2.getAppContext().getResources(); int orientation = r.getConfiguration().orientation; switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: // landscape Bitmap wallpaperLandscape = ScalingUtilities.createScaledBitmap(wallpaper, reqHeight, reqWidth, sl); if (Utils.hasJellyBean()) vg.setBackground(new BitmapDrawable(r, wallpaperLandscape)); else { if (vg instanceof LinearLayout) { LinearLayout ll = (LinearLayout) vg; ll.setBackgroundDrawable(new BitmapDrawable(r, wallpaperLandscape)); } else if (vg instanceof DrawerLayout) { DrawerLayout dl = (DrawerLayout) vg; dl.setBackgroundDrawable(new BitmapDrawable(r, wallpaperLandscape)); } } //wallpaperLandscape.recycle(); break; case Configuration.ORIENTATION_PORTRAIT: // portrait Bitmap wallpaperPortrait = ScalingUtilities.createScaledBitmap(wallpaper, reqWidth, reqHeight, sl); if (Utils.hasJellyBean()) vg.setBackground(new BitmapDrawable(r, wallpaperPortrait)); else { if (vg instanceof LinearLayout) { LinearLayout ll = (LinearLayout) vg; ll.setBackgroundDrawable(new BitmapDrawable(r, wallpaperPortrait)); } else if (vg instanceof DrawerLayout) { DrawerLayout dl = (DrawerLayout) vg; dl.setBackgroundDrawable(new BitmapDrawable(r, wallpaperPortrait)); } } //wallpaperPortrait.recycle(); break; default: //ll.setBackgroundDrawable(App_2.wallpaperDrawable); break; } }
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);/*from w w w . j a v a 2 s . c om*/ // 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:com.deltadna.android.sdk.ImageMessage.java
/** * Recalculates the layouts, assumes that the larger dimension will be * portrait vertical.//from w w w . ja v 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:de.tlabs.ssr.g1.client.SourcesView.java
private void init() { // make this view focusable setFocusable(true);//from w ww .j a v a 2 s . co m // init fields viewportTransformation = new Matrix(); newViewportTransformation = new Matrix(); inverseViewportTransformation = new Matrix(); selectionOffset = new float[2]; touchPoint = new float[2]; buffer = ByteBuffer.allocate(1024); scalingInterpolator = new TimedInterpolator(); scalingInterpolator.setDuration(800); translationXInterpolator = new TimedInterpolator(); translationXInterpolator.setDuration(800); translationYInterpolator = new TimedInterpolator(); translationYInterpolator.setDuration(800); rotationInterpolator = new TimedInterpolator(); rotationInterpolator.setDuration(800); centerRotationInterpolator = new TimedInterpolator(); centerRotationInterpolator.setDuration(800); currentOrientation = getContext().getResources().getConfiguration().orientation; setOrientationFlag(true); if (SourcesView.paint == null) { SourcesView.paint = new Paint(); SourcesView.paint.setAntiAlias(false); SourcesView.paint.setStrokeWidth(0); SourcesView.paint.setTextAlign(Paint.Align.CENTER); SourcesView.paint.setTextSize(9.0f); } // set up orientation event listener orientationEventListener = new OrientationEventListener(getContext(), SensorManager.SENSOR_DELAY_NORMAL) { @Override public void onOrientationChanged(int orientation) { if ((orientation >= 80 && orientation <= 100) || (orientation >= 260 && orientation <= 280)) { // landscape setOrientation(Configuration.ORIENTATION_LANDSCAPE); } else if ((orientation >= 350 || orientation <= 10) || (orientation >= 170 && orientation <= 190)) { // portrait setOrientation(Configuration.ORIENTATION_PORTRAIT); } } }; if (!GlobalData.orientationTrackingEnabled) // orientation tracking and screen rotation tracking don't go together orientationEventListener.enable(); // set up gesture detector gestureDetector = new GestureDetector(getContext(), this); gestureDetector.setIsLongpressEnabled(false); gestureDetector.setOnDoubleTapListener(this); // init viewport transformation matrix recalculateViewportTransformation(); }
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;/* w ww . j a v a2 s .c om*/ 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.embeddedlog.LightUpDroid.DeskClock.java
@Override public void onConfigurationChanged(final Configuration config) { super.onConfigurationChanged(config); if (config.orientation == Configuration.ORIENTATION_PORTRAIT) { forceTabsInActionBar(getActionBar()); }// w w w . j av a 2s . co m }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device orientation. *//*from w w w . j a va 2 s.c om*/ 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:org.catrobat.paintroid.ui.BottomBar.java
private void scrollToSelectedTool(ToolType toolType) { int orientation = mMainActivity.getResources().getConfiguration().orientation; View toolButton = getToolButtonByToolType(toolType); if (orientation == Configuration.ORIENTATION_PORTRAIT) { HorizontalScrollView scrollView = (HorizontalScrollView) mMainActivity .findViewById(R.id.bottom_bar_scroll_view); scrollView.smoothScrollTo(/* w ww . ja v a 2s . c o m*/ (int) (toolButton.getX() - scrollView.getWidth() / 2.0f + toolButton.getWidth() / 2.0f), (int) toolButton.getY()); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { ScrollView scrollView = (ScrollView) mMainActivity.findViewById(R.id.bottom_bar_landscape_scroll_view); scrollView.smoothScrollTo((int) (toolButton.getX()), (int) (toolButton.getY() - scrollView.getHeight() / 2.0f + toolButton.getHeight() / 2.0f)); } }
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); }//from w w w.j a v a 2 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(); } }