CMSDK: Document the capabilities of ExpandedStyles for CustomTile.
Change-Id: I4e609a9ad7ec17d18271334dfb087a51eb5d5bd6
This commit is contained in:
parent
ee4e8f9bea
commit
1299f2b0e5
|
@ -73,6 +73,10 @@ public class CustomTile implements Parcelable {
|
||||||
*/
|
*/
|
||||||
public int icon;
|
public int icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An expanded style for when the CustomTile is clicked, can either be
|
||||||
|
* a {@link GridExpandedStyle} or a {@link ListExpandedStyle}
|
||||||
|
*/
|
||||||
public ExpandedStyle expandedStyle;
|
public ExpandedStyle expandedStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,12 +206,27 @@ public class CustomTile implements Parcelable {
|
||||||
out.writeInt(icon);
|
out.writeInt(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object that can apply an expanded view style to a {@link CustomTile.Builder}
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
public static class ExpandedStyle implements Parcelable {
|
public static class ExpandedStyle implements Parcelable {
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
public static final int NO_STYLE = -1;
|
public static final int NO_STYLE = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier for a grid style expanded view
|
||||||
|
*/
|
||||||
public static final int GRID_STYLE = 0;
|
public static final int GRID_STYLE = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier for a list style expanded view
|
||||||
|
*/
|
||||||
public static final int LIST_STYLE = 1;
|
public static final int LIST_STYLE = 1;
|
||||||
|
|
||||||
public ExpandedStyle() {
|
private ExpandedStyle() {
|
||||||
styleId = NO_STYLE;
|
styleId = NO_STYLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,25 +240,42 @@ public class CustomTile implements Parcelable {
|
||||||
styleId = parcel.readInt();
|
styleId = parcel.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
public void setBuilder(Builder builder) {
|
public void setBuilder(Builder builder) {
|
||||||
if (builder != null) {
|
if (builder != null) {
|
||||||
builder.setExpandedStyle(this);
|
builder.setExpandedStyle(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
protected void internalSetExpandedItems(ArrayList<? extends ExpandedItem> items) {
|
protected void internalSetExpandedItems(ArrayList<? extends ExpandedItem> items) {
|
||||||
expandedItems = new ExpandedItem[items.size()];
|
expandedItems = new ExpandedItem[items.size()];
|
||||||
items.toArray(expandedItems);
|
items.toArray(expandedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
protected void internalStyleId(int id) {
|
protected void internalStyleId(int id) {
|
||||||
styleId = id;
|
styleId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the {@link ExpandedItem}s that have been set on this expanded style
|
||||||
|
* @return array of {@link ExpandedItem}
|
||||||
|
*/
|
||||||
public ExpandedItem[] getExpandedItems() {
|
public ExpandedItem[] getExpandedItems() {
|
||||||
return expandedItems;
|
return expandedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the style id associated with the {@link ExpandedStyle}
|
||||||
|
* @return id for style
|
||||||
|
*/
|
||||||
public int getStyle() {
|
public int getStyle() {
|
||||||
return styleId;
|
return styleId;
|
||||||
}
|
}
|
||||||
|
@ -290,56 +326,112 @@ public class CustomTile implements Parcelable {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An instance of {@link ExpandedStyle} that shows the {@link ExpandedGridItem}s in a
|
||||||
|
* non-scrollable grid.
|
||||||
|
*/
|
||||||
public static class GridExpandedStyle extends ExpandedStyle {
|
public static class GridExpandedStyle extends ExpandedStyle {
|
||||||
|
/**
|
||||||
|
* Constructs a GridExpandedStyle object with default values.
|
||||||
|
*/
|
||||||
public GridExpandedStyle() {
|
public GridExpandedStyle() {
|
||||||
internalStyleId(GRID_STYLE);
|
internalStyleId(GRID_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an {@link ArrayList} of {@link ExpandedGridItem}'s to be utilized by
|
||||||
|
* the PseudoGridView for presentation.
|
||||||
|
* @param expandedGridItems an array list of {@link ExpandedGridItem}'s
|
||||||
|
*/
|
||||||
public void setGridItems(ArrayList<ExpandedGridItem> expandedGridItems) {
|
public void setGridItems(ArrayList<ExpandedGridItem> expandedGridItems) {
|
||||||
internalSetExpandedItems(expandedGridItems);
|
internalSetExpandedItems(expandedGridItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An instance of {@link ExpandedStyle} that shows the {@link ExpandedListItem}'s in a
|
||||||
|
* scrollable ListView.
|
||||||
|
*/
|
||||||
public static class ListExpandedStyle extends ExpandedStyle {
|
public static class ListExpandedStyle extends ExpandedStyle {
|
||||||
|
/**
|
||||||
|
* Constructs a ListExpandedStyle object with default values.
|
||||||
|
*/
|
||||||
public ListExpandedStyle() {
|
public ListExpandedStyle() {
|
||||||
internalStyleId(LIST_STYLE);
|
internalStyleId(LIST_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an {@link ArrayList} of {@link ExpandedListItem}s to be utilized by
|
||||||
|
* the ListView for presentation.
|
||||||
|
* @param expandedListItems an array list of {@link ExpandedListItem}s
|
||||||
|
*/
|
||||||
public void setListItems(ArrayList<ExpandedListItem> expandedListItems) {
|
public void setListItems(ArrayList<ExpandedListItem> expandedListItems) {
|
||||||
internalSetExpandedItems(expandedListItems);
|
internalSetExpandedItems(expandedListItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container object that is utilized by {@link ExpandedStyle} to show specific items in either
|
||||||
|
* a PseudoGridView or a ListView via {@link GridExpandedStyle} and {@link ListExpandedStyle}
|
||||||
|
*/
|
||||||
public static class ExpandedItem implements Parcelable {
|
public static class ExpandedItem implements Parcelable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link PendingIntent} associated with the item.
|
||||||
|
* Triggers a {@link PendingIntent#send()} when the item is clicked.
|
||||||
|
*/
|
||||||
public PendingIntent onClickPendingIntent;
|
public PendingIntent onClickPendingIntent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A drawable resource id associated with the {@link ExpandedItem}
|
||||||
|
*/
|
||||||
public int itemDrawableResourceId;
|
public int itemDrawableResourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The title of the item
|
||||||
|
*/
|
||||||
public String itemTitle;
|
public String itemTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The summary associated with the item, may be null
|
||||||
|
*/
|
||||||
public String itemSummary = null;
|
public String itemSummary = null;
|
||||||
|
|
||||||
private ExpandedItem() {
|
private ExpandedItem() {
|
||||||
// Don't want to have this baseclass be instantiable
|
// Don't want to have this baseclass be instantiable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
protected void internalSetItemDrawable(int resourceId) {
|
protected void internalSetItemDrawable(int resourceId) {
|
||||||
itemDrawableResourceId = resourceId;
|
itemDrawableResourceId = resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
protected void internalSetItemSummary(String resourceId) {
|
protected void internalSetItemSummary(String resourceId) {
|
||||||
itemSummary = resourceId;
|
itemSummary = resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
protected void internalSetItemTitle(String title) {
|
protected void internalSetItemTitle(String title) {
|
||||||
itemTitle = title;
|
itemTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
protected void internalSetOnClickPendingIntent(PendingIntent pendingIntent) {
|
protected void internalSetOnClickPendingIntent(PendingIntent pendingIntent) {
|
||||||
onClickPendingIntent = pendingIntent;
|
onClickPendingIntent = pendingIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unflatten the ExpandedItem from a parcel.
|
||||||
|
*/
|
||||||
protected ExpandedItem(Parcel parcel) {
|
protected ExpandedItem(Parcel parcel) {
|
||||||
if (parcel.readInt() != 0) {
|
if (parcel.readInt() != 0) {
|
||||||
onClickPendingIntent = PendingIntent.CREATOR.createFromParcel(parcel);
|
onClickPendingIntent = PendingIntent.CREATOR.createFromParcel(parcel);
|
||||||
|
@ -398,54 +490,93 @@ public class CustomTile implements Parcelable {
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public static final Creator<ExpandedItem> CREATOR =
|
public static final Creator<ExpandedItem> CREATOR =
|
||||||
new Creator<ExpandedItem>() {
|
new Creator<ExpandedItem>() {
|
||||||
@Override
|
@Override
|
||||||
public ExpandedItem createFromParcel(Parcel in) {
|
public ExpandedItem createFromParcel(Parcel in) {
|
||||||
return new ExpandedItem(in);
|
return new ExpandedItem(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExpandedItem[] newArray(int size) {
|
public ExpandedItem[] newArray(int size) {
|
||||||
return new ExpandedItem[size];
|
return new ExpandedItem[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An instance of {@link ExpandedItem} to be utilized within a {@link GridExpandedStyle}
|
||||||
|
*/
|
||||||
public static class ExpandedGridItem extends ExpandedItem {
|
public static class ExpandedGridItem extends ExpandedItem {
|
||||||
|
/**
|
||||||
|
* Constructor for the ExpandedGridItem
|
||||||
|
*/
|
||||||
public ExpandedGridItem() {
|
public ExpandedGridItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the title for the {@link ExpandedGridItem}
|
||||||
|
* @param title a string title
|
||||||
|
*/
|
||||||
public void setExpandedGridItemTitle(String title) {
|
public void setExpandedGridItemTitle(String title) {
|
||||||
internalSetItemTitle(title);
|
internalSetItemTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link PendingIntent} associated with the {@link ExpandedGridItem}
|
||||||
|
* @param intent a pending intent to be triggered on click
|
||||||
|
*/
|
||||||
public void setExpandedGridItemOnClickIntent(PendingIntent intent) {
|
public void setExpandedGridItemOnClickIntent(PendingIntent intent) {
|
||||||
internalSetOnClickPendingIntent(intent);
|
internalSetOnClickPendingIntent(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the drawable resource id associated with the {@link ExpandedGridItem}
|
||||||
|
* @param resourceId a resource id that maps to a drawable
|
||||||
|
*/
|
||||||
public void setExpandedGridItemDrawable(int resourceId) {
|
public void setExpandedGridItemDrawable(int resourceId) {
|
||||||
internalSetItemDrawable(resourceId);
|
internalSetItemDrawable(resourceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An instance of {@link ExpandedItem} to be utilized within a {@link ListExpandedStyle}
|
||||||
|
*/
|
||||||
public static class ExpandedListItem extends ExpandedItem {
|
public static class ExpandedListItem extends ExpandedItem {
|
||||||
|
/**
|
||||||
|
* Constructor fot the ExpandedListItem
|
||||||
|
*/
|
||||||
public ExpandedListItem() {
|
public ExpandedListItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the title for the {@link ExpandedListItem}
|
||||||
|
* @param title a string title
|
||||||
|
*/
|
||||||
public void setExpandedListItemTitle(String title) {
|
public void setExpandedListItemTitle(String title) {
|
||||||
internalSetItemTitle(title);
|
internalSetItemTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExpandedListItemSummary(String subText) {
|
/**
|
||||||
internalSetItemSummary(subText);
|
* Sets the title for the {@link ExpandedListItem}
|
||||||
|
* @param summary a string summary
|
||||||
|
*/
|
||||||
|
public void setExpandedListItemSummary(String summary) {
|
||||||
|
internalSetItemSummary(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link PendingIntent} associated with the {@link ExpandedListItem}
|
||||||
|
* @param intent a pending intent to be triggered on click
|
||||||
|
*/
|
||||||
public void setExpandedListItemOnClickIntent(PendingIntent intent) {
|
public void setExpandedListItemOnClickIntent(PendingIntent intent) {
|
||||||
internalSetOnClickPendingIntent(intent);
|
internalSetOnClickPendingIntent(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the drawable resource id associated with the {@link ExpandedListItem}
|
||||||
|
* @param resourceId a resource id that maps to a drawable
|
||||||
|
*/
|
||||||
public void setExpandedListItemDrawable(int resourceId) {
|
public void setExpandedListItemDrawable(int resourceId) {
|
||||||
internalSetItemDrawable(resourceId);
|
internalSetItemDrawable(resourceId);
|
||||||
}
|
}
|
||||||
|
@ -582,6 +713,11 @@ public class CustomTile implements Parcelable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an {@link ExpandedStyle} to to be displayed when a user clicks the custom tile
|
||||||
|
* @param expandedStyle
|
||||||
|
* @return {@link cyanogenmod.app.CustomTile.Builder}
|
||||||
|
*/
|
||||||
public Builder setExpandedStyle(ExpandedStyle expandedStyle) {
|
public Builder setExpandedStyle(ExpandedStyle expandedStyle) {
|
||||||
if (mExpandedStyle != expandedStyle) {
|
if (mExpandedStyle != expandedStyle) {
|
||||||
mExpandedStyle = expandedStyle;
|
mExpandedStyle = expandedStyle;
|
||||||
|
|
Loading…
Reference in New Issue