Allow system apps to add to settings dashboard

Allow system apps to add a tile to the top level of settings that
links to an activity through adding a filter for a specific action.
Determine the info for the tile based off manifest info for the
activity. Also allow the same for managed profiles, but show a dialog
in between to select which profile.

The category in which the item is to be placed must be in meta-data.
The icon and title can be specified through meta-data as well or
if unspecified the activity's label and icon will be used.

Also added an optional <external-tiles> tag to the dashboard
category xml, this allows Settings to put external tiles
in the middle of some categories (Personal does this).

Bug: 19443117
Change-Id: Idc9938d1549d181103a3030a8784b527215a8399
This commit is contained in:
Jason Monk
2015-02-13 15:23:19 -05:00
parent 5528d8952b
commit 2ebc8a0169
14 changed files with 328 additions and 37 deletions

View File

@@ -21,8 +21,11 @@ import android.content.res.Resources;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
import android.text.TextUtils;
import java.util.ArrayList;
/**
* Description of a single dashboard tile that the user can select.
*/
@@ -72,6 +75,11 @@ public class DashboardTile implements Parcelable {
*/
public int iconRes;
/**
* Optional package to pull the icon resource from.
*/
public String iconPkg;
/**
* Full class name of the fragment to display when this tile is
* selected.
@@ -90,6 +98,11 @@ public class DashboardTile implements Parcelable {
*/
public Intent intent;
/**
* Optional list of user handles which the intent should be launched on.
*/
public ArrayList<UserHandle> userHandle = new ArrayList<>();
/**
* Optional additional data for use by subclasses of the activity
*/
@@ -136,6 +149,7 @@ public class DashboardTile implements Parcelable {
dest.writeInt(summaryRes);
TextUtils.writeToParcel(summary, dest, flags);
dest.writeInt(iconRes);
dest.writeString(iconPkg);
dest.writeString(fragment);
dest.writeBundle(fragmentArguments);
if (intent != null) {
@@ -144,6 +158,11 @@ public class DashboardTile implements Parcelable {
} else {
dest.writeInt(0);
}
final int N = userHandle.size();
dest.writeInt(N);
for (int i = 0; i < N; i++) {
dest.writeParcelable(userHandle.get(i), flags);
}
dest.writeBundle(extras);
}
@@ -154,11 +173,16 @@ public class DashboardTile implements Parcelable {
summaryRes = in.readInt();
summary = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
iconRes = in.readInt();
iconPkg = in.readString();
fragment = in.readString();
fragmentArguments = in.readBundle();
if (in.readInt() != 0) {
intent = Intent.CREATOR.createFromParcel(in);
}
final int N = in.readInt();
for (int i = 0; i < N; i++) {
userHandle.add(UserHandle.CREATOR.createFromParcel(in));
}
extras = in.readBundle();
}