diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-08-05 21:32:16 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-08-05 21:32:16 -0700 |
commit | 107f839cdf5f159703017319ee231da9118df91e (patch) | |
tree | 64ebaf445d5f3cf8e59b0bbeda83cc091c7f738f /src/com/android/launcher2/WallpaperChooser.java | |
parent | e77c08d15f23c403293dbb40c6a36967de822c89 (diff) | |
download | android_packages_apps_Trebuchet-107f839cdf5f159703017319ee231da9118df91e.tar.gz android_packages_apps_Trebuchet-107f839cdf5f159703017319ee231da9118df91e.tar.bz2 android_packages_apps_Trebuchet-107f839cdf5f159703017319ee231da9118df91e.zip |
Update to use new wallpaper APIs.
Diffstat (limited to 'src/com/android/launcher2/WallpaperChooser.java')
-rw-r--r-- | src/com/android/launcher2/WallpaperChooser.java | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/src/com/android/launcher2/WallpaperChooser.java b/src/com/android/launcher2/WallpaperChooser.java index 02e85eef5..4517bf5bc 100644 --- a/src/com/android/launcher2/WallpaperChooser.java +++ b/src/com/android/launcher2/WallpaperChooser.java @@ -17,15 +17,12 @@ package com.android.launcher2; import android.app.Activity; -import android.app.IWallpaperService; +import android.app.WallpaperManager; import android.content.res.Resources; import android.graphics.BitmapFactory; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.os.ParcelFileDescriptor; -import android.os.RemoteException; -import android.os.ServiceManager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -39,8 +36,6 @@ import android.widget.Gallery; import android.widget.ImageView; import java.io.IOException; -import java.io.InputStream; -import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Collections; @@ -90,7 +85,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele private ArrayList<Integer> mThumbs; private ArrayList<Integer> mImages; - private ArrayList<String> mNames; @Override public void onCreate(Bundle icicle) { @@ -125,11 +119,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele final Resources resources = getResources(); - mNames = new ArrayList<String>(IMAGE_IDS.length + 4); - for (int res: mImages) { - mNames.add("res:" + resources.getResourceName(res)); - } - final String[] extras = resources.getStringArray(R.array.extra_wallpapers); final String packageName = getApplication().getPackageName(); @@ -142,7 +131,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele if (thumbRes != 0) { mThumbs.add(thumbRes); mImages.add(res); - mNames.add("res:" + extra); } } } @@ -182,8 +170,9 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele mIsWallpaperSet = true; try { - InputStream stream = getResources().openRawResource(mImages.get(position)); - setWallpaper(stream, mNames.get(position)); + WallpaperManager wpm = (WallpaperManager)getSystemService( + WALLPAPER_SERVICE); + wpm.set(mImages.get(position)); setResult(RESULT_OK); finish(); } catch (IOException e) { @@ -231,34 +220,4 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele public void onClick(View v) { selectWallpaper(mGallery.getSelectedItemPosition()); } - - private void setWallpaper(InputStream data, String name) throws IOException { - try { - IWallpaperService svc = IWallpaperService.Stub.asInterface( - ServiceManager.getService(WALLPAPER_SERVICE)); - ParcelFileDescriptor fd = svc.setWallpaper(name); - if (fd == null) { - return; - } - FileOutputStream fos = null; - try { - fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd); - setWallpaper(data, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } catch (RemoteException e) { - } - } - - private void setWallpaper(InputStream data, FileOutputStream fos) - throws IOException { - byte[] buffer = new byte[32768]; - int amt; - while ((amt=data.read(buffer)) > 0) { - fos.write(buffer, 0, amt); - } - } } |