private void collectCurrentSizeRange(@NonNull Display display, @NonNull JSONObject container) throws JSONException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { final Point smallest = new Point(); final Point largest = new Point(); display.getCurrentSizeRange(smallest, largest); final JSONObject result = new JSONObject(); result.put("smallest", new JSONArray(Arrays.asList(smallest.x, smallest.y))); result.put("largest", new JSONArray(Arrays.asList(largest.x, largest.y))); container.put("currentSizeRange", result); } }
@Test @Config(minSdk = JELLY_BEAN_MR1) public void withQualifiers_changeDisplay_shouldUpdateSmallestAndLargestNominalWidthAndHeight() throws Exception { Point smallest = new Point(); Point largest = new Point(); Display display = ShadowDisplay.getDefaultDisplay(); display.getCurrentSizeRange(smallest, largest); assertThat(smallest).isEqualTo(new Point(320, 320)); assertThat(largest).isEqualTo(new Point(470, 470)); ShadowDisplayManager.changeDisplay(display.getDisplayId(), "w310dp-h460dp"); display.getCurrentSizeRange(smallest, largest); assertThat(smallest).isEqualTo(new Point(310, 310)); assertThat(largest).isEqualTo(new Point(460, 460)); }
@Test @Config(minSdk = JELLY_BEAN_MR1) public void changeDisplay_shouldUpdateSmallestAndLargestNominalWidthAndHeight() throws Exception { Point smallest = new Point(); Point largest = new Point(); ShadowDisplay.getDefaultDisplay().getCurrentSizeRange(smallest, largest); assertThat(smallest).isEqualTo(new Point(320, 320)); assertThat(largest).isEqualTo(new Point(470, 470)); Display display = ShadowDisplay.getDefaultDisplay(); ShadowDisplay shadowDisplay = Shadow.extract(display); shadowDisplay.setWidth(display.getWidth() - 10); shadowDisplay.setHeight(display.getHeight() - 10); ShadowDisplay.getDefaultDisplay().getCurrentSizeRange(smallest, largest); assertThat(smallest).isEqualTo(new Point(310, 310)); assertThat(largest).isEqualTo(new Point(460, 460)); }
@Test public void shouldProvideDisplaySize() throws Exception { Point outSmallestSize = new Point(); Point outLargestSize = new Point(); Point outSize = new Point(); Rect outRect = new Rect(); shadow.setWidth(400); shadow.setHeight(600); shadow.setRealWidth(480); shadow.setRealHeight(800); display.getCurrentSizeRange(outSmallestSize, outLargestSize); assertEquals(400, outSmallestSize.x); assertEquals(400, outSmallestSize.y); assertEquals(600, outLargestSize.x); assertEquals(600, outLargestSize.y); display.getSize(outSize); assertEquals(400, outSize.x); assertEquals(600, outSize.y); display.getRectSize(outRect); assertEquals(400, outRect.width()); assertEquals(600, outRect.height()); display.getRealSize(outSize); assertEquals(480, outSize.x); assertEquals(800, outSize.y); }
Point minDims = new Point(); Point maxDims = new Point(); windowManager.getDefaultDisplay().getCurrentSizeRange(minDims, maxDims);
static protected Point getDefaultWallpaperSize(Resources res, WindowManager windowManager) { if (sDefaultWallpaperSize == null) { Point minDims = new Point(); Point maxDims = new Point(); windowManager.getDefaultDisplay().getCurrentSizeRange(minDims, maxDims); int maxDim = Math.max(maxDims.x, maxDims.y); int minDim = Math.max(minDims.x, minDims.y); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { Point realSize = new Point(); windowManager.getDefaultDisplay().getRealSize(realSize); maxDim = Math.max(realSize.x, realSize.y); minDim = Math.min(realSize.x, realSize.y); } // We need to ensure that there is enough extra space in the wallpaper // for the intended parallax effects final int defaultWidth, defaultHeight; if (isScreenLarge(res)) { defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); defaultHeight = maxDim; } else { defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim); defaultHeight = maxDim; } sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight); } return sDefaultWallpaperSize; }
Point largestSize = new Point(); display.getSize(size); display.getCurrentSizeRange(smallestSize, largestSize); availableWidthPx = size.x; if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
display.getCurrentSizeRange(smallestSize, largestSize);
display.getCurrentSizeRange(smallestSize, largestSize);
display.getCurrentSizeRange(smallestSize, largestSize);
display.getCurrentSizeRange(smallestSize, largestSize);
Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows;
Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) inv.numColumns; int countY = (int) inv.numRows;
Point realSize = new Point(); Display display = getWindowManager().getDefaultDisplay(); display.getCurrentSizeRange(smallestSize, largestSize); display.getRealSize(realSize); DisplayMetrics dm = new DisplayMetrics();