Implement all of the infrastructure for configuring wallpapers.

Actually being able to configure a wallpaper relies on additional
work in the launcher and wallpapers that will be in another change.
Also note that this breaks all existing wallpapers, since they now
need to include a meta-data item about themselves.  This also
will be fixed in another change.

Change-Id: I97d2c2bd07237abc32f92b9147c32530a2f73c71
This commit is contained in:
Dianne Hackborn
2009-09-07 00:49:58 -07:00
parent 9c93007bcd
commit eb034652c2
21 changed files with 880 additions and 44 deletions

View File

@@ -1928,6 +1928,15 @@ public class Intent implements Parcelable {
*/
public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
/**
* A Parcelable[] of {@link Intent} or
* {@link android.content.pm.LabeledIntent} objects as set with
* {@link #putExtra(String, Parcelable[])} of additional activities to place
* a the front of the list of choices, when shown to the user with a
* {@link #ACTION_CHOOSER}.
*/
public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
/**
* A {@link android.view.KeyEvent} object containing the event that
* triggered the creation of the Intent it is in.
@@ -5067,7 +5076,8 @@ public class Intent implements Parcelable {
}
};
private Intent(Parcel in) {
/** @hide */
protected Intent(Parcel in) {
readFromParcel(in);
}

View File

@@ -0,0 +1,177 @@
package android.content.pm;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.text.TextUtils;
/**
* A special subclass of Intent that can have a custom label/icon
* associated with it. Primarily for use with {@link Intent#ACTION_CHOOSER}.
*/
public class LabeledIntent extends Intent {
private String mSourcePackage;
private int mLabelRes;
private CharSequence mNonLocalizedLabel;
private int mIcon;
/**
* Create a labeled intent from the given intent, supplying the label
* and icon resources for it.
*
* @param origIntent The original Intent to copy.
* @param sourcePackage The package in which the label and icon live.
* @param labelRes Resource containing the label, or 0 if none.
* @param icon Resource containing the icon, or 0 if none.
*/
public LabeledIntent(Intent origIntent, String sourcePackage,
int labelRes, int icon) {
super(origIntent);
mSourcePackage = sourcePackage;
mLabelRes = labelRes;
mNonLocalizedLabel = null;
mIcon = icon;
}
/**
* Create a labeled intent from the given intent, supplying a textual
* label and icon resource for it.
*
* @param origIntent The original Intent to copy.
* @param sourcePackage The package in which the label and icon live.
* @param nonLocalizedLabel Concrete text to use for the label.
* @param icon Resource containing the icon, or 0 if none.
*/
public LabeledIntent(Intent origIntent, String sourcePackage,
CharSequence nonLocalizedLabel, int icon) {
super(origIntent);
mSourcePackage = sourcePackage;
mLabelRes = 0;
mNonLocalizedLabel = nonLocalizedLabel;
mIcon = icon;
}
/**
* Create a labeled intent with no intent data but supplying the label
* and icon resources for it.
*
* @param sourcePackage The package in which the label and icon live.
* @param labelRes Resource containing the label, or 0 if none.
* @param icon Resource containing the icon, or 0 if none.
*/
public LabeledIntent(String sourcePackage, int labelRes, int icon) {
mSourcePackage = sourcePackage;
mLabelRes = labelRes;
mNonLocalizedLabel = null;
mIcon = icon;
}
/**
* Create a labeled intent with no intent data but supplying a textual
* label and icon resource for it.
*
* @param sourcePackage The package in which the label and icon live.
* @param nonLocalizedLabel Concrete text to use for the label.
* @param icon Resource containing the icon, or 0 if none.
*/
public LabeledIntent(String sourcePackage,
CharSequence nonLocalizedLabel, int icon) {
mSourcePackage = sourcePackage;
mLabelRes = 0;
mNonLocalizedLabel = nonLocalizedLabel;
mIcon = icon;
}
/**
* Return the name of the package holding label and icon resources.
*/
public String getSourcePackage() {
return mSourcePackage;
}
/**
* Return any resource identifier that has been given for the label text.
*/
public int getLabelResource() {
return mLabelRes;
}
/**
* Return any concrete text that has been given for the label text.
*/
public CharSequence getNonLocalizedLabel() {
return mNonLocalizedLabel;
}
/**
* Return any resource identifier that has been given for the label icon.
*/
public int getIconResource() {
return mIcon;
}
/**
* Retrieve the label associated with this object. If the object does
* not have a label, null will be returned, in which case you will probably
* want to load the label from the underlying resolved info for the Intent.
*/
public CharSequence loadLabel(PackageManager pm) {
if (mNonLocalizedLabel != null) {
return mNonLocalizedLabel;
}
if (mLabelRes != 0 && mSourcePackage != null) {
CharSequence label = pm.getText(mSourcePackage, mLabelRes, null);
if (label != null) {
return label;
}
}
return null;
}
/**
* Retrieve the icon associated with this object. If the object does
* not have a icon, null will be returned, in which case you will probably
* want to load the icon from the underlying resolved info for the Intent.
*/
public Drawable loadIcon(PackageManager pm) {
if (mIcon != 0 && mSourcePackage != null) {
Drawable icon = pm.getDrawable(mSourcePackage, mIcon, null);
if (icon != null) {
return icon;
}
}
return null;
}
public void writeToParcel(Parcel dest, int parcelableFlags) {
super.writeToParcel(dest, parcelableFlags);
dest.writeString(mSourcePackage);
dest.writeInt(mLabelRes);
TextUtils.writeToParcel(mNonLocalizedLabel, dest, parcelableFlags);
dest.writeInt(mIcon);
}
/** @hide */
protected LabeledIntent(Parcel in) {
readFromParcel(in);
}
public void readFromParcel(Parcel in) {
super.readFromParcel(in);
mSourcePackage = in.readString();
mLabelRes = in.readInt();
mNonLocalizedLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
mIcon = in.readInt();
}
public static final Creator<LabeledIntent> CREATOR
= new Creator<LabeledIntent>() {
public LabeledIntent createFromParcel(Parcel source) {
return new LabeledIntent(source);
}
public LabeledIntent[] newArray(int size) {
return new LabeledIntent[size];
}
};
}

View File

@@ -91,6 +91,13 @@ public class ResolveInfo implements Parcelable {
*/
public int icon;
/**
* Optional -- if non-null, the {@link #labelRes} and {@link #icon}
* resources will be loaded from this package, rather than the one
* containing the resolved component.
*/
public String resolvePackageName;
/**
* Retrieve the current textual label associated with this resolution. This
* will call back on the given PackageManager to load the label from
@@ -106,9 +113,15 @@ public class ResolveInfo implements Parcelable {
if (nonLocalizedLabel != null) {
return nonLocalizedLabel;
}
CharSequence label;
if (resolvePackageName != null && labelRes != 0) {
label = pm.getText(resolvePackageName, labelRes, null);
if (label != null) {
return label;
}
}
ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo;
ApplicationInfo ai = ci.applicationInfo;
CharSequence label;
if (labelRes != 0) {
label = pm.getText(ci.packageName, labelRes, ai);
if (label != null) {
@@ -133,6 +146,12 @@ public class ResolveInfo implements Parcelable {
ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo;
ApplicationInfo ai = ci.applicationInfo;
Drawable dr;
if (resolvePackageName != null && icon != 0) {
dr = pm.getDrawable(resolvePackageName, icon, null);
if (dr != null) {
return dr;
}
}
if (icon != 0) {
dr = pm.getDrawable(ci.packageName, icon, ai);
if (dr != null) {
@@ -160,24 +179,26 @@ public class ResolveInfo implements Parcelable {
if (filter != null) {
pw.println(prefix + "Filter:");
filter.dump(pw, prefix + " ");
} else {
pw.println(prefix + "Filter: null");
}
pw.println(prefix + "priority=" + priority
+ " preferredOrder=" + preferredOrder
+ " match=0x" + Integer.toHexString(match)
+ " specificIndex=" + specificIndex
+ " isDefault=" + isDefault);
pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
+ " nonLocalizedLabel=" + nonLocalizedLabel
+ " icon=0x" + Integer.toHexString(icon));
if (resolvePackageName != null) {
pw.println(prefix + "resolvePackageName=" + resolvePackageName);
}
if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
+ " nonLocalizedLabel=" + nonLocalizedLabel
+ " icon=0x" + Integer.toHexString(icon));
}
if (activityInfo != null) {
pw.println(prefix + "ActivityInfo:");
activityInfo.dump(pw, prefix + " ");
} else if (serviceInfo != null) {
pw.println(prefix + "ServiceInfo:");
// TODO
//serviceInfo.dump(pw, prefix + " ");
serviceInfo.dump(pw, prefix + " ");
}
}
@@ -219,6 +240,7 @@ public class ResolveInfo implements Parcelable {
dest.writeInt(labelRes);
TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
dest.writeInt(icon);
dest.writeString(resolvePackageName);
}
public static final Creator<ResolveInfo> CREATOR
@@ -257,6 +279,7 @@ public class ResolveInfo implements Parcelable {
nonLocalizedLabel
= TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
icon = source.readInt();
resolvePackageName = source.readString();
}
public static class DisplayNameComparator

View File

@@ -2,6 +2,7 @@ package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Printer;
/**
* Information you can retrieve about a particular application
@@ -24,6 +25,11 @@ public class ServiceInfo extends ComponentInfo
permission = orig.permission;
}
public void dump(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "permission=" + permission);
}
public String toString() {
return "ServiceInfo{"
+ Integer.toHexString(System.identityHashCode(this))