From 3290540468c1e46d4bb345f5fd82db86dad04afb Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Wed, 22 Jul 2015 13:34:09 -0700 Subject: [PATCH] cmsdk: Add method for shouldCollapsePanel. - Allow for disabling of panel collapse when handling an onClick or onClickUri event in CustomTile. Change-Id: I73bd513baf0fb8b7db33020a3456430702ccd609 --- api/cm_current.txt | 2 ++ src/java/cyanogenmod/app/CustomTile.java | 27 +++++++++++++++++++++++- system-api/cm_system-current.txt | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/api/cm_current.txt b/api/cm_current.txt index 93d868d..ab82c67 100644 --- a/api/cm_current.txt +++ b/api/cm_current.txt @@ -17,6 +17,7 @@ package cyanogenmod.app { method public int describeContents(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; + field public boolean collapsePanel; field public java.lang.String contentDescription; field public cyanogenmod.app.CustomTile.ExpandedStyle expandedStyle; field public int icon; @@ -38,6 +39,7 @@ package cyanogenmod.app { method public cyanogenmod.app.CustomTile.Builder setOnClickIntent(android.app.PendingIntent); method public cyanogenmod.app.CustomTile.Builder setOnClickUri(android.net.Uri); method public cyanogenmod.app.CustomTile.Builder setOnSettingsClickIntent(android.content.Intent); + method public cyanogenmod.app.CustomTile.Builder shouldCollapsePanel(boolean); } public static class CustomTile.ExpandedGridItem extends cyanogenmod.app.CustomTile.ExpandedItem { diff --git a/src/java/cyanogenmod/app/CustomTile.java b/src/java/cyanogenmod/app/CustomTile.java index 3578a66..02811c3 100644 --- a/src/java/cyanogenmod/app/CustomTile.java +++ b/src/java/cyanogenmod/app/CustomTile.java @@ -82,6 +82,13 @@ public class CustomTile implements Parcelable { */ public ExpandedStyle expandedStyle; + /** + * Boolean that forces the status bar panel to collapse when a user clicks on the + * {@link CustomTile} + * By default {@link #collapsePanel} is true + */ + public boolean collapsePanel = true; + /** * Unflatten the CustomTile from a parcel. */ @@ -119,6 +126,7 @@ public class CustomTile implements Parcelable { if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) { this.resourcesPackageName = parcel.readString(); + this.collapsePanel = (parcel.readInt() == 1); } parcel.setDataPosition(startPosition + parcelableSize); @@ -149,7 +157,6 @@ public class CustomTile implements Parcelable { public String toString() { StringBuilder b = new StringBuilder(); String NEW_LINE = System.getProperty("line.separator"); - b.append("resourcesPackageName=" + resourcesPackageName + NEW_LINE); if (onClickUri != null) { b.append("onClickUri=" + onClickUri.toString() + NEW_LINE); } @@ -168,7 +175,10 @@ public class CustomTile implements Parcelable { if (expandedStyle != null) { b.append("expandedStyle=" + expandedStyle + NEW_LINE); } + b.append("icon=" + icon + NEW_LINE); + b.append("resourcesPackageName=" + resourcesPackageName + NEW_LINE); + b.append("collapsePanel=" + collapsePanel + NEW_LINE); return b.toString(); } @@ -185,6 +195,7 @@ public class CustomTile implements Parcelable { that.contentDescription = this.contentDescription; that.expandedStyle = this.expandedStyle; that.icon = this.icon; + that.collapsePanel = this.collapsePanel; } @Override @@ -245,6 +256,7 @@ public class CustomTile implements Parcelable { // ==== BOYSENBERRY ===== out.writeString(resourcesPackageName); + out.writeInt(collapsePanel ? 1 : 0); // Go back and write size int parcelableSize = out.dataPosition() - startPosition; @@ -730,6 +742,7 @@ public class CustomTile implements Parcelable { private int mIcon; private Context mContext; private ExpandedStyle mExpandedStyle; + private boolean mCollapsePanel; /** * Constructs a new Builder with the defaults: @@ -834,6 +847,17 @@ public class CustomTile implements Parcelable { return this; } + /** + * Set whether or not the Statusbar Panel should be collapsed when an + * {@link #onClick} or {@link #onClickUri} event is fired. + * @param bool + * @return {@link cyanogenmod.app.CustomTile.Builder} + */ + public Builder shouldCollapsePanel(boolean bool) { + mCollapsePanel = bool; + return this; + } + /** * Create a {@link cyanogenmod.app.CustomTile} object * @return {@link cyanogenmod.app.CustomTile} @@ -848,6 +872,7 @@ public class CustomTile implements Parcelable { tile.contentDescription = mContentDescription; tile.expandedStyle = mExpandedStyle; tile.icon = mIcon; + tile.collapsePanel = mCollapsePanel; return tile; } } diff --git a/system-api/cm_system-current.txt b/system-api/cm_system-current.txt index 93d868d..ab82c67 100644 --- a/system-api/cm_system-current.txt +++ b/system-api/cm_system-current.txt @@ -17,6 +17,7 @@ package cyanogenmod.app { method public int describeContents(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; + field public boolean collapsePanel; field public java.lang.String contentDescription; field public cyanogenmod.app.CustomTile.ExpandedStyle expandedStyle; field public int icon; @@ -38,6 +39,7 @@ package cyanogenmod.app { method public cyanogenmod.app.CustomTile.Builder setOnClickIntent(android.app.PendingIntent); method public cyanogenmod.app.CustomTile.Builder setOnClickUri(android.net.Uri); method public cyanogenmod.app.CustomTile.Builder setOnSettingsClickIntent(android.content.Intent); + method public cyanogenmod.app.CustomTile.Builder shouldCollapsePanel(boolean); } public static class CustomTile.ExpandedGridItem extends cyanogenmod.app.CustomTile.ExpandedItem {