Skip to content

Commit

Permalink
cmsdk: Add method for shouldCollapsePanel.
Browse files Browse the repository at this point in the history
  - Allow for disabling of panel collapse when
  handling an onClick or onClickUri event in
  CustomTile.

Change-Id: I73bd513baf0fb8b7db33020a3456430702ccd609
  • Loading branch information
Adnan Begovic committed Jul 27, 2015
1 parent ff70beb commit 3290540
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/cm_current.txt
Expand Up @@ -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<cyanogenmod.app.CustomTile> CREATOR;
field public boolean collapsePanel;
field public java.lang.String contentDescription;
field public cyanogenmod.app.CustomTile.ExpandedStyle expandedStyle;
field public int icon;
Expand All @@ -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 {
Expand Down
27 changes: 26 additions & 1 deletion src/java/cyanogenmod/app/CustomTile.java
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -119,6 +126,7 @@ public CustomTile(Parcel parcel) {

if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
this.resourcesPackageName = parcel.readString();
this.collapsePanel = (parcel.readInt() == 1);
}

parcel.setDataPosition(startPosition + parcelableSize);
Expand Down Expand Up @@ -149,7 +157,6 @@ public CustomTile clone() {
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);
}
Expand All @@ -168,7 +175,10 @@ public String toString() {
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();
}

Expand All @@ -185,6 +195,7 @@ public void cloneInto(CustomTile that) {
that.contentDescription = this.contentDescription;
that.expandedStyle = this.expandedStyle;
that.icon = this.icon;
that.collapsePanel = this.collapsePanel;
}

@Override
Expand Down Expand Up @@ -245,6 +256,7 @@ public void writeToParcel(Parcel out, int flags) {

// ==== BOYSENBERRY =====
out.writeString(resourcesPackageName);
out.writeInt(collapsePanel ? 1 : 0);

// Go back and write size
int parcelableSize = out.dataPosition() - startPosition;
Expand Down Expand Up @@ -730,6 +742,7 @@ public static class Builder {
private int mIcon;
private Context mContext;
private ExpandedStyle mExpandedStyle;
private boolean mCollapsePanel;

/**
* Constructs a new Builder with the defaults:
Expand Down Expand Up @@ -834,6 +847,17 @@ public Builder setExpandedStyle(ExpandedStyle expandedStyle) {
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}
Expand All @@ -848,6 +872,7 @@ public CustomTile build() {
tile.contentDescription = mContentDescription;
tile.expandedStyle = mExpandedStyle;
tile.icon = mIcon;
tile.collapsePanel = mCollapsePanel;
return tile;
}
}
Expand Down
2 changes: 2 additions & 0 deletions system-api/cm_system-current.txt
Expand Up @@ -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<cyanogenmod.app.CustomTile> CREATOR;
field public boolean collapsePanel;
field public java.lang.String contentDescription;
field public cyanogenmod.app.CustomTile.ExpandedStyle expandedStyle;
field public int icon;
Expand All @@ -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 {
Expand Down

0 comments on commit 3290540

Please sign in to comment.