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.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@ -39,6 +40,14 @@ public class CustomTile implements Parcelable {
|
|||||||
**/
|
**/
|
||||||
public PendingIntent onClick;
|
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
|
* An optional Uri to be parsed and broadcast on tile click
|
||||||
**/
|
**/
|
||||||
@ -67,6 +76,9 @@ public class CustomTile implements Parcelable {
|
|||||||
if (parcel.readInt() != 0) {
|
if (parcel.readInt() != 0) {
|
||||||
this.onClick = PendingIntent.CREATOR.createFromParcel(parcel);
|
this.onClick = PendingIntent.CREATOR.createFromParcel(parcel);
|
||||||
}
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
this.onSettingsClick = Intent.CREATOR.createFromParcel(parcel);
|
||||||
|
}
|
||||||
if (parcel.readInt() != 0) {
|
if (parcel.readInt() != 0) {
|
||||||
this.onClickUri = Uri.CREATOR.createFromParcel(parcel);
|
this.onClickUri = Uri.CREATOR.createFromParcel(parcel);
|
||||||
}
|
}
|
||||||
@ -106,6 +118,9 @@ public class CustomTile implements Parcelable {
|
|||||||
if (onClick != null) {
|
if (onClick != null) {
|
||||||
b.append("onClick=" + onClick.toString() + NEW_LINE);
|
b.append("onClick=" + onClick.toString() + NEW_LINE);
|
||||||
}
|
}
|
||||||
|
if (onSettingsClick != null) {
|
||||||
|
b.append("onSettingsClick=" + onSettingsClick.toString() + NEW_LINE);
|
||||||
|
}
|
||||||
if (!TextUtils.isEmpty(label)) {
|
if (!TextUtils.isEmpty(label)) {
|
||||||
b.append("label=" + label + NEW_LINE);
|
b.append("label=" + label + NEW_LINE);
|
||||||
}
|
}
|
||||||
@ -122,6 +137,7 @@ public class CustomTile implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public void cloneInto(CustomTile that) {
|
public void cloneInto(CustomTile that) {
|
||||||
that.onClick = this.onClick;
|
that.onClick = this.onClick;
|
||||||
|
that.onSettingsClick = this.onSettingsClick;
|
||||||
that.onClickUri = this.onClickUri;
|
that.onClickUri = this.onClickUri;
|
||||||
that.label = this.label;
|
that.label = this.label;
|
||||||
that.contentDescription = this.contentDescription;
|
that.contentDescription = this.contentDescription;
|
||||||
@ -141,6 +157,12 @@ public class CustomTile implements Parcelable {
|
|||||||
} else {
|
} else {
|
||||||
out.writeInt(0);
|
out.writeInt(0);
|
||||||
}
|
}
|
||||||
|
if (onSettingsClick != null) {
|
||||||
|
out.writeInt(1);
|
||||||
|
onSettingsClick.writeToParcel(out, 0);
|
||||||
|
} else {
|
||||||
|
out.writeInt(0);
|
||||||
|
}
|
||||||
if (onClickUri != null) {
|
if (onClickUri != null) {
|
||||||
out.writeInt(1);
|
out.writeInt(1);
|
||||||
onClickUri.writeToParcel(out, 0);
|
onClickUri.writeToParcel(out, 0);
|
||||||
@ -189,6 +211,7 @@ public class CustomTile implements Parcelable {
|
|||||||
* .setLabel("custom label")
|
* .setLabel("custom label")
|
||||||
* .setContentDescription("custom description")
|
* .setContentDescription("custom description")
|
||||||
* .setOnClickIntent(pendingIntent)
|
* .setOnClickIntent(pendingIntent)
|
||||||
|
* .setOnSettingsClickIntent(intent)
|
||||||
* .setOnClickUri(Uri.parse("custom uri"))
|
* .setOnClickUri(Uri.parse("custom uri"))
|
||||||
* .setIcon(R.drawable.ic_launcher)
|
* .setIcon(R.drawable.ic_launcher)
|
||||||
* .build();
|
* .build();
|
||||||
@ -196,6 +219,7 @@ public class CustomTile implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private PendingIntent mOnClick;
|
private PendingIntent mOnClick;
|
||||||
|
private Intent mOnSettingsClick;
|
||||||
private Uri mOnClickUri;
|
private Uri mOnClickUri;
|
||||||
private String mLabel;
|
private String mLabel;
|
||||||
private String mContentDescription;
|
private String mContentDescription;
|
||||||
@ -259,6 +283,17 @@ public class CustomTile implements Parcelable {
|
|||||||
return this;
|
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
|
* Set a {@link android.net.Uri} to be broadcasted in an intent on custom tile click
|
||||||
* @param uri
|
* @param uri
|
||||||
@ -286,6 +321,7 @@ public class CustomTile implements Parcelable {
|
|||||||
public CustomTile build() {
|
public CustomTile build() {
|
||||||
CustomTile tile = new CustomTile();
|
CustomTile tile = new CustomTile();
|
||||||
tile.onClick = mOnClick;
|
tile.onClick = mOnClick;
|
||||||
|
tile.onSettingsClick = mOnSettingsClick;
|
||||||
tile.onClickUri = mOnClickUri;
|
tile.onClickUri = mOnClickUri;
|
||||||
tile.label = mLabel;
|
tile.label = mLabel;
|
||||||
tile.contentDescription = mContentDescription;
|
tile.contentDescription = mContentDescription;
|
||||||
|
Loading…
Reference in New Issue
Block a user