diff options
author | Roman Birg <roman@cyngn.com> | 2016-01-14 09:44:13 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-01-18 10:31:08 -0800 |
commit | 8d4920022f5b09a07e257fdf61a102a140c2f267 (patch) | |
tree | 5c0f1934fba2c17d2026bb25ceaedcf243ef832e /src/java/cyanogenmod/app | |
parent | 5400b2f30e16fefb5260aaa0b4e69c1b1cb104bb (diff) | |
download | vendor_cmsdk-8d4920022f5b09a07e257fdf61a102a140c2f267.zip vendor_cmsdk-8d4920022f5b09a07e257fdf61a102a140c2f267.tar.gz vendor_cmsdk-8d4920022f5b09a07e257fdf61a102a140c2f267.tar.bz2 |
CustomTiles: add a custom long press PendingIntent
Ref: CYNGNOS-1602
Change-Id: Id0cca88fabb091dcf0fbad2ae24416fa1c0af83e
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'src/java/cyanogenmod/app')
-rw-r--r-- | src/java/cyanogenmod/app/CustomTile.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/java/cyanogenmod/app/CustomTile.java b/src/java/cyanogenmod/app/CustomTile.java index 4ab71c1..26ff6b4 100644 --- a/src/java/cyanogenmod/app/CustomTile.java +++ b/src/java/cyanogenmod/app/CustomTile.java @@ -54,6 +54,15 @@ public class CustomTile implements Parcelable { public PendingIntent onClick; /** + * An optional intent to execute when the custom tile entry is long clicked. If + * this is an activity, it must include the + * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} flag, which requires + * that you take care of task management. Activities will also automatically trigger + * the host panel to automatically collapse after executing the pending intent. + **/ + public PendingIntent onLongClick; + + /** * An optional settings intent to execute when the custom tile's detail is shown * If this is an activity, it must include the * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} flag, which requires @@ -162,6 +171,12 @@ public class CustomTile implements Parcelable { this.sensitiveData = (parcel.readInt() == 1); } + if (parcelableVersion >= Build.CM_VERSION_CODES.DRAGON_FRUIT) { + if (parcel.readInt() != 0) { + this.onLongClick = PendingIntent.CREATOR.createFromParcel(parcel); + } + } + parcel.setDataPosition(startPosition + parcelableSize); } @@ -196,6 +211,9 @@ public class CustomTile implements Parcelable { if (onClick != null) { b.append("onClick=" + onClick.toString() + NEW_LINE); } + if (onLongClick != null) { + b.append("onLongClick=" + onLongClick.toString() + NEW_LINE); + } if (onSettingsClick != null) { b.append("onSettingsClick=" + onSettingsClick.toString() + NEW_LINE); } @@ -229,6 +247,7 @@ public class CustomTile implements Parcelable { public void cloneInto(CustomTile that) { that.resourcesPackageName = this.resourcesPackageName; that.onClick = this.onClick; + that.onLongClick = this.onLongClick; that.onSettingsClick = this.onSettingsClick; that.onClickUri = this.onClickUri; that.label = this.label; @@ -314,6 +333,14 @@ public class CustomTile implements Parcelable { } out.writeInt(sensitiveData ? 1 : 0); + // ==== DRAGONFRUIT ==== + if (onLongClick != null) { + out.writeInt(1); + onLongClick.writeToParcel(out, 0); + } else { + out.writeInt(0); + } + // Go back and write size int parcelableSize = out.dataPosition() - startPosition; out.setDataPosition(sizePosition); @@ -907,6 +934,7 @@ public class CustomTile implements Parcelable { */ public static class Builder { private PendingIntent mOnClick; + private PendingIntent mOnLongClick; private Intent mOnSettingsClick; private Uri mOnClickUri; private String mLabel; @@ -977,6 +1005,17 @@ public class CustomTile implements Parcelable { } /** + * Set a {@link android.app.PendingIntent} to be fired on custom tile long press. + * Note: if this is an activity, the host panel will automatically collapse. + * @param intent + * @return {@link cyanogenmod.app.CustomTile.Builder} + */ + public Builder setOnLongClickIntent(PendingIntent intent) { + mOnLongClick = intent; + return this; + } + + /** * Set a settings {@link android.content.Intent} to be fired on custom * tile detail pane click * @param intent @@ -1080,6 +1119,7 @@ public class CustomTile implements Parcelable { CustomTile tile = new CustomTile(); tile.resourcesPackageName = mContext.getPackageName(); tile.onClick = mOnClick; + tile.onLongClick = mOnLongClick; tile.onSettingsClick = mOnSettingsClick; tile.onClickUri = mOnClickUri; tile.label = mLabel; |