From 8a34bdba657b5d8d1e919e89c31c81e38846b63c Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Wed, 25 Sep 2013 07:57:33 -0700 Subject: Fix bug where no images could be deleted in wallpaper picker Bug: 10926729 Change-Id: I9392e297d071f1ed12bb6665e591756dfe42009f --- src/com/android/launcher3/LiveWallpaperListAdapter.java | 1 + src/com/android/launcher3/SavedWallpaperImages.java | 4 ++++ .../launcher3/ThirdPartyWallpaperPickerListAdapter.java | 1 + src/com/android/launcher3/WallpaperPickerActivity.java | 13 ++++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/com') diff --git a/src/com/android/launcher3/LiveWallpaperListAdapter.java b/src/com/android/launcher3/LiveWallpaperListAdapter.java index 9d0f48bf0..e9e5e79a8 100644 --- a/src/com/android/launcher3/LiveWallpaperListAdapter.java +++ b/src/com/android/launcher3/LiveWallpaperListAdapter.java @@ -116,6 +116,7 @@ public class LiveWallpaperListAdapter extends BaseAdapter implements ListAdapter mThumbnail = thumbnail; mInfo = info; } + @Override public void onClick(WallpaperPickerActivity a) { Intent preview = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER); preview.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, diff --git a/src/com/android/launcher3/SavedWallpaperImages.java b/src/com/android/launcher3/SavedWallpaperImages.java index f00f62ff6..7cd82f075 100644 --- a/src/com/android/launcher3/SavedWallpaperImages.java +++ b/src/com/android/launcher3/SavedWallpaperImages.java @@ -57,6 +57,7 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { mDbId = dbId; mThumb = thumb; } + @Override public void onClick(WallpaperPickerActivity a) { String imageFilename = a.getSavedImages().getImageFilename(mDbId); File file = new File(a.getFilesDir(), imageFilename); @@ -65,14 +66,17 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { v.moveToLeft(); v.setTouchEnabled(false); } + @Override public void onSave(WallpaperPickerActivity a) { boolean finishActivityWhenDone = true; String imageFilename = a.getSavedImages().getImageFilename(mDbId); a.setWallpaper(imageFilename, finishActivityWhenDone); } + @Override public void onDelete(WallpaperPickerActivity a) { a.getSavedImages().deleteImage(mDbId); } + @Override public boolean isSelectable() { return true; } diff --git a/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java b/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java index ab2f5d72a..7ed1c1bfb 100644 --- a/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java +++ b/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java @@ -46,6 +46,7 @@ public class ThirdPartyWallpaperPickerListAdapter extends BaseAdapter implements public ThirdPartyWallpaperTile(ResolveInfo resolveInfo) { mResolveInfo = resolveInfo; } + @Override public void onClick(WallpaperPickerActivity a) { final ComponentName itemComponentName = new ComponentName( mResolveInfo.activityInfo.packageName, mResolveInfo.activityInfo.name); diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java index 5f35cde21..a7c96f5df 100644 --- a/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/src/com/android/launcher3/WallpaperPickerActivity.java @@ -87,11 +87,12 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { public static abstract class WallpaperTileInfo { public void onClick(WallpaperPickerActivity a) {} public void onSave(WallpaperPickerActivity a) {} - public void onDelete() {} + public void onDelete(WallpaperPickerActivity a) {} public boolean isSelectable() { return false; } } public static class PickImageInfo extends WallpaperTileInfo { + @Override public void onClick(WallpaperPickerActivity a) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); @@ -104,13 +105,14 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { public UriWallpaperInfo(Uri uri) { mUri = uri; } + @Override public void onClick(WallpaperPickerActivity a) { CropView v = a.getCropView(); v.setTileSource(new BitmapRegionTileSource( a, mUri, 1024, 0), null); v.setTouchEnabled(true); } - + @Override public void onSave(final WallpaperPickerActivity a) { boolean finishActivityWhenDone = true; OnBitmapCroppedHandler h = new OnBitmapCroppedHandler() { @@ -123,6 +125,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { }; a.cropImageAndSetWallpaper(mUri, h, finishActivityWhenDone); } + @Override public boolean isSelectable() { return true; } @@ -138,6 +141,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { mResId = resId; mThumb = thumb; } + @Override public void onClick(WallpaperPickerActivity a) { BitmapRegionTileSource source = new BitmapRegionTileSource( mResources, a, mResId, 1024, 0); @@ -151,10 +155,12 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { v.setScale(wallpaperSize.x / crop.width()); v.setTouchEnabled(false); } + @Override public void onSave(WallpaperPickerActivity a) { boolean finishActivityWhenDone = true; a.cropImageAndSetWallpaper(mResources, mResId, finishActivityWhenDone); } + @Override public boolean isSelectable() { return true; } @@ -361,7 +367,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { CheckableFrameLayout c = (CheckableFrameLayout) mWallpapersView.getChildAt(i); if (c.isChecked()) { - ((WallpaperTileInfo) c.getTag()).onDelete(); + WallpaperTileInfo info = (WallpaperTileInfo) c.getTag(); + info.onDelete(WallpaperPickerActivity.this); viewsToRemove.add(c); } } -- cgit v1.2.3