Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88f041ed authored by Adam Cohen's avatar Adam Cohen
Browse files

Account for auto-padding in AppWidgetHostView#updateAppWidgetSize (issue 6454251)

Change-Id: Ibf837671cc13ee89ca979e9e6dc9d144b296deba
parent aa997294
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -208,8 +208,10 @@ public class AppWidgetHostView extends FrameLayout {
    }

    /**
     * Provide guidance about the size of this widget to the AppWidgetManager. This information
     * gets embedded into the AppWidgetExtras and causes a callback to the AppWidgetProvider.
     * Provide guidance about the size of this widget to the AppWidgetManager. The widths and
     * heights should correspond to the full area the AppWidgetHostView is given. Padding added by
     * the framework will be accounted for automatically. This information gets embedded into the
     * AppWidget options and causes a callback to the AppWidgetProvider.
     * @see AppWidgetProvider#onAppWidgetOptionsChanged(Context, AppWidgetManager, int, Bundle)
     *
     * @param options The bundle of options, in addition to the size information,
@@ -225,10 +227,19 @@ public class AppWidgetHostView extends FrameLayout {
        if (options == null) {
            options = new Bundle();
        }
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight);

        Rect padding = new Rect();
        if (mInfo != null) {
            padding = getDefaultPaddingForWidget(mContext, mInfo.provider, padding);
        }

        int xPadding = padding.left + padding.right;
        int yPadding = padding.top + padding.bottom;

        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth - xPadding);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight - yPadding);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth - xPadding);
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight - yPadding);
        updateAppWidgetOptions(options);
    }