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

Commit dfe30aa6 authored by John Hoford's avatar John Hoford Committed by Android (Google) Code Review
Browse files

Merge "fix showing wrong image post save" into gb-ub-photos-carlsbad

parents 4c107f27 ef4c2131
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -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;
    }
@@ -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();
@@ -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);
@@ -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");
+6 −0
Original line number Diff line number Diff line
@@ -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
+4 −3
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class SaveImage {
     * Callback for updates
     */
    public interface Callback {
        void onPreviewSaved(Uri uri);
        void onProgress(int max, int current);
    }

@@ -381,6 +382,9 @@ public class SaveImage {
                            mDestinationFile, time, !flatten);
                }
            }
            if (mCallback != null) {
                mCallback.onPreviewSaved(savedUri);
            }
        }

        // Stopgap fix for low-memory devices.
@@ -542,9 +546,6 @@ public class SaveImage {
            Toast.makeText(filterShowActivity,
                    toastMessage,
                    Toast.LENGTH_SHORT).show();

            // terminate for now
            filterShowActivity.completeSaveImage(selectedImageUri);
        }
    }