java.lang.Objectcom.google.android.apps.dashclock.api.ExtensionData
public class ExtensionData
A parcelable, serializable object representing data related to a DashClockExtension that
should be shown to the user.
This class follows the fluent
interface style, using method chaining to provide for more readable code. For example, to set
the status and visibility of this data, use status(String) and visible(boolean)
methods like so:
ExtensionData data = new ExtensionData();
data.visible(true).status("hello");
Conversely, to get the status, use status(). Setters and getters are thus overloads
(or overlords?) of the same method.
visible(boolean) has been
called with true, at least the following fields should be populated:
Really awesome extensions will also set these fields:
DashClockExtension.publishUpdate(ExtensionData)| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface android.os.Parcelable |
|---|
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T> |
| Field Summary | |
|---|---|
static Parcelable.Creator<ExtensionData> |
CREATOR
|
static int |
MAX_CONTENT_DESCRIPTION_LENGTH
The maximum length for contentDescription(String). |
static int |
MAX_EXPANDED_BODY_LENGTH
The maximum length for expandedBody(String). |
static int |
MAX_EXPANDED_TITLE_LENGTH
The maximum length for expandedTitle(String). |
static int |
MAX_STATUS_LENGTH
The maximum length for status(String). |
static int |
PARCELABLE_VERSION
Since there might be a case where new versions of DashClock use extensions running old versions of the protocol (and thus old versions of this class), we need a versioning system for the parcels sent between the core app and its extensions. |
| Fields inherited from interface android.os.Parcelable |
|---|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE |
| Constructor Summary | |
|---|---|
ExtensionData()
|
|
| Method Summary | |
|---|---|
void |
clean()
Cleans up this object's data according to the size limits described by MAX_STATUS_LENGTH, MAX_EXPANDED_TITLE_LENGTH, etc. |
Intent |
clickIntent()
Returns the click intent to start (using Context.startActivity(android.content.Intent)) when the user clicks
the status in DashClock. |
ExtensionData |
clickIntent(Intent clickIntent)
Sets the click intent to start (using Context.startActivity(android.content.Intent)) when the user clicks
the status in DashClock. |
String |
contentDescription()
Returns the content description for this data, used for accessibility purposes. |
ExtensionData |
contentDescription(String contentDescription)
Sets the content description for this data. |
int |
describeContents()
|
void |
deserialize(JSONObject data)
Deserializes the given JSON representation of extension data, populating this object. |
static boolean |
equals(ExtensionData x,
ExtensionData y)
Returns true if the two provided data objects are equal (or both null). |
boolean |
equals(Object o)
|
String |
expandedBody()
Returns the expanded body text representing this data. |
ExtensionData |
expandedBody(String expandedBody)
Sets the expanded body text (below the expanded title), representing this data. |
String |
expandedTitle()
Returns the expanded title representing this data. |
ExtensionData |
expandedTitle(String expandedTitle)
Sets the expanded title representing this data. |
void |
fromBundle(Bundle src)
Deserializes the given Bundle representation of extension data, populating this
object. |
int |
hashCode()
|
int |
icon()
Returns the ID of the drawable resource within the extension's package that represents this data. |
ExtensionData |
icon(int icon)
Sets the ID of the drawable resource within the extension's package that represents this data. |
Uri |
iconUri()
Returns the content:// URI of a bitmap representing this data. |
ExtensionData |
iconUri(Uri iconUri)
Sets the content:// URI of the bitmap representing this data. |
JSONObject |
serialize()
Serializes the contents of this object to JSON. |
String |
status()
Returns the short string representing this data, to be shown in DashClock's collapsed form. |
ExtensionData |
status(String status)
Sets the short string representing this data, to be shown in DashClock's collapsed form. |
Bundle |
toBundle()
Serializes the contents of this object to a Bundle. |
boolean |
visible()
Returns whether or not the relevant extension should be visible (whether or not there is relevant information to show to the user about the extension). |
ExtensionData |
visible(boolean visible)
Sets whether or not the relevant extension should be visible (whether or not there is relevant information to show to the user about the extension). |
void |
writeToParcel(Parcel parcel,
int i)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Parcelable.Creator<ExtensionData> CREATOR
Parcelablepublic static final int MAX_CONTENT_DESCRIPTION_LENGTH
contentDescription(String). Enforced by clean().
public static final int MAX_EXPANDED_BODY_LENGTH
expandedBody(String). Enforced by clean().
public static final int MAX_EXPANDED_TITLE_LENGTH
expandedTitle(String). Enforced by clean().
public static final int MAX_STATUS_LENGTH
status(String). Enforced by clean().
public static final int PARCELABLE_VERSION
| Constructor Detail |
|---|
public ExtensionData()
| Method Detail |
|---|
public void clean()
MAX_STATUS_LENGTH, MAX_EXPANDED_TITLE_LENGTH, etc.
public Intent clickIntent()
Context.startActivity(android.content.Intent)) when the user clicks
the status in DashClock. Default null.
public ExtensionData clickIntent(Intent clickIntent)
Context.startActivity(android.content.Intent)) when the user clicks
the status in DashClock. The activity represented by this intent will be started in a new
task and should be exported. Default null.
public String contentDescription()
public ExtensionData contentDescription(String contentDescription)
status(), expandedTitle() and expandedBody() for accessibility
purposes.
Viewpublic int describeContents()
describeContents in interface Parcelable
public void deserialize(JSONObject data)
throws JSONException
JSONException
public static boolean equals(ExtensionData x,
ExtensionData y)
public boolean equals(Object o)
equals in class Objectpublic String expandedBody()
public ExtensionData expandedBody(String expandedBody)
public String expandedTitle()
status(). Default null.
public ExtensionData expandedTitle(String expandedTitle)
status(). Can be multiple lines, although DashClock will cap the number of lines
shown. If this is not set, DashClock will just use the status().
Default null.
public void fromBundle(Bundle src)
Bundle representation of extension data, populating this
object.
public int hashCode()
hashCode in class Objectpublic int icon()
public ExtensionData icon(int icon)
iconUri is provided, it
will take precedence over this value. Default 0.
iconUri(Uri)public Uri iconUri()
public ExtensionData iconUri(Uri iconUri)
icon resource ID if set. This resource will be loaded
using ContentResolver.openFileDescriptor(android.net.Uri, String) and
BitmapFactory. See the
icon method for guidelines on the styling of this bitmap.
public JSONObject serialize()
throws JSONException
JSONExceptionpublic String status()
public ExtensionData status(String status)
expandedTitle() is
"45°, Sunny", your status could simply be "45°". Alternatively, if the status contains a
single newline, DashClock may break it up over two lines and use a smaller font. This should
be avoided where possible in favor of an expandedTitle(String). Default null.
public Bundle toBundle()
Bundle.
public boolean visible()
public ExtensionData visible(boolean visible)
public void writeToParcel(Parcel parcel,
int i)
writeToParcel in interface Parcelable