Loading src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java +21 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ public class ImageSavingTask extends ProcessingTask { int current; } static class UpdatePreviewSaved implements Update { Uri uri; } static class URIResult implements Result { Uri uri; } Loading Loading @@ -84,11 +88,18 @@ public class ImageSavingTask extends ProcessingTask { // We create a small bitmap showing the result that we can // give to the notification UpdateBitmap updateBitmap = new UpdateBitmap(); updateBitmap.bitmap = createNotificationBitmap(sourceUri, preset); updateBitmap.bitmap = createNotificationBitmap(previewImage, sourceUri, preset); postUpdate(updateBitmap); SaveImage saveImage = new SaveImage(mProcessingService, sourceUri, selectedUri, destinationFile, previewImage, new SaveImage.Callback() { @Override public void onPreviewSaved(Uri uri){ UpdatePreviewSaved previewSaved = new UpdatePreviewSaved(); previewSaved.uri = uri; postUpdate(previewSaved); } @Override public void onProgress(int max, int current) { UpdateProgress updateProgress = new UpdateProgress(); Loading @@ -112,6 +123,10 @@ public class ImageSavingTask extends ProcessingTask { @Override public void onUpdate(Update message) { if (message instanceof UpdatePreviewSaved){ Uri uri = ((UpdatePreviewSaved) message).uri; mProcessingService.completePreviewSaveImage(uri); } if (message instanceof UpdateBitmap) { Bitmap bitmap = ((UpdateBitmap) message).bitmap; mProcessingService.updateNotificationWithBitmap(bitmap); Loading @@ -122,9 +137,13 @@ public class ImageSavingTask extends ProcessingTask { } } private Bitmap createNotificationBitmap(Uri sourceUri, ImagePreset preset) { private Bitmap createNotificationBitmap(Bitmap preview, Uri sourceUri, ImagePreset preset) { int notificationBitmapSize = Resources.getSystem().getDimensionPixelSize( android.R.dimen.notification_large_icon_width); if (preview != null) { return Bitmap.createScaledBitmap(preview, notificationBitmapSize, notificationBitmapSize, true); } Bitmap bitmap = ImageLoader.loadConstrainedBitmap(sourceUri, getContext(), notificationBitmapSize, null, true); CachingPipeline pipeline = new CachingPipeline(FiltersManager.getManager(), "Thumb"); Loading src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java +6 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,12 @@ public class ProcessingService extends Service { mNotifyMgr.notify(mNotificationId, mBuilder.build()); } public void completePreviewSaveImage(Uri result) { if (!mNeedsAlive && !mFiltershowActivity.isSimpleEditAction()) { mFiltershowActivity.completeSaveImage(result); } } public void completeSaveImage(Uri result) { if (SHOW_IMAGE) { // TODO: we should update the existing image in Gallery instead Loading src/com/android/gallery3d/filtershow/tools/SaveImage.java +4 −3 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public class SaveImage { * Callback for updates */ public interface Callback { void onPreviewSaved(Uri uri); void onProgress(int max, int current); } Loading Loading @@ -381,6 +382,9 @@ public class SaveImage { mDestinationFile, time, !flatten); } } if (mCallback != null) { mCallback.onPreviewSaved(savedUri); } } // Stopgap fix for low-memory devices. Loading Loading @@ -542,9 +546,6 @@ public class SaveImage { Toast.makeText(filterShowActivity, toastMessage, Toast.LENGTH_SHORT).show(); // terminate for now filterShowActivity.completeSaveImage(selectedImageUri); } } Loading Loading
src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java +21 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ public class ImageSavingTask extends ProcessingTask { int current; } static class UpdatePreviewSaved implements Update { Uri uri; } static class URIResult implements Result { Uri uri; } Loading Loading @@ -84,11 +88,18 @@ public class ImageSavingTask extends ProcessingTask { // We create a small bitmap showing the result that we can // give to the notification UpdateBitmap updateBitmap = new UpdateBitmap(); updateBitmap.bitmap = createNotificationBitmap(sourceUri, preset); updateBitmap.bitmap = createNotificationBitmap(previewImage, sourceUri, preset); postUpdate(updateBitmap); SaveImage saveImage = new SaveImage(mProcessingService, sourceUri, selectedUri, destinationFile, previewImage, new SaveImage.Callback() { @Override public void onPreviewSaved(Uri uri){ UpdatePreviewSaved previewSaved = new UpdatePreviewSaved(); previewSaved.uri = uri; postUpdate(previewSaved); } @Override public void onProgress(int max, int current) { UpdateProgress updateProgress = new UpdateProgress(); Loading @@ -112,6 +123,10 @@ public class ImageSavingTask extends ProcessingTask { @Override public void onUpdate(Update message) { if (message instanceof UpdatePreviewSaved){ Uri uri = ((UpdatePreviewSaved) message).uri; mProcessingService.completePreviewSaveImage(uri); } if (message instanceof UpdateBitmap) { Bitmap bitmap = ((UpdateBitmap) message).bitmap; mProcessingService.updateNotificationWithBitmap(bitmap); Loading @@ -122,9 +137,13 @@ public class ImageSavingTask extends ProcessingTask { } } private Bitmap createNotificationBitmap(Uri sourceUri, ImagePreset preset) { private Bitmap createNotificationBitmap(Bitmap preview, Uri sourceUri, ImagePreset preset) { int notificationBitmapSize = Resources.getSystem().getDimensionPixelSize( android.R.dimen.notification_large_icon_width); if (preview != null) { return Bitmap.createScaledBitmap(preview, notificationBitmapSize, notificationBitmapSize, true); } Bitmap bitmap = ImageLoader.loadConstrainedBitmap(sourceUri, getContext(), notificationBitmapSize, null, true); CachingPipeline pipeline = new CachingPipeline(FiltersManager.getManager(), "Thumb"); Loading
src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java +6 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,12 @@ public class ProcessingService extends Service { mNotifyMgr.notify(mNotificationId, mBuilder.build()); } public void completePreviewSaveImage(Uri result) { if (!mNeedsAlive && !mFiltershowActivity.isSimpleEditAction()) { mFiltershowActivity.completeSaveImage(result); } } public void completeSaveImage(Uri result) { if (SHOW_IMAGE) { // TODO: we should update the existing image in Gallery instead Loading
src/com/android/gallery3d/filtershow/tools/SaveImage.java +4 −3 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public class SaveImage { * Callback for updates */ public interface Callback { void onPreviewSaved(Uri uri); void onProgress(int max, int current); } Loading Loading @@ -381,6 +382,9 @@ public class SaveImage { mDestinationFile, time, !flatten); } } if (mCallback != null) { mCallback.onPreviewSaved(savedUri); } } // Stopgap fix for low-memory devices. Loading Loading @@ -542,9 +546,6 @@ public class SaveImage { Toast.makeText(filterShowActivity, toastMessage, Toast.LENGTH_SHORT).show(); // terminate for now filterShowActivity.completeSaveImage(selectedImageUri); } } Loading