Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 270CF10DD6 for ; Mon, 9 Sep 2013 20:11:15 +0000 (UTC) Received: (qmail 14325 invoked by uid 500); 9 Sep 2013 20:11:12 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 14091 invoked by uid 500); 9 Sep 2013 20:11:12 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 13967 invoked by uid 99); 9 Sep 2013 20:11:11 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Sep 2013 20:11:11 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AD43B8252FE; Mon, 9 Sep 2013 20:11:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: [CB-4764] Remove reference to DirectoryManager from CameraLauncher Date: Mon, 9 Sep 2013 20:11:11 +0000 (UTC) Updated Branches: refs/heads/dev 44517ea93 -> df028dd25 [CB-4764] Remove reference to DirectoryManager from CameraLauncher Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/df028dd2 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/df028dd2 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/df028dd2 Branch: refs/heads/dev Commit: df028dd2571ab8fd1032a20b0f55ca2b32e8c0b9 Parents: 44517ea Author: Andrew Grieve Authored: Mon Sep 9 16:03:36 2013 -0400 Committer: Andrew Grieve Committed: Mon Sep 9 16:10:16 2013 -0400 ---------------------------------------------------------------------- src/android/CameraLauncher.java | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/df028dd2/src/android/CameraLauncher.java ---------------------------------------------------------------------- diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java index c8961f6..4d01179 100755 --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -27,7 +27,6 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.cordova.ExifHelper; -import org.apache.cordova.DirectoryManager; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.LOG; @@ -94,23 +93,6 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect private MediaScannerConnection conn; // Used to update gallery app with newly-written files private Uri scanMe; // Uri of image to be added to content store - //This should never be null! - //private CordovaInterface cordova; - - /** - * Constructor. - */ - public CameraLauncher() { - } - -// public void setContext(CordovaInterface mCtx) { -// super.setContext(mCtx); -// if (CordovaInterface.class.isInstance(mCtx)) -// cordova = (CordovaInterface) mCtx; -// else -// LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity"); -// } - /** * Executes the request and returns PluginResult. * @@ -181,6 +163,24 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect // LOCAL METHODS //-------------------------------------------------------------------------- + private String getTempDirectoryPath() { + File cache = null; + + // SD Card Mounted + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { + cache = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + + "/Android/data/" + cordova.getActivity().getPackageName() + "/cache/"); + } + // Use internal storage + else { + cache = cordova.getActivity().getCacheDir(); + } + + // Create the cache directory if it doesn't exist + cache.mkdirs(); + return cache.getAbsolutePath(); + } + /** * Take a picture with the camera. * When an image is captured or the camera view is cancelled, the result is returned @@ -223,9 +223,9 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect private File createCaptureFile(int encodingType) { File photo = null; if (encodingType == JPEG) { - photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), ".Pic.jpg"); + photo = new File(getTempDirectoryPath(), ".Pic.jpg"); } else if (encodingType == PNG) { - photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), ".Pic.png"); + photo = new File(getTempDirectoryPath(), ".Pic.png"); } else { throw new IllegalArgumentException("Invalid Encoding Type: " + encodingType); } @@ -289,7 +289,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect ExifHelper exif = new ExifHelper(); try { if (this.encodingType == JPEG) { - exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg"); + exif.createInFile(getTempDirectoryPath() + "/.Pic.jpg"); exif.readExifData(); rotate = exif.getOrientation(); } @@ -330,7 +330,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect //Just because we have a media URI doesn't mean we have a real file, we need to make it uri = Uri.fromFile(new File(FileHelper.getRealPath(inputUri, this.cordova))); } else { - uri = Uri.fromFile(new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), System.currentTimeMillis() + ".jpg")); + uri = Uri.fromFile(new File(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg")); } if (uri == null) { @@ -450,7 +450,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect if (this.targetHeight > 0 && this.targetWidth > 0) { try { // Create an ExifHelper to save the exif data that is lost during compression - String resizePath = DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/resize.jpg"; + String resizePath = getTempDirectoryPath() + "/resize.jpg"; // Some content: URIs do not map to file paths (e.g. picasa). String realPath = FileHelper.getRealPath(uri, this.cordova); ExifHelper exif = new ExifHelper();