summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/appwidget/AppWidgetHost.java21
-rw-r--r--core/java/android/appwidget/AppWidgetProviderInfo.java27
2 files changed, 44 insertions, 4 deletions
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 9835484..8204a4f 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -16,6 +16,9 @@
package android.appwidget;
+import java.util.ArrayList;
+import java.util.HashMap;
+
import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
@@ -23,11 +26,10 @@ import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
import android.widget.RemoteViews;
-import java.util.ArrayList;
-import java.util.HashMap;
-
import com.android.internal.appwidget.IAppWidgetHost;
import com.android.internal.appwidget.IAppWidgetService;
@@ -43,6 +45,7 @@ public class AppWidgetHost {
final static Object sServiceLock = new Object();
static IAppWidgetService sService;
+ private DisplayMetrics mDisplayMetrics;
Context mContext;
String mPackageName;
@@ -103,6 +106,7 @@ public class AppWidgetHost {
mContext = context;
mHostId = hostId;
mHandler = new UpdateHandler(context.getMainLooper());
+ mDisplayMetrics = context.getResources().getDisplayMetrics();
synchronized (sServiceLock) {
if (sService == null) {
IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
@@ -243,12 +247,21 @@ public class AppWidgetHost {
AppWidgetProviderInfo appWidget) {
return new AppWidgetHostView(context);
}
-
+
/**
* Called when the AppWidget provider for a AppWidget has been upgraded to a new apk.
*/
protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
AppWidgetHostView v;
+
+ // Convert complex to dp -- we are getting the AppWidgetProviderInfo from the
+ // AppWidgetService, which doesn't have our context, hence we need to do the
+ // conversion here.
+ appWidget.minWidth =
+ TypedValue.complexToDimensionPixelSize(appWidget.minWidth, mDisplayMetrics);
+ appWidget.minHeight =
+ TypedValue.complexToDimensionPixelSize(appWidget.minHeight, mDisplayMetrics);
+
synchronized (mViews) {
v = mViews.get(appWidgetId);
}
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
index fe33782..32c2397 100644
--- a/core/java/android/appwidget/AppWidgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -25,6 +25,24 @@ import android.content.ComponentName;
* correspond to the fields in the <code>&lt;appwidget-provider&gt;</code> xml tag.
*/
public class AppWidgetProviderInfo implements Parcelable {
+
+ /**
+ * Widget is not resizable.
+ */
+ public static final int RESIZE_NONE = 0;
+ /**
+ * Widget is resizable in the horizontal axis only.
+ */
+ public static final int RESIZE_HORIZONTAL = 1;
+ /**
+ * Widget is resizable in the vertical axis only.
+ */
+ public static final int RESIZE_VERTICAL = 2;
+ /**
+ * Widget is resizable in both the horizontal and vertical axes.
+ */
+ public static final int RESIZE_BOTH = RESIZE_HORIZONTAL | RESIZE_VERTICAL;
+
/**
* Identity of this AppWidget component. This component should be a {@link
* android.content.BroadcastReceiver}, and it will be sent the AppWidget intents
@@ -124,6 +142,13 @@ public class AppWidgetProviderInfo implements Parcelable {
*/
public int previewImage;
+ /**
+ * The rules by which a widget can be resized. See {@link #RESIZE_NONE},
+ * {@link #RESIZE_NONE}, {@link #RESIZE_HORIZONTAL},
+ * {@link #RESIZE_VERTICAL}, {@link #RESIZE_BOTH}.
+ */
+ public int resizableMode;
+
public AppWidgetProviderInfo() {
}
@@ -145,6 +170,7 @@ public class AppWidgetProviderInfo implements Parcelable {
this.icon = in.readInt();
this.previewImage = in.readInt();
this.autoAdvanceViewId = in.readInt();
+ this.resizableMode = in.readInt();
}
public void writeToParcel(android.os.Parcel out, int flags) {
@@ -168,6 +194,7 @@ public class AppWidgetProviderInfo implements Parcelable {
out.writeInt(this.icon);
out.writeInt(this.previewImage);
out.writeInt(this.autoAdvanceViewId);
+ out.writeInt(this.resizableMode);
}
public int describeContents() {