diff options
Diffstat (limited to 'src/java/cyanogenmod/app/CustomTile.java')
-rw-r--r-- | src/java/cyanogenmod/app/CustomTile.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/java/cyanogenmod/app/CustomTile.java b/src/java/cyanogenmod/app/CustomTile.java index d6e7e2d..7e57fd8 100644 --- a/src/java/cyanogenmod/app/CustomTile.java +++ b/src/java/cyanogenmod/app/CustomTile.java @@ -62,6 +62,14 @@ public class CustomTile implements Parcelable { public Intent onSettingsClick; /** + * The intent to execute when the custom tile is explicitly removed by the user. + * + * This probably shouldn't be launching an activity since several of those will be sent + * at the same time. + */ + public PendingIntent deleteIntent; + + /** * An optional Uri to be parsed and broadcast on tile click, if an onClick pending intent * is specified, it will take priority over the uri to be broadcasted. **/ @@ -141,6 +149,9 @@ public class CustomTile implements Parcelable { if (parcel.readInt() != 0) { this.remoteIcon = Bitmap.CREATOR.createFromParcel(parcel); } + if (parcel.readInt() != 0) { + this.deleteIntent = PendingIntent.CREATOR.createFromParcel(parcel); + } } parcel.setDataPosition(startPosition + parcelableSize); @@ -196,6 +207,9 @@ public class CustomTile implements Parcelable { if (remoteIcon != null) { b.append("remoteIcon=" + remoteIcon.getGenerationId() + NEW_LINE); } + if (deleteIntent != null) { + b.append("deleteIntent=" + deleteIntent.toString() + NEW_LINE); + } return b.toString(); } @@ -214,6 +228,7 @@ public class CustomTile implements Parcelable { that.icon = this.icon; that.collapsePanel = this.collapsePanel; that.remoteIcon = this.remoteIcon; + that.deleteIntent = this.deleteIntent; } @Override @@ -283,6 +298,13 @@ public class CustomTile implements Parcelable { out.writeInt(0); } + if (deleteIntent != null) { + out.writeInt(1); + deleteIntent.writeToParcel(out, 0); + } else { + out.writeInt(0); + } + // Go back and write size int parcelableSize = out.dataPosition() - startPosition; out.setDataPosition(sizePosition); @@ -885,6 +907,7 @@ public class CustomTile implements Parcelable { private Context mContext; private ExpandedStyle mExpandedStyle; private boolean mCollapsePanel = true; + private PendingIntent mDeleteIntent; /** * Constructs a new Builder with the defaults: @@ -1016,6 +1039,19 @@ public class CustomTile implements Parcelable { } /** + * Supply a {@link PendingIntent} to send when the custom tile is cleared explicitly + * by the user. + * + * @see CustomTile#deleteIntent + * @param intent + * @return {@link cyanogenmod.app.CustomTile.Builder} + */ + public Builder setDeleteIntent(PendingIntent intent) { + mDeleteIntent = intent; + return this; + } + + /** * Create a {@link cyanogenmod.app.CustomTile} object * @return {@link cyanogenmod.app.CustomTile} */ @@ -1031,6 +1067,7 @@ public class CustomTile implements Parcelable { tile.icon = mIcon; tile.collapsePanel = mCollapsePanel; tile.remoteIcon = mRemoteIcon; + tile.deleteIntent = mDeleteIntent; return tile; } } |