diff --git a/src/java/cyanogenmod/app/CustomTile.java b/src/java/cyanogenmod/app/CustomTile.java index 67dcea2..d6e7e2d 100644 --- a/src/java/cyanogenmod/app/CustomTile.java +++ b/src/java/cyanogenmod/app/CustomTile.java @@ -25,6 +25,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; +import android.widget.RemoteViews; import cyanogenmod.os.Build; import java.util.ArrayList; @@ -309,10 +310,16 @@ public class CustomTile implements Parcelable { */ public static final int LIST_STYLE = 1; + /** + * Identifier for a remote view style expanded view + */ + public static final int REMOTE_STYLE = 2; + private ExpandedStyle() { styleId = NO_STYLE; } + private RemoteViews contentViews; private ExpandedItem[] expandedItems; private int styleId; @@ -333,6 +340,12 @@ public class CustomTile implements Parcelable { styleId = parcel.readInt(); } + if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) { + if (parcel.readInt() != 0) { + contentViews = RemoteViews.CREATOR.createFromParcel(parcel); + } + } + parcel.setDataPosition(startPosition + parcelableSize); } @@ -357,6 +370,13 @@ public class CustomTile implements Parcelable { items.toArray(expandedItems); } + /** + * @hide + */ + protected void internalSetRemoteViews(RemoteViews remoteViews) { + contentViews = remoteViews; + } + /** * @hide */ @@ -372,6 +392,14 @@ public class CustomTile implements Parcelable { return expandedItems; } + /** + * Retrieve the RemoteViews that have been set on this expanded style + * @return RemoteViews + */ + public RemoteViews getContentViews() { + return contentViews; + } + /** * Retrieve the style id associated with the {@link ExpandedStyle} * @return id for style @@ -406,6 +434,14 @@ public class CustomTile implements Parcelable { } parcel.writeInt(styleId); + // ==== BOYSENBERRY ==== + if (contentViews != null) { + parcel.writeInt(1); + contentViews.writeToParcel(parcel, 0); + } else { + parcel.writeInt(0); + } + // Go back and write size int parcelableSize = parcel.dataPosition() - startPosition; parcel.setDataPosition(sizePosition); @@ -490,6 +526,26 @@ public class CustomTile implements Parcelable { } } + /** + * An instance of {@link ExpandedStyle} that shows a remote view in the remote process + */ + public static class RemoteExpandedStyle extends ExpandedStyle { + /** + * Constructs a RemoteExpandedStyle object with default values. + */ + public RemoteExpandedStyle() { + internalStyleId(REMOTE_STYLE); + } + + /** + * Sets the RemoteViews for the {@link RemoteExpandedStyle} + * @param remoteViews a remote view + */ + public void setRemoteViews(RemoteViews remoteViews) { + internalSetRemoteViews(remoteViews); + } + } + /** * A container object that is utilized by {@link ExpandedStyle} to show specific items in either * a PseudoGridView or a ListView via {@link GridExpandedStyle} and {@link ListExpandedStyle} diff --git a/tests/res/layout/main.xml b/tests/res/layout/main.xml index fbc4640..15b422c 100644 --- a/tests/res/layout/main.xml +++ b/tests/res/layout/main.xml @@ -1,4 +1,19 @@ + + + + + + + + + + +