Loading src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java +12 −4 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ public class ImageSavingTask extends ProcessingTask { int quality; float sizeFactor; Bitmap previewImage; boolean exit; } static class UpdateBitmap implements Update { Loading @@ -51,10 +52,12 @@ public class ImageSavingTask extends ProcessingTask { static class UpdatePreviewSaved implements Update { Uri uri; boolean exit; } static class URIResult implements Result { Uri uri; boolean exit; } public ImageSavingTask(ProcessingService service) { Loading @@ -64,7 +67,7 @@ public class ImageSavingTask extends ProcessingTask { public void saveImage(Uri sourceUri, Uri selectedUri, File destinationFile, ImagePreset preset, Bitmap previewImage, boolean flatten, int quality, float sizeFactor) { int quality, float sizeFactor, boolean exit) { SaveRequest request = new SaveRequest(); request.sourceUri = sourceUri; request.selectedUri = selectedUri; Loading @@ -74,6 +77,7 @@ public class ImageSavingTask extends ProcessingTask { request.quality = quality; request.sizeFactor = sizeFactor; request.previewImage = previewImage; request.exit = exit; postRequest(request); } Loading @@ -85,6 +89,7 @@ public class ImageSavingTask extends ProcessingTask { Bitmap previewImage = request.previewImage; ImagePreset preset = request.preset; boolean flatten = request.flatten; final boolean exit = request.exit; // We create a small bitmap showing the result that we can // give to the notification UpdateBitmap updateBitmap = new UpdateBitmap(); Loading @@ -97,6 +102,7 @@ public class ImageSavingTask extends ProcessingTask { public void onPreviewSaved(Uri uri){ UpdatePreviewSaved previewSaved = new UpdatePreviewSaved(); previewSaved.uri = uri; previewSaved.exit = exit; postUpdate(previewSaved); } Loading @@ -109,23 +115,25 @@ public class ImageSavingTask extends ProcessingTask { } }); Uri uri = saveImage.processAndSaveImage(preset, flatten, request.quality, request.sizeFactor); request.quality, request.sizeFactor, request.exit); URIResult result = new URIResult(); result.uri = uri; result.exit = request.exit; return result; } @Override public void onResult(Result message) { URIResult result = (URIResult) message; mProcessingService.completeSaveImage(result.uri); mProcessingService.completeSaveImage(result.uri, result.exit); } @Override public void onUpdate(Update message) { if (message instanceof UpdatePreviewSaved){ Uri uri = ((UpdatePreviewSaved) message).uri; mProcessingService.completePreviewSaveImage(uri); boolean exit = ((UpdatePreviewSaved) message).exit; mProcessingService.completePreviewSaveImage(uri, exit); } if (message instanceof UpdateBitmap) { Bitmap bitmap = ((UpdateBitmap) message).bitmap; Loading src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java +18 −9 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public class ProcessingService extends Service { private static final String SAVING = "saving"; private static final String FLATTEN = "flatten"; private static final String SIZE_FACTOR = "sizeFactor"; private static final String EXIT = "exit"; private ProcessingTaskController mProcessingTaskController; private ImageSavingTask mImageSavingTask; Loading Loading @@ -140,7 +141,8 @@ public class ProcessingService extends Service { } public static Intent getSaveIntent(Context context, ImagePreset preset, File destination, Uri selectedImageUri, Uri sourceImageUri, boolean doFlatten, int quality, float sizeFactor) { Uri selectedImageUri, Uri sourceImageUri, boolean doFlatten, int quality, float sizeFactor, boolean needsExit) { Intent processIntent = new Intent(context, ProcessingService.class); processIntent.putExtra(ProcessingService.SOURCE_URI, sourceImageUri.toString()); Loading @@ -154,6 +156,7 @@ public class ProcessingService extends Service { processIntent.putExtra(ProcessingService.PRESET, preset.getJsonString(ImagePreset.JASON_SAVED)); processIntent.putExtra(ProcessingService.SAVING, true); processIntent.putExtra(ProcessingService.EXIT, needsExit); if (doFlatten) { processIntent.putExtra(ProcessingService.FLATTEN, true); } Loading Loading @@ -196,6 +199,7 @@ public class ProcessingService extends Service { int quality = intent.getIntExtra(QUALITY, 100); float sizeFactor = intent.getFloatExtra(SIZE_FACTOR, 1); boolean flatten = intent.getBooleanExtra(FLATTEN, false); boolean exit = intent.getBooleanExtra(EXIT, false); Uri sourceUri = Uri.parse(source); Uri selectedUri = null; if (selected != null) { Loading @@ -211,7 +215,7 @@ public class ProcessingService extends Service { mSaving = true; handleSaveRequest(sourceUri, selectedUri, destinationFile, preset, MasterImage.getImage().getHighresImage(), flatten, quality, sizeFactor); flatten, quality, sizeFactor, exit); } return START_REDELIVER_INTENT; } Loading @@ -230,10 +234,9 @@ public class ProcessingService extends Service { public void handleSaveRequest(Uri sourceUri, Uri selectedUri, File destinationFile, ImagePreset preset, Bitmap previewImage, boolean flatten, int quality, float sizeFactor) { boolean flatten, int quality, float sizeFactor, boolean exit) { mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNotificationId++; mNotifyMgr.cancelAll(); mBuilder = new Notification.Builder(this) Loading @@ -248,7 +251,7 @@ public class ProcessingService extends Service { // Process the image mImageSavingTask.saveImage(sourceUri, selectedUri, destinationFile, preset, previewImage, flatten, quality, sizeFactor); preset, previewImage, flatten, quality, sizeFactor, exit); } public void updateNotificationWithBitmap(Bitmap bitmap) { Loading @@ -261,19 +264,25 @@ public class ProcessingService extends Service { mNotifyMgr.notify(mNotificationId, mBuilder.build()); } public void completePreviewSaveImage(Uri result) { if (!mNeedsAlive && !mFiltershowActivity.isSimpleEditAction()) { public void completePreviewSaveImage(Uri result, boolean exit) { if (exit && !mNeedsAlive && !mFiltershowActivity.isSimpleEditAction()) { mFiltershowActivity.completeSaveImage(result); } } public void completeSaveImage(Uri result) { public void completeSaveImage(Uri result, boolean exit) { if (SHOW_IMAGE) { // TODO: we should update the existing image in Gallery instead Intent viewImage = new Intent(Intent.ACTION_VIEW, result); viewImage.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(viewImage); } mNotifyMgr.cancel(mNotificationId); if (!exit) { stopForeground(true); stopSelf(); return; } stopForeground(true); stopSelf(); if (mNeedsAlive) { Loading src/com/android/gallery3d/filtershow/tools/SaveImage.java +6 −5 Original line number Diff line number Diff line Loading @@ -326,9 +326,12 @@ public class SaveImage { } public Uri processAndSaveImage(ImagePreset preset, boolean flatten, int quality, float sizeFactor) { int quality, float sizeFactor, boolean exit) { Uri uri = resetToOriginalImageIfNeeded(preset, !flatten); Uri uri = null; if (exit) { uri = resetToOriginalImageIfNeeded(preset, !flatten); } if (uri != null) { return null; } Loading Loading @@ -361,9 +364,7 @@ public class SaveImage { Images.Media.EXTERNAL_CONTENT_URI, values); } } else { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); long time = System.currentTimeMillis(); Loading Loading @@ -536,7 +537,7 @@ public class SaveImage { flatten = true; } Intent processIntent = ProcessingService.getSaveIntent(filterShowActivity, preset, destination, selectedImageUri, sourceImageUri, flatten, 90, 1f); destination, selectedImageUri, sourceImageUri, flatten, 90, 1f, true); filterShowActivity.startService(processIntent); Loading src/com/android/gallery3d/filtershow/ui/ExportDialog.java +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class ExportDialog extends DialogFragment implements View.OnClickListener float scaleFactor = mExportWidth / (float) mOriginalBounds.width(); Intent processIntent = ProcessingService.getSaveIntent(activity, MasterImage .getImage().getPreset(), dest, activity.getSelectedImageUri(), sourceUri, true, mSeekBar.getProgress(), scaleFactor); true, mSeekBar.getProgress(), scaleFactor, false); activity.startService(processIntent); dismiss(); break; Loading Loading
src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java +12 −4 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ public class ImageSavingTask extends ProcessingTask { int quality; float sizeFactor; Bitmap previewImage; boolean exit; } static class UpdateBitmap implements Update { Loading @@ -51,10 +52,12 @@ public class ImageSavingTask extends ProcessingTask { static class UpdatePreviewSaved implements Update { Uri uri; boolean exit; } static class URIResult implements Result { Uri uri; boolean exit; } public ImageSavingTask(ProcessingService service) { Loading @@ -64,7 +67,7 @@ public class ImageSavingTask extends ProcessingTask { public void saveImage(Uri sourceUri, Uri selectedUri, File destinationFile, ImagePreset preset, Bitmap previewImage, boolean flatten, int quality, float sizeFactor) { int quality, float sizeFactor, boolean exit) { SaveRequest request = new SaveRequest(); request.sourceUri = sourceUri; request.selectedUri = selectedUri; Loading @@ -74,6 +77,7 @@ public class ImageSavingTask extends ProcessingTask { request.quality = quality; request.sizeFactor = sizeFactor; request.previewImage = previewImage; request.exit = exit; postRequest(request); } Loading @@ -85,6 +89,7 @@ public class ImageSavingTask extends ProcessingTask { Bitmap previewImage = request.previewImage; ImagePreset preset = request.preset; boolean flatten = request.flatten; final boolean exit = request.exit; // We create a small bitmap showing the result that we can // give to the notification UpdateBitmap updateBitmap = new UpdateBitmap(); Loading @@ -97,6 +102,7 @@ public class ImageSavingTask extends ProcessingTask { public void onPreviewSaved(Uri uri){ UpdatePreviewSaved previewSaved = new UpdatePreviewSaved(); previewSaved.uri = uri; previewSaved.exit = exit; postUpdate(previewSaved); } Loading @@ -109,23 +115,25 @@ public class ImageSavingTask extends ProcessingTask { } }); Uri uri = saveImage.processAndSaveImage(preset, flatten, request.quality, request.sizeFactor); request.quality, request.sizeFactor, request.exit); URIResult result = new URIResult(); result.uri = uri; result.exit = request.exit; return result; } @Override public void onResult(Result message) { URIResult result = (URIResult) message; mProcessingService.completeSaveImage(result.uri); mProcessingService.completeSaveImage(result.uri, result.exit); } @Override public void onUpdate(Update message) { if (message instanceof UpdatePreviewSaved){ Uri uri = ((UpdatePreviewSaved) message).uri; mProcessingService.completePreviewSaveImage(uri); boolean exit = ((UpdatePreviewSaved) message).exit; mProcessingService.completePreviewSaveImage(uri, exit); } if (message instanceof UpdateBitmap) { Bitmap bitmap = ((UpdateBitmap) message).bitmap; Loading
src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java +18 −9 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public class ProcessingService extends Service { private static final String SAVING = "saving"; private static final String FLATTEN = "flatten"; private static final String SIZE_FACTOR = "sizeFactor"; private static final String EXIT = "exit"; private ProcessingTaskController mProcessingTaskController; private ImageSavingTask mImageSavingTask; Loading Loading @@ -140,7 +141,8 @@ public class ProcessingService extends Service { } public static Intent getSaveIntent(Context context, ImagePreset preset, File destination, Uri selectedImageUri, Uri sourceImageUri, boolean doFlatten, int quality, float sizeFactor) { Uri selectedImageUri, Uri sourceImageUri, boolean doFlatten, int quality, float sizeFactor, boolean needsExit) { Intent processIntent = new Intent(context, ProcessingService.class); processIntent.putExtra(ProcessingService.SOURCE_URI, sourceImageUri.toString()); Loading @@ -154,6 +156,7 @@ public class ProcessingService extends Service { processIntent.putExtra(ProcessingService.PRESET, preset.getJsonString(ImagePreset.JASON_SAVED)); processIntent.putExtra(ProcessingService.SAVING, true); processIntent.putExtra(ProcessingService.EXIT, needsExit); if (doFlatten) { processIntent.putExtra(ProcessingService.FLATTEN, true); } Loading Loading @@ -196,6 +199,7 @@ public class ProcessingService extends Service { int quality = intent.getIntExtra(QUALITY, 100); float sizeFactor = intent.getFloatExtra(SIZE_FACTOR, 1); boolean flatten = intent.getBooleanExtra(FLATTEN, false); boolean exit = intent.getBooleanExtra(EXIT, false); Uri sourceUri = Uri.parse(source); Uri selectedUri = null; if (selected != null) { Loading @@ -211,7 +215,7 @@ public class ProcessingService extends Service { mSaving = true; handleSaveRequest(sourceUri, selectedUri, destinationFile, preset, MasterImage.getImage().getHighresImage(), flatten, quality, sizeFactor); flatten, quality, sizeFactor, exit); } return START_REDELIVER_INTENT; } Loading @@ -230,10 +234,9 @@ public class ProcessingService extends Service { public void handleSaveRequest(Uri sourceUri, Uri selectedUri, File destinationFile, ImagePreset preset, Bitmap previewImage, boolean flatten, int quality, float sizeFactor) { boolean flatten, int quality, float sizeFactor, boolean exit) { mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNotificationId++; mNotifyMgr.cancelAll(); mBuilder = new Notification.Builder(this) Loading @@ -248,7 +251,7 @@ public class ProcessingService extends Service { // Process the image mImageSavingTask.saveImage(sourceUri, selectedUri, destinationFile, preset, previewImage, flatten, quality, sizeFactor); preset, previewImage, flatten, quality, sizeFactor, exit); } public void updateNotificationWithBitmap(Bitmap bitmap) { Loading @@ -261,19 +264,25 @@ public class ProcessingService extends Service { mNotifyMgr.notify(mNotificationId, mBuilder.build()); } public void completePreviewSaveImage(Uri result) { if (!mNeedsAlive && !mFiltershowActivity.isSimpleEditAction()) { public void completePreviewSaveImage(Uri result, boolean exit) { if (exit && !mNeedsAlive && !mFiltershowActivity.isSimpleEditAction()) { mFiltershowActivity.completeSaveImage(result); } } public void completeSaveImage(Uri result) { public void completeSaveImage(Uri result, boolean exit) { if (SHOW_IMAGE) { // TODO: we should update the existing image in Gallery instead Intent viewImage = new Intent(Intent.ACTION_VIEW, result); viewImage.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(viewImage); } mNotifyMgr.cancel(mNotificationId); if (!exit) { stopForeground(true); stopSelf(); return; } stopForeground(true); stopSelf(); if (mNeedsAlive) { Loading
src/com/android/gallery3d/filtershow/tools/SaveImage.java +6 −5 Original line number Diff line number Diff line Loading @@ -326,9 +326,12 @@ public class SaveImage { } public Uri processAndSaveImage(ImagePreset preset, boolean flatten, int quality, float sizeFactor) { int quality, float sizeFactor, boolean exit) { Uri uri = resetToOriginalImageIfNeeded(preset, !flatten); Uri uri = null; if (exit) { uri = resetToOriginalImageIfNeeded(preset, !flatten); } if (uri != null) { return null; } Loading Loading @@ -361,9 +364,7 @@ public class SaveImage { Images.Media.EXTERNAL_CONTENT_URI, values); } } else { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); long time = System.currentTimeMillis(); Loading Loading @@ -536,7 +537,7 @@ public class SaveImage { flatten = true; } Intent processIntent = ProcessingService.getSaveIntent(filterShowActivity, preset, destination, selectedImageUri, sourceImageUri, flatten, 90, 1f); destination, selectedImageUri, sourceImageUri, flatten, 90, 1f, true); filterShowActivity.startService(processIntent); Loading
src/com/android/gallery3d/filtershow/ui/ExportDialog.java +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class ExportDialog extends DialogFragment implements View.OnClickListener float scaleFactor = mExportWidth / (float) mOriginalBounds.width(); Intent processIntent = ProcessingService.getSaveIntent(activity, MasterImage .getImage().getPreset(), dest, activity.getSelectedImageUri(), sourceUri, true, mSeekBar.getProgress(), scaleFactor); true, mSeekBar.getProgress(), scaleFactor, false); activity.startService(processIntent); dismiss(); break; Loading