summaryrefslogtreecommitdiff
path: root/core/java/android/appwidget/AppWidgetHostView.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-05-08 15:32:23 -0700
committerAdam Cohen <adamcohen@google.com>2012-05-08 15:53:43 -0700
commit88f041ed312299f1d2746e570b989c336bfd97c8 (patch)
tree44bf830730615bf563cc9571fbfd284a3cda22af /core/java/android/appwidget/AppWidgetHostView.java
parentaa9972943cab627db9b10e5c9c4bb80f99f8a4bd (diff)
Account for auto-padding in AppWidgetHostView#updateAppWidgetSize (issue 6454251)
Change-Id: Ibf837671cc13ee89ca979e9e6dc9d144b296deba
Diffstat (limited to 'core/java/android/appwidget/AppWidgetHostView.java')
-rw-r--r--core/java/android/appwidget/AppWidgetHostView.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java
index c9bacbad0125..2ca2ae4c47e4 100644
--- a/core/java/android/appwidget/AppWidgetHostView.java
+++ b/core/java/android/appwidget/AppWidgetHostView.java
@@ -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);
}