summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-04-27 18:33:18 -0700
committerAdam Cohen <adamcohen@google.com>2012-04-30 13:25:59 -0700
commitc88d11f9493e65d318dcd3b094ef446e1905ebfd (patch)
tree44c7dd531721d3a5e12b18fa16c6da0c57abed00
parent3ea8761974a530218a246dc73583c8820b12bf0b (diff)
downloadframeworks_base-c88d11f9493e65d318dcd3b094ef446e1905ebfd.zip
frameworks_base-c88d11f9493e65d318dcd3b094ef446e1905ebfd.tar.gz
frameworks_base-c88d11f9493e65d318dcd3b094ef446e1905ebfd.tar.bz2
Pushing widget resize callback responsibility to AppWidgetHost
Change-Id: I33ca691deee11f8249eed6733a9ac82ed9bfbd15
-rw-r--r--core/java/android/appwidget/AppWidgetHostView.java36
1 files changed, 16 insertions, 20 deletions
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java
index c1b8e7c..c707ea3 100644
--- a/core/java/android/appwidget/AppWidgetHostView.java
+++ b/core/java/android/appwidget/AppWidgetHostView.java
@@ -207,31 +207,20 @@ public class AppWidgetHostView extends FrameLayout {
super.dispatchRestoreInstanceState(jail);
}
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int oldWidth = getMeasuredWidth();
- int oldHeight = getMeasuredHeight();
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- int newWidth = getMeasuredWidth();
- int newHeight = getMeasuredHeight();
-
- // TODO: this is just a hack for now -- we actually have the AppWidgetHost
- // be responsible for updating the size of the widget.
- if (oldWidth != newWidth || oldHeight != newHeight) {
- final float density = mContext.getResources().getDisplayMetrics().density;
- final int newWidthDips = (int) (newWidth / density);
- final int newHeightDips = (int) (newHeight / density);
- updateAppWidgetSize(null, newWidthDips, newHeightDips, newWidthDips, newHeightDips);
- }
- }
-
/**
* 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.
+ * @see AppWidgetProvider#onAppWidgetExtrasChanged(Context, AppWidgetManager, int, Bundle)
+ *
+ * @param extras The bundle of extra information, in addition to the size information
+ * can be null.
+ * @param minWidth The minimum width that the widget will be displayed at.
+ * @param minHeight The maximum height that the widget will be displayed at.
+ * @param maxWidth The maximum height that the widget will be displayed at.
*
- * @see AppWidgetProvider#onAppWidgetExtrasChanged(Context, AppWidgetManager, int, Bundle)
*/
- public void updateAppWidgetSize(Bundle extras, int minWidth, int minHeight, int maxWidth, int maxHeight) {
+ public void updateAppWidgetSize(Bundle extras, int minWidth, int minHeight, int maxWidth,
+ int maxHeight) {
if (extras == null) {
extras = new Bundle();
}
@@ -242,6 +231,13 @@ public class AppWidgetHostView extends FrameLayout {
updateAppWidgetExtras(extras);
}
+ /**
+ * Specify some extra information for the widget provider. Causes a callback to the
+ * AppWidgetProvider.
+ * @see AppWidgetProvider#onAppWidgetExtrasChanged(Context, AppWidgetManager, int, Bundle)
+ *
+ * @param extras The bundle of extra information.
+ */
public void updateAppWidgetExtras(Bundle extras) {
AppWidgetManager.getInstance(mContext).updateAppWidgetExtras(mAppWidgetId, extras);
}