List of usage examples for android.graphics Point Point
public Point()
From source file:com.android.launcher2.Workspace.java
static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { Resources res = launcher.getResources(); Display display = launcher.getWindowManager().getDefaultDisplay(); Point smallestSize = new Point(); Point largestSize = new Point(); DisplayCompt.getCurrentSizeRange(display, smallestSize, largestSize); if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { int paddingLeft = res.getDimensionPixelSize(R.dimen.workspace_left_padding_land); int paddingRight = res.getDimensionPixelSize(R.dimen.workspace_right_padding_land); int paddingTop = res.getDimensionPixelSize(R.dimen.workspace_top_padding_land); int paddingBottom = res.getDimensionPixelSize(R.dimen.workspace_bottom_padding_land); int width = largestSize.x - paddingLeft - paddingRight; int height = smallestSize.y - paddingTop - paddingBottom; mLandscapeCellLayoutMetrics = new Rect(); CellLayout.getMetrics(mLandscapeCellLayoutMetrics, res, width, height, LauncherModel.getCellCountX(), LauncherModel.getCellCountY(), orientation); }//from w w w.j av a 2 s .c o m return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { int paddingLeft = res.getDimensionPixelSize(R.dimen.workspace_left_padding_land); int paddingRight = res.getDimensionPixelSize(R.dimen.workspace_right_padding_land); int paddingTop = res.getDimensionPixelSize(R.dimen.workspace_top_padding_land); int paddingBottom = res.getDimensionPixelSize(R.dimen.workspace_bottom_padding_land); int width = smallestSize.x - paddingLeft - paddingRight; int height = largestSize.y - paddingTop - paddingBottom; mPortraitCellLayoutMetrics = new Rect(); CellLayout.getMetrics(mPortraitCellLayoutMetrics, res, width, height, LauncherModel.getCellCountX(), LauncherModel.getCellCountY(), orientation); } return mPortraitCellLayoutMetrics; } return null; }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Gets the device screen size in pixels. * // ww w . jav a2 s .c o m * @param context * @return */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") public static Point device_screenSize(Context context) { Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); final Point size = new Point(); try { display.getSize(size); } catch (NoSuchMethodError ignore) { // Older device size.x = display.getWidth(); size.y = display.getHeight(); } return size; }
From source file:org.chromium.android_webview.test.AwSettingsTest.java
@SmallTest @Feature({ "AndroidWebView", "Preferences" }) public void testSetInitialScale() throws Throwable { final TestAwContentsClient contentClient = new TestAwContentsClient(); final AwTestContainerView testContainerView = createAwTestContainerViewOnMainSync(contentClient); final AwContents awContents = testContainerView.getAwContents(); final AwSettings awSettings = getAwSettingsOnUiThread(awContents); CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper(); WindowManager wm = (WindowManager) getInstrumentation().getTargetContext() .getSystemService(Context.WINDOW_SERVICE); Point screenSize = new Point(); wm.getDefaultDisplay().getSize(screenSize); // Make sure after 50% scale, page width still larger than screen. int height = screenSize.y * 2 + 1; int width = screenSize.x * 2 + 1; final String page = "<html><body>" + "<p style='height:" + height + "px;width:" + width + "px'>" + "testSetInitialScale</p></body></html>"; final float defaultScale = getInstrumentation().getTargetContext().getResources() .getDisplayMetrics().density; assertEquals(defaultScale, getPixelScaleOnUiThread(awContents), .01f); loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false); assertEquals(defaultScale, getPixelScaleOnUiThread(awContents), .01f); int onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().getCallCount(); awSettings.setInitialPageScale(50);//w ww . j ava 2 s . com loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false); contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCallCount); assertEquals(0.5f, getPixelScaleOnUiThread(awContents), .01f); onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().getCallCount(); awSettings.setInitialPageScale(500); loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false); contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCallCount); assertEquals(5.0f, getPixelScaleOnUiThread(awContents), .01f); onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().getCallCount(); awSettings.setInitialPageScale(0); loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false); contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCallCount); assertEquals(defaultScale, getPixelScaleOnUiThread(awContents), .01f); }
From source file:com.klinker.android.launcher.launcher3.Workspace.java
/** Return a rect that has the cellWidth/cellHeight (left, top), and * widthGap/heightGap (right, bottom) */ static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { LauncherAppState app = LauncherAppState.getInstance(); InvariantDeviceProfile inv = app.getInvariantDeviceProfile(); Display display = launcher.getWindowManager().getDefaultDisplay(); Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) inv.numColumns; int countY = (int) inv.numRows; boolean isLayoutRtl = Utilities.isRtl(launcher.getResources()); if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = inv.landscapeProfile.getWorkspacePadding(isLayoutRtl); int width = largestSize.x - padding.left - padding.right; int height = smallestSize.y - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); mLandscapeCellLayoutMetrics.set(DeviceProfile.calculateCellWidth(width, countX), DeviceProfile.calculateCellHeight(height, countY), 0, 0); }/* w w w . j a v a2 s . com*/ return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = inv.portraitProfile.getWorkspacePadding(isLayoutRtl); int width = smallestSize.x - padding.left - padding.right; int height = largestSize.y - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); mPortraitCellLayoutMetrics.set(DeviceProfile.calculateCellWidth(width, countX), DeviceProfile.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } return null; }
From source file:cc.flydev.launcher.Workspace.java
/** Return a rect that has the cellWidth/cellHeight (left, top), and * widthGap/heightGap (right, bottom) */ static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Resources res = launcher.getResources(); Display display = launcher.getWindowManager().getDefaultDisplay(); Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows; int constrainedLongEdge = largestSize.y; int constrainedShortEdge = smallestSize.y; if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE); int width = constrainedLongEdge - padding.left - padding.right; int height = constrainedShortEdge - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); mLandscapeCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); }//from w w w. j a v a 2 s .c o m return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.PORTRAIT); int width = constrainedShortEdge - padding.left - padding.right; int height = constrainedLongEdge - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); mPortraitCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } return null; }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
/** * Return a rect that has the cellWidth/cellHeight (left, top), and * widthGap/heightGap (right, bottom)// ww w.j a v a 2s. com */ public static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Resources res = launcher.getResources(); Display display = launcher.getWindowManager().getDefaultDisplay(); Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows; int constrainedLongEdge = largestSize.y; int constrainedShortEdge = smallestSize.y; if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE); int width = constrainedLongEdge - padding.left - padding.right; int height = constrainedShortEdge - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); mLandscapeCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); } return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.PORTRAIT); int width = constrainedShortEdge - padding.left - padding.right; int height = constrainedLongEdge - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); mPortraitCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } return null; }
From source file:com.auratech.launcher.Workspace.java
/** Return a rect that has the cellWidth/cellHeight (left, top), and * widthGap/heightGap (right, bottom) */ static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Resources res = launcher.getResources(); Display display = launcher.getWindowManager().getDefaultDisplay(); Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows; if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE); int width = largestSize.x - padding.left - padding.right; int height = smallestSize.y - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); mLandscapeCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); }//from ww w .j a va2 s .co m return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.PORTRAIT); int width = smallestSize.x - padding.left - padding.right; int height = largestSize.y - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); mPortraitCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } return null; }
From source file:com.fairphone.fplauncher3.Workspace.java
/** Return a rect that has the cellWidth/cellHeight (left, top), and * widthGap/heightGap (right, bottom) */ static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Display display = launcher.getWindowManager().getDefaultDisplay(); Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows; if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE); int width = largestSize.x - padding.left - padding.right; int height = smallestSize.y - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); mLandscapeCellLayoutMetrics.set(DeviceProfile.calculateCellWidth(width, countX), DeviceProfile.calculateCellHeight(height, countY), 0, 0); }/*from w ww . j av a 2s. c o m*/ return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.PORTRAIT); int width = smallestSize.x - padding.left - padding.right; int height = largestSize.y - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); mPortraitCellLayoutMetrics.set(DeviceProfile.calculateCellWidth(width, countX), DeviceProfile.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } return null; }
From source file:com.android.launcher3.Workspace.java
/** Return a rect that has the cellWidth/cellHeight (left, top), and * widthGap/heightGap (right, bottom) */ static Rect getCellLayoutMetrics(Launcher launcher, int orientation) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Display display = launcher.getWindowManager().getDefaultDisplay(); Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows; if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE); int width = largestSize.x - padding.left - padding.right; int height = smallestSize.y - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); mLandscapeCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); }/*from ww w . j a va 2 s . co m*/ return mLandscapeCellLayoutMetrics; } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.PORTRAIT); int width = smallestSize.x - padding.left - padding.right; int height = largestSize.y - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); mPortraitCellLayoutMetrics.set(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } return null; }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
private void setupDrawer() { mWorkspace.setOnPageChangedListener(new Workspace.OnPageChangeListener() { @Override//from w w w .j ava 2s.co m public void onPageChanged(int page) { if (mLauncherDrawer == null) { return; } if (mLauncherDrawer.getDrawerLockMode(Gravity.LEFT) == LauncherDrawerLayout.LOCK_MODE_LOCKED_CLOSED && !mWorkspace.isSmall()) { lockLauncherDrawer(false); } if (page == 0) { // on the first page mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, 1.0f); } else { // somewhere in the middle mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, .07f); } } @Override public void onScrollStart() { lockLauncherDrawer(true); } @Override public void onScrollEnd() { } }); mDrawerPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mLauncherDrawer.setCurrentDrawerPage(position); } }); mLauncherDrawer.setDrawerListener(new LauncherDrawerLayout.DrawerListener() { @Override public void onDrawerSlide(View drawerView, float slideOffset) { if (drawerView == mDrawerPager) { mDragLayer.setTranslationX(getScreenWidth() * slideOffset); ((PagesFragmentAdapter) mDrawerPager.getAdapter()) .adjustFragmentBackgroundAlpha(mDrawerPager.getCurrentItem(), slideOffset); } else { mDragLayer.setTranslationX(getScreenWidth() * slideOffset * -1); for (View v : ((BaseLauncherPage) extraFragment).getBackground()) { v.setAlpha(slideOffset); } } } @Override public void onDrawerOpened(View drawerView) { if (drawerView == mDrawerPager) { mDragLayer.setTranslationX(getScreenWidth()); } else { mDragLayer.setTranslationX(getScreenWidth() * -1); } sendBroadcast(new Intent("com.klinker.android.launcher.FRAGMENTS_OPENED")); } @Override public void onDrawerClosed(View drawerView) { mDragLayer.setTranslationX(0); sendBroadcast(new Intent("com.klinker.android.launcher.FRAGMENTS_CLOSED")); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mLauncherDrawer.getWindowToken(), 0); } @Override public void onDrawerStateChanged(int newState) { } private int screenWidth = -1; private int getScreenWidth() { if (screenWidth == -1) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x; } return screenWidth; } }); }