Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 520ca7e5 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 26415 into eclair

* changes:
  Add support for thumbnails to WallpaperInfo.
parents c3c6621a 465ccb8a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -8259,6 +8259,17 @@
 visibility="public"
>
</field>
<field name="thumbnail"
 type="int"
 transient="false"
 volatile="false"
 value="16843429"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="tileMode"
 type="int"
 transient="false"
+28 −0
Original line number Diff line number Diff line
@@ -39,6 +39,11 @@ public final class WallpaperInfo implements Parcelable {
     */
    final String mSettingsActivityName;

    /**
     * Resource identifier for this wallpaper's thumbnail image.
     */
    final int mThumbnailResource;

    /**
     * Constructor.
     * 
@@ -53,6 +58,7 @@ public final class WallpaperInfo implements Parcelable {
        
        PackageManager pm = context.getPackageManager();
        String settingsActivityComponent = null;
        int thumbnailRes = -1;
        
        XmlResourceParser parser = null;
        try {
@@ -79,16 +85,23 @@ public final class WallpaperInfo implements Parcelable {
                    com.android.internal.R.styleable.Wallpaper);
            settingsActivityComponent = sa.getString(
                    com.android.internal.R.styleable.Wallpaper_settingsActivity);
            
            thumbnailRes = sa.getResourceId(
                    com.android.internal.R.styleable.Wallpaper_thumbnail,
                    -1);

            sa.recycle();
        } finally {
            if (parser != null) parser.close();
        }
        
        mSettingsActivityName = settingsActivityComponent;
        mThumbnailResource = thumbnailRes;
    }

    WallpaperInfo(Parcel source) {
        mSettingsActivityName = source.readString();
        mThumbnailResource = source.readInt();
        mService = ResolveInfo.CREATOR.createFromParcel(source);
    }
    
@@ -143,6 +156,20 @@ public final class WallpaperInfo implements Parcelable {
        return mService.loadIcon(pm);
    }
    
    /**
     * Load the thumbnail image for this wallpaper.
     * 
     * @param pm Supply a PackageManager used to load the wallpaper's
     * resources.
     */
    public Drawable loadThumbnail(PackageManager pm) {
        if (mThumbnailResource < 0) return null;

        return pm.getDrawable(mService.serviceInfo.packageName,
                              mThumbnailResource,
                              null);
    }
    
    /**
     * Return the class name of an activity that provides a settings UI for
     * the wallpaper.  You can launch this activity be starting it with
@@ -178,6 +205,7 @@ public final class WallpaperInfo implements Parcelable {
     */
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mSettingsActivityName);
        dest.writeInt(mThumbnailResource);
        mService.writeToParcel(dest, flags);
    }

+3 −0
Original line number Diff line number Diff line
@@ -3451,6 +3451,9 @@
        <!-- Component name of an activity that allows the user to modify
             the current settings for this wallpaper. -->
        <attr name="settingsActivity" />

        <!-- Reference to a the wallpaper's thumbnail bitmap. -->
        <attr name="thumbnail" format="reference" />
    </declare-styleable>

    <!-- =============================== -->
+1 −0
Original line number Diff line number Diff line
@@ -1169,6 +1169,7 @@
  <public type="attr" name="summaryColumn" />
  <public type="attr" name="detailColumn" />
  <public type="attr" name="detailSocialSummary" />
  <public type="attr" name="thumbnail" />

  <public type="style" name="Theme.Wallpaper" />
  <public type="style" name="Theme.Wallpaper.NoTitleBar" />