Example usage for android.appwidget AppWidgetHostView getDefaultPaddingForWidget

List of usage examples for android.appwidget AppWidgetHostView getDefaultPaddingForWidget

Introduction

In this page you can find the example usage for android.appwidget AppWidgetHostView getDefaultPaddingForWidget.

Prototype

@UnsupportedAppUsage
    private static Rect getDefaultPaddingForWidget(Context context, ApplicationInfo appInfo, Rect padding) 

Source Link

Usage

From source file:com.android.leanlauncher.LauncherTransitionable.java

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);
}

From source file:com.zyk.launcher.AsyncTaskCallback.java

static Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) {
    Bundle options = null;/* ww w.  ja va2s. co  m*/
    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;
}

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) {
    Bundle options = null;// w  w w  .  j  av a  2  s.co  m
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, mTmpRect);
        Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(mLauncher, info.componentName, null);

        float density = 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, mTmpRect.left - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, mTmpRect.top - yPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, mTmpRect.right - xPaddingDips);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, mTmpRect.bottom - yPaddingDips);
    }
    return options;
}

From source file:com.gxapplications.android.gxsuite.launcher.Launcher.java

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(context.getResources(), requiredWidth, requiredHeight, null);
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

private int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight) {
    Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(this, 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(this, requiredWidth, requiredHeight, null);
}