CMSDK: Allow for a settings intent to be set by 3rd party.
This onSettingsClick intent will be triggered when the detail pane is shown in SystemuI and the user clicks "More Settings". Change-Id: I3ddb65c64e81cd230718e7e6e56c436e5b05df8c
This commit is contained in:
parent
aa558ade9e
commit
346b7587b3
@ -18,6 +18,7 @@ package cyanogenmod.app;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@ -39,6 +40,14 @@ public class CustomTile implements Parcelable {
|
||||
**/
|
||||
public PendingIntent onClick;
|
||||
|
||||
/**
|
||||
* An optional settings intent to execute when the custom tile's detail is shown
|
||||
* If this is an activity, it must include the
|
||||
* {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} flag, which requires
|
||||
* that you take care of task management
|
||||
*/
|
||||
public Intent onSettingsClick;
|
||||
|
||||
/**
|
||||
* An optional Uri to be parsed and broadcast on tile click
|
||||
**/
|
||||
@ -67,6 +76,9 @@ public class CustomTile implements Parcelable {
|
||||
if (parcel.readInt() != 0) {
|
||||
this.onClick = PendingIntent.CREATOR.createFromParcel(parcel);
|
||||
}
|
||||
if (parcel.readInt() != 0) {
|
||||
this.onSettingsClick = Intent.CREATOR.createFromParcel(parcel);
|
||||
}
|
||||
if (parcel.readInt() != 0) {
|
||||
this.onClickUri = Uri.CREATOR.createFromParcel(parcel);
|
||||
}
|
||||
@ -106,6 +118,9 @@ public class CustomTile implements Parcelable {
|
||||
if (onClick != null) {
|
||||
b.append("onClick=" + onClick.toString() + NEW_LINE);
|
||||
}
|
||||
if (onSettingsClick != null) {
|
||||
b.append("onSettingsClick=" + onSettingsClick.toString() + NEW_LINE);
|
||||
}
|
||||
if (!TextUtils.isEmpty(label)) {
|
||||
b.append("label=" + label + NEW_LINE);
|
||||
}
|
||||
@ -122,6 +137,7 @@ public class CustomTile implements Parcelable {
|
||||
*/
|
||||
public void cloneInto(CustomTile that) {
|
||||
that.onClick = this.onClick;
|
||||
that.onSettingsClick = this.onSettingsClick;
|
||||
that.onClickUri = this.onClickUri;
|
||||
that.label = this.label;
|
||||
that.contentDescription = this.contentDescription;
|
||||
@ -141,6 +157,12 @@ public class CustomTile implements Parcelable {
|
||||
} else {
|
||||
out.writeInt(0);
|
||||
}
|
||||
if (onSettingsClick != null) {
|
||||
out.writeInt(1);
|
||||
onSettingsClick.writeToParcel(out, 0);
|
||||
} else {
|
||||
out.writeInt(0);
|
||||
}
|
||||
if (onClickUri != null) {
|
||||
out.writeInt(1);
|
||||
onClickUri.writeToParcel(out, 0);
|
||||
@ -189,6 +211,7 @@ public class CustomTile implements Parcelable {
|
||||
* .setLabel("custom label")
|
||||
* .setContentDescription("custom description")
|
||||
* .setOnClickIntent(pendingIntent)
|
||||
* .setOnSettingsClickIntent(intent)
|
||||
* .setOnClickUri(Uri.parse("custom uri"))
|
||||
* .setIcon(R.drawable.ic_launcher)
|
||||
* .build();
|
||||
@ -196,6 +219,7 @@ public class CustomTile implements Parcelable {
|
||||
*/
|
||||
public static class Builder {
|
||||
private PendingIntent mOnClick;
|
||||
private Intent mOnSettingsClick;
|
||||
private Uri mOnClickUri;
|
||||
private String mLabel;
|
||||
private String mContentDescription;
|
||||
@ -259,6 +283,17 @@ public class CustomTile implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a settings {@link android.content.Intent} to be fired on custom
|
||||
* tile detail pane click
|
||||
* @param intent
|
||||
* @return {@link cyanogenmod.app.CustomTile.Builder}
|
||||
*/
|
||||
public Builder setOnSettingsClickIntent(Intent intent) {
|
||||
mOnSettingsClick = intent;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a {@link android.net.Uri} to be broadcasted in an intent on custom tile click
|
||||
* @param uri
|
||||
@ -286,6 +321,7 @@ public class CustomTile implements Parcelable {
|
||||
public CustomTile build() {
|
||||
CustomTile tile = new CustomTile();
|
||||
tile.onClick = mOnClick;
|
||||
tile.onSettingsClick = mOnSettingsClick;
|
||||
tile.onClickUri = mOnClickUri;
|
||||
tile.label = mLabel;
|
||||
tile.contentDescription = mContentDescription;
|
||||
|
Loading…
Reference in New Issue
Block a user