static int[] getSpanForWidget(Context context, ComponentName component, int minWidth, int minHeight) { Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, component, null); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested int requiredWidth = minWidth + padding.left + padding.right; int requiredHeight = minHeight + padding.top + padding.bottom; return CellLayout.rectToCell(requiredWidth, requiredHeight, null); }
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) { Bundle options = null; if (Utilities.ATLEAST_JB_MR1) { Rect rect = new Rect(); AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect); Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, info.componentName, null); float density = context.getResources().getDisplayMetrics().density; int xPaddingDips = (int) ((padding.left + padding.right) / density); int yPaddingDips = (int) ((padding.top + padding.bottom) / density); options = new Bundle(); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, rect.left - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, rect.top - yPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, rect.right - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, rect.bottom - yPaddingDips); } return options; } }
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) { Rect rect = new Rect(); AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect); Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, info.componentName, null); float density = context.getResources().getDisplayMetrics().density; int xPaddingDips = (int) ((padding.left + padding.right) / density); int yPaddingDips = (int) ((padding.top + padding.bottom) / density); Bundle options = new Bundle(); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, rect.left - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, rect.top - yPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, rect.right - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, rect.bottom - yPaddingDips); return options; } }
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) { Bundle options = null; if (Utilities.ATLEAST_JB_MR1) { Rect rect = new Rect(); AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect); Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, info.componentName, null); float density = context.getResources().getDisplayMetrics().density; int xPaddingDips = (int) ((padding.left + padding.right) / density); int yPaddingDips = (int) ((padding.top + padding.bottom) / density); options = new Bundle(); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, rect.left - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, rect.top - yPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, rect.right - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, rect.bottom - yPaddingDips); } return options; } }
static Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) { Bundle options = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { AppWidgetResizeFrame.getWidgetSizeRanges(launcher, info.spanX, info.spanY, sTmpRect); Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(launcher, info.componentName, null); float density = launcher.getResources().getDisplayMetrics().density; int xPaddingDips = (int) ((padding.left + padding.right) / density); int yPaddingDips = (int) ((padding.top + padding.bottom) / density); options = new Bundle(); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, sTmpRect.left - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, sTmpRect.top - yPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, sTmpRect.right - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, sTmpRect.bottom - yPaddingDips); } return options; }
public static Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) { Bundle options = null; Rect rect = new Rect(); if (Utilities.ATLEAST_JB_MR1) { AppWidgetResizeFrame.getWidgetSizeRanges(launcher, info.spanX, info.spanY, rect); Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(launcher, info.componentName, null); float density = launcher.getResources().getDisplayMetrics().density; int xPaddingDips = (int) ((padding.left + padding.right) / density); int yPaddingDips = (int) ((padding.top + padding.bottom) / density); options = new Bundle(); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, rect.left - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, rect.top - yPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, rect.right - xPaddingDips); options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, rect.bottom - yPaddingDips); } return options; } }
void initSpans(Context context) { InvariantDeviceProfile idp = LauncherAppState.getIDP(context); Point paddingLand = idp.landscapeProfile.getTotalWorkspacePadding(); Point paddingPort = idp.portraitProfile.getTotalWorkspacePadding(); // Always assume we're working with the smallest span to make sure we // reserve enough space in both orientations. float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.widthPx - paddingLand.x, idp.portraitProfile.widthPx - paddingPort.x), idp.numColumns); float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.heightPx - paddingLand.y, idp.portraitProfile.heightPx - paddingPort.y), idp.numRows); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested. Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget( context, provider, null); spanX = Math.max(1, (int) Math.ceil( (minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); spanY = Math.max(1, (int) Math.ceil( (minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); minSpanX = Math.max(1, (int) Math.ceil( (minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); minSpanY = Math.max(1, (int) Math.ceil( (minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); }
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null); edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); desiredWorkspaceLeftRightMarginPx = edgeMarginPx;
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null); edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); desiredWorkspaceLeftRightMarginPx = 2 * edgeMarginPx;
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null); edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); desiredWorkspaceLeftRightMarginPx = edgeMarginPx;
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null); edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); desiredWorkspaceLeftRightMarginPx = edgeMarginPx;
private void initSpans() { LauncherAppState app = LauncherAppState.getInstance(); InvariantDeviceProfile idp = app.getInvariantDeviceProfile(); // We only care out the cell size, which is independent of the the layout direction. Rect paddingLand = idp.landscapeProfile.getWorkspacePadding(false /* isLayoutRtl */); Rect paddingPort = idp.portraitProfile.getWorkspacePadding(false /* isLayoutRtl */); // Always assume we're working with the smallest span to make sure we // reserve enough space in both orientations. float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.widthPx - paddingLand.left - paddingLand.right, idp.portraitProfile.widthPx - paddingPort.left - paddingPort.right), idp.numColumns); float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.heightPx - paddingLand.top - paddingLand.bottom, idp.portraitProfile.heightPx - paddingPort.top - paddingPort.bottom), idp.numRows); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested. Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget( app.getContext(), provider, null); spanX = Math.max(1, (int) Math.ceil( (minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); spanY = Math.max(1, (int) Math.ceil( (minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); minSpanX = Math.max(1, (int) Math.ceil( (minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); minSpanY = Math.max(1, (int) Math.ceil( (minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); }
public void initSpans() { LauncherAppState app = LauncherAppState.getInstance(); InvariantDeviceProfile idp = app.getInvariantDeviceProfile(); Point paddingLand = idp.landscapeProfile.getTotalWorkspacePadding(); Point paddingPort = idp.portraitProfile.getTotalWorkspacePadding(); // Always assume we're working with the smallest span to make sure we // reserve enough space in both orientations. float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.widthPx - paddingLand.x, idp.portraitProfile.widthPx - paddingPort.x), idp.numColumns); float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.heightPx - paddingLand.y, idp.portraitProfile.heightPx - paddingPort.y), idp.numRows); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested. Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget( app.getContext(), provider, null); spanX = Math.max(1, (int) Math.ceil( (minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); spanY = Math.max(1, (int) Math.ceil( (minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); minSpanX = Math.max(1, (int) Math.ceil( (minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); minSpanY = Math.max(1, (int) Math.ceil( (minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); }
public void initSpans() { LauncherAppState app = LauncherAppState.getInstance(); InvariantDeviceProfile idp = app.getInvariantDeviceProfile(); Point paddingLand = idp.landscapeProfile.getTotalWorkspacePadding(); Point paddingPort = idp.portraitProfile.getTotalWorkspacePadding(); // Always assume we're working with the smallest span to make sure we // reserve enough space in both orientations. float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.widthPx - paddingLand.x, idp.portraitProfile.widthPx - paddingPort.x), idp.numColumns); float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min( idp.landscapeProfile.heightPx - paddingLand.y, idp.portraitProfile.heightPx - paddingPort.y), idp.numRows); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested. Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget( app.getContext(), provider, null); spanX = Math.max(1, (int) Math.ceil( (minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); spanY = Math.max(1, (int) Math.ceil( (minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); minSpanX = Math.max(1, (int) Math.ceil( (minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth)); minSpanY = Math.max(1, (int) Math.ceil( (minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight)); }
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(getContext(), widgetView.getAppWidgetInfo().provider, null); } else {
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, widgetView.getAppWidgetInfo().provider, null); } else {
addView(mBottomHandle, lp); Rect p = AppWidgetHostView.getDefaultPaddingForWidget(context, widgetView.getAppWidgetInfo().provider, null); mWidgetPaddingLeft = p.left;
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null); edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); desiredWorkspaceLeftRightMarginPx = 2 * edgeMarginPx;
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, widgetView.getAppWidgetInfo().provider, null); } else {
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, widgetView.getAppWidgetInfo().provider, null); } else {