diff --git a/api/current.txt b/api/current.txt index 07455d1b82c4c..90d0b9ae4f8ae 100644 --- a/api/current.txt +++ b/api/current.txt @@ -420,7 +420,9 @@ package android { field public static final int contentInsetStart = 16843859; // 0x1010453 field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522 field public static final int contextClickable = 16844007; // 0x10104e7 + field public static final int contextDescription = 16844082; // 0x1010532 field public static final int contextPopupMenuStyle = 16844033; // 0x1010501 + field public static final int contextUri = 16844081; // 0x1010531 field public static final int controlX1 = 16843772; // 0x10103fc field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd @@ -1120,6 +1122,7 @@ package android { field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 field public static final int showForAllUsers = 16844015; // 0x10104ef + field public static final int showMetadataInPreview = 16844083; // 0x1010533 field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9 field public static final int showSilent = 16843259; // 0x10101fb field public static final int showText = 16843949; // 0x10104ad @@ -5767,7 +5770,10 @@ package android.app { method public android.content.pm.ServiceInfo getServiceInfo(); method public java.lang.String getServiceName(); method public java.lang.String getSettingsActivity(); + method public boolean getShowMetadataInPreview(); method public java.lang.CharSequence loadAuthor(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; + method public java.lang.CharSequence loadContextDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; + method public android.net.Uri loadContextUri(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager); method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager); diff --git a/api/system-current.txt b/api/system-current.txt index a1b4b1d5e2b1b..f877f3318e5c8 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -526,7 +526,9 @@ package android { field public static final int contentInsetStart = 16843859; // 0x1010453 field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522 field public static final int contextClickable = 16844007; // 0x10104e7 + field public static final int contextDescription = 16844082; // 0x1010532 field public static final int contextPopupMenuStyle = 16844033; // 0x1010501 + field public static final int contextUri = 16844081; // 0x1010531 field public static final int controlX1 = 16843772; // 0x10103fc field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd @@ -1230,6 +1232,7 @@ package android { field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 field public static final int showForAllUsers = 16844015; // 0x10104ef + field public static final int showMetadataInPreview = 16844083; // 0x1010533 field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9 field public static final int showSilent = 16843259; // 0x10101fb field public static final int showText = 16843949; // 0x10104ad @@ -5914,7 +5917,10 @@ package android.app { method public android.content.pm.ServiceInfo getServiceInfo(); method public java.lang.String getServiceName(); method public java.lang.String getSettingsActivity(); + method public boolean getShowMetadataInPreview(); method public java.lang.CharSequence loadAuthor(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; + method public java.lang.CharSequence loadContextDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; + method public android.net.Uri loadContextUri(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager); method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager); diff --git a/api/test-current.txt b/api/test-current.txt index 713189b04af62..0bbca5ad289b8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -420,7 +420,9 @@ package android { field public static final int contentInsetStart = 16843859; // 0x1010453 field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522 field public static final int contextClickable = 16844007; // 0x10104e7 + field public static final int contextDescription = 16844082; // 0x1010532 field public static final int contextPopupMenuStyle = 16844033; // 0x1010501 + field public static final int contextUri = 16844081; // 0x1010531 field public static final int controlX1 = 16843772; // 0x10103fc field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd @@ -1120,6 +1122,7 @@ package android { field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 field public static final int showForAllUsers = 16844015; // 0x10104ef + field public static final int showMetadataInPreview = 16844083; // 0x1010533 field public static final deprecated int showOnLockScreen = 16843721; // 0x10103c9 field public static final int showSilent = 16843259; // 0x10101fb field public static final int showText = 16843949; // 0x10104ad @@ -5773,7 +5776,10 @@ package android.app { method public android.content.pm.ServiceInfo getServiceInfo(); method public java.lang.String getServiceName(); method public java.lang.String getSettingsActivity(); + method public boolean getShowMetadataInPreview(); method public java.lang.CharSequence loadAuthor(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; + method public java.lang.CharSequence loadContextDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; + method public android.net.Uri loadContextUri(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager); method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager); diff --git a/core/java/android/app/WallpaperInfo.java b/core/java/android/app/WallpaperInfo.java index 7db9fa8fed659..84a16cf3e96a1 100644 --- a/core/java/android/app/WallpaperInfo.java +++ b/core/java/android/app/WallpaperInfo.java @@ -31,6 +31,7 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.service.wallpaper.WallpaperService; @@ -72,6 +73,10 @@ public final class WallpaperInfo implements Parcelable { */ final int mDescriptionResource; + final int mContextUriResource; + final int mContextDescriptionResource; + final boolean mShowMetadataInPreview; + /** * Constructor. * @@ -89,7 +94,10 @@ public final class WallpaperInfo implements Parcelable { int thumbnailRes = -1; int authorRes = -1; int descriptionRes = -1; - + int contextUriRes = -1; + int contextDescriptionRes = -1; + boolean showMetadataInPreview = false; + XmlResourceParser parser = null; try { parser = si.loadXmlMetaData(pm, WallpaperService.SERVICE_META_DATA); @@ -127,6 +135,15 @@ public final class WallpaperInfo implements Parcelable { descriptionRes = sa.getResourceId( com.android.internal.R.styleable.Wallpaper_description, -1); + contextUriRes = sa.getResourceId( + com.android.internal.R.styleable.Wallpaper_contextUri, + -1); + contextDescriptionRes = sa.getResourceId( + com.android.internal.R.styleable.Wallpaper_contextDescription, + -1); + showMetadataInPreview = sa.getBoolean( + com.android.internal.R.styleable.Wallpaper_showMetadataInPreview, + false); sa.recycle(); } catch (NameNotFoundException e) { @@ -140,6 +157,9 @@ public final class WallpaperInfo implements Parcelable { mThumbnailResource = thumbnailRes; mAuthorResource = authorRes; mDescriptionResource = descriptionRes; + mContextUriResource = contextUriRes; + mContextDescriptionResource = contextDescriptionRes; + mShowMetadataInPreview = showMetadataInPreview; } WallpaperInfo(Parcel source) { @@ -147,6 +167,9 @@ public final class WallpaperInfo implements Parcelable { mThumbnailResource = source.readInt(); mAuthorResource = source.readInt(); mDescriptionResource = source.readInt(); + mContextUriResource = source.readInt(); + mContextDescriptionResource = source.readInt(); + mShowMetadataInPreview = source.readInt() != 0; mService = ResolveInfo.CREATOR.createFromParcel(source); } @@ -248,7 +271,55 @@ public final class WallpaperInfo implements Parcelable { return pm.getText(packageName, mDescriptionResource, mService.serviceInfo.applicationInfo); } - + + /** + * Returns an URI that specifies a link for further context about this wallpaper. + * + * @param pm An instance of {@link PackageManager} to retrieve the URI. + * @return The URI. + */ + public Uri loadContextUri(PackageManager pm) throws NotFoundException { + if (mContextUriResource <= 0) throw new NotFoundException(); + String packageName = mService.resolvePackageName; + ApplicationInfo applicationInfo = null; + if (packageName == null) { + packageName = mService.serviceInfo.packageName; + applicationInfo = mService.serviceInfo.applicationInfo; + } + String contextUriString = pm.getText( + packageName, mContextUriResource, applicationInfo).toString(); + if (contextUriString == null) { + return null; + } + return Uri.parse(contextUriString); + } + + /** + * Retrieves a title of the URI that specifies a link for further context about this wallpaper. + * + * @param pm An instance of {@link PackageManager} to retrieve the title. + * @return The title. + */ + public CharSequence loadContextDescription(PackageManager pm) throws NotFoundException { + if (mContextDescriptionResource <= 0) throw new NotFoundException(); + String packageName = mService.resolvePackageName; + ApplicationInfo applicationInfo = null; + if (packageName == null) { + packageName = mService.serviceInfo.packageName; + applicationInfo = mService.serviceInfo.applicationInfo; + } + return pm.getText(packageName, mContextDescriptionResource, applicationInfo).toString(); + } + + /** + * Queries whether any metadata should be shown when previewing the wallpaper. + * + * @return Whether any metadata should be shown when previewing the wallpaper. + */ + public boolean getShowMetadataInPreview() { + return mShowMetadataInPreview; + } + /** * Return the class name of an activity that provides a settings UI for * the wallpaper. You can launch this activity be starting it with @@ -287,6 +358,9 @@ public final class WallpaperInfo implements Parcelable { dest.writeInt(mThumbnailResource); dest.writeInt(mAuthorResource); dest.writeInt(mDescriptionResource); + dest.writeInt(mContextUriResource); + dest.writeInt(mContextDescriptionResource); + dest.writeInt(mShowMetadataInPreview ? 1 : 0); mService.writeToParcel(dest, flags); } diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index de8133b33aa6f..06d87f84699d1 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -55,6 +55,7 @@ import android.view.SurfaceHolder; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.view.WindowManager.LayoutParams; import android.view.WindowManagerGlobal; import java.io.FileDescriptor; @@ -628,9 +629,9 @@ public abstract class WallpaperService extends Service { mCurWindowFlags = mWindowFlags; mLayout.flags = mWindowFlags | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN - | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE - ; + | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mCurWindowPrivateFlags = mWindowPrivateFlags; mLayout.privateFlags = mWindowPrivateFlags; diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 1af991104a840..d0c6a8ef012e6 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -7335,14 +7335,24 @@ i - + - + + + + + + + + + + +