You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/25 20:12:00 UTC
[3/3] git commit: CB-6521: Remove development branch
CB-6521: Remove development branch
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/20aa744b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/20aa744b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/20aa744b
Branch: refs/heads/dev
Commit: 20aa744b556fee77536c6d52276e644442136115
Parents: d6af209
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Apr 25 14:09:46 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 25 14:09:46 2014 -0400
----------------------------------------------------------------------
LICENSE | 202 --------
NOTICE | 5 -
README.md | 2 +
RELEASENOTES.md | 82 ----
doc/index.md | 441 ------------------
plugin.xml | 219 ---------
src/android/CameraLauncher.java | 866 -----------------------------------
src/android/ExifHelper.java | 185 --------
src/android/FileHelper.java | 158 -------
src/blackberry10/index.js | 129 ------
src/firefoxos/CameraProxy.js | 51 ---
src/ios/CDVCamera.h | 102 -----
src/ios/CDVCamera.m | 756 ------------------------------
src/ios/CDVExif.h | 43 --
src/ios/CDVJpegHeaderWriter.h | 62 ---
src/ios/CDVJpegHeaderWriter.m | 547 ----------------------
src/ubuntu/CaptureWidget.qml | 119 -----
src/ubuntu/back.png | Bin 12428 -> 0 bytes
src/ubuntu/camera.cpp | 143 ------
src/ubuntu/camera.h | 76 ---
src/ubuntu/shoot.png | Bin 14430 -> 0 bytes
src/ubuntu/toolbar-left.png | Bin 1212 -> 0 bytes
src/ubuntu/toolbar-middle.png | Bin 4416 -> 0 bytes
src/ubuntu/toolbar-right.png | Bin 1161 -> 0 bytes
src/windows8/CameraProxy.js | 354 --------------
src/wp/Camera.cs | 515 ---------------------
www/Camera.js | 75 ---
www/CameraConstants.js | 53 ---
www/CameraPopoverHandle.js | 33 --
www/CameraPopoverOptions.js | 37 --
www/ios/CameraPopoverHandle.js | 34 --
31 files changed, 2 insertions(+), 5287 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 7a4a3ea..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 8ec56a5..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache Cordova
-Copyright 2012 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index f84180e..dcda226 100644
--- a/README.md
+++ b/README.md
@@ -20,3 +20,5 @@
# org.apache.cordova.camera
Plugin documentation: [doc/index.md](doc/index.md)
+
+This is `dev` - the deprecated development branch of this plugin; development of this plugin has moved to the `master` branch
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
deleted file mode 100644
index 836bc27..0000000
--- a/RELEASENOTES.md
+++ /dev/null
@@ -1,82 +0,0 @@
-<!--
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
--->
-# Release Notes
-
-### 0.2.1 (Sept 5, 2013)
-* [CB-4656] Don't add line-breaks to base64-encoded images (Fixes type=DataURI)
-* [CB-4432] copyright notice change
-
-### 0.2.3 (Sept 25, 2013)
-* CB-4889 bumping&resetting version
-* CB-4889 forgot index.html
-* CB-4889 renaming core inside cameraProxy
-* [Windows8] commandProxy has moved
-* [Windows8] commandProxy has moved
-* added Camera API for FirefoxOS
-* Rename CHANGELOG.md -> RELEASENOTES.md
-* [CB-4823] Fix XCode 5 camera plugin warnings
-* Fix compiler warnings
-* [CB-4765] Move ExifHelper.java into Camera Plugin
-* [CB-4764] Remove reference to DirectoryManager from CameraLauncher
-* [CB-4763] Use a copy of FileHelper.java within camera-plugin.
-* [CB-4752] Incremented plugin version on dev branch.
-* CB-4633: We really should close cursors. It's just the right thing to do.
-* No longer causes a stack trace, but it doesn't cause the error to be called.
-* CB-4889 renaming org.apache.cordova.core.camera to org.apache.cordova.camera
-
- ### 0.2.4 (Oct 28, 2013)
-* CB-5128: added repo + issue tag to plugin.xml for camera plugin
-* CB-4958 - iOS - Camera plugin should not show the status bar
-* [CB-4919] updated plugin.xml for FxOS
-* [CB-4915] Incremented plugin version on dev branch.
-
-### 0.2.5 (Dec 4, 2013)
-* fix camera for firefox os
-* getPicture via web activities
-* [ubuntu] specify policy_group
-* add ubuntu platform
-* 1. User Agent detection now detects AmazonWebView. 2. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
-* Added amazon-fireos platform.
-
-### 0.2.6 (Jan 02, 2014)
-* CB-5658 Add doc/index.md for Camera plugin
-* CB-2442 CB-2419 Use Windows.Storage.ApplicationData.current.localFolder, instead of writing to app package.
-* [BlackBerry10] Adding platform level permissions
-* CB-5599 Android: Catch and ignore OutOfMemoryError in getRotatedBitmap()
-
-### 0.2.7 (Feb 05, 2014)
-* CB-4919 firefox os quirks added and supported platforms list is updated
-* getPicture via web activities
-* Documented quirk for CB-5335 + CB-5206 for WP7+8
-* reference the correct firefoxos implementation
-* [BlackBerry10] Add permission to access_shared
-
-### 0.2.8 (Feb 26, 2014)
-* CB-1826 Catch OOM on gallery image resize
-
-### 0.2.9 (Apr 17, 2014)
-* CB-6460: Update license headers
-* CB-6422: [windows8] use cordova/exec/proxy
-* [WP8] When only targetWidth or targetHeight is provided, use it as the only bound
-* CB-4027, CB-5102, CB-2737, CB-2387: [WP] Fix camera issues, cropping, memory leaks
-* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
-* [BlackBerry10] Add rim xml namespaces declaration
-* Add NOTICE file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
deleted file mode 100644
index edd881f..0000000
--- a/doc/index.md
+++ /dev/null
@@ -1,441 +0,0 @@
-<!---
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-# org.apache.cordova.camera
-
-This plugin provides an API for taking pictures and for choosing images from
-the system's image library.
-
- cordova plugin add org.apache.cordova.camera
-
-
-## navigator.camera.getPicture
-
-Takes a photo using the camera, or retrieves a photo from the device's
-image gallery. The image is passed to the success callback as a
-base64-encoded `String`, or as the URI for the image file. The method
-itself returns a `CameraPopoverHandle` object that can be used to
-reposition the file selection popover.
-
- navigator.camera.getPicture( cameraSuccess, cameraError, [ cameraOptions ] );
-
-### Description
-
-The `camera.getPicture` function opens the device's default camera
-application that allows users to snap pictures. This behavior occurs
-by default, when `Camera.sourceType` equals
-`Camera.PictureSourceType.CAMERA`. Once the user snaps the photo, the
-camera application closes and the application is restored.
-
-If `Camera.sourceType` is `Camera.PictureSourceType.PHOTOLIBRARY` or
-`Camera.PictureSourceType.SAVEDPHOTOALBUM`, then a dialog displays
-that allows users to select an existing image. The
-`camera.getPicture` function returns a `CameraPopoverHandle` object,
-which can be used to reposition the image selection dialog, for
-example, when the device orientation changes.
-
-The return value is sent to the `cameraSuccess` callback function, in
-one of the following formats, depending on the specified
-`cameraOptions`:
-
-- A `String` containing the base64-encoded photo image.
-
-- A `String` representing the image file location on local storage (default).
-
-You can do whatever you want with the encoded image or URI, for
-example:
-
-- Render the image in an `<img>` tag, as in the example below
-
-- Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.)
-
-- Post the data to a remote server
-
-__NOTE__: Photo resolution on newer devices is quite good. Photos
-selected from the device's gallery are not downscaled to a lower
-quality, even if a `quality` parameter is specified. To avoid common
-memory problems, set `Camera.destinationType` to `FILE_URI` rather
-than `DATA_URL`.
-
-### Supported Platforms
-
-- Amazon Fire OS
-- Android
-- BlackBerry 10
-- Firefox OS
-- iOS
-- Tizen
-- Windows Phone 7 and 8
-- Windows 8
-
-### Amazon Fire OS Quirks
-
-Amazon Fire OS uses intents to launch the camera activity on the device to capture
-images, and on phones with low memory, the Cordova activity may be killed. In this
-scenario, the image may not appear when the cordova activity is restored.
-
-### Android Quirks
-
-*Android 4.4 only*: Android 4.4 introduced a new [Storage Access Framework](https://developer.android.com/guide/topics/providers/document-provider.html) that makes it
-easier for users to browse and open documents across all of their preferred document storage providers.
-Cordova has not yet been fully integrated with this new Storage Access Framework. Because of this, the `getPicture()`
-method will not correctly return pictures when the user selects from the "Recent", "Drive", "Images", or "External
-Storage" folders when the `destinationType` is `FILE_URI`. However, the user will be able to correctly select any pictures
-if they go through the "Gallery" app first. Potential workarounds for this issue are documented on [this StackOverflow question](http://stackoverflow.com/questions/19834842/android-gallery-on-kitkat-returns-different-uri-for-intent-action-get-content/20177611). Please see [CB-5398](https://issues.apache.org/jira/browse/CB-5398) to track this issue.
-
-Android uses intents to launch the camera activity on the device to capture
-images, and on phones with low memory, the Cordova activity may be killed. In this
-scenario, the image may not appear when the Cordova activity is restored.
-
-### Firefox OS Quirks
-
-Camera plugin is currently implemented using [Web Activities](https://hacks.mozilla.org/2013/01/introducing-web-activities/).
-
-### iOS Quirks
-
-Including a JavaScript `alert()` in either of the callback functions
-can cause problems. Wrap the alert within a `setTimeout()` to allow
-the iOS image picker or popover to fully close before the alert
-displays:
-
- setTimeout(function() {
- // do your thing here!
- }, 0);
-
-### Windows Phone 7 Quirks
-
-Invoking the native camera application while the device is connected
-via Zune does not work, and triggers an error callback.
-
-### Tizen Quirks
-
-Tizen only supports a `destinationType` of
-`Camera.DestinationType.FILE_URI` and a `sourceType` of
-`Camera.PictureSourceType.PHOTOLIBRARY`.
-
-### Example
-
-Take a photo and retrieve it as a base64-encoded image:
-
- navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
- destinationType: Camera.DestinationType.DATA_URL
- });
-
- function onSuccess(imageData) {
- var image = document.getElementById('myImage');
- image.src = "data:image/jpeg;base64," + imageData;
- }
-
- function onFail(message) {
- alert('Failed because: ' + message);
- }
-
-Take a photo and retrieve the image's file location:
-
- navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
- destinationType: Camera.DestinationType.FILE_URI });
-
- function onSuccess(imageURI) {
- var image = document.getElementById('myImage');
- image.src = imageURI;
- }
-
- function onFail(message) {
- alert('Failed because: ' + message);
- }
-
-## CameraOptions
-
-Optional parameters to customize the camera settings.
-
- { quality : 75,
- destinationType : Camera.DestinationType.DATA_URL,
- sourceType : Camera.PictureSourceType.CAMERA,
- allowEdit : true,
- encodingType: Camera.EncodingType.JPEG,
- targetWidth: 100,
- targetHeight: 100,
- popoverOptions: CameraPopoverOptions,
- saveToPhotoAlbum: false };
-
-### Options
-
-- __quality__: Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. _(Number)_ (Note that information about the camera's resolution is unavailable.)
-
-- __destinationType__: Choose the format of the return value. Defined in `navigator.camera.DestinationType` _(Number)_
-
- Camera.DestinationType = {
- DATA_URL : 0, // Return image as base64-encoded string
- FILE_URI : 1, // Return image file URI
- NATIVE_URI : 2 // Return image native URI (e.g., assets-library:// on iOS or content:// on Android)
- };
-
-- __sourceType__: Set the source of the picture. Defined in `navigator.camera.PictureSourceType` _(Number)_
-
- Camera.PictureSourceType = {
- PHOTOLIBRARY : 0,
- CAMERA : 1,
- SAVEDPHOTOALBUM : 2
- };
-
-- __allowEdit__: Allow simple editing of image before selection. _(Boolean)_
-
-- __encodingType__: Choose the returned image file's encoding. Defined in `navigator.camera.EncodingType` _(Number)_
-
- Camera.EncodingType = {
- JPEG : 0, // Return JPEG encoded image
- PNG : 1 // Return PNG encoded image
- };
-
-- __targetWidth__: Width in pixels to scale image. Must be used with __targetHeight__. Aspect ratio remains constant. _(Number)_
-
-- __targetHeight__: Height in pixels to scale image. Must be used with __targetWidth__. Aspect ratio remains constant. _(Number)_
-
-- __mediaType__: Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. Defined in `nagivator.camera.MediaType` _(Number)_
-
- Camera.MediaType = {
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- VIDEO: 1, // allow selection of video only, WILL ALWAYS RETURN FILE_URI
- ALLMEDIA : 2 // allow selection from all media types
-};
-
-- __correctOrientation__: Rotate the image to correct for the orientation of the device during capture. _(Boolean)_
-
-- __saveToPhotoAlbum__: Save the image to the photo album on the device after capture. _(Boolean)_
-
-- __popoverOptions__: iOS-only options that specify popover location in iPad. Defined in `CameraPopoverOptions`.
-
-- __cameraDirection__: Choose the camera to use (front- or back-facing). Defined in `navigator.camera.Direction` _(Number)_
-
- Camera.Direction = {
- BACK : 0, // Use the back-facing camera
- FRONT : 1 // Use the front-facing camera
- };
-
-### Amazon Fire OSQuirks
-
-- Any `cameraDirection` value results in a back-facing photo.
-
-- Ignores the `allowEdit` parameter.
-
-- `Camera.PictureSourceType.PHOTOLIBRARY` and `Camera.PictureSourceType.SAVEDPHOTOALBUM` both display the same photo album.
-
-### Android Quirks
-
-- Any `cameraDirection` value results in a back-facing photo.
-
-- Ignores the `allowEdit` parameter.
-
-- `Camera.PictureSourceType.PHOTOLIBRARY` and `Camera.PictureSourceType.SAVEDPHOTOALBUM` both display the same photo album.
-
-### BlackBerry 10 Quirks
-
-- Ignores the `quality` parameter.
-
-- Ignores the `sourceType` parameter.
-
-- Ignores the `allowEdit` parameter.
-
-- `Camera.MediaType` is not supported.
-
-- Ignores the `correctOrientation` parameter.
-
-- Ignores the `cameraDirection` parameter.
-
-### Firefox OS Quirks
-
-- Ignores the `quality` parameter.
-
-- `Camera.DestinationType` is ignored and equals `1` (image file URI)
-
-- Ignores the `allowEdit` parameter.
-
-- Ignores the `PictureSourceType` parameter (user chooses it in a dialog window)
-
-- Ignores the `encodingType`
-
-- Ignores the `targetWidth` and `targetHeight`
-
-- `Camera.MediaType` is not supported.
-
-- Ignores the `correctOrientation` parameter.
-
-- Ignores the `cameraDirection` parameter.
-
-### iOS Quirks
-
-- Set `quality` below 50 to avoid memory errors on some devices.
-
-- When using `destinationType.FILE_URI`, photos are saved in the application's temporary directory. You may delete the contents of this directory using the `navigator.fileMgr` APIs if storage space is a concern.
-
-### Tizen Quirks
-
-- options not supported
-
-- always returns a FILE URI
-
-### Windows Phone 7 and 8 Quirks
-
-- Ignores the `allowEdit` parameter.
-
-- Ignores the `correctOrientation` parameter.
-
-- Ignores the `cameraDirection` parameter.
-
-- Ignores the `mediaType` property of `cameraOptions` as the Windows Phone SDK does not provide a way to choose videos from PHOTOLIBRARY.
-
-
-## CameraError
-
-onError callback function that provides an error message.
-
- function(message) {
- // Show a helpful message
- }
-
-### Parameters
-
-- __message__: The message is provided by the device's native code. _(String)_
-
-
-## cameraSuccess
-
-onSuccess callback function that provides the image data.
-
- function(imageData) {
- // Do something with the image
- }
-
-### Parameters
-
-- __imageData__: Base64 encoding of the image data, _or_ the image file URI, depending on `cameraOptions` in effect. _(String)_
-
-### Example
-
- // Show image
- //
- function cameraCallback(imageData) {
- var image = document.getElementById('myImage');
- image.src = "data:image/jpeg;base64," + imageData;
- }
-
-
-## CameraPopoverHandle
-
-A handle to the popover dialog created by `navigator.camera.getPicture`.
-
-### Methods
-
-- __setPosition__: Set the position of the popover.
-
-### Supported Platforms
-
-- iOS
-
-### setPosition
-
-Set the position of the popover.
-
-__Parameters__:
-
-- `cameraPopoverOptions`: the `CameraPopoverOptions` that specify the new position
-
-### Example
-
- var cameraPopoverHandle = navigator.camera.getPicture(onSuccess, onFail,
- { destinationType: Camera.DestinationType.FILE_URI,
- sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
- popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)
- });
-
- // Reposition the popover if the orientation changes.
- window.onorientationchange = function() {
- var cameraPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY);
- cameraPopoverHandle.setPosition(cameraPopoverOptions);
- }
-
-
-## CameraPopoverOptions
-
-iOS-only parameters that specify the anchor element location and arrow
-direction of the popover when selecting images from an iPad's library
-or album.
-
- { x : 0,
- y : 32,
- width : 320,
- height : 480,
- arrowDir : Camera.PopoverArrowDirection.ARROW_ANY
- };
-
-### CameraPopoverOptions
-
-- __x__: x pixel coordinate of screen element onto which to anchor the popover. _(Number)_
-
-- __y__: y pixel coordinate of screen element onto which to anchor the popover. _(Number)_
-
-- __width__: width, in pixels, of the screen element onto which to anchor the popover. _(Number)_
-
-- __height__: height, in pixels, of the screen element onto which to anchor the popover. _(Number)_
-
-- __arrowDir__: Direction the arrow on the popover should point. Defined in `Camera.PopoverArrowDirection` _(Number)_
-
- Camera.PopoverArrowDirection = {
- ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants
- ARROW_DOWN : 2,
- ARROW_LEFT : 4,
- ARROW_RIGHT : 8,
- ARROW_ANY : 15
- };
-
-Note that the size of the popover may change to adjust to the
-direction of the arrow and orientation of the screen. Make sure to
-account for orientation changes when specifying the anchor element
-location.
-
-## navigator.camera.cleanup
-
-Removes intermediate photos taken by the camera from temporary
-storage.
-
- navigator.camera.cleanup( cameraSuccess, cameraError );
-
-### Description
-
-Removes intermediate image files that are kept in temporary storage
-after calling `camera.getPicture`. Applies only when the value of
-`Camera.sourceType` equals `Camera.PictureSourceType.CAMERA` and the
-`Camera.destinationType` equals `Camera.DestinationType.FILE_URI`.
-
-### Supported Platforms
-
-- iOS
-
-### Example
-
- navigator.camera.cleanup(onSuccess, onFail);
-
- function onSuccess() {
- console.log("Camera cleanup success.")
- }
-
- function onFail(message) {
- alert('Failed because: ' + message);
- }
-
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
deleted file mode 100644
index a51f172..0000000
--- a/plugin.xml
+++ /dev/null
@@ -1,219 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:rim="http://www.blackberry.com/ns/widgets"
- id="org.apache.cordova.camera"
- version="0.2.10-dev">
- <name>Camera</name>
- <description>Cordova Camera Plugin</description>
- <license>Apache 2.0</license>
- <keywords>cordova,camera</keywords>
- <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git</repo>
- <issue>https://issues.apache.org/jira/browse/CB/component/12320645</issue>
-
- <js-module src="www/CameraConstants.js" name="Camera">
- <clobbers target="Camera" />
- </js-module>
-
- <js-module src="www/CameraPopoverOptions.js" name="CameraPopoverOptions">
- <clobbers target="CameraPopoverOptions" />
- </js-module>
-
-
-
- <js-module src="www/Camera.js" name="camera">
- <clobbers target="navigator.camera" />
- </js-module>
-
- <!-- firefoxos -->
- <platform name="firefoxos">
- <config-file target="config.xml" parent="/*">
- <feature name="Camera">
- <param name="firefoxos-package" value="Camera" />
- </feature>
- </config-file>
-
- <js-module src="src/firefoxos/CameraProxy.js" name="CameraProxy">
- <runs />
- </js-module>
- </platform>
-
- <!-- android -->
- <platform name="android">
- <config-file target="res/xml/config.xml" parent="/*">
- <feature name="Camera">
- <param name="android-package" value="org.apache.cordova.camera.CameraLauncher"/>
- </feature>
- </config-file>
- <config-file target="AndroidManifest.xml" parent="/*">
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- </config-file>
-
- <source-file src="src/android/CameraLauncher.java" target-dir="src/org/apache/cordova/camera" />
- <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/camera" />
- <source-file src="src/android/ExifHelper.java" target-dir="src/org/apache/cordova/camera" />
-
- <js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
-
- </platform>
-
- <!-- amazon-fireos -->
- <platform name="amazon-fireos">
- <config-file target="res/xml/config.xml" parent="/*">
- <feature name="Camera">
- <param name="android-package" value="org.apache.cordova.camera.CameraLauncher"/>
- </feature>
- </config-file>
- <config-file target="AndroidManifest.xml" parent="/*">
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- </config-file>
-
- <source-file src="src/android/CameraLauncher.java" target-dir="src/org/apache/cordova/camera" />
- <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/camera" />
- <source-file src="src/android/ExifHelper.java" target-dir="src/org/apache/cordova/camera" />
-
- <js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
-
- </platform>
-
- <!-- ubuntu -->
- <platform name="ubuntu">
- <config-file target="config.xml" parent="/*">
- <feature name="Camera">
- <param policy_group="camera" policy_version="1" />
- </feature>
- </config-file>
- <js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
- <header-file src="src/ubuntu/camera.h" />
- <source-file src="src/ubuntu/camera.cpp" />
-
- <resource-file src="src/ubuntu/back.png" />
- <resource-file src="src/ubuntu/CaptureWidget.qml" />
- <resource-file src="src/ubuntu/shoot.png" />
- <resource-file src="src/ubuntu/toolbar-left.png" />
- <resource-file src="src/ubuntu/toolbar-middle.png" />
- <resource-file src="src/ubuntu/toolbar-right.png" />
- </platform>
-
- <!-- ios -->
- <platform name="ios">
- <config-file target="config.xml" parent="/*">
- <feature name="Camera">
- <param name="ios-package" value="CDVCamera" />
- </feature>
- </config-file>
-
- <js-module src="www/ios/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
-
- <header-file src="src/ios/CDVCamera.h" />
- <source-file src="src/ios/CDVCamera.m" />
- <header-file src="src/ios/CDVJpegHeaderWriter.h" />
- <source-file src="src/ios/CDVJpegHeaderWriter.m" />
- <header-file src="src/ios/CDVExif.h" />
- <framework src="ImageIO.framework" weak="true" />
- <framework src="CoreLocation.framework" />
- <framework src="CoreGraphics.framework" />
- <framework src="AssetsLibrary.framework" />
- <framework src="MobileCoreServices.framework" />
- </platform>
-
- <!-- blackberry10 -->
- <platform name="blackberry10">
- <source-file src="src/blackberry10/index.js" target-dir="Camera" />
- <config-file target="www/config.xml" parent="/widget">
- <feature name="Camera" value="Camera"/>
- </config-file>
- <config-file target="www/config.xml" parent="/widget/rim:permissions">
- <rim:permit>access_shared</rim:permit>
- </config-file>
- <js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
- </platform>
-
- <!-- wp7 -->
- <platform name="wp7">
- <config-file target="config.xml" parent="/*">
- <feature name="Camera">
- <param name="wp-package" value="Camera"/>
- </feature>
- </config-file>
-
- <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
- <Capability Name="ID_CAP_ISV_CAMERA" />
- <Capability Name="ID_CAP_MEDIALIB" />
- </config-file>
-
- <source-file src="src/wp/Camera.cs" />
-
-
- <js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
- </platform>
-
- <!-- wp8 -->
- <platform name="wp8">
- <config-file target="config.xml" parent="/*">
- <feature name="Camera">
- <param name="wp-package" value="Camera"/>
- </feature>
- </config-file>
-
- <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
- <Capability Name="ID_CAP_ISV_CAMERA" />
- <Capability Name="ID_CAP_MEDIALIB_PHOTO"/>
- </config-file>
-
- <source-file src="src/wp/Camera.cs" />
-
- <js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
- </platform>
-
- <!-- windows8 -->
- <platform name="windows8">
-
- <dependency id="org.apache.cordova.file" />
- <config-file target="package.appxmanifest" parent="/Package/Capabilities">
- <Capability Name="picturesLibrary" />
- <DeviceCapability Name="webcam" />
- </config-file>
- <js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
- <clobbers target="CameraPopoverHandle" />
- </js-module>
- <js-module src="src/windows8/CameraProxy.js" name="CameraProxy">
- <merges target="" />
- </js-module>
-
- </platform>
-
-</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/src/android/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java
deleted file mode 100755
index 57878ab..0000000
--- a/src/android/CameraLauncher.java
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova.camera;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.LOG;
-import org.apache.cordova.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import android.app.Activity;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.graphics.Bitmap.CompressFormat;
-import android.media.MediaScannerConnection;
-import android.media.MediaScannerConnection.MediaScannerConnectionClient;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.util.Base64;
-import android.util.Log;
-
-/**
- * This class launches the camera view, allows the user to take a picture, closes the camera view,
- * and returns the captured image. When the camera view is closed, the screen displayed before
- * the camera view was shown is redisplayed.
- */
-public class CameraLauncher extends CordovaPlugin implements MediaScannerConnectionClient {
-
- private static final int DATA_URL = 0; // Return base64 encoded string
- private static final int FILE_URI = 1; // Return file uri (content://media/external/images/media/2 for Android)
- private static final int NATIVE_URI = 2; // On Android, this is the same as FILE_URI
-
- private static final int PHOTOLIBRARY = 0; // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
- private static final int CAMERA = 1; // Take picture from camera
- private static final int SAVEDPHOTOALBUM = 2; // Choose image from picture library (same as PHOTOLIBRARY for Android)
-
- private static final int PICTURE = 0; // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- private static final int VIDEO = 1; // allow selection of video only, ONLY RETURNS URL
- private static final int ALLMEDIA = 2; // allow selection from all media types
-
- private static final int JPEG = 0; // Take a picture of type JPEG
- private static final int PNG = 1; // Take a picture of type PNG
- private static final String GET_PICTURE = "Get Picture";
- private static final String GET_VIDEO = "Get Video";
- private static final String GET_All = "Get All";
-
- private static final String LOG_TAG = "CameraLauncher";
-
- private int mQuality; // Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
- private int targetWidth; // desired width of the image
- private int targetHeight; // desired height of the image
- private Uri imageUri; // Uri of captured image
- private int encodingType; // Type of encoding to use
- private int mediaType; // What type of media to retrieve
- private boolean saveToPhotoAlbum; // Should the picture be saved to the device's photo album
- private boolean correctOrientation; // Should the pictures orientation be corrected
- private boolean orientationCorrected; // Has the picture's orientation been corrected
- //private boolean allowEdit; // Should we allow the user to crop the image. UNUSED.
-
- public CallbackContext callbackContext;
- private int numPics;
-
- private MediaScannerConnection conn; // Used to update gallery app with newly-written files
- private Uri scanMe; // Uri of image to be added to content store
-
- /**
- * Executes the request and returns PluginResult.
- *
- * @param action The action to execute.
- * @param args JSONArry of arguments for the plugin.
- * @param callbackContext The callback id used when calling back into JavaScript.
- * @return A PluginResult object with a status and message.
- */
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- this.callbackContext = callbackContext;
-
- if (action.equals("takePicture")) {
- int srcType = CAMERA;
- int destType = FILE_URI;
- this.saveToPhotoAlbum = false;
- this.targetHeight = 0;
- this.targetWidth = 0;
- this.encodingType = JPEG;
- this.mediaType = PICTURE;
- this.mQuality = 80;
-
- this.mQuality = args.getInt(0);
- destType = args.getInt(1);
- srcType = args.getInt(2);
- this.targetWidth = args.getInt(3);
- this.targetHeight = args.getInt(4);
- this.encodingType = args.getInt(5);
- this.mediaType = args.getInt(6);
- //this.allowEdit = args.getBoolean(7); // This field is unused.
- this.correctOrientation = args.getBoolean(8);
- this.saveToPhotoAlbum = args.getBoolean(9);
-
- // If the user specifies a 0 or smaller width/height
- // make it -1 so later comparisons succeed
- if (this.targetWidth < 1) {
- this.targetWidth = -1;
- }
- if (this.targetHeight < 1) {
- this.targetHeight = -1;
- }
-
- try {
- if (srcType == CAMERA) {
- this.takePicture(destType, encodingType);
- }
- else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) {
- this.getImage(srcType, destType);
- }
- }
- catch (IllegalArgumentException e)
- {
- callbackContext.error("Illegal Argument Exception");
- PluginResult r = new PluginResult(PluginResult.Status.ERROR);
- callbackContext.sendPluginResult(r);
- return true;
- }
-
- PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
- r.setKeepCallback(true);
- callbackContext.sendPluginResult(r);
-
- return true;
- }
- return false;
- }
-
- //--------------------------------------------------------------------------
- // 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
- * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult.
- *
- * The image can either be returned as a base64 string or a URI that points to the file.
- * To display base64 string in an img tag, set the source to:
- * img.src="data:image/jpeg;base64,"+result;
- * or to display URI in an img tag
- * img.src=result;
- *
- * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
- * @param returnType Set the type of image to return.
- */
- public void takePicture(int returnType, int encodingType) {
- // Save the number of images currently on disk for later
- this.numPics = queryImgDB(whichContentStore()).getCount();
-
- // Display camera
- Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
-
- // Specify file so that large image is captured and returned
- File photo = createCaptureFile(encodingType);
- intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
- this.imageUri = Uri.fromFile(photo);
-
- if (this.cordova != null) {
- this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1);
- }
-// else
-// LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
- }
-
- /**
- * Create a file in the applications temporary directory based upon the supplied encoding.
- *
- * @param encodingType of the image to be taken
- * @return a File object pointing to the temporary picture
- */
- private File createCaptureFile(int encodingType) {
- File photo = null;
- if (encodingType == JPEG) {
- photo = new File(getTempDirectoryPath(), ".Pic.jpg");
- } else if (encodingType == PNG) {
- photo = new File(getTempDirectoryPath(), ".Pic.png");
- } else {
- throw new IllegalArgumentException("Invalid Encoding Type: " + encodingType);
- }
- return photo;
- }
-
- /**
- * Get image from photo library.
- *
- * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
- * @param srcType The album to get image from.
- * @param returnType Set the type of image to return.
- */
- // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do!
- public void getImage(int srcType, int returnType) {
- Intent intent = new Intent();
- String title = GET_PICTURE;
- if (this.mediaType == PICTURE) {
- intent.setType("image/*");
- }
- else if (this.mediaType == VIDEO) {
- intent.setType("video/*");
- title = GET_VIDEO;
- }
- else if (this.mediaType == ALLMEDIA) {
- // I wanted to make the type 'image/*, video/*' but this does not work on all versions
- // of android so I had to go with the wildcard search.
- intent.setType("*/*");
- title = GET_All;
- }
-
- intent.setAction(Intent.ACTION_GET_CONTENT);
- intent.addCategory(Intent.CATEGORY_OPENABLE);
- if (this.cordova != null) {
- this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent,
- new String(title)), (srcType + 1) * 16 + returnType + 1);
- }
- }
-
- /**
- * Applies all needed transformation to the image received from the camera.
- *
- * @param destType In which form should we return the image
- * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
- */
- private void processResultFromCamera(int destType, Intent intent) throws IOException {
- int rotate = 0;
-
- // Create an ExifHelper to save the exif data that is lost during compression
- ExifHelper exif = new ExifHelper();
- try {
- if (this.encodingType == JPEG) {
- exif.createInFile(getTempDirectoryPath() + "/.Pic.jpg");
- exif.readExifData();
- rotate = exif.getOrientation();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- Bitmap bitmap = null;
- Uri uri = null;
-
- // If sending base64 image back
- if (destType == DATA_URL) {
- bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString()));
- if (bitmap == null) {
- // Try to get the bitmap from intent.
- bitmap = (Bitmap)intent.getExtras().get("data");
- }
-
- // Double-check the bitmap.
- if (bitmap == null) {
- Log.d(LOG_TAG, "I either have a null image path or bitmap");
- this.failPicture("Unable to create bitmap!");
- return;
- }
-
- if (rotate != 0 && this.correctOrientation) {
- bitmap = getRotatedBitmap(rotate, bitmap, exif);
- }
-
- this.processPicture(bitmap);
- checkForDuplicateImage(DATA_URL);
- }
-
- // If sending filename back
- else if (destType == FILE_URI || destType == NATIVE_URI) {
- if (this.saveToPhotoAlbum) {
- Uri inputUri = getUriFromMediaStore();
- //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(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg"));
- }
-
- if (uri == null) {
- this.failPicture("Error capturing image - no media storage found.");
- }
-
- // If all this is true we shouldn't compress the image.
- if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 &&
- !this.correctOrientation) {
- writeUncompressedImage(uri);
-
- this.callbackContext.success(uri.toString());
- } else {
- bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString()));
-
- if (rotate != 0 && this.correctOrientation) {
- bitmap = getRotatedBitmap(rotate, bitmap, exif);
- }
-
- // Add compressed version of captured image to returned media store Uri
- OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
- bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
- os.close();
-
- // Restore exif data to file
- if (this.encodingType == JPEG) {
- String exifPath;
- if (this.saveToPhotoAlbum) {
- exifPath = FileHelper.getRealPath(uri, this.cordova);
- } else {
- exifPath = uri.getPath();
- }
- exif.createOutFile(exifPath);
- exif.writeExifData();
- }
-
- }
- // Send Uri back to JavaScript for viewing image
- this.callbackContext.success(uri.toString());
- }
-
- this.cleanup(FILE_URI, this.imageUri, uri, bitmap);
- bitmap = null;
- }
-
- private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException {
- // Create an ExifHelper to save the exif data that is lost during compression
- String modifiedPath = getTempDirectoryPath() + "/modified.jpg";
-
- OutputStream os = new FileOutputStream(modifiedPath);
- bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
- os.close();
-
- // Some content: URIs do not map to file paths (e.g. picasa).
- String realPath = FileHelper.getRealPath(uri, this.cordova);
- ExifHelper exif = new ExifHelper();
- if (realPath != null && this.encodingType == JPEG) {
- try {
- exif.createInFile(realPath);
- exif.readExifData();
- if (this.correctOrientation && this.orientationCorrected) {
- exif.resetOrientation();
- }
- exif.createOutFile(modifiedPath);
- exif.writeExifData();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return modifiedPath;
- }
-
- /**
- * Applies all needed transformation to the image received from the gallery.
- *
- * @param destType In which form should we return the image
- * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
- */
- private void processResultFromGallery(int destType, Intent intent) {
- Uri uri = intent.getData();
- int rotate = 0;
-
- // If you ask for video or all media type you will automatically get back a file URI
- // and there will be no attempt to resize any returned data
- if (this.mediaType != PICTURE) {
- this.callbackContext.success(uri.toString());
- }
- else {
- // This is a special case to just return the path as no scaling,
- // rotating, nor compressing needs to be done
- if (this.targetHeight == -1 && this.targetWidth == -1 &&
- (destType == FILE_URI || destType == NATIVE_URI) && !this.correctOrientation) {
- this.callbackContext.success(uri.toString());
- } else {
- String uriString = uri.toString();
- // Get the path to the image. Makes loading so much easier.
- String mimeType = FileHelper.getMimeType(uriString, this.cordova);
- // If we don't have a valid image so quit.
- if (!("image/jpeg".equalsIgnoreCase(mimeType) || "image/png".equalsIgnoreCase(mimeType))) {
- Log.d(LOG_TAG, "I either have a null image path or bitmap");
- this.failPicture("Unable to retrieve path to picture!");
- return;
- }
- Bitmap bitmap = null;
- try {
- bitmap = getScaledBitmap(uriString);
- } catch (IOException e) {
- e.printStackTrace();
- }
- if (bitmap == null) {
- Log.d(LOG_TAG, "I either have a null image path or bitmap");
- this.failPicture("Unable to create bitmap!");
- return;
- }
-
- if (this.correctOrientation) {
- rotate = getImageOrientation(uri);
- if (rotate != 0) {
- Matrix matrix = new Matrix();
- matrix.setRotate(rotate);
- try {
- bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
- this.orientationCorrected = true;
- } catch (OutOfMemoryError oom) {
- this.orientationCorrected = false;
- }
- }
- }
-
- // If sending base64 image back
- if (destType == DATA_URL) {
- this.processPicture(bitmap);
- }
-
- // If sending filename back
- else if (destType == FILE_URI || destType == NATIVE_URI) {
- // Did we modify the image?
- if ( (this.targetHeight > 0 && this.targetWidth > 0) ||
- (this.correctOrientation && this.orientationCorrected) ) {
- try {
- String modifiedPath = this.ouputModifiedBitmap(bitmap, uri);
- // The modified image is cached by the app in order to get around this and not have to delete you
- // application cache I'm adding the current system time to the end of the file url.
- this.callbackContext.success("file://" + modifiedPath + "?" + System.currentTimeMillis());
- } catch (Exception e) {
- e.printStackTrace();
- this.failPicture("Error retrieving image.");
- }
- }
- else {
- this.callbackContext.success(uri.toString());
- }
- }
- if (bitmap != null) {
- bitmap.recycle();
- bitmap = null;
- }
- System.gc();
- }
- }
- }
-
- /**
- * Called when the camera view exits.
- *
- * @param requestCode The request code originally supplied to startActivityForResult(),
- * allowing you to identify who this result came from.
- * @param resultCode The integer result code returned by the child activity through its setResult().
- * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
- */
- public void onActivityResult(int requestCode, int resultCode, Intent intent) {
-
- // Get src and dest types from request code
- int srcType = (requestCode / 16) - 1;
- int destType = (requestCode % 16) - 1;
-
- // If CAMERA
- if (srcType == CAMERA) {
- // If image available
- if (resultCode == Activity.RESULT_OK) {
- try {
- this.processResultFromCamera(destType, intent);
- } catch (IOException e) {
- e.printStackTrace();
- this.failPicture("Error capturing image.");
- }
- }
-
- // If cancelled
- else if (resultCode == Activity.RESULT_CANCELED) {
- this.failPicture("Camera cancelled.");
- }
-
- // If something else
- else {
- this.failPicture("Did not complete!");
- }
- }
-
- // If retrieving photo from library
- else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) {
- if (resultCode == Activity.RESULT_OK) {
- this.processResultFromGallery(destType, intent);
- }
- else if (resultCode == Activity.RESULT_CANCELED) {
- this.failPicture("Selection cancelled.");
- }
- else {
- this.failPicture("Selection did not complete!");
- }
- }
- }
-
- private int getImageOrientation(Uri uri) {
- int rotate = 0;
- String[] cols = { MediaStore.Images.Media.ORIENTATION };
- try {
- Cursor cursor = cordova.getActivity().getContentResolver().query(uri,
- cols, null, null, null);
- if (cursor != null) {
- cursor.moveToPosition(0);
- rotate = cursor.getInt(0);
- cursor.close();
- }
- } catch (Exception e) {
- // You can get an IllegalArgumentException if ContentProvider doesn't support querying for orientation.
- }
- return rotate;
- }
-
- /**
- * Figure out if the bitmap should be rotated. For instance if the picture was taken in
- * portrait mode
- *
- * @param rotate
- * @param bitmap
- * @return rotated bitmap
- */
- private Bitmap getRotatedBitmap(int rotate, Bitmap bitmap, ExifHelper exif) {
- Matrix matrix = new Matrix();
- if (rotate == 180) {
- matrix.setRotate(rotate);
- } else {
- matrix.setRotate(rotate, (float) bitmap.getWidth() / 2, (float) bitmap.getHeight() / 2);
- }
-
- try
- {
- bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
- exif.resetOrientation();
- }
- catch (OutOfMemoryError oom)
- {
- // You can run out of memory if the image is very large:
- // http://simonmacdonald.blogspot.ca/2012/07/change-to-camera-code-in-phonegap-190.html
- // If this happens, simply do not rotate the image and return it unmodified.
- // If you do not catch the OutOfMemoryError, the Android app crashes.
- }
-
- return bitmap;
- }
-
- /**
- * In the special case where the default width, height and quality are unchanged
- * we just write the file out to disk saving the expensive Bitmap.compress function.
- *
- * @param uri
- * @throws FileNotFoundException
- * @throws IOException
- */
- private void writeUncompressedImage(Uri uri) throws FileNotFoundException,
- IOException {
- FileInputStream fis = new FileInputStream(FileHelper.stripFileProtocol(imageUri.toString()));
- OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
- byte[] buffer = new byte[4096];
- int len;
- while ((len = fis.read(buffer)) != -1) {
- os.write(buffer, 0, len);
- }
- os.flush();
- os.close();
- fis.close();
- }
-
- /**
- * Create entry in media store for image
- *
- * @return uri
- */
- private Uri getUriFromMediaStore() {
- ContentValues values = new ContentValues();
- values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
- Uri uri;
- try {
- uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
- } catch (UnsupportedOperationException e) {
- LOG.d(LOG_TAG, "Can't write to external media storage.");
- try {
- uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
- } catch (UnsupportedOperationException ex) {
- LOG.d(LOG_TAG, "Can't write to internal media storage.");
- return null;
- }
- }
- return uri;
- }
-
- /**
- * Return a scaled bitmap based on the target width and height
- *
- * @param imagePath
- * @return
- * @throws IOException
- */
- private Bitmap getScaledBitmap(String imageUrl) throws IOException {
- // If no new width or height were specified return the original bitmap
- if (this.targetWidth <= 0 && this.targetHeight <= 0) {
- return BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova));
- }
-
- // figure out the original width and height of the image
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova), null, options);
-
- //CB-2292: WTF? Why is the width null?
- if(options.outWidth == 0 || options.outHeight == 0)
- {
- return null;
- }
-
- // determine the correct aspect ratio
- int[] widthHeight = calculateAspectRatio(options.outWidth, options.outHeight);
-
- // Load in the smallest bitmap possible that is closest to the size we want
- options.inJustDecodeBounds = false;
- options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
- Bitmap unscaledBitmap = BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova), null, options);
- if (unscaledBitmap == null) {
- return null;
- }
-
- return Bitmap.createScaledBitmap(unscaledBitmap, widthHeight[0], widthHeight[1], true);
- }
-
- /**
- * Maintain the aspect ratio so the resulting image does not look smooshed
- *
- * @param origWidth
- * @param origHeight
- * @return
- */
- public int[] calculateAspectRatio(int origWidth, int origHeight) {
- int newWidth = this.targetWidth;
- int newHeight = this.targetHeight;
-
- // If no new width or height were specified return the original bitmap
- if (newWidth <= 0 && newHeight <= 0) {
- newWidth = origWidth;
- newHeight = origHeight;
- }
- // Only the width was specified
- else if (newWidth > 0 && newHeight <= 0) {
- newHeight = (newWidth * origHeight) / origWidth;
- }
- // only the height was specified
- else if (newWidth <= 0 && newHeight > 0) {
- newWidth = (newHeight * origWidth) / origHeight;
- }
- // If the user specified both a positive width and height
- // (potentially different aspect ratio) then the width or height is
- // scaled so that the image fits while maintaining aspect ratio.
- // Alternatively, the specified width and height could have been
- // kept and Bitmap.SCALE_TO_FIT specified when scaling, but this
- // would result in whitespace in the new image.
- else {
- double newRatio = newWidth / (double) newHeight;
- double origRatio = origWidth / (double) origHeight;
-
- if (origRatio > newRatio) {
- newHeight = (newWidth * origHeight) / origWidth;
- } else if (origRatio < newRatio) {
- newWidth = (newHeight * origWidth) / origHeight;
- }
- }
-
- int[] retval = new int[2];
- retval[0] = newWidth;
- retval[1] = newHeight;
- return retval;
- }
-
- /**
- * Figure out what ratio we can load our image into memory at while still being bigger than
- * our desired width and height
- *
- * @param srcWidth
- * @param srcHeight
- * @param dstWidth
- * @param dstHeight
- * @return
- */
- public static int calculateSampleSize(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
- final float srcAspect = (float)srcWidth / (float)srcHeight;
- final float dstAspect = (float)dstWidth / (float)dstHeight;
-
- if (srcAspect > dstAspect) {
- return srcWidth / dstWidth;
- } else {
- return srcHeight / dstHeight;
- }
- }
-
- /**
- * Creates a cursor that can be used to determine how many images we have.
- *
- * @return a cursor
- */
- private Cursor queryImgDB(Uri contentStore) {
- return this.cordova.getActivity().getContentResolver().query(
- contentStore,
- new String[] { MediaStore.Images.Media._ID },
- null,
- null,
- null);
- }
-
- /**
- * Cleans up after picture taking. Checking for duplicates and that kind of stuff.
- * @param newImage
- */
- private void cleanup(int imageType, Uri oldImage, Uri newImage, Bitmap bitmap) {
- if (bitmap != null) {
- bitmap.recycle();
- }
-
- // Clean up initial camera-written image file.
- (new File(FileHelper.stripFileProtocol(oldImage.toString()))).delete();
-
- checkForDuplicateImage(imageType);
- // Scan for the gallery to update pic refs in gallery
- if (this.saveToPhotoAlbum && newImage != null) {
- this.scanForGallery(newImage);
- }
-
- System.gc();
- }
-
- /**
- * Used to find out if we are in a situation where the Camera Intent adds to images
- * to the content store. If we are using a FILE_URI and the number of images in the DB
- * increases by 2 we have a duplicate, when using a DATA_URL the number is 1.
- *
- * @param type FILE_URI or DATA_URL
- */
- private void checkForDuplicateImage(int type) {
- int diff = 1;
- Uri contentStore = whichContentStore();
- Cursor cursor = queryImgDB(contentStore);
- int currentNumOfImages = cursor.getCount();
-
- if (type == FILE_URI && this.saveToPhotoAlbum) {
- diff = 2;
- }
-
- // delete the duplicate file if the difference is 2 for file URI or 1 for Data URL
- if ((currentNumOfImages - numPics) == diff) {
- cursor.moveToLast();
- int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)));
- if (diff == 2) {
- id--;
- }
- Uri uri = Uri.parse(contentStore + "/" + id);
- this.cordova.getActivity().getContentResolver().delete(uri, null, null);
- cursor.close();
- }
- }
-
- /**
- * Determine if we are storing the images in internal or external storage
- * @return Uri
- */
- private Uri whichContentStore() {
- if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
- return android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
- } else {
- return android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI;
- }
- }
-
- /**
- * Compress bitmap using jpeg, convert to Base64 encoded string, and return to JavaScript.
- *
- * @param bitmap
- */
- public void processPicture(Bitmap bitmap) {
- ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream();
- try {
- if (bitmap.compress(CompressFormat.JPEG, mQuality, jpeg_data)) {
- byte[] code = jpeg_data.toByteArray();
- byte[] output = Base64.encode(code, Base64.NO_WRAP);
- String js_out = new String(output);
- this.callbackContext.success(js_out);
- js_out = null;
- output = null;
- code = null;
- }
- } catch (Exception e) {
- this.failPicture("Error compressing image.");
- }
- jpeg_data = null;
- }
-
- /**
- * Send error message to JavaScript.
- *
- * @param err
- */
- public void failPicture(String err) {
- this.callbackContext.error(err);
- }
-
- private void scanForGallery(Uri newImage) {
- this.scanMe = newImage;
- if(this.conn != null) {
- this.conn.disconnect();
- }
- this.conn = new MediaScannerConnection(this.cordova.getActivity().getApplicationContext(), this);
- conn.connect();
- }
-
- public void onMediaScannerConnected() {
- try{
- this.conn.scanFile(this.scanMe.toString(), "image/*");
- } catch (java.lang.IllegalStateException e){
- LOG.e(LOG_TAG, "Can't scan file in MediaScanner after taking picture");
- }
-
- }
-
- public void onScanCompleted(String path, Uri uri) {
- this.conn.disconnect();
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/20aa744b/src/android/ExifHelper.java
----------------------------------------------------------------------
diff --git a/src/android/ExifHelper.java b/src/android/ExifHelper.java
deleted file mode 100644
index 5160a2f..0000000
--- a/src/android/ExifHelper.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova.camera;
-
-import java.io.IOException;
-
-import android.media.ExifInterface;
-
-public class ExifHelper {
- private String aperture = null;
- private String datetime = null;
- private String exposureTime = null;
- private String flash = null;
- private String focalLength = null;
- private String gpsAltitude = null;
- private String gpsAltitudeRef = null;
- private String gpsDateStamp = null;
- private String gpsLatitude = null;
- private String gpsLatitudeRef = null;
- private String gpsLongitude = null;
- private String gpsLongitudeRef = null;
- private String gpsProcessingMethod = null;
- private String gpsTimestamp = null;
- private String iso = null;
- private String make = null;
- private String model = null;
- private String orientation = null;
- private String whiteBalance = null;
-
- private ExifInterface inFile = null;
- private ExifInterface outFile = null;
-
- /**
- * The file before it is compressed
- *
- * @param filePath
- * @throws IOException
- */
- public void createInFile(String filePath) throws IOException {
- this.inFile = new ExifInterface(filePath);
- }
-
- /**
- * The file after it has been compressed
- *
- * @param filePath
- * @throws IOException
- */
- public void createOutFile(String filePath) throws IOException {
- this.outFile = new ExifInterface(filePath);
- }
-
- /**
- * Reads all the EXIF data from the input file.
- */
- public void readExifData() {
- this.aperture = inFile.getAttribute(ExifInterface.TAG_APERTURE);
- this.datetime = inFile.getAttribute(ExifInterface.TAG_DATETIME);
- this.exposureTime = inFile.getAttribute(ExifInterface.TAG_EXPOSURE_TIME);
- this.flash = inFile.getAttribute(ExifInterface.TAG_FLASH);
- this.focalLength = inFile.getAttribute(ExifInterface.TAG_FOCAL_LENGTH);
- this.gpsAltitude = inFile.getAttribute(ExifInterface.TAG_GPS_ALTITUDE);
- this.gpsAltitudeRef = inFile.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF);
- this.gpsDateStamp = inFile.getAttribute(ExifInterface.TAG_GPS_DATESTAMP);
- this.gpsLatitude = inFile.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
- this.gpsLatitudeRef = inFile.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);
- this.gpsLongitude = inFile.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
- this.gpsLongitudeRef = inFile.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);
- this.gpsProcessingMethod = inFile.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD);
- this.gpsTimestamp = inFile.getAttribute(ExifInterface.TAG_GPS_TIMESTAMP);
- this.iso = inFile.getAttribute(ExifInterface.TAG_ISO);
- this.make = inFile.getAttribute(ExifInterface.TAG_MAKE);
- this.model = inFile.getAttribute(ExifInterface.TAG_MODEL);
- this.orientation = inFile.getAttribute(ExifInterface.TAG_ORIENTATION);
- this.whiteBalance = inFile.getAttribute(ExifInterface.TAG_WHITE_BALANCE);
- }
-
- /**
- * Writes the previously stored EXIF data to the output file.
- *
- * @throws IOException
- */
- public void writeExifData() throws IOException {
- // Don't try to write to a null file
- if (this.outFile == null) {
- return;
- }
-
- if (this.aperture != null) {
- this.outFile.setAttribute(ExifInterface.TAG_APERTURE, this.aperture);
- }
- if (this.datetime != null) {
- this.outFile.setAttribute(ExifInterface.TAG_DATETIME, this.datetime);
- }
- if (this.exposureTime != null) {
- this.outFile.setAttribute(ExifInterface.TAG_EXPOSURE_TIME, this.exposureTime);
- }
- if (this.flash != null) {
- this.outFile.setAttribute(ExifInterface.TAG_FLASH, this.flash);
- }
- if (this.focalLength != null) {
- this.outFile.setAttribute(ExifInterface.TAG_FOCAL_LENGTH, this.focalLength);
- }
- if (this.gpsAltitude != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_ALTITUDE, this.gpsAltitude);
- }
- if (this.gpsAltitudeRef != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF, this.gpsAltitudeRef);
- }
- if (this.gpsDateStamp != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_DATESTAMP, this.gpsDateStamp);
- }
- if (this.gpsLatitude != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_LATITUDE, this.gpsLatitude);
- }
- if (this.gpsLatitudeRef != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, this.gpsLatitudeRef);
- }
- if (this.gpsLongitude != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, this.gpsLongitude);
- }
- if (this.gpsLongitudeRef != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, this.gpsLongitudeRef);
- }
- if (this.gpsProcessingMethod != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD, this.gpsProcessingMethod);
- }
- if (this.gpsTimestamp != null) {
- this.outFile.setAttribute(ExifInterface.TAG_GPS_TIMESTAMP, this.gpsTimestamp);
- }
- if (this.iso != null) {
- this.outFile.setAttribute(ExifInterface.TAG_ISO, this.iso);
- }
- if (this.make != null) {
- this.outFile.setAttribute(ExifInterface.TAG_MAKE, this.make);
- }
- if (this.model != null) {
- this.outFile.setAttribute(ExifInterface.TAG_MODEL, this.model);
- }
- if (this.orientation != null) {
- this.outFile.setAttribute(ExifInterface.TAG_ORIENTATION, this.orientation);
- }
- if (this.whiteBalance != null) {
- this.outFile.setAttribute(ExifInterface.TAG_WHITE_BALANCE, this.whiteBalance);
- }
-
- this.outFile.saveAttributes();
- }
-
- public int getOrientation() {
- int o = Integer.parseInt(this.orientation);
-
- if (o == ExifInterface.ORIENTATION_NORMAL) {
- return 0;
- } else if (o == ExifInterface.ORIENTATION_ROTATE_90) {
- return 90;
- } else if (o == ExifInterface.ORIENTATION_ROTATE_180) {
- return 180;
- } else if (o == ExifInterface.ORIENTATION_ROTATE_270) {
- return 270;
- } else {
- return 0;
- }
- }
-
- public void resetOrientation() {
- this.orientation = "" + ExifInterface.ORIENTATION_NORMAL;
- }
-}