Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F3C8AEAE for ; Thu, 21 Jun 2012 19:37:01 +0000 (UTC) Received: (qmail 57898 invoked by uid 500); 21 Jun 2012 19:37:01 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 57850 invoked by uid 500); 21 Jun 2012 19:37:01 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 57734 invoked by uid 99); 21 Jun 2012 19:37:01 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jun 2012 19:37:01 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7E54B63B6; Thu, 21 Jun 2012 19:37:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [4/7] android commit: Removing images and saving images to jail if SaveToPhotoAlbum is set to true Message-Id: <20120621193701.7E54B63B6@tyr.zones.apache.org> Date: Thu, 21 Jun 2012 19:37:01 +0000 (UTC) Removing images and saving images to jail if SaveToPhotoAlbum is set to true Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/f6d4402f Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/f6d4402f Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/f6d4402f Branch: refs/heads/master Commit: f6d4402fdc8eae41352f2f268a69e578bf33754f Parents: 9f66ccb Author: Fil Maj Authored: Wed Jun 20 14:12:06 2012 -0700 Committer: Fil Maj Committed: Thu Jun 21 12:09:50 2012 -0700 ---------------------------------------------------------------------- .../src/org/apache/cordova/CameraLauncher.java | 27 ++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/f6d4402f/framework/src/org/apache/cordova/CameraLauncher.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java index f2c3e12..d9467fb 100755 --- a/framework/src/org/apache/cordova/CameraLauncher.java +++ b/framework/src/org/apache/cordova/CameraLauncher.java @@ -338,6 +338,7 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie ContentValues values = new ContentValues(); values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); + try { this.imageUri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException e) { @@ -350,6 +351,22 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie return; } } + if (!this.saveToPhotoAlbum) { + File tempFile = new File(this.imageUri.toString()); + Uri jailURI = Uri.fromFile(new File("/data/data/" + this.cordova.getActivity().getPackageName() + "/", tempFile.getName())); + + // Clean up initial URI before writing out safe URI + boolean didWeDeleteIt = tempFile.delete(); + if (!didWeDeleteIt) { + int result = this.cordova.getActivity().getContentResolver().delete( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + MediaStore.Images.Media.DATA + " = ?", + new String[] { this.imageUri.toString() } + ); + LOG.d("TAG!","result is " + result); + } + this.imageUri = jailURI; + } // If all this is true we shouldn't compress the image. if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100) { @@ -378,10 +395,18 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie os.close(); // Restore exif data to file + if (this.encodingType == JPEG) { - exif.createOutFile(FileUtils.getRealPathFromURI(this.imageUri, this.cordova)); + String exifPath; + if (this.saveToPhotoAlbum) { + exifPath = FileUtils.getRealPathFromURI(this.imageUri, this.cordova); + } else { + exifPath = this.imageUri.toString(); + } + exif.createOutFile(exifPath); exif.writeExifData(); } + // Scan for the gallery to update pic refs in gallery this.scanForGallery();