cmsdk: Add method for shouldCollapsePanel.

- Allow for disabling of panel collapse when
  handling an onClick or onClickUri event in
  CustomTile.

Change-Id: I73bd513baf0fb8b7db33020a3456430702ccd609
This commit is contained in:
Adnan Begovic 2015-07-22 13:34:09 -07:00
parent ff70bebdc9
commit 3290540468
3 changed files with 30 additions and 1 deletions

View File

@ -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;
@ -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 {

View File

@ -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;
}
}

View File

@ -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;
@ -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 {