List of usage examples for android.view Display getCurrentSizeRange
public void getCurrentSizeRange(Point outSmallestSize, Point outLargestSize)
From source file:org.acra.collector.DisplayManagerCollector.java
@NonNull private static String collectCurrentSizeRange(@NonNull Display display) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { final Point smallest = new Point(); final Point largest = new Point(); display.getCurrentSizeRange(smallest, largest); return display.getDisplayId() + ".currentSizeRange.smallest=[" + smallest.x + ',' + smallest.y + "]\n" + display.getDisplayId() + ".currentSizeRange.largest=[" + largest.x + ',' + largest.y + "]\n"; }//from w w w . j av a2 s.co m return ""; }
From source file:me.wimanacra.collector.DisplayManagerCollector.java
private static 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); 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); }/* w w w. j a v a 2 s.co m*/ }
From source file:com.android.leanlauncher.LauncherAppState.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) static DynamicGrid createDynamicGrid(Context context, DynamicGrid dynamicGrid) { // Determine the dynamic grid properties WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point realSize = new Point(); display.getRealSize(realSize);//from w w w . j a v a 2s. c o m DisplayMetrics dm = new DisplayMetrics(); display.getMetrics(dm); if (dynamicGrid == null) { Point smallestSize = new Point(); Point largestSize = new Point(); display.getCurrentSizeRange(smallestSize, largestSize); dynamicGrid = new DynamicGrid(context, context.getResources(), Math.min(smallestSize.x, smallestSize.y), Math.min(largestSize.x, largestSize.y), realSize.x, realSize.y, dm.widthPixels, dm.heightPixels); } // Update the icon size DeviceProfile grid = dynamicGrid.getDeviceProfile(); grid.updateFromConfiguration(context, context.getResources(), realSize.x, realSize.y, dm.widthPixels, dm.heightPixels); return dynamicGrid; }
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); }/* w ww . j a v a2s. 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.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); }//from w w w. ja v a 2s. co m 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:com.aidy.launcher3.ui.workspace.Workspace.java
/** * Return a rect that has the cellWidth/cellHeight (left, top), and * widthGap/heightGap (right, bottom)/* w ww. ja v a2 s.c o m*/ */ 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 w w w . j a v a 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.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. ja v 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); }/* w w w .j a va 2 s . 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(grid.calculateCellWidth(width, countX), grid.calculateCellHeight(height, countY), 0, 0); } return mPortraitCellLayoutMetrics; } return null; }
From source file:com.android.soma.Launcher.java
@Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG_STRICT_MODE) { StrictMode.setThreadPolicy(/*from w w w. j av a 2 s.c o m*/ new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork() // or .detectAll() for all detectable problems .penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); } super.onCreate(savedInstanceState); LauncherAppState.setApplicationContext(getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); // Determine the dynamic grid properties Point smallestSize = new Point(); Point largestSize = new Point(); Point realSize = new Point(); Display display = getWindowManager().getDefaultDisplay(); display.getCurrentSizeRange(smallestSize, largestSize); display.getRealSize(realSize); DisplayMetrics dm = new DisplayMetrics(); display.getMetrics(dm); // Lazy-initialize the dynamic grid DeviceProfile grid = app.initDynamicGrid(this, Math.min(smallestSize.x, smallestSize.y), Math.min(largestSize.x, largestSize.y), realSize.x, realSize.y, dm.widthPixels, dm.heightPixels); // the LauncherApplication should call this, but in case of Instrumentation it might not be present yet mSharedPrefs = getSharedPreferences(LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); mModel = app.setLauncher(this); mIconCache = app.getIconCache(); mIconCache.flushInvalidIcons(grid); mDragController = new DragController(this); mInflater = getLayoutInflater(); mStats = new Stats(this); mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID); mAppWidgetHost.startListening(); // If we are getting an onCreate, we can actually preempt onResume and unset mPaused here, // this also ensures that any synchronous binding below doesn't re-trigger another // LauncherModel load. mPaused = false; if (PROFILE_STARTUP) { android.os.Debug.startMethodTracing(Environment.getExternalStorageDirectory() + "/launcher"); } checkForLocaleChange(); setContentView(R.layout.launcher); setupViews(); grid.layout(this); registerContentObservers(); lockAllApps(); mSavedState = savedInstanceState; restoreState(mSavedState); // Update customization drawer _after_ restoring the states if (mAppsCustomizeContent != null) { mAppsCustomizeContent.onPackagesUpdated(LauncherModel.getSortedWidgetsAndShortcuts(this)); } { { final RajawaliSurfaceView surface = new RajawaliSurfaceView(this); surface.setFrameRate(60.0); surface.setRenderMode(IRajawaliSurface.RENDERMODE_WHEN_DIRTY); // Add mSurface to your root view addContentView(surface, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT)); mRenderer = new WallpaperRenderer(this); surface.setSurfaceRenderer(mRenderer); } } if (PROFILE_STARTUP) { android.os.Debug.stopMethodTracing(); } if (!mRestoring) { if (sPausedFromUserAction) { // If the user leaves launcher, then we should just load items asynchronously when // they return. mModel.startLoader(true, -1); } else { // We only load the page synchronously if the user rotates (or triggers a // configuration change) while launcher is in the foreground mModel.startLoader(true, mWorkspace.getCurrentPage()); } } // For handling default keys mDefaultKeySsb = new SpannableStringBuilder(); Selection.setSelection(mDefaultKeySsb, 0); IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mCloseSystemDialogsReceiver, filter); updateGlobalIcons(); // On large interfaces, we want the screen to auto-rotate based on the current orientation unlockScreenOrientation(true); showFirstRunCling(); // following code is for Native method support test { } }