Fix bug where no images could be deleted in wallpaper picker

Bug: 10926729

Change-Id: I9392e297d071f1ed12bb6665e591756dfe42009f
This commit is contained in:
Michael Jurka
2013-09-25 08:08:49 -07:00
parent b923fb3399
commit 8a34bdba65
4 changed files with 16 additions and 3 deletions
@@ -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,
@@ -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;
}
@@ -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);
@@ -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);
}
}