diff --git a/config.xml b/config.xml index 5d467ac..b66354d 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + TerranQuest Augmented Reality fantasy game @@ -9,22 +9,22 @@ - + - - - - - + + + + + - + - + diff --git a/nbproject/build.xml b/nbproject/build.xml index ab714d3..8c77ec9 100644 --- a/nbproject/build.xml +++ b/nbproject/build.xml @@ -226,13 +226,13 @@ made subject to such option by the copyright holder. - - + + - + @@ -282,7 +282,9 @@ made subject to such option by the copyright holder. - + + + diff --git a/nbproject/plugins.properties b/nbproject/plugins.properties index d30883a..dc5c041 100644 --- a/nbproject/plugins.properties +++ b/nbproject/plugins.properties @@ -9,16 +9,14 @@ # For more information about plugins see http://cordova.apache.org/blog/releases/2013/07/23/cordova-3.html # -org.apache.cordova.device=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git -org.apache.cordova.network-information=https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git -org.apache.cordova.device-motion=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git -org.apache.cordova.device-orientation=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git -org.apache.cordova.geolocation=https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git -org.apache.cordova.camera=https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git -org.apache.cordova.media-capture=https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git -org.apache.cordova.media=https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git -org.apache.cordova.file=https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git -org.apache.cordova.file-transfer=https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git -org.apache.cordova.dialogs=https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git -org.apache.cordova.console=https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git -com.phonegap.plugins.barcodescanner=https://github.com/phonegap/phonegap-plugin-barcodescanner.git \ No newline at end of file +com.phonegap.plugins.barcodescanner=https://github.com/phonegap/phonegap-plugin-barcodescanner.git +cordova-plugin-whitelist=https://github.com/apache/cordova-plugin-whitelist.git +cordova-plugin-splashscreen=https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git +cordova-plugin-dialogs=https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git +cordova-plugin-camera=https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git +cordova-plugin-media=https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git +cordova-plugin-media-capture=https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git +cordova-plugin-geolocation=https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git +cordova-plugin-network-information=https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git +cordova-plugin-console=https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git +cordova-plugin-device=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git diff --git a/nbproject/project.properties b/nbproject/project.properties index 72b96cf..750f685 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -auxiliary.org-netbeans-modules-cordova.cordova_5f_build_5f_script_5f_version=50 +auxiliary.org-netbeans-modules-cordova.cordova_5f_build_5f_script_5f_version=52 auxiliary.org-netbeans-modules-cordova.phonegap=false auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs file.reference.TerranQuest-test=test diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties b/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties index 79c2115..391f23f 100644 --- a/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties +++ b/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties @@ -1 +1 @@ -#Sat Feb 20 23:05:08 MST 2016 +#Tue Apr 12 16:04:29 MDT 2016 diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock b/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock index 9d2b0bd..d03a8af 100644 Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock and b/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock differ diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin b/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin index cad468c..0966afd 100644 Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin and b/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin differ diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin b/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin index 6f56d13..bd97cad 100644 Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin and b/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin differ diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/outputFileStates.bin b/platforms/android/.gradle/2.2.1/taskArtifacts/outputFileStates.bin index f646d14..4838971 100644 Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/outputFileStates.bin and b/platforms/android/.gradle/2.2.1/taskArtifacts/outputFileStates.bin differ diff --git a/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin b/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin index 72ae41d..a34bd4e 100644 Binary files a/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin and b/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin differ diff --git a/platforms/android/AndroidManifest.xml b/platforms/android/AndroidManifest.xml index 97ecd6d..701d88f 100644 --- a/platforms/android/AndroidManifest.xml +++ b/platforms/android/AndroidManifest.xml @@ -30,12 +30,14 @@ - - + + + + diff --git a/platforms/android/CordovaLib/build/generated/source/buildConfig/release/org/apache/cordova/BuildConfig.java b/platforms/android/CordovaLib/build/generated/source/buildConfig/release/org/apache/cordova/BuildConfig.java deleted file mode 100644 index 3e3c0cf..0000000 --- a/platforms/android/CordovaLib/build/generated/source/buildConfig/release/org/apache/cordova/BuildConfig.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Automatically generated file. DO NOT MODIFY - */ -package org.apache.cordova; - -public final class BuildConfig { - public static final boolean DEBUG = false; - public static final String APPLICATION_ID = "org.apache.cordova"; - public static final String BUILD_TYPE = "release"; - public static final String FLAVOR = ""; - public static final int VERSION_CODE = 1; - public static final String VERSION_NAME = "1.0"; -} diff --git a/platforms/android/CordovaLib/build/intermediates/bundles/debug/classes.jar b/platforms/android/CordovaLib/build/intermediates/bundles/debug/classes.jar index 1bbb61a..d9fb0d1 100644 Binary files a/platforms/android/CordovaLib/build/intermediates/bundles/debug/classes.jar and b/platforms/android/CordovaLib/build/intermediates/bundles/debug/classes.jar differ diff --git a/platforms/android/CordovaLib/build/intermediates/bundles/release/AndroidManifest.xml b/platforms/android/CordovaLib/build/intermediates/bundles/release/AndroidManifest.xml deleted file mode 100644 index 90863ed..0000000 --- a/platforms/android/CordovaLib/build/intermediates/bundles/release/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/intermediates/bundles/release/aapt/AndroidManifest.xml b/platforms/android/CordovaLib/build/intermediates/bundles/release/aapt/AndroidManifest.xml deleted file mode 100644 index 90863ed..0000000 --- a/platforms/android/CordovaLib/build/intermediates/bundles/release/aapt/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/intermediates/bundles/release/classes.jar b/platforms/android/CordovaLib/build/intermediates/bundles/release/classes.jar deleted file mode 100644 index cef63ed..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/bundles/release/classes.jar and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaActivity.class b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaActivity.class index 6572d93..efd1ee6 100644 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaActivity.class and b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaActivity.class differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl$ActivityResultHolder.class b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl$ActivityResultHolder.class index a060b1a..8562638 100644 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl$ActivityResultHolder.class and b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl$ActivityResultHolder.class differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl.class b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl.class index 69b6af0..718b002 100644 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl.class and b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaInterfaceImpl.class differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaWebView.class b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaWebView.class index 4994e66..feaba8c 100644 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaWebView.class and b/platforms/android/CordovaLib/build/intermediates/classes/debug/org/apache/cordova/CordovaWebView.class differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/AuthenticationToken.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/AuthenticationToken.class deleted file mode 100644 index e9d5146..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/AuthenticationToken.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/BuildConfig.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/BuildConfig.class deleted file mode 100644 index bf0083a..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/BuildConfig.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CallbackContext.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CallbackContext.class deleted file mode 100644 index 6367893..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CallbackContext.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Config.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Config.class deleted file mode 100644 index 173ea3d..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Config.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ConfigXmlParser.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ConfigXmlParser.class deleted file mode 100644 index 62fa0b3..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ConfigXmlParser.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$1.class deleted file mode 100644 index d4e3070..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$2.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$2.class deleted file mode 100644 index fff3f96..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$2.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$3.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$3.class deleted file mode 100644 index 2e0296f..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$3.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$4$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$4$1.class deleted file mode 100644 index 785cbf9..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$4$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$4.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$4.class deleted file mode 100644 index e1fa4e8..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity$4.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity.class deleted file mode 100644 index 6572d93..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaActivity.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaArgs.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaArgs.class deleted file mode 100644 index 18014a3..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaArgs.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaBridge.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaBridge.class deleted file mode 100644 index 17f3eef..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaBridge.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaClientCertRequest.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaClientCertRequest.class deleted file mode 100644 index 46007d4..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaClientCertRequest.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$1.class deleted file mode 100644 index 683ff52..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$2.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$2.class deleted file mode 100644 index c7f3d4a..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$2.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$3.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$3.class deleted file mode 100644 index 4cb4f9b..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$3.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$4.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$4.class deleted file mode 100644 index ac24ba5..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$4.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$5.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$5.class deleted file mode 100644 index 3ab9531..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$5.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$6.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$6.class deleted file mode 100644 index 05530d9..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$6.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$7.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$7.class deleted file mode 100644 index 5cd2cb8..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$7.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$8.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$8.class deleted file mode 100644 index e57fded..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$8.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$9.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$9.class deleted file mode 100644 index 628d462..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$9.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$Result.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$Result.class deleted file mode 100644 index c4dd999..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper$Result.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper.class deleted file mode 100644 index fd87376..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaDialogsHelper.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaHttpAuthHandler.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaHttpAuthHandler.class deleted file mode 100644 index c912f92..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaHttpAuthHandler.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterface.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterface.class deleted file mode 100644 index b205943..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterface.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterfaceImpl$ActivityResultHolder.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterfaceImpl$ActivityResultHolder.class deleted file mode 100644 index a060b1a..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterfaceImpl$ActivityResultHolder.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterfaceImpl.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterfaceImpl.class deleted file mode 100644 index 69b6af0..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaInterfaceImpl.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaPlugin.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaPlugin.class deleted file mode 100644 index b8f64c6..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaPlugin.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaPreferences.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaPreferences.class deleted file mode 100644 index ed0b3da..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaPreferences.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaResourceApi$OpenForReadResult.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaResourceApi$OpenForReadResult.class deleted file mode 100644 index 15ab1f6..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaResourceApi$OpenForReadResult.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaResourceApi.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaResourceApi.class deleted file mode 100644 index 6079ff4..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaResourceApi.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebView.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebView.class deleted file mode 100644 index 4994e66..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebView.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine$Client.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine$Client.class deleted file mode 100644 index deb6dfd..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine$Client.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine$EngineView.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine$EngineView.class deleted file mode 100644 index 1149bf2..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine$EngineView.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine.class deleted file mode 100644 index 39e1336..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewEngine.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$1.class deleted file mode 100644 index 4cf05bb..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$2.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$2.class deleted file mode 100644 index af9110d..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$2.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$3.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$3.class deleted file mode 100644 index e5c567e..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$3.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient$1$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient$1$1.class deleted file mode 100644 index 1370f66..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient$1$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient$1.class deleted file mode 100644 index a93f937..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient.class deleted file mode 100644 index 4df9559..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl$EngineClient.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl.class deleted file mode 100644 index 5100928..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CordovaWebViewImpl.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$1.class deleted file mode 100644 index 4ae5090..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$2.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$2.class deleted file mode 100644 index 967a4d1..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$2.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$3.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$3.class deleted file mode 100644 index 5292b39..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$3.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$4.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$4.class deleted file mode 100644 index 8d97659..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$4.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$5.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$5.class deleted file mode 100644 index caf3782..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid$5.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid.class deleted file mode 100644 index 2581199..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/CoreAndroid.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ExposedJsApi.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ExposedJsApi.class deleted file mode 100644 index 6e67520..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ExposedJsApi.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaClientCertRequest.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaClientCertRequest.class deleted file mode 100644 index 18ad39e..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaClientCertRequest.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaCookieManager.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaCookieManager.class deleted file mode 100644 index 142b69c..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaCookieManager.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaHttpAuthHandler.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaHttpAuthHandler.class deleted file mode 100644 index ac03d2d..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ICordovaHttpAuthHandler.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/LOG.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/LOG.class deleted file mode 100644 index 7a7e8dd..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/LOG.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$BridgeMode.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$BridgeMode.class deleted file mode 100644 index 38bd839..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$BridgeMode.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$JsMessage.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$JsMessage.class deleted file mode 100644 index 5182181..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$JsMessage.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$LoadUrlBridgeMode$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$LoadUrlBridgeMode$1.class deleted file mode 100644 index 3eb921f..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$LoadUrlBridgeMode$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$LoadUrlBridgeMode.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$LoadUrlBridgeMode.class deleted file mode 100644 index c08ebb4..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$LoadUrlBridgeMode.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$NoOpBridgeMode.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$NoOpBridgeMode.class deleted file mode 100644 index c508806..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$NoOpBridgeMode.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$1.class deleted file mode 100644 index 04fe4ea..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$2.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$2.class deleted file mode 100644 index cc3af31..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$2.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$OnlineEventsBridgeModeDelegate.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$OnlineEventsBridgeModeDelegate.class deleted file mode 100644 index c384804..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode$OnlineEventsBridgeModeDelegate.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode.class deleted file mode 100644 index d537202..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue$OnlineEventsBridgeMode.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue.class deleted file mode 100644 index b62f957..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/NativeToJsMessageQueue.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginEntry.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginEntry.class deleted file mode 100644 index 4adc8d0..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginEntry.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginManager.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginManager.class deleted file mode 100644 index 9dfc6fa..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginManager.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginResult$Status.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginResult$Status.class deleted file mode 100644 index d9ff981..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginResult$Status.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginResult.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginResult.class deleted file mode 100644 index dfefc65..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/PluginResult.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ResumeCallback.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ResumeCallback.class deleted file mode 100644 index fc6a4d1..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/ResumeCallback.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Whitelist$URLPattern.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Whitelist$URLPattern.class deleted file mode 100644 index db85196..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Whitelist$URLPattern.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Whitelist.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Whitelist.class deleted file mode 100644 index 1be2bfc..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/Whitelist.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemCookieManager.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemCookieManager.class deleted file mode 100644 index 55051d0..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemCookieManager.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemExposedJsApi.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemExposedJsApi.class deleted file mode 100644 index 8511795..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemExposedJsApi.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$1.class deleted file mode 100644 index 95996f7..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$2.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$2.class deleted file mode 100644 index 8c8da1b..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$2.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$3.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$3.class deleted file mode 100644 index 5a345dd..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$3.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$4.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$4.class deleted file mode 100644 index a06e973..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$4.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$5.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$5.class deleted file mode 100644 index 461dd70..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient$5.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient.class deleted file mode 100644 index f7fbd21..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebChromeClient.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebView.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebView.class deleted file mode 100644 index 9dfe6ed..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebView.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewClient.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewClient.class deleted file mode 100644 index 4ded578..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewClient.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine$1.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine$1.class deleted file mode 100644 index 5b5b15e..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine$1.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine$2.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine$2.class deleted file mode 100644 index 4cb98c4..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine$2.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine.class b/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine.class deleted file mode 100644 index b71c6d8..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/classes/release/org/apache/cordova/engine/SystemWebViewEngine.class and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/incremental/compileReleaseAidl/dependency.store b/platforms/android/CordovaLib/build/intermediates/incremental/compileReleaseAidl/dependency.store deleted file mode 100644 index 8b8400d..0000000 Binary files a/platforms/android/CordovaLib/build/intermediates/incremental/compileReleaseAidl/dependency.store and /dev/null differ diff --git a/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugAssets/merger.xml b/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugAssets/merger.xml index ff0f2d5..358319f 100644 --- a/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugAssets/merger.xml +++ b/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugAssets/merger.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml b/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml index 94ac7f4..59c640e 100644 --- a/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +++ b/platforms/android/CordovaLib/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/intermediates/incremental/mergeReleaseAssets/merger.xml b/platforms/android/CordovaLib/build/intermediates/incremental/mergeReleaseAssets/merger.xml deleted file mode 100644 index f7944e7..0000000 --- a/platforms/android/CordovaLib/build/intermediates/incremental/mergeReleaseAssets/merger.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml b/platforms/android/CordovaLib/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml deleted file mode 100644 index 7ff1de5..0000000 --- a/platforms/android/CordovaLib/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/intermediates/incremental/packageDebugResources/merger.xml b/platforms/android/CordovaLib/build/intermediates/incremental/packageDebugResources/merger.xml index a6b27cb..4ae521c 100644 --- a/platforms/android/CordovaLib/build/intermediates/incremental/packageDebugResources/merger.xml +++ b/platforms/android/CordovaLib/build/intermediates/incremental/packageDebugResources/merger.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/intermediates/incremental/packageReleaseResources/merger.xml b/platforms/android/CordovaLib/build/intermediates/incremental/packageReleaseResources/merger.xml deleted file mode 100644 index 429a120..0000000 --- a/platforms/android/CordovaLib/build/intermediates/incremental/packageReleaseResources/merger.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/platforms/android/CordovaLib/build/outputs/aar/CordovaLib-debug.aar b/platforms/android/CordovaLib/build/outputs/aar/CordovaLib-debug.aar index 62503a4..02692ed 100644 Binary files a/platforms/android/CordovaLib/build/outputs/aar/CordovaLib-debug.aar and b/platforms/android/CordovaLib/build/outputs/aar/CordovaLib-debug.aar differ diff --git a/platforms/android/CordovaLib/build/outputs/aar/CordovaLib-release.aar b/platforms/android/CordovaLib/build/outputs/aar/CordovaLib-release.aar deleted file mode 100644 index 22c53d3..0000000 Binary files a/platforms/android/CordovaLib/build/outputs/aar/CordovaLib-release.aar and /dev/null differ diff --git a/platforms/android/CordovaLib/proguard-project.txt b/platforms/android/CordovaLib/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/platforms/android/CordovaLib/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaInterfaceImpl.java b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaInterfaceImpl.java index 65e2a90..d1420b6 100644 --- a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaInterfaceImpl.java +++ b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaInterfaceImpl.java @@ -108,17 +108,20 @@ public class CordovaInterfaceImpl implements CordovaInterface { // If there was no Activity result, we still need to send out the resume event if the // Activity was destroyed by the OS activityWasDestroyed = false; - - CoreAndroid appPlugin = (CoreAndroid) pluginManager.getPlugin(CoreAndroid.PLUGIN_NAME); - if(appPlugin != null) { - JSONObject obj = new JSONObject(); - try { - obj.put("action", "resume"); - } catch (JSONException e) { - LOG.e(TAG, "Failed to create event message", e); + if(pluginManager != null) + { + CoreAndroid appPlugin = (CoreAndroid) pluginManager.getPlugin(CoreAndroid.PLUGIN_NAME); + if(appPlugin != null) { + JSONObject obj = new JSONObject(); + try { + obj.put("action", "resume"); + } catch (JSONException e) { + LOG.e(TAG, "Failed to create event message", e); + } + appPlugin.sendResumeEvent(new PluginResult(PluginResult.Status.OK, obj)); } - appPlugin.sendResumeEvent(new PluginResult(PluginResult.Status.OK, obj)); } + } } @@ -169,8 +172,10 @@ public class CordovaInterfaceImpl implements CordovaInterface { String serviceName = activityResultCallback.getServiceName(); outState.putString("callbackService", serviceName); } + if(pluginManager != null){ + outState.putBundle("plugin", pluginManager.onSaveInstanceState()); + } - outState.putBundle("plugin", pluginManager.onSaveInstanceState()); } /** diff --git a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java index 096f063..6b0abca 100644 --- a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java +++ b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java @@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback; * are not expected to implement it. */ public interface CordovaWebView { - public static final String CORDOVA_VERSION = "5.1.0"; + public static final String CORDOVA_VERSION = "5.1.1"; void init(CordovaInterface cordova, List pluginEntries, CordovaPreferences preferences); diff --git a/platforms/android/android.json b/platforms/android/android.json index ab1995c..701dee2 100644 --- a/platforms/android/android.json +++ b/platforms/android/android.json @@ -9,43 +9,47 @@ "parents": { "/*": [ { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", "count": 1 }, { - "xml": "", + "xml": "", + "count": 1 + }, + { + "xml": "", "count": 1 } ] @@ -53,28 +57,14 @@ }, "AndroidManifest.xml": { "parents": { - "/manifest": [ - { - "xml": "", - "count": 1 - }, - { - "xml": "", - "count": 1 - } - ], "/*": [ { "xml": "", "count": 4 }, { - "xml": "", - "count": 2 - }, - { - "xml": "", - "count": 2 + "xml": "", + "count": 1 }, { "xml": "", @@ -91,6 +81,14 @@ { "xml": "", "count": 1 + }, + { + "xml": "", + "count": 1 + }, + { + "xml": "", + "count": 1 } ], "/manifest/application": [ @@ -106,6 +104,20 @@ "xml": "", "count": 1 } + ], + "/manifest": [ + { + "xml": "", + "count": 1 + }, + { + "xml": "", + "count": 1 + }, + { + "xml": "", + "count": 1 + } ] } }, @@ -594,50 +606,123 @@ } }, "installed_plugins": { - "cordova-plugin-geolocation": { + "cordova-plugin-compat": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file": { + "cordova-plugin-whitelist": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media": { + "cordova-plugin-console": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media-capture": { + "cordova-plugin-device": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file-transfer": { + "cordova-plugin-camera": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-device-orientation": { + "cordova-plugin-splashscreen": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "phonegap-plugin-barcodescanner": { + "cordova-plugin-network-information": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, "cordova-plugin-dialogs": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-splashscreen": { + "cordova-plugin-file": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-whitelist": { + "cordova-plugin-media": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "cordova-plugin-media-capture": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "cordova-plugin-geolocation": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "phonegap-plugin-barcodescanner": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" } }, "dependent_plugins": {}, "modules": [ { - "file": "plugins/cordova-plugin-geolocation/www/android/geolocation.js", - "id": "cordova-plugin-geolocation.geolocation", + "file": "plugins/cordova-plugin-whitelist/whitelist.js", + "id": "cordova-plugin-whitelist.whitelist", + "runs": true + }, + { + "file": "plugins/cordova-plugin-device/www/device.js", + "id": "cordova-plugin-device.device", "clobbers": [ - "navigator.geolocation" + "device" ] }, { - "file": "plugins/cordova-plugin-geolocation/www/PositionError.js", - "id": "cordova-plugin-geolocation.PositionError", - "runs": true + "file": "plugins/cordova-plugin-camera/www/CameraConstants.js", + "id": "cordova-plugin-camera.Camera", + "clobbers": [ + "Camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js", + "id": "cordova-plugin-camera.CameraPopoverOptions", + "clobbers": [ + "CameraPopoverOptions" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/Camera.js", + "id": "cordova-plugin-camera.camera", + "clobbers": [ + "navigator.camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverHandle.js", + "id": "cordova-plugin-camera.CameraPopoverHandle", + "clobbers": [ + "CameraPopoverHandle" + ] + }, + { + "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", + "id": "cordova-plugin-splashscreen.SplashScreen", + "clobbers": [ + "navigator.splashscreen" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/network.js", + "id": "cordova-plugin-network-information.network", + "clobbers": [ + "navigator.connection", + "navigator.network.connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/Connection.js", + "id": "cordova-plugin-network-information.Connection", + "clobbers": [ + "Connection" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/notification.js", + "id": "cordova-plugin-dialogs.notification", + "merges": [ + "navigator.notification" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/android/notification.js", + "id": "cordova-plugin-dialogs.notification_android", + "merges": [ + "navigator.notification" + ] }, { "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js", @@ -854,39 +939,16 @@ ] }, { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransferError.js", - "id": "cordova-plugin-file-transfer.FileTransferError", - "clobbers": [ - "window.FileTransferError" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransfer.js", - "id": "cordova-plugin-file-transfer.FileTransfer", - "clobbers": [ - "window.FileTransfer" - ] - }, - { - "file": "plugins/cordova-plugin-device-orientation/www/CompassError.js", - "id": "cordova-plugin-device-orientation.CompassError", - "clobbers": [ - "CompassError" - ] - }, - { - "file": "plugins/cordova-plugin-device-orientation/www/CompassHeading.js", - "id": "cordova-plugin-device-orientation.CompassHeading", + "file": "plugins/cordova-plugin-geolocation/www/android/geolocation.js", + "id": "cordova-plugin-geolocation.geolocation", "clobbers": [ - "CompassHeading" + "navigator.geolocation" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/compass.js", - "id": "cordova-plugin-device-orientation.compass", - "clobbers": [ - "navigator.compass" - ] + "file": "plugins/cordova-plugin-geolocation/www/PositionError.js", + "id": "cordova-plugin-geolocation.PositionError", + "runs": true }, { "file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", @@ -894,32 +956,21 @@ "clobbers": [ "cordova.plugins.barcodeScanner" ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/notification.js", - "id": "cordova-plugin-dialogs.notification", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/android/notification.js", - "id": "cordova-plugin-dialogs.notification_android", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", - "id": "cordova-plugin-splashscreen.SplashScreen", - "clobbers": [ - "navigator.splashscreen" - ] - }, - { - "file": "plugins/cordova-plugin-whitelist/whitelist.js", - "id": "cordova-plugin-whitelist.whitelist", - "runs": true } - ] + ], + "plugin_metadata": { + "cordova-plugin-compat": "1.0.0", + "cordova-plugin-whitelist": "1.2.1", + "cordova-plugin-console": "1.0.3-dev", + "cordova-plugin-device": "1.1.2-dev", + "cordova-plugin-camera": "2.1.2-dev", + "cordova-plugin-splashscreen": "3.2.2-dev", + "cordova-plugin-network-information": "1.2.1-dev", + "cordova-plugin-dialogs": "1.2.1-dev", + "cordova-plugin-file": "4.1.1", + "cordova-plugin-media": "2.2.1-dev", + "cordova-plugin-media-capture": "1.2.1-dev", + "cordova-plugin-geolocation": "2.1.1-dev", + "phonegap-plugin-barcodescanner": "4.1.0" + } } \ No newline at end of file diff --git a/platforms/android/assets/www/cordova-js-src/platform.js b/platforms/android/assets/www/cordova-js-src/platform.js index 0706a34..2bfd024 100644 --- a/platforms/android/assets/www/cordova-js-src/platform.js +++ b/platforms/android/assets/www/cordova-js-src/platform.js @@ -19,6 +19,9 @@ * */ +// The last resume event that was received that had the result of a plugin call. +var lastResumeEvent = null; + module.exports = { id: 'android', bootstrap: function() { @@ -58,6 +61,19 @@ module.exports = { bindButtonChannel('volumeup'); bindButtonChannel('volumedown'); + // The resume event is not "sticky", but it is possible that the event + // will contain the result of a plugin call. We need to ensure that the + // plugin result is delivered even after the event is fired (CB-10498) + var cordovaAddEventListener = document.addEventListener; + + document.addEventListener = function(evt, handler, capture) { + cordovaAddEventListener(evt, handler, capture); + + if (evt === 'resume' && lastResumeEvent) { + handler(lastResumeEvent); + } + }; + // Let native code know we are all done on the JS side. // Native code will then un-hide the WebView. channel.onCordovaReady.subscribe(function() { @@ -96,6 +112,10 @@ function onMessageFromNative(msg) { } msg.pendingResult.result = res; } + + // Save the plugin result so that it can be delivered to the js + // even if they miss the initial firing of the event + lastResumeEvent = msg; } cordova.fireDocumentEvent(action, msg); break; diff --git a/platforms/android/assets/www/cordova.js b/platforms/android/assets/www/cordova.js index ece529c..e94e0f7 100644 --- a/platforms/android/assets/www/cordova.js +++ b/platforms/android/assets/www/cordova.js @@ -1,5 +1,5 @@ // Platform: android -// ded62dda172755defaf75378ed007dc05730ec22 +// c517ca811b4948b630e0b74dbae6c9637939da24 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -19,7 +19,7 @@ under the License. */ ;(function() { -var PLATFORM_VERSION_BUILD_LABEL = '5.1.0'; +var PLATFORM_VERSION_BUILD_LABEL = '5.1.1'; // file: src/scripts/require.js /*jshint -W079 */ @@ -1614,6 +1614,9 @@ exports.reset(); // file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/platform.js define("cordova/platform", function(require, exports, module) { +// The last resume event that was received that had the result of a plugin call. +var lastResumeEvent = null; + module.exports = { id: 'android', bootstrap: function() { @@ -1653,6 +1656,19 @@ module.exports = { bindButtonChannel('volumeup'); bindButtonChannel('volumedown'); + // The resume event is not "sticky", but it is possible that the event + // will contain the result of a plugin call. We need to ensure that the + // plugin result is delivered even after the event is fired (CB-10498) + var cordovaAddEventListener = document.addEventListener; + + document.addEventListener = function(evt, handler, capture) { + cordovaAddEventListener(evt, handler, capture); + + if (evt === 'resume' && lastResumeEvent) { + handler(lastResumeEvent); + } + }; + // Let native code know we are all done on the JS side. // Native code will then un-hide the WebView. channel.onCordovaReady.subscribe(function() { @@ -1691,6 +1707,10 @@ function onMessageFromNative(msg) { } msg.pendingResult.result = res; } + + // Save the plugin result so that it can be delivered to the js + // even if they miss the initial firing of the event + lastResumeEvent = msg; } cordova.fireDocumentEvent(action, msg); break; diff --git a/platforms/android/assets/www/cordova_plugins.js b/platforms/android/assets/www/cordova_plugins.js index 23d5bd2..301549e 100644 --- a/platforms/android/assets/www/cordova_plugins.js +++ b/platforms/android/assets/www/cordova_plugins.js @@ -1,16 +1,80 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { module.exports = [ { - "file": "plugins/cordova-plugin-geolocation/www/android/geolocation.js", - "id": "cordova-plugin-geolocation.geolocation", + "file": "plugins/cordova-plugin-whitelist/whitelist.js", + "id": "cordova-plugin-whitelist.whitelist", + "runs": true + }, + { + "file": "plugins/cordova-plugin-device/www/device.js", + "id": "cordova-plugin-device.device", "clobbers": [ - "navigator.geolocation" + "device" ] }, { - "file": "plugins/cordova-plugin-geolocation/www/PositionError.js", - "id": "cordova-plugin-geolocation.PositionError", - "runs": true + "file": "plugins/cordova-plugin-camera/www/CameraConstants.js", + "id": "cordova-plugin-camera.Camera", + "clobbers": [ + "Camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js", + "id": "cordova-plugin-camera.CameraPopoverOptions", + "clobbers": [ + "CameraPopoverOptions" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/Camera.js", + "id": "cordova-plugin-camera.camera", + "clobbers": [ + "navigator.camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverHandle.js", + "id": "cordova-plugin-camera.CameraPopoverHandle", + "clobbers": [ + "CameraPopoverHandle" + ] + }, + { + "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", + "id": "cordova-plugin-splashscreen.SplashScreen", + "clobbers": [ + "navigator.splashscreen" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/network.js", + "id": "cordova-plugin-network-information.network", + "clobbers": [ + "navigator.connection", + "navigator.network.connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/Connection.js", + "id": "cordova-plugin-network-information.Connection", + "clobbers": [ + "Connection" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/notification.js", + "id": "cordova-plugin-dialogs.notification", + "merges": [ + "navigator.notification" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/android/notification.js", + "id": "cordova-plugin-dialogs.notification_android", + "merges": [ + "navigator.notification" + ] }, { "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js", @@ -227,39 +291,16 @@ module.exports = [ ] }, { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransferError.js", - "id": "cordova-plugin-file-transfer.FileTransferError", - "clobbers": [ - "window.FileTransferError" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransfer.js", - "id": "cordova-plugin-file-transfer.FileTransfer", - "clobbers": [ - "window.FileTransfer" - ] - }, - { - "file": "plugins/cordova-plugin-device-orientation/www/CompassError.js", - "id": "cordova-plugin-device-orientation.CompassError", - "clobbers": [ - "CompassError" - ] - }, - { - "file": "plugins/cordova-plugin-device-orientation/www/CompassHeading.js", - "id": "cordova-plugin-device-orientation.CompassHeading", + "file": "plugins/cordova-plugin-geolocation/www/android/geolocation.js", + "id": "cordova-plugin-geolocation.geolocation", "clobbers": [ - "CompassHeading" + "navigator.geolocation" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/compass.js", - "id": "cordova-plugin-device-orientation.compass", - "clobbers": [ - "navigator.compass" - ] + "file": "plugins/cordova-plugin-geolocation/www/PositionError.js", + "id": "cordova-plugin-geolocation.PositionError", + "runs": true }, { "file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", @@ -267,36 +308,24 @@ module.exports = [ "clobbers": [ "cordova.plugins.barcodeScanner" ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/notification.js", - "id": "cordova-plugin-dialogs.notification", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/android/notification.js", - "id": "cordova-plugin-dialogs.notification_android", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", - "id": "cordova-plugin-splashscreen.SplashScreen", - "clobbers": [ - "navigator.splashscreen" - ] - }, - { - "file": "plugins/cordova-plugin-whitelist/whitelist.js", - "id": "cordova-plugin-whitelist.whitelist", - "runs": true } ]; module.exports.metadata = // TOP OF METADATA -{} +{ + "cordova-plugin-compat": "1.0.0", + "cordova-plugin-whitelist": "1.2.1", + "cordova-plugin-console": "1.0.3-dev", + "cordova-plugin-device": "1.1.2-dev", + "cordova-plugin-camera": "2.1.2-dev", + "cordova-plugin-splashscreen": "3.2.2-dev", + "cordova-plugin-network-information": "1.2.1-dev", + "cordova-plugin-dialogs": "1.2.1-dev", + "cordova-plugin-file": "4.1.1", + "cordova-plugin-media": "2.2.1-dev", + "cordova-plugin-media-capture": "1.2.1-dev", + "cordova-plugin-geolocation": "2.1.1-dev", + "phonegap-plugin-barcodescanner": "4.1.0" +}; // BOTTOM OF METADATA }); \ No newline at end of file diff --git a/platforms/android/assets/www/css/leaflet.css b/platforms/android/assets/www/css/leaflet.css index dea175f..c161c31 100644 --- a/platforms/android/assets/www/css/leaflet.css +++ b/platforms/android/assets/www/css/leaflet.css @@ -1,479 +1,479 @@ -/* required styles */ - -.leaflet-map-pane, -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow, -.leaflet-tile-pane, -.leaflet-tile-container, -.leaflet-overlay-pane, -.leaflet-shadow-pane, -.leaflet-marker-pane, -.leaflet-popup-pane, -.leaflet-overlay-pane svg, -.leaflet-zoom-box, -.leaflet-image-layer, -.leaflet-layer { - position: absolute; - left: 0; - top: 0; - } -.leaflet-container { - overflow: hidden; - -ms-touch-action: none; - touch-action: none; - } -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow { - -webkit-user-select: none; - -moz-user-select: none; - user-select: none; - -webkit-user-drag: none; - } -.leaflet-marker-icon, -.leaflet-marker-shadow { - display: block; - } -/* map is broken in FF if you have max-width: 100% on tiles */ -.leaflet-container img { - max-width: none !important; - } -/* stupid Android 2 doesn't understand "max-width: none" properly */ -.leaflet-container img.leaflet-image-layer { - max-width: 15000px !important; - } -.leaflet-tile { - filter: inherit; - visibility: hidden; - } -.leaflet-tile-loaded { - visibility: inherit; - } -.leaflet-zoom-box { - width: 0; - height: 0; - } -/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ -.leaflet-overlay-pane svg { - -moz-user-select: none; - } - -.leaflet-tile-pane { z-index: 2; } -.leaflet-objects-pane { z-index: 3; } -.leaflet-overlay-pane { z-index: 4; } -.leaflet-shadow-pane { z-index: 5; } -.leaflet-marker-pane { z-index: 6; } -.leaflet-popup-pane { z-index: 7; } - -.leaflet-vml-shape { - width: 1px; - height: 1px; - } -.lvml { - behavior: url(#default#VML); - display: inline-block; - position: absolute; - } - - -/* control positioning */ - -.leaflet-control { - position: relative; - z-index: 7; - pointer-events: auto; - } -.leaflet-top, -.leaflet-bottom { - position: absolute; - z-index: 1000; - pointer-events: none; - } -.leaflet-top { - top: 0; - } -.leaflet-right { - right: 0; - } -.leaflet-bottom { - bottom: 0; - } -.leaflet-left { - left: 0; - } -.leaflet-control { - float: left; - clear: both; - } -.leaflet-right .leaflet-control { - float: right; - } -.leaflet-top .leaflet-control { - margin-top: 10px; - } -.leaflet-bottom .leaflet-control { - margin-bottom: 10px; - } -.leaflet-left .leaflet-control { - margin-left: 10px; - } -.leaflet-right .leaflet-control { - margin-right: 10px; - } - - -/* zoom and fade animations */ - -.leaflet-fade-anim .leaflet-tile, -.leaflet-fade-anim .leaflet-popup { - opacity: 0; - -webkit-transition: opacity 0.2s linear; - -moz-transition: opacity 0.2s linear; - -o-transition: opacity 0.2s linear; - transition: opacity 0.2s linear; - } -.leaflet-fade-anim .leaflet-tile-loaded, -.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { - opacity: 1; - } - -.leaflet-zoom-anim .leaflet-zoom-animated { - -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); - -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); - -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); - transition: transform 0.25s cubic-bezier(0,0,0.25,1); - } -.leaflet-zoom-anim .leaflet-tile, -.leaflet-pan-anim .leaflet-tile, -.leaflet-touching .leaflet-zoom-animated { - -webkit-transition: none; - -moz-transition: none; - -o-transition: none; - transition: none; - } - -.leaflet-zoom-anim .leaflet-zoom-hide { - visibility: hidden; - } - - -/* cursors */ - -.leaflet-clickable { - cursor: pointer; - } -.leaflet-container { - cursor: -webkit-grab; - cursor: -moz-grab; - } -.leaflet-popup-pane, -.leaflet-control { - cursor: auto; - } -.leaflet-dragging .leaflet-container, -.leaflet-dragging .leaflet-clickable { - cursor: move; - cursor: -webkit-grabbing; - cursor: -moz-grabbing; - } - - -/* visual tweaks */ - -.leaflet-container { - background: #ddd; - outline: 0; - } -.leaflet-container a { - color: #0078A8; - } -.leaflet-container a.leaflet-active { - outline: 2px solid orange; - } -.leaflet-zoom-box { - border: 2px dotted #38f; - background: rgba(255,255,255,0.5); - } - - -/* general typography */ -.leaflet-container { - font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; - } - - -/* general toolbar styles */ - -.leaflet-bar { - box-shadow: 0 1px 5px rgba(0,0,0,0.65); - border-radius: 4px; - } -.leaflet-bar a, -.leaflet-bar a:hover { - background-color: #fff; - border-bottom: 1px solid #ccc; - width: 26px; - height: 26px; - line-height: 26px; - display: block; - text-align: center; - text-decoration: none; - color: black; - } -.leaflet-bar a, -.leaflet-control-layers-toggle { - background-position: 50% 50%; - background-repeat: no-repeat; - display: block; - } -.leaflet-bar a:hover { - background-color: #f4f4f4; - } -.leaflet-bar a:first-child { - border-top-left-radius: 4px; - border-top-right-radius: 4px; - } -.leaflet-bar a:last-child { - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - border-bottom: none; - } -.leaflet-bar a.leaflet-disabled { - cursor: default; - background-color: #f4f4f4; - color: #bbb; - } - -.leaflet-touch .leaflet-bar a { - width: 30px; - height: 30px; - line-height: 30px; - } - - -/* zoom control */ - -.leaflet-control-zoom-in, -.leaflet-control-zoom-out { - font: bold 18px 'Lucida Console', Monaco, monospace; - text-indent: 1px; - } -.leaflet-control-zoom-out { - font-size: 20px; - } - -.leaflet-touch .leaflet-control-zoom-in { - font-size: 22px; - } -.leaflet-touch .leaflet-control-zoom-out { - font-size: 24px; - } - - -/* layers control */ - -.leaflet-control-layers { - box-shadow: 0 1px 5px rgba(0,0,0,0.4); - background: #fff; - border-radius: 5px; - } -.leaflet-control-layers-toggle { - background-image: url(images/layers.png); - width: 36px; - height: 36px; - } -.leaflet-retina .leaflet-control-layers-toggle { - background-image: url(images/layers-2x.png); - background-size: 26px 26px; - } -.leaflet-touch .leaflet-control-layers-toggle { - width: 44px; - height: 44px; - } -.leaflet-control-layers .leaflet-control-layers-list, -.leaflet-control-layers-expanded .leaflet-control-layers-toggle { - display: none; - } -.leaflet-control-layers-expanded .leaflet-control-layers-list { - display: block; - position: relative; - } -.leaflet-control-layers-expanded { - padding: 6px 10px 6px 6px; - color: #333; - background: #fff; - } -.leaflet-control-layers-selector { - margin-top: 2px; - position: relative; - top: 1px; - } -.leaflet-control-layers label { - display: block; - } -.leaflet-control-layers-separator { - height: 0; - border-top: 1px solid #ddd; - margin: 5px -10px 5px -6px; - } - - -/* attribution and scale controls */ - -.leaflet-container .leaflet-control-attribution { - background: #fff; - background: rgba(255, 255, 255, 0.7); - margin: 0; - } -.leaflet-control-attribution, -.leaflet-control-scale-line { - padding: 0 5px; - color: #333; - } -.leaflet-control-attribution a { - text-decoration: none; - } -.leaflet-control-attribution a:hover { - text-decoration: underline; - } -.leaflet-container .leaflet-control-attribution, -.leaflet-container .leaflet-control-scale { - font-size: 11px; - } -.leaflet-left .leaflet-control-scale { - margin-left: 5px; - } -.leaflet-bottom .leaflet-control-scale { - margin-bottom: 5px; - } -.leaflet-control-scale-line { - border: 2px solid #777; - border-top: none; - line-height: 1.1; - padding: 2px 5px 1px; - font-size: 11px; - white-space: nowrap; - overflow: hidden; - -moz-box-sizing: content-box; - box-sizing: content-box; - - background: #fff; - background: rgba(255, 255, 255, 0.5); - } -.leaflet-control-scale-line:not(:first-child) { - border-top: 2px solid #777; - border-bottom: none; - margin-top: -2px; - } -.leaflet-control-scale-line:not(:first-child):not(:last-child) { - border-bottom: 2px solid #777; - } - -.leaflet-touch .leaflet-control-attribution, -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - box-shadow: none; - } -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - border: 2px solid rgba(0,0,0,0.2); - background-clip: padding-box; - } - - -/* popup */ - -.leaflet-popup { - position: absolute; - text-align: center; - } -.leaflet-popup-content-wrapper { - padding: 1px; - text-align: left; - border-radius: 12px; - } -.leaflet-popup-content { - margin: 13px 19px; - line-height: 1.4; - } -.leaflet-popup-content p { - margin: 18px 0; - } -.leaflet-popup-tip-container { - margin: 0 auto; - width: 40px; - height: 20px; - position: relative; - overflow: hidden; - } -.leaflet-popup-tip { - width: 17px; - height: 17px; - padding: 1px; - - margin: -10px auto 0; - - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -ms-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); - } -.leaflet-popup-content-wrapper, -.leaflet-popup-tip { - background: white; - - box-shadow: 0 3px 14px rgba(0,0,0,0.4); - } -.leaflet-container a.leaflet-popup-close-button { - position: absolute; - top: 0; - right: 0; - padding: 4px 4px 0 0; - text-align: center; - width: 18px; - height: 14px; - font: 16px/14px Tahoma, Verdana, sans-serif; - color: #c3c3c3; - text-decoration: none; - font-weight: bold; - background: transparent; - } -.leaflet-container a.leaflet-popup-close-button:hover { - color: #999; - } -.leaflet-popup-scrolled { - overflow: auto; - border-bottom: 1px solid #ddd; - border-top: 1px solid #ddd; - } - -.leaflet-oldie .leaflet-popup-content-wrapper { - zoom: 1; - } -.leaflet-oldie .leaflet-popup-tip { - width: 24px; - margin: 0 auto; - - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; - filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); - } -.leaflet-oldie .leaflet-popup-tip-container { - margin-top: -1px; - } - -.leaflet-oldie .leaflet-control-zoom, -.leaflet-oldie .leaflet-control-layers, -.leaflet-oldie .leaflet-popup-content-wrapper, -.leaflet-oldie .leaflet-popup-tip { - border: 1px solid #999; - } - - -/* div icon */ - -.leaflet-div-icon { - background: #fff; - border: 1px solid #666; - } +/* required styles */ + +.leaflet-map-pane, +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-tile-pane, +.leaflet-tile-container, +.leaflet-overlay-pane, +.leaflet-shadow-pane, +.leaflet-marker-pane, +.leaflet-popup-pane, +.leaflet-overlay-pane svg, +.leaflet-zoom-box, +.leaflet-image-layer, +.leaflet-layer { + position: absolute; + left: 0; + top: 0; + } +.leaflet-container { + overflow: hidden; + -ms-touch-action: none; + touch-action: none; + } +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + -webkit-user-drag: none; + } +.leaflet-marker-icon, +.leaflet-marker-shadow { + display: block; + } +/* map is broken in FF if you have max-width: 100% on tiles */ +.leaflet-container img { + max-width: none !important; + } +/* stupid Android 2 doesn't understand "max-width: none" properly */ +.leaflet-container img.leaflet-image-layer { + max-width: 15000px !important; + } +.leaflet-tile { + filter: inherit; + visibility: hidden; + } +.leaflet-tile-loaded { + visibility: inherit; + } +.leaflet-zoom-box { + width: 0; + height: 0; + } +/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ +.leaflet-overlay-pane svg { + -moz-user-select: none; + } + +.leaflet-tile-pane { z-index: 2; } +.leaflet-objects-pane { z-index: 3; } +.leaflet-overlay-pane { z-index: 4; } +.leaflet-shadow-pane { z-index: 5; } +.leaflet-marker-pane { z-index: 6; } +.leaflet-popup-pane { z-index: 7; } + +.leaflet-vml-shape { + width: 1px; + height: 1px; + } +.lvml { + behavior: url(#default#VML); + display: inline-block; + position: absolute; + } + + +/* control positioning */ + +.leaflet-control { + position: relative; + z-index: 7; + pointer-events: auto; + } +.leaflet-top, +.leaflet-bottom { + position: absolute; + z-index: 1000; + pointer-events: none; + } +.leaflet-top { + top: 0; + } +.leaflet-right { + right: 0; + } +.leaflet-bottom { + bottom: 0; + } +.leaflet-left { + left: 0; + } +.leaflet-control { + float: left; + clear: both; + } +.leaflet-right .leaflet-control { + float: right; + } +.leaflet-top .leaflet-control { + margin-top: 10px; + } +.leaflet-bottom .leaflet-control { + margin-bottom: 10px; + } +.leaflet-left .leaflet-control { + margin-left: 10px; + } +.leaflet-right .leaflet-control { + margin-right: 10px; + } + + +/* zoom and fade animations */ + +.leaflet-fade-anim .leaflet-tile, +.leaflet-fade-anim .leaflet-popup { + opacity: 0; + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + -o-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; + } +.leaflet-fade-anim .leaflet-tile-loaded, +.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { + opacity: 1; + } + +.leaflet-zoom-anim .leaflet-zoom-animated { + -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); + -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); + -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); + transition: transform 0.25s cubic-bezier(0,0,0.25,1); + } +.leaflet-zoom-anim .leaflet-tile, +.leaflet-pan-anim .leaflet-tile, +.leaflet-touching .leaflet-zoom-animated { + -webkit-transition: none; + -moz-transition: none; + -o-transition: none; + transition: none; + } + +.leaflet-zoom-anim .leaflet-zoom-hide { + visibility: hidden; + } + + +/* cursors */ + +.leaflet-clickable { + cursor: pointer; + } +.leaflet-container { + cursor: -webkit-grab; + cursor: -moz-grab; + } +.leaflet-popup-pane, +.leaflet-control { + cursor: auto; + } +.leaflet-dragging .leaflet-container, +.leaflet-dragging .leaflet-clickable { + cursor: move; + cursor: -webkit-grabbing; + cursor: -moz-grabbing; + } + + +/* visual tweaks */ + +.leaflet-container { + background: #ddd; + outline: 0; + } +.leaflet-container a { + color: #0078A8; + } +.leaflet-container a.leaflet-active { + outline: 2px solid orange; + } +.leaflet-zoom-box { + border: 2px dotted #38f; + background: rgba(255,255,255,0.5); + } + + +/* general typography */ +.leaflet-container { + font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; + } + + +/* general toolbar styles */ + +.leaflet-bar { + box-shadow: 0 1px 5px rgba(0,0,0,0.65); + border-radius: 4px; + } +.leaflet-bar a, +.leaflet-bar a:hover { + background-color: #fff; + border-bottom: 1px solid #ccc; + width: 26px; + height: 26px; + line-height: 26px; + display: block; + text-align: center; + text-decoration: none; + color: black; + } +.leaflet-bar a, +.leaflet-control-layers-toggle { + background-position: 50% 50%; + background-repeat: no-repeat; + display: block; + } +.leaflet-bar a:hover { + background-color: #f4f4f4; + } +.leaflet-bar a:first-child { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + } +.leaflet-bar a:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom: none; + } +.leaflet-bar a.leaflet-disabled { + cursor: default; + background-color: #f4f4f4; + color: #bbb; + } + +.leaflet-touch .leaflet-bar a { + width: 30px; + height: 30px; + line-height: 30px; + } + + +/* zoom control */ + +.leaflet-control-zoom-in, +.leaflet-control-zoom-out { + font: bold 18px 'Lucida Console', Monaco, monospace; + text-indent: 1px; + } +.leaflet-control-zoom-out { + font-size: 20px; + } + +.leaflet-touch .leaflet-control-zoom-in { + font-size: 22px; + } +.leaflet-touch .leaflet-control-zoom-out { + font-size: 24px; + } + + +/* layers control */ + +.leaflet-control-layers { + box-shadow: 0 1px 5px rgba(0,0,0,0.4); + background: #fff; + border-radius: 5px; + } +.leaflet-control-layers-toggle { + background-image: url(images/layers.png); + width: 36px; + height: 36px; + } +.leaflet-retina .leaflet-control-layers-toggle { + background-image: url(images/layers-2x.png); + background-size: 26px 26px; + } +.leaflet-touch .leaflet-control-layers-toggle { + width: 44px; + height: 44px; + } +.leaflet-control-layers .leaflet-control-layers-list, +.leaflet-control-layers-expanded .leaflet-control-layers-toggle { + display: none; + } +.leaflet-control-layers-expanded .leaflet-control-layers-list { + display: block; + position: relative; + } +.leaflet-control-layers-expanded { + padding: 6px 10px 6px 6px; + color: #333; + background: #fff; + } +.leaflet-control-layers-selector { + margin-top: 2px; + position: relative; + top: 1px; + } +.leaflet-control-layers label { + display: block; + } +.leaflet-control-layers-separator { + height: 0; + border-top: 1px solid #ddd; + margin: 5px -10px 5px -6px; + } + + +/* attribution and scale controls */ + +.leaflet-container .leaflet-control-attribution { + background: #fff; + background: rgba(255, 255, 255, 0.7); + margin: 0; + } +.leaflet-control-attribution, +.leaflet-control-scale-line { + padding: 0 5px; + color: #333; + } +.leaflet-control-attribution a { + text-decoration: none; + } +.leaflet-control-attribution a:hover { + text-decoration: underline; + } +.leaflet-container .leaflet-control-attribution, +.leaflet-container .leaflet-control-scale { + font-size: 11px; + } +.leaflet-left .leaflet-control-scale { + margin-left: 5px; + } +.leaflet-bottom .leaflet-control-scale { + margin-bottom: 5px; + } +.leaflet-control-scale-line { + border: 2px solid #777; + border-top: none; + line-height: 1.1; + padding: 2px 5px 1px; + font-size: 11px; + white-space: nowrap; + overflow: hidden; + -moz-box-sizing: content-box; + box-sizing: content-box; + + background: #fff; + background: rgba(255, 255, 255, 0.5); + } +.leaflet-control-scale-line:not(:first-child) { + border-top: 2px solid #777; + border-bottom: none; + margin-top: -2px; + } +.leaflet-control-scale-line:not(:first-child):not(:last-child) { + border-bottom: 2px solid #777; + } + +.leaflet-touch .leaflet-control-attribution, +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + box-shadow: none; + } +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + border: 2px solid rgba(0,0,0,0.2); + background-clip: padding-box; + } + + +/* popup */ + +.leaflet-popup { + position: absolute; + text-align: center; + } +.leaflet-popup-content-wrapper { + padding: 1px; + text-align: left; + border-radius: 12px; + } +.leaflet-popup-content { + margin: 13px 19px; + line-height: 1.4; + } +.leaflet-popup-content p { + margin: 18px 0; + } +.leaflet-popup-tip-container { + margin: 0 auto; + width: 40px; + height: 20px; + position: relative; + overflow: hidden; + } +.leaflet-popup-tip { + width: 17px; + height: 17px; + padding: 1px; + + margin: -10px auto 0; + + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + } +.leaflet-popup-content-wrapper, +.leaflet-popup-tip { + background: white; + + box-shadow: 0 3px 14px rgba(0,0,0,0.4); + } +.leaflet-container a.leaflet-popup-close-button { + position: absolute; + top: 0; + right: 0; + padding: 4px 4px 0 0; + text-align: center; + width: 18px; + height: 14px; + font: 16px/14px Tahoma, Verdana, sans-serif; + color: #c3c3c3; + text-decoration: none; + font-weight: bold; + background: transparent; + } +.leaflet-container a.leaflet-popup-close-button:hover { + color: #999; + } +.leaflet-popup-scrolled { + overflow: auto; + border-bottom: 1px solid #ddd; + border-top: 1px solid #ddd; + } + +.leaflet-oldie .leaflet-popup-content-wrapper { + zoom: 1; + } +.leaflet-oldie .leaflet-popup-tip { + width: 24px; + margin: 0 auto; + + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; + filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); + } +.leaflet-oldie .leaflet-popup-tip-container { + margin-top: -1px; + } + +.leaflet-oldie .leaflet-control-zoom, +.leaflet-oldie .leaflet-control-layers, +.leaflet-oldie .leaflet-popup-content-wrapper, +.leaflet-oldie .leaflet-popup-tip { + border: 1px solid #999; + } + + +/* div icon */ + +.leaflet-div-icon { + background: #fff; + border: 1px solid #666; + } diff --git a/platforms/android/assets/www/css/main.css b/platforms/android/assets/www/css/main.css index 468f96c..91dbb61 100644 --- a/platforms/android/assets/www/css/main.css +++ b/platforms/android/assets/www/css/main.css @@ -69,7 +69,7 @@ body { top: 0; left: 0; width: 100%; - height: 20%; + height: auto; z-index: 9500; } @@ -167,9 +167,10 @@ body { position: absolute; bottom: 0px; left: 0px; - height: 50%; + height: auto !important; max-height: 50%; width: 100%; + z-index: 9501; } #chatmsgs { diff --git a/platforms/android/assets/www/index.html b/platforms/android/assets/www/index.html index 5846f9c..13899f6 100644 --- a/platforms/android/assets/www/index.html +++ b/platforms/android/assets/www/index.html @@ -9,7 +9,10 @@ - + TerranQuest @@ -28,6 +31,15 @@ + + + + + + + + + @@ -39,12 +51,6 @@ - - - - - - diff --git a/platforms/android/assets/www/js/auth.js b/platforms/android/assets/www/js/auth.js index 1690630..344b93e 100644 --- a/platforms/android/assets/www/js/auth.js +++ b/platforms/android/assets/www/js/auth.js @@ -4,6 +4,19 @@ var authOpInProgress = false; +function askLogout() { + navigator.notification.confirm( + 'Do you really want to logout?', // message + function (btn) { + if (btn === 1) { + logout(); + } + }, + 'Logout?', + ['Logout', 'Cancel'] + ); +} + function logout() { localStorage.setItem("username", ''); localStorage.setItem("password", ''); @@ -97,6 +110,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: " + out.message); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; } }).fail(function (err) { @@ -104,6 +118,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: Login OK, but cannot connect to game server. Try again later."); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; }); } else { @@ -111,6 +126,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text(data); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); } authOpInProgress = false; }).fail(function () { @@ -118,6 +134,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: Network failure."); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; }); } diff --git a/platforms/android/assets/www/js/home.js b/platforms/android/assets/www/js/home.js index 15faf2f..8f5f6c2 100644 --- a/platforms/android/assets/www/js/home.js +++ b/platforms/android/assets/www/js/home.js @@ -64,23 +64,23 @@ var lc = L.control.locate({ }, locateOptions: {} // define location options e.g enableHighAccuracy: true or maxZoom: 10 }).addTo(map); -map.addLayer(new L.tileLayer(tileurl, {minZoom: 17, maxZoom: 17})); +map.addLayer(new L.tileLayer(tileurl, {minZoom: 17, maxZoom: 18})); // GeoJSON layer var placeLayer = L.geoJson( {"name": "Places", "type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [0, 0]}, "properties": {"osm_id": -1, "name": null}}]}, -{ - onEachFeature: onPlaceTap, - pointToLayer: function (feature, latlng) { - return L.circleMarker(latlng, { - radius: 8, - fillColor: "#ff7800", - color: "#000", - weight: 1, - opacity: 1, - fillOpacity: 0.8 - }); - } -}).addTo(map); + { + onEachFeature: onPlaceTap, + pointToLayer: function (feature, latlng) { + return L.circleMarker(latlng, { + radius: 14, + fillColor: "#ff7800", + color: "#000", + weight: 1, + opacity: 1, + fillOpacity: 0.6 + }); + } + }).addTo(map); lc.start(); function mapPos(lat, lon) { lockGot = true; @@ -291,9 +291,11 @@ function toggleChat() { function closeChat() { $('#chatmsgs').css('display', 'none'); + $('.chatbox').css('height', 'auto'); } function openChat() { + $('.chatbox').css('height', '50%'); $('#chatmsgs').css('display', 'block'); $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000); } diff --git a/platforms/android/assets/www/plugins/cordova-plugin-camera/www/Camera.js b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/Camera.js new file mode 100644 index 0000000..df633a2 --- /dev/null +++ b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/Camera.js @@ -0,0 +1,194 @@ +cordova.define("cordova-plugin-camera.camera", function(require, exports, module) { +/* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + exec = require('cordova/exec'), + Camera = require('./Camera'); + // XXX: commented out + //CameraPopoverHandle = require('./CameraPopoverHandle'); + +/** + * @namespace navigator + */ + +/** + * @exports camera + */ +var cameraExport = {}; + +// Tack on the Camera Constants to the base camera plugin. +for (var key in Camera) { + cameraExport[key] = Camera[key]; +} + +/** + * Callback function that provides an error message. + * @callback module:camera.onError + * @param {string} message - The message is provided by the device's native code. + */ + +/** + * Callback function that provides the image data. + * @callback module:camera.onSuccess + * @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect. + * @example + * // Show image + * // + * function cameraCallback(imageData) { + * var image = document.getElementById('myImage'); + * image.src = "data:image/jpeg;base64," + imageData; + * } + */ + +/** + * Optional parameters to customize the camera settings. + * * [Quirks](#CameraOptions-quirks) + * @typedef module:camera.CameraOptions + * @type {Object} + * @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.) + * @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value. + * @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture. + * @property {Boolean} [allowEdit=true] - Allow simple editing of image before selection. + * @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding. + * @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant. + * @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant. + * @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. + * @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture. + * @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture. + * @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad. + * @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing). + */ + +/** + * @description 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 `camera.getPicture` function opens the device's default camera + * application that allows users to snap pictures by default - this behavior occurs, + * when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}. + * 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`]{@link module: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`]{@link module:camera.onSuccess} 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 `` 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__ + * + * - Android + * - BlackBerry + * - Browser + * - Firefox + * - FireOS + * - iOS + * - Windows + * - WP8 + * - Ubuntu + * + * More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks). + * + * @example + * navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + * @param {module:camera.onSuccess} successCallback + * @param {module:camera.onError} errorCallback + * @param {module:camera.CameraOptions} options CameraOptions + */ +cameraExport.getPicture = function(successCallback, errorCallback, options) { + argscheck.checkArgs('fFO', 'Camera.getPicture', arguments); + options = options || {}; + var getValue = argscheck.getValue; + + var quality = getValue(options.quality, 50); + var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI); + var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA); + var targetWidth = getValue(options.targetWidth, -1); + var targetHeight = getValue(options.targetHeight, -1); + var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG); + var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE); + var allowEdit = !!options.allowEdit; + var correctOrientation = !!options.correctOrientation; + var saveToPhotoAlbum = !!options.saveToPhotoAlbum; + var popoverOptions = getValue(options.popoverOptions, null); + var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK); + + var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, + mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection]; + + exec(successCallback, errorCallback, "Camera", "takePicture", args); + // XXX: commented out + //return new CameraPopoverHandle(); +}; + +/** + * Removes intermediate image files that are kept in temporary storage + * after calling [`camera.getPicture`]{@link module: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); + * } + */ +cameraExport.cleanup = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "Camera", "cleanup", []); +}; + +module.exports = cameraExport; + +}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraConstants.js b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraConstants.js new file mode 100644 index 0000000..1a786df --- /dev/null +++ b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraConstants.js @@ -0,0 +1,91 @@ +cordova.define("cordova-plugin-camera.Camera", function(require, exports, module) { +/* + * + * 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. + * +*/ + +/** + * @module Camera + */ +module.exports = { + /** + * @enum {number} + */ + DestinationType:{ + /** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */ + DATA_URL: 0, + /** Return file uri (content://media/external/images/media/2 for Android) */ + FILE_URI: 1, + /** Return native uri (eg. asset-library://... for iOS) */ + NATIVE_URI: 2 + }, + /** + * @enum {number} + */ + EncodingType:{ + /** Return JPEG encoded image */ + JPEG: 0, + /** Return PNG encoded image */ + PNG: 1 + }, + /** + * @enum {number} + */ + MediaType:{ + /** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */ + PICTURE: 0, + /** Allow selection of video only, ONLY RETURNS URL */ + VIDEO: 1, + /** Allow selection from all media types */ + ALLMEDIA : 2 + }, + /** + * @enum {number} + */ + PictureSourceType:{ + /** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */ + PHOTOLIBRARY : 0, + /** Take picture from camera */ + CAMERA : 1, + /** Choose image from picture library (same as PHOTOLIBRARY for Android) */ + SAVEDPHOTOALBUM : 2 + }, + /** + * Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover. + * @enum {number} + */ + PopoverArrowDirection:{ + ARROW_UP : 1, + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }, + /** + * @enum {number} + */ + Direction:{ + /** Use the back-facing camera */ + BACK: 0, + /** Use the front-facing camera */ + FRONT: 1 + } +}; + +}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js new file mode 100644 index 0000000..a65ac7e --- /dev/null +++ b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js @@ -0,0 +1,35 @@ +cordova.define("cordova-plugin-camera.CameraPopoverHandle", function(require, exports, module) { +/* + * + * 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. + * +*/ + +/** + * @ignore in favour of iOS' one + * A handle to an image picker popover. + */ +var CameraPopoverHandle = function() { + this.setPosition = function(popoverOptions) { + console.log('CameraPopoverHandle.setPosition is only supported on iOS.'); + }; +}; + +module.exports = CameraPopoverHandle; + +}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js new file mode 100644 index 0000000..f6a1e8f --- /dev/null +++ b/platforms/android/assets/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js @@ -0,0 +1,55 @@ +cordova.define("cordova-plugin-camera.CameraPopoverOptions", function(require, exports, module) { +/* + * + * 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. + * +*/ + +var Camera = require('./Camera'); + +/** + * @namespace navigator + */ + +/** + * 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. + * 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. + * @module CameraPopoverOptions + * @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover. + * @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover. + * @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point. + */ +var CameraPopoverOptions = function (x, y, width, height, arrowDir) { + // information of rectangle that popover should be anchored to + this.x = x || 0; + this.y = y || 32; + this.width = width || 320; + this.height = height || 480; + this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY; +}; + +module.exports = CameraPopoverOptions; + +}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/CompassError.js b/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/CompassError.js deleted file mode 100644 index 0055b9a..0000000 --- a/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/CompassError.js +++ /dev/null @@ -1,37 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassError", function(require, exports, module) { -/* - * - * 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. - * -*/ - -/** - * CompassError. - * An error code assigned by an implementation when an error has occurred - * @constructor - */ -var CompassError = function(err) { - this.code = (err !== undefined ? err : null); -}; - -CompassError.COMPASS_INTERNAL_ERR = 0; -CompassError.COMPASS_NOT_SUPPORTED = 20; - -module.exports = CompassError; - -}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js b/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js deleted file mode 100644 index 4ebb4aa..0000000 --- a/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js +++ /dev/null @@ -1,32 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassHeading", function(require, exports, module) { -/* - * - * 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. - * -*/ - -var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) { - this.magneticHeading = magneticHeading; - this.trueHeading = trueHeading; - this.headingAccuracy = headingAccuracy; - this.timestamp = timestamp || new Date().getTime(); -}; - -module.exports = CompassHeading; - -}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/compass.js b/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/compass.js deleted file mode 100644 index 48ee5f6..0000000 --- a/platforms/android/assets/www/plugins/cordova-plugin-device-orientation/www/compass.js +++ /dev/null @@ -1,121 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.compass", function(require, exports, module) { -/* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - utils = require('cordova/utils'), - CompassHeading = require('./CompassHeading'), - CompassError = require('./CompassError'), - - timers = {}, - eventTimerId = null, - compass = { - /** - * Asynchronously acquires the current heading. - * @param {Function} successCallback The function to call when the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {CompassOptions} options The options for getting the heading data (not used). - */ - getCurrentHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments); - - var win = function(result) { - var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp); - successCallback(ch); - }; - var fail = errorCallback && function(code) { - var ce = new CompassError(code); - errorCallback(ce); - }; - - // Get heading - exec(win, fail, "Compass", "getHeading", [options]); - }, - - /** - * Asynchronously acquires the heading repeatedly at a given interval. - * @param {Function} successCallback The function to call each time the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {HeadingOptions} options The options for getting the heading data - * such as timeout and the frequency of the watch. For iOS, filter parameter - * specifies to watch via a distance filter rather than time. - */ - watchHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.watchHeading', arguments); - // Default interval (100 msec) - var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100; - var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0; - - var id = utils.createUUID(); - if (filter > 0) { - // is an iOS request for watch by filter, no timer needed - timers[id] = "iOS"; - compass.getCurrentHeading(successCallback, errorCallback, options); - } else { - // Start watch timer to get headings - timers[id] = window.setInterval(function() { - compass.getCurrentHeading(successCallback, errorCallback); - }, frequency); - } - - if (cordova.platformId === 'browser' && !eventTimerId) { - // Start firing deviceorientation events if haven't already - var deviceorientationEvent = new Event('deviceorientation'); - eventTimerId = window.setInterval(function() { - window.dispatchEvent(deviceorientationEvent); - }, 200); - } - - return id; - }, - - /** - * Clears the specified heading watch. - * @param {String} id The ID of the watch returned from #watchHeading. - */ - clearWatch:function(id) { - // Stop javascript timer & remove from timer list - if (id && timers[id]) { - if (timers[id] != "iOS") { - clearInterval(timers[id]); - } else { - // is iOS watch by filter so call into device to stop - exec(null, null, "Compass", "stopHeading", []); - } - delete timers[id]; - - if (eventTimerId && Object.keys(timers).length === 0) { - // No more watchers, so stop firing 'deviceorientation' events - window.clearInterval(eventTimerId); - eventTimerId = null; - } - } - } - }; - -module.exports = compass; - -}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-device/www/device.js b/platforms/android/assets/www/plugins/cordova-plugin-device/www/device.js new file mode 100644 index 0000000..977dfc0 --- /dev/null +++ b/platforms/android/assets/www/plugins/cordova-plugin-device/www/device.js @@ -0,0 +1,86 @@ +cordova.define("cordova-plugin-device.device", function(require, exports, module) { +/* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + channel = require('cordova/channel'), + utils = require('cordova/utils'), + exec = require('cordova/exec'), + cordova = require('cordova'); + +channel.createSticky('onCordovaInfoReady'); +// Tell cordova channel to wait on the CordovaInfoReady event +channel.waitForInitialization('onCordovaInfoReady'); + +/** + * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the + * phone, etc. + * @constructor + */ +function Device() { + this.available = false; + this.platform = null; + this.version = null; + this.uuid = null; + this.cordova = null; + this.model = null; + this.manufacturer = null; + this.isVirtual = null; + this.serial = null; + + var me = this; + + channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js + //TODO: CB-5105 native implementations should not return info.cordova + var buildLabel = cordova.version; + me.available = true; + me.platform = info.platform; + me.version = info.version; + me.uuid = info.uuid; + me.cordova = buildLabel; + me.model = info.model; + me.isVirtual = info.isVirtual; + me.manufacturer = info.manufacturer || 'unknown'; + me.serial = info.serial || 'unknown'; + channel.onCordovaInfoReady.fire(); + },function(e) { + me.available = false; + utils.alert("[ERROR] Error initializing Cordova: " + e); + }); + }); +} + +/** + * Get device info + * + * @param {Function} successCallback The function to call when the heading data is available + * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL) + */ +Device.prototype.getInfo = function(successCallback, errorCallback) { + argscheck.checkArgs('fF', 'Device.getInfo', arguments); + exec(successCallback, errorCallback, "Device", "getDeviceInfo", []); +}; + +module.exports = new Device(); + +}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/platforms/android/assets/www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js deleted file mode 100644 index 28cc200..0000000 --- a/platforms/android/assets/www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js +++ /dev/null @@ -1,238 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransfer", function(require, exports, module) { -/* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - FileTransferError = require('./FileTransferError'), - ProgressEvent = require('cordova-plugin-file.ProgressEvent'); - -function newProgressEvent(result) { - var pe = new ProgressEvent(); - pe.lengthComputable = result.lengthComputable; - pe.loaded = result.loaded; - pe.total = result.total; - return pe; -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function convertHeadersToArray(headers) { - var result = []; - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - var headerValue = headers[header]; - result.push({ - name: header, - value: headerValue.toString() - }); - } - } - return result; -} - -var idCounter = 0; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** -* Given an absolute file path, uploads a file on the device to a remote server -* using a multipart HTTP request. -* @param filePath {String} Full path of the file on the device -* @param server {String} URL of the server to receive the file -* @param successCallback (Function} Callback to be invoked when upload has completed -* @param errorCallback {Function} Callback to be invoked upon error -* @param options {FileUploadOptions} Optional parameters such as file name and mimetype -* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false -*/ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - // check for options - var fileKey = null; - var fileName = null; - var mimeType = null; - var params = null; - var chunkedMode = true; - var headers = null; - var httpMethod = null; - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - if (options) { - fileKey = options.fileKey; - fileName = options.fileName; - mimeType = options.mimeType; - headers = options.headers; - httpMethod = options.httpMethod || "POST"; - if (httpMethod.toUpperCase() == "PUT"){ - httpMethod = "PUT"; - } else { - httpMethod = "POST"; - } - if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { - chunkedMode = options.chunkedMode; - } - if (options.params) { - params = options.params; - } - else { - params = {}; - } - } - - if (cordova.platformId === "windowsphone") { - headers = headers && convertHeadersToArray(headers); - params = params && convertHeadersToArray(params); - } - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - var self = this; - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - self.onprogress(newProgressEvent(result)); - } - } else { - successCallback && successCallback(result); - } - }; - exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - var self = this; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var headers = null; - if (options) { - headers = options.headers || null; - } - - if (cordova.platformId === "windowsphone" && headers) { - headers = convertHeadersToArray(headers); - } - - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - return self.onprogress(newProgressEvent(result)); - } - } else if (successCallback) { - var entry = null; - if (result.isDirectory) { - entry = new (require('cordova-plugin-file.DirectoryEntry'))(); - } - else if (result.isFile) { - entry = new (require('cordova-plugin-file.FileEntry'))(); - } - entry.isDirectory = result.isDirectory; - entry.isFile = result.isFile; - entry.name = result.name; - entry.fullPath = result.fullPath; - entry.filesystem = new FileSystem(result.filesystemName || (result.filesystem == window.PERSISTENT ? 'persistent' : 'temporary')); - entry.nativeURL = result.nativeURL; - successCallback(entry); - } - }; - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - exec(null, null, 'FileTransfer', 'abort', [this._id]); -}; - -module.exports = FileTransfer; - -}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/platforms/android/assets/www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js deleted file mode 100644 index 18fb64c..0000000 --- a/platforms/android/assets/www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js +++ /dev/null @@ -1,44 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransferError", function(require, exports, module) { -/* - * - * 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. - * -*/ - -/** - * FileTransferError - * @constructor - */ -var FileTransferError = function(code, source, target, status, body, exception) { - this.code = code || null; - this.source = source || null; - this.target = target || null; - this.http_status = status || null; - this.body = body || null; - this.exception = exception || null; -}; - -FileTransferError.FILE_NOT_FOUND_ERR = 1; -FileTransferError.INVALID_URL_ERR = 2; -FileTransferError.CONNECTION_ERR = 3; -FileTransferError.ABORT_ERR = 4; -FileTransferError.NOT_MODIFIED_ERR = 5; - -module.exports = FileTransferError; - -}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-file/www/browser/isChrome.js b/platforms/android/assets/www/plugins/cordova-plugin-file/www/browser/isChrome.js index 90450d8..c74fd9c 100644 --- a/platforms/android/assets/www/plugins/cordova-plugin-file/www/browser/isChrome.js +++ b/platforms/android/assets/www/plugins/cordova-plugin-file/www/browser/isChrome.js @@ -1,29 +1,29 @@ cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) { -/* - * - * 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. - * - */ - -module.exports = function () { - // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and - // possibly a good flag to indicate that we're running in Chrome - return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; -}; +/* + * + * 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. + * + */ + +module.exports = function () { + // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and + // possibly a good flag to indicate that we're running in Chrome + return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; +}; }); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-geolocation/www/android/geolocation.js b/platforms/android/assets/www/plugins/cordova-plugin-geolocation/www/android/geolocation.js index c34ba06..814aafb 100644 --- a/platforms/android/assets/www/plugins/cordova-plugin-geolocation/www/android/geolocation.js +++ b/platforms/android/assets/www/plugins/cordova-plugin-geolocation/www/android/geolocation.js @@ -20,13 +20,15 @@ cordova.define("cordova-plugin-geolocation.geolocation", function(require, expor * */ - var exec = cordova.require('cordova/exec'); var utils = require('cordova/utils'); var PositionError = require('./PositionError'); -module.exports = { +// Native watchPosition method is called async after permissions prompt. +// So we use additional map and own ids to return watch id synchronously. +var pluginToNativeWatchMap = {}; +module.exports = { getCurrentPosition: function(success, error, args) { var win = function() { var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); @@ -69,8 +71,4 @@ module.exports = { } }; -// Native watchPosition method is called async after permissions prompt. -// So we use additional map and own ids to return watch id synchronously. -var pluginToNativeWatchMap = {}; - }); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-media-capture/www/CaptureError.js b/platforms/android/assets/www/plugins/cordova-plugin-media-capture/www/CaptureError.js index 3bd253c..0101382 100644 --- a/platforms/android/assets/www/plugins/cordova-plugin-media-capture/www/CaptureError.js +++ b/platforms/android/assets/www/plugins/cordova-plugin-media-capture/www/CaptureError.js @@ -35,6 +35,8 @@ CaptureError.CAPTURE_APPLICATION_BUSY = 1; CaptureError.CAPTURE_INVALID_ARGUMENT = 2; // User exited camera application or audio capture application before capturing anything. CaptureError.CAPTURE_NO_MEDIA_FILES = 3; +// User denied permissions required to perform the capture request. +CaptureError.CAPTURE_PERMISSION_DENIED = 4; // The requested capture operation is not supported. CaptureError.CAPTURE_NOT_SUPPORTED = 20; diff --git a/platforms/android/assets/www/plugins/cordova-plugin-media/www/Media.js b/platforms/android/assets/www/plugins/cordova-plugin-media/www/Media.js index 2d83ad6..d42fca7 100644 --- a/platforms/android/assets/www/plugins/cordova-plugin-media/www/Media.js +++ b/platforms/android/assets/www/plugins/cordova-plugin-media/www/Media.js @@ -160,10 +160,18 @@ Media.prototype.setRate = function(rate) { if (cordova.platformId === 'ios'){ exec(null, null, "Media", "setRate", [this.id, rate]); } else { - console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.') + console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.'); } }; +/** + * Get amplitude of audio. + */ +Media.prototype.getCurrentAmplitude = function(success, fail) { + exec(function(p) { + success(p); + }, fail, "Media", "getCurrentAmplitudeAudio", [this.id]); +}; /** * Audio has status update. @@ -177,30 +185,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value == Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value == Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } - else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/platforms/android/assets/www/plugins/cordova-plugin-network-information/www/Connection.js b/platforms/android/assets/www/plugins/cordova-plugin-network-information/www/Connection.js new file mode 100644 index 0000000..5f7279c --- /dev/null +++ b/platforms/android/assets/www/plugins/cordova-plugin-network-information/www/Connection.js @@ -0,0 +1,37 @@ +cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) { +/* + * + * 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. + * +*/ + +/** + * Network status + */ +module.exports = { + UNKNOWN: "unknown", + ETHERNET: "ethernet", + WIFI: "wifi", + CELL_2G: "2g", + CELL_3G: "3g", + CELL_4G: "4g", + CELL:"cellular", + NONE: "none" +}; + +}); diff --git a/platforms/android/assets/www/plugins/cordova-plugin-network-information/www/network.js b/platforms/android/assets/www/plugins/cordova-plugin-network-information/www/network.js new file mode 100644 index 0000000..770e6ba --- /dev/null +++ b/platforms/android/assets/www/plugins/cordova-plugin-network-information/www/network.js @@ -0,0 +1,94 @@ +cordova.define("cordova-plugin-network-information.network", function(require, exports, module) { +/* + * 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. + * +*/ + +var exec = require('cordova/exec'), + cordova = require('cordova'), + channel = require('cordova/channel'), + utils = require('cordova/utils'); + +// Link the onLine property with the Cordova-supplied network info. +// This works because we clobber the navigator object with our own +// object in bootstrap.js. +// Browser platform do not need to define this property, because +// it is already supported by modern browsers +if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') { + utils.defineGetter(navigator, 'onLine', function() { + return this.connection.type != 'none'; + }); +} + +function NetworkConnection() { + this.type = 'unknown'; +} + +/** + * Get connection info + * + * @param {Function} successCallback The function to call when the Connection data is available + * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL) + */ +NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []); +}; + +var me = new NetworkConnection(); +var timerId = null; +var timeout = 500; + +channel.createSticky('onCordovaConnectionReady'); +channel.waitForInitialization('onCordovaConnectionReady'); + +channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + me.type = info; + if (info === "none") { + // set a timer if still offline at the end of timer send the offline event + timerId = setTimeout(function(){ + cordova.fireDocumentEvent("offline"); + timerId = null; + }, timeout); + } else { + // If there is a current offline event pending clear it + if (timerId !== null) { + clearTimeout(timerId); + timerId = null; + } + cordova.fireDocumentEvent("online"); + } + + // should only fire this once + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + }, + function (e) { + // If we can't get the network info we should still tell Cordova + // to fire the deviceready event. + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + console.log("Error initializing Network Connection: " + e); + }); +}); + +module.exports = me; + +}); diff --git a/platforms/android/assets/www/screens/home.html b/platforms/android/assets/www/screens/home.html index ad6f529..0213329 100644 --- a/platforms/android/assets/www/screens/home.html +++ b/platforms/android/assets/www/screens/home.html @@ -1,57 +1,57 @@ -
-
- -

- Acquiring Location... -
-
-

-
-
-
- -
-

GPS location inaccurate. -
-
- Waiting for better accuracy...

-
- - - -
-

-
-
-
-
-

Energy

- -
- -
-
- Menu -
-
- -
-
-
-
-
-
-
- -
-
-
-
- +
+
+ +

+ Acquiring Location... +
+
+

+
+
+
+ +
+

GPS location inaccurate. +
+
+ Waiting for better accuracy...

+
+ + + +
+

+
+
+
+
+

Energy

+ +
+ +
+
+ Menu +
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/platforms/android/assets/www/screens/inventory.html b/platforms/android/assets/www/screens/inventory.html index d6694d0..262b022 100644 --- a/platforms/android/assets/www/screens/inventory.html +++ b/platforms/android/assets/www/screens/inventory.html @@ -1,3 +1,3 @@ -
- +
+
\ No newline at end of file diff --git a/platforms/android/assets/www/screens/login.html b/platforms/android/assets/www/screens/login.html index 3d75bd1..13a7a25 100644 --- a/platforms/android/assets/www/screens/login.html +++ b/platforms/android/assets/www/screens/login.html @@ -1,68 +1,69 @@ -
-
- -

- Logging in... -
-
-

-
-
-
-
-
-
-
- Login to TerranQuest -
-
- -
- - -
-
-
- - -
-
- -
-
-
- - \ No newline at end of file +
+
+ +

+ Logging in... +
+
+

+
+
+
+
+
+
+
+ Login to TerranQuest +
+
+ +
+ + +
+
+
+ + +
+
+ +
+
+
+ \ No newline at end of file diff --git a/platforms/android/assets/www/screens/menu.html b/platforms/android/assets/www/screens/menu.html index 90e71cf..dca5af9 100644 --- a/platforms/android/assets/www/screens/menu.html +++ b/platforms/android/assets/www/screens/menu.html @@ -1,24 +1,24 @@ -
- - - - - - - -
- \ No newline at end of file diff --git a/platforms/android/assets/www/screens/place.html b/platforms/android/assets/www/screens/place.html index 1bd2dd2..5c993a1 100644 --- a/platforms/android/assets/www/screens/place.html +++ b/platforms/android/assets/www/screens/place.html @@ -1,9 +1,9 @@ -
-
-
- - \ No newline at end of file diff --git a/platforms/android/assets/www/screens/profile.html b/platforms/android/assets/www/screens/profile.html index e13a063..b7e6a70 100644 --- a/platforms/android/assets/www/screens/profile.html +++ b/platforms/android/assets/www/screens/profile.html @@ -1,61 +1,61 @@ -
-
-

-
Badges
-
- Loading... -
-
- -
- +
+
+

+
Badges
+
+ Loading... +
+
+ +
+
\ No newline at end of file diff --git a/platforms/android/assets/www/screens/rules.html b/platforms/android/assets/www/screens/rules.html index 24d06ce..4ce35a7 100644 --- a/platforms/android/assets/www/screens/rules.html +++ b/platforms/android/assets/www/screens/rules.html @@ -1,20 +1,20 @@ -
-
Rules
-

Please read these rules. Because TerranQuest is a game involving other - people and the environment, it's important to show good etiquette.

-
    -
  1. Do not endanger yourself or others
  2. -
  3. Be considerate and polite in the in-game chat, and don't swear
  4. -
  5. Observe all local laws and rules
  6. -
  7. Respect property rights and obtain permission for playing on private land
  8. -
  9. Be nice to other people and try not to look too creepy
  10. -
  11. Respect and minimize your impact on the environment
  12. -
  13. Don't tamper with or deface any objects, landmarks, barcodes, or other real-world items
  14. -
  15. Pick up any trash you find and dispose of it properly if you can
  16. -
  17. Socialize with any players of other games, such as Geocaching and Ingress, you might meet
  18. -
  19. Follow the Netsyms Technologies Terms of Service at netsyms.com/legal
  20. - -
+
+
Rules
+

Please read these rules. Because TerranQuest is a game involving other + people and the environment, it's important to show good etiquette.

+
    +
  1. Do not endanger yourself or others
  2. +
  3. Be considerate and polite in the in-game chat, and don't swear
  4. +
  5. Observe all local laws and rules
  6. +
  7. Respect property rights and obtain permission for playing on private land
  8. +
  9. Be nice to other people and try not to look too creepy
  10. +
  11. Respect and minimize your impact on the environment
  12. +
  13. Don't tamper with or deface any objects, landmarks, barcodes, or other real-world items
  14. +
  15. Pick up any trash you find and dispose of it properly if you can
  16. +
  17. Socialize with any players of other games, such as Geocaching and Ingress, you might meet
  18. +
  19. Follow the Netsyms Technologies Terms of Service at netsyms.com/legal
  20. + +
\ No newline at end of file diff --git a/platforms/android/assets/www/screens/settings.html b/platforms/android/assets/www/screens/settings.html index b370c7d..c8d4efa 100644 --- a/platforms/android/assets/www/screens/settings.html +++ b/platforms/android/assets/www/screens/settings.html @@ -1,26 +1,26 @@ -
-
-
- Logout from app -
-
-

- Third-Party Licenses -
- Map tiles by Stamen Design (stamen.com), under CC BY 3.0 (creativecommons.org/licenses/by/3.0). -
- Map tile data by OpenStreetMap (openstreetmap.org), under CC BY-SA (creativecommons.org/licenses/by-sa/3.0). -
- Places from OpenStreetMap and contributers, licensed under the ODbL (opendatacommons.org/licenses/odbl). Email apis@netsyms.com for free access to our API. -
- Map display is powered by Leaflet (leafletjs.com), copyright (c) 2010-2016, Vladimir Agafonkin and copyright (c) 2010-2011, CloudMade. BSD 2-clause license. -
- Terrain information for the United States from the MRLC National Land Cover Database 2011 (mrlc.gov). -
- Weather data Powered by Forecast (forecast.io). -
- Geocache data from the OpenCaching.US OKAPI. Data licensed under the CC BY-NC-SA 2.5 (creativecommons.org/licenses/by-nc-sa/2.5). -

-
-
+
+
+
+ Logout from app +
+
+

+ Third-Party Licenses +
+ Map tiles by Stamen Design (stamen.com), under CC BY 3.0 (creativecommons.org/licenses/by/3.0). +
+ Map tile data by OpenStreetMap (openstreetmap.org), under CC BY-SA (creativecommons.org/licenses/by-sa/3.0). +
+ Places from OpenStreetMap and contributers, licensed under the ODbL (opendatacommons.org/licenses/odbl). Email apis@netsyms.com for free access to our API. +
+ Map display is powered by Leaflet (leafletjs.com), copyright (c) 2010-2016, Vladimir Agafonkin and copyright (c) 2010-2011, CloudMade. BSD 2-clause license. +
+ Terrain information for the United States from the MRLC National Land Cover Database 2011 (mrlc.gov). +
+ Weather data Powered by Forecast (forecast.io). +
+ Geocache data from the OpenCaching.US OKAPI. Data licensed under the CC BY-NC-SA 2.5 (creativecommons.org/licenses/by-nc-sa/2.5). +

+
+
\ No newline at end of file diff --git a/platforms/android/assets/www/screens/signup.html b/platforms/android/assets/www/screens/signup.html index 2202c42..950770b 100644 --- a/platforms/android/assets/www/screens/signup.html +++ b/platforms/android/assets/www/screens/signup.html @@ -1,45 +1,45 @@ -
-
-
-
- Create Netsyms Account -
-
- -
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-

By signing up, you agree to the Netsyms Technologies Terms of Service and Privacy Policy at netsyms.com/legal

-
- -
-
-
+
+
+
+
+ Create Netsyms Account +
+
+ +
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+

By signing up, you agree to the Netsyms Technologies Terms of Service and Privacy Policy at netsyms.com/legal

+
+ +
+
+
\ No newline at end of file diff --git a/platforms/android/assets/www/screens/splash.html b/platforms/android/assets/www/screens/splash.html index 1930201..b4d347e 100644 --- a/platforms/android/assets/www/screens/splash.html +++ b/platforms/android/assets/www/screens/splash.html @@ -1,9 +1,9 @@ -
- -

- Loading... -
-
-

-
+
+ +

+ Loading... +
+
+

+
\ No newline at end of file diff --git a/platforms/android/cordova/.jshintrc b/platforms/android/cordova/.jshintrc new file mode 100644 index 0000000..89a121c --- /dev/null +++ b/platforms/android/cordova/.jshintrc @@ -0,0 +1,10 @@ +{ + "node": true + , "bitwise": true + , "undef": true + , "trailing": true + , "quotmark": true + , "indent": 4 + , "unused": "vars" + , "latedef": "nofunc" +} diff --git a/platforms/android/cordova/Api.js b/platforms/android/cordova/Api.js index 7b7731f..ad6f71c 100644 --- a/platforms/android/cordova/Api.js +++ b/platforms/android/cordova/Api.js @@ -219,6 +219,11 @@ Api.prototype.addPlugin = function (plugin, installOptions) { .add_plugin_changes(plugin, installOptions.variables, /*is_top_level=*/true, /*should_increment=*/true) .save_all(); + if (plugin.getFrameworks(self.platform).length > 0) { + self.events.emit('verbose', 'Updating build files since android plugin contained '); + require('./lib/builders/builders').getBuilder('gradle').prepBuildFiles(); + } + var targetDir = installOptions.usePlatformWww ? self.locations.platformWww : self.locations.www; @@ -272,6 +277,11 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) { .remove_plugin_changes(plugin, /*is_top_level=*/true) .save_all(); + if (plugin.getFrameworks(self.platform).length > 0) { + self.events.emit('verbose', 'Updating build files since android plugin contained '); + require('./lib/builders/builders').getBuilder('gradle').prepBuildFiles(); + } + var targetDir = uninstallOptions.usePlatformWww ? self.locations.platformWww : self.locations.www; @@ -431,6 +441,11 @@ Api.prototype._addModulesInfo = function(plugin, targetDir) { }); this._platformJson.root.modules = installedModules.concat(modulesToInstall); + if (!this._platformJson.root.plugin_metadata) { + this._platformJson.root.plugin_metadata = {}; + } + this._platformJson.root.plugin_metadata[plugin.id] = plugin.version; + this._writePluginModules(targetDir); this._platformJson.save(); }; @@ -457,6 +472,10 @@ Api.prototype._removeModulesInfo = function(plugin, targetDir) { }); this._platformJson.root.modules = updatedModules; + if (this._platformJson.root.plugin_metadata) { + delete this._platformJson.root.plugin_metadata[plugin.id]; + } + this._writePluginModules(targetDir); this._platformJson.save(); }; @@ -470,20 +489,13 @@ Api.prototype._removeModulesInfo = function(plugin, targetDir) { * directories. */ Api.prototype._writePluginModules = function (targetDir) { - var self = this; // Write out moduleObjects as JSON wrapped in a cordova module to cordova_plugins.js var final_contents = 'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {\n'; final_contents += 'module.exports = ' + JSON.stringify(this._platformJson.root.modules, null, ' ') + ';\n'; final_contents += 'module.exports.metadata = \n'; final_contents += '// TOP OF METADATA\n'; - var pluginMetadata = Object.keys(this._platformJson.root.installed_plugins) - .reduce(function (metadata, plugin) { - metadata[plugin] = self._platformJson.root.installed_plugins[plugin].version; - return metadata; - }, {}); - - final_contents += JSON.stringify(pluginMetadata, null, 4) + '\n'; + final_contents += JSON.stringify(this._platformJson.root.plugin_metadata, null, 4) + ';\n'; final_contents += '// BOTTOM OF METADATA\n'; final_contents += '});'; // Close cordova.define. diff --git a/platforms/android/cordova/build b/platforms/android/cordova/build index da44783..de86a36 100644 --- a/platforms/android/cordova/build +++ b/platforms/android/cordova/build @@ -39,7 +39,7 @@ var buildOpts = nopt({ }, { 'd' : '--verbose' }); // Make buildOptions compatible with PlatformApi build method spec -buildOpts.argv = buildOpts.argv.remain; +buildOpts.argv = buildOpts.argv.original; new Api().build(buildOpts) .catch(function(err) { diff --git a/platforms/android/cordova/lib/build.js b/platforms/android/cordova/lib/build.js index 47aaa16..e1263ef 100644 --- a/platforms/android/cordova/lib/build.js +++ b/platforms/android/cordova/lib/build.js @@ -31,7 +31,7 @@ var events = require('cordova-common').events; var spawn = require('cordova-common').superspawn.spawn; var CordovaError = require('cordova-common').CordovaError; -function parseOpts(options, resolvedTarget) { +function parseOpts(options, resolvedTarget, projectRoot) { options = options || {}; options.argv = nopt({ gradle: Boolean, @@ -72,7 +72,7 @@ function parseOpts(options, resolvedTarget) { var packageArgs = {}; if (options.argv.keystore) - packageArgs.keystore = path.relative(this.root, path.resolve(options.argv.keystore)); + packageArgs.keystore = path.relative(projectRoot, path.resolve(options.argv.keystore)); ['alias','storePassword','password','keystoreType'].forEach(function (flagName) { if (options.argv[flagName]) @@ -126,7 +126,7 @@ function parseOpts(options, resolvedTarget) { * Returns a promise. */ module.exports.runClean = function(options) { - var opts = parseOpts(options); + var opts = parseOpts(options, null, this.root); var builder = builders.getBuilder(opts.buildMethod); return builder.prepEnv(opts) .then(function() { @@ -147,7 +147,7 @@ module.exports.runClean = function(options) { * information. */ module.exports.run = function(options, optResolvedTarget) { - var opts = parseOpts(options, optResolvedTarget); + var opts = parseOpts(options, optResolvedTarget, this.root); var builder = builders.getBuilder(opts.buildMethod); var self = this; return builder.prepEnv(opts) @@ -169,11 +169,6 @@ module.exports.run = function(options, optResolvedTarget) { }); }; -// Called by plugman after installing plugins, and by create script after creating project. -module.exports.prepBuildFiles = function() { - return builders.getBuilder('gradle').prepBuildFiles(); -}; - /* * Detects the architecture of a device/emulator * Returns "arm" or "x86". diff --git a/platforms/android/cordova/lib/builders/AntBuilder.js b/platforms/android/cordova/lib/builders/AntBuilder.js index d214f48..7094fe5 100644 --- a/platforms/android/cordova/lib/builders/AntBuilder.js +++ b/platforms/android/cordova/lib/builders/AntBuilder.js @@ -45,7 +45,7 @@ util.inherits(AntBuilder, GenericBuilder); AntBuilder.prototype.getArgs = function(cmd, opts) { var args = [cmd, '-f', path.join(this.root, 'build.xml')]; // custom_rules.xml is required for incremental builds. - if (hasCustomRules()) { + if (hasCustomRules(this.root)) { args.push('-Dout.dir=ant-build', '-Dgen.absolute.dir=ant-gen'); } if(opts.packageInfo) { @@ -99,7 +99,7 @@ AntBuilder.prototype.prepEnv = function(opts) { AntBuilder.prototype.build = function(opts) { // Without our custom_rules.xml, we need to clean before building. var ret = Q(); - if (!hasCustomRules()) { + if (!hasCustomRules(this.root)) { // clean will call check_ant() for us. ret = this.clean(opts); } diff --git a/platforms/android/cordova/lib/device.js b/platforms/android/cordova/lib/device.js index e62e3db..4f9acc8 100644 --- a/platforms/android/cordova/lib/device.js +++ b/platforms/android/cordova/lib/device.js @@ -89,12 +89,25 @@ module.exports.install = function(target, buildResults) { var pkgName = manifest.getPackageId(); var launchName = pkgName + '/.' + manifest.getActivity().getName(); events.emit('log', 'Using apk: ' + apk_path); - // This promise is always resolved, even if 'adb uninstall' fails to uninstall app - // or the app doesn't installed at all, so no error catching needed. - return Adb.uninstall(resolvedTarget.target, pkgName) + + return Adb.install(resolvedTarget.target, apk_path, {replace: true}) + .catch(function (error) { + // CB-9557 CB-10157 only uninstall and reinstall app if the one that + // is already installed on device was signed w/different certificate + if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString())) + throw error; + + events.emit('warn', 'Uninstalling app from device and reinstalling it again because the ' + + 'installed app already signed with different key'); + + // This promise is always resolved, even if 'adb uninstall' fails to uninstall app + // or the app doesn't installed at all, so no error catching needed. + return Adb.uninstall(resolvedTarget.target, pkgName) + .then(function() { + return Adb.install(resolvedTarget.target, apk_path, {replace: true}); + }); + }) .then(function() { - return Adb.install(resolvedTarget.target, apk_path, {replace: true}); - }).then(function() { //unlock screen return Adb.shell(resolvedTarget.target, 'input keyevent 82'); }).then(function() { diff --git a/platforms/android/cordova/lib/emulator.js b/platforms/android/cordova/lib/emulator.js index 9e214b1..96bb5c9 100644 --- a/platforms/android/cordova/lib/emulator.js +++ b/platforms/android/cordova/lib/emulator.js @@ -23,7 +23,6 @@ var retry = require('./retry'); var build = require('./build'); -var check_reqs = require('./check_reqs'); var path = require('path'); var Adb = require('./Adb'); var AndroidManifest = require('./AndroidManifest'); @@ -40,6 +39,7 @@ var ONE_SECOND = 1000; // in milliseconds var ONE_MINUTE = 60 * ONE_SECOND; // in milliseconds var INSTALL_COMMAND_TIMEOUT = 5 * ONE_MINUTE; // in milliseconds var NUM_INSTALL_RETRIES = 3; +var CHECK_BOOTED_INTERVAL = 3 * ONE_SECOND; // in milliseconds var EXEC_KILL_SIGNAL = 'SIGKILL'; /** @@ -104,7 +104,8 @@ module.exports.best_image = function() { var closest = 9999; var best = images[0]; - var project_target = check_reqs.get_target().replace('android-', ''); + // Loading check_reqs at run-time to avoid test-time vs run-time directory structure difference issue + var project_target = require('./check_reqs').get_target().replace('android-', ''); for (var i in images) { var target = images[i].target; if(target) { @@ -146,10 +147,12 @@ module.exports.list_targets = function() { * and returns the started ID of that emulator. * If no ID is given it will use the first image available, * if no image is available it will error out (maybe create one?). + * If no boot timeout is given or the value is negative it will wait forever for + * the emulator to boot * * Returns a promise. */ -module.exports.start = function(emulator_ID) { +module.exports.start = function(emulator_ID, boot_timeout) { var self = this; return Q().then(function() { @@ -162,7 +165,8 @@ module.exports.start = function(emulator_ID) { return best.name; } - var androidCmd = check_reqs.getAbsoluteAndroidCmd(); + // Loading check_reqs at run-time to avoid test-time vs run-time directory structure difference issue + var androidCmd = require('./check_reqs').getAbsoluteAndroidCmd(); return Q.reject(new CordovaError('No emulator images (avds) found.\n' + '1. Download desired System Image by running: ' + androidCmd + ' sdk\n' + '2. Create an AVD by running: ' + androidCmd + ' avd\n' + @@ -186,14 +190,20 @@ module.exports.start = function(emulator_ID) { //wait for emulator to boot up process.stdout.write('Booting up emulator (this may take a while)...'); - return self.wait_for_boot(emulatorId) - .then(function() { - events.emit('log','BOOT COMPLETE'); - //unlock screen - return Adb.shell(emulatorId, 'input keyevent 82'); - }).then(function() { - //return the new emulator id for the started emulators - return emulatorId; + return self.wait_for_boot(emulatorId, boot_timeout) + .then(function(success) { + if (success) { + events.emit('log','BOOT COMPLETE'); + //unlock screen + return Adb.shell(emulatorId, 'input keyevent 82') + .then(function() { + //return the new emulator id for the started emulators + return emulatorId; + }); + } else { + // We timed out waiting for the boot to happen + return null; + } }); }); }; @@ -227,18 +237,25 @@ module.exports.wait_for_emulator = function(uuid) { }; /* - * Waits for the core android process of the emulator to start + * Waits for the core android process of the emulator to start. Returns a + * promise that resolves to a boolean indicating success. Not specifying a + * time_remaining or passing a negative value will cause it to wait forever */ -module.exports.wait_for_boot = function(emulator_id) { +module.exports.wait_for_boot = function(emulator_id, time_remaining) { var self = this; return Adb.shell(emulator_id, 'ps') .then(function(output) { if (output.match(/android\.process\.acore/)) { - return; + return true; + } else if (time_remaining === 0) { + return false; } else { process.stdout.write('.'); - return Q.delay(3000).then(function() { - return self.wait_for_boot(emulator_id); + + // Check at regular intervals + return Q.delay(time_remaining < CHECK_BOOTED_INTERVAL ? time_remaining : CHECK_BOOTED_INTERVAL).then(function() { + var updated_time = time_remaining >= 0 ? Math.max(time_remaining - CHECK_BOOTED_INTERVAL, 0) : time_remaining; + return self.wait_for_boot(emulator_id, updated_time); }); } }); @@ -321,7 +338,7 @@ module.exports.install = function(givenTarget, buildResults) { }).then(function () { // This promise is always resolved, even if 'adb uninstall' fails to uninstall app // or the app doesn't installed at all, so no error catching needed. - return Adb.uninstall(target.target, pkgName) + return Q.when() .then(function() { var apk_path = build.findBestApkForArchitecture(buildResults, target.arch); @@ -334,28 +351,47 @@ module.exports.install = function(givenTarget, buildResults) { events.emit('log', 'Using apk: ' + apk_path); events.emit('verbose', 'Installing app on emulator...'); - function exec(command, opts) { + // A special function to call adb install in specific environment w/ specific options. + // Introduced as a part of fix for http://issues.apache.org/jira/browse/CB-9119 + // to workaround sporadic emulator hangs + function adbInstallWithOptions(target, apk, opts) { + events.emit('verbose', 'Installing apk ' + apk + ' on ' + target + '...'); + + var command = 'adb -s ' + target + ' install -r "' + apk + '"'; return Q.promise(function (resolve, reject) { child_process.exec(command, opts, function(err, stdout, stderr) { if (err) reject(new CordovaError('Error executing "' + command + '": ' + stderr)); + // adb does not return an error code even if installation fails. Instead it puts a specific + // message to stdout, so we have to use RegExp matching to detect installation failure. + else if (/Failure/.test(stdout)) reject(new CordovaError('Failed to install apk to emulator: ' + stdout)); else resolve(stdout); }); }); } - var retriedInstall = retry.retryPromise( - NUM_INSTALL_RETRIES, - exec, 'adb -s ' + target.target + ' install -r "' + apk_path + '"', execOptions - ); + function installPromise () { + return adbInstallWithOptions(target.target, apk_path, execOptions) + .catch(function (error) { + // CB-9557 CB-10157 only uninstall and reinstall app if the one that + // is already installed on device was signed w/different certificate + if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString())) + throw error; + + events.emit('warn', 'Uninstalling app from device and reinstalling it again because the ' + + 'installed app already signed with different key'); + + // This promise is always resolved, even if 'adb uninstall' fails to uninstall app + // or the app doesn't installed at all, so no error catching needed. + return Adb.uninstall(target.target, pkgName) + .then(function() { + return adbInstallWithOptions(target.target, apk_path, execOptions); + }); + }); + } - return retriedInstall.then(function (output) { - if (output.match(/Failure/)) { - return Q.reject(new CordovaError('Failed to install apk to emulator: ' + output)); - } else { - events.emit('log', 'INSTALL SUCCESS'); - } - }, function (err) { - return Q.reject(new CordovaError('Failed to install apk to emulator: ' + err)); + return retry.retryPromise(NUM_INSTALL_RETRIES, installPromise) + .then(function (output) { + events.emit('log', 'INSTALL SUCCESS'); }); }); // unlock screen diff --git a/platforms/android/cordova/lib/run.js b/platforms/android/cordova/lib/run.js index b001f47..3cc5c0d 100644 --- a/platforms/android/cordova/lib/run.js +++ b/platforms/android/cordova/lib/run.js @@ -27,6 +27,19 @@ var path = require('path'), device = require('./device'), Q = require('q'); +function getInstallTarget(runOptions) { + var install_target; + if (runOptions.target) { + install_target = runOptions.target; + } else if (runOptions.device) { + install_target = '--device'; + } else if (runOptions.emulator) { + install_target = '--emulator'; + } + + return install_target; +} + /** * Runs the application on a device if available. If no device is found, it will * use a started emulator. If no started emulators are found it will attempt @@ -40,10 +53,7 @@ var path = require('path'), module.exports.run = function(runOptions) { var self = this; - - var install_target = runOptions.device ? '--device' : - runOptions.emulator ? '--emulator' : - runOptions.target; + var install_target = getInstallTarget(runOptions); return Q() .then(function() { @@ -116,8 +126,8 @@ var path = require('path'), }); }; -module.exports.help = function(args) { - console.log('Usage: ' + path.relative(process.cwd(), args[1]) + ' [options]'); +module.exports.help = function() { + console.log('Usage: ' + path.relative(process.cwd(), process.argv[1]) + ' [options]'); console.log('Build options :'); console.log(' --debug : Builds project in debug mode'); console.log(' --release : Builds project in release mode'); diff --git a/platforms/android/cordova/node_modules/abbrev/.npmignore b/platforms/android/cordova/node_modules/abbrev/.npmignore new file mode 100644 index 0000000..9d6cd2f --- /dev/null +++ b/platforms/android/cordova/node_modules/abbrev/.npmignore @@ -0,0 +1,4 @@ +.nyc_output +nyc_output +node_modules +coverage diff --git a/platforms/android/cordova/node_modules/abbrev/.travis.yml b/platforms/android/cordova/node_modules/abbrev/.travis.yml new file mode 100644 index 0000000..991d04b --- /dev/null +++ b/platforms/android/cordova/node_modules/abbrev/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - '0.10' + - '0.12' + - 'iojs' diff --git a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md b/platforms/android/cordova/node_modules/abbrev/CONTRIBUTING.md similarity index 100% rename from platforms/android/cordova/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md rename to platforms/android/cordova/node_modules/abbrev/CONTRIBUTING.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/LICENSE b/platforms/android/cordova/node_modules/abbrev/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/LICENSE rename to platforms/android/cordova/node_modules/abbrev/LICENSE diff --git a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/README.md b/platforms/android/cordova/node_modules/abbrev/README.md similarity index 100% rename from platforms/android/cordova/node_modules/nopt/node_modules/abbrev/README.md rename to platforms/android/cordova/node_modules/abbrev/README.md diff --git a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/abbrev.js b/platforms/android/cordova/node_modules/abbrev/abbrev.js similarity index 100% rename from platforms/android/cordova/node_modules/nopt/node_modules/abbrev/abbrev.js rename to platforms/android/cordova/node_modules/abbrev/abbrev.js diff --git a/platforms/android/cordova/node_modules/abbrev/package.json b/platforms/android/cordova/node_modules/abbrev/package.json new file mode 100644 index 0000000..700d159 --- /dev/null +++ b/platforms/android/cordova/node_modules/abbrev/package.json @@ -0,0 +1,74 @@ +{ + "_args": [ + [ + "abbrev@1", + "/Users/steveng/repo/cordova/cordova-android/node_modules/nopt" + ] + ], + "_from": "abbrev@>=1.0.0 <2.0.0", + "_id": "abbrev@1.0.7", + "_inCache": true, + "_installable": true, + "_location": "/abbrev", + "_nodeVersion": "2.0.1", + "_npmUser": { + "email": "isaacs@npmjs.com", + "name": "isaacs" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "abbrev", + "raw": "abbrev@1", + "rawSpec": "1", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/nopt" + ], + "_resolved": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz", + "_shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", + "_shrinkwrap": null, + "_spec": "abbrev@1", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/nopt", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter" + }, + "bugs": { + "url": "https://github.com/isaacs/abbrev-js/issues" + }, + "dependencies": {}, + "description": "Like ruby's abbrev module, but in js", + "devDependencies": { + "tap": "^1.2.0" + }, + "directories": {}, + "dist": { + "shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", + "tarball": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz" + }, + "gitHead": "821d09ce7da33627f91bbd8ed631497ed6f760c2", + "homepage": "https://github.com/isaacs/abbrev-js#readme", + "license": "ISC", + "main": "abbrev.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "abbrev", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" + }, + "scripts": { + "test": "tap test.js --cov" + }, + "version": "1.0.7" +} diff --git a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/test.js b/platforms/android/cordova/node_modules/abbrev/test.js similarity index 100% rename from platforms/android/cordova/node_modules/nopt/node_modules/abbrev/test.js rename to platforms/android/cordova/node_modules/abbrev/test.js diff --git a/platforms/android/cordova/node_modules/ansi/.jshintrc b/platforms/android/cordova/node_modules/ansi/.jshintrc new file mode 100644 index 0000000..248c542 --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/.jshintrc @@ -0,0 +1,4 @@ +{ + "laxcomma": true, + "asi": true +} diff --git a/platforms/android/cordova/node_modules/ansi/.npmignore b/platforms/android/cordova/node_modules/ansi/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/platforms/android/cordova/node_modules/ansi/History.md b/platforms/android/cordova/node_modules/ansi/History.md new file mode 100644 index 0000000..aea8aaf --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/History.md @@ -0,0 +1,23 @@ + +0.3.1 / 2016-01-14 +================== + + * add MIT LICENSE file (#23, @kasicka) + * preserve chaining after redundant style-method calls (#19, @drewblaisdell) + * package: add "license" field (#16, @BenjaminTsai) + +0.3.0 / 2014-05-09 +================== + + * package: remove "test" script and "devDependencies" + * package: remove "engines" section + * pacakge: remove "bin" section + * package: beautify + * examples: remove `starwars` example (#15) + * Documented goto, horizontalAbsolute, and eraseLine methods in README.md (#12, @Jammerwoch) + * add `.jshintrc` file + +< 0.3.0 +======= + + * Prehistoric diff --git a/platforms/android/cordova/node_modules/ansi/LICENSE b/platforms/android/cordova/node_modules/ansi/LICENSE new file mode 100644 index 0000000..2ea4dc5 --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/LICENSE @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2012 Nathan Rajlich + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/platforms/android/cordova/node_modules/ansi/README.md b/platforms/android/cordova/node_modules/ansi/README.md new file mode 100644 index 0000000..6ce1940 --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/README.md @@ -0,0 +1,98 @@ +ansi.js +========= +### Advanced ANSI formatting tool for Node.js + +`ansi.js` is a module for Node.js that provides an easy-to-use API for +writing ANSI escape codes to `Stream` instances. ANSI escape codes are used to do +fancy things in a terminal window, like render text in colors, delete characters, +lines, the entire window, or hide and show the cursor, and lots more! + +#### Features: + + * 256 color support for the terminal! + * Make a beep sound from your terminal! + * Works with *any* writable `Stream` instance. + * Allows you to move the cursor anywhere on the terminal window. + * Allows you to delete existing contents from the terminal window. + * Allows you to hide and show the cursor. + * Converts CSS color codes and RGB values into ANSI escape codes. + * Low-level; you are in control of when escape codes are used, it's not abstracted. + + +Installation +------------ + +Install with `npm`: + +``` bash +$ npm install ansi +``` + + +Example +------- + +``` js +var ansi = require('ansi') + , cursor = ansi(process.stdout) + +// You can chain your calls forever: +cursor + .red() // Set font color to red + .bg.grey() // Set background color to grey + .write('Hello World!') // Write 'Hello World!' to stdout + .bg.reset() // Reset the bgcolor before writing the trailing \n, + // to avoid Terminal glitches + .write('\n') // And a final \n to wrap things up + +// Rendering modes are persistent: +cursor.hex('#660000').bold().underline() + +// You can use the regular logging functions, text will be green: +console.log('This is blood red, bold text') + +// To reset just the foreground color: +cursor.fg.reset() + +console.log('This will still be bold') + +// to go to a location (x,y) on the console +// note: 1-indexed, not 0-indexed: +cursor.goto(10, 5).write('Five down, ten over') + +// to clear the current line: +cursor.horizontalAbsolute(0).eraseLine().write('Starting again') + +// to go to a different column on the current line: +cursor.horizontalAbsolute(5).write('column five') + +// Clean up after yourself! +cursor.reset() +``` + + +License +------- + +(The MIT License) + +Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/platforms/android/cordova/node_modules/ansi/examples/beep/index.js b/platforms/android/cordova/node_modules/ansi/examples/beep/index.js new file mode 100644 index 0000000..c1ec929 --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/examples/beep/index.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +/** + * Invokes the terminal "beep" sound once per second on every exact second. + */ + +process.title = 'beep' + +var cursor = require('../../')(process.stdout) + +function beep () { + cursor.beep() + setTimeout(beep, 1000 - (new Date()).getMilliseconds()) +} + +setTimeout(beep, 1000 - (new Date()).getMilliseconds()) diff --git a/platforms/android/cordova/node_modules/ansi/examples/clear/index.js b/platforms/android/cordova/node_modules/ansi/examples/clear/index.js new file mode 100644 index 0000000..6ac21ff --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/examples/clear/index.js @@ -0,0 +1,15 @@ +#!/usr/bin/env node + +/** + * Like GNU ncurses "clear" command. + * https://github.com/mscdex/node-ncurses/blob/master/deps/ncurses/progs/clear.c + */ + +process.title = 'clear' + +function lf () { return '\n' } + +require('../../')(process.stdout) + .write(Array.apply(null, Array(process.stdout.getWindowSize()[1])).map(lf).join('')) + .eraseData(2) + .goto(1, 1) diff --git a/platforms/android/cordova/node_modules/ansi/examples/cursorPosition.js b/platforms/android/cordova/node_modules/ansi/examples/cursorPosition.js new file mode 100644 index 0000000..50f9644 --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/examples/cursorPosition.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +var tty = require('tty') +var cursor = require('../')(process.stdout) + +// listen for the queryPosition report on stdin +process.stdin.resume() +raw(true) + +process.stdin.once('data', function (b) { + var match = /\[(\d+)\;(\d+)R$/.exec(b.toString()) + if (match) { + var xy = match.slice(1, 3).reverse().map(Number) + console.error(xy) + } + + // cleanup and close stdin + raw(false) + process.stdin.pause() +}) + + +// send the query position request code to stdout +cursor.queryPosition() + +function raw (mode) { + if (process.stdin.setRawMode) { + process.stdin.setRawMode(mode) + } else { + tty.setRawMode(mode) + } +} diff --git a/platforms/android/cordova/node_modules/ansi/examples/progress/index.js b/platforms/android/cordova/node_modules/ansi/examples/progress/index.js new file mode 100644 index 0000000..d28dbda --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/examples/progress/index.js @@ -0,0 +1,87 @@ +#!/usr/bin/env node + +var assert = require('assert') + , ansi = require('../../') + +function Progress (stream, width) { + this.cursor = ansi(stream) + this.delta = this.cursor.newlines + this.width = width | 0 || 10 + this.open = '[' + this.close = ']' + this.complete = '█' + this.incomplete = '_' + + // initial render + this.progress = 0 +} + +Object.defineProperty(Progress.prototype, 'progress', { + get: get + , set: set + , configurable: true + , enumerable: true +}) + +function get () { + return this._progress +} + +function set (v) { + this._progress = Math.max(0, Math.min(v, 100)) + + var w = this.width - this.complete.length - this.incomplete.length + , n = w * (this._progress / 100) | 0 + , i = w - n + , com = c(this.complete, n) + , inc = c(this.incomplete, i) + , delta = this.cursor.newlines - this.delta + + assert.equal(com.length + inc.length, w) + + if (delta > 0) { + this.cursor.up(delta) + this.delta = this.cursor.newlines + } + + this.cursor + .horizontalAbsolute(0) + .eraseLine(2) + .fg.white() + .write(this.open) + .fg.grey() + .bold() + .write(com) + .resetBold() + .write(inc) + .fg.white() + .write(this.close) + .fg.reset() + .write('\n') +} + +function c (char, length) { + return Array.apply(null, Array(length)).map(function () { + return char + }).join('') +} + + + + +// Usage +var width = parseInt(process.argv[2], 10) || process.stdout.getWindowSize()[0] / 2 + , p = new Progress(process.stdout, width) + +;(function tick () { + p.progress += Math.random() * 5 + p.cursor + .eraseLine(2) + .write('Progress: ') + .bold().write(p.progress.toFixed(2)) + .write('%') + .resetBold() + .write('\n') + if (p.progress < 100) + setTimeout(tick, 100) +})() diff --git a/platforms/android/cordova/node_modules/ansi/lib/ansi.js b/platforms/android/cordova/node_modules/ansi/lib/ansi.js new file mode 100644 index 0000000..b1714e3 --- /dev/null +++ b/platforms/android/cordova/node_modules/ansi/lib/ansi.js @@ -0,0 +1,405 @@ + +/** + * References: + * + * - http://en.wikipedia.org/wiki/ANSI_escape_code + * - http://www.termsys.demon.co.uk/vtansi.htm + * + */ + +/** + * Module dependencies. + */ + +var emitNewlineEvents = require('./newlines') + , prefix = '\x1b[' // For all escape codes + , suffix = 'm' // Only for color codes + +/** + * The ANSI escape sequences. + */ + +var codes = { + up: 'A' + , down: 'B' + , forward: 'C' + , back: 'D' + , nextLine: 'E' + , previousLine: 'F' + , horizontalAbsolute: 'G' + , eraseData: 'J' + , eraseLine: 'K' + , scrollUp: 'S' + , scrollDown: 'T' + , savePosition: 's' + , restorePosition: 'u' + , queryPosition: '6n' + , hide: '?25l' + , show: '?25h' +} + +/** + * Rendering ANSI codes. + */ + +var styles = { + bold: 1 + , italic: 3 + , underline: 4 + , inverse: 7 +} + +/** + * The negating ANSI code for the rendering modes. + */ + +var reset = { + bold: 22 + , italic: 23 + , underline: 24 + , inverse: 27 +} + +/** + * The standard, styleable ANSI colors. + */ + +var colors = { + white: 37 + , black: 30 + , blue: 34 + , cyan: 36 + , green: 32 + , magenta: 35 + , red: 31 + , yellow: 33 + , grey: 90 + , brightBlack: 90 + , brightRed: 91 + , brightGreen: 92 + , brightYellow: 93 + , brightBlue: 94 + , brightMagenta: 95 + , brightCyan: 96 + , brightWhite: 97 +} + + +/** + * Creates a Cursor instance based off the given `writable stream` instance. + */ + +function ansi (stream, options) { + if (stream._ansicursor) { + return stream._ansicursor + } else { + return stream._ansicursor = new Cursor(stream, options) + } +} +module.exports = exports = ansi + +/** + * The `Cursor` class. + */ + +function Cursor (stream, options) { + if (!(this instanceof Cursor)) { + return new Cursor(stream, options) + } + if (typeof stream != 'object' || typeof stream.write != 'function') { + throw new Error('a valid Stream instance must be passed in') + } + + // the stream to use + this.stream = stream + + // when 'enabled' is false then all the functions are no-ops except for write() + this.enabled = options && options.enabled + if (typeof this.enabled === 'undefined') { + this.enabled = stream.isTTY + } + this.enabled = !!this.enabled + + // then `buffering` is true, then `write()` calls are buffered in + // memory until `flush()` is invoked + this.buffering = !!(options && options.buffering) + this._buffer = [] + + // controls the foreground and background colors + this.fg = this.foreground = new Colorer(this, 0) + this.bg = this.background = new Colorer(this, 10) + + // defaults + this.Bold = false + this.Italic = false + this.Underline = false + this.Inverse = false + + // keep track of the number of "newlines" that get encountered + this.newlines = 0 + emitNewlineEvents(stream) + stream.on('newline', function () { + this.newlines++ + }.bind(this)) +} +exports.Cursor = Cursor + +/** + * Helper function that calls `write()` on the underlying Stream. + * Returns `this` instead of the write() return value to keep + * the chaining going. + */ + +Cursor.prototype.write = function (data) { + if (this.buffering) { + this._buffer.push(arguments) + } else { + this.stream.write.apply(this.stream, arguments) + } + return this +} + +/** + * Buffer `write()` calls into memory. + * + * @api public + */ + +Cursor.prototype.buffer = function () { + this.buffering = true + return this +} + +/** + * Write out the in-memory buffer. + * + * @api public + */ + +Cursor.prototype.flush = function () { + this.buffering = false + var str = this._buffer.map(function (args) { + if (args.length != 1) throw new Error('unexpected args length! ' + args.length); + return args[0]; + }).join(''); + this._buffer.splice(0); // empty + this.write(str); + return this +} + + +/** + * The `Colorer` class manages both the background and foreground colors. + */ + +function Colorer (cursor, base) { + this.current = null + this.cursor = cursor + this.base = base +} +exports.Colorer = Colorer + +/** + * Write an ANSI color code, ensuring that the same code doesn't get rewritten. + */ + +Colorer.prototype._setColorCode = function setColorCode (code) { + var c = String(code) + if (this.current === c) return + this.cursor.enabled && this.cursor.write(prefix + c + suffix) + this.current = c + return this +} + + +/** + * Set up the positional ANSI codes. + */ + +Object.keys(codes).forEach(function (name) { + var code = String(codes[name]) + Cursor.prototype[name] = function () { + var c = code + if (arguments.length > 0) { + c = toArray(arguments).map(Math.round).join(';') + code + } + this.enabled && this.write(prefix + c) + return this + } +}) + +/** + * Set up the functions for the rendering ANSI codes. + */ + +Object.keys(styles).forEach(function (style) { + var name = style[0].toUpperCase() + style.substring(1) + , c = styles[style] + , r = reset[style] + + Cursor.prototype[style] = function () { + if (this[name]) return this + this.enabled && this.write(prefix + c + suffix) + this[name] = true + return this + } + + Cursor.prototype['reset' + name] = function () { + if (!this[name]) return this + this.enabled && this.write(prefix + r + suffix) + this[name] = false + return this + } +}) + +/** + * Setup the functions for the standard colors. + */ + +Object.keys(colors).forEach(function (color) { + var code = colors[color] + + Colorer.prototype[color] = function () { + this._setColorCode(this.base + code) + return this.cursor + } + + Cursor.prototype[color] = function () { + return this.foreground[color]() + } +}) + +/** + * Makes a beep sound! + */ + +Cursor.prototype.beep = function () { + this.enabled && this.write('\x07') + return this +} + +/** + * Moves cursor to specific position + */ + +Cursor.prototype.goto = function (x, y) { + x = x | 0 + y = y | 0 + this.enabled && this.write(prefix + y + ';' + x + 'H') + return this +} + +/** + * Resets the color. + */ + +Colorer.prototype.reset = function () { + this._setColorCode(this.base + 39) + return this.cursor +} + +/** + * Resets all ANSI formatting on the stream. + */ + +Cursor.prototype.reset = function () { + this.enabled && this.write(prefix + '0' + suffix) + this.Bold = false + this.Italic = false + this.Underline = false + this.Inverse = false + this.foreground.current = null + this.background.current = null + return this +} + +/** + * Sets the foreground color with the given RGB values. + * The closest match out of the 216 colors is picked. + */ + +Colorer.prototype.rgb = function (r, g, b) { + var base = this.base + 38 + , code = rgb(r, g, b) + this._setColorCode(base + ';5;' + code) + return this.cursor +} + +/** + * Same as `cursor.fg.rgb(r, g, b)`. + */ + +Cursor.prototype.rgb = function (r, g, b) { + return this.foreground.rgb(r, g, b) +} + +/** + * Accepts CSS color codes for use with ANSI escape codes. + * For example: `#FF000` would be bright red. + */ + +Colorer.prototype.hex = function (color) { + return this.rgb.apply(this, hex(color)) +} + +/** + * Same as `cursor.fg.hex(color)`. + */ + +Cursor.prototype.hex = function (color) { + return this.foreground.hex(color) +} + + +// UTIL FUNCTIONS // + +/** + * Translates a 255 RGB value to a 0-5 ANSI RGV value, + * then returns the single ANSI color code to use. + */ + +function rgb (r, g, b) { + var red = r / 255 * 5 + , green = g / 255 * 5 + , blue = b / 255 * 5 + return rgb5(red, green, blue) +} + +/** + * Turns rgb 0-5 values into a single ANSI color code to use. + */ + +function rgb5 (r, g, b) { + var red = Math.round(r) + , green = Math.round(g) + , blue = Math.round(b) + return 16 + (red*36) + (green*6) + blue +} + +/** + * Accepts a hex CSS color code string (# is optional) and + * translates it into an Array of 3 RGB 0-255 values, which + * can then be used with rgb(). + */ + +function hex (color) { + var c = color[0] === '#' ? color.substring(1) : color + , r = c.substring(0, 2) + , g = c.substring(2, 4) + , b = c.substring(4, 6) + return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)] +} + +/** + * Turns an array-like object into a real array. + */ + +function toArray (a) { + var i = 0 + , l = a.length + , rtn = [] + for (; i 0) { + var len = data.length + , i = 0 + // now try to calculate any deltas + if (typeof data == 'string') { + for (; i=0.3.1 <0.4.0", + "_id": "ansi@0.3.1", + "_inCache": true, + "_installable": true, + "_location": "/ansi", + "_nodeVersion": "5.3.0", + "_npmUser": { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "ansi", + "raw": "ansi@^0.3.1", + "rawSpec": "^0.3.1", + "scope": null, + "spec": ">=0.3.1 <0.4.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/ansi/-/ansi-0.3.1.tgz", + "_shasum": "0c42d4fb17160d5a9af1e484bace1c66922c1b21", + "_shrinkwrap": null, + "_spec": "ansi@^0.3.1", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "email": "nathan@tootallnate.net", + "name": "Nathan Rajlich", + "url": "http://tootallnate.net" + }, + "bugs": { + "url": "https://github.com/TooTallNate/ansi.js/issues" + }, + "dependencies": {}, + "description": "Advanced ANSI formatting tool for Node.js", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "0c42d4fb17160d5a9af1e484bace1c66922c1b21", + "tarball": "http://registry.npmjs.org/ansi/-/ansi-0.3.1.tgz" + }, + "gitHead": "4d0d4af94e0bdaa648bd7262acd3bde4b98d5246", + "homepage": "https://github.com/TooTallNate/ansi.js#readme", + "keywords": [ + "256", + "ansi", + "color", + "cursor", + "formatting", + "rgb", + "stream", + "terminal" + ], + "license": "MIT", + "main": "./lib/ansi.js", + "maintainers": [ + { + "name": "TooTallNate", + "email": "nathan@tootallnate.net" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "name": "ansi", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/ansi.js.git" + }, + "scripts": {}, + "version": "0.3.1" +} diff --git a/platforms/android/cordova/node_modules/balanced-match/.npmignore b/platforms/android/cordova/node_modules/balanced-match/.npmignore new file mode 100644 index 0000000..fd4f2b0 --- /dev/null +++ b/platforms/android/cordova/node_modules/balanced-match/.npmignore @@ -0,0 +1,2 @@ +node_modules +.DS_Store diff --git a/platforms/android/cordova/node_modules/balanced-match/.travis.yml b/platforms/android/cordova/node_modules/balanced-match/.travis.yml new file mode 100644 index 0000000..6e5919d --- /dev/null +++ b/platforms/android/cordova/node_modules/balanced-match/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.10" diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md b/platforms/android/cordova/node_modules/balanced-match/LICENSE.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md rename to platforms/android/cordova/node_modules/balanced-match/LICENSE.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile b/platforms/android/cordova/node_modules/balanced-match/Makefile similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile rename to platforms/android/cordova/node_modules/balanced-match/Makefile diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md b/platforms/android/cordova/node_modules/balanced-match/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md rename to platforms/android/cordova/node_modules/balanced-match/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js b/platforms/android/cordova/node_modules/balanced-match/example.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js rename to platforms/android/cordova/node_modules/balanced-match/example.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js b/platforms/android/cordova/node_modules/balanced-match/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js rename to platforms/android/cordova/node_modules/balanced-match/index.js diff --git a/platforms/android/cordova/node_modules/balanced-match/package.json b/platforms/android/cordova/node_modules/balanced-match/package.json new file mode 100644 index 0000000..044a171 --- /dev/null +++ b/platforms/android/cordova/node_modules/balanced-match/package.json @@ -0,0 +1,98 @@ +{ + "_args": [ + [ + "balanced-match@^0.3.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion" + ] + ], + "_from": "balanced-match@>=0.3.0 <0.4.0", + "_id": "balanced-match@0.3.0", + "_inCache": true, + "_installable": true, + "_location": "/balanced-match", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "julian@juliangruber.com", + "name": "juliangruber" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "balanced-match", + "raw": "balanced-match@^0.3.0", + "rawSpec": "^0.3.0", + "scope": null, + "spec": ">=0.3.0 <0.4.0", + "type": "range" + }, + "_requiredBy": [ + "/brace-expansion" + ], + "_resolved": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz", + "_shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", + "_shrinkwrap": null, + "_spec": "balanced-match@^0.3.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion", + "author": { + "email": "mail@juliangruber.com", + "name": "Julian Gruber", + "url": "http://juliangruber.com" + }, + "bugs": { + "url": "https://github.com/juliangruber/balanced-match/issues" + }, + "dependencies": {}, + "description": "Match balanced character pairs, like \"{\" and \"}\"", + "devDependencies": { + "tape": "~4.2.2" + }, + "directories": {}, + "dist": { + "shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", + "tarball": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz" + }, + "gitHead": "a7114b0986554787e90b7ac595a043ca75ea77e5", + "homepage": "https://github.com/juliangruber/balanced-match", + "keywords": [ + "balanced", + "match", + "parse", + "regexp", + "test" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + } + ], + "name": "balanced-match", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/balanced-match.git" + }, + "scripts": { + "test": "make test" + }, + "testling": { + "browsers": [ + "android-browser/4.2..latest", + "chrome/25..latest", + "chrome/canary", + "firefox/20..latest", + "firefox/nightly", + "ie/8..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "opera/12..latest", + "opera/next", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "version": "0.3.0" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js b/platforms/android/cordova/node_modules/balanced-match/test/balanced.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js rename to platforms/android/cordova/node_modules/balanced-match/test/balanced.js diff --git a/platforms/android/cordova/node_modules/base64-js/.travis.yml b/platforms/android/cordova/node_modules/base64-js/.travis.yml new file mode 100644 index 0000000..939cb51 --- /dev/null +++ b/platforms/android/cordova/node_modules/base64-js/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.11" \ No newline at end of file diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/LICENSE.MIT b/platforms/android/cordova/node_modules/base64-js/LICENSE.MIT similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/LICENSE.MIT rename to platforms/android/cordova/node_modules/base64-js/LICENSE.MIT diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/README.md b/platforms/android/cordova/node_modules/base64-js/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/README.md rename to platforms/android/cordova/node_modules/base64-js/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/bench/bench.js b/platforms/android/cordova/node_modules/base64-js/bench/bench.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/bench/bench.js rename to platforms/android/cordova/node_modules/base64-js/bench/bench.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/lib/b64.js b/platforms/android/cordova/node_modules/base64-js/lib/b64.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/lib/b64.js rename to platforms/android/cordova/node_modules/base64-js/lib/b64.js diff --git a/platforms/android/cordova/node_modules/base64-js/package.json b/platforms/android/cordova/node_modules/base64-js/package.json new file mode 100644 index 0000000..4b30e7d --- /dev/null +++ b/platforms/android/cordova/node_modules/base64-js/package.json @@ -0,0 +1,93 @@ +{ + "_args": [ + [ + "base64-js@0.0.8", + "/Users/steveng/repo/cordova/cordova-android/node_modules/plist" + ] + ], + "_from": "base64-js@0.0.8", + "_id": "base64-js@0.0.8", + "_inCache": true, + "_installable": true, + "_location": "/base64-js", + "_nodeVersion": "0.10.35", + "_npmUser": { + "email": "feross@feross.org", + "name": "feross" + }, + "_npmVersion": "2.1.16", + "_phantomChildren": {}, + "_requested": { + "name": "base64-js", + "raw": "base64-js@0.0.8", + "rawSpec": "0.0.8", + "scope": null, + "spec": "0.0.8", + "type": "version" + }, + "_requiredBy": [ + "/plist" + ], + "_resolved": "http://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", + "_shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978", + "_shrinkwrap": null, + "_spec": "base64-js@0.0.8", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/plist", + "author": { + "email": "t.jameson.little@gmail.com", + "name": "T. Jameson Little" + }, + "bugs": { + "url": "https://github.com/beatgammit/base64-js/issues" + }, + "dependencies": {}, + "description": "Base64 encoding/decoding in pure JS", + "devDependencies": { + "tape": "~2.3.2" + }, + "directories": {}, + "dist": { + "shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978", + "tarball": "http://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz" + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "b4a8a5fa9b0caeddb5ad94dd1108253d8f2a315f", + "homepage": "https://github.com/beatgammit/base64-js", + "license": "MIT", + "main": "lib/b64.js", + "maintainers": [ + { + "name": "beatgammit", + "email": "t.jameson.little@gmail.com" + }, + { + "name": "feross", + "email": "feross@feross.org" + } + ], + "name": "base64-js", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/beatgammit/base64-js.git" + }, + "scripts": { + "test": "tape test/*.js" + }, + "testling": { + "browsers": [ + "chrome/4..latest", + "firefox/3..latest", + "ie/6..latest", + "ipad/6", + "iphone/6", + "opera/11.0..latest", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "version": "0.0.8" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/test/convert.js b/platforms/android/cordova/node_modules/base64-js/test/convert.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/test/convert.js rename to platforms/android/cordova/node_modules/base64-js/test/convert.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/test/url-safe.js b/platforms/android/cordova/node_modules/base64-js/test/url-safe.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/test/url-safe.js rename to platforms/android/cordova/node_modules/base64-js/test/url-safe.js diff --git a/platforms/android/cordova/node_modules/big-integer/BigInteger.js b/platforms/android/cordova/node_modules/big-integer/BigInteger.js new file mode 100644 index 0000000..8c06143 --- /dev/null +++ b/platforms/android/cordova/node_modules/big-integer/BigInteger.js @@ -0,0 +1,1189 @@ +var bigInt = (function (undefined) { + "use strict"; + + var BASE = 1e7, + LOG_BASE = 7, + MAX_INT = 9007199254740992, + MAX_INT_ARR = smallToArray(MAX_INT), + LOG_MAX_INT = Math.log(MAX_INT); + + function BigInteger(value, sign) { + this.value = value; + this.sign = sign; + this.isSmall = false; + } + + function SmallInteger(value) { + this.value = value; + this.sign = value < 0; + this.isSmall = true; + } + + function isPrecise(n) { + return -MAX_INT < n && n < MAX_INT; + } + + function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes + if (n < 1e7) + return [n]; + if (n < 1e14) + return [n % 1e7, Math.floor(n / 1e7)]; + return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)]; + } + + function arrayToSmall(arr) { // If BASE changes this function may need to change + trim(arr); + var length = arr.length; + if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) { + switch (length) { + case 0: return 0; + case 1: return arr[0]; + case 2: return arr[0] + arr[1] * BASE; + default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE; + } + } + return arr; + } + + function trim(v) { + var i = v.length; + while (v[--i] === 0); + v.length = i + 1; + } + + function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger + var x = new Array(length); + var i = -1; + while (++i < length) { + x[i] = 0; + } + return x; + } + + function truncate(n) { + if (n > 0) return Math.floor(n); + return Math.ceil(n); + } + + function add(a, b) { // assumes a and b are arrays with a.length >= b.length + var l_a = a.length, + l_b = b.length, + r = new Array(l_a), + carry = 0, + base = BASE, + sum, i; + for (i = 0; i < l_b; i++) { + sum = a[i] + b[i] + carry; + carry = sum >= base ? 1 : 0; + r[i] = sum - carry * base; + } + while (i < l_a) { + sum = a[i] + carry; + carry = sum === base ? 1 : 0; + r[i++] = sum - carry * base; + } + if (carry > 0) r.push(carry); + return r; + } + + function addAny(a, b) { + if (a.length >= b.length) return add(a, b); + return add(b, a); + } + + function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT + var l = a.length, + r = new Array(l), + base = BASE, + sum, i; + for (i = 0; i < l; i++) { + sum = a[i] - base + carry; + carry = Math.floor(sum / base); + r[i] = sum - carry * base; + carry += 1; + } + while (carry > 0) { + r[i++] = carry % base; + carry = Math.floor(carry / base); + } + return r; + } + + BigInteger.prototype.add = function (v) { + var value, n = parseValue(v); + if (this.sign !== n.sign) { + return this.subtract(n.negate()); + } + var a = this.value, b = n.value; + if (n.isSmall) { + return new BigInteger(addSmall(a, Math.abs(b)), this.sign); + } + return new BigInteger(addAny(a, b), this.sign); + }; + BigInteger.prototype.plus = BigInteger.prototype.add; + + SmallInteger.prototype.add = function (v) { + var n = parseValue(v); + var a = this.value; + if (a < 0 !== n.sign) { + return this.subtract(n.negate()); + } + var b = n.value; + if (n.isSmall) { + if (isPrecise(a + b)) return new SmallInteger(a + b); + b = smallToArray(Math.abs(b)); + } + return new BigInteger(addSmall(b, Math.abs(a)), a < 0); + }; + SmallInteger.prototype.plus = SmallInteger.prototype.add; + + function subtract(a, b) { // assumes a and b are arrays with a >= b + var a_l = a.length, + b_l = b.length, + r = new Array(a_l), + borrow = 0, + base = BASE, + i, difference; + for (i = 0; i < b_l; i++) { + difference = a[i] - borrow - b[i]; + if (difference < 0) { + difference += base; + borrow = 1; + } else borrow = 0; + r[i] = difference; + } + for (i = b_l; i < a_l; i++) { + difference = a[i] - borrow; + if (difference < 0) difference += base; + else { + r[i++] = difference; + break; + } + r[i] = difference; + } + for (; i < a_l; i++) { + r[i] = a[i]; + } + trim(r); + return r; + } + + function subtractAny(a, b, sign) { + var value, isSmall; + if (compareAbs(a, b) >= 0) { + value = subtract(a,b); + } else { + value = subtract(b, a); + sign = !sign; + } + value = arrayToSmall(value); + if (typeof value === "number") { + if (sign) value = -value; + return new SmallInteger(value); + } + return new BigInteger(value, sign); + } + + function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT + var l = a.length, + r = new Array(l), + carry = -b, + base = BASE, + i, difference; + for (i = 0; i < l; i++) { + difference = a[i] + carry; + carry = Math.floor(difference / base); + difference %= base; + r[i] = difference < 0 ? difference + base : difference; + } + r = arrayToSmall(r); + if (typeof r === "number") { + if (sign) r = -r; + return new SmallInteger(r); + } return new BigInteger(r, sign); + } + + BigInteger.prototype.subtract = function (v) { + var n = parseValue(v); + if (this.sign !== n.sign) { + return this.add(n.negate()); + } + var a = this.value, b = n.value; + if (n.isSmall) + return subtractSmall(a, Math.abs(b), this.sign); + return subtractAny(a, b, this.sign); + }; + BigInteger.prototype.minus = BigInteger.prototype.subtract; + + SmallInteger.prototype.subtract = function (v) { + var n = parseValue(v); + var a = this.value; + if (a < 0 !== n.sign) { + return this.add(n.negate()); + } + var b = n.value; + if (n.isSmall) { + return new SmallInteger(a - b); + } + return subtractSmall(b, Math.abs(a), a >= 0); + }; + SmallInteger.prototype.minus = SmallInteger.prototype.subtract; + + BigInteger.prototype.negate = function () { + return new BigInteger(this.value, !this.sign); + }; + SmallInteger.prototype.negate = function () { + var sign = this.sign; + var small = new SmallInteger(-this.value); + small.sign = !sign; + return small; + }; + + BigInteger.prototype.abs = function () { + return new BigInteger(this.value, false); + }; + SmallInteger.prototype.abs = function () { + return new SmallInteger(Math.abs(this.value)); + }; + + function multiplyLong(a, b) { + var a_l = a.length, + b_l = b.length, + l = a_l + b_l, + r = createArray(l), + base = BASE, + product, carry, i, a_i, b_j; + for (i = 0; i < a_l; ++i) { + a_i = a[i]; + for (var j = 0; j < b_l; ++j) { + b_j = b[j]; + product = a_i * b_j + r[i + j]; + carry = Math.floor(product / base); + r[i + j] = product - carry * base; + r[i + j + 1] += carry; + } + } + trim(r); + return r; + } + + function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE + var l = a.length, + r = new Array(l), + base = BASE, + carry = 0, + product, i; + for (i = 0; i < l; i++) { + product = a[i] * b + carry; + carry = Math.floor(product / base); + r[i] = product - carry * base; + } + while (carry > 0) { + r[i++] = carry % base; + carry = Math.floor(carry / base); + } + return r; + } + + function shiftLeft(x, n) { + var r = []; + while (n-- > 0) r.push(0); + return r.concat(x); + } + + function multiplyKaratsuba(x, y) { + var n = Math.max(x.length, y.length); + + if (n <= 30) return multiplyLong(x, y); + n = Math.ceil(n / 2); + + var b = x.slice(n), + a = x.slice(0, n), + d = y.slice(n), + c = y.slice(0, n); + + var ac = multiplyKaratsuba(a, c), + bd = multiplyKaratsuba(b, d), + abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d)); + + var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n)); + trim(product); + return product; + } + + // The following function is derived from a surface fit of a graph plotting the performance difference + // between long multiplication and karatsuba multiplication versus the lengths of the two arrays. + function useKaratsuba(l1, l2) { + return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0; + } + + BigInteger.prototype.multiply = function (v) { + var value, n = parseValue(v), + a = this.value, b = n.value, + sign = this.sign !== n.sign, + abs; + if (n.isSmall) { + if (b === 0) return CACHE[0]; + if (b === 1) return this; + if (b === -1) return this.negate(); + abs = Math.abs(b); + if (abs < BASE) { + return new BigInteger(multiplySmall(a, abs), sign); + } + b = smallToArray(abs); + } + if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes + return new BigInteger(multiplyKaratsuba(a, b), sign); + return new BigInteger(multiplyLong(a, b), sign); + }; + + BigInteger.prototype.times = BigInteger.prototype.multiply; + + function multiplySmallAndArray(a, b, sign) { // a >= 0 + if (a < BASE) { + return new BigInteger(multiplySmall(b, a), sign); + } + return new BigInteger(multiplyLong(b, smallToArray(a)), sign); + } + SmallInteger.prototype["_multiplyBySmall"] = function (a) { + if (isPrecise(a.value * this.value)) { + return new SmallInteger(a.value * this.value); + } + return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign); + }; + BigInteger.prototype["_multiplyBySmall"] = function (a) { + if (a.value === 0) return CACHE[0]; + if (a.value === 1) return this; + if (a.value === -1) return this.negate(); + return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign); + }; + SmallInteger.prototype.multiply = function (v) { + return parseValue(v)["_multiplyBySmall"](this); + }; + SmallInteger.prototype.times = SmallInteger.prototype.multiply; + + function square(a) { + var l = a.length, + r = createArray(l + l), + base = BASE, + product, carry, i, a_i, a_j; + for (i = 0; i < l; i++) { + a_i = a[i]; + for (var j = 0; j < l; j++) { + a_j = a[j]; + product = a_i * a_j + r[i + j]; + carry = Math.floor(product / base); + r[i + j] = product - carry * base; + r[i + j + 1] += carry; + } + } + trim(r); + return r; + } + + BigInteger.prototype.square = function () { + return new BigInteger(square(this.value), false); + }; + + SmallInteger.prototype.square = function () { + var value = this.value * this.value; + if (isPrecise(value)) return new SmallInteger(value); + return new BigInteger(square(smallToArray(Math.abs(this.value))), false); + }; + + function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes. + var a_l = a.length, + b_l = b.length, + base = BASE, + result = createArray(b.length), + divisorMostSignificantDigit = b[b_l - 1], + // normalization + lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)), + remainder = multiplySmall(a, lambda), + divisor = multiplySmall(b, lambda), + quotientDigit, shift, carry, borrow, i, l, q; + if (remainder.length <= a_l) remainder.push(0); + divisor.push(0); + divisorMostSignificantDigit = divisor[b_l - 1]; + for (shift = a_l - b_l; shift >= 0; shift--) { + quotientDigit = base - 1; + if (remainder[shift + b_l] !== divisorMostSignificantDigit) { + quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit); + } + // quotientDigit <= base - 1 + carry = 0; + borrow = 0; + l = divisor.length; + for (i = 0; i < l; i++) { + carry += quotientDigit * divisor[i]; + q = Math.floor(carry / base); + borrow += remainder[shift + i] - (carry - q * base); + carry = q; + if (borrow < 0) { + remainder[shift + i] = borrow + base; + borrow = -1; + } else { + remainder[shift + i] = borrow; + borrow = 0; + } + } + while (borrow !== 0) { + quotientDigit -= 1; + carry = 0; + for (i = 0; i < l; i++) { + carry += remainder[shift + i] - base + divisor[i]; + if (carry < 0) { + remainder[shift + i] = carry + base; + carry = 0; + } else { + remainder[shift + i] = carry; + carry = 1; + } + } + borrow += carry; + } + result[shift] = quotientDigit; + } + // denormalization + remainder = divModSmall(remainder, lambda)[0]; + return [arrayToSmall(result), arrayToSmall(remainder)]; + } + + function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/ + // Performs faster than divMod1 on larger input sizes. + var a_l = a.length, + b_l = b.length, + result = [], + part = [], + base = BASE, + guess, xlen, highx, highy, check; + while (a_l) { + part.unshift(a[--a_l]); + if (compareAbs(part, b) < 0) { + result.push(0); + continue; + } + xlen = part.length; + highx = part[xlen - 1] * base + part[xlen - 2]; + highy = b[b_l - 1] * base + b[b_l - 2]; + if (xlen > b_l) { + highx = (highx + 1) * base; + } + guess = Math.ceil(highx / highy); + do { + check = multiplySmall(b, guess); + if (compareAbs(check, part) <= 0) break; + guess--; + } while (guess); + result.push(guess); + part = subtract(part, check); + } + result.reverse(); + return [arrayToSmall(result), arrayToSmall(part)]; + } + + function divModSmall(value, lambda) { + var length = value.length, + quotient = createArray(length), + base = BASE, + i, q, remainder, divisor; + remainder = 0; + for (i = length - 1; i >= 0; --i) { + divisor = remainder * base + value[i]; + q = truncate(divisor / lambda); + remainder = divisor - q * lambda; + quotient[i] = q | 0; + } + return [quotient, remainder | 0]; + } + + function divModAny(self, v) { + var value, n = parseValue(v); + var a = self.value, b = n.value; + var quotient; + if (b === 0) throw new Error("Cannot divide by zero"); + if (self.isSmall) { + if (n.isSmall) { + return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)]; + } + return [CACHE[0], self]; + } + if (n.isSmall) { + if (b === 1) return [self, CACHE[0]]; + if (b == -1) return [self.negate(), CACHE[0]]; + var abs = Math.abs(b); + if (abs < BASE) { + value = divModSmall(a, abs); + quotient = arrayToSmall(value[0]); + var remainder = value[1]; + if (self.sign) remainder = -remainder; + if (typeof quotient === "number") { + if (self.sign !== n.sign) quotient = -quotient; + return [new SmallInteger(quotient), new SmallInteger(remainder)]; + } + return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)]; + } + b = smallToArray(abs); + } + var comparison = compareAbs(a, b); + if (comparison === -1) return [CACHE[0], self]; + if (comparison === 0) return [CACHE[self.sign === n.sign ? 1 : -1], CACHE[0]]; + + // divMod1 is faster on smaller input sizes + if (a.length + b.length <= 200) + value = divMod1(a, b); + else value = divMod2(a, b); + + quotient = value[0]; + var qSign = self.sign !== n.sign, + mod = value[1], + mSign = self.sign; + if (typeof quotient === "number") { + if (qSign) quotient = -quotient; + quotient = new SmallInteger(quotient); + } else quotient = new BigInteger(quotient, qSign); + if (typeof mod === "number") { + if (mSign) mod = -mod; + mod = new SmallInteger(mod); + } else mod = new BigInteger(mod, mSign); + return [quotient, mod]; + } + + BigInteger.prototype.divmod = function (v) { + var result = divModAny(this, v); + return { + quotient: result[0], + remainder: result[1] + }; + }; + SmallInteger.prototype.divmod = BigInteger.prototype.divmod; + + BigInteger.prototype.divide = function (v) { + return divModAny(this, v)[0]; + }; + SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide; + + BigInteger.prototype.mod = function (v) { + return divModAny(this, v)[1]; + }; + SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod; + + BigInteger.prototype.pow = function (v) { + var n = parseValue(v), + a = this.value, + b = n.value, + value, x, y; + if (b === 0) return CACHE[1]; + if (a === 0) return CACHE[0]; + if (a === 1) return CACHE[1]; + if (a === -1) return n.isEven() ? CACHE[1] : CACHE[-1]; + if (n.sign) { + return CACHE[0]; + } + if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large."); + if (this.isSmall) { + if (isPrecise(value = Math.pow(a, b))) + return new SmallInteger(truncate(value)); + } + x = this; + y = CACHE[1]; + while (true) { + if (b & 1 === 1) { + y = y.times(x); + --b; + } + if (b === 0) break; + b /= 2; + x = x.square(); + } + return y; + }; + SmallInteger.prototype.pow = BigInteger.prototype.pow; + + BigInteger.prototype.modPow = function (exp, mod) { + exp = parseValue(exp); + mod = parseValue(mod); + if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0"); + var r = CACHE[1], + base = this.mod(mod); + while (exp.isPositive()) { + if (base.isZero()) return CACHE[0]; + if (exp.isOdd()) r = r.multiply(base).mod(mod); + exp = exp.divide(2); + base = base.square().mod(mod); + } + return r; + }; + SmallInteger.prototype.modPow = BigInteger.prototype.modPow; + + function compareAbs(a, b) { + if (a.length !== b.length) { + return a.length > b.length ? 1 : -1; + } + for (var i = a.length - 1; i >= 0; i--) { + if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1; + } + return 0; + } + + BigInteger.prototype.compareAbs = function (v) { + var n = parseValue(v), + a = this.value, + b = n.value; + if (n.isSmall) return 1; + return compareAbs(a, b); + }; + SmallInteger.prototype.compareAbs = function (v) { + var n = parseValue(v), + a = Math.abs(this.value), + b = n.value; + if (n.isSmall) { + b = Math.abs(b); + return a === b ? 0 : a > b ? 1 : -1; + } + return -1; + }; + + BigInteger.prototype.compare = function (v) { + // See discussion about comparison with Infinity: + // https://github.com/peterolson/BigInteger.js/issues/61 + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + + var n = parseValue(v), + a = this.value, + b = n.value; + if (this.sign !== n.sign) { + return n.sign ? 1 : -1; + } + if (n.isSmall) { + return this.sign ? -1 : 1; + } + return compareAbs(a, b) * (this.sign ? -1 : 1); + }; + BigInteger.prototype.compareTo = BigInteger.prototype.compare; + + SmallInteger.prototype.compare = function (v) { + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + + var n = parseValue(v), + a = this.value, + b = n.value; + if (n.isSmall) { + return a == b ? 0 : a > b ? 1 : -1; + } + if (a < 0 !== n.sign) { + return a < 0 ? -1 : 1; + } + return a < 0 ? 1 : -1; + }; + SmallInteger.prototype.compareTo = SmallInteger.prototype.compare; + + BigInteger.prototype.equals = function (v) { + return this.compare(v) === 0; + }; + SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals; + + BigInteger.prototype.notEquals = function (v) { + return this.compare(v) !== 0; + }; + SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals; + + BigInteger.prototype.greater = function (v) { + return this.compare(v) > 0; + }; + SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater; + + BigInteger.prototype.lesser = function (v) { + return this.compare(v) < 0; + }; + SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser; + + BigInteger.prototype.greaterOrEquals = function (v) { + return this.compare(v) >= 0; + }; + SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals; + + BigInteger.prototype.lesserOrEquals = function (v) { + return this.compare(v) <= 0; + }; + SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals; + + BigInteger.prototype.isEven = function () { + return (this.value[0] & 1) === 0; + }; + SmallInteger.prototype.isEven = function () { + return (this.value & 1) === 0; + }; + + BigInteger.prototype.isOdd = function () { + return (this.value[0] & 1) === 1; + }; + SmallInteger.prototype.isOdd = function () { + return (this.value & 1) === 1; + }; + + BigInteger.prototype.isPositive = function () { + return !this.sign; + }; + SmallInteger.prototype.isPositive = function () { + return this.value > 0; + }; + + BigInteger.prototype.isNegative = function () { + return this.sign; + }; + SmallInteger.prototype.isNegative = function () { + return this.value < 0; + }; + + BigInteger.prototype.isUnit = function () { + return false; + }; + SmallInteger.prototype.isUnit = function () { + return Math.abs(this.value) === 1; + }; + + BigInteger.prototype.isZero = function () { + return false; + }; + SmallInteger.prototype.isZero = function () { + return this.value === 0; + }; + BigInteger.prototype.isDivisibleBy = function (v) { + var n = parseValue(v); + var value = n.value; + if (value === 0) return false; + if (value === 1) return true; + if (value === 2) return this.isEven(); + return this.mod(n).equals(CACHE[0]); + }; + SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy; + + function isBasicPrime(v) { + var n = v.abs(); + if (n.isUnit()) return false; + if (n.equals(2) || n.equals(3) || n.equals(5)) return true; + if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false; + if (n.lesser(25)) return true; + // we don't know if it's prime: let the other functions figure it out + }; + + BigInteger.prototype.isPrime = function () { + var isPrime = isBasicPrime(this); + if (isPrime !== undefined) return isPrime; + var n = this.abs(), + nPrev = n.prev(); + var a = [2, 3, 5, 7, 11, 13, 17, 19], + b = nPrev, + d, t, i, x; + while (b.isEven()) b = b.divide(2); + for (i = 0; i < a.length; i++) { + x = bigInt(a[i]).modPow(b, n); + if (x.equals(CACHE[1]) || x.equals(nPrev)) continue; + for (t = true, d = b; t && d.lesser(nPrev) ; d = d.multiply(2)) { + x = x.square().mod(n); + if (x.equals(nPrev)) t = false; + } + if (t) return false; + } + return true; + }; + SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime; + + BigInteger.prototype.isProbablePrime = function (iterations) { + var isPrime = isBasicPrime(this); + if (isPrime !== undefined) return isPrime; + var n = this.abs(); + var t = iterations === undefined ? 5 : iterations; + // use the Fermat primality test + for (var i = 0; i < t; i++) { + var a = bigInt.randBetween(2, n.minus(2)); + if (!a.modPow(n.prev(), n).isUnit()) return false; // definitely composite + } + return true; // large chance of being prime + }; + SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime; + + BigInteger.prototype.next = function () { + var value = this.value; + if (this.sign) { + return subtractSmall(value, 1, this.sign); + } + return new BigInteger(addSmall(value, 1), this.sign); + }; + SmallInteger.prototype.next = function () { + var value = this.value; + if (value + 1 < MAX_INT) return new SmallInteger(value + 1); + return new BigInteger(MAX_INT_ARR, false); + }; + + BigInteger.prototype.prev = function () { + var value = this.value; + if (this.sign) { + return new BigInteger(addSmall(value, 1), true); + } + return subtractSmall(value, 1, this.sign); + }; + SmallInteger.prototype.prev = function () { + var value = this.value; + if (value - 1 > -MAX_INT) return new SmallInteger(value - 1); + return new BigInteger(MAX_INT_ARR, true); + }; + + var powersOfTwo = [1]; + while (powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]); + var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1]; + + function shift_isSmall(n) { + return ((typeof n === "number" || typeof n === "string") && +Math.abs(n) <= BASE) || + (n instanceof BigInteger && n.value.length <= 1); + } + + BigInteger.prototype.shiftLeft = function (n) { + if (!shift_isSmall(n)) { + throw new Error(String(n) + " is too large for shifting."); + } + n = +n; + if (n < 0) return this.shiftRight(-n); + var result = this; + while (n >= powers2Length) { + result = result.multiply(highestPower2); + n -= powers2Length - 1; + } + return result.multiply(powersOfTwo[n]); + }; + SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft; + + BigInteger.prototype.shiftRight = function (n) { + var remQuo; + if (!shift_isSmall(n)) { + throw new Error(String(n) + " is too large for shifting."); + } + n = +n; + if (n < 0) return this.shiftLeft(-n); + var result = this; + while (n >= powers2Length) { + if (result.isZero()) return result; + remQuo = divModAny(result, highestPower2); + result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; + n -= powers2Length - 1; + } + remQuo = divModAny(result, powersOfTwo[n]); + return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; + }; + SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight; + + function bitwise(x, y, fn) { + y = parseValue(y); + var xSign = x.isNegative(), ySign = y.isNegative(); + var xRem = xSign ? x.not() : x, + yRem = ySign ? y.not() : y; + var xBits = [], yBits = []; + var xStop = false, yStop = false; + while (!xStop || !yStop) { + if (xRem.isZero()) { // virtual sign extension for simulating two's complement + xStop = true; + xBits.push(xSign ? 1 : 0); + } + else if (xSign) xBits.push(xRem.isEven() ? 1 : 0); // two's complement for negative numbers + else xBits.push(xRem.isEven() ? 0 : 1); + + if (yRem.isZero()) { + yStop = true; + yBits.push(ySign ? 1 : 0); + } + else if (ySign) yBits.push(yRem.isEven() ? 1 : 0); + else yBits.push(yRem.isEven() ? 0 : 1); + + xRem = xRem.over(2); + yRem = yRem.over(2); + } + var result = []; + for (var i = 0; i < xBits.length; i++) result.push(fn(xBits[i], yBits[i])); + var sum = bigInt(result.pop()).negate().times(bigInt(2).pow(result.length)); + while (result.length) { + sum = sum.add(bigInt(result.pop()).times(bigInt(2).pow(result.length))); + } + return sum; + } + + BigInteger.prototype.not = function () { + return this.negate().prev(); + }; + SmallInteger.prototype.not = BigInteger.prototype.not; + + BigInteger.prototype.and = function (n) { + return bitwise(this, n, function (a, b) { return a & b; }); + }; + SmallInteger.prototype.and = BigInteger.prototype.and; + + BigInteger.prototype.or = function (n) { + return bitwise(this, n, function (a, b) { return a | b; }); + }; + SmallInteger.prototype.or = BigInteger.prototype.or; + + BigInteger.prototype.xor = function (n) { + return bitwise(this, n, function (a, b) { return a ^ b; }); + }; + SmallInteger.prototype.xor = BigInteger.prototype.xor; + + var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I; + function roughLOB(n) { // get lowestOneBit (rough) + // SmallInteger: return Min(lowestOneBit(n), 1 << 30) + // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7] + var v = n.value, x = typeof v === "number" ? v | LOBMASK_I : v[0] + v[1] * BASE | LOBMASK_BI; + return x & -x; + } + + function max(a, b) { + a = parseValue(a); + b = parseValue(b); + return a.greater(b) ? a : b; + } + function min(a,b) { + a = parseValue(a); + b = parseValue(b); + return a.lesser(b) ? a : b; + } + function gcd(a, b) { + a = parseValue(a).abs(); + b = parseValue(b).abs(); + if (a.equals(b)) return a; + if (a.isZero()) return b; + if (b.isZero()) return a; + var c = CACHE[1], d, t; + while (a.isEven() && b.isEven()) { + d = Math.min(roughLOB(a), roughLOB(b)); + a = a.divide(d); + b = b.divide(d); + c = c.multiply(d); + } + while (a.isEven()) { + a = a.divide(roughLOB(a)); + } + do { + while (b.isEven()) { + b = b.divide(roughLOB(b)); + } + if (a.greater(b)) { + t = b; b = a; a = t; + } + b = b.subtract(a); + } while (!b.isZero()); + return c.isUnit() ? a : a.multiply(c); + } + function lcm(a, b) { + a = parseValue(a).abs(); + b = parseValue(b).abs(); + return a.divide(gcd(a, b)).multiply(b); + } + function randBetween(a, b) { + a = parseValue(a); + b = parseValue(b); + var low = min(a, b), high = max(a, b); + var range = high.subtract(low); + if (range.isSmall) return low.add(Math.round(Math.random() * range)); + var length = range.value.length - 1; + var result = [], restricted = true; + for (var i = length; i >= 0; i--) { + var top = restricted ? range.value[i] : BASE; + var digit = truncate(Math.random() * top); + result.unshift(digit); + if (digit < top) restricted = false; + } + result = arrayToSmall(result); + return low.add(typeof result === "number" ? new SmallInteger(result) : new BigInteger(result, false)); + } + var parseBase = function (text, base) { + var val = CACHE[0], pow = CACHE[1], + length = text.length; + if (2 <= base && base <= 36) { + if (length <= LOG_MAX_INT / Math.log(base)) { + return new SmallInteger(parseInt(text, base)); + } + } + base = parseValue(base); + var digits = []; + var i; + var isNegative = text[0] === "-"; + for (i = isNegative ? 1 : 0; i < text.length; i++) { + var c = text[i].toLowerCase(), + charCode = c.charCodeAt(0); + if (48 <= charCode && charCode <= 57) digits.push(parseValue(c)); + else if (97 <= charCode && charCode <= 122) digits.push(parseValue(c.charCodeAt(0) - 87)); + else if (c === "<") { + var start = i; + do { i++; } while (text[i] !== ">"); + digits.push(parseValue(text.slice(start + 1, i))); + } + else throw new Error(c + " is not a valid character"); + } + digits.reverse(); + for (i = 0; i < digits.length; i++) { + val = val.add(digits[i].times(pow)); + pow = pow.times(base); + } + return isNegative ? val.negate() : val; + }; + + function stringify(digit) { + var v = digit.value; + if (typeof v === "number") v = [v]; + if (v.length === 1 && v[0] <= 35) { + return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0]); + } + return "<" + v + ">"; + } + function toBase(n, base) { + base = bigInt(base); + if (base.isZero()) { + if (n.isZero()) return "0"; + throw new Error("Cannot convert nonzero numbers to base 0."); + } + if (base.equals(-1)) { + if (n.isZero()) return "0"; + if (n.isNegative()) return new Array(1 - n).join("10"); + return "1" + new Array(+n).join("01"); + } + var minusSign = ""; + if (n.isNegative() && base.isPositive()) { + minusSign = "-"; + n = n.abs(); + } + if (base.equals(1)) { + if (n.isZero()) return "0"; + return minusSign + new Array(+n + 1).join(1); + } + var out = []; + var left = n, divmod; + while (left.isNegative() || left.compareAbs(base) >= 0) { + divmod = left.divmod(base); + left = divmod.quotient; + var digit = divmod.remainder; + if (digit.isNegative()) { + digit = base.minus(digit).abs(); + left = left.next(); + } + out.push(stringify(digit)); + } + out.push(stringify(left)); + return minusSign + out.reverse().join(""); + } + + BigInteger.prototype.toString = function (radix) { + if (radix === undefined) radix = 10; + if (radix !== 10) return toBase(this, radix); + var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit; + while (--l >= 0) { + digit = String(v[l]); + str += zeros.slice(digit.length) + digit; + } + var sign = this.sign ? "-" : ""; + return sign + str; + }; + SmallInteger.prototype.toString = function (radix) { + if (radix === undefined) radix = 10; + if (radix != 10) return toBase(this, radix); + return String(this.value); + }; + + BigInteger.prototype.valueOf = function () { + return +this.toString(); + }; + BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf; + + SmallInteger.prototype.valueOf = function () { + return this.value; + }; + SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf; + + function parseStringValue(v) { + if (isPrecise(+v)) { + var x = +v; + if (x === truncate(x)) + return new SmallInteger(x); + throw "Invalid integer: " + v; + } + var sign = v[0] === "-"; + if (sign) v = v.slice(1); + var split = v.split(/e/i); + if (split.length > 2) throw new Error("Invalid integer: " + text.join("e")); + if (split.length === 2) { + var exp = split[1]; + if (exp[0] === "+") exp = exp.slice(1); + exp = +exp; + if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent."); + var text = split[0]; + var decimalPlace = text.indexOf("."); + if (decimalPlace >= 0) { + exp -= text.length - decimalPlace - 1; + text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1); + } + if (exp < 0) throw new Error("Cannot include negative exponent part for integers"); + text += (new Array(exp + 1)).join("0"); + v = text; + } + var isValid = /^([0-9][0-9]*)$/.test(v); + if (!isValid) throw new Error("Invalid integer: " + v); + var r = [], max = v.length, l = LOG_BASE, min = max - l; + while (max > 0) { + r.push(+v.slice(min, max)); + min -= l; + if (min < 0) min = 0; + max -= l; + } + trim(r); + return new BigInteger(r, sign); + } + + function parseNumberValue(v) { + if (isPrecise(v)) return new SmallInteger(v); + return parseStringValue(v.toString()); + } + + function parseValue(v) { + if (typeof v === "number") { + return parseNumberValue(v); + } + if (typeof v === "string") { + return parseStringValue(v); + } + return v; + } + // Pre-define numbers in range [-999,999] + var CACHE = function (v, radix) { + if (typeof v === "undefined") return CACHE[0]; + if (typeof radix !== "undefined") return +radix === 10 ? parseValue(v) : parseBase(v, radix); + return parseValue(v); + }; + for (var i = 0; i < 1000; i++) { + CACHE[i] = new SmallInteger(i); + if (i > 0) CACHE[-i] = new SmallInteger(-i); + } + // Backwards compatibility + CACHE.one = CACHE[1]; + CACHE.zero = CACHE[0]; + CACHE.minusOne = CACHE[-1]; + CACHE.max = max; + CACHE.min = min; + CACHE.gcd = gcd; + CACHE.lcm = lcm; + CACHE.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; }; + CACHE.randBetween = randBetween; + return CACHE; +})(); + +// Node.js check +if (typeof module !== "undefined" && module.hasOwnProperty("exports")) { + module.exports = bigInt; +} diff --git a/platforms/android/cordova/node_modules/big-integer/BigInteger.min.js b/platforms/android/cordova/node_modules/big-integer/BigInteger.min.js new file mode 100644 index 0000000..53480ea --- /dev/null +++ b/platforms/android/cordova/node_modules/big-integer/BigInteger.min.js @@ -0,0 +1 @@ +var bigInt=function(e){"use strict";function o(e,t){this.value=e,this.sign=t,this.isSmall=!1}function u(e){this.value=e,this.sign=e<0,this.isSmall=!0}function a(e){return-r0?Math.floor(e):Math.ceil(e)}function d(e,n){var r=e.length,i=n.length,s=new Array(r),o=0,u=t,a,f;for(f=0;f=u?1:0,s[f]=a-o*u;while(f0&&s.push(o),s}function v(e,t){return e.length>=t.length?d(e,t):d(t,e)}function m(e,n){var r=e.length,i=new Array(r),s=t,o,u;for(u=0;u0)i[u++]=n%s,n=Math.floor(n/s);return i}function g(e,n){var r=e.length,i=n.length,s=new Array(r),o=0,u=t,a,f;for(a=0;a=0?r=g(e,t):(r=g(t,e),n=!n),r=l(r),typeof r=="number"?(n&&(r=-r),new u(r)):new o(r,n)}function b(e,n,r){var i=e.length,s=new Array(i),a=-n,f=t,c,h;for(c=0;c0)i[a++]=o%s,o=Math.floor(o/s);return i}function S(e,t){var n=[];while(t-->0)n.push(0);return n.concat(e)}function x(e,t){var n=Math.max(e.length,t.length);if(n<=30)return w(e,t);n=Math.ceil(n/2);var r=e.slice(n),i=e.slice(0,n),s=t.slice(n),o=t.slice(0,n),u=x(i,o),a=x(r,s),f=x(v(i,r),v(o,s)),l=v(v(u,S(g(g(f,u),a),n)),S(a,2*n));return c(l),l}function T(e,t){return-0.012*e-.012*t+15e-6*e*t>0}function N(e,n,r){return e=0;d--){p=s-1,f[d+i]!==u&&(p=Math.floor((f[d+i]*s+f[d+i-1])/u)),v=0,m=0,y=c.length;for(g=0;gi&&(c=(c+1)*u),a=Math.ceil(c/h);do{p=E(n,a);if(M(p,o)<=0)break;a--}while(a);s.push(a),o=g(o,p)}return s.reverse(),[l(s),l(o)]}function A(e,n){var r=e.length,i=h(r),s=t,o,u,a,f;a=0;for(o=r-1;o>=0;--o)f=a*s+e[o],u=p(f/n),a=f-u*n,i[o]=u|0;return[i,a|0]}function O(e,n){var r,i=G(n),s=e.value,a=i.value,c;if(a===0)throw new Error("Cannot divide by zero");if(e.isSmall)return i.isSmall?[new u(p(s/a)),new u(s%a)]:[Y[0],e];if(i.isSmall){if(a===1)return[e,Y[0]];if(a==-1)return[e.negate(),Y[0]];var h=Math.abs(a);if(ht.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function _(e){var t=e.abs();if(t.isUnit())return!1;if(t.equals(2)||t.equals(3)||t.equals(5))return!0;if(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))return!1;if(t.lesser(25))return!0}function B(e){return(typeof e=="number"||typeof e=="string")&&+Math.abs(e)<=t||e instanceof o&&e.value.length<=1}function j(e,t,n){t=G(t);var r=e.isNegative(),i=t.isNegative(),s=r?e.not():e,o=i?t.not():t,u=[],a=[],f=!1,l=!1;while(!f||!l)s.isZero()?(f=!0,u.push(r?1:0)):r?u.push(s.isEven()?1:0):u.push(s.isEven()?0:1),o.isZero()?(l=!0,a.push(i?1:0)):i?a.push(o.isEven()?1:0):a.push(o.isEven()?0:1),s=s.over(2),o=o.over(2);var c=[];for(var h=0;h=0;h--){var d=c?s.value[h]:t,v=p(Math.random()*d);f.unshift(v),v"}function J(e,t){t=bigInt(t);if(t.isZero()){if(e.isZero())return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1))return e.isZero()?"0":e.isNegative()?(new Array(1-e)).join("10"):"1"+(new Array(+e)).join("01");var n="";e.isNegative()&&t.isPositive()&&(n="-",e=e.abs());if(t.equals(1))return e.isZero()?"0":n+(new Array(+e+1)).join(1);var r=[],i=e,s;while(i.isNegative()||i.compareAbs(t)>=0){s=i.divmod(t),i=s.quotient;var o=s.remainder;o.isNegative()&&(o=t.minus(o).abs(),i=i.next()),r.push($(o))}return r.push($(i)),n+r.reverse().join("")}function K(e){if(a(+e)){var t=+e;if(t===p(t))return new u(t);throw"Invalid integer: "+e}var r=e[0]==="-";r&&(e=e.slice(1));var i=e.split(/e/i);if(i.length>2)throw new Error("Invalid integer: "+f.join("e"));if(i.length===2){var s=i[1];s[0]==="+"&&(s=s.slice(1)),s=+s;if(s!==p(s)||!a(s))throw new Error("Invalid integer: "+s+" is not a valid exponent.");var f=i[0],l=f.indexOf(".");l>=0&&(s-=f.length-l-1,f=f.slice(0,l)+f.slice(l+1));if(s<0)throw new Error("Cannot include negative exponent part for integers");f+=(new Array(s+1)).join("0"),e=f}var h=/^([0-9][0-9]*)$/.test(e);if(!h)throw new Error("Invalid integer: "+e);var d=[],v=e.length,m=n,g=v-m;while(v>0)d.push(+e.slice(g,v)),g-=m,g<0&&(g=0),v-=m;return c(d),new o(d,r)}function Q(e){return a(e)?new u(e):K(e.toString())}function G(e){return typeof e=="number"?Q(e):typeof e=="string"?K(e):e}var t=1e7,n=7,r=9007199254740992,i=f(r),s=Math.log(r);o.prototype.add=function(e){var t,n=G(e);if(this.sign!==n.sign)return this.subtract(n.negate());var r=this.value,i=n.value;return n.isSmall?new o(m(r,Math.abs(i)),this.sign):new o(v(r,i),this.sign)},o.prototype.plus=o.prototype.add,u.prototype.add=function(e){var t=G(e),n=this.value;if(n<0!==t.sign)return this.subtract(t.negate());var r=t.value;if(t.isSmall){if(a(n+r))return new u(n+r);r=f(Math.abs(r))}return new o(m(r,Math.abs(n)),n<0)},u.prototype.plus=u.prototype.add,o.prototype.subtract=function(e){var t=G(e);if(this.sign!==t.sign)return this.add(t.negate());var n=this.value,r=t.value;return t.isSmall?b(n,Math.abs(r),this.sign):y(n,r,this.sign)},o.prototype.minus=o.prototype.subtract,u.prototype.subtract=function(e){var t=G(e),n=this.value;if(n<0!==t.sign)return this.add(t.negate());var r=t.value;return t.isSmall?new u(n-r):b(r,Math.abs(n),n>=0)},u.prototype.minus=u.prototype.subtract,o.prototype.negate=function(){return new o(this.value,!this.sign)},u.prototype.negate=function(){var e=this.sign,t=new u(-this.value);return t.sign=!e,t},o.prototype.abs=function(){return new o(this.value,!1)},u.prototype.abs=function(){return new u(Math.abs(this.value))},o.prototype.multiply=function(e){var n,r=G(e),i=this.value,s=r.value,u=this.sign!==r.sign,a;if(r.isSmall){if(s===0)return Y[0];if(s===1)return this;if(s===-1)return this.negate();a=Math.abs(s);if(ar?1:-1):-1},o.prototype.compare=function(e){if(e===Infinity)return-1;if(e===-Infinity)return 1;var t=G(e),n=this.value,r=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:M(n,r)*(this.sign?-1:1)},o.prototype.compareTo=o.prototype.compare,u.prototype.compare=function(e){if(e===Infinity)return-1;if(e===-Infinity)return 1;var t=G(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0!==t.sign?n<0?-1:1:n<0?1:-1},u.prototype.compareTo=u.prototype.compare,o.prototype.equals=function(e){return this.compare(e)===0},u.prototype.eq=u.prototype.equals=o.prototype.eq=o.prototype.equals,o.prototype.notEquals=function(e){return this.compare(e)!==0},u.prototype.neq=u.prototype.notEquals=o.prototype.neq=o.prototype.notEquals,o.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=o.prototype.gt=o.prototype.greater,o.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=o.prototype.lt=o.prototype.lesser,o.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=o.prototype.geq=o.prototype.greaterOrEquals,o.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=o.prototype.leq=o.prototype.lesserOrEquals,o.prototype.isEven=function(){return(this.value[0]&1)===0},u.prototype.isEven=function(){return(this.value&1)===0},o.prototype.isOdd=function(){return(this.value[0]&1)===1},u.prototype.isOdd=function(){return(this.value&1)===1},o.prototype.isPositive=function(){return!this.sign},u.prototype.isPositive=function(){return this.value>0},o.prototype.isNegative=function(){return this.sign},u.prototype.isNegative=function(){return this.value<0},o.prototype.isUnit=function(){return!1},u.prototype.isUnit=function(){return Math.abs(this.value)===1},o.prototype.isZero=function(){return!1},u.prototype.isZero=function(){return this.value===0},o.prototype.isDivisibleBy=function(e){var t=G(e),n=t.value;return n===0?!1:n===1?!0:n===2?this.isEven():this.mod(t).equals(Y[0])},u.prototype.isDivisibleBy=o.prototype.isDivisibleBy,o.prototype.isPrime=function(){var t=_(this);if(t!==e)return t;var n=this.abs(),r=n.prev(),i=[2,3,5,7,11,13,17,19],s=r,o,u,a,f;while(s.isEven())s=s.divide(2);for(a=0;a-r?new u(e-1):new o(i,!0)};var D=[1];while(D[D.length-1]<=t)D.push(2*D[D.length-1]);var P=D.length,H=D[P-1];o.prototype.shiftLeft=function(e){if(!B(e))throw new Error(String(e)+" is too large for shifting.");e=+e;if(e<0)return this.shiftRight(-e);var t=this;while(e>=P)t=t.multiply(H),e-=P-1;return t.multiply(D[e])},u.prototype.shiftLeft=o.prototype.shiftLeft,o.prototype.shiftRight=function(e){var t;if(!B(e))throw new Error(String(e)+" is too large for shifting.");e=+e;if(e<0)return this.shiftLeft(-e);var n=this;while(e>=P){if(n.isZero())return n;t=O(n,H),n=t[1].isNegative()?t[0].prev():t[0],e-=P-1}return t=O(n,D[e]),t[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=o.prototype.shiftRight,o.prototype.not=function(){return this.negate().prev()},u.prototype.not=o.prototype.not,o.prototype.and=function(e){return j(this,e,function(e,t){return e&t})},u.prototype.and=o.prototype.and,o.prototype.or=function(e){return j(this,e,function(e,t){return e|t})},u.prototype.or=o.prototype.or,o.prototype.xor=function(e){return j(this,e,function(e,t){return e^t})},u.prototype.xor=o.prototype.xor;var F=1<<30,I=(t&-t)*(t&-t)|F,V=function(e,t){var n=Y[0],r=Y[1],i=e.length;if(2<=t&&t<=36&&i<=s/Math.log(t))return new u(parseInt(e,t));t=G(t);var o=[],a,f=e[0]==="-";for(a=f?1:0;a");o.push(G(e.slice(h+1,a)))}}o.reverse();for(a=0;a=0)o=String(n[r]),i+=s.slice(o.length)+o;var u=this.sign?"-":"";return u+i},u.prototype.toString=function(t){return t===e&&(t=10),t!=10?J(this,t):String(this.value)},o.prototype.valueOf=function(){return+this.toString()},o.prototype.toJSNumber=o.prototype.valueOf,u.prototype.valueOf=function(){return this.value},u.prototype.toJSNumber=u.prototype.valueOf;var Y=function(e,t){return typeof e=="undefined"?Y[0]:typeof t!="undefined"?+t===10?G(e):V(e,t):G(e)};for(var Z=0;Z<1e3;Z++)Y[Z]=new u(Z),Z>0&&(Y[-Z]=new u(-Z));return Y.one=Y[1],Y.zero=Y[0],Y.minusOne=Y[-1],Y.max=R,Y.min=U,Y.gcd=z,Y.lcm=W,Y.isInstance=function(e){return e instanceof o||e instanceof u},Y.randBetween=X,Y}();typeof module!="undefined"&&module.hasOwnProperty("exports")&&(module.exports=bigInt); \ No newline at end of file diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/README.md b/platforms/android/cordova/node_modules/big-integer/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/README.md rename to platforms/android/cordova/node_modules/big-integer/README.md diff --git a/platforms/android/cordova/node_modules/big-integer/package.json b/platforms/android/cordova/node_modules/big-integer/package.json new file mode 100644 index 0000000..f51a9b6 --- /dev/null +++ b/platforms/android/cordova/node_modules/big-integer/package.json @@ -0,0 +1,100 @@ +{ + "_args": [ + [ + "big-integer@^1.6.7", + "/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser" + ] + ], + "_from": "big-integer@>=1.6.7 <2.0.0", + "_id": "big-integer@1.6.12", + "_inCache": true, + "_installable": true, + "_location": "/big-integer", + "_nodeVersion": "0.12.3", + "_npmOperationalInternal": { + "host": "packages-6-west.internal.npmjs.com", + "tmp": "tmp/big-integer-1.6.12.tgz_1455702804335_0.11810904298909009" + }, + "_npmUser": { + "email": "peter.e.c.olson+npm@gmail.com", + "name": "peterolson" + }, + "_npmVersion": "2.9.1", + "_phantomChildren": {}, + "_requested": { + "name": "big-integer", + "raw": "big-integer@^1.6.7", + "rawSpec": "^1.6.7", + "scope": null, + "spec": ">=1.6.7 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/bplist-parser" + ], + "_resolved": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.12.tgz", + "_shasum": "39afcddafcd5c4480864efb757337d508938bb26", + "_shrinkwrap": null, + "_spec": "big-integer@^1.6.7", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser", + "author": { + "email": "peter.e.c.olson+npm@gmail.com", + "name": "Peter Olson" + }, + "bin": {}, + "bugs": { + "url": "https://github.com/peterolson/BigInteger.js/issues" + }, + "contributors": [], + "dependencies": {}, + "description": "An arbitrary length integer library for Javascript", + "devDependencies": { + "coveralls": "^2.11.4", + "jasmine": "2.1.x", + "jasmine-core": "^2.3.4", + "karma": "^0.13.3", + "karma-coverage": "^0.4.2", + "karma-jasmine": "^0.3.6", + "karma-phantomjs-launcher": "~0.1" + }, + "directories": {}, + "dist": { + "shasum": "39afcddafcd5c4480864efb757337d508938bb26", + "tarball": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.12.tgz" + }, + "engines": { + "node": ">=0.6" + }, + "gitHead": "56f449108e31542f939e701f1fe562a46e6c1fab", + "homepage": "https://github.com/peterolson/BigInteger.js#readme", + "keywords": [ + "arbitrary", + "arithmetic", + "big", + "bigint", + "biginteger", + "bignum", + "integer", + "math", + "precision" + ], + "license": "Unlicense", + "main": "./BigInteger", + "maintainers": [ + { + "name": "peterolson", + "email": "peter.e.c.olson+npm@gmail.com" + } + ], + "name": "big-integer", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/peterolson/BigInteger.js.git" + }, + "scripts": { + "test": "karma start my.conf.js" + }, + "version": "1.6.12" +} diff --git a/platforms/android/cordova/node_modules/bplist-parser/.npmignore b/platforms/android/cordova/node_modules/bplist-parser/.npmignore new file mode 100644 index 0000000..a9b46ea --- /dev/null +++ b/platforms/android/cordova/node_modules/bplist-parser/.npmignore @@ -0,0 +1,8 @@ +/build/* +node_modules +*.node +*.sh +*.swp +.lock* +npm-debug.log +.idea diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/README.md b/platforms/android/cordova/node_modules/bplist-parser/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/README.md rename to platforms/android/cordova/node_modules/bplist-parser/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/bplistParser.js b/platforms/android/cordova/node_modules/bplist-parser/bplistParser.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/bplistParser.js rename to platforms/android/cordova/node_modules/bplist-parser/bplistParser.js diff --git a/platforms/android/cordova/node_modules/bplist-parser/package.json b/platforms/android/cordova/node_modules/bplist-parser/package.json new file mode 100644 index 0000000..899b577 --- /dev/null +++ b/platforms/android/cordova/node_modules/bplist-parser/package.json @@ -0,0 +1,81 @@ +{ + "_args": [ + [ + "bplist-parser@^0.1.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "bplist-parser@>=0.1.0 <0.2.0", + "_id": "bplist-parser@0.1.1", + "_inCache": true, + "_installable": true, + "_location": "/bplist-parser", + "_nodeVersion": "5.1.0", + "_npmUser": { + "email": "joe@fernsroth.com", + "name": "joeferner" + }, + "_npmVersion": "3.4.0", + "_phantomChildren": {}, + "_requested": { + "name": "bplist-parser", + "raw": "bplist-parser@^0.1.0", + "rawSpec": "^0.1.0", + "scope": null, + "spec": ">=0.1.0 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz", + "_shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6", + "_shrinkwrap": null, + "_spec": "bplist-parser@^0.1.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "email": "joe.ferner@nearinfinity.com", + "name": "Joe Ferner" + }, + "bugs": { + "url": "https://github.com/nearinfinity/node-bplist-parser/issues" + }, + "dependencies": { + "big-integer": "^1.6.7" + }, + "description": "Binary plist parser.", + "devDependencies": { + "nodeunit": "~0.9.1" + }, + "directories": {}, + "dist": { + "shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6", + "tarball": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz" + }, + "gitHead": "c4f22650de2cc95edd21a6e609ff0654a2b951bd", + "homepage": "https://github.com/nearinfinity/node-bplist-parser#readme", + "keywords": [ + "bplist", + "parser", + "plist" + ], + "license": "MIT", + "main": "bplistParser.js", + "maintainers": [ + { + "name": "joeferner", + "email": "joe@fernsroth.com" + } + ], + "name": "bplist-parser", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/nearinfinity/node-bplist-parser.git" + }, + "scripts": { + "test": "./node_modules/nodeunit/bin/nodeunit test" + }, + "version": "0.1.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/airplay.bplist b/platforms/android/cordova/node_modules/bplist-parser/test/airplay.bplist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/airplay.bplist rename to platforms/android/cordova/node_modules/bplist-parser/test/airplay.bplist diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/iTunes-small.bplist b/platforms/android/cordova/node_modules/bplist-parser/test/iTunes-small.bplist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/iTunes-small.bplist rename to platforms/android/cordova/node_modules/bplist-parser/test/iTunes-small.bplist diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/int64.bplist b/platforms/android/cordova/node_modules/bplist-parser/test/int64.bplist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/int64.bplist rename to platforms/android/cordova/node_modules/bplist-parser/test/int64.bplist diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/int64.xml b/platforms/android/cordova/node_modules/bplist-parser/test/int64.xml similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/int64.xml rename to platforms/android/cordova/node_modules/bplist-parser/test/int64.xml diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/parseTest.js b/platforms/android/cordova/node_modules/bplist-parser/test/parseTest.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/parseTest.js rename to platforms/android/cordova/node_modules/bplist-parser/test/parseTest.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/sample1.bplist b/platforms/android/cordova/node_modules/bplist-parser/test/sample1.bplist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/sample1.bplist rename to platforms/android/cordova/node_modules/bplist-parser/test/sample1.bplist diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/sample2.bplist b/platforms/android/cordova/node_modules/bplist-parser/test/sample2.bplist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/sample2.bplist rename to platforms/android/cordova/node_modules/bplist-parser/test/sample2.bplist diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/uid.bplist b/platforms/android/cordova/node_modules/bplist-parser/test/uid.bplist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/uid.bplist rename to platforms/android/cordova/node_modules/bplist-parser/test/uid.bplist diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/utf16.bplist b/platforms/android/cordova/node_modules/bplist-parser/test/utf16.bplist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/utf16.bplist rename to platforms/android/cordova/node_modules/bplist-parser/test/utf16.bplist diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/utf16_chinese.plist b/platforms/android/cordova/node_modules/bplist-parser/test/utf16_chinese.plist similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/test/utf16_chinese.plist rename to platforms/android/cordova/node_modules/bplist-parser/test/utf16_chinese.plist diff --git a/platforms/android/cordova/node_modules/brace-expansion/.npmignore b/platforms/android/cordova/node_modules/brace-expansion/.npmignore new file mode 100644 index 0000000..353546a --- /dev/null +++ b/platforms/android/cordova/node_modules/brace-expansion/.npmignore @@ -0,0 +1,3 @@ +test +.gitignore +.travis.yml diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md b/platforms/android/cordova/node_modules/brace-expansion/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md rename to platforms/android/cordova/node_modules/brace-expansion/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js b/platforms/android/cordova/node_modules/brace-expansion/example.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js rename to platforms/android/cordova/node_modules/brace-expansion/example.js diff --git a/platforms/android/cordova/node_modules/brace-expansion/index.js b/platforms/android/cordova/node_modules/brace-expansion/index.js new file mode 100644 index 0000000..932718f --- /dev/null +++ b/platforms/android/cordova/node_modules/brace-expansion/index.js @@ -0,0 +1,191 @@ +var concatMap = require('concat-map'); +var balanced = require('balanced-match'); + +module.exports = expandTop; + +var escSlash = '\0SLASH'+Math.random()+'\0'; +var escOpen = '\0OPEN'+Math.random()+'\0'; +var escClose = '\0CLOSE'+Math.random()+'\0'; +var escComma = '\0COMMA'+Math.random()+'\0'; +var escPeriod = '\0PERIOD'+Math.random()+'\0'; + +function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); +} + +function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); +} + +function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); +} + + +// Basically just str.split(","), but handling cases +// where we have nested braced sections, which should be +// treated as individual members, like {a,{b,c},d} +function parseCommaParts(str) { + if (!str) + return ['']; + + var parts = []; + var m = balanced('{', '}', str); + + if (!m) + return str.split(','); + + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); + + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } + + parts.push.apply(parts, p); + + return parts; +} + +function expandTop(str) { + if (!str) + return []; + + return expand(escapeBraces(str), true).map(unescapeBraces); +} + +function identity(e) { + return e; +} + +function embrace(str) { + return '{' + str + '}'; +} +function isPadded(el) { + return /^-?0\d/.test(el); +} + +function lte(i, y) { + return i <= y; +} +function gte(i, y) { + return i >= y; +} + +function expand(str, isTop) { + var expansions = []; + + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; + + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = /^(.*,)+(.+)?$/.test(m.body); + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + return [str]; + } + + var n; + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0], false).map(embrace); + if (n.length === 1) { + var post = m.post.length + ? expand(m.post, false) + : ['']; + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } + } + + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. + + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand(m.post, false) + : ['']; + + var N; + + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length) + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); + + N = []; + + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = concatMap(n, function(el) { return expand(el, false) }); + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) + expansions.push(expansion); + } + } + + return expansions; +} + diff --git a/platforms/android/cordova/node_modules/brace-expansion/package.json b/platforms/android/cordova/node_modules/brace-expansion/package.json new file mode 100644 index 0000000..d6d2f78 --- /dev/null +++ b/platforms/android/cordova/node_modules/brace-expansion/package.json @@ -0,0 +1,104 @@ +{ + "_args": [ + [ + "brace-expansion@^1.0.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/minimatch" + ] + ], + "_from": "brace-expansion@>=1.0.0 <2.0.0", + "_id": "brace-expansion@1.1.3", + "_inCache": true, + "_installable": true, + "_location": "/brace-expansion", + "_nodeVersion": "5.5.0", + "_npmOperationalInternal": { + "host": "packages-6-west.internal.npmjs.com", + "tmp": "tmp/brace-expansion-1.1.3.tgz_1455216688668_0.948847763473168" + }, + "_npmUser": { + "email": "julian@juliangruber.com", + "name": "juliangruber" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "brace-expansion", + "raw": "brace-expansion@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/minimatch" + ], + "_resolved": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz", + "_shasum": "46bff50115d47fc9ab89854abb87d98078a10991", + "_shrinkwrap": null, + "_spec": "brace-expansion@^1.0.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/minimatch", + "author": { + "email": "mail@juliangruber.com", + "name": "Julian Gruber", + "url": "http://juliangruber.com" + }, + "bugs": { + "url": "https://github.com/juliangruber/brace-expansion/issues" + }, + "dependencies": { + "balanced-match": "^0.3.0", + "concat-map": "0.0.1" + }, + "description": "Brace expansion as known from sh/bash", + "devDependencies": { + "tape": "4.4.0" + }, + "directories": {}, + "dist": { + "shasum": "46bff50115d47fc9ab89854abb87d98078a10991", + "tarball": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz" + }, + "gitHead": "f0da1bb668e655f67b6b2d660c6e1c19e2a6f231", + "homepage": "https://github.com/juliangruber/brace-expansion", + "keywords": [], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + { + "name": "isaacs", + "email": "isaacs@npmjs.com" + } + ], + "name": "brace-expansion", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/brace-expansion.git" + }, + "scripts": { + "gentest": "bash test/generate.sh", + "test": "tape test/*.js" + }, + "testling": { + "browsers": [ + "android-browser/4.2..latest", + "chrome/25..latest", + "chrome/canary", + "firefox/20..latest", + "firefox/nightly", + "ie/8..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "opera/12..latest", + "opera/next", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "version": "1.1.3" +} diff --git a/platforms/android/cordova/node_modules/concat-map/.travis.yml b/platforms/android/cordova/node_modules/concat-map/.travis.yml new file mode 100644 index 0000000..f1d0f13 --- /dev/null +++ b/platforms/android/cordova/node_modules/concat-map/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.4 + - 0.6 diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE b/platforms/android/cordova/node_modules/concat-map/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE rename to platforms/android/cordova/node_modules/concat-map/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown b/platforms/android/cordova/node_modules/concat-map/README.markdown similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown rename to platforms/android/cordova/node_modules/concat-map/README.markdown diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js b/platforms/android/cordova/node_modules/concat-map/example/map.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js rename to platforms/android/cordova/node_modules/concat-map/example/map.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js b/platforms/android/cordova/node_modules/concat-map/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js rename to platforms/android/cordova/node_modules/concat-map/index.js diff --git a/platforms/android/cordova/node_modules/concat-map/package.json b/platforms/android/cordova/node_modules/concat-map/package.json new file mode 100644 index 0000000..3ebe787 --- /dev/null +++ b/platforms/android/cordova/node_modules/concat-map/package.json @@ -0,0 +1,109 @@ +{ + "_args": [ + [ + "concat-map@0.0.1", + "/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion" + ] + ], + "_from": "concat-map@0.0.1", + "_id": "concat-map@0.0.1", + "_inCache": true, + "_installable": true, + "_location": "/concat-map", + "_npmUser": { + "email": "mail@substack.net", + "name": "substack" + }, + "_npmVersion": "1.3.21", + "_phantomChildren": {}, + "_requested": { + "name": "concat-map", + "raw": "concat-map@0.0.1", + "rawSpec": "0.0.1", + "scope": null, + "spec": "0.0.1", + "type": "version" + }, + "_requiredBy": [ + "/brace-expansion" + ], + "_resolved": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", + "_shrinkwrap": null, + "_spec": "concat-map@0.0.1", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/brace-expansion", + "author": { + "email": "mail@substack.net", + "name": "James Halliday", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/node-concat-map/issues" + }, + "dependencies": {}, + "description": "concatenative mapdashery", + "devDependencies": { + "tape": "~2.4.0" + }, + "directories": { + "example": "example", + "test": "test" + }, + "dist": { + "shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", + "tarball": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + }, + "homepage": "https://github.com/substack/node-concat-map", + "keywords": [ + "concat", + "concatMap", + "functional", + "higher-order", + "map" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + } + ], + "name": "concat-map", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/substack/node-concat-map.git" + }, + "scripts": { + "test": "tape test/*.js" + }, + "testling": { + "browsers": { + "chrome": [ + 10, + 22 + ], + "ff": [ + 10, + 15, + 3.5 + ], + "ie": [ + 6, + 7, + 8, + 9 + ], + "opera": [ + 12 + ], + "safari": [ + 5.1 + ] + }, + "files": "test/*.js" + }, + "version": "0.0.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js b/platforms/android/cordova/node_modules/concat-map/test/map.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js rename to platforms/android/cordova/node_modules/concat-map/test/map.js diff --git a/platforms/android/cordova/node_modules/cordova-common/.jscs.json b/platforms/android/cordova/node_modules/cordova-common/.jscs.json new file mode 100644 index 0000000..5cc7e26 --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-common/.jscs.json @@ -0,0 +1,24 @@ +{ + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "validateLineBreaks": "LF", + "validateIndentation": 4, + "requireLineFeedAtFileEnd": true, + + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "requireSpaceAfterLineComment": true, + "requireCapitalizedConstructors": true, + + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do" + ] +} diff --git a/platforms/android/cordova/node_modules/cordova-common/.jshintignore b/platforms/android/cordova/node_modules/cordova-common/.jshintignore new file mode 100644 index 0000000..d606f61 --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-common/.jshintignore @@ -0,0 +1 @@ +spec/fixtures/* diff --git a/platforms/android/cordova/node_modules/cordova-common/.npmignore b/platforms/android/cordova/node_modules/cordova-common/.npmignore new file mode 100644 index 0000000..5d14118 --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-common/.npmignore @@ -0,0 +1,2 @@ +spec +coverage diff --git a/platforms/android/cordova/node_modules/cordova-common/.ratignore b/platforms/android/cordova/node_modules/cordova-common/.ratignore new file mode 100644 index 0000000..26f7205 --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-common/.ratignore @@ -0,0 +1,2 @@ +fixtures +coverage diff --git a/platforms/android/cordova/node_modules/cordova-common/README.md b/platforms/android/cordova/node_modules/cordova-common/README.md index f19b59f..6454481 100644 --- a/platforms/android/cordova/node_modules/cordova-common/README.md +++ b/platforms/android/cordova/node_modules/cordova-common/README.md @@ -107,6 +107,10 @@ Usage: ``` var superspawn = require('cordova-common').superspawn; superspawn.spawn('adb', ['devices']) +.progress(function(data){ + if (data.stderr) + console.error('"adb devices" raised an error: ' + data.stderr); +}) .then(function(devices){ // Do something... }) diff --git a/platforms/android/cordova/node_modules/cordova-common/RELEASENOTES.md b/platforms/android/cordova/node_modules/cordova-common/RELEASENOTES.md index 5a4cc51..e7db69c 100644 --- a/platforms/android/cordova/node_modules/cordova-common/RELEASENOTES.md +++ b/platforms/android/cordova/node_modules/cordova-common/RELEASENOTES.md @@ -20,6 +20,14 @@ --> # Cordova-common Release Notes +### 1.1.0 (Feb 16, 2016) +* CB-10482 Remove references to windows8 from cordova-lib/cli +* CB-10430 Adds forwardEvents method to easily connect two EventEmitters +* CB-10176 Adds CordovaLogger class, based on logger module from cordova-cli +* CB-10052 Expose child process' io streams via promise progress notification +* CB-10497 Prefer .bat over .cmd on windows platform +* CB-9984 Bumps plist version and fixes failing cordova-common test + ### 1.0.0 (Oct 29, 2015) * CB-9890 Documents cordova-common diff --git a/platforms/android/cordova/node_modules/cordova-common/cordova-common.js b/platforms/android/cordova/node_modules/cordova-common/cordova-common.js index 59b52fc..22e90a7 100644 --- a/platforms/android/cordova/node_modules/cordova-common/cordova-common.js +++ b/platforms/android/cordova/node_modules/cordova-common/cordova-common.js @@ -26,6 +26,7 @@ exports = module.exports = { ActionStack: require('./src/ActionStack'), CordovaError: require('./src/CordovaError/CordovaError'), + CordovaLogger: require('./src/CordovaLogger'), CordovaExternalToolErrorContext: require('./src/CordovaError/CordovaExternalToolErrorContext'), PlatformJson: require('./src/PlatformJson'), ConfigParser: require('./src/ConfigParser/ConfigParser.js'), diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/.gitconfig b/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/.gitconfig deleted file mode 100644 index 7683432..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/.gitconfig +++ /dev/null @@ -1,3 +0,0 @@ -[remote "github"] - push = +refs/heads/master:refs/heads/gh-pages - push = +refs/heads/master:refs/heads/master diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/BigInteger.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/BigInteger.js deleted file mode 100644 index b3f9558..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/BigInteger.js +++ /dev/null @@ -1,1181 +0,0 @@ -var bigInt = (function (undefined) { - "use strict"; - - var BASE = 1e7, - LOG_BASE = 7, - MAX_INT = 9007199254740992, - MAX_INT_ARR = smallToArray(MAX_INT), - LOG_MAX_INT = Math.log(MAX_INT); - - function BigInteger(value, sign) { - this.value = value; - this.sign = sign; - this.isSmall = false; - } - - function SmallInteger(value) { - this.value = value; - this.sign = value < 0; - this.isSmall = true; - } - - function isPrecise(n) { - return -MAX_INT < n && n < MAX_INT; - } - - function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes - if (n < 1e7) - return [n]; - if (n < 1e14) - return [n % 1e7, Math.floor(n / 1e7)]; - return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)]; - } - - function arrayToSmall(arr) { // If BASE changes this function may need to change - trim(arr); - var length = arr.length; - if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) { - switch (length) { - case 0: return 0; - case 1: return arr[0]; - case 2: return arr[0] + arr[1] * BASE; - default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE; - } - } - return arr; - } - - function trim(v) { - var i = v.length; - while (v[--i] === 0); - v.length = i + 1; - } - - function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger - var x = new Array(length); - var i = -1; - while (++i < length) { - x[i] = 0; - } - return x; - } - - function truncate(n) { - if (n > 0) return Math.floor(n); - return Math.ceil(n); - } - - function add(a, b) { // assumes a and b are arrays with a.length >= b.length - var l_a = a.length, - l_b = b.length, - r = new Array(l_a), - carry = 0, - base = BASE, - sum, i; - for (i = 0; i < l_b; i++) { - sum = a[i] + b[i] + carry; - carry = sum >= base ? 1 : 0; - r[i] = sum - carry * base; - } - while (i < l_a) { - sum = a[i] + carry; - carry = sum === base ? 1 : 0; - r[i++] = sum - carry * base; - } - if (carry > 0) r.push(carry); - return r; - } - - function addAny(a, b) { - if (a.length >= b.length) return add(a, b); - return add(b, a); - } - - function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT - var l = a.length, - r = new Array(l), - base = BASE, - sum, i; - for (i = 0; i < l; i++) { - sum = a[i] - base + carry; - carry = Math.floor(sum / base); - r[i] = sum - carry * base; - carry += 1; - } - while (carry > 0) { - r[i++] = carry % base; - carry = Math.floor(carry / base); - } - return r; - } - - BigInteger.prototype.add = function (v) { - var value, n = parseValue(v); - if (this.sign !== n.sign) { - return this.subtract(n.negate()); - } - var a = this.value, b = n.value; - if (n.isSmall) { - return new BigInteger(addSmall(a, Math.abs(b)), this.sign); - } - return new BigInteger(addAny(a, b), this.sign); - }; - BigInteger.prototype.plus = BigInteger.prototype.add; - - SmallInteger.prototype.add = function (v) { - var n = parseValue(v); - var a = this.value; - if (a < 0 !== n.sign) { - return this.subtract(n.negate()); - } - var b = n.value; - if (n.isSmall) { - if (isPrecise(a + b)) return new SmallInteger(a + b); - b = smallToArray(Math.abs(b)); - } - return new BigInteger(addSmall(b, Math.abs(a)), a < 0); - }; - SmallInteger.prototype.plus = SmallInteger.prototype.add; - - function subtract(a, b) { // assumes a and b are arrays with a >= b - var a_l = a.length, - b_l = b.length, - r = new Array(a_l), - borrow = 0, - base = BASE, - i, difference; - for (i = 0; i < b_l; i++) { - difference = a[i] - borrow - b[i]; - if (difference < 0) { - difference += base; - borrow = 1; - } else borrow = 0; - r[i] = difference; - } - for (i = b_l; i < a_l; i++) { - difference = a[i] - borrow; - if (difference < 0) difference += base; - else { - r[i++] = difference; - break; - } - r[i] = difference; - } - for (; i < a_l; i++) { - r[i] = a[i]; - } - trim(r); - return r; - } - - function subtractAny(a, b, sign) { - var value, isSmall; - if (compareAbs(a, b) >= 0) { - value = subtract(a,b); - } else { - value = subtract(b, a); - sign = !sign; - } - value = arrayToSmall(value); - if (typeof value === "number") { - if (sign) value = -value; - return new SmallInteger(value); - } - return new BigInteger(value, sign); - } - - function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT - var l = a.length, - r = new Array(l), - carry = -b, - base = BASE, - i, difference; - for (i = 0; i < l; i++) { - difference = a[i] + carry; - carry = Math.floor(difference / base); - difference %= base; - r[i] = difference < 0 ? difference + base : difference; - } - r = arrayToSmall(r); - if (typeof r === "number") { - if (sign) r = -r; - return new SmallInteger(r); - } return new BigInteger(r, sign); - } - - BigInteger.prototype.subtract = function (v) { - var n = parseValue(v); - if (this.sign !== n.sign) { - return this.add(n.negate()); - } - var a = this.value, b = n.value; - if (n.isSmall) - return subtractSmall(a, Math.abs(b), this.sign); - return subtractAny(a, b, this.sign); - }; - BigInteger.prototype.minus = BigInteger.prototype.subtract; - - SmallInteger.prototype.subtract = function (v) { - var n = parseValue(v); - var a = this.value; - if (a < 0 !== n.sign) { - return this.add(n.negate()); - } - var b = n.value; - if (n.isSmall) { - return new SmallInteger(a - b); - } - return subtractSmall(b, Math.abs(a), a >= 0); - }; - SmallInteger.prototype.minus = SmallInteger.prototype.subtract; - - BigInteger.prototype.negate = function () { - return new BigInteger(this.value, !this.sign); - }; - SmallInteger.prototype.negate = function () { - var sign = this.sign; - var small = new SmallInteger(-this.value); - small.sign = !sign; - return small; - }; - - BigInteger.prototype.abs = function () { - return new BigInteger(this.value, false); - }; - SmallInteger.prototype.abs = function () { - return new SmallInteger(Math.abs(this.value)); - }; - - function multiplyLong(a, b) { - var a_l = a.length, - b_l = b.length, - l = a_l + b_l, - r = createArray(l), - base = BASE, - product, carry, i, a_i, b_j; - for (i = 0; i < a_l; ++i) { - a_i = a[i]; - for (var j = 0; j < b_l; ++j) { - b_j = b[j]; - product = a_i * b_j + r[i + j]; - carry = Math.floor(product / base); - r[i + j] = product - carry * base; - r[i + j + 1] += carry; - } - } - trim(r); - return r; - } - - function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE - var l = a.length, - r = new Array(l), - base = BASE, - carry = 0, - product, i; - for (i = 0; i < l; i++) { - product = a[i] * b + carry; - carry = Math.floor(product / base); - r[i] = product - carry * base; - } - while (carry > 0) { - r[i++] = carry % base; - carry = Math.floor(carry / base); - } - return r; - } - - function shiftLeft(x, n) { - var r = []; - while (n-- > 0) r.push(0); - return r.concat(x); - } - - function multiplyKaratsuba(x, y) { - var n = Math.max(x.length, y.length); - - if (n <= 400) return multiplyLong(x, y); - n = Math.ceil(n / 2); - - var b = x.slice(n), - a = x.slice(0, n), - d = y.slice(n), - c = y.slice(0, n); - - var ac = multiplyKaratsuba(a, c), - bd = multiplyKaratsuba(b, d), - abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d)); - - return addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n)); - } - - BigInteger.prototype.multiply = function (v) { - var value, n = parseValue(v), - a = this.value, b = n.value, - sign = this.sign !== n.sign, - abs; - if (n.isSmall) { - if (b === 0) return CACHE[0]; - if (b === 1) return this; - if (b === -1) return this.negate(); - abs = Math.abs(b); - if (abs < BASE) { - return new BigInteger(multiplySmall(a, abs), sign); - } - b = smallToArray(abs); - } - if (a.length + b.length > 4000) // Karatsuba is only faster for sufficiently large inputs - return new BigInteger(multiplyKaratsuba(a, b), sign); - return new BigInteger(multiplyLong(a, b), sign); - }; - - BigInteger.prototype.times = BigInteger.prototype.multiply; - - function multiplySmallAndArray(a, b, sign) { // a >= 0 - if (a < BASE) { - return new BigInteger(multiplySmall(b, a), sign); - } - return new BigInteger(multiplyLong(b, smallToArray(a)), sign); - } - SmallInteger.prototype["_multiplyBySmall"] = function (a) { - if (isPrecise(a.value * this.value)) { - return new SmallInteger(a.value * this.value); - } - return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign); - }; - BigInteger.prototype["_multiplyBySmall"] = function (a) { - if (a.value === 0) return CACHE[0]; - if (a.value === 1) return this; - if (a.value === -1) return this.negate(); - return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign); - }; - SmallInteger.prototype.multiply = function (v) { - return parseValue(v)["_multiplyBySmall"](this); - }; - SmallInteger.prototype.times = SmallInteger.prototype.multiply; - - function square(a) { - var l = a.length, - r = createArray(l + l), - base = BASE, - product, carry, i, a_i, a_j; - for (i = 0; i < l; i++) { - a_i = a[i]; - for (var j = 0; j < l; j++) { - a_j = a[j]; - product = a_i * a_j + r[i + j]; - carry = Math.floor(product / base); - r[i + j] = product - carry * base; - r[i + j + 1] += carry; - } - } - trim(r); - return r; - } - - BigInteger.prototype.square = function () { - return new BigInteger(square(this.value), false); - }; - - SmallInteger.prototype.square = function () { - var value = this.value * this.value; - if (isPrecise(value)) return new SmallInteger(value); - return new BigInteger(square(smallToArray(Math.abs(this.value))), false); - }; - - function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes. - var a_l = a.length, - b_l = b.length, - base = BASE, - result = createArray(b.length), - divisorMostSignificantDigit = b[b_l - 1], - // normalization - lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)), - remainder = multiplySmall(a, lambda), - divisor = multiplySmall(b, lambda), - quotientDigit, shift, carry, borrow, i, l, q; - if (remainder.length <= a_l) remainder.push(0); - divisor.push(0); - divisorMostSignificantDigit = divisor[b_l - 1]; - for (shift = a_l - b_l; shift >= 0; shift--) { - quotientDigit = base - 1; - if (remainder[shift + b_l] !== divisorMostSignificantDigit) { - quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit); - } - // quotientDigit <= base - 1 - carry = 0; - borrow = 0; - l = divisor.length; - for (i = 0; i < l; i++) { - carry += quotientDigit * divisor[i]; - q = Math.floor(carry / base); - borrow += remainder[shift + i] - (carry - q * base); - carry = q; - if (borrow < 0) { - remainder[shift + i] = borrow + base; - borrow = -1; - } else { - remainder[shift + i] = borrow; - borrow = 0; - } - } - while (borrow !== 0) { - quotientDigit -= 1; - carry = 0; - for (i = 0; i < l; i++) { - carry += remainder[shift + i] - base + divisor[i]; - if (carry < 0) { - remainder[shift + i] = carry + base; - carry = 0; - } else { - remainder[shift + i] = carry; - carry = 1; - } - } - borrow += carry; - } - result[shift] = quotientDigit; - } - // denormalization - remainder = divModSmall(remainder, lambda)[0]; - return [arrayToSmall(result), arrayToSmall(remainder)]; - } - - function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/ - // Performs faster than divMod1 on larger input sizes. - var a_l = a.length, - b_l = b.length, - result = [], - part = [], - base = BASE, - guess, xlen, highx, highy, check; - while (a_l) { - part.unshift(a[--a_l]); - if (compareAbs(part, b) < 0) { - result.push(0); - continue; - } - xlen = part.length; - highx = part[xlen - 1] * base + part[xlen - 2]; - highy = b[b_l - 1] * base + b[b_l - 2]; - if (xlen > b_l) { - highx = (highx + 1) * base; - } - guess = Math.ceil(highx / highy); - do { - check = multiplySmall(b, guess); - if (compareAbs(check, part) <= 0) break; - guess--; - } while (guess); - result.push(guess); - part = subtract(part, check); - } - result.reverse(); - return [arrayToSmall(result), arrayToSmall(part)]; - } - - function divModSmall(value, lambda) { - var length = value.length, - quotient = createArray(length), - base = BASE, - i, q, remainder, divisor; - remainder = 0; - for (i = length - 1; i >= 0; --i) { - divisor = remainder * base + value[i]; - q = truncate(divisor / lambda); - remainder = divisor - q * lambda; - quotient[i] = q | 0; - } - return [quotient, remainder | 0]; - } - - function divModAny(self, v) { - var value, n = parseValue(v); - var a = self.value, b = n.value; - var quotient; - if (b === 0) throw new Error("Cannot divide by zero"); - if (self.isSmall) { - if (n.isSmall) { - return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)]; - } - return [CACHE[0], self]; - } - if (n.isSmall) { - if (b === 1) return [self, CACHE[0]]; - if (b == -1) return [self.negate(), CACHE[0]]; - var abs = Math.abs(b); - if (abs < BASE) { - value = divModSmall(a, abs); - quotient = arrayToSmall(value[0]); - var remainder = value[1]; - if (self.sign) remainder = -remainder; - if (typeof quotient === "number") { - if (self.sign !== n.sign) quotient = -quotient; - return [new SmallInteger(quotient), new SmallInteger(remainder)]; - } - return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)]; - } - b = smallToArray(abs); - } - var comparison = compareAbs(a, b); - if (comparison === -1) return [CACHE[0], self]; - if (comparison === 0) return [CACHE[self.sign === n.sign ? 1 : -1], CACHE[0]]; - - // divMod1 is faster on smaller input sizes - if (a.length + b.length <= 200) - value = divMod1(a, b); - else value = divMod2(a, b); - - quotient = value[0]; - var qSign = self.sign !== n.sign, - mod = value[1], - mSign = self.sign; - if (typeof quotient === "number") { - if (qSign) quotient = -quotient; - quotient = new SmallInteger(quotient); - } else quotient = new BigInteger(quotient, qSign); - if (typeof mod === "number") { - if (mSign) mod = -mod; - mod = new SmallInteger(mod); - } else mod = new BigInteger(mod, mSign); - return [quotient, mod]; - } - - BigInteger.prototype.divmod = function (v) { - var result = divModAny(this, v); - return { - quotient: result[0], - remainder: result[1] - }; - }; - SmallInteger.prototype.divmod = BigInteger.prototype.divmod; - - BigInteger.prototype.divide = function (v) { - return divModAny(this, v)[0]; - }; - SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide; - - BigInteger.prototype.mod = function (v) { - return divModAny(this, v)[1]; - }; - SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod; - - BigInteger.prototype.pow = function (v) { - var n = parseValue(v), - a = this.value, - b = n.value, - value, x, y; - if (b === 0) return CACHE[1]; - if (a === 0) return CACHE[0]; - if (a === 1) return CACHE[1]; - if (a === -1) return n.isEven() ? CACHE[1] : CACHE[-1]; - if (n.sign) { - return CACHE[0]; - } - if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large."); - if (this.isSmall) { - if (isPrecise(value = Math.pow(a, b))) - return new SmallInteger(truncate(value)); - } - x = this; - y = CACHE[1]; - while (true) { - if (b & 1 === 1) { - y = y.times(x); - --b; - } - if (b === 0) break; - b /= 2; - x = x.square(); - } - return y; - }; - SmallInteger.prototype.pow = BigInteger.prototype.pow; - - BigInteger.prototype.modPow = function (exp, mod) { - exp = parseValue(exp); - mod = parseValue(mod); - if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0"); - var r = CACHE[1], - base = this.mod(mod); - while (exp.isPositive()) { - if (base.isZero()) return CACHE[0]; - if (exp.isOdd()) r = r.multiply(base).mod(mod); - exp = exp.divide(2); - base = base.square().mod(mod); - } - return r; - }; - SmallInteger.prototype.modPow = BigInteger.prototype.modPow; - - function compareAbs(a, b) { - if (a.length !== b.length) { - return a.length > b.length ? 1 : -1; - } - for (var i = a.length - 1; i >= 0; i--) { - if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1; - } - return 0; - } - - BigInteger.prototype.compareAbs = function (v) { - var n = parseValue(v), - a = this.value, - b = n.value; - if (n.isSmall) return 1; - return compareAbs(a, b); - }; - SmallInteger.prototype.compareAbs = function (v) { - var n = parseValue(v), - a = Math.abs(this.value), - b = n.value; - if (n.isSmall) { - b = Math.abs(b); - return a === b ? 0 : a > b ? 1 : -1; - } - return -1; - }; - - BigInteger.prototype.compare = function (v) { - // See discussion about comparison with Infinity: - // https://github.com/peterolson/BigInteger.js/issues/61 - if (v === Infinity) { - return -1; - } - if (v === -Infinity) { - return 1; - } - - var n = parseValue(v), - a = this.value, - b = n.value; - if (this.sign !== n.sign) { - return n.sign ? 1 : -1; - } - if (n.isSmall) { - return this.sign ? -1 : 1; - } - return compareAbs(a, b) * (this.sign ? -1 : 1); - }; - BigInteger.prototype.compareTo = BigInteger.prototype.compare; - - SmallInteger.prototype.compare = function (v) { - if (v === Infinity) { - return -1; - } - if (v === -Infinity) { - return 1; - } - - var n = parseValue(v), - a = this.value, - b = n.value; - if (n.isSmall) { - return a == b ? 0 : a > b ? 1 : -1; - } - if (a < 0 !== n.sign) { - return a < 0 ? -1 : 1; - } - return a < 0 ? 1 : -1; - }; - SmallInteger.prototype.compareTo = SmallInteger.prototype.compare; - - BigInteger.prototype.equals = function (v) { - return this.compare(v) === 0; - }; - SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals; - - BigInteger.prototype.notEquals = function (v) { - return this.compare(v) !== 0; - }; - SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals; - - BigInteger.prototype.greater = function (v) { - return this.compare(v) > 0; - }; - SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater; - - BigInteger.prototype.lesser = function (v) { - return this.compare(v) < 0; - }; - SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser; - - BigInteger.prototype.greaterOrEquals = function (v) { - return this.compare(v) >= 0; - }; - SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals; - - BigInteger.prototype.lesserOrEquals = function (v) { - return this.compare(v) <= 0; - }; - SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals; - - BigInteger.prototype.isEven = function () { - return (this.value[0] & 1) === 0; - }; - SmallInteger.prototype.isEven = function () { - return (this.value & 1) === 0; - }; - - BigInteger.prototype.isOdd = function () { - return (this.value[0] & 1) === 1; - }; - SmallInteger.prototype.isOdd = function () { - return (this.value & 1) === 1; - }; - - BigInteger.prototype.isPositive = function () { - return !this.sign; - }; - SmallInteger.prototype.isPositive = function () { - return this.value > 0; - }; - - BigInteger.prototype.isNegative = function () { - return this.sign; - }; - SmallInteger.prototype.isNegative = function () { - return this.value < 0; - }; - - BigInteger.prototype.isUnit = function () { - return false; - }; - SmallInteger.prototype.isUnit = function () { - return Math.abs(this.value) === 1; - }; - - BigInteger.prototype.isZero = function () { - return false; - }; - SmallInteger.prototype.isZero = function () { - return this.value === 0; - }; - BigInteger.prototype.isDivisibleBy = function (v) { - var n = parseValue(v); - var value = n.value; - if (value === 0) return false; - if (value === 1) return true; - if (value === 2) return this.isEven(); - return this.mod(n).equals(CACHE[0]); - }; - SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy; - - function isBasicPrime(v) { - var n = v.abs(); - if (n.isUnit()) return false; - if (n.equals(2) || n.equals(3) || n.equals(5)) return true; - if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false; - if (n.lesser(25)) return true; - // we don't know if it's prime: let the other functions figure it out - }; - - BigInteger.prototype.isPrime = function () { - var isPrime = isBasicPrime(this); - if (isPrime !== undefined) return isPrime; - var n = this.abs(), - nPrev = n.prev(); - var a = [2, 3, 5, 7, 11, 13, 17, 19], - b = nPrev, - d, t, i, x; - while (b.isEven()) b = b.divide(2); - for (i = 0; i < a.length; i++) { - x = bigInt(a[i]).modPow(b, n); - if (x.equals(CACHE[1]) || x.equals(nPrev)) continue; - for (t = true, d = b; t && d.lesser(nPrev) ; d = d.multiply(2)) { - x = x.square().mod(n); - if (x.equals(nPrev)) t = false; - } - if (t) return false; - } - return true; - }; - SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime; - - BigInteger.prototype.isProbablePrime = function (iterations) { - var isPrime = isBasicPrime(this); - if (isPrime !== undefined) return isPrime; - var n = this.abs(); - var t = iterations === undefined ? 5 : iterations; - // use the Fermat primality test - for (var i = 0; i < t; i++) { - var a = bigInt.randBetween(2, n.minus(2)); - if (!a.modPow(n.prev(), n).isUnit()) return false; // definitely composite - } - return true; // large chance of being prime - }; - SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime; - - BigInteger.prototype.next = function () { - var value = this.value; - if (this.sign) { - return subtractSmall(value, 1, this.sign); - } - return new BigInteger(addSmall(value, 1), this.sign); - }; - SmallInteger.prototype.next = function () { - var value = this.value; - if (value + 1 < MAX_INT) return new SmallInteger(value + 1); - return new BigInteger(MAX_INT_ARR, false); - }; - - BigInteger.prototype.prev = function () { - var value = this.value; - if (this.sign) { - return new BigInteger(addSmall(value, 1), true); - } - return subtractSmall(value, 1, this.sign); - }; - SmallInteger.prototype.prev = function () { - var value = this.value; - if (value - 1 > -MAX_INT) return new SmallInteger(value - 1); - return new BigInteger(MAX_INT_ARR, true); - }; - - var powersOfTwo = [1]; - while (powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]); - var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1]; - - function shift_isSmall(n) { - return ((typeof n === "number" || typeof n === "string") && +Math.abs(n) <= BASE) || - (n instanceof BigInteger && n.value.length <= 1); - } - - BigInteger.prototype.shiftLeft = function (n) { - if (!shift_isSmall(n)) { - throw new Error(String(n) + " is too large for shifting."); - } - n = +n; - if (n < 0) return this.shiftRight(-n); - var result = this; - while (n >= powers2Length) { - result = result.multiply(highestPower2); - n -= powers2Length - 1; - } - return result.multiply(powersOfTwo[n]); - }; - SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft; - - BigInteger.prototype.shiftRight = function (n) { - var remQuo; - if (!shift_isSmall(n)) { - throw new Error(String(n) + " is too large for shifting."); - } - n = +n; - if (n < 0) return this.shiftLeft(-n); - var result = this; - while (n >= powers2Length) { - if (result.isZero()) return result; - remQuo = divModAny(result, highestPower2); - result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; - n -= powers2Length - 1; - } - remQuo = divModAny(result, powersOfTwo[n]); - return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; - }; - SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight; - - function bitwise(x, y, fn) { - y = parseValue(y); - var xSign = x.isNegative(), ySign = y.isNegative(); - var xRem = xSign ? x.not() : x, - yRem = ySign ? y.not() : y; - var xBits = [], yBits = []; - var xStop = false, yStop = false; - while (!xStop || !yStop) { - if (xRem.isZero()) { // virtual sign extension for simulating two's complement - xStop = true; - xBits.push(xSign ? 1 : 0); - } - else if (xSign) xBits.push(xRem.isEven() ? 1 : 0); // two's complement for negative numbers - else xBits.push(xRem.isEven() ? 0 : 1); - - if (yRem.isZero()) { - yStop = true; - yBits.push(ySign ? 1 : 0); - } - else if (ySign) yBits.push(yRem.isEven() ? 1 : 0); - else yBits.push(yRem.isEven() ? 0 : 1); - - xRem = xRem.over(2); - yRem = yRem.over(2); - } - var result = []; - for (var i = 0; i < xBits.length; i++) result.push(fn(xBits[i], yBits[i])); - var sum = bigInt(result.pop()).negate().times(bigInt(2).pow(result.length)); - while (result.length) { - sum = sum.add(bigInt(result.pop()).times(bigInt(2).pow(result.length))); - } - return sum; - } - - BigInteger.prototype.not = function () { - return this.negate().prev(); - }; - SmallInteger.prototype.not = BigInteger.prototype.not; - - BigInteger.prototype.and = function (n) { - return bitwise(this, n, function (a, b) { return a & b; }); - }; - SmallInteger.prototype.and = BigInteger.prototype.and; - - BigInteger.prototype.or = function (n) { - return bitwise(this, n, function (a, b) { return a | b; }); - }; - SmallInteger.prototype.or = BigInteger.prototype.or; - - BigInteger.prototype.xor = function (n) { - return bitwise(this, n, function (a, b) { return a ^ b; }); - }; - SmallInteger.prototype.xor = BigInteger.prototype.xor; - - var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I; - function roughLOB(n) { // get lowestOneBit (rough) - // SmallInteger: return Min(lowestOneBit(n), 1 << 30) - // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7] - var v = n.value, x = typeof v === "number" ? v | LOBMASK_I : v[0] + v[1] * BASE | LOBMASK_BI; - return x & -x; - } - - function max(a, b) { - a = parseValue(a); - b = parseValue(b); - return a.greater(b) ? a : b; - } - function min(a,b) { - a = parseValue(a); - b = parseValue(b); - return a.lesser(b) ? a : b; - } - function gcd(a, b) { - a = parseValue(a).abs(); - b = parseValue(b).abs(); - if (a.equals(b)) return a; - if (a.isZero()) return b; - if (b.isZero()) return a; - var c = CACHE[1], d, t; - while (a.isEven() && b.isEven()) { - d = Math.min(roughLOB(a), roughLOB(b)); - a = a.divide(d); - b = b.divide(d); - c = c.multiply(d); - } - while (a.isEven()) { - a = a.divide(roughLOB(a)); - } - do { - while (b.isEven()) { - b = b.divide(roughLOB(b)); - } - if (a.greater(b)) { - t = b; b = a; a = t; - } - b = b.subtract(a); - } while (!b.isZero()); - return c.isUnit() ? a : a.multiply(c); - } - function lcm(a, b) { - a = parseValue(a).abs(); - b = parseValue(b).abs(); - return a.divide(gcd(a, b)).multiply(b); - } - function randBetween(a, b) { - a = parseValue(a); - b = parseValue(b); - var low = min(a, b), high = max(a, b); - var range = high.subtract(low); - if (range.isSmall) return low.add(Math.round(Math.random() * range)); - var length = range.value.length - 1; - var result = [], restricted = true; - for (var i = length; i >= 0; i--) { - var top = restricted ? range.value[i] : BASE; - var digit = truncate(Math.random() * top); - result.unshift(digit); - if (digit < top) restricted = false; - } - result = arrayToSmall(result); - return low.add(typeof result === "number" ? new SmallInteger(result) : new BigInteger(result, false)); - } - var parseBase = function (text, base) { - var val = CACHE[0], pow = CACHE[1], - length = text.length; - if (2 <= base && base <= 36) { - if (length <= LOG_MAX_INT / Math.log(base)) { - return new SmallInteger(parseInt(text, base)); - } - } - base = parseValue(base); - var digits = []; - var i; - var isNegative = text[0] === "-"; - for (i = isNegative ? 1 : 0; i < text.length; i++) { - var c = text[i].toLowerCase(), - charCode = c.charCodeAt(0); - if (48 <= charCode && charCode <= 57) digits.push(parseValue(c)); - else if (97 <= charCode && charCode <= 122) digits.push(parseValue(c.charCodeAt(0) - 87)); - else if (c === "<") { - var start = i; - do { i++; } while (text[i] !== ">"); - digits.push(parseValue(text.slice(start + 1, i))); - } - else throw new Error(c + " is not a valid character"); - } - digits.reverse(); - for (i = 0; i < digits.length; i++) { - val = val.add(digits[i].times(pow)); - pow = pow.times(base); - } - return isNegative ? val.negate() : val; - }; - - function stringify(digit) { - var v = digit.value; - if (typeof v === "number") v = [v]; - if (v.length === 1 && v[0] <= 35) { - return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0]); - } - return "<" + v + ">"; - } - function toBase(n, base) { - base = bigInt(base); - if (base.isZero()) { - if (n.isZero()) return "0"; - throw new Error("Cannot convert nonzero numbers to base 0."); - } - if (base.equals(-1)) { - if (n.isZero()) return "0"; - if (n.isNegative()) return new Array(1 - n).join("10"); - return "1" + new Array(+n).join("01"); - } - var minusSign = ""; - if (n.isNegative() && base.isPositive()) { - minusSign = "-"; - n = n.abs(); - } - if (base.equals(1)) { - if (n.isZero()) return "0"; - return minusSign + new Array(+n + 1).join(1); - } - var out = []; - var left = n, divmod; - while (left.isNegative() || left.compareAbs(base) >= 0) { - divmod = left.divmod(base); - left = divmod.quotient; - var digit = divmod.remainder; - if (digit.isNegative()) { - digit = base.minus(digit).abs(); - left = left.next(); - } - out.push(stringify(digit)); - } - out.push(stringify(left)); - return minusSign + out.reverse().join(""); - } - - BigInteger.prototype.toString = function (radix) { - if (radix === undefined) radix = 10; - if (radix !== 10) return toBase(this, radix); - var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit; - while (--l >= 0) { - digit = String(v[l]); - str += zeros.slice(digit.length) + digit; - } - var sign = this.sign ? "-" : ""; - return sign + str; - }; - SmallInteger.prototype.toString = function (radix) { - if (radix === undefined) radix = 10; - if (radix != 10) return toBase(this, radix); - return String(this.value); - }; - - BigInteger.prototype.valueOf = function () { - return +this.toString(); - }; - BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf; - - SmallInteger.prototype.valueOf = function () { - return this.value; - }; - SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf; - - function parseStringValue(v) { - if (isPrecise(+v)) { - var x = +v; - if (x === truncate(x)) - return new SmallInteger(x); - throw "Invalid integer: " + v; - } - var sign = v[0] === "-"; - if (sign) v = v.slice(1); - var split = v.split(/e/i); - if (split.length > 2) throw new Error("Invalid integer: " + text.join("e")); - if (split.length === 2) { - var exp = split[1]; - if (exp[0] === "+") exp = exp.slice(1); - exp = +exp; - if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent."); - var text = split[0]; - var decimalPlace = text.indexOf("."); - if (decimalPlace >= 0) { - exp -= text.length - decimalPlace - 1; - text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1); - } - if (exp < 0) throw new Error("Cannot include negative exponent part for integers"); - text += (new Array(exp + 1)).join("0"); - v = text; - } - var isValid = /^([0-9][0-9]*)$/.test(v); - if (!isValid) throw new Error("Invalid integer: " + v); - var r = [], max = v.length, l = LOG_BASE, min = max - l; - while (max > 0) { - r.push(+v.slice(min, max)); - min -= l; - if (min < 0) min = 0; - max -= l; - } - trim(r); - return new BigInteger(r, sign); - } - - function parseNumberValue(v) { - if (isPrecise(v)) return new SmallInteger(v); - return parseStringValue(v.toString()); - } - - function parseValue(v) { - if (typeof v === "number") { - return parseNumberValue(v); - } - if (typeof v === "string") { - return parseStringValue(v); - } - return v; - } - // Pre-define numbers in range [-999,999] - var CACHE = function (v, radix) { - if (typeof v === "undefined") return CACHE[0]; - if (typeof radix !== "undefined") return +radix === 10 ? parseValue(v) : parseBase(v, radix); - return parseValue(v); - }; - for (var i = 0; i < 1000; i++) { - CACHE[i] = new SmallInteger(i); - if (i > 0) CACHE[-i] = new SmallInteger(-i); - } - // Backwards compatibility - CACHE.one = CACHE[1]; - CACHE.zero = CACHE[0]; - CACHE.minusOne = CACHE[-1]; - CACHE.max = max; - CACHE.min = min; - CACHE.gcd = gcd; - CACHE.lcm = lcm; - CACHE.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; }; - CACHE.randBetween = randBetween; - return CACHE; -})(); - -// Node.js check -if (typeof module !== "undefined" && module.hasOwnProperty("exports")) { - module.exports = bigInt; -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/BigInteger.min.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/BigInteger.min.js deleted file mode 100644 index b39f103..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/BigInteger.min.js +++ /dev/null @@ -1 +0,0 @@ -var bigInt=function(e){"use strict";function o(e,t){this.value=e,this.sign=t,this.isSmall=!1}function u(e){this.value=e,this.sign=e<0,this.isSmall=!0}function a(e){return-r0?Math.floor(e):Math.ceil(e)}function d(e,n){var r=e.length,i=n.length,s=new Array(r),o=0,u=t,a,f;for(f=0;f=u?1:0,s[f]=a-o*u;while(f0&&s.push(o),s}function v(e,t){return e.length>=t.length?d(e,t):d(t,e)}function m(e,n){var r=e.length,i=new Array(r),s=t,o,u;for(u=0;u0)i[u++]=n%s,n=Math.floor(n/s);return i}function g(e,n){var r=e.length,i=n.length,s=new Array(r),o=0,u=t,a,f;for(a=0;a=0?r=g(e,t):(r=g(t,e),n=!n),r=l(r),typeof r=="number"?(n&&(r=-r),new u(r)):new o(r,n)}function b(e,n,r){var i=e.length,s=new Array(i),a=-n,f=t,c,h;for(c=0;c0)i[a++]=o%s,o=Math.floor(o/s);return i}function S(e,t){var n=[];while(t-->0)n.push(0);return n.concat(e)}function x(e,t){var n=Math.max(e.length,t.length);if(n<=400)return w(e,t);n=Math.ceil(n/2);var r=e.slice(n),i=e.slice(0,n),s=t.slice(n),o=t.slice(0,n),u=x(i,o),a=x(r,s),f=x(v(i,r),v(o,s));return v(v(u,S(g(g(f,u),a),n)),S(a,2*n))}function T(e,n,r){return e=0;d--){p=s-1,f[d+i]!==u&&(p=Math.floor((f[d+i]*s+f[d+i-1])/u)),v=0,m=0,y=c.length;for(g=0;gi&&(c=(c+1)*u),a=Math.ceil(c/h);do{p=E(n,a);if(O(p,o)<=0)break;a--}while(a);s.push(a),o=g(o,p)}return s.reverse(),[l(s),l(o)]}function L(e,n){var r=e.length,i=h(r),s=t,o,u,a,f;a=0;for(o=r-1;o>=0;--o)f=a*s+e[o],u=p(f/n),a=f-u*n,i[o]=u|0;return[i,a|0]}function A(e,n){var r,i=Q(n),s=e.value,a=i.value,c;if(a===0)throw new Error("Cannot divide by zero");if(e.isSmall)return i.isSmall?[new u(p(s/a)),new u(s%a)]:[G[0],e];if(i.isSmall){if(a===1)return[e,G[0]];if(a==-1)return[e.negate(),G[0]];var h=Math.abs(a);if(ht.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function M(e){var t=e.abs();if(t.isUnit())return!1;if(t.equals(2)||t.equals(3)||t.equals(5))return!0;if(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))return!1;if(t.lesser(25))return!0}function H(e){return(typeof e=="number"||typeof e=="string")&&+Math.abs(e)<=t||e instanceof o&&e.value.length<=1}function B(e,t,n){t=Q(t);var r=e.isNegative(),i=t.isNegative(),s=r?e.not():e,o=i?t.not():t,u=[],a=[],f=!1,l=!1;while(!f||!l)s.isZero()?(f=!0,u.push(r?1:0)):r?u.push(s.isEven()?1:0):u.push(s.isEven()?0:1),o.isZero()?(l=!0,a.push(i?1:0)):i?a.push(o.isEven()?1:0):a.push(o.isEven()?0:1),s=s.over(2),o=o.over(2);var c=[];for(var h=0;h=0;h--){var d=c?s.value[h]:t,v=p(Math.random()*d);f.unshift(v),v"}function $(e,t){t=bigInt(t);if(t.isZero()){if(e.isZero())return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1))return e.isZero()?"0":e.isNegative()?(new Array(1-e)).join("10"):"1"+(new Array(+e)).join("01");var n="";e.isNegative()&&t.isPositive()&&(n="-",e=e.abs());if(t.equals(1))return e.isZero()?"0":n+(new Array(+e+1)).join(1);var r=[],i=e,s;while(i.isNegative()||i.compareAbs(t)>=0){s=i.divmod(t),i=s.quotient;var o=s.remainder;o.isNegative()&&(o=t.minus(o).abs(),i=i.next()),r.push(V(o))}return r.push(V(i)),n+r.reverse().join("")}function J(e){if(a(+e)){var t=+e;if(t===p(t))return new u(t);throw"Invalid integer: "+e}var r=e[0]==="-";r&&(e=e.slice(1));var i=e.split(/e/i);if(i.length>2)throw new Error("Invalid integer: "+f.join("e"));if(i.length===2){var s=i[1];s[0]==="+"&&(s=s.slice(1)),s=+s;if(s!==p(s)||!a(s))throw new Error("Invalid integer: "+s+" is not a valid exponent.");var f=i[0],l=f.indexOf(".");l>=0&&(s-=f.length-l-1,f=f.slice(0,l)+f.slice(l+1));if(s<0)throw new Error("Cannot include negative exponent part for integers");f+=(new Array(s+1)).join("0"),e=f}var h=/^([0-9][0-9]*)$/.test(e);if(!h)throw new Error("Invalid integer: "+e);var d=[],v=e.length,m=n,g=v-m;while(v>0)d.push(+e.slice(g,v)),g-=m,g<0&&(g=0),v-=m;return c(d),new o(d,r)}function K(e){return a(e)?new u(e):J(e.toString())}function Q(e){return typeof e=="number"?K(e):typeof e=="string"?J(e):e}var t=1e7,n=7,r=9007199254740992,i=f(r),s=Math.log(r);o.prototype.add=function(e){var t,n=Q(e);if(this.sign!==n.sign)return this.subtract(n.negate());var r=this.value,i=n.value;return n.isSmall?new o(m(r,Math.abs(i)),this.sign):new o(v(r,i),this.sign)},o.prototype.plus=o.prototype.add,u.prototype.add=function(e){var t=Q(e),n=this.value;if(n<0!==t.sign)return this.subtract(t.negate());var r=t.value;if(t.isSmall){if(a(n+r))return new u(n+r);r=f(Math.abs(r))}return new o(m(r,Math.abs(n)),n<0)},u.prototype.plus=u.prototype.add,o.prototype.subtract=function(e){var t=Q(e);if(this.sign!==t.sign)return this.add(t.negate());var n=this.value,r=t.value;return t.isSmall?b(n,Math.abs(r),this.sign):y(n,r,this.sign)},o.prototype.minus=o.prototype.subtract,u.prototype.subtract=function(e){var t=Q(e),n=this.value;if(n<0!==t.sign)return this.add(t.negate());var r=t.value;return t.isSmall?new u(n-r):b(r,Math.abs(n),n>=0)},u.prototype.minus=u.prototype.subtract,o.prototype.negate=function(){return new o(this.value,!this.sign)},u.prototype.negate=function(){var e=this.sign,t=new u(-this.value);return t.sign=!e,t},o.prototype.abs=function(){return new o(this.value,!1)},u.prototype.abs=function(){return new u(Math.abs(this.value))},o.prototype.multiply=function(e){var n,r=Q(e),i=this.value,s=r.value,u=this.sign!==r.sign,a;if(r.isSmall){if(s===0)return G[0];if(s===1)return this;if(s===-1)return this.negate();a=Math.abs(s);if(a4e3?new o(x(i,s),u):new o(w(i,s),u)},o.prototype.times=o.prototype.multiply,u.prototype._multiplyBySmall=function(e){return a(e.value*this.value)?new u(e.value*this.value):T(Math.abs(e.value),f(Math.abs(this.value)),this.sign!==e.sign)},o.prototype._multiplyBySmall=function(e){return e.value===0?G[0]:e.value===1?this:e.value===-1?this.negate():T(Math.abs(e.value),this.value,this.sign!==e.sign)},u.prototype.multiply=function(e){return Q(e)._multiplyBySmall(this)},u.prototype.times=u.prototype.multiply,o.prototype.square=function(){return new o(N(this.value),!1)},u.prototype.square=function(){var e=this.value*this.value;return a(e)?new u(e):new o(N(f(Math.abs(this.value))),!1)},o.prototype.divmod=function(e){var t=A(this,e);return{quotient:t[0],remainder:t[1]}},u.prototype.divmod=o.prototype.divmod,o.prototype.divide=function(e){return A(this,e)[0]},u.prototype.over=u.prototype.divide=o.prototype.over=o.prototype.divide,o.prototype.mod=function(e){return A(this,e)[1]},u.prototype.remainder=u.prototype.mod=o.prototype.remainder=o.prototype.mod,o.prototype.pow=function(e){var t=Q(e),n=this.value,r=t.value,i,s,o;if(r===0)return G[1];if(n===0)return G[0];if(n===1)return G[1];if(n===-1)return t.isEven()?G[1]:G[-1];if(t.sign)return G[0];if(!t.isSmall)throw new Error("The exponent "+t.toString()+" is too large.");if(this.isSmall&&a(i=Math.pow(n,r)))return new u(p(i));s=this,o=G[1];for(;;){r&!0&&(o=o.times(s),--r);if(r===0)break;r/=2,s=s.square()}return o},u.prototype.pow=o.prototype.pow,o.prototype.modPow=function(e,t){e=Q(e),t=Q(t);if(t.isZero())throw new Error("Cannot take modPow with modulus 0");var n=G[1],r=this.mod(t);while(e.isPositive()){if(r.isZero())return G[0];e.isOdd()&&(n=n.multiply(r).mod(t)),e=e.divide(2),r=r.square().mod(t)}return n},u.prototype.modPow=o.prototype.modPow,o.prototype.compareAbs=function(e){var t=Q(e),n=this.value,r=t.value;return t.isSmall?1:O(n,r)},u.prototype.compareAbs=function(e){var t=Q(e),n=Math.abs(this.value),r=t.value;return t.isSmall?(r=Math.abs(r),n===r?0:n>r?1:-1):-1},o.prototype.compare=function(e){if(e===Infinity)return-1;if(e===-Infinity)return 1;var t=Q(e),n=this.value,r=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:O(n,r)*(this.sign?-1:1)},o.prototype.compareTo=o.prototype.compare,u.prototype.compare=function(e){if(e===Infinity)return-1;if(e===-Infinity)return 1;var t=Q(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0!==t.sign?n<0?-1:1:n<0?1:-1},u.prototype.compareTo=u.prototype.compare,o.prototype.equals=function(e){return this.compare(e)===0},u.prototype.eq=u.prototype.equals=o.prototype.eq=o.prototype.equals,o.prototype.notEquals=function(e){return this.compare(e)!==0},u.prototype.neq=u.prototype.notEquals=o.prototype.neq=o.prototype.notEquals,o.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=o.prototype.gt=o.prototype.greater,o.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=o.prototype.lt=o.prototype.lesser,o.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=o.prototype.geq=o.prototype.greaterOrEquals,o.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=o.prototype.leq=o.prototype.lesserOrEquals,o.prototype.isEven=function(){return(this.value[0]&1)===0},u.prototype.isEven=function(){return(this.value&1)===0},o.prototype.isOdd=function(){return(this.value[0]&1)===1},u.prototype.isOdd=function(){return(this.value&1)===1},o.prototype.isPositive=function(){return!this.sign},u.prototype.isPositive=function(){return this.value>0},o.prototype.isNegative=function(){return this.sign},u.prototype.isNegative=function(){return this.value<0},o.prototype.isUnit=function(){return!1},u.prototype.isUnit=function(){return Math.abs(this.value)===1},o.prototype.isZero=function(){return!1},u.prototype.isZero=function(){return this.value===0},o.prototype.isDivisibleBy=function(e){var t=Q(e),n=t.value;return n===0?!1:n===1?!0:n===2?this.isEven():this.mod(t).equals(G[0])},u.prototype.isDivisibleBy=o.prototype.isDivisibleBy,o.prototype.isPrime=function(){var t=M(this);if(t!==e)return t;var n=this.abs(),r=n.prev(),i=[2,3,5,7,11,13,17,19],s=r,o,u,a,f;while(s.isEven())s=s.divide(2);for(a=0;a-r?new u(e-1):new o(i,!0)};var _=[1];while(_[_.length-1]<=t)_.push(2*_[_.length-1]);var D=_.length,P=_[D-1];o.prototype.shiftLeft=function(e){if(!H(e))throw new Error(String(e)+" is too large for shifting.");e=+e;if(e<0)return this.shiftRight(-e);var t=this;while(e>=D)t=t.multiply(P),e-=D-1;return t.multiply(_[e])},u.prototype.shiftLeft=o.prototype.shiftLeft,o.prototype.shiftRight=function(e){var t;if(!H(e))throw new Error(String(e)+" is too large for shifting.");e=+e;if(e<0)return this.shiftLeft(-e);var n=this;while(e>=D){if(n.isZero())return n;t=A(n,P),n=t[1].isNegative()?t[0].prev():t[0],e-=D-1}return t=A(n,_[e]),t[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=o.prototype.shiftRight,o.prototype.not=function(){return this.negate().prev()},u.prototype.not=o.prototype.not,o.prototype.and=function(e){return B(this,e,function(e,t){return e&t})},u.prototype.and=o.prototype.and,o.prototype.or=function(e){return B(this,e,function(e,t){return e|t})},u.prototype.or=o.prototype.or,o.prototype.xor=function(e){return B(this,e,function(e,t){return e^t})},u.prototype.xor=o.prototype.xor;var j=1<<30,F=(t&-t)*(t&-t)|j,X=function(e,t){var n=G[0],r=G[1],i=e.length;if(2<=t&&t<=36&&i<=s/Math.log(t))return new u(parseInt(e,t));t=Q(t);var o=[],a,f=e[0]==="-";for(a=f?1:0;a");o.push(Q(e.slice(h+1,a)))}}o.reverse();for(a=0;a=0)o=String(n[r]),i+=s.slice(o.length)+o;var u=this.sign?"-":"";return u+i},u.prototype.toString=function(t){return t===e&&(t=10),t!=10?$(this,t):String(this.value)},o.prototype.valueOf=function(){return+this.toString()},o.prototype.toJSNumber=o.prototype.valueOf,u.prototype.valueOf=function(){return this.value},u.prototype.toJSNumber=u.prototype.valueOf;var G=function(e,t){return typeof e=="undefined"?G[0]:typeof t!="undefined"?+t===10?Q(e):X(e,t):Q(e)};for(var Y=0;Y<1e3;Y++)G[Y]=new u(Y),Y>0&&(G[-Y]=new u(-Y));return G.one=G[1],G.zero=G[0],G.minusOne=G[-1],G.max=q,G.min=R,G.gcd=U,G.lcm=z,G.isInstance=function(e){return e instanceof o||e instanceof u},G.randBetween=W,G}();typeof module!="undefined"&&module.hasOwnProperty("exports")&&(module.exports=bigInt); \ No newline at end of file diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/LICENSE b/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/LICENSE deleted file mode 100644 index cf1ab25..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/package.json deleted file mode 100644 index 5ec444f..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/node_modules/big-integer/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "big-integer", - "version": "1.6.10", - "author": { - "name": "Peter Olson", - "email": "peter.e.c.olson+npm@gmail.com" - }, - "description": "An arbitrary length integer library for Javascript", - "contributors": [], - "bin": {}, - "scripts": { - "test": "karma start my.conf.js" - }, - "main": "./BigInteger", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/peterolson/BigInteger.js.git" - }, - "keywords": [ - "math", - "big", - "bignum", - "bigint", - "biginteger", - "integer", - "arbitrary", - "precision", - "arithmetic" - ], - "devDependencies": { - "coveralls": "^2.11.4", - "jasmine": "2.1.x", - "jasmine-core": "^2.3.4", - "karma": "^0.13.3", - "karma-coverage": "^0.4.2", - "karma-jasmine": "^0.3.6", - "karma-phantomjs-launcher": "~0.1" - }, - "license": "Unlicense", - "engines": { - "node": ">=0.6" - }, - "gitHead": "e9a739fa1a15fe3da4eb302ea7072112ec91e318", - "bugs": { - "url": "https://github.com/peterolson/BigInteger.js/issues" - }, - "homepage": "https://github.com/peterolson/BigInteger.js#readme", - "_id": "big-integer@1.6.10", - "_shasum": "0f05dcce24278bc33bd8eb9297f4858acacb1fea", - "_from": "big-integer@>=1.6.7 <2.0.0", - "_npmVersion": "2.9.1", - "_nodeVersion": "0.12.3", - "_npmUser": { - "name": "peterolson", - "email": "peter.e.c.olson+npm@gmail.com" - }, - "maintainers": [ - { - "name": "peterolson", - "email": "peter.e.c.olson+npm@gmail.com" - } - ], - "dist": { - "shasum": "0f05dcce24278bc33bd8eb9297f4858acacb1fea", - "tarball": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.10.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.10.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/package.json deleted file mode 100644 index fb184ea..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/bplist-parser/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "bplist-parser", - "version": "0.1.1", - "description": "Binary plist parser.", - "main": "bplistParser.js", - "scripts": { - "test": "./node_modules/nodeunit/bin/nodeunit test" - }, - "keywords": [ - "bplist", - "plist", - "parser" - ], - "author": { - "name": "Joe Ferner", - "email": "joe.ferner@nearinfinity.com" - }, - "license": "MIT", - "devDependencies": { - "nodeunit": "~0.9.1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/nearinfinity/node-bplist-parser.git" - }, - "dependencies": { - "big-integer": "^1.6.7" - }, - "gitHead": "c4f22650de2cc95edd21a6e609ff0654a2b951bd", - "bugs": { - "url": "https://github.com/nearinfinity/node-bplist-parser/issues" - }, - "homepage": "https://github.com/nearinfinity/node-bplist-parser#readme", - "_id": "bplist-parser@0.1.1", - "_shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6", - "_from": "bplist-parser@>=0.1.0 <0.2.0", - "_npmVersion": "3.4.0", - "_nodeVersion": "5.1.0", - "_npmUser": { - "name": "joeferner", - "email": "joe@fernsroth.com" - }, - "dist": { - "shasum": "d60d5dcc20cba6dc7e1f299b35d3e1f95dafbae6", - "tarball": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz" - }, - "maintainers": [ - { - "name": "joeferner", - "email": "joe@fernsroth.com" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/index.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/index.js deleted file mode 100644 index 72279d0..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/index.js +++ /dev/null @@ -1,201 +0,0 @@ -var map = { - 'org.apache.cordova.battery-status':'cordova-plugin-battery-status', - 'org.apache.cordova.camera':'cordova-plugin-camera', - 'org.apache.cordova.console':'cordova-plugin-console', - 'org.apache.cordova.contacts':'cordova-plugin-contacts', - 'org.apache.cordova.device':'cordova-plugin-device', - 'org.apache.cordova.device-motion':'cordova-plugin-device-motion', - 'org.apache.cordova.device-orientation':'cordova-plugin-device-orientation', - 'org.apache.cordova.dialogs':'cordova-plugin-dialogs', - 'org.apache.cordova.file':'cordova-plugin-file', - 'org.apache.cordova.file-transfer':'cordova-plugin-file-transfer', - 'org.apache.cordova.geolocation':'cordova-plugin-geolocation', - 'org.apache.cordova.globalization':'cordova-plugin-globalization', - 'org.apache.cordova.inappbrowser':'cordova-plugin-inappbrowser', - 'org.apache.cordova.media':'cordova-plugin-media', - 'org.apache.cordova.media-capture':'cordova-plugin-media-capture', - 'org.apache.cordova.network-information':'cordova-plugin-network-information', - 'org.apache.cordova.splashscreen':'cordova-plugin-splashscreen', - 'org.apache.cordova.statusbar':'cordova-plugin-statusbar', - 'org.apache.cordova.vibration':'cordova-plugin-vibration', - 'org.apache.cordova.test-framework':'cordova-plugin-test-framework', - 'com.msopentech.websql' : 'cordova-plugin-websql', - 'com.msopentech.indexeddb' : 'cordova-plugin-indexeddb', - 'com.microsoft.aad.adal' : 'cordova-plugin-ms-adal', - 'com.microsoft.capptain' : 'capptain-cordova', - 'com.microsoft.services.aadgraph' : 'cordova-plugin-ms-aad-graph', - 'com.microsoft.services.files' : 'cordova-plugin-ms-files', - 'om.microsoft.services.outlook' : 'cordova-plugin-ms-outlook', - 'com.pbakondy.sim' : 'cordova-plugin-sim', - 'android.support.v4' : 'cordova-plugin-android-support-v4', - 'android.support.v7-appcompat' : 'cordova-plugin-android-support-v7-appcompat', - 'com.google.playservices' : 'cordova-plugin-googleplayservices', - 'com.google.cordova.admob' : 'cordova-plugin-admobpro', - 'com.rjfun.cordova.extension' : 'cordova-plugin-extension', - 'com.rjfun.cordova.plugin.admob' : 'cordova-plugin-admob', - 'com.rjfun.cordova.flurryads' : 'cordova-plugin-flurry', - 'com.rjfun.cordova.facebookads' : 'cordova-plugin-facebookads', - 'com.rjfun.cordova.httpd' : 'cordova-plugin-httpd', - 'com.rjfun.cordova.iad' : 'cordova-plugin-iad', - 'com.rjfun.cordova.iflyspeech' : 'cordova-plugin-iflyspeech', - 'com.rjfun.cordova.lianlianpay' : 'cordova-plugin-lianlianpay', - 'com.rjfun.cordova.mobfox' : 'cordova-plugin-mobfox', - 'com.rjfun.cordova.mopub' : 'cordova-plugin-mopub', - 'com.rjfun.cordova.mmedia' : 'cordova-plugin-mmedia', - 'com.rjfun.cordova.nativeaudio' : 'cordova-plugin-nativeaudio', - 'com.rjfun.cordova.plugin.paypalmpl' : 'cordova-plugin-paypalmpl', - 'com.rjfun.cordova.smartadserver' : 'cordova-plugin-smartadserver', - 'com.rjfun.cordova.sms' : 'cordova-plugin-sms', - 'com.rjfun.cordova.wifi' : 'cordova-plugin-wifi', - 'com.ohh2ahh.plugins.appavailability' : 'cordova-plugin-appavailability', - 'org.adapt-it.cordova.fonts' : 'cordova-plugin-fonts', - 'de.martinreinhardt.cordova.plugins.barcodeScanner' : 'cordova-plugin-barcodescanner', - 'de.martinreinhardt.cordova.plugins.urlhandler' : 'cordova-plugin-urlhandler', - 'de.martinreinhardt.cordova.plugins.email' : 'cordova-plugin-email', - 'de.martinreinhardt.cordova.plugins.certificates' : 'cordova-plugin-certificates', - 'de.martinreinhardt.cordova.plugins.sqlite' : 'cordova-plugin-sqlite', - 'fr.smile.cordova.fileopener' : 'cordova-plugin-fileopener', - 'org.smile.websqldatabase.initializer' : 'cordova-plugin-websqldatabase-initializer', - 'org.smile.websqldatabase.wpdb' : 'cordova-plugin-websqldatabase', - 'org.jboss.aerogear.cordova.push' : 'aerogear-cordova-push', - 'org.jboss.aerogear.cordova.oauth2' : 'aerogear-cordova-oauth2', - 'org.jboss.aerogear.cordova.geo' : 'aerogear-cordova-geo', - 'org.jboss.aerogear.cordova.crypto' : 'aerogear-cordova-crypto', - 'org.jboss.aerogaer.cordova.otp' : 'aerogear-cordova-otp', - 'uk.co.ilee.applewatch' : 'cordova-plugin-apple-watch', - 'uk.co.ilee.directions' : 'cordova-plugin-directions', - 'uk.co.ilee.gamecenter' : 'cordova-plugin-game-center', - 'uk.co.ilee.jailbreakdetection' : 'cordova-plugin-jailbreak-detection', - 'uk.co.ilee.nativetransitions' : 'cordova-plugin-native-transitions', - 'uk.co.ilee.pedometer' : 'cordova-plugin-pedometer', - 'uk.co.ilee.shake' : 'cordova-plugin-shake', - 'uk.co.ilee.touchid' : 'cordova-plugin-touchid', - 'com.knowledgecode.cordova.websocket' : 'cordova-plugin-websocket', - 'com.elixel.plugins.settings' : 'cordova-plugin-settings', - 'com.cowbell.cordova.geofence' : 'cordova-plugin-geofence', - 'com.blackberry.community.preventsleep' : 'cordova-plugin-preventsleep', - 'com.blackberry.community.gamepad' : 'cordova-plugin-gamepad', - 'com.blackberry.community.led' : 'cordova-plugin-led', - 'com.blackberry.community.thumbnail' : 'cordova-plugin-thumbnail', - 'com.blackberry.community.mediakeys' : 'cordova-plugin-mediakeys', - 'com.blackberry.community.simplebtlehrplugin' : 'cordova-plugin-bluetoothheartmonitor', - 'com.blackberry.community.simplebeaconplugin' : 'cordova-plugin-bluetoothibeacon', - 'com.blackberry.community.simplebtsppplugin' : 'cordova-plugin-bluetoothspp', - 'com.blackberry.community.clipboard' : 'cordova-plugin-clipboard', - 'com.blackberry.community.curl' : 'cordova-plugin-curl', - 'com.blackberry.community.qt' : 'cordova-plugin-qtbridge', - 'com.blackberry.community.upnp' : 'cordova-plugin-upnp', - 'com.blackberry.community.PasswordCrypto' : 'cordova-plugin-password-crypto', - 'com.blackberry.community.deviceinfoplugin' : 'cordova-plugin-deviceinfo', - 'com.blackberry.community.gsecrypto' : 'cordova-plugin-bb-crypto', - 'com.blackberry.community.mongoose' : 'cordova-plugin-mongoose', - 'com.blackberry.community.sysdialog' : 'cordova-plugin-bb-sysdialog', - 'com.blackberry.community.screendisplay' : 'cordova-plugin-screendisplay', - 'com.blackberry.community.messageplugin' : 'cordova-plugin-bb-messageretrieve', - 'com.blackberry.community.emailsenderplugin' : 'cordova-plugin-emailsender', - 'com.blackberry.community.audiometadata' : 'cordova-plugin-audiometadata', - 'com.blackberry.community.deviceemails' : 'cordova-plugin-deviceemails', - 'com.blackberry.community.audiorecorder' : 'cordova-plugin-audiorecorder', - 'com.blackberry.community.vibration' : 'cordova-plugin-vibrate-intense', - 'com.blackberry.community.SMSPlugin' : 'cordova-plugin-bb-sms', - 'com.blackberry.community.extractZipFile' : 'cordova-plugin-bb-zip', - 'com.blackberry.community.lowlatencyaudio' : 'cordova-plugin-bb-nativeaudio', - 'com.blackberry.community.barcodescanner' : 'phonegap-plugin-barcodescanner', - 'com.blackberry.app' : 'cordova-plugin-bb-app', - 'com.blackberry.bbm.platform' : 'cordova-plugin-bbm', - 'com.blackberry.connection' : 'cordova-plugin-bb-connection', - 'com.blackberry.identity' : 'cordova-plugin-bb-identity', - 'com.blackberry.invoke.card' : 'cordova-plugin-bb-card', - 'com.blackberry.invoke' : 'cordova-plugin-bb-invoke', - 'com.blackberry.invoked' : 'cordova-plugin-bb-invoked', - 'com.blackberry.io.filetransfer' : 'cordova-plugin-bb-filetransfer', - 'com.blackberry.io' : 'cordova-plugin-bb-io', - 'com.blackberry.notification' : 'cordova-plugin-bb-notification', - 'com.blackberry.payment' : 'cordova-plugin-bb-payment', - 'com.blackberry.pim.calendar' : 'cordova-plugin-bb-calendar', - 'com.blackberry.pim.contacts' : 'cordova-plugin-bb-contacts', - 'com.blackberry.pim.lib' : 'cordova-plugin-bb-pimlib', - 'com.blackberry.push' : 'cordova-plugin-bb-push', - 'com.blackberry.screenshot' : 'cordova-plugin-screenshot', - 'com.blackberry.sensors' : 'cordova-plugin-bb-sensors', - 'com.blackberry.system' : 'cordova-plugin-bb-system', - 'com.blackberry.ui.contextmenu' : 'cordova-plugin-bb-ctxmenu', - 'com.blackberry.ui.cover' : 'cordova-plugin-bb-cover', - 'com.blackberry.ui.dialog' : 'cordova-plugin-bb-dialog', - 'com.blackberry.ui.input' : 'cordova-plugin-touch-keyboard', - 'com.blackberry.ui.toast' : 'cordova-plugin-toast', - 'com.blackberry.user.identity' : 'cordova-plugin-bb-idservice', - 'com.blackberry.utils' : 'cordova-plugin-bb-utils', - 'net.yoik.cordova.plugins.screenorientation' : 'cordova-plugin-screen-orientation', - 'com.phonegap.plugins.barcodescanner' : 'phonegap-plugin-barcodescanner', - 'com.manifoldjs.hostedwebapp' : 'cordova-plugin-hostedwebapp', - 'com.initialxy.cordova.themeablebrowser' : 'cordova-plugin-themeablebrowser', - 'gr.denton.photosphere' : 'cordova-plugin-panoramaviewer', - 'nl.x-services.plugins.actionsheet' : 'cordova-plugin-actionsheet', - 'nl.x-services.plugins.socialsharing' : 'cordova-plugin-x-socialsharing', - 'nl.x-services.plugins.googleplus' : 'cordova-plugin-googleplus', - 'nl.x-services.plugins.insomnia' : 'cordova-plugin-insomnia', - 'nl.x-services.plugins.toast' : 'cordova-plugin-x-toast', - 'nl.x-services.plugins.calendar' : 'cordova-plugin-calendar', - 'nl.x-services.plugins.launchmyapp' : 'cordova-plugin-customurlscheme', - 'nl.x-services.plugins.flashlight' : 'cordova-plugin-flashlight', - 'nl.x-services.plugins.sslcertificatechecker' : 'cordova-plugin-sslcertificatechecker', - 'com.bridge.open' : 'cordova-open', - 'com.bridge.safe' : 'cordova-safe', - 'com.disusered.open' : 'cordova-open', - 'com.disusered.safe' : 'cordova-safe', - 'me.apla.cordova.app-preferences' : 'cordova-plugin-app-preferences', - 'com.konotor.cordova' : 'cordova-plugin-konotor', - 'io.intercom.cordova' : 'cordova-plugin-intercom', - 'com.onesignal.plugins.onesignal' : 'onesignal-cordova-plugin', - 'com.danjarvis.document-contract': 'cordova-plugin-document-contract', - 'com.eface2face.iosrtc' : 'cordova-plugin-iosrtc', - 'com.mobileapptracking.matplugin' : 'cordova-plugin-tune', - 'com.marianhello.cordova.background-geolocation' : 'cordova-plugin-mauron85-background-geolocation', - 'fr.louisbl.cordova.locationservices' : 'cordova-plugin-locationservices', - 'fr.louisbl.cordova.gpslocation' : 'cordova-plugin-gpslocation', - 'com.hiliaox.weibo' : 'cordova-plugin-weibo', - 'com.uxcam.cordova.plugin' : 'cordova-uxcam', - 'de.fastr.phonegap.plugins.downloader' : 'cordova-plugin-fastrde-downloader', - 'de.fastr.phonegap.plugins.injectView' : 'cordova-plugin-fastrde-injectview', - 'de.fastr.phonegap.plugins.CheckGPS' : 'cordova-plugin-fastrde-checkgps', - 'de.fastr.phonegap.plugins.md5chksum' : ' cordova-plugin-fastrde-md5', - 'io.repro.cordova' : 'cordova-plugin-repro', - 're.notifica.cordova': 'cordova-plugin-notificare-push', - 'com.megster.cordova.ble': 'cordova-plugin-ble-central', - 'com.megster.cordova.bluetoothserial': 'cordova-plugin-bluetooth-serial', - 'com.megster.cordova.rfduino': 'cordova-plugin-rfduino', - 'cz.velda.cordova.plugin.devicefeedback': 'cordova-plugin-velda-devicefeedback', - 'cz.Velda.cordova.plugin.devicefeedback': 'cordova-plugin-velda-devicefeedback', - 'org.scriptotek.appinfo': 'cordova-plugin-appinfo', - 'com.yezhiming.cordova.appinfo': 'cordova-plugin-appinfo', - 'pl.makingwaves.estimotebeacons': 'cordova-plugin-estimote', - 'com.evothings.ble': 'cordova-plugin-ble', - 'com.appsee.plugin' : 'cordova-plugin-appsee', - 'am.armsoft.plugins.listpicker': 'cordova-plugin-listpicker', - 'com.pushbots.push': 'pushbots-cordova-plugin', - 'com.admob.google': 'cordova-admob', - 'admob.ads.google': 'cordova-admob-ads', - 'admob.google.plugin': 'admob-google', - 'com.admob.admobads': 'admob-ads', - 'com.connectivity.monitor': 'cordova-connectivity-monitor', - 'com.ios.libgoogleadmobads': 'cordova-libgoogleadmobads', - 'com.google.play.services': 'cordova-google-play-services', - 'android.support.v13': 'cordova-android-support-v13', - 'android.support.v4': 'cordova-android-support-v4', // Duplicated key ;) - 'com.analytics.google': 'cordova-plugin-analytics', - 'com.analytics.adid.google': 'cordova-plugin-analytics-adid', - 'com.chariotsolutions.nfc.plugin': 'phonegap-nfc', - 'com.samz.mixpanel': 'cordova-plugin-mixpanel', - 'de.appplant.cordova.common.RegisterUserNotificationSettings': 'cordova-plugin-registerusernotificationsettings', - 'plugin.google.maps': 'cordova-plugin-googlemaps' -}; - -module.exports.oldToNew = map; - -var reverseMap = {}; -Object.keys(map).forEach(function(elem){ - reverseMap[map[elem]] = elem; -}); - -module.exports.newToOld = reverseMap; diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/package.json deleted file mode 100644 index e6aff05..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "cordova-registry-mapper", - "version": "1.1.14", - "description": "Maps old plugin ids to new plugin names for fetching from npm", - "main": "index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/stevengill/cordova-registry-mapper.git" - }, - "scripts": { - "test": "node tests/test.js" - }, - "keywords": [ - "cordova", - "plugins" - ], - "author": { - "name": "Steve Gill" - }, - "license": "Apache version 2.0", - "devDependencies": { - "tape": "^3.5.0" - }, - "gitHead": "0ad8505f61afaac3c7ab112e6e79bd61cb953762", - "bugs": { - "url": "https://github.com/stevengill/cordova-registry-mapper/issues" - }, - "homepage": "https://github.com/stevengill/cordova-registry-mapper#readme", - "_id": "cordova-registry-mapper@1.1.14", - "_shasum": "cca1084e1e3a1b4737405123989251d4a6a5ca07", - "_from": "cordova-registry-mapper@>=1.1.8 <2.0.0", - "_npmVersion": "3.5.1", - "_nodeVersion": "5.0.0", - "_npmUser": { - "name": "stevegill", - "email": "stevengill97@gmail.com" - }, - "dist": { - "shasum": "cca1084e1e3a1b4737405123989251d4a6a5ca07", - "tarball": "http://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.14.tgz" - }, - "maintainers": [ - { - "name": "stevegill", - "email": "stevengill97@gmail.com" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.14.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json deleted file mode 100644 index b5ee2f1..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "wrappy", - "version": "1.0.1", - "description": "Callback wrapping utility", - "main": "wrappy.js", - "directories": { - "test": "test" - }, - "dependencies": {}, - "devDependencies": { - "tap": "^0.4.12" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/npm/wrappy.git" - }, - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "ISC", - "bugs": { - "url": "https://github.com/npm/wrappy/issues" - }, - "homepage": "https://github.com/npm/wrappy", - "gitHead": "006a8cbac6b99988315834c207896eed71fd069a", - "_id": "wrappy@1.0.1", - "_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "_from": "wrappy@>=1.0.0 <2.0.0", - "_npmVersion": "2.0.0", - "_nodeVersion": "0.10.31", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "tarball": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" - }, - "_resolved": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/package.json deleted file mode 100644 index dafb7e0..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "inflight", - "version": "1.0.4", - "description": "Add callbacks to requests in flight to avoid async duplication", - "main": "inflight.js", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - }, - "devDependencies": { - "tap": "^0.4.10" - }, - "scripts": { - "test": "tap test.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/isaacs/inflight.git" - }, - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "bugs": { - "url": "https://github.com/isaacs/inflight/issues" - }, - "homepage": "https://github.com/isaacs/inflight", - "license": "ISC", - "gitHead": "c7b5531d572a867064d4a1da9e013e8910b7d1ba", - "_id": "inflight@1.0.4", - "_shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", - "_from": "inflight@>=1.0.4 <2.0.0", - "_npmVersion": "2.1.3", - "_nodeVersion": "0.10.32", - "_npmUser": { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "dist": { - "shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", - "tarball": "http://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/package.json deleted file mode 100644 index 435bd6e..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/package.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "inherits", - "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", - "version": "2.0.1", - "keywords": [ - "inheritance", - "class", - "klass", - "oop", - "object-oriented", - "inherits", - "browser", - "browserify" - ], - "main": "./inherits.js", - "browser": "./inherits_browser.js", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/inherits.git" - }, - "license": "ISC", - "scripts": { - "test": "node test" - }, - "bugs": { - "url": "https://github.com/isaacs/inherits/issues" - }, - "_id": "inherits@2.0.1", - "dist": { - "shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", - "tarball": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - }, - "_from": "inherits@>=2.0.0 <3.0.0", - "_npmVersion": "1.3.8", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", - "_resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/isaacs/inherits#readme" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js deleted file mode 100644 index a23104e..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +++ /dev/null @@ -1,191 +0,0 @@ -var concatMap = require('concat-map'); -var balanced = require('balanced-match'); - -module.exports = expandTop; - -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; - -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} - -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); -} - -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} - - -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; -} - -function expandTop(str) { - if (!str) - return []; - - return expand(escapeBraces(str), true).map(unescapeBraces); -} - -function identity(e) { - return e; -} - -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} - -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} - -function expand(str, isTop) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = /^(.*,)+(.+)?$/.test(m.body); - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } - - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, false) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el, false) }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); - } - } - - return expansions; -} - diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json deleted file mode 100644 index 64460d4..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "balanced-match", - "description": "Match balanced character pairs, like \"{\" and \"}\"", - "version": "0.3.0", - "repository": { - "type": "git", - "url": "git://github.com/juliangruber/balanced-match.git" - }, - "homepage": "https://github.com/juliangruber/balanced-match", - "main": "index.js", - "scripts": { - "test": "make test" - }, - "dependencies": {}, - "devDependencies": { - "tape": "~4.2.2" - }, - "keywords": [ - "match", - "regexp", - "test", - "balanced", - "parse" - ], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT", - "testling": { - "files": "test/*.js", - "browsers": [ - "ie/8..latest", - "firefox/20..latest", - "firefox/nightly", - "chrome/25..latest", - "chrome/canary", - "opera/12..latest", - "opera/next", - "safari/5.1..latest", - "ipad/6.0..latest", - "iphone/6.0..latest", - "android-browser/4.2..latest" - ] - }, - "gitHead": "a7114b0986554787e90b7ac595a043ca75ea77e5", - "bugs": { - "url": "https://github.com/juliangruber/balanced-match/issues" - }, - "_id": "balanced-match@0.3.0", - "_shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", - "_from": "balanced-match@>=0.3.0 <0.4.0", - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.1", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "dist": { - "shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", - "tarball": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz" - }, - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json deleted file mode 100644 index 10162a7..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "concat-map", - "description": "concatenative mapdashery", - "version": "0.0.1", - "repository": { - "type": "git", - "url": "git://github.com/substack/node-concat-map.git" - }, - "main": "index.js", - "keywords": [ - "concat", - "concatMap", - "map", - "functional", - "higher-order" - ], - "directories": { - "example": "example", - "test": "test" - }, - "scripts": { - "test": "tape test/*.js" - }, - "devDependencies": { - "tape": "~2.4.0" - }, - "license": "MIT", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "testling": { - "files": "test/*.js", - "browsers": { - "ie": [ - 6, - 7, - 8, - 9 - ], - "ff": [ - 3.5, - 10, - 15 - ], - "chrome": [ - 10, - 22 - ], - "safari": [ - 5.1 - ], - "opera": [ - 12 - ] - } - }, - "bugs": { - "url": "https://github.com/substack/node-concat-map/issues" - }, - "homepage": "https://github.com/substack/node-concat-map", - "_id": "concat-map@0.0.1", - "dist": { - "shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", - "tarball": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - }, - "_from": "concat-map@0.0.1", - "_npmVersion": "1.3.21", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", - "_resolved": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json deleted file mode 100644 index 58c7b2d..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "brace-expansion", - "description": "Brace expansion as known from sh/bash", - "version": "1.1.2", - "repository": { - "type": "git", - "url": "git://github.com/juliangruber/brace-expansion.git" - }, - "homepage": "https://github.com/juliangruber/brace-expansion", - "main": "index.js", - "scripts": { - "test": "tape test/*.js", - "gentest": "bash test/generate.sh" - }, - "dependencies": { - "balanced-match": "^0.3.0", - "concat-map": "0.0.1" - }, - "devDependencies": { - "tape": "4.2.2" - }, - "keywords": [], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT", - "testling": { - "files": "test/*.js", - "browsers": [ - "ie/8..latest", - "firefox/20..latest", - "firefox/nightly", - "chrome/25..latest", - "chrome/canary", - "opera/12..latest", - "opera/next", - "safari/5.1..latest", - "ipad/6.0..latest", - "iphone/6.0..latest", - "android-browser/4.2..latest" - ] - }, - "gitHead": "b03773a30fa516b1374945b68e9acb6253d595fa", - "bugs": { - "url": "https://github.com/juliangruber/brace-expansion/issues" - }, - "_id": "brace-expansion@1.1.2", - "_shasum": "f21445d0488b658e2771efd870eff51df29f04ef", - "_from": "brace-expansion@>=1.0.0 <2.0.0", - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.1", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "dist": { - "shasum": "f21445d0488b658e2771efd870eff51df29f04ef", - "tarball": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.2.tgz" - }, - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - { - "name": "isaacs", - "email": "isaacs@npmjs.com" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.2.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/package.json deleted file mode 100644 index 5cd95f2..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me" - }, - "name": "minimatch", - "description": "a glob matcher in javascript", - "version": "3.0.0", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/minimatch.git" - }, - "main": "minimatch.js", - "scripts": { - "posttest": "standard minimatch.js test/*.js", - "test": "tap test/*.js" - }, - "engines": { - "node": "*" - }, - "dependencies": { - "brace-expansion": "^1.0.0" - }, - "devDependencies": { - "standard": "^3.7.2", - "tap": "^1.2.0" - }, - "license": "ISC", - "files": [ - "minimatch.js" - ], - "gitHead": "270dbea567f0af6918cb18103e98c612aa717a20", - "bugs": { - "url": "https://github.com/isaacs/minimatch/issues" - }, - "homepage": "https://github.com/isaacs/minimatch#readme", - "_id": "minimatch@3.0.0", - "_shasum": "5236157a51e4f004c177fb3c527ff7dd78f0ef83", - "_from": "minimatch@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", - "_npmVersion": "3.3.2", - "_nodeVersion": "4.0.0", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "5236157a51e4f004c177fb3c527ff7dd78f0ef83", - "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/README.md b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/README.md deleted file mode 100644 index 98eab25..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# wrappy - -Callback wrapping utility - -## USAGE - -```javascript -var wrappy = require("wrappy") - -// var wrapper = wrappy(wrapperFunction) - -// make sure a cb is called only once -// See also: http://npm.im/once for this specific use case -var once = wrappy(function (cb) { - var called = false - return function () { - if (called) return - called = true - return cb.apply(this, arguments) - } -}) - -function printBoo () { - console.log('boo') -} -// has some rando property -printBoo.iAmBooPrinter = true - -var onlyPrintOnce = once(printBoo) - -onlyPrintOnce() // prints 'boo' -onlyPrintOnce() // does nothing - -// random property is retained! -assert.equal(onlyPrintOnce.iAmBooPrinter, true) -``` diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/package.json deleted file mode 100644 index b5ee2f1..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "wrappy", - "version": "1.0.1", - "description": "Callback wrapping utility", - "main": "wrappy.js", - "directories": { - "test": "test" - }, - "dependencies": {}, - "devDependencies": { - "tap": "^0.4.12" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/npm/wrappy.git" - }, - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "ISC", - "bugs": { - "url": "https://github.com/npm/wrappy/issues" - }, - "homepage": "https://github.com/npm/wrappy", - "gitHead": "006a8cbac6b99988315834c207896eed71fd069a", - "_id": "wrappy@1.0.1", - "_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "_from": "wrappy@>=1.0.0 <2.0.0", - "_npmVersion": "2.0.0", - "_nodeVersion": "0.10.31", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "tarball": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" - }, - "_resolved": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js deleted file mode 100644 index 5ed0fcd..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +++ /dev/null @@ -1,51 +0,0 @@ -var test = require('tap').test -var wrappy = require('../wrappy.js') - -test('basic', function (t) { - function onceifier (cb) { - var called = false - return function () { - if (called) return - called = true - return cb.apply(this, arguments) - } - } - onceifier.iAmOnce = {} - var once = wrappy(onceifier) - t.equal(once.iAmOnce, onceifier.iAmOnce) - - var called = 0 - function boo () { - t.equal(called, 0) - called++ - } - // has some rando property - boo.iAmBoo = true - - var onlyPrintOnce = once(boo) - - onlyPrintOnce() // prints 'boo' - onlyPrintOnce() // does nothing - t.equal(called, 1) - - // random property is retained! - t.equal(onlyPrintOnce.iAmBoo, true) - - var logs = [] - var logwrap = wrappy(function (msg, cb) { - logs.push(msg + ' wrapping cb') - return function () { - logs.push(msg + ' before cb') - var ret = cb.apply(this, arguments) - logs.push(msg + ' after cb') - } - }) - - var c = logwrap('foo', function () { - t.same(logs, [ 'foo wrapping cb', 'foo before cb' ]) - }) - c() - t.same(logs, [ 'foo wrapping cb', 'foo before cb', 'foo after cb' ]) - - t.end() -}) diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js deleted file mode 100644 index bb7e7d6..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +++ /dev/null @@ -1,33 +0,0 @@ -// Returns a wrapper function that returns a wrapped callback -// The wrapper function should do some stuff, and return a -// presumably different callback function. -// This makes sure that own properties are retained, so that -// decorations and such are not lost along the way. -module.exports = wrappy -function wrappy (fn, cb) { - if (fn && cb) return wrappy(fn)(cb) - - if (typeof fn !== 'function') - throw new TypeError('need wrapper function') - - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k] - }) - - return wrapper - - function wrapper() { - var args = new Array(arguments.length) - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i] - } - var ret = fn.apply(this, args) - var cb = args[args.length-1] - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k] - }) - } - return ret - } -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/package.json deleted file mode 100644 index 6e86138..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "once", - "version": "1.3.3", - "description": "Run a function exactly one time", - "main": "once.js", - "directories": { - "test": "test" - }, - "dependencies": { - "wrappy": "1" - }, - "devDependencies": { - "tap": "^1.2.0" - }, - "scripts": { - "test": "tap test/*.js" - }, - "files": [ - "once.js" - ], - "repository": { - "type": "git", - "url": "git://github.com/isaacs/once.git" - }, - "keywords": [ - "once", - "function", - "one", - "single" - ], - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "ISC", - "gitHead": "2ad558657e17fafd24803217ba854762842e4178", - "bugs": { - "url": "https://github.com/isaacs/once/issues" - }, - "homepage": "https://github.com/isaacs/once#readme", - "_id": "once@1.3.3", - "_shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20", - "_from": "once@>=1.3.0 <2.0.0", - "_npmVersion": "3.3.2", - "_nodeVersion": "4.0.0", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20", - "tarball": "http://registry.npmjs.org/once/-/once-1.3.3.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_resolved": "http://registry.npmjs.org/once/-/once-1.3.3.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/package.json deleted file mode 100644 index 1a12c82..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "path-is-absolute", - "version": "1.0.0", - "description": "Node.js 0.12 path.isAbsolute() ponyfill", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/path-is-absolute.git" - }, - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "node test.js" - }, - "files": [ - "index.js" - ], - "keywords": [ - "path", - "paths", - "file", - "dir", - "absolute", - "isabsolute", - "is-absolute", - "built-in", - "util", - "utils", - "core", - "ponyfill", - "polyfill", - "shim", - "is", - "detect", - "check" - ], - "gitHead": "7a76a0c9f2263192beedbe0a820e4d0baee5b7a1", - "bugs": { - "url": "https://github.com/sindresorhus/path-is-absolute/issues" - }, - "homepage": "https://github.com/sindresorhus/path-is-absolute", - "_id": "path-is-absolute@1.0.0", - "_shasum": "263dada66ab3f2fb10bf7f9d24dd8f3e570ef912", - "_from": "path-is-absolute@>=1.0.0 <2.0.0", - "_npmVersion": "2.5.1", - "_nodeVersion": "0.12.0", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "dist": { - "shasum": "263dada66ab3f2fb10bf7f9d24dd8f3e570ef912", - "tarball": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/package.json deleted file mode 100644 index e1d5cb7..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "name": "glob", - "description": "a little globber", - "version": "5.0.15", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/node-glob.git" - }, - "main": "glob.js", - "files": [ - "glob.js", - "sync.js", - "common.js" - ], - "engines": { - "node": "*" - }, - "dependencies": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "devDependencies": { - "mkdirp": "0", - "rimraf": "^2.2.8", - "tap": "^1.1.4", - "tick": "0.0.6" - }, - "scripts": { - "prepublish": "npm run benchclean", - "profclean": "rm -f v8.log profile.txt", - "test": "tap test/*.js --cov", - "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js", - "bench": "bash benchmark.sh", - "prof": "bash prof.sh && cat profile.txt", - "benchclean": "node benchclean.js" - }, - "license": "ISC", - "gitHead": "3a7e71d453dd80e75b196fd262dd23ed54beeceb", - "bugs": { - "url": "https://github.com/isaacs/node-glob/issues" - }, - "homepage": "https://github.com/isaacs/node-glob#readme", - "_id": "glob@5.0.15", - "_shasum": "1bc936b9e02f4a603fcc222ecf7633d30b8b93b1", - "_from": "glob@>=5.0.13 <6.0.0", - "_npmVersion": "3.3.2", - "_nodeVersion": "4.0.0", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "1bc936b9e02f4a603fcc222ecf7633d30b8b93b1", - "tarball": "http://registry.npmjs.org/glob/-/glob-5.0.15.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/package.json deleted file mode 100644 index 7078228..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "os-homedir", - "version": "1.0.1", - "description": "io.js 2.3.0 os.homedir() ponyfill", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/os-homedir.git" - }, - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "node test.js" - }, - "files": [ - "index.js" - ], - "keywords": [ - "built-in", - "core", - "ponyfill", - "polyfill", - "shim", - "os", - "homedir", - "home", - "dir", - "directory", - "folder", - "user", - "path" - ], - "devDependencies": { - "ava": "0.0.4", - "path-exists": "^1.0.0" - }, - "gitHead": "13ff83fbd13ebe286a6092286b2c634ab4534c5f", - "bugs": { - "url": "https://github.com/sindresorhus/os-homedir/issues" - }, - "homepage": "https://github.com/sindresorhus/os-homedir", - "_id": "os-homedir@1.0.1", - "_shasum": "0d62bdf44b916fd3bbdcf2cab191948fb094f007", - "_from": "os-homedir@>=1.0.0 <2.0.0", - "_npmVersion": "2.11.2", - "_nodeVersion": "0.12.5", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "dist": { - "shasum": "0d62bdf44b916fd3bbdcf2cab191948fb094f007", - "tarball": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz" - }, - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/package.json deleted file mode 100644 index 8a19b3f..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "os-tmpdir", - "version": "1.0.1", - "description": "Node.js os.tmpdir() ponyfill", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/os-tmpdir.git" - }, - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "node test.js" - }, - "files": [ - "index.js" - ], - "keywords": [ - "built-in", - "core", - "ponyfill", - "polyfill", - "shim", - "os", - "tmpdir", - "tempdir", - "tmp", - "temp", - "dir", - "directory", - "env", - "environment" - ], - "devDependencies": { - "ava": "0.0.4" - }, - "gitHead": "5c5d355f81378980db629d60128ad03e02b1c1e5", - "bugs": { - "url": "https://github.com/sindresorhus/os-tmpdir/issues" - }, - "homepage": "https://github.com/sindresorhus/os-tmpdir", - "_id": "os-tmpdir@1.0.1", - "_shasum": "e9b423a1edaf479882562e92ed71d7743a071b6e", - "_from": "os-tmpdir@>=1.0.0 <2.0.0", - "_npmVersion": "2.9.1", - "_nodeVersion": "0.12.3", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "dist": { - "shasum": "e9b423a1edaf479882562e92ed71d7743a071b6e", - "tarball": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz" - }, - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/package.json deleted file mode 100644 index 61262ea..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/package.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "osenv", - "version": "0.1.3", - "main": "osenv.js", - "directories": { - "test": "test" - }, - "dependencies": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - }, - "devDependencies": { - "tap": "^1.2.0" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/npm/osenv.git" - }, - "keywords": [ - "environment", - "variable", - "home", - "tmpdir", - "path", - "prompt", - "ps1" - ], - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "ISC", - "description": "Look up environment settings specific to different operating systems", - "gitHead": "f746b3405d8f9e28054d11b97e1436f6a15016c4", - "bugs": { - "url": "https://github.com/npm/osenv/issues" - }, - "homepage": "https://github.com/npm/osenv#readme", - "_id": "osenv@0.1.3", - "_shasum": "83cf05c6d6458fc4d5ac6362ea325d92f2754217", - "_from": "osenv@>=0.1.3 <0.2.0", - "_npmVersion": "3.0.0", - "_nodeVersion": "2.2.1", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "83cf05c6d6458fc4d5ac6362ea325d92f2754217", - "tarball": "http://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "robertkowalski", - "email": "rok@kowalski.gd" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "_resolved": "http://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/package.json deleted file mode 100644 index 82e0dca..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/base64-js/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "author": { - "name": "T. Jameson Little", - "email": "t.jameson.little@gmail.com" - }, - "name": "base64-js", - "description": "Base64 encoding/decoding in pure JS", - "version": "0.0.8", - "repository": { - "type": "git", - "url": "git://github.com/beatgammit/base64-js.git" - }, - "main": "lib/b64.js", - "scripts": { - "test": "tape test/*.js" - }, - "testling": { - "files": "test/*.js", - "browsers": [ - "ie/6..latest", - "chrome/4..latest", - "firefox/3..latest", - "safari/5.1..latest", - "opera/11.0..latest", - "iphone/6", - "ipad/6" - ] - }, - "engines": { - "node": ">= 0.4" - }, - "license": "MIT", - "dependencies": {}, - "devDependencies": { - "tape": "~2.3.2" - }, - "gitHead": "b4a8a5fa9b0caeddb5ad94dd1108253d8f2a315f", - "bugs": { - "url": "https://github.com/beatgammit/base64-js/issues" - }, - "homepage": "https://github.com/beatgammit/base64-js", - "_id": "base64-js@0.0.8", - "_shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978", - "_from": "base64-js@0.0.8", - "_npmVersion": "2.1.16", - "_nodeVersion": "0.10.35", - "_npmUser": { - "name": "feross", - "email": "feross@feross.org" - }, - "maintainers": [ - { - "name": "beatgammit", - "email": "t.jameson.little@gmail.com" - }, - { - "name": "feross", - "email": "feross@feross.org" - } - ], - "dist": { - "shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978", - "tarball": "http://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/package.json deleted file mode 100644 index b73c41e..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/package.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "util-deprecate", - "version": "1.0.2", - "description": "The Node.js `util.deprecate()` function with browser support", - "main": "node.js", - "browser": "browser.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git://github.com/TooTallNate/util-deprecate.git" - }, - "keywords": [ - "util", - "deprecate", - "browserify", - "browser", - "node" - ], - "author": { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net", - "url": "http://n8.io/" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/TooTallNate/util-deprecate/issues" - }, - "homepage": "https://github.com/TooTallNate/util-deprecate", - "gitHead": "475fb6857cd23fafff20c1be846c1350abf8e6d4", - "_id": "util-deprecate@1.0.2", - "_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", - "_from": "util-deprecate@1.0.2", - "_npmVersion": "2.14.4", - "_nodeVersion": "4.1.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "dist": { - "shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", - "tarball": "http://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/package.json deleted file mode 100644 index daef6d2..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/package.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "name": "lodash", - "version": "3.10.1", - "description": "The modern build of lodash modular utilities.", - "homepage": "https://lodash.com/", - "icon": "https://lodash.com/icon.svg", - "license": "MIT", - "main": "index.js", - "keywords": [ - "modules", - "stdlib", - "util" - ], - "author": { - "name": "John-David Dalton", - "email": "john.david.dalton@gmail.com", - "url": "http://allyoucanleet.com/" - }, - "contributors": [ - { - "name": "John-David Dalton", - "email": "john.david.dalton@gmail.com", - "url": "http://allyoucanleet.com/" - }, - { - "name": "Benjamin Tan", - "email": "demoneaux@gmail.com", - "url": "https://d10.github.io/" - }, - { - "name": "Blaine Bublitz", - "email": "blaine@iceddev.com", - "url": "http://www.iceddev.com/" - }, - { - "name": "Kit Cambridge", - "email": "github@kitcambridge.be", - "url": "http://kitcambridge.be/" - }, - { - "name": "Mathias Bynens", - "email": "mathias@qiwi.be", - "url": "https://mathiasbynens.be/" - } - ], - "repository": { - "type": "git", - "url": "git+https://github.com/lodash/lodash.git" - }, - "scripts": { - "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" - }, - "bugs": { - "url": "https://github.com/lodash/lodash/issues" - }, - "_id": "lodash@3.10.1", - "_shasum": "5bf45e8e49ba4189e17d482789dfd15bd140b7b6", - "_from": "lodash@>=3.5.0 <4.0.0", - "_npmVersion": "2.13.1", - "_nodeVersion": "0.12.5", - "_npmUser": { - "name": "jdalton", - "email": "john.david.dalton@gmail.com" - }, - "maintainers": [ - { - "name": "jdalton", - "email": "john.david.dalton@gmail.com" - }, - { - "name": "mathias", - "email": "mathias@qiwi.be" - }, - { - "name": "phated", - "email": "blaine@iceddev.com" - }, - { - "name": "kitcambridge", - "email": "github@kitcambridge.be" - }, - { - "name": "d10", - "email": "demoneaux@gmail.com" - } - ], - "dist": { - "shasum": "5bf45e8e49ba4189e17d482789dfd15bd140b7b6", - "tarball": "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/package.json deleted file mode 100644 index e2c86ed..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "xmlbuilder", - "version": "4.0.0", - "keywords": [ - "xml", - "xmlbuilder" - ], - "homepage": "http://github.com/oozcitak/xmlbuilder-js", - "description": "An XML builder for node.js", - "author": { - "name": "Ozgur Ozcitak", - "email": "oozcitak@gmail.com" - }, - "contributors": [], - "license": "MIT", - "repository": { - "type": "git", - "url": "git://github.com/oozcitak/xmlbuilder-js.git" - }, - "bugs": { - "url": "http://github.com/oozcitak/xmlbuilder-js/issues" - }, - "main": "./lib/index", - "engines": { - "node": ">=0.8.0" - }, - "dependencies": { - "lodash": "^3.5.0" - }, - "devDependencies": { - "coffee-script": "*", - "mocha": "*", - "coffee-coverage": "*", - "istanbul": "*", - "coveralls": "*" - }, - "scripts": { - "prepublish": "coffee -co lib src", - "postpublish": "rm -rf lib", - "test": "mocha && istanbul report text lcov" - }, - "gitHead": "ec17840a6705ef666b7d04c771de11df6091fff5", - "_id": "xmlbuilder@4.0.0", - "_shasum": "98b8f651ca30aa624036f127d11cc66dc7b907a3", - "_from": "xmlbuilder@4.0.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "oozcitak", - "email": "oozcitak@gmail.com" - }, - "maintainers": [ - { - "name": "oozcitak", - "email": "oozcitak@gmail.com" - } - ], - "dist": { - "shasum": "98b8f651ca30aa624036f127d11cc66dc7b907a3", - "tarball": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.0.0.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.0.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/dom-parser.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/dom-parser.js deleted file mode 100644 index 7d763f4..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/dom-parser.js +++ /dev/null @@ -1,256 +0,0 @@ -function DOMParser(options){ - this.options = options ||{locator:{}}; - -} -DOMParser.prototype.parseFromString = function(source,mimeType){ - var options = this.options; - var sax = new XMLReader(); - var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler - var errorHandler = options.errorHandler; - var locator = options.locator; - var defaultNSMap = options.xmlns||{}; - var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"} - if(locator){ - domBuilder.setDocumentLocator(locator) - } - - sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator); - sax.domBuilder = options.domBuilder || domBuilder; - if(/\/x?html?$/.test(mimeType)){ - entityMap.nbsp = '\xa0'; - entityMap.copy = '\xa9'; - defaultNSMap['']= 'http://www.w3.org/1999/xhtml'; - } - defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace'; - if(source){ - sax.parse(source,defaultNSMap,entityMap); - }else{ - sax.errorHandler.error("invalid document source"); - } - return domBuilder.document; -} -function buildErrorHandler(errorImpl,domBuilder,locator){ - if(!errorImpl){ - if(domBuilder instanceof DOMHandler){ - return domBuilder; - } - errorImpl = domBuilder ; - } - var errorHandler = {} - var isCallback = errorImpl instanceof Function; - locator = locator||{} - function build(key){ - var fn = errorImpl[key]; - if(!fn){ - if(isCallback){ - fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl; - }else{ - var i=arguments.length; - while(--i){ - if(fn = errorImpl[arguments[i]]){ - break; - } - } - } - } - errorHandler[key] = fn && function(msg){ - fn(msg+_locator(locator)); - }||function(){}; - } - build('warning','warn'); - build('error','warn','warning'); - build('fatalError','warn','warning','error'); - return errorHandler; -} -/** - * +ContentHandler+ErrorHandler - * +LexicalHandler+EntityResolver2 - * -DeclHandler-DTDHandler - * - * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler - * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2 - * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html - */ -function DOMHandler() { - this.cdata = false; -} -function position(locator,node){ - node.lineNumber = locator.lineNumber; - node.columnNumber = locator.columnNumber; -} -/** - * @see org.xml.sax.ContentHandler#startDocument - * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html - */ -DOMHandler.prototype = { - startDocument : function() { - this.document = new DOMImplementation().createDocument(null, null, null); - if (this.locator) { - this.document.documentURI = this.locator.systemId; - } - }, - startElement:function(namespaceURI, localName, qName, attrs) { - var doc = this.document; - var el = doc.createElementNS(namespaceURI, qName||localName); - var len = attrs.length; - appendElement(this, el); - this.currentElement = el; - - this.locator && position(this.locator,el) - for (var i = 0 ; i < len; i++) { - var namespaceURI = attrs.getURI(i); - var value = attrs.getValue(i); - var qName = attrs.getQName(i); - var attr = doc.createAttributeNS(namespaceURI, qName); - if( attr.getOffset){ - position(attr.getOffset(1),attr) - } - attr.value = attr.nodeValue = value; - el.setAttributeNode(attr) - } - }, - endElement:function(namespaceURI, localName, qName) { - var current = this.currentElement - var tagName = current.tagName; - this.currentElement = current.parentNode; - }, - startPrefixMapping:function(prefix, uri) { - }, - endPrefixMapping:function(prefix) { - }, - processingInstruction:function(target, data) { - var ins = this.document.createProcessingInstruction(target, data); - this.locator && position(this.locator,ins) - appendElement(this, ins); - }, - ignorableWhitespace:function(ch, start, length) { - }, - characters:function(chars, start, length) { - chars = _toString.apply(this,arguments) - //console.log(chars) - if(this.currentElement && chars){ - if (this.cdata) { - var charNode = this.document.createCDATASection(chars); - this.currentElement.appendChild(charNode); - } else { - var charNode = this.document.createTextNode(chars); - this.currentElement.appendChild(charNode); - } - this.locator && position(this.locator,charNode) - } - }, - skippedEntity:function(name) { - }, - endDocument:function() { - this.document.normalize(); - }, - setDocumentLocator:function (locator) { - if(this.locator = locator){// && !('lineNumber' in locator)){ - locator.lineNumber = 0; - } - }, - //LexicalHandler - comment:function(chars, start, length) { - chars = _toString.apply(this,arguments) - var comm = this.document.createComment(chars); - this.locator && position(this.locator,comm) - appendElement(this, comm); - }, - - startCDATA:function() { - //used in characters() methods - this.cdata = true; - }, - endCDATA:function() { - this.cdata = false; - }, - - startDTD:function(name, publicId, systemId) { - var impl = this.document.implementation; - if (impl && impl.createDocumentType) { - var dt = impl.createDocumentType(name, publicId, systemId); - this.locator && position(this.locator,dt) - appendElement(this, dt); - } - }, - /** - * @see org.xml.sax.ErrorHandler - * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html - */ - warning:function(error) { - console.warn(error,_locator(this.locator)); - }, - error:function(error) { - console.error(error,_locator(this.locator)); - }, - fatalError:function(error) { - console.error(error,_locator(this.locator)); - throw error; - } -} -function _locator(l){ - if(l){ - return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']' - } -} -function _toString(chars,start,length){ - if(typeof chars == 'string'){ - return chars.substr(start,length) - }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)") - if(chars.length >= start+length || start){ - return new java.lang.String(chars,start,length)+''; - } - return chars; - } -} - -/* - * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html - * used method of org.xml.sax.ext.LexicalHandler: - * #comment(chars, start, length) - * #startCDATA() - * #endCDATA() - * #startDTD(name, publicId, systemId) - * - * - * IGNORED method of org.xml.sax.ext.LexicalHandler: - * #endDTD() - * #startEntity(name) - * #endEntity(name) - * - * - * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html - * IGNORED method of org.xml.sax.ext.DeclHandler - * #attributeDecl(eName, aName, type, mode, value) - * #elementDecl(name, model) - * #externalEntityDecl(name, publicId, systemId) - * #internalEntityDecl(name, value) - * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html - * IGNORED method of org.xml.sax.EntityResolver2 - * #resolveEntity(String name,String publicId,String baseURI,String systemId) - * #resolveEntity(publicId, systemId) - * #getExternalSubset(name, baseURI) - * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html - * IGNORED method of org.xml.sax.DTDHandler - * #notationDecl(name, publicId, systemId) {}; - * #unparsedEntityDecl(name, publicId, systemId, notationName) {}; - */ -"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){ - DOMHandler.prototype[key] = function(){return null} -}) - -/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ -function appendElement (hander,node) { - if (!hander.currentElement) { - hander.document.appendChild(node); - } else { - hander.currentElement.appendChild(node); - } -}//appendChild and setAttributeNS are preformance key - -if(typeof require == 'function'){ - var XMLReader = require('./sax').XMLReader; - var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation; - exports.XMLSerializer = require('./dom').XMLSerializer ; - exports.DOMParser = DOMParser; -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/dom.js b/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/dom.js deleted file mode 100644 index 0a3b8ad..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/dom.js +++ /dev/null @@ -1,1141 +0,0 @@ -/* - * DOM Level 2 - * Object DOMException - * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html - * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html - */ - -function copy(src,dest){ - for(var p in src){ - dest[p] = src[p]; - } -} -/** -^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));? -^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));? - */ -function _extends(Class,Super){ - var pt = Class.prototype; - if(Object.create){ - var ppt = Object.create(Super.prototype) - pt.__proto__ = ppt; - } - if(!(pt instanceof Super)){ - function t(){}; - t.prototype = Super.prototype; - t = new t(); - copy(pt,t); - Class.prototype = pt = t; - } - if(pt.constructor != Class){ - if(typeof Class != 'function'){ - console.error("unknow Class:"+Class) - } - pt.constructor = Class - } -} -var htmlns = 'http://www.w3.org/1999/xhtml' ; -// Node Types -var NodeType = {} -var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1; -var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2; -var TEXT_NODE = NodeType.TEXT_NODE = 3; -var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4; -var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5; -var ENTITY_NODE = NodeType.ENTITY_NODE = 6; -var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7; -var COMMENT_NODE = NodeType.COMMENT_NODE = 8; -var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9; -var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10; -var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11; -var NOTATION_NODE = NodeType.NOTATION_NODE = 12; - -// ExceptionCode -var ExceptionCode = {} -var ExceptionMessage = {}; -var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1); -var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2); -var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3); -var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4); -var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5); -var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6); -var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7); -var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8); -var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9); -var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10); -//level2 -var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11); -var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12); -var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13); -var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14); -var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15); - - -function DOMException(code, message) { - if(message instanceof Error){ - var error = message; - }else{ - error = this; - Error.call(this, ExceptionMessage[code]); - this.message = ExceptionMessage[code]; - if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException); - } - error.code = code; - if(message) this.message = this.message + ": " + message; - return error; -}; -DOMException.prototype = Error.prototype; -copy(ExceptionCode,DOMException) -/** - * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177 - * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. - * The items in the NodeList are accessible via an integral index, starting from 0. - */ -function NodeList() { -}; -NodeList.prototype = { - /** - * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. - * @standard level1 - */ - length:0, - /** - * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null. - * @standard level1 - * @param index unsigned long - * Index into the collection. - * @return Node - * The node at the indexth position in the NodeList, or null if that is not a valid index. - */ - item: function(index) { - return this[index] || null; - } -}; -function LiveNodeList(node,refresh){ - this._node = node; - this._refresh = refresh - _updateLiveList(this); -} -function _updateLiveList(list){ - var inc = list._node._inc || list._node.ownerDocument._inc; - if(list._inc != inc){ - var ls = list._refresh(list._node); - //console.log(ls.length) - __set__(list,'length',ls.length); - copy(ls,list); - list._inc = inc; - } -} -LiveNodeList.prototype.item = function(i){ - _updateLiveList(this); - return this[i]; -} - -_extends(LiveNodeList,NodeList); -/** - * - * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes. - * NamedNodeMap objects in the DOM are live. - * used for attributes or DocumentType entities - */ -function NamedNodeMap() { -}; - -function _findNodeIndex(list,node){ - var i = list.length; - while(i--){ - if(list[i] === node){return i} - } -} - -function _addNamedNode(el,list,newAttr,oldAttr){ - if(oldAttr){ - list[_findNodeIndex(list,oldAttr)] = newAttr; - }else{ - list[list.length++] = newAttr; - } - if(el){ - newAttr.ownerElement = el; - var doc = el.ownerDocument; - if(doc){ - oldAttr && _onRemoveAttribute(doc,el,oldAttr); - _onAddAttribute(doc,el,newAttr); - } - } -} -function _removeNamedNode(el,list,attr){ - var i = _findNodeIndex(list,attr); - if(i>=0){ - var lastIndex = list.length-1 - while(i0 || key == 'xmlns'){ -// return null; -// } - var i = this.length; - while(i--){ - var attr = this[i]; - if(attr.nodeName == key){ - return attr; - } - } - }, - setNamedItem: function(attr) { - var el = attr.ownerElement; - if(el && el!=this._ownerElement){ - throw new DOMException(INUSE_ATTRIBUTE_ERR); - } - var oldAttr = this.getNamedItem(attr.nodeName); - _addNamedNode(this._ownerElement,this,attr,oldAttr); - return oldAttr; - }, - /* returns Node */ - setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR - var el = attr.ownerElement, oldAttr; - if(el && el!=this._ownerElement){ - throw new DOMException(INUSE_ATTRIBUTE_ERR); - } - oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName); - _addNamedNode(this._ownerElement,this,attr,oldAttr); - return oldAttr; - }, - - /* returns Node */ - removeNamedItem: function(key) { - var attr = this.getNamedItem(key); - _removeNamedNode(this._ownerElement,this,attr); - return attr; - - - },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR - - //for level2 - removeNamedItemNS:function(namespaceURI,localName){ - var attr = this.getNamedItemNS(namespaceURI,localName); - _removeNamedNode(this._ownerElement,this,attr); - return attr; - }, - getNamedItemNS: function(namespaceURI, localName) { - var i = this.length; - while(i--){ - var node = this[i]; - if(node.localName == localName && node.namespaceURI == namespaceURI){ - return node; - } - } - return null; - } -}; -/** - * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 - */ -function DOMImplementation(/* Object */ features) { - this._features = {}; - if (features) { - for (var feature in features) { - this._features = features[feature]; - } - } -}; - -DOMImplementation.prototype = { - hasFeature: function(/* string */ feature, /* string */ version) { - var versions = this._features[feature.toLowerCase()]; - if (versions && (!version || version in versions)) { - return true; - } else { - return false; - } - }, - // Introduced in DOM Level 2: - createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR - var doc = new Document(); - doc.implementation = this; - doc.childNodes = new NodeList(); - doc.doctype = doctype; - if(doctype){ - doc.appendChild(doctype); - } - if(qualifiedName){ - var root = doc.createElementNS(namespaceURI,qualifiedName); - doc.appendChild(root); - } - return doc; - }, - // Introduced in DOM Level 2: - createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR - var node = new DocumentType(); - node.name = qualifiedName; - node.nodeName = qualifiedName; - node.publicId = publicId; - node.systemId = systemId; - // Introduced in DOM Level 2: - //readonly attribute DOMString internalSubset; - - //TODO:.. - // readonly attribute NamedNodeMap entities; - // readonly attribute NamedNodeMap notations; - return node; - } -}; - - -/** - * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247 - */ - -function Node() { -}; - -Node.prototype = { - firstChild : null, - lastChild : null, - previousSibling : null, - nextSibling : null, - attributes : null, - parentNode : null, - childNodes : null, - ownerDocument : null, - nodeValue : null, - namespaceURI : null, - prefix : null, - localName : null, - // Modified in DOM Level 2: - insertBefore:function(newChild, refChild){//raises - return _insertBefore(this,newChild,refChild); - }, - replaceChild:function(newChild, oldChild){//raises - this.insertBefore(newChild,oldChild); - if(oldChild){ - this.removeChild(oldChild); - } - }, - removeChild:function(oldChild){ - return _removeChild(this,oldChild); - }, - appendChild:function(newChild){ - return this.insertBefore(newChild,null); - }, - hasChildNodes:function(){ - return this.firstChild != null; - }, - cloneNode:function(deep){ - return cloneNode(this.ownerDocument||this,this,deep); - }, - // Modified in DOM Level 2: - normalize:function(){ - var child = this.firstChild; - while(child){ - var next = child.nextSibling; - if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){ - this.removeChild(next); - child.appendData(next.data); - }else{ - child.normalize(); - child = next; - } - } - }, - // Introduced in DOM Level 2: - isSupported:function(feature, version){ - return this.ownerDocument.implementation.hasFeature(feature,version); - }, - // Introduced in DOM Level 2: - hasAttributes:function(){ - return this.attributes.length>0; - }, - lookupPrefix:function(namespaceURI){ - var el = this; - while(el){ - var map = el._nsMap; - //console.dir(map) - if(map){ - for(var n in map){ - if(map[n] == namespaceURI){ - return n; - } - } - } - el = el.nodeType == 2?el.ownerDocument : el.parentNode; - } - return null; - }, - // Introduced in DOM Level 3: - lookupNamespaceURI:function(prefix){ - var el = this; - while(el){ - var map = el._nsMap; - //console.dir(map) - if(map){ - if(prefix in map){ - return map[prefix] ; - } - } - el = el.nodeType == 2?el.ownerDocument : el.parentNode; - } - return null; - }, - // Introduced in DOM Level 3: - isDefaultNamespace:function(namespaceURI){ - var prefix = this.lookupPrefix(namespaceURI); - return prefix == null; - } -}; - - -function _xmlEncoder(c){ - return c == '<' && '<' || - c == '>' && '>' || - c == '&' && '&' || - c == '"' && '"' || - '&#'+c.charCodeAt()+';' -} - - -copy(NodeType,Node); -copy(NodeType,Node.prototype); - -/** - * @param callback return true for continue,false for break - * @return boolean true: break visit; - */ -function _visitNode(node,callback){ - if(callback(node)){ - return true; - } - if(node = node.firstChild){ - do{ - if(_visitNode(node,callback)){return true} - }while(node=node.nextSibling) - } -} - - - -function Document(){ -} -function _onAddAttribute(doc,el,newAttr){ - doc && doc._inc++; - var ns = newAttr.namespaceURI ; - if(ns == 'http://www.w3.org/2000/xmlns/'){ - //update namespace - el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value - } -} -function _onRemoveAttribute(doc,el,newAttr,remove){ - doc && doc._inc++; - var ns = newAttr.namespaceURI ; - if(ns == 'http://www.w3.org/2000/xmlns/'){ - //update namespace - delete el._nsMap[newAttr.prefix?newAttr.localName:''] - } -} -function _onUpdateChild(doc,el,newChild){ - if(doc && doc._inc){ - doc._inc++; - //update childNodes - var cs = el.childNodes; - if(newChild){ - cs[cs.length++] = newChild; - }else{ - //console.log(1) - var child = el.firstChild; - var i = 0; - while(child){ - cs[i++] = child; - child =child.nextSibling; - } - cs.length = i; - } - } -} - -/** - * attributes; - * children; - * - * writeable properties: - * nodeValue,Attr:value,CharacterData:data - * prefix - */ -function _removeChild(parentNode,child){ - var previous = child.previousSibling; - var next = child.nextSibling; - if(previous){ - previous.nextSibling = next; - }else{ - parentNode.firstChild = next - } - if(next){ - next.previousSibling = previous; - }else{ - parentNode.lastChild = previous; - } - _onUpdateChild(parentNode.ownerDocument,parentNode); - return child; -} -/** - * preformance key(refChild == null) - */ -function _insertBefore(parentNode,newChild,nextChild){ - var cp = newChild.parentNode; - if(cp){ - cp.removeChild(newChild);//remove and update - } - if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ - var newFirst = newChild.firstChild; - if (newFirst == null) { - return newChild; - } - var newLast = newChild.lastChild; - }else{ - newFirst = newLast = newChild; - } - var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild; - - newFirst.previousSibling = pre; - newLast.nextSibling = nextChild; - - - if(pre){ - pre.nextSibling = newFirst; - }else{ - parentNode.firstChild = newFirst; - } - if(nextChild == null){ - parentNode.lastChild = newLast; - }else{ - nextChild.previousSibling = newLast; - } - do{ - newFirst.parentNode = parentNode; - }while(newFirst !== newLast && (newFirst= newFirst.nextSibling)) - _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode); - //console.log(parentNode.lastChild.nextSibling == null) - if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { - newChild.firstChild = newChild.lastChild = null; - } - return newChild; -} -function _appendSingleChild(parentNode,newChild){ - var cp = newChild.parentNode; - if(cp){ - var pre = parentNode.lastChild; - cp.removeChild(newChild);//remove and update - var pre = parentNode.lastChild; - } - var pre = parentNode.lastChild; - newChild.parentNode = parentNode; - newChild.previousSibling = pre; - newChild.nextSibling = null; - if(pre){ - pre.nextSibling = newChild; - }else{ - parentNode.firstChild = newChild; - } - parentNode.lastChild = newChild; - _onUpdateChild(parentNode.ownerDocument,parentNode,newChild); - return newChild; - //console.log("__aa",parentNode.lastChild.nextSibling == null) -} -Document.prototype = { - //implementation : null, - nodeName : '#document', - nodeType : DOCUMENT_NODE, - doctype : null, - documentElement : null, - _inc : 1, - - insertBefore : function(newChild, refChild){//raises - if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){ - var child = newChild.firstChild; - while(child){ - var next = child.nextSibling; - this.insertBefore(child,refChild); - child = next; - } - return newChild; - } - if(this.documentElement == null && newChild.nodeType == 1){ - this.documentElement = newChild; - } - - return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild; - }, - removeChild : function(oldChild){ - if(this.documentElement == oldChild){ - this.documentElement = null; - } - return _removeChild(this,oldChild); - }, - // Introduced in DOM Level 2: - importNode : function(importedNode,deep){ - return importNode(this,importedNode,deep); - }, - // Introduced in DOM Level 2: - getElementById : function(id){ - var rtv = null; - _visitNode(this.documentElement,function(node){ - if(node.nodeType == 1){ - if(node.getAttribute('id') == id){ - rtv = node; - return true; - } - } - }) - return rtv; - }, - - //document factory method: - createElement : function(tagName){ - var node = new Element(); - node.ownerDocument = this; - node.nodeName = tagName; - node.tagName = tagName; - node.childNodes = new NodeList(); - var attrs = node.attributes = new NamedNodeMap(); - attrs._ownerElement = node; - return node; - }, - createDocumentFragment : function(){ - var node = new DocumentFragment(); - node.ownerDocument = this; - node.childNodes = new NodeList(); - return node; - }, - createTextNode : function(data){ - var node = new Text(); - node.ownerDocument = this; - node.appendData(data) - return node; - }, - createComment : function(data){ - var node = new Comment(); - node.ownerDocument = this; - node.appendData(data) - return node; - }, - createCDATASection : function(data){ - var node = new CDATASection(); - node.ownerDocument = this; - node.appendData(data) - return node; - }, - createProcessingInstruction : function(target,data){ - var node = new ProcessingInstruction(); - node.ownerDocument = this; - node.tagName = node.target = target; - node.nodeValue= node.data = data; - return node; - }, - createAttribute : function(name){ - var node = new Attr(); - node.ownerDocument = this; - node.name = name; - node.nodeName = name; - node.localName = name; - node.specified = true; - return node; - }, - createEntityReference : function(name){ - var node = new EntityReference(); - node.ownerDocument = this; - node.nodeName = name; - return node; - }, - // Introduced in DOM Level 2: - createElementNS : function(namespaceURI,qualifiedName){ - var node = new Element(); - var pl = qualifiedName.split(':'); - var attrs = node.attributes = new NamedNodeMap(); - node.childNodes = new NodeList(); - node.ownerDocument = this; - node.nodeName = qualifiedName; - node.tagName = qualifiedName; - node.namespaceURI = namespaceURI; - if(pl.length == 2){ - node.prefix = pl[0]; - node.localName = pl[1]; - }else{ - //el.prefix = null; - node.localName = qualifiedName; - } - attrs._ownerElement = node; - return node; - }, - // Introduced in DOM Level 2: - createAttributeNS : function(namespaceURI,qualifiedName){ - var node = new Attr(); - var pl = qualifiedName.split(':'); - node.ownerDocument = this; - node.nodeName = qualifiedName; - node.name = qualifiedName; - node.namespaceURI = namespaceURI; - node.specified = true; - if(pl.length == 2){ - node.prefix = pl[0]; - node.localName = pl[1]; - }else{ - //el.prefix = null; - node.localName = qualifiedName; - } - return node; - } -}; -_extends(Document,Node); - - -function Element() { - this._nsMap = {}; -}; -Element.prototype = { - nodeType : ELEMENT_NODE, - hasAttribute : function(name){ - return this.getAttributeNode(name)!=null; - }, - getAttribute : function(name){ - var attr = this.getAttributeNode(name); - return attr && attr.value || ''; - }, - getAttributeNode : function(name){ - return this.attributes.getNamedItem(name); - }, - setAttribute : function(name, value){ - var attr = this.ownerDocument.createAttribute(name); - attr.value = attr.nodeValue = "" + value; - this.setAttributeNode(attr) - }, - removeAttribute : function(name){ - var attr = this.getAttributeNode(name) - attr && this.removeAttributeNode(attr); - }, - - //four real opeartion method - appendChild:function(newChild){ - if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ - return this.insertBefore(newChild,null); - }else{ - return _appendSingleChild(this,newChild); - } - }, - setAttributeNode : function(newAttr){ - return this.attributes.setNamedItem(newAttr); - }, - setAttributeNodeNS : function(newAttr){ - return this.attributes.setNamedItemNS(newAttr); - }, - removeAttributeNode : function(oldAttr){ - return this.attributes.removeNamedItem(oldAttr.nodeName); - }, - //get real attribute name,and remove it by removeAttributeNode - removeAttributeNS : function(namespaceURI, localName){ - var old = this.getAttributeNodeNS(namespaceURI, localName); - old && this.removeAttributeNode(old); - }, - - hasAttributeNS : function(namespaceURI, localName){ - return this.getAttributeNodeNS(namespaceURI, localName)!=null; - }, - getAttributeNS : function(namespaceURI, localName){ - var attr = this.getAttributeNodeNS(namespaceURI, localName); - return attr && attr.value || ''; - }, - setAttributeNS : function(namespaceURI, qualifiedName, value){ - var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); - attr.value = attr.nodeValue = "" + value; - this.setAttributeNode(attr) - }, - getAttributeNodeNS : function(namespaceURI, localName){ - return this.attributes.getNamedItemNS(namespaceURI, localName); - }, - - getElementsByTagName : function(tagName){ - return new LiveNodeList(this,function(base){ - var ls = []; - _visitNode(base,function(node){ - if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){ - ls.push(node); - } - }); - return ls; - }); - }, - getElementsByTagNameNS : function(namespaceURI, localName){ - return new LiveNodeList(this,function(base){ - var ls = []; - _visitNode(base,function(node){ - if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){ - ls.push(node); - } - }); - return ls; - }); - } -}; -Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName; -Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS; - - -_extends(Element,Node); -function Attr() { -}; -Attr.prototype.nodeType = ATTRIBUTE_NODE; -_extends(Attr,Node); - - -function CharacterData() { -}; -CharacterData.prototype = { - data : '', - substringData : function(offset, count) { - return this.data.substring(offset, offset+count); - }, - appendData: function(text) { - text = this.data+text; - this.nodeValue = this.data = text; - this.length = text.length; - }, - insertData: function(offset,text) { - this.replaceData(offset,0,text); - - }, - appendChild:function(newChild){ - //if(!(newChild instanceof CharacterData)){ - throw new Error(ExceptionMessage[3]) - //} - return Node.prototype.appendChild.apply(this,arguments) - }, - deleteData: function(offset, count) { - this.replaceData(offset,count,""); - }, - replaceData: function(offset, count, text) { - var start = this.data.substring(0,offset); - var end = this.data.substring(offset+count); - text = start + text + end; - this.nodeValue = this.data = text; - this.length = text.length; - } -} -_extends(CharacterData,Node); -function Text() { -}; -Text.prototype = { - nodeName : "#text", - nodeType : TEXT_NODE, - splitText : function(offset) { - var text = this.data; - var newText = text.substring(offset); - text = text.substring(0, offset); - this.data = this.nodeValue = text; - this.length = text.length; - var newNode = this.ownerDocument.createTextNode(newText); - if(this.parentNode){ - this.parentNode.insertBefore(newNode, this.nextSibling); - } - return newNode; - } -} -_extends(Text,CharacterData); -function Comment() { -}; -Comment.prototype = { - nodeName : "#comment", - nodeType : COMMENT_NODE -} -_extends(Comment,CharacterData); - -function CDATASection() { -}; -CDATASection.prototype = { - nodeName : "#cdata-section", - nodeType : CDATA_SECTION_NODE -} -_extends(CDATASection,CharacterData); - - -function DocumentType() { -}; -DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE; -_extends(DocumentType,Node); - -function Notation() { -}; -Notation.prototype.nodeType = NOTATION_NODE; -_extends(Notation,Node); - -function Entity() { -}; -Entity.prototype.nodeType = ENTITY_NODE; -_extends(Entity,Node); - -function EntityReference() { -}; -EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE; -_extends(EntityReference,Node); - -function DocumentFragment() { -}; -DocumentFragment.prototype.nodeName = "#document-fragment"; -DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE; -_extends(DocumentFragment,Node); - - -function ProcessingInstruction() { -} -ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE; -_extends(ProcessingInstruction,Node); -function XMLSerializer(){} -XMLSerializer.prototype.serializeToString = function(node,attributeSorter){ - return node.toString(attributeSorter); -} -Node.prototype.toString =function(attributeSorter){ - var buf = []; - serializeToString(this,buf,attributeSorter); - return buf.join(''); -} -function serializeToString(node,buf,attributeSorter,isHTML){ - switch(node.nodeType){ - case ELEMENT_NODE: - var attrs = node.attributes; - var len = attrs.length; - var child = node.firstChild; - var nodeName = node.tagName; - isHTML = (htmlns === node.namespaceURI) ||isHTML - buf.push('<',nodeName); - if(attributeSorter){ - buf.sort.apply(attrs, attributeSorter); - } - for(var i=0;i'); - //if is cdata child node - if(isHTML && /^script$/i.test(nodeName)){ - if(child){ - buf.push(child.data); - } - }else{ - while(child){ - serializeToString(child,buf,attributeSorter,isHTML); - child = child.nextSibling; - } - } - buf.push(''); - }else{ - buf.push('/>'); - } - return; - case DOCUMENT_NODE: - case DOCUMENT_FRAGMENT_NODE: - var child = node.firstChild; - while(child){ - serializeToString(child,buf,attributeSorter,isHTML); - child = child.nextSibling; - } - return; - case ATTRIBUTE_NODE: - return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"'); - case TEXT_NODE: - return buf.push(node.data.replace(/[<&]/g,_xmlEncoder)); - case CDATA_SECTION_NODE: - return buf.push( ''); - case COMMENT_NODE: - return buf.push( ""); - case DOCUMENT_TYPE_NODE: - var pubid = node.publicId; - var sysid = node.systemId; - buf.push(''); - }else if(sysid && sysid!='.'){ - buf.push(' SYSTEM "',sysid,'">'); - }else{ - var sub = node.internalSubset; - if(sub){ - buf.push(" [",sub,"]"); - } - buf.push(">"); - } - return; - case PROCESSING_INSTRUCTION_NODE: - return buf.push( ""); - case ENTITY_REFERENCE_NODE: - return buf.push( '&',node.nodeName,';'); - //case ENTITY_NODE: - //case NOTATION_NODE: - default: - buf.push('??',node.nodeName); - } -} -function importNode(doc,node,deep){ - var node2; - switch (node.nodeType) { - case ELEMENT_NODE: - node2 = node.cloneNode(false); - node2.ownerDocument = doc; - //var attrs = node2.attributes; - //var len = attrs.length; - //for(var i=0;i=0.1" - }, - "dependencies": {}, - "devDependencies": { - "proof": "0.0.28" - }, - "maintainers": [ - { - "name": "jindw", - "email": "jindw@xidea.org" - }, - { - "name": "yaron", - "email": "yaronn01@gmail.com" - }, - { - "name": "bigeasy", - "email": "alan@prettyrobots.com" - }, - { - "name": "kethinov", - "email": "kethinov@gmail.com" - }, - { - "name": "jinjinyun", - "email": "jinyun.jin@gmail.com" - } - ], - "contributors": [ - { - "name": "Yaron Naveh", - "email": "yaronn01@gmail.com", - "url": "http://webservices20.blogspot.com/" - }, - { - "name": "Harutyun Amirjanyan", - "email": "amirjanyan@gmail.com", - "url": "https://github.com/nightwing" - }, - { - "name": "Alan Gutierrez", - "email": "alan@prettyrobots.com", - "url": "http://www.prettyrobots.com/" - } - ], - "bugs": { - "url": "http://github.com/jindw/xmldom/issues", - "email": "jindw@xidea.org" - }, - "licenses": [ - { - "type": "LGPL", - "url": "http://www.gnu.org/licenses/lgpl.html", - "MIT": "http://opensource.org/licenses/MIT" - } - ], - "_id": "xmldom@0.1.21", - "_shasum": "a29e1210dab1f10c25665b5e80129baa8d69a97b", - "_from": "xmldom@>=0.1.0 <0.2.0", - "_npmVersion": "1.4.9", - "_npmUser": { - "name": "jindw", - "email": "jindw@xidea.org" - }, - "dist": { - "shasum": "a29e1210dab1f10c25665b5e80129baa8d69a97b", - "tarball": "http://registry.npmjs.org/xmldom/-/xmldom-0.1.21.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/xmldom/-/xmldom-0.1.21.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/package.json deleted file mode 100644 index b6059ad..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/package.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "name": "plist", - "description": "Mac OS X Plist parser/builder for Node.js and browsers", - "version": "1.2.0", - "author": { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net" - }, - "contributors": [ - { - "name": "Hans Huebner", - "email": "hans.huebner@gmail.com" - }, - { - "name": "Pierre Metrailler" - }, - { - "name": "Mike Reinstein", - "email": "reinstein.mike@gmail.com" - }, - { - "name": "Vladimir Tsvang" - }, - { - "name": "Mathieu D'Amours" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/TooTallNate/node-plist.git" - }, - "license": "MIT", - "keywords": [ - "apple", - "browser", - "mac", - "plist", - "parser", - "xml" - ], - "main": "lib/plist.js", - "dependencies": { - "base64-js": "0.0.8", - "xmlbuilder": "4.0.0", - "xmldom": "0.1.x", - "util-deprecate": "1.0.2" - }, - "devDependencies": { - "browserify": "12.0.1", - "mocha": "2.3.3", - "multiline": "1.0.2", - "zuul": "3.7.2" - }, - "scripts": { - "test": "make test" - }, - "gitHead": "69520574f27864145192338b72e608fbe1bda6f7", - "bugs": { - "url": "https://github.com/TooTallNate/node-plist/issues" - }, - "homepage": "https://github.com/TooTallNate/node-plist#readme", - "_id": "plist@1.2.0", - "_shasum": "084b5093ddc92506e259f874b8d9b1afb8c79593", - "_from": "plist@>=1.1.0 <2.0.0", - "_npmVersion": "3.3.11", - "_nodeVersion": "5.0.0", - "_npmUser": { - "name": "mreinstein", - "email": "reinstein.mike@gmail.com" - }, - "dist": { - "shasum": "084b5093ddc92506e259f874b8d9b1afb8c79593", - "tarball": "http://registry.npmjs.org/plist/-/plist-1.2.0.tgz" - }, - "maintainers": [ - { - "name": "TooTallNate", - "email": "nathan@tootallnate.net" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - { - "name": "mreinstein", - "email": "reinstein.mike@gmail.com" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/plist/-/plist-1.2.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/package.json deleted file mode 100644 index 2a8618b..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "semver", - "version": "5.1.0", - "description": "The semantic version parser used by npm.", - "main": "semver.js", - "scripts": { - "test": "tap test/*.js" - }, - "devDependencies": { - "tap": "^2.0.0" - }, - "license": "ISC", - "repository": { - "type": "git", - "url": "git+https://github.com/npm/node-semver.git" - }, - "bin": { - "semver": "./bin/semver" - }, - "gitHead": "8e33a30e62e40e4983d1c5f55e794331b861aadc", - "bugs": { - "url": "https://github.com/npm/node-semver/issues" - }, - "homepage": "https://github.com/npm/node-semver#readme", - "_id": "semver@5.1.0", - "_shasum": "85f2cf8550465c4df000cf7d86f6b054106ab9e5", - "_from": "semver@>=5.0.1 <6.0.0", - "_npmVersion": "3.3.2", - "_nodeVersion": "4.0.0", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "shasum": "85f2cf8550465c4df000cf7d86f6b054106ab9e5", - "tarball": "http://registry.npmjs.org/semver/-/semver-5.1.0.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/semver/-/semver-5.1.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/package.json deleted file mode 100644 index 36ad4c0..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "underscore", - "description": "JavaScript's functional programming helper library.", - "homepage": "http://underscorejs.org", - "keywords": [ - "util", - "functional", - "server", - "client", - "browser" - ], - "author": { - "name": "Jeremy Ashkenas", - "email": "jeremy@documentcloud.org" - }, - "repository": { - "type": "git", - "url": "git://github.com/jashkenas/underscore.git" - }, - "main": "underscore.js", - "version": "1.8.3", - "devDependencies": { - "docco": "*", - "eslint": "0.6.x", - "karma": "~0.12.31", - "karma-qunit": "~0.1.4", - "qunit-cli": "~0.2.0", - "uglify-js": "2.4.x" - }, - "scripts": { - "test": "npm run test-node && npm run lint", - "lint": "eslint underscore.js test/*.js", - "test-node": "qunit-cli test/*.js", - "test-browser": "npm i karma-phantomjs-launcher && ./node_modules/karma/bin/karma start", - "build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js", - "doc": "docco underscore.js" - }, - "license": "MIT", - "files": [ - "underscore.js", - "underscore-min.js", - "underscore-min.map", - "LICENSE" - ], - "gitHead": "e4743ab712b8ab42ad4ccb48b155034d02394e4d", - "bugs": { - "url": "https://github.com/jashkenas/underscore/issues" - }, - "_id": "underscore@1.8.3", - "_shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022", - "_from": "underscore@>=1.8.3 <2.0.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "jashkenas", - "email": "jashkenas@gmail.com" - }, - "maintainers": [ - { - "name": "jashkenas", - "email": "jashkenas@gmail.com" - } - ], - "dist": { - "shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022", - "tarball": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/package.json b/platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/package.json deleted file mode 100644 index a978cb1..0000000 --- a/platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "unorm", - "version": "1.4.1", - "description": "JavaScript Unicode 8.0 Normalization - NFC, NFD, NFKC, NFKD. Read UAX #15 Unicode Normalization Forms.", - "author": { - "name": "Bjarke Walling", - "email": "bwp@bwp.dk" - }, - "license": "MIT or GPL-2.0", - "contributors": [ - { - "name": "Bjarke Walling", - "email": "bwp@bwp.dk" - }, - { - "name": "Oleg Grenrus", - "email": "oleg.grenrus@iki.fi" - }, - { - "name": "Matsuza", - "email": "matsuza@gmail.com" - } - ], - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/walling/unorm.git" - }, - "main": "./lib/unorm.js", - "engines": { - "node": ">= 0.4.0" - }, - "scripts": { - "test": "grunt test" - }, - "devDependencies": { - "benchmark": "~1.0.0", - "unorm": "1.4.1", - "grunt-contrib-jshint": "~0.8.0", - "grunt-contrib-watch": "~0.5.0", - "grunt-simple-mocha": "~0.4.0", - "grunt": "~0.4.1" - }, - "gitHead": "e802d0d7844cf74b03742bce1147a82ace218396", - "bugs": { - "url": "https://github.com/walling/unorm/issues" - }, - "homepage": "https://github.com/walling/unorm", - "_id": "unorm@1.4.1", - "_shasum": "364200d5f13646ca8bcd44490271335614792300", - "_from": "unorm@>=1.3.3 <2.0.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "walling", - "email": "bwp@bwp.dk" - }, - "maintainers": [ - { - "name": "walling", - "email": "bwp@bwp.dk" - } - ], - "dist": { - "shasum": "364200d5f13646ca8bcd44490271335614792300", - "tarball": "http://registry.npmjs.org/unorm/-/unorm-1.4.1.tgz" - }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/unorm/-/unorm-1.4.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/cordova-common/package.json b/platforms/android/cordova/node_modules/cordova-common/package.json index 6c4d7e8..4bd1675 100644 --- a/platforms/android/cordova/node_modules/cordova-common/package.json +++ b/platforms/android/cordova/node_modules/cordova-common/package.json @@ -1,63 +1,81 @@ { - "author": { - "name": "Apache Software Foundation" + "_args": [ + [ + "cordova-common@^1.1.0", + "/Users/steveng/repo/cordova/cordova-android" + ] + ], + "_from": "cordova-common@>=1.1.0 <2.0.0", + "_id": "cordova-common@1.1.0", + "_inCache": true, + "_installable": true, + "_location": "/cordova-common", + "_nodeVersion": "4.2.3", + "_npmOperationalInternal": { + "host": "packages-5-east.internal.npmjs.com", + "tmp": "tmp/cordova-common-1.1.0.tgz_1455781889491_0.6937742941081524" }, - "name": "cordova-common", - "description": "Apache Cordova tools and platforms shared routines", - "license": "Apache-2.0", - "version": "1.0.0", - "repository": { - "type": "git", - "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git" + "_npmUser": { + "email": "kotikov.vladimir@gmail.com", + "name": "kotikov.vladimir" }, - "bugs": { - "url": "https://issues.apache.org/jira/browse/CB", - "email": "dev@cordova.apache.org" + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "cordova-common", + "raw": "cordova-common@^1.1.0", + "rawSpec": "^1.1.0", + "scope": null, + "spec": ">=1.1.0 <2.0.0", + "type": "range" }, - "main": "cordova-common.js", - "engines": { - "node": ">=0.9.9" + "_requiredBy": [ + "/" + ], + "_resolved": "http://registry.npmjs.org/cordova-common/-/cordova-common-1.1.0.tgz", + "_shasum": "8682721466ee354747ec6241f34f412b7e0ef636", + "_shrinkwrap": null, + "_spec": "cordova-common@^1.1.0", + "_where": "/Users/steveng/repo/cordova/cordova-android", + "author": { + "name": "Apache Software Foundation" }, - "scripts": { - "test": "npm run jshint && npm run jasmine", - "jshint": "node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint spec", - "jasmine": "node node_modules/jasmine-node/bin/jasmine-node --captureExceptions --color spec", - "cover": "node node_modules/istanbul/lib/cli.js cover --root src --print detail node_modules/jasmine-node/bin/jasmine-node -- spec" + "bugs": { + "email": "dev@cordova.apache.org", + "url": "https://issues.apache.org/jira/browse/CB" }, - "engineStrict": true, + "contributors": [], "dependencies": { + "ansi": "^0.3.1", "bplist-parser": "^0.1.0", "cordova-registry-mapper": "^1.1.8", "elementtree": "^0.1.6", "glob": "^5.0.13", "osenv": "^0.1.3", - "plist": "^1.1.0", + "plist": "^1.2.0", "q": "^1.4.1", "semver": "^5.0.1", "shelljs": "^0.5.1", "underscore": "^1.8.3", "unorm": "^1.3.3" }, + "description": "Apache Cordova tools and platforms shared routines", "devDependencies": { "istanbul": "^0.3.17", "jasmine-node": "^1.14.5", "jshint": "^2.8.0" }, - "contributors": [], - "_id": "cordova-common@1.0.0", - "_shasum": "b21947e89a4a89292ec563abf9ee6ccb2b9f3aef", - "_resolved": "http://registry.npmjs.org/cordova-common/-/cordova-common-1.0.0.tgz", - "_from": "cordova-common@>=1.0.0 <1.1.0", - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.1", - "_npmUser": { - "name": "kotikov.vladimir", - "email": "kotikov.vladimir@gmail.com" - }, + "directories": {}, "dist": { - "shasum": "b21947e89a4a89292ec563abf9ee6ccb2b9f3aef", - "tarball": "http://registry.npmjs.org/cordova-common/-/cordova-common-1.0.0.tgz" + "shasum": "8682721466ee354747ec6241f34f412b7e0ef636", + "tarball": "http://registry.npmjs.org/cordova-common/-/cordova-common-1.1.0.tgz" + }, + "engineStrict": true, + "engines": { + "node": ">=0.9.9" }, + "license": "Apache-2.0", + "main": "cordova-common.js", "maintainers": [ { "name": "bowserj", @@ -84,6 +102,18 @@ "email": "npmjs@barhams.info" } ], - "directories": {}, - "readme": "ERROR: No README data found!" + "name": "cordova-common", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git" + }, + "scripts": { + "cover": "node node_modules/istanbul/lib/cli.js cover --root src --print detail node_modules/jasmine-node/bin/jasmine-node -- spec", + "jasmine": "node node_modules/jasmine-node/bin/jasmine-node --captureExceptions --color spec", + "jshint": "node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint spec", + "test": "npm run jshint && npm run jasmine" + }, + "version": "1.1.0" } diff --git a/platforms/android/cordova/node_modules/cordova-common/src/.jshintrc b/platforms/android/cordova/node_modules/cordova-common/src/.jshintrc new file mode 100644 index 0000000..89a121c --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-common/src/.jshintrc @@ -0,0 +1,10 @@ +{ + "node": true + , "bitwise": true + , "undef": true + , "trailing": true + , "quotmark": true + , "indent": 4 + , "unused": "vars" + , "latedef": "nofunc" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js b/platforms/android/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js index a38fca6..a914fc8 100644 --- a/platforms/android/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js +++ b/platforms/android/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js @@ -106,8 +106,8 @@ function remove_plugin_changes(pluginInfo, is_top_level) { // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins. if (self.platform == 'windows' && file == 'package.appxmanifest' && !fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) { - // New windows template separate manifest files for Windows8, Windows8.1 and WP8.1 - var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows80.appxmanifest', 'package.windows10.appxmanifest']; + // New windows template separate manifest files for Windows10, Windows8.1 and WP8.1 + var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest']; /* jshint loopfunc:true */ substs.forEach(function(subst) { events.emit('verbose', 'Applying munge to ' + subst); @@ -149,7 +149,7 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins. if (self.platform == 'windows' && file == 'package.appxmanifest' && !fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) { - var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows80.appxmanifest', 'package.windows10.appxmanifest']; + var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest']; /* jshint loopfunc:true */ substs.forEach(function(subst) { events.emit('verbose', 'Applying munge to ' + subst); @@ -203,7 +203,6 @@ function generate_plugin_config_munge(pluginInfo, vars) { { var manifests = { 'windows': { - '8.0.0': 'package.windows80.appxmanifest', '8.1.0': 'package.windows.appxmanifest', '10.0.0': 'package.windows10.appxmanifest' }, @@ -212,7 +211,6 @@ function generate_plugin_config_munge(pluginInfo, vars) { '10.0.0': 'package.windows10.appxmanifest' }, 'all': { - '8.0.0': 'package.windows80.appxmanifest', '8.1.0': ['package.windows.appxmanifest', 'package.phone.appxmanifest'], '10.0.0': 'package.windows10.appxmanifest' } diff --git a/platforms/android/cordova/node_modules/cordova-common/src/CordovaLogger.js b/platforms/android/cordova/node_modules/cordova-common/src/CordovaLogger.js new file mode 100644 index 0000000..06dbcf3 --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-common/src/CordovaLogger.js @@ -0,0 +1,203 @@ +/* + 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. + */ + +var ansi = require('ansi'); +var EventEmitter = require('events').EventEmitter; +var CordovaError = require('./CordovaError/CordovaError'); +var EOL = require('os').EOL; + +var INSTANCE; + +/** + * @class CordovaLogger + * + * Implements logging facility that anybody could use. Should not be + * instantiated directly, `CordovaLogger.get()` method should be used instead + * to acquire logger instance + */ +function CordovaLogger () { + this.levels = {}; + this.colors = {}; + this.stdout = process.stdout; + this.stderr = process.stderr; + + this.stdoutCursor = ansi(this.stdout); + this.stderrCursor = ansi(this.stderr); + + this.addLevel('verbose', 1000, 'grey'); + this.addLevel('normal' , 2000); + this.addLevel('warn' , 2000, 'yellow'); + this.addLevel('info' , 3000, 'blue'); + this.addLevel('error' , 5000, 'red'); + this.addLevel('results' , 10000); + + this.setLevel('normal'); +} + +/** + * Static method to create new or acquire existing instance. + * + * @return {CordovaLogger} Logger instance + */ +CordovaLogger.get = function () { + return INSTANCE || (INSTANCE = new CordovaLogger()); +}; + +CordovaLogger.VERBOSE = 'verbose'; +CordovaLogger.NORMAL = 'normal'; +CordovaLogger.WARN = 'warn'; +CordovaLogger.INFO = 'info'; +CordovaLogger.ERROR = 'error'; +CordovaLogger.RESULTS = 'results'; + +/** + * Emits log message to process' stdout/stderr depending on message's severity + * and current log level. If severity is less than current logger's level, + * then the message is ignored. + * + * @param {String} logLevel The message's log level. The logger should have + * corresponding level added (via logger.addLevel), otherwise + * `CordovaLogger.NORMAL` level will be used. + * @param {String} message The message, that should be logged to process' + * stdio + * + * @return {CordovaLogger} Current instance, to allow calls chaining. + */ +CordovaLogger.prototype.log = function (logLevel, message) { + // if there is no such logLevel defined, or provided level has + // less severity than active level, then just ignore this call and return + if (!this.levels[logLevel] || this.levels[logLevel] < this.levels[this.logLevel]) + // return instance to allow to chain calls + return this; + + var isVerbose = this.logLevel === 'verbose'; + var cursor = this.stdoutCursor; + + if(message instanceof Error || logLevel === CordovaLogger.ERROR) { + message = formatError(message, isVerbose); + cursor = this.stderrCursor; + } + + var color = this.colors[logLevel]; + if (color) { + cursor.bold().fg[color](); + } + + cursor.write(message).reset().write(EOL); + + return this; +}; + +/** + * Adds a new level to logger instance. This method also creates a shortcut + * method to log events with the level provided (i.e. after adding new level + * 'debug', the method `debug(message)`, equal to logger.log('debug', message), + * will be added to logger instance) + * + * @param {String} level A log level name. The levels with the following + * names added by default to every instance: 'verbose', 'normal', 'warn', + * 'info', 'error', 'results' + * @param {Number} severity A number that represents level's severity. + * @param {String} color A valid color name, that will be used to log + * messages with this level. Any CSS color code or RGB value is allowed + * (according to ansi documentation: + * https://github.com/TooTallNate/ansi.js#features) + * + * @return {CordovaLogger} Current instance, to allow calls chaining. + */ +CordovaLogger.prototype.addLevel = function (level, severity, color) { + + this.levels[level] = severity; + + if (color) { + this.colors[level] = color; + } + + // Define own method with corresponding name + if (!this[level]) { + this[level] = this.log.bind(this, level); + } + + return this; +}; + +/** + * Sets the current logger level to provided value. If logger doesn't have level + * with this name, `CordovaLogger.NORMAL` will be used. + * + * @param {String} logLevel Level name. The level with this name should be + * added to logger before. + * + * @return {CordovaLogger} Current instance, to allow calls chaining. + */ +CordovaLogger.prototype.setLevel = function (logLevel) { + this.logLevel = this.levels[logLevel] ? logLevel : CordovaLogger.NORMAL; + + return this; +}; + +/** + * Attaches logger to EventEmitter instance provided. + * + * @param {EventEmitter} eventEmitter An EventEmitter instance to attach + * logger to. + * + * @return {CordovaLogger} Current instance, to allow calls chaining. + */ +CordovaLogger.prototype.subscribe = function (eventEmitter) { + + if (!(eventEmitter instanceof EventEmitter)) + throw new Error('Subscribe method only accepts an EventEmitter instance as argument'); + + eventEmitter.on('verbose', this.verbose) + .on('log', this.normal) + .on('info', this.info) + .on('warn', this.warn) + .on('warning', this.warn) + // Set up event handlers for logging and results emitted as events. + .on('results', this.results); + + return this; +}; + +function formatError(error, isVerbose) { + var message = ''; + + if(error instanceof CordovaError) { + message = error.toString(isVerbose); + } else if(error instanceof Error) { + if(isVerbose) { + message = error.stack; + } else { + message = error.message; + } + } else { + // Plain text error message + message = error; + } + + if(message.toUpperCase().indexOf('ERROR:') !== 0) { + // Needed for backward compatibility with external tools + message = 'Error: ' + message; + } + + return message; +} + +module.exports = CordovaLogger; diff --git a/platforms/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js b/platforms/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js index 073f3f9..2554a3c 100644 --- a/platforms/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js +++ b/platforms/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js @@ -376,9 +376,6 @@ function addCordova(someArray) { // applied to each element. function _getTags(pelem, tag, platform, transform) { var platformTag = pelem.find('./platform[@name="' + platform + '"]'); - if (platform == 'windows' && !platformTag) { - platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); - } var tagsInRoot = pelem.findall(tag); tagsInRoot = tagsInRoot || []; var tagsInPlatform = platformTag ? platformTag.findall(tag) : []; @@ -392,9 +389,6 @@ function _getTags(pelem, tag, platform, transform) { // Same as _getTags() but only looks inside a platfrom section. function _getTagsInPlatform(pelem, tag, platform, transform) { var platformTag = pelem.find('./platform[@name="' + platform + '"]'); - if (platform == 'windows' && !platformTag) { - platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); - } var tags = platformTag ? platformTag.findall(tag) : []; if ( typeof transform === 'function' ) { tags = tags.map(transform); diff --git a/platforms/android/cordova/node_modules/cordova-common/src/events.js b/platforms/android/cordova/node_modules/cordova-common/src/events.js index a6ec340..868d363 100644 --- a/platforms/android/cordova/node_modules/cordova-common/src/events.js +++ b/platforms/android/cordova/node_modules/cordova-common/src/events.js @@ -16,4 +16,50 @@ specific language governing permissions and limitations under the License. */ -module.exports = new (require('events').EventEmitter)(); + +var EventEmitter = require('events').EventEmitter; + +var INSTANCE = new EventEmitter(); +var EVENTS_RECEIVER; + +module.exports = INSTANCE; + +/** + * Sets up current instance to forward emitted events to another EventEmitter + * instance. + * + * @param {EventEmitter} [eventEmitter] The emitter instance to forward + * events to. Falsy value, when passed, disables forwarding. + */ +module.exports.forwardEventsTo = function (eventEmitter) { + + // If no argument is specified disable events forwarding + if (!eventEmitter) { + EVENTS_RECEIVER = undefined; + return; + } + + if (!(eventEmitter instanceof EventEmitter)) + throw new Error('Cordova events could be redirected to another EventEmitter instance only'); + + EVENTS_RECEIVER = eventEmitter; +}; + +var emit = INSTANCE.emit; + +/** + * This method replaces original 'emit' method to allow events forwarding. + * + * @return {eventEmitter} Current instance to allow calls chaining, as + * original 'emit' does + */ +module.exports.emit = function () { + + var args = Array.prototype.slice.call(arguments); + + if (EVENTS_RECEIVER) { + EVENTS_RECEIVER.emit.apply(EVENTS_RECEIVER, args); + } + + return emit.apply(this, args); +}; diff --git a/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js b/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js index b4129ec..a3f1431 100644 --- a/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js +++ b/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js @@ -28,7 +28,7 @@ var iswin32 = process.platform == 'win32'; // On Windows, spawn() for batch files requires absolute path & having the extension. function resolveWindowsExe(cmd) { - var winExtensions = ['.exe', '.cmd', '.bat', '.js', '.vbs']; + var winExtensions = ['.exe', '.bat', '.cmd', '.js', '.vbs']; function isValidExe(c) { return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c); } @@ -52,15 +52,39 @@ function maybeQuote(a) { return a; } -// opts: -// printCommand: Whether to log the command (default: false) -// stdio: 'default' is to capture output and returning it as a string to success (same as exec) -// 'ignore' means don't bother capturing it -// 'inherit' means pipe the input & output. This is required for anything that prompts. -// env: Map of extra environment variables. -// cwd: Working directory for the command. -// chmod: If truthy, will attempt to set the execute bit before executing on non-Windows platforms. -// Returns a promise that succeeds only for return code = 0. +/** + * A special implementation for child_process.spawn that handles + * Windows-specific issues with batch files and spaces in paths. Returns a + * promise that succeeds only for return code 0. It is also possible to + * subscribe on spawned process' stdout and stderr streams using progress + * handler for resultant promise. + * + * @example spawn('mycommand', [], {stdio: 'pipe'}) .progress(function (stdio){ + * if (stdio.stderr) { console.error(stdio.stderr); } }) + * .then(function(result){ // do other stuff }) + * + * @param {String} cmd A command to spawn + * @param {String[]} [args=[]] An array of arguments, passed to spawned + * process + * @param {Object} [opts={}] A configuration object + * @param {String|String[]|Object} opts.stdio Property that configures how + * spawned process' stdio will behave. Has the same meaning and possible + * values as 'stdio' options for child_process.spawn method + * (https://nodejs.org/api/child_process.html#child_process_options_stdio). + * @param {Object} [env={}] A map of extra environment variables + * @param {String} [cwd=process.cwd()] Working directory for the command + * @param {Boolean} [chmod=false] If truthy, will attempt to set the execute + * bit before executing on non-Windows platforms + * + * @return {Promise} A promise that is either fulfilled if the spawned + * process is exited with zero error code or rejected otherwise. If the + * 'stdio' option set to 'default' or 'pipe', the promise also emits progress + * messages with the following contents: + * { + * 'stdout': ..., + * 'stderr': ... + * } + */ exports.spawn = function(cmd, args, opts) { args = args || []; opts = opts || {}; @@ -83,17 +107,19 @@ exports.spawn = function(cmd, args, opts) { } } - if (opts.stdio == 'ignore') { - spawnOpts.stdio = 'ignore'; - } else if (opts.stdio == 'inherit') { - spawnOpts.stdio = 'inherit'; + if (opts.stdio !== 'default') { + // Ignore 'default' value for stdio because it corresponds to child_process's default 'pipe' option + spawnOpts.stdio = opts.stdio; } + if (opts.cwd) { spawnOpts.cwd = opts.cwd; } + if (opts.env) { spawnOpts.env = _.extend(_.extend({}, process.env), opts.env); } + if (opts.chmod && !iswin32) { try { // This fails when module is installed in a system directory (e.g. via sudo npm install) @@ -113,11 +139,15 @@ exports.spawn = function(cmd, args, opts) { child.stdout.setEncoding('utf8'); child.stdout.on('data', function(data) { capturedOut += data; + d.notify({'stdout': data}); }); + } + if (child.stderr) { child.stderr.setEncoding('utf8'); child.stderr.on('data', function(data) { capturedErr += data; + d.notify({'stderr': data}); }); } diff --git a/platforms/android/cordova/node_modules/cordova-registry-mapper/.npmignore b/platforms/android/cordova/node_modules/cordova-registry-mapper/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-registry-mapper/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/platforms/android/cordova/node_modules/cordova-registry-mapper/.travis.yml b/platforms/android/cordova/node_modules/cordova-registry-mapper/.travis.yml new file mode 100644 index 0000000..ae381fc --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-registry-mapper/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +sudo: false +node_js: + - "0.10" +install: npm install +script: + - npm test diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/README.md b/platforms/android/cordova/node_modules/cordova-registry-mapper/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/README.md rename to platforms/android/cordova/node_modules/cordova-registry-mapper/README.md diff --git a/platforms/android/cordova/node_modules/cordova-registry-mapper/index.js b/platforms/android/cordova/node_modules/cordova-registry-mapper/index.js new file mode 100644 index 0000000..4550774 --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-registry-mapper/index.js @@ -0,0 +1,204 @@ +var map = { + 'org.apache.cordova.battery-status':'cordova-plugin-battery-status', + 'org.apache.cordova.camera':'cordova-plugin-camera', + 'org.apache.cordova.console':'cordova-plugin-console', + 'org.apache.cordova.contacts':'cordova-plugin-contacts', + 'org.apache.cordova.device':'cordova-plugin-device', + 'org.apache.cordova.device-motion':'cordova-plugin-device-motion', + 'org.apache.cordova.device-orientation':'cordova-plugin-device-orientation', + 'org.apache.cordova.dialogs':'cordova-plugin-dialogs', + 'org.apache.cordova.file':'cordova-plugin-file', + 'org.apache.cordova.file-transfer':'cordova-plugin-file-transfer', + 'org.apache.cordova.geolocation':'cordova-plugin-geolocation', + 'org.apache.cordova.globalization':'cordova-plugin-globalization', + 'org.apache.cordova.inappbrowser':'cordova-plugin-inappbrowser', + 'org.apache.cordova.media':'cordova-plugin-media', + 'org.apache.cordova.media-capture':'cordova-plugin-media-capture', + 'org.apache.cordova.network-information':'cordova-plugin-network-information', + 'org.apache.cordova.splashscreen':'cordova-plugin-splashscreen', + 'org.apache.cordova.statusbar':'cordova-plugin-statusbar', + 'org.apache.cordova.vibration':'cordova-plugin-vibration', + 'org.apache.cordova.test-framework':'cordova-plugin-test-framework', + 'com.msopentech.websql' : 'cordova-plugin-websql', + 'com.msopentech.indexeddb' : 'cordova-plugin-indexeddb', + 'com.microsoft.aad.adal' : 'cordova-plugin-ms-adal', + 'com.microsoft.capptain' : 'capptain-cordova', + 'com.microsoft.services.aadgraph' : 'cordova-plugin-ms-aad-graph', + 'com.microsoft.services.files' : 'cordova-plugin-ms-files', + 'om.microsoft.services.outlook' : 'cordova-plugin-ms-outlook', + 'com.pbakondy.sim' : 'cordova-plugin-sim', + 'android.support.v4' : 'cordova-plugin-android-support-v4', + 'android.support.v7-appcompat' : 'cordova-plugin-android-support-v7-appcompat', + 'com.google.playservices' : 'cordova-plugin-googleplayservices', + 'com.google.cordova.admob' : 'cordova-plugin-admobpro', + 'com.rjfun.cordova.extension' : 'cordova-plugin-extension', + 'com.rjfun.cordova.plugin.admob' : 'cordova-plugin-admob', + 'com.rjfun.cordova.flurryads' : 'cordova-plugin-flurry', + 'com.rjfun.cordova.facebookads' : 'cordova-plugin-facebookads', + 'com.rjfun.cordova.httpd' : 'cordova-plugin-httpd', + 'com.rjfun.cordova.iad' : 'cordova-plugin-iad', + 'com.rjfun.cordova.iflyspeech' : 'cordova-plugin-iflyspeech', + 'com.rjfun.cordova.lianlianpay' : 'cordova-plugin-lianlianpay', + 'com.rjfun.cordova.mobfox' : 'cordova-plugin-mobfox', + 'com.rjfun.cordova.mopub' : 'cordova-plugin-mopub', + 'com.rjfun.cordova.mmedia' : 'cordova-plugin-mmedia', + 'com.rjfun.cordova.nativeaudio' : 'cordova-plugin-nativeaudio', + 'com.rjfun.cordova.plugin.paypalmpl' : 'cordova-plugin-paypalmpl', + 'com.rjfun.cordova.smartadserver' : 'cordova-plugin-smartadserver', + 'com.rjfun.cordova.sms' : 'cordova-plugin-sms', + 'com.rjfun.cordova.wifi' : 'cordova-plugin-wifi', + 'com.ohh2ahh.plugins.appavailability' : 'cordova-plugin-appavailability', + 'org.adapt-it.cordova.fonts' : 'cordova-plugin-fonts', + 'de.martinreinhardt.cordova.plugins.barcodeScanner' : 'cordova-plugin-barcodescanner', + 'de.martinreinhardt.cordova.plugins.urlhandler' : 'cordova-plugin-urlhandler', + 'de.martinreinhardt.cordova.plugins.email' : 'cordova-plugin-email', + 'de.martinreinhardt.cordova.plugins.certificates' : 'cordova-plugin-certificates', + 'de.martinreinhardt.cordova.plugins.sqlite' : 'cordova-plugin-sqlite', + 'fr.smile.cordova.fileopener' : 'cordova-plugin-fileopener', + 'org.smile.websqldatabase.initializer' : 'cordova-plugin-websqldatabase-initializer', + 'org.smile.websqldatabase.wpdb' : 'cordova-plugin-websqldatabase', + 'org.jboss.aerogear.cordova.push' : 'aerogear-cordova-push', + 'org.jboss.aerogear.cordova.oauth2' : 'aerogear-cordova-oauth2', + 'org.jboss.aerogear.cordova.geo' : 'aerogear-cordova-geo', + 'org.jboss.aerogear.cordova.crypto' : 'aerogear-cordova-crypto', + 'org.jboss.aerogaer.cordova.otp' : 'aerogear-cordova-otp', + 'uk.co.ilee.applewatch' : 'cordova-plugin-apple-watch', + 'uk.co.ilee.directions' : 'cordova-plugin-directions', + 'uk.co.ilee.gamecenter' : 'cordova-plugin-game-center', + 'uk.co.ilee.jailbreakdetection' : 'cordova-plugin-jailbreak-detection', + 'uk.co.ilee.nativetransitions' : 'cordova-plugin-native-transitions', + 'uk.co.ilee.pedometer' : 'cordova-plugin-pedometer', + 'uk.co.ilee.shake' : 'cordova-plugin-shake', + 'uk.co.ilee.touchid' : 'cordova-plugin-touchid', + 'com.knowledgecode.cordova.websocket' : 'cordova-plugin-websocket', + 'com.elixel.plugins.settings' : 'cordova-plugin-settings', + 'com.cowbell.cordova.geofence' : 'cordova-plugin-geofence', + 'com.blackberry.community.preventsleep' : 'cordova-plugin-preventsleep', + 'com.blackberry.community.gamepad' : 'cordova-plugin-gamepad', + 'com.blackberry.community.led' : 'cordova-plugin-led', + 'com.blackberry.community.thumbnail' : 'cordova-plugin-thumbnail', + 'com.blackberry.community.mediakeys' : 'cordova-plugin-mediakeys', + 'com.blackberry.community.simplebtlehrplugin' : 'cordova-plugin-bluetoothheartmonitor', + 'com.blackberry.community.simplebeaconplugin' : 'cordova-plugin-bluetoothibeacon', + 'com.blackberry.community.simplebtsppplugin' : 'cordova-plugin-bluetoothspp', + 'com.blackberry.community.clipboard' : 'cordova-plugin-clipboard', + 'com.blackberry.community.curl' : 'cordova-plugin-curl', + 'com.blackberry.community.qt' : 'cordova-plugin-qtbridge', + 'com.blackberry.community.upnp' : 'cordova-plugin-upnp', + 'com.blackberry.community.PasswordCrypto' : 'cordova-plugin-password-crypto', + 'com.blackberry.community.deviceinfoplugin' : 'cordova-plugin-deviceinfo', + 'com.blackberry.community.gsecrypto' : 'cordova-plugin-bb-crypto', + 'com.blackberry.community.mongoose' : 'cordova-plugin-mongoose', + 'com.blackberry.community.sysdialog' : 'cordova-plugin-bb-sysdialog', + 'com.blackberry.community.screendisplay' : 'cordova-plugin-screendisplay', + 'com.blackberry.community.messageplugin' : 'cordova-plugin-bb-messageretrieve', + 'com.blackberry.community.emailsenderplugin' : 'cordova-plugin-emailsender', + 'com.blackberry.community.audiometadata' : 'cordova-plugin-audiometadata', + 'com.blackberry.community.deviceemails' : 'cordova-plugin-deviceemails', + 'com.blackberry.community.audiorecorder' : 'cordova-plugin-audiorecorder', + 'com.blackberry.community.vibration' : 'cordova-plugin-vibrate-intense', + 'com.blackberry.community.SMSPlugin' : 'cordova-plugin-bb-sms', + 'com.blackberry.community.extractZipFile' : 'cordova-plugin-bb-zip', + 'com.blackberry.community.lowlatencyaudio' : 'cordova-plugin-bb-nativeaudio', + 'com.blackberry.community.barcodescanner' : 'phonegap-plugin-barcodescanner', + 'com.blackberry.app' : 'cordova-plugin-bb-app', + 'com.blackberry.bbm.platform' : 'cordova-plugin-bbm', + 'com.blackberry.connection' : 'cordova-plugin-bb-connection', + 'com.blackberry.identity' : 'cordova-plugin-bb-identity', + 'com.blackberry.invoke.card' : 'cordova-plugin-bb-card', + 'com.blackberry.invoke' : 'cordova-plugin-bb-invoke', + 'com.blackberry.invoked' : 'cordova-plugin-bb-invoked', + 'com.blackberry.io.filetransfer' : 'cordova-plugin-bb-filetransfer', + 'com.blackberry.io' : 'cordova-plugin-bb-io', + 'com.blackberry.notification' : 'cordova-plugin-bb-notification', + 'com.blackberry.payment' : 'cordova-plugin-bb-payment', + 'com.blackberry.pim.calendar' : 'cordova-plugin-bb-calendar', + 'com.blackberry.pim.contacts' : 'cordova-plugin-bb-contacts', + 'com.blackberry.pim.lib' : 'cordova-plugin-bb-pimlib', + 'com.blackberry.push' : 'cordova-plugin-bb-push', + 'com.blackberry.screenshot' : 'cordova-plugin-screenshot', + 'com.blackberry.sensors' : 'cordova-plugin-bb-sensors', + 'com.blackberry.system' : 'cordova-plugin-bb-system', + 'com.blackberry.ui.contextmenu' : 'cordova-plugin-bb-ctxmenu', + 'com.blackberry.ui.cover' : 'cordova-plugin-bb-cover', + 'com.blackberry.ui.dialog' : 'cordova-plugin-bb-dialog', + 'com.blackberry.ui.input' : 'cordova-plugin-touch-keyboard', + 'com.blackberry.ui.toast' : 'cordova-plugin-toast', + 'com.blackberry.user.identity' : 'cordova-plugin-bb-idservice', + 'com.blackberry.utils' : 'cordova-plugin-bb-utils', + 'net.yoik.cordova.plugins.screenorientation' : 'cordova-plugin-screen-orientation', + 'com.phonegap.plugins.barcodescanner' : 'phonegap-plugin-barcodescanner', + 'com.manifoldjs.hostedwebapp' : 'cordova-plugin-hostedwebapp', + 'com.initialxy.cordova.themeablebrowser' : 'cordova-plugin-themeablebrowser', + 'gr.denton.photosphere' : 'cordova-plugin-panoramaviewer', + 'nl.x-services.plugins.actionsheet' : 'cordova-plugin-actionsheet', + 'nl.x-services.plugins.socialsharing' : 'cordova-plugin-x-socialsharing', + 'nl.x-services.plugins.googleplus' : 'cordova-plugin-googleplus', + 'nl.x-services.plugins.insomnia' : 'cordova-plugin-insomnia', + 'nl.x-services.plugins.toast' : 'cordova-plugin-x-toast', + 'nl.x-services.plugins.calendar' : 'cordova-plugin-calendar', + 'nl.x-services.plugins.launchmyapp' : 'cordova-plugin-customurlscheme', + 'nl.x-services.plugins.flashlight' : 'cordova-plugin-flashlight', + 'nl.x-services.plugins.sslcertificatechecker' : 'cordova-plugin-sslcertificatechecker', + 'com.bridge.open' : 'cordova-open', + 'com.bridge.safe' : 'cordova-safe', + 'com.disusered.open' : 'cordova-open', + 'com.disusered.safe' : 'cordova-safe', + 'me.apla.cordova.app-preferences' : 'cordova-plugin-app-preferences', + 'com.konotor.cordova' : 'cordova-plugin-konotor', + 'io.intercom.cordova' : 'cordova-plugin-intercom', + 'com.onesignal.plugins.onesignal' : 'onesignal-cordova-plugin', + 'com.danjarvis.document-contract': 'cordova-plugin-document-contract', + 'com.eface2face.iosrtc' : 'cordova-plugin-iosrtc', + 'com.mobileapptracking.matplugin' : 'cordova-plugin-tune', + 'com.marianhello.cordova.background-geolocation' : 'cordova-plugin-mauron85-background-geolocation', + 'fr.louisbl.cordova.locationservices' : 'cordova-plugin-locationservices', + 'fr.louisbl.cordova.gpslocation' : 'cordova-plugin-gpslocation', + 'com.hiliaox.weibo' : 'cordova-plugin-weibo', + 'com.uxcam.cordova.plugin' : 'cordova-uxcam', + 'de.fastr.phonegap.plugins.downloader' : 'cordova-plugin-fastrde-downloader', + 'de.fastr.phonegap.plugins.injectView' : 'cordova-plugin-fastrde-injectview', + 'de.fastr.phonegap.plugins.CheckGPS' : 'cordova-plugin-fastrde-checkgps', + 'de.fastr.phonegap.plugins.md5chksum' : 'cordova-plugin-fastrde-md5', + 'io.repro.cordova' : 'cordova-plugin-repro', + 're.notifica.cordova': 'cordova-plugin-notificare-push', + 'com.megster.cordova.ble': 'cordova-plugin-ble-central', + 'com.megster.cordova.bluetoothserial': 'cordova-plugin-bluetooth-serial', + 'com.megster.cordova.rfduino': 'cordova-plugin-rfduino', + 'cz.velda.cordova.plugin.devicefeedback': 'cordova-plugin-velda-devicefeedback', + 'cz.Velda.cordova.plugin.devicefeedback': 'cordova-plugin-velda-devicefeedback', + 'org.scriptotek.appinfo': 'cordova-plugin-appinfo', + 'com.yezhiming.cordova.appinfo': 'cordova-plugin-appinfo', + 'pl.makingwaves.estimotebeacons': 'cordova-plugin-estimote', + 'com.evothings.ble': 'cordova-plugin-ble', + 'com.appsee.plugin' : 'cordova-plugin-appsee', + 'am.armsoft.plugins.listpicker': 'cordova-plugin-listpicker', + 'com.pushbots.push': 'pushbots-cordova-plugin', + 'com.admob.google': 'cordova-admob', + 'admob.ads.google': 'cordova-admob-ads', + 'admob.google.plugin': 'admob-google', + 'com.admob.admobads': 'admob-ads', + 'com.connectivity.monitor': 'cordova-connectivity-monitor', + 'com.ios.libgoogleadmobads': 'cordova-libgoogleadmobads', + 'com.google.play.services': 'cordova-google-play-services', + 'android.support.v13': 'cordova-android-support-v13', + 'android.support.v4': 'cordova-android-support-v4', // Duplicated key ;) + 'com.analytics.google': 'cordova-plugin-analytics', + 'com.analytics.adid.google': 'cordova-plugin-analytics-adid', + 'com.chariotsolutions.nfc.plugin': 'phonegap-nfc', + 'com.samz.mixpanel': 'cordova-plugin-mixpanel', + 'de.appplant.cordova.common.RegisterUserNotificationSettings': 'cordova-plugin-registerusernotificationsettings', + 'plugin.google.maps': 'cordova-plugin-googlemaps', + 'xu.li.cordova.wechat': 'cordova-plugin-wechat', + 'es.keensoft.fullscreenimage': 'cordova-plugin-fullscreenimage', + 'com.arcoirislabs.plugin.mqtt' : 'cordova-plugin-mqtt' +}; + +module.exports.oldToNew = map; + +var reverseMap = {}; +Object.keys(map).forEach(function(elem){ + reverseMap[map[elem]] = elem; +}); + +module.exports.newToOld = reverseMap; diff --git a/platforms/android/cordova/node_modules/cordova-registry-mapper/package.json b/platforms/android/cordova/node_modules/cordova-registry-mapper/package.json new file mode 100644 index 0000000..989efad --- /dev/null +++ b/platforms/android/cordova/node_modules/cordova-registry-mapper/package.json @@ -0,0 +1,77 @@ +{ + "_args": [ + [ + "cordova-registry-mapper@^1.1.8", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "cordova-registry-mapper@>=1.1.8 <2.0.0", + "_id": "cordova-registry-mapper@1.1.15", + "_inCache": true, + "_installable": true, + "_location": "/cordova-registry-mapper", + "_nodeVersion": "5.4.1", + "_npmUser": { + "email": "stevengill97@gmail.com", + "name": "stevegill" + }, + "_npmVersion": "3.5.3", + "_phantomChildren": {}, + "_requested": { + "name": "cordova-registry-mapper", + "raw": "cordova-registry-mapper@^1.1.8", + "rawSpec": "^1.1.8", + "scope": null, + "spec": ">=1.1.8 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.15.tgz", + "_shasum": "e244b9185b8175473bff6079324905115f83dc7c", + "_shrinkwrap": null, + "_spec": "cordova-registry-mapper@^1.1.8", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "name": "Steve Gill" + }, + "bugs": { + "url": "https://github.com/stevengill/cordova-registry-mapper/issues" + }, + "dependencies": {}, + "description": "Maps old plugin ids to new plugin names for fetching from npm", + "devDependencies": { + "tape": "^3.5.0" + }, + "directories": {}, + "dist": { + "shasum": "e244b9185b8175473bff6079324905115f83dc7c", + "tarball": "http://registry.npmjs.org/cordova-registry-mapper/-/cordova-registry-mapper-1.1.15.tgz" + }, + "gitHead": "00af0f028ec94154a364eeabe38b8e22320647bd", + "homepage": "https://github.com/stevengill/cordova-registry-mapper#readme", + "keywords": [ + "cordova", + "plugins" + ], + "license": "Apache version 2.0", + "main": "index.js", + "maintainers": [ + { + "name": "stevegill", + "email": "stevengill97@gmail.com" + } + ], + "name": "cordova-registry-mapper", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/stevengill/cordova-registry-mapper.git" + }, + "scripts": { + "test": "node tests/test.js" + }, + "version": "1.1.15" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/tests/test.js b/platforms/android/cordova/node_modules/cordova-registry-mapper/tests/test.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/cordova-registry-mapper/tests/test.js rename to platforms/android/cordova/node_modules/cordova-registry-mapper/tests/test.js diff --git a/platforms/android/cordova/node_modules/elementtree/.npmignore b/platforms/android/cordova/node_modules/elementtree/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/platforms/android/cordova/node_modules/elementtree/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/platforms/android/cordova/node_modules/elementtree/.travis.yml b/platforms/android/cordova/node_modules/elementtree/.travis.yml new file mode 100644 index 0000000..6f27c96 --- /dev/null +++ b/platforms/android/cordova/node_modules/elementtree/.travis.yml @@ -0,0 +1,10 @@ +language: node_js + +node_js: + - 0.6 + +script: make test + +notifications: + email: + - tomaz+travisci@tomaz.me diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/package.json b/platforms/android/cordova/node_modules/elementtree/node_modules/sax/package.json deleted file mode 100644 index 74a2664..0000000 --- a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/package.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "name": "sax", - "description": "An evented streaming XML parser in JavaScript", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "version": "0.3.5", - "main": "lib/sax.js", - "license": { - "type": "MIT", - "url": "https://raw.github.com/isaacs/sax-js/master/LICENSE" - }, - "scripts": { - "test": "node test/index.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/isaacs/sax-js.git" - }, - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "_id": "sax@0.3.5", - "contributors": [ - { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - { - "name": "Stein Martin Hustad", - "email": "stein@hustad.com" - }, - { - "name": "Mikeal Rogers", - "email": "mikeal.rogers@gmail.com" - }, - { - "name": "Laurie Harper", - "email": "laurie@holoweb.net" - }, - { - "name": "Jann Horn", - "email": "jann@Jann-PC.fritz.box" - }, - { - "name": "Elijah Insua", - "email": "tmpvar@gmail.com" - }, - { - "name": "Henry Rawas", - "email": "henryr@schakra.com" - }, - { - "name": "Justin Makeig", - "email": "jmpublic@makeig.com" - } - ], - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": "*" - }, - "_engineSupported": true, - "_npmVersion": "1.1.0-beta-7", - "_nodeVersion": "v0.6.7-pre", - "_defaultsLoaded": true, - "dist": { - "shasum": "88fcfc1f73c0c8bbd5b7c776b6d3f3501eed073d", - "tarball": "http://registry.npmjs.org/sax/-/sax-0.3.5.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_shasum": "88fcfc1f73c0c8bbd5b7c776b6d3f3501eed073d", - "_resolved": "http://registry.npmjs.org/sax/-/sax-0.3.5.tgz", - "_from": "sax@0.3.5", - "bugs": { - "url": "https://github.com/isaacs/sax-js/issues" - }, - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/isaacs/sax-js#readme" -} diff --git a/platforms/android/cordova/node_modules/elementtree/package.json b/platforms/android/cordova/node_modules/elementtree/package.json index 03adc91..f1a5f14 100644 --- a/platforms/android/cordova/node_modules/elementtree/package.json +++ b/platforms/android/cordova/node_modules/elementtree/package.json @@ -1,7 +1,44 @@ { + "_args": [ + [ + "elementtree@^0.1.6", + "/Users/steveng/repo/cordova/cordova-android" + ] + ], + "_from": "elementtree@>=0.1.6 <0.2.0", + "_id": "elementtree@0.1.6", + "_inCache": true, + "_installable": true, + "_location": "/elementtree", + "_npmUser": { + "email": "ryan@trolocsis.com", + "name": "rphillips" + }, + "_npmVersion": "1.3.24", + "_phantomChildren": {}, + "_requested": { + "name": "elementtree", + "raw": "elementtree@^0.1.6", + "rawSpec": "^0.1.6", + "scope": null, + "spec": ">=0.1.6 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/", + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz", + "_shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", + "_shrinkwrap": null, + "_spec": "elementtree@^0.1.6", + "_where": "/Users/steveng/repo/cordova/cordova-android", "author": { "name": "Rackspace US, Inc." }, + "bugs": { + "url": "https://github.com/racker/node-elementtree/issues" + }, "contributors": [ { "name": "Paul Querna", @@ -12,64 +49,53 @@ "email": "tomaz.muraus@rackspace.com" } ], - "name": "elementtree", + "dependencies": { + "sax": "0.3.5" + }, "description": "XML Serialization and Parsing module based on Python's ElementTree.", - "version": "0.1.6", - "keywords": [ - "xml", - "sax", - "parser", - "seralization", - "elementtree" - ], - "homepage": "https://github.com/racker/node-elementtree", - "repository": { - "type": "git", - "url": "git://github.com/racker/node-elementtree.git" + "devDependencies": { + "whiskey": "0.8.x" }, - "main": "lib/elementtree.js", "directories": { "lib": "lib" }, - "scripts": { - "test": "make test" + "dist": { + "shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", + "tarball": "http://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz" }, "engines": { "node": ">= 0.4.0" }, - "dependencies": { - "sax": "0.3.5" - }, - "devDependencies": { - "whiskey": "0.8.x" - }, + "homepage": "https://github.com/racker/node-elementtree", + "keywords": [ + "elementtree", + "parser", + "sax", + "seralization", + "xml" + ], "licenses": [ { "type": "Apache", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } ], - "bugs": { - "url": "https://github.com/racker/node-elementtree/issues" - }, - "_id": "elementtree@0.1.6", - "dist": { - "shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", - "tarball": "http://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz" - }, - "_from": "elementtree@>=0.1.6 <0.2.0", - "_npmVersion": "1.3.24", - "_npmUser": { - "name": "rphillips", - "email": "ryan@trolocsis.com" - }, + "main": "lib/elementtree.js", "maintainers": [ { "name": "rphillips", "email": "ryan@trolocsis.com" } ], - "_shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", - "_resolved": "http://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz", - "readme": "ERROR: No README data found!" + "name": "elementtree", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/racker/node-elementtree.git" + }, + "scripts": { + "test": "make test" + }, + "version": "0.1.6" } diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE b/platforms/android/cordova/node_modules/glob/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE rename to platforms/android/cordova/node_modules/glob/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/README.md b/platforms/android/cordova/node_modules/glob/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/README.md rename to platforms/android/cordova/node_modules/glob/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/common.js b/platforms/android/cordova/node_modules/glob/common.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/common.js rename to platforms/android/cordova/node_modules/glob/common.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/glob.js b/platforms/android/cordova/node_modules/glob/glob.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/glob.js rename to platforms/android/cordova/node_modules/glob/glob.js diff --git a/platforms/android/cordova/node_modules/glob/package.json b/platforms/android/cordova/node_modules/glob/package.json new file mode 100644 index 0000000..7c398ae --- /dev/null +++ b/platforms/android/cordova/node_modules/glob/package.json @@ -0,0 +1,98 @@ +{ + "_args": [ + [ + "glob@^5.0.13", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "glob@>=5.0.13 <6.0.0", + "_id": "glob@5.0.15", + "_inCache": true, + "_installable": true, + "_location": "/glob", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "isaacs@npmjs.com", + "name": "isaacs" + }, + "_npmVersion": "3.3.2", + "_phantomChildren": {}, + "_requested": { + "name": "glob", + "raw": "glob@^5.0.13", + "rawSpec": "^5.0.13", + "scope": null, + "spec": ">=5.0.13 <6.0.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "_shasum": "1bc936b9e02f4a603fcc222ecf7633d30b8b93b1", + "_shrinkwrap": null, + "_spec": "glob@^5.0.13", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/node-glob/issues" + }, + "dependencies": { + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "description": "a little globber", + "devDependencies": { + "mkdirp": "0", + "rimraf": "^2.2.8", + "tap": "^1.1.4", + "tick": "0.0.6" + }, + "directories": {}, + "dist": { + "shasum": "1bc936b9e02f4a603fcc222ecf7633d30b8b93b1", + "tarball": "http://registry.npmjs.org/glob/-/glob-5.0.15.tgz" + }, + "engines": { + "node": "*" + }, + "files": [ + "common.js", + "glob.js", + "sync.js" + ], + "gitHead": "3a7e71d453dd80e75b196fd262dd23ed54beeceb", + "homepage": "https://github.com/isaacs/node-glob#readme", + "license": "ISC", + "main": "glob.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "glob", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-glob.git" + }, + "scripts": { + "bench": "bash benchmark.sh", + "benchclean": "node benchclean.js", + "prepublish": "npm run benchclean", + "prof": "bash prof.sh && cat profile.txt", + "profclean": "rm -f v8.log profile.txt", + "test": "tap test/*.js --cov", + "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js" + }, + "version": "5.0.15" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/sync.js b/platforms/android/cordova/node_modules/glob/sync.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/sync.js rename to platforms/android/cordova/node_modules/glob/sync.js diff --git a/platforms/android/cordova/node_modules/inflight/.eslintrc b/platforms/android/cordova/node_modules/inflight/.eslintrc new file mode 100644 index 0000000..b7a1550 --- /dev/null +++ b/platforms/android/cordova/node_modules/inflight/.eslintrc @@ -0,0 +1,17 @@ +{ + "env" : { + "node" : true + }, + "rules" : { + "semi": [2, "never"], + "strict": 0, + "quotes": [1, "single", "avoid-escape"], + "no-use-before-define": 0, + "curly": 0, + "no-underscore-dangle": 0, + "no-lonely-if": 1, + "no-unused-vars": [2, {"vars" : "all", "args" : "after-used"}], + "no-mixed-requires": 0, + "space-infix-ops": 0 + } +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/LICENSE b/platforms/android/cordova/node_modules/inflight/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/LICENSE rename to platforms/android/cordova/node_modules/inflight/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/README.md b/platforms/android/cordova/node_modules/inflight/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/README.md rename to platforms/android/cordova/node_modules/inflight/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/inflight.js b/platforms/android/cordova/node_modules/inflight/inflight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/inflight.js rename to platforms/android/cordova/node_modules/inflight/inflight.js diff --git a/platforms/android/cordova/node_modules/inflight/package.json b/platforms/android/cordova/node_modules/inflight/package.json new file mode 100644 index 0000000..3bc7cf7 --- /dev/null +++ b/platforms/android/cordova/node_modules/inflight/package.json @@ -0,0 +1,86 @@ +{ + "_args": [ + [ + "inflight@^1.0.4", + "/Users/steveng/repo/cordova/cordova-android/node_modules/glob" + ] + ], + "_from": "inflight@>=1.0.4 <2.0.0", + "_id": "inflight@1.0.4", + "_inCache": true, + "_installable": true, + "_location": "/inflight", + "_nodeVersion": "0.10.32", + "_npmUser": { + "email": "ogd@aoaioxxysz.net", + "name": "othiym23" + }, + "_npmVersion": "2.1.3", + "_phantomChildren": {}, + "_requested": { + "name": "inflight", + "raw": "inflight@^1.0.4", + "rawSpec": "^1.0.4", + "scope": null, + "spec": ">=1.0.4 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob" + ], + "_resolved": "http://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", + "_shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", + "_shrinkwrap": null, + "_spec": "inflight@^1.0.4", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/glob", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/inflight/issues" + }, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + }, + "description": "Add callbacks to requests in flight to avoid async duplication", + "devDependencies": { + "tap": "^0.4.10" + }, + "directories": {}, + "dist": { + "shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", + "tarball": "http://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz" + }, + "gitHead": "c7b5531d572a867064d4a1da9e013e8910b7d1ba", + "homepage": "https://github.com/isaacs/inflight", + "license": "ISC", + "main": "inflight.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + }, + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "name": "inflight", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/inflight.git" + }, + "scripts": { + "test": "tap test.js" + }, + "version": "1.0.4" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/test.js b/platforms/android/cordova/node_modules/inflight/test.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/test.js rename to platforms/android/cordova/node_modules/inflight/test.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/LICENSE b/platforms/android/cordova/node_modules/inherits/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/LICENSE rename to platforms/android/cordova/node_modules/inherits/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/README.md b/platforms/android/cordova/node_modules/inherits/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/README.md rename to platforms/android/cordova/node_modules/inherits/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/inherits.js b/platforms/android/cordova/node_modules/inherits/inherits.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/inherits.js rename to platforms/android/cordova/node_modules/inherits/inherits.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/inherits_browser.js b/platforms/android/cordova/node_modules/inherits/inherits_browser.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/inherits_browser.js rename to platforms/android/cordova/node_modules/inherits/inherits_browser.js diff --git a/platforms/android/cordova/node_modules/inherits/package.json b/platforms/android/cordova/node_modules/inherits/package.json new file mode 100644 index 0000000..6313b8e --- /dev/null +++ b/platforms/android/cordova/node_modules/inherits/package.json @@ -0,0 +1,77 @@ +{ + "_args": [ + [ + "inherits@2", + "/Users/steveng/repo/cordova/cordova-android/node_modules/glob" + ] + ], + "_from": "inherits@>=2.0.0 <3.0.0", + "_id": "inherits@2.0.1", + "_inCache": true, + "_installable": true, + "_location": "/inherits", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "1.3.8", + "_phantomChildren": {}, + "_requested": { + "name": "inherits", + "raw": "inherits@2", + "rawSpec": "2", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob" + ], + "_resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "_shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", + "_shrinkwrap": null, + "_spec": "inherits@2", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/glob", + "browser": "./inherits_browser.js", + "bugs": { + "url": "https://github.com/isaacs/inherits/issues" + }, + "dependencies": {}, + "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", + "tarball": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + }, + "homepage": "https://github.com/isaacs/inherits#readme", + "keywords": [ + "browser", + "browserify", + "class", + "inheritance", + "inherits", + "klass", + "object-oriented", + "oop" + ], + "license": "ISC", + "main": "./inherits.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "inherits", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/inherits.git" + }, + "scripts": { + "test": "node test" + }, + "version": "2.0.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/test.js b/platforms/android/cordova/node_modules/inherits/test.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inherits/test.js rename to platforms/android/cordova/node_modules/inherits/test.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/LICENSE b/platforms/android/cordova/node_modules/lodash/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/LICENSE rename to platforms/android/cordova/node_modules/lodash/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/README.md b/platforms/android/cordova/node_modules/lodash/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/README.md rename to platforms/android/cordova/node_modules/lodash/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array.js b/platforms/android/cordova/node_modules/lodash/array.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array.js rename to platforms/android/cordova/node_modules/lodash/array.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/chunk.js b/platforms/android/cordova/node_modules/lodash/array/chunk.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/chunk.js rename to platforms/android/cordova/node_modules/lodash/array/chunk.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/compact.js b/platforms/android/cordova/node_modules/lodash/array/compact.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/compact.js rename to platforms/android/cordova/node_modules/lodash/array/compact.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/difference.js b/platforms/android/cordova/node_modules/lodash/array/difference.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/difference.js rename to platforms/android/cordova/node_modules/lodash/array/difference.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/drop.js b/platforms/android/cordova/node_modules/lodash/array/drop.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/drop.js rename to platforms/android/cordova/node_modules/lodash/array/drop.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/dropRight.js b/platforms/android/cordova/node_modules/lodash/array/dropRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/dropRight.js rename to platforms/android/cordova/node_modules/lodash/array/dropRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/dropRightWhile.js b/platforms/android/cordova/node_modules/lodash/array/dropRightWhile.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/dropRightWhile.js rename to platforms/android/cordova/node_modules/lodash/array/dropRightWhile.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/dropWhile.js b/platforms/android/cordova/node_modules/lodash/array/dropWhile.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/dropWhile.js rename to platforms/android/cordova/node_modules/lodash/array/dropWhile.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/fill.js b/platforms/android/cordova/node_modules/lodash/array/fill.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/fill.js rename to platforms/android/cordova/node_modules/lodash/array/fill.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/findIndex.js b/platforms/android/cordova/node_modules/lodash/array/findIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/findIndex.js rename to platforms/android/cordova/node_modules/lodash/array/findIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/findLastIndex.js b/platforms/android/cordova/node_modules/lodash/array/findLastIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/findLastIndex.js rename to platforms/android/cordova/node_modules/lodash/array/findLastIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/first.js b/platforms/android/cordova/node_modules/lodash/array/first.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/first.js rename to platforms/android/cordova/node_modules/lodash/array/first.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/flatten.js b/platforms/android/cordova/node_modules/lodash/array/flatten.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/flatten.js rename to platforms/android/cordova/node_modules/lodash/array/flatten.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/flattenDeep.js b/platforms/android/cordova/node_modules/lodash/array/flattenDeep.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/flattenDeep.js rename to platforms/android/cordova/node_modules/lodash/array/flattenDeep.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/head.js b/platforms/android/cordova/node_modules/lodash/array/head.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/head.js rename to platforms/android/cordova/node_modules/lodash/array/head.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/indexOf.js b/platforms/android/cordova/node_modules/lodash/array/indexOf.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/indexOf.js rename to platforms/android/cordova/node_modules/lodash/array/indexOf.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/initial.js b/platforms/android/cordova/node_modules/lodash/array/initial.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/initial.js rename to platforms/android/cordova/node_modules/lodash/array/initial.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/intersection.js b/platforms/android/cordova/node_modules/lodash/array/intersection.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/intersection.js rename to platforms/android/cordova/node_modules/lodash/array/intersection.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/last.js b/platforms/android/cordova/node_modules/lodash/array/last.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/last.js rename to platforms/android/cordova/node_modules/lodash/array/last.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/lastIndexOf.js b/platforms/android/cordova/node_modules/lodash/array/lastIndexOf.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/lastIndexOf.js rename to platforms/android/cordova/node_modules/lodash/array/lastIndexOf.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/object.js b/platforms/android/cordova/node_modules/lodash/array/object.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/object.js rename to platforms/android/cordova/node_modules/lodash/array/object.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/pull.js b/platforms/android/cordova/node_modules/lodash/array/pull.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/pull.js rename to platforms/android/cordova/node_modules/lodash/array/pull.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/pullAt.js b/platforms/android/cordova/node_modules/lodash/array/pullAt.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/pullAt.js rename to platforms/android/cordova/node_modules/lodash/array/pullAt.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/remove.js b/platforms/android/cordova/node_modules/lodash/array/remove.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/remove.js rename to platforms/android/cordova/node_modules/lodash/array/remove.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/rest.js b/platforms/android/cordova/node_modules/lodash/array/rest.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/rest.js rename to platforms/android/cordova/node_modules/lodash/array/rest.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/slice.js b/platforms/android/cordova/node_modules/lodash/array/slice.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/slice.js rename to platforms/android/cordova/node_modules/lodash/array/slice.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/sortedIndex.js b/platforms/android/cordova/node_modules/lodash/array/sortedIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/sortedIndex.js rename to platforms/android/cordova/node_modules/lodash/array/sortedIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/sortedLastIndex.js b/platforms/android/cordova/node_modules/lodash/array/sortedLastIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/sortedLastIndex.js rename to platforms/android/cordova/node_modules/lodash/array/sortedLastIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/tail.js b/platforms/android/cordova/node_modules/lodash/array/tail.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/tail.js rename to platforms/android/cordova/node_modules/lodash/array/tail.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/take.js b/platforms/android/cordova/node_modules/lodash/array/take.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/take.js rename to platforms/android/cordova/node_modules/lodash/array/take.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/takeRight.js b/platforms/android/cordova/node_modules/lodash/array/takeRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/takeRight.js rename to platforms/android/cordova/node_modules/lodash/array/takeRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/takeRightWhile.js b/platforms/android/cordova/node_modules/lodash/array/takeRightWhile.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/takeRightWhile.js rename to platforms/android/cordova/node_modules/lodash/array/takeRightWhile.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/takeWhile.js b/platforms/android/cordova/node_modules/lodash/array/takeWhile.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/takeWhile.js rename to platforms/android/cordova/node_modules/lodash/array/takeWhile.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/union.js b/platforms/android/cordova/node_modules/lodash/array/union.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/union.js rename to platforms/android/cordova/node_modules/lodash/array/union.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/uniq.js b/platforms/android/cordova/node_modules/lodash/array/uniq.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/uniq.js rename to platforms/android/cordova/node_modules/lodash/array/uniq.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/unique.js b/platforms/android/cordova/node_modules/lodash/array/unique.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/unique.js rename to platforms/android/cordova/node_modules/lodash/array/unique.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/unzip.js b/platforms/android/cordova/node_modules/lodash/array/unzip.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/unzip.js rename to platforms/android/cordova/node_modules/lodash/array/unzip.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/unzipWith.js b/platforms/android/cordova/node_modules/lodash/array/unzipWith.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/unzipWith.js rename to platforms/android/cordova/node_modules/lodash/array/unzipWith.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/without.js b/platforms/android/cordova/node_modules/lodash/array/without.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/without.js rename to platforms/android/cordova/node_modules/lodash/array/without.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/xor.js b/platforms/android/cordova/node_modules/lodash/array/xor.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/xor.js rename to platforms/android/cordova/node_modules/lodash/array/xor.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/zip.js b/platforms/android/cordova/node_modules/lodash/array/zip.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/zip.js rename to platforms/android/cordova/node_modules/lodash/array/zip.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/zipObject.js b/platforms/android/cordova/node_modules/lodash/array/zipObject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/zipObject.js rename to platforms/android/cordova/node_modules/lodash/array/zipObject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/zipWith.js b/platforms/android/cordova/node_modules/lodash/array/zipWith.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/array/zipWith.js rename to platforms/android/cordova/node_modules/lodash/array/zipWith.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain.js b/platforms/android/cordova/node_modules/lodash/chain.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain.js rename to platforms/android/cordova/node_modules/lodash/chain.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/chain.js b/platforms/android/cordova/node_modules/lodash/chain/chain.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/chain.js rename to platforms/android/cordova/node_modules/lodash/chain/chain.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/commit.js b/platforms/android/cordova/node_modules/lodash/chain/commit.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/commit.js rename to platforms/android/cordova/node_modules/lodash/chain/commit.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/concat.js b/platforms/android/cordova/node_modules/lodash/chain/concat.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/concat.js rename to platforms/android/cordova/node_modules/lodash/chain/concat.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/lodash.js b/platforms/android/cordova/node_modules/lodash/chain/lodash.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/lodash.js rename to platforms/android/cordova/node_modules/lodash/chain/lodash.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/plant.js b/platforms/android/cordova/node_modules/lodash/chain/plant.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/plant.js rename to platforms/android/cordova/node_modules/lodash/chain/plant.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/reverse.js b/platforms/android/cordova/node_modules/lodash/chain/reverse.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/reverse.js rename to platforms/android/cordova/node_modules/lodash/chain/reverse.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/run.js b/platforms/android/cordova/node_modules/lodash/chain/run.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/run.js rename to platforms/android/cordova/node_modules/lodash/chain/run.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/tap.js b/platforms/android/cordova/node_modules/lodash/chain/tap.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/tap.js rename to platforms/android/cordova/node_modules/lodash/chain/tap.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/thru.js b/platforms/android/cordova/node_modules/lodash/chain/thru.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/thru.js rename to platforms/android/cordova/node_modules/lodash/chain/thru.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/toJSON.js b/platforms/android/cordova/node_modules/lodash/chain/toJSON.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/toJSON.js rename to platforms/android/cordova/node_modules/lodash/chain/toJSON.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/toString.js b/platforms/android/cordova/node_modules/lodash/chain/toString.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/toString.js rename to platforms/android/cordova/node_modules/lodash/chain/toString.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/value.js b/platforms/android/cordova/node_modules/lodash/chain/value.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/value.js rename to platforms/android/cordova/node_modules/lodash/chain/value.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/valueOf.js b/platforms/android/cordova/node_modules/lodash/chain/valueOf.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/valueOf.js rename to platforms/android/cordova/node_modules/lodash/chain/valueOf.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperChain.js b/platforms/android/cordova/node_modules/lodash/chain/wrapperChain.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperChain.js rename to platforms/android/cordova/node_modules/lodash/chain/wrapperChain.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperCommit.js b/platforms/android/cordova/node_modules/lodash/chain/wrapperCommit.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperCommit.js rename to platforms/android/cordova/node_modules/lodash/chain/wrapperCommit.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperConcat.js b/platforms/android/cordova/node_modules/lodash/chain/wrapperConcat.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperConcat.js rename to platforms/android/cordova/node_modules/lodash/chain/wrapperConcat.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperPlant.js b/platforms/android/cordova/node_modules/lodash/chain/wrapperPlant.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperPlant.js rename to platforms/android/cordova/node_modules/lodash/chain/wrapperPlant.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperReverse.js b/platforms/android/cordova/node_modules/lodash/chain/wrapperReverse.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperReverse.js rename to platforms/android/cordova/node_modules/lodash/chain/wrapperReverse.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperToString.js b/platforms/android/cordova/node_modules/lodash/chain/wrapperToString.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperToString.js rename to platforms/android/cordova/node_modules/lodash/chain/wrapperToString.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperValue.js b/platforms/android/cordova/node_modules/lodash/chain/wrapperValue.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/chain/wrapperValue.js rename to platforms/android/cordova/node_modules/lodash/chain/wrapperValue.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection.js b/platforms/android/cordova/node_modules/lodash/collection.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection.js rename to platforms/android/cordova/node_modules/lodash/collection.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/all.js b/platforms/android/cordova/node_modules/lodash/collection/all.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/all.js rename to platforms/android/cordova/node_modules/lodash/collection/all.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/any.js b/platforms/android/cordova/node_modules/lodash/collection/any.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/any.js rename to platforms/android/cordova/node_modules/lodash/collection/any.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/at.js b/platforms/android/cordova/node_modules/lodash/collection/at.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/at.js rename to platforms/android/cordova/node_modules/lodash/collection/at.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/collect.js b/platforms/android/cordova/node_modules/lodash/collection/collect.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/collect.js rename to platforms/android/cordova/node_modules/lodash/collection/collect.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/contains.js b/platforms/android/cordova/node_modules/lodash/collection/contains.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/contains.js rename to platforms/android/cordova/node_modules/lodash/collection/contains.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/countBy.js b/platforms/android/cordova/node_modules/lodash/collection/countBy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/countBy.js rename to platforms/android/cordova/node_modules/lodash/collection/countBy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/detect.js b/platforms/android/cordova/node_modules/lodash/collection/detect.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/detect.js rename to platforms/android/cordova/node_modules/lodash/collection/detect.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/each.js b/platforms/android/cordova/node_modules/lodash/collection/each.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/each.js rename to platforms/android/cordova/node_modules/lodash/collection/each.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/eachRight.js b/platforms/android/cordova/node_modules/lodash/collection/eachRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/eachRight.js rename to platforms/android/cordova/node_modules/lodash/collection/eachRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/every.js b/platforms/android/cordova/node_modules/lodash/collection/every.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/every.js rename to platforms/android/cordova/node_modules/lodash/collection/every.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/filter.js b/platforms/android/cordova/node_modules/lodash/collection/filter.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/filter.js rename to platforms/android/cordova/node_modules/lodash/collection/filter.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/find.js b/platforms/android/cordova/node_modules/lodash/collection/find.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/find.js rename to platforms/android/cordova/node_modules/lodash/collection/find.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/findLast.js b/platforms/android/cordova/node_modules/lodash/collection/findLast.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/findLast.js rename to platforms/android/cordova/node_modules/lodash/collection/findLast.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/findWhere.js b/platforms/android/cordova/node_modules/lodash/collection/findWhere.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/findWhere.js rename to platforms/android/cordova/node_modules/lodash/collection/findWhere.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/foldl.js b/platforms/android/cordova/node_modules/lodash/collection/foldl.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/foldl.js rename to platforms/android/cordova/node_modules/lodash/collection/foldl.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/foldr.js b/platforms/android/cordova/node_modules/lodash/collection/foldr.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/foldr.js rename to platforms/android/cordova/node_modules/lodash/collection/foldr.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/forEach.js b/platforms/android/cordova/node_modules/lodash/collection/forEach.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/forEach.js rename to platforms/android/cordova/node_modules/lodash/collection/forEach.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/forEachRight.js b/platforms/android/cordova/node_modules/lodash/collection/forEachRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/forEachRight.js rename to platforms/android/cordova/node_modules/lodash/collection/forEachRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/groupBy.js b/platforms/android/cordova/node_modules/lodash/collection/groupBy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/groupBy.js rename to platforms/android/cordova/node_modules/lodash/collection/groupBy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/include.js b/platforms/android/cordova/node_modules/lodash/collection/include.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/include.js rename to platforms/android/cordova/node_modules/lodash/collection/include.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/includes.js b/platforms/android/cordova/node_modules/lodash/collection/includes.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/includes.js rename to platforms/android/cordova/node_modules/lodash/collection/includes.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/indexBy.js b/platforms/android/cordova/node_modules/lodash/collection/indexBy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/indexBy.js rename to platforms/android/cordova/node_modules/lodash/collection/indexBy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/inject.js b/platforms/android/cordova/node_modules/lodash/collection/inject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/inject.js rename to platforms/android/cordova/node_modules/lodash/collection/inject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/invoke.js b/platforms/android/cordova/node_modules/lodash/collection/invoke.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/invoke.js rename to platforms/android/cordova/node_modules/lodash/collection/invoke.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/map.js b/platforms/android/cordova/node_modules/lodash/collection/map.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/map.js rename to platforms/android/cordova/node_modules/lodash/collection/map.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/max.js b/platforms/android/cordova/node_modules/lodash/collection/max.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/max.js rename to platforms/android/cordova/node_modules/lodash/collection/max.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/min.js b/platforms/android/cordova/node_modules/lodash/collection/min.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/min.js rename to platforms/android/cordova/node_modules/lodash/collection/min.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/partition.js b/platforms/android/cordova/node_modules/lodash/collection/partition.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/partition.js rename to platforms/android/cordova/node_modules/lodash/collection/partition.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/pluck.js b/platforms/android/cordova/node_modules/lodash/collection/pluck.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/pluck.js rename to platforms/android/cordova/node_modules/lodash/collection/pluck.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/reduce.js b/platforms/android/cordova/node_modules/lodash/collection/reduce.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/reduce.js rename to platforms/android/cordova/node_modules/lodash/collection/reduce.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/reduceRight.js b/platforms/android/cordova/node_modules/lodash/collection/reduceRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/reduceRight.js rename to platforms/android/cordova/node_modules/lodash/collection/reduceRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/reject.js b/platforms/android/cordova/node_modules/lodash/collection/reject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/reject.js rename to platforms/android/cordova/node_modules/lodash/collection/reject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sample.js b/platforms/android/cordova/node_modules/lodash/collection/sample.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sample.js rename to platforms/android/cordova/node_modules/lodash/collection/sample.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/select.js b/platforms/android/cordova/node_modules/lodash/collection/select.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/select.js rename to platforms/android/cordova/node_modules/lodash/collection/select.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/shuffle.js b/platforms/android/cordova/node_modules/lodash/collection/shuffle.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/shuffle.js rename to platforms/android/cordova/node_modules/lodash/collection/shuffle.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/size.js b/platforms/android/cordova/node_modules/lodash/collection/size.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/size.js rename to platforms/android/cordova/node_modules/lodash/collection/size.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/some.js b/platforms/android/cordova/node_modules/lodash/collection/some.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/some.js rename to platforms/android/cordova/node_modules/lodash/collection/some.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sortBy.js b/platforms/android/cordova/node_modules/lodash/collection/sortBy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sortBy.js rename to platforms/android/cordova/node_modules/lodash/collection/sortBy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sortByAll.js b/platforms/android/cordova/node_modules/lodash/collection/sortByAll.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sortByAll.js rename to platforms/android/cordova/node_modules/lodash/collection/sortByAll.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sortByOrder.js b/platforms/android/cordova/node_modules/lodash/collection/sortByOrder.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sortByOrder.js rename to platforms/android/cordova/node_modules/lodash/collection/sortByOrder.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sum.js b/platforms/android/cordova/node_modules/lodash/collection/sum.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/sum.js rename to platforms/android/cordova/node_modules/lodash/collection/sum.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/where.js b/platforms/android/cordova/node_modules/lodash/collection/where.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/collection/where.js rename to platforms/android/cordova/node_modules/lodash/collection/where.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/date.js b/platforms/android/cordova/node_modules/lodash/date.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/date.js rename to platforms/android/cordova/node_modules/lodash/date.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/date/now.js b/platforms/android/cordova/node_modules/lodash/date/now.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/date/now.js rename to platforms/android/cordova/node_modules/lodash/date/now.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function.js b/platforms/android/cordova/node_modules/lodash/function.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function.js rename to platforms/android/cordova/node_modules/lodash/function.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/after.js b/platforms/android/cordova/node_modules/lodash/function/after.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/after.js rename to platforms/android/cordova/node_modules/lodash/function/after.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/ary.js b/platforms/android/cordova/node_modules/lodash/function/ary.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/ary.js rename to platforms/android/cordova/node_modules/lodash/function/ary.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/backflow.js b/platforms/android/cordova/node_modules/lodash/function/backflow.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/backflow.js rename to platforms/android/cordova/node_modules/lodash/function/backflow.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/before.js b/platforms/android/cordova/node_modules/lodash/function/before.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/before.js rename to platforms/android/cordova/node_modules/lodash/function/before.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/bind.js b/platforms/android/cordova/node_modules/lodash/function/bind.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/bind.js rename to platforms/android/cordova/node_modules/lodash/function/bind.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/bindAll.js b/platforms/android/cordova/node_modules/lodash/function/bindAll.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/bindAll.js rename to platforms/android/cordova/node_modules/lodash/function/bindAll.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/bindKey.js b/platforms/android/cordova/node_modules/lodash/function/bindKey.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/bindKey.js rename to platforms/android/cordova/node_modules/lodash/function/bindKey.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/compose.js b/platforms/android/cordova/node_modules/lodash/function/compose.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/compose.js rename to platforms/android/cordova/node_modules/lodash/function/compose.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/curry.js b/platforms/android/cordova/node_modules/lodash/function/curry.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/curry.js rename to platforms/android/cordova/node_modules/lodash/function/curry.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/curryRight.js b/platforms/android/cordova/node_modules/lodash/function/curryRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/curryRight.js rename to platforms/android/cordova/node_modules/lodash/function/curryRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/debounce.js b/platforms/android/cordova/node_modules/lodash/function/debounce.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/debounce.js rename to platforms/android/cordova/node_modules/lodash/function/debounce.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/defer.js b/platforms/android/cordova/node_modules/lodash/function/defer.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/defer.js rename to platforms/android/cordova/node_modules/lodash/function/defer.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/delay.js b/platforms/android/cordova/node_modules/lodash/function/delay.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/delay.js rename to platforms/android/cordova/node_modules/lodash/function/delay.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/flow.js b/platforms/android/cordova/node_modules/lodash/function/flow.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/flow.js rename to platforms/android/cordova/node_modules/lodash/function/flow.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/flowRight.js b/platforms/android/cordova/node_modules/lodash/function/flowRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/flowRight.js rename to platforms/android/cordova/node_modules/lodash/function/flowRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/memoize.js b/platforms/android/cordova/node_modules/lodash/function/memoize.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/memoize.js rename to platforms/android/cordova/node_modules/lodash/function/memoize.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/modArgs.js b/platforms/android/cordova/node_modules/lodash/function/modArgs.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/modArgs.js rename to platforms/android/cordova/node_modules/lodash/function/modArgs.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/negate.js b/platforms/android/cordova/node_modules/lodash/function/negate.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/negate.js rename to platforms/android/cordova/node_modules/lodash/function/negate.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/once.js b/platforms/android/cordova/node_modules/lodash/function/once.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/once.js rename to platforms/android/cordova/node_modules/lodash/function/once.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/partial.js b/platforms/android/cordova/node_modules/lodash/function/partial.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/partial.js rename to platforms/android/cordova/node_modules/lodash/function/partial.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/partialRight.js b/platforms/android/cordova/node_modules/lodash/function/partialRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/partialRight.js rename to platforms/android/cordova/node_modules/lodash/function/partialRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/rearg.js b/platforms/android/cordova/node_modules/lodash/function/rearg.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/rearg.js rename to platforms/android/cordova/node_modules/lodash/function/rearg.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/restParam.js b/platforms/android/cordova/node_modules/lodash/function/restParam.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/restParam.js rename to platforms/android/cordova/node_modules/lodash/function/restParam.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/spread.js b/platforms/android/cordova/node_modules/lodash/function/spread.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/spread.js rename to platforms/android/cordova/node_modules/lodash/function/spread.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/throttle.js b/platforms/android/cordova/node_modules/lodash/function/throttle.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/throttle.js rename to platforms/android/cordova/node_modules/lodash/function/throttle.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/wrap.js b/platforms/android/cordova/node_modules/lodash/function/wrap.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/function/wrap.js rename to platforms/android/cordova/node_modules/lodash/function/wrap.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/index.js b/platforms/android/cordova/node_modules/lodash/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/index.js rename to platforms/android/cordova/node_modules/lodash/index.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/LazyWrapper.js b/platforms/android/cordova/node_modules/lodash/internal/LazyWrapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/LazyWrapper.js rename to platforms/android/cordova/node_modules/lodash/internal/LazyWrapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/LodashWrapper.js b/platforms/android/cordova/node_modules/lodash/internal/LodashWrapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/LodashWrapper.js rename to platforms/android/cordova/node_modules/lodash/internal/LodashWrapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/MapCache.js b/platforms/android/cordova/node_modules/lodash/internal/MapCache.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/MapCache.js rename to platforms/android/cordova/node_modules/lodash/internal/MapCache.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/SetCache.js b/platforms/android/cordova/node_modules/lodash/internal/SetCache.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/SetCache.js rename to platforms/android/cordova/node_modules/lodash/internal/SetCache.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayConcat.js b/platforms/android/cordova/node_modules/lodash/internal/arrayConcat.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayConcat.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayConcat.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayCopy.js b/platforms/android/cordova/node_modules/lodash/internal/arrayCopy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayCopy.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayCopy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayEach.js b/platforms/android/cordova/node_modules/lodash/internal/arrayEach.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayEach.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayEach.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayEachRight.js b/platforms/android/cordova/node_modules/lodash/internal/arrayEachRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayEachRight.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayEachRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayEvery.js b/platforms/android/cordova/node_modules/lodash/internal/arrayEvery.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayEvery.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayEvery.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayExtremum.js b/platforms/android/cordova/node_modules/lodash/internal/arrayExtremum.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayExtremum.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayExtremum.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayFilter.js b/platforms/android/cordova/node_modules/lodash/internal/arrayFilter.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayFilter.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayFilter.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayMap.js b/platforms/android/cordova/node_modules/lodash/internal/arrayMap.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayMap.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayMap.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayPush.js b/platforms/android/cordova/node_modules/lodash/internal/arrayPush.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayPush.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayPush.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayReduce.js b/platforms/android/cordova/node_modules/lodash/internal/arrayReduce.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayReduce.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayReduce.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayReduceRight.js b/platforms/android/cordova/node_modules/lodash/internal/arrayReduceRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arrayReduceRight.js rename to platforms/android/cordova/node_modules/lodash/internal/arrayReduceRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arraySome.js b/platforms/android/cordova/node_modules/lodash/internal/arraySome.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arraySome.js rename to platforms/android/cordova/node_modules/lodash/internal/arraySome.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arraySum.js b/platforms/android/cordova/node_modules/lodash/internal/arraySum.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/arraySum.js rename to platforms/android/cordova/node_modules/lodash/internal/arraySum.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/assignDefaults.js b/platforms/android/cordova/node_modules/lodash/internal/assignDefaults.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/assignDefaults.js rename to platforms/android/cordova/node_modules/lodash/internal/assignDefaults.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/assignOwnDefaults.js b/platforms/android/cordova/node_modules/lodash/internal/assignOwnDefaults.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/assignOwnDefaults.js rename to platforms/android/cordova/node_modules/lodash/internal/assignOwnDefaults.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/assignWith.js b/platforms/android/cordova/node_modules/lodash/internal/assignWith.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/assignWith.js rename to platforms/android/cordova/node_modules/lodash/internal/assignWith.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseAssign.js b/platforms/android/cordova/node_modules/lodash/internal/baseAssign.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseAssign.js rename to platforms/android/cordova/node_modules/lodash/internal/baseAssign.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseAt.js b/platforms/android/cordova/node_modules/lodash/internal/baseAt.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseAt.js rename to platforms/android/cordova/node_modules/lodash/internal/baseAt.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCallback.js b/platforms/android/cordova/node_modules/lodash/internal/baseCallback.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCallback.js rename to platforms/android/cordova/node_modules/lodash/internal/baseCallback.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseClone.js b/platforms/android/cordova/node_modules/lodash/internal/baseClone.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseClone.js rename to platforms/android/cordova/node_modules/lodash/internal/baseClone.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCompareAscending.js b/platforms/android/cordova/node_modules/lodash/internal/baseCompareAscending.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCompareAscending.js rename to platforms/android/cordova/node_modules/lodash/internal/baseCompareAscending.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCopy.js b/platforms/android/cordova/node_modules/lodash/internal/baseCopy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCopy.js rename to platforms/android/cordova/node_modules/lodash/internal/baseCopy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCreate.js b/platforms/android/cordova/node_modules/lodash/internal/baseCreate.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseCreate.js rename to platforms/android/cordova/node_modules/lodash/internal/baseCreate.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseDelay.js b/platforms/android/cordova/node_modules/lodash/internal/baseDelay.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseDelay.js rename to platforms/android/cordova/node_modules/lodash/internal/baseDelay.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseDifference.js b/platforms/android/cordova/node_modules/lodash/internal/baseDifference.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseDifference.js rename to platforms/android/cordova/node_modules/lodash/internal/baseDifference.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseEach.js b/platforms/android/cordova/node_modules/lodash/internal/baseEach.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseEach.js rename to platforms/android/cordova/node_modules/lodash/internal/baseEach.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseEachRight.js b/platforms/android/cordova/node_modules/lodash/internal/baseEachRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseEachRight.js rename to platforms/android/cordova/node_modules/lodash/internal/baseEachRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseEvery.js b/platforms/android/cordova/node_modules/lodash/internal/baseEvery.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseEvery.js rename to platforms/android/cordova/node_modules/lodash/internal/baseEvery.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseExtremum.js b/platforms/android/cordova/node_modules/lodash/internal/baseExtremum.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseExtremum.js rename to platforms/android/cordova/node_modules/lodash/internal/baseExtremum.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFill.js b/platforms/android/cordova/node_modules/lodash/internal/baseFill.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFill.js rename to platforms/android/cordova/node_modules/lodash/internal/baseFill.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFilter.js b/platforms/android/cordova/node_modules/lodash/internal/baseFilter.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFilter.js rename to platforms/android/cordova/node_modules/lodash/internal/baseFilter.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFind.js b/platforms/android/cordova/node_modules/lodash/internal/baseFind.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFind.js rename to platforms/android/cordova/node_modules/lodash/internal/baseFind.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFindIndex.js b/platforms/android/cordova/node_modules/lodash/internal/baseFindIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFindIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/baseFindIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFlatten.js b/platforms/android/cordova/node_modules/lodash/internal/baseFlatten.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFlatten.js rename to platforms/android/cordova/node_modules/lodash/internal/baseFlatten.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFor.js b/platforms/android/cordova/node_modules/lodash/internal/baseFor.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFor.js rename to platforms/android/cordova/node_modules/lodash/internal/baseFor.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForIn.js b/platforms/android/cordova/node_modules/lodash/internal/baseForIn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForIn.js rename to platforms/android/cordova/node_modules/lodash/internal/baseForIn.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForOwn.js b/platforms/android/cordova/node_modules/lodash/internal/baseForOwn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForOwn.js rename to platforms/android/cordova/node_modules/lodash/internal/baseForOwn.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForOwnRight.js b/platforms/android/cordova/node_modules/lodash/internal/baseForOwnRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForOwnRight.js rename to platforms/android/cordova/node_modules/lodash/internal/baseForOwnRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForRight.js b/platforms/android/cordova/node_modules/lodash/internal/baseForRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseForRight.js rename to platforms/android/cordova/node_modules/lodash/internal/baseForRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFunctions.js b/platforms/android/cordova/node_modules/lodash/internal/baseFunctions.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseFunctions.js rename to platforms/android/cordova/node_modules/lodash/internal/baseFunctions.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseGet.js b/platforms/android/cordova/node_modules/lodash/internal/baseGet.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseGet.js rename to platforms/android/cordova/node_modules/lodash/internal/baseGet.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIndexOf.js b/platforms/android/cordova/node_modules/lodash/internal/baseIndexOf.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIndexOf.js rename to platforms/android/cordova/node_modules/lodash/internal/baseIndexOf.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsEqual.js b/platforms/android/cordova/node_modules/lodash/internal/baseIsEqual.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsEqual.js rename to platforms/android/cordova/node_modules/lodash/internal/baseIsEqual.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsEqualDeep.js b/platforms/android/cordova/node_modules/lodash/internal/baseIsEqualDeep.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsEqualDeep.js rename to platforms/android/cordova/node_modules/lodash/internal/baseIsEqualDeep.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsFunction.js b/platforms/android/cordova/node_modules/lodash/internal/baseIsFunction.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsFunction.js rename to platforms/android/cordova/node_modules/lodash/internal/baseIsFunction.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsMatch.js b/platforms/android/cordova/node_modules/lodash/internal/baseIsMatch.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseIsMatch.js rename to platforms/android/cordova/node_modules/lodash/internal/baseIsMatch.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseLodash.js b/platforms/android/cordova/node_modules/lodash/internal/baseLodash.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseLodash.js rename to platforms/android/cordova/node_modules/lodash/internal/baseLodash.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMap.js b/platforms/android/cordova/node_modules/lodash/internal/baseMap.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMap.js rename to platforms/android/cordova/node_modules/lodash/internal/baseMap.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMatches.js b/platforms/android/cordova/node_modules/lodash/internal/baseMatches.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMatches.js rename to platforms/android/cordova/node_modules/lodash/internal/baseMatches.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMatchesProperty.js b/platforms/android/cordova/node_modules/lodash/internal/baseMatchesProperty.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMatchesProperty.js rename to platforms/android/cordova/node_modules/lodash/internal/baseMatchesProperty.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMerge.js b/platforms/android/cordova/node_modules/lodash/internal/baseMerge.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMerge.js rename to platforms/android/cordova/node_modules/lodash/internal/baseMerge.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMergeDeep.js b/platforms/android/cordova/node_modules/lodash/internal/baseMergeDeep.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseMergeDeep.js rename to platforms/android/cordova/node_modules/lodash/internal/baseMergeDeep.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseProperty.js b/platforms/android/cordova/node_modules/lodash/internal/baseProperty.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseProperty.js rename to platforms/android/cordova/node_modules/lodash/internal/baseProperty.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/basePropertyDeep.js b/platforms/android/cordova/node_modules/lodash/internal/basePropertyDeep.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/basePropertyDeep.js rename to platforms/android/cordova/node_modules/lodash/internal/basePropertyDeep.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/basePullAt.js b/platforms/android/cordova/node_modules/lodash/internal/basePullAt.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/basePullAt.js rename to platforms/android/cordova/node_modules/lodash/internal/basePullAt.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseRandom.js b/platforms/android/cordova/node_modules/lodash/internal/baseRandom.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseRandom.js rename to platforms/android/cordova/node_modules/lodash/internal/baseRandom.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseReduce.js b/platforms/android/cordova/node_modules/lodash/internal/baseReduce.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseReduce.js rename to platforms/android/cordova/node_modules/lodash/internal/baseReduce.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSetData.js b/platforms/android/cordova/node_modules/lodash/internal/baseSetData.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSetData.js rename to platforms/android/cordova/node_modules/lodash/internal/baseSetData.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSlice.js b/platforms/android/cordova/node_modules/lodash/internal/baseSlice.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSlice.js rename to platforms/android/cordova/node_modules/lodash/internal/baseSlice.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSome.js b/platforms/android/cordova/node_modules/lodash/internal/baseSome.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSome.js rename to platforms/android/cordova/node_modules/lodash/internal/baseSome.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSortBy.js b/platforms/android/cordova/node_modules/lodash/internal/baseSortBy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSortBy.js rename to platforms/android/cordova/node_modules/lodash/internal/baseSortBy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSortByOrder.js b/platforms/android/cordova/node_modules/lodash/internal/baseSortByOrder.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSortByOrder.js rename to platforms/android/cordova/node_modules/lodash/internal/baseSortByOrder.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSum.js b/platforms/android/cordova/node_modules/lodash/internal/baseSum.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseSum.js rename to platforms/android/cordova/node_modules/lodash/internal/baseSum.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseToString.js b/platforms/android/cordova/node_modules/lodash/internal/baseToString.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseToString.js rename to platforms/android/cordova/node_modules/lodash/internal/baseToString.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseUniq.js b/platforms/android/cordova/node_modules/lodash/internal/baseUniq.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseUniq.js rename to platforms/android/cordova/node_modules/lodash/internal/baseUniq.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseValues.js b/platforms/android/cordova/node_modules/lodash/internal/baseValues.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseValues.js rename to platforms/android/cordova/node_modules/lodash/internal/baseValues.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseWhile.js b/platforms/android/cordova/node_modules/lodash/internal/baseWhile.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseWhile.js rename to platforms/android/cordova/node_modules/lodash/internal/baseWhile.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseWrapperValue.js b/platforms/android/cordova/node_modules/lodash/internal/baseWrapperValue.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/baseWrapperValue.js rename to platforms/android/cordova/node_modules/lodash/internal/baseWrapperValue.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/binaryIndex.js b/platforms/android/cordova/node_modules/lodash/internal/binaryIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/binaryIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/binaryIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/binaryIndexBy.js b/platforms/android/cordova/node_modules/lodash/internal/binaryIndexBy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/binaryIndexBy.js rename to platforms/android/cordova/node_modules/lodash/internal/binaryIndexBy.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/bindCallback.js b/platforms/android/cordova/node_modules/lodash/internal/bindCallback.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/bindCallback.js rename to platforms/android/cordova/node_modules/lodash/internal/bindCallback.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/bufferClone.js b/platforms/android/cordova/node_modules/lodash/internal/bufferClone.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/bufferClone.js rename to platforms/android/cordova/node_modules/lodash/internal/bufferClone.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/cacheIndexOf.js b/platforms/android/cordova/node_modules/lodash/internal/cacheIndexOf.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/cacheIndexOf.js rename to platforms/android/cordova/node_modules/lodash/internal/cacheIndexOf.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/cachePush.js b/platforms/android/cordova/node_modules/lodash/internal/cachePush.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/cachePush.js rename to platforms/android/cordova/node_modules/lodash/internal/cachePush.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/charsLeftIndex.js b/platforms/android/cordova/node_modules/lodash/internal/charsLeftIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/charsLeftIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/charsLeftIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/charsRightIndex.js b/platforms/android/cordova/node_modules/lodash/internal/charsRightIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/charsRightIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/charsRightIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/compareAscending.js b/platforms/android/cordova/node_modules/lodash/internal/compareAscending.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/compareAscending.js rename to platforms/android/cordova/node_modules/lodash/internal/compareAscending.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/compareMultiple.js b/platforms/android/cordova/node_modules/lodash/internal/compareMultiple.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/compareMultiple.js rename to platforms/android/cordova/node_modules/lodash/internal/compareMultiple.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/composeArgs.js b/platforms/android/cordova/node_modules/lodash/internal/composeArgs.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/composeArgs.js rename to platforms/android/cordova/node_modules/lodash/internal/composeArgs.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/composeArgsRight.js b/platforms/android/cordova/node_modules/lodash/internal/composeArgsRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/composeArgsRight.js rename to platforms/android/cordova/node_modules/lodash/internal/composeArgsRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createAggregator.js b/platforms/android/cordova/node_modules/lodash/internal/createAggregator.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createAggregator.js rename to platforms/android/cordova/node_modules/lodash/internal/createAggregator.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createAssigner.js b/platforms/android/cordova/node_modules/lodash/internal/createAssigner.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createAssigner.js rename to platforms/android/cordova/node_modules/lodash/internal/createAssigner.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createBaseEach.js b/platforms/android/cordova/node_modules/lodash/internal/createBaseEach.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createBaseEach.js rename to platforms/android/cordova/node_modules/lodash/internal/createBaseEach.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createBaseFor.js b/platforms/android/cordova/node_modules/lodash/internal/createBaseFor.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createBaseFor.js rename to platforms/android/cordova/node_modules/lodash/internal/createBaseFor.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createBindWrapper.js b/platforms/android/cordova/node_modules/lodash/internal/createBindWrapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createBindWrapper.js rename to platforms/android/cordova/node_modules/lodash/internal/createBindWrapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCache.js b/platforms/android/cordova/node_modules/lodash/internal/createCache.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCache.js rename to platforms/android/cordova/node_modules/lodash/internal/createCache.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCompounder.js b/platforms/android/cordova/node_modules/lodash/internal/createCompounder.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCompounder.js rename to platforms/android/cordova/node_modules/lodash/internal/createCompounder.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCtorWrapper.js b/platforms/android/cordova/node_modules/lodash/internal/createCtorWrapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCtorWrapper.js rename to platforms/android/cordova/node_modules/lodash/internal/createCtorWrapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCurry.js b/platforms/android/cordova/node_modules/lodash/internal/createCurry.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createCurry.js rename to platforms/android/cordova/node_modules/lodash/internal/createCurry.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createDefaults.js b/platforms/android/cordova/node_modules/lodash/internal/createDefaults.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createDefaults.js rename to platforms/android/cordova/node_modules/lodash/internal/createDefaults.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createExtremum.js b/platforms/android/cordova/node_modules/lodash/internal/createExtremum.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createExtremum.js rename to platforms/android/cordova/node_modules/lodash/internal/createExtremum.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFind.js b/platforms/android/cordova/node_modules/lodash/internal/createFind.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFind.js rename to platforms/android/cordova/node_modules/lodash/internal/createFind.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFindIndex.js b/platforms/android/cordova/node_modules/lodash/internal/createFindIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFindIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/createFindIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFindKey.js b/platforms/android/cordova/node_modules/lodash/internal/createFindKey.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFindKey.js rename to platforms/android/cordova/node_modules/lodash/internal/createFindKey.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFlow.js b/platforms/android/cordova/node_modules/lodash/internal/createFlow.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createFlow.js rename to platforms/android/cordova/node_modules/lodash/internal/createFlow.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createForEach.js b/platforms/android/cordova/node_modules/lodash/internal/createForEach.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createForEach.js rename to platforms/android/cordova/node_modules/lodash/internal/createForEach.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createForIn.js b/platforms/android/cordova/node_modules/lodash/internal/createForIn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createForIn.js rename to platforms/android/cordova/node_modules/lodash/internal/createForIn.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createForOwn.js b/platforms/android/cordova/node_modules/lodash/internal/createForOwn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createForOwn.js rename to platforms/android/cordova/node_modules/lodash/internal/createForOwn.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createHybridWrapper.js b/platforms/android/cordova/node_modules/lodash/internal/createHybridWrapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createHybridWrapper.js rename to platforms/android/cordova/node_modules/lodash/internal/createHybridWrapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createObjectMapper.js b/platforms/android/cordova/node_modules/lodash/internal/createObjectMapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createObjectMapper.js rename to platforms/android/cordova/node_modules/lodash/internal/createObjectMapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPadDir.js b/platforms/android/cordova/node_modules/lodash/internal/createPadDir.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPadDir.js rename to platforms/android/cordova/node_modules/lodash/internal/createPadDir.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPadding.js b/platforms/android/cordova/node_modules/lodash/internal/createPadding.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPadding.js rename to platforms/android/cordova/node_modules/lodash/internal/createPadding.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPartial.js b/platforms/android/cordova/node_modules/lodash/internal/createPartial.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPartial.js rename to platforms/android/cordova/node_modules/lodash/internal/createPartial.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPartialWrapper.js b/platforms/android/cordova/node_modules/lodash/internal/createPartialWrapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createPartialWrapper.js rename to platforms/android/cordova/node_modules/lodash/internal/createPartialWrapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createReduce.js b/platforms/android/cordova/node_modules/lodash/internal/createReduce.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createReduce.js rename to platforms/android/cordova/node_modules/lodash/internal/createReduce.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createRound.js b/platforms/android/cordova/node_modules/lodash/internal/createRound.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createRound.js rename to platforms/android/cordova/node_modules/lodash/internal/createRound.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createSortedIndex.js b/platforms/android/cordova/node_modules/lodash/internal/createSortedIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createSortedIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/createSortedIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createWrapper.js b/platforms/android/cordova/node_modules/lodash/internal/createWrapper.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/createWrapper.js rename to platforms/android/cordova/node_modules/lodash/internal/createWrapper.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/deburrLetter.js b/platforms/android/cordova/node_modules/lodash/internal/deburrLetter.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/deburrLetter.js rename to platforms/android/cordova/node_modules/lodash/internal/deburrLetter.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/equalArrays.js b/platforms/android/cordova/node_modules/lodash/internal/equalArrays.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/equalArrays.js rename to platforms/android/cordova/node_modules/lodash/internal/equalArrays.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/equalByTag.js b/platforms/android/cordova/node_modules/lodash/internal/equalByTag.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/equalByTag.js rename to platforms/android/cordova/node_modules/lodash/internal/equalByTag.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/equalObjects.js b/platforms/android/cordova/node_modules/lodash/internal/equalObjects.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/equalObjects.js rename to platforms/android/cordova/node_modules/lodash/internal/equalObjects.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/escapeHtmlChar.js b/platforms/android/cordova/node_modules/lodash/internal/escapeHtmlChar.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/escapeHtmlChar.js rename to platforms/android/cordova/node_modules/lodash/internal/escapeHtmlChar.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/escapeRegExpChar.js b/platforms/android/cordova/node_modules/lodash/internal/escapeRegExpChar.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/escapeRegExpChar.js rename to platforms/android/cordova/node_modules/lodash/internal/escapeRegExpChar.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/escapeStringChar.js b/platforms/android/cordova/node_modules/lodash/internal/escapeStringChar.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/escapeStringChar.js rename to platforms/android/cordova/node_modules/lodash/internal/escapeStringChar.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getData.js b/platforms/android/cordova/node_modules/lodash/internal/getData.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getData.js rename to platforms/android/cordova/node_modules/lodash/internal/getData.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getFuncName.js b/platforms/android/cordova/node_modules/lodash/internal/getFuncName.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getFuncName.js rename to platforms/android/cordova/node_modules/lodash/internal/getFuncName.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getLength.js b/platforms/android/cordova/node_modules/lodash/internal/getLength.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getLength.js rename to platforms/android/cordova/node_modules/lodash/internal/getLength.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getMatchData.js b/platforms/android/cordova/node_modules/lodash/internal/getMatchData.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getMatchData.js rename to platforms/android/cordova/node_modules/lodash/internal/getMatchData.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getNative.js b/platforms/android/cordova/node_modules/lodash/internal/getNative.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getNative.js rename to platforms/android/cordova/node_modules/lodash/internal/getNative.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getView.js b/platforms/android/cordova/node_modules/lodash/internal/getView.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/getView.js rename to platforms/android/cordova/node_modules/lodash/internal/getView.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/indexOfNaN.js b/platforms/android/cordova/node_modules/lodash/internal/indexOfNaN.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/indexOfNaN.js rename to platforms/android/cordova/node_modules/lodash/internal/indexOfNaN.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/initCloneArray.js b/platforms/android/cordova/node_modules/lodash/internal/initCloneArray.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/initCloneArray.js rename to platforms/android/cordova/node_modules/lodash/internal/initCloneArray.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/initCloneByTag.js b/platforms/android/cordova/node_modules/lodash/internal/initCloneByTag.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/initCloneByTag.js rename to platforms/android/cordova/node_modules/lodash/internal/initCloneByTag.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/initCloneObject.js b/platforms/android/cordova/node_modules/lodash/internal/initCloneObject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/initCloneObject.js rename to platforms/android/cordova/node_modules/lodash/internal/initCloneObject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/invokePath.js b/platforms/android/cordova/node_modules/lodash/internal/invokePath.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/invokePath.js rename to platforms/android/cordova/node_modules/lodash/internal/invokePath.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isArrayLike.js b/platforms/android/cordova/node_modules/lodash/internal/isArrayLike.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isArrayLike.js rename to platforms/android/cordova/node_modules/lodash/internal/isArrayLike.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isIndex.js b/platforms/android/cordova/node_modules/lodash/internal/isIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/isIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isIterateeCall.js b/platforms/android/cordova/node_modules/lodash/internal/isIterateeCall.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isIterateeCall.js rename to platforms/android/cordova/node_modules/lodash/internal/isIterateeCall.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isKey.js b/platforms/android/cordova/node_modules/lodash/internal/isKey.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isKey.js rename to platforms/android/cordova/node_modules/lodash/internal/isKey.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isLaziable.js b/platforms/android/cordova/node_modules/lodash/internal/isLaziable.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isLaziable.js rename to platforms/android/cordova/node_modules/lodash/internal/isLaziable.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isLength.js b/platforms/android/cordova/node_modules/lodash/internal/isLength.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isLength.js rename to platforms/android/cordova/node_modules/lodash/internal/isLength.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isObjectLike.js b/platforms/android/cordova/node_modules/lodash/internal/isObjectLike.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isObjectLike.js rename to platforms/android/cordova/node_modules/lodash/internal/isObjectLike.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isSpace.js b/platforms/android/cordova/node_modules/lodash/internal/isSpace.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isSpace.js rename to platforms/android/cordova/node_modules/lodash/internal/isSpace.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isStrictComparable.js b/platforms/android/cordova/node_modules/lodash/internal/isStrictComparable.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/isStrictComparable.js rename to platforms/android/cordova/node_modules/lodash/internal/isStrictComparable.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/lazyClone.js b/platforms/android/cordova/node_modules/lodash/internal/lazyClone.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/lazyClone.js rename to platforms/android/cordova/node_modules/lodash/internal/lazyClone.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/lazyReverse.js b/platforms/android/cordova/node_modules/lodash/internal/lazyReverse.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/lazyReverse.js rename to platforms/android/cordova/node_modules/lodash/internal/lazyReverse.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/lazyValue.js b/platforms/android/cordova/node_modules/lodash/internal/lazyValue.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/lazyValue.js rename to platforms/android/cordova/node_modules/lodash/internal/lazyValue.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapDelete.js b/platforms/android/cordova/node_modules/lodash/internal/mapDelete.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapDelete.js rename to platforms/android/cordova/node_modules/lodash/internal/mapDelete.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapGet.js b/platforms/android/cordova/node_modules/lodash/internal/mapGet.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapGet.js rename to platforms/android/cordova/node_modules/lodash/internal/mapGet.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapHas.js b/platforms/android/cordova/node_modules/lodash/internal/mapHas.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapHas.js rename to platforms/android/cordova/node_modules/lodash/internal/mapHas.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapSet.js b/platforms/android/cordova/node_modules/lodash/internal/mapSet.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mapSet.js rename to platforms/android/cordova/node_modules/lodash/internal/mapSet.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mergeData.js b/platforms/android/cordova/node_modules/lodash/internal/mergeData.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mergeData.js rename to platforms/android/cordova/node_modules/lodash/internal/mergeData.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mergeDefaults.js b/platforms/android/cordova/node_modules/lodash/internal/mergeDefaults.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/mergeDefaults.js rename to platforms/android/cordova/node_modules/lodash/internal/mergeDefaults.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/metaMap.js b/platforms/android/cordova/node_modules/lodash/internal/metaMap.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/metaMap.js rename to platforms/android/cordova/node_modules/lodash/internal/metaMap.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/pickByArray.js b/platforms/android/cordova/node_modules/lodash/internal/pickByArray.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/pickByArray.js rename to platforms/android/cordova/node_modules/lodash/internal/pickByArray.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/pickByCallback.js b/platforms/android/cordova/node_modules/lodash/internal/pickByCallback.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/pickByCallback.js rename to platforms/android/cordova/node_modules/lodash/internal/pickByCallback.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reEscape.js b/platforms/android/cordova/node_modules/lodash/internal/reEscape.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reEscape.js rename to platforms/android/cordova/node_modules/lodash/internal/reEscape.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reEvaluate.js b/platforms/android/cordova/node_modules/lodash/internal/reEvaluate.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reEvaluate.js rename to platforms/android/cordova/node_modules/lodash/internal/reEvaluate.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reInterpolate.js b/platforms/android/cordova/node_modules/lodash/internal/reInterpolate.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reInterpolate.js rename to platforms/android/cordova/node_modules/lodash/internal/reInterpolate.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/realNames.js b/platforms/android/cordova/node_modules/lodash/internal/realNames.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/realNames.js rename to platforms/android/cordova/node_modules/lodash/internal/realNames.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reorder.js b/platforms/android/cordova/node_modules/lodash/internal/reorder.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/reorder.js rename to platforms/android/cordova/node_modules/lodash/internal/reorder.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/replaceHolders.js b/platforms/android/cordova/node_modules/lodash/internal/replaceHolders.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/replaceHolders.js rename to platforms/android/cordova/node_modules/lodash/internal/replaceHolders.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/setData.js b/platforms/android/cordova/node_modules/lodash/internal/setData.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/setData.js rename to platforms/android/cordova/node_modules/lodash/internal/setData.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/shimKeys.js b/platforms/android/cordova/node_modules/lodash/internal/shimKeys.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/shimKeys.js rename to platforms/android/cordova/node_modules/lodash/internal/shimKeys.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/sortedUniq.js b/platforms/android/cordova/node_modules/lodash/internal/sortedUniq.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/sortedUniq.js rename to platforms/android/cordova/node_modules/lodash/internal/sortedUniq.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/toIterable.js b/platforms/android/cordova/node_modules/lodash/internal/toIterable.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/toIterable.js rename to platforms/android/cordova/node_modules/lodash/internal/toIterable.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/toObject.js b/platforms/android/cordova/node_modules/lodash/internal/toObject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/toObject.js rename to platforms/android/cordova/node_modules/lodash/internal/toObject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/toPath.js b/platforms/android/cordova/node_modules/lodash/internal/toPath.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/toPath.js rename to platforms/android/cordova/node_modules/lodash/internal/toPath.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/trimmedLeftIndex.js b/platforms/android/cordova/node_modules/lodash/internal/trimmedLeftIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/trimmedLeftIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/trimmedLeftIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/trimmedRightIndex.js b/platforms/android/cordova/node_modules/lodash/internal/trimmedRightIndex.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/trimmedRightIndex.js rename to platforms/android/cordova/node_modules/lodash/internal/trimmedRightIndex.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/unescapeHtmlChar.js b/platforms/android/cordova/node_modules/lodash/internal/unescapeHtmlChar.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/unescapeHtmlChar.js rename to platforms/android/cordova/node_modules/lodash/internal/unescapeHtmlChar.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/wrapperClone.js b/platforms/android/cordova/node_modules/lodash/internal/wrapperClone.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/internal/wrapperClone.js rename to platforms/android/cordova/node_modules/lodash/internal/wrapperClone.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang.js b/platforms/android/cordova/node_modules/lodash/lang.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang.js rename to platforms/android/cordova/node_modules/lodash/lang.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/clone.js b/platforms/android/cordova/node_modules/lodash/lang/clone.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/clone.js rename to platforms/android/cordova/node_modules/lodash/lang/clone.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/cloneDeep.js b/platforms/android/cordova/node_modules/lodash/lang/cloneDeep.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/cloneDeep.js rename to platforms/android/cordova/node_modules/lodash/lang/cloneDeep.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/eq.js b/platforms/android/cordova/node_modules/lodash/lang/eq.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/eq.js rename to platforms/android/cordova/node_modules/lodash/lang/eq.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/gt.js b/platforms/android/cordova/node_modules/lodash/lang/gt.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/gt.js rename to platforms/android/cordova/node_modules/lodash/lang/gt.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/gte.js b/platforms/android/cordova/node_modules/lodash/lang/gte.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/gte.js rename to platforms/android/cordova/node_modules/lodash/lang/gte.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isArguments.js b/platforms/android/cordova/node_modules/lodash/lang/isArguments.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isArguments.js rename to platforms/android/cordova/node_modules/lodash/lang/isArguments.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isArray.js b/platforms/android/cordova/node_modules/lodash/lang/isArray.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isArray.js rename to platforms/android/cordova/node_modules/lodash/lang/isArray.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isBoolean.js b/platforms/android/cordova/node_modules/lodash/lang/isBoolean.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isBoolean.js rename to platforms/android/cordova/node_modules/lodash/lang/isBoolean.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isDate.js b/platforms/android/cordova/node_modules/lodash/lang/isDate.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isDate.js rename to platforms/android/cordova/node_modules/lodash/lang/isDate.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isElement.js b/platforms/android/cordova/node_modules/lodash/lang/isElement.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isElement.js rename to platforms/android/cordova/node_modules/lodash/lang/isElement.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isEmpty.js b/platforms/android/cordova/node_modules/lodash/lang/isEmpty.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isEmpty.js rename to platforms/android/cordova/node_modules/lodash/lang/isEmpty.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isEqual.js b/platforms/android/cordova/node_modules/lodash/lang/isEqual.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isEqual.js rename to platforms/android/cordova/node_modules/lodash/lang/isEqual.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isError.js b/platforms/android/cordova/node_modules/lodash/lang/isError.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isError.js rename to platforms/android/cordova/node_modules/lodash/lang/isError.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isFinite.js b/platforms/android/cordova/node_modules/lodash/lang/isFinite.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isFinite.js rename to platforms/android/cordova/node_modules/lodash/lang/isFinite.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isFunction.js b/platforms/android/cordova/node_modules/lodash/lang/isFunction.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isFunction.js rename to platforms/android/cordova/node_modules/lodash/lang/isFunction.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isMatch.js b/platforms/android/cordova/node_modules/lodash/lang/isMatch.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isMatch.js rename to platforms/android/cordova/node_modules/lodash/lang/isMatch.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNaN.js b/platforms/android/cordova/node_modules/lodash/lang/isNaN.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNaN.js rename to platforms/android/cordova/node_modules/lodash/lang/isNaN.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNative.js b/platforms/android/cordova/node_modules/lodash/lang/isNative.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNative.js rename to platforms/android/cordova/node_modules/lodash/lang/isNative.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNull.js b/platforms/android/cordova/node_modules/lodash/lang/isNull.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNull.js rename to platforms/android/cordova/node_modules/lodash/lang/isNull.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNumber.js b/platforms/android/cordova/node_modules/lodash/lang/isNumber.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isNumber.js rename to platforms/android/cordova/node_modules/lodash/lang/isNumber.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isObject.js b/platforms/android/cordova/node_modules/lodash/lang/isObject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isObject.js rename to platforms/android/cordova/node_modules/lodash/lang/isObject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isPlainObject.js b/platforms/android/cordova/node_modules/lodash/lang/isPlainObject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isPlainObject.js rename to platforms/android/cordova/node_modules/lodash/lang/isPlainObject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isRegExp.js b/platforms/android/cordova/node_modules/lodash/lang/isRegExp.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isRegExp.js rename to platforms/android/cordova/node_modules/lodash/lang/isRegExp.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isString.js b/platforms/android/cordova/node_modules/lodash/lang/isString.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isString.js rename to platforms/android/cordova/node_modules/lodash/lang/isString.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isTypedArray.js b/platforms/android/cordova/node_modules/lodash/lang/isTypedArray.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isTypedArray.js rename to platforms/android/cordova/node_modules/lodash/lang/isTypedArray.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isUndefined.js b/platforms/android/cordova/node_modules/lodash/lang/isUndefined.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/isUndefined.js rename to platforms/android/cordova/node_modules/lodash/lang/isUndefined.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/lt.js b/platforms/android/cordova/node_modules/lodash/lang/lt.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/lt.js rename to platforms/android/cordova/node_modules/lodash/lang/lt.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/lte.js b/platforms/android/cordova/node_modules/lodash/lang/lte.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/lte.js rename to platforms/android/cordova/node_modules/lodash/lang/lte.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/toArray.js b/platforms/android/cordova/node_modules/lodash/lang/toArray.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/toArray.js rename to platforms/android/cordova/node_modules/lodash/lang/toArray.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/toPlainObject.js b/platforms/android/cordova/node_modules/lodash/lang/toPlainObject.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/lang/toPlainObject.js rename to platforms/android/cordova/node_modules/lodash/lang/toPlainObject.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math.js b/platforms/android/cordova/node_modules/lodash/math.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math.js rename to platforms/android/cordova/node_modules/lodash/math.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/add.js b/platforms/android/cordova/node_modules/lodash/math/add.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/add.js rename to platforms/android/cordova/node_modules/lodash/math/add.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/ceil.js b/platforms/android/cordova/node_modules/lodash/math/ceil.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/ceil.js rename to platforms/android/cordova/node_modules/lodash/math/ceil.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/floor.js b/platforms/android/cordova/node_modules/lodash/math/floor.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/floor.js rename to platforms/android/cordova/node_modules/lodash/math/floor.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/max.js b/platforms/android/cordova/node_modules/lodash/math/max.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/max.js rename to platforms/android/cordova/node_modules/lodash/math/max.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/min.js b/platforms/android/cordova/node_modules/lodash/math/min.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/min.js rename to platforms/android/cordova/node_modules/lodash/math/min.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/round.js b/platforms/android/cordova/node_modules/lodash/math/round.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/round.js rename to platforms/android/cordova/node_modules/lodash/math/round.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/sum.js b/platforms/android/cordova/node_modules/lodash/math/sum.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/math/sum.js rename to platforms/android/cordova/node_modules/lodash/math/sum.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/number.js b/platforms/android/cordova/node_modules/lodash/number.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/number.js rename to platforms/android/cordova/node_modules/lodash/number.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/number/inRange.js b/platforms/android/cordova/node_modules/lodash/number/inRange.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/number/inRange.js rename to platforms/android/cordova/node_modules/lodash/number/inRange.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/number/random.js b/platforms/android/cordova/node_modules/lodash/number/random.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/number/random.js rename to platforms/android/cordova/node_modules/lodash/number/random.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object.js b/platforms/android/cordova/node_modules/lodash/object.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object.js rename to platforms/android/cordova/node_modules/lodash/object.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/assign.js b/platforms/android/cordova/node_modules/lodash/object/assign.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/assign.js rename to platforms/android/cordova/node_modules/lodash/object/assign.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/create.js b/platforms/android/cordova/node_modules/lodash/object/create.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/create.js rename to platforms/android/cordova/node_modules/lodash/object/create.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/defaults.js b/platforms/android/cordova/node_modules/lodash/object/defaults.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/defaults.js rename to platforms/android/cordova/node_modules/lodash/object/defaults.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/defaultsDeep.js b/platforms/android/cordova/node_modules/lodash/object/defaultsDeep.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/defaultsDeep.js rename to platforms/android/cordova/node_modules/lodash/object/defaultsDeep.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/extend.js b/platforms/android/cordova/node_modules/lodash/object/extend.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/extend.js rename to platforms/android/cordova/node_modules/lodash/object/extend.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/findKey.js b/platforms/android/cordova/node_modules/lodash/object/findKey.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/findKey.js rename to platforms/android/cordova/node_modules/lodash/object/findKey.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/findLastKey.js b/platforms/android/cordova/node_modules/lodash/object/findLastKey.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/findLastKey.js rename to platforms/android/cordova/node_modules/lodash/object/findLastKey.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forIn.js b/platforms/android/cordova/node_modules/lodash/object/forIn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forIn.js rename to platforms/android/cordova/node_modules/lodash/object/forIn.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forInRight.js b/platforms/android/cordova/node_modules/lodash/object/forInRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forInRight.js rename to platforms/android/cordova/node_modules/lodash/object/forInRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forOwn.js b/platforms/android/cordova/node_modules/lodash/object/forOwn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forOwn.js rename to platforms/android/cordova/node_modules/lodash/object/forOwn.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forOwnRight.js b/platforms/android/cordova/node_modules/lodash/object/forOwnRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/forOwnRight.js rename to platforms/android/cordova/node_modules/lodash/object/forOwnRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/functions.js b/platforms/android/cordova/node_modules/lodash/object/functions.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/functions.js rename to platforms/android/cordova/node_modules/lodash/object/functions.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/get.js b/platforms/android/cordova/node_modules/lodash/object/get.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/get.js rename to platforms/android/cordova/node_modules/lodash/object/get.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/has.js b/platforms/android/cordova/node_modules/lodash/object/has.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/has.js rename to platforms/android/cordova/node_modules/lodash/object/has.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/invert.js b/platforms/android/cordova/node_modules/lodash/object/invert.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/invert.js rename to platforms/android/cordova/node_modules/lodash/object/invert.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/keys.js b/platforms/android/cordova/node_modules/lodash/object/keys.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/keys.js rename to platforms/android/cordova/node_modules/lodash/object/keys.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/keysIn.js b/platforms/android/cordova/node_modules/lodash/object/keysIn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/keysIn.js rename to platforms/android/cordova/node_modules/lodash/object/keysIn.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/mapKeys.js b/platforms/android/cordova/node_modules/lodash/object/mapKeys.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/mapKeys.js rename to platforms/android/cordova/node_modules/lodash/object/mapKeys.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/mapValues.js b/platforms/android/cordova/node_modules/lodash/object/mapValues.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/mapValues.js rename to platforms/android/cordova/node_modules/lodash/object/mapValues.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/merge.js b/platforms/android/cordova/node_modules/lodash/object/merge.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/merge.js rename to platforms/android/cordova/node_modules/lodash/object/merge.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/methods.js b/platforms/android/cordova/node_modules/lodash/object/methods.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/methods.js rename to platforms/android/cordova/node_modules/lodash/object/methods.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/omit.js b/platforms/android/cordova/node_modules/lodash/object/omit.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/omit.js rename to platforms/android/cordova/node_modules/lodash/object/omit.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/pairs.js b/platforms/android/cordova/node_modules/lodash/object/pairs.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/pairs.js rename to platforms/android/cordova/node_modules/lodash/object/pairs.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/pick.js b/platforms/android/cordova/node_modules/lodash/object/pick.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/pick.js rename to platforms/android/cordova/node_modules/lodash/object/pick.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/result.js b/platforms/android/cordova/node_modules/lodash/object/result.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/result.js rename to platforms/android/cordova/node_modules/lodash/object/result.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/set.js b/platforms/android/cordova/node_modules/lodash/object/set.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/set.js rename to platforms/android/cordova/node_modules/lodash/object/set.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/transform.js b/platforms/android/cordova/node_modules/lodash/object/transform.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/transform.js rename to platforms/android/cordova/node_modules/lodash/object/transform.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/values.js b/platforms/android/cordova/node_modules/lodash/object/values.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/values.js rename to platforms/android/cordova/node_modules/lodash/object/values.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/valuesIn.js b/platforms/android/cordova/node_modules/lodash/object/valuesIn.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/object/valuesIn.js rename to platforms/android/cordova/node_modules/lodash/object/valuesIn.js diff --git a/platforms/android/cordova/node_modules/lodash/package.json b/platforms/android/cordova/node_modules/lodash/package.json new file mode 100644 index 0000000..38e2638 --- /dev/null +++ b/platforms/android/cordova/node_modules/lodash/package.json @@ -0,0 +1,121 @@ +{ + "_args": [ + [ + "lodash@^3.5.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/xmlbuilder" + ] + ], + "_from": "lodash@>=3.5.0 <4.0.0", + "_id": "lodash@3.10.1", + "_inCache": true, + "_installable": true, + "_location": "/lodash", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "john.david.dalton@gmail.com", + "name": "jdalton" + }, + "_npmVersion": "2.13.1", + "_phantomChildren": {}, + "_requested": { + "name": "lodash", + "raw": "lodash@^3.5.0", + "rawSpec": "^3.5.0", + "scope": null, + "spec": ">=3.5.0 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/xmlbuilder" + ], + "_resolved": "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "_shasum": "5bf45e8e49ba4189e17d482789dfd15bd140b7b6", + "_shrinkwrap": null, + "_spec": "lodash@^3.5.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/xmlbuilder", + "author": { + "email": "john.david.dalton@gmail.com", + "name": "John-David Dalton", + "url": "http://allyoucanleet.com/" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "dependencies": {}, + "description": "The modern build of lodash modular utilities.", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "5bf45e8e49ba4189e17d482789dfd15bd140b7b6", + "tarball": "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" + }, + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "keywords": [ + "modules", + "stdlib", + "util" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + { + "name": "mathias", + "email": "mathias@qiwi.be" + }, + { + "name": "phated", + "email": "blaine@iceddev.com" + }, + { + "name": "kitcambridge", + "email": "github@kitcambridge.be" + }, + { + "name": "d10", + "email": "demoneaux@gmail.com" + } + ], + "name": "lodash", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/lodash/lodash.git" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "version": "3.10.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string.js b/platforms/android/cordova/node_modules/lodash/string.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string.js rename to platforms/android/cordova/node_modules/lodash/string.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/camelCase.js b/platforms/android/cordova/node_modules/lodash/string/camelCase.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/camelCase.js rename to platforms/android/cordova/node_modules/lodash/string/camelCase.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/capitalize.js b/platforms/android/cordova/node_modules/lodash/string/capitalize.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/capitalize.js rename to platforms/android/cordova/node_modules/lodash/string/capitalize.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/deburr.js b/platforms/android/cordova/node_modules/lodash/string/deburr.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/deburr.js rename to platforms/android/cordova/node_modules/lodash/string/deburr.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/endsWith.js b/platforms/android/cordova/node_modules/lodash/string/endsWith.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/endsWith.js rename to platforms/android/cordova/node_modules/lodash/string/endsWith.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/escape.js b/platforms/android/cordova/node_modules/lodash/string/escape.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/escape.js rename to platforms/android/cordova/node_modules/lodash/string/escape.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/escapeRegExp.js b/platforms/android/cordova/node_modules/lodash/string/escapeRegExp.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/escapeRegExp.js rename to platforms/android/cordova/node_modules/lodash/string/escapeRegExp.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/kebabCase.js b/platforms/android/cordova/node_modules/lodash/string/kebabCase.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/kebabCase.js rename to platforms/android/cordova/node_modules/lodash/string/kebabCase.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/pad.js b/platforms/android/cordova/node_modules/lodash/string/pad.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/pad.js rename to platforms/android/cordova/node_modules/lodash/string/pad.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/padLeft.js b/platforms/android/cordova/node_modules/lodash/string/padLeft.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/padLeft.js rename to platforms/android/cordova/node_modules/lodash/string/padLeft.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/padRight.js b/platforms/android/cordova/node_modules/lodash/string/padRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/padRight.js rename to platforms/android/cordova/node_modules/lodash/string/padRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/parseInt.js b/platforms/android/cordova/node_modules/lodash/string/parseInt.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/parseInt.js rename to platforms/android/cordova/node_modules/lodash/string/parseInt.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/repeat.js b/platforms/android/cordova/node_modules/lodash/string/repeat.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/repeat.js rename to platforms/android/cordova/node_modules/lodash/string/repeat.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/snakeCase.js b/platforms/android/cordova/node_modules/lodash/string/snakeCase.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/snakeCase.js rename to platforms/android/cordova/node_modules/lodash/string/snakeCase.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/startCase.js b/platforms/android/cordova/node_modules/lodash/string/startCase.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/startCase.js rename to platforms/android/cordova/node_modules/lodash/string/startCase.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/startsWith.js b/platforms/android/cordova/node_modules/lodash/string/startsWith.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/startsWith.js rename to platforms/android/cordova/node_modules/lodash/string/startsWith.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/template.js b/platforms/android/cordova/node_modules/lodash/string/template.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/template.js rename to platforms/android/cordova/node_modules/lodash/string/template.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/templateSettings.js b/platforms/android/cordova/node_modules/lodash/string/templateSettings.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/templateSettings.js rename to platforms/android/cordova/node_modules/lodash/string/templateSettings.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trim.js b/platforms/android/cordova/node_modules/lodash/string/trim.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trim.js rename to platforms/android/cordova/node_modules/lodash/string/trim.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trimLeft.js b/platforms/android/cordova/node_modules/lodash/string/trimLeft.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trimLeft.js rename to platforms/android/cordova/node_modules/lodash/string/trimLeft.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trimRight.js b/platforms/android/cordova/node_modules/lodash/string/trimRight.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trimRight.js rename to platforms/android/cordova/node_modules/lodash/string/trimRight.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trunc.js b/platforms/android/cordova/node_modules/lodash/string/trunc.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/trunc.js rename to platforms/android/cordova/node_modules/lodash/string/trunc.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/unescape.js b/platforms/android/cordova/node_modules/lodash/string/unescape.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/unescape.js rename to platforms/android/cordova/node_modules/lodash/string/unescape.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/words.js b/platforms/android/cordova/node_modules/lodash/string/words.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/string/words.js rename to platforms/android/cordova/node_modules/lodash/string/words.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/support.js b/platforms/android/cordova/node_modules/lodash/support.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/support.js rename to platforms/android/cordova/node_modules/lodash/support.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility.js b/platforms/android/cordova/node_modules/lodash/utility.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility.js rename to platforms/android/cordova/node_modules/lodash/utility.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/attempt.js b/platforms/android/cordova/node_modules/lodash/utility/attempt.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/attempt.js rename to platforms/android/cordova/node_modules/lodash/utility/attempt.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/callback.js b/platforms/android/cordova/node_modules/lodash/utility/callback.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/callback.js rename to platforms/android/cordova/node_modules/lodash/utility/callback.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/constant.js b/platforms/android/cordova/node_modules/lodash/utility/constant.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/constant.js rename to platforms/android/cordova/node_modules/lodash/utility/constant.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/identity.js b/platforms/android/cordova/node_modules/lodash/utility/identity.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/identity.js rename to platforms/android/cordova/node_modules/lodash/utility/identity.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/iteratee.js b/platforms/android/cordova/node_modules/lodash/utility/iteratee.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/iteratee.js rename to platforms/android/cordova/node_modules/lodash/utility/iteratee.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/matches.js b/platforms/android/cordova/node_modules/lodash/utility/matches.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/matches.js rename to platforms/android/cordova/node_modules/lodash/utility/matches.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/matchesProperty.js b/platforms/android/cordova/node_modules/lodash/utility/matchesProperty.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/matchesProperty.js rename to platforms/android/cordova/node_modules/lodash/utility/matchesProperty.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/method.js b/platforms/android/cordova/node_modules/lodash/utility/method.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/method.js rename to platforms/android/cordova/node_modules/lodash/utility/method.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/methodOf.js b/platforms/android/cordova/node_modules/lodash/utility/methodOf.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/methodOf.js rename to platforms/android/cordova/node_modules/lodash/utility/methodOf.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/mixin.js b/platforms/android/cordova/node_modules/lodash/utility/mixin.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/mixin.js rename to platforms/android/cordova/node_modules/lodash/utility/mixin.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/noop.js b/platforms/android/cordova/node_modules/lodash/utility/noop.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/noop.js rename to platforms/android/cordova/node_modules/lodash/utility/noop.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/property.js b/platforms/android/cordova/node_modules/lodash/utility/property.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/property.js rename to platforms/android/cordova/node_modules/lodash/utility/property.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/propertyOf.js b/platforms/android/cordova/node_modules/lodash/utility/propertyOf.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/propertyOf.js rename to platforms/android/cordova/node_modules/lodash/utility/propertyOf.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/range.js b/platforms/android/cordova/node_modules/lodash/utility/range.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/range.js rename to platforms/android/cordova/node_modules/lodash/utility/range.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/times.js b/platforms/android/cordova/node_modules/lodash/utility/times.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/times.js rename to platforms/android/cordova/node_modules/lodash/utility/times.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/uniqueId.js b/platforms/android/cordova/node_modules/lodash/utility/uniqueId.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/node_modules/lodash/utility/uniqueId.js rename to platforms/android/cordova/node_modules/lodash/utility/uniqueId.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/LICENSE b/platforms/android/cordova/node_modules/minimatch/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/LICENSE rename to platforms/android/cordova/node_modules/minimatch/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/README.md b/platforms/android/cordova/node_modules/minimatch/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/README.md rename to platforms/android/cordova/node_modules/minimatch/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/minimatch.js b/platforms/android/cordova/node_modules/minimatch/minimatch.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/minimatch/minimatch.js rename to platforms/android/cordova/node_modules/minimatch/minimatch.js diff --git a/platforms/android/cordova/node_modules/minimatch/package.json b/platforms/android/cordova/node_modules/minimatch/package.json new file mode 100644 index 0000000..5f6a7fc --- /dev/null +++ b/platforms/android/cordova/node_modules/minimatch/package.json @@ -0,0 +1,85 @@ +{ + "_args": [ + [ + "minimatch@2 || 3", + "/Users/steveng/repo/cordova/cordova-android/node_modules/glob" + ] + ], + "_from": "minimatch@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", + "_id": "minimatch@3.0.0", + "_inCache": true, + "_installable": true, + "_location": "/minimatch", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "isaacs@npmjs.com", + "name": "isaacs" + }, + "_npmVersion": "3.3.2", + "_phantomChildren": {}, + "_requested": { + "name": "minimatch", + "raw": "minimatch@2 || 3", + "rawSpec": "2 || 3", + "scope": null, + "spec": ">=2.0.0 <3.0.0||>=3.0.0 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob" + ], + "_resolved": "http://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz", + "_shasum": "5236157a51e4f004c177fb3c527ff7dd78f0ef83", + "_shrinkwrap": null, + "_spec": "minimatch@2 || 3", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/glob", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me" + }, + "bugs": { + "url": "https://github.com/isaacs/minimatch/issues" + }, + "dependencies": { + "brace-expansion": "^1.0.0" + }, + "description": "a glob matcher in javascript", + "devDependencies": { + "standard": "^3.7.2", + "tap": "^1.2.0" + }, + "directories": {}, + "dist": { + "shasum": "5236157a51e4f004c177fb3c527ff7dd78f0ef83", + "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz" + }, + "engines": { + "node": "*" + }, + "files": [ + "minimatch.js" + ], + "gitHead": "270dbea567f0af6918cb18103e98c612aa717a20", + "homepage": "https://github.com/isaacs/minimatch#readme", + "license": "ISC", + "main": "minimatch.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "minimatch", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/minimatch.git" + }, + "scripts": { + "posttest": "standard minimatch.js test/*.js", + "test": "tap test/*.js" + }, + "version": "3.0.0" +} diff --git a/platforms/android/cordova/node_modules/nopt/.npmignore b/platforms/android/cordova/node_modules/nopt/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/platforms/android/cordova/node_modules/nopt/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/platforms/android/cordova/node_modules/nopt/.travis.yml b/platforms/android/cordova/node_modules/nopt/.travis.yml new file mode 100644 index 0000000..99f2bbf --- /dev/null +++ b/platforms/android/cordova/node_modules/nopt/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +language: node_js +node_js: + - '0.8' + - '0.10' + - '0.12' + - 'iojs' +before_install: + - npm install -g npm@latest diff --git a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/LICENSE b/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/LICENSE deleted file mode 100644 index 19129e3..0000000 --- a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/package.json b/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/package.json deleted file mode 100644 index 1daa38c..0000000 --- a/platforms/android/cordova/node_modules/nopt/node_modules/abbrev/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "abbrev", - "version": "1.0.7", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "tap test.js --cov" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" - }, - "license": "ISC", - "devDependencies": { - "tap": "^1.2.0" - }, - "gitHead": "821d09ce7da33627f91bbd8ed631497ed6f760c2", - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js#readme", - "_id": "abbrev@1.0.7", - "_shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", - "_from": "abbrev@>=1.0.0 <2.0.0", - "_npmVersion": "2.10.1", - "_nodeVersion": "2.0.1", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", - "tarball": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/platforms/android/cordova/node_modules/nopt/package.json b/platforms/android/cordova/node_modules/nopt/package.json index be245f4..37ed58d 100644 --- a/platforms/android/cordova/node_modules/nopt/package.json +++ b/platforms/android/cordova/node_modules/nopt/package.json @@ -1,48 +1,65 @@ { - "name": "nopt", - "version": "3.0.6", - "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", + "_args": [ + [ + "nopt@^3.0.1", + "/Users/steveng/repo/cordova/cordova-android" + ] + ], + "_from": "nopt@>=3.0.1 <4.0.0", + "_id": "nopt@3.0.6", + "_inCache": true, + "_installable": true, + "_location": "/nopt", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "ogd@aoaioxxysz.net", + "name": "othiym23" + }, + "_npmVersion": "2.14.10", + "_phantomChildren": {}, + "_requested": { + "name": "nopt", + "raw": "nopt@^3.0.1", + "rawSpec": "^3.0.1", + "scope": null, + "spec": ">=3.0.1 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "http://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "_shasum": "c6465dbf08abcd4db359317f79ac68a646b28ff9", + "_shrinkwrap": null, + "_spec": "nopt@^3.0.1", + "_where": "/Users/steveng/repo/cordova/cordova-android", "author": { - "name": "Isaac Z. Schlueter", "email": "i@izs.me", + "name": "Isaac Z. Schlueter", "url": "http://blog.izs.me/" }, - "main": "lib/nopt.js", - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/npm/nopt.git" - }, "bin": { "nopt": "./bin/nopt.js" }, - "license": "ISC", + "bugs": { + "url": "https://github.com/npm/nopt/issues" + }, "dependencies": { "abbrev": "1" }, + "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", "devDependencies": { "tap": "^1.2.0" }, - "gitHead": "10a750c9bb99c1950160353459e733ac2aa18cb6", - "bugs": { - "url": "https://github.com/npm/nopt/issues" - }, - "homepage": "https://github.com/npm/nopt#readme", - "_id": "nopt@3.0.6", - "_shasum": "c6465dbf08abcd4db359317f79ac68a646b28ff9", - "_from": "nopt@>=3.0.1 <4.0.0", - "_npmVersion": "2.14.10", - "_nodeVersion": "4.2.1", - "_npmUser": { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, + "directories": {}, "dist": { "shasum": "c6465dbf08abcd4db359317f79ac68a646b28ff9", "tarball": "http://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz" }, + "gitHead": "10a750c9bb99c1950160353459e733ac2aa18cb6", + "homepage": "https://github.com/npm/nopt#readme", + "license": "ISC", + "main": "lib/nopt.js", "maintainers": [ { "name": "isaacs", @@ -57,7 +74,15 @@ "email": "kat@sykosomatic.org" } ], - "directories": {}, - "_resolved": "http://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "readme": "ERROR: No README data found!" + "name": "nopt", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/nopt.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "3.0.6" } diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/LICENSE b/platforms/android/cordova/node_modules/once/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/LICENSE rename to platforms/android/cordova/node_modules/once/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/README.md b/platforms/android/cordova/node_modules/once/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/README.md rename to platforms/android/cordova/node_modules/once/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/once.js b/platforms/android/cordova/node_modules/once/once.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/once.js rename to platforms/android/cordova/node_modules/once/once.js diff --git a/platforms/android/cordova/node_modules/once/package.json b/platforms/android/cordova/node_modules/once/package.json new file mode 100644 index 0000000..18c7f8c --- /dev/null +++ b/platforms/android/cordova/node_modules/once/package.json @@ -0,0 +1,89 @@ +{ + "_args": [ + [ + "once@^1.3.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/glob" + ] + ], + "_from": "once@>=1.3.0 <2.0.0", + "_id": "once@1.3.3", + "_inCache": true, + "_installable": true, + "_location": "/once", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "3.3.2", + "_phantomChildren": {}, + "_requested": { + "name": "once", + "raw": "once@^1.3.0", + "rawSpec": "^1.3.0", + "scope": null, + "spec": ">=1.3.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob", + "/inflight" + ], + "_resolved": "http://registry.npmjs.org/once/-/once-1.3.3.tgz", + "_shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20", + "_shrinkwrap": null, + "_spec": "once@^1.3.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/glob", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/once/issues" + }, + "dependencies": { + "wrappy": "1" + }, + "description": "Run a function exactly one time", + "devDependencies": { + "tap": "^1.2.0" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20", + "tarball": "http://registry.npmjs.org/once/-/once-1.3.3.tgz" + }, + "files": [ + "once.js" + ], + "gitHead": "2ad558657e17fafd24803217ba854762842e4178", + "homepage": "https://github.com/isaacs/once#readme", + "keywords": [ + "function", + "once", + "one", + "single" + ], + "license": "ISC", + "main": "once.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "once", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/once.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "1.3.3" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/index.js b/platforms/android/cordova/node_modules/os-homedir/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/index.js rename to platforms/android/cordova/node_modules/os-homedir/index.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/license b/platforms/android/cordova/node_modules/os-homedir/license similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/license rename to platforms/android/cordova/node_modules/os-homedir/license diff --git a/platforms/android/cordova/node_modules/os-homedir/package.json b/platforms/android/cordova/node_modules/os-homedir/package.json new file mode 100644 index 0000000..7dbd200 --- /dev/null +++ b/platforms/android/cordova/node_modules/os-homedir/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "os-homedir@^1.0.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/osenv" + ] + ], + "_from": "os-homedir@>=1.0.0 <2.0.0", + "_id": "os-homedir@1.0.1", + "_inCache": true, + "_installable": true, + "_location": "/os-homedir", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "os-homedir", + "raw": "os-homedir@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/osenv" + ], + "_resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz", + "_shasum": "0d62bdf44b916fd3bbdcf2cab191948fb094f007", + "_shrinkwrap": null, + "_spec": "os-homedir@^1.0.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/osenv", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/os-homedir/issues" + }, + "dependencies": {}, + "description": "io.js 2.3.0 os.homedir() ponyfill", + "devDependencies": { + "ava": "0.0.4", + "path-exists": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "0d62bdf44b916fd3bbdcf2cab191948fb094f007", + "tarball": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "13ff83fbd13ebe286a6092286b2c634ab4534c5f", + "homepage": "https://github.com/sindresorhus/os-homedir", + "keywords": [ + "built-in", + "core", + "dir", + "directory", + "folder", + "home", + "homedir", + "os", + "path", + "polyfill", + "ponyfill", + "shim", + "user" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "os-homedir", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/os-homedir.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/readme.md b/platforms/android/cordova/node_modules/os-homedir/readme.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/readme.md rename to platforms/android/cordova/node_modules/os-homedir/readme.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/index.js b/platforms/android/cordova/node_modules/os-tmpdir/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/index.js rename to platforms/android/cordova/node_modules/os-tmpdir/index.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/license b/platforms/android/cordova/node_modules/os-tmpdir/license similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-homedir/license rename to platforms/android/cordova/node_modules/os-tmpdir/license diff --git a/platforms/android/cordova/node_modules/os-tmpdir/package.json b/platforms/android/cordova/node_modules/os-tmpdir/package.json new file mode 100644 index 0000000..ce48381 --- /dev/null +++ b/platforms/android/cordova/node_modules/os-tmpdir/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "os-tmpdir@^1.0.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/osenv" + ] + ], + "_from": "os-tmpdir@>=1.0.0 <2.0.0", + "_id": "os-tmpdir@1.0.1", + "_inCache": true, + "_installable": true, + "_location": "/os-tmpdir", + "_nodeVersion": "0.12.3", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.9.1", + "_phantomChildren": {}, + "_requested": { + "name": "os-tmpdir", + "raw": "os-tmpdir@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/osenv" + ], + "_resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz", + "_shasum": "e9b423a1edaf479882562e92ed71d7743a071b6e", + "_shrinkwrap": null, + "_spec": "os-tmpdir@^1.0.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/osenv", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/os-tmpdir/issues" + }, + "dependencies": {}, + "description": "Node.js os.tmpdir() ponyfill", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "e9b423a1edaf479882562e92ed71d7743a071b6e", + "tarball": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "5c5d355f81378980db629d60128ad03e02b1c1e5", + "homepage": "https://github.com/sindresorhus/os-tmpdir", + "keywords": [ + "built-in", + "core", + "dir", + "directory", + "env", + "environment", + "os", + "polyfill", + "ponyfill", + "shim", + "temp", + "tempdir", + "tmp", + "tmpdir" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "os-tmpdir", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/os-tmpdir.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/readme.md b/platforms/android/cordova/node_modules/os-tmpdir/readme.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/readme.md rename to platforms/android/cordova/node_modules/os-tmpdir/readme.md diff --git a/platforms/android/cordova/node_modules/osenv/.npmignore b/platforms/android/cordova/node_modules/osenv/.npmignore new file mode 100644 index 0000000..8c23dee --- /dev/null +++ b/platforms/android/cordova/node_modules/osenv/.npmignore @@ -0,0 +1,13 @@ +*.swp +.*.swp + +.DS_Store +*~ +.project +.settings +npm-debug.log +coverage.html +.idea +lib-cov + +node_modules diff --git a/platforms/android/cordova/node_modules/osenv/.travis.yml b/platforms/android/cordova/node_modules/osenv/.travis.yml new file mode 100644 index 0000000..99f2bbf --- /dev/null +++ b/platforms/android/cordova/node_modules/osenv/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +language: node_js +node_js: + - '0.8' + - '0.10' + - '0.12' + - 'iojs' +before_install: + - npm install -g npm@latest diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE b/platforms/android/cordova/node_modules/osenv/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE rename to platforms/android/cordova/node_modules/osenv/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/README.md b/platforms/android/cordova/node_modules/osenv/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/README.md rename to platforms/android/cordova/node_modules/osenv/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/osenv.js b/platforms/android/cordova/node_modules/osenv/osenv.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/osenv.js rename to platforms/android/cordova/node_modules/osenv/osenv.js diff --git a/platforms/android/cordova/node_modules/osenv/package.json b/platforms/android/cordova/node_modules/osenv/package.json new file mode 100644 index 0000000..43da54d --- /dev/null +++ b/platforms/android/cordova/node_modules/osenv/package.json @@ -0,0 +1,101 @@ +{ + "_args": [ + [ + "osenv@^0.1.3", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "osenv@>=0.1.3 <0.2.0", + "_id": "osenv@0.1.3", + "_inCache": true, + "_installable": true, + "_location": "/osenv", + "_nodeVersion": "2.2.1", + "_npmUser": { + "email": "isaacs@npmjs.com", + "name": "isaacs" + }, + "_npmVersion": "3.0.0", + "_phantomChildren": {}, + "_requested": { + "name": "osenv", + "raw": "osenv@^0.1.3", + "rawSpec": "^0.1.3", + "scope": null, + "spec": ">=0.1.3 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz", + "_shasum": "83cf05c6d6458fc4d5ac6362ea325d92f2754217", + "_shrinkwrap": null, + "_spec": "osenv@^0.1.3", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/npm/osenv/issues" + }, + "dependencies": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + }, + "description": "Look up environment settings specific to different operating systems", + "devDependencies": { + "tap": "^1.2.0" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "83cf05c6d6458fc4d5ac6362ea325d92f2754217", + "tarball": "http://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz" + }, + "gitHead": "f746b3405d8f9e28054d11b97e1436f6a15016c4", + "homepage": "https://github.com/npm/osenv#readme", + "keywords": [ + "environment", + "home", + "path", + "prompt", + "ps1", + "tmpdir", + "variable" + ], + "license": "ISC", + "main": "osenv.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "robertkowalski", + "email": "rok@kowalski.gd" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + }, + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "name": "osenv", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/osenv.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "0.1.3" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/test/unix.js b/platforms/android/cordova/node_modules/osenv/test/unix.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/test/unix.js rename to platforms/android/cordova/node_modules/osenv/test/unix.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/test/windows.js b/platforms/android/cordova/node_modules/osenv/test/windows.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/test/windows.js rename to platforms/android/cordova/node_modules/osenv/test/windows.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/x.tap b/platforms/android/cordova/node_modules/osenv/x.tap similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/x.tap rename to platforms/android/cordova/node_modules/osenv/x.tap diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/index.js b/platforms/android/cordova/node_modules/path-is-absolute/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/index.js rename to platforms/android/cordova/node_modules/path-is-absolute/index.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/license b/platforms/android/cordova/node_modules/path-is-absolute/license similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/node_modules/os-tmpdir/license rename to platforms/android/cordova/node_modules/path-is-absolute/license diff --git a/platforms/android/cordova/node_modules/path-is-absolute/package.json b/platforms/android/cordova/node_modules/path-is-absolute/package.json new file mode 100644 index 0000000..12bed5a --- /dev/null +++ b/platforms/android/cordova/node_modules/path-is-absolute/package.json @@ -0,0 +1,97 @@ +{ + "_args": [ + [ + "path-is-absolute@^1.0.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/glob" + ] + ], + "_from": "path-is-absolute@>=1.0.0 <2.0.0", + "_id": "path-is-absolute@1.0.0", + "_inCache": true, + "_installable": true, + "_location": "/path-is-absolute", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "path-is-absolute", + "raw": "path-is-absolute@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob" + ], + "_resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz", + "_shasum": "263dada66ab3f2fb10bf7f9d24dd8f3e570ef912", + "_shrinkwrap": null, + "_spec": "path-is-absolute@^1.0.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/glob", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/path-is-absolute/issues" + }, + "dependencies": {}, + "description": "Node.js 0.12 path.isAbsolute() ponyfill", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "263dada66ab3f2fb10bf7f9d24dd8f3e570ef912", + "tarball": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "7a76a0c9f2263192beedbe0a820e4d0baee5b7a1", + "homepage": "https://github.com/sindresorhus/path-is-absolute", + "keywords": [ + "absolute", + "built-in", + "check", + "core", + "detect", + "dir", + "file", + "is", + "is-absolute", + "isabsolute", + "path", + "paths", + "polyfill", + "ponyfill", + "shim", + "util", + "utils" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "path-is-absolute", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/path-is-absolute.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/readme.md b/platforms/android/cordova/node_modules/path-is-absolute/readme.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/path-is-absolute/readme.md rename to platforms/android/cordova/node_modules/path-is-absolute/readme.md diff --git a/platforms/android/cordova/node_modules/plist/.jshintrc b/platforms/android/cordova/node_modules/plist/.jshintrc new file mode 100644 index 0000000..3f42622 --- /dev/null +++ b/platforms/android/cordova/node_modules/plist/.jshintrc @@ -0,0 +1,4 @@ +{ + "laxbreak": true, + "laxcomma": true +} diff --git a/platforms/android/cordova/node_modules/plist/.travis.yml b/platforms/android/cordova/node_modules/plist/.travis.yml new file mode 100644 index 0000000..f82fbdc --- /dev/null +++ b/platforms/android/cordova/node_modules/plist/.travis.yml @@ -0,0 +1,34 @@ +language: node_js +node_js: +- '0.10' +- '0.11' +- '4.0' +- '4.1' +env: + global: + - secure: xlLmWO7akYQjmDgrv6/b/ZMGILF8FReD+k6A/u8pYRD2JW29hhwvRwIQGcKp9+zmJdn4i5M4D1/qJkCeI3pdhAYBDHvzHOHSEwLJz1ESB2Crv6fa69CtpIufQkWvIxmZoU49tCaLpMBaIroGihJ4DAXdIVOIz6Ur9vXLDhGsE4c= + - secure: aQ46RdxL10xR5ZJJTMUKdH5k4tdrzgZ87nlwHC+pTr6bfRw3UKYC+6Rm7yQpg9wq0Io9O9dYCP007gQGSWstbjr1+jXNu/ubtNG+q5cpWBQZZZ013VHh9QJTf1MnetsZxbv8Yhrjg590s6vruT0oqesOnB2CizO/BsKxnY37Nos= +matrix: + include: + - node_js: '0.10' + env: BROWSER_NAME=chrome BROWSER_VERSION=latest + - node_js: '0.10' + env: BROWSER_NAME=chrome BROWSER_VERSION=29 + - node_js: '0.10' + env: BROWSER_NAME=firefox BROWSER_VERSION=latest + - node_js: '0.10' + env: BROWSER_NAME=opera BROWSER_VERSION=latest + - node_js: '0.10' + env: BROWSER_NAME=safari BROWSER_VERSION=latest + - node_js: '0.10' + env: BROWSER_NAME=safari BROWSER_VERSION=7 + - node_js: '0.10' + env: BROWSER_NAME=safari BROWSER_VERSION=6 + - node_js: '0.10' + env: BROWSER_NAME=safari BROWSER_VERSION=5 + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=11 + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=10 + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=9 diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/History.md b/platforms/android/cordova/node_modules/plist/History.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/History.md rename to platforms/android/cordova/node_modules/plist/History.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/LICENSE b/platforms/android/cordova/node_modules/plist/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/LICENSE rename to platforms/android/cordova/node_modules/plist/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/Makefile b/platforms/android/cordova/node_modules/plist/Makefile similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/Makefile rename to platforms/android/cordova/node_modules/plist/Makefile diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/README.md b/platforms/android/cordova/node_modules/plist/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/README.md rename to platforms/android/cordova/node_modules/plist/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/dist/plist-build.js b/platforms/android/cordova/node_modules/plist/dist/plist-build.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/dist/plist-build.js rename to platforms/android/cordova/node_modules/plist/dist/plist-build.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/dist/plist-parse.js b/platforms/android/cordova/node_modules/plist/dist/plist-parse.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/dist/plist-parse.js rename to platforms/android/cordova/node_modules/plist/dist/plist-parse.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/dist/plist.js b/platforms/android/cordova/node_modules/plist/dist/plist.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/dist/plist.js rename to platforms/android/cordova/node_modules/plist/dist/plist.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/examples/browser/index.html b/platforms/android/cordova/node_modules/plist/examples/browser/index.html similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/examples/browser/index.html rename to platforms/android/cordova/node_modules/plist/examples/browser/index.html diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/build.js b/platforms/android/cordova/node_modules/plist/lib/build.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/build.js rename to platforms/android/cordova/node_modules/plist/lib/build.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/node.js b/platforms/android/cordova/node_modules/plist/lib/node.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/node.js rename to platforms/android/cordova/node_modules/plist/lib/node.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/parse.js b/platforms/android/cordova/node_modules/plist/lib/parse.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/parse.js rename to platforms/android/cordova/node_modules/plist/lib/parse.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/plist.js b/platforms/android/cordova/node_modules/plist/lib/plist.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/lib/plist.js rename to platforms/android/cordova/node_modules/plist/lib/plist.js diff --git a/platforms/android/cordova/node_modules/plist/package.json b/platforms/android/cordova/node_modules/plist/package.json new file mode 100644 index 0000000..dddb405 --- /dev/null +++ b/platforms/android/cordova/node_modules/plist/package.json @@ -0,0 +1,117 @@ +{ + "_args": [ + [ + "plist@^1.2.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "plist@>=1.2.0 <2.0.0", + "_id": "plist@1.2.0", + "_inCache": true, + "_installable": true, + "_location": "/plist", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "reinstein.mike@gmail.com", + "name": "mreinstein" + }, + "_npmVersion": "3.3.11", + "_phantomChildren": {}, + "_requested": { + "name": "plist", + "raw": "plist@^1.2.0", + "rawSpec": "^1.2.0", + "scope": null, + "spec": ">=1.2.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/plist/-/plist-1.2.0.tgz", + "_shasum": "084b5093ddc92506e259f874b8d9b1afb8c79593", + "_shrinkwrap": null, + "_spec": "plist@^1.2.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "email": "nathan@tootallnate.net", + "name": "Nathan Rajlich" + }, + "bugs": { + "url": "https://github.com/TooTallNate/node-plist/issues" + }, + "contributors": [ + { + "name": "Hans Huebner", + "email": "hans.huebner@gmail.com" + }, + { + "name": "Pierre Metrailler" + }, + { + "name": "Mike Reinstein", + "email": "reinstein.mike@gmail.com" + }, + { + "name": "Vladimir Tsvang" + }, + { + "name": "Mathieu D'Amours" + } + ], + "dependencies": { + "base64-js": "0.0.8", + "util-deprecate": "1.0.2", + "xmlbuilder": "4.0.0", + "xmldom": "0.1.x" + }, + "description": "Mac OS X Plist parser/builder for Node.js and browsers", + "devDependencies": { + "browserify": "12.0.1", + "mocha": "2.3.3", + "multiline": "1.0.2", + "zuul": "3.7.2" + }, + "directories": {}, + "dist": { + "shasum": "084b5093ddc92506e259f874b8d9b1afb8c79593", + "tarball": "http://registry.npmjs.org/plist/-/plist-1.2.0.tgz" + }, + "gitHead": "69520574f27864145192338b72e608fbe1bda6f7", + "homepage": "https://github.com/TooTallNate/node-plist#readme", + "keywords": [ + "apple", + "browser", + "mac", + "parser", + "plist", + "xml" + ], + "license": "MIT", + "main": "lib/plist.js", + "maintainers": [ + { + "name": "TooTallNate", + "email": "nathan@tootallnate.net" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + { + "name": "mreinstein", + "email": "reinstein.mike@gmail.com" + } + ], + "name": "plist", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/node-plist.git" + }, + "scripts": { + "test": "make test" + }, + "version": "1.2.0" +} diff --git a/platforms/android/cordova/node_modules/properties-parser/package.json b/platforms/android/cordova/node_modules/properties-parser/package.json index c74be98..b089b27 100644 --- a/platforms/android/cordova/node_modules/properties-parser/package.json +++ b/platforms/android/cordova/node_modules/properties-parser/package.json @@ -1,46 +1,73 @@ { - "name": "properties-parser", - "version": "0.2.3", + "_args": [ + [ + "properties-parser@^0.2.3", + "/Users/steveng/repo/cordova/cordova-android" + ] + ], + "_from": "properties-parser@>=0.2.3 <0.3.0", + "_id": "properties-parser@0.2.3", + "_inCache": true, + "_installable": true, + "_location": "/properties-parser", + "_npmUser": { + "email": "xavi.rmz@gmail.com", + "name": "xavi" + }, + "_npmVersion": "1.3.23", + "_phantomChildren": {}, + "_requested": { + "name": "properties-parser", + "raw": "properties-parser@^0.2.3", + "rawSpec": "^0.2.3", + "scope": null, + "spec": ">=0.2.3 <0.3.0", + "type": "range" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "http://registry.npmjs.org/properties-parser/-/properties-parser-0.2.3.tgz", + "_shasum": "f7591255f707abbff227c7b56b637dbb0373a10f", + "_shrinkwrap": null, + "_spec": "properties-parser@^0.2.3", + "_where": "/Users/steveng/repo/cordova/cordova-android", + "bugs": { + "url": "https://github.com/xavi-/node-properties-parser/issues" + }, + "dependencies": {}, "description": "A parser for .properties files written in javascript", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "f7591255f707abbff227c7b56b637dbb0373a10f", + "tarball": "http://registry.npmjs.org/properties-parser/-/properties-parser-0.2.3.tgz" + }, + "engines": { + "node": ">= 0.3.1" + }, + "homepage": "https://github.com/xavi-/node-properties-parser", "keywords": [ - "parser", ".properties", - "properties", - "java", + "actionscript", "file parser", - "actionscript" + "java", + "parser", + "properties" ], + "main": "./index.js", "maintainers": [ { "name": "xavi", "email": "xavi.rmz@gmail.com" } ], - "main": "./index.js", + "name": "properties-parser", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", "repository": { "type": "git", "url": "git+https://github.com/xavi-/node-properties-parser.git" }, - "engines": { - "node": ">= 0.3.1" - }, - "bugs": { - "url": "https://github.com/xavi-/node-properties-parser/issues" - }, - "homepage": "https://github.com/xavi-/node-properties-parser", - "_id": "properties-parser@0.2.3", - "dist": { - "shasum": "f7591255f707abbff227c7b56b637dbb0373a10f", - "tarball": "http://registry.npmjs.org/properties-parser/-/properties-parser-0.2.3.tgz" - }, - "_from": "properties-parser@>=0.2.3 <0.3.0", - "_npmVersion": "1.3.23", - "_npmUser": { - "name": "xavi", - "email": "xavi.rmz@gmail.com" - }, - "directories": {}, - "_shasum": "f7591255f707abbff227c7b56b637dbb0373a10f", - "_resolved": "http://registry.npmjs.org/properties-parser/-/properties-parser-0.2.3.tgz", - "readme": "ERROR: No README data found!" + "version": "0.2.3" } diff --git a/platforms/android/cordova/node_modules/q/package.json b/platforms/android/cordova/node_modules/q/package.json index a576af9..40e4b1e 100644 --- a/platforms/android/cordova/node_modules/q/package.json +++ b/platforms/android/cordova/node_modules/q/package.json @@ -1,27 +1,47 @@ { - "name": "q", - "version": "1.4.1", - "description": "A library for promises (CommonJS/Promises/A,B,D)", - "homepage": "https://github.com/kriskowal/q", + "_args": [ + [ + "q@^1.4.1", + "/Users/steveng/repo/cordova/cordova-android" + ] + ], + "_from": "q@>=1.4.1 <2.0.0", + "_id": "q@1.4.1", + "_inCache": true, + "_installable": true, + "_location": "/q", + "_nodeVersion": "1.8.1", + "_npmUser": { + "email": "kris.kowal@cixar.com", + "name": "kriskowal" + }, + "_npmVersion": "2.8.3", + "_phantomChildren": {}, + "_requested": { + "name": "q", + "raw": "q@^1.4.1", + "rawSpec": "^1.4.1", + "scope": null, + "spec": ">=1.4.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/", + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/q/-/q-1.4.1.tgz", + "_shasum": "55705bcd93c5f3673530c2c2cbc0c2b3addc286e", + "_shrinkwrap": null, + "_spec": "q@^1.4.1", + "_where": "/Users/steveng/repo/cordova/cordova-android", "author": { - "name": "Kris Kowal", "email": "kris@cixar.com", + "name": "Kris Kowal", "url": "https://github.com/kriskowal" }, - "keywords": [ - "q", - "promise", - "promises", - "promises-a", - "promises-aplus", - "deferred", - "future", - "async", - "flow control", - "fluent", - "browser", - "node" - ], + "bugs": { + "url": "http://github.com/kriskowal/q/issues" + }, "contributors": [ { "name": "Kris Kowal", @@ -39,28 +59,8 @@ "url": "http://domenicdenicola.com" } ], - "bugs": { - "url": "http://github.com/kriskowal/q/issues" - }, - "license": { - "type": "MIT", - "url": "http://github.com/kriskowal/q/raw/master/LICENSE" - }, - "main": "q.js", - "files": [ - "LICENSE", - "q.js", - "queue.js" - ], - "repository": { - "type": "git", - "url": "git://github.com/kriskowal/q.git" - }, - "engines": { - "node": ">=0.6.0", - "teleport": ">=0.2.0" - }, "dependencies": {}, + "description": "A library for promises (CommonJS/Promises/A,B,D)", "devDependencies": { "cover": "*", "grunt": "~0.4.1", @@ -72,35 +72,43 @@ "opener": "*", "promises-aplus-tests": "1.x" }, - "scripts": { - "test": "jasmine-node spec && promises-aplus-tests spec/aplus-adapter", - "test-browser": "opener spec/q-spec.html", - "benchmark": "matcha", - "lint": "jshint q.js", - "cover": "cover run jasmine-node spec && cover report html && opener cover_html/index.html", - "minify": "grunt", - "prepublish": "grunt" - }, - "overlay": { - "teleport": { - "dependencies": { - "system": ">=0.0.4" - } - } - }, "directories": { "test": "./spec" }, + "dist": { + "shasum": "55705bcd93c5f3673530c2c2cbc0c2b3addc286e", + "tarball": "http://registry.npmjs.org/q/-/q-1.4.1.tgz" + }, + "engines": { + "node": ">=0.6.0", + "teleport": ">=0.2.0" + }, + "files": [ + "LICENSE", + "q.js", + "queue.js" + ], "gitHead": "d373079d3620152e3d60e82f27265a09ee0e81bd", - "_id": "q@1.4.1", - "_shasum": "55705bcd93c5f3673530c2c2cbc0c2b3addc286e", - "_from": "q@>=1.4.1 <2.0.0", - "_npmVersion": "2.8.3", - "_nodeVersion": "1.8.1", - "_npmUser": { - "name": "kriskowal", - "email": "kris.kowal@cixar.com" + "homepage": "https://github.com/kriskowal/q", + "keywords": [ + "async", + "browser", + "deferred", + "flow control", + "fluent", + "future", + "node", + "promise", + "promises", + "promises-a", + "promises-aplus", + "q" + ], + "license": { + "type": "MIT", + "url": "http://github.com/kriskowal/q/raw/master/LICENSE" }, + "main": "q.js", "maintainers": [ { "name": "kriskowal", @@ -111,10 +119,28 @@ "email": "domenic@domenicdenicola.com" } ], - "dist": { - "shasum": "55705bcd93c5f3673530c2c2cbc0c2b3addc286e", - "tarball": "http://registry.npmjs.org/q/-/q-1.4.1.tgz" + "name": "q", + "optionalDependencies": {}, + "overlay": { + "teleport": { + "dependencies": { + "system": ">=0.0.4" + } + } }, - "_resolved": "http://registry.npmjs.org/q/-/q-1.4.1.tgz", - "readme": "ERROR: No README data found!" + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/kriskowal/q.git" + }, + "scripts": { + "benchmark": "matcha", + "cover": "cover run jasmine-node spec && cover report html && opener cover_html/index.html", + "lint": "jshint q.js", + "minify": "grunt", + "prepublish": "grunt", + "test": "jasmine-node spec && promises-aplus-tests spec/aplus-adapter", + "test-browser": "opener spec/q-spec.html" + }, + "version": "1.4.1" } diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/AUTHORS b/platforms/android/cordova/node_modules/sax/AUTHORS similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/AUTHORS rename to platforms/android/cordova/node_modules/sax/AUTHORS diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/LICENSE b/platforms/android/cordova/node_modules/sax/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/LICENSE rename to platforms/android/cordova/node_modules/sax/LICENSE diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/README.md b/platforms/android/cordova/node_modules/sax/README.md similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/README.md rename to platforms/android/cordova/node_modules/sax/README.md diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/big-not-pretty.xml b/platforms/android/cordova/node_modules/sax/examples/big-not-pretty.xml similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/big-not-pretty.xml rename to platforms/android/cordova/node_modules/sax/examples/big-not-pretty.xml diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/example.js b/platforms/android/cordova/node_modules/sax/examples/example.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/example.js rename to platforms/android/cordova/node_modules/sax/examples/example.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/get-products.js b/platforms/android/cordova/node_modules/sax/examples/get-products.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/get-products.js rename to platforms/android/cordova/node_modules/sax/examples/get-products.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/hello-world.js b/platforms/android/cordova/node_modules/sax/examples/hello-world.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/hello-world.js rename to platforms/android/cordova/node_modules/sax/examples/hello-world.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/not-pretty.xml b/platforms/android/cordova/node_modules/sax/examples/not-pretty.xml similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/not-pretty.xml rename to platforms/android/cordova/node_modules/sax/examples/not-pretty.xml diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/pretty-print.js b/platforms/android/cordova/node_modules/sax/examples/pretty-print.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/pretty-print.js rename to platforms/android/cordova/node_modules/sax/examples/pretty-print.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/shopping.xml b/platforms/android/cordova/node_modules/sax/examples/shopping.xml similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/shopping.xml rename to platforms/android/cordova/node_modules/sax/examples/shopping.xml diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/strict.dtd b/platforms/android/cordova/node_modules/sax/examples/strict.dtd similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/strict.dtd rename to platforms/android/cordova/node_modules/sax/examples/strict.dtd diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/switch-bench.js b/platforms/android/cordova/node_modules/sax/examples/switch-bench.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/switch-bench.js rename to platforms/android/cordova/node_modules/sax/examples/switch-bench.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/test.html b/platforms/android/cordova/node_modules/sax/examples/test.html similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/test.html rename to platforms/android/cordova/node_modules/sax/examples/test.html diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/test.xml b/platforms/android/cordova/node_modules/sax/examples/test.xml similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/examples/test.xml rename to platforms/android/cordova/node_modules/sax/examples/test.xml diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/lib/sax.js b/platforms/android/cordova/node_modules/sax/lib/sax.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/lib/sax.js rename to platforms/android/cordova/node_modules/sax/lib/sax.js diff --git a/platforms/android/cordova/node_modules/sax/package.json b/platforms/android/cordova/node_modules/sax/package.json new file mode 100644 index 0000000..d53c86b --- /dev/null +++ b/platforms/android/cordova/node_modules/sax/package.json @@ -0,0 +1,114 @@ +{ + "_args": [ + [ + "sax@0.3.5", + "/Users/steveng/repo/cordova/cordova-android/node_modules/elementtree" + ] + ], + "_defaultsLoaded": true, + "_engineSupported": true, + "_from": "sax@0.3.5", + "_id": "sax@0.3.5", + "_inCache": true, + "_installable": true, + "_location": "/sax", + "_nodeVersion": "v0.6.7-pre", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "1.1.0-beta-7", + "_phantomChildren": {}, + "_requested": { + "name": "sax", + "raw": "sax@0.3.5", + "rawSpec": "0.3.5", + "scope": null, + "spec": "0.3.5", + "type": "version" + }, + "_requiredBy": [ + "/elementtree" + ], + "_resolved": "http://registry.npmjs.org/sax/-/sax-0.3.5.tgz", + "_shasum": "88fcfc1f73c0c8bbd5b7c776b6d3f3501eed073d", + "_shrinkwrap": null, + "_spec": "sax@0.3.5", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/elementtree", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/sax-js/issues" + }, + "contributors": [ + { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me" + }, + { + "name": "Stein Martin Hustad", + "email": "stein@hustad.com" + }, + { + "name": "Mikeal Rogers", + "email": "mikeal.rogers@gmail.com" + }, + { + "name": "Laurie Harper", + "email": "laurie@holoweb.net" + }, + { + "name": "Jann Horn", + "email": "jann@Jann-PC.fritz.box" + }, + { + "name": "Elijah Insua", + "email": "tmpvar@gmail.com" + }, + { + "name": "Henry Rawas", + "email": "henryr@schakra.com" + }, + { + "name": "Justin Makeig", + "email": "jmpublic@makeig.com" + } + ], + "dependencies": {}, + "description": "An evented streaming XML parser in JavaScript", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "88fcfc1f73c0c8bbd5b7c776b6d3f3501eed073d", + "tarball": "http://registry.npmjs.org/sax/-/sax-0.3.5.tgz" + }, + "engines": { + "node": "*" + }, + "homepage": "https://github.com/isaacs/sax-js#readme", + "license": { + "type": "MIT", + "url": "https://raw.github.com/isaacs/sax-js/master/LICENSE" + }, + "main": "lib/sax.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "sax", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/sax-js.git" + }, + "scripts": { + "test": "node test/index.js" + }, + "version": "0.3.5" +} diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/buffer-overrun.js b/platforms/android/cordova/node_modules/sax/test/buffer-overrun.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/buffer-overrun.js rename to platforms/android/cordova/node_modules/sax/test/buffer-overrun.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-chunked.js b/platforms/android/cordova/node_modules/sax/test/cdata-chunked.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-chunked.js rename to platforms/android/cordova/node_modules/sax/test/cdata-chunked.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-end-split.js b/platforms/android/cordova/node_modules/sax/test/cdata-end-split.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-end-split.js rename to platforms/android/cordova/node_modules/sax/test/cdata-end-split.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-fake-end.js b/platforms/android/cordova/node_modules/sax/test/cdata-fake-end.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-fake-end.js rename to platforms/android/cordova/node_modules/sax/test/cdata-fake-end.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-multiple.js b/platforms/android/cordova/node_modules/sax/test/cdata-multiple.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata-multiple.js rename to platforms/android/cordova/node_modules/sax/test/cdata-multiple.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata.js b/platforms/android/cordova/node_modules/sax/test/cdata.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/cdata.js rename to platforms/android/cordova/node_modules/sax/test/cdata.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/index.js b/platforms/android/cordova/node_modules/sax/test/index.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/index.js rename to platforms/android/cordova/node_modules/sax/test/index.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-23.js b/platforms/android/cordova/node_modules/sax/test/issue-23.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-23.js rename to platforms/android/cordova/node_modules/sax/test/issue-23.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-30.js b/platforms/android/cordova/node_modules/sax/test/issue-30.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-30.js rename to platforms/android/cordova/node_modules/sax/test/issue-30.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-35.js b/platforms/android/cordova/node_modules/sax/test/issue-35.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-35.js rename to platforms/android/cordova/node_modules/sax/test/issue-35.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-47.js b/platforms/android/cordova/node_modules/sax/test/issue-47.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-47.js rename to platforms/android/cordova/node_modules/sax/test/issue-47.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-49.js b/platforms/android/cordova/node_modules/sax/test/issue-49.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/issue-49.js rename to platforms/android/cordova/node_modules/sax/test/issue-49.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/parser-position.js b/platforms/android/cordova/node_modules/sax/test/parser-position.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/parser-position.js rename to platforms/android/cordova/node_modules/sax/test/parser-position.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/script.js b/platforms/android/cordova/node_modules/sax/test/script.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/script.js rename to platforms/android/cordova/node_modules/sax/test/script.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/self-closing-child-strict.js b/platforms/android/cordova/node_modules/sax/test/self-closing-child-strict.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/self-closing-child-strict.js rename to platforms/android/cordova/node_modules/sax/test/self-closing-child-strict.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/self-closing-child.js b/platforms/android/cordova/node_modules/sax/test/self-closing-child.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/self-closing-child.js rename to platforms/android/cordova/node_modules/sax/test/self-closing-child.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/self-closing-tag.js b/platforms/android/cordova/node_modules/sax/test/self-closing-tag.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/self-closing-tag.js rename to platforms/android/cordova/node_modules/sax/test/self-closing-tag.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/stray-ending.js b/platforms/android/cordova/node_modules/sax/test/stray-ending.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/stray-ending.js rename to platforms/android/cordova/node_modules/sax/test/stray-ending.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/trailing-non-whitespace.js b/platforms/android/cordova/node_modules/sax/test/trailing-non-whitespace.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/trailing-non-whitespace.js rename to platforms/android/cordova/node_modules/sax/test/trailing-non-whitespace.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/unquoted.js b/platforms/android/cordova/node_modules/sax/test/unquoted.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/unquoted.js rename to platforms/android/cordova/node_modules/sax/test/unquoted.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-issue-41.js b/platforms/android/cordova/node_modules/sax/test/xmlns-issue-41.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-issue-41.js rename to platforms/android/cordova/node_modules/sax/test/xmlns-issue-41.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-rebinding.js b/platforms/android/cordova/node_modules/sax/test/xmlns-rebinding.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-rebinding.js rename to platforms/android/cordova/node_modules/sax/test/xmlns-rebinding.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-strict.js b/platforms/android/cordova/node_modules/sax/test/xmlns-strict.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-strict.js rename to platforms/android/cordova/node_modules/sax/test/xmlns-strict.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-unbound.js b/platforms/android/cordova/node_modules/sax/test/xmlns-unbound.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-unbound.js rename to platforms/android/cordova/node_modules/sax/test/xmlns-unbound.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js b/platforms/android/cordova/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js rename to platforms/android/cordova/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-prefix.js b/platforms/android/cordova/node_modules/sax/test/xmlns-xml-default-prefix.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-prefix.js rename to platforms/android/cordova/node_modules/sax/test/xmlns-xml-default-prefix.js diff --git a/platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-redefine.js b/platforms/android/cordova/node_modules/sax/test/xmlns-xml-default-redefine.js similarity index 100% rename from platforms/android/cordova/node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-redefine.js rename to platforms/android/cordova/node_modules/sax/test/xmlns-xml-default-redefine.js diff --git a/platforms/android/cordova/node_modules/semver/.npmignore b/platforms/android/cordova/node_modules/semver/.npmignore new file mode 100644 index 0000000..534108e --- /dev/null +++ b/platforms/android/cordova/node_modules/semver/.npmignore @@ -0,0 +1,4 @@ +node_modules/ +coverage/ +.nyc_output/ +nyc_output/ diff --git a/platforms/android/cordova/node_modules/semver/.travis.yml b/platforms/android/cordova/node_modules/semver/.travis.yml new file mode 100644 index 0000000..991d04b --- /dev/null +++ b/platforms/android/cordova/node_modules/semver/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - '0.10' + - '0.12' + - 'iojs' diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/LICENSE b/platforms/android/cordova/node_modules/semver/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/osenv/LICENSE rename to platforms/android/cordova/node_modules/semver/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/README.md b/platforms/android/cordova/node_modules/semver/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/README.md rename to platforms/android/cordova/node_modules/semver/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/bin/semver b/platforms/android/cordova/node_modules/semver/bin/semver similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/bin/semver rename to platforms/android/cordova/node_modules/semver/bin/semver diff --git a/platforms/android/cordova/node_modules/semver/package.json b/platforms/android/cordova/node_modules/semver/package.json new file mode 100644 index 0000000..0db0065 --- /dev/null +++ b/platforms/android/cordova/node_modules/semver/package.json @@ -0,0 +1,77 @@ +{ + "_args": [ + [ + "semver@^5.0.1", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "semver@>=5.0.1 <6.0.0", + "_id": "semver@5.1.0", + "_inCache": true, + "_installable": true, + "_location": "/semver", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "3.3.2", + "_phantomChildren": {}, + "_requested": { + "name": "semver", + "raw": "semver@^5.0.1", + "rawSpec": "^5.0.1", + "scope": null, + "spec": ">=5.0.1 <6.0.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/semver/-/semver-5.1.0.tgz", + "_shasum": "85f2cf8550465c4df000cf7d86f6b054106ab9e5", + "_shrinkwrap": null, + "_spec": "semver@^5.0.1", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "bin": { + "semver": "./bin/semver" + }, + "bugs": { + "url": "https://github.com/npm/node-semver/issues" + }, + "dependencies": {}, + "description": "The semantic version parser used by npm.", + "devDependencies": { + "tap": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "85f2cf8550465c4df000cf7d86f6b054106ab9e5", + "tarball": "http://registry.npmjs.org/semver/-/semver-5.1.0.tgz" + }, + "gitHead": "8e33a30e62e40e4983d1c5f55e794331b861aadc", + "homepage": "https://github.com/npm/node-semver#readme", + "license": "ISC", + "main": "semver.js", + "maintainers": [ + { + "name": "isaacs", + "email": "isaacs@npmjs.com" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + } + ], + "name": "semver", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/node-semver.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "5.1.0" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/range.bnf b/platforms/android/cordova/node_modules/semver/range.bnf similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/range.bnf rename to platforms/android/cordova/node_modules/semver/range.bnf diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/semver.js b/platforms/android/cordova/node_modules/semver/semver.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/semver.js rename to platforms/android/cordova/node_modules/semver/semver.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/big-numbers.js b/platforms/android/cordova/node_modules/semver/test/big-numbers.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/big-numbers.js rename to platforms/android/cordova/node_modules/semver/test/big-numbers.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/clean.js b/platforms/android/cordova/node_modules/semver/test/clean.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/clean.js rename to platforms/android/cordova/node_modules/semver/test/clean.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/gtr.js b/platforms/android/cordova/node_modules/semver/test/gtr.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/gtr.js rename to platforms/android/cordova/node_modules/semver/test/gtr.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/index.js b/platforms/android/cordova/node_modules/semver/test/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/index.js rename to platforms/android/cordova/node_modules/semver/test/index.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/ltr.js b/platforms/android/cordova/node_modules/semver/test/ltr.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/ltr.js rename to platforms/android/cordova/node_modules/semver/test/ltr.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/major-minor-patch.js b/platforms/android/cordova/node_modules/semver/test/major-minor-patch.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/test/major-minor-patch.js rename to platforms/android/cordova/node_modules/semver/test/major-minor-patch.js diff --git a/platforms/android/cordova/node_modules/shelljs/.documentup.json b/platforms/android/cordova/node_modules/shelljs/.documentup.json new file mode 100644 index 0000000..57fe301 --- /dev/null +++ b/platforms/android/cordova/node_modules/shelljs/.documentup.json @@ -0,0 +1,6 @@ +{ + "name": "ShellJS", + "twitter": [ + "r2r" + ] +} diff --git a/platforms/android/cordova/node_modules/shelljs/.jshintrc b/platforms/android/cordova/node_modules/shelljs/.jshintrc new file mode 100644 index 0000000..a80c559 --- /dev/null +++ b/platforms/android/cordova/node_modules/shelljs/.jshintrc @@ -0,0 +1,7 @@ +{ + "loopfunc": true, + "sub": true, + "undef": true, + "unused": true, + "node": true +} \ No newline at end of file diff --git a/platforms/android/cordova/node_modules/shelljs/.npmignore b/platforms/android/cordova/node_modules/shelljs/.npmignore new file mode 100644 index 0000000..6b20c38 --- /dev/null +++ b/platforms/android/cordova/node_modules/shelljs/.npmignore @@ -0,0 +1,2 @@ +test/ +tmp/ \ No newline at end of file diff --git a/platforms/android/cordova/node_modules/shelljs/.travis.yml b/platforms/android/cordova/node_modules/shelljs/.travis.yml new file mode 100644 index 0000000..1b3280a --- /dev/null +++ b/platforms/android/cordova/node_modules/shelljs/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.11" + - "0.12" + diff --git a/platforms/android/cordova/node_modules/shelljs/package.json b/platforms/android/cordova/node_modules/shelljs/package.json index 2c9f998..572bd7c 100644 --- a/platforms/android/cordova/node_modules/shelljs/package.json +++ b/platforms/android/cordova/node_modules/shelljs/package.json @@ -1,64 +1,89 @@ { - "name": "shelljs", - "version": "0.5.3", - "author": { - "name": "Artur Adib", - "email": "arturadib@gmail.com" - }, - "description": "Portable Unix shell commands for Node.js", - "keywords": [ - "unix", - "shell", - "makefile", - "make", - "jake", - "synchronous" + "_args": [ + [ + "shelljs@^0.5.3", + "/Users/steveng/repo/cordova/cordova-android" + ] ], - "repository": { - "type": "git", - "url": "git://github.com/arturadib/shelljs.git" + "_from": "shelljs@>=0.5.3 <0.6.0", + "_id": "shelljs@0.5.3", + "_inCache": true, + "_installable": true, + "_location": "/shelljs", + "_nodeVersion": "1.2.0", + "_npmUser": { + "email": "arturadib@gmail.com", + "name": "artur" }, - "license": "BSD*", - "homepage": "http://github.com/arturadib/shelljs", - "main": "./shell.js", - "scripts": { - "test": "node scripts/run-tests" + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "shelljs", + "raw": "shelljs@^0.5.3", + "rawSpec": "^0.5.3", + "scope": null, + "spec": ">=0.5.3 <0.6.0", + "type": "range" + }, + "_requiredBy": [ + "/", + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz", + "_shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113", + "_shrinkwrap": null, + "_spec": "shelljs@^0.5.3", + "_where": "/Users/steveng/repo/cordova/cordova-android", + "author": { + "email": "arturadib@gmail.com", + "name": "Artur Adib" }, "bin": { "shjs": "./bin/shjs" }, + "bugs": { + "url": "https://github.com/arturadib/shelljs/issues" + }, "dependencies": {}, + "description": "Portable Unix shell commands for Node.js", "devDependencies": { "jshint": "~2.1.11" }, - "optionalDependencies": {}, + "directories": {}, + "dist": { + "shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113", + "tarball": "http://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz" + }, "engines": { "node": ">=0.8.0" }, "gitHead": "22d0975040b9b8234755dc6e692d6869436e8485", - "bugs": { - "url": "https://github.com/arturadib/shelljs/issues" - }, - "_id": "shelljs@0.5.3", - "_shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113", - "_from": "shelljs@>=0.5.3 <0.6.0", - "_npmVersion": "2.5.1", - "_nodeVersion": "1.2.0", - "_npmUser": { - "name": "artur", - "email": "arturadib@gmail.com" - }, + "homepage": "http://github.com/arturadib/shelljs", + "keywords": [ + "jake", + "make", + "makefile", + "shell", + "synchronous", + "unix" + ], + "license": "BSD*", + "main": "./shell.js", "maintainers": [ { "name": "artur", "email": "arturadib@gmail.com" } ], - "dist": { - "shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113", - "tarball": "http://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz" + "name": "shelljs", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/arturadib/shelljs.git" }, - "directories": {}, - "_resolved": "http://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz", - "readme": "ERROR: No README data found!" + "scripts": { + "test": "node scripts/run-tests" + }, + "version": "0.5.3" } diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/LICENSE b/platforms/android/cordova/node_modules/underscore/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/LICENSE rename to platforms/android/cordova/node_modules/underscore/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/README.md b/platforms/android/cordova/node_modules/underscore/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/README.md rename to platforms/android/cordova/node_modules/underscore/README.md diff --git a/platforms/android/cordova/node_modules/underscore/package.json b/platforms/android/cordova/node_modules/underscore/package.json new file mode 100644 index 0000000..3304948 --- /dev/null +++ b/platforms/android/cordova/node_modules/underscore/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "underscore@^1.8.3", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "underscore@>=1.8.3 <2.0.0", + "_id": "underscore@1.8.3", + "_inCache": true, + "_installable": true, + "_location": "/underscore", + "_npmUser": { + "email": "jashkenas@gmail.com", + "name": "jashkenas" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": {}, + "_requested": { + "name": "underscore", + "raw": "underscore@^1.8.3", + "rawSpec": "^1.8.3", + "scope": null, + "spec": ">=1.8.3 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "_shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022", + "_shrinkwrap": null, + "_spec": "underscore@^1.8.3", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "email": "jeremy@documentcloud.org", + "name": "Jeremy Ashkenas" + }, + "bugs": { + "url": "https://github.com/jashkenas/underscore/issues" + }, + "dependencies": {}, + "description": "JavaScript's functional programming helper library.", + "devDependencies": { + "docco": "*", + "eslint": "0.6.x", + "karma": "~0.12.31", + "karma-qunit": "~0.1.4", + "qunit-cli": "~0.2.0", + "uglify-js": "2.4.x" + }, + "directories": {}, + "dist": { + "shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022", + "tarball": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz" + }, + "files": [ + "LICENSE", + "underscore-min.js", + "underscore-min.map", + "underscore.js" + ], + "gitHead": "e4743ab712b8ab42ad4ccb48b155034d02394e4d", + "homepage": "http://underscorejs.org", + "keywords": [ + "browser", + "client", + "functional", + "server", + "util" + ], + "license": "MIT", + "main": "underscore.js", + "maintainers": [ + { + "name": "jashkenas", + "email": "jashkenas@gmail.com" + } + ], + "name": "underscore", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/jashkenas/underscore.git" + }, + "scripts": { + "build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js", + "doc": "docco underscore.js", + "lint": "eslint underscore.js test/*.js", + "test": "npm run test-node && npm run lint", + "test-browser": "npm i karma-phantomjs-launcher && ./node_modules/karma/bin/karma start", + "test-node": "qunit-cli test/*.js" + }, + "version": "1.8.3" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/underscore-min.js b/platforms/android/cordova/node_modules/underscore/underscore-min.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/underscore-min.js rename to platforms/android/cordova/node_modules/underscore/underscore-min.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/underscore-min.map b/platforms/android/cordova/node_modules/underscore/underscore-min.map similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/underscore-min.map rename to platforms/android/cordova/node_modules/underscore/underscore-min.map diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/underscore.js b/platforms/android/cordova/node_modules/underscore/underscore.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/underscore/underscore.js rename to platforms/android/cordova/node_modules/underscore/underscore.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/LICENSE.md b/platforms/android/cordova/node_modules/unorm/LICENSE.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/LICENSE.md rename to platforms/android/cordova/node_modules/unorm/LICENSE.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/README.md b/platforms/android/cordova/node_modules/unorm/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/README.md rename to platforms/android/cordova/node_modules/unorm/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/lib/unorm.js b/platforms/android/cordova/node_modules/unorm/lib/unorm.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/unorm/lib/unorm.js rename to platforms/android/cordova/node_modules/unorm/lib/unorm.js diff --git a/platforms/android/cordova/node_modules/unorm/package.json b/platforms/android/cordova/node_modules/unorm/package.json new file mode 100644 index 0000000..ca5fd67 --- /dev/null +++ b/platforms/android/cordova/node_modules/unorm/package.json @@ -0,0 +1,95 @@ +{ + "_args": [ + [ + "unorm@^1.3.3", + "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" + ] + ], + "_from": "unorm@>=1.3.3 <2.0.0", + "_id": "unorm@1.4.1", + "_inCache": true, + "_installable": true, + "_location": "/unorm", + "_npmUser": { + "email": "bwp@bwp.dk", + "name": "walling" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": {}, + "_requested": { + "name": "unorm", + "raw": "unorm@^1.3.3", + "rawSpec": "^1.3.3", + "scope": null, + "spec": ">=1.3.3 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "http://registry.npmjs.org/unorm/-/unorm-1.4.1.tgz", + "_shasum": "364200d5f13646ca8bcd44490271335614792300", + "_shrinkwrap": null, + "_spec": "unorm@^1.3.3", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", + "author": { + "email": "bwp@bwp.dk", + "name": "Bjarke Walling" + }, + "bugs": { + "url": "https://github.com/walling/unorm/issues" + }, + "contributors": [ + { + "name": "Bjarke Walling", + "email": "bwp@bwp.dk" + }, + { + "name": "Oleg Grenrus", + "email": "oleg.grenrus@iki.fi" + }, + { + "name": "Matsuza", + "email": "matsuza@gmail.com" + } + ], + "dependencies": {}, + "description": "JavaScript Unicode 8.0 Normalization - NFC, NFD, NFKC, NFKD. Read UAX #15 Unicode Normalization Forms.", + "devDependencies": { + "benchmark": "~1.0.0", + "grunt": "~0.4.1", + "grunt-contrib-jshint": "~0.8.0", + "grunt-contrib-watch": "~0.5.0", + "grunt-simple-mocha": "~0.4.0", + "unorm": "1.4.1" + }, + "directories": {}, + "dist": { + "shasum": "364200d5f13646ca8bcd44490271335614792300", + "tarball": "http://registry.npmjs.org/unorm/-/unorm-1.4.1.tgz" + }, + "engines": { + "node": ">= 0.4.0" + }, + "gitHead": "e802d0d7844cf74b03742bce1147a82ace218396", + "homepage": "https://github.com/walling/unorm", + "license": "MIT or GPL-2.0", + "main": "./lib/unorm.js", + "maintainers": [ + { + "name": "walling", + "email": "bwp@bwp.dk" + } + ], + "name": "unorm", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/walling/unorm.git" + }, + "scripts": { + "test": "grunt test" + }, + "version": "1.4.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/History.md b/platforms/android/cordova/node_modules/util-deprecate/History.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/History.md rename to platforms/android/cordova/node_modules/util-deprecate/History.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/LICENSE b/platforms/android/cordova/node_modules/util-deprecate/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/LICENSE rename to platforms/android/cordova/node_modules/util-deprecate/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/README.md b/platforms/android/cordova/node_modules/util-deprecate/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/README.md rename to platforms/android/cordova/node_modules/util-deprecate/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/browser.js b/platforms/android/cordova/node_modules/util-deprecate/browser.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/browser.js rename to platforms/android/cordova/node_modules/util-deprecate/browser.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/node.js b/platforms/android/cordova/node_modules/util-deprecate/node.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/util-deprecate/node.js rename to platforms/android/cordova/node_modules/util-deprecate/node.js diff --git a/platforms/android/cordova/node_modules/util-deprecate/package.json b/platforms/android/cordova/node_modules/util-deprecate/package.json new file mode 100644 index 0000000..4ad9893 --- /dev/null +++ b/platforms/android/cordova/node_modules/util-deprecate/package.json @@ -0,0 +1,81 @@ +{ + "_args": [ + [ + "util-deprecate@1.0.2", + "/Users/steveng/repo/cordova/cordova-android/node_modules/plist" + ] + ], + "_from": "util-deprecate@1.0.2", + "_id": "util-deprecate@1.0.2", + "_inCache": true, + "_installable": true, + "_location": "/util-deprecate", + "_nodeVersion": "4.1.2", + "_npmUser": { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "util-deprecate", + "raw": "util-deprecate@1.0.2", + "rawSpec": "1.0.2", + "scope": null, + "spec": "1.0.2", + "type": "version" + }, + "_requiredBy": [ + "/plist" + ], + "_resolved": "http://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", + "_shrinkwrap": null, + "_spec": "util-deprecate@1.0.2", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/plist", + "author": { + "email": "nathan@tootallnate.net", + "name": "Nathan Rajlich", + "url": "http://n8.io/" + }, + "browser": "browser.js", + "bugs": { + "url": "https://github.com/TooTallNate/util-deprecate/issues" + }, + "dependencies": {}, + "description": "The Node.js `util.deprecate()` function with browser support", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", + "tarball": "http://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + }, + "gitHead": "475fb6857cd23fafff20c1be846c1350abf8e6d4", + "homepage": "https://github.com/TooTallNate/util-deprecate", + "keywords": [ + "browser", + "browserify", + "deprecate", + "node", + "util" + ], + "license": "MIT", + "main": "node.js", + "maintainers": [ + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "name": "util-deprecate", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/util-deprecate.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "1.0.2" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/semver/LICENSE b/platforms/android/cordova/node_modules/wrappy/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/semver/LICENSE rename to platforms/android/cordova/node_modules/wrappy/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md b/platforms/android/cordova/node_modules/wrappy/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md rename to platforms/android/cordova/node_modules/wrappy/README.md diff --git a/platforms/android/cordova/node_modules/wrappy/package.json b/platforms/android/cordova/node_modules/wrappy/package.json new file mode 100644 index 0000000..35d4cc7 --- /dev/null +++ b/platforms/android/cordova/node_modules/wrappy/package.json @@ -0,0 +1,78 @@ +{ + "_args": [ + [ + "wrappy@1", + "/Users/steveng/repo/cordova/cordova-android/node_modules/inflight" + ] + ], + "_from": "wrappy@>=1.0.0 <2.0.0", + "_id": "wrappy@1.0.1", + "_inCache": true, + "_installable": true, + "_location": "/wrappy", + "_nodeVersion": "0.10.31", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "2.0.0", + "_phantomChildren": {}, + "_requested": { + "name": "wrappy", + "raw": "wrappy@1", + "rawSpec": "1", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/inflight", + "/once" + ], + "_resolved": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", + "_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", + "_shrinkwrap": null, + "_spec": "wrappy@1", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/inflight", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/npm/wrappy/issues" + }, + "dependencies": {}, + "description": "Callback wrapping utility", + "devDependencies": { + "tap": "^0.4.12" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", + "tarball": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" + }, + "gitHead": "006a8cbac6b99988315834c207896eed71fd069a", + "homepage": "https://github.com/npm/wrappy", + "license": "ISC", + "main": "wrappy.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "wrappy", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/wrappy.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "1.0.1" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js b/platforms/android/cordova/node_modules/wrappy/test/basic.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js rename to platforms/android/cordova/node_modules/wrappy/test/basic.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js b/platforms/android/cordova/node_modules/wrappy/wrappy.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js rename to platforms/android/cordova/node_modules/wrappy/wrappy.js diff --git a/platforms/android/cordova/node_modules/xmlbuilder/.npmignore b/platforms/android/cordova/node_modules/xmlbuilder/.npmignore new file mode 100644 index 0000000..b6ad1f6 --- /dev/null +++ b/platforms/android/cordova/node_modules/xmlbuilder/.npmignore @@ -0,0 +1,5 @@ +.travis.yml +src +test +perf +coverage diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/LICENSE b/platforms/android/cordova/node_modules/xmlbuilder/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/LICENSE rename to platforms/android/cordova/node_modules/xmlbuilder/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/README.md b/platforms/android/cordova/node_modules/xmlbuilder/README.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/README.md rename to platforms/android/cordova/node_modules/xmlbuilder/README.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLAttribute.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLAttribute.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLAttribute.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLAttribute.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLBuilder.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLBuilder.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLBuilder.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLBuilder.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLCData.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLCData.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLCData.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLCData.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLComment.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLComment.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLComment.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLComment.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDAttList.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDAttList.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDAttList.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDAttList.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDElement.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDElement.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDElement.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDElement.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDEntity.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDEntity.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDEntity.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDEntity.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDNotation.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDNotation.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDTDNotation.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDTDNotation.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDeclaration.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDeclaration.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDeclaration.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDeclaration.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDocType.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDocType.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLDocType.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLDocType.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLElement.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLElement.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLElement.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLElement.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLNode.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLNode.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLNode.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLNode.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLRaw.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLRaw.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLRaw.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLRaw.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLStringifier.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLStringifier.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLStringifier.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLStringifier.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLText.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/XMLText.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/XMLText.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/XMLText.js diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/index.js b/platforms/android/cordova/node_modules/xmlbuilder/lib/index.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmlbuilder/lib/index.js rename to platforms/android/cordova/node_modules/xmlbuilder/lib/index.js diff --git a/platforms/android/cordova/node_modules/xmlbuilder/package.json b/platforms/android/cordova/node_modules/xmlbuilder/package.json new file mode 100644 index 0000000..cc32dc4 --- /dev/null +++ b/platforms/android/cordova/node_modules/xmlbuilder/package.json @@ -0,0 +1,89 @@ +{ + "_args": [ + [ + "xmlbuilder@4.0.0", + "/Users/steveng/repo/cordova/cordova-android/node_modules/plist" + ] + ], + "_from": "xmlbuilder@4.0.0", + "_id": "xmlbuilder@4.0.0", + "_inCache": true, + "_installable": true, + "_location": "/xmlbuilder", + "_npmUser": { + "email": "oozcitak@gmail.com", + "name": "oozcitak" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": {}, + "_requested": { + "name": "xmlbuilder", + "raw": "xmlbuilder@4.0.0", + "rawSpec": "4.0.0", + "scope": null, + "spec": "4.0.0", + "type": "version" + }, + "_requiredBy": [ + "/plist" + ], + "_resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.0.0.tgz", + "_shasum": "98b8f651ca30aa624036f127d11cc66dc7b907a3", + "_shrinkwrap": null, + "_spec": "xmlbuilder@4.0.0", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/plist", + "author": { + "email": "oozcitak@gmail.com", + "name": "Ozgur Ozcitak" + }, + "bugs": { + "url": "http://github.com/oozcitak/xmlbuilder-js/issues" + }, + "contributors": [], + "dependencies": { + "lodash": "^3.5.0" + }, + "description": "An XML builder for node.js", + "devDependencies": { + "coffee-coverage": "*", + "coffee-script": "*", + "coveralls": "*", + "istanbul": "*", + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "98b8f651ca30aa624036f127d11cc66dc7b907a3", + "tarball": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.0.0.tgz" + }, + "engines": { + "node": ">=0.8.0" + }, + "gitHead": "ec17840a6705ef666b7d04c771de11df6091fff5", + "homepage": "http://github.com/oozcitak/xmlbuilder-js", + "keywords": [ + "xml", + "xmlbuilder" + ], + "license": "MIT", + "main": "./lib/index", + "maintainers": [ + { + "name": "oozcitak", + "email": "oozcitak@gmail.com" + } + ], + "name": "xmlbuilder", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/oozcitak/xmlbuilder-js.git" + }, + "scripts": { + "postpublish": "rm -rf lib", + "prepublish": "coffee -co lib src", + "test": "mocha && istanbul report text lcov" + }, + "version": "4.0.0" +} diff --git a/platforms/android/cordova/node_modules/xmldom/.npmignore b/platforms/android/cordova/node_modules/xmldom/.npmignore new file mode 100644 index 0000000..b094a44 --- /dev/null +++ b/platforms/android/cordova/node_modules/xmldom/.npmignore @@ -0,0 +1,5 @@ +test +t +travis.yml +.project +changelog diff --git a/platforms/android/cordova/node_modules/xmldom/.travis.yml b/platforms/android/cordova/node_modules/xmldom/.travis.yml new file mode 100644 index 0000000..b95408e --- /dev/null +++ b/platforms/android/cordova/node_modules/xmldom/.travis.yml @@ -0,0 +1,22 @@ +language: node_js + +node_js: + - '0.10' + +branches: + only: + - master + - proof + - travis-ci + +# Not using `npm install --dev` because it is recursive. It will pull in the all +# development dependencies for CoffeeScript. Way too much spew in the Travis CI +# build output. + +before_install: + - npm install + - npm install istanbul coveralls + +env: + global: + - secure: "BxUHTsa1WVANLQoimilbZwa1MCWSdM9hOmPWBE/rsYb7uT/iiqkRXXwnWhKtN5CLvTvIQbiAzq4iyPID0S8UHrnxClYQrOuA6QkrtwgIEuDAmijao/bgxobPOremvkwXcpMGIwzYKyYQQtSEaEIQbqf6gSSKW9dBh/GZ/vfTsqo=" diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/LICENSE b/platforms/android/cordova/node_modules/xmldom/LICENSE similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/LICENSE rename to platforms/android/cordova/node_modules/xmldom/LICENSE diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/__package__.js b/platforms/android/cordova/node_modules/xmldom/__package__.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/__package__.js rename to platforms/android/cordova/node_modules/xmldom/__package__.js diff --git a/platforms/android/cordova/node_modules/xmldom/changelog b/platforms/android/cordova/node_modules/xmldom/changelog new file mode 100644 index 0000000..ab815bb --- /dev/null +++ b/platforms/android/cordova/node_modules/xmldom/changelog @@ -0,0 +1,14 @@ +### Version 0.1.16 + +Sat May 4 14:58:03 UTC 2013 + + * Correctly handle multibyte Unicode greater than two byts. #57. #56. + * Initial unit testing and test coverage. #53. #46. #19. + * Create Bower `component.json` #52. + +### Version 0.1.8 + + * Add: some test case from node-o3-xml(excludes xpath support) + * Fix: remove existed attribute before setting (bug introduced in v0.1.5) + * Fix: index direct access for childNodes and any NodeList collection(not w3c standard) + * Fix: remove last child bug diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/component.json b/platforms/android/cordova/node_modules/xmldom/component.json similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/component.json rename to platforms/android/cordova/node_modules/xmldom/component.json diff --git a/platforms/android/cordova/node_modules/xmldom/dom-parser.js b/platforms/android/cordova/node_modules/xmldom/dom-parser.js new file mode 100644 index 0000000..08c2f70 --- /dev/null +++ b/platforms/android/cordova/node_modules/xmldom/dom-parser.js @@ -0,0 +1,249 @@ +function DOMParser(options){ + this.options = options ||{locator:{}}; + +} +DOMParser.prototype.parseFromString = function(source,mimeType){ + var options = this.options; + var sax = new XMLReader(); + var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler + var errorHandler = options.errorHandler; + var locator = options.locator; + var defaultNSMap = options.xmlns||{}; + var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"} + if(locator){ + domBuilder.setDocumentLocator(locator) + } + + sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator); + sax.domBuilder = options.domBuilder || domBuilder; + if(/\/x?html?$/.test(mimeType)){ + entityMap.nbsp = '\xa0'; + entityMap.copy = '\xa9'; + defaultNSMap['']= 'http://www.w3.org/1999/xhtml'; + } + defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace'; + if(source){ + sax.parse(source,defaultNSMap,entityMap); + }else{ + sax.errorHandler.error("invalid document source"); + } + return domBuilder.document; +} +function buildErrorHandler(errorImpl,domBuilder,locator){ + if(!errorImpl){ + if(domBuilder instanceof DOMHandler){ + return domBuilder; + } + errorImpl = domBuilder ; + } + var errorHandler = {} + var isCallback = errorImpl instanceof Function; + locator = locator||{} + function build(key){ + var fn = errorImpl[key]; + if(!fn && isCallback){ + fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl; + } + errorHandler[key] = fn && function(msg){ + fn('[xmldom '+key+']\t'+msg+_locator(locator)); + }||function(){}; + } + build('warning'); + build('error'); + build('fatalError'); + return errorHandler; +} + +//console.log('#\n\n\n\n\n\n\n####') +/** + * +ContentHandler+ErrorHandler + * +LexicalHandler+EntityResolver2 + * -DeclHandler-DTDHandler + * + * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler + * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2 + * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html + */ +function DOMHandler() { + this.cdata = false; +} +function position(locator,node){ + node.lineNumber = locator.lineNumber; + node.columnNumber = locator.columnNumber; +} +/** + * @see org.xml.sax.ContentHandler#startDocument + * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html + */ +DOMHandler.prototype = { + startDocument : function() { + this.document = new DOMImplementation().createDocument(null, null, null); + if (this.locator) { + this.document.documentURI = this.locator.systemId; + } + }, + startElement:function(namespaceURI, localName, qName, attrs) { + var doc = this.document; + var el = doc.createElementNS(namespaceURI, qName||localName); + var len = attrs.length; + appendElement(this, el); + this.currentElement = el; + + this.locator && position(this.locator,el) + for (var i = 0 ; i < len; i++) { + var namespaceURI = attrs.getURI(i); + var value = attrs.getValue(i); + var qName = attrs.getQName(i); + var attr = doc.createAttributeNS(namespaceURI, qName); + if( attr.getOffset){ + position(attr.getOffset(1),attr) + } + attr.value = attr.nodeValue = value; + el.setAttributeNode(attr) + } + }, + endElement:function(namespaceURI, localName, qName) { + var current = this.currentElement + var tagName = current.tagName; + this.currentElement = current.parentNode; + }, + startPrefixMapping:function(prefix, uri) { + }, + endPrefixMapping:function(prefix) { + }, + processingInstruction:function(target, data) { + var ins = this.document.createProcessingInstruction(target, data); + this.locator && position(this.locator,ins) + appendElement(this, ins); + }, + ignorableWhitespace:function(ch, start, length) { + }, + characters:function(chars, start, length) { + chars = _toString.apply(this,arguments) + //console.log(chars) + if(this.currentElement && chars){ + if (this.cdata) { + var charNode = this.document.createCDATASection(chars); + this.currentElement.appendChild(charNode); + } else { + var charNode = this.document.createTextNode(chars); + this.currentElement.appendChild(charNode); + } + this.locator && position(this.locator,charNode) + } + }, + skippedEntity:function(name) { + }, + endDocument:function() { + this.document.normalize(); + }, + setDocumentLocator:function (locator) { + if(this.locator = locator){// && !('lineNumber' in locator)){ + locator.lineNumber = 0; + } + }, + //LexicalHandler + comment:function(chars, start, length) { + chars = _toString.apply(this,arguments) + var comm = this.document.createComment(chars); + this.locator && position(this.locator,comm) + appendElement(this, comm); + }, + + startCDATA:function() { + //used in characters() methods + this.cdata = true; + }, + endCDATA:function() { + this.cdata = false; + }, + + startDTD:function(name, publicId, systemId) { + var impl = this.document.implementation; + if (impl && impl.createDocumentType) { + var dt = impl.createDocumentType(name, publicId, systemId); + this.locator && position(this.locator,dt) + appendElement(this, dt); + } + }, + /** + * @see org.xml.sax.ErrorHandler + * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html + */ + warning:function(error) { + console.warn('[xmldom warning]\t'+error,_locator(this.locator)); + }, + error:function(error) { + console.error('[xmldom error]\t'+error,_locator(this.locator)); + }, + fatalError:function(error) { + console.error('[xmldom fatalError]\t'+error,_locator(this.locator)); + throw error; + } +} +function _locator(l){ + if(l){ + return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']' + } +} +function _toString(chars,start,length){ + if(typeof chars == 'string'){ + return chars.substr(start,length) + }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)") + if(chars.length >= start+length || start){ + return new java.lang.String(chars,start,length)+''; + } + return chars; + } +} + +/* + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html + * used method of org.xml.sax.ext.LexicalHandler: + * #comment(chars, start, length) + * #startCDATA() + * #endCDATA() + * #startDTD(name, publicId, systemId) + * + * + * IGNORED method of org.xml.sax.ext.LexicalHandler: + * #endDTD() + * #startEntity(name) + * #endEntity(name) + * + * + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html + * IGNORED method of org.xml.sax.ext.DeclHandler + * #attributeDecl(eName, aName, type, mode, value) + * #elementDecl(name, model) + * #externalEntityDecl(name, publicId, systemId) + * #internalEntityDecl(name, value) + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html + * IGNORED method of org.xml.sax.EntityResolver2 + * #resolveEntity(String name,String publicId,String baseURI,String systemId) + * #resolveEntity(publicId, systemId) + * #getExternalSubset(name, baseURI) + * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html + * IGNORED method of org.xml.sax.DTDHandler + * #notationDecl(name, publicId, systemId) {}; + * #unparsedEntityDecl(name, publicId, systemId, notationName) {}; + */ +"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){ + DOMHandler.prototype[key] = function(){return null} +}) + +/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ +function appendElement (hander,node) { + if (!hander.currentElement) { + hander.document.appendChild(node); + } else { + hander.currentElement.appendChild(node); + } +}//appendChild and setAttributeNS are preformance key + +if(typeof require == 'function'){ + var XMLReader = require('./sax').XMLReader; + var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation; + exports.XMLSerializer = require('./dom').XMLSerializer ; + exports.DOMParser = DOMParser; +} diff --git a/platforms/android/cordova/node_modules/xmldom/dom.js b/platforms/android/cordova/node_modules/xmldom/dom.js new file mode 100644 index 0000000..460a1be --- /dev/null +++ b/platforms/android/cordova/node_modules/xmldom/dom.js @@ -0,0 +1,1147 @@ +/* + * DOM Level 2 + * Object DOMException + * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html + */ + +function copy(src,dest){ + for(var p in src){ + dest[p] = src[p]; + } +} +/** +^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));? +^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));? + */ +function _extends(Class,Super){ + var pt = Class.prototype; + if(Object.create){ + var ppt = Object.create(Super.prototype) + pt.__proto__ = ppt; + } + if(!(pt instanceof Super)){ + function t(){}; + t.prototype = Super.prototype; + t = new t(); + copy(pt,t); + Class.prototype = pt = t; + } + if(pt.constructor != Class){ + if(typeof Class != 'function'){ + console.error("unknow Class:"+Class) + } + pt.constructor = Class + } +} +var htmlns = 'http://www.w3.org/1999/xhtml' ; +// Node Types +var NodeType = {} +var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1; +var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2; +var TEXT_NODE = NodeType.TEXT_NODE = 3; +var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4; +var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5; +var ENTITY_NODE = NodeType.ENTITY_NODE = 6; +var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7; +var COMMENT_NODE = NodeType.COMMENT_NODE = 8; +var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9; +var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10; +var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11; +var NOTATION_NODE = NodeType.NOTATION_NODE = 12; + +// ExceptionCode +var ExceptionCode = {} +var ExceptionMessage = {}; +var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1); +var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2); +var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3); +var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4); +var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5); +var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6); +var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7); +var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8); +var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9); +var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10); +//level2 +var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11); +var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12); +var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13); +var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14); +var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15); + + +function DOMException(code, message) { + if(message instanceof Error){ + var error = message; + }else{ + error = this; + Error.call(this, ExceptionMessage[code]); + this.message = ExceptionMessage[code]; + if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException); + } + error.code = code; + if(message) this.message = this.message + ": " + message; + return error; +}; +DOMException.prototype = Error.prototype; +copy(ExceptionCode,DOMException) +/** + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177 + * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. + * The items in the NodeList are accessible via an integral index, starting from 0. + */ +function NodeList() { +}; +NodeList.prototype = { + /** + * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. + * @standard level1 + */ + length:0, + /** + * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null. + * @standard level1 + * @param index unsigned long + * Index into the collection. + * @return Node + * The node at the indexth position in the NodeList, or null if that is not a valid index. + */ + item: function(index) { + return this[index] || null; + }, + toString:function(){ + for(var buf = [], i = 0;i=0){ + var lastIndex = list.length-1 + while(i0 || key == 'xmlns'){ +// return null; +// } + var i = this.length; + while(i--){ + var attr = this[i]; + if(attr.nodeName == key){ + return attr; + } + } + }, + setNamedItem: function(attr) { + var el = attr.ownerElement; + if(el && el!=this._ownerElement){ + throw new DOMException(INUSE_ATTRIBUTE_ERR); + } + var oldAttr = this.getNamedItem(attr.nodeName); + _addNamedNode(this._ownerElement,this,attr,oldAttr); + return oldAttr; + }, + /* returns Node */ + setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR + var el = attr.ownerElement, oldAttr; + if(el && el!=this._ownerElement){ + throw new DOMException(INUSE_ATTRIBUTE_ERR); + } + oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName); + _addNamedNode(this._ownerElement,this,attr,oldAttr); + return oldAttr; + }, + + /* returns Node */ + removeNamedItem: function(key) { + var attr = this.getNamedItem(key); + _removeNamedNode(this._ownerElement,this,attr); + return attr; + + + },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR + + //for level2 + removeNamedItemNS:function(namespaceURI,localName){ + var attr = this.getNamedItemNS(namespaceURI,localName); + _removeNamedNode(this._ownerElement,this,attr); + return attr; + }, + getNamedItemNS: function(namespaceURI, localName) { + var i = this.length; + while(i--){ + var node = this[i]; + if(node.localName == localName && node.namespaceURI == namespaceURI){ + return node; + } + } + return null; + } +}; +/** + * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 + */ +function DOMImplementation(/* Object */ features) { + this._features = {}; + if (features) { + for (var feature in features) { + this._features = features[feature]; + } + } +}; + +DOMImplementation.prototype = { + hasFeature: function(/* string */ feature, /* string */ version) { + var versions = this._features[feature.toLowerCase()]; + if (versions && (!version || version in versions)) { + return true; + } else { + return false; + } + }, + // Introduced in DOM Level 2: + createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR + var doc = new Document(); + doc.implementation = this; + doc.childNodes = new NodeList(); + doc.doctype = doctype; + if(doctype){ + doc.appendChild(doctype); + } + if(qualifiedName){ + var root = doc.createElementNS(namespaceURI,qualifiedName); + doc.appendChild(root); + } + return doc; + }, + // Introduced in DOM Level 2: + createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR + var node = new DocumentType(); + node.name = qualifiedName; + node.nodeName = qualifiedName; + node.publicId = publicId; + node.systemId = systemId; + // Introduced in DOM Level 2: + //readonly attribute DOMString internalSubset; + + //TODO:.. + // readonly attribute NamedNodeMap entities; + // readonly attribute NamedNodeMap notations; + return node; + } +}; + + +/** + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247 + */ + +function Node() { +}; + +Node.prototype = { + firstChild : null, + lastChild : null, + previousSibling : null, + nextSibling : null, + attributes : null, + parentNode : null, + childNodes : null, + ownerDocument : null, + nodeValue : null, + namespaceURI : null, + prefix : null, + localName : null, + // Modified in DOM Level 2: + insertBefore:function(newChild, refChild){//raises + return _insertBefore(this,newChild,refChild); + }, + replaceChild:function(newChild, oldChild){//raises + this.insertBefore(newChild,oldChild); + if(oldChild){ + this.removeChild(oldChild); + } + }, + removeChild:function(oldChild){ + return _removeChild(this,oldChild); + }, + appendChild:function(newChild){ + return this.insertBefore(newChild,null); + }, + hasChildNodes:function(){ + return this.firstChild != null; + }, + cloneNode:function(deep){ + return cloneNode(this.ownerDocument||this,this,deep); + }, + // Modified in DOM Level 2: + normalize:function(){ + var child = this.firstChild; + while(child){ + var next = child.nextSibling; + if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){ + this.removeChild(next); + child.appendData(next.data); + }else{ + child.normalize(); + child = next; + } + } + }, + // Introduced in DOM Level 2: + isSupported:function(feature, version){ + return this.ownerDocument.implementation.hasFeature(feature,version); + }, + // Introduced in DOM Level 2: + hasAttributes:function(){ + return this.attributes.length>0; + }, + lookupPrefix:function(namespaceURI){ + var el = this; + while(el){ + var map = el._nsMap; + //console.dir(map) + if(map){ + for(var n in map){ + if(map[n] == namespaceURI){ + return n; + } + } + } + el = el.nodeType == 2?el.ownerDocument : el.parentNode; + } + return null; + }, + // Introduced in DOM Level 3: + lookupNamespaceURI:function(prefix){ + var el = this; + while(el){ + var map = el._nsMap; + //console.dir(map) + if(map){ + if(prefix in map){ + return map[prefix] ; + } + } + el = el.nodeType == 2?el.ownerDocument : el.parentNode; + } + return null; + }, + // Introduced in DOM Level 3: + isDefaultNamespace:function(namespaceURI){ + var prefix = this.lookupPrefix(namespaceURI); + return prefix == null; + } +}; + + +function _xmlEncoder(c){ + return c == '<' && '<' || + c == '>' && '>' || + c == '&' && '&' || + c == '"' && '"' || + '&#'+c.charCodeAt()+';' +} + + +copy(NodeType,Node); +copy(NodeType,Node.prototype); + +/** + * @param callback return true for continue,false for break + * @return boolean true: break visit; + */ +function _visitNode(node,callback){ + if(callback(node)){ + return true; + } + if(node = node.firstChild){ + do{ + if(_visitNode(node,callback)){return true} + }while(node=node.nextSibling) + } +} + + + +function Document(){ +} +function _onAddAttribute(doc,el,newAttr){ + doc && doc._inc++; + var ns = newAttr.namespaceURI ; + if(ns == 'http://www.w3.org/2000/xmlns/'){ + //update namespace + el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value + } +} +function _onRemoveAttribute(doc,el,newAttr,remove){ + doc && doc._inc++; + var ns = newAttr.namespaceURI ; + if(ns == 'http://www.w3.org/2000/xmlns/'){ + //update namespace + delete el._nsMap[newAttr.prefix?newAttr.localName:''] + } +} +function _onUpdateChild(doc,el,newChild){ + if(doc && doc._inc){ + doc._inc++; + //update childNodes + var cs = el.childNodes; + if(newChild){ + cs[cs.length++] = newChild; + }else{ + //console.log(1) + var child = el.firstChild; + var i = 0; + while(child){ + cs[i++] = child; + child =child.nextSibling; + } + cs.length = i; + } + } +} + +/** + * attributes; + * children; + * + * writeable properties: + * nodeValue,Attr:value,CharacterData:data + * prefix + */ +function _removeChild(parentNode,child){ + var previous = child.previousSibling; + var next = child.nextSibling; + if(previous){ + previous.nextSibling = next; + }else{ + parentNode.firstChild = next + } + if(next){ + next.previousSibling = previous; + }else{ + parentNode.lastChild = previous; + } + _onUpdateChild(parentNode.ownerDocument,parentNode); + return child; +} +/** + * preformance key(refChild == null) + */ +function _insertBefore(parentNode,newChild,nextChild){ + var cp = newChild.parentNode; + if(cp){ + cp.removeChild(newChild);//remove and update + } + if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ + var newFirst = newChild.firstChild; + if (newFirst == null) { + return newChild; + } + var newLast = newChild.lastChild; + }else{ + newFirst = newLast = newChild; + } + var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild; + + newFirst.previousSibling = pre; + newLast.nextSibling = nextChild; + + + if(pre){ + pre.nextSibling = newFirst; + }else{ + parentNode.firstChild = newFirst; + } + if(nextChild == null){ + parentNode.lastChild = newLast; + }else{ + nextChild.previousSibling = newLast; + } + do{ + newFirst.parentNode = parentNode; + }while(newFirst !== newLast && (newFirst= newFirst.nextSibling)) + _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode); + //console.log(parentNode.lastChild.nextSibling == null) + if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { + newChild.firstChild = newChild.lastChild = null; + } + return newChild; +} +function _appendSingleChild(parentNode,newChild){ + var cp = newChild.parentNode; + if(cp){ + var pre = parentNode.lastChild; + cp.removeChild(newChild);//remove and update + var pre = parentNode.lastChild; + } + var pre = parentNode.lastChild; + newChild.parentNode = parentNode; + newChild.previousSibling = pre; + newChild.nextSibling = null; + if(pre){ + pre.nextSibling = newChild; + }else{ + parentNode.firstChild = newChild; + } + parentNode.lastChild = newChild; + _onUpdateChild(parentNode.ownerDocument,parentNode,newChild); + return newChild; + //console.log("__aa",parentNode.lastChild.nextSibling == null) +} +Document.prototype = { + //implementation : null, + nodeName : '#document', + nodeType : DOCUMENT_NODE, + doctype : null, + documentElement : null, + _inc : 1, + + insertBefore : function(newChild, refChild){//raises + if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){ + var child = newChild.firstChild; + while(child){ + var next = child.nextSibling; + this.insertBefore(child,refChild); + child = next; + } + return newChild; + } + if(this.documentElement == null && newChild.nodeType == 1){ + this.documentElement = newChild; + } + + return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild; + }, + removeChild : function(oldChild){ + if(this.documentElement == oldChild){ + this.documentElement = null; + } + return _removeChild(this,oldChild); + }, + // Introduced in DOM Level 2: + importNode : function(importedNode,deep){ + return importNode(this,importedNode,deep); + }, + // Introduced in DOM Level 2: + getElementById : function(id){ + var rtv = null; + _visitNode(this.documentElement,function(node){ + if(node.nodeType == 1){ + if(node.getAttribute('id') == id){ + rtv = node; + return true; + } + } + }) + return rtv; + }, + + //document factory method: + createElement : function(tagName){ + var node = new Element(); + node.ownerDocument = this; + node.nodeName = tagName; + node.tagName = tagName; + node.childNodes = new NodeList(); + var attrs = node.attributes = new NamedNodeMap(); + attrs._ownerElement = node; + return node; + }, + createDocumentFragment : function(){ + var node = new DocumentFragment(); + node.ownerDocument = this; + node.childNodes = new NodeList(); + return node; + }, + createTextNode : function(data){ + var node = new Text(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createComment : function(data){ + var node = new Comment(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createCDATASection : function(data){ + var node = new CDATASection(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createProcessingInstruction : function(target,data){ + var node = new ProcessingInstruction(); + node.ownerDocument = this; + node.tagName = node.target = target; + node.nodeValue= node.data = data; + return node; + }, + createAttribute : function(name){ + var node = new Attr(); + node.ownerDocument = this; + node.name = name; + node.nodeName = name; + node.localName = name; + node.specified = true; + return node; + }, + createEntityReference : function(name){ + var node = new EntityReference(); + node.ownerDocument = this; + node.nodeName = name; + return node; + }, + // Introduced in DOM Level 2: + createElementNS : function(namespaceURI,qualifiedName){ + var node = new Element(); + var pl = qualifiedName.split(':'); + var attrs = node.attributes = new NamedNodeMap(); + node.childNodes = new NodeList(); + node.ownerDocument = this; + node.nodeName = qualifiedName; + node.tagName = qualifiedName; + node.namespaceURI = namespaceURI; + if(pl.length == 2){ + node.prefix = pl[0]; + node.localName = pl[1]; + }else{ + //el.prefix = null; + node.localName = qualifiedName; + } + attrs._ownerElement = node; + return node; + }, + // Introduced in DOM Level 2: + createAttributeNS : function(namespaceURI,qualifiedName){ + var node = new Attr(); + var pl = qualifiedName.split(':'); + node.ownerDocument = this; + node.nodeName = qualifiedName; + node.name = qualifiedName; + node.namespaceURI = namespaceURI; + node.specified = true; + if(pl.length == 2){ + node.prefix = pl[0]; + node.localName = pl[1]; + }else{ + //el.prefix = null; + node.localName = qualifiedName; + } + return node; + } +}; +_extends(Document,Node); + + +function Element() { + this._nsMap = {}; +}; +Element.prototype = { + nodeType : ELEMENT_NODE, + hasAttribute : function(name){ + return this.getAttributeNode(name)!=null; + }, + getAttribute : function(name){ + var attr = this.getAttributeNode(name); + return attr && attr.value || ''; + }, + getAttributeNode : function(name){ + return this.attributes.getNamedItem(name); + }, + setAttribute : function(name, value){ + var attr = this.ownerDocument.createAttribute(name); + attr.value = attr.nodeValue = "" + value; + this.setAttributeNode(attr) + }, + removeAttribute : function(name){ + var attr = this.getAttributeNode(name) + attr && this.removeAttributeNode(attr); + }, + + //four real opeartion method + appendChild:function(newChild){ + if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ + return this.insertBefore(newChild,null); + }else{ + return _appendSingleChild(this,newChild); + } + }, + setAttributeNode : function(newAttr){ + return this.attributes.setNamedItem(newAttr); + }, + setAttributeNodeNS : function(newAttr){ + return this.attributes.setNamedItemNS(newAttr); + }, + removeAttributeNode : function(oldAttr){ + return this.attributes.removeNamedItem(oldAttr.nodeName); + }, + //get real attribute name,and remove it by removeAttributeNode + removeAttributeNS : function(namespaceURI, localName){ + var old = this.getAttributeNodeNS(namespaceURI, localName); + old && this.removeAttributeNode(old); + }, + + hasAttributeNS : function(namespaceURI, localName){ + return this.getAttributeNodeNS(namespaceURI, localName)!=null; + }, + getAttributeNS : function(namespaceURI, localName){ + var attr = this.getAttributeNodeNS(namespaceURI, localName); + return attr && attr.value || ''; + }, + setAttributeNS : function(namespaceURI, qualifiedName, value){ + var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); + attr.value = attr.nodeValue = "" + value; + this.setAttributeNode(attr) + }, + getAttributeNodeNS : function(namespaceURI, localName){ + return this.attributes.getNamedItemNS(namespaceURI, localName); + }, + + getElementsByTagName : function(tagName){ + return new LiveNodeList(this,function(base){ + var ls = []; + _visitNode(base,function(node){ + if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){ + ls.push(node); + } + }); + return ls; + }); + }, + getElementsByTagNameNS : function(namespaceURI, localName){ + return new LiveNodeList(this,function(base){ + var ls = []; + _visitNode(base,function(node){ + if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){ + ls.push(node); + } + }); + return ls; + }); + } +}; +Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName; +Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS; + + +_extends(Element,Node); +function Attr() { +}; +Attr.prototype.nodeType = ATTRIBUTE_NODE; +_extends(Attr,Node); + + +function CharacterData() { +}; +CharacterData.prototype = { + data : '', + substringData : function(offset, count) { + return this.data.substring(offset, offset+count); + }, + appendData: function(text) { + text = this.data+text; + this.nodeValue = this.data = text; + this.length = text.length; + }, + insertData: function(offset,text) { + this.replaceData(offset,0,text); + + }, + appendChild:function(newChild){ + //if(!(newChild instanceof CharacterData)){ + throw new Error(ExceptionMessage[3]) + //} + return Node.prototype.appendChild.apply(this,arguments) + }, + deleteData: function(offset, count) { + this.replaceData(offset,count,""); + }, + replaceData: function(offset, count, text) { + var start = this.data.substring(0,offset); + var end = this.data.substring(offset+count); + text = start + text + end; + this.nodeValue = this.data = text; + this.length = text.length; + } +} +_extends(CharacterData,Node); +function Text() { +}; +Text.prototype = { + nodeName : "#text", + nodeType : TEXT_NODE, + splitText : function(offset) { + var text = this.data; + var newText = text.substring(offset); + text = text.substring(0, offset); + this.data = this.nodeValue = text; + this.length = text.length; + var newNode = this.ownerDocument.createTextNode(newText); + if(this.parentNode){ + this.parentNode.insertBefore(newNode, this.nextSibling); + } + return newNode; + } +} +_extends(Text,CharacterData); +function Comment() { +}; +Comment.prototype = { + nodeName : "#comment", + nodeType : COMMENT_NODE +} +_extends(Comment,CharacterData); + +function CDATASection() { +}; +CDATASection.prototype = { + nodeName : "#cdata-section", + nodeType : CDATA_SECTION_NODE +} +_extends(CDATASection,CharacterData); + + +function DocumentType() { +}; +DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE; +_extends(DocumentType,Node); + +function Notation() { +}; +Notation.prototype.nodeType = NOTATION_NODE; +_extends(Notation,Node); + +function Entity() { +}; +Entity.prototype.nodeType = ENTITY_NODE; +_extends(Entity,Node); + +function EntityReference() { +}; +EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE; +_extends(EntityReference,Node); + +function DocumentFragment() { +}; +DocumentFragment.prototype.nodeName = "#document-fragment"; +DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE; +_extends(DocumentFragment,Node); + + +function ProcessingInstruction() { +} +ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE; +_extends(ProcessingInstruction,Node); +function XMLSerializer(){} +XMLSerializer.prototype.serializeToString = function(node,attributeSorter){ + return node.toString(attributeSorter); +} +Node.prototype.toString =function(attributeSorter){ + var buf = []; + serializeToString(this,buf,attributeSorter); + return buf.join(''); +} +function serializeToString(node,buf,attributeSorter,isHTML){ + switch(node.nodeType){ + case ELEMENT_NODE: + var attrs = node.attributes; + var len = attrs.length; + var child = node.firstChild; + var nodeName = node.tagName; + isHTML = (htmlns === node.namespaceURI) ||isHTML + buf.push('<',nodeName); + if(attributeSorter){ + buf.sort.apply(attrs, attributeSorter); + } + for(var i=0;i'); + //if is cdata child node + if(isHTML && /^script$/i.test(nodeName)){ + if(child){ + buf.push(child.data); + } + }else{ + while(child){ + serializeToString(child,buf,attributeSorter,isHTML); + child = child.nextSibling; + } + } + buf.push(''); + }else{ + buf.push('/>'); + } + return; + case DOCUMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: + var child = node.firstChild; + while(child){ + serializeToString(child,buf,attributeSorter,isHTML); + child = child.nextSibling; + } + return; + case ATTRIBUTE_NODE: + return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"'); + case TEXT_NODE: + return buf.push(node.data.replace(/[<&]/g,_xmlEncoder)); + case CDATA_SECTION_NODE: + return buf.push( ''); + case COMMENT_NODE: + return buf.push( ""); + case DOCUMENT_TYPE_NODE: + var pubid = node.publicId; + var sysid = node.systemId; + buf.push(''); + }else if(sysid && sysid!='.'){ + buf.push(' SYSTEM "',sysid,'">'); + }else{ + var sub = node.internalSubset; + if(sub){ + buf.push(" [",sub,"]"); + } + buf.push(">"); + } + return; + case PROCESSING_INSTRUCTION_NODE: + return buf.push( ""); + case ENTITY_REFERENCE_NODE: + return buf.push( '&',node.nodeName,';'); + //case ENTITY_NODE: + //case NOTATION_NODE: + default: + buf.push('??',node.nodeName); + } +} +function importNode(doc,node,deep){ + var node2; + switch (node.nodeType) { + case ELEMENT_NODE: + node2 = node.cloneNode(false); + node2.ownerDocument = doc; + //var attrs = node2.attributes; + //var len = attrs.length; + //for(var i=0;i=0.1.0 <0.2.0", + "_id": "xmldom@0.1.22", + "_inCache": true, + "_installable": true, + "_location": "/xmldom", + "_nodeVersion": "5.5.0", + "_npmUser": { + "email": "jindw@xidea.org", + "name": "jindw" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "xmldom", + "raw": "xmldom@0.1.x", + "rawSpec": "0.1.x", + "scope": null, + "spec": ">=0.1.0 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/plist" + ], + "_resolved": "http://registry.npmjs.org/xmldom/-/xmldom-0.1.22.tgz", + "_shasum": "10de4e5e964981f03c8cc72fadc08d14b6c3aa26", + "_shrinkwrap": null, + "_spec": "xmldom@0.1.x", + "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/plist", + "author": { + "email": "jindw@xidea.org", + "name": "jindw", + "url": "http://www.xidea.org" + }, + "bugs": { + "email": "jindw@xidea.org", + "url": "http://github.com/jindw/xmldom/issues" + }, + "contributors": [ + { + "name": "Yaron Naveh", + "email": "yaronn01@gmail.com", + "url": "http://webservices20.blogspot.com/" + }, + { + "name": "Harutyun Amirjanyan", + "email": "amirjanyan@gmail.com", + "url": "https://github.com/nightwing" + }, + { + "name": "Alan Gutierrez", + "email": "alan@prettyrobots.com", + "url": "http://www.prettyrobots.com/" + } + ], + "dependencies": {}, + "description": "A W3C Standard XML DOM(Level2 CORE) implementation and parser(DOMParser/XMLSerializer).", + "devDependencies": { + "proof": "0.0.28" + }, + "directories": {}, + "dist": { + "shasum": "10de4e5e964981f03c8cc72fadc08d14b6c3aa26", + "tarball": "http://registry.npmjs.org/xmldom/-/xmldom-0.1.22.tgz" + }, + "engines": { + "node": ">=0.1" + }, + "gitHead": "29a83b315aef56c156602286b2d884a3b4c2521f", + "homepage": "https://github.com/jindw/xmldom", + "keywords": [ + "DOMParser", + "XMLSerializer", + "dom", + "javascript", + "parser", + "w3c", + "xml" + ], + "licenses": [ + { + "type": "LGPL", + "url": "http://www.gnu.org/licenses/lgpl.html", + "MIT": "http://opensource.org/licenses/MIT" + } + ], + "main": "./dom-parser.js", + "maintainers": [ + { + "name": "jindw", + "email": "jindw@xidea.org" + }, + { + "name": "yaron", + "email": "yaronn01@gmail.com" + }, + { + "name": "bigeasy", + "email": "alan@prettyrobots.com" + }, + { + "name": "kethinov", + "email": "kethinov@gmail.com" + }, + { + "name": "jinjinyun", + "email": "jinyun.jin@gmail.com" + } + ], + "name": "xmldom", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/jindw/xmldom.git" + }, + "scripts": { + "test": "proof platform win32 && proof test */*/*.t.js || t/test" + }, + "version": "0.1.22" +} diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/readme.md b/platforms/android/cordova/node_modules/xmldom/readme.md similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/readme.md rename to platforms/android/cordova/node_modules/xmldom/readme.md diff --git a/platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/sax.js b/platforms/android/cordova/node_modules/xmldom/sax.js similarity index 100% rename from platforms/android/cordova/node_modules/cordova-common/node_modules/plist/node_modules/xmldom/sax.js rename to platforms/android/cordova/node_modules/xmldom/sax.js diff --git a/platforms/android/cordova/version b/platforms/android/cordova/version index 0778301..2a55fb9 100644 --- a/platforms/android/cordova/version +++ b/platforms/android/cordova/version @@ -20,7 +20,7 @@ */ // Coho updates this line: -var VERSION = "5.1.0"; +var VERSION = "5.1.1"; module.exports.version = VERSION; diff --git a/platforms/android/platform_www/cordova-js-src/platform.js b/platforms/android/platform_www/cordova-js-src/platform.js index 0706a34..2bfd024 100644 --- a/platforms/android/platform_www/cordova-js-src/platform.js +++ b/platforms/android/platform_www/cordova-js-src/platform.js @@ -19,6 +19,9 @@ * */ +// The last resume event that was received that had the result of a plugin call. +var lastResumeEvent = null; + module.exports = { id: 'android', bootstrap: function() { @@ -58,6 +61,19 @@ module.exports = { bindButtonChannel('volumeup'); bindButtonChannel('volumedown'); + // The resume event is not "sticky", but it is possible that the event + // will contain the result of a plugin call. We need to ensure that the + // plugin result is delivered even after the event is fired (CB-10498) + var cordovaAddEventListener = document.addEventListener; + + document.addEventListener = function(evt, handler, capture) { + cordovaAddEventListener(evt, handler, capture); + + if (evt === 'resume' && lastResumeEvent) { + handler(lastResumeEvent); + } + }; + // Let native code know we are all done on the JS side. // Native code will then un-hide the WebView. channel.onCordovaReady.subscribe(function() { @@ -96,6 +112,10 @@ function onMessageFromNative(msg) { } msg.pendingResult.result = res; } + + // Save the plugin result so that it can be delivered to the js + // even if they miss the initial firing of the event + lastResumeEvent = msg; } cordova.fireDocumentEvent(action, msg); break; diff --git a/platforms/android/platform_www/cordova.js b/platforms/android/platform_www/cordova.js index ece529c..e94e0f7 100644 --- a/platforms/android/platform_www/cordova.js +++ b/platforms/android/platform_www/cordova.js @@ -1,5 +1,5 @@ // Platform: android -// ded62dda172755defaf75378ed007dc05730ec22 +// c517ca811b4948b630e0b74dbae6c9637939da24 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -19,7 +19,7 @@ under the License. */ ;(function() { -var PLATFORM_VERSION_BUILD_LABEL = '5.1.0'; +var PLATFORM_VERSION_BUILD_LABEL = '5.1.1'; // file: src/scripts/require.js /*jshint -W079 */ @@ -1614,6 +1614,9 @@ exports.reset(); // file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/platform.js define("cordova/platform", function(require, exports, module) { +// The last resume event that was received that had the result of a plugin call. +var lastResumeEvent = null; + module.exports = { id: 'android', bootstrap: function() { @@ -1653,6 +1656,19 @@ module.exports = { bindButtonChannel('volumeup'); bindButtonChannel('volumedown'); + // The resume event is not "sticky", but it is possible that the event + // will contain the result of a plugin call. We need to ensure that the + // plugin result is delivered even after the event is fired (CB-10498) + var cordovaAddEventListener = document.addEventListener; + + document.addEventListener = function(evt, handler, capture) { + cordovaAddEventListener(evt, handler, capture); + + if (evt === 'resume' && lastResumeEvent) { + handler(lastResumeEvent); + } + }; + // Let native code know we are all done on the JS side. // Native code will then un-hide the WebView. channel.onCordovaReady.subscribe(function() { @@ -1691,6 +1707,10 @@ function onMessageFromNative(msg) { } msg.pendingResult.result = res; } + + // Save the plugin result so that it can be delivered to the js + // even if they miss the initial firing of the event + lastResumeEvent = msg; } cordova.fireDocumentEvent(action, msg); break; diff --git a/platforms/android/platform_www/cordova_plugins.js b/platforms/android/platform_www/cordova_plugins.js index 23d5bd2..301549e 100644 --- a/platforms/android/platform_www/cordova_plugins.js +++ b/platforms/android/platform_www/cordova_plugins.js @@ -1,16 +1,80 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { module.exports = [ { - "file": "plugins/cordova-plugin-geolocation/www/android/geolocation.js", - "id": "cordova-plugin-geolocation.geolocation", + "file": "plugins/cordova-plugin-whitelist/whitelist.js", + "id": "cordova-plugin-whitelist.whitelist", + "runs": true + }, + { + "file": "plugins/cordova-plugin-device/www/device.js", + "id": "cordova-plugin-device.device", "clobbers": [ - "navigator.geolocation" + "device" ] }, { - "file": "plugins/cordova-plugin-geolocation/www/PositionError.js", - "id": "cordova-plugin-geolocation.PositionError", - "runs": true + "file": "plugins/cordova-plugin-camera/www/CameraConstants.js", + "id": "cordova-plugin-camera.Camera", + "clobbers": [ + "Camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js", + "id": "cordova-plugin-camera.CameraPopoverOptions", + "clobbers": [ + "CameraPopoverOptions" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/Camera.js", + "id": "cordova-plugin-camera.camera", + "clobbers": [ + "navigator.camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverHandle.js", + "id": "cordova-plugin-camera.CameraPopoverHandle", + "clobbers": [ + "CameraPopoverHandle" + ] + }, + { + "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", + "id": "cordova-plugin-splashscreen.SplashScreen", + "clobbers": [ + "navigator.splashscreen" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/network.js", + "id": "cordova-plugin-network-information.network", + "clobbers": [ + "navigator.connection", + "navigator.network.connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/Connection.js", + "id": "cordova-plugin-network-information.Connection", + "clobbers": [ + "Connection" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/notification.js", + "id": "cordova-plugin-dialogs.notification", + "merges": [ + "navigator.notification" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/android/notification.js", + "id": "cordova-plugin-dialogs.notification_android", + "merges": [ + "navigator.notification" + ] }, { "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js", @@ -227,39 +291,16 @@ module.exports = [ ] }, { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransferError.js", - "id": "cordova-plugin-file-transfer.FileTransferError", - "clobbers": [ - "window.FileTransferError" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransfer.js", - "id": "cordova-plugin-file-transfer.FileTransfer", - "clobbers": [ - "window.FileTransfer" - ] - }, - { - "file": "plugins/cordova-plugin-device-orientation/www/CompassError.js", - "id": "cordova-plugin-device-orientation.CompassError", - "clobbers": [ - "CompassError" - ] - }, - { - "file": "plugins/cordova-plugin-device-orientation/www/CompassHeading.js", - "id": "cordova-plugin-device-orientation.CompassHeading", + "file": "plugins/cordova-plugin-geolocation/www/android/geolocation.js", + "id": "cordova-plugin-geolocation.geolocation", "clobbers": [ - "CompassHeading" + "navigator.geolocation" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/compass.js", - "id": "cordova-plugin-device-orientation.compass", - "clobbers": [ - "navigator.compass" - ] + "file": "plugins/cordova-plugin-geolocation/www/PositionError.js", + "id": "cordova-plugin-geolocation.PositionError", + "runs": true }, { "file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", @@ -267,36 +308,24 @@ module.exports = [ "clobbers": [ "cordova.plugins.barcodeScanner" ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/notification.js", - "id": "cordova-plugin-dialogs.notification", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/android/notification.js", - "id": "cordova-plugin-dialogs.notification_android", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", - "id": "cordova-plugin-splashscreen.SplashScreen", - "clobbers": [ - "navigator.splashscreen" - ] - }, - { - "file": "plugins/cordova-plugin-whitelist/whitelist.js", - "id": "cordova-plugin-whitelist.whitelist", - "runs": true } ]; module.exports.metadata = // TOP OF METADATA -{} +{ + "cordova-plugin-compat": "1.0.0", + "cordova-plugin-whitelist": "1.2.1", + "cordova-plugin-console": "1.0.3-dev", + "cordova-plugin-device": "1.1.2-dev", + "cordova-plugin-camera": "2.1.2-dev", + "cordova-plugin-splashscreen": "3.2.2-dev", + "cordova-plugin-network-information": "1.2.1-dev", + "cordova-plugin-dialogs": "1.2.1-dev", + "cordova-plugin-file": "4.1.1", + "cordova-plugin-media": "2.2.1-dev", + "cordova-plugin-media-capture": "1.2.1-dev", + "cordova-plugin-geolocation": "2.1.1-dev", + "phonegap-plugin-barcodescanner": "4.1.0" +}; // BOTTOM OF METADATA }); \ No newline at end of file diff --git a/platforms/android/platform_www/plugins/cordova-plugin-camera/www/Camera.js b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/Camera.js new file mode 100644 index 0000000..df633a2 --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/Camera.js @@ -0,0 +1,194 @@ +cordova.define("cordova-plugin-camera.camera", function(require, exports, module) { +/* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + exec = require('cordova/exec'), + Camera = require('./Camera'); + // XXX: commented out + //CameraPopoverHandle = require('./CameraPopoverHandle'); + +/** + * @namespace navigator + */ + +/** + * @exports camera + */ +var cameraExport = {}; + +// Tack on the Camera Constants to the base camera plugin. +for (var key in Camera) { + cameraExport[key] = Camera[key]; +} + +/** + * Callback function that provides an error message. + * @callback module:camera.onError + * @param {string} message - The message is provided by the device's native code. + */ + +/** + * Callback function that provides the image data. + * @callback module:camera.onSuccess + * @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect. + * @example + * // Show image + * // + * function cameraCallback(imageData) { + * var image = document.getElementById('myImage'); + * image.src = "data:image/jpeg;base64," + imageData; + * } + */ + +/** + * Optional parameters to customize the camera settings. + * * [Quirks](#CameraOptions-quirks) + * @typedef module:camera.CameraOptions + * @type {Object} + * @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.) + * @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value. + * @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture. + * @property {Boolean} [allowEdit=true] - Allow simple editing of image before selection. + * @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding. + * @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant. + * @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant. + * @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. + * @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture. + * @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture. + * @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad. + * @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing). + */ + +/** + * @description 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 `camera.getPicture` function opens the device's default camera + * application that allows users to snap pictures by default - this behavior occurs, + * when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}. + * 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`]{@link module: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`]{@link module:camera.onSuccess} 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 `` 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__ + * + * - Android + * - BlackBerry + * - Browser + * - Firefox + * - FireOS + * - iOS + * - Windows + * - WP8 + * - Ubuntu + * + * More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks). + * + * @example + * navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + * @param {module:camera.onSuccess} successCallback + * @param {module:camera.onError} errorCallback + * @param {module:camera.CameraOptions} options CameraOptions + */ +cameraExport.getPicture = function(successCallback, errorCallback, options) { + argscheck.checkArgs('fFO', 'Camera.getPicture', arguments); + options = options || {}; + var getValue = argscheck.getValue; + + var quality = getValue(options.quality, 50); + var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI); + var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA); + var targetWidth = getValue(options.targetWidth, -1); + var targetHeight = getValue(options.targetHeight, -1); + var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG); + var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE); + var allowEdit = !!options.allowEdit; + var correctOrientation = !!options.correctOrientation; + var saveToPhotoAlbum = !!options.saveToPhotoAlbum; + var popoverOptions = getValue(options.popoverOptions, null); + var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK); + + var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, + mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection]; + + exec(successCallback, errorCallback, "Camera", "takePicture", args); + // XXX: commented out + //return new CameraPopoverHandle(); +}; + +/** + * Removes intermediate image files that are kept in temporary storage + * after calling [`camera.getPicture`]{@link module: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); + * } + */ +cameraExport.cleanup = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "Camera", "cleanup", []); +}; + +module.exports = cameraExport; + +}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraConstants.js b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraConstants.js new file mode 100644 index 0000000..1a786df --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraConstants.js @@ -0,0 +1,91 @@ +cordova.define("cordova-plugin-camera.Camera", function(require, exports, module) { +/* + * + * 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. + * +*/ + +/** + * @module Camera + */ +module.exports = { + /** + * @enum {number} + */ + DestinationType:{ + /** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */ + DATA_URL: 0, + /** Return file uri (content://media/external/images/media/2 for Android) */ + FILE_URI: 1, + /** Return native uri (eg. asset-library://... for iOS) */ + NATIVE_URI: 2 + }, + /** + * @enum {number} + */ + EncodingType:{ + /** Return JPEG encoded image */ + JPEG: 0, + /** Return PNG encoded image */ + PNG: 1 + }, + /** + * @enum {number} + */ + MediaType:{ + /** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */ + PICTURE: 0, + /** Allow selection of video only, ONLY RETURNS URL */ + VIDEO: 1, + /** Allow selection from all media types */ + ALLMEDIA : 2 + }, + /** + * @enum {number} + */ + PictureSourceType:{ + /** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */ + PHOTOLIBRARY : 0, + /** Take picture from camera */ + CAMERA : 1, + /** Choose image from picture library (same as PHOTOLIBRARY for Android) */ + SAVEDPHOTOALBUM : 2 + }, + /** + * Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover. + * @enum {number} + */ + PopoverArrowDirection:{ + ARROW_UP : 1, + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }, + /** + * @enum {number} + */ + Direction:{ + /** Use the back-facing camera */ + BACK: 0, + /** Use the front-facing camera */ + FRONT: 1 + } +}; + +}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js new file mode 100644 index 0000000..a65ac7e --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js @@ -0,0 +1,35 @@ +cordova.define("cordova-plugin-camera.CameraPopoverHandle", function(require, exports, module) { +/* + * + * 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. + * +*/ + +/** + * @ignore in favour of iOS' one + * A handle to an image picker popover. + */ +var CameraPopoverHandle = function() { + this.setPosition = function(popoverOptions) { + console.log('CameraPopoverHandle.setPosition is only supported on iOS.'); + }; +}; + +module.exports = CameraPopoverHandle; + +}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js new file mode 100644 index 0000000..f6a1e8f --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js @@ -0,0 +1,55 @@ +cordova.define("cordova-plugin-camera.CameraPopoverOptions", function(require, exports, module) { +/* + * + * 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. + * +*/ + +var Camera = require('./Camera'); + +/** + * @namespace navigator + */ + +/** + * 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. + * 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. + * @module CameraPopoverOptions + * @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover. + * @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover. + * @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point. + */ +var CameraPopoverOptions = function (x, y, width, height, arrowDir) { + // information of rectangle that popover should be anchored to + this.x = x || 0; + this.y = y || 32; + this.width = width || 320; + this.height = height || 480; + this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY; +}; + +module.exports = CameraPopoverOptions; + +}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/CompassError.js b/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/CompassError.js deleted file mode 100644 index 0055b9a..0000000 --- a/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/CompassError.js +++ /dev/null @@ -1,37 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassError", function(require, exports, module) { -/* - * - * 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. - * -*/ - -/** - * CompassError. - * An error code assigned by an implementation when an error has occurred - * @constructor - */ -var CompassError = function(err) { - this.code = (err !== undefined ? err : null); -}; - -CompassError.COMPASS_INTERNAL_ERR = 0; -CompassError.COMPASS_NOT_SUPPORTED = 20; - -module.exports = CompassError; - -}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js b/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js deleted file mode 100644 index 4ebb4aa..0000000 --- a/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js +++ /dev/null @@ -1,32 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassHeading", function(require, exports, module) { -/* - * - * 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. - * -*/ - -var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) { - this.magneticHeading = magneticHeading; - this.trueHeading = trueHeading; - this.headingAccuracy = headingAccuracy; - this.timestamp = timestamp || new Date().getTime(); -}; - -module.exports = CompassHeading; - -}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/compass.js b/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/compass.js deleted file mode 100644 index 48ee5f6..0000000 --- a/platforms/android/platform_www/plugins/cordova-plugin-device-orientation/www/compass.js +++ /dev/null @@ -1,121 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.compass", function(require, exports, module) { -/* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - utils = require('cordova/utils'), - CompassHeading = require('./CompassHeading'), - CompassError = require('./CompassError'), - - timers = {}, - eventTimerId = null, - compass = { - /** - * Asynchronously acquires the current heading. - * @param {Function} successCallback The function to call when the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {CompassOptions} options The options for getting the heading data (not used). - */ - getCurrentHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments); - - var win = function(result) { - var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp); - successCallback(ch); - }; - var fail = errorCallback && function(code) { - var ce = new CompassError(code); - errorCallback(ce); - }; - - // Get heading - exec(win, fail, "Compass", "getHeading", [options]); - }, - - /** - * Asynchronously acquires the heading repeatedly at a given interval. - * @param {Function} successCallback The function to call each time the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {HeadingOptions} options The options for getting the heading data - * such as timeout and the frequency of the watch. For iOS, filter parameter - * specifies to watch via a distance filter rather than time. - */ - watchHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.watchHeading', arguments); - // Default interval (100 msec) - var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100; - var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0; - - var id = utils.createUUID(); - if (filter > 0) { - // is an iOS request for watch by filter, no timer needed - timers[id] = "iOS"; - compass.getCurrentHeading(successCallback, errorCallback, options); - } else { - // Start watch timer to get headings - timers[id] = window.setInterval(function() { - compass.getCurrentHeading(successCallback, errorCallback); - }, frequency); - } - - if (cordova.platformId === 'browser' && !eventTimerId) { - // Start firing deviceorientation events if haven't already - var deviceorientationEvent = new Event('deviceorientation'); - eventTimerId = window.setInterval(function() { - window.dispatchEvent(deviceorientationEvent); - }, 200); - } - - return id; - }, - - /** - * Clears the specified heading watch. - * @param {String} id The ID of the watch returned from #watchHeading. - */ - clearWatch:function(id) { - // Stop javascript timer & remove from timer list - if (id && timers[id]) { - if (timers[id] != "iOS") { - clearInterval(timers[id]); - } else { - // is iOS watch by filter so call into device to stop - exec(null, null, "Compass", "stopHeading", []); - } - delete timers[id]; - - if (eventTimerId && Object.keys(timers).length === 0) { - // No more watchers, so stop firing 'deviceorientation' events - window.clearInterval(eventTimerId); - eventTimerId = null; - } - } - } - }; - -module.exports = compass; - -}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-device/www/device.js b/platforms/android/platform_www/plugins/cordova-plugin-device/www/device.js new file mode 100644 index 0000000..977dfc0 --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-device/www/device.js @@ -0,0 +1,86 @@ +cordova.define("cordova-plugin-device.device", function(require, exports, module) { +/* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + channel = require('cordova/channel'), + utils = require('cordova/utils'), + exec = require('cordova/exec'), + cordova = require('cordova'); + +channel.createSticky('onCordovaInfoReady'); +// Tell cordova channel to wait on the CordovaInfoReady event +channel.waitForInitialization('onCordovaInfoReady'); + +/** + * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the + * phone, etc. + * @constructor + */ +function Device() { + this.available = false; + this.platform = null; + this.version = null; + this.uuid = null; + this.cordova = null; + this.model = null; + this.manufacturer = null; + this.isVirtual = null; + this.serial = null; + + var me = this; + + channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js + //TODO: CB-5105 native implementations should not return info.cordova + var buildLabel = cordova.version; + me.available = true; + me.platform = info.platform; + me.version = info.version; + me.uuid = info.uuid; + me.cordova = buildLabel; + me.model = info.model; + me.isVirtual = info.isVirtual; + me.manufacturer = info.manufacturer || 'unknown'; + me.serial = info.serial || 'unknown'; + channel.onCordovaInfoReady.fire(); + },function(e) { + me.available = false; + utils.alert("[ERROR] Error initializing Cordova: " + e); + }); + }); +} + +/** + * Get device info + * + * @param {Function} successCallback The function to call when the heading data is available + * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL) + */ +Device.prototype.getInfo = function(successCallback, errorCallback) { + argscheck.checkArgs('fF', 'Device.getInfo', arguments); + exec(successCallback, errorCallback, "Device", "getDeviceInfo", []); +}; + +module.exports = new Device(); + +}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/platforms/android/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js deleted file mode 100644 index 28cc200..0000000 --- a/platforms/android/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js +++ /dev/null @@ -1,238 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransfer", function(require, exports, module) { -/* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - FileTransferError = require('./FileTransferError'), - ProgressEvent = require('cordova-plugin-file.ProgressEvent'); - -function newProgressEvent(result) { - var pe = new ProgressEvent(); - pe.lengthComputable = result.lengthComputable; - pe.loaded = result.loaded; - pe.total = result.total; - return pe; -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function convertHeadersToArray(headers) { - var result = []; - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - var headerValue = headers[header]; - result.push({ - name: header, - value: headerValue.toString() - }); - } - } - return result; -} - -var idCounter = 0; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** -* Given an absolute file path, uploads a file on the device to a remote server -* using a multipart HTTP request. -* @param filePath {String} Full path of the file on the device -* @param server {String} URL of the server to receive the file -* @param successCallback (Function} Callback to be invoked when upload has completed -* @param errorCallback {Function} Callback to be invoked upon error -* @param options {FileUploadOptions} Optional parameters such as file name and mimetype -* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false -*/ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - // check for options - var fileKey = null; - var fileName = null; - var mimeType = null; - var params = null; - var chunkedMode = true; - var headers = null; - var httpMethod = null; - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - if (options) { - fileKey = options.fileKey; - fileName = options.fileName; - mimeType = options.mimeType; - headers = options.headers; - httpMethod = options.httpMethod || "POST"; - if (httpMethod.toUpperCase() == "PUT"){ - httpMethod = "PUT"; - } else { - httpMethod = "POST"; - } - if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { - chunkedMode = options.chunkedMode; - } - if (options.params) { - params = options.params; - } - else { - params = {}; - } - } - - if (cordova.platformId === "windowsphone") { - headers = headers && convertHeadersToArray(headers); - params = params && convertHeadersToArray(params); - } - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - var self = this; - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - self.onprogress(newProgressEvent(result)); - } - } else { - successCallback && successCallback(result); - } - }; - exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - var self = this; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var headers = null; - if (options) { - headers = options.headers || null; - } - - if (cordova.platformId === "windowsphone" && headers) { - headers = convertHeadersToArray(headers); - } - - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - return self.onprogress(newProgressEvent(result)); - } - } else if (successCallback) { - var entry = null; - if (result.isDirectory) { - entry = new (require('cordova-plugin-file.DirectoryEntry'))(); - } - else if (result.isFile) { - entry = new (require('cordova-plugin-file.FileEntry'))(); - } - entry.isDirectory = result.isDirectory; - entry.isFile = result.isFile; - entry.name = result.name; - entry.fullPath = result.fullPath; - entry.filesystem = new FileSystem(result.filesystemName || (result.filesystem == window.PERSISTENT ? 'persistent' : 'temporary')); - entry.nativeURL = result.nativeURL; - successCallback(entry); - } - }; - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - exec(null, null, 'FileTransfer', 'abort', [this._id]); -}; - -module.exports = FileTransfer; - -}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/platforms/android/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js deleted file mode 100644 index 18fb64c..0000000 --- a/platforms/android/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js +++ /dev/null @@ -1,44 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransferError", function(require, exports, module) { -/* - * - * 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. - * -*/ - -/** - * FileTransferError - * @constructor - */ -var FileTransferError = function(code, source, target, status, body, exception) { - this.code = code || null; - this.source = source || null; - this.target = target || null; - this.http_status = status || null; - this.body = body || null; - this.exception = exception || null; -}; - -FileTransferError.FILE_NOT_FOUND_ERR = 1; -FileTransferError.INVALID_URL_ERR = 2; -FileTransferError.CONNECTION_ERR = 3; -FileTransferError.ABORT_ERR = 4; -FileTransferError.NOT_MODIFIED_ERR = 5; - -module.exports = FileTransferError; - -}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js b/platforms/android/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js index 90450d8..c74fd9c 100644 --- a/platforms/android/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js +++ b/platforms/android/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js @@ -1,29 +1,29 @@ cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) { -/* - * - * 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. - * - */ - -module.exports = function () { - // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and - // possibly a good flag to indicate that we're running in Chrome - return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; -}; +/* + * + * 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. + * + */ + +module.exports = function () { + // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and + // possibly a good flag to indicate that we're running in Chrome + return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; +}; }); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-geolocation/www/android/geolocation.js b/platforms/android/platform_www/plugins/cordova-plugin-geolocation/www/android/geolocation.js index c34ba06..814aafb 100644 --- a/platforms/android/platform_www/plugins/cordova-plugin-geolocation/www/android/geolocation.js +++ b/platforms/android/platform_www/plugins/cordova-plugin-geolocation/www/android/geolocation.js @@ -20,13 +20,15 @@ cordova.define("cordova-plugin-geolocation.geolocation", function(require, expor * */ - var exec = cordova.require('cordova/exec'); var utils = require('cordova/utils'); var PositionError = require('./PositionError'); -module.exports = { +// Native watchPosition method is called async after permissions prompt. +// So we use additional map and own ids to return watch id synchronously. +var pluginToNativeWatchMap = {}; +module.exports = { getCurrentPosition: function(success, error, args) { var win = function() { var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); @@ -69,8 +71,4 @@ module.exports = { } }; -// Native watchPosition method is called async after permissions prompt. -// So we use additional map and own ids to return watch id synchronously. -var pluginToNativeWatchMap = {}; - }); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js b/platforms/android/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js index 3bd253c..0101382 100644 --- a/platforms/android/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js +++ b/platforms/android/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js @@ -35,6 +35,8 @@ CaptureError.CAPTURE_APPLICATION_BUSY = 1; CaptureError.CAPTURE_INVALID_ARGUMENT = 2; // User exited camera application or audio capture application before capturing anything. CaptureError.CAPTURE_NO_MEDIA_FILES = 3; +// User denied permissions required to perform the capture request. +CaptureError.CAPTURE_PERMISSION_DENIED = 4; // The requested capture operation is not supported. CaptureError.CAPTURE_NOT_SUPPORTED = 20; diff --git a/platforms/android/platform_www/plugins/cordova-plugin-media/www/Media.js b/platforms/android/platform_www/plugins/cordova-plugin-media/www/Media.js index 2d83ad6..d42fca7 100644 --- a/platforms/android/platform_www/plugins/cordova-plugin-media/www/Media.js +++ b/platforms/android/platform_www/plugins/cordova-plugin-media/www/Media.js @@ -160,10 +160,18 @@ Media.prototype.setRate = function(rate) { if (cordova.platformId === 'ios'){ exec(null, null, "Media", "setRate", [this.id, rate]); } else { - console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.') + console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.'); } }; +/** + * Get amplitude of audio. + */ +Media.prototype.getCurrentAmplitude = function(success, fail) { + exec(function(p) { + success(p); + }, fail, "Media", "getCurrentAmplitudeAudio", [this.id]); +}; /** * Audio has status update. @@ -177,30 +185,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value == Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value == Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } - else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/platforms/android/platform_www/plugins/cordova-plugin-network-information/www/Connection.js b/platforms/android/platform_www/plugins/cordova-plugin-network-information/www/Connection.js new file mode 100644 index 0000000..5f7279c --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-network-information/www/Connection.js @@ -0,0 +1,37 @@ +cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) { +/* + * + * 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. + * +*/ + +/** + * Network status + */ +module.exports = { + UNKNOWN: "unknown", + ETHERNET: "ethernet", + WIFI: "wifi", + CELL_2G: "2g", + CELL_3G: "3g", + CELL_4G: "4g", + CELL:"cellular", + NONE: "none" +}; + +}); diff --git a/platforms/android/platform_www/plugins/cordova-plugin-network-information/www/network.js b/platforms/android/platform_www/plugins/cordova-plugin-network-information/www/network.js new file mode 100644 index 0000000..770e6ba --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-network-information/www/network.js @@ -0,0 +1,94 @@ +cordova.define("cordova-plugin-network-information.network", function(require, exports, module) { +/* + * 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. + * +*/ + +var exec = require('cordova/exec'), + cordova = require('cordova'), + channel = require('cordova/channel'), + utils = require('cordova/utils'); + +// Link the onLine property with the Cordova-supplied network info. +// This works because we clobber the navigator object with our own +// object in bootstrap.js. +// Browser platform do not need to define this property, because +// it is already supported by modern browsers +if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') { + utils.defineGetter(navigator, 'onLine', function() { + return this.connection.type != 'none'; + }); +} + +function NetworkConnection() { + this.type = 'unknown'; +} + +/** + * Get connection info + * + * @param {Function} successCallback The function to call when the Connection data is available + * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL) + */ +NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []); +}; + +var me = new NetworkConnection(); +var timerId = null; +var timeout = 500; + +channel.createSticky('onCordovaConnectionReady'); +channel.waitForInitialization('onCordovaConnectionReady'); + +channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + me.type = info; + if (info === "none") { + // set a timer if still offline at the end of timer send the offline event + timerId = setTimeout(function(){ + cordova.fireDocumentEvent("offline"); + timerId = null; + }, timeout); + } else { + // If there is a current offline event pending clear it + if (timerId !== null) { + clearTimeout(timerId); + timerId = null; + } + cordova.fireDocumentEvent("online"); + } + + // should only fire this once + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + }, + function (e) { + // If we can't get the network info we should still tell Cordova + // to fire the deviceready event. + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + console.log("Error initializing Network Connection: " + e); + }); +}); + +module.exports = me; + +}); diff --git a/platforms/android/proguard-project.txt b/platforms/android/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/platforms/android/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/platforms/android/release-signing.properties b/platforms/android/release-signing.properties deleted file mode 100644 index 9155dcd..0000000 --- a/platforms/android/release-signing.properties +++ /dev/null @@ -1,5 +0,0 @@ -storeFile=C:\\Users\\Skylar\\Documents\\Projects\\Certificates\\Android\\android.keystore -storeType=jks -keyAlias=Android -keyPassword=skylar11 -storePassword=skylar11 diff --git a/platforms/android/res/drawable-land-hdpi/screen.png b/platforms/android/res/drawable-land-hdpi/screen.png new file mode 100644 index 0000000..a61e2b1 Binary files /dev/null and b/platforms/android/res/drawable-land-hdpi/screen.png differ diff --git a/platforms/android/res/drawable-land-ldpi/screen.png b/platforms/android/res/drawable-land-ldpi/screen.png new file mode 100644 index 0000000..f3934cd Binary files /dev/null and b/platforms/android/res/drawable-land-ldpi/screen.png differ diff --git a/platforms/android/res/drawable-land-mdpi/screen.png b/platforms/android/res/drawable-land-mdpi/screen.png new file mode 100644 index 0000000..a1b697c Binary files /dev/null and b/platforms/android/res/drawable-land-mdpi/screen.png differ diff --git a/platforms/android/res/drawable-land-xhdpi/screen.png b/platforms/android/res/drawable-land-xhdpi/screen.png new file mode 100644 index 0000000..79f2f09 Binary files /dev/null and b/platforms/android/res/drawable-land-xhdpi/screen.png differ diff --git a/platforms/android/res/drawable-port-hdpi/screen.png b/platforms/android/res/drawable-port-hdpi/screen.png new file mode 100644 index 0000000..5d6a28a Binary files /dev/null and b/platforms/android/res/drawable-port-hdpi/screen.png differ diff --git a/platforms/android/res/drawable-port-ldpi/screen.png b/platforms/android/res/drawable-port-ldpi/screen.png new file mode 100644 index 0000000..65ad163 Binary files /dev/null and b/platforms/android/res/drawable-port-ldpi/screen.png differ diff --git a/platforms/android/res/drawable-port-mdpi/screen.png b/platforms/android/res/drawable-port-mdpi/screen.png new file mode 100644 index 0000000..ea15693 Binary files /dev/null and b/platforms/android/res/drawable-port-mdpi/screen.png differ diff --git a/platforms/android/res/drawable-port-xhdpi/screen.png b/platforms/android/res/drawable-port-xhdpi/screen.png new file mode 100644 index 0000000..c2e8042 Binary files /dev/null and b/platforms/android/res/drawable-port-xhdpi/screen.png differ diff --git a/platforms/android/res/xml/config.xml b/platforms/android/res/xml/config.xml index 6630776..5804569 100644 --- a/platforms/android/res/xml/config.xml +++ b/platforms/android/res/xml/config.xml @@ -1,8 +1,25 @@ - - + + + + + + + + + + + + + + + + + + + @@ -14,26 +31,12 @@ - - - - - + + - - - - - - - - - - - TerranQuest diff --git a/platforms/android/src/org/apache/cordova/PermissionHelper.java b/platforms/android/src/org/apache/cordova/PermissionHelper.java new file mode 100644 index 0000000..bbd7911 --- /dev/null +++ b/platforms/android/src/org/apache/cordova/PermissionHelper.java @@ -0,0 +1,138 @@ +/* + 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; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; + +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.LOG; + +import android.content.pm.PackageManager; + +/** + * This class provides reflective methods for permission requesting and checking so that plugins + * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. + */ +public class PermissionHelper { + private static final String LOG_TAG = "CordovaPermissionHelper"; + + /** + * Requests a "dangerous" permission for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermission() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permission request + * @param permission The permission to be requested + */ + public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { + PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); + } + + /** + * Requests "dangerous" permissions for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermissions() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permissions are being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permissions request + * @param permissions The permissions to be requested + */ + public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { + try { + Method requestPermission = CordovaInterface.class.getDeclaredMethod( + "requestPermissions", CordovaPlugin.class, int.class, String[].class); + + // If there is no exception, then this is cordova-android 5.0.0+ + requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); + + // Notify the plugin that all were granted by using more reflection + deliverPermissionResult(plugin, requestCode, permissions); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); + } + } + + /** + * Checks at runtime to see if the application has been granted a permission. This is a helper + * method alternative to cordovaInterface.hasPermission() that does not require the project to + * be built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being checked against + * @param permission The permission to be checked + * + * @return True if the permission has already been granted and false otherwise + */ + public static boolean hasPermission(CordovaPlugin plugin, String permission) { + try { + Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); + + // If there is no exception, then this is cordova-android 5.0.0+ + return (Boolean) hasPermission.invoke(plugin.cordova, permission); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to check for permission " + permission); + return true; + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); + } + return false; + } + + private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { + // Generate the request results + int[] requestResults = new int[permissions.length]; + Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); + + try { + Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( + "onRequestPermissionResult", int.class, String[].class, int[].class); + + onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); + } catch (NoSuchMethodException noSuchMethodException) { + // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it + // made it to this point + LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method may throw a JSONException. We are just duplicating cordova-android's + // exception handling behavior here; all it does is log the exception in CordovaActivity, + // print the stacktrace, and ignore it + LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); + } + } +} diff --git a/platforms/android/src/org/apache/cordova/camera/CameraLauncher.java b/platforms/android/src/org/apache/cordova/camera/CameraLauncher.java new file mode 100644 index 0000000..4d15bdf --- /dev/null +++ b/platforms/android/src/org/apache/cordova/camera/CameraLauncher.java @@ -0,0 +1,1291 @@ +/* + 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.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CordovaResourceApi; +import org.apache.cordova.LOG; +import org.apache.cordova.PermissionHelper; +import org.apache.cordova.PluginResult; +import org.json.JSONArray; +import org.json.JSONException; + +import android.Manifest; +import android.app.Activity; +import android.content.ActivityNotFoundException; +import android.content.ContentValues; +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.Bitmap.CompressFormat; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.media.MediaScannerConnection; +import android.media.MediaScannerConnection.MediaScannerConnectionClient; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; +import android.util.Base64; +import android.util.Log; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.PermissionInfo; + +/** + * 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"; + + public static final int PERMISSION_DENIED_ERROR = 20; + public static final int TAKE_PIC_SEC = 0; + public static final int SAVE_TO_ALBUM_SEC = 1; + + private static final String LOG_TAG = "CameraLauncher"; + + //Where did this come from? + private static final int CROP_CAMERA = 100; + + 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 int destType; // Source type (needs to be saved for the permission handling) + private int srcType; // Destination type (needs to be saved for permission handling) + 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. + + protected final static String[] permissions = { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE }; + + 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 + private Uri croppedUri; + + + /** + * 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")) { + this.srcType = CAMERA; + this.destType = FILE_URI; + this.saveToPhotoAlbum = false; + this.targetHeight = 0; + this.targetWidth = 0; + this.encodingType = JPEG; + this.mediaType = PICTURE; + this.mQuality = 80; + + //Take the values from the arguments if they're not already defined (this is tricky) + this.destType = args.getInt(1); + this.srcType = args.getInt(2); + this.mQuality = args.getInt(0); + 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.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; + } + + // We don't return full-quality PNG files. The camera outputs a JPEG + // so requesting it as a PNG provides no actual benefit + if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 && + !this.correctOrientation && this.encodingType == PNG && this.srcType == CAMERA) { + this.encodingType = JPEG; + } + + try { + if (this.srcType == CAMERA) { + this.callTakePicture(destType, encodingType); + } + else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) { + // FIXME: Stop always requesting the permission + if(!PermissionHelper.hasPermission(this, permissions[0])) { + PermissionHelper.requestPermission(this, SAVE_TO_ALBUM_SEC, Manifest.permission.READ_EXTERNAL_STORAGE); + } else { + this.getImage(this.srcType, destType, encodingType); + } + } + } + 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 = cordova.getActivity().getExternalCacheDir(); + } + // 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 callTakePicture(int returnType, int encodingType) { + boolean saveAlbumPermission = PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE); + boolean takePicturePermission = PermissionHelper.hasPermission(this, Manifest.permission.CAMERA); + + // CB-10120: The CAMERA permission does not need to be requested unless it is declared + // in AndroidManifest.xml. This plugin does not declare it, but others may and so we must + // check the package info to determine if the permission is present. + + if (!takePicturePermission) { + takePicturePermission = true; + try { + PackageManager packageManager = this.cordova.getActivity().getPackageManager(); + String[] permissionsInPackage = packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), PackageManager.GET_PERMISSIONS).requestedPermissions; + if (permissionsInPackage != null) { + for (String permission : permissionsInPackage) { + if (permission.equals(Manifest.permission.CAMERA)) { + takePicturePermission = false; + break; + } + } + } + } catch (NameNotFoundException e) { + // We are requesting the info for our package, so this should + // never be caught + } + } + + if (takePicturePermission && saveAlbumPermission) { + takePicture(returnType, encodingType); + } else if (saveAlbumPermission && !takePicturePermission) { + PermissionHelper.requestPermission(this, TAKE_PIC_SEC, Manifest.permission.CAMERA); + } else if (!saveAlbumPermission && takePicturePermission) { + PermissionHelper.requestPermission(this, TAKE_PIC_SEC, Manifest.permission.READ_EXTERNAL_STORAGE); + } else { + PermissionHelper.requestPermissions(this, TAKE_PIC_SEC, permissions); + } + } + + public void takePicture(int returnType, int encodingType) + { + // Save the number of images currently on disk for later + this.numPics = queryImgDB(whichContentStore()).getCount(); + + // Let's use the intent and see what happens + Intent intent = new Intent(MediaStore.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) { + // Let's check to make sure the camera is actually installed. (Legacy Nexus 7 code) + PackageManager mPm = this.cordova.getActivity().getPackageManager(); + if(intent.resolveActivity(mPm) != null) + { + + this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); + } + else + { + LOG.d(LOG_TAG, "Error: You don't have a default camera. Your device may not be CTS complaint."); + } + } +// 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) { + return createCaptureFile(encodingType, ""); + } + + /** + * Create a file in the applications temporary directory based upon the supplied encoding. + * + * @param encodingType of the image to be taken + * @param fileName or resultant File object. + * @return a File object pointing to the temporary picture + */ + private File createCaptureFile(int encodingType, String fileName) { + if (fileName.isEmpty()) { + fileName = ".Pic"; + } + + if (encodingType == JPEG) { + fileName = fileName + ".jpg"; + } else if (encodingType == PNG) { + fileName = fileName + ".png"; + } else { + throw new IllegalArgumentException("Invalid Encoding Type: " + encodingType); + } + + return new File(getTempDirectoryPath(), fileName); + } + + + + /** + * 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. + * @param encodingType + */ + // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! + // TODO: Images from kitkat filechooser not going into crop function + public void getImage(int srcType, int returnType, int encodingType) { + Intent intent = new Intent(); + String title = GET_PICTURE; + croppedUri = null; + if (this.mediaType == PICTURE) { + intent.setType("image/*"); + if (this.allowEdit) { + intent.setAction(Intent.ACTION_PICK); + intent.putExtra("crop", "true"); + if (targetWidth > 0) { + intent.putExtra("outputX", targetWidth); + } + if (targetHeight > 0) { + intent.putExtra("outputY", targetHeight); + } + if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { + intent.putExtra("aspectX", 1); + intent.putExtra("aspectY", 1); + } + File photo = createCaptureFile(encodingType); + croppedUri = Uri.fromFile(photo); + intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, croppedUri); + } else { + intent.setAction(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + } + } else if (this.mediaType == VIDEO) { + intent.setType("video/*"); + title = GET_VIDEO; + intent.setAction(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + } 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); + } + } + + /** + * Brings up the UI to perform crop on passed image URI + * + * @param picUri + */ + private void performCrop(Uri picUri, int destType, Intent cameraIntent) { + try { + Intent cropIntent = new Intent("com.android.camera.action.CROP"); + // indicate image type and Uri + cropIntent.setDataAndType(picUri, "image/*"); + // set crop properties + cropIntent.putExtra("crop", "true"); + + // indicate output X and Y + if (targetWidth > 0) { + cropIntent.putExtra("outputX", targetWidth); + } + if (targetHeight > 0) { + cropIntent.putExtra("outputY", targetHeight); + } + if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { + cropIntent.putExtra("aspectX", 1); + cropIntent.putExtra("aspectY", 1); + } + // create new file handle to get full resolution crop + croppedUri = Uri.fromFile(createCaptureFile(this.encodingType, System.currentTimeMillis() + "")); + cropIntent.putExtra("output", croppedUri); + + // start the activity - we handle returning in onActivityResult + + if (this.cordova != null) { + this.cordova.startActivityForResult((CordovaPlugin) this, + cropIntent, CROP_CAMERA + destType); + } + } catch (ActivityNotFoundException anfe) { + Log.e(LOG_TAG, "Crop operation not supported on this device"); + try { + processResultFromCamera(destType, cameraIntent); + } + catch (IOException e) + { + e.printStackTrace(); + Log.e(LOG_TAG, "Unable to write to file"); + } + } + } + + /** + * 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(); + String sourcePath = (this.allowEdit && this.croppedUri != null) ? + FileHelper.stripFileProtocol(this.croppedUri.toString()) : + FileHelper.stripFileProtocol(this.imageUri.toString()); + + if (this.encodingType == JPEG) { + try { + //We don't support PNG, so let's not pretend we do + exif.createInFile(sourcePath); + exif.readExifData(); + rotate = exif.getOrientation(); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + Bitmap bitmap = null; + Uri galleryUri = null; + + // CB-5479 When this option is given the unchanged image should be saved + // in the gallery and the modified image is saved in the temporary + // directory + if (this.saveToPhotoAlbum) { + galleryUri = Uri.fromFile(new File(getPicutresPath())); + + if(this.allowEdit && this.croppedUri != null) { + writeUncompressedImage(this.croppedUri, galleryUri); + } else { + writeUncompressedImage(this.imageUri, galleryUri); + } + + refreshGallery(galleryUri); + } + + // If sending base64 image back + if (destType == DATA_URL) { + bitmap = getScaledBitmap(sourcePath); + + 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, this.encodingType); + + if (!this.saveToPhotoAlbum) { + checkForDuplicateImage(DATA_URL); + } + } + + // If sending filename back + else if (destType == FILE_URI || destType == NATIVE_URI) { + // If all this is true we shouldn't compress the image. + if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 && + !this.correctOrientation) { + + // If we saved the uncompressed photo to the album, we can just + // return the URI we already created + if (this.saveToPhotoAlbum) { + this.callbackContext.success(galleryUri.toString()); + } else { + Uri uri = Uri.fromFile(createCaptureFile(this.encodingType, System.currentTimeMillis() + "")); + + if(this.allowEdit && this.croppedUri != null) { + writeUncompressedImage(this.croppedUri, uri); + } else { + writeUncompressedImage(this.imageUri, uri); + } + + this.callbackContext.success(uri.toString()); + } + } else { + Uri uri = Uri.fromFile(createCaptureFile(this.encodingType, System.currentTimeMillis() + "")); + bitmap = getScaledBitmap(sourcePath); + + // 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); + } + + // Add compressed version of captured image to returned media store Uri + OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); + CompressFormat compressFormat = encodingType == JPEG ? + CompressFormat.JPEG : + CompressFormat.PNG; + + bitmap.compress(compressFormat, this.mQuality, os); + os.close(); + + // Restore exif data to file + if (this.encodingType == JPEG) { + String exifPath; + exifPath = uri.getPath(); + exif.createOutFile(exifPath); + exif.writeExifData(); + } + + // Send Uri back to JavaScript for viewing image + this.callbackContext.success(uri.toString()); + + } + } else { + throw new IllegalStateException(); + } + + this.cleanup(FILE_URI, this.imageUri, galleryUri, bitmap); + bitmap = null; + } + +private String getPicutresPath() +{ + String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + String imageFileName = "IMG_" + timeStamp + (this.encodingType == JPEG ? ".jpg" : ".png"); + File storageDir = Environment.getExternalStoragePublicDirectory( + Environment.DIRECTORY_PICTURES); + String galleryPath = storageDir.getAbsolutePath() + "/" + imageFileName; + return galleryPath; +} + +private void refreshGallery(Uri contentUri) +{ + Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + mediaScanIntent.setData(contentUri); + this.cordova.getActivity().sendBroadcast(mediaScanIntent); +} + + +private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException { + // Some content: URIs do not map to file paths (e.g. picasa). + String realPath = FileHelper.getRealPath(uri, this.cordova); + + // Get filename from uri + String fileName = realPath != null ? + realPath.substring(realPath.lastIndexOf('/') + 1) : + "modified." + (this.encodingType == JPEG ? "jpg" : "png"); + + String modifiedPath = getTempDirectoryPath() + "/" + fileName; + + OutputStream os = new FileOutputStream(modifiedPath); + CompressFormat compressFormat = this.encodingType == JPEG ? + CompressFormat.JPEG : + CompressFormat.PNG; + + bitmap.compress(compressFormat, this.mQuality, os); + os.close(); + + if (realPath != null && this.encodingType == JPEG) { + // Create an ExifHelper to save the exif data that is lost during compression + ExifHelper exif = new ExifHelper(); + + 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(); + if (uri == null) { + if (croppedUri != null) { + uri = croppedUri; + } else { + this.failPicture("null data from photo library"); + return; + } + } + int rotate = 0; + + String fileLocation = FileHelper.getRealPath(uri, this.cordova); + Log.d(LOG_TAG, "File locaton is: " + fileLocation); + + // 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(fileLocation); + } + 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, this.encodingType); + } + + // 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(fileLocation); + } + } + 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 for a Camera Activity + int srcType = (requestCode / 16) - 1; + int destType = (requestCode % 16) - 1; + + // If Camera Crop + if (requestCode >= CROP_CAMERA) { + if (resultCode == Activity.RESULT_OK) { + + // Because of the inability to pass through multiple intents, this hack will allow us + // to pass arcane codes back. + destType = requestCode - CROP_CAMERA; + try { + processResultFromCamera(destType, intent); + } catch (IOException e) { + e.printStackTrace(); + Log.e(LOG_TAG, "Unable to write to file"); + } + + }// If cancelled + else if (resultCode == Activity.RESULT_CANCELED) { + this.failPicture("Camera cancelled."); + } + + // If something else + else { + this.failPicture("Did not complete!"); + } + } + // If CAMERA + else if (srcType == CAMERA) { + // If image available + if (resultCode == Activity.RESULT_OK) { + try { + if(this.allowEdit) + { + Uri tmpFile = Uri.fromFile(createCaptureFile(this.encodingType)); + performCrop(tmpFile, destType, intent); + } + else { + 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 && intent != null) { + final Intent i = intent; + final int finalDestType = destType; + cordova.getThreadPool().execute(new Runnable() { + public void run() { + processResultFromGallery(finalDestType, i); + } + }); + } + 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 src, Uri dest) throws FileNotFoundException, + IOException { + FileInputStream fis = null; + OutputStream os = null; + try { + fis = new FileInputStream(FileHelper.stripFileProtocol(src.toString())); + os = this.cordova.getActivity().getContentResolver().openOutputStream(dest); + byte[] buffer = new byte[4096]; + int len; + while ((len = fis.read(buffer)) != -1) { + os.write(buffer, 0, len); + } + os.flush(); + } finally { + if (os != null) { + try { + os.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing output stream."); + } + } + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + } + + /** + * 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 (RuntimeException 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 (RuntimeException 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) { + InputStream fileStream = null; + Bitmap image = null; + try { + fileStream = FileHelper.getInputStreamFromUriString(imageUrl, cordova); + image = BitmapFactory.decodeStream(fileStream); + } finally { + if (fileStream != null) { + try { + fileStream.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + return image; + } + + // figure out the original width and height of the image + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + InputStream fileStream = null; + try { + fileStream = FileHelper.getInputStreamFromUriString(imageUrl, cordova); + BitmapFactory.decodeStream(fileStream, null, options); + } finally { + if (fileStream != null) { + try { + fileStream.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + + //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 = null; + try { + fileStream = FileHelper.getInputStreamFromUriString(imageUrl, cordova); + unscaledBitmap = BitmapFactory.decodeStream(fileStream, null, options); + } finally { + if (fileStream != null) { + try { + fileStream.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + 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, int encodingType) { + ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream(); + CompressFormat compressFormat = encodingType == JPEG ? + CompressFormat.JPEG : + CompressFormat.PNG; + + try { + if (bitmap.compress(compressFormat, 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(); + } + + + public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException + { + for(int r:grantResults) + { + if(r == PackageManager.PERMISSION_DENIED) + { + this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR)); + return; + } + } + switch(requestCode) + { + case TAKE_PIC_SEC: + takePicture(this.destType, this.encodingType); + break; + case SAVE_TO_ALBUM_SEC: + this.getImage(this.srcType, this.destType, this.encodingType); + break; + } + } + + /** + * Taking or choosing a picture launches another Activity, so we need to implement the + * save/restore APIs to handle the case where the CordovaActivity is killed by the OS + * before we get the launched Activity's result. + */ + public Bundle onSaveInstanceState() { + Bundle state = new Bundle(); + state.putInt("destType", this.destType); + state.putInt("srcType", this.srcType); + state.putInt("mQuality", this.mQuality); + state.putInt("targetWidth", this.targetWidth); + state.putInt("targetHeight", this.targetHeight); + state.putInt("encodingType", this.encodingType); + state.putInt("mediaType", this.mediaType); + state.putInt("numPics", this.numPics); + state.putBoolean("allowEdit", this.allowEdit); + state.putBoolean("correctOrientation", this.correctOrientation); + state.putBoolean("saveToPhotoAlbum", this.saveToPhotoAlbum); + + if(this.croppedUri != null) { + state.putString("croppedUri", this.croppedUri.toString()); + } + + if(this.imageUri != null) { + state.putString("imageUri", this.imageUri.toString()); + } + + return state; + } + + public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) { + this.destType = state.getInt("destType"); + this.srcType = state.getInt("srcType"); + this.mQuality = state.getInt("mQuality"); + this.targetWidth = state.getInt("targetWidth"); + this.targetHeight = state.getInt("targetHeight"); + this.encodingType = state.getInt("encodingType"); + this.mediaType = state.getInt("mediaType"); + this.numPics = state.getInt("numPics"); + this.allowEdit = state.getBoolean("allowEdit"); + this.correctOrientation = state.getBoolean("correctOrientation"); + this.saveToPhotoAlbum = state.getBoolean("saveToPhotoAlbum"); + + if(state.containsKey("croppedUri")) { + this.croppedUri = Uri.parse(state.getString("croppedUri")); + } + + if(state.containsKey("imageUri")) { + this.imageUri = Uri.parse(state.getString("imageUri")); + } + + this.callbackContext = callbackContext; + } +} diff --git a/platforms/android/src/org/apache/cordova/camera/ExifHelper.java b/platforms/android/src/org/apache/cordova/camera/ExifHelper.java new file mode 100644 index 0000000..5160a2f --- /dev/null +++ b/platforms/android/src/org/apache/cordova/camera/ExifHelper.java @@ -0,0 +1,185 @@ +/* + 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; + } +} diff --git a/platforms/android/src/org/apache/cordova/camera/FileHelper.java b/platforms/android/src/org/apache/cordova/camera/FileHelper.java new file mode 100644 index 0000000..ccc5e3e --- /dev/null +++ b/platforms/android/src/org/apache/cordova/camera/FileHelper.java @@ -0,0 +1,319 @@ +/* + 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 android.annotation.SuppressLint; +import android.content.ContentUris; +import android.content.Context; +import android.content.CursorLoader; +import android.database.Cursor; +import android.net.Uri; +import android.os.Build; +import android.os.Environment; +import android.provider.DocumentsContract; +import android.provider.MediaStore; +import android.webkit.MimeTypeMap; + +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.LOG; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; + +public class FileHelper { + private static final String LOG_TAG = "FileUtils"; + private static final String _DATA = "_data"; + + /** + * Returns the real path of the given URI string. + * If the given URI string represents a content:// URI, the real path is retrieved from the media store. + * + * @param uriString the URI string of the audio/image/video + * @param cordova the current application context + * @return the full path to the file + */ + @SuppressWarnings("deprecation") + public static String getRealPath(Uri uri, CordovaInterface cordova) { + String realPath = null; + + if (Build.VERSION.SDK_INT < 11) + realPath = FileHelper.getRealPathFromURI_BelowAPI11(cordova.getActivity(), uri); + + // SDK >= 11 + else + realPath = FileHelper.getRealPathFromURI_API11_And_Above(cordova.getActivity(), uri); + + return realPath; + } + + /** + * Returns the real path of the given URI. + * If the given URI is a content:// URI, the real path is retrieved from the media store. + * + * @param uri the URI of the audio/image/video + * @param cordova the current application context + * @return the full path to the file + */ + public static String getRealPath(String uriString, CordovaInterface cordova) { + return FileHelper.getRealPath(Uri.parse(uriString), cordova); + } + + @SuppressLint("NewApi") + public static String getRealPathFromURI_API11_And_Above(final Context context, final Uri uri) { + + final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; + // DocumentProvider + if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { + + // ExternalStorageProvider + if (isExternalStorageDocument(uri)) { + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; + + if ("primary".equalsIgnoreCase(type)) { + return Environment.getExternalStorageDirectory() + "/" + split[1]; + } + + // TODO handle non-primary volumes + } + // DownloadsProvider + else if (isDownloadsDocument(uri)) { + + final String id = DocumentsContract.getDocumentId(uri); + final Uri contentUri = ContentUris.withAppendedId( + Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); + + return getDataColumn(context, contentUri, null, null); + } + // MediaProvider + else if (isMediaDocument(uri)) { + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; + + Uri contentUri = null; + if ("image".equals(type)) { + contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; + } else if ("video".equals(type)) { + contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; + } else if ("audio".equals(type)) { + contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; + } + + final String selection = "_id=?"; + final String[] selectionArgs = new String[] { + split[1] + }; + + return getDataColumn(context, contentUri, selection, selectionArgs); + } + } + // MediaStore (and general) + else if ("content".equalsIgnoreCase(uri.getScheme())) { + + // Return the remote address + if (isGooglePhotosUri(uri)) + return uri.getLastPathSegment(); + + return getDataColumn(context, uri, null, null); + } + // File + else if ("file".equalsIgnoreCase(uri.getScheme())) { + return uri.getPath(); + } + + return null; + } + + public static String getRealPathFromURI_BelowAPI11(Context context, Uri contentUri) { + String[] proj = { MediaStore.Images.Media.DATA }; + String result = null; + + try { + Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null); + int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); + cursor.moveToFirst(); + result = cursor.getString(column_index); + + } catch (Exception e) { + result = null; + } + return result; + } + + /** + * Returns an input stream based on given URI string. + * + * @param uriString the URI string from which to obtain the input stream + * @param cordova the current application context + * @return an input stream into the data at the given URI or null if given an invalid URI string + * @throws IOException + */ + public static InputStream getInputStreamFromUriString(String uriString, CordovaInterface cordova) + throws IOException { + InputStream returnValue = null; + if (uriString.startsWith("content")) { + Uri uri = Uri.parse(uriString); + returnValue = cordova.getActivity().getContentResolver().openInputStream(uri); + } else if (uriString.startsWith("file://")) { + int question = uriString.indexOf("?"); + if (question > -1) { + uriString = uriString.substring(0, question); + } + if (uriString.startsWith("file:///android_asset/")) { + Uri uri = Uri.parse(uriString); + String relativePath = uri.getPath().substring(15); + returnValue = cordova.getActivity().getAssets().open(relativePath); + } else { + // might still be content so try that first + try { + returnValue = cordova.getActivity().getContentResolver().openInputStream(Uri.parse(uriString)); + } catch (Exception e) { + returnValue = null; + } + if (returnValue == null) { + returnValue = new FileInputStream(getRealPath(uriString, cordova)); + } + } + } else { + returnValue = new FileInputStream(uriString); + } + return returnValue; + } + + /** + * Removes the "file://" prefix from the given URI string, if applicable. + * If the given URI string doesn't have a "file://" prefix, it is returned unchanged. + * + * @param uriString the URI string to operate on + * @return a path without the "file://" prefix + */ + public static String stripFileProtocol(String uriString) { + if (uriString.startsWith("file://")) { + uriString = uriString.substring(7); + } + return uriString; + } + + public static String getMimeTypeForExtension(String path) { + String extension = path; + int lastDot = extension.lastIndexOf('.'); + if (lastDot != -1) { + extension = extension.substring(lastDot + 1); + } + // Convert the URI string to lower case to ensure compatibility with MimeTypeMap (see CB-2185). + extension = extension.toLowerCase(Locale.getDefault()); + if (extension.equals("3ga")) { + return "audio/3gpp"; + } + return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + + /** + * Returns the mime type of the data specified by the given URI string. + * + * @param uriString the URI string of the data + * @return the mime type of the specified data + */ + public static String getMimeType(String uriString, CordovaInterface cordova) { + String mimeType = null; + + Uri uri = Uri.parse(uriString); + if (uriString.startsWith("content://")) { + mimeType = cordova.getActivity().getContentResolver().getType(uri); + } else { + mimeType = getMimeTypeForExtension(uri.getPath()); + } + + return mimeType; + } + + /** + * Get the value of the data column for this Uri. This is useful for + * MediaStore Uris, and other file-based ContentProviders. + * + * @param context The context. + * @param uri The Uri to query. + * @param selection (Optional) Filter used in the query. + * @param selectionArgs (Optional) Selection arguments used in the query. + * @return The value of the _data column, which is typically a file path. + * @author paulburke + */ + public static String getDataColumn(Context context, Uri uri, String selection, + String[] selectionArgs) { + + Cursor cursor = null; + final String column = "_data"; + final String[] projection = { + column + }; + + try { + cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, + null); + if (cursor != null && cursor.moveToFirst()) { + + final int column_index = cursor.getColumnIndexOrThrow(column); + return cursor.getString(column_index); + } + } catch (Exception e) { + return null; + } finally { + if (cursor != null) + cursor.close(); + } + return null; + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is ExternalStorageProvider. + * @author paulburke + */ + public static boolean isExternalStorageDocument(Uri uri) { + return "com.android.externalstorage.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is DownloadsProvider. + * @author paulburke + */ + public static boolean isDownloadsDocument(Uri uri) { + return "com.android.providers.downloads.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is MediaProvider. + * @author paulburke + */ + public static boolean isMediaDocument(Uri uri) { + return "com.android.providers.media.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is Google Photos. + */ + public static boolean isGooglePhotosUri(Uri uri) { + return "com.google.android.apps.photos.content".equals(uri.getAuthority()); + } +} diff --git a/platforms/android/src/org/apache/cordova/device/Device.java b/platforms/android/src/org/apache/cordova/device/Device.java new file mode 100644 index 0000000..e9efcb4 --- /dev/null +++ b/platforms/android/src/org/apache/cordova/device/Device.java @@ -0,0 +1,174 @@ +/* + 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.device; + +import java.util.TimeZone; + +import org.apache.cordova.CordovaWebView; +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CordovaInterface; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import android.provider.Settings; + +public class Device extends CordovaPlugin { + public static final String TAG = "Device"; + + public static String platform; // Device OS + public static String uuid; // Device UUID + + private static final String ANDROID_PLATFORM = "Android"; + private static final String AMAZON_PLATFORM = "amazon-fireos"; + private static final String AMAZON_DEVICE = "Amazon"; + + /** + * Constructor. + */ + public Device() { + } + + /** + * Sets the context of the Command. This can then be used to do things like + * get file paths associated with the Activity. + * + * @param cordova The context of the main Activity. + * @param webView The CordovaWebView Cordova is running in. + */ + public void initialize(CordovaInterface cordova, CordovaWebView webView) { + super.initialize(cordova, webView); + Device.uuid = getUuid(); + } + + /** + * 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 True if the action was valid, false if not. + */ + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + if ("getDeviceInfo".equals(action)) { + JSONObject r = new JSONObject(); + r.put("uuid", Device.uuid); + r.put("version", this.getOSVersion()); + r.put("platform", this.getPlatform()); + r.put("model", this.getModel()); + r.put("manufacturer", this.getManufacturer()); + r.put("isVirtual", this.isVirtual()); + r.put("serial", this.getSerialNumber()); + callbackContext.success(r); + } + else { + return false; + } + return true; + } + + //-------------------------------------------------------------------------- + // LOCAL METHODS + //-------------------------------------------------------------------------- + + /** + * Get the OS name. + * + * @return + */ + public String getPlatform() { + String platform; + if (isAmazonDevice()) { + platform = AMAZON_PLATFORM; + } else { + platform = ANDROID_PLATFORM; + } + return platform; + } + + /** + * Get the device's Universally Unique Identifier (UUID). + * + * @return + */ + public String getUuid() { + String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); + return uuid; + } + + public String getModel() { + String model = android.os.Build.MODEL; + return model; + } + + public String getProductName() { + String productname = android.os.Build.PRODUCT; + return productname; + } + + public String getManufacturer() { + String manufacturer = android.os.Build.MANUFACTURER; + return manufacturer; + } + + public String getSerialNumber() { + String serial = android.os.Build.SERIAL; + return serial; + } + + /** + * Get the OS version. + * + * @return + */ + public String getOSVersion() { + String osversion = android.os.Build.VERSION.RELEASE; + return osversion; + } + + public String getSDKVersion() { + @SuppressWarnings("deprecation") + String sdkversion = android.os.Build.VERSION.SDK; + return sdkversion; + } + + public String getTimeZoneID() { + TimeZone tz = TimeZone.getDefault(); + return (tz.getID()); + } + + /** + * Function to check if the device is manufactured by Amazon + * + * @return + */ + public boolean isAmazonDevice() { + if (android.os.Build.MANUFACTURER.equals(AMAZON_DEVICE)) { + return true; + } + return false; + } + + public boolean isVirtual() { + return android.os.Build.FINGERPRINT.contains("generic") || + android.os.Build.PRODUCT.contains("sdk"); + } + +} diff --git a/platforms/android/src/org/apache/cordova/deviceorientation/CompassListener.java b/platforms/android/src/org/apache/cordova/deviceorientation/CompassListener.java deleted file mode 100644 index 194db0d..0000000 --- a/platforms/android/src/org/apache/cordova/deviceorientation/CompassListener.java +++ /dev/null @@ -1,296 +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.deviceorientation; - -import java.util.List; - -import org.apache.cordova.CordovaWebView; -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.PluginResult; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.content.Context; - -import android.os.Handler; -import android.os.Looper; - -/** - * This class listens to the compass sensor and stores the latest heading value. - */ -public class CompassListener extends CordovaPlugin implements SensorEventListener { - - public static int STOPPED = 0; - public static int STARTING = 1; - public static int RUNNING = 2; - public static int ERROR_FAILED_TO_START = 3; - - public long TIMEOUT = 30000; // Timeout in msec to shut off listener - - int status; // status of listener - float heading; // most recent heading value - long timeStamp; // time of most recent value - long lastAccessTime; // time the value was last retrieved - int accuracy; // accuracy of the sensor - - private SensorManager sensorManager;// Sensor manager - Sensor mSensor; // Compass sensor returned by sensor manager - - private CallbackContext callbackContext; - - /** - * Constructor. - */ - public CompassListener() { - this.heading = 0; - this.timeStamp = 0; - this.setStatus(CompassListener.STOPPED); - } - - /** - * Sets the context of the Command. This can then be used to do things like - * get file paths associated with the Activity. - * - * @param cordova The context of the main Activity. - * @param webView The CordovaWebView Cordova is running in. - */ - public void initialize(CordovaInterface cordova, CordovaWebView webView) { - super.initialize(cordova, webView); - this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE); - } - - /** - * Executes the request and returns PluginResult. - * - * @param action The action to execute. - * @param args JSONArry of arguments for the plugin. - * @param callbackS=Context The callback id used when calling back into JavaScript. - * @return True if the action was valid. - * @throws JSONException - */ - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("start")) { - this.start(); - } - else if (action.equals("stop")) { - this.stop(); - } - else if (action.equals("getStatus")) { - int i = this.getStatus(); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, i)); - } - else if (action.equals("getHeading")) { - // If not running, then this is an async call, so don't worry about waiting - if (this.status != CompassListener.RUNNING) { - int r = this.start(); - if (r == CompassListener.ERROR_FAILED_TO_START) { - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, CompassListener.ERROR_FAILED_TO_START)); - return true; - } - // Set a timeout callback on the main thread. - Handler handler = new Handler(Looper.getMainLooper()); - handler.postDelayed(new Runnable() { - public void run() { - CompassListener.this.timeout(); - } - }, 2000); - } - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, getCompassHeading())); - } - else if (action.equals("setTimeout")) { - this.setTimeout(args.getLong(0)); - } - else if (action.equals("getTimeout")) { - long l = this.getTimeout(); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, l)); - } else { - // Unsupported action - return false; - } - return true; - } - - /** - * Called when listener is to be shut down and object is being destroyed. - */ - public void onDestroy() { - this.stop(); - } - - /** - * Called when app has navigated and JS listeners have been destroyed. - */ - public void onReset() { - this.stop(); - } - - //-------------------------------------------------------------------------- - // LOCAL METHODS - //-------------------------------------------------------------------------- - - /** - * Start listening for compass sensor. - * - * @return status of listener - */ - public int start() { - - // If already starting or running, then just return - if ((this.status == CompassListener.RUNNING) || (this.status == CompassListener.STARTING)) { - return this.status; - } - - // Get compass sensor from sensor manager - @SuppressWarnings("deprecation") - List list = this.sensorManager.getSensorList(Sensor.TYPE_ORIENTATION); - - // If found, then register as listener - if (list != null && list.size() > 0) { - this.mSensor = list.get(0); - this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL); - this.lastAccessTime = System.currentTimeMillis(); - this.setStatus(CompassListener.STARTING); - } - - // If error, then set status to error - else { - this.setStatus(CompassListener.ERROR_FAILED_TO_START); - } - - return this.status; - } - - /** - * Stop listening to compass sensor. - */ - public void stop() { - if (this.status != CompassListener.STOPPED) { - this.sensorManager.unregisterListener(this); - } - this.setStatus(CompassListener.STOPPED); - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - /** - * Called after a delay to time out if the listener has not attached fast enough. - */ - private void timeout() { - if (this.status == CompassListener.STARTING) { - this.setStatus(CompassListener.ERROR_FAILED_TO_START); - if (this.callbackContext != null) { - this.callbackContext.error("Compass listener failed to start."); - } - } - } - - /** - * Sensor listener event. - * - * @param SensorEvent event - */ - public void onSensorChanged(SensorEvent event) { - - // We only care about the orientation as far as it refers to Magnetic North - float heading = event.values[0]; - - // Save heading - this.timeStamp = System.currentTimeMillis(); - this.heading = heading; - this.setStatus(CompassListener.RUNNING); - - // If heading hasn't been read for TIMEOUT time, then turn off compass sensor to save power - if ((this.timeStamp - this.lastAccessTime) > this.TIMEOUT) { - this.stop(); - } - } - - /** - * Get status of compass sensor. - * - * @return status - */ - public int getStatus() { - return this.status; - } - - /** - * Get the most recent compass heading. - * - * @return heading - */ - public float getHeading() { - this.lastAccessTime = System.currentTimeMillis(); - return this.heading; - } - - /** - * Set the timeout to turn off compass sensor if getHeading() hasn't been called. - * - * @param timeout Timeout in msec. - */ - public void setTimeout(long timeout) { - this.TIMEOUT = timeout; - } - - /** - * Get the timeout to turn off compass sensor if getHeading() hasn't been called. - * - * @return timeout in msec - */ - public long getTimeout() { - return this.TIMEOUT; - } - - /** - * Set the status and send it to JavaScript. - * @param status - */ - private void setStatus(int status) { - this.status = status; - } - - /** - * Create the CompassHeading JSON object to be returned to JavaScript - * - * @return a compass heading - */ - private JSONObject getCompassHeading() throws JSONException { - JSONObject obj = new JSONObject(); - - obj.put("magneticHeading", this.getHeading()); - obj.put("trueHeading", this.getHeading()); - // Since the magnetic and true heading are always the same our and accuracy - // is defined as the difference between true and magnetic always return zero - obj.put("headingAccuracy", 0); - obj.put("timestamp", this.timeStamp); - - return obj; - } - -} diff --git a/platforms/android/src/org/apache/cordova/file/PermissionHelper.java b/platforms/android/src/org/apache/cordova/file/PermissionHelper.java index 089da03..778e5ce 100644 --- a/platforms/android/src/org/apache/cordova/file/PermissionHelper.java +++ b/platforms/android/src/org/apache/cordova/file/PermissionHelper.java @@ -1,138 +1,138 @@ -/* - 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.file; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; - -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.LOG; - -import android.content.pm.PackageManager; - -/** - * This class provides reflective methods for permission requesting and checking so that plugins - * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. - */ -public class PermissionHelper { - private static final String LOG_TAG = "CordovaPermissionHelper"; - - /** - * Requests a "dangerous" permission for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermission() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permission request - * @param permission The permission to be requested - */ - public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { - PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); - } - - /** - * Requests "dangerous" permissions for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermissions() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permissions are being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permissions request - * @param permissions The permissions to be requested - */ - public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { - try { - Method requestPermission = CordovaInterface.class.getDeclaredMethod( - "requestPermissions", CordovaPlugin.class, int.class, String[].class); - - // If there is no exception, then this is cordova-android 5.0.0+ - requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); - - // Notify the plugin that all were granted by using more reflection - deliverPermissionResult(plugin, requestCode, permissions); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); - } - } - - /** - * Checks at runtime to see if the application has been granted a permission. This is a helper - * method alternative to cordovaInterface.hasPermission() that does not require the project to - * be built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being checked against - * @param permission The permission to be checked - * - * @return True if the permission has already been granted and false otherwise - */ - public static boolean hasPermission(CordovaPlugin plugin, String permission) { - try { - Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); - - // If there is no exception, then this is cordova-android 5.0.0+ - return (Boolean) hasPermission.invoke(plugin.cordova, permission); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to check for permission " + permission); - return true; - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); - } - return false; - } - - private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { - // Generate the request results - int[] requestResults = new int[permissions.length]; - Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); - - try { - Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( - "onRequestPermissionResult", int.class, String[].class, int[].class); - - onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); - } catch (NoSuchMethodException noSuchMethodException) { - // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it - // made it to this point - LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method may throw a JSONException. We are just duplicating cordova-android's - // exception handling behavior here; all it does is log the exception in CordovaActivity, - // print the stacktrace, and ignore it - LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); - } - } -} +/* + 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.file; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; + +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.LOG; + +import android.content.pm.PackageManager; + +/** + * This class provides reflective methods for permission requesting and checking so that plugins + * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. + */ +public class PermissionHelper { + private static final String LOG_TAG = "CordovaPermissionHelper"; + + /** + * Requests a "dangerous" permission for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermission() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permission request + * @param permission The permission to be requested + */ + public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { + PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); + } + + /** + * Requests "dangerous" permissions for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermissions() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permissions are being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permissions request + * @param permissions The permissions to be requested + */ + public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { + try { + Method requestPermission = CordovaInterface.class.getDeclaredMethod( + "requestPermissions", CordovaPlugin.class, int.class, String[].class); + + // If there is no exception, then this is cordova-android 5.0.0+ + requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); + + // Notify the plugin that all were granted by using more reflection + deliverPermissionResult(plugin, requestCode, permissions); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); + } + } + + /** + * Checks at runtime to see if the application has been granted a permission. This is a helper + * method alternative to cordovaInterface.hasPermission() that does not require the project to + * be built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being checked against + * @param permission The permission to be checked + * + * @return True if the permission has already been granted and false otherwise + */ + public static boolean hasPermission(CordovaPlugin plugin, String permission) { + try { + Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); + + // If there is no exception, then this is cordova-android 5.0.0+ + return (Boolean) hasPermission.invoke(plugin.cordova, permission); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to check for permission " + permission); + return true; + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); + } + return false; + } + + private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { + // Generate the request results + int[] requestResults = new int[permissions.length]; + Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); + + try { + Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( + "onRequestPermissionResult", int.class, String[].class, int[].class); + + onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); + } catch (NoSuchMethodException noSuchMethodException) { + // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it + // made it to this point + LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method may throw a JSONException. We are just duplicating cordova-android's + // exception handling behavior here; all it does is log the exception in CordovaActivity, + // print the stacktrace, and ignore it + LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); + } + } +} diff --git a/platforms/android/src/org/apache/cordova/filetransfer/FileProgressResult.java b/platforms/android/src/org/apache/cordova/filetransfer/FileProgressResult.java deleted file mode 100644 index 76a7b13..0000000 --- a/platforms/android/src/org/apache/cordova/filetransfer/FileProgressResult.java +++ /dev/null @@ -1,63 +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.filetransfer; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Encapsulates in-progress status of uploading or downloading a file to a remote server. - */ -public class FileProgressResult { - - private boolean lengthComputable = false; // declares whether total is known - private long loaded = 0; // bytes sent so far - private long total = 0; // bytes total, if known - - public boolean getLengthComputable() { - return lengthComputable; - } - - public void setLengthComputable(boolean computable) { - this.lengthComputable = computable; - } - - public long getLoaded() { - return loaded; - } - - public void setLoaded(long bytes) { - this.loaded = bytes; - } - - public long getTotal() { - return total; - } - - public void setTotal(long bytes) { - this.total = bytes; - } - - public JSONObject toJSONObject() throws JSONException { - return new JSONObject( - "{loaded:" + loaded + - ",total:" + total + - ",lengthComputable:" + (lengthComputable ? "true" : "false") + "}"); - } -} diff --git a/platforms/android/src/org/apache/cordova/filetransfer/FileTransfer.java b/platforms/android/src/org/apache/cordova/filetransfer/FileTransfer.java deleted file mode 100644 index b9b99dc..0000000 --- a/platforms/android/src/org/apache/cordova/filetransfer/FileTransfer.java +++ /dev/null @@ -1,1024 +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.filetransfer; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.net.HttpURLConnection; -import java.net.URLConnection; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.Iterator; -import java.util.zip.GZIPInputStream; -import java.util.zip.Inflater; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.apache.cordova.Config; -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CordovaResourceApi; -import org.apache.cordova.CordovaResourceApi.OpenForReadResult; -import org.apache.cordova.PluginManager; -import org.apache.cordova.PluginResult; -import org.apache.cordova.Whitelist; -import org.apache.cordova.file.FileUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.net.Uri; -import android.os.Build; -import android.util.Log; -import android.webkit.CookieManager; - -public class FileTransfer extends CordovaPlugin { - - private static final String LOG_TAG = "FileTransfer"; - private static final String LINE_START = "--"; - private static final String LINE_END = "\r\n"; - private static final String BOUNDARY = "+++++"; - - public static int FILE_NOT_FOUND_ERR = 1; - public static int INVALID_URL_ERR = 2; - public static int CONNECTION_ERR = 3; - public static int ABORTED_ERR = 4; - public static int NOT_MODIFIED_ERR = 5; - - private static HashMap activeRequests = new HashMap(); - private static final int MAX_BUFFER_SIZE = 16 * 1024; - - private static final class RequestContext { - String source; - String target; - File targetFile; - CallbackContext callbackContext; - HttpURLConnection connection; - boolean aborted; - RequestContext(String source, String target, CallbackContext callbackContext) { - this.source = source; - this.target = target; - this.callbackContext = callbackContext; - } - void sendPluginResult(PluginResult pluginResult) { - synchronized (this) { - if (!aborted) { - callbackContext.sendPluginResult(pluginResult); - } - } - } - } - - /** - * Adds an interface method to an InputStream to return the number of bytes - * read from the raw stream. This is used to track total progress against - * the HTTP Content-Length header value from the server. - */ - private static abstract class TrackingInputStream extends FilterInputStream { - public TrackingInputStream(final InputStream in) { - super(in); - } - public abstract long getTotalRawBytesRead(); - } - - private static class ExposedGZIPInputStream extends GZIPInputStream { - public ExposedGZIPInputStream(final InputStream in) throws IOException { - super(in); - } - public Inflater getInflater() { - return inf; - } - } - - /** - * Provides raw bytes-read tracking for a GZIP input stream. Reports the - * total number of compressed bytes read from the input, rather than the - * number of uncompressed bytes. - */ - private static class TrackingGZIPInputStream extends TrackingInputStream { - private ExposedGZIPInputStream gzin; - public TrackingGZIPInputStream(final ExposedGZIPInputStream gzin) throws IOException { - super(gzin); - this.gzin = gzin; - } - public long getTotalRawBytesRead() { - return gzin.getInflater().getBytesRead(); - } - } - - /** - * Provides simple total-bytes-read tracking for an existing InputStream - */ - private static class SimpleTrackingInputStream extends TrackingInputStream { - private long bytesRead = 0; - public SimpleTrackingInputStream(InputStream stream) { - super(stream); - } - - private int updateBytesRead(int newBytesRead) { - if (newBytesRead != -1) { - bytesRead += newBytesRead; - } - return newBytesRead; - } - - @Override - public int read() throws IOException { - return updateBytesRead(super.read()); - } - - // Note: FilterInputStream delegates read(byte[] bytes) to the below method, - // so we don't override it or else double count (CB-5631). - @Override - public int read(byte[] bytes, int offset, int count) throws IOException { - return updateBytesRead(super.read(bytes, offset, count)); - } - - public long getTotalRawBytesRead() { - return bytesRead; - } - } - - @Override - public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - if (action.equals("upload") || action.equals("download")) { - String source = args.getString(0); - String target = args.getString(1); - - if (action.equals("upload")) { - upload(source, target, args, callbackContext); - } else { - download(source, target, args, callbackContext); - } - return true; - } else if (action.equals("abort")) { - String objectId = args.getString(0); - abort(objectId); - callbackContext.success(); - return true; - } - return false; - } - - private static void addHeadersToRequest(URLConnection connection, JSONObject headers) { - try { - for (Iterator iter = headers.keys(); iter.hasNext(); ) { - /* RFC 2616 says that non-ASCII characters and control - * characters are not allowed in header names or values. - * Additionally, spaces are not allowed in header names. - * RFC 2046 Quoted-printable encoding may be used to encode - * arbitrary characters, but we donon- not do that encoding here. - */ - String headerKey = iter.next().toString(); - String cleanHeaderKey = headerKey.replaceAll("\\n","") - .replaceAll("\\s+","") - .replaceAll(":", "") - .replaceAll("[^\\x20-\\x7E]+", ""); - - JSONArray headerValues = headers.optJSONArray(headerKey); - if (headerValues == null) { - headerValues = new JSONArray(); - - /* RFC 2616 also says that any amount of consecutive linear - * whitespace within a header value can be replaced with a - * single space character, without affecting the meaning of - * that value. - */ - - String headerValue = headers.getString(headerKey); - String finalValue = headerValue.replaceAll("\\s+", " ").replaceAll("\\n"," ").replaceAll("[^\\x20-\\x7E]+", " "); - headerValues.put(finalValue); - } - - //Use the clean header key, not the one that we passed in - connection.setRequestProperty(cleanHeaderKey, headerValues.getString(0)); - for (int i = 1; i < headerValues.length(); ++i) { - connection.addRequestProperty(headerKey, headerValues.getString(i)); - } - } - } catch (JSONException e1) { - // No headers to be manipulated! - } - } - - private String getCookies(final String target) { - boolean gotCookie = false; - String cookie = null; - Class webViewClass = webView.getClass(); - try { - Method gcmMethod = webViewClass.getMethod("getCookieManager"); - Class iccmClass = gcmMethod.getReturnType(); - Method gcMethod = iccmClass.getMethod("getCookie", String.class); - - cookie = (String)gcMethod.invoke( - iccmClass.cast( - gcmMethod.invoke(webView) - ), target); - - gotCookie = true; - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } catch (ClassCastException e) { - } - - if (!gotCookie && CookieManager.getInstance() != null) { - cookie = CookieManager.getInstance().getCookie(target); - } - - return cookie; - } - - /** - * Uploads the specified file to the server URL provided using an HTTP multipart request. - * @param source Full path of the file on the file system - * @param target URL of the server to receive the file - * @param args JSON Array of args - * @param callbackContext callback id for optional progress reports - * - * args[2] fileKey Name of file request parameter - * args[3] fileName File name to be used on server - * args[4] mimeType Describes file content type - * args[5] params key:value pairs of user-defined parameters - * @return FileUploadResult containing result of upload request - */ - private void upload(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException { - Log.d(LOG_TAG, "upload " + source + " to " + target); - - // Setup the options - final String fileKey = getArgument(args, 2, "file"); - final String fileName = getArgument(args, 3, "image.jpg"); - final String mimeType = getArgument(args, 4, "image/jpeg"); - final JSONObject params = args.optJSONObject(5) == null ? new JSONObject() : args.optJSONObject(5); - final boolean trustEveryone = args.optBoolean(6); - // Always use chunked mode unless set to false as per API - final boolean chunkedMode = args.optBoolean(7) || args.isNull(7); - // Look for headers on the params map for backwards compatibility with older Cordova versions. - final JSONObject headers = args.optJSONObject(8) == null ? params.optJSONObject("headers") : args.optJSONObject(8); - final String objectId = args.getString(9); - final String httpMethod = getArgument(args, 10, "POST"); - - final CordovaResourceApi resourceApi = webView.getResourceApi(); - - Log.d(LOG_TAG, "fileKey: " + fileKey); - Log.d(LOG_TAG, "fileName: " + fileName); - Log.d(LOG_TAG, "mimeType: " + mimeType); - Log.d(LOG_TAG, "params: " + params); - Log.d(LOG_TAG, "trustEveryone: " + trustEveryone); - Log.d(LOG_TAG, "chunkedMode: " + chunkedMode); - Log.d(LOG_TAG, "headers: " + headers); - Log.d(LOG_TAG, "objectId: " + objectId); - Log.d(LOG_TAG, "httpMethod: " + httpMethod); - - final Uri targetUri = resourceApi.remapUri(Uri.parse(target)); - // Accept a path or a URI for the source. - Uri tmpSrc = Uri.parse(source); - final Uri sourceUri = resourceApi.remapUri( - tmpSrc.getScheme() != null ? tmpSrc : Uri.fromFile(new File(source))); - - int uriType = CordovaResourceApi.getUriType(targetUri); - final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS; - if (uriType != CordovaResourceApi.URI_TYPE_HTTP && !useHttps) { - JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target, null, 0, null); - Log.e(LOG_TAG, "Unsupported URI: " + targetUri); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - final RequestContext context = new RequestContext(source, target, callbackContext); - synchronized (activeRequests) { - activeRequests.put(objectId, context); - } - - cordova.getThreadPool().execute(new Runnable() { - public void run() { - if (context.aborted) { - return; - } - HttpURLConnection conn = null; - HostnameVerifier oldHostnameVerifier = null; - SSLSocketFactory oldSocketFactory = null; - int totalBytes = 0; - int fixedLength = -1; - try { - // Create return object - FileUploadResult result = new FileUploadResult(); - FileProgressResult progress = new FileProgressResult(); - - //------------------ CLIENT REQUEST - // Open a HTTP connection to the URL based on protocol - conn = resourceApi.createHttpConnection(targetUri); - if (useHttps && trustEveryone) { - // Setup the HTTPS connection class to trust everyone - HttpsURLConnection https = (HttpsURLConnection)conn; - oldSocketFactory = trustAllHosts(https); - // Save the current hostnameVerifier - oldHostnameVerifier = https.getHostnameVerifier(); - // Setup the connection not to verify hostnames - https.setHostnameVerifier(DO_NOT_VERIFY); - } - - // Allow Inputs - conn.setDoInput(true); - - // Allow Outputs - conn.setDoOutput(true); - - // Don't use a cached copy. - conn.setUseCaches(false); - - // Use a post method. - conn.setRequestMethod(httpMethod); - - // if we specified a Content-Type header, don't do multipart form upload - boolean multipartFormUpload = (headers == null) || !headers.has("Content-Type"); - if (multipartFormUpload) { - conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); - } - - // Set the cookies on the response - String cookie = getCookies(target); - - if (cookie != null) { - conn.setRequestProperty("Cookie", cookie); - } - - // Handle the other headers - if (headers != null) { - addHeadersToRequest(conn, headers); - } - - /* - * Store the non-file portions of the multipart data as a string, so that we can add it - * to the contentSize, since it is part of the body of the HTTP request. - */ - StringBuilder beforeData = new StringBuilder(); - try { - for (Iterator iter = params.keys(); iter.hasNext();) { - Object key = iter.next(); - if(!String.valueOf(key).equals("headers")) - { - beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END); - beforeData.append("Content-Disposition: form-data; name=\"").append(key.toString()).append('"'); - beforeData.append(LINE_END).append(LINE_END); - beforeData.append(params.getString(key.toString())); - beforeData.append(LINE_END); - } - } - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - - beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END); - beforeData.append("Content-Disposition: form-data; name=\"").append(fileKey).append("\";"); - beforeData.append(" filename=\"").append(fileName).append('"').append(LINE_END); - beforeData.append("Content-Type: ").append(mimeType).append(LINE_END).append(LINE_END); - byte[] beforeDataBytes = beforeData.toString().getBytes("UTF-8"); - byte[] tailParamsBytes = (LINE_END + LINE_START + BOUNDARY + LINE_START + LINE_END).getBytes("UTF-8"); - - - // Get a input stream of the file on the phone - OpenForReadResult readResult = resourceApi.openForRead(sourceUri); - - int stringLength = beforeDataBytes.length + tailParamsBytes.length; - if (readResult.length >= 0) { - fixedLength = (int)readResult.length; - if (multipartFormUpload) - fixedLength += stringLength; - progress.setLengthComputable(true); - progress.setTotal(fixedLength); - } - Log.d(LOG_TAG, "Content Length: " + fixedLength); - // setFixedLengthStreamingMode causes and OutOfMemoryException on pre-Froyo devices. - // http://code.google.com/p/android/issues/detail?id=3164 - // It also causes OOM if HTTPS is used, even on newer devices. - boolean useChunkedMode = chunkedMode && (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO || useHttps); - useChunkedMode = useChunkedMode || (fixedLength == -1); - - if (useChunkedMode) { - conn.setChunkedStreamingMode(MAX_BUFFER_SIZE); - // Although setChunkedStreamingMode sets this header, setting it explicitly here works - // around an OutOfMemoryException when using https. - conn.setRequestProperty("Transfer-Encoding", "chunked"); - } else { - conn.setFixedLengthStreamingMode(fixedLength); - } - - conn.connect(); - - OutputStream sendStream = null; - try { - sendStream = conn.getOutputStream(); - synchronized (context) { - if (context.aborted) { - return; - } - context.connection = conn; - } - - if (multipartFormUpload) { - //We don't want to change encoding, we just want this to write for all Unicode. - sendStream.write(beforeDataBytes); - totalBytes += beforeDataBytes.length; - } - - // create a buffer of maximum size - int bytesAvailable = readResult.inputStream.available(); - int bufferSize = Math.min(bytesAvailable, MAX_BUFFER_SIZE); - byte[] buffer = new byte[bufferSize]; - - // read file and write it into form... - int bytesRead = readResult.inputStream.read(buffer, 0, bufferSize); - - long prevBytesRead = 0; - while (bytesRead > 0) { - totalBytes += bytesRead; - result.setBytesSent(totalBytes); - sendStream.write(buffer, 0, bytesRead); - if (totalBytes > prevBytesRead + 102400) { - prevBytesRead = totalBytes; - Log.d(LOG_TAG, "Uploaded " + totalBytes + " of " + fixedLength + " bytes"); - } - bytesAvailable = readResult.inputStream.available(); - bufferSize = Math.min(bytesAvailable, MAX_BUFFER_SIZE); - bytesRead = readResult.inputStream.read(buffer, 0, bufferSize); - - // Send a progress event. - progress.setLoaded(totalBytes); - PluginResult progressResult = new PluginResult(PluginResult.Status.OK, progress.toJSONObject()); - progressResult.setKeepCallback(true); - context.sendPluginResult(progressResult); - } - - if (multipartFormUpload) { - // send multipart form data necessary after file data... - sendStream.write(tailParamsBytes); - totalBytes += tailParamsBytes.length; - } - sendStream.flush(); - } finally { - safeClose(readResult.inputStream); - safeClose(sendStream); - } - synchronized (context) { - context.connection = null; - } - Log.d(LOG_TAG, "Sent " + totalBytes + " of " + fixedLength); - - //------------------ read the SERVER RESPONSE - String responseString; - int responseCode = conn.getResponseCode(); - Log.d(LOG_TAG, "response code: " + responseCode); - Log.d(LOG_TAG, "response headers: " + conn.getHeaderFields()); - TrackingInputStream inStream = null; - try { - inStream = getInputStream(conn); - synchronized (context) { - if (context.aborted) { - return; - } - context.connection = conn; - } - - ByteArrayOutputStream out = new ByteArrayOutputStream(Math.max(1024, conn.getContentLength())); - byte[] buffer = new byte[1024]; - int bytesRead = 0; - // write bytes to file - while ((bytesRead = inStream.read(buffer)) > 0) { - out.write(buffer, 0, bytesRead); - } - responseString = out.toString("UTF-8"); - } finally { - synchronized (context) { - context.connection = null; - } - safeClose(inStream); - } - - Log.d(LOG_TAG, "got response from server"); - Log.d(LOG_TAG, responseString.substring(0, Math.min(256, responseString.length()))); - - // send request and retrieve response - result.setResponseCode(responseCode); - result.setResponse(responseString); - - context.sendPluginResult(new PluginResult(PluginResult.Status.OK, result.toJSONObject())); - } catch (FileNotFoundException e) { - JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, conn, e); - Log.e(LOG_TAG, error.toString(), e); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } catch (IOException e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn, e); - Log.e(LOG_TAG, error.toString(), e); - Log.e(LOG_TAG, "Failed after uploading " + totalBytes + " of " + fixedLength + " bytes."); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - context.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - } catch (Throwable t) { - // Shouldn't happen, but will - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn, t); - Log.e(LOG_TAG, error.toString(), t); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } finally { - synchronized (activeRequests) { - activeRequests.remove(objectId); - } - - if (conn != null) { - // Revert back to the proper verifier and socket factories - // Revert back to the proper verifier and socket factories - if (trustEveryone && useHttps) { - HttpsURLConnection https = (HttpsURLConnection) conn; - https.setHostnameVerifier(oldHostnameVerifier); - https.setSSLSocketFactory(oldSocketFactory); - } - } - } - } - }); - } - - private static void safeClose(Closeable stream) { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - } - } - } - - private static TrackingInputStream getInputStream(URLConnection conn) throws IOException { - String encoding = conn.getContentEncoding(); - if (encoding != null && encoding.equalsIgnoreCase("gzip")) { - return new TrackingGZIPInputStream(new ExposedGZIPInputStream(conn.getInputStream())); - } - return new SimpleTrackingInputStream(conn.getInputStream()); - } - - // always verify the host - don't check for certificate - private static final HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - // Create a trust manager that does not validate certificate chains - private static final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[] {}; - } - - public void checkClientTrusted(X509Certificate[] chain, - String authType) throws CertificateException { - } - - public void checkServerTrusted(X509Certificate[] chain, - String authType) throws CertificateException { - } - } }; - - /** - * This function will install a trust manager that will blindly trust all SSL - * certificates. The reason this code is being added is to enable developers - * to do development using self signed SSL certificates on their web server. - * - * The standard HttpsURLConnection class will throw an exception on self - * signed certificates if this code is not run. - */ - private static SSLSocketFactory trustAllHosts(HttpsURLConnection connection) { - // Install the all-trusting trust manager - SSLSocketFactory oldFactory = connection.getSSLSocketFactory(); - try { - // Install our all trusting manager - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - SSLSocketFactory newFactory = sc.getSocketFactory(); - connection.setSSLSocketFactory(newFactory); - } catch (Exception e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - return oldFactory; - } - - private static JSONObject createFileTransferError(int errorCode, String source, String target, URLConnection connection, Throwable throwable) { - - int httpStatus = 0; - StringBuilder bodyBuilder = new StringBuilder(); - String body = null; - if (connection != null) { - try { - if (connection instanceof HttpURLConnection) { - httpStatus = ((HttpURLConnection)connection).getResponseCode(); - InputStream err = ((HttpURLConnection) connection).getErrorStream(); - if(err != null) - { - BufferedReader reader = new BufferedReader(new InputStreamReader(err, "UTF-8")); - try { - String line = reader.readLine(); - while(line != null) { - bodyBuilder.append(line); - line = reader.readLine(); - if(line != null) { - bodyBuilder.append('\n'); - } - } - body = bodyBuilder.toString(); - } finally { - reader.close(); - } - } - } - // IOException can leave connection object in a bad state, so catch all exceptions. - } catch (Throwable e) { - Log.w(LOG_TAG, "Error getting HTTP status code from connection.", e); - } - } - - return createFileTransferError(errorCode, source, target, body, httpStatus, throwable); - } - - /** - * Create an error object based on the passed in errorCode - * @param errorCode the error - * @return JSONObject containing the error - */ - private static JSONObject createFileTransferError(int errorCode, String source, String target, String body, Integer httpStatus, Throwable throwable) { - JSONObject error = null; - try { - error = new JSONObject(); - error.put("code", errorCode); - error.put("source", source); - error.put("target", target); - if(body != null) - { - error.put("body", body); - } - if (httpStatus != null) { - error.put("http_status", httpStatus); - } - if (throwable != null) { - String msg = throwable.getMessage(); - if (msg == null || "".equals(msg)) { - msg = throwable.toString(); - } - error.put("exception", msg); - } - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - return error; - } - - /** - * Convenience method to read a parameter from the list of JSON args. - * @param args the args passed to the Plugin - * @param position the position to retrieve the arg from - * @param defaultString the default to be used if the arg does not exist - * @return String with the retrieved value - */ - private static String getArgument(JSONArray args, int position, String defaultString) { - String arg = defaultString; - if (args.length() > position) { - arg = args.optString(position); - if (arg == null || "null".equals(arg)) { - arg = defaultString; - } - } - return arg; - } - - /** - * Downloads a file form a given URL and saves it to the specified directory. - * - * @param source URL of the server to receive the file - * @param target Full path of the file on the file system - */ - private void download(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException { - Log.d(LOG_TAG, "download " + source + " to " + target); - - final CordovaResourceApi resourceApi = webView.getResourceApi(); - - final boolean trustEveryone = args.optBoolean(2); - final String objectId = args.getString(3); - final JSONObject headers = args.optJSONObject(4); - - final Uri sourceUri = resourceApi.remapUri(Uri.parse(source)); - // Accept a path or a URI for the source. - Uri tmpTarget = Uri.parse(target); - final Uri targetUri = resourceApi.remapUri( - tmpTarget.getScheme() != null ? tmpTarget : Uri.fromFile(new File(target))); - - int uriType = CordovaResourceApi.getUriType(sourceUri); - final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS; - final boolean isLocalTransfer = !useHttps && uriType != CordovaResourceApi.URI_TYPE_HTTP; - if (uriType == CordovaResourceApi.URI_TYPE_UNKNOWN) { - JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target, null, 0, null); - Log.e(LOG_TAG, "Unsupported URI: " + sourceUri); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - /* This code exists for compatibility between 3.x and 4.x versions of Cordova. - * Previously the CordovaWebView class had a method, getWhitelist, which would - * return a Whitelist object. Since the fixed whitelist is removed in Cordova 4.x, - * the correct call now is to shouldAllowRequest from the plugin manager. - */ - Boolean shouldAllowRequest = null; - if (isLocalTransfer) { - shouldAllowRequest = true; - } - if (shouldAllowRequest == null) { - try { - Method gwl = webView.getClass().getMethod("getWhitelist"); - Whitelist whitelist = (Whitelist)gwl.invoke(webView); - shouldAllowRequest = whitelist.isUrlWhiteListed(source); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - } - if (shouldAllowRequest == null) { - try { - Method gpm = webView.getClass().getMethod("getPluginManager"); - PluginManager pm = (PluginManager)gpm.invoke(webView); - Method san = pm.getClass().getMethod("shouldAllowRequest", String.class); - shouldAllowRequest = (Boolean)san.invoke(pm, source); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - } - - if (!Boolean.TRUE.equals(shouldAllowRequest)) { - Log.w(LOG_TAG, "Source URL is not in white list: '" + source + "'"); - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, null, 401, null); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - - final RequestContext context = new RequestContext(source, target, callbackContext); - synchronized (activeRequests) { - activeRequests.put(objectId, context); - } - - cordova.getThreadPool().execute(new Runnable() { - public void run() { - if (context.aborted) { - return; - } - HttpURLConnection connection = null; - HostnameVerifier oldHostnameVerifier = null; - SSLSocketFactory oldSocketFactory = null; - File file = null; - PluginResult result = null; - TrackingInputStream inputStream = null; - boolean cached = false; - - OutputStream outputStream = null; - try { - OpenForReadResult readResult = null; - - file = resourceApi.mapUriToFile(targetUri); - context.targetFile = file; - - Log.d(LOG_TAG, "Download file:" + sourceUri); - - FileProgressResult progress = new FileProgressResult(); - - if (isLocalTransfer) { - readResult = resourceApi.openForRead(sourceUri); - if (readResult.length != -1) { - progress.setLengthComputable(true); - progress.setTotal(readResult.length); - } - inputStream = new SimpleTrackingInputStream(readResult.inputStream); - } else { - // connect to server - // Open a HTTP connection to the URL based on protocol - connection = resourceApi.createHttpConnection(sourceUri); - if (useHttps && trustEveryone) { - // Setup the HTTPS connection class to trust everyone - HttpsURLConnection https = (HttpsURLConnection)connection; - oldSocketFactory = trustAllHosts(https); - // Save the current hostnameVerifier - oldHostnameVerifier = https.getHostnameVerifier(); - // Setup the connection not to verify hostnames - https.setHostnameVerifier(DO_NOT_VERIFY); - } - - connection.setRequestMethod("GET"); - - // TODO: Make OkHttp use this CookieManager by default. - String cookie = getCookies(sourceUri.toString()); - - if(cookie != null) - { - connection.setRequestProperty("cookie", cookie); - } - - // This must be explicitly set for gzip progress tracking to work. - connection.setRequestProperty("Accept-Encoding", "gzip"); - - // Handle the other headers - if (headers != null) { - addHeadersToRequest(connection, headers); - } - - connection.connect(); - if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) { - cached = true; - connection.disconnect(); - Log.d(LOG_TAG, "Resource not modified: " + source); - JSONObject error = createFileTransferError(NOT_MODIFIED_ERR, source, target, connection, null); - result = new PluginResult(PluginResult.Status.ERROR, error); - } else { - if (connection.getContentEncoding() == null || connection.getContentEncoding().equalsIgnoreCase("gzip")) { - // Only trust content-length header if we understand - // the encoding -- identity or gzip - if (connection.getContentLength() != -1) { - progress.setLengthComputable(true); - progress.setTotal(connection.getContentLength()); - } - } - inputStream = getInputStream(connection); - } - } - - if (!cached) { - try { - synchronized (context) { - if (context.aborted) { - return; - } - context.connection = connection; - } - - // write bytes to file - byte[] buffer = new byte[MAX_BUFFER_SIZE]; - int bytesRead = 0; - outputStream = resourceApi.openOutputStream(targetUri); - while ((bytesRead = inputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, bytesRead); - // Send a progress event. - progress.setLoaded(inputStream.getTotalRawBytesRead()); - PluginResult progressResult = new PluginResult(PluginResult.Status.OK, progress.toJSONObject()); - progressResult.setKeepCallback(true); - context.sendPluginResult(progressResult); - } - } finally { - synchronized (context) { - context.connection = null; - } - safeClose(inputStream); - safeClose(outputStream); - } - - Log.d(LOG_TAG, "Saved file: " + target); - - - // create FileEntry object - Class webViewClass = webView.getClass(); - PluginManager pm = null; - try { - Method gpm = webViewClass.getMethod("getPluginManager"); - pm = (PluginManager) gpm.invoke(webView); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - if (pm == null) { - try { - Field pmf = webViewClass.getField("pluginManager"); - pm = (PluginManager)pmf.get(webView); - } catch (NoSuchFieldException e) { - } catch (IllegalAccessException e) { - } - } - file = resourceApi.mapUriToFile(targetUri); - context.targetFile = file; - FileUtils filePlugin = (FileUtils) pm.getPlugin("File"); - if (filePlugin != null) { - JSONObject fileEntry = filePlugin.getEntryForFile(file); - if (fileEntry != null) { - result = new PluginResult(PluginResult.Status.OK, fileEntry); - } else { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection, null); - Log.e(LOG_TAG, "File plugin cannot represent download path"); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } - } else { - Log.e(LOG_TAG, "File plugin not found; cannot save downloaded file"); - result = new PluginResult(PluginResult.Status.ERROR, "File plugin not found; cannot save downloaded file"); - } - } - } catch (FileNotFoundException e) { - JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection, e); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } catch (IOException e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection, e); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - result = new PluginResult(PluginResult.Status.JSON_EXCEPTION); - } catch (Throwable e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection, e); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } finally { - synchronized (activeRequests) { - activeRequests.remove(objectId); - } - - if (connection != null) { - // Revert back to the proper verifier and socket factories - if (trustEveryone && useHttps) { - HttpsURLConnection https = (HttpsURLConnection) connection; - https.setHostnameVerifier(oldHostnameVerifier); - https.setSSLSocketFactory(oldSocketFactory); - } - } - - if (result == null) { - result = new PluginResult(PluginResult.Status.ERROR, createFileTransferError(CONNECTION_ERR, source, target, connection, null)); - } - // Remove incomplete download. - if (!cached && result.getStatus() != PluginResult.Status.OK.ordinal() && file != null) { - file.delete(); - } - context.sendPluginResult(result); - } - } - }); - } - - /** - * Abort an ongoing upload or download. - */ - private void abort(String objectId) { - final RequestContext context; - synchronized (activeRequests) { - context = activeRequests.remove(objectId); - } - if (context != null) { - // Closing the streams can block, so execute on a background thread. - cordova.getThreadPool().execute(new Runnable() { - public void run() { - synchronized (context) { - File file = context.targetFile; - if (file != null) { - file.delete(); - } - // Trigger the abort callback immediately to minimize latency between it and abort() being called. - JSONObject error = createFileTransferError(ABORTED_ERR, context.source, context.target, null, -1, null); - context.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, error)); - context.aborted = true; - if (context.connection != null) { - try { - context.connection.disconnect(); - } catch (Exception e) { - Log.e(LOG_TAG, "CB-8431 Catch workaround for fatal exception", e); - } - } - } - } - }); - } - } -} diff --git a/platforms/android/src/org/apache/cordova/filetransfer/FileUploadResult.java b/platforms/android/src/org/apache/cordova/filetransfer/FileUploadResult.java deleted file mode 100644 index c24ea78..0000000 --- a/platforms/android/src/org/apache/cordova/filetransfer/FileUploadResult.java +++ /dev/null @@ -1,73 +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.filetransfer; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Encapsulates the result and/or status of uploading a file to a remote server. - */ -public class FileUploadResult { - - private long bytesSent = 0; // bytes sent - private int responseCode = -1; // HTTP response code - private String response = null; // HTTP response - private String objectId = null; // FileTransfer object id - - public long getBytesSent() { - return bytesSent; - } - - public void setBytesSent(long bytes) { - this.bytesSent = bytes; - } - - public int getResponseCode() { - return responseCode; - } - - public void setResponseCode(int responseCode) { - this.responseCode = responseCode; - } - - public String getResponse() { - return response; - } - - public void setResponse(String response) { - this.response = response; - } - - public String getObjectId() { - return objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public JSONObject toJSONObject() throws JSONException { - return new JSONObject( - "{bytesSent:" + bytesSent + - ",responseCode:" + responseCode + - ",response:" + JSONObject.quote(response) + - ",objectId:" + JSONObject.quote(objectId) + "}"); - } -} diff --git a/platforms/android/src/org/apache/cordova/geolocation/Geolocation.java b/platforms/android/src/org/apache/cordova/geolocation/Geolocation.java index 79f0684..3e0bd8a 100644 --- a/platforms/android/src/org/apache/cordova/geolocation/Geolocation.java +++ b/platforms/android/src/org/apache/cordova/geolocation/Geolocation.java @@ -21,10 +21,12 @@ package org.apache.cordova.geolocation; import android.content.pm.PackageManager; import android.Manifest; import android.os.Build; +import android.util.Log; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaArgs; import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PermissionHelper; import org.apache.cordova.PluginResult; import org.apache.cordova.LOG; import org.json.JSONArray; @@ -41,6 +43,7 @@ public class Geolocation extends CordovaPlugin { public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + Log.d(TAG, "We are entering execute"); context = callbackContext; if(action.equals("getPermission")) { @@ -63,18 +66,20 @@ public class Geolocation extends CordovaPlugin { int[] grantResults) throws JSONException { PluginResult result; - for(int r:grantResults) - { - if(r == PackageManager.PERMISSION_DENIED) - { - LOG.d(TAG, "Permission Denied!"); - result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION); - context.sendPluginResult(result); - return; + //This is important if we're using Cordova without using Cordova, but we have the geolocation plugin installed + if(context != null) { + for (int r : grantResults) { + if (r == PackageManager.PERMISSION_DENIED) { + LOG.d(TAG, "Permission Denied!"); + result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION); + context.sendPluginResult(result); + return; + } + } + result = new PluginResult(PluginResult.Status.OK); + context.sendPluginResult(result); } - result = new PluginResult(PluginResult.Status.OK); - context.sendPluginResult(result); } public boolean hasPermisssion() { diff --git a/platforms/android/src/org/apache/cordova/geolocation/PermissionHelper.java b/platforms/android/src/org/apache/cordova/geolocation/PermissionHelper.java deleted file mode 100644 index 50fc4a8..0000000 --- a/platforms/android/src/org/apache/cordova/geolocation/PermissionHelper.java +++ /dev/null @@ -1,138 +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.geolocation; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; - -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.LOG; - -import android.content.pm.PackageManager; - -/** - * This class provides reflective methods for permission requesting and checking so that plugins - * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. - */ -public class PermissionHelper { - private static final String LOG_TAG = "CordovaPermissionHelper"; - - /** - * Requests a "dangerous" permission for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermission() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permission request - * @param permission The permission to be requested - */ - public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { - PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); - } - - /** - * Requests "dangerous" permissions for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermissions() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permissions are being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permissions request - * @param permissions The permissions to be requested - */ - public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { - try { - Method requestPermission = CordovaInterface.class.getDeclaredMethod( - "requestPermissions", CordovaPlugin.class, int.class, String[].class); - - // If there is no exception, then this is cordova-android 5.0.0+ - requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); - - // Notify the plugin that all were granted by using more reflection - deliverPermissionResult(plugin, requestCode, permissions); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); - } - } - - /** - * Checks at runtime to see if the application has been granted a permission. This is a helper - * method alternative to cordovaInterface.hasPermission() that does not require the project to - * be built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being checked against - * @param permission The permission to be checked - * - * @return True if the permission has already been granted and false otherwise - */ - public static boolean hasPermission(CordovaPlugin plugin, String permission) { - try { - Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); - - // If there is no exception, then this is cordova-android 5.0.0+ - return (Boolean) hasPermission.invoke(plugin.cordova, permission); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to check for permission " + permission); - return true; - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); - } - return false; - } - - private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { - // Generate the request results - int[] requestResults = new int[permissions.length]; - Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); - - try { - Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( - "onRequestPermissionResult", int.class, String[].class, int[].class); - - onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); - } catch (NoSuchMethodException noSuchMethodException) { - // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it - // made it to this point - LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method may throw a JSONException. We are just duplicating cordova-android's - // exception handling behavior here; all it does is log the exception in CordovaActivity, - // print the stacktrace, and ignore it - LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); - } - } -} diff --git a/platforms/android/src/org/apache/cordova/media/AudioHandler.java b/platforms/android/src/org/apache/cordova/media/AudioHandler.java index 2ff601d..39702a1 100644 --- a/platforms/android/src/org/apache/cordova/media/AudioHandler.java +++ b/platforms/android/src/org/apache/cordova/media/AudioHandler.java @@ -21,11 +21,13 @@ package org.apache.cordova.media; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaResourceApi; +import org.apache.cordova.PermissionHelper; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.media.AudioManager; +import android.media.AudioManager.OnAudioFocusChangeListener; import android.net.Uri; import android.os.Build; import android.util.Log; @@ -54,8 +56,9 @@ import java.util.HashMap; public class AudioHandler extends CordovaPlugin { public static String TAG = "AudioHandler"; - HashMap players; // Audio player object - ArrayList pausedForPhone; // Audio players that were paused when phone call came in + HashMap players; // Audio player object + ArrayList pausedForPhone; // Audio players that were paused when phone call came in + ArrayList pausedForFocus; // Audio players that were paused when focus was lost private int origVolumeStream = -1; private CallbackContext messageChannel; @@ -75,6 +78,7 @@ public class AudioHandler extends CordovaPlugin { public AudioHandler() { this.players = new HashMap(); this.pausedForPhone = new ArrayList(); + this.pausedForFocus = new ArrayList(); } @@ -164,6 +168,10 @@ public class AudioHandler extends CordovaPlugin { else if (action.equals("messageChannel")) { messageChannel = callbackContext; return true; + } else if (action.equals("getCurrentAmplitudeAudio")) { + float f = this.getCurrentAmplitudeAudio(args.getString(0)); + callbackContext.sendPluginResult(new PluginResult(status, f)); + return true; } else { // Unrecognized action. return false; @@ -292,6 +300,7 @@ public class AudioHandler extends CordovaPlugin { public void startPlayingAudio(String id, String file) { AudioPlayer audio = getOrCreatePlayer(id, file); audio.startPlaying(file); + getAudioFocus(); } /** @@ -371,6 +380,55 @@ public class AudioHandler extends CordovaPlugin { } } + public void pauseAllLostFocus() { + for (AudioPlayer audio : this.players.values()) { + if (audio.getState() == AudioPlayer.STATE.MEDIA_RUNNING.ordinal()) { + this.pausedForFocus.add(audio); + audio.pausePlaying(); + } + } + } + + public void resumeAllGainedFocus() { + for (AudioPlayer audio : this.pausedForFocus) { + audio.startPlaying(null); + } + this.pausedForFocus.clear(); + } + + /** + * Get the the audio focus + */ + private OnAudioFocusChangeListener focusChangeListener = new OnAudioFocusChangeListener() { + public void onAudioFocusChange(int focusChange) { + switch (focusChange) { + case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) : + case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT) : + case (AudioManager.AUDIOFOCUS_LOSS) : + pauseAllLostFocus(); + break; + case (AudioManager.AUDIOFOCUS_GAIN): + resumeAllGainedFocus(); + break; + default: + break; + } + } + }; + + public void getAudioFocus() { + AudioManager am = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE); + int result = am.requestAudioFocus(focusChangeListener, + AudioManager.STREAM_MUSIC, + AudioManager.AUDIOFOCUS_GAIN); + + if (result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { + System.out.println("AudioHandler.getAudioFocus() Error: Got " + result + " instead of " + AudioManager.AUDIOFOCUS_REQUEST_GRANTED); + } + + } + + /** * Get the audio device to be used for playback. * @@ -471,5 +529,16 @@ public class AudioHandler extends CordovaPlugin { } - + /** + * Get current amplitude of recording. + * @param id The id of the audio player + * @return amplitude + */ + public float getCurrentAmplitudeAudio(String id) { + AudioPlayer audio = this.players.get(id); + if (audio != null) { + return (audio.getCurrentAmplitude()); + } + return 0; + } } diff --git a/platforms/android/src/org/apache/cordova/media/AudioPlayer.java b/platforms/android/src/org/apache/cordova/media/AudioPlayer.java index ede9330..26248e5 100644 --- a/platforms/android/src/org/apache/cordova/media/AudioPlayer.java +++ b/platforms/android/src/org/apache/cordova/media/AudioPlayer.java @@ -501,13 +501,13 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On sendErrorStatus(MEDIA_ERR_ABORTED); } return false;//we´re not ready yet - } + } else { //reset the audio file player.seekTo(0); player.pause(); - return true; - } + return true; + } } else { //reset the player this.player.reset(); @@ -598,4 +598,23 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On this.handler.sendEventMessage("status", statusDetails); } + + /** + * Get current amplitude of recording. + * + * @return amplitude or 0 if not recording + */ + public float getCurrentAmplitude() { + if (this.recorder != null) { + try{ + if (this.state == STATE.MEDIA_RUNNING) { + return (float) this.recorder.getMaxAmplitude() / 32762; + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + return 0; + } } diff --git a/platforms/android/src/org/apache/cordova/media/PermissionHelper.java b/platforms/android/src/org/apache/cordova/media/PermissionHelper.java deleted file mode 100644 index aa0ed97..0000000 --- a/platforms/android/src/org/apache/cordova/media/PermissionHelper.java +++ /dev/null @@ -1,138 +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.media; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; - -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.LOG; - -import android.content.pm.PackageManager; - -/** - * This class provides reflective methods for permission requesting and checking so that plugins - * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. - */ -public class PermissionHelper { - private static final String LOG_TAG = "CordovaPermissionHelper"; - - /** - * Requests a "dangerous" permission for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermission() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permission request - * @param permission The permission to be requested - */ - public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { - PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); - } - - /** - * Requests "dangerous" permissions for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermissions() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permissions are being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permissions request - * @param permissions The permissions to be requested - */ - public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { - try { - Method requestPermission = CordovaInterface.class.getDeclaredMethod( - "requestPermissions", CordovaPlugin.class, int.class, String[].class); - - // If there is no exception, then this is cordova-android 5.0.0+ - requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); - - // Notify the plugin that all were granted by using more reflection - deliverPermissionResult(plugin, requestCode, permissions); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); - } - } - - /** - * Checks at runtime to see if the application has been granted a permission. This is a helper - * method alternative to cordovaInterface.hasPermission() that does not require the project to - * be built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being checked against - * @param permission The permission to be checked - * - * @return True if the permission has already been granted and false otherwise - */ - public static boolean hasPermission(CordovaPlugin plugin, String permission) { - try { - Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); - - // If there is no exception, then this is cordova-android 5.0.0+ - return (Boolean) hasPermission.invoke(plugin.cordova, permission); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to check for permission " + permission); - return true; - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); - } - return false; - } - - private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { - // Generate the request results - int[] requestResults = new int[permissions.length]; - Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); - - try { - Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( - "onRequestPermissionResult", int.class, String[].class, int[].class); - - onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); - } catch (NoSuchMethodException noSuchMethodException) { - // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it - // made it to this point - LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method may throw a JSONException. We are just duplicating cordova-android's - // exception handling behavior here; all it does is log the exception in CordovaActivity, - // print the stacktrace, and ignore it - LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); - } - } -} diff --git a/platforms/android/src/org/apache/cordova/mediacapture/Capture.java b/platforms/android/src/org/apache/cordova/mediacapture/Capture.java index 8afed36..0fb0edb 100644 --- a/platforms/android/src/org/apache/cordova/mediacapture/Capture.java +++ b/platforms/android/src/org/apache/cordova/mediacapture/Capture.java @@ -34,15 +34,19 @@ import org.apache.cordova.file.LocalFilesystemURL; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.LOG; +import org.apache.cordova.PermissionHelper; import org.apache.cordova.PluginManager; -import org.apache.cordova.PluginResult; +import org.apache.cordova.mediacapture.PendingRequests.Request; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import android.Manifest; import android.app.Activity; import android.content.ContentValues; import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.database.Cursor; import android.graphics.BitmapFactory; import android.media.MediaPlayer; @@ -67,14 +71,13 @@ public class Capture extends CordovaPlugin { // private static final int CAPTURE_APPLICATION_BUSY = 1; // private static final int CAPTURE_INVALID_ARGUMENT = 2; private static final int CAPTURE_NO_MEDIA_FILES = 3; + private static final int CAPTURE_PERMISSION_DENIED = 4; + + private boolean cameraPermissionInManifest; // Whether or not the CAMERA permission is declared in AndroidManifest.xml + + private final PendingRequests pendingRequests = new PendingRequests(); - private CallbackContext callbackContext; // The callback context from which we were invoked. - private long limit; // the number of pics/vids/clips to take - private int duration; // optional max duration of video recording in seconds - private JSONArray results; // The array of results to be returned to the user private int numPics; // Number of pictures before capture activity - private int quality; // Quality level for video capture 0 low, 1 high - //private CordovaInterface cordova; // public void setContext(Context mCtx) // { @@ -85,33 +88,50 @@ public class Capture extends CordovaPlugin { // } @Override - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - this.callbackContext = callbackContext; - this.limit = 1; - this.duration = 0; - this.results = new JSONArray(); - this.quality = 1; + protected void pluginInitialize() { + super.pluginInitialize(); - JSONObject options = args.optJSONObject(0); - if (options != null) { - limit = options.optLong("limit", 1); - duration = options.optInt("duration", 0); - quality = options.optInt("quality", 1); + // CB-10670: The CAMERA permission does not need to be requested unless it is declared + // in AndroidManifest.xml. This plugin does not declare it, but others may and so we must + // check the package info to determine if the permission is present. + + cameraPermissionInManifest = false; + try { + PackageManager packageManager = this.cordova.getActivity().getPackageManager(); + String[] permissionsInPackage = packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), PackageManager.GET_PERMISSIONS).requestedPermissions; + if (permissionsInPackage != null) { + for (String permission : permissionsInPackage) { + if (permission.equals(Manifest.permission.CAMERA)) { + cameraPermissionInManifest = true; + break; + } + } + } + } catch (NameNotFoundException e) { + // We are requesting the info for our package, so this should + // never be caught + LOG.e(LOG_TAG, "Failed checking for CAMERA permission in manifest", e); } + } + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("getFormatData")) { JSONObject obj = getFormatData(args.getString(0), args.getString(1)); callbackContext.success(obj); return true; } - else if (action.equals("captureAudio")) { - this.captureAudio(); + + JSONObject options = args.optJSONObject(0); + + if (action.equals("captureAudio")) { + this.captureAudio(pendingRequests.createRequest(CAPTURE_AUDIO, options, callbackContext)); } else if (action.equals("captureImage")) { - this.captureImage(); + this.captureImage(pendingRequests.createRequest(CAPTURE_IMAGE, options, callbackContext)); } else if (action.equals("captureVideo")) { - this.captureVideo(duration, quality); + this.captureVideo(pendingRequests.createRequest(CAPTURE_VIDEO, options, callbackContext)); } else { return false; @@ -201,10 +221,10 @@ public class Capture extends CordovaPlugin { /** * Sets up an intent to capture audio. Result handled by onActivityResult() */ - private void captureAudio() { + private void captureAudio(Request req) { Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION); - this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_AUDIO); + this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode); } private String getTempDirectoryPath() { @@ -221,24 +241,40 @@ public class Capture extends CordovaPlugin { /** * Sets up an intent to capture images. Result handled by onActivityResult() */ - private void captureImage() { - // Save the number of images currently on disk for later - this.numPics = queryImgDB(whichContentStore()).getCount(); + private void captureImage(Request req) { + boolean needExternalStoragePermission = + !PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE); + + boolean needCameraPermission = cameraPermissionInManifest && + !PermissionHelper.hasPermission(this, Manifest.permission.CAMERA); + + if (needExternalStoragePermission || needCameraPermission) { + if (needExternalStoragePermission && needCameraPermission) { + PermissionHelper.requestPermissions(this, req.requestCode, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA}); + } else if (needExternalStoragePermission) { + PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.READ_EXTERNAL_STORAGE); + } else { + PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.CAMERA); + } + } else { + // Save the number of images currently on disk for later + this.numPics = queryImgDB(whichContentStore()).getCount(); - Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); + Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); - // Specify file so that large image is captured and returned - File photo = new File(getTempDirectoryPath(), "Capture.jpg"); - try { - // the ACTION_IMAGE_CAPTURE is run under different credentials and has to be granted write permissions - createWritableFile(photo); - } catch (IOException ex) { - this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, ex.toString())); - return; - } - intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); + // Specify file so that large image is captured and returned + File photo = new File(getTempDirectoryPath(), "Capture.jpg"); + try { + // the ACTION_IMAGE_CAPTURE is run under different credentials and has to be granted write permissions + createWritableFile(photo); + } catch (IOException ex) { + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_INTERNAL_ERR, ex.toString())); + return; + } + intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); - this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_IMAGE); + this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode); + } } private static void createWritableFile(File file) throws IOException { @@ -249,14 +285,18 @@ public class Capture extends CordovaPlugin { /** * Sets up an intent to capture video. Result handled by onActivityResult() */ - private void captureVideo(int duration, int quality) { - Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); + private void captureVideo(Request req) { + if(cameraPermissionInManifest && !PermissionHelper.hasPermission(this, Manifest.permission.CAMERA)) { + PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.CAMERA); + } else { + Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); - if(Build.VERSION.SDK_INT > 7){ - intent.putExtra("android.intent.extra.durationLimit", duration); - intent.putExtra("android.intent.extra.videoQuality", quality); + if(Build.VERSION.SDK_INT > 7){ + intent.putExtra("android.intent.extra.durationLimit", req.duration); + intent.putExtra("android.intent.extra.videoQuality", req.quality); + } + this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode); } - this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO); } /** @@ -269,153 +309,147 @@ public class Capture extends CordovaPlugin { * @throws JSONException */ public void onActivityResult(int requestCode, int resultCode, final Intent intent) { + final Request req = pendingRequests.get(requestCode); // Result received okay if (resultCode == Activity.RESULT_OK) { - // An audio clip was requested - if (requestCode == CAPTURE_AUDIO) { - - final Capture that = this; - Runnable captureAudio = new Runnable() { - - @Override - public void run() { - // Get the uri of the audio clip - Uri data = intent.getData(); - // create a file object from the uri - results.put(createMediaFile(data)); - - if (results.length() >= limit) { - // Send Uri back to JavaScript for listening to audio - that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); - } else { - // still need to capture more audio clips - captureAudio(); - } - } - }; - this.cordova.getThreadPool().execute(captureAudio); - } else if (requestCode == CAPTURE_IMAGE) { - // For some reason if I try to do: - // Uri data = intent.getData(); - // It crashes in the emulator and on my phone with a null pointer exception - // To work around it I had to grab the code from CameraLauncher.java - - final Capture that = this; - Runnable captureImage = new Runnable() { - @Override - public void run() { - try { - // TODO Auto-generated method stub - // Create entry in media store for image - // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it) - ContentValues values = new ContentValues(); - values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG); - Uri uri = null; - try { - uri = that.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 = that.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."); - that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found.")); - return; - } - } - FileInputStream fis = new FileInputStream(getTempDirectoryPath() + "/Capture.jpg"); - OutputStream os = that.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(); - - // Add image to results - results.put(createMediaFile(uri)); - - checkForDuplicateImage(); - - if (results.length() >= limit) { - // Send Uri back to JavaScript for viewing image - that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); - } else { - // still need to capture more images - captureImage(); - } - } catch (IOException e) { - e.printStackTrace(); - that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image.")); - } + Runnable processActivityResult = new Runnable() { + @Override + public void run() { + switch(req.action) { + case CAPTURE_AUDIO: + onAudioActivityResult(req, intent); + break; + case CAPTURE_IMAGE: + onImageActivityResult(req); + break; + case CAPTURE_VIDEO: + onVideoActivityResult(req, intent); + break; } - }; - this.cordova.getThreadPool().execute(captureImage); - } else if (requestCode == CAPTURE_VIDEO) { - - final Capture that = this; - Runnable captureVideo = new Runnable() { - - @Override - public void run() { - - Uri data = null; - - if (intent != null){ - // Get the uri of the video clip - data = intent.getData(); - } - - if( data == null){ - File movie = new File(getTempDirectoryPath(), "Capture.avi"); - data = Uri.fromFile(movie); - } - - // create a file object from the uri - if(data == null) - { - that.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null")); - } - else - { - results.put(createMediaFile(data)); - - if (results.length() >= limit) { - // Send Uri back to JavaScript for viewing video - that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); - } else { - // still need to capture more video clips - captureVideo(duration, quality); - } - } - } - }; - this.cordova.getThreadPool().execute(captureVideo); - } + } + }; + + this.cordova.getThreadPool().execute(processActivityResult); } // If canceled else if (resultCode == Activity.RESULT_CANCELED) { // If we have partial results send them back to the user - if (results.length() > 0) { - this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); + if (req.results.length() > 0) { + pendingRequests.resolveWithSuccess(req); } // user canceled the action else { - this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled.")); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled.")); } } // If something else else { // If we have partial results send them back to the user - if (results.length() > 0) { - this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); + if (req.results.length() > 0) { + pendingRequests.resolveWithSuccess(req); } // something bad happened else { - this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!")); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!")); + } + } + } + + + public void onAudioActivityResult(Request req, Intent intent) { + // Get the uri of the audio clip + Uri data = intent.getData(); + // create a file object from the uri + req.results.put(createMediaFile(data)); + + if (req.results.length() >= req.limit) { + // Send Uri back to JavaScript for listening to audio + pendingRequests.resolveWithSuccess(req); + } else { + // still need to capture more audio clips + captureAudio(req); + } + } + + public void onImageActivityResult(Request req) { + // For some reason if I try to do: + // Uri data = intent.getData(); + // It crashes in the emulator and on my phone with a null pointer exception + // To work around it I had to grab the code from CameraLauncher.java + try { + // Create entry in media store for image + // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it) + ContentValues values = new ContentValues(); + values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG); + Uri uri = null; + 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."); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found.")); + return; + } + } + FileInputStream fis = new FileInputStream(getTempDirectoryPath() + "/Capture.jpg"); + 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(); + + // Add image to results + req.results.put(createMediaFile(uri)); + + checkForDuplicateImage(); + + if (req.results.length() >= req.limit) { + // Send Uri back to JavaScript for viewing image + pendingRequests.resolveWithSuccess(req); + } else { + // still need to capture more images + captureImage(req); + } + } catch (IOException e) { + e.printStackTrace(); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image.")); + } + } + + public void onVideoActivityResult(Request req, Intent intent) { + Uri data = null; + + if (intent != null){ + // Get the uri of the video clip + data = intent.getData(); + } + + if( data == null){ + File movie = new File(getTempDirectoryPath(), "Capture.avi"); + data = Uri.fromFile(movie); + } + + // create a file object from the uri + if(data == null) { + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null")); + } + else { + req.results.put(createMediaFile(data)); + + if (req.results.length() >= req.limit) { + // Send Uri back to JavaScript for viewing video + pendingRequests.resolveWithSuccess(req); + } else { + // still need to capture more video clips + captureVideo(req); } } } @@ -491,16 +525,6 @@ public class Capture extends CordovaPlugin { return obj; } - /** - * Send error message to JavaScript. - * - * @param err - */ - public void fail(JSONObject err) { - this.callbackContext.error(err); - } - - /** * Creates a cursor that can be used to determine how many images we have. * @@ -544,4 +568,39 @@ public class Capture extends CordovaPlugin { return android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI; } } + + private void executeRequest(Request req) { + switch (req.action) { + case CAPTURE_AUDIO: + this.captureAudio(req); + break; + case CAPTURE_IMAGE: + this.captureImage(req); + break; + case CAPTURE_VIDEO: + this.captureVideo(req); + break; + } + } + + public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException { + Request req = pendingRequests.get(requestCode); + + if (req != null) { + boolean success = true; + for(int r:grantResults) { + if (r == PackageManager.PERMISSION_DENIED) { + success = false; + break; + } + } + + if (success) { + executeRequest(req); + } else { + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_PERMISSION_DENIED, "Permission denied.")); + } + } + } } diff --git a/platforms/android/src/org/apache/cordova/mediacapture/PendingRequests.java b/platforms/android/src/org/apache/cordova/mediacapture/PendingRequests.java new file mode 100644 index 0000000..5676bd9 --- /dev/null +++ b/platforms/android/src/org/apache/cordova/mediacapture/PendingRequests.java @@ -0,0 +1,132 @@ +/* + 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.mediacapture; + +import android.util.SparseArray; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.PluginResult; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Holds the pending javascript requests for the plugin + */ +public class PendingRequests { + private int currentReqId = 0; + private SparseArray requests = new SparseArray(); + + /** + * Creates a request and adds it to the array of pending requests. Each created request gets a + * unique result code for use with startActivityForResult() and requestPermission() + * @param action The action this request corresponds to (capture image, capture audio, etc.) + * @param options The options for this request passed from the javascript + * @param callbackContext The CallbackContext to return the result to + * @return The newly created Request object with a unique result code + * @throws JSONException + */ + public synchronized Request createRequest(int action, JSONObject options, CallbackContext callbackContext) throws JSONException { + Request req = new Request(action, options, callbackContext); + requests.put(req.requestCode, req); + return req; + } + + /** + * Gets the request corresponding to this request code + * @param requestCode The request code for the desired request + * @return The request corresponding to the given request code or null if such a + * request is not found + */ + public synchronized Request get(int requestCode) { + return requests.get(requestCode); + } + + /** + * Removes the request from the array of pending requests and sends an error plugin result + * to the CallbackContext that contains the given error object + * @param req The request to be resolved + * @param error The error to be returned to the CallbackContext + */ + public synchronized void resolveWithFailure(Request req, JSONObject error) { + req.callbackContext.error(error); + requests.remove(req.requestCode); + } + + /** + * Removes the request from the array of pending requests and sends a successful plugin result + * to the CallbackContext that contains the result of the request + * @param req The request to be resolved + */ + public synchronized void resolveWithSuccess(Request req) { + req.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, req.results)); + requests.remove(req.requestCode); + } + + + /** + * Each request gets a unique ID that represents its request code when calls are made to + * Activities and for permission requests + * @return A unique request code + */ + private synchronized int incrementCurrentReqId() { + return currentReqId ++; + } + + /** + * Holds the options and CallbackContext for a capture request made to the plugin. + */ + public class Request { + + // Unique int used to identify this request in any Android Permission or Activity callbacks + public int requestCode; + + // The action that this request is performing + public int action; + + // The number of pics/vids/audio clips to take (CAPTURE_IMAGE, CAPTURE_VIDEO, CAPTURE_AUDIO) + public long limit = 1; + + // Optional max duration of recording in seconds (CAPTURE_VIDEO only) + public int duration = 0; + + // Quality level for video capture 0 low, 1 high (CAPTURE_VIDEO only) + public int quality = 1; + + // The array of results to be returned to the javascript callback on success + public JSONArray results = new JSONArray(); + + // The callback context for this plugin request + private CallbackContext callbackContext; + + private Request(int action, JSONObject options, CallbackContext callbackContext) throws JSONException { + this.callbackContext = callbackContext; + this.action = action; + + if (options != null) { + this.limit = options.optLong("limit", 1); + this.duration = options.optInt("duration", 0); + this.quality = options.optInt("quality", 1); + } + + this.requestCode = incrementCurrentReqId(); + } + } +} diff --git a/platforms/android/src/org/apache/cordova/networkinformation/NetworkManager.java b/platforms/android/src/org/apache/cordova/networkinformation/NetworkManager.java new file mode 100644 index 0000000..59965bd --- /dev/null +++ b/platforms/android/src/org/apache/cordova/networkinformation/NetworkManager.java @@ -0,0 +1,274 @@ +/* + 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.networkinformation; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PluginResult; +import org.apache.cordova.CordovaWebView; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.util.Log; + +import java.util.Locale; + +public class NetworkManager extends CordovaPlugin { + + public static int NOT_REACHABLE = 0; + public static int REACHABLE_VIA_CARRIER_DATA_NETWORK = 1; + public static int REACHABLE_VIA_WIFI_NETWORK = 2; + + public static final String WIFI = "wifi"; + public static final String WIMAX = "wimax"; + // mobile + public static final String MOBILE = "mobile"; + + // Android L calls this Cellular, because I have no idea! + public static final String CELLULAR = "cellular"; + // 2G network types + public static final String GSM = "gsm"; + public static final String GPRS = "gprs"; + public static final String EDGE = "edge"; + // 3G network types + public static final String CDMA = "cdma"; + public static final String UMTS = "umts"; + public static final String HSPA = "hspa"; + public static final String HSUPA = "hsupa"; + public static final String HSDPA = "hsdpa"; + public static final String ONEXRTT = "1xrtt"; + public static final String EHRPD = "ehrpd"; + // 4G network types + public static final String LTE = "lte"; + public static final String UMB = "umb"; + public static final String HSPA_PLUS = "hspa+"; + // return type + public static final String TYPE_UNKNOWN = "unknown"; + public static final String TYPE_ETHERNET = "ethernet"; + public static final String TYPE_WIFI = "wifi"; + public static final String TYPE_2G = "2g"; + public static final String TYPE_3G = "3g"; + public static final String TYPE_4G = "4g"; + public static final String TYPE_NONE = "none"; + + private static final String LOG_TAG = "NetworkManager"; + + private CallbackContext connectionCallbackContext; + + ConnectivityManager sockMan; + BroadcastReceiver receiver; + private JSONObject lastInfo = null; + + /** + * Sets the context of the Command. This can then be used to do things like + * get file paths associated with the Activity. + * + * @param cordova The context of the main Activity. + * @param webView The CordovaWebView Cordova is running in. + */ + public void initialize(CordovaInterface cordova, CordovaWebView webView) { + super.initialize(cordova, webView); + this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); + this.connectionCallbackContext = null; + + // We need to listen to connectivity events to update navigator.connection + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + if (this.receiver == null) { + this.receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + // (The null check is for the ARM Emulator, please use Intel Emulator for better results) + if(NetworkManager.this.webView != null) + updateConnectionInfo(sockMan.getActiveNetworkInfo()); + } + }; + webView.getContext().registerReceiver(this.receiver, intentFilter); + } + + } + + /** + * 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 True if the action was valid, false otherwise. + */ + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { + if (action.equals("getConnectionInfo")) { + this.connectionCallbackContext = callbackContext; + NetworkInfo info = sockMan.getActiveNetworkInfo(); + String connectionType = ""; + try { + connectionType = this.getConnectionInfo(info).get("type").toString(); + } catch (JSONException e) { } + + PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, connectionType); + pluginResult.setKeepCallback(true); + callbackContext.sendPluginResult(pluginResult); + return true; + } + return false; + } + + /** + * Stop network receiver. + */ + public void onDestroy() { + if (this.receiver != null) { + try { + webView.getContext().unregisterReceiver(this.receiver); + } catch (Exception e) { + Log.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e); + } finally { + receiver = null; + } + } + } + + //-------------------------------------------------------------------------- + // LOCAL METHODS + //-------------------------------------------------------------------------- + + /** + * Updates the JavaScript side whenever the connection changes + * + * @param info the current active network info + * @return + */ + private void updateConnectionInfo(NetworkInfo info) { + // send update to javascript "navigator.network.connection" + // Jellybean sends its own info + JSONObject thisInfo = this.getConnectionInfo(info); + if(!thisInfo.equals(lastInfo)) + { + String connectionType = ""; + try { + connectionType = thisInfo.get("type").toString(); + } catch (JSONException e) { } + + sendUpdate(connectionType); + lastInfo = thisInfo; + } + } + + /** + * Get the latest network connection information + * + * @param info the current active network info + * @return a JSONObject that represents the network info + */ + private JSONObject getConnectionInfo(NetworkInfo info) { + String type = TYPE_NONE; + String extraInfo = ""; + if (info != null) { + // If we are not connected to any network set type to none + if (!info.isConnected()) { + type = TYPE_NONE; + } + else { + type = getType(info); + } + extraInfo = info.getExtraInfo(); + } + + Log.d("CordovaNetworkManager", "Connection Type: " + type); + Log.d("CordovaNetworkManager", "Connection Extra Info: " + extraInfo); + + JSONObject connectionInfo = new JSONObject(); + + try { + connectionInfo.put("type", type); + connectionInfo.put("extraInfo", extraInfo); + } catch (JSONException e) { } + + return connectionInfo; + } + + /** + * Create a new plugin result and send it back to JavaScript + * + * @param connection the network info to set as navigator.connection + */ + private void sendUpdate(String type) { + if (connectionCallbackContext != null) { + PluginResult result = new PluginResult(PluginResult.Status.OK, type); + result.setKeepCallback(true); + connectionCallbackContext.sendPluginResult(result); + } + webView.postMessage("networkconnection", type); + } + + /** + * Determine the type of connection + * + * @param info the network info so we can determine connection type. + * @return the type of mobile network we are on + */ + private String getType(NetworkInfo info) { + if (info != null) { + String type = info.getTypeName().toLowerCase(Locale.US); + + Log.d("CordovaNetworkManager", "toLower : " + type.toLowerCase()); + Log.d("CordovaNetworkManager", "wifi : " + WIFI); + if (type.equals(WIFI)) { + return TYPE_WIFI; + } + else if (type.toLowerCase().equals(TYPE_ETHERNET)) { + return TYPE_ETHERNET; + } + else if (type.equals(MOBILE) || type.equals(CELLULAR)) { + type = info.getSubtypeName().toLowerCase(Locale.US); + if (type.equals(GSM) || + type.equals(GPRS) || + type.equals(EDGE)) { + return TYPE_2G; + } + else if (type.startsWith(CDMA) || + type.equals(UMTS) || + type.equals(ONEXRTT) || + type.equals(EHRPD) || + type.equals(HSUPA) || + type.equals(HSDPA) || + type.equals(HSPA)) { + return TYPE_3G; + } + else if (type.equals(LTE) || + type.equals(UMB) || + type.equals(HSPA_PLUS)) { + return TYPE_4G; + } + } + } + else { + return TYPE_NONE; + } + return TYPE_UNKNOWN; + } +} diff --git a/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java b/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java index 7f91147..d9ac66a 100644 --- a/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java +++ b/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java @@ -25,8 +25,10 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.Configuration; import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.os.Handler; import android.view.Display; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; @@ -35,6 +37,8 @@ import android.view.animation.AlphaAnimation; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; @@ -51,6 +55,7 @@ public class SplashScreen extends CordovaPlugin { private static Dialog splashDialog; private static ProgressDialog spinnerDialog; private static boolean firstShow = true; + private static boolean lastHideAfterDelay; // https://issues.apache.org/jira/browse/CB-9094 /** * Displays the splash drawable. @@ -73,7 +78,7 @@ public class SplashScreen extends CordovaPlugin { @Override protected void pluginInitialize() { - if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) { + if (HAS_BUILT_IN_SPLASH_SCREEN) { return; } // Make WebView invisible while loading URL @@ -93,12 +98,14 @@ public class SplashScreen extends CordovaPlugin { // Save initial orientation. orientation = cordova.getActivity().getResources().getConfiguration().orientation; + if (firstShow) { + boolean autoHide = preferences.getBoolean("AutoHideSplashScreen", true); + showSplashScreen(autoHide); + } + if (preferences.getBoolean("SplashShowOnlyFirstTime", true)) { firstShow = false; } - - loadSpinner(); - showSplashScreen(true); } /** @@ -109,7 +116,7 @@ public class SplashScreen extends CordovaPlugin { } private int getFadeDuration () { - int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) == true ? + int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ? preferences.getInteger("FadeSplashScreenDuration", DEFAULT_SPLASHSCREEN_DURATION) : 0; if (fadeSplashScreenDuration < 30) { @@ -127,7 +134,7 @@ public class SplashScreen extends CordovaPlugin { return; } // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); + this.removeSplashScreen(true); } @Override @@ -136,7 +143,7 @@ public class SplashScreen extends CordovaPlugin { return; } // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); + this.removeSplashScreen(true); // If we set this to true onDestroy, we lose track when we go from page to page! //firstShow = true; } @@ -155,16 +162,6 @@ public class SplashScreen extends CordovaPlugin { webView.postMessage("splashscreen", "show"); } }); - } else if (action.equals("spinnerStart")) { - if (!HAS_BUILT_IN_SPLASH_SCREEN) { - final String title = args.getString(0); - final String message = args.getString(1); - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - spinnerStart(title, message); - } - }); - } } else { return false; } @@ -180,17 +177,16 @@ public class SplashScreen extends CordovaPlugin { } if ("splashscreen".equals(id)) { if ("hide".equals(data.toString())) { - this.removeSplashScreen(); + this.removeSplashScreen(false); } else { this.showSplashScreen(false); } } else if ("spinner".equals(id)) { if ("stop".equals(data.toString())) { - this.spinnerStop(); getView().setVisibility(View.VISIBLE); } } else if ("onReceivedError".equals(id)) { - spinnerStop(); + this.spinnerStop(); } return null; } @@ -210,12 +206,13 @@ public class SplashScreen extends CordovaPlugin { } } - private void removeSplashScreen() { + private void removeSplashScreen(final boolean forceHideImmediately) { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { if (splashDialog != null && splashDialog.isShowing()) { final int fadeSplashScreenDuration = getFadeDuration(); - if (fadeSplashScreenDuration > 0) { + // CB-10692 If the plugin is being paused/destroyed, skip the fading and hide it immediately + if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) { AlphaAnimation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.setDuration(fadeSplashScreenDuration); @@ -226,6 +223,7 @@ public class SplashScreen extends CordovaPlugin { fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { + spinnerStop(); } @Override @@ -242,6 +240,7 @@ public class SplashScreen extends CordovaPlugin { } }); } else { + spinnerStop(); splashDialog.dismiss(); splashDialog = null; splashImageView = null; @@ -260,13 +259,15 @@ public class SplashScreen extends CordovaPlugin { final int drawableId = preferences.getInteger("SplashDrawableId", 0); final int fadeSplashScreenDuration = getFadeDuration(); - final int effectiveSplashDuration = splashscreenTime - fadeSplashScreenDuration; + final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration); + + lastHideAfterDelay = hideAfterDelay; // If the splash dialog is showing don't try to show it again if (splashDialog != null && splashDialog.isShowing()) { return; } - if (drawableId == 0 || (effectiveSplashDuration <= 0 && hideAfterDelay)) { + if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { return; } @@ -309,12 +310,18 @@ public class SplashScreen extends CordovaPlugin { splashDialog.setCancelable(false); splashDialog.show(); + if (preferences.getBoolean("ShowSplashScreenSpinner", true)) { + spinnerStart(); + } + // Set Runnable to remove splash screen just in case if (hideAfterDelay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { - removeSplashScreen(); + if (lastHideAfterDelay) { + removeSplashScreen(false); + } } }, effectiveSplashDuration); } @@ -322,47 +329,38 @@ public class SplashScreen extends CordovaPlugin { }); } - /* - * Load the spinner - */ - private void loadSpinner() { - // If loadingDialog property, then show the App loading dialog for first page of app - String loading = null; - if (webView.canGoBack()) { - loading = preferences.getString("LoadingDialog", null); - } - else { - loading = preferences.getString("LoadingPageDialog", null); - } - if (loading != null) { - String title = ""; - String message = "Loading Application..."; - - if (loading.length() > 0) { - int comma = loading.indexOf(','); - if (comma > 0) { - title = loading.substring(0, comma); - message = loading.substring(comma + 1); - } - else { - title = ""; - message = loading; - } - } - spinnerStart(title, message); - } - } - - private void spinnerStart(final String title, final String message) { + // Show only spinner in the center of the screen + private void spinnerStart() { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { spinnerStop(); - spinnerDialog = ProgressDialog.show(webView.getContext(), title, message, true, true, - new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { - spinnerDialog = null; - } - }); + + spinnerDialog = new ProgressDialog(webView.getContext()); + spinnerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { + public void onCancel(DialogInterface dialog) { + spinnerDialog = null; + } + }); + + spinnerDialog.setCancelable(false); + spinnerDialog.setIndeterminate(true); + + RelativeLayout centeredLayout = new RelativeLayout(cordova.getActivity()); + centeredLayout.setGravity(Gravity.CENTER); + centeredLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + + ProgressBar progressBar = new ProgressBar(webView.getContext()); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + progressBar.setLayoutParams(layoutParams); + + centeredLayout.addView(progressBar); + + spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + spinnerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + + spinnerDialog.show(); + spinnerDialog.setContentView(centeredLayout); } }); } diff --git a/platforms/browser/browser.json b/platforms/browser/browser.json index 656c221..99629ff 100644 --- a/platforms/browser/browser.json +++ b/platforms/browser/browser.json @@ -8,6 +8,14 @@ "config.xml": { "parents": { "/*": [ + { + "xml": "", + "count": 1 + }, + { + "xml": "", + "count": 1 + }, { "xml": "", "count": 1 @@ -18,69 +26,145 @@ } }, "installed_plugins": { - "cordova-plugin-device-orientation": { + "cordova-plugin-compat": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file": { + "cordova-plugin-whitelist": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file-transfer": { + "cordova-plugin-console": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-geolocation": { + "cordova-plugin-device": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media": { + "cordova-plugin-camera": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media-capture": { + "cordova-plugin-splashscreen": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "phonegap-plugin-barcodescanner": { + "cordova-plugin-network-information": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, "cordova-plugin-dialogs": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-splashscreen": { + "cordova-plugin-file": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-whitelist": { + "cordova-plugin-media": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "cordova-plugin-media-capture": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "cordova-plugin-geolocation": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "phonegap-plugin-barcodescanner": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" } }, "dependent_plugins": {}, "modules": [ { - "file": "plugins/cordova-plugin-device-orientation/www/CompassError.js", - "id": "cordova-plugin-device-orientation.CompassError", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-device/www/device.js", + "id": "cordova-plugin-device.device", + "pluginId": "cordova-plugin-device", "clobbers": [ - "CompassError" + "device" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/CompassHeading.js", - "id": "cordova-plugin-device-orientation.CompassHeading", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-device/src/browser/DeviceProxy.js", + "id": "cordova-plugin-device.DeviceProxy", + "pluginId": "cordova-plugin-device", + "runs": true + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraConstants.js", + "id": "cordova-plugin-camera.Camera", + "pluginId": "cordova-plugin-camera", "clobbers": [ - "CompassHeading" + "Camera" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/compass.js", - "id": "cordova-plugin-device-orientation.compass", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js", + "id": "cordova-plugin-camera.CameraPopoverOptions", + "pluginId": "cordova-plugin-camera", "clobbers": [ - "navigator.compass" + "CameraPopoverOptions" ] }, { - "file": "plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js", - "id": "cordova-plugin-device-orientation.CompassProxy", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-camera/www/Camera.js", + "id": "cordova-plugin-camera.camera", + "pluginId": "cordova-plugin-camera", + "clobbers": [ + "navigator.camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/src/browser/CameraProxy.js", + "id": "cordova-plugin-camera.CameraProxy", + "pluginId": "cordova-plugin-camera", + "runs": true + }, + { + "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", + "id": "cordova-plugin-splashscreen.SplashScreen", + "pluginId": "cordova-plugin-splashscreen", + "clobbers": [ + "navigator.splashscreen" + ] + }, + { + "file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js", + "id": "cordova-plugin-splashscreen.SplashScreenProxy", + "pluginId": "cordova-plugin-splashscreen", + "runs": true + }, + { + "file": "plugins/cordova-plugin-network-information/www/network.js", + "id": "cordova-plugin-network-information.network", + "pluginId": "cordova-plugin-network-information", + "clobbers": [ + "navigator.connection", + "navigator.network.connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/Connection.js", + "id": "cordova-plugin-network-information.Connection", + "pluginId": "cordova-plugin-network-information", + "clobbers": [ + "Connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/src/browser/network.js", + "id": "cordova-plugin-network-information.NetworkInfoProxy", + "pluginId": "cordova-plugin-network-information", "runs": true }, + { + "file": "plugins/cordova-plugin-dialogs/www/notification.js", + "id": "cordova-plugin-dialogs.notification", + "pluginId": "cordova-plugin-dialogs", + "merges": [ + "navigator.notification" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/browser/notification.js", + "id": "cordova-plugin-dialogs.notification_browser", + "pluginId": "cordova-plugin-dialogs", + "merges": [ + "navigator.notification" + ] + }, { "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js", "id": "cordova-plugin-file.DirectoryEntry", @@ -260,30 +344,6 @@ "window.FileSystem" ] }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransferError.js", - "id": "cordova-plugin-file-transfer.FileTransferError", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransferError" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransfer.js", - "id": "cordova-plugin-file-transfer.FileTransfer", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransfer" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js", - "id": "cordova-plugin-file-transfer.BrowserFileTransfer", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransfer" - ] - }, { "file": "plugins/cordova-plugin-media/www/MediaError.js", "id": "cordova-plugin-media.MediaError", @@ -383,48 +443,21 @@ "id": "phonegap-plugin-barcodescanner.BarcodeScannerProxy", "pluginId": "phonegap-plugin-barcodescanner", "runs": true - }, - { - "file": "plugins/cordova-plugin-dialogs/www/notification.js", - "id": "cordova-plugin-dialogs.notification", - "pluginId": "cordova-plugin-dialogs", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/browser/notification.js", - "id": "cordova-plugin-dialogs.notification_browser", - "pluginId": "cordova-plugin-dialogs", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", - "id": "cordova-plugin-splashscreen.SplashScreen", - "pluginId": "cordova-plugin-splashscreen", - "clobbers": [ - "navigator.splashscreen" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js", - "id": "cordova-plugin-splashscreen.SplashScreenProxy", - "pluginId": "cordova-plugin-splashscreen", - "runs": true } ], "plugin_metadata": { - "cordova-plugin-device-orientation": "1.0.3-dev", - "cordova-plugin-file": "4.1.2-dev", - "cordova-plugin-file-transfer": "1.5.1-dev", - "cordova-plugin-geolocation": "2.1.0", + "cordova-plugin-compat": "1.0.0", + "cordova-plugin-whitelist": "1.2.1", + "cordova-plugin-console": "1.0.3-dev", + "cordova-plugin-device": "1.1.2-dev", + "cordova-plugin-camera": "2.1.2-dev", + "cordova-plugin-splashscreen": "3.2.2-dev", + "cordova-plugin-network-information": "1.2.1-dev", + "cordova-plugin-dialogs": "1.2.1-dev", + "cordova-plugin-file": "4.1.1", "cordova-plugin-media": "2.2.1-dev", "cordova-plugin-media-capture": "1.2.1-dev", - "phonegap-plugin-barcodescanner": "4.1.0", - "cordova-plugin-dialogs": "1.2.0", - "cordova-plugin-splashscreen": "3.1.0", - "cordova-plugin-whitelist": "1.2.1" + "cordova-plugin-geolocation": "2.1.1-dev", + "phonegap-plugin-barcodescanner": "4.1.0" } } \ No newline at end of file diff --git a/platforms/browser/config.xml b/platforms/browser/config.xml index a110866..f90e409 100644 --- a/platforms/browser/config.xml +++ b/platforms/browser/config.xml @@ -1,9 +1,14 @@ - + + + + + + + - TerranQuest Augmented Reality fantasy game @@ -12,20 +17,21 @@ Netsyms Technologies - - - - - - - - + + + + + + + + + diff --git a/platforms/browser/cordova/node_modules/cordova-serve/.jshintrc b/platforms/browser/cordova/node_modules/cordova-serve/.jshintrc new file mode 100644 index 0000000..6997763 --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/.jshintrc @@ -0,0 +1,11 @@ +{ + "node": true, + "bitwise": true, + "undef": true, + "trailing": true, + "quotmark": true, + "indent": 4, + "unused": "vars", + "latedef": "nofunc", + "-W030": false +} diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/combined-stream/node_modules/delayed-stream/.npmignore b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/combined-stream/node_modules/delayed-stream/.npmignore new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/combined-stream/node_modules/delayed-stream/.npmignore @@ -0,0 +1 @@ +test diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.catn8 b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.catn8 new file mode 100644 index 0000000..8768cab --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.catn8 @@ -0,0 +1,12 @@ +{ + "source" : { + "dir" : "./src", + "files" : ["utils", "vars", "coerce", "diff", "fns", "format", + "lexicalize", "localize", "filters", "formats", "parsers", "expose"] + }, + "target" : { + "dir" : "{pwd}", + "min" : true + }, + "type" : "application/javascript" +} diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.npmignore b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.npmignore new file mode 100644 index 0000000..aaceacc --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.npmignore @@ -0,0 +1,11 @@ +.git* +.DS_Store +.idea + +node_modules +npm-debug.log + +*.bak* +*.local* + +__ignore__ diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.travis.yml b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.travis.yml new file mode 100644 index 0000000..a2f5f9f --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/.travis.yml @@ -0,0 +1,2 @@ +language: node_js +node_js: 0.8 diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.catn8 b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.catn8 new file mode 100644 index 0000000..c531401 --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.catn8 @@ -0,0 +1,11 @@ +{ + "source" : { + "dir" : "./src", + "files" : ["vars", "lib", "lib.x", "nativex", "expose"] + }, + "target" : { + "dir" : "{pwd}", + "min" : true + }, + "type" : "application/javascript" +} diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.nodemonignore b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.nodemonignore new file mode 100644 index 0000000..69161ff --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.nodemonignore @@ -0,0 +1,6 @@ +.git/* +.idea/* +node_modules/* +m8.js +m8.min.js +*.sh diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.npmignore b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.npmignore new file mode 100644 index 0000000..aaceacc --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.npmignore @@ -0,0 +1,11 @@ +.git* +.DS_Store +.idea + +node_modules +npm-debug.log + +*.bak* +*.local* + +__ignore__ diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.travis.yml b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.travis.yml new file mode 100644 index 0000000..a2f5f9f --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/d8/node_modules/m8/.travis.yml @@ -0,0 +1,2 @@ +language: node_js +node_js: 0.8 diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/mime/.npmignore b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/mime/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.documentup.json b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.documentup.json new file mode 100644 index 0000000..57fe301 --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.documentup.json @@ -0,0 +1,6 @@ +{ + "name": "ShellJS", + "twitter": [ + "r2r" + ] +} diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.jshintrc b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.jshintrc new file mode 100644 index 0000000..a80c559 --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.jshintrc @@ -0,0 +1,7 @@ +{ + "loopfunc": true, + "sub": true, + "undef": true, + "unused": true, + "node": true +} \ No newline at end of file diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.npmignore b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.npmignore new file mode 100644 index 0000000..6b20c38 --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.npmignore @@ -0,0 +1,2 @@ +test/ +tmp/ \ No newline at end of file diff --git a/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.travis.yml b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.travis.yml new file mode 100644 index 0000000..1b3280a --- /dev/null +++ b/platforms/browser/cordova/node_modules/cordova-serve/node_modules/shelljs/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.11" + - "0.12" + diff --git a/platforms/browser/cordova/node_modules/nopt/.npmignore b/platforms/browser/cordova/node_modules/nopt/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/platforms/browser/cordova/node_modules/nopt/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/platforms/browser/cordova/node_modules/shelljs/.documentup.json b/platforms/browser/cordova/node_modules/shelljs/.documentup.json new file mode 100644 index 0000000..57fe301 --- /dev/null +++ b/platforms/browser/cordova/node_modules/shelljs/.documentup.json @@ -0,0 +1,6 @@ +{ + "name": "ShellJS", + "twitter": [ + "r2r" + ] +} diff --git a/platforms/browser/cordova/node_modules/shelljs/.npmignore b/platforms/browser/cordova/node_modules/shelljs/.npmignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/platforms/browser/cordova/node_modules/shelljs/.npmignore @@ -0,0 +1 @@ +node_modules/ diff --git a/platforms/browser/cordova/node_modules/shelljs/.travis.yml b/platforms/browser/cordova/node_modules/shelljs/.travis.yml new file mode 100644 index 0000000..5caf599 --- /dev/null +++ b/platforms/browser/cordova/node_modules/shelljs/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.6 + - 0.8 + diff --git a/platforms/browser/cordova/node_modules/shelljs/test/.npmignore b/platforms/browser/cordova/node_modules/shelljs/test/.npmignore new file mode 100644 index 0000000..a1632ab --- /dev/null +++ b/platforms/browser/cordova/node_modules/shelljs/test/.npmignore @@ -0,0 +1,2 @@ +tmp/ + diff --git a/platforms/browser/cordova/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore b/platforms/browser/cordova/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/platforms/browser/cordova/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore b/platforms/browser/cordova/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/platforms/browser/cordova/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore b/platforms/browser/cordova/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/platforms/browser/cordova/node_modules/shelljs/test/resources/find/.hidden b/platforms/browser/cordova/node_modules/shelljs/test/resources/find/.hidden new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/platforms/browser/cordova/node_modules/shelljs/test/resources/find/.hidden @@ -0,0 +1 @@ +asdf diff --git a/platforms/browser/cordova/node_modules/shelljs/test/resources/ls/.hidden_file b/platforms/browser/cordova/node_modules/shelljs/test/resources/ls/.hidden_file new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/platforms/browser/cordova/node_modules/shelljs/test/resources/ls/.hidden_file @@ -0,0 +1 @@ +asdf diff --git a/platforms/browser/platform_www/cordova_plugins.js b/platforms/browser/platform_www/cordova_plugins.js index 024b774..9b75735 100644 --- a/platforms/browser/platform_www/cordova_plugins.js +++ b/platforms/browser/platform_www/cordova_plugins.js @@ -1,35 +1,102 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { module.exports = [ { - "file": "plugins/cordova-plugin-device-orientation/www/CompassError.js", - "id": "cordova-plugin-device-orientation.CompassError", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-device/www/device.js", + "id": "cordova-plugin-device.device", + "pluginId": "cordova-plugin-device", "clobbers": [ - "CompassError" + "device" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/CompassHeading.js", - "id": "cordova-plugin-device-orientation.CompassHeading", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-device/src/browser/DeviceProxy.js", + "id": "cordova-plugin-device.DeviceProxy", + "pluginId": "cordova-plugin-device", + "runs": true + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraConstants.js", + "id": "cordova-plugin-camera.Camera", + "pluginId": "cordova-plugin-camera", + "clobbers": [ + "Camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js", + "id": "cordova-plugin-camera.CameraPopoverOptions", + "pluginId": "cordova-plugin-camera", "clobbers": [ - "CompassHeading" + "CameraPopoverOptions" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/compass.js", - "id": "cordova-plugin-device-orientation.compass", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-camera/www/Camera.js", + "id": "cordova-plugin-camera.camera", + "pluginId": "cordova-plugin-camera", "clobbers": [ - "navigator.compass" + "navigator.camera" ] }, { - "file": "plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js", - "id": "cordova-plugin-device-orientation.CompassProxy", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-camera/src/browser/CameraProxy.js", + "id": "cordova-plugin-camera.CameraProxy", + "pluginId": "cordova-plugin-camera", "runs": true }, + { + "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", + "id": "cordova-plugin-splashscreen.SplashScreen", + "pluginId": "cordova-plugin-splashscreen", + "clobbers": [ + "navigator.splashscreen" + ] + }, + { + "file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js", + "id": "cordova-plugin-splashscreen.SplashScreenProxy", + "pluginId": "cordova-plugin-splashscreen", + "runs": true + }, + { + "file": "plugins/cordova-plugin-network-information/www/network.js", + "id": "cordova-plugin-network-information.network", + "pluginId": "cordova-plugin-network-information", + "clobbers": [ + "navigator.connection", + "navigator.network.connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/Connection.js", + "id": "cordova-plugin-network-information.Connection", + "pluginId": "cordova-plugin-network-information", + "clobbers": [ + "Connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/src/browser/network.js", + "id": "cordova-plugin-network-information.NetworkInfoProxy", + "pluginId": "cordova-plugin-network-information", + "runs": true + }, + { + "file": "plugins/cordova-plugin-dialogs/www/notification.js", + "id": "cordova-plugin-dialogs.notification", + "pluginId": "cordova-plugin-dialogs", + "merges": [ + "navigator.notification" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/browser/notification.js", + "id": "cordova-plugin-dialogs.notification_browser", + "pluginId": "cordova-plugin-dialogs", + "merges": [ + "navigator.notification" + ] + }, { "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js", "id": "cordova-plugin-file.DirectoryEntry", @@ -209,30 +276,6 @@ module.exports = [ "window.FileSystem" ] }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransferError.js", - "id": "cordova-plugin-file-transfer.FileTransferError", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransferError" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransfer.js", - "id": "cordova-plugin-file-transfer.FileTransfer", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransfer" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js", - "id": "cordova-plugin-file-transfer.BrowserFileTransfer", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransfer" - ] - }, { "file": "plugins/cordova-plugin-media/www/MediaError.js", "id": "cordova-plugin-media.MediaError", @@ -332,51 +375,24 @@ module.exports = [ "id": "phonegap-plugin-barcodescanner.BarcodeScannerProxy", "pluginId": "phonegap-plugin-barcodescanner", "runs": true - }, - { - "file": "plugins/cordova-plugin-dialogs/www/notification.js", - "id": "cordova-plugin-dialogs.notification", - "pluginId": "cordova-plugin-dialogs", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/browser/notification.js", - "id": "cordova-plugin-dialogs.notification_browser", - "pluginId": "cordova-plugin-dialogs", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", - "id": "cordova-plugin-splashscreen.SplashScreen", - "pluginId": "cordova-plugin-splashscreen", - "clobbers": [ - "navigator.splashscreen" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js", - "id": "cordova-plugin-splashscreen.SplashScreenProxy", - "pluginId": "cordova-plugin-splashscreen", - "runs": true } ]; module.exports.metadata = // TOP OF METADATA { - "cordova-plugin-device-orientation": "1.0.3-dev", - "cordova-plugin-file": "4.1.2-dev", - "cordova-plugin-file-transfer": "1.5.1-dev", - "cordova-plugin-geolocation": "2.1.0", + "cordova-plugin-compat": "1.0.0", + "cordova-plugin-whitelist": "1.2.1", + "cordova-plugin-console": "1.0.3-dev", + "cordova-plugin-device": "1.1.2-dev", + "cordova-plugin-camera": "2.1.2-dev", + "cordova-plugin-splashscreen": "3.2.2-dev", + "cordova-plugin-network-information": "1.2.1-dev", + "cordova-plugin-dialogs": "1.2.1-dev", + "cordova-plugin-file": "4.1.1", "cordova-plugin-media": "2.2.1-dev", "cordova-plugin-media-capture": "1.2.1-dev", - "phonegap-plugin-barcodescanner": "4.1.0", - "cordova-plugin-dialogs": "1.2.0", - "cordova-plugin-splashscreen": "3.1.0", - "cordova-plugin-whitelist": "1.2.1" + "cordova-plugin-geolocation": "2.1.1-dev", + "phonegap-plugin-barcodescanner": "4.1.0" } // BOTTOM OF METADATA }); \ No newline at end of file diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-camera/src/browser/CameraProxy.js b/platforms/browser/platform_www/plugins/cordova-plugin-camera/src/browser/CameraProxy.js new file mode 100644 index 0000000..03d5778 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-camera/src/browser/CameraProxy.js @@ -0,0 +1,116 @@ +cordova.define("cordova-plugin-camera.CameraProxy", function(require, exports, module) { /* + * + * 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. + * + */ + +var HIGHEST_POSSIBLE_Z_INDEX = 2147483647; + +function takePicture(success, error, opts) { + if (opts && opts[2] === 1) { + capture(success, error); + } else { + var input = document.createElement('input'); + input.style.position = 'relative'; + input.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX; + input.type = 'file'; + input.name = 'files[]'; + + input.onchange = function(inputEvent) { + var reader = new FileReader(); + reader.onload = function(readerEvent) { + input.parentNode.removeChild(input); + + var imageData = readerEvent.target.result; + + return success(imageData.substr(imageData.indexOf(',') + 1)); + }; + + reader.readAsDataURL(inputEvent.target.files[0]); + }; + + document.body.appendChild(input); + } +} + +function capture(success, errorCallback) { + var localMediaStream; + + var video = document.createElement('video'); + var button = document.createElement('button'); + var parent = document.createElement('div'); + parent.style.position = 'relative'; + parent.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX; + parent.appendChild(video); + parent.appendChild(button); + + video.width = 320; + video.height = 240; + button.innerHTML = 'Capture!'; + + button.onclick = function() { + // create a canvas and capture a frame from video stream + var canvas = document.createElement('canvas'); + canvas.getContext('2d').drawImage(video, 0, 0, 320, 240); + + // convert image stored in canvas to base64 encoded image + var imageData = canvas.toDataURL('img/png'); + imageData = imageData.replace('data:image/png;base64,', ''); + + // stop video stream, remove video and button. + // Note that MediaStream.stop() is deprecated as of Chrome 47. + if (localMediaStream.stop) { + localMediaStream.stop(); + } else { + localMediaStream.getTracks().forEach(function (track) { + track.stop(); + }); + } + parent.parentNode.removeChild(parent); + + return success(imageData); + }; + + navigator.getUserMedia = navigator.getUserMedia || + navigator.webkitGetUserMedia || + navigator.mozGetUserMedia || + navigator.msGetUserMedia; + + var successCallback = function(stream) { + localMediaStream = stream; + video.src = window.URL.createObjectURL(localMediaStream); + video.play(); + + document.body.appendChild(parent); + }; + + if (navigator.getUserMedia) { + navigator.getUserMedia({video: true, audio: true}, successCallback, errorCallback); + } else { + alert('Browser does not support camera :('); + } +} + +module.exports = { + takePicture: takePicture, + cleanup: function(){} +}; + +require("cordova/exec/proxy").add("Camera",module.exports); + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/Camera.js b/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/Camera.js new file mode 100644 index 0000000..e69b18a --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/Camera.js @@ -0,0 +1,193 @@ +cordova.define("cordova-plugin-camera.camera", function(require, exports, module) { /* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + exec = require('cordova/exec'), + Camera = require('./Camera'); + // XXX: commented out + //CameraPopoverHandle = require('./CameraPopoverHandle'); + +/** + * @namespace navigator + */ + +/** + * @exports camera + */ +var cameraExport = {}; + +// Tack on the Camera Constants to the base camera plugin. +for (var key in Camera) { + cameraExport[key] = Camera[key]; +} + +/** + * Callback function that provides an error message. + * @callback module:camera.onError + * @param {string} message - The message is provided by the device's native code. + */ + +/** + * Callback function that provides the image data. + * @callback module:camera.onSuccess + * @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect. + * @example + * // Show image + * // + * function cameraCallback(imageData) { + * var image = document.getElementById('myImage'); + * image.src = "data:image/jpeg;base64," + imageData; + * } + */ + +/** + * Optional parameters to customize the camera settings. + * * [Quirks](#CameraOptions-quirks) + * @typedef module:camera.CameraOptions + * @type {Object} + * @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.) + * @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value. + * @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture. + * @property {Boolean} [allowEdit=true] - Allow simple editing of image before selection. + * @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding. + * @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant. + * @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant. + * @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. + * @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture. + * @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture. + * @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad. + * @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing). + */ + +/** + * @description 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 `camera.getPicture` function opens the device's default camera + * application that allows users to snap pictures by default - this behavior occurs, + * when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}. + * 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`]{@link module: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`]{@link module:camera.onSuccess} 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 `` 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__ + * + * - Android + * - BlackBerry + * - Browser + * - Firefox + * - FireOS + * - iOS + * - Windows + * - WP8 + * - Ubuntu + * + * More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks). + * + * @example + * navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + * @param {module:camera.onSuccess} successCallback + * @param {module:camera.onError} errorCallback + * @param {module:camera.CameraOptions} options CameraOptions + */ +cameraExport.getPicture = function(successCallback, errorCallback, options) { + argscheck.checkArgs('fFO', 'Camera.getPicture', arguments); + options = options || {}; + var getValue = argscheck.getValue; + + var quality = getValue(options.quality, 50); + var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI); + var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA); + var targetWidth = getValue(options.targetWidth, -1); + var targetHeight = getValue(options.targetHeight, -1); + var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG); + var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE); + var allowEdit = !!options.allowEdit; + var correctOrientation = !!options.correctOrientation; + var saveToPhotoAlbum = !!options.saveToPhotoAlbum; + var popoverOptions = getValue(options.popoverOptions, null); + var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK); + + var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, + mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection]; + + exec(successCallback, errorCallback, "Camera", "takePicture", args); + // XXX: commented out + //return new CameraPopoverHandle(); +}; + +/** + * Removes intermediate image files that are kept in temporary storage + * after calling [`camera.getPicture`]{@link module: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); + * } + */ +cameraExport.cleanup = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "Camera", "cleanup", []); +}; + +module.exports = cameraExport; + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/CameraConstants.js b/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/CameraConstants.js new file mode 100644 index 0000000..df6cce4 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/CameraConstants.js @@ -0,0 +1,90 @@ +cordova.define("cordova-plugin-camera.Camera", function(require, exports, module) { /* + * + * 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. + * +*/ + +/** + * @module Camera + */ +module.exports = { + /** + * @enum {number} + */ + DestinationType:{ + /** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */ + DATA_URL: 0, + /** Return file uri (content://media/external/images/media/2 for Android) */ + FILE_URI: 1, + /** Return native uri (eg. asset-library://... for iOS) */ + NATIVE_URI: 2 + }, + /** + * @enum {number} + */ + EncodingType:{ + /** Return JPEG encoded image */ + JPEG: 0, + /** Return PNG encoded image */ + PNG: 1 + }, + /** + * @enum {number} + */ + MediaType:{ + /** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */ + PICTURE: 0, + /** Allow selection of video only, ONLY RETURNS URL */ + VIDEO: 1, + /** Allow selection from all media types */ + ALLMEDIA : 2 + }, + /** + * @enum {number} + */ + PictureSourceType:{ + /** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */ + PHOTOLIBRARY : 0, + /** Take picture from camera */ + CAMERA : 1, + /** Choose image from picture library (same as PHOTOLIBRARY for Android) */ + SAVEDPHOTOALBUM : 2 + }, + /** + * Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover. + * @enum {number} + */ + PopoverArrowDirection:{ + ARROW_UP : 1, + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }, + /** + * @enum {number} + */ + Direction:{ + /** Use the back-facing camera */ + BACK: 0, + /** Use the front-facing camera */ + FRONT: 1 + } +}; + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js b/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js new file mode 100644 index 0000000..08d20d3 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js @@ -0,0 +1,54 @@ +cordova.define("cordova-plugin-camera.CameraPopoverOptions", function(require, exports, module) { /* + * + * 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. + * +*/ + +var Camera = require('./Camera'); + +/** + * @namespace navigator + */ + +/** + * 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. + * 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. + * @module CameraPopoverOptions + * @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover. + * @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover. + * @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point. + */ +var CameraPopoverOptions = function (x, y, width, height, arrowDir) { + // information of rectangle that popover should be anchored to + this.x = x || 0; + this.y = y || 32; + this.width = width || 320; + this.height = height || 480; + this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY; +}; + +module.exports = CameraPopoverOptions; + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js b/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js deleted file mode 100644 index 5eccab5..0000000 --- a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js +++ /dev/null @@ -1,47 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassProxy", function(require, exports, module) { /* - * - * 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. - * -*/ - -var Compass = { - getHeading: function(success, error) { - var listener = function() { - var orient = {}; - var heading = (Math.round((Math.random() * 360) * 100) / 100); - - orient.trueHeading = heading; - orient.magneticHeading = heading; - orient.headingAccuracy = 0; - orient.timestamp = new Date().getTime(); - - success(orient); - - window.removeEventListener('deviceorientation', listener, false); - }; - - return window.addEventListener('deviceorientation', listener, false); - } -}; - -var browser = require('cordova/platform'); - -module.exports = Compass; -require('cordova/exec/proxy').add('Compass', Compass); - -}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/CompassError.js b/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/CompassError.js deleted file mode 100644 index 7f9d177..0000000 --- a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/CompassError.js +++ /dev/null @@ -1,36 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassError", function(require, exports, module) { /* - * - * 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. - * -*/ - -/** - * CompassError. - * An error code assigned by an implementation when an error has occurred - * @constructor - */ -var CompassError = function(err) { - this.code = (err !== undefined ? err : null); -}; - -CompassError.COMPASS_INTERNAL_ERR = 0; -CompassError.COMPASS_NOT_SUPPORTED = 20; - -module.exports = CompassError; - -}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js b/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js deleted file mode 100644 index 32bc9b5..0000000 --- a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js +++ /dev/null @@ -1,31 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassHeading", function(require, exports, module) { /* - * - * 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. - * -*/ - -var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) { - this.magneticHeading = magneticHeading; - this.trueHeading = trueHeading; - this.headingAccuracy = headingAccuracy; - this.timestamp = timestamp || new Date().getTime(); -}; - -module.exports = CompassHeading; - -}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/compass.js b/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/compass.js deleted file mode 100644 index c1b7ae6..0000000 --- a/platforms/browser/platform_www/plugins/cordova-plugin-device-orientation/www/compass.js +++ /dev/null @@ -1,120 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.compass", function(require, exports, module) { /* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - utils = require('cordova/utils'), - CompassHeading = require('./CompassHeading'), - CompassError = require('./CompassError'), - - timers = {}, - eventTimerId = null, - compass = { - /** - * Asynchronously acquires the current heading. - * @param {Function} successCallback The function to call when the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {CompassOptions} options The options for getting the heading data (not used). - */ - getCurrentHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments); - - var win = function(result) { - var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp); - successCallback(ch); - }; - var fail = errorCallback && function(code) { - var ce = new CompassError(code); - errorCallback(ce); - }; - - // Get heading - exec(win, fail, "Compass", "getHeading", [options]); - }, - - /** - * Asynchronously acquires the heading repeatedly at a given interval. - * @param {Function} successCallback The function to call each time the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {HeadingOptions} options The options for getting the heading data - * such as timeout and the frequency of the watch. For iOS, filter parameter - * specifies to watch via a distance filter rather than time. - */ - watchHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.watchHeading', arguments); - // Default interval (100 msec) - var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100; - var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0; - - var id = utils.createUUID(); - if (filter > 0) { - // is an iOS request for watch by filter, no timer needed - timers[id] = "iOS"; - compass.getCurrentHeading(successCallback, errorCallback, options); - } else { - // Start watch timer to get headings - timers[id] = window.setInterval(function() { - compass.getCurrentHeading(successCallback, errorCallback); - }, frequency); - } - - if (cordova.platformId === 'browser' && !eventTimerId) { - // Start firing deviceorientation events if haven't already - var deviceorientationEvent = new Event('deviceorientation'); - eventTimerId = window.setInterval(function() { - window.dispatchEvent(deviceorientationEvent); - }, 200); - } - - return id; - }, - - /** - * Clears the specified heading watch. - * @param {String} id The ID of the watch returned from #watchHeading. - */ - clearWatch:function(id) { - // Stop javascript timer & remove from timer list - if (id && timers[id]) { - if (timers[id] != "iOS") { - clearInterval(timers[id]); - } else { - // is iOS watch by filter so call into device to stop - exec(null, null, "Compass", "stopHeading", []); - } - delete timers[id]; - - if (eventTimerId && Object.keys(timers).length === 0) { - // No more watchers, so stop firing 'deviceorientation' events - window.clearInterval(eventTimerId); - eventTimerId = null; - } - } - } - }; - -module.exports = compass; - -}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-device/src/browser/DeviceProxy.js b/platforms/browser/platform_www/plugins/cordova-plugin-device/src/browser/DeviceProxy.js new file mode 100644 index 0000000..f62801d --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-device/src/browser/DeviceProxy.js @@ -0,0 +1,84 @@ +cordova.define("cordova-plugin-device.DeviceProxy", function(require, exports, module) { /* + * + * 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. + * + */ +var browser = require('cordova/platform'); + +function getPlatform() { + return "browser"; +} + +function getModel() { + return getBrowserInfo(true); +} + +function getVersion() { + return getBrowserInfo(false); +} + +function getBrowserInfo(getModel) { + var userAgent = navigator.userAgent; + var returnVal = ''; + var offset; + + if ((offset = userAgent.indexOf('Chrome')) !== -1) { + returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); + } else if ((offset = userAgent.indexOf('Safari')) !== -1) { + if (getModel) { + returnVal = 'Safari'; + } else { + returnVal = userAgent.substring(offset + 7); + + if ((offset = userAgent.indexOf('Version')) !== -1) { + returnVal = userAgent.substring(offset + 8); + } + } + } else if ((offset = userAgent.indexOf('Firefox')) !== -1) { + returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8); + } else if ((offset = userAgent.indexOf('MSIE')) !== -1) { + returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5); + } else if ((offset = userAgent.indexOf('Trident')) !== -1) { + returnVal = (getModel) ? 'MSIE' : '11'; + } + + if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) { + returnVal = returnVal.substring(0, offset); + } + + return returnVal; +} + + +module.exports = { + getDeviceInfo: function (success, error) { + setTimeout(function () { + success({ + cordova: browser.cordovaVersion, + platform: getPlatform(), + model: getModel(), + version: getVersion(), + uuid: null + }); + }, 0); + } +}; + +require("cordova/exec/proxy").add("Device", module.exports); + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-device/www/device.js b/platforms/browser/platform_www/plugins/cordova-plugin-device/www/device.js new file mode 100644 index 0000000..ff0c5b4 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-device/www/device.js @@ -0,0 +1,85 @@ +cordova.define("cordova-plugin-device.device", function(require, exports, module) { /* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + channel = require('cordova/channel'), + utils = require('cordova/utils'), + exec = require('cordova/exec'), + cordova = require('cordova'); + +channel.createSticky('onCordovaInfoReady'); +// Tell cordova channel to wait on the CordovaInfoReady event +channel.waitForInitialization('onCordovaInfoReady'); + +/** + * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the + * phone, etc. + * @constructor + */ +function Device() { + this.available = false; + this.platform = null; + this.version = null; + this.uuid = null; + this.cordova = null; + this.model = null; + this.manufacturer = null; + this.isVirtual = null; + this.serial = null; + + var me = this; + + channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js + //TODO: CB-5105 native implementations should not return info.cordova + var buildLabel = cordova.version; + me.available = true; + me.platform = info.platform; + me.version = info.version; + me.uuid = info.uuid; + me.cordova = buildLabel; + me.model = info.model; + me.isVirtual = info.isVirtual; + me.manufacturer = info.manufacturer || 'unknown'; + me.serial = info.serial || 'unknown'; + channel.onCordovaInfoReady.fire(); + },function(e) { + me.available = false; + utils.alert("[ERROR] Error initializing Cordova: " + e); + }); + }); +} + +/** + * Get device info + * + * @param {Function} successCallback The function to call when the heading data is available + * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL) + */ +Device.prototype.getInfo = function(successCallback, errorCallback) { + argscheck.checkArgs('fF', 'Device.getInfo', arguments); + exec(successCallback, errorCallback, "Device", "getDeviceInfo", []); +}; + +module.exports = new Device(); + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-dialogs/www/browser/notification.js b/platforms/browser/platform_www/plugins/cordova-plugin-dialogs/www/browser/notification.js index 661f02b..b66573e 100644 --- a/platforms/browser/platform_www/plugins/cordova-plugin-dialogs/www/browser/notification.js +++ b/platforms/browser/platform_www/plugins/cordova-plugin-dialogs/www/browser/notification.js @@ -65,6 +65,21 @@ module.exports.prompt = window.navigator.notification.prompt = function(message, }; +var audioContext = (function() { + // Determine if the Audio API is supported by this browser + var AudioApi = window.AudioContext; + if (!AudioApi) { + AudioApi = window.webkitAudioContext; + } + + if (AudioApi) { + // The Audio API is supported, so create a singleton instance of the AudioContext + return new AudioApi(); + } + + return undefined; +}()); + module.exports.beep = window.navigator.notification.beep = function(times) { if (times > 0) { var BEEP_DURATION = 700; @@ -99,19 +114,4 @@ module.exports.beep = window.navigator.notification.beep = function(times) { } }; -var audioContext = (function() { - // Determine if the Audio API is supported by this browser - var AudioApi = window.AudioContext; - if (!AudioApi) { - AudioApi = window.webkitAudioContext; - } - - if (AudioApi) { - // The Audio API is supported, so create a singleton instance of the AudioContext - return new AudioApi(); - } - - return undefined; -}()); - }); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js deleted file mode 100644 index ff0e6c9..0000000 --- a/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js +++ /dev/null @@ -1,237 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransfer", function(require, exports, module) { /* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - FileTransferError = require('./FileTransferError'), - ProgressEvent = require('cordova-plugin-file.ProgressEvent'); - -function newProgressEvent(result) { - var pe = new ProgressEvent(); - pe.lengthComputable = result.lengthComputable; - pe.loaded = result.loaded; - pe.total = result.total; - return pe; -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function convertHeadersToArray(headers) { - var result = []; - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - var headerValue = headers[header]; - result.push({ - name: header, - value: headerValue.toString() - }); - } - } - return result; -} - -var idCounter = 0; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** -* Given an absolute file path, uploads a file on the device to a remote server -* using a multipart HTTP request. -* @param filePath {String} Full path of the file on the device -* @param server {String} URL of the server to receive the file -* @param successCallback (Function} Callback to be invoked when upload has completed -* @param errorCallback {Function} Callback to be invoked upon error -* @param options {FileUploadOptions} Optional parameters such as file name and mimetype -* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false -*/ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - // check for options - var fileKey = null; - var fileName = null; - var mimeType = null; - var params = null; - var chunkedMode = true; - var headers = null; - var httpMethod = null; - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - if (options) { - fileKey = options.fileKey; - fileName = options.fileName; - mimeType = options.mimeType; - headers = options.headers; - httpMethod = options.httpMethod || "POST"; - if (httpMethod.toUpperCase() == "PUT"){ - httpMethod = "PUT"; - } else { - httpMethod = "POST"; - } - if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { - chunkedMode = options.chunkedMode; - } - if (options.params) { - params = options.params; - } - else { - params = {}; - } - } - - if (cordova.platformId === "windowsphone") { - headers = headers && convertHeadersToArray(headers); - params = params && convertHeadersToArray(params); - } - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - var self = this; - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - self.onprogress(newProgressEvent(result)); - } - } else { - successCallback && successCallback(result); - } - }; - exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - var self = this; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var headers = null; - if (options) { - headers = options.headers || null; - } - - if (cordova.platformId === "windowsphone" && headers) { - headers = convertHeadersToArray(headers); - } - - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - return self.onprogress(newProgressEvent(result)); - } - } else if (successCallback) { - var entry = null; - if (result.isDirectory) { - entry = new (require('cordova-plugin-file.DirectoryEntry'))(); - } - else if (result.isFile) { - entry = new (require('cordova-plugin-file.FileEntry'))(); - } - entry.isDirectory = result.isDirectory; - entry.isFile = result.isFile; - entry.name = result.name; - entry.fullPath = result.fullPath; - entry.filesystem = new FileSystem(result.filesystemName || (result.filesystem == window.PERSISTENT ? 'persistent' : 'temporary')); - entry.nativeURL = result.nativeURL; - successCallback(entry); - } - }; - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - exec(null, null, 'FileTransfer', 'abort', [this._id]); -}; - -module.exports = FileTransfer; - -}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js deleted file mode 100644 index 8339c2b..0000000 --- a/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js +++ /dev/null @@ -1,43 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransferError", function(require, exports, module) { /* - * - * 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. - * -*/ - -/** - * FileTransferError - * @constructor - */ -var FileTransferError = function(code, source, target, status, body, exception) { - this.code = code || null; - this.source = source || null; - this.target = target || null; - this.http_status = status || null; - this.body = body || null; - this.exception = exception || null; -}; - -FileTransferError.FILE_NOT_FOUND_ERR = 1; -FileTransferError.INVALID_URL_ERR = 2; -FileTransferError.CONNECTION_ERR = 3; -FileTransferError.ABORT_ERR = 4; -FileTransferError.NOT_MODIFIED_ERR = 5; - -module.exports = FileTransferError; - -}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js b/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js deleted file mode 100644 index 7c76828..0000000 --- a/platforms/browser/platform_www/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js +++ /dev/null @@ -1,330 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.BrowserFileTransfer", function(require, exports, module) { /* - * - * 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. - * -*/ - -/*global module, require*/ - -var argscheck = require('cordova/argscheck'), - FileTransferError = require('./FileTransferError'); - -function getParentPath(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(0, pos + 1); -} - -function getFileName(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(pos + 1); -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function checkURL(url) { - return url.indexOf(' ') === -1 ? true : false; -} - -var idCounter = 0; - -var transfers = {}; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** - * Given an absolute file path, uploads a file on the device to a remote server - * using a multipart HTTP request. - * @param filePath {String} Full path of the file on the device - * @param server {String} URL of the server to receive the file - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param options {FileUploadOptions} Optional parameters such as file name and mimetype - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - */ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options) { - // check for arguments - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - - // Check if target URL doesn't contain spaces. If contains, it should be escaped first - // (see https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#upload) - if (!checkURL(server)) { - errorCallback && errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR, filePath, server)); - return; - } - - options = options || {}; - - var fileKey = options.fileKey || "file"; - var fileName = options.fileName || "image.jpg"; - var mimeType = options.mimeType || "image/jpeg"; - var params = options.params || {}; - var withCredentials = options.withCredentials || false; - // var chunkedMode = !!options.chunkedMode; // Not supported - var headers = options.headers || {}; - var httpMethod = options.httpMethod && options.httpMethod.toUpperCase() === "PUT" ? "PUT" : "POST"; - - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var that = this; - var xhr = transfers[this._id] = new XMLHttpRequest(); - xhr.withCredentials = withCredentials; - - var fail = errorCallback && function(code, status, response) { - transfers[this._id] && delete transfers[this._id]; - var error = new FileTransferError(code, filePath, server, status, response); - errorCallback && errorCallback(error); - }; - - window.resolveLocalFileSystemURL(filePath, function(entry) { - entry.file(function(file) { - var reader = new FileReader(); - reader.onloadend = function() { - var blob = new Blob([this.result], {type: mimeType}); - - // Prepare form data to send to server - var fd = new FormData(); - fd.append(fileKey, blob, fileName); - for (var prop in params) { - if (params.hasOwnProperty(prop)) { - fd.append(prop, params[prop]); - } - } - - xhr.open(httpMethod, server); - - // Fill XHR headers - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr.setRequestHeader(header, headers[header]); - } - } - - xhr.onload = function() { - if (this.status === 200) { - var result = new FileUploadResult(); // jshint ignore:line - result.bytesSent = blob.size; - result.responseCode = this.status; - result.response = this.response; - delete transfers[that._id]; - successCallback(result); - } else if (this.status === 404) { - fail(FileTransferError.INVALID_URL_ERR, this.status, this.response); - } else { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - } - }; - - xhr.ontimeout = function() { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onerror = function() { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onabort = function () { - fail(FileTransferError.ABORT_ERR, this.status, this.response); - }; - - xhr.upload.onprogress = function (e) { - that.onprogress && that.onprogress(e); - }; - - xhr.send(fd); - // Special case when transfer already aborted, but XHR isn't sent. - // In this case XHR won't fire an abort event, so we need to check if transfers record - // isn't deleted by filetransfer.abort and if so, call XHR's abort method again - if (!transfers[that._id]) { - xhr.abort(); - } - }; - reader.readAsArrayBuffer(file); - }, function() { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }); - }, function() { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - - // Check if target URL doesn't contain spaces. If contains, it should be escaped first - // (see https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#download) - if (!checkURL(source)) { - errorCallback && errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target)); - return; - } - - options = options || {}; - - var headers = options.headers || {}; - var withCredentials = options.withCredentials || false; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var that = this; - var xhr = transfers[this._id] = new XMLHttpRequest(); - xhr.withCredentials = withCredentials; - var fail = errorCallback && function(code, status, response) { - transfers[that._id] && delete transfers[that._id]; - // In XHR GET reqests we're setting response type to Blob - // but in case of error we need to raise event with plain text response - if (response instanceof Blob) { - var reader = new FileReader(); - reader.readAsText(response); - reader.onloadend = function(e) { - var error = new FileTransferError(code, source, target, status, e.target.result); - errorCallback(error); - }; - } else { - var error = new FileTransferError(code, source, target, status, response); - errorCallback(error); - } - }; - - xhr.onload = function (e) { - - var fileNotFound = function () { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }; - - var req = e.target; - // req.status === 0 is special case for local files with file:// URI scheme - if ((req.status === 200 || req.status === 0) && req.response) { - window.resolveLocalFileSystemURL(getParentPath(target), function (dir) { - dir.getFile(getFileName(target), {create: true}, function writeFile(entry) { - entry.createWriter(function (fileWriter) { - fileWriter.onwriteend = function (evt) { - if (!evt.target.error) { - entry.filesystemName = entry.filesystem.name; - delete transfers[that._id]; - successCallback && successCallback(entry); - } else { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - } - }; - fileWriter.onerror = function () { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }; - fileWriter.write(req.response); - }, fileNotFound); - }, fileNotFound); - }, fileNotFound); - } else if (req.status === 404) { - fail(FileTransferError.INVALID_URL_ERR, req.status, req.response); - } else { - fail(FileTransferError.CONNECTION_ERR, req.status, req.response); - } - }; - - xhr.onprogress = function (e) { - that.onprogress && that.onprogress(e); - }; - - xhr.onerror = function () { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onabort = function () { - fail(FileTransferError.ABORT_ERR, this.status, this.response); - }; - - xhr.open("GET", source, true); - - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr.setRequestHeader(header, headers[header]); - } - } - - xhr.responseType = "blob"; - - xhr.send(); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - if (this instanceof FileTransfer) { - if (transfers[this._id]) { - transfers[this._id].abort(); - delete transfers[this._id]; - } - } -}; - -module.exports = FileTransfer; - -}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js b/platforms/browser/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js index 42083da..1421b21 100644 --- a/platforms/browser/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js +++ b/platforms/browser/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js @@ -1,28 +1,28 @@ -cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) { /* - * - * 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. - * - */ - -module.exports = function () { - // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and - // possibly a good flag to indicate that we're running in Chrome - return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; -}; +cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) { /* + * + * 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. + * + */ + +module.exports = function () { + // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and + // possibly a good flag to indicate that we're running in Chrome + return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; +}; }); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js b/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js index 812abf0..b2f5b45 100644 --- a/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js +++ b/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js @@ -92,6 +92,7 @@ function CameraUI() { * @param {Function} errorCB Error callback */ CameraUI.prototype.startPreview = function(count, successCB, errorCB) { + var that = this; this.preview.onclick = function (e) { // proceed with capture here @@ -113,7 +114,6 @@ CameraUI.prototype.startPreview = function(count, successCB, errorCB) { errorCB(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }; - var that = this; navigator.getUserMedia({video: true}, function (previewStream) { // Save video stream to be able to stop it later that._previewStream = previewStream; @@ -133,24 +133,31 @@ CameraUI.prototype.destroyPreview = function () { this.preview.src = null; this._previewStream.stop(); this._previewStream = null; - this.container && document.body.removeChild(this.container); + if (this.container) { + document.body.removeChild(this.container); + } }; module.exports = { - captureAudio:function(successCallback, errorCallback) { - errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + if (errorCallback) { + errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + } }, captureVideo:function (successCallback, errorCallback) { - errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + if (errorCallback) { + errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + } }, captureImage:function (successCallback, errorCallback, args) { var fail = function (code) { - errorCallback && errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR)); + if (errorCallback) { + errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR)); + } }; var options = args[0]; @@ -217,7 +224,9 @@ module.exports = { var img = document.createElement('img'); img.src = args[0]; img.onload = function () { - successCallback && successCallback(new MediaFileData(null, 0, img.height, img.width, 0)); + if (successCallback) { + successCallback(new MediaFileData(null, 0, img.height, img.width, 0)); + } }; } }; diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js b/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js index c4eba1e..e73ac80 100644 --- a/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js +++ b/platforms/browser/platform_www/plugins/cordova-plugin-media-capture/www/CaptureError.js @@ -34,6 +34,8 @@ CaptureError.CAPTURE_APPLICATION_BUSY = 1; CaptureError.CAPTURE_INVALID_ARGUMENT = 2; // User exited camera application or audio capture application before capturing anything. CaptureError.CAPTURE_NO_MEDIA_FILES = 3; +// User denied permissions required to perform the capture request. +CaptureError.CAPTURE_PERMISSION_DENIED = 4; // The requested capture operation is not supported. CaptureError.CAPTURE_NOT_SUPPORTED = 20; diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-media/www/Media.js b/platforms/browser/platform_www/plugins/cordova-plugin-media/www/Media.js index 96620db..c3aa111 100644 --- a/platforms/browser/platform_www/plugins/cordova-plugin-media/www/Media.js +++ b/platforms/browser/platform_www/plugins/cordova-plugin-media/www/Media.js @@ -159,10 +159,18 @@ Media.prototype.setRate = function(rate) { if (cordova.platformId === 'ios'){ exec(null, null, "Media", "setRate", [this.id, rate]); } else { - console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.') + console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.'); } }; +/** + * Get amplitude of audio. + */ +Media.prototype.getCurrentAmplitude = function(success, fail) { + exec(function(p) { + success(p); + }, fail, "Media", "getCurrentAmplitudeAudio", [this.id]); +}; /** * Audio has status update. @@ -176,30 +184,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value == Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value == Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } - else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-media/www/browser/Media.js b/platforms/browser/platform_www/plugins/cordova-plugin-media/www/browser/Media.js index 350ebab..5422b50 100644 --- a/platforms/browser/platform_www/plugins/cordova-plugin-media/www/browser/Media.js +++ b/platforms/browser/platform_www/plugins/cordova-plugin-media/www/browser/Media.js @@ -19,13 +19,45 @@ cordova.define("cordova-plugin-media.BrowserMedia", function(require, exports, m * */ -/*global MediaError, module, require*/ +/* global MediaError */ var argscheck = require('cordova/argscheck'), utils = require('cordova/utils'); var mediaObjects = {}; +/** + * This class provides access to the device media, interfaces to both sound and video + * + * @constructor + * @param src The file name or url to play + * @param successCallback The callback to be called when the file is done playing or recording. + * successCallback() + * @param errorCallback The callback to be called if there is an error. + * errorCallback(int errorCode) - OPTIONAL + * @param statusCallback The callback to be called when media status has changed. + * statusCallback(int statusCode) - OPTIONAL + */ +var Media = function(src, successCallback, errorCallback, statusCallback) { + argscheck.checkArgs('SFFF', 'Media', arguments); + this.id = utils.createUUID(); + mediaObjects[this.id] = this; + this.src = src; + this.successCallback = successCallback; + this.errorCallback = errorCallback; + this.statusCallback = statusCallback; + this._duration = -1; + this._position = -1; + + Media.onStatus(this.id, Media.MEDIA_STATE, Media.MEDIA_STARTING); + + try { + this.node = createNode(this); + } catch (err) { + Media.onStatus(this.id, Media.MEDIA_ERROR, { code: MediaError.MEDIA_ERR_ABORTED }); + } +}; + /** * Creates new Audio node and with necessary event listeners attached * @param {Media} media Media object @@ -66,38 +98,6 @@ function createNode (media) { return node; } -/** - * This class provides access to the device media, interfaces to both sound and video - * - * @constructor - * @param src The file name or url to play - * @param successCallback The callback to be called when the file is done playing or recording. - * successCallback() - * @param errorCallback The callback to be called if there is an error. - * errorCallback(int errorCode) - OPTIONAL - * @param statusCallback The callback to be called when media status has changed. - * statusCallback(int statusCode) - OPTIONAL - */ -var Media = function(src, successCallback, errorCallback, statusCallback) { - argscheck.checkArgs('SFFF', 'Media', arguments); - this.id = utils.createUUID(); - mediaObjects[this.id] = this; - this.src = src; - this.successCallback = successCallback; - this.errorCallback = errorCallback; - this.statusCallback = statusCallback; - this._duration = -1; - this._position = -1; - - Media.onStatus(this.id, Media.MEDIA_STATE, Media.MEDIA_STARTING); - - try { - this.node = createNode(this); - } catch (err) { - Media.onStatus(this.id, Media.MEDIA_ERROR, { code: MediaError.MEDIA_ERR_ABORTED }); - } -}; - // Media messages Media.MEDIA_STATE = 1; Media.MEDIA_DURATION = 2; @@ -230,29 +230,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value === Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value === Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-network-information/src/browser/network.js b/platforms/browser/platform_www/plugins/cordova-plugin-network-information/src/browser/network.js new file mode 100644 index 0000000..fb11242 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-network-information/src/browser/network.js @@ -0,0 +1,50 @@ +cordova.define("cordova-plugin-network-information.NetworkInfoProxy", function(require, exports, module) { /* + * 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. + * +*/ + +var cordova = require('cordova'), + proxy = require("cordova/exec/proxy"), + Connection = require('./Connection'); + +var type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + +// Subscribe to 'native' online/offline events +function onStatusChange(evt) { + type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + // force async + setTimeout(function(){ + cordova.fireDocumentEvent(evt.type); + },0); +} + +window.addEventListener('online', onStatusChange); +window.addEventListener('offline', onStatusChange); + +proxy.add("NetworkStatus", { + getConnectionInfo:function(cbSuccess) { + // force async + setTimeout(function(){ + cbSuccess(type); + },0); + } +}); + + + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-network-information/www/Connection.js b/platforms/browser/platform_www/plugins/cordova-plugin-network-information/www/Connection.js new file mode 100644 index 0000000..1450e95 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-network-information/www/Connection.js @@ -0,0 +1,36 @@ +cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) { /* + * + * 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. + * +*/ + +/** + * Network status + */ +module.exports = { + UNKNOWN: "unknown", + ETHERNET: "ethernet", + WIFI: "wifi", + CELL_2G: "2g", + CELL_3G: "3g", + CELL_4G: "4g", + CELL:"cellular", + NONE: "none" +}; + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-network-information/www/network.js b/platforms/browser/platform_www/plugins/cordova-plugin-network-information/www/network.js new file mode 100644 index 0000000..bfac2e3 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-network-information/www/network.js @@ -0,0 +1,93 @@ +cordova.define("cordova-plugin-network-information.network", function(require, exports, module) { /* + * 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. + * +*/ + +var exec = require('cordova/exec'), + cordova = require('cordova'), + channel = require('cordova/channel'), + utils = require('cordova/utils'); + +// Link the onLine property with the Cordova-supplied network info. +// This works because we clobber the navigator object with our own +// object in bootstrap.js. +// Browser platform do not need to define this property, because +// it is already supported by modern browsers +if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') { + utils.defineGetter(navigator, 'onLine', function() { + return this.connection.type != 'none'; + }); +} + +function NetworkConnection() { + this.type = 'unknown'; +} + +/** + * Get connection info + * + * @param {Function} successCallback The function to call when the Connection data is available + * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL) + */ +NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []); +}; + +var me = new NetworkConnection(); +var timerId = null; +var timeout = 500; + +channel.createSticky('onCordovaConnectionReady'); +channel.waitForInitialization('onCordovaConnectionReady'); + +channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + me.type = info; + if (info === "none") { + // set a timer if still offline at the end of timer send the offline event + timerId = setTimeout(function(){ + cordova.fireDocumentEvent("offline"); + timerId = null; + }, timeout); + } else { + // If there is a current offline event pending clear it + if (timerId !== null) { + clearTimeout(timerId); + timerId = null; + } + cordova.fireDocumentEvent("online"); + } + + // should only fire this once + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + }, + function (e) { + // If we can't get the network info we should still tell Cordova + // to fire the deviceready event. + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + console.log("Error initializing Network Connection: " + e); + }); +}); + +module.exports = me; + +}); diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js b/platforms/browser/platform_www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js index b01d8f8..2d1db9f 100644 --- a/platforms/browser/platform_www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js +++ b/platforms/browser/platform_www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js @@ -18,17 +18,18 @@ cordova.define("cordova-plugin-splashscreen.SplashScreenProxy", function(require * under the License. * */ + // Default parameter values including image size can be changed in `config.xml` var splashImageWidth = 170; var splashImageHeight = 200; var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight }; -var splash = null; // var localSplash; // the image to display var localSplashImage; var bgColor = "#464646"; -var imageSrc = 'img/logo.png'; +var imageSrc = '/img/logo.png'; var splashScreenDelay = 3000; // in milliseconds var showSplashScreen = true; // show splashcreen by default +var cordova = require('cordova'); var configHelper = cordova.require('cordova/confighelper'); function updateImageLocation() { @@ -103,7 +104,6 @@ function readPreferencesFromCfg(cfg) { } catch(e) { var msg = '[Browser][SplashScreen] Error occured on loading preferences from config.xml: ' + JSON.stringify(e); console.error(msg); - error(msg); } } diff --git a/platforms/browser/www/assets/badges/alphatester.png b/platforms/browser/www/assets/badges/alphatester.png new file mode 100644 index 0000000..9059f3f Binary files /dev/null and b/platforms/browser/www/assets/badges/alphatester.png differ diff --git a/platforms/browser/www/assets/bars.svg b/platforms/browser/www/assets/bars.svg new file mode 100644 index 0000000..a3cd72b --- /dev/null +++ b/platforms/browser/www/assets/bars.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/platforms/browser/www/config.xml b/platforms/browser/www/config.xml index a110866..f90e409 100644 --- a/platforms/browser/www/config.xml +++ b/platforms/browser/www/config.xml @@ -1,9 +1,14 @@ - + + + + + + + - TerranQuest Augmented Reality fantasy game @@ -12,20 +17,21 @@ Netsyms Technologies - - - - - - - - + + + + + + + + + diff --git a/platforms/browser/www/cordova_plugins.js b/platforms/browser/www/cordova_plugins.js index 024b774..9b75735 100644 --- a/platforms/browser/www/cordova_plugins.js +++ b/platforms/browser/www/cordova_plugins.js @@ -1,35 +1,102 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { module.exports = [ { - "file": "plugins/cordova-plugin-device-orientation/www/CompassError.js", - "id": "cordova-plugin-device-orientation.CompassError", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-device/www/device.js", + "id": "cordova-plugin-device.device", + "pluginId": "cordova-plugin-device", "clobbers": [ - "CompassError" + "device" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/CompassHeading.js", - "id": "cordova-plugin-device-orientation.CompassHeading", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-device/src/browser/DeviceProxy.js", + "id": "cordova-plugin-device.DeviceProxy", + "pluginId": "cordova-plugin-device", + "runs": true + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraConstants.js", + "id": "cordova-plugin-camera.Camera", + "pluginId": "cordova-plugin-camera", + "clobbers": [ + "Camera" + ] + }, + { + "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js", + "id": "cordova-plugin-camera.CameraPopoverOptions", + "pluginId": "cordova-plugin-camera", "clobbers": [ - "CompassHeading" + "CameraPopoverOptions" ] }, { - "file": "plugins/cordova-plugin-device-orientation/www/compass.js", - "id": "cordova-plugin-device-orientation.compass", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-camera/www/Camera.js", + "id": "cordova-plugin-camera.camera", + "pluginId": "cordova-plugin-camera", "clobbers": [ - "navigator.compass" + "navigator.camera" ] }, { - "file": "plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js", - "id": "cordova-plugin-device-orientation.CompassProxy", - "pluginId": "cordova-plugin-device-orientation", + "file": "plugins/cordova-plugin-camera/src/browser/CameraProxy.js", + "id": "cordova-plugin-camera.CameraProxy", + "pluginId": "cordova-plugin-camera", "runs": true }, + { + "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", + "id": "cordova-plugin-splashscreen.SplashScreen", + "pluginId": "cordova-plugin-splashscreen", + "clobbers": [ + "navigator.splashscreen" + ] + }, + { + "file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js", + "id": "cordova-plugin-splashscreen.SplashScreenProxy", + "pluginId": "cordova-plugin-splashscreen", + "runs": true + }, + { + "file": "plugins/cordova-plugin-network-information/www/network.js", + "id": "cordova-plugin-network-information.network", + "pluginId": "cordova-plugin-network-information", + "clobbers": [ + "navigator.connection", + "navigator.network.connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/www/Connection.js", + "id": "cordova-plugin-network-information.Connection", + "pluginId": "cordova-plugin-network-information", + "clobbers": [ + "Connection" + ] + }, + { + "file": "plugins/cordova-plugin-network-information/src/browser/network.js", + "id": "cordova-plugin-network-information.NetworkInfoProxy", + "pluginId": "cordova-plugin-network-information", + "runs": true + }, + { + "file": "plugins/cordova-plugin-dialogs/www/notification.js", + "id": "cordova-plugin-dialogs.notification", + "pluginId": "cordova-plugin-dialogs", + "merges": [ + "navigator.notification" + ] + }, + { + "file": "plugins/cordova-plugin-dialogs/www/browser/notification.js", + "id": "cordova-plugin-dialogs.notification_browser", + "pluginId": "cordova-plugin-dialogs", + "merges": [ + "navigator.notification" + ] + }, { "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js", "id": "cordova-plugin-file.DirectoryEntry", @@ -209,30 +276,6 @@ module.exports = [ "window.FileSystem" ] }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransferError.js", - "id": "cordova-plugin-file-transfer.FileTransferError", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransferError" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/FileTransfer.js", - "id": "cordova-plugin-file-transfer.FileTransfer", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransfer" - ] - }, - { - "file": "plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js", - "id": "cordova-plugin-file-transfer.BrowserFileTransfer", - "pluginId": "cordova-plugin-file-transfer", - "clobbers": [ - "window.FileTransfer" - ] - }, { "file": "plugins/cordova-plugin-media/www/MediaError.js", "id": "cordova-plugin-media.MediaError", @@ -332,51 +375,24 @@ module.exports = [ "id": "phonegap-plugin-barcodescanner.BarcodeScannerProxy", "pluginId": "phonegap-plugin-barcodescanner", "runs": true - }, - { - "file": "plugins/cordova-plugin-dialogs/www/notification.js", - "id": "cordova-plugin-dialogs.notification", - "pluginId": "cordova-plugin-dialogs", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-dialogs/www/browser/notification.js", - "id": "cordova-plugin-dialogs.notification_browser", - "pluginId": "cordova-plugin-dialogs", - "merges": [ - "navigator.notification" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js", - "id": "cordova-plugin-splashscreen.SplashScreen", - "pluginId": "cordova-plugin-splashscreen", - "clobbers": [ - "navigator.splashscreen" - ] - }, - { - "file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js", - "id": "cordova-plugin-splashscreen.SplashScreenProxy", - "pluginId": "cordova-plugin-splashscreen", - "runs": true } ]; module.exports.metadata = // TOP OF METADATA { - "cordova-plugin-device-orientation": "1.0.3-dev", - "cordova-plugin-file": "4.1.2-dev", - "cordova-plugin-file-transfer": "1.5.1-dev", - "cordova-plugin-geolocation": "2.1.0", + "cordova-plugin-compat": "1.0.0", + "cordova-plugin-whitelist": "1.2.1", + "cordova-plugin-console": "1.0.3-dev", + "cordova-plugin-device": "1.1.2-dev", + "cordova-plugin-camera": "2.1.2-dev", + "cordova-plugin-splashscreen": "3.2.2-dev", + "cordova-plugin-network-information": "1.2.1-dev", + "cordova-plugin-dialogs": "1.2.1-dev", + "cordova-plugin-file": "4.1.1", "cordova-plugin-media": "2.2.1-dev", "cordova-plugin-media-capture": "1.2.1-dev", - "phonegap-plugin-barcodescanner": "4.1.0", - "cordova-plugin-dialogs": "1.2.0", - "cordova-plugin-splashscreen": "3.1.0", - "cordova-plugin-whitelist": "1.2.1" + "cordova-plugin-geolocation": "2.1.1-dev", + "phonegap-plugin-barcodescanner": "4.1.0" } // BOTTOM OF METADATA }); \ No newline at end of file diff --git a/platforms/browser/www/css/leaflet.css b/platforms/browser/www/css/leaflet.css index dea175f..c161c31 100644 --- a/platforms/browser/www/css/leaflet.css +++ b/platforms/browser/www/css/leaflet.css @@ -1,479 +1,479 @@ -/* required styles */ - -.leaflet-map-pane, -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow, -.leaflet-tile-pane, -.leaflet-tile-container, -.leaflet-overlay-pane, -.leaflet-shadow-pane, -.leaflet-marker-pane, -.leaflet-popup-pane, -.leaflet-overlay-pane svg, -.leaflet-zoom-box, -.leaflet-image-layer, -.leaflet-layer { - position: absolute; - left: 0; - top: 0; - } -.leaflet-container { - overflow: hidden; - -ms-touch-action: none; - touch-action: none; - } -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow { - -webkit-user-select: none; - -moz-user-select: none; - user-select: none; - -webkit-user-drag: none; - } -.leaflet-marker-icon, -.leaflet-marker-shadow { - display: block; - } -/* map is broken in FF if you have max-width: 100% on tiles */ -.leaflet-container img { - max-width: none !important; - } -/* stupid Android 2 doesn't understand "max-width: none" properly */ -.leaflet-container img.leaflet-image-layer { - max-width: 15000px !important; - } -.leaflet-tile { - filter: inherit; - visibility: hidden; - } -.leaflet-tile-loaded { - visibility: inherit; - } -.leaflet-zoom-box { - width: 0; - height: 0; - } -/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ -.leaflet-overlay-pane svg { - -moz-user-select: none; - } - -.leaflet-tile-pane { z-index: 2; } -.leaflet-objects-pane { z-index: 3; } -.leaflet-overlay-pane { z-index: 4; } -.leaflet-shadow-pane { z-index: 5; } -.leaflet-marker-pane { z-index: 6; } -.leaflet-popup-pane { z-index: 7; } - -.leaflet-vml-shape { - width: 1px; - height: 1px; - } -.lvml { - behavior: url(#default#VML); - display: inline-block; - position: absolute; - } - - -/* control positioning */ - -.leaflet-control { - position: relative; - z-index: 7; - pointer-events: auto; - } -.leaflet-top, -.leaflet-bottom { - position: absolute; - z-index: 1000; - pointer-events: none; - } -.leaflet-top { - top: 0; - } -.leaflet-right { - right: 0; - } -.leaflet-bottom { - bottom: 0; - } -.leaflet-left { - left: 0; - } -.leaflet-control { - float: left; - clear: both; - } -.leaflet-right .leaflet-control { - float: right; - } -.leaflet-top .leaflet-control { - margin-top: 10px; - } -.leaflet-bottom .leaflet-control { - margin-bottom: 10px; - } -.leaflet-left .leaflet-control { - margin-left: 10px; - } -.leaflet-right .leaflet-control { - margin-right: 10px; - } - - -/* zoom and fade animations */ - -.leaflet-fade-anim .leaflet-tile, -.leaflet-fade-anim .leaflet-popup { - opacity: 0; - -webkit-transition: opacity 0.2s linear; - -moz-transition: opacity 0.2s linear; - -o-transition: opacity 0.2s linear; - transition: opacity 0.2s linear; - } -.leaflet-fade-anim .leaflet-tile-loaded, -.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { - opacity: 1; - } - -.leaflet-zoom-anim .leaflet-zoom-animated { - -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); - -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); - -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); - transition: transform 0.25s cubic-bezier(0,0,0.25,1); - } -.leaflet-zoom-anim .leaflet-tile, -.leaflet-pan-anim .leaflet-tile, -.leaflet-touching .leaflet-zoom-animated { - -webkit-transition: none; - -moz-transition: none; - -o-transition: none; - transition: none; - } - -.leaflet-zoom-anim .leaflet-zoom-hide { - visibility: hidden; - } - - -/* cursors */ - -.leaflet-clickable { - cursor: pointer; - } -.leaflet-container { - cursor: -webkit-grab; - cursor: -moz-grab; - } -.leaflet-popup-pane, -.leaflet-control { - cursor: auto; - } -.leaflet-dragging .leaflet-container, -.leaflet-dragging .leaflet-clickable { - cursor: move; - cursor: -webkit-grabbing; - cursor: -moz-grabbing; - } - - -/* visual tweaks */ - -.leaflet-container { - background: #ddd; - outline: 0; - } -.leaflet-container a { - color: #0078A8; - } -.leaflet-container a.leaflet-active { - outline: 2px solid orange; - } -.leaflet-zoom-box { - border: 2px dotted #38f; - background: rgba(255,255,255,0.5); - } - - -/* general typography */ -.leaflet-container { - font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; - } - - -/* general toolbar styles */ - -.leaflet-bar { - box-shadow: 0 1px 5px rgba(0,0,0,0.65); - border-radius: 4px; - } -.leaflet-bar a, -.leaflet-bar a:hover { - background-color: #fff; - border-bottom: 1px solid #ccc; - width: 26px; - height: 26px; - line-height: 26px; - display: block; - text-align: center; - text-decoration: none; - color: black; - } -.leaflet-bar a, -.leaflet-control-layers-toggle { - background-position: 50% 50%; - background-repeat: no-repeat; - display: block; - } -.leaflet-bar a:hover { - background-color: #f4f4f4; - } -.leaflet-bar a:first-child { - border-top-left-radius: 4px; - border-top-right-radius: 4px; - } -.leaflet-bar a:last-child { - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - border-bottom: none; - } -.leaflet-bar a.leaflet-disabled { - cursor: default; - background-color: #f4f4f4; - color: #bbb; - } - -.leaflet-touch .leaflet-bar a { - width: 30px; - height: 30px; - line-height: 30px; - } - - -/* zoom control */ - -.leaflet-control-zoom-in, -.leaflet-control-zoom-out { - font: bold 18px 'Lucida Console', Monaco, monospace; - text-indent: 1px; - } -.leaflet-control-zoom-out { - font-size: 20px; - } - -.leaflet-touch .leaflet-control-zoom-in { - font-size: 22px; - } -.leaflet-touch .leaflet-control-zoom-out { - font-size: 24px; - } - - -/* layers control */ - -.leaflet-control-layers { - box-shadow: 0 1px 5px rgba(0,0,0,0.4); - background: #fff; - border-radius: 5px; - } -.leaflet-control-layers-toggle { - background-image: url(images/layers.png); - width: 36px; - height: 36px; - } -.leaflet-retina .leaflet-control-layers-toggle { - background-image: url(images/layers-2x.png); - background-size: 26px 26px; - } -.leaflet-touch .leaflet-control-layers-toggle { - width: 44px; - height: 44px; - } -.leaflet-control-layers .leaflet-control-layers-list, -.leaflet-control-layers-expanded .leaflet-control-layers-toggle { - display: none; - } -.leaflet-control-layers-expanded .leaflet-control-layers-list { - display: block; - position: relative; - } -.leaflet-control-layers-expanded { - padding: 6px 10px 6px 6px; - color: #333; - background: #fff; - } -.leaflet-control-layers-selector { - margin-top: 2px; - position: relative; - top: 1px; - } -.leaflet-control-layers label { - display: block; - } -.leaflet-control-layers-separator { - height: 0; - border-top: 1px solid #ddd; - margin: 5px -10px 5px -6px; - } - - -/* attribution and scale controls */ - -.leaflet-container .leaflet-control-attribution { - background: #fff; - background: rgba(255, 255, 255, 0.7); - margin: 0; - } -.leaflet-control-attribution, -.leaflet-control-scale-line { - padding: 0 5px; - color: #333; - } -.leaflet-control-attribution a { - text-decoration: none; - } -.leaflet-control-attribution a:hover { - text-decoration: underline; - } -.leaflet-container .leaflet-control-attribution, -.leaflet-container .leaflet-control-scale { - font-size: 11px; - } -.leaflet-left .leaflet-control-scale { - margin-left: 5px; - } -.leaflet-bottom .leaflet-control-scale { - margin-bottom: 5px; - } -.leaflet-control-scale-line { - border: 2px solid #777; - border-top: none; - line-height: 1.1; - padding: 2px 5px 1px; - font-size: 11px; - white-space: nowrap; - overflow: hidden; - -moz-box-sizing: content-box; - box-sizing: content-box; - - background: #fff; - background: rgba(255, 255, 255, 0.5); - } -.leaflet-control-scale-line:not(:first-child) { - border-top: 2px solid #777; - border-bottom: none; - margin-top: -2px; - } -.leaflet-control-scale-line:not(:first-child):not(:last-child) { - border-bottom: 2px solid #777; - } - -.leaflet-touch .leaflet-control-attribution, -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - box-shadow: none; - } -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - border: 2px solid rgba(0,0,0,0.2); - background-clip: padding-box; - } - - -/* popup */ - -.leaflet-popup { - position: absolute; - text-align: center; - } -.leaflet-popup-content-wrapper { - padding: 1px; - text-align: left; - border-radius: 12px; - } -.leaflet-popup-content { - margin: 13px 19px; - line-height: 1.4; - } -.leaflet-popup-content p { - margin: 18px 0; - } -.leaflet-popup-tip-container { - margin: 0 auto; - width: 40px; - height: 20px; - position: relative; - overflow: hidden; - } -.leaflet-popup-tip { - width: 17px; - height: 17px; - padding: 1px; - - margin: -10px auto 0; - - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -ms-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); - } -.leaflet-popup-content-wrapper, -.leaflet-popup-tip { - background: white; - - box-shadow: 0 3px 14px rgba(0,0,0,0.4); - } -.leaflet-container a.leaflet-popup-close-button { - position: absolute; - top: 0; - right: 0; - padding: 4px 4px 0 0; - text-align: center; - width: 18px; - height: 14px; - font: 16px/14px Tahoma, Verdana, sans-serif; - color: #c3c3c3; - text-decoration: none; - font-weight: bold; - background: transparent; - } -.leaflet-container a.leaflet-popup-close-button:hover { - color: #999; - } -.leaflet-popup-scrolled { - overflow: auto; - border-bottom: 1px solid #ddd; - border-top: 1px solid #ddd; - } - -.leaflet-oldie .leaflet-popup-content-wrapper { - zoom: 1; - } -.leaflet-oldie .leaflet-popup-tip { - width: 24px; - margin: 0 auto; - - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; - filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); - } -.leaflet-oldie .leaflet-popup-tip-container { - margin-top: -1px; - } - -.leaflet-oldie .leaflet-control-zoom, -.leaflet-oldie .leaflet-control-layers, -.leaflet-oldie .leaflet-popup-content-wrapper, -.leaflet-oldie .leaflet-popup-tip { - border: 1px solid #999; - } - - -/* div icon */ - -.leaflet-div-icon { - background: #fff; - border: 1px solid #666; - } +/* required styles */ + +.leaflet-map-pane, +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-tile-pane, +.leaflet-tile-container, +.leaflet-overlay-pane, +.leaflet-shadow-pane, +.leaflet-marker-pane, +.leaflet-popup-pane, +.leaflet-overlay-pane svg, +.leaflet-zoom-box, +.leaflet-image-layer, +.leaflet-layer { + position: absolute; + left: 0; + top: 0; + } +.leaflet-container { + overflow: hidden; + -ms-touch-action: none; + touch-action: none; + } +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + -webkit-user-drag: none; + } +.leaflet-marker-icon, +.leaflet-marker-shadow { + display: block; + } +/* map is broken in FF if you have max-width: 100% on tiles */ +.leaflet-container img { + max-width: none !important; + } +/* stupid Android 2 doesn't understand "max-width: none" properly */ +.leaflet-container img.leaflet-image-layer { + max-width: 15000px !important; + } +.leaflet-tile { + filter: inherit; + visibility: hidden; + } +.leaflet-tile-loaded { + visibility: inherit; + } +.leaflet-zoom-box { + width: 0; + height: 0; + } +/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ +.leaflet-overlay-pane svg { + -moz-user-select: none; + } + +.leaflet-tile-pane { z-index: 2; } +.leaflet-objects-pane { z-index: 3; } +.leaflet-overlay-pane { z-index: 4; } +.leaflet-shadow-pane { z-index: 5; } +.leaflet-marker-pane { z-index: 6; } +.leaflet-popup-pane { z-index: 7; } + +.leaflet-vml-shape { + width: 1px; + height: 1px; + } +.lvml { + behavior: url(#default#VML); + display: inline-block; + position: absolute; + } + + +/* control positioning */ + +.leaflet-control { + position: relative; + z-index: 7; + pointer-events: auto; + } +.leaflet-top, +.leaflet-bottom { + position: absolute; + z-index: 1000; + pointer-events: none; + } +.leaflet-top { + top: 0; + } +.leaflet-right { + right: 0; + } +.leaflet-bottom { + bottom: 0; + } +.leaflet-left { + left: 0; + } +.leaflet-control { + float: left; + clear: both; + } +.leaflet-right .leaflet-control { + float: right; + } +.leaflet-top .leaflet-control { + margin-top: 10px; + } +.leaflet-bottom .leaflet-control { + margin-bottom: 10px; + } +.leaflet-left .leaflet-control { + margin-left: 10px; + } +.leaflet-right .leaflet-control { + margin-right: 10px; + } + + +/* zoom and fade animations */ + +.leaflet-fade-anim .leaflet-tile, +.leaflet-fade-anim .leaflet-popup { + opacity: 0; + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + -o-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; + } +.leaflet-fade-anim .leaflet-tile-loaded, +.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { + opacity: 1; + } + +.leaflet-zoom-anim .leaflet-zoom-animated { + -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); + -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); + -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); + transition: transform 0.25s cubic-bezier(0,0,0.25,1); + } +.leaflet-zoom-anim .leaflet-tile, +.leaflet-pan-anim .leaflet-tile, +.leaflet-touching .leaflet-zoom-animated { + -webkit-transition: none; + -moz-transition: none; + -o-transition: none; + transition: none; + } + +.leaflet-zoom-anim .leaflet-zoom-hide { + visibility: hidden; + } + + +/* cursors */ + +.leaflet-clickable { + cursor: pointer; + } +.leaflet-container { + cursor: -webkit-grab; + cursor: -moz-grab; + } +.leaflet-popup-pane, +.leaflet-control { + cursor: auto; + } +.leaflet-dragging .leaflet-container, +.leaflet-dragging .leaflet-clickable { + cursor: move; + cursor: -webkit-grabbing; + cursor: -moz-grabbing; + } + + +/* visual tweaks */ + +.leaflet-container { + background: #ddd; + outline: 0; + } +.leaflet-container a { + color: #0078A8; + } +.leaflet-container a.leaflet-active { + outline: 2px solid orange; + } +.leaflet-zoom-box { + border: 2px dotted #38f; + background: rgba(255,255,255,0.5); + } + + +/* general typography */ +.leaflet-container { + font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; + } + + +/* general toolbar styles */ + +.leaflet-bar { + box-shadow: 0 1px 5px rgba(0,0,0,0.65); + border-radius: 4px; + } +.leaflet-bar a, +.leaflet-bar a:hover { + background-color: #fff; + border-bottom: 1px solid #ccc; + width: 26px; + height: 26px; + line-height: 26px; + display: block; + text-align: center; + text-decoration: none; + color: black; + } +.leaflet-bar a, +.leaflet-control-layers-toggle { + background-position: 50% 50%; + background-repeat: no-repeat; + display: block; + } +.leaflet-bar a:hover { + background-color: #f4f4f4; + } +.leaflet-bar a:first-child { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + } +.leaflet-bar a:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom: none; + } +.leaflet-bar a.leaflet-disabled { + cursor: default; + background-color: #f4f4f4; + color: #bbb; + } + +.leaflet-touch .leaflet-bar a { + width: 30px; + height: 30px; + line-height: 30px; + } + + +/* zoom control */ + +.leaflet-control-zoom-in, +.leaflet-control-zoom-out { + font: bold 18px 'Lucida Console', Monaco, monospace; + text-indent: 1px; + } +.leaflet-control-zoom-out { + font-size: 20px; + } + +.leaflet-touch .leaflet-control-zoom-in { + font-size: 22px; + } +.leaflet-touch .leaflet-control-zoom-out { + font-size: 24px; + } + + +/* layers control */ + +.leaflet-control-layers { + box-shadow: 0 1px 5px rgba(0,0,0,0.4); + background: #fff; + border-radius: 5px; + } +.leaflet-control-layers-toggle { + background-image: url(images/layers.png); + width: 36px; + height: 36px; + } +.leaflet-retina .leaflet-control-layers-toggle { + background-image: url(images/layers-2x.png); + background-size: 26px 26px; + } +.leaflet-touch .leaflet-control-layers-toggle { + width: 44px; + height: 44px; + } +.leaflet-control-layers .leaflet-control-layers-list, +.leaflet-control-layers-expanded .leaflet-control-layers-toggle { + display: none; + } +.leaflet-control-layers-expanded .leaflet-control-layers-list { + display: block; + position: relative; + } +.leaflet-control-layers-expanded { + padding: 6px 10px 6px 6px; + color: #333; + background: #fff; + } +.leaflet-control-layers-selector { + margin-top: 2px; + position: relative; + top: 1px; + } +.leaflet-control-layers label { + display: block; + } +.leaflet-control-layers-separator { + height: 0; + border-top: 1px solid #ddd; + margin: 5px -10px 5px -6px; + } + + +/* attribution and scale controls */ + +.leaflet-container .leaflet-control-attribution { + background: #fff; + background: rgba(255, 255, 255, 0.7); + margin: 0; + } +.leaflet-control-attribution, +.leaflet-control-scale-line { + padding: 0 5px; + color: #333; + } +.leaflet-control-attribution a { + text-decoration: none; + } +.leaflet-control-attribution a:hover { + text-decoration: underline; + } +.leaflet-container .leaflet-control-attribution, +.leaflet-container .leaflet-control-scale { + font-size: 11px; + } +.leaflet-left .leaflet-control-scale { + margin-left: 5px; + } +.leaflet-bottom .leaflet-control-scale { + margin-bottom: 5px; + } +.leaflet-control-scale-line { + border: 2px solid #777; + border-top: none; + line-height: 1.1; + padding: 2px 5px 1px; + font-size: 11px; + white-space: nowrap; + overflow: hidden; + -moz-box-sizing: content-box; + box-sizing: content-box; + + background: #fff; + background: rgba(255, 255, 255, 0.5); + } +.leaflet-control-scale-line:not(:first-child) { + border-top: 2px solid #777; + border-bottom: none; + margin-top: -2px; + } +.leaflet-control-scale-line:not(:first-child):not(:last-child) { + border-bottom: 2px solid #777; + } + +.leaflet-touch .leaflet-control-attribution, +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + box-shadow: none; + } +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + border: 2px solid rgba(0,0,0,0.2); + background-clip: padding-box; + } + + +/* popup */ + +.leaflet-popup { + position: absolute; + text-align: center; + } +.leaflet-popup-content-wrapper { + padding: 1px; + text-align: left; + border-radius: 12px; + } +.leaflet-popup-content { + margin: 13px 19px; + line-height: 1.4; + } +.leaflet-popup-content p { + margin: 18px 0; + } +.leaflet-popup-tip-container { + margin: 0 auto; + width: 40px; + height: 20px; + position: relative; + overflow: hidden; + } +.leaflet-popup-tip { + width: 17px; + height: 17px; + padding: 1px; + + margin: -10px auto 0; + + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + } +.leaflet-popup-content-wrapper, +.leaflet-popup-tip { + background: white; + + box-shadow: 0 3px 14px rgba(0,0,0,0.4); + } +.leaflet-container a.leaflet-popup-close-button { + position: absolute; + top: 0; + right: 0; + padding: 4px 4px 0 0; + text-align: center; + width: 18px; + height: 14px; + font: 16px/14px Tahoma, Verdana, sans-serif; + color: #c3c3c3; + text-decoration: none; + font-weight: bold; + background: transparent; + } +.leaflet-container a.leaflet-popup-close-button:hover { + color: #999; + } +.leaflet-popup-scrolled { + overflow: auto; + border-bottom: 1px solid #ddd; + border-top: 1px solid #ddd; + } + +.leaflet-oldie .leaflet-popup-content-wrapper { + zoom: 1; + } +.leaflet-oldie .leaflet-popup-tip { + width: 24px; + margin: 0 auto; + + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; + filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); + } +.leaflet-oldie .leaflet-popup-tip-container { + margin-top: -1px; + } + +.leaflet-oldie .leaflet-control-zoom, +.leaflet-oldie .leaflet-control-layers, +.leaflet-oldie .leaflet-popup-content-wrapper, +.leaflet-oldie .leaflet-popup-tip { + border: 1px solid #999; + } + + +/* div icon */ + +.leaflet-div-icon { + background: #fff; + border: 1px solid #666; + } diff --git a/platforms/browser/www/css/main.css b/platforms/browser/www/css/main.css index 174c418..91dbb61 100644 --- a/platforms/browser/www/css/main.css +++ b/platforms/browser/www/css/main.css @@ -69,7 +69,7 @@ body { top: 0; left: 0; width: 100%; - height: 20%; + height: auto; z-index: 9500; } @@ -83,6 +83,16 @@ body { background: rgba(0,0,0,.9); } +#overlay-main #main-content { + overflow-x: auto; + overflow-y: auto; + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; +} + #mainCloseBtn { z-index: 999999; position: absolute; @@ -151,4 +161,70 @@ body { padding: 0px 5px 0px 5px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; +} + +.chatbox { + position: absolute; + bottom: 0px; + left: 0px; + height: auto !important; + max-height: 50%; + width: 100%; + z-index: 9501; +} + +#chatmsgs { + z-index: 9500; + top: 0px; + width: 100%; + height: calc(100% - 35px) !important; + display: none; + position: absolute; + font-family: monospace; + color: #ffffff; + overflow-x: hidden; + overflow-y: auto; + overflow-wrap: break-word; + word-wrap: break-word; + hyphens: auto; + word-break: break-all; + background: rgba(0,0,0,.8); +} + +.chatbox #chatmsgs .chat-username { + color: green; + font-weight: bold; +} + +#buttons { + position: absolute; + right: 0px; + top: 25%; + width: 70px; + padding-top: auto; + padding-bottom: auto; + padding-right: 10px; + display: block; + z-index: 9000; +} + +#buttons .circlebutton { + border: 1px solid black; + background: rgba(255,255,255,.8); + border-radius: 50%; + box-shadow: 0 0 5px grey; + width: 60px; + height: 60px; +} + +#buttons .circlebutton img { + position: absolute; + top: 15px; + left: 15px; + width: 30px; + height: 30px; +} + +.scrollable-box { + overflow-y: auto; } \ No newline at end of file diff --git a/platforms/browser/www/index.html b/platforms/browser/www/index.html index d211726..13899f6 100644 --- a/platforms/browser/www/index.html +++ b/platforms/browser/www/index.html @@ -9,35 +9,48 @@ - ... + + + TerranQuest - + - + - - -
- -
+ - + + + + + +
+
+
+ +
+
+
+
diff --git a/platforms/browser/www/js/auth.js b/platforms/browser/www/js/auth.js index 2412be6..344b93e 100644 --- a/platforms/browser/www/js/auth.js +++ b/platforms/browser/www/js/auth.js @@ -4,6 +4,27 @@ var authOpInProgress = false; +function askLogout() { + navigator.notification.confirm( + 'Do you really want to logout?', // message + function (btn) { + if (btn === 1) { + logout(); + } + }, + 'Logout?', + ['Logout', 'Cancel'] + ); +} + +function logout() { + localStorage.setItem("username", ''); + localStorage.setItem("password", ''); + username = null; + password = null; + $('#content-zone').load("screens/login.html"); +} + function dosignup() { if (authOpInProgress) { return; @@ -35,7 +56,7 @@ function dosignup() { }, function (data) { if (data === 'OK') { - username = $('#usernameBox').val(); + username = $('#usernameBox').val().toLowerCase(); password = $('#passwordBox').val(); localStorage.setItem("username", username); localStorage.setItem("password", password); @@ -62,8 +83,6 @@ function dologin() { } authOpInProgress = true; $('#errorbase').hide(); - $('#loginBtn').html(' Logging in...'); - $('#loginBtn').attr('disabled', true); if ($('#usernameBox').val() === "") { $('#errormsg').text("Error: Missing username."); $('#errorbase').css('display', 'block'); @@ -71,6 +90,8 @@ function dologin() { $('#loginBtn').attr('disabled', false); return; } + $('#loginBtn').attr('disabled', true); + $('#loginBtn').html(' Logging in...'); $.post("https://sso.netsyms.com/api/simpleauth.php", {user: $('#usernameBox').val(), pass: $('#passwordBox').val()}, function (data) { @@ -78,16 +99,18 @@ function dologin() { // Now that auth is OK, ping the game server $.getJSON(mkApiUrl('pinglogin') + "?user=" + $('#usernameBox').val(), function (out) { if (out.status === 'OK') { - username = $('#usernameBox').val(); + username = $('#usernameBox').val().toLowerCase(); password = $('#passwordBox').val(); localStorage.setItem("username", username); localStorage.setItem("password", password); + navigator.splashscreen.hide(); openscreen("home"); } else { $('#loginBtn').html(' Login'); $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: " + out.message); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; } }).fail(function (err) { @@ -95,6 +118,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: Login OK, but cannot connect to game server. Try again later."); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; }); } else { @@ -102,6 +126,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text(data); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); } authOpInProgress = false; }).fail(function () { @@ -109,6 +134,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: Network failure."); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; }); } diff --git a/platforms/browser/www/js/comm.js b/platforms/browser/www/js/comm.js deleted file mode 100644 index b5eccfe..0000000 --- a/platforms/browser/www/js/comm.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Handles general server communication. - */ - -/** - * Syncs the user's stats with the server and calls refreshStats(). - */ -function syncStats() { - $.getJSON(mkApiUrl('getstats') + "?user=" + username, null, function (data) { - if (data.status === 'OK') { - maxenergy = data.stats.maxenergy; - energy = data.stats.energy; - level = data.stats.level; - refreshStats(); - } - }); -} - -/** - * Display the current stats on the home screen. - */ -function refreshStats() { - energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0; - $('#energybar').css('width', String(energypercent) + '%'); -} - - -syncStats(); -setInterval(function () { - syncStats(); -}, 10 * 1000); \ No newline at end of file diff --git a/platforms/browser/www/js/home.js b/platforms/browser/www/js/home.js new file mode 100644 index 0000000..8f5f6c2 --- /dev/null +++ b/platforms/browser/www/js/home.js @@ -0,0 +1,352 @@ +/* global PositionError */ + +////////////////////////////////////////////// +// GPS and terrain stuff +////////////////////////////////////////////// + +/** + * Handles GPS and terrain data. + */ + +// Globals +lockGot = false; +terrainGot = false; +latitude = 0.0000; +longitude = 0.0000; +gpsaccuracy = 9999; +// End Globals + +var lastgpstime = 0; +var terraintypeid = 0; +var map = L.map('map'); +var tileurl = "http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg"; +map.setZoom(17); +map.dragging.disable(); +//map.touchZoom.disable(); +//map.doubleClickZoom.disable(); +//map.scrollWheelZoom.disable(); +map.keyboard.disable(); +$(".leaflet-control-zoom").css("visibility", "hidden"); +// Disable tap handler, if present. +//if (map.tap) { +// map.tap.disable(); +//} +var lc = L.control.locate({ + position: 'topleft', // set the location of the control + layer: undefined, // use your own layer for the location marker, creates a new layer by default + drawCircle: false, // controls whether a circle is drawn that shows the uncertainty about the location + follow: true, // follow the user's location + setView: true, // automatically sets the map view to the user's location, enabled if `follow` is true + keepCurrentZoomLevel: true, // keep the current map zoom level when displaying the user's location. (if `false`, use maxZoom) + stopFollowingOnDrag: false, // stop following when the map is dragged if `follow` is true (deprecated, see below) + remainActive: true, // if true locate control remains active on click even if the user's location is in view. + markerClass: L.circleMarker, // L.circleMarker or L.marker + circleStyle: {}, // change the style of the circle around the user's location + markerStyle: {}, + followCircleStyle: {}, // set difference for the style of the circle around the user's location while following + followMarkerStyle: {}, + icon: 'fa fa-map-marker', // class for icon, fa-location-arrow or fa-map-marker + iconLoading: 'fa fa-spinner fa-pulse', // class for loading icon + iconElementTag: 'span', // tag for the icon element, span or i + circlePadding: [0, 0], // padding around accuracy circle, value is passed to setBounds + metric: true, // use metric or imperial units + onLocationError: function (err) { + }, // define an error callback function + onLocationOutsideMapBounds: function (context) { // called when outside map boundaries + }, + showPopup: false, // display a popup when the user click on the inner marker + strings: { + title: ".", // title of the locate control + metersUnit: "meters", // string for metric units + feetUnit: "feet", // string for imperial units + popup: "You are within {distance} {unit} from this point", // text to appear if user clicks on circle + outsideMapBoundsMsg: "You seem located outside the boundaries of the map" // default message for onLocationOutsideMapBounds + }, + locateOptions: {} // define location options e.g enableHighAccuracy: true or maxZoom: 10 +}).addTo(map); +map.addLayer(new L.tileLayer(tileurl, {minZoom: 17, maxZoom: 18})); +// GeoJSON layer +var placeLayer = L.geoJson( + {"name": "Places", "type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [0, 0]}, "properties": {"osm_id": -1, "name": null}}]}, + { + onEachFeature: onPlaceTap, + pointToLayer: function (feature, latlng) { + return L.circleMarker(latlng, { + radius: 14, + fillColor: "#ff7800", + color: "#000", + weight: 1, + opacity: 1, + fillOpacity: 0.6 + }); + } + }).addTo(map); +lc.start(); +function mapPos(lat, lon) { + lockGot = true; + hideLoading(); + loadPlaces(latitude, longitude); + //map.setView(new L.LatLng(lat, lon), 16, {animate: true}); + //map.panTo(new L.LatLng(lat, lon)); + //map.invalidateSize(); + //redraw('.leaflet-map-pane'); +// $('.leaflet-map-plane').css('height', '90%'); +// setTimeout(function () { +// $('#map').css('width', '100%'); +// $('#map').css('height', '100%'); +// }, 100); +} + +function onPlaceTap(feature, layer) { + layer.on('click', function (e) { + openPlace(feature); + }); +} + +function loadPlaces(lat, long) { + $.getJSON( + "http://earth.apis.netsyms.net/places.php?format=geojson&lat=" + lat + "&long=" + long + "&radius=.25&names=1", + function (data) { + if (data.type === 'FeatureCollection') { + placeLayer.clearLayers(); + data.features.forEach(function (item) { + item.properties.popupContent = "" + item.properties.name + ""; + placeLayer.addData(item); + }); + } + }); +} + +function openPlace(feature) { + $('#main-content').load("screens/place.html", null, function () { + loadPlace(feature); + $('#overlay-main').css('display', 'block'); + }); +} + +/** + * Hide the loading overlay if everything is loaded, otherwise do nothing + */ +function hideLoading() { + if (lockGot && terrainGot && gpsaccuracy < 30 && $('#loading').css('display') !== 'none') { + $('#loading').fadeOut('slow', function () { + $('#loading').css('display', 'none'); + }); + } +} + +var updatePosition = function (position) { + latitude = position.coords.latitude; + longitude = position.coords.longitude; + lastgpstime = position.timestamp; + gpsaccuracy = position.coords.accuracy; + if (gpsaccuracy > 30) { + $('#no-lock').css('display', 'block'); + } else { + $('#no-lock').css('display', 'none'); + } + mapPos(latitude, longitude); +}; +var updateTerrain = function (position) { + latitude = position.coords.latitude; + longitude = position.coords.longitude; + lastgpstime = position.timestamp; + gpsaccuracy = position.coords.accuracy; + var rasterurl = "http://earth.apis.netsyms.net/terrain.php?format=json&lat=" + + latitude + "&long=" + longitude; + $.get(rasterurl, function (data) { + if (data.status === 'OK') { + terraintypeid = data.typeid; + terraintypename = data.typename; + $('#terrain-image').attr('src', 'assets/terrain/' + terraintypeid + '.png'); + terrainGot = true; + hideLoading(); + } + }, "json").fail(function (err) { + $('#terrain-image').attr('src', 'assets/terrain/0.png'); + }); +}; +function pingServer() { + if (lockGot && gpsaccuracy < 30) { + $.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude); + } +} +; +function onError(error) { + $('#loading-error').text("Check your device's network and location settings, and ensure a clear view of the sky."); +} + +function popGPS() { + navigator.notification.alert("Latitude: " + latitude + + "\nLongitude: " + longitude + + "\nAccuracy: " + gpsaccuracy + + "\nTerrain: " + terraintypename + " (" + terraintypeid + ")", + null, + "GPS Information", + "Close"); +} +$('#terrain-image').click(function () { + popGPS(); +}); +// Initial GPS position and stuff +navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true}); +// Update position +setInterval(function () { + navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 10000, enableHighAccuracy: true}); +}, 1000); +// Update position + terrain +setInterval(function () { + navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true}); + loadPlaces(latitude, longitude); +}, 1000 * 20); +// Ping the server with coordinates +setInterval(pingServer, 5000); +// Show error if it's taking too long +setTimeout(function () { + onError(); +}, 15 * 1000); +////////////////////////////////////////////// +// Profile, stats, and chat stuff +////////////////////////////////////////////// + + +/* + * Handles general server communication. + */ + +/** + * Syncs the user's stats with the server and calls refreshStats(). + */ +function syncStats() { + $.getJSON(mkApiUrl('getstats'), { + user: username + }, function (data) { + if (data.status === 'OK') { + maxenergy = data.stats.maxenergy; + energy = data.stats.energy; + level = data.stats.level; + refreshStats(); + } + }); +} + +/** + * Display the current stats on the home screen. + */ +function refreshStats() { + energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0; + $('#energybar').css('width', String(energypercent) + '%'); +} + +function getChat() { + if (lockGot) { + $.getJSON(mkApiUrl('chat', 'cs'), { + lat: latitude, + long: longitude + }, function (data) { + data = sortResults(data, 'time', true); + var content = ""; + data.forEach(function (msg) { + content += "" + msg.username + " " + msg.message + "
"; + }); + $('#chatmsgs').html(content); + }); + } +} + + +syncStats(); +setInterval(function () { + syncStats(); +}, 10 * 1000); +setInterval(function () { + getChat(); +}, 2000); +// Send chat messages +$("#chatsendform").submit(function (event) { + message = $('#chatbox-input').val(); + if (message !== '') { + $.post(mkApiUrl('chat', 'cs'), { + user: username, + lat: latitude, + long: longitude, + msg: message + }, function (data) { + if (data.status === 'OK') { + $('#chatbox-input').val(""); + $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000); + } + }, "json"); + } + event.preventDefault(); + return false; +}); +function toggleChat() { + if ($('#chatmsgs').css('display') === 'none') { + openChat(); + } else { + closeChat(); + } +} + +function closeChat() { + $('#chatmsgs').css('display', 'none'); + $('.chatbox').css('height', 'auto'); +} + +function openChat() { + $('.chatbox').css('height', '50%'); + $('#chatmsgs').css('display', 'block'); + $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000); +} + +function openProfile(user) { + user = typeof user !== 'undefined' ? user : username; + $('#main-content').load("screens/profile.html", null, function (x) { + $('#overlay-main').css('display', 'block'); + loadProfile(user); + }); +} + +function openRules() { + $('#main-content').load("screens/rules.html", null, function (x) { + $('#overlay-main').css('display', 'block'); + }); +} + +function openMenu(topage) { + topage = typeof topage !== 'undefined' ? topage : ""; + $('#main-content').load("screens/menu.html", null, function (x) { + $('#overlay-main').css('display', 'block'); + if (topage !== '') { + $('#' + topage + '-tab').tab('show'); + } + }); +} + + + +////////////////////////////////////////////// +// Other things +////////////////////////////////////////////// + +function closeMain() { + $('#overlay-main').slideDown(100, function () { + $('#overlay-main').css('display', 'none'); + $('#main-content').html(""); + }); +} + +// Handle back button to close things +document.addEventListener("backbutton", function (event) { + if ($('#overlay-main').css('display') !== 'none') { + closeMain(); + } else if ($('#chatmsgs').css('display') !== 'none') { + toggleChat(); + } +}, false); +// Show the rules +if (localStorage.getItem("seenrules") !== 'yes') { + openRules(); + localStorage.setItem("seenrules", 'yes'); +} \ No newline at end of file diff --git a/platforms/browser/www/js/main.js b/platforms/browser/www/js/main.js index 6b2de53..45ecfa0 100644 --- a/platforms/browser/www/js/main.js +++ b/platforms/browser/www/js/main.js @@ -1,8 +1,3 @@ -/* - * This file loads after JQuery and sets up variables and whatnot. - */ - - // Constants username = ""; password = ""; @@ -19,20 +14,6 @@ $(document).ready(function () { function onDeviceReady() { openscreen("login"); - if ($('#usernameBox').val() !== '' && $('#passwordBox').val() !== '') { - // Try to login with stored credentials - $.post("https://sso.netsyms.com/api/simpleauth.php", - {user: $('#usernameBox').val(), pass: $('#passwordBox').val()}, - function (data) { - if (data === 'OK') { - dologin(); - } - }).fail(function () { - navigator.splashscreen.hide(); - }); - } else { - navigator.splashscreen.hide(); - } if (navigator.network.connection.type === Connection.NONE) { navigator.notification.alert("You need an Internet connection to continue.", function () { navigator.app.exitApp(); @@ -40,8 +21,9 @@ function onDeviceReady() { } } -function mkApiUrl(action) { - return "http://gs.terranquest.net/" + action + ".php"; +function mkApiUrl(action, server) { + server = typeof server !== 'undefined' ? server : "gs"; + return "http://" + server + ".terranquest.net/" + action + ".php"; //return "config/" + action + ".json"; } @@ -86,19 +68,10 @@ function scanCode() { } } -function syncEnergy() { - //$('.progress-bar').css('width', valeur+'%').attr('aria-valuenow', valeur); -} - -/** - * Function to enable forcing redraw of elements - * - * redraw('#theElement'); - */ -function redraw(element) { - var n = document.createTextNode(' '); - $(element).append(n); - setTimeout(function () { - n.parentNode.removeChild(n) - }, 0); +function sortResults(array, prop, asc) { + array = array.sort(function(a, b) { + if (asc) return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0); + else return (b[prop] > a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0); + }); + return array; } \ No newline at end of file diff --git a/platforms/browser/www/js/terrain.js b/platforms/browser/www/js/terrain.js deleted file mode 100644 index 92a48e6..0000000 --- a/platforms/browser/www/js/terrain.js +++ /dev/null @@ -1,146 +0,0 @@ -/* global PositionError */ - -/** - * Handles GPS and terrain data. - */ - -var lockGot = false; -var terrainGot = false; - -var latitude = 0.0000; -var longitude = 0.0000; -var lastgpstime = 0; -var gpsaccuracy = 9999; -var terraintypeid = 0; -var map = L.map('map'); -var tileurl = "http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg"; -map.setZoom(16); -map.dragging.disable(); -map.touchZoom.disable(); -map.doubleClickZoom.disable(); -map.scrollWheelZoom.disable(); -map.keyboard.disable(); -$(".leaflet-control-zoom").css("visibility", "hidden"); -// Disable tap handler, if present. -if (map.tap) - map.tap.disable(); -var lc = L.control.locate({ - position: 'topleft', // set the location of the control - layer: undefined, // use your own layer for the location marker, creates a new layer by default - drawCircle: false, // controls whether a circle is drawn that shows the uncertainty about the location - follow: true, // follow the user's location - setView: true, // automatically sets the map view to the user's location, enabled if `follow` is true - keepCurrentZoomLevel: true, // keep the current map zoom level when displaying the user's location. (if `false`, use maxZoom) - stopFollowingOnDrag: false, // stop following when the map is dragged if `follow` is true (deprecated, see below) - remainActive: true, // if true locate control remains active on click even if the user's location is in view. - markerClass: L.circleMarker, // L.circleMarker or L.marker - circleStyle: {}, // change the style of the circle around the user's location - markerStyle: {}, - followCircleStyle: {}, // set difference for the style of the circle around the user's location while following - followMarkerStyle: {}, - icon: 'fa fa-map-marker', // class for icon, fa-location-arrow or fa-map-marker - iconLoading: 'fa fa-spinner fa-pulse', // class for loading icon - iconElementTag: 'span', // tag for the icon element, span or i - circlePadding: [0, 0], // padding around accuracy circle, value is passed to setBounds - metric: true, // use metric or imperial units - onLocationError: function (err) { - }, // define an error callback function - onLocationOutsideMapBounds: function (context) { // called when outside map boundaries - }, - showPopup: false, // display a popup when the user click on the inner marker - strings: { - title: ".", // title of the locate control - metersUnit: "meters", // string for metric units - feetUnit: "feet", // string for imperial units - popup: "You are within {distance} {unit} from this point", // text to appear if user clicks on circle - outsideMapBoundsMsg: "You seem located outside the boundaries of the map" // default message for onLocationOutsideMapBounds - }, - locateOptions: {} // define location options e.g enableHighAccuracy: true or maxZoom: 10 -}).addTo(map); -map.addLayer(new L.tileLayer(tileurl, {minZoom: 16, maxZoom: 16})); -//map.setView(new L.LatLng(46, -112), 15); -lc.start(); - -function mapPos(lat, lon) { - lockGot = true; - hideLoading(); - //map.setView(new L.LatLng(lat, lon), 16, {animate: true}); - //map.panTo(new L.LatLng(lat, lon)); - //map.invalidateSize(); - //redraw('.leaflet-map-pane'); -// $('.leaflet-map-plane').css('height', '90%'); -// setTimeout(function () { -// $('#map').css('width', '100%'); -// $('#map').css('height', '100%'); -// }, 100); -} - -/** - * Hide the loading overlay if everything is loaded, otherwise do nothing - */ -function hideLoading() { - if (lockGot && terrainGot) { - $('#loading').css('display', 'none'); - } -} - -var updatePosition = function (position) { - latitude = position.coords.latitude; - longitude = position.coords.longitude; - lastgpstime = position.timestamp; - gpsaccuracy = position.coords.accuracy; - if (gpsaccuracy > 30) { - $('#no-lock').css('display', 'block'); - } else { - $('#no-lock').css('display', 'none'); - } - mapPos(latitude, longitude); -}; - -var updateTerrain = function (position) { - latitude = position.coords.latitude; - longitude = position.coords.longitude; - lastgpstime = position.timestamp; - gpsaccuracy = position.coords.accuracy; - var rasterurl = "http://earth.apis.netsyms.net/terrain.php?format=json&lat=" - + latitude + "&long=" + longitude; - $.get(rasterurl, function (data) { - if (data.status === 'OK') { - terraintypeid = data.typeid; - terraintypename = data.typename; - $('#terrain-image').attr('src', 'assets/terrain/' + terraintypeid + '.png'); - terrainGot = true; - hideLoading(); - } - }, "json").fail(function (err) { - $('#terrain-image').attr('src', 'assets/terrain/0.png'); - }); -}; - -function pingServer() { - if (lockGot && gpsaccuracy < 30) { - $.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude); - } -} -; - -function onError(error) { - $('#loading-error').text("GPS lock is taking longer than expected. Check your device's network and location settings, and ensure a clear view of the sky."); -} - -// Initial GPS position and stuff -navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true}); -// Update position -setInterval(function () { - navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 10000, enableHighAccuracy: true}); -}, 1000); -// Update position + terrain -setInterval(function () { - navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true}); -}, 1000 * 10); -// Ping the server with coordinates -setInterval(pingServer, 5000); -// Show error if it's taking too long -setTimeout(function () { - onError(); -}, 10000); \ No newline at end of file diff --git a/platforms/browser/www/plugins/cordova-plugin-camera/src/browser/CameraProxy.js b/platforms/browser/www/plugins/cordova-plugin-camera/src/browser/CameraProxy.js new file mode 100644 index 0000000..03d5778 --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-camera/src/browser/CameraProxy.js @@ -0,0 +1,116 @@ +cordova.define("cordova-plugin-camera.CameraProxy", function(require, exports, module) { /* + * + * 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. + * + */ + +var HIGHEST_POSSIBLE_Z_INDEX = 2147483647; + +function takePicture(success, error, opts) { + if (opts && opts[2] === 1) { + capture(success, error); + } else { + var input = document.createElement('input'); + input.style.position = 'relative'; + input.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX; + input.type = 'file'; + input.name = 'files[]'; + + input.onchange = function(inputEvent) { + var reader = new FileReader(); + reader.onload = function(readerEvent) { + input.parentNode.removeChild(input); + + var imageData = readerEvent.target.result; + + return success(imageData.substr(imageData.indexOf(',') + 1)); + }; + + reader.readAsDataURL(inputEvent.target.files[0]); + }; + + document.body.appendChild(input); + } +} + +function capture(success, errorCallback) { + var localMediaStream; + + var video = document.createElement('video'); + var button = document.createElement('button'); + var parent = document.createElement('div'); + parent.style.position = 'relative'; + parent.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX; + parent.appendChild(video); + parent.appendChild(button); + + video.width = 320; + video.height = 240; + button.innerHTML = 'Capture!'; + + button.onclick = function() { + // create a canvas and capture a frame from video stream + var canvas = document.createElement('canvas'); + canvas.getContext('2d').drawImage(video, 0, 0, 320, 240); + + // convert image stored in canvas to base64 encoded image + var imageData = canvas.toDataURL('img/png'); + imageData = imageData.replace('data:image/png;base64,', ''); + + // stop video stream, remove video and button. + // Note that MediaStream.stop() is deprecated as of Chrome 47. + if (localMediaStream.stop) { + localMediaStream.stop(); + } else { + localMediaStream.getTracks().forEach(function (track) { + track.stop(); + }); + } + parent.parentNode.removeChild(parent); + + return success(imageData); + }; + + navigator.getUserMedia = navigator.getUserMedia || + navigator.webkitGetUserMedia || + navigator.mozGetUserMedia || + navigator.msGetUserMedia; + + var successCallback = function(stream) { + localMediaStream = stream; + video.src = window.URL.createObjectURL(localMediaStream); + video.play(); + + document.body.appendChild(parent); + }; + + if (navigator.getUserMedia) { + navigator.getUserMedia({video: true, audio: true}, successCallback, errorCallback); + } else { + alert('Browser does not support camera :('); + } +} + +module.exports = { + takePicture: takePicture, + cleanup: function(){} +}; + +require("cordova/exec/proxy").add("Camera",module.exports); + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-camera/www/Camera.js b/platforms/browser/www/plugins/cordova-plugin-camera/www/Camera.js new file mode 100644 index 0000000..e69b18a --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-camera/www/Camera.js @@ -0,0 +1,193 @@ +cordova.define("cordova-plugin-camera.camera", function(require, exports, module) { /* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + exec = require('cordova/exec'), + Camera = require('./Camera'); + // XXX: commented out + //CameraPopoverHandle = require('./CameraPopoverHandle'); + +/** + * @namespace navigator + */ + +/** + * @exports camera + */ +var cameraExport = {}; + +// Tack on the Camera Constants to the base camera plugin. +for (var key in Camera) { + cameraExport[key] = Camera[key]; +} + +/** + * Callback function that provides an error message. + * @callback module:camera.onError + * @param {string} message - The message is provided by the device's native code. + */ + +/** + * Callback function that provides the image data. + * @callback module:camera.onSuccess + * @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect. + * @example + * // Show image + * // + * function cameraCallback(imageData) { + * var image = document.getElementById('myImage'); + * image.src = "data:image/jpeg;base64," + imageData; + * } + */ + +/** + * Optional parameters to customize the camera settings. + * * [Quirks](#CameraOptions-quirks) + * @typedef module:camera.CameraOptions + * @type {Object} + * @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.) + * @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value. + * @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture. + * @property {Boolean} [allowEdit=true] - Allow simple editing of image before selection. + * @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding. + * @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant. + * @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant. + * @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. + * @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture. + * @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture. + * @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad. + * @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing). + */ + +/** + * @description 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 `camera.getPicture` function opens the device's default camera + * application that allows users to snap pictures by default - this behavior occurs, + * when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}. + * 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`]{@link module: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`]{@link module:camera.onSuccess} 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 `` 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__ + * + * - Android + * - BlackBerry + * - Browser + * - Firefox + * - FireOS + * - iOS + * - Windows + * - WP8 + * - Ubuntu + * + * More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks). + * + * @example + * navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + * @param {module:camera.onSuccess} successCallback + * @param {module:camera.onError} errorCallback + * @param {module:camera.CameraOptions} options CameraOptions + */ +cameraExport.getPicture = function(successCallback, errorCallback, options) { + argscheck.checkArgs('fFO', 'Camera.getPicture', arguments); + options = options || {}; + var getValue = argscheck.getValue; + + var quality = getValue(options.quality, 50); + var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI); + var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA); + var targetWidth = getValue(options.targetWidth, -1); + var targetHeight = getValue(options.targetHeight, -1); + var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG); + var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE); + var allowEdit = !!options.allowEdit; + var correctOrientation = !!options.correctOrientation; + var saveToPhotoAlbum = !!options.saveToPhotoAlbum; + var popoverOptions = getValue(options.popoverOptions, null); + var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK); + + var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, + mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection]; + + exec(successCallback, errorCallback, "Camera", "takePicture", args); + // XXX: commented out + //return new CameraPopoverHandle(); +}; + +/** + * Removes intermediate image files that are kept in temporary storage + * after calling [`camera.getPicture`]{@link module: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); + * } + */ +cameraExport.cleanup = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "Camera", "cleanup", []); +}; + +module.exports = cameraExport; + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-camera/www/CameraConstants.js b/platforms/browser/www/plugins/cordova-plugin-camera/www/CameraConstants.js new file mode 100644 index 0000000..df6cce4 --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-camera/www/CameraConstants.js @@ -0,0 +1,90 @@ +cordova.define("cordova-plugin-camera.Camera", function(require, exports, module) { /* + * + * 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. + * +*/ + +/** + * @module Camera + */ +module.exports = { + /** + * @enum {number} + */ + DestinationType:{ + /** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */ + DATA_URL: 0, + /** Return file uri (content://media/external/images/media/2 for Android) */ + FILE_URI: 1, + /** Return native uri (eg. asset-library://... for iOS) */ + NATIVE_URI: 2 + }, + /** + * @enum {number} + */ + EncodingType:{ + /** Return JPEG encoded image */ + JPEG: 0, + /** Return PNG encoded image */ + PNG: 1 + }, + /** + * @enum {number} + */ + MediaType:{ + /** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */ + PICTURE: 0, + /** Allow selection of video only, ONLY RETURNS URL */ + VIDEO: 1, + /** Allow selection from all media types */ + ALLMEDIA : 2 + }, + /** + * @enum {number} + */ + PictureSourceType:{ + /** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */ + PHOTOLIBRARY : 0, + /** Take picture from camera */ + CAMERA : 1, + /** Choose image from picture library (same as PHOTOLIBRARY for Android) */ + SAVEDPHOTOALBUM : 2 + }, + /** + * Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover. + * @enum {number} + */ + PopoverArrowDirection:{ + ARROW_UP : 1, + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }, + /** + * @enum {number} + */ + Direction:{ + /** Use the back-facing camera */ + BACK: 0, + /** Use the front-facing camera */ + FRONT: 1 + } +}; + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js b/platforms/browser/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js new file mode 100644 index 0000000..08d20d3 --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js @@ -0,0 +1,54 @@ +cordova.define("cordova-plugin-camera.CameraPopoverOptions", function(require, exports, module) { /* + * + * 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. + * +*/ + +var Camera = require('./Camera'); + +/** + * @namespace navigator + */ + +/** + * 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. + * 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. + * @module CameraPopoverOptions + * @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover. + * @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover. + * @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point. + */ +var CameraPopoverOptions = function (x, y, width, height, arrowDir) { + // information of rectangle that popover should be anchored to + this.x = x || 0; + this.y = y || 32; + this.width = width || 320; + this.height = height || 480; + this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY; +}; + +module.exports = CameraPopoverOptions; + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js b/platforms/browser/www/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js deleted file mode 100644 index 5eccab5..0000000 --- a/platforms/browser/www/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js +++ /dev/null @@ -1,47 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassProxy", function(require, exports, module) { /* - * - * 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. - * -*/ - -var Compass = { - getHeading: function(success, error) { - var listener = function() { - var orient = {}; - var heading = (Math.round((Math.random() * 360) * 100) / 100); - - orient.trueHeading = heading; - orient.magneticHeading = heading; - orient.headingAccuracy = 0; - orient.timestamp = new Date().getTime(); - - success(orient); - - window.removeEventListener('deviceorientation', listener, false); - }; - - return window.addEventListener('deviceorientation', listener, false); - } -}; - -var browser = require('cordova/platform'); - -module.exports = Compass; -require('cordova/exec/proxy').add('Compass', Compass); - -}); diff --git a/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/CompassError.js b/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/CompassError.js deleted file mode 100644 index 7f9d177..0000000 --- a/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/CompassError.js +++ /dev/null @@ -1,36 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassError", function(require, exports, module) { /* - * - * 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. - * -*/ - -/** - * CompassError. - * An error code assigned by an implementation when an error has occurred - * @constructor - */ -var CompassError = function(err) { - this.code = (err !== undefined ? err : null); -}; - -CompassError.COMPASS_INTERNAL_ERR = 0; -CompassError.COMPASS_NOT_SUPPORTED = 20; - -module.exports = CompassError; - -}); diff --git a/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js b/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js deleted file mode 100644 index 32bc9b5..0000000 --- a/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/CompassHeading.js +++ /dev/null @@ -1,31 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.CompassHeading", function(require, exports, module) { /* - * - * 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. - * -*/ - -var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) { - this.magneticHeading = magneticHeading; - this.trueHeading = trueHeading; - this.headingAccuracy = headingAccuracy; - this.timestamp = timestamp || new Date().getTime(); -}; - -module.exports = CompassHeading; - -}); diff --git a/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/compass.js b/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/compass.js deleted file mode 100644 index c1b7ae6..0000000 --- a/platforms/browser/www/plugins/cordova-plugin-device-orientation/www/compass.js +++ /dev/null @@ -1,120 +0,0 @@ -cordova.define("cordova-plugin-device-orientation.compass", function(require, exports, module) { /* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - utils = require('cordova/utils'), - CompassHeading = require('./CompassHeading'), - CompassError = require('./CompassError'), - - timers = {}, - eventTimerId = null, - compass = { - /** - * Asynchronously acquires the current heading. - * @param {Function} successCallback The function to call when the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {CompassOptions} options The options for getting the heading data (not used). - */ - getCurrentHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments); - - var win = function(result) { - var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp); - successCallback(ch); - }; - var fail = errorCallback && function(code) { - var ce = new CompassError(code); - errorCallback(ce); - }; - - // Get heading - exec(win, fail, "Compass", "getHeading", [options]); - }, - - /** - * Asynchronously acquires the heading repeatedly at a given interval. - * @param {Function} successCallback The function to call each time the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {HeadingOptions} options The options for getting the heading data - * such as timeout and the frequency of the watch. For iOS, filter parameter - * specifies to watch via a distance filter rather than time. - */ - watchHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.watchHeading', arguments); - // Default interval (100 msec) - var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100; - var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0; - - var id = utils.createUUID(); - if (filter > 0) { - // is an iOS request for watch by filter, no timer needed - timers[id] = "iOS"; - compass.getCurrentHeading(successCallback, errorCallback, options); - } else { - // Start watch timer to get headings - timers[id] = window.setInterval(function() { - compass.getCurrentHeading(successCallback, errorCallback); - }, frequency); - } - - if (cordova.platformId === 'browser' && !eventTimerId) { - // Start firing deviceorientation events if haven't already - var deviceorientationEvent = new Event('deviceorientation'); - eventTimerId = window.setInterval(function() { - window.dispatchEvent(deviceorientationEvent); - }, 200); - } - - return id; - }, - - /** - * Clears the specified heading watch. - * @param {String} id The ID of the watch returned from #watchHeading. - */ - clearWatch:function(id) { - // Stop javascript timer & remove from timer list - if (id && timers[id]) { - if (timers[id] != "iOS") { - clearInterval(timers[id]); - } else { - // is iOS watch by filter so call into device to stop - exec(null, null, "Compass", "stopHeading", []); - } - delete timers[id]; - - if (eventTimerId && Object.keys(timers).length === 0) { - // No more watchers, so stop firing 'deviceorientation' events - window.clearInterval(eventTimerId); - eventTimerId = null; - } - } - } - }; - -module.exports = compass; - -}); diff --git a/platforms/browser/www/plugins/cordova-plugin-device/src/browser/DeviceProxy.js b/platforms/browser/www/plugins/cordova-plugin-device/src/browser/DeviceProxy.js new file mode 100644 index 0000000..f62801d --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-device/src/browser/DeviceProxy.js @@ -0,0 +1,84 @@ +cordova.define("cordova-plugin-device.DeviceProxy", function(require, exports, module) { /* + * + * 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. + * + */ +var browser = require('cordova/platform'); + +function getPlatform() { + return "browser"; +} + +function getModel() { + return getBrowserInfo(true); +} + +function getVersion() { + return getBrowserInfo(false); +} + +function getBrowserInfo(getModel) { + var userAgent = navigator.userAgent; + var returnVal = ''; + var offset; + + if ((offset = userAgent.indexOf('Chrome')) !== -1) { + returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); + } else if ((offset = userAgent.indexOf('Safari')) !== -1) { + if (getModel) { + returnVal = 'Safari'; + } else { + returnVal = userAgent.substring(offset + 7); + + if ((offset = userAgent.indexOf('Version')) !== -1) { + returnVal = userAgent.substring(offset + 8); + } + } + } else if ((offset = userAgent.indexOf('Firefox')) !== -1) { + returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8); + } else if ((offset = userAgent.indexOf('MSIE')) !== -1) { + returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5); + } else if ((offset = userAgent.indexOf('Trident')) !== -1) { + returnVal = (getModel) ? 'MSIE' : '11'; + } + + if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) { + returnVal = returnVal.substring(0, offset); + } + + return returnVal; +} + + +module.exports = { + getDeviceInfo: function (success, error) { + setTimeout(function () { + success({ + cordova: browser.cordovaVersion, + platform: getPlatform(), + model: getModel(), + version: getVersion(), + uuid: null + }); + }, 0); + } +}; + +require("cordova/exec/proxy").add("Device", module.exports); + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-device/www/device.js b/platforms/browser/www/plugins/cordova-plugin-device/www/device.js new file mode 100644 index 0000000..ff0c5b4 --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-device/www/device.js @@ -0,0 +1,85 @@ +cordova.define("cordova-plugin-device.device", function(require, exports, module) { /* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + channel = require('cordova/channel'), + utils = require('cordova/utils'), + exec = require('cordova/exec'), + cordova = require('cordova'); + +channel.createSticky('onCordovaInfoReady'); +// Tell cordova channel to wait on the CordovaInfoReady event +channel.waitForInitialization('onCordovaInfoReady'); + +/** + * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the + * phone, etc. + * @constructor + */ +function Device() { + this.available = false; + this.platform = null; + this.version = null; + this.uuid = null; + this.cordova = null; + this.model = null; + this.manufacturer = null; + this.isVirtual = null; + this.serial = null; + + var me = this; + + channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js + //TODO: CB-5105 native implementations should not return info.cordova + var buildLabel = cordova.version; + me.available = true; + me.platform = info.platform; + me.version = info.version; + me.uuid = info.uuid; + me.cordova = buildLabel; + me.model = info.model; + me.isVirtual = info.isVirtual; + me.manufacturer = info.manufacturer || 'unknown'; + me.serial = info.serial || 'unknown'; + channel.onCordovaInfoReady.fire(); + },function(e) { + me.available = false; + utils.alert("[ERROR] Error initializing Cordova: " + e); + }); + }); +} + +/** + * Get device info + * + * @param {Function} successCallback The function to call when the heading data is available + * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL) + */ +Device.prototype.getInfo = function(successCallback, errorCallback) { + argscheck.checkArgs('fF', 'Device.getInfo', arguments); + exec(successCallback, errorCallback, "Device", "getDeviceInfo", []); +}; + +module.exports = new Device(); + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-dialogs/www/browser/notification.js b/platforms/browser/www/plugins/cordova-plugin-dialogs/www/browser/notification.js index 661f02b..b66573e 100644 --- a/platforms/browser/www/plugins/cordova-plugin-dialogs/www/browser/notification.js +++ b/platforms/browser/www/plugins/cordova-plugin-dialogs/www/browser/notification.js @@ -65,6 +65,21 @@ module.exports.prompt = window.navigator.notification.prompt = function(message, }; +var audioContext = (function() { + // Determine if the Audio API is supported by this browser + var AudioApi = window.AudioContext; + if (!AudioApi) { + AudioApi = window.webkitAudioContext; + } + + if (AudioApi) { + // The Audio API is supported, so create a singleton instance of the AudioContext + return new AudioApi(); + } + + return undefined; +}()); + module.exports.beep = window.navigator.notification.beep = function(times) { if (times > 0) { var BEEP_DURATION = 700; @@ -99,19 +114,4 @@ module.exports.beep = window.navigator.notification.beep = function(times) { } }; -var audioContext = (function() { - // Determine if the Audio API is supported by this browser - var AudioApi = window.AudioContext; - if (!AudioApi) { - AudioApi = window.webkitAudioContext; - } - - if (AudioApi) { - // The Audio API is supported, so create a singleton instance of the AudioContext - return new AudioApi(); - } - - return undefined; -}()); - }); diff --git a/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js deleted file mode 100644 index ff0e6c9..0000000 --- a/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/FileTransfer.js +++ /dev/null @@ -1,237 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransfer", function(require, exports, module) { /* - * - * 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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - FileTransferError = require('./FileTransferError'), - ProgressEvent = require('cordova-plugin-file.ProgressEvent'); - -function newProgressEvent(result) { - var pe = new ProgressEvent(); - pe.lengthComputable = result.lengthComputable; - pe.loaded = result.loaded; - pe.total = result.total; - return pe; -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function convertHeadersToArray(headers) { - var result = []; - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - var headerValue = headers[header]; - result.push({ - name: header, - value: headerValue.toString() - }); - } - } - return result; -} - -var idCounter = 0; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** -* Given an absolute file path, uploads a file on the device to a remote server -* using a multipart HTTP request. -* @param filePath {String} Full path of the file on the device -* @param server {String} URL of the server to receive the file -* @param successCallback (Function} Callback to be invoked when upload has completed -* @param errorCallback {Function} Callback to be invoked upon error -* @param options {FileUploadOptions} Optional parameters such as file name and mimetype -* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false -*/ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - // check for options - var fileKey = null; - var fileName = null; - var mimeType = null; - var params = null; - var chunkedMode = true; - var headers = null; - var httpMethod = null; - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - if (options) { - fileKey = options.fileKey; - fileName = options.fileName; - mimeType = options.mimeType; - headers = options.headers; - httpMethod = options.httpMethod || "POST"; - if (httpMethod.toUpperCase() == "PUT"){ - httpMethod = "PUT"; - } else { - httpMethod = "POST"; - } - if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { - chunkedMode = options.chunkedMode; - } - if (options.params) { - params = options.params; - } - else { - params = {}; - } - } - - if (cordova.platformId === "windowsphone") { - headers = headers && convertHeadersToArray(headers); - params = params && convertHeadersToArray(params); - } - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - var self = this; - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - self.onprogress(newProgressEvent(result)); - } - } else { - successCallback && successCallback(result); - } - }; - exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - var self = this; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var headers = null; - if (options) { - headers = options.headers || null; - } - - if (cordova.platformId === "windowsphone" && headers) { - headers = convertHeadersToArray(headers); - } - - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - return self.onprogress(newProgressEvent(result)); - } - } else if (successCallback) { - var entry = null; - if (result.isDirectory) { - entry = new (require('cordova-plugin-file.DirectoryEntry'))(); - } - else if (result.isFile) { - entry = new (require('cordova-plugin-file.FileEntry'))(); - } - entry.isDirectory = result.isDirectory; - entry.isFile = result.isFile; - entry.name = result.name; - entry.fullPath = result.fullPath; - entry.filesystem = new FileSystem(result.filesystemName || (result.filesystem == window.PERSISTENT ? 'persistent' : 'temporary')); - entry.nativeURL = result.nativeURL; - successCallback(entry); - } - }; - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - exec(null, null, 'FileTransfer', 'abort', [this._id]); -}; - -module.exports = FileTransfer; - -}); diff --git a/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js deleted file mode 100644 index 8339c2b..0000000 --- a/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/FileTransferError.js +++ /dev/null @@ -1,43 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.FileTransferError", function(require, exports, module) { /* - * - * 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. - * -*/ - -/** - * FileTransferError - * @constructor - */ -var FileTransferError = function(code, source, target, status, body, exception) { - this.code = code || null; - this.source = source || null; - this.target = target || null; - this.http_status = status || null; - this.body = body || null; - this.exception = exception || null; -}; - -FileTransferError.FILE_NOT_FOUND_ERR = 1; -FileTransferError.INVALID_URL_ERR = 2; -FileTransferError.CONNECTION_ERR = 3; -FileTransferError.ABORT_ERR = 4; -FileTransferError.NOT_MODIFIED_ERR = 5; - -module.exports = FileTransferError; - -}); diff --git a/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js b/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js deleted file mode 100644 index 7c76828..0000000 --- a/platforms/browser/www/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js +++ /dev/null @@ -1,330 +0,0 @@ -cordova.define("cordova-plugin-file-transfer.BrowserFileTransfer", function(require, exports, module) { /* - * - * 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. - * -*/ - -/*global module, require*/ - -var argscheck = require('cordova/argscheck'), - FileTransferError = require('./FileTransferError'); - -function getParentPath(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(0, pos + 1); -} - -function getFileName(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(pos + 1); -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function checkURL(url) { - return url.indexOf(' ') === -1 ? true : false; -} - -var idCounter = 0; - -var transfers = {}; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** - * Given an absolute file path, uploads a file on the device to a remote server - * using a multipart HTTP request. - * @param filePath {String} Full path of the file on the device - * @param server {String} URL of the server to receive the file - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param options {FileUploadOptions} Optional parameters such as file name and mimetype - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - */ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options) { - // check for arguments - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - - // Check if target URL doesn't contain spaces. If contains, it should be escaped first - // (see https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#upload) - if (!checkURL(server)) { - errorCallback && errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR, filePath, server)); - return; - } - - options = options || {}; - - var fileKey = options.fileKey || "file"; - var fileName = options.fileName || "image.jpg"; - var mimeType = options.mimeType || "image/jpeg"; - var params = options.params || {}; - var withCredentials = options.withCredentials || false; - // var chunkedMode = !!options.chunkedMode; // Not supported - var headers = options.headers || {}; - var httpMethod = options.httpMethod && options.httpMethod.toUpperCase() === "PUT" ? "PUT" : "POST"; - - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var that = this; - var xhr = transfers[this._id] = new XMLHttpRequest(); - xhr.withCredentials = withCredentials; - - var fail = errorCallback && function(code, status, response) { - transfers[this._id] && delete transfers[this._id]; - var error = new FileTransferError(code, filePath, server, status, response); - errorCallback && errorCallback(error); - }; - - window.resolveLocalFileSystemURL(filePath, function(entry) { - entry.file(function(file) { - var reader = new FileReader(); - reader.onloadend = function() { - var blob = new Blob([this.result], {type: mimeType}); - - // Prepare form data to send to server - var fd = new FormData(); - fd.append(fileKey, blob, fileName); - for (var prop in params) { - if (params.hasOwnProperty(prop)) { - fd.append(prop, params[prop]); - } - } - - xhr.open(httpMethod, server); - - // Fill XHR headers - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr.setRequestHeader(header, headers[header]); - } - } - - xhr.onload = function() { - if (this.status === 200) { - var result = new FileUploadResult(); // jshint ignore:line - result.bytesSent = blob.size; - result.responseCode = this.status; - result.response = this.response; - delete transfers[that._id]; - successCallback(result); - } else if (this.status === 404) { - fail(FileTransferError.INVALID_URL_ERR, this.status, this.response); - } else { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - } - }; - - xhr.ontimeout = function() { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onerror = function() { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onabort = function () { - fail(FileTransferError.ABORT_ERR, this.status, this.response); - }; - - xhr.upload.onprogress = function (e) { - that.onprogress && that.onprogress(e); - }; - - xhr.send(fd); - // Special case when transfer already aborted, but XHR isn't sent. - // In this case XHR won't fire an abort event, so we need to check if transfers record - // isn't deleted by filetransfer.abort and if so, call XHR's abort method again - if (!transfers[that._id]) { - xhr.abort(); - } - }; - reader.readAsArrayBuffer(file); - }, function() { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }); - }, function() { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - - // Check if target URL doesn't contain spaces. If contains, it should be escaped first - // (see https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#download) - if (!checkURL(source)) { - errorCallback && errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target)); - return; - } - - options = options || {}; - - var headers = options.headers || {}; - var withCredentials = options.withCredentials || false; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var that = this; - var xhr = transfers[this._id] = new XMLHttpRequest(); - xhr.withCredentials = withCredentials; - var fail = errorCallback && function(code, status, response) { - transfers[that._id] && delete transfers[that._id]; - // In XHR GET reqests we're setting response type to Blob - // but in case of error we need to raise event with plain text response - if (response instanceof Blob) { - var reader = new FileReader(); - reader.readAsText(response); - reader.onloadend = function(e) { - var error = new FileTransferError(code, source, target, status, e.target.result); - errorCallback(error); - }; - } else { - var error = new FileTransferError(code, source, target, status, response); - errorCallback(error); - } - }; - - xhr.onload = function (e) { - - var fileNotFound = function () { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }; - - var req = e.target; - // req.status === 0 is special case for local files with file:// URI scheme - if ((req.status === 200 || req.status === 0) && req.response) { - window.resolveLocalFileSystemURL(getParentPath(target), function (dir) { - dir.getFile(getFileName(target), {create: true}, function writeFile(entry) { - entry.createWriter(function (fileWriter) { - fileWriter.onwriteend = function (evt) { - if (!evt.target.error) { - entry.filesystemName = entry.filesystem.name; - delete transfers[that._id]; - successCallback && successCallback(entry); - } else { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - } - }; - fileWriter.onerror = function () { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }; - fileWriter.write(req.response); - }, fileNotFound); - }, fileNotFound); - }, fileNotFound); - } else if (req.status === 404) { - fail(FileTransferError.INVALID_URL_ERR, req.status, req.response); - } else { - fail(FileTransferError.CONNECTION_ERR, req.status, req.response); - } - }; - - xhr.onprogress = function (e) { - that.onprogress && that.onprogress(e); - }; - - xhr.onerror = function () { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onabort = function () { - fail(FileTransferError.ABORT_ERR, this.status, this.response); - }; - - xhr.open("GET", source, true); - - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr.setRequestHeader(header, headers[header]); - } - } - - xhr.responseType = "blob"; - - xhr.send(); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - if (this instanceof FileTransfer) { - if (transfers[this._id]) { - transfers[this._id].abort(); - delete transfers[this._id]; - } - } -}; - -module.exports = FileTransfer; - -}); diff --git a/platforms/browser/www/plugins/cordova-plugin-file/www/browser/isChrome.js b/platforms/browser/www/plugins/cordova-plugin-file/www/browser/isChrome.js index 42083da..1421b21 100644 --- a/platforms/browser/www/plugins/cordova-plugin-file/www/browser/isChrome.js +++ b/platforms/browser/www/plugins/cordova-plugin-file/www/browser/isChrome.js @@ -1,28 +1,28 @@ -cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) { /* - * - * 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. - * - */ - -module.exports = function () { - // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and - // possibly a good flag to indicate that we're running in Chrome - return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; -}; +cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) { /* + * + * 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. + * + */ + +module.exports = function () { + // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and + // possibly a good flag to indicate that we're running in Chrome + return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; +}; }); diff --git a/platforms/browser/www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js b/platforms/browser/www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js index 812abf0..b2f5b45 100644 --- a/platforms/browser/www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js +++ b/platforms/browser/www/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js @@ -92,6 +92,7 @@ function CameraUI() { * @param {Function} errorCB Error callback */ CameraUI.prototype.startPreview = function(count, successCB, errorCB) { + var that = this; this.preview.onclick = function (e) { // proceed with capture here @@ -113,7 +114,6 @@ CameraUI.prototype.startPreview = function(count, successCB, errorCB) { errorCB(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }; - var that = this; navigator.getUserMedia({video: true}, function (previewStream) { // Save video stream to be able to stop it later that._previewStream = previewStream; @@ -133,24 +133,31 @@ CameraUI.prototype.destroyPreview = function () { this.preview.src = null; this._previewStream.stop(); this._previewStream = null; - this.container && document.body.removeChild(this.container); + if (this.container) { + document.body.removeChild(this.container); + } }; module.exports = { - captureAudio:function(successCallback, errorCallback) { - errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + if (errorCallback) { + errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + } }, captureVideo:function (successCallback, errorCallback) { - errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + if (errorCallback) { + errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + } }, captureImage:function (successCallback, errorCallback, args) { var fail = function (code) { - errorCallback && errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR)); + if (errorCallback) { + errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR)); + } }; var options = args[0]; @@ -217,7 +224,9 @@ module.exports = { var img = document.createElement('img'); img.src = args[0]; img.onload = function () { - successCallback && successCallback(new MediaFileData(null, 0, img.height, img.width, 0)); + if (successCallback) { + successCallback(new MediaFileData(null, 0, img.height, img.width, 0)); + } }; } }; diff --git a/platforms/browser/www/plugins/cordova-plugin-media-capture/www/CaptureError.js b/platforms/browser/www/plugins/cordova-plugin-media-capture/www/CaptureError.js index c4eba1e..e73ac80 100644 --- a/platforms/browser/www/plugins/cordova-plugin-media-capture/www/CaptureError.js +++ b/platforms/browser/www/plugins/cordova-plugin-media-capture/www/CaptureError.js @@ -34,6 +34,8 @@ CaptureError.CAPTURE_APPLICATION_BUSY = 1; CaptureError.CAPTURE_INVALID_ARGUMENT = 2; // User exited camera application or audio capture application before capturing anything. CaptureError.CAPTURE_NO_MEDIA_FILES = 3; +// User denied permissions required to perform the capture request. +CaptureError.CAPTURE_PERMISSION_DENIED = 4; // The requested capture operation is not supported. CaptureError.CAPTURE_NOT_SUPPORTED = 20; diff --git a/platforms/browser/www/plugins/cordova-plugin-media/www/Media.js b/platforms/browser/www/plugins/cordova-plugin-media/www/Media.js index 96620db..c3aa111 100644 --- a/platforms/browser/www/plugins/cordova-plugin-media/www/Media.js +++ b/platforms/browser/www/plugins/cordova-plugin-media/www/Media.js @@ -159,10 +159,18 @@ Media.prototype.setRate = function(rate) { if (cordova.platformId === 'ios'){ exec(null, null, "Media", "setRate", [this.id, rate]); } else { - console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.') + console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.'); } }; +/** + * Get amplitude of audio. + */ +Media.prototype.getCurrentAmplitude = function(success, fail) { + exec(function(p) { + success(p); + }, fail, "Media", "getCurrentAmplitudeAudio", [this.id]); +}; /** * Audio has status update. @@ -176,30 +184,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value == Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value == Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } - else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/platforms/browser/www/plugins/cordova-plugin-media/www/browser/Media.js b/platforms/browser/www/plugins/cordova-plugin-media/www/browser/Media.js index 350ebab..5422b50 100644 --- a/platforms/browser/www/plugins/cordova-plugin-media/www/browser/Media.js +++ b/platforms/browser/www/plugins/cordova-plugin-media/www/browser/Media.js @@ -19,13 +19,45 @@ cordova.define("cordova-plugin-media.BrowserMedia", function(require, exports, m * */ -/*global MediaError, module, require*/ +/* global MediaError */ var argscheck = require('cordova/argscheck'), utils = require('cordova/utils'); var mediaObjects = {}; +/** + * This class provides access to the device media, interfaces to both sound and video + * + * @constructor + * @param src The file name or url to play + * @param successCallback The callback to be called when the file is done playing or recording. + * successCallback() + * @param errorCallback The callback to be called if there is an error. + * errorCallback(int errorCode) - OPTIONAL + * @param statusCallback The callback to be called when media status has changed. + * statusCallback(int statusCode) - OPTIONAL + */ +var Media = function(src, successCallback, errorCallback, statusCallback) { + argscheck.checkArgs('SFFF', 'Media', arguments); + this.id = utils.createUUID(); + mediaObjects[this.id] = this; + this.src = src; + this.successCallback = successCallback; + this.errorCallback = errorCallback; + this.statusCallback = statusCallback; + this._duration = -1; + this._position = -1; + + Media.onStatus(this.id, Media.MEDIA_STATE, Media.MEDIA_STARTING); + + try { + this.node = createNode(this); + } catch (err) { + Media.onStatus(this.id, Media.MEDIA_ERROR, { code: MediaError.MEDIA_ERR_ABORTED }); + } +}; + /** * Creates new Audio node and with necessary event listeners attached * @param {Media} media Media object @@ -66,38 +98,6 @@ function createNode (media) { return node; } -/** - * This class provides access to the device media, interfaces to both sound and video - * - * @constructor - * @param src The file name or url to play - * @param successCallback The callback to be called when the file is done playing or recording. - * successCallback() - * @param errorCallback The callback to be called if there is an error. - * errorCallback(int errorCode) - OPTIONAL - * @param statusCallback The callback to be called when media status has changed. - * statusCallback(int statusCode) - OPTIONAL - */ -var Media = function(src, successCallback, errorCallback, statusCallback) { - argscheck.checkArgs('SFFF', 'Media', arguments); - this.id = utils.createUUID(); - mediaObjects[this.id] = this; - this.src = src; - this.successCallback = successCallback; - this.errorCallback = errorCallback; - this.statusCallback = statusCallback; - this._duration = -1; - this._position = -1; - - Media.onStatus(this.id, Media.MEDIA_STATE, Media.MEDIA_STARTING); - - try { - this.node = createNode(this); - } catch (err) { - Media.onStatus(this.id, Media.MEDIA_ERROR, { code: MediaError.MEDIA_ERR_ABORTED }); - } -}; - // Media messages Media.MEDIA_STATE = 1; Media.MEDIA_DURATION = 2; @@ -230,29 +230,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value === Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value === Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/platforms/browser/www/plugins/cordova-plugin-network-information/src/browser/network.js b/platforms/browser/www/plugins/cordova-plugin-network-information/src/browser/network.js new file mode 100644 index 0000000..fb11242 --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-network-information/src/browser/network.js @@ -0,0 +1,50 @@ +cordova.define("cordova-plugin-network-information.NetworkInfoProxy", function(require, exports, module) { /* + * 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. + * +*/ + +var cordova = require('cordova'), + proxy = require("cordova/exec/proxy"), + Connection = require('./Connection'); + +var type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + +// Subscribe to 'native' online/offline events +function onStatusChange(evt) { + type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + // force async + setTimeout(function(){ + cordova.fireDocumentEvent(evt.type); + },0); +} + +window.addEventListener('online', onStatusChange); +window.addEventListener('offline', onStatusChange); + +proxy.add("NetworkStatus", { + getConnectionInfo:function(cbSuccess) { + // force async + setTimeout(function(){ + cbSuccess(type); + },0); + } +}); + + + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-network-information/www/Connection.js b/platforms/browser/www/plugins/cordova-plugin-network-information/www/Connection.js new file mode 100644 index 0000000..1450e95 --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-network-information/www/Connection.js @@ -0,0 +1,36 @@ +cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) { /* + * + * 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. + * +*/ + +/** + * Network status + */ +module.exports = { + UNKNOWN: "unknown", + ETHERNET: "ethernet", + WIFI: "wifi", + CELL_2G: "2g", + CELL_3G: "3g", + CELL_4G: "4g", + CELL:"cellular", + NONE: "none" +}; + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-network-information/www/network.js b/platforms/browser/www/plugins/cordova-plugin-network-information/www/network.js new file mode 100644 index 0000000..bfac2e3 --- /dev/null +++ b/platforms/browser/www/plugins/cordova-plugin-network-information/www/network.js @@ -0,0 +1,93 @@ +cordova.define("cordova-plugin-network-information.network", function(require, exports, module) { /* + * 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. + * +*/ + +var exec = require('cordova/exec'), + cordova = require('cordova'), + channel = require('cordova/channel'), + utils = require('cordova/utils'); + +// Link the onLine property with the Cordova-supplied network info. +// This works because we clobber the navigator object with our own +// object in bootstrap.js. +// Browser platform do not need to define this property, because +// it is already supported by modern browsers +if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') { + utils.defineGetter(navigator, 'onLine', function() { + return this.connection.type != 'none'; + }); +} + +function NetworkConnection() { + this.type = 'unknown'; +} + +/** + * Get connection info + * + * @param {Function} successCallback The function to call when the Connection data is available + * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL) + */ +NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []); +}; + +var me = new NetworkConnection(); +var timerId = null; +var timeout = 500; + +channel.createSticky('onCordovaConnectionReady'); +channel.waitForInitialization('onCordovaConnectionReady'); + +channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + me.type = info; + if (info === "none") { + // set a timer if still offline at the end of timer send the offline event + timerId = setTimeout(function(){ + cordova.fireDocumentEvent("offline"); + timerId = null; + }, timeout); + } else { + // If there is a current offline event pending clear it + if (timerId !== null) { + clearTimeout(timerId); + timerId = null; + } + cordova.fireDocumentEvent("online"); + } + + // should only fire this once + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + }, + function (e) { + // If we can't get the network info we should still tell Cordova + // to fire the deviceready event. + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + console.log("Error initializing Network Connection: " + e); + }); +}); + +module.exports = me; + +}); diff --git a/platforms/browser/www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js b/platforms/browser/www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js index b01d8f8..2d1db9f 100644 --- a/platforms/browser/www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js +++ b/platforms/browser/www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js @@ -18,17 +18,18 @@ cordova.define("cordova-plugin-splashscreen.SplashScreenProxy", function(require * under the License. * */ + // Default parameter values including image size can be changed in `config.xml` var splashImageWidth = 170; var splashImageHeight = 200; var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight }; -var splash = null; // var localSplash; // the image to display var localSplashImage; var bgColor = "#464646"; -var imageSrc = 'img/logo.png'; +var imageSrc = '/img/logo.png'; var splashScreenDelay = 3000; // in milliseconds var showSplashScreen = true; // show splashcreen by default +var cordova = require('cordova'); var configHelper = cordova.require('cordova/confighelper'); function updateImageLocation() { @@ -103,7 +104,6 @@ function readPreferencesFromCfg(cfg) { } catch(e) { var msg = '[Browser][SplashScreen] Error occured on loading preferences from config.xml: ' + JSON.stringify(e); console.error(msg); - error(msg); } } diff --git a/platforms/browser/www/screens/home.html b/platforms/browser/www/screens/home.html index a30fe38..0213329 100644 --- a/platforms/browser/www/screens/home.html +++ b/platforms/browser/www/screens/home.html @@ -1,71 +1,57 @@ -
-
- -

- Loading... -
-
-

-
-
-
- -
-

GPS location inaccurate. -
-
- Waiting for better accuracy...

-
- - - -
-

-
-
-
-
-

Energy

- -
-
- -
-
- - - - \ No newline at end of file +
+
+ +

+ Acquiring Location... +
+
+

+
+
+
+ +
+

GPS location inaccurate. +
+
+ Waiting for better accuracy...

+
+ + + +
+

+
+
+
+
+

Energy

+ +
+ +
+
+ Menu +
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/platforms/browser/www/screens/inventory.html b/platforms/browser/www/screens/inventory.html index e69de29..262b022 100644 --- a/platforms/browser/www/screens/inventory.html +++ b/platforms/browser/www/screens/inventory.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/platforms/browser/www/screens/login.html b/platforms/browser/www/screens/login.html index 2fe5c5d..13a7a25 100644 --- a/platforms/browser/www/screens/login.html +++ b/platforms/browser/www/screens/login.html @@ -1,37 +1,69 @@ -
-
-
-
- Login to TerranQuest -
-
- -
- - -
-
-
- - -
-
- -
-
-
- - \ No newline at end of file +
+
+ +

+ Logging in... +
+
+

+
+
+
+
+
+
+
+ Login to TerranQuest +
+
+ +
+ + +
+
+
+ + +
+
+ +
+
+
+ \ No newline at end of file diff --git a/platforms/browser/www/screens/menu.html b/platforms/browser/www/screens/menu.html index e69de29..dca5af9 100644 --- a/platforms/browser/www/screens/menu.html +++ b/platforms/browser/www/screens/menu.html @@ -0,0 +1,24 @@ +
+ + + + + + + +
+ \ No newline at end of file diff --git a/platforms/browser/www/screens/newhtml.html b/platforms/browser/www/screens/newhtml.html deleted file mode 100644 index a894055..0000000 --- a/platforms/browser/www/screens/newhtml.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - Test - - - - -
- -

- Loading... -
-
-

-
-
- - diff --git a/platforms/browser/www/screens/place.html b/platforms/browser/www/screens/place.html new file mode 100644 index 0000000..5c993a1 --- /dev/null +++ b/platforms/browser/www/screens/place.html @@ -0,0 +1,9 @@ +
+
+
+ + \ No newline at end of file diff --git a/platforms/browser/www/screens/profile.html b/platforms/browser/www/screens/profile.html index 01bb045..b7e6a70 100644 --- a/platforms/browser/www/screens/profile.html +++ b/platforms/browser/www/screens/profile.html @@ -1,44 +1,61 @@ -
-
Badges
-
- Loading... -
-
- -
- \ No newline at end of file +
+
+

+
Badges
+
+ Loading... +
+
+ +
+ +
\ No newline at end of file diff --git a/platforms/browser/www/screens/rules.html b/platforms/browser/www/screens/rules.html new file mode 100644 index 0000000..4ce35a7 --- /dev/null +++ b/platforms/browser/www/screens/rules.html @@ -0,0 +1,20 @@ +
+
Rules
+

Please read these rules. Because TerranQuest is a game involving other + people and the environment, it's important to show good etiquette.

+
    +
  1. Do not endanger yourself or others
  2. +
  3. Be considerate and polite in the in-game chat, and don't swear
  4. +
  5. Observe all local laws and rules
  6. +
  7. Respect property rights and obtain permission for playing on private land
  8. +
  9. Be nice to other people and try not to look too creepy
  10. +
  11. Respect and minimize your impact on the environment
  12. +
  13. Don't tamper with or deface any objects, landmarks, barcodes, or other real-world items
  14. +
  15. Pick up any trash you find and dispose of it properly if you can
  16. +
  17. Socialize with any players of other games, such as Geocaching and Ingress, you might meet
  18. +
  19. Follow the Netsyms Technologies Terms of Service at netsyms.com/legal
  20. + +
+
\ No newline at end of file diff --git a/platforms/browser/www/screens/settings.html b/platforms/browser/www/screens/settings.html new file mode 100644 index 0000000..c8d4efa --- /dev/null +++ b/platforms/browser/www/screens/settings.html @@ -0,0 +1,26 @@ +
+
+
+ Logout from app +
+
+

+ Third-Party Licenses +
+ Map tiles by Stamen Design (stamen.com), under CC BY 3.0 (creativecommons.org/licenses/by/3.0). +
+ Map tile data by OpenStreetMap (openstreetmap.org), under CC BY-SA (creativecommons.org/licenses/by-sa/3.0). +
+ Places from OpenStreetMap and contributers, licensed under the ODbL (opendatacommons.org/licenses/odbl). Email apis@netsyms.com for free access to our API. +
+ Map display is powered by Leaflet (leafletjs.com), copyright (c) 2010-2016, Vladimir Agafonkin and copyright (c) 2010-2011, CloudMade. BSD 2-clause license. +
+ Terrain information for the United States from the MRLC National Land Cover Database 2011 (mrlc.gov). +
+ Weather data Powered by Forecast (forecast.io). +
+ Geocache data from the OpenCaching.US OKAPI. Data licensed under the CC BY-NC-SA 2.5 (creativecommons.org/licenses/by-nc-sa/2.5). +

+
+
+
\ No newline at end of file diff --git a/platforms/browser/www/screens/signup.html b/platforms/browser/www/screens/signup.html index f7fab03..950770b 100644 --- a/platforms/browser/www/screens/signup.html +++ b/platforms/browser/www/screens/signup.html @@ -1,43 +1,45 @@ -
-
-
-
- Create Netsyms Account -
-
- -
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
- -
-
-
+
+
+
+
+ Create Netsyms Account +
+
+ +
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+

By signing up, you agree to the Netsyms Technologies Terms of Service and Privacy Policy at netsyms.com/legal

+
+ +
+
+
\ No newline at end of file diff --git a/platforms/browser/www/screens/splash.html b/platforms/browser/www/screens/splash.html index 1e6dd95..b4d347e 100644 --- a/platforms/browser/www/screens/splash.html +++ b/platforms/browser/www/screens/splash.html @@ -1,5 +1,9 @@ -
- - - +
+ +

+ Loading... +
+
+

+
\ No newline at end of file diff --git a/platforms/platforms.json b/platforms/platforms.json index e0007af..2509682 100644 --- a/platforms/platforms.json +++ b/platforms/platforms.json @@ -1,4 +1,4 @@ { - "android": "5.1.0", - "browser": "4.0.0" + "browser": "4.0.0", + "android": "5.1.1" } \ No newline at end of file diff --git a/plugins/android.json b/plugins/android.json index 596f68f..e425c3c 100644 --- a/plugins/android.json +++ b/plugins/android.json @@ -7,36 +7,46 @@ "files": {} }, "installed_plugins": { - "cordova-plugin-geolocation": { + "cordova-plugin-whitelist": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file": { + "cordova-plugin-console": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media": { + "cordova-plugin-device": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media-capture": { + "cordova-plugin-camera": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file-transfer": { + "cordova-plugin-splashscreen": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-device-orientation": { + "cordova-plugin-network-information": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "phonegap-plugin-barcodescanner": { + "cordova-plugin-dialogs": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-dialogs": { + "cordova-plugin-media": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-splashscreen": { + "cordova-plugin-media-capture": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-whitelist": { + "cordova-plugin-geolocation": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "phonegap-plugin-barcodescanner": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" } }, - "dependent_plugins": {} + "dependent_plugins": { + "cordova-plugin-compat": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "cordova-plugin-file": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + } + } } \ No newline at end of file diff --git a/plugins/browser.json b/plugins/browser.json index e851370..e425c3c 100644 --- a/plugins/browser.json +++ b/plugins/browser.json @@ -7,36 +7,46 @@ "files": {} }, "installed_plugins": { - "cordova-plugin-device-orientation": { + "cordova-plugin-whitelist": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file": { + "cordova-plugin-console": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-file-transfer": { + "cordova-plugin-device": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-geolocation": { + "cordova-plugin-camera": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media": { + "cordova-plugin-splashscreen": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-media-capture": { + "cordova-plugin-network-information": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "phonegap-plugin-barcodescanner": { + "cordova-plugin-dialogs": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-dialogs": { + "cordova-plugin-media": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-splashscreen": { + "cordova-plugin-media-capture": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" }, - "cordova-plugin-whitelist": { + "cordova-plugin-geolocation": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "phonegap-plugin-barcodescanner": { "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" } }, - "dependent_plugins": {} + "dependent_plugins": { + "cordova-plugin-compat": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + }, + "cordova-plugin-file": { + "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" + } + } } \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/CONTRIBUTING.md b/plugins/cordova-plugin-camera/CONTRIBUTING.md similarity index 100% rename from plugins/cordova-plugin-device-orientation/CONTRIBUTING.md rename to plugins/cordova-plugin-camera/CONTRIBUTING.md diff --git a/plugins/cordova-plugin-device-orientation/LICENSE b/plugins/cordova-plugin-camera/LICENSE similarity index 100% rename from plugins/cordova-plugin-device-orientation/LICENSE rename to plugins/cordova-plugin-camera/LICENSE diff --git a/plugins/cordova-plugin-device-orientation/NOTICE b/plugins/cordova-plugin-camera/NOTICE similarity index 100% rename from plugins/cordova-plugin-device-orientation/NOTICE rename to plugins/cordova-plugin-camera/NOTICE diff --git a/plugins/cordova-plugin-camera/README.md b/plugins/cordova-plugin-camera/README.md new file mode 100644 index 0000000..6d175f0 --- /dev/null +++ b/plugins/cordova-plugin-camera/README.md @@ -0,0 +1,528 @@ + + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-camera) + +# cordova-plugin-camera + +This plugin defines a global `navigator.camera` object, which provides an API for taking pictures and for choosing images from +the system's image library. + +Although the object is attached to the global scoped `navigator`, it is not available until after the `deviceready` event. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## Installation + +This requires cordova 5.0+ + + cordova plugin add cordova-plugin-camera +Older versions of cordova can still install via the __deprecated__ id + + cordova plugin add org.apache.cordova.camera +It is also possible to install via repo url directly ( unstable ) + + cordova plugin add https://github.com/apache/cordova-plugin-camera.git + + +## How to Contribute + +Contributors are welcome! And we need your contributions to keep the project moving forward. You can [report bugs](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Camera%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC), improve the documentation, or [contribute code](https://github.com/apache/cordova-plugin-camera/pulls). + +There is a specific [contributor workflow](http://wiki.apache.org/cordova/ContributorWorkflow) we recommend. Start reading there. More information is available on [our wiki](http://wiki.apache.org/cordova). + +:warning: **Found an issue?** File it on [JIRA issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Camera%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC). + +**Have a solution?** Send a [Pull Request](https://github.com/apache/cordova-plugin-camera/pulls). + +In order for your changes to be accepted, you need to sign and submit an Apache [ICLA](http://www.apache.org/licenses/#clas) (Individual Contributor License Agreement). Then your name will appear on the list of CLAs signed by [non-committers](https://people.apache.org/committer-index.html#unlistedclas) or [Cordova committers](http://people.apache.org/committers-by-project.html#cordova). + +**And don't forget to test and document your code.** + + +## This documentation is generated by a tool + +:warning: Run `npm install` in the plugin repo to enable automatic docs generation if you plan to send a PR. +[jsdoc-to-markdown](https://www.npmjs.com/package/jsdoc-to-markdown) is used to generate the docs. +Documentation consists of template and API docs produced from the plugin JS code and should be regenerated before each commit (done automatically via [husky](https://github.com/typicode/husky), running `npm run gen-docs` script as a `precommit` hook - see `package.json` for details). + + +--- + +# API Reference + + +* [camera](#module_camera) + * [.getPicture(successCallback, errorCallback, options)](#module_camera.getPicture) + * [.cleanup()](#module_camera.cleanup) + * [.onError](#module_camera.onError) : function + * [.onSuccess](#module_camera.onSuccess) : function + * [.CameraOptions](#module_camera.CameraOptions) : Object + + +* [Camera](#module_Camera) + * [.DestinationType](#module_Camera.DestinationType) : enum + * [.EncodingType](#module_Camera.EncodingType) : enum + * [.MediaType](#module_Camera.MediaType) : enum + * [.PictureSourceType](#module_Camera.PictureSourceType) : enum + * [.PopoverArrowDirection](#module_Camera.PopoverArrowDirection) : enum + * [.Direction](#module_Camera.Direction) : enum + +* [CameraPopoverHandle](#module_CameraPopoverHandle) +* [CameraPopoverOptions](#module_CameraPopoverOptions) + +--- + + +## camera + +### camera.getPicture(successCallback, errorCallback, options) +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 `camera.getPicture` function opens the device's default camera +application that allows users to snap pictures by default - this behavior occurs, +when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`](#module_Camera.PictureSourceType). +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`](#module_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`](#module_camera.onSuccess) 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 `` 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__ + +- Android +- BlackBerry +- Browser +- Firefox +- FireOS +- iOS +- Windows +- WP8 +- Ubuntu + +More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks). + +**Kind**: static method of [camera](#module_camera) + +| Param | Type | Description | +| --- | --- | --- | +| successCallback | [onSuccess](#module_camera.onSuccess) | | +| errorCallback | [onError](#module_camera.onError) | | +| options | [CameraOptions](#module_camera.CameraOptions) | CameraOptions | + +**Example** +```js +navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); +``` + +### camera.cleanup() +Removes intermediate image files that are kept in temporary storage +after calling [`camera.getPicture`](#module_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 + +**Kind**: static method of [camera](#module_camera) +**Example** +```js +navigator.camera.cleanup(onSuccess, onFail); + +function onSuccess() { + console.log("Camera cleanup success.") +} + +function onFail(message) { + alert('Failed because: ' + message); +} +``` + +### camera.onError : function +Callback function that provides an error message. + +**Kind**: static typedef of [camera](#module_camera) + +| Param | Type | Description | +| --- | --- | --- | +| message | string | The message is provided by the device's native code. | + + +### camera.onSuccess : function +Callback function that provides the image data. + +**Kind**: static typedef of [camera](#module_camera) + +| Param | Type | Description | +| --- | --- | --- | +| imageData | string | Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`](#module_camera.CameraOptions) in effect. | + +**Example** +```js +// Show image +// +function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; +} +``` + +### camera.CameraOptions : Object +Optional parameters to customize the camera settings. +* [Quirks](#CameraOptions-quirks) + +**Kind**: static typedef of [camera](#module_camera) +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| quality | number | 50 | Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.) | +| destinationType | [DestinationType](#module_Camera.DestinationType) | FILE_URI | Choose the format of the return value. | +| sourceType | [PictureSourceType](#module_Camera.PictureSourceType) | CAMERA | Set the source of the picture. | +| allowEdit | Boolean | true | Allow simple editing of image before selection. | +| encodingType | [EncodingType](#module_Camera.EncodingType) | JPEG | Choose the returned image file's encoding. | +| targetWidth | number | | Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant. | +| targetHeight | number | | Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant. | +| mediaType | [MediaType](#module_Camera.MediaType) | PICTURE | Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. | +| correctOrientation | Boolean | | Rotate the image to correct for the orientation of the device during capture. | +| saveToPhotoAlbum | Boolean | | Save the image to the photo album on the device after capture. | +| popoverOptions | [CameraPopoverOptions](#module_CameraPopoverOptions) | | iOS-only options that specify popover location in iPad. | +| cameraDirection | [Direction](#module_Camera.Direction) | BACK | Choose the camera to use (front- or back-facing). | + +--- + + +## Camera + +### Camera.DestinationType : enum +**Kind**: static enum property of [Camera](#module_Camera) +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| DATA_URL | number | 0 | Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible | +| FILE_URI | number | 1 | Return file uri (content://media/external/images/media/2 for Android) | +| NATIVE_URI | number | 2 | Return native uri (eg. asset-library://... for iOS) | + + +### Camera.EncodingType : enum +**Kind**: static enum property of [Camera](#module_Camera) +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| JPEG | number | 0 | Return JPEG encoded image | +| PNG | number | 1 | Return PNG encoded image | + + +### Camera.MediaType : enum +**Kind**: static enum property of [Camera](#module_Camera) +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| PICTURE | number | 0 | Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType | +| VIDEO | number | 1 | Allow selection of video only, ONLY RETURNS URL | +| ALLMEDIA | number | 2 | Allow selection from all media types | + + +### Camera.PictureSourceType : enum +**Kind**: static enum property of [Camera](#module_Camera) +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| PHOTOLIBRARY | number | 0 | Choose image from picture library (same as SAVEDPHOTOALBUM for Android) | +| CAMERA | number | 1 | Take picture from camera | +| SAVEDPHOTOALBUM | number | 2 | Choose image from picture library (same as PHOTOLIBRARY for Android) | + + +### Camera.PopoverArrowDirection : enum +Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover. + +**Kind**: static enum property of [Camera](#module_Camera) +**Properties** + +| Name | Type | Default | +| --- | --- | --- | +| ARROW_UP | number | 1 | +| ARROW_DOWN | number | 2 | +| ARROW_LEFT | number | 4 | +| ARROW_RIGHT | number | 8 | +| ARROW_ANY | number | 15 | + + +### Camera.Direction : enum +**Kind**: static enum property of [Camera](#module_Camera) +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| BACK | number | 0 | Use the back-facing camera | +| FRONT | number | 1 | Use the front-facing camera | + +--- + + +## 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. 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. + + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| [x] | Number | 0 | x pixel coordinate of screen element onto which to anchor the popover. | +| [y] | Number | 32 | y pixel coordinate of screen element onto which to anchor the popover. | +| [width] | Number | 320 | width, in pixels, of the screen element onto which to anchor the popover. | +| [height] | Number | 480 | height, in pixels, of the screen element onto which to anchor the popover. | +| [arrowDir] | [PopoverArrowDirection](#module_Camera.PopoverArrowDirection) | ARROW_ANY | Direction the arrow on the popover should point. | + +--- + + +## CameraPopoverHandle +A handle to an image picker popover. + +__Supported Platforms__ + +- iOS + +**Example** +```js +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); +} +``` +--- + + +## `camera.getPicture` Errata + +#### Example + +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); + } + +Take a photo and retrieve it as a Base64-encoded image: + + /** + * Warning: Using DATA_URL is not recommended! The DATA_URL destination + * type is very memory intensive, even with a low quality setting. Using it + * can result in out of memory errors and application crashes. Use FILE_URI + * or NATIVE_URI instead. + */ + navigator.camera.getPicture(onSuccess, onFail, { quality: 25, + 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); + } + +#### Preferences (iOS) + +- __CameraUsesGeolocation__ (boolean, defaults to false). For capturing JPEGs, set to true to get geolocation data in the EXIF header. This will trigger a request for geolocation permissions if set to true. + + + +#### 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 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 result from the plugin call will be delivered via the resume event. +See [the Android Lifecycle guide][android_lifecycle] +for more information. The `pendingResult.result` value will contain the value that +would be passed to the callbacks (either the URI/URL or an error message). Check +the `pendingResult.pluginStatus` to determine whether or not the call was +successful. + +#### Browser Quirks + +Can only return photos as Base64-encoded image. + +#### Firefox OS Quirks + +Camera plugin is currently implemented using [Web Activities][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`. + + +## `CameraOptions` Errata + +#### Amazon Fire OS 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. + +#### Android Quirks + +- Any `cameraDirection` value results in a back-facing photo. + +- **`allowEdit` is unpredictable on Android and it should not be used!** The Android implementation of this plugin tries to find and use an application on the user's device to do image cropping. The plugin has no control over what application the user selects to perform the image cropping and it is very possible that the user could choose an incompatible option and cause the plugin to fail. This sometimes works because most devices come with an application that handles cropping in a way that is compatible with this plugin (Google Plus Photos), but it is unwise to rely on that being the case. If image editing is essential to your application, consider seeking a third party library or plugin that provides its own image editing utility for a more robust solution. + +- `Camera.PictureSourceType.PHOTOLIBRARY` and `Camera.PictureSourceType.SAVEDPHOTOALBUM` both display the same photo album. + +- Ignores the `encodingType` parameter if the image is unedited (i.e. `quality` is 100, `correctOrientation` is false, and no `targetHeight` or `targetWidth` are specified). The `CAMERA` source will always return the JPEG file given by the native camera and the `PHOTOLIBRARY` and `SAVEDPHOTOALBUM` sources will return the selected file in its existing encoding. + +#### BlackBerry 10 Quirks + +- Ignores the `quality` 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 + +- When using `destinationType.FILE_URI`, photos are saved in the application's temporary directory. The contents of the application's temporary directory is deleted when the application ends. + +- When using `destinationType.NATIVE_URI` and `sourceType.CAMERA`, photos are saved in the saved photo album regardless on the value of `saveToPhotoAlbum` parameter. + +#### 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 `saveToPhotoAlbum` parameter. IMPORTANT: All images taken with the WP8/8 Cordova camera API are always copied to the phone's camera roll. Depending on the user's settings, this could also mean the image is auto-uploaded to their OneDrive. This could potentially mean the image is available to a wider audience than your app intended. If this is a blocker for your application, you will need to implement the CameraCaptureTask as [documented on MSDN][msdn_wp8_docs]. You may also comment or up-vote the related issue in the [issue tracker][wp8_bug]. + +- Ignores the `mediaType` property of `cameraOptions` as the Windows Phone SDK does not provide a way to choose videos from PHOTOLIBRARY. + +[android_lifecycle]: http://cordova.apache.org/docs/en/dev/guide/platforms/android/lifecycle.html +[web_activities]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ +[wp8_bug]: https://issues.apache.org/jira/browse/CB-2083 +[msdn_wp8_docs]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx diff --git a/plugins/cordova-plugin-camera/RELEASENOTES.md b/plugins/cordova-plugin-camera/RELEASENOTES.md new file mode 100644 index 0000000..659837e --- /dev/null +++ b/plugins/cordova-plugin-camera/RELEASENOTES.md @@ -0,0 +1,282 @@ + +# Release Notes + +### 2.1.1 (Mar 09, 2016) +* [CB-10825](https://issues.apache.org/jira/browse/CB-10825) **Android** should request READ permission for gallery source +* added apache license header to appium files +* [CB-10720](https://issues.apache.org/jira/browse/CB-10720) Fixed spelling, capitalization, and other small issues. +* [CB-10414](https://issues.apache.org/jira/browse/CB-10414) Adding focus handler to resume video when user comes back on leaving the app while preview was running +* Appium tests: adjust swipe distance on **Android** +* [CB-10750](https://issues.apache.org/jira/browse/CB-10750) Appium tests: fail fast if session is irrecoverable +* Adding missing semi colon +* Adding focus handler to make sure filepicker gets launched when app is active on **Windows** +* [CB-10128](https://issues.apache.org/jira/browse/CB-10128) **iOS** Fixed how checks access authorization to camera & library. This closes #146 +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins +* [CB-10639](https://issues.apache.org/jira/browse/CB-10639) Appium tests: Added some timeouts, Taking a screenshot on failure, Retry taking a picture up to 3 times, Try to restart the Appium session if it's lost +* [CB-10552](https://issues.apache.org/jira/browse/CB-10552) Replacing images in README.md. +* Added a lot of more cases to get the real path on **Android** +* [CB-10625](https://issues.apache.org/jira/browse/CB-10625) **Android** getPicture fails when getting a photo from the Photo Library - Google Photos +* [CB-10619](https://issues.apache.org/jira/browse/CB-10619) Appium tests: Properly switch to webview on **Android** +* [CB-10397](https://issues.apache.org/jira/browse/CB-10397) Added Appium tests +* [CB-10576](https://issues.apache.org/jira/browse/CB-10576) MobileSpec can't get results for **Windows**-Store 8.1 Builds +* chore: edit package.json license to match SPDX id +* [CB-10539](https://issues.apache.org/jira/browse/CB-10539) Commenting out the verySmallQvga maxResolution option on **Windows** +* [CB-10541](https://issues.apache.org/jira/browse/CB-10541) Changing default maxResoltion to be highestAvailable for CameraCaptureUI on **Windows** +* [CB-10113](https://issues.apache.org/jira/browse/CB-10113) **Browse** - Layer camera UI on top of all! +* [CB-10502](https://issues.apache.org/jira/browse/CB-10502) **Browser** - Fix camera plugin exception in Chrome when click capture. +* Adding comments +* Camera tapping fix on **Windows** + +### 2.1.0 (Jan 15, 2016) +* added `.ratignore` +* CB-10319 **Android** Adding reflective helper methods for permission requests +* CB-9189 **Android** Implementing `save/restore` API to handle Activity destruction +* CB-10241 App Crash cause by Camera Plugin **iOS 7** +* CB-8940 Setting `z-index` values to maximum for UI buttons. + +### 2.0.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* [CB-8863](https://issues.apache.org/jira/browse/CB-8863) correct block usage for `async` calls +* [CB-5479](https://issues.apache.org/jira/browse/CB-5479) changed `saveToPhotoAlbum` to save uncompressed images for **Android** +* [CB-9169](https://issues.apache.org/jira/browse/CB-9169) Fixed `filetype` for uncompressed images and added quirk for **Android** +* [CB-9446](https://issues.apache.org/jira/browse/CB-9446) Removing `CordovaResource` library code in favour of the code we're supposed to be deprecating because that at least works. +* [CB-9942](https://issues.apache.org/jira/browse/CB-9942) Normalize line endings in Camera plugin docs +* [CB-9910](https://issues.apache.org/jira/browse/CB-9910) Add permission request for some gallery requests for **Android** +* [CB-7668](https://issues.apache.org/jira/browse/CB-7668) Adding a sterner warning for `allowedit` on **Android** +* Fixing contribute link. +* Using the `CordovaResourceApi` to fine paths of files in the background thread. If the file doesn't exist, return the content `URI`. +* Add engine tag for **Cordova-Android 5.0.x** +* [CB-9583](https://issues.apache.org/jira/browse/CB-9583): Added support for **Marshmallow** permissions (**Android 6.0**) +* Try to use `realpath` filename instead of default `modified.jpg` +* [CB-6190](https://issues.apache.org/jira/browse/CB-6190) **iOS** camera plugin ignores quality parameter +* [CB-9633](https://issues.apache.org/jira/browse/CB-9633) **iOS** Taking a Picture With Option `destinationType:NATIVE_URI` doesn't show image +* [CB-9745](https://issues.apache.org/jira/browse/CB-9745) Camera plugin docs should be generated from the source +* [CB-9622](https://issues.apache.org/jira/browse/CB-9622) **WP8** Camera Option `destinationType:NATIVE_URI` is a `NO-OP` +* [CB-9623](https://issues.apache.org/jira/browse/CB-9623) Fixes various issues when `encodingType` set to `png` +* [CB-9591](https://issues.apache.org/jira/browse/CB-9591) Retaining aspect ratio when resizing +* [CB-9443](https://issues.apache.org/jira/browse/CB-9443) Pick correct `maxResolution` +* [CB-9151](https://issues.apache.org/jira/browse/CB-9151) Trigger `captureAction` only once +* [CB-9413](https://issues.apache.org/jira/browse/CB-9413) Close `RandomAccessStream` once copied +* [CB-5661](https://issues.apache.org/jira/browse/CB-5661) Remove outdated **iOS** quirks about memory +* [CB-9349](https://issues.apache.org/jira/browse/CB-9349) Focus control and nice UI +* [CB-9259](https://issues.apache.org/jira/browse/CB-9259) Forgot to add another check on which `URI` we're using when fixing this thing the first time +* [CB-9247](https://issues.apache.org/jira/browse/CB-9247) Added macro to conditionally add `NSData+Base64.h` +* [CB-9247](https://issues.apache.org/jira/browse/CB-9247) Fixes compilation errors with **cordova-ios 4.x** +* Fix returning native url on **Windows**. + +### 1.2.0 (Jun 17, 2015) +* Closing stale pull request: close #84 +* Closing stale pull request: close #66 +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-camera documentation translation: cordova-plugin-camera +* Update docs. This closes #100 +* attempt to fix npm markdown issue +* [CB-8883](https://issues.apache.org/jira/browse/CB-8883) fix picture rotation issue +* one more alias +* Fixed some nit white-space issues, aliased a little more +* major refactor : readability +* Patch for [CB-8498](https://issues.apache.org/jira/browse/CB-8498), this closes #64 +* [CB-8879](https://issues.apache.org/jira/browse/CB-8879) fix stripe issue with correct aspect ratio +* [CB-8601](https://issues.apache.org/jira/browse/CB-8601) - iOS camera unit tests broken +* [CB-7667](https://issues.apache.org/jira/browse/CB-7667) iOS8: Handle case where camera is not authorized (closes #49) +* add missing license header + +### 1.1.0 (May 06, 2015) +* [CB-8943](https://issues.apache.org/jira/browse/CB-8943) fix `PickAndContinue` issue on *Win10Phone* +* [CB-8253](https://issues.apache.org/jira/browse/CB-8253) Fix potential unreleased resources +* [CB-8909](https://issues.apache.org/jira/browse/CB-8909): Remove unused import from File +* [CB-8404](https://issues.apache.org/jira/browse/CB-8404) typo fix `cameraproxy.js` +* [CB-8404](https://issues.apache.org/jira/browse/CB-8404) Rotate camera feed with device orientation +* [CB-8054](https://issues.apache.org/jira/browse/CB-8054) Support taking pictures from file for *WP8* +* [CB-8405](https://issues.apache.org/jira/browse/CB-8405) Use `z-index` instead of `z-order` + +### 1.0.0 (Apr 15, 2015) +* [CB-8780](https://issues.apache.org/jira/browse/CB-8780) - Display popover using main thread. Fixes popover slowness (closes #81) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) bumped version of file dependency +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8707](https://issues.apache.org/jira/browse/CB-8707) refactoring windows code to improve readability +* [CB-8706](https://issues.apache.org/jira/browse/CB-8706) use filePicker if saveToPhotoAlbum is true +* [CB-8706](https://issues.apache.org/jira/browse/CB-8706) remove unnecessary capabilities from xml +* [CB-8747](https://issues.apache.org/jira/browse/CB-8747) updated dependency, added peer dependency +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) updated blackberry specific references of org.apache.cordova.camera to cordova-plugin-camera +* [CB-8782](https://issues.apache.org/jira/browse/CB-8782): Updated the docs to talk about the allowEdit quirks, it's not 100% working, but better than it was +* [CB-8782](https://issues.apache.org/jira/browse/CB-8782): Fixed the flow so that we save the cropped image and use it, not the original non-cropped. Crop only supports G+ Photos Crop, other crops may not work, depending on the OEM +* [CB-8740](https://issues.apache.org/jira/browse/CB-8740): Removing FileHelper call that was failing on Samsung Galaxy S3, now that we have a real path, we only need to update the MediaStore, not pull from it in this case +* [CB-8740](https://issues.apache.org/jira/browse/CB-8740): Partial fix for Save Image to Gallery error found in MobileSpec +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) Fix custom implementation of integerValueForKey (close #79) +* Fix cordova-paramedic path change, build with TRAVIS_BUILD_DIR, use npm to install paramedic +* docs: added 'Windows' to supported platforms +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of deprecated headers + +### 0.3.6 (Mar 10, 2015) +* Fix localize key for Videos. This closes #58 +* [CB-8235](https://issues.apache.org/jira/browse/CB-8235) android: Fix crash when selecting images from DropBox with spaces in path (close #65) +* add try ... catch for getting image orientation +* [CB-8599](https://issues.apache.org/jira/browse/CB-8599) fix threading issue with cameraPicker (fixes #72) +* [CB-8559](https://issues.apache.org/jira/browse/CB-8559) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-camera documentation translation: cordova-plugin-camera +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file + +### 0.3.5 (Feb 04, 2015) +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Stop using now-deprecated [NSData base64EncodedString] +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Stop using now-deprecated integerValueForKey: class extension +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension +* [CB-8032](https://issues.apache.org/jira/browse/CB-8032) ios: Add nativeURL external method support for CDVFileSystem->makeEntryForPath:isDirectory: +* [CB-7938](https://issues.apache.org/jira/browse/CB-7938) ios: Added XCTest unit tests project, with stubs (adapted from SplashScreen unit test setup) +* [CB-7937](https://issues.apache.org/jira/browse/CB-7937) ios: Re-factor iOS Camera plugin so that it is testable + +### 0.3.4 (Dec 02, 2014) +* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs +* [CB-7979](https://issues.apache.org/jira/browse/CB-7979) Each plugin doc should have a ## Installation section +* Fix memory leak of image data in `imagePickerControllerReturnImageResult` +* Pass uri to crop instead of pulling the low resolution image out of the intent return (close #43) +* Add orientation support for PNG to Android (closes #45) +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-camera documentation translation: cordova-plugin-camera + +### 0.3.3 (Oct 03, 2014) +* [CB-7600](https://issues.apache.org/jira/browse/CB-7600) Adds informative message to error callback in manual test. + +### 0.3.2 (Sep 17, 2014) +* [CB-7551](https://issues.apache.org/jira/browse/CB-7551) [Camera][iOS 8] Scaled images show a white line +* [CB-7558](https://issues.apache.org/jira/browse/CB-7558) hasPendingOperation flag in Camera plugin's takePicture should be reversed to fix memory errors +* [CB-7557](https://issues.apache.org/jira/browse/CB-7557) Camera plugin tests is missing a File dependency +* [CB-7423](https://issues.apache.org/jira/browse/CB-7423) do cleanup after copyImage manual test +* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-camera documentation translation: cordova-plugin-camera +* [CB-7413](https://issues.apache.org/jira/browse/CB-7413) Resolve 'ms-appdata' URIs with File plugin +* Fixed minor bugs with the browser +* [CB-7433](https://issues.apache.org/jira/browse/CB-7433) Adds missing window reference to prevent manual tests failure on Android and iOS +* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-camera documentation translation: cordova-plugin-camera +* [CB-4003](https://issues.apache.org/jira/browse/CB-4003) Add config option to not use location information in Camera plugin (and default to not use it) +* [CB-7461](https://issues.apache.org/jira/browse/CB-7461) Geolocation fails in Camera plugin in iOS 8 +* [CB-7378](https://issues.apache.org/jira/browse/CB-7378) Use single Proxy for both windows8 and windows. +* [CB-7378](https://issues.apache.org/jira/browse/CB-7378) Adds support for windows platform +* [CB-7433](https://issues.apache.org/jira/browse/CB-7433) Fixes manual tests failure on windows +* [CB-6958](https://issues.apache.org/jira/browse/CB-6958) Get the correct default for "quality" in the test +* add documentation for manual tests +* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-camera documentation translation: cordova-plugin-camera +* [CB-4003](https://issues.apache.org/jira/browse/CB-4003) Add config option to not use location information in Camera plugin (and default to not use it) +* [CB-7461](https://issues.apache.org/jira/browse/CB-7461) Geolocation fails in Camera plugin in iOS 8 +* [CB-7433](https://issues.apache.org/jira/browse/CB-7433) Fixes manual tests failure on windows +* [CB-7378](https://issues.apache.org/jira/browse/CB-7378) Use single Proxy for both windows8 and windows. +* [CB-7378](https://issues.apache.org/jira/browse/CB-7378) Adds support for windows platform +* [CB-6958](https://issues.apache.org/jira/browse/CB-6958) Get the correct default for "quality" in the test +* add documentation for manual tests +* Updated docs for browser +* Added support for the browser +* [CB-7286](https://issues.apache.org/jira/browse/CB-7286) [BlackBerry10] Use getUserMedia if camera card is unavailable +* [CB-7180](https://issues.apache.org/jira/browse/CB-7180) Update Camera plugin to support generic plugin webView UIView (which can be either a UIWebView or WKWebView) +* Renamed test dir, added nested plugin.xml +* [CB-6958](https://issues.apache.org/jira/browse/CB-6958) added manual tests +* [CB-6958](https://issues.apache.org/jira/browse/CB-6958) Port camera tests to plugin-test-framework + +### 0.3.1 (Aug 06, 2014) +* **FFOS** update CameraProxy.js +* [CB-7187](https://issues.apache.org/jira/browse/CB-7187) ios: Add explicit dependency on CoreLocation.framework +* [BlackBerry10] Doc correction - sourceType is supported +* [CB-7071](https://issues.apache.org/jira/browse/CB-7071) android: Fix callback firing before CROP intent is sent when allowEdit=true +* [CB-6875](https://issues.apache.org/jira/browse/CB-6875) android: Handle exception when SDCard is not mounted +* ios: Delete postImage (dead code) +* Prevent NPE on processResiultFromGallery when intent comes null +* Remove iOS doc reference to non-existing navigator.fileMgr API +* Docs updated with some default values +* Removes File plugin dependency from windows8 code. +* Use WinJS functionality to resize image instead of File plugin functionality +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs + +### 0.3.0 (Jun 05, 2014) +* [CB-5895](https://issues.apache.org/jira/browse/CB-5895) documented saveToPhotoAlbum quirk on WP8 +* Remove deprecated symbols for iOS < 6 +* documentation translation: cordova-plugin-camera +* ubuntu: use application directory for images +* [CB-6795](https://issues.apache.org/jira/browse/CB-6795) Add license +* Little fix in code formatting +* [CB-6613](https://issues.apache.org/jira/browse/CB-6613) Use WinJS functionality to get base64-encoded content of image instead of File plugin functionality +* [CB-6612](https://issues.apache.org/jira/browse/CB-6612) camera.getPicture now always returns encoded JPEG image +* Removed invalid note from [CB-5398](https://issues.apache.org/jira/browse/CB-5398) +* [CB-6576](https://issues.apache.org/jira/browse/CB-6576) - Returns a specific error message when app has no access to library. +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md +* [CB-6546](https://issues.apache.org/jira/browse/CB-6546) android: Fix a couple bugs with allowEdit pull request +* [CB-6546](https://issues.apache.org/jira/browse/CB-6546) android: Add support for allowEdit Camera option + +### 0.2.9 (Apr 17, 2014) +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [WP8] When only targetWidth or targetHeight is provided, use it as the only bound +* [CB-4027](https://issues.apache.org/jira/browse/CB-4027), [CB-5102](https://issues.apache.org/jira/browse/CB-5102), [CB-2737](https://issues.apache.org/jira/browse/CB-2737), [CB-2387](https://issues.apache.org/jira/browse/CB-2387): [WP] Fix camera issues, cropping, memory leaks +* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit +* [BlackBerry10] Add rim xml namespaces declaration +* Add NOTICE file + +### 0.2.8 (Feb 26, 2014) +* [CB-1826](https://issues.apache.org/jira/browse/CB-1826) Catch OOM on gallery image resize + +### 0.2.7 (Feb 05, 2014) +* [CB-4919](https://issues.apache.org/jira/browse/CB-4919) firefox os quirks added and supported platforms list is updated +* getPicture via web activities +* Documented quirk for [CB-5335](https://issues.apache.org/jira/browse/CB-5335) + [CB-5206](https://issues.apache.org/jira/browse/CB-5206) for WP7+8 +* reference the correct firefoxos implementation +* [BlackBerry10] Add permission to access_shared + +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Camera plugin +* [CB-2442](https://issues.apache.org/jira/browse/CB-2442) [CB-2419](https://issues.apache.org/jira/browse/CB-2419) Use Windows.Storage.ApplicationData.current.localFolder, instead of writing to app package. +* [BlackBerry10] Adding platform level permissions +* [CB-5599](https://issues.apache.org/jira/browse/CB-5599) Android: Catch and ignore OutOfMemoryError in getRotatedBitmap() + +### 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.4 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for camera plugin +* [CB-4958](https://issues.apache.org/jira/browse/CB-4958) - iOS - Camera plugin should not show the status bar +* [CB-4919](https://issues.apache.org/jira/browse/CB-4919) updated plugin.xml for FxOS +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) forgot index.html +* [CB-4889](https://issues.apache.org/jira/browse/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](https://issues.apache.org/jira/browse/CB-4823) Fix XCode 5 camera plugin warnings +* Fix compiler warnings +* [CB-4765](https://issues.apache.org/jira/browse/CB-4765) Move ExifHelper.java into Camera Plugin +* [CB-4764](https://issues.apache.org/jira/browse/CB-4764) Remove reference to DirectoryManager from CameraLauncher +* [CB-4763](https://issues.apache.org/jira/browse/CB-4763) Use a copy of FileHelper.java within camera-plugin. +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. +* [CB-4633](https://issues.apache.org/jira/browse/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](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.camera to org.apache.cordova.camera + +### 0.2.1 (Sept 5, 2013) +* [CB-4656](https://issues.apache.org/jira/browse/CB-4656) Don't add line-breaks to base64-encoded images (Fixes type=DataURI) +* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change diff --git a/plugins/cordova-plugin-camera/appium-tests/android/android.spec.js b/plugins/cordova-plugin-camera/appium-tests/android/android.spec.js new file mode 100644 index 0000000..37485ca --- /dev/null +++ b/plugins/cordova-plugin-camera/appium-tests/android/android.spec.js @@ -0,0 +1,592 @@ +/*jshint node: true, jasmine: true */ +/* + * + * 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. + * +*/ + +// these tests are meant to be executed by Cordova Medic Appium runner +// you can find it here: https://github.com/apache/cordova-medic/ +// it is not necessary to do a full CI setup to run these tests +// just run "node cordova-medic/medic/medic.js appium --platform android --plugins cordova-plugin-camera" + +'use strict'; + +var wdHelper = require('../helpers/wdHelper'); +var wd = wdHelper.getWD(); +var cameraConstants = require('../../www/CameraConstants'); +var cameraHelper = require('../helpers/cameraHelper'); +var screenshotHelper = require('../helpers/screenshotHelper'); + +var STARTING_MESSAGE = 'Ready for action!'; +var RETRY_COUNT = 3; // how many times to retry taking a picture before failing +var MINUTE = 60 * 1000; +var DEFAULT_SCREEN_WIDTH = 360; +var DEFAULT_SCREEN_HEIGHT = 567; +var DEFAULT_WEBVIEW_CONTEXT = 'WEBVIEW'; + +describe('Camera tests Android.', function () { + var driver; + // the name of webview context, it will be changed to match needed context if there are named ones: + var webviewContext = DEFAULT_WEBVIEW_CONTEXT; + // this indicates that the device library has the test picture: + var isTestPictureSaved = false; + // this indicates that there was a critical error and we should try to recover: + var errorFlag = false; + // this indicates that we couldn't restore Appium session and should fail fast: + var stopFlag = false; + // we need to know the screen width and height to properly click on an image in the gallery: + var screenWidth = DEFAULT_SCREEN_WIDTH; + var screenHeight = DEFAULT_SCREEN_HEIGHT; + + function win() { + expect(true).toBe(true); + } + + function fail(error) { + screenshotHelper.saveScreenshot(driver); + if (error && error.message) { + console.log('An error occured: ' + error.message); + expect(true).toFailWithMessage(error.message); + throw error.message; + } + if (error) { + console.log('Failed expectation: ' + error); + expect(true).toFailWithMessage(error); + throw error; + } + // no message provided :( + expect(true).toBe(false); + throw 'An error without description occured'; + } + + // generates test specs by combining all the specified options + // you can add more options to test more scenarios + function generateSpecs() { + var sourceTypes = [ + cameraConstants.PictureSourceType.CAMERA, + cameraConstants.PictureSourceType.PHOTOLIBRARY + ], + destinationTypes = cameraConstants.DestinationType, + encodingTypes = [ + cameraConstants.EncodingType.JPEG, + cameraConstants.EncodingType.PNG + ], + allowEditOptions = [ + true, + false + ]; + + return cameraHelper.generateSpecs(sourceTypes, destinationTypes, encodingTypes, allowEditOptions); + } + + function getPicture(options, skipUiInteractions, retry) { + if (!options) { + options = {}; + } + if (typeof retry === 'undefined') { + retry = 1; + } + + var command = "navigator.camera.getPicture(function (result) { document.getElementById('info').innerHTML = result.slice(0, 100); }, " + + "function (err) { document.getElementById('info').innerHTML = 'ERROR: ' + err; }," + JSON.stringify(options) + ");"; + return driver + .context(webviewContext) + .execute(command) + .sleep(7000) + .context('NATIVE_APP') + .sleep(5000) + .then(function () { + if (skipUiInteractions) { + return; + } + if (options.hasOwnProperty('sourceType') && + (options.sourceType === cameraConstants.PictureSourceType.PHOTOLIBRARY || + options.sourceType === cameraConstants.PictureSourceType.SAVEDPHOTOALBUM)) { + var touchTile = new wd.TouchAction(), + swipeRight = new wd.TouchAction(); + touchTile.press({x: Math.round(screenWidth / 4), y: Math.round(screenHeight / 5)}).release(); + swipeRight.press({x: 10, y: Math.round(screenHeight * 0.8)}) + .wait(300) + .moveTo({x: Math.round(screenWidth / 2), y: Math.round(screenHeight / 2)}) + .release(); + return driver + .performTouchAction(swipeRight) + .sleep(3000) + .elementByXPath('//*[@text="Gallery"]') + .then(function (element) { + return element.click().sleep(5000); + }, function () { + // if the gallery is already opened, we'd just go on: + return driver; + }) + .performTouchAction(touchTile); + } + return driver + .elementByXPath('//android.widget.ImageView[contains(@resource-id,\'shutter\')]') + .click() + .sleep(3000) + .elementByXPath('//android.widget.ImageView[contains(@resource-id,\'done\')]') + .click() + .sleep(10000); + }) + .then(function () { + if (skipUiInteractions) { + return; + } + if (options.hasOwnProperty('allowEdit') && options.allowEdit === true) { + return driver + .elementByXPath('//*[contains(@resource-id,\'save\')]') + .click(); + } + }) + .then(function () { + if (!skipUiInteractions) { + return driver.sleep(10000); + } + }) + .fail(function (error) { + if (retry < RETRY_COUNT) { + console.log('Failed to get a picture. Let\'s try it again... '); + return getPicture(options, skipUiInteractions, ++retry); + } else { + console.log('Tried ' + RETRY_COUNT + ' times but couldn\'t get the picture. Failing...'); + fail(error); + } + }); + } + + function enterTest() { + return driver + // trying to determine where we are + .context(webviewContext) + .fail(function (error) { + fail(error); + }) + .elementById('info') + .then(function () { + return driver; //we're already on the test screen + }, function () { + return driver + .elementById('middle') + .then(function () { + return driver + // we're on autotests page, we should go to start page + .execute('window.location = "../index.html"') + .sleep(5000) + .fail(function () { + errorFlag = true; + throw 'Couldn\'t find start page.'; + }); + }, function () { + return; // no-op + }) + // unknown starting page: no 'info' div + // adding it manually + .execute('var info = document.createElement("div"); ' + + 'info.id = "info"; ' + + 'document.body.appendChild(info);'); + }) + .sleep(5000); + } + + function checkPicture(shouldLoad) { + return driver + .context(webviewContext) + .elementById('info') + .getAttribute('innerHTML') + .then(function (html) { + if (html.indexOf(STARTING_MESSAGE) >= 0) { + expect(true).toFailWithMessage('No callback was fired'); + } else if (shouldLoad) { + expect(html.length).toBeGreaterThan(0); + if (html.indexOf('ERROR') >= 0) { + fail(html); + } + } else { + if (html.indexOf('ERROR') === -1) { + fail('Unexpected success callback with result: ' + html); + } + expect(html.indexOf('ERROR')).toBe(0); + } + }); + } + + function runCombinedSpec(spec) { + return enterTest() + .then(function () { + return getPicture(spec.options); + }) + .then(function () { + return checkPicture(true); + }) + .then(win, fail); + } + + function deleteImage() { + var holdTile = new wd.TouchAction(); + holdTile.press({x: Math.round(screenWidth / 3), y: Math.round(screenHeight / 5)}).wait(1000).release(); + return driver + .performTouchAction(holdTile) + .elementByXPath('//android.widget.TextView[@text="Delete"]') + .then(function (element) { + return element + .click() + .elementByXPath('//android.widget.Button[@text="OK"]') + .click(); + }, function () { + // couldn't find Delete menu item. Possibly there is no image. + return; + }); + } + + function getDriver() { + driver = wdHelper.getDriver('Android'); + return driver; + } + + function checkStopFlag() { + if (stopFlag) { + fail('Something went wrong: the stopFlag is on. Please see the log for more details.'); + } + return stopFlag; + } + + beforeEach(function () { + jasmine.addMatchers({ + toFailWithMessage : function () { + return { + compare: function (actual, msg) { + console.log('Failing with message: ' + msg); + var result = { + pass: false, + message: msg + }; + // status 6 means that we've lost the session + // status 7 means that Appium couldn't find an element + // both these statuses mean that the test has failed but + // we should try to recreate the session for the following tests + if (msg.indexOf('Error response status: 6') >= 0 || + msg.indexOf('Error response status: 7') >= 0) { + errorFlag = true; + } + return result; + } + }; + } + }); + }); + + it('camera.ui.util configuring driver and starting a session', function (done) { + stopFlag = true; // just in case of timeout + getDriver().then(function () { + stopFlag = false; + }, function (error) { + fail(error); + }) + .finally(done); + }, 5 * MINUTE); + + it('camera.ui.util determine webview context name', function (done) { + var i = 0; + return driver + .contexts(function (err, contexts) { + if (err) { + console.log(err); + } + for (i = 0; i < contexts.length; i++) { + if (contexts[i].indexOf('mobilespec') >= 0) { + webviewContext = contexts[i]; + } + } + done(); + }); + }, MINUTE); + + it('camera.ui.util determine screen dimensions', function (done) { + return enterTest() + .execute('document.getElementById(\'info\').innerHTML = window.innerWidth;') + .sleep(5000) + .elementById('info') + .getAttribute('innerHTML') + .then(function (html) { + if (html !== STARTING_MESSAGE) { + screenWidth = Number(html); + } + }) + .execute('document.getElementById(\'info\').innerHTML = \'' + STARTING_MESSAGE + '\';') + .execute('document.getElementById(\'info\').innerHTML = window.innerHeight;') + .sleep(5000) + .elementById('info') + .getAttribute('innerHTML') + .then(function (html) { + if (html !== STARTING_MESSAGE) { + screenHeight = Number(html); + } + done(); + }); + }, MINUTE); + + describe('Specs.', function () { + beforeEach(function (done) { + // prepare the app for the test + if (!stopFlag) { + return driver + .context(webviewContext) + .then(function () { + return driver; // no-op + }, function (error) { + expect(true).toFailWithMessage(error); + }) + .execute('document.getElementById("info").innerHTML = "' + STARTING_MESSAGE + '";') + .finally(done); + } + done(); + }, 3 * MINUTE); + + afterEach(function (done) { + if (!errorFlag || stopFlag) { + // either there's no error or we've failed irrecoverably + // nothing to worry about! + done(); + return; + } + // recreate the session if there was a critical error in a previous spec + stopFlag = true; // we're going to set this to false if we're able to restore the session + return driver + .quit() + .then(function () { + return getDriver() + .then(function () { + errorFlag = false; + stopFlag = false; + }, function (error) { + fail(error); + stopFlag = true; + }); + }, function (error) { + fail(error); + stopFlag = true; + }) + .finally(done); + }, 3 * MINUTE); + + // getPicture() with saveToPhotoLibrary = true + it('camera.ui.spec.1 Saving the picture to photo library', function (done) { + var options = { + quality: 50, + allowEdit: false, + sourceType: cameraConstants.PictureSourceType.CAMERA, + saveToPhotoAlbum: true + }; + enterTest() + .context(webviewContext) + .then(function () { + return getPicture(options); + }) + .then(function () { + isTestPictureSaved = true; + return checkPicture(true); + }) + .then(win, fail) + .finally(done); + }, 3 * MINUTE); + + // getPicture() with mediaType: VIDEO, sourceType: PHOTOLIBRARY + it('camera.ui.spec.2 Selecting only videos', function (done) { + if (checkStopFlag()) { + done(); + return; + } + var options = { sourceType: cameraConstants.PictureSourceType.PHOTOLIBRARY, + mediaType: cameraConstants.MediaType.VIDEO }; + enterTest() + .then(function () { + return getPicture(options, true); + }) + .sleep(5000) + .context(webviewContext) + .elementById('info') + .getAttribute('innerHTML') + .then(function (html) { + if (html.indexOf('ERROR') >= 0) { + throw html; + } + }) + .context('NATIVE_APP') + .sleep(5000) + .then(function () { + // try to find "Gallery" menu item + // if there's none, the gallery should be already opened + return driver + .elementByXPath('//*[@text="Gallery"]') + .then(function (element) { + return element.click().sleep(2000); + }, function () { + return driver; + }); + }) + .then(function () { + // if the gallery is opened on the videos page, + // there should be a "Choose video" caption + return driver + .elementByXPath('//*[@text="Choose video"]') + .fail(function () { + throw 'Couldn\'t find "Choose video" element.'; + }); + }) + .then(win, fail) + .deviceKeyEvent(4) + .sleep(2000) + .deviceKeyEvent(4) + .sleep(2000) + .elementById('action_bar_title') + .then(function () { + // success means we're still in native app + return driver + .deviceKeyEvent(4) + .sleep(2000); + }, function () { + // error means we're already in webview + return driver; + }) + .finally(done); + }, 3 * MINUTE); + + // getPicture(), then dismiss + // wait for the error callback to bee called + it('camera.ui.spec.3 Dismissing the camera', function (done) { + if (checkStopFlag()) { + done(); + return; + } + var options = { quality: 50, + allowEdit: true, + sourceType: cameraConstants.PictureSourceType.CAMERA, + destinationType: cameraConstants.DestinationType.FILE_URI }; + enterTest() + .context(webviewContext) + .then(function () { + return getPicture(options, true); + }) + .sleep(5000) + .context("NATIVE_APP") + .elementByXPath('//android.widget.ImageView[contains(@resource-id,\'cancel\')]') + .click() + .context(webviewContext) + .then(function () { + return driver + .elementByXPath('//*[contains(text(),"Camera cancelled")]') + .then(function () { + return checkPicture(false); + }, function () { + throw 'Couldn\'t find "Camera cancelled" message.'; + }); + }) + .then(win, fail) + .finally(done); + }, 3 * MINUTE); + + // getPicture(), then take picture but dismiss the edit + // wait for the error cllback to be called + it('camera.ui.spec.4 Dismissing the edit', function (done) { + if (checkStopFlag()) { + done(); + return; + } + var options = { quality: 50, + allowEdit: true, + sourceType: cameraConstants.PictureSourceType.CAMERA, + destinationType: cameraConstants.DestinationType.FILE_URI }; + enterTest() + .context(webviewContext) + .then(function () { + return getPicture(options, true); + }) + .sleep(5000) + .context('NATIVE_APP') + .elementByXPath('//android.widget.ImageView[contains(@resource-id,\'shutter\')]') + .click() + .elementByXPath('//android.widget.ImageView[contains(@resource-id,\'done\')]') + .click() + .elementByXPath('//*[contains(@resource-id,\'discard\')]') + .click() + .sleep(5000) + .context(webviewContext) + .then(function () { + return driver + .elementByXPath('//*[contains(text(),"Camera cancelled")]') + .then(function () { + return checkPicture(false); + }, function () { + throw 'Couldn\'t find "Camera cancelled" message.'; + }); + }) + .then(win, fail) + .finally(done); + }, 3 * MINUTE); + + // combine various options for getPicture() + generateSpecs().forEach(function (spec) { + it('camera.ui.spec.5.' + spec.id + ' Combining options', function (done) { + if (checkStopFlag()) { + done(); + return; + } + runCombinedSpec(spec).then(done); + }, 3 * MINUTE); + }); + + + it('camera.ui.util Delete test image from device library', function (done) { + if (checkStopFlag()) { + done(); + return; + } + if (isTestPictureSaved) { + // delete exactly one last picture + // this should be the picture we've taken in the first spec + return driver + .context('NATIVE_APP') + .deviceKeyEvent(3) + .sleep(5000) + .elementByName('Apps') + .click() + .elementByXPath('//android.widget.TextView[@text="Gallery"]') + .click() + .elementByXPath('//android.widget.TextView[contains(@text,"Pictures")]') + .then(function (element) { + return element + .click() + .sleep(3000) + .then(deleteImage) + .then(function () { done(); }, function () { done(); }); + }, function () { + done(); + }); + } + // couldn't save test picture earlier, so nothing to delete here + done(); + }, 3 * MINUTE); + + }); + + it('camera.ui.util Destroy the session', function (done) { + return driver.quit(done); + }, MINUTE); +}); diff --git a/plugins/cordova-plugin-camera/appium-tests/helpers/cameraHelper.js b/plugins/cordova-plugin-camera/appium-tests/helpers/cameraHelper.js new file mode 100644 index 0000000..9342a30 --- /dev/null +++ b/plugins/cordova-plugin-camera/appium-tests/helpers/cameraHelper.js @@ -0,0 +1,86 @@ +/*jshint node: true */ +/* + * + * 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. + * +*/ + +'use strict'; + +var cameraConstants = require('../../www/CameraConstants'); + +module.exports.generateSpecs = function (sourceTypes, destinationTypes, encodingTypes, allowEditOptions) { + var destinationType, + sourceType, + encodingType, + allowEdit, + specs = [], + id = 1; + for (destinationType in destinationTypes) { + if (destinationTypes.hasOwnProperty(destinationType)) { + for (sourceType in sourceTypes) { + if (sourceTypes.hasOwnProperty(sourceType)) { + for (encodingType in encodingTypes) { + if (encodingTypes.hasOwnProperty(encodingType)) { + for (allowEdit in allowEditOptions) { + if (allowEditOptions.hasOwnProperty(allowEdit)) { + // if taking picture from photolibrary, don't vary 'correctOrientation' option + if (sourceTypes[sourceType] === cameraConstants.PictureSourceType.PHOTOLIBRARY) { + specs.push({ + 'id': id++, + 'options': { + 'destinationType': destinationTypes[destinationType], + 'sourceType': sourceTypes[sourceType], + 'encodingType': encodingTypes[encodingType], + 'allowEdit': allowEditOptions[allowEdit], + 'saveToPhotoAlbum': false, + } + }); + } else { + specs.push({ + 'id': id++, + 'options': { + 'destinationType': destinationTypes[destinationType], + 'sourceType': sourceTypes[sourceType], + 'encodingType': encodingTypes[encodingType], + 'correctOrientation': true, + 'allowEdit': allowEditOptions[allowEdit], + 'saveToPhotoAlbum': false, + } + }, { + 'id': id++, + 'options': { + 'destinationType': destinationTypes[destinationType], + 'sourceType': sourceTypes[sourceType], + 'encodingType': encodingTypes[encodingType], + 'correctOrientation': false, + 'allowEdit': allowEditOptions[allowEdit], + 'saveToPhotoAlbum': false, + } + }); + } + } + } + } + } + } + } + } + } + return specs; +}; diff --git a/plugins/cordova-plugin-camera/appium-tests/helpers/screenshotHelper.js b/plugins/cordova-plugin-camera/appium-tests/helpers/screenshotHelper.js new file mode 100644 index 0000000..e3cf136 --- /dev/null +++ b/plugins/cordova-plugin-camera/appium-tests/helpers/screenshotHelper.js @@ -0,0 +1,58 @@ +/* jshint node: true */ +/* + * + * 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. + * +*/ + +'use strict'; + +var path = require('path'); +var screenshotPath = global.SCREENSHOT_PATH || path.join(__dirname, '../../../appium_screenshots/'); + +function generateScreenshotName() { + var date = new Date(); + + var month = date.getMonth() + 1; + var day = date.getDate(); + var hour = date.getHours(); + var min = date.getMinutes(); + var sec = date.getSeconds(); + + month = (month < 10 ? "0" : "") + month; + day = (day < 10 ? "0" : "") + day; + hour = (hour < 10 ? "0" : "") + hour; + min = (min < 10 ? "0" : "") + min; + sec = (sec < 10 ? "0" : "") + sec; + + return date.getFullYear() + '-' + month + '-' + day + '_' + hour + '.' + min + '.' + sec + '.png'; +} + +module.exports.saveScreenshot = function (driver) { + var oldContext; + return driver + .currentContext() + .then(function (cc) { + oldContext = cc; + }) + .context('NATIVE_APP') + .saveScreenshot(path.join(screenshotPath, generateScreenshotName())) + .then(function () { + return driver.context(oldContext); + }); +}; diff --git a/plugins/cordova-plugin-camera/appium-tests/helpers/wdHelper.js b/plugins/cordova-plugin-camera/appium-tests/helpers/wdHelper.js new file mode 100644 index 0000000..f14c933 --- /dev/null +++ b/plugins/cordova-plugin-camera/appium-tests/helpers/wdHelper.js @@ -0,0 +1,68 @@ +/* jshint node: true */ +/* + * + * 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. + * +*/ + +'use strict'; + +var wd = global.WD || require('wd'); +var driver; + +module.exports.getDriver = function (platform, callback) { + var serverConfig = { + host: 'localhost', + port: 4723 + }, + driverConfig = { + browserName: '', + 'appium-version': '1.5', + platformName: platform, + platformVersion: global.PLATFORM_VERSION || '', + deviceName: global.DEVICE_NAME || '', + app: global.PACKAGE_PATH, + autoAcceptAlerts: true, + }; + + if (process.env.CHROMEDRIVER_EXECUTABLE) { + driverConfig.chromedriverExecutable = process.env.CHROMEDRIVER_EXECUTABLE; + } + driver = wd.promiseChainRemote(serverConfig); + module.exports.configureLogging(driver); + + return driver.init(driverConfig).setImplicitWaitTimeout(10000) + .sleep(20000) // wait for the app to load + .then(callback); +}; + +module.exports.getWD = function () { + return wd; +}; + +module.exports.configureLogging = function (driver) { + driver.on('status', function (info) { + console.log(info); + }); + driver.on('command', function (meth, path, data) { + console.log(' > ' + meth, path, data || ''); + }); + driver.on('http', function (meth, path, data) { + console.log(' > ' + meth, path, data || ''); + }); +}; diff --git a/plugins/cordova-plugin-camera/appium-tests/ios/ios.spec.js b/plugins/cordova-plugin-camera/appium-tests/ios/ios.spec.js new file mode 100644 index 0000000..4b82fb2 --- /dev/null +++ b/plugins/cordova-plugin-camera/appium-tests/ios/ios.spec.js @@ -0,0 +1,288 @@ +/*jshint node: true, jasmine: true */ +/* + * + * 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. + * +*/ + +// these tests are meant to be executed by Cordova Medic Appium runner +// you can find it here: https://github.com/apache/cordova-medic/ +// it is not necessary to do a full CI setup to run these tests +// just run "node cordova-medic/medic/medic.js appium --platform android --plugins cordova-plugin-camera" + +'use strict'; + +var wdHelper = require('../helpers/wdHelper'); +var wd = wdHelper.getWD(); +var isDevice = global.DEVICE; +var cameraConstants = require('../../www/CameraConstants'); +var cameraHelper = require('../helpers/cameraHelper'); +var screenshotHelper = require('../helpers/screenshotHelper'); + +var MINUTE = 60 * 1000; +var DEFAULT_WEBVIEW_CONTEXT = 'WEBVIEW_1'; + +describe('Camera tests iOS.', function () { + + var driver; + var webviewContext = DEFAULT_WEBVIEW_CONTEXT; + var startingMessage = 'Ready for action!'; + + function win() { + expect(true).toBe(true); + } + + function fail(error) { + screenshotHelper.saveScreenshot(driver); + if (error && error.message) { + console.log('An error occured: ' + error.message); + expect(true).toFailWithMessage(error.message); + throw error.message; + } + if (error) { + console.log('Failed expectation: ' + error); + expect(true).toFailWithMessage(error); + throw error; + } + // no message provided :( + expect(true).toBe(false); + throw 'An error without description occured'; + } + + // generates test specs by combining all the specified options + // you can add more options to test more scenarios + function generateSpecs() { + var sourceTypes = [ + cameraConstants.PictureSourceType.CAMERA, + cameraConstants.PictureSourceType.PHOTOLIBRARY + ], + destinationTypes = cameraConstants.DestinationType, + encodingTypes = [ + cameraConstants.EncodingType.JPEG, + cameraConstants.EncodingType.PNG + ], + allowEditOptions = [ + true, + false + ]; + + return cameraHelper.generateSpecs(sourceTypes, destinationTypes, encodingTypes, allowEditOptions); + } + + function getPicture(options, cancelCamera, skipUiInteractions) { + if (!options) { + options = {}; + } + var command = "navigator.camera.getPicture(function (result) { document.getElementById('info').innerHTML = 'Success: ' + result.slice(0, 100); }, " + + "function (err) { document.getElementById('info').innerHTML = 'ERROR: ' + err; }," + JSON.stringify(options) + ");"; + return driver + .sleep(2000) + .context(webviewContext) + .execute(command) + .sleep(5000) + .context('NATIVE_APP') + .then(function () { + if (skipUiInteractions) { + return; + } + if (options.hasOwnProperty('sourceType') && options.sourceType === cameraConstants.PictureSourceType.PHOTOLIBRARY) { + return driver + .elementByName('Camera Roll') + .click() + .elementByXPath('//UIACollectionCell') + .click() + .then(function () { + if (options.hasOwnProperty('allowEdit') && options.allowEdit === true) { + return driver + .elementByName('Use') + .click(); + } + return driver; + }); + } + if (options.hasOwnProperty('sourceType') && options.sourceType === cameraConstants.PictureSourceType.SAVEDPHOTOALBUM) { + return driver + .elementByXPath('//UIACollectionCell') + .click() + .then(function () { + if (options.hasOwnProperty('allowEdit') && options.allowEdit === true) { + return driver + .elementByName('Use') + .click(); + } + return driver; + }); + } + if (cancelCamera) { + return driver + .elementByName('Cancel') + .click(); + } + return driver + .elementByName('PhotoCapture') + .click() + .elementByName('Use Photo') + .click(); + }) + .sleep(3000); + } + + function enterTest() { + return driver + .contexts(function (err, contexts) { + if (err) { + fail(err); + } else { + // if WEBVIEW context is available, use it + // if not, use NATIVE_APP + webviewContext = contexts[contexts.length - 1]; + } + }) + .then(function () { + return driver + .context(webviewContext); + }) + .fail(fail) + .elementById('info') + .fail(function () { + // unknown starting page: no 'info' div + // adding it manually + return driver + .execute('var info = document.createElement("div"); ' + + 'info.id = "info"' + + 'document.body.appendChild(info);') + .fail(fail); + }) + .execute('document.getElementById("info").innerHTML = "' + startingMessage + '";') + .fail(fail); + } + + function checkPicture(shouldLoad) { + return driver + .contexts(function (err, contexts) { + // if WEBVIEW context is available, use it + // if not, use NATIVE_APP + webviewContext = contexts[contexts.length - 1]; + }) + .context(webviewContext) + .elementById('info') + .getAttribute('innerHTML') + .then(function (html) { + if (html.indexOf(startingMessage) >= 0) { + expect(true).toFailWithMessage('No callback was fired'); + } else if (shouldLoad) { + expect(html.length).toBeGreaterThan(0); + if (html.indexOf('ERROR') >= 0) { + expect(true).toFailWithMessage(html); + } + } else { + if (html.indexOf('ERROR') === -1) { + expect(true).toFailWithMessage('Unexpected success callback with result: ' + html); + } + expect(html.indexOf('ERROR')).toBe(0); + } + }) + .context('NATIVE_APP'); + } + + function runCombinedSpec(spec) { + return enterTest() + .then(function () { + return getPicture(spec.options); + }) + .then(function () { + return checkPicture(true); + }) + .then(win, fail); + } + + beforeEach(function () { + jasmine.addMatchers({ + toFailWithMessage : function () { + return { + compare: function (actual, msg) { + console.log('Failing with message: ' + msg); + var result = { + pass: false, + message: msg + }; + return result; + } + }; + } + }); + }); + + it('camera.ui.util Configuring driver and starting a session', function (done) { + driver = wdHelper.getDriver('iOS', done); + }, 3 * MINUTE); + + describe('Specs.', function () { + // getPicture() with mediaType: VIDEO, sourceType: PHOTOLIBRARY + it('camera.ui.spec.1 Selecting only videos', function (done) { + var options = { sourceType: cameraConstants.PictureSourceType.PHOTOLIBRARY, + mediaType: cameraConstants.MediaType.VIDEO }; + enterTest() + .then(function () { return getPicture(options, false, true); }) // skip ui unteractions + .sleep(5000) + .elementByName('Videos') + .then(win, fail) + .elementByName('Cancel') + .click() + .finally(done); + }, 3 * MINUTE); + + // getPicture(), then dismiss + // wait for the error callback to bee called + it('camera.ui.spec.2 Dismissing the camera', function (done) { + // camera is not available on iOS simulator + if (!isDevice) { + pending(); + } + var options = { sourceType: cameraConstants.PictureSourceType.CAMERA }; + enterTest() + .then(function () { + return getPicture(options, true); + }) + .then(function () { + return checkPicture(false); + }) + .elementByXPath('//UIAStaticText[contains(@label,"no image selected")]') + .then(function () { + return checkPicture(false); + }, fail) + .finally(done); + }, 3 * MINUTE); + + // combine various options for getPicture() + generateSpecs().forEach(function (spec) { + it('camera.ui.spec.3.' + spec.id + ' Combining options', function (done) { + // camera is not available on iOS simulator + if (!isDevice) { + pending(); + } + runCombinedSpec(spec).then(done); + }, 3 * MINUTE); + }); + + }); + + it('camera.ui.util.4 Destroy the session', function (done) { + driver.quit(done); + }, MINUTE); +}); diff --git a/plugins/cordova-plugin-camera/doc/de/README.md b/plugins/cordova-plugin-camera/doc/de/README.md new file mode 100644 index 0000000..97e6526 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/de/README.md @@ -0,0 +1,421 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +Dieses Plugin definiert eine globale `navigator.camera`-Objekt, das eine API für Aufnahmen und für die Auswahl der Bilder aus dem System-Image-Library bietet. + +Obwohl das Objekt mit der globalen Gültigkeitsbereich `navigator` verbunden ist, steht es nicht bis nach dem `Deviceready`-Ereignis. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## Installation + + cordova plugin add cordova-plugin-camera + + +## API + + * Kamera + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * navigator.camera.cleanup + +## navigator.camera.getPicture + +Nimmt ein Foto mit der Kamera, oder ein Foto aus dem Gerät Bildergalerie abgerufen. Das Bild wird an den Erfolg-Rückruf als base64-codierte `String` oder als URI für die Image-Datei übergeben. Die Methode selbst gibt ein `CameraPopoverHandle`-Objekt, das verwendet werden kann, um die Datei-Auswahl-Popover neu zu positionieren. + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### Beschreibung + +Die `camera.getPicture`-Funktion öffnet das Gerät Standard-Kamera-Anwendung, die Benutzern ermöglicht, Bilder ausrichten. Dieses Verhalten tritt in der Standardeinstellung, wenn `Camera.sourceType` `Camera.PictureSourceType.CAMERA` entspricht. Sobald der Benutzer die Fotoschnäpper, die Kameraanwendung geschlossen wird und die Anwendung wird wiederhergestellt. + +Wenn `Camera.sourceType` `Camera.PictureSourceType.PHOTOLIBRARY` oder `Camera.PictureSourceType.SAVEDPHOTOALBUM` ist, dann wird ein Dialogfeld angezeigt, das Benutzern ermöglicht, ein vorhandenes Bild auszuwählen. Die `camera.getPicture`-Funktion gibt ein `CameraPopoverHandle`-Objekt, das verwendet werden kann, um die Bild-Auswahl-Dialog, z. B. beim ändert sich der Orientierung des Geräts neu positionieren. + +Der Rückgabewert wird an die `cameraSuccess`-Callback-Funktion in einem der folgenden Formate, je nach dem angegebenen `cameraOptions` gesendet: + + * A `String` mit dem base64-codierte Foto-Bild. + + * A `String` , die die Bild-Datei-Stelle auf lokalem Speicher (Standard). + +Sie können tun, was Sie wollen, mit dem codierten Bildes oder URI, zum Beispiel: + + * Rendern Sie das Bild in ein `` Tag, wie im folgenden Beispiel + + * Die Daten lokal zu speichern ( `LocalStorage` , [Lawnchair](http://brianleroux.github.com/lawnchair/), etc..) + + * Post die Daten an einen entfernten server + +**Hinweis**: Fotoauflösung auf neueren Geräten ist ganz gut. Fotos aus dem Gerät Galerie ausgewählt sind nicht zu einer niedrigeren Qualität herunterskaliert, selbst wenn ein `Qualität`-Parameter angegeben wird. Um Speicherprobleme zu vermeiden, legen Sie `Camera.destinationType` auf `FILE_URI` statt `DATA_URL`. + +#### Unterstützte Plattformen + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### Beispiel + +Nehmen Sie ein Foto und rufen Sie sie als base64-codierte Bild: + + 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); + } + + +Nehmen Sie ein Foto und rufen Sie das Bild-Datei-Speicherort: + + 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); + } + + +#### "Einstellungen" (iOS) + + * **CameraUsesGeolocation** (Boolean, Standardwert ist False). Zur Erfassung von JPEGs, auf true festgelegt, um Geolocation-Daten im EXIF-Header zu erhalten. Dies löst einen Antrag auf Geolocation-Berechtigungen, wenn auf True festgelegt. + + + + +#### Amazon Fire OS Macken + +Amazon Fire OS verwendet Absichten zum Starten von der Kamera-Aktivität auf dem Gerät, um Bilder zu erfassen und auf Handys mit wenig Speicher, Cordova Tätigkeit getötet werden kann. In diesem Szenario kann das Bild nicht angezeigt, wenn die Aktivität von Cordova wiederhergestellt wird. + +#### Android Eigenarten + +Android verwendet Absichten zum Starten von der Kamera-Aktivität auf dem Gerät, um Bilder zu erfassen und auf Handys mit wenig Speicher, Cordova Tätigkeit getötet werden kann. In diesem Szenario kann das Bild nicht angezeigt, wenn die Aktivität von Cordova wiederhergestellt wird. + +#### Browser-Eigenheiten + +Fotos können nur als base64-codierte Bild zurückgeben werden. + +#### Firefox OS Macken + +Kamera-Plugin ist derzeit implementiert mithilfe von [Web-Aktivitäten](https://hacks.mozilla.org/2013/01/introducing-web-activities/). + +#### iOS Macken + +Einschließlich einer JavaScript-`alert()` entweder Rückruffunktionen kann Probleme verursachen. Wickeln Sie die Warnung innerhalb eine `setTimeout()` erlauben die iOS-Bild-Picker oder Popover vollständig zu schließen, bevor die Warnung angezeigt: + + setTimeout(function() { + // do your thing here! + }, 0); + + +#### Windows Phone 7 Macken + +Die native Kameraanwendung aufrufen, während das Gerät via Zune angeschlossen ist funktioniert nicht und löst eine Fehler-Callback. + +#### Tizen Macken + +Tizen unterstützt nur ein `DestinationType` von `Camera.DestinationType.FILE_URI` und ein `SourceType` von `Camera.PictureSourceType.PHOTOLIBRARY`. + +## CameraOptions + +Optionale Parameter die Kameraeinstellungen anpassen. + + { 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 }; + + + * **Qualität**: Qualität des gespeicherten Bildes, ausgedrückt als ein Bereich von 0-100, wo 100 in der Regel voller Auflösung ohne Verlust aus der Dateikomprimierung ist. Der Standardwert ist 50. *(Anzahl)* (Beachten Sie, dass Informationen über die Kamera Auflösung nicht verfügbar ist.) + + * **DestinationType**: Wählen Sie das Format des Rückgabewerts. Der Standardwert ist FILE_URI. Im Sinne `navigator.camera.DestinationType` *(Anzahl)* + + 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**: Legen Sie die Quelle des Bildes. Der Standardwert ist die Kamera. Im Sinne `navigator.camera.PictureSourceType` *(Anzahl)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **AllowEdit**: einfache Bearbeitung des Bildes vor Auswahl zu ermöglichen. *(Boolesch)* + + * **EncodingType**: die zurückgegebene Image-Datei ist Codierung auswählen. Standardwert ist JPEG. Im Sinne `navigator.camera.EncodingType` *(Anzahl)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **TargetWidth**: Breite in Pixel zum Bild skalieren. Muss mit **TargetHeight**verwendet werden. Seitenverhältnis bleibt konstant. *(Anzahl)* + + * **TargetHeight**: Höhe in Pixel zum Bild skalieren. Muss mit **TargetWidth**verwendet werden. Seitenverhältnis bleibt konstant. *(Anzahl)* + + * **MediaType**: Legen Sie den Typ der Medien zur Auswahl. Funktioniert nur, wenn `PictureSourceType` ist `PHOTOLIBRARY` oder `SAVEDPHOTOALBUM` . Im Sinne `nagivator.camera.MediaType` *(Anzahl)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. STANDARD. 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**: Drehen Sie das Bild um die Ausrichtung des Geräts während der Aufnahme zu korrigieren. *(Boolesch)* + + * **SaveToPhotoAlbum**: das Bild auf das Fotoalbum auf dem Gerät zu speichern, nach Einnahme. *(Boolesch)* + + * **PopoverOptions**: iOS-nur Optionen, die Popover Lage in iPad angeben. In definierten`CameraPopoverOptions`. + + * **CameraDirection**: Wählen Sie die Kamera (vorn oder hinten-gerichtete) verwenden. Der Standardwert ist zurück. Im Sinne `navigator.camera.Direction` *(Anzahl)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### Amazon Fire OS Macken + + * `cameraDirection`Ergebnisse in einem hinten gerichteter Foto Wert. + + * Ignoriert die `allowEdit` Parameter. + + * `Camera.PictureSourceType.PHOTOLIBRARY`und `Camera.PictureSourceType.SAVEDPHOTOALBUM` beide das gleiche Fotoalbum anzuzeigen. + +#### Android Eigenarten + + * `cameraDirection`Ergebnisse in einem hinten gerichteter Foto Wert. + + * Android verwendet auch die Ernte-Aktivität für AllowEdit, obwohl Ernte sollte arbeiten und das zugeschnittene Bild zurück zu Cordova, das einzige, dass Werke konsequent die gebündelt mit der Google-Plus-Fotos-Anwendung ist tatsächlich zu übergeben. Andere Kulturen funktioniert möglicherweise nicht. + + * `Camera.PictureSourceType.PHOTOLIBRARY`und `Camera.PictureSourceType.SAVEDPHOTOALBUM` beide das gleiche Fotoalbum anzuzeigen. + +#### BlackBerry 10 Macken + + * Ignoriert die `quality` Parameter. + + * Ignoriert die `allowEdit` Parameter. + + * `Camera.MediaType`wird nicht unterstützt. + + * Ignoriert die `correctOrientation` Parameter. + + * Ignoriert die `cameraDirection` Parameter. + +#### Firefox OS Macken + + * Ignoriert die `quality` Parameter. + + * `Camera.DestinationType`wird ignoriert, und gleich `1` (Bilddatei-URI) + + * Ignoriert die `allowEdit` Parameter. + + * Ignoriert die `PictureSourceType` Parameter (Benutzer wählt es in einem Dialogfenster) + + * Ignoriert die`encodingType` + + * Ignoriert die `targetWidth` und`targetHeight` + + * `Camera.MediaType`wird nicht unterstützt. + + * Ignoriert die `correctOrientation` Parameter. + + * Ignoriert die `cameraDirection` Parameter. + +#### iOS Macken + + * Legen Sie `quality` unter 50 Speicherfehler auf einigen Geräten zu vermeiden. + + * Bei der Verwendung `destinationType.FILE_URI` , Fotos werden im temporären Verzeichnis der Anwendung gespeichert. Den Inhalt des temporären Verzeichnis der Anwendung wird gelöscht, wenn die Anwendung beendet. + +#### Tizen Macken + + * nicht unterstützte Optionen + + * gibt immer einen Datei-URI + +#### Windows Phone 7 und 8 Eigenarten + + * Ignoriert die `allowEdit` Parameter. + + * Ignoriert die `correctOrientation` Parameter. + + * Ignoriert die `cameraDirection` Parameter. + + * Ignoriert die `saveToPhotoAlbum` Parameter. WICHTIG: Alle Aufnahmen die wp7/8 Cordova-Kamera-API werden immer in Kamerarolle des Telefons kopiert. Abhängig von den Einstellungen des Benutzers könnte dies auch bedeuten, dass das Bild in ihre OneDrive automatisch hochgeladen ist. Dies könnte möglicherweise bedeuten, dass das Bild für ein breiteres Publikum als Ihre Anwendung vorgesehen ist. Wenn diese einen Blocker für Ihre Anwendung, Sie müssen die CameraCaptureTask zu implementieren, wie im Msdn dokumentiert: Sie können kommentieren oder Up-Abstimmung das Beiträge zu diesem Thema im [Bugtracker](https://issues.apache.org/jira/browse/CB-2083) + + * Ignoriert die `mediaType` -Eigenschaft des `cameraOptions` wie das Windows Phone SDK keine Möglichkeit, Fotothek Videos wählen. + +## CameraError + +onError-Callback-Funktion, die eine Fehlermeldung bereitstellt. + + function(message) { + // Show a helpful message + } + + +#### Beschreibung + + * **Meldung**: die Nachricht wird durch das Gerät systemeigenen Code bereitgestellt. *(String)* + +## cameraSuccess + +onSuccess Callback-Funktion, die die Bilddaten bereitstellt. + + function(imageData) { + // Do something with the image + } + + +#### Beschreibung + + * **CMYK**: Base64-Codierung der Bilddaten, *oder* die Image-Datei-URI, je nach `cameraOptions` in Kraft. *(String)* + +#### Beispiel + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Ein Handle für das Dialogfeld "Popover" erstellt von `navigator.camera.getPicture`. + +#### Beschreibung + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### Unterstützte Plattformen + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Beispiel + + 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 + +nur iOS-Parametern, die Anker-Element Lage und Pfeil Richtung der Popover angeben, bei der Auswahl von Bildern aus einem iPad Bibliothek oder Album. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +#### Beschreibung + + * **X**: x Pixelkoordinate des Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + + * **y**: y Pixelkoordinate des Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + + * **width**: Breite in Pixeln, das Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + + * **height**: Höhe in Pixeln, das Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + + * **arrowDir**: Richtung der Pfeil auf der Popover zeigen sollte. Im Sinne `Camera.PopoverArrowDirection` *(Anzahl)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Beachten Sie, dass die Größe der Popover ändern kann, um die Richtung des Pfeils und Ausrichtung des Bildschirms anzupassen. Achten Sie darauf, um Orientierung zu berücksichtigen, wenn Sie den Anker-Element-Speicherort angeben. + +## navigator.camera.cleanup + +Entfernt Mittelstufe Fotos von der Kamera aus der vorübergehenden Verwahrung genommen. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +#### Beschreibung + +Fortgeschrittene Image-Dateien, die in vorübergehender Verwahrung gehalten werden, nach dem Aufruf von `camera.getPicture` entfernt. Gilt nur wenn der Wert von `Camera.sourceType` gleich `Camera.PictureSourceType.CAMERA` und `Camera.destinationType` gleich `Camera.DestinationType.FILE_URI`. + +#### Unterstützte Plattformen + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Beispiel + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/de/index.md b/plugins/cordova-plugin-camera/doc/de/index.md new file mode 100644 index 0000000..1c7486c --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/de/index.md @@ -0,0 +1,434 @@ + + +# cordova-plugin-camera + +Dieses Plugin definiert eine globale `navigator.camera`-Objekt, das eine API für Aufnahmen und für die Auswahl der Bilder aus dem System-Image-Library bietet. + +Obwohl das Objekt mit der globalen Gültigkeitsbereich `navigator` verbunden ist, steht es nicht bis nach dem `Deviceready`-Ereignis. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## Installation + + cordova plugin add cordova-plugin-camera + + +## navigator.camera.getPicture + +Nimmt ein Foto mit der Kamera, oder ein Foto aus dem Gerät Bildergalerie abgerufen. Das Bild wird an den Erfolg-Rückruf als base64-codierte `String` oder als URI für die Image-Datei übergeben. Die Methode selbst gibt ein `CameraPopoverHandle`-Objekt, das verwendet werden kann, um die Datei-Auswahl-Popover neu zu positionieren. + + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); + + +### Beschreibung + +Die `camera.getPicture`-Funktion öffnet das Gerät Standard-Kamera-Anwendung, die Benutzern ermöglicht, Bilder ausrichten. Dieses Verhalten tritt in der Standardeinstellung, wenn `Camera.sourceType` `Camera.PictureSourceType.CAMERA` entspricht. Sobald der Benutzer die Fotoschnäpper, die Kameraanwendung geschlossen wird und die Anwendung wird wiederhergestellt. + +Wenn `Camera.sourceType` `Camera.PictureSourceType.PHOTOLIBRARY` oder `Camera.PictureSourceType.SAVEDPHOTOALBUM` ist, dann wird ein Dialogfeld angezeigt, das Benutzern ermöglicht, ein vorhandenes Bild auszuwählen. Die `camera.getPicture`-Funktion gibt ein `CameraPopoverHandle`-Objekt, das verwendet werden kann, um die Bild-Auswahl-Dialog, z. B. beim ändert sich der Orientierung des Geräts neu positionieren. + +Der Rückgabewert wird an die `cameraSuccess`-Callback-Funktion in einem der folgenden Formate, je nach dem angegebenen `cameraOptions` gesendet: + +* A `String` mit dem base64-codierte Foto-Bild. + +* A `String` , die die Bild-Datei-Stelle auf lokalem Speicher (Standard). + +Sie können tun, was Sie wollen, mit dem codierten Bildes oder URI, zum Beispiel: + +* Rendern Sie das Bild in ein `` Tag, wie im folgenden Beispiel + +* Die Daten lokal zu speichern ( `LocalStorage` , [Lawnchair][1], etc..) + +* Post die Daten an einen entfernten server + + [1]: http://brianleroux.github.com/lawnchair/ + +**Hinweis**: Fotoauflösung auf neueren Geräten ist ganz gut. Fotos aus dem Gerät Galerie ausgewählt sind nicht zu einer niedrigeren Qualität herunterskaliert, selbst wenn ein `Qualität`-Parameter angegeben wird. Um Speicherprobleme zu vermeiden, legen Sie `Camera.destinationType` auf `FILE_URI` statt `DATA_URL`. + +### Unterstützte Plattformen + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Browser +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 und 8 +* Windows 8 + +### "Einstellungen" (iOS) + +* **CameraUsesGeolocation** (Boolean, Standardwert ist False). Zur Erfassung von JPEGs, auf true festgelegt, um Geolocation-Daten im EXIF-Header zu erhalten. Dies löst einen Antrag auf Geolocation-Berechtigungen, wenn auf True festgelegt. + + + + +### Amazon Fire OS Macken + +Amazon Fire OS verwendet Absichten zum Starten von der Kamera-Aktivität auf dem Gerät, um Bilder zu erfassen und auf Handys mit wenig Speicher, Cordova Tätigkeit getötet werden kann. In diesem Szenario kann das Bild nicht angezeigt, wenn die Aktivität von Cordova wiederhergestellt wird. + +### Android Eigenarten + +Android verwendet Absichten zum Starten von der Kamera-Aktivität auf dem Gerät, um Bilder zu erfassen und auf Handys mit wenig Speicher, Cordova Tätigkeit getötet werden kann. In diesem Szenario kann das Bild nicht angezeigt, wenn die Aktivität von Cordova wiederhergestellt wird. + +### Browser-Eigenheiten + +Fotos können nur als base64-codierte Bild zurückgeben werden. + +### Firefox OS Macken + +Kamera-Plugin ist derzeit implementiert mithilfe von [Web-Aktivitäten][2]. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### iOS Macken + +Einschließlich einer JavaScript-`alert()` entweder Rückruffunktionen kann Probleme verursachen. Wickeln Sie die Warnung innerhalb eine `setTimeout()` erlauben die iOS-Bild-Picker oder Popover vollständig zu schließen, bevor die Warnung angezeigt: + + setTimeout(function() { + // do your thing here! + }, 0); + + +### Windows Phone 7 Macken + +Die native Kameraanwendung aufrufen, während das Gerät via Zune angeschlossen ist funktioniert nicht und löst eine Fehler-Callback. + +### Tizen Macken + +Tizen unterstützt nur ein `DestinationType` von `Camera.DestinationType.FILE_URI` und ein `SourceType` von `Camera.PictureSourceType.PHOTOLIBRARY`. + +### Beispiel + +Nehmen Sie ein Foto und rufen Sie sie als base64-codierte Bild: + + 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); + } + + +Nehmen Sie ein Foto und rufen Sie das Bild-Datei-Speicherort: + + 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 + +Optionale Parameter die Kameraeinstellungen anpassen. + + { 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 }; + + +### Optionen + +* **Qualität**: Qualität des gespeicherten Bildes, ausgedrückt als ein Bereich von 0-100, wo 100 in der Regel voller Auflösung ohne Verlust aus der Dateikomprimierung ist. Der Standardwert ist 50. *(Anzahl)* (Beachten Sie, dass Informationen über die Kamera Auflösung nicht verfügbar ist.) + +* **DestinationType**: Wählen Sie das Format des Rückgabewerts. Der Standardwert ist FILE_URI. Im Sinne `navigator.camera.DestinationType` *(Anzahl)* + + 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**: Legen Sie die Quelle des Bildes. Der Standardwert ist die Kamera. Im Sinne `navigator.camera.PictureSourceType` *(Anzahl)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **AllowEdit**: einfache Bearbeitung des Bildes vor Auswahl zu ermöglichen. *(Boolesch)* + +* **EncodingType**: die zurückgegebene Image-Datei ist Codierung auswählen. Standardwert ist JPEG. Im Sinne `navigator.camera.EncodingType` *(Anzahl)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **TargetWidth**: Breite in Pixel zum Bild skalieren. Muss mit **TargetHeight**verwendet werden. Seitenverhältnis bleibt konstant. *(Anzahl)* + +* **TargetHeight**: Höhe in Pixel zum Bild skalieren. Muss mit **TargetWidth**verwendet werden. Seitenverhältnis bleibt konstant. *(Anzahl)* + +* **MediaType**: Legen Sie den Typ der Medien zur Auswahl. Funktioniert nur, wenn `PictureSourceType` ist `PHOTOLIBRARY` oder `SAVEDPHOTOALBUM` . Im Sinne `nagivator.camera.MediaType` *(Anzahl)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. STANDARD. 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**: Drehen Sie das Bild um die Ausrichtung des Geräts während der Aufnahme zu korrigieren. *(Boolesch)* + +* **SaveToPhotoAlbum**: das Bild auf das Fotoalbum auf dem Gerät zu speichern, nach Einnahme. *(Boolesch)* + +* **PopoverOptions**: iOS-nur Optionen, die Popover Lage in iPad angeben. In definierten`CameraPopoverOptions`. + +* **CameraDirection**: Wählen Sie die Kamera (vorn oder hinten-gerichtete) verwenden. Der Standardwert ist zurück. Im Sinne `navigator.camera.Direction` *(Anzahl)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### Amazon Fire OS Macken + +* `cameraDirection`Ergebnisse in einem hinten gerichteter Foto Wert. + +* Ignoriert die `allowEdit` Parameter. + +* `Camera.PictureSourceType.PHOTOLIBRARY`und `Camera.PictureSourceType.SAVEDPHOTOALBUM` beide das gleiche Fotoalbum anzuzeigen. + +### Android Eigenarten + +* `cameraDirection`Ergebnisse in einem hinten gerichteter Foto Wert. + +* Ignoriert die `allowEdit` Parameter. + +* `Camera.PictureSourceType.PHOTOLIBRARY`und `Camera.PictureSourceType.SAVEDPHOTOALBUM` beide das gleiche Fotoalbum anzuzeigen. + +### BlackBerry 10 Macken + +* Ignoriert die `quality` Parameter. + +* Ignoriert die `allowEdit` Parameter. + +* `Camera.MediaType`wird nicht unterstützt. + +* Ignoriert die `correctOrientation` Parameter. + +* Ignoriert die `cameraDirection` Parameter. + +### Firefox OS Macken + +* Ignoriert die `quality` Parameter. + +* `Camera.DestinationType`wird ignoriert, und gleich `1` (Bilddatei-URI) + +* Ignoriert die `allowEdit` Parameter. + +* Ignoriert die `PictureSourceType` Parameter (Benutzer wählt es in einem Dialogfenster) + +* Ignoriert die`encodingType` + +* Ignoriert die `targetWidth` und`targetHeight` + +* `Camera.MediaType`wird nicht unterstützt. + +* Ignoriert die `correctOrientation` Parameter. + +* Ignoriert die `cameraDirection` Parameter. + +### iOS Macken + +* Legen Sie `quality` unter 50 Speicherfehler auf einigen Geräten zu vermeiden. + +* Bei der Verwendung `destinationType.FILE_URI` , Fotos werden im temporären Verzeichnis der Anwendung gespeichert. Den Inhalt des temporären Verzeichnis der Anwendung wird gelöscht, wenn die Anwendung beendet. + +### Tizen Macken + +* nicht unterstützte Optionen + +* gibt immer einen Datei-URI + +### Windows Phone 7 und 8 Eigenarten + +* Ignoriert die `allowEdit` Parameter. + +* Ignoriert die `correctOrientation` Parameter. + +* Ignoriert die `cameraDirection` Parameter. + +* Ignoriert die `saveToPhotoAlbum` Parameter. WICHTIG: Alle Aufnahmen die wp7/8 Cordova-Kamera-API werden immer in Kamerarolle des Telefons kopiert. Abhängig von den Einstellungen des Benutzers könnte dies auch bedeuten, dass das Bild in ihre OneDrive automatisch hochgeladen ist. Dies könnte möglicherweise bedeuten, dass das Bild für ein breiteres Publikum als Ihre Anwendung vorgesehen ist. Wenn diese einen Blocker für Ihre Anwendung, Sie müssen die CameraCaptureTask zu implementieren, wie im Msdn dokumentiert: Sie können kommentieren oder Up-Abstimmung das Beiträge zu diesem Thema im [Bugtracker][3] + +* Ignoriert die `mediaType` -Eigenschaft des `cameraOptions` wie das Windows Phone SDK keine Möglichkeit, Fotothek Videos wählen. + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +onError-Callback-Funktion, die eine Fehlermeldung bereitstellt. + + function(message) { + // Show a helpful message + } + + +### Parameter + +* **Meldung**: die Nachricht wird durch das Gerät systemeigenen Code bereitgestellt. *(String)* + +## cameraSuccess + +onSuccess Callback-Funktion, die die Bilddaten bereitstellt. + + function(imageData) { + // Do something with the image + } + + +### Parameter + +* **CMYK**: Base64-Codierung der Bilddaten, *oder* die Image-Datei-URI, je nach `cameraOptions` in Kraft. *(String)* + +### Beispiel + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Ein Handle für das Dialogfeld "Popover" erstellt von `navigator.camera.getPicture`. + +### Methoden + +* **SetPosition**: Legen Sie die Position der Popover. + +### Unterstützte Plattformen + +* iOS + +### setPosition + +Legen Sie die Position von der Popover. + +**Parameter**: + +* `cameraPopoverOptions`: die `CameraPopoverOptions` angeben, dass die neue Position + +### Beispiel + + 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 + +nur iOS-Parametern, die Anker-Element Lage und Pfeil Richtung der Popover angeben, bei der Auswahl von Bildern aus einem iPad Bibliothek oder Album. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +### CameraPopoverOptions + +* **X**: x Pixelkoordinate des Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + +* **y**: y Pixelkoordinate des Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + +* **width**: Breite in Pixeln, das Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + +* **height**: Höhe in Pixeln, das Bildschirmelement auf dem der Popover zu verankern. *(Anzahl)* + +* **arrowDir**: Richtung der Pfeil auf der Popover zeigen sollte. Im Sinne `Camera.PopoverArrowDirection` *(Anzahl)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Beachten Sie, dass die Größe der Popover ändern kann, um die Richtung des Pfeils und Ausrichtung des Bildschirms anzupassen. Achten Sie darauf, um Orientierung zu berücksichtigen, wenn Sie den Anker-Element-Speicherort angeben. + +## navigator.camera.cleanup + +Entfernt Mittelstufe Fotos von der Kamera aus der vorübergehenden Verwahrung genommen. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +### Beschreibung + +Fortgeschrittene Image-Dateien, die in vorübergehender Verwahrung gehalten werden, nach dem Aufruf von `camera.getPicture` entfernt. Gilt nur wenn der Wert von `Camera.sourceType` gleich `Camera.PictureSourceType.CAMERA` und `Camera.destinationType` gleich `Camera.DestinationType.FILE_URI`. + +### Unterstützte Plattformen + +* iOS + +### Beispiel + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } diff --git a/plugins/cordova-plugin-camera/doc/es/README.md b/plugins/cordova-plugin-camera/doc/es/README.md new file mode 100644 index 0000000..76af164 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/es/README.md @@ -0,0 +1,411 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +Este plugin define un global `navigator.camera` objeto que proporciona una API para tomar fotografías y por elegir imágenes de biblioteca de imágenes del sistema. + +Aunque el objeto está unido al ámbito global `navigator` , no estará disponible hasta después de la `deviceready` evento. + + document.addEventListener ("deviceready", onDeviceReady, false); + function onDeviceReady() {console.log(navigator.camera)}; + + +## Instalación + + cordova plugin add cordova-plugin-camera + + +## API + + * Cámara + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * Navigator.Camera.Cleanup + +## navigator.camera.getPicture + +Toma una foto con la cámara, o recupera una foto de Galería de imágenes del dispositivo. La imagen se pasa a la devolución de llamada de éxito como un codificado en base64 `String` , o como el URI para el archivo de imagen. El método se devuelve un `CameraPopoverHandle` objeto que puede utilizarse para volver a colocar el popover de selección de archivo. + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### Descripción + +El `camera.getPicture` función abre la aplicación de cámara predeterminada del dispositivo que permite a los usuarios ajustar imágenes. Este comportamiento se produce de forma predeterminada, cuando `Camera.sourceType` es igual a `Camera.PictureSourceType.CAMERA` . Una vez que el usuario ajusta la foto, una aplicación de cámara se cierra y se restablecerá la aplicación. + +Si `Camera.sourceType` es `Camera.PictureSourceType.PHOTOLIBRARY` o `Camera.PictureSourceType.SAVEDPHOTOALBUM` , entonces una muestra de diálogo que permite a los usuarios seleccionar una imagen existente. El `camera.getPicture` función devuelve un `CameraPopoverHandle` objeto, que puede utilizarse para volver a colocar el diálogo de selección de imagen, por ejemplo, cuando cambia la orientación del dispositivo. + +El valor devuelto es enviado a la `cameraSuccess` función de callback, en uno de los formatos siguientes, dependiendo del objeto `cameraOptions` : + + * Una `String` que contiene la imagen codificada en base64. + + * Una `String` que representa la ubicación del archivo de imagen en almacenamiento local (por defecto). + +Puedes hacer lo que quieras con la imagen codificada o URI, por ejemplo: + + * Representar la imagen en una etiqueta de ``, como en el ejemplo siguiente + + * Guardar los datos localmente (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.) + + * Enviar los datos a un servidor remoto + +**Nota**: resolución de la foto en los nuevos dispositivos es bastante bueno. Fotos seleccionadas de la Galería del dispositivo no son degradadas a una calidad más baja, incluso si un `quality` se especifica el parámetro. Para evitar problemas con la memoria común, establezca `Camera.destinationType` a `FILE_URI` en lugar de`DATA_URL`. + +#### Plataformas soportadas + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### Ejemplo + +Tomar una foto y recuperarlo como una imagen codificada en base64: + + 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); + } + + +Tomar una foto y recuperar la ubicación del archivo de la imagen: + + 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); + } + + +#### Preferencias (iOS) + + * **CameraUsesGeolocation** (booleano, el valor predeterminado de false). Para la captura de imágenes JPEG, establecido en true para obtener datos de geolocalización en la cabecera EXIF. Esto activará la solicitud de permisos de geolocalización si establecido en true. + + + + +#### Amazon fuego OS rarezas + +Amazon fuego OS utiliza los intentos para poner en marcha la actividad de la cámara del dispositivo para capturar imágenes y en teléfonos con poca memoria, puede matar la actividad Cordova. En este escenario, la imagen no aparezca cuando se restaura la actividad cordova. + +#### Rarezas Android + +Android utiliza los intentos para iniciar la actividad de la cámara del dispositivo para capturar imágenes, y en los teléfonos con poca memoria, puede matar la actividad Cordova. En este escenario, la imagen no aparezca cuando se restaura la actividad Cordova. + +#### Navegador rarezas + +Sólo puede devolver fotos como imagen codificada en base64. + +#### Firefox OS rarezas + +Cámara plugin actualmente se implementa mediante [Actividades Web](https://hacks.mozilla.org/2013/01/introducing-web-activities/). + +#### iOS rarezas + +Incluyendo un JavaScript `alert()` en cualquiera de la devolución de llamada funciones pueden causar problemas. Envuelva la alerta dentro de un `setTimeout()` para permitir que el selector de imagen iOS o popover cerrar completamente antes de la alerta se muestra: + + setTimeout(function() { + // do your thing here! + }, 0); + + +#### Windows Phone 7 rarezas + +Invocando la aplicación de cámara nativa mientras el dispositivo está conectado vía Zune no funciona y desencadena un callback de error. + +#### Rarezas Tizen + +Tizen sólo es compatible con un `destinationType` de `Camera.DestinationType.FILE_URI` y un `sourceType` de`Camera.PictureSourceType.PHOTOLIBRARY`. + +## CameraOptions + +Parámetros opcionales para personalizar la configuración de la cámara. + + {calidad: destinationType 75,: Camera.DestinationType.DATA_URL, sourceType: Camera.PictureSourceType.CAMERA, allowEdit: true, encodingType: Camera.EncodingType.JPEG, targetWidth: 100, targetHeight: 100, popoverOptions: CameraPopoverOptions, saveToPhotoAlbum: falsa}; + + + * **calidad**: calidad de la imagen guardada, expresada en un rango de 0-100, donde 100 es típicamente resolución sin pérdida de compresión del archivo. El valor predeterminado es 50. *(Número)* (Tenga en cuenta que no está disponible información sobre resolución de la cámara). + + * **destinationType**: elegir el formato del valor devuelto. El valor predeterminado es FILE_URI. Definido en `navigator.camera.DestinationType` *(número)* + + 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**: establecer el origen de la imagen. El valor predeterminado es cámara. Definido en `navigator.camera.PictureSourceType` *(número)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **allowEdit**: permite edición sencilla de imagen antes de la selección. *(Booleano)* + + * **encodingType**: elegir la codificación del archivo de imagen devuelta. Por defecto es JPEG. Definido en `navigator.camera.EncodingType` *(número)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **targetWidth**: ancho en píxeles a escala de la imagen. Debe usarse con **targetHeight**. Proporción se mantiene constante. *(Número)* + + * **targetHeight**: altura en píxeles a escala de la imagen. Debe usarse con **targetWidth**. Proporción se mantiene constante. *(Número)* + + * **mediaType**: definir el tipo de medios para seleccionar. Sólo funciona cuando `PictureSourceType` es `PHOTOLIBRARY` o `SAVEDPHOTOALBUM` . Definido en `nagivator.camera.MediaType` *(número)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. DE FORMA PREDETERMINADA. 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**: rotar la imagen para corregir la orientación del dispositivo durante la captura. *(Booleano)* + + * **saveToPhotoAlbum**: guardar la imagen en el álbum de fotos en el dispositivo después de su captura. *(Booleano)* + + * **popoverOptions**: opciones sólo iOS que especifican popover ubicación en iPad. Definido en`CameraPopoverOptions`. + + * **cameraDirection**: elegir la cámara para usar (o parte posterior-frontal). El valor predeterminado es atrás. Definido en `navigator.camera.Direction` *(número)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### Amazon fuego OS rarezas + + * Cualquier valor de `cameraDirection` da como resultado una foto orientada hacia atrás. + + * Ignora el `allowEdit` parámetro. + + * `Camera.PictureSourceType.PHOTOLIBRARY` y `Camera.PictureSourceType.SAVEDPHOTOALBUM` Mostrar el mismo álbum de fotos. + +#### Rarezas Android + + * Cualquier valor de `cameraDirection` da como resultado una foto orientada hacia atrás. + + * Android también utiliza la actividad de cultivo de allowEdit, aunque cultivo debe trabajar y realmente pasar la imagen recortada a Córdoba, el único que funciona constantemente es el integrado con la aplicación de Google Plus fotos. Otros cultivos pueden no funcionar. + + * `Camera.PictureSourceType.PHOTOLIBRARY` y `Camera.PictureSourceType.SAVEDPHOTOALBUM` Mostrar el mismo álbum de fotos. + +#### BlackBerry 10 rarezas + + * Ignora el `quality` parámetro. + + * Ignora el `allowEdit` parámetro. + + * `Camera.MediaType`No se admite. + + * Ignora el `correctOrientation` parámetro. + + * Ignora el `cameraDirection` parámetro. + +#### Firefox OS rarezas + + * Ignora el `quality` parámetro. + + * `Camera.DestinationType`se ignora y es igual a `1` (URI del archivo de imagen) + + * Ignora el `allowEdit` parámetro. + + * Ignora el `PictureSourceType` parámetro (el usuario lo elige en una ventana de diálogo) + + * Ignora el`encodingType` + + * Ignora el `targetWidth` y`targetHeight` + + * `Camera.MediaType`No se admite. + + * Ignora el `correctOrientation` parámetro. + + * Ignora el `cameraDirection` parámetro. + +#### iOS rarezas + + * Establecer `quality` por debajo de 50 para evitar errores de memoria en algunos dispositivos. + + * Cuando se utiliza `destinationType.FILE_URI` , fotos se guardan en el directorio temporal de la aplicación. El contenido del directorio temporal de la aplicación se eliminará cuando finalice la aplicación. + +#### Rarezas Tizen + + * opciones no compatibles + + * siempre devuelve un identificador URI de archivo + +#### Windows Phone 7 y 8 rarezas + + * Ignora el `allowEdit` parámetro. + + * Ignora el `correctOrientation` parámetro. + + * Ignora el `cameraDirection` parámetro. + + * Ignora el `saveToPhotoAlbum` parámetro. IMPORTANTE: Todas las imágenes tomadas con la cámara wp7/8 cordova API siempre se copian en rollo de cámara del teléfono. Dependiendo de la configuración del usuario, esto podría significar también que la imagen es auto-subido a su OneDrive. Esto potencialmente podría significar que la imagen está disponible a una audiencia más amplia que su aplicación previsto. Si un bloqueador para su aplicación, usted necesitará aplicar el CameraCaptureTask como se documenta en msdn: también puede comentar o votar hasta el tema relacionado en el [issue tracker de](https://issues.apache.org/jira/browse/CB-2083) + + * Ignora el `mediaType` propiedad de `cameraOptions` como el SDK de Windows Phone no proporciona una manera para elegir vídeos fototeca. + +## CameraError + +onError función callback que proporciona un mensaje de error. + + function(message) { + // Show a helpful message + } + + +#### Descripción + + * **mensaje**: el mensaje es proporcionado por código nativo del dispositivo. *(String)* + +## cameraSuccess + +onSuccess función callback que proporciona los datos de imagen. + + function(imageData) { + // Do something with the image + } + + +#### Descripción + + * **imageData**: codificación en Base64 de los datos de imagen, *o* el archivo de imagen URI, dependiendo de `cameraOptions` en vigor. *(String)* + +#### Ejemplo + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Un identificador para el cuadro de diálogo popover creado por`navigator.camera.getPicture`. + +#### Descripción + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### Plataformas soportadas + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Ejemplo + + 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 + +Sólo iOS parámetros que especifican la dirección ancla elemento ubicación y la flecha de la popover al seleccionar imágenes de biblioteca o álbum de un iPad. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +#### Descripción + + * **x**: coordenadas de píxeles del elemento de la pantalla en la que anclar el popover x. *(Número)* + + * **y**: coordenada píxeles del elemento de la pantalla en la que anclar el popover. *(Número)* + + * **anchura**: anchura, en píxeles, del elemento sobre el que anclar el popover pantalla. *(Número)* + + * **altura**: alto, en píxeles, del elemento sobre el que anclar el popover pantalla. *(Número)* + + * **arrowDir**: dirección de la flecha en el popover debe apuntar. Definido en `Camera.PopoverArrowDirection` *(número)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Tenga en cuenta que puede cambiar el tamaño de la popover para ajustar la dirección de la flecha y orientación de la pantalla. Asegúrese de que para tener en cuenta los cambios de orientación cuando se especifica la ubicación del elemento de anclaje. + +## Navigator.Camera.Cleanup + +Elimina intermedio fotos tomadas por la cámara de almacenamiento temporal. + + Navigator.Camera.cleanup (cameraSuccess, cameraError); + + +#### Descripción + +Elimina intermedio archivos de imagen que se mantienen en depósito temporal después de llamar `camera.getPicture` . Se aplica sólo cuando el valor de `Camera.sourceType` es igual a `Camera.PictureSourceType.CAMERA` y el `Camera.destinationType` es igual a`Camera.DestinationType.FILE_URI`. + +#### Plataformas soportadas + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Ejemplo + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/es/index.md b/plugins/cordova-plugin-camera/doc/es/index.md new file mode 100644 index 0000000..dfd0970 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/es/index.md @@ -0,0 +1,391 @@ + + +# cordova-plugin-camera + +Este plugin define un global `navigator.camera` objeto que proporciona una API para tomar fotografías y por elegir imágenes de biblioteca de imágenes del sistema. + +Aunque el objeto está unido al ámbito global `navigator` , no estará disponible hasta después de la `deviceready` evento. + + document.addEventListener ("deviceready", onDeviceReady, false); + function onDeviceReady() {console.log(navigator.camera)}; + + +## Instalación + + Cordova plugin agregar cordova-plugin-camera + + +## navigator.camera.getPicture + +Toma una foto con la cámara, o recupera una foto de Galería de imágenes del dispositivo. La imagen se pasa a la devolución de llamada de éxito como un codificado en base64 `String` , o como el URI para el archivo de imagen. El método se devuelve un `CameraPopoverHandle` objeto que puede utilizarse para volver a colocar el popover de selección de archivo. + + navigator.camera.getPicture (cameraSuccess, cameraError, cameraOptions); + + +### Descripción + +El `camera.getPicture` función abre la aplicación de cámara predeterminada del dispositivo que permite a los usuarios ajustar imágenes. Este comportamiento se produce de forma predeterminada, cuando `Camera.sourceType` es igual a `Camera.PictureSourceType.CAMERA` . Una vez que el usuario ajusta la foto, una aplicación de cámara se cierra y se restablecerá la aplicación. + +Si `Camera.sourceType` es `Camera.PictureSourceType.PHOTOLIBRARY` o `Camera.PictureSourceType.SAVEDPHOTOALBUM` , entonces una muestra de diálogo que permite a los usuarios seleccionar una imagen existente. El `camera.getPicture` función devuelve un `CameraPopoverHandle` objeto, que puede utilizarse para volver a colocar el diálogo de selección de imagen, por ejemplo, cuando cambia la orientación del dispositivo. + +El valor devuelto es enviado a la `cameraSuccess` función de callback, en uno de los formatos siguientes, dependiendo del objeto `cameraOptions` : + +* Una `String` que contiene la imagen codificada en base64. + +* Una `String` que representa la ubicación del archivo de imagen en almacenamiento local (por defecto). + +Puedes hacer lo que quieras con la imagen codificada o URI, por ejemplo: + +* Representar la imagen en una etiqueta de ``, como en el ejemplo siguiente + +* Guardar los datos localmente (`LocalStorage`, [Lawnchair][1], etc.) + +* Enviar los datos a un servidor remoto + + [1]: http://brianleroux.github.com/lawnchair/ + +**Nota**: resolución de la foto en los nuevos dispositivos es bastante bueno. Fotos seleccionadas de la Galería del dispositivo no son degradadas a una calidad más baja, incluso si un `quality` se especifica el parámetro. Para evitar problemas con la memoria común, establezca `Camera.destinationType` a `FILE_URI` en lugar de`DATA_URL`. + +### Plataformas soportadas + +* Amazon fire OS +* Android +* BlackBerry 10 +* Explorador +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 y 8 +* Windows 8 + +### Preferencias (iOS) + +* **CameraUsesGeolocation** (booleano, el valor predeterminado de false). Para la captura de imágenes JPEG, establecido en true para obtener datos de geolocalización en la cabecera EXIF. Esto activará la solicitud de permisos de geolocalización si establecido en true. + + + + +### Amazon fuego OS rarezas + +Amazon fuego OS utiliza los intentos para poner en marcha la actividad de la cámara del dispositivo para capturar imágenes y en teléfonos con poca memoria, puede matar la actividad Cordova. En este escenario, la imagen no aparezca cuando se restaura la actividad cordova. + +### Rarezas Android + +Android utiliza los intentos para iniciar la actividad de la cámara del dispositivo para capturar imágenes, y en los teléfonos con poca memoria, puede matar la actividad Cordova. En este escenario, la imagen no aparezca cuando se restaura la actividad Cordova. + +### Navegador rarezas + +Sólo puede devolver fotos como imagen codificada en base64. + +### Firefox OS rarezas + +Cámara plugin actualmente se implementa mediante [Actividades Web][2]. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### iOS rarezas + +Incluyendo un JavaScript `alert()` en cualquiera de la devolución de llamada funciones pueden causar problemas. Envuelva la alerta dentro de un `setTimeout()` para permitir que el selector de imagen iOS o popover cerrar completamente antes de la alerta se muestra: + + setTimeout(function() {/ / Haz lo tuyo aquí!}, 0); + + +### Windows Phone 7 rarezas + +Invocando la aplicación de cámara nativa mientras el dispositivo está conectado vía Zune no funciona y desencadena un callback de error. + +### Rarezas Tizen + +Tizen sólo es compatible con un `destinationType` de `Camera.DestinationType.FILE_URI` y un `sourceType` de`Camera.PictureSourceType.PHOTOLIBRARY`. + +### Ejemplo + +Tomar una foto y recuperarlo como una imagen codificada en base64: + + navigator.camera.getPicture (onSuccess, onFail, { quality: 50, + destinationType: Camera.DestinationType.DATA_URL + }); + + function onSuccess(imageData) {var imagen = document.getElementById('myImage'); + Image.src = "datos: image / jpeg; base64," + imageData;} + + function onFail(message) {alert (' falló porque: ' + mensaje);} + + +Tomar una foto y recuperar la ubicación del archivo de la imagen: + + navigator.camera.getPicture (onSuccess, onFail, { quality: 50, + destinationType: Camera.DestinationType.FILE_URI }); + + function onSuccess(imageURI) {var imagen = document.getElementById('myImage'); + Image.src = imageURI; + } function onFail(message) {alert (' falló porque: ' + mensaje);} + + +## CameraOptions + +Parámetros opcionales para personalizar la configuración de la cámara. + + {calidad: destinationType 75,: Camera.DestinationType.DATA_URL, sourceType: Camera.PictureSourceType.CAMERA, allowEdit: true, encodingType: Camera.EncodingType.JPEG, targetWidth: 100, targetHeight: 100, popoverOptions: CameraPopoverOptions, saveToPhotoAlbum: falsa}; + + +### Opciones + +* **calidad**: calidad de la imagen guardada, expresada en un rango de 0-100, donde 100 es típicamente resolución sin pérdida de compresión del archivo. El valor predeterminado es 50. *(Número)* (Tenga en cuenta que no está disponible información sobre resolución de la cámara). + +* **destinationType**: elegir el formato del valor devuelto. El valor predeterminado es FILE_URI. Definido en `navigator.camera.DestinationType` *(número)* + + 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**: establecer el origen de la imagen. El valor predeterminado es cámara. Definido en `navigator.camera.PictureSourceType` *(número)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **allowEdit**: permite edición sencilla de imagen antes de la selección. *(Booleano)* + +* **encodingType**: elegir la codificación del archivo de imagen devuelta. Por defecto es JPEG. Definido en `navigator.camera.EncodingType` *(número)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **targetWidth**: ancho en píxeles a escala de la imagen. Debe usarse con **targetHeight**. Proporción se mantiene constante. *(Número)* + +* **targetHeight**: altura en píxeles a escala de la imagen. Debe usarse con **targetWidth**. Proporción se mantiene constante. *(Número)* + +* **mediaType**: definir el tipo de medios para seleccionar. Sólo funciona cuando `PictureSourceType` es `PHOTOLIBRARY` o `SAVEDPHOTOALBUM` . Definido en `nagivator.camera.MediaType` *(número)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. DE FORMA PREDETERMINADA. 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**: rotar la imagen para corregir la orientación del dispositivo durante la captura. *(Booleano)* + +* **saveToPhotoAlbum**: guardar la imagen en el álbum de fotos en el dispositivo después de su captura. *(Booleano)* + +* **popoverOptions**: opciones sólo iOS que especifican popover ubicación en iPad. Definido en`CameraPopoverOptions`. + +* **cameraDirection**: elegir la cámara para usar (o parte posterior-frontal). El valor predeterminado es atrás. Definido en `navigator.camera.Direction` *(número)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### Amazon fuego OS rarezas + +* Cualquier valor de `cameraDirection` da como resultado una foto orientada hacia atrás. + +* Ignora el `allowEdit` parámetro. + +* `Camera.PictureSourceType.PHOTOLIBRARY` y `Camera.PictureSourceType.SAVEDPHOTOALBUM` Mostrar el mismo álbum de fotos. + +### Rarezas Android + +* Cualquier valor de `cameraDirection` da como resultado una foto orientada hacia atrás. + +* Ignora el `allowEdit` parámetro. + +* `Camera.PictureSourceType.PHOTOLIBRARY` y `Camera.PictureSourceType.SAVEDPHOTOALBUM` Mostrar el mismo álbum de fotos. + +### BlackBerry 10 rarezas + +* Ignora el `quality` parámetro. + +* Ignora el `allowEdit` parámetro. + +* `Camera.MediaType`No se admite. + +* Ignora el `correctOrientation` parámetro. + +* Ignora el `cameraDirection` parámetro. + +### Firefox OS rarezas + +* Ignora el `quality` parámetro. + +* `Camera.DestinationType`se ignora y es igual a `1` (URI del archivo de imagen) + +* Ignora el `allowEdit` parámetro. + +* Ignora el `PictureSourceType` parámetro (el usuario lo elige en una ventana de diálogo) + +* Ignora el`encodingType` + +* Ignora el `targetWidth` y`targetHeight` + +* `Camera.MediaType`No se admite. + +* Ignora el `correctOrientation` parámetro. + +* Ignora el `cameraDirection` parámetro. + +### iOS rarezas + +* Establecer `quality` por debajo de 50 para evitar errores de memoria en algunos dispositivos. + +* Cuando se utiliza `destinationType.FILE_URI` , fotos se guardan en el directorio temporal de la aplicación. El contenido del directorio temporal de la aplicación se eliminará cuando finalice la aplicación. + +### Rarezas Tizen + +* opciones no compatibles + +* siempre devuelve un identificador URI de archivo + +### Windows Phone 7 y 8 rarezas + +* Ignora el `allowEdit` parámetro. + +* Ignora el `correctOrientation` parámetro. + +* Ignora el `cameraDirection` parámetro. + +* Ignora el `saveToPhotoAlbum` parámetro. IMPORTANTE: Todas las imágenes tomadas con la cámara wp7/8 cordova API siempre se copian en rollo de cámara del teléfono. Dependiendo de la configuración del usuario, esto podría significar también que la imagen es auto-subido a su OneDrive. Esto potencialmente podría significar que la imagen está disponible a una audiencia más amplia que su aplicación previsto. Si un bloqueador para su aplicación, usted necesitará aplicar el CameraCaptureTask como se documenta en msdn: también puede comentar o votar hasta el tema relacionado en el [issue tracker de][3] + +* Ignora el `mediaType` propiedad de `cameraOptions` como el SDK de Windows Phone no proporciona una manera para elegir vídeos fototeca. + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +onError función callback que proporciona un mensaje de error. + + function(Message) {/ / Mostrar un mensaje útil} + + +### Parámetros + +* **mensaje**: el mensaje es proporcionado por código nativo del dispositivo. *(String)* + +## cameraSuccess + +onSuccess función callback que proporciona los datos de imagen. + + function(ImageData) {/ / hacer algo con la imagen} + + +### Parámetros + +* **imageData**: codificación en Base64 de los datos de imagen, *o* el archivo de imagen URI, dependiendo de `cameraOptions` en vigor. *(String)* + +### Ejemplo + + Mostrar imagen / / function cameraCallback(imageData) {var imagen = document.getElementById('myImage'); + Image.src = "datos: image / jpeg; base64," + imageData;} + + +## CameraPopoverHandle + +Un identificador para el cuadro de diálogo popover creado por`navigator.camera.getPicture`. + +### Métodos + +* **setPosition**: establecer la posición de la popover. + +### Plataformas soportadas + +* iOS + +### setPosition + +Establecer la posición de la popover. + +**Parámetros**: + +* `cameraPopoverOptions`: el `CameraPopoverOptions` que especifican la nueva posición + +### Ejemplo + + var cameraPopoverHandle = navigator.camera.getPicture (onSuccess, onFail, {destinationType: Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY, popoverOptions: CameraPopoverOptions nuevo (300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)}); + + Vuelva a colocar el popover si cambia la orientación. + Window.onorientationchange = function() {var cameraPopoverOptions = new CameraPopoverOptions (0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY); + cameraPopoverHandle.setPosition(cameraPopoverOptions); + } + + +## CameraPopoverOptions + +Sólo iOS parámetros que especifican la dirección ancla elemento ubicación y la flecha de la popover al seleccionar imágenes de biblioteca o álbum de un iPad. + + {x: 0, y: 32, ancho: 320, altura: 480, arrowDir: Camera.PopoverArrowDirection.ARROW_ANY}; + + +### CameraPopoverOptions + +* **x**: coordenadas de píxeles del elemento de la pantalla en la que anclar el popover x. *(Número)* + +* **y**: coordenada píxeles del elemento de la pantalla en la que anclar el popover. *(Número)* + +* **anchura**: anchura, en píxeles, del elemento sobre el que anclar el popover pantalla. *(Número)* + +* **altura**: alto, en píxeles, del elemento sobre el que anclar el popover pantalla. *(Número)* + +* **arrowDir**: dirección de la flecha en el popover debe apuntar. Definido en `Camera.PopoverArrowDirection` *(número)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Tenga en cuenta que puede cambiar el tamaño de la popover para ajustar la dirección de la flecha y orientación de la pantalla. Asegúrese de que para tener en cuenta los cambios de orientación cuando se especifica la ubicación del elemento de anclaje. + +## Navigator.Camera.Cleanup + +Elimina intermedio fotos tomadas por la cámara de almacenamiento temporal. + + Navigator.Camera.cleanup (cameraSuccess, cameraError); + + +### Descripción + +Elimina intermedio archivos de imagen que se mantienen en depósito temporal después de llamar `camera.getPicture` . Se aplica sólo cuando el valor de `Camera.sourceType` es igual a `Camera.PictureSourceType.CAMERA` y el `Camera.destinationType` es igual a`Camera.DestinationType.FILE_URI`. + +### Plataformas soportadas + +* iOS + +### Ejemplo + + Navigator.Camera.cleanup (onSuccess, onFail); + + function onSuccess() {console.log ("cámara limpieza éxito.")} + + function onFail(message) {alert (' falló porque: ' + mensaje);} diff --git a/plugins/cordova-plugin-camera/doc/fr/README.md b/plugins/cordova-plugin-camera/doc/fr/README.md new file mode 100644 index 0000000..091dd23 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/fr/README.md @@ -0,0 +1,378 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +Ce plugin définit un global `navigator.camera` objet qui fournit une API pour la prise de photos et de choisir des images de la bibliothèque d'images du système. + +Bien que l'objet est attaché à la portée globale `navigator` , il n'est pas disponible jusqu'après la `deviceready` événement. + + document.addEventListener (« deviceready », onDeviceReady, false) ; + function onDeviceReady() {console.log(navigator.camera);} + + +## Installation + + cordova plugin add cordova-plugin-camera + + +## API + + * Appareil photo + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * Navigator.Camera.Cleanup + +## navigator.camera.getPicture + +Prend une photo à l'aide de la caméra, ou récupère une photo de la Galerie d'images de l'appareil. L'image est passé au rappel succès comme un codage base64 `String` , ou comme l'URI du fichier de l'image. La méthode elle-même retourne un `CameraPopoverHandle` objet qui permet de repositionner le kangourou de sélection de fichier. + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### Description + +Le `camera.getPicture` fonction ouvre l'application de caméra par défaut de l'appareil qui permet aux utilisateurs de prendre des photos. Ce comportement se produit par défaut, lorsque `Camera.sourceType` est égal à `Camera.PictureSourceType.CAMERA` . Une fois que l'utilisateur s'enclenche la photo, l'application appareil photo se ferme et l'application est restaurée. + +Si `Camera.sourceType` est `Camera.PictureSourceType.PHOTOLIBRARY` ou `Camera.PictureSourceType.SAVEDPHOTOALBUM` , puis un dialogue affiche qui permet aux utilisateurs de sélectionner une image existante. Le `camera.getPicture` retourne un `CameraPopoverHandle` objet, ce qui permet de repositionner le dialogue de sélection d'image, par exemple, lorsque l'orientation de l'appareil change. + +La valeur de retour est envoyée à la `cameraSuccess` la fonction de rappel, dans l'un des formats suivants, selon les `cameraOptions` : + + * A `String` contenant l'image photo codée en base64. + + * A `String` qui représente l'emplacement du fichier image sur le stockage local (par défaut). + +Vous pouvez faire ce que vous voulez avec l'image codée ou URI, par exemple : + + * Afficher l'image dans un `` tag, comme dans l'exemple ci-dessous + + * Enregistrer les données localement ( `LocalStorage` , [poids](http://brianleroux.github.com/lawnchair/), etc..) + + * Publier les données sur un serveur distant + +**NOTE**: la résolution de Photo sur les nouveaux appareils est assez bonne. Photos sélectionnées de la Galerie de l'appareil ne sont pas réduites à une baisse de la qualité, même si un `quality` paramètre est spécifié. Pour éviter les problèmes de mémoire commun, définissez `Camera.destinationType` à `FILE_URI` au lieu de`DATA_URL`. + +#### Plates-formes supportées + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### Exemple + +Prendre une photo, puis extrayez-la comme une image codée en base64 : + + navigator.camera.getPicture (onSuccess, onFail, { quality: 50, + destinationType: Camera.DestinationType.DATA_URL + }) ; + + function onSuccess(imageData) {var image = document.getElementById('myImage') ; + image.src = "données : image / jpeg ; base64," + imageData;} + + function onFail(message) {alert (' a échoué car: "+ message);} + + +Prendre une photo et récupérer l'emplacement du fichier de l'image : + + 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 (' a échoué car: "+ message);} + + +#### Préférences (iOS) + + * **CameraUsesGeolocation** (boolean, par défaut, false). Pour capturer des images JPEG, true pour obtenir des données de géolocalisation dans l'en-tête EXIF. Cela va déclencher une demande d'autorisations de géolocalisation si défini à true. + + + + +#### Amazon Fire OS Quirks + +Amazon Fire OS utilise des intentions pour lancer l'activité de l'appareil photo sur l'appareil pour capturer des images et sur les téléphones avec peu de mémoire, l'activité de Cordova peut être tuée. Dans ce scénario, l'image peut ne pas apparaître lorsque l'activité de cordova est restaurée. + +#### Quirks Android + +Android utilise des intentions pour lancer l'activité de l'appareil photo sur l'appareil pour capturer des images et sur les téléphones avec peu de mémoire, l'activité de Cordova peut être tuée. Dans ce scénario, l'image peut ne pas apparaître lorsque l'activité de Cordova est restaurée. + +#### Bizarreries navigateur + +Peut retourner uniquement les photos comme image codée en base64. + +#### Firefox OS Quirks + +Appareil photo plugin est actuellement mis en œuvre à l'aide [d'Activités sur le Web](https://hacks.mozilla.org/2013/01/introducing-web-activities/). + +#### Notes au sujet d'iOS + +Y compris un JavaScript `alert()` dans les deux le rappel fonctions peuvent causer des problèmes. Envelopper l'alerte dans un `setTimeout()` pour permettre le sélecteur d'image iOS ou kangourou pour fermer entièrement avant que l'alerte s'affiche : + + setTimeout(function() {/ / faire votre truc ici!}, 0) ; + + +#### Windows Phone 7 Quirks + +Invoquant l'application native caméra alors que l'appareil est connecté via Zune ne fonctionne pas et déclenche un rappel de l'erreur. + +#### Bizarreries de paciarelli + +Paciarelli prend uniquement en charge un `destinationType` de `Camera.DestinationType.FILE_URI` et un `sourceType` de`Camera.PictureSourceType.PHOTOLIBRARY`. + +## CameraOptions + +Paramètres optionnels pour personnaliser les réglages de l'appareil. + + {qualité : destinationType 75,: Camera.DestinationType.DATA_URL, TypeSource : Camera.PictureSourceType.CAMERA, allowEdit : encodingType vrai,: Camera.EncodingType.JPEG, targetWidth : 100, targetHeight : 100, popoverOptions : CameraPopoverOptions, saveToPhotoAlbum : false} ; + + + * **qualité**: qualité de l'image enregistrée, exprimée en une gamme de 0 à 100, 100 étant généralement pleine résolution sans perte de compression de fichiers. La valeur par défaut est 50. *(Nombre)* (Notez que les informations sur la résolution de la caméra sont indisponibles). + + * **destinationType**: choisissez le format de la valeur de retour. La valeur par défaut est FILE_URI. Définies dans `navigator.camera.DestinationType` *(nombre)* + + 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**: définissez la source de l'image. La valeur par défaut est la caméra. Définies dans `navigator.camera.PictureSourceType` *(nombre)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **allowEdit**: permettre un montage simple d'image avant la sélection. *(Booléen)* + + * **encodingType**: choisir le fichier image retournée de codage. Valeur par défaut est JPEG. Définies dans `navigator.camera.EncodingType` *(nombre)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **targetWidth**: largeur en pixels de l'image de l'échelle. Doit être utilisé avec **targetHeight**. Aspect ratio reste constant. *(Nombre)* + + * **targetHeight**: hauteur en pixels de l'image de l'échelle. Doit être utilisé avec **targetWidth**. Aspect ratio reste constant. *(Nombre)* + + * **mediaType**: définir le type de média pour choisir de. Ne fonctionne que quand `PictureSourceType` est `PHOTOLIBRARY` ou `SAVEDPHOTOALBUM` . Définies dans `nagivator.camera.MediaType` *(nombre)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. PAR DÉFAUT. 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**: faire pivoter l'image afin de corriger l'orientation de l'appareil lors de la capture. *(Booléen)* + + * **saveToPhotoAlbum**: enregistrer l'image sur l'album photo sur l'appareil après la capture. *(Booléen)* + + * **popoverOptions**: iOS uniquement des options qui spécifient l'emplacement de kangourou dans iPad. Défini dans`CameraPopoverOptions`. + + * **cameraDirection**: choisissez la caméra à utiliser (ou dos-face). La valeur par défaut est de retour. Définies dans `navigator.camera.Direction` *(nombre)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### Amazon Fire OS Quirks + + * Tout `cameraDirection` résultats dans le back-face photo de valeur. + + * Ignore la `allowEdit` paramètre. + + * `Camera.PictureSourceType.PHOTOLIBRARY`et `Camera.PictureSourceType.SAVEDPHOTOALBUM` les deux affichent le même album photo. + +#### Quirks Android + + * Tout `cameraDirection` résultats dans le back-face photo de valeur. + + * Android utilise également l'activité de récolte pour allowEdit, même si la récolte doit travailler et transmet en réalité l'image recadrée à Cordoue, le seul que les œuvres sont toujours celui livré avec l'application Google Plus Photos. Autres cultures peuvent ne pas fonctionner. + + * `Camera.PictureSourceType.PHOTOLIBRARY`et `Camera.PictureSourceType.SAVEDPHOTOALBUM` les deux affichent le même album photo. + +#### BlackBerry 10 Quirks + + * Ignore la `quality` paramètre. + + * Ignore la `allowEdit` paramètre. + + * `Camera.MediaType`n'est pas pris en charge. + + * Ignore la `correctOrientation` paramètre. + + * Ignore la `cameraDirection` paramètre. + +#### Firefox OS Quirks + + * Ignore la `quality` paramètre. + + * `Camera.DestinationType`est ignorée et est égal à `1` (URI du fichier image) + + * Ignore la `allowEdit` paramètre. + + * Ignore la `PictureSourceType` paramètre (utilisateur il choisit dans une fenêtre de dialogue) + + * Ignore le`encodingType` + + * Ignore la `targetWidth` et`targetHeight` + + * `Camera.MediaType`n'est pas pris en charge. + + * Ignore la `correctOrientation` paramètre. + + * Ignore la `cameraDirection` paramètre. + +#### Notes au sujet d'iOS + + * La valeur `quality` inférieur à 50 pour éviter les erreurs de mémoire sur certains appareils. + + * Lorsque vous utilisez `destinationType.FILE_URI` , les photos sont sauvegardées dans le répertoire temporaire de l'application. Le contenu du répertoire temporaire de l'application est supprimé lorsque l'application se termine. + +#### Bizarreries de paciarelli + + * options non prises en charge + + * retourne toujours un URI de fichier + +#### Notes au sujet de Windows Phone 7 et 8 + + * Ignore la `allowEdit` paramètre. + + * Ignore la `correctOrientation` paramètre. + + * Ignore la `cameraDirection` paramètre. + + * Ignore la `saveToPhotoAlbum` paramètre. IMPORTANT : Toutes les images prises avec la caméra de cordova wp7/8 API sont toujours copiés au rôle d'appareil photo du téléphone. Selon les paramètres de l'utilisateur, cela pourrait également signifier que l'image est auto-téléchargées à leur OneDrive. Potentiellement, cela pourrait signifier que l'image est disponible à un public plus large que votre application destinée. Si ce un bloqueur pour votre application, vous devrez implémenter le CameraCaptureTask tel que documenté sur msdn : vous pouvez aussi commenter ou haut-vote la question connexe dans le [gestionnaire d'incidents](https://issues.apache.org/jira/browse/CB-2083) + + * Ignore la `mediaType` propriété de `cameraOptions` comme le kit de développement Windows Phone ne fournit pas un moyen de choisir les vidéos de PHOTOLIBRARY. + +## CameraError + +fonction de rappel onError qui fournit un message d'erreur. + + function(message) {/ / afficher un message utile} + + +#### Description + + * **message**: le message est fourni par du code natif de l'appareil. *(String)* + +## cameraSuccess + +fonction de rappel onSuccess qui fournit les données d'image. + + function(ImageData) {/ / faire quelque chose avec l'image} + + +#### Description + + * **imageData**: codage Base64 de l'image, *ou* le fichier image URI, selon `cameraOptions` en vigueur. *(String)* + +#### Exemple + + Afficher image / / function cameraCallback(imageData) {var image = document.getElementById('myImage') ; + image.src = "données : image / jpeg ; base64," + imageData;} + + +## CameraPopoverHandle + +Un handle vers la boîte de dialogue de kangourou créé par`navigator.camera.getPicture`. + +#### Description + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### Plates-formes supportées + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Exemple + + var cameraPopoverHandle = navigator.camera.getPicture (onSuccess, onFail, {destinationType : Camera.DestinationType.FILE_URI, TypeSource : Camera.PictureSourceType.PHOTOLIBRARY, popoverOptions : nouvelle CameraPopoverOptions (300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)}) ; + + Repositionner le kangourou si l'orientation change. + Window.onorientationchange = function() {var cameraPopoverOptions = new CameraPopoverOptions (0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY) ; + cameraPopoverHandle.setPosition(cameraPopoverOptions) ; + } + + +## CameraPopoverOptions + +iOS uniquement les paramètres qui spécifient la direction ancre élément emplacement et de la flèche de la kangourou lors de la sélection des images de la bibliothèque de l'iPad ou l'album. + + {x: 0, y: 32, largeur : 320, hauteur : 480, arrowDir : Camera.PopoverArrowDirection.ARROW_ANY} ; + + +#### Description + + * **x**: coordonnée de pixel de l'élément de l'écran sur lequel ancrer le kangourou x. *(Nombre)* + + * **y**: coordonnée de y pixels de l'élément de l'écran sur lequel ancrer le kangourou. *(Nombre)* + + * **largeur**: largeur, en pixels, de l'élément de l'écran sur lequel ancrer le kangourou. *(Nombre)* + + * **hauteur**: hauteur, en pixels, de l'élément de l'écran sur lequel ancrer le kangourou. *(Nombre)* + + * **arrowDir**: Direction de la flèche sur le kangourou doit pointer. Définies dans `Camera.PopoverArrowDirection` *(nombre)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Notez que la taille de la kangourou peut changer pour s'adapter à la direction de la flèche et l'orientation de l'écran. Assurez-vous que tenir compte des changements d'orientation lors de la spécification de l'emplacement d'élément d'ancrage. + +## Navigator.Camera.Cleanup + +Supprime les intermédiaires photos prises par la caméra de stockage temporaire. + + Navigator.Camera.Cleanup (cameraSuccess, cameraError) ; + + +#### Description + +Supprime les intermédiaires les fichiers image qui sont gardées en dépôt temporaire après avoir appelé `camera.getPicture` . S'applique uniquement lorsque la valeur de `Camera.sourceType` est égale à `Camera.PictureSourceType.CAMERA` et le `Camera.destinationType` est égal à`Camera.DestinationType.FILE_URI`. + +#### Plates-formes supportées + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Exemple + + Navigator.Camera.Cleanup (onSuccess, onFail) ; + + fonction onSuccess() {console.log ("succès de caméra nettoyage.")} + + function onFail(message) {alert (' a échoué car: "+ message);} \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/fr/index.md b/plugins/cordova-plugin-camera/doc/fr/index.md new file mode 100644 index 0000000..ec005f0 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/fr/index.md @@ -0,0 +1,391 @@ + + +# cordova-plugin-camera + +Ce plugin définit un global `navigator.camera` objet qui fournit une API pour la prise de photos et de choisir des images de la bibliothèque d'images du système. + +Bien que l'objet est attaché à la portée globale `navigator` , il n'est pas disponible jusqu'après la `deviceready` événement. + + document.addEventListener (« deviceready », onDeviceReady, false) ; + function onDeviceReady() {console.log(navigator.camera);} + + +## Installation + + Cordova plugin ajouter cordova-plugin-camera + + +## navigator.camera.getPicture + +Prend une photo à l'aide de la caméra, ou récupère une photo de la Galerie d'images de l'appareil. L'image est passé au rappel succès comme un codage base64 `String` , ou comme l'URI du fichier de l'image. La méthode elle-même retourne un `CameraPopoverHandle` objet qui permet de repositionner le kangourou de sélection de fichier. + + navigator.camera.getPicture (cameraSuccess, cameraError, cameraOptions) ; + + +### Description + +Le `camera.getPicture` fonction ouvre l'application de caméra par défaut de l'appareil qui permet aux utilisateurs de prendre des photos. Ce comportement se produit par défaut, lorsque `Camera.sourceType` est égal à `Camera.PictureSourceType.CAMERA` . Une fois que l'utilisateur s'enclenche la photo, l'application appareil photo se ferme et l'application est restaurée. + +Si `Camera.sourceType` est `Camera.PictureSourceType.PHOTOLIBRARY` ou `Camera.PictureSourceType.SAVEDPHOTOALBUM` , puis un dialogue affiche qui permet aux utilisateurs de sélectionner une image existante. Le `camera.getPicture` retourne un `CameraPopoverHandle` objet, ce qui permet de repositionner le dialogue de sélection d'image, par exemple, lorsque l'orientation de l'appareil change. + +La valeur de retour est envoyée à la `cameraSuccess` la fonction de rappel, dans l'un des formats suivants, selon les `cameraOptions` : + +* A `String` contenant l'image photo codée en base64. + +* A `String` qui représente l'emplacement du fichier image sur le stockage local (par défaut). + +Vous pouvez faire ce que vous voulez avec l'image codée ou URI, par exemple : + +* Afficher l'image dans un `` tag, comme dans l'exemple ci-dessous + +* Enregistrer les données localement ( `LocalStorage` , [poids][1], etc..) + +* Publier les données sur un serveur distant + + [1]: http://brianleroux.github.com/lawnchair/ + +**NOTE**: la résolution de Photo sur les nouveaux appareils est assez bonne. Photos sélectionnées de la Galerie de l'appareil ne sont pas réduites à une baisse de la qualité, même si un `quality` paramètre est spécifié. Pour éviter les problèmes de mémoire commun, définissez `Camera.destinationType` à `FILE_URI` au lieu de`DATA_URL`. + +### Plates-formes prises en charge + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Navigateur +* Firefox OS +* iOS +* Paciarelli +* Windows Phone 7 et 8 +* Windows 8 + +### Préférences (iOS) + +* **CameraUsesGeolocation** (boolean, par défaut, false). Pour capturer des images JPEG, true pour obtenir des données de géolocalisation dans l'en-tête EXIF. Cela va déclencher une demande d'autorisations de géolocalisation si défini à true. + + + + +### Amazon Fire OS Quirks + +Amazon Fire OS utilise des intentions pour lancer l'activité de l'appareil photo sur l'appareil pour capturer des images et sur les téléphones avec peu de mémoire, l'activité de Cordova peut être tuée. Dans ce scénario, l'image peut ne pas apparaître lorsque l'activité de cordova est restaurée. + +### Quirks Android + +Android utilise des intentions pour lancer l'activité de l'appareil photo sur l'appareil pour capturer des images et sur les téléphones avec peu de mémoire, l'activité de Cordova peut être tuée. Dans ce scénario, l'image peut ne pas apparaître lorsque l'activité de Cordova est restaurée. + +### Bizarreries navigateur + +Peut retourner uniquement les photos comme image codée en base64. + +### Firefox OS Quirks + +Appareil photo plugin est actuellement mis en œuvre à l'aide [d'Activités sur le Web][2]. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### iOS Quirks + +Y compris un JavaScript `alert()` dans les deux le rappel fonctions peuvent causer des problèmes. Envelopper l'alerte dans un `setTimeout()` pour permettre le sélecteur d'image iOS ou kangourou pour fermer entièrement avant que l'alerte s'affiche : + + setTimeout(function() {/ / faire votre truc ici!}, 0) ; + + +### Windows Phone 7 Quirks + +Invoquant l'application native caméra alors que l'appareil est connecté via Zune ne fonctionne pas et déclenche un rappel de l'erreur. + +### Bizarreries de paciarelli + +Paciarelli prend uniquement en charge un `destinationType` de `Camera.DestinationType.FILE_URI` et un `sourceType` de`Camera.PictureSourceType.PHOTOLIBRARY`. + +### Exemple + +Prendre une photo, puis extrayez-la comme une image codée en base64 : + + navigator.camera.getPicture (onSuccess, onFail, { quality: 50, + destinationType: Camera.DestinationType.DATA_URL + }) ; + + function onSuccess(imageData) {var image = document.getElementById('myImage') ; + image.src = "données : image / jpeg ; base64," + imageData;} + + function onFail(message) {alert (' a échoué car: "+ message);} + + +Prendre une photo et récupérer l'emplacement du fichier de l'image : + + 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 (' a échoué car: "+ message);} + + +## CameraOptions + +Paramètres optionnels pour personnaliser les réglages de l'appareil. + + {qualité : destinationType 75,: Camera.DestinationType.DATA_URL, TypeSource : Camera.PictureSourceType.CAMERA, allowEdit : encodingType vrai,: Camera.EncodingType.JPEG, targetWidth : 100, targetHeight : 100, popoverOptions : CameraPopoverOptions, saveToPhotoAlbum : false} ; + + +### Options + +* **qualité**: qualité de l'image enregistrée, exprimée en une gamme de 0 à 100, 100 étant généralement pleine résolution sans perte de compression de fichiers. La valeur par défaut est 50. *(Nombre)* (Notez que les informations sur la résolution de la caméra sont indisponibles). + +* **destinationType**: choisissez le format de la valeur de retour. La valeur par défaut est FILE_URI. Définies dans `navigator.camera.DestinationType` *(nombre)* + + 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**: définissez la source de l'image. La valeur par défaut est la caméra. Définies dans `navigator.camera.PictureSourceType` *(nombre)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **allowEdit**: permettre un montage simple d'image avant la sélection. *(Booléen)* + +* **encodingType**: choisir le fichier image retournée de codage. Valeur par défaut est JPEG. Définies dans `navigator.camera.EncodingType` *(nombre)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **targetWidth**: largeur en pixels de l'image de l'échelle. Doit être utilisé avec **targetHeight**. Aspect ratio reste constant. *(Nombre)* + +* **targetHeight**: hauteur en pixels de l'image de l'échelle. Doit être utilisé avec **targetWidth**. Aspect ratio reste constant. *(Nombre)* + +* **mediaType**: définir le type de média pour choisir de. Ne fonctionne que quand `PictureSourceType` est `PHOTOLIBRARY` ou `SAVEDPHOTOALBUM` . Définies dans `nagivator.camera.MediaType` *(nombre)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. PAR DÉFAUT. 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**: faire pivoter l'image afin de corriger l'orientation de l'appareil lors de la capture. *(Booléen)* + +* **saveToPhotoAlbum**: enregistrer l'image sur l'album photo sur l'appareil après la capture. *(Booléen)* + +* **popoverOptions**: iOS uniquement des options qui spécifient l'emplacement de kangourou dans iPad. Défini dans`CameraPopoverOptions`. + +* **cameraDirection**: choisissez la caméra à utiliser (ou dos-face). La valeur par défaut est de retour. Définies dans `navigator.camera.Direction` *(nombre)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### Amazon Fire OS Quirks + +* Tout `cameraDirection` résultats dans le back-face photo de valeur. + +* Ignore la `allowEdit` paramètre. + +* `Camera.PictureSourceType.PHOTOLIBRARY`et `Camera.PictureSourceType.SAVEDPHOTOALBUM` les deux affichent le même album photo. + +### Quirks Android + +* Tout `cameraDirection` résultats dans le back-face photo de valeur. + +* Ignore la `allowEdit` paramètre. + +* `Camera.PictureSourceType.PHOTOLIBRARY`et `Camera.PictureSourceType.SAVEDPHOTOALBUM` les deux affichent le même album photo. + +### BlackBerry 10 Quirks + +* Ignore la `quality` paramètre. + +* Ignore la `allowEdit` paramètre. + +* `Camera.MediaType`n'est pas pris en charge. + +* Ignore la `correctOrientation` paramètre. + +* Ignore la `cameraDirection` paramètre. + +### Firefox OS Quirks + +* Ignore la `quality` paramètre. + +* `Camera.DestinationType`est ignorée et est égal à `1` (URI du fichier image) + +* Ignore la `allowEdit` paramètre. + +* Ignore la `PictureSourceType` paramètre (utilisateur il choisit dans une fenêtre de dialogue) + +* Ignore le`encodingType` + +* Ignore la `targetWidth` et`targetHeight` + +* `Camera.MediaType`n'est pas pris en charge. + +* Ignore la `correctOrientation` paramètre. + +* Ignore la `cameraDirection` paramètre. + +### iOS Quirks + +* La valeur `quality` inférieur à 50 pour éviter les erreurs de mémoire sur certains appareils. + +* Lorsque vous utilisez `destinationType.FILE_URI` , les photos sont sauvegardées dans le répertoire temporaire de l'application. Le contenu du répertoire temporaire de l'application est supprimé lorsque l'application se termine. + +### Bizarreries de paciarelli + +* options non prises en charge + +* retourne toujours un URI de fichier + +### Windows Phone 7 et 8 Quirks + +* Ignore la `allowEdit` paramètre. + +* Ignore la `correctOrientation` paramètre. + +* Ignore la `cameraDirection` paramètre. + +* Ignore la `saveToPhotoAlbum` paramètre. IMPORTANT : Toutes les images prises avec la caméra de cordova wp7/8 API sont toujours copiés au rôle d'appareil photo du téléphone. Selon les paramètres de l'utilisateur, cela pourrait également signifier que l'image est auto-téléchargées à leur OneDrive. Potentiellement, cela pourrait signifier que l'image est disponible à un public plus large que votre application destinée. Si ce un bloqueur pour votre application, vous devrez implémenter le CameraCaptureTask tel que documenté sur msdn : vous pouvez aussi commenter ou haut-vote la question connexe dans le [gestionnaire d'incidents][3] + +* Ignore la `mediaType` propriété de `cameraOptions` comme le kit de développement Windows Phone ne fournit pas un moyen de choisir les vidéos de PHOTOLIBRARY. + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +fonction de rappel onError qui fournit un message d'erreur. + + function(message) {/ / afficher un message utile} + + +### Paramètres + +* **message**: le message est fourni par du code natif de l'appareil. *(String)* + +## cameraSuccess + +fonction de rappel onSuccess qui fournit les données d'image. + + function(ImageData) {/ / faire quelque chose avec l'image} + + +### Paramètres + +* **imageData**: codage Base64 de l'image, *ou* le fichier image URI, selon `cameraOptions` en vigueur. *(String)* + +### Exemple + + Afficher image / / function cameraCallback(imageData) {var image = document.getElementById('myImage') ; + image.src = "données : image / jpeg ; base64," + imageData;} + + +## CameraPopoverHandle + +Un handle vers la boîte de dialogue de kangourou créé par`navigator.camera.getPicture`. + +### Méthodes + +* **setPosition**: définir la position de la kangourou. + +### Plates-formes prises en charge + +* iOS + +### setPosition + +Définir la position de la kangourou. + +**Paramètres**: + +* `cameraPopoverOptions`: la `CameraPopoverOptions` qui spécifie la nouvelle position + +### Exemple + + var cameraPopoverHandle = navigator.camera.getPicture (onSuccess, onFail, {destinationType : Camera.DestinationType.FILE_URI, TypeSource : Camera.PictureSourceType.PHOTOLIBRARY, popoverOptions : nouvelle CameraPopoverOptions (300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)}) ; + + Repositionner le kangourou si l'orientation change. + Window.onorientationchange = function() {var cameraPopoverOptions = new CameraPopoverOptions (0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY) ; + cameraPopoverHandle.setPosition(cameraPopoverOptions) ; + } + + +## CameraPopoverOptions + +iOS uniquement les paramètres qui spécifient la direction ancre élément emplacement et de la flèche de la kangourou lors de la sélection des images de la bibliothèque de l'iPad ou l'album. + + {x: 0, y: 32, largeur : 320, hauteur : 480, arrowDir : Camera.PopoverArrowDirection.ARROW_ANY} ; + + +### CameraPopoverOptions + +* **x**: coordonnée de pixel de l'élément de l'écran sur lequel ancrer le kangourou x. *(Nombre)* + +* **y**: coordonnée de y pixels de l'élément de l'écran sur lequel ancrer le kangourou. *(Nombre)* + +* **largeur**: largeur, en pixels, de l'élément de l'écran sur lequel ancrer le kangourou. *(Nombre)* + +* **hauteur**: hauteur, en pixels, de l'élément de l'écran sur lequel ancrer le kangourou. *(Nombre)* + +* **arrowDir**: Direction de la flèche sur le kangourou doit pointer. Définies dans `Camera.PopoverArrowDirection` *(nombre)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Notez que la taille de la kangourou peut changer pour s'adapter à la direction de la flèche et l'orientation de l'écran. Assurez-vous que tenir compte des changements d'orientation lors de la spécification de l'emplacement d'élément d'ancrage. + +## Navigator.Camera.Cleanup + +Supprime les intermédiaires photos prises par la caméra de stockage temporaire. + + Navigator.Camera.Cleanup (cameraSuccess, cameraError) ; + + +### Description + +Supprime les intermédiaires les fichiers image qui sont gardées en dépôt temporaire après avoir appelé `camera.getPicture` . S'applique uniquement lorsque la valeur de `Camera.sourceType` est égale à `Camera.PictureSourceType.CAMERA` et le `Camera.destinationType` est égal à`Camera.DestinationType.FILE_URI`. + +### Plates-formes prises en charge + +* iOS + +### Exemple + + Navigator.Camera.Cleanup (onSuccess, onFail) ; + + fonction onSuccess() {console.log ("succès de caméra nettoyage.")} + + function onFail(message) {alert (' a échoué car: "+ message);} diff --git a/plugins/cordova-plugin-camera/doc/img/android-fail.png b/plugins/cordova-plugin-camera/doc/img/android-fail.png new file mode 100644 index 0000000..f9e4e86 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/android-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/android-success.png b/plugins/cordova-plugin-camera/doc/img/android-success.png new file mode 100644 index 0000000..0bb9abd Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/android-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/blackberry-fail.png b/plugins/cordova-plugin-camera/doc/img/blackberry-fail.png new file mode 100644 index 0000000..b89efaf Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/blackberry-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/blackberry-success.png b/plugins/cordova-plugin-camera/doc/img/blackberry-success.png new file mode 100644 index 0000000..286d0b9 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/blackberry-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/browser-fail.png b/plugins/cordova-plugin-camera/doc/img/browser-fail.png new file mode 100644 index 0000000..3894be6 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/browser-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/browser-success.png b/plugins/cordova-plugin-camera/doc/img/browser-success.png new file mode 100644 index 0000000..6c2c000 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/browser-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/firefox-fail.png b/plugins/cordova-plugin-camera/doc/img/firefox-fail.png new file mode 100644 index 0000000..2c6cbd1 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/firefox-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/firefox-success.png b/plugins/cordova-plugin-camera/doc/img/firefox-success.png new file mode 100644 index 0000000..deb9d24 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/firefox-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/fireos-fail.png b/plugins/cordova-plugin-camera/doc/img/fireos-fail.png new file mode 100644 index 0000000..b1e7b9b Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/fireos-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/fireos-success.png b/plugins/cordova-plugin-camera/doc/img/fireos-success.png new file mode 100644 index 0000000..7b6289e Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/fireos-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/ios-fail.png b/plugins/cordova-plugin-camera/doc/img/ios-fail.png new file mode 100644 index 0000000..2d8caf8 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/ios-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/ios-success.png b/plugins/cordova-plugin-camera/doc/img/ios-success.png new file mode 100644 index 0000000..3bf3b5a Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/ios-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/ubuntu-fail.png b/plugins/cordova-plugin-camera/doc/img/ubuntu-fail.png new file mode 100644 index 0000000..ca82c79 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/ubuntu-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/ubuntu-success.png b/plugins/cordova-plugin-camera/doc/img/ubuntu-success.png new file mode 100644 index 0000000..b15227d Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/ubuntu-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/windows-fail.png b/plugins/cordova-plugin-camera/doc/img/windows-fail.png new file mode 100644 index 0000000..982a8cf Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/windows-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/windows-success.png b/plugins/cordova-plugin-camera/doc/img/windows-success.png new file mode 100644 index 0000000..b8ae79b Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/windows-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/wp8-fail.png b/plugins/cordova-plugin-camera/doc/img/wp8-fail.png new file mode 100644 index 0000000..28c4588 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/wp8-fail.png differ diff --git a/plugins/cordova-plugin-camera/doc/img/wp8-success.png b/plugins/cordova-plugin-camera/doc/img/wp8-success.png new file mode 100644 index 0000000..a37cad6 Binary files /dev/null and b/plugins/cordova-plugin-camera/doc/img/wp8-success.png differ diff --git a/plugins/cordova-plugin-camera/doc/it/README.md b/plugins/cordova-plugin-camera/doc/it/README.md new file mode 100644 index 0000000..601f6f1 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/it/README.md @@ -0,0 +1,421 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +Questo plugin definisce un oggetto globale `navigator.camera`, che fornisce un'API per scattare foto e per aver scelto immagini dalla libreria di immagini del sistema. + +Anche se l'oggetto è associato con ambito globale del `navigator`, non è disponibile fino a dopo l'evento `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## Installazione + + cordova plugin add cordova-plugin-camera + + +## API + + * Fotocamera + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * navigator.camera.cleanup + +## navigator.camera.getPicture + +Prende una foto utilizzando la fotocamera, o recupera una foto dalla galleria di immagini del dispositivo. L'immagine è passata al callback di successo come `String` con codifica base64, o come l'URI per il file di immagine. Lo stesso metodo restituisce un oggetto `CameraPopoverHandle` che può essere utilizzato per riposizionare il Muffin di selezione file. + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### Descrizione + +La funzione `camera.getPicture` apre predefinito fotocamera applicazione il dispositivo che consente agli utenti di scattare foto. Questo comportamento si verifica per impostazione predefinita, quando `Camera.sourceType` è uguale a `Camera.PictureSourceType.CAMERA`. Una volta che l'utente scatta la foto, si chiude l'applicazione fotocamera e l'applicazione viene ripristinato. + +Se `Camera.sourceType` è `Camera.PictureSourceType.PHOTOLIBRARY` o `Camera.PictureSourceType.SAVEDPHOTOALBUM`, una finestra di dialogo Visualizza che permette agli utenti di selezionare un'immagine esistente. La funzione `camera.getPicture` restituisce un oggetto `CameraPopoverHandle` che può essere utilizzato per riposizionare la finestra di selezione immagine, ad esempio, quando l'orientamento del dispositivo. + +Il valore restituito viene inviato alla funzione di callback `cameraSuccess`, in uno dei seguenti formati, a seconda il `cameraOptions` specificato: + + * A `String` contenente l'immagine della foto con codifica base64. + + * A `String` che rappresenta il percorso del file di immagine su archiviazione locale (predefinito). + +Si può fare quello che vuoi con l'immagine codificata o URI, ad esempio: + + * Il rendering dell'immagine in un `` tag, come nell'esempio qui sotto + + * Salvare i dati localmente ( `LocalStorage` , [Lawnchair](http://brianleroux.github.com/lawnchair/), ecc.) + + * Inviare i dati a un server remoto + +**Nota**: risoluzione foto sui più recenti dispositivi è abbastanza buona. Foto selezionate dalla galleria del dispositivo non è percepiranno di qualità inferiore, anche se viene specificato un parametro di `quality`. Per evitare problemi di memoria comune, impostare `Camera.destinationType` `FILE_URI` piuttosto che `DATA_URL`. + +#### Piattaforme supportate + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### Esempio + +Scattare una foto e recuperarla come un'immagine con codifica base64: + + 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); + } + + +Scattare una foto e recuperare il percorso del file dell'immagine: + + 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); + } + + +#### Preferenze (iOS) + + * **CameraUsesGeolocation** (boolean, default è false). Per l'acquisizione di immagini JPEG, impostato su true per ottenere dati di geolocalizzazione nell'intestazione EXIF. Questo innescherà una richiesta per le autorizzazioni di geolocalizzazione, se impostato su true. + + + + +#### Amazon fuoco OS stranezze + +Amazon fuoco OS utilizza intenti a lanciare l'attività della fotocamera sul dispositivo per catturare immagini e sui telefoni con poca memoria, l'attività di Cordova può essere ucciso. In questo scenario, l'immagine potrebbe non apparire quando viene ripristinata l'attività di cordova. + +#### Stranezze Android + +Android utilizza intenti a lanciare l'attività della fotocamera sul dispositivo per catturare immagini e sui telefoni con poca memoria, l'attività di Cordova può essere ucciso. In questo scenario, l'immagine potrebbe non apparire quando viene ripristinata l'attività di Cordova. + +#### Stranezze browser + +Può restituire solo la foto come immagine con codifica base64. + +#### Firefox OS stranezze + +Fotocamera plugin è attualmente implementato mediante [Web Activities](https://hacks.mozilla.org/2013/01/introducing-web-activities/). + +#### iOS stranezze + +Compreso un JavaScript `alert()` in una delle funzioni di callback può causare problemi. Avvolgere l'avviso all'interno di un `setTimeout()` per consentire la selezione immagine iOS o muffin per chiudere completamente la prima che viene visualizzato l'avviso: + + setTimeout(function() { + // do your thing here! + }, 0); + + +#### Windows Phone 7 capricci + +Richiamando l'applicazione nativa fotocamera mentre il dispositivo è collegato tramite Zune non funziona e innesca un callback di errore. + +#### Tizen stranezze + +Tizen supporta solo a `destinationType` di `Camera.DestinationType.FILE_URI` e un `sourceType` di `Camera.PictureSourceType.PHOTOLIBRARY`. + +## CameraOptions + +Parametri opzionali per personalizzare le impostazioni della fotocamera. + + { 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 }; + + + * **quality**: qualità dell'immagine salvata, espressa come un intervallo di 0-100, dove 100 è tipicamente piena risoluzione senza perdita di compressione file. Il valore predefinito è 50. *(Numero)* (Si noti che informazioni sulla risoluzione della fotocamera non sono disponibile). + + * **destinationType**: Scegli il formato del valore restituito. Il valore predefinito è FILE_URI. Definito in `navigator.camera.DestinationType` *(numero)* + + 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**: impostare l'origine dell'immagine. Il valore predefinito è la fotocamera. Definito in `navigator.camera.PictureSourceType` *(numero)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **Proprietà allowEdit**: consentire la semplice modifica dell'immagine prima di selezione. *(Booleano)* + + * **encodingType**: scegliere il file immagine restituita di codifica. Predefinito è JPEG. Definito in `navigator.camera.EncodingType` *(numero)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **targetWidth**: larghezza in pixel all'immagine della scala. Deve essere usato con **targetHeight**. Proporzioni rimane costante. *(Numero)* + + * **targetHeight**: altezza in pixel all'immagine della scala. Deve essere usato con **targetWidth**. Proporzioni rimane costante. *(Numero)* + + * **mediaType**: impostare il tipo di supporto per scegliere da. Funziona solo quando `PictureSourceType` è `PHOTOLIBRARY` o `SAVEDPHOTOALBUM` . Definito in `nagivator.camera.MediaType` *(numero)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. PER IMPOSTAZIONE PREDEFINITA. 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**: ruotare l'immagine per correggere l'orientamento del dispositivo durante l'acquisizione. *(Booleano)* + + * **saveToPhotoAlbum**: salvare l'immagine nell'album di foto sul dispositivo dopo la cattura. *(Booleano)* + + * **popoverOptions**: solo iOS opzioni che specificano la posizione di muffin in iPad. Definito in`CameraPopoverOptions`. + + * **cameraDirection**: scegliere la telecamera da utilizzare (o retro-frontale). Il valore predefinito è tornato. Definito in `navigator.camera.Direction` *(numero)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### Amazon fuoco OS stranezze + + * Qualsiasi `cameraDirection` valore i risultati in una foto di lamatura. + + * Ignora il `allowEdit` parametro. + + * `Camera.PictureSourceType.PHOTOLIBRARY`e `Camera.PictureSourceType.SAVEDPHOTOALBUM` entrambi visualizzare l'album fotografico stesso. + +#### Stranezze Android + + * Qualsiasi `cameraDirection` valore i risultati in una foto di lamatura. + + * Android utilizza anche l'attività di ritaglio per allowEdit, anche se raccolto dovrebbe funzionare ed effettivamente passare l'immagine ritagliata a Cordova, l'unico che funziona è sempre quello in bundle con l'applicazione di Google Plus foto. Altre colture potrebbero non funzionare. + + * `Camera.PictureSourceType.PHOTOLIBRARY`e `Camera.PictureSourceType.SAVEDPHOTOALBUM` entrambi visualizzare l'album fotografico stesso. + +#### BlackBerry 10 capricci + + * Ignora il `quality` parametro. + + * Ignora il `allowEdit` parametro. + + * `Camera.MediaType`non è supportato. + + * Ignora il `correctOrientation` parametro. + + * Ignora il `cameraDirection` parametro. + +#### Firefox OS stranezze + + * Ignora il `quality` parametro. + + * `Camera.DestinationType`viene ignorato e corrisponde a `1` (URI del file di immagine) + + * Ignora il `allowEdit` parametro. + + * Ignora il `PictureSourceType` parametro (utente ne sceglie in una finestra di dialogo) + + * Ignora il`encodingType` + + * Ignora le `targetWidth` e`targetHeight` + + * `Camera.MediaType`non è supportato. + + * Ignora il `correctOrientation` parametro. + + * Ignora il `cameraDirection` parametro. + +#### iOS stranezze + + * Impostare `quality` inferiore al 50 per evitare errori di memoria su alcuni dispositivi. + + * Quando si utilizza `destinationType.FILE_URI` , foto vengono salvati nella directory temporanea dell'applicazione. Il contenuto della directory temporanea dell'applicazione viene eliminato quando l'applicazione termina. + +#### Tizen stranezze + + * opzioni non supportate + + * restituisce sempre un URI del FILE + +#### Windows Phone 7 e 8 stranezze + + * Ignora il `allowEdit` parametro. + + * Ignora il `correctOrientation` parametro. + + * Ignora il `cameraDirection` parametro. + + * Ignora il `saveToPhotoAlbum` parametro. IMPORTANTE: Tutte le immagini scattate con la fotocamera di cordova wp7/8 API vengono sempre copiate rotolo fotocamera del telefono cellulare. A seconda delle impostazioni dell'utente, questo potrebbe anche significare che l'immagine viene caricato in automatico a loro OneDrive. Questo potenzialmente potrebbe significare che l'immagine è disponibile a un pubblico più ampio di app destinate. Se questo un blocco dell'applicazione, sarà necessario implementare il CameraCaptureTask come documentato su msdn: si può anche commentare o up-voto la questione correlata nel [tracciatore di problemi](https://issues.apache.org/jira/browse/CB-2083) + + * Ignora la `mediaType` proprietà di `cameraOptions` come il SDK di Windows Phone non fornisce un modo per scegliere il video da PHOTOLIBRARY. + +## CameraError + +funzione di callback onError che fornisce un messaggio di errore. + + function(message) { + // Show a helpful message + } + + +#### Descrizione + + * **message**: il messaggio è fornito dal codice nativo del dispositivo. *(String)* + +## cameraSuccess + +funzione di callback onSuccess che fornisce i dati di immagine. + + function(imageData) { + // Do something with the image + } + + +#### Descrizione + + * **imageData**: Base64 codifica dei dati immagine, *o* il file di immagine URI, a seconda `cameraOptions` in vigore. *(String)* + +#### Esempio + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Un handle per la finestra di dialogo di muffin creato da `navigator.camera.getPicture`. + +#### Descrizione + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### Piattaforme supportate + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Esempio + + 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 solo parametri che specificano l'ancoraggio elemento posizione e freccia direzione il Muffin quando si selezionano le immagini dalla libreria un iPad o un album. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +#### Descrizione + + * **x**: pixel coordinata x dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + + * **y**: coordinata y di pixel dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + + * **width**: larghezza, in pixel, dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + + * **height**: altezza, in pixel, dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + + * **arrowDir**: direzione dovrebbe puntare la freccia il muffin. Definito in `Camera.PopoverArrowDirection` *(numero)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Si noti che la dimensione del muffin possa cambiare per regolare la direzione della freccia e l'orientamento dello schermo. Assicurarsi che tenere conto di modifiche di orientamento quando si specifica la posizione di elemento di ancoraggio. + +## navigator.camera.cleanup + +Rimuove intermedio foto scattate con la fotocamera da deposito temporaneo. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +#### Descrizione + +Rimuove i file di immagine intermedia che vengono tenuti in custodia temporanea dopo la chiamata a `camera.getPicture`. Si applica solo quando il valore di `Camera.sourceType` è uguale a `Camera.PictureSourceType.CAMERA` e il `Camera.destinationType` è uguale a `Camera.DestinationType.FILE_URI`. + +#### Piattaforme supportate + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Esempio + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/it/index.md b/plugins/cordova-plugin-camera/doc/it/index.md new file mode 100644 index 0000000..da0b919 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/it/index.md @@ -0,0 +1,434 @@ + + +# cordova-plugin-camera + +Questo plugin definisce un oggetto globale `navigator.camera`, che fornisce un'API per scattare foto e per aver scelto immagini dalla libreria di immagini del sistema. + +Anche se l'oggetto è associato con ambito globale del `navigator`, non è disponibile fino a dopo l'evento `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## Installazione + + cordova plugin add cordova-plugin-camera + + +## navigator.camera.getPicture + +Prende una foto utilizzando la fotocamera, o recupera una foto dalla galleria di immagini del dispositivo. L'immagine è passata al callback di successo come `String` con codifica base64, o come l'URI per il file di immagine. Lo stesso metodo restituisce un oggetto `CameraPopoverHandle` che può essere utilizzato per riposizionare il Muffin di selezione file. + + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); + + +### Descrizione + +La funzione `camera.getPicture` apre predefinito fotocamera applicazione il dispositivo che consente agli utenti di scattare foto. Questo comportamento si verifica per impostazione predefinita, quando `Camera.sourceType` è uguale a `Camera.PictureSourceType.CAMERA`. Una volta che l'utente scatta la foto, si chiude l'applicazione fotocamera e l'applicazione viene ripristinato. + +Se `Camera.sourceType` è `Camera.PictureSourceType.PHOTOLIBRARY` o `Camera.PictureSourceType.SAVEDPHOTOALBUM`, una finestra di dialogo Visualizza che permette agli utenti di selezionare un'immagine esistente. La funzione `camera.getPicture` restituisce un oggetto `CameraPopoverHandle` che può essere utilizzato per riposizionare la finestra di selezione immagine, ad esempio, quando l'orientamento del dispositivo. + +Il valore restituito viene inviato alla funzione di callback `cameraSuccess`, in uno dei seguenti formati, a seconda il `cameraOptions` specificato: + +* A `String` contenente l'immagine della foto con codifica base64. + +* A `String` che rappresenta il percorso del file di immagine su archiviazione locale (predefinito). + +Si può fare quello che vuoi con l'immagine codificata o URI, ad esempio: + +* Il rendering dell'immagine in un `` tag, come nell'esempio qui sotto + +* Salvare i dati localmente ( `LocalStorage` , [Lawnchair][1], ecc.) + +* Inviare i dati a un server remoto + + [1]: http://brianleroux.github.com/lawnchair/ + +**Nota**: risoluzione foto sui più recenti dispositivi è abbastanza buona. Foto selezionate dalla galleria del dispositivo non è percepiranno di qualità inferiore, anche se viene specificato un parametro di `quality`. Per evitare problemi di memoria comune, impostare `Camera.destinationType` `FILE_URI` piuttosto che `DATA_URL`. + +### Piattaforme supportate + +* Amazon fuoco OS +* Android +* BlackBerry 10 +* Browser +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 e 8 +* Windows 8 + +### Preferenze (iOS) + +* **CameraUsesGeolocation** (boolean, default è false). Per l'acquisizione di immagini JPEG, impostato su true per ottenere dati di geolocalizzazione nell'intestazione EXIF. Questo innescherà una richiesta per le autorizzazioni di geolocalizzazione, se impostato su true. + + + + +### Amazon fuoco OS stranezze + +Amazon fuoco OS utilizza intenti a lanciare l'attività della fotocamera sul dispositivo per catturare immagini e sui telefoni con poca memoria, l'attività di Cordova può essere ucciso. In questo scenario, l'immagine potrebbe non apparire quando viene ripristinata l'attività di cordova. + +### Stranezze Android + +Android utilizza intenti a lanciare l'attività della fotocamera sul dispositivo per catturare immagini e sui telefoni con poca memoria, l'attività di Cordova può essere ucciso. In questo scenario, l'immagine potrebbe non apparire quando viene ripristinata l'attività di Cordova. + +### Stranezze browser + +Può restituire solo la foto come immagine con codifica base64. + +### Firefox OS stranezze + +Fotocamera plugin è attualmente implementato mediante [Web Activities][2]. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### iOS stranezze + +Compreso un JavaScript `alert()` in una delle funzioni di callback può causare problemi. Avvolgere l'avviso all'interno di un `setTimeout()` per consentire la selezione immagine iOS o muffin per chiudere completamente la prima che viene visualizzato l'avviso: + + setTimeout(function() { + // do your thing here! + }, 0); + + +### Windows Phone 7 stranezze + +Richiamando l'applicazione nativa fotocamera mentre il dispositivo è collegato tramite Zune non funziona e innesca un callback di errore. + +### Tizen stranezze + +Tizen supporta solo a `destinationType` di `Camera.DestinationType.FILE_URI` e un `sourceType` di `Camera.PictureSourceType.PHOTOLIBRARY`. + +### Esempio + +Scattare una foto e recuperarla come un'immagine con codifica base64: + + 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); + } + + +Scattare una foto e recuperare il percorso del file dell'immagine: + + 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 + +Parametri opzionali per personalizzare le impostazioni della fotocamera. + + { 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 }; + + +### Opzioni + +* **quality**: qualità dell'immagine salvata, espressa come un intervallo di 0-100, dove 100 è tipicamente piena risoluzione senza perdita di compressione file. Il valore predefinito è 50. *(Numero)* (Si noti che informazioni sulla risoluzione della fotocamera non sono disponibile). + +* **destinationType**: Scegli il formato del valore restituito. Il valore predefinito è FILE_URI. Definito in `navigator.camera.DestinationType` *(numero)* + + 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**: impostare l'origine dell'immagine. Il valore predefinito è la fotocamera. Definito in `navigator.camera.PictureSourceType` *(numero)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **Proprietà allowEdit**: consentire la semplice modifica dell'immagine prima di selezione. *(Booleano)* + +* **encodingType**: scegliere il file immagine restituita di codifica. Predefinito è JPEG. Definito in `navigator.camera.EncodingType` *(numero)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **targetWidth**: larghezza in pixel all'immagine della scala. Deve essere usato con **targetHeight**. Proporzioni rimane costante. *(Numero)* + +* **targetHeight**: altezza in pixel all'immagine della scala. Deve essere usato con **targetWidth**. Proporzioni rimane costante. *(Numero)* + +* **mediaType**: impostare il tipo di supporto per scegliere da. Funziona solo quando `PictureSourceType` è `PHOTOLIBRARY` o `SAVEDPHOTOALBUM` . Definito in `nagivator.camera.MediaType` *(numero)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. PER IMPOSTAZIONE PREDEFINITA. 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**: ruotare l'immagine per correggere l'orientamento del dispositivo durante l'acquisizione. *(Booleano)* + +* **saveToPhotoAlbum**: salvare l'immagine nell'album di foto sul dispositivo dopo la cattura. *(Booleano)* + +* **popoverOptions**: solo iOS opzioni che specificano la posizione di muffin in iPad. Definito in`CameraPopoverOptions`. + +* **cameraDirection**: scegliere la telecamera da utilizzare (o retro-frontale). Il valore predefinito è tornato. Definito in `navigator.camera.Direction` *(numero)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### Amazon fuoco OS stranezze + +* Qualsiasi `cameraDirection` valore i risultati in una foto di lamatura. + +* Ignora il `allowEdit` parametro. + +* `Camera.PictureSourceType.PHOTOLIBRARY`e `Camera.PictureSourceType.SAVEDPHOTOALBUM` entrambi visualizzare l'album fotografico stesso. + +### Stranezze Android + +* Qualsiasi `cameraDirection` valore i risultati in una foto di lamatura. + +* Ignora il `allowEdit` parametro. + +* `Camera.PictureSourceType.PHOTOLIBRARY`e `Camera.PictureSourceType.SAVEDPHOTOALBUM` entrambi visualizzare l'album fotografico stesso. + +### BlackBerry 10 capricci + +* Ignora il `quality` parametro. + +* Ignora il `allowEdit` parametro. + +* `Camera.MediaType`non è supportato. + +* Ignora il `correctOrientation` parametro. + +* Ignora il `cameraDirection` parametro. + +### Firefox OS stranezze + +* Ignora il `quality` parametro. + +* `Camera.DestinationType`viene ignorato e corrisponde a `1` (URI del file di immagine) + +* Ignora il `allowEdit` parametro. + +* Ignora il `PictureSourceType` parametro (utente ne sceglie in una finestra di dialogo) + +* Ignora il`encodingType` + +* Ignora le `targetWidth` e`targetHeight` + +* `Camera.MediaType`non è supportato. + +* Ignora il `correctOrientation` parametro. + +* Ignora il `cameraDirection` parametro. + +### iOS stranezze + +* Impostare `quality` inferiore al 50 per evitare errori di memoria su alcuni dispositivi. + +* Quando si utilizza `destinationType.FILE_URI` , foto vengono salvati nella directory temporanea dell'applicazione. Il contenuto della directory temporanea dell'applicazione viene eliminato quando l'applicazione termina. + +### Tizen stranezze + +* opzioni non supportate + +* restituisce sempre un URI del FILE + +### Windows Phone 7 e 8 stranezze + +* Ignora il `allowEdit` parametro. + +* Ignora il `correctOrientation` parametro. + +* Ignora il `cameraDirection` parametro. + +* Ignora il `saveToPhotoAlbum` parametro. IMPORTANTE: Tutte le immagini scattate con la fotocamera di cordova wp7/8 API vengono sempre copiate rotolo fotocamera del telefono cellulare. A seconda delle impostazioni dell'utente, questo potrebbe anche significare che l'immagine viene caricato in automatico a loro OneDrive. Questo potenzialmente potrebbe significare che l'immagine è disponibile a un pubblico più ampio di app destinate. Se questo un blocco dell'applicazione, sarà necessario implementare il CameraCaptureTask come documentato su msdn: si può anche commentare o up-voto la questione correlata nel [tracciatore di problemi][3] + +* Ignora la `mediaType` proprietà di `cameraOptions` come il SDK di Windows Phone non fornisce un modo per scegliere il video da PHOTOLIBRARY. + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +funzione di callback onError che fornisce un messaggio di errore. + + function(message) { + // Show a helpful message + } + + +### Parametri + +* **message**: il messaggio è fornito dal codice nativo del dispositivo. *(String)* + +## cameraSuccess + +funzione di callback onSuccess che fornisce i dati di immagine. + + function(imageData) { + // Do something with the image + } + + +### Parametri + +* **imageData**: Base64 codifica dei dati immagine, *o* il file di immagine URI, a seconda `cameraOptions` in vigore. *(String)* + +### Esempio + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Un handle per la finestra di dialogo di muffin creato da `navigator.camera.getPicture`. + +### Metodi + +* **setPosition**: impostare la posizione dei muffin. + +### Piattaforme supportate + +* iOS + +### setPosition + +Impostare la posizione dei muffin. + +**Parametri**: + +* `cameraPopoverOptions`: il `CameraPopoverOptions` che specificare la nuova posizione + +### Esempio + + 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 solo parametri che specificano l'ancoraggio elemento posizione e freccia direzione il Muffin quando si selezionano le immagini dalla libreria un iPad o un album. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +### CameraPopoverOptions + +* **x**: pixel coordinata x dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + +* **y**: coordinata y di pixel dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + +* **width**: larghezza, in pixel, dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + +* **height**: altezza, in pixel, dell'elemento dello schermo su cui ancorare il muffin. *(Numero)* + +* **arrowDir**: direzione dovrebbe puntare la freccia il muffin. Definito in `Camera.PopoverArrowDirection` *(numero)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Si noti che la dimensione del muffin possa cambiare per regolare la direzione della freccia e l'orientamento dello schermo. Assicurarsi che tenere conto di modifiche di orientamento quando si specifica la posizione di elemento di ancoraggio. + +## navigator.camera.cleanup + +Rimuove intermedio foto scattate con la fotocamera da deposito temporaneo. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +### Descrizione + +Rimuove i file di immagine intermedia che vengono tenuti in custodia temporanea dopo la chiamata a `camera.getPicture`. Si applica solo quando il valore di `Camera.sourceType` è uguale a `Camera.PictureSourceType.CAMERA` e il `Camera.destinationType` è uguale a `Camera.DestinationType.FILE_URI`. + +### Piattaforme supportate + +* iOS + +### Esempio + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } diff --git a/plugins/cordova-plugin-camera/doc/ja/README.md b/plugins/cordova-plugin-camera/doc/ja/README.md new file mode 100644 index 0000000..a50c185 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/ja/README.md @@ -0,0 +1,421 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +このプラグインは、写真を撮るため、システムのイメージ ライブラリからイメージを選択するために API を提供します、グローバル `navigator.camera` オブジェクトを定義します。 + +オブジェクトは、グローバル スコープの `ナビゲーター` に添付、それがないまで `deviceready` イベントの後。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## インストール + + cordova plugin add cordova-plugin-camera + + +## API + + * カメラ + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * navigator.camera.cleanup + +## navigator.camera.getPicture + +カメラを使用して写真を取るか、デバイスの画像ギャラリーから写真を取得します。 イメージが渡されます成功時のコールバックを base64 エンコードされた `文字列`、または、URI としてイメージ ファイル。 メソッド自体はファイル選択ポップ オーバーの位置を変更するために使用できる `CameraPopoverHandle` オブジェクトを返します。 + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### 解説 + +`camera.getPicture` 関数は、ユーザーの写真をスナップすることができますデバイスのデフォルト カメラ アプリケーションを開きます。 `Camera.sourceType` が `Camera.PictureSourceType.CAMERA` と等しい場合既定では、この現象が発生します。 ユーザーは写真をスナップ、カメラ アプリケーションを閉じるし、アプリケーションが復元されます。 + +`Camera.sourceType` `Camera.PictureSourceType.PHOTOLIBRARY` または `Camera.PictureSourceType.SAVEDPHOTOALBUM` の場合、ダイアログ ボックスはユーザーを既存のイメージを選択することができますが表示されます。 `camera.getPicture` 関数は、デバイスの向きが変更されたとき、たとえば、イメージの選択ダイアログには、位置を変更するために使用することができます、`CameraPopoverHandle` オブジェクトを返します。 + +戻り値が `cameraSuccess` コールバック関数の指定 `cameraOptions` に応じて、次の形式のいずれかに送信されます。 + + * A `String` 写真の base64 でエンコードされたイメージを含んでいます。 + + * A `String` (既定値) のローカル記憶域上のイメージ ファイルの場所を表します。 + +自由に変更、エンコードされたイメージ、または URI などを行うことができます。 + + * イメージをレンダリングする `` 以下の例のように、タグ + + * ローカル データの保存 ( `LocalStorage` 、 [Lawnchair](http://brianleroux.github.com/lawnchair/)など)。 + + * リモート サーバーにデータを投稿します。 + +**注**: 新しいデバイス上の写真の解像度はかなり良いです。 デバイスのギャラリーから選択した写真は `quality` パラメーターが指定されて場合でも下方の品質に縮小されません。 一般的なメモリの問題を避けるために `DATA_URL` ではなく `FILE_URI` に `Camera.destinationType` を設定します。. + +#### サポートされているプラットフォーム + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### 例 + +写真を撮るし、base64 エンコード イメージとして取得します。 + + 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); + } + + +写真を撮るし、イメージのファイルの場所を取得します。 + + 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); + } + + +#### 環境設定 (iOS) + + * **CameraUsesGeolocation**(ブール値、デフォルトは false)。 Jpeg 画像をキャプチャするため EXIF ヘッダーで地理位置情報データを取得する場合は true に設定します。 これは、場合地理位置情報のアクセス許可に対する要求をトリガーする true に設定します。 + + + + +#### アマゾン火 OS 癖 + +アマゾン火 OS イメージをキャプチャするデバイス上のカメラの活動を開始する意図を使用して、メモリの少ない携帯電話、コルドバ活動が殺されるかもしれない。 このシナリオではコルドバ活動が復元されると、イメージが表示されません。 + +#### Android の癖 + +アンドロイド、イメージをキャプチャするデバイス上でカメラのアクティビティを開始する意図を使用し、メモリの少ない携帯電話、コルドバ活動が殺されるかもしれない。 このシナリオではコルドバ活動が復元されると、イメージが表示されません。 + +#### ブラウザーの癖 + +Base64 エンコード イメージとして写真を返すのみことができます。 + +#### Firefox OS 癖 + +カメラのプラグインは現在、[Web アクティビティ](https://hacks.mozilla.org/2013/01/introducing-web-activities/) を使用して実装されていた. + +#### iOS の癖 + +コールバック関数のいずれかの JavaScript `alert()` を含む問題が発生することができます。 IOS イメージ ピッカーまたは完全が終了するまで、警告が表示されますポップ オーバーを許可する `setTimeout()` 内でアラートをラップします。 + + setTimeout(function() { + // do your thing here! + }, 0); + + +#### Windows Phone 7 の癖 + +ネイティブ カメラ アプリケーションを呼び出すと、デバイスが Zune を介して接続されている動作しませんし、エラー コールバックをトリガーします。 + +#### Tizen の癖 + +Tizen のみ `Camera.DestinationType.FILE_URI` の `destinationType` と `Camera.PictureSourceType.PHOTOLIBRARY` の `sourceType` をサポートしています. + +## CameraOptions + +カメラの設定をカスタマイズするオプションのパラメーター。 + + { 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 }; + + + * **quality**: 0-100、100 がファイルの圧縮から損失なしで通常のフル解像度の範囲で表される、保存されたイメージの品質。 既定値は 50 です。 *(数)*(カメラの解像度についての情報が利用できないことに注意してください)。 + + * **destinationType**: 戻り値の形式を選択します。既定値は FILE_URI です。定義されている `navigator.camera.DestinationType` *(番号)* + + 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**: 画像のソースを設定します。既定値は、カメラです。定義されている `navigator.camera.PictureSourceType` *(番号)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **allowEdit**: 単純な選択の前に画像の編集を許可します。*(ブール値)* + + * **encodingType**: 返されるイメージ ファイルのエンコーディングを選択します。デフォルトは JPEG です。定義されている `navigator.camera.EncodingType` *(番号)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **targetWidth**: スケール イメージにピクセル単位の幅。**TargetHeight**を使用する必要があります。縦横比は変わりません。*(数)* + + * **targetHeight**: スケール イメージにピクセル単位の高さ。**TargetWidth**を使用する必要があります。縦横比は変わりません。*(数)* + + * **mediaType**: から選択するメディアの種類を設定します。 場合にのみ働きます `PictureSourceType` は `PHOTOLIBRARY` または `SAVEDPHOTOALBUM` 。 定義されている `nagivator.camera.MediaType` *(番号)* + + 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**: キャプチャ中に、デバイスの向きを修正する画像を回転させます。*(ブール値)* + + * **saveToPhotoAlbum**: キャプチャ後、デバイス上のフォト アルバムに画像を保存します。*(ブール値)* + + * **popoverOptions**: iPad のポップ オーバーの場所を指定する iOS のみのオプションです。定義されています。`CameraPopoverOptions`. + + * **cameraDirection**: (前面または背面側) を使用するカメラを選択します。既定値は戻るです。定義されている `navigator.camera.Direction` *(番号)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### アマゾン火 OS 癖 + + * 任意 `cameraDirection` 背面写真で結果の値します。 + + * 無視、 `allowEdit` パラメーター。 + + * `Camera.PictureSourceType.PHOTOLIBRARY``Camera.PictureSourceType.SAVEDPHOTOALBUM`両方のアルバムが表示されます同じ写真。 + +#### Android の癖 + + * 任意 `cameraDirection` 背面写真で結果の値します。 + + * アンドロイドも使用しています作物活性、allowEdit もトリミングする必要があります動作し、実際にトリミングされた画像をコルドバで 1 つだけの作品一貫して Google プラス写真アプリケーションにバンドルされているものであることに渡します。 他の作物が機能しません。 + + * `Camera.PictureSourceType.PHOTOLIBRARY``Camera.PictureSourceType.SAVEDPHOTOALBUM`両方のアルバムが表示されます同じ写真。 + +#### ブラックベリー 10 癖 + + * 無視、 `quality` パラメーター。 + + * 無視、 `allowEdit` パラメーター。 + + * `Camera.MediaType`サポートされていません。 + + * 無視、 `correctOrientation` パラメーター。 + + * 無視、 `cameraDirection` パラメーター。 + +#### Firefox OS 癖 + + * 無視、 `quality` パラメーター。 + + * `Camera.DestinationType`無視され、等しい `1` (イメージ ファイル URI) + + * 無視、 `allowEdit` パラメーター。 + + * 無視、 `PictureSourceType` パラメーター (ユーザーが選択ダイアログ ウィンドウに) + + * 無視します、`encodingType` + + * 無視、 `targetWidth` と`targetHeight` + + * `Camera.MediaType`サポートされていません。 + + * 無視、 `correctOrientation` パラメーター。 + + * 無視、 `cameraDirection` パラメーター。 + +#### iOS の癖 + + * 設定 `quality` 一部のデバイスでメモリ不足エラーを避けるために 50 の下。 + + * 使用する場合 `destinationType.FILE_URI` 、写真、アプリケーションの一時ディレクトリに保存されます。アプリケーションの一時ディレクトリの内容は、アプリケーションの終了時に削除されます。 + +#### Tizen の癖 + + * サポートされていないオプション + + * 常にファイルの URI を返す + +#### Windows Phone 7 と 8 癖 + + * 無視、 `allowEdit` パラメーター。 + + * 無視、 `correctOrientation` パラメーター。 + + * 無視、 `cameraDirection` パラメーター。 + + * 無視、 `saveToPhotoAlbum` パラメーター。 重要: wp7/8 コルドバ カメラ API で撮影したすべての画像は携帯電話のカメラ巻き物に常にコピーします。 ユーザーの設定に応じて、これも、画像はその OneDrive に自動アップロードを意味できます。 イメージは意図したアプリより広い聴衆に利用できる可能性があります可能性があります。 場合は、このアプリケーションのブロッカー、msdn で説明されているように、CameraCaptureTask を実装する必要があります: コメントにすることがありますもかアップ投票関連の問題を[課題追跡システム](https://issues.apache.org/jira/browse/CB-2083)で + + * 無視、 `mediaType` のプロパティ `cameraOptions` として Windows Phone SDK には、フォト ライブラリからビデオを選択する方法は行いません。 + +## CameraError + +エラー メッセージを提供する onError コールバック関数。 + + function(message) { + // Show a helpful message + } + + +#### 解説 + + * **message**: メッセージは、デバイスのネイティブ コードによって提供されます。*(文字列)* + +## cameraSuccess + +画像データを提供する onSuccess コールバック関数。 + + function(imageData) { + // Do something with the image + } + + +#### 解説 + + * **imagedata を扱う**: Base64 エンコード イメージのデータ、*または*画像ファイルによって URI の `cameraOptions` 効果。*(文字列)* + +#### 例 + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +`Navigator.camera.getPicture` によって作成されたポップオーバーパン ダイアログ ボックスへのハンドル. + +#### 解説 + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### サポートされているプラットフォーム + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### 例 + + 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 だけ指定パラメーターをポップ オーバーのアンカー要素の場所および矢印方向計算されたライブラリまたはアルバムから画像を選択するとき。 + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +#### 解説 + + * **x**: ピクセルの x 座標画面要素にポップ オーバーのアンカーになります。*(数)* + + * **y**: y ピクセル座標の画面要素にポップ オーバーのアンカーになります。*(数)* + + * **width**: ポップ オーバーのアンカーになる上の画面要素のピクセル単位の幅。*(数)* + + * **height**: ポップ オーバーのアンカーになる上の画面要素のピクセル単位の高さ。*(数)* + + * **arrowDir**: 方向のポップ オーバーで矢印をポイントする必要があります。定義されている `Camera.PopoverArrowDirection` *(番号)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +矢印の方向と、画面の向きを調整するポップ オーバーのサイズを変更可能性がありますに注意してください。 アンカー要素の位置を指定するときの方向の変化を考慮することを確認します。 + +## navigator.camera.cleanup + +削除中間一時ストレージからカメラで撮影した写真。 + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +#### 解説 + +`camera.getPicture` を呼び出した後一時記憶域に保存されている中間画像ファイルを削除します。 `Camera.sourceType` の値が `Camera.PictureSourceType.CAMERA` に等しい、`Camera.destinationType` が `Camera.DestinationType.FILE_URI` と等しいの場合にのみ適用されます。. + +#### サポートされているプラットフォーム + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### 例 + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/ja/index.md b/plugins/cordova-plugin-camera/doc/ja/index.md new file mode 100644 index 0000000..5bdb3e1 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/ja/index.md @@ -0,0 +1,434 @@ + + +# cordova-plugin-camera + +このプラグインは、写真を撮るため、システムのイメージ ライブラリからイメージを選択するために API を提供します、グローバル `navigator.camera` オブジェクトを定義します。 + +オブジェクトは、グローバル スコープの `ナビゲーター` に添付、それがないまで `deviceready` イベントの後。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## インストール + + cordova plugin add cordova-plugin-camera + + +## navigator.camera.getPicture + +カメラを使用して写真を取るか、デバイスの画像ギャラリーから写真を取得します。 イメージが渡されます成功時のコールバックを base64 エンコードされた `文字列`、または、URI としてイメージ ファイル。 メソッド自体はファイル選択ポップ オーバーの位置を変更するために使用できる `CameraPopoverHandle` オブジェクトを返します。 + + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); + + +### 解説 + +`camera.getPicture` 関数は、ユーザーの写真をスナップすることができますデバイスのデフォルト カメラ アプリケーションを開きます。 `Camera.sourceType` が `Camera.PictureSourceType.CAMERA` と等しい場合既定では、この現象が発生します。 ユーザーは写真をスナップ、カメラ アプリケーションを閉じるし、アプリケーションが復元されます。 + +`Camera.sourceType` `Camera.PictureSourceType.PHOTOLIBRARY` または `Camera.PictureSourceType.SAVEDPHOTOALBUM` の場合、ダイアログ ボックスはユーザーを既存のイメージを選択することができますが表示されます。 `camera.getPicture` 関数は、デバイスの向きが変更されたとき、たとえば、イメージの選択ダイアログには、位置を変更するために使用することができます、`CameraPopoverHandle` オブジェクトを返します。 + +戻り値が `cameraSuccess` コールバック関数の指定 `cameraOptions` に応じて、次の形式のいずれかに送信されます。 + +* A `String` 写真の base64 でエンコードされたイメージを含んでいます。 + +* A `String` (既定値) のローカル記憶域上のイメージ ファイルの場所を表します。 + +自由に変更、エンコードされたイメージ、または URI などを行うことができます。 + +* イメージをレンダリングする `` 以下の例のように、タグ + +* ローカル データの保存 ( `LocalStorage` 、 [Lawnchair][1]など)。 + +* リモート サーバーにデータを投稿します。 + + [1]: http://brianleroux.github.com/lawnchair/ + +**注**: 新しいデバイス上の写真の解像度はかなり良いです。 デバイスのギャラリーから選択した写真は `quality` パラメーターが指定されて場合でも下方の品質に縮小されません。 一般的なメモリの問題を避けるために `DATA_URL` ではなく `FILE_URI` に `Camera.destinationType` を設定します。. + +### サポートされているプラットフォーム + +* アマゾン火 OS +* アンドロイド +* ブラックベリー 10 +* ブラウザー +* Firefox の OS +* iOS +* Tizen +* Windows Phone 7 と 8 +* Windows 8 + +### 環境設定 (iOS) + +* **CameraUsesGeolocation**(ブール値、デフォルトは false)。 Jpeg 画像をキャプチャするため EXIF ヘッダーで地理位置情報データを取得する場合は true に設定します。 これは、場合地理位置情報のアクセス許可に対する要求をトリガーする true に設定します。 + + + + +### アマゾン火 OS 癖 + +アマゾン火 OS イメージをキャプチャするデバイス上のカメラの活動を開始する意図を使用して、メモリの少ない携帯電話、コルドバ活動が殺されるかもしれない。 このシナリオではコルドバ活動が復元されると、イメージが表示されません。 + +### Android の癖 + +アンドロイド、イメージをキャプチャするデバイス上でカメラのアクティビティを開始する意図を使用し、メモリの少ない携帯電話、コルドバ活動が殺されるかもしれない。 このシナリオではコルドバ活動が復元されると、イメージが表示されません。 + +### ブラウザーの癖 + +Base64 エンコード イメージとして写真を返すのみことができます。 + +### Firefox OS 癖 + +カメラのプラグインは現在、[Web アクティビティ][2] を使用して実装されていた. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### iOS の癖 + +コールバック関数のいずれかの JavaScript `alert()` を含む問題が発生することができます。 IOS イメージ ピッカーまたは完全が終了するまで、警告が表示されますポップ オーバーを許可する `setTimeout()` 内でアラートをラップします。 + + setTimeout(function() { + // do your thing here! + }, 0); + + +### Windows Phone 7 の癖 + +ネイティブ カメラ アプリケーションを呼び出すと、デバイスが Zune を介して接続されている動作しませんし、エラー コールバックをトリガーします。 + +### Tizen の癖 + +Tizen のみ `Camera.DestinationType.FILE_URI` の `destinationType` と `Camera.PictureSourceType.PHOTOLIBRARY` の `sourceType` をサポートしています. + +### 例 + +写真を撮るし、base64 エンコード イメージとして取得します。 + + 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); + } + + +写真を撮るし、イメージのファイルの場所を取得します。 + + 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 + +カメラの設定をカスタマイズするオプションのパラメーター。 + + { 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 }; + + +### オプション + +* **quality**: 0-100、100 がファイルの圧縮から損失なしで通常のフル解像度の範囲で表される、保存されたイメージの品質。 既定値は 50 です。 *(数)*(カメラの解像度についての情報が利用できないことに注意してください)。 + +* **destinationType**: 戻り値の形式を選択します。既定値は FILE_URI です。定義されている `navigator.camera.DestinationType` *(番号)* + + 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**: 画像のソースを設定します。既定値は、カメラです。定義されている `navigator.camera.PictureSourceType` *(番号)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **allowEdit**: 単純な選択の前に画像の編集を許可します。*(ブール値)* + +* **encodingType**: 返されるイメージ ファイルのエンコーディングを選択します。デフォルトは JPEG です。定義されている `navigator.camera.EncodingType` *(番号)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **targetWidth**: スケール イメージにピクセル単位の幅。**TargetHeight**を使用する必要があります。縦横比は変わりません。*(数)* + +* **targetHeight**: スケール イメージにピクセル単位の高さ。**TargetWidth**を使用する必要があります。縦横比は変わりません。*(数)* + +* **mediaType**: から選択するメディアの種類を設定します。 場合にのみ働きます `PictureSourceType` は `PHOTOLIBRARY` または `SAVEDPHOTOALBUM` 。 定義されている `nagivator.camera.MediaType` *(番号)* + + 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**: キャプチャ中に、デバイスの向きを修正する画像を回転させます。*(ブール値)* + +* **saveToPhotoAlbum**: キャプチャ後、デバイス上のフォト アルバムに画像を保存します。*(ブール値)* + +* **popoverOptions**: iPad のポップ オーバーの場所を指定する iOS のみのオプションです。定義されています。`CameraPopoverOptions`. + +* **cameraDirection**: (前面または背面側) を使用するカメラを選択します。既定値は戻るです。定義されている `navigator.camera.Direction` *(番号)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### アマゾン火 OS 癖 + +* 任意 `cameraDirection` 背面写真で結果の値します。 + +* 無視、 `allowEdit` パラメーター。 + +* `Camera.PictureSourceType.PHOTOLIBRARY``Camera.PictureSourceType.SAVEDPHOTOALBUM`両方のアルバムが表示されます同じ写真。 + +### Android の癖 + +* 任意 `cameraDirection` 背面写真で結果の値します。 + +* 無視、 `allowEdit` パラメーター。 + +* `Camera.PictureSourceType.PHOTOLIBRARY``Camera.PictureSourceType.SAVEDPHOTOALBUM`両方のアルバムが表示されます同じ写真。 + +### ブラックベリー 10 癖 + +* 無視、 `quality` パラメーター。 + +* 無視、 `allowEdit` パラメーター。 + +* `Camera.MediaType`サポートされていません。 + +* 無視、 `correctOrientation` パラメーター。 + +* 無視、 `cameraDirection` パラメーター。 + +### Firefox OS 癖 + +* 無視、 `quality` パラメーター。 + +* `Camera.DestinationType`無視され、等しい `1` (イメージ ファイル URI) + +* 無視、 `allowEdit` パラメーター。 + +* 無視、 `PictureSourceType` パラメーター (ユーザーが選択ダイアログ ウィンドウに) + +* 無視します、`encodingType` + +* 無視、 `targetWidth` と`targetHeight` + +* `Camera.MediaType`サポートされていません。 + +* 無視、 `correctOrientation` パラメーター。 + +* 無視、 `cameraDirection` パラメーター。 + +### iOS の癖 + +* 設定 `quality` 一部のデバイスでメモリ不足エラーを避けるために 50 の下。 + +* 使用する場合 `destinationType.FILE_URI` 、写真、アプリケーションの一時ディレクトリに保存されます。アプリケーションの一時ディレクトリの内容は、アプリケーションの終了時に削除されます。 + +### Tizen の癖 + +* サポートされていないオプション + +* 常にファイルの URI を返す + +### Windows Phone 7 と 8 癖 + +* 無視、 `allowEdit` パラメーター。 + +* 無視、 `correctOrientation` パラメーター。 + +* 無視、 `cameraDirection` パラメーター。 + +* 無視、 `saveToPhotoAlbum` パラメーター。 重要: wp7/8 コルドバ カメラ API で撮影したすべての画像は携帯電話のカメラ巻き物に常にコピーします。 ユーザーの設定に応じて、これも、画像はその OneDrive に自動アップロードを意味できます。 イメージは意図したアプリより広い聴衆に利用できる可能性があります可能性があります。 場合は、このアプリケーションのブロッカー、msdn で説明されているように、CameraCaptureTask を実装する必要があります: コメントにすることがありますもかアップ投票関連の問題を[課題追跡システム][3]で + +* 無視、 `mediaType` のプロパティ `cameraOptions` として Windows Phone SDK には、フォト ライブラリからビデオを選択する方法は行いません。 + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +エラー メッセージを提供する onError コールバック関数。 + + function(message) { + // Show a helpful message + } + + +### パラメーター + +* **message**: メッセージは、デバイスのネイティブ コードによって提供されます。*(文字列)* + +## cameraSuccess + +画像データを提供する onSuccess コールバック関数。 + + function(imageData) { + // Do something with the image + } + + +### パラメーター + +* **imagedata を扱う**: Base64 エンコード イメージのデータ、*または*画像ファイルによって URI の `cameraOptions` 効果。*(文字列)* + +### 例 + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +`Navigator.camera.getPicture` によって作成されたポップオーバーパン ダイアログ ボックスへのハンドル. + +### メソッド + +* **setPosition**: ポップ オーバーの位置を設定します。 + +### サポートされているプラットフォーム + +* iOS + +### setPosition + +ポップ オーバーの位置を設定します。 + +**パラメーター**: + +* `cameraPopoverOptions`:、 `CameraPopoverOptions` の新しい位置を指定します。 + +### 例 + + 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 だけ指定パラメーターをポップ オーバーのアンカー要素の場所および矢印方向計算されたライブラリまたはアルバムから画像を選択するとき。 + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +### CameraPopoverOptions + +* **x**: ピクセルの x 座標画面要素にポップ オーバーのアンカーになります。*(数)* + +* **y**: y ピクセル座標の画面要素にポップ オーバーのアンカーになります。*(数)* + +* **width**: ポップ オーバーのアンカーになる上の画面要素のピクセル単位の幅。*(数)* + +* **height**: ポップ オーバーのアンカーになる上の画面要素のピクセル単位の高さ。*(数)* + +* **arrowDir**: 方向のポップ オーバーで矢印をポイントする必要があります。定義されている `Camera.PopoverArrowDirection` *(番号)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +矢印の方向と、画面の向きを調整するポップ オーバーのサイズを変更可能性がありますに注意してください。 アンカー要素の位置を指定するときの方向の変化を考慮することを確認します。 + +## navigator.camera.cleanup + +削除中間一時ストレージからカメラで撮影した写真。 + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +### 説明 + +`camera.getPicture` を呼び出した後一時記憶域に保存されている中間画像ファイルを削除します。 `Camera.sourceType` の値が `Camera.PictureSourceType.CAMERA` に等しい、`Camera.destinationType` が `Camera.DestinationType.FILE_URI` と等しいの場合にのみ適用されます。. + +### サポートされているプラットフォーム + +* iOS + +### 例 + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } diff --git a/plugins/cordova-plugin-camera/doc/ko/README.md b/plugins/cordova-plugin-camera/doc/ko/README.md new file mode 100644 index 0000000..7b7c215 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/ko/README.md @@ -0,0 +1,421 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +이 플러그인 시스템의 이미지 라이브러리에서 이미지를 선택 및 사진 촬영을 위한 API를 제공 하는 글로벌 `navigator.camera` 개체를 정의 합니다. + +개체 `navigator` 글로벌 범위 첨부 아니에요 때까지 사용할 수 있는 `deviceready` 이벤트 후. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## 설치 + + cordova plugin add cordova-plugin-camera + + +## API + + * 카메라 + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * navigator.camera.cleanup + +## navigator.camera.getPicture + +카메라를 사용 하 여 사진을 걸립니다 또는 소자의 이미지 갤러리에서 사진을 검색 합니다. 이미지는 성공 콜백에 전달 base64 인코딩된 `문자열` 또는 URI로 이미지 파일에 대 한. 방법 자체는 파일 선택 popover 위치를 사용할 수 있는 `CameraPopoverHandle` 개체를 반환 합니다. + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### 설명 + +`Camera.getPicture` 함수 스냅 사진을 사용자가 소자의 기본 카메라 응용 프로그램을 엽니다. 이 문제는 `Camera.sourceType` `Camera.PictureSourceType.CAMERA` 경우 기본적으로 발생 합니다. 일단 사용자 스냅 사진, 카메라 응용 프로그램 종료 하 고 응용 프로그램 복원 됩니다. + +`Camera.sourceType`은 `Camera.PictureSourceType.PHOTOLIBRARY` 또는 `Camera.PictureSourceType.SAVEDPHOTOALBUM`, 대화 상자가 사용자가 기존 이미지를 선택할 수 있도록 표시 됩니다. `camera.getPicture` 함수는 장치 방향 변경 될 때 이미지 선택 대화 상자, 예를 들어, 위치를 변경 하려면 사용할 수 있는 `CameraPopoverHandle` 개체를 반환 합니다. + +반환 값은 `cameraSuccess` 콜백 함수 지정된 `cameraOptions`에 따라 다음 형식 중 하나에 전송 됩니다. + + * A `String` base64 인코딩된 사진 이미지를 포함 합니다. + + * A `String` 로컬 저장소 (기본값)의 이미지 파일 위치를 나타내는. + +할 수 있는 당신이 원하는대로 인코딩된 이미지 또는 URI, 예를 들면: + + * 렌더링 이미지는 `` 아래 예제와 같이 태그 + + * 로컬로 데이터를 저장 ( `LocalStorage` , [Lawnchair](http://brianleroux.github.com/lawnchair/), 등.) + + * 원격 서버에 데이터 게시 + +**참고**: 더 새로운 장치에 사진 해상도 아주 좋은. 소자의 갤러리에서 선택 된 사진 `품질` 매개 변수를 지정 하는 경우에 낮은 품질에 관하여 하지는. 일반적인 메모리 문제를 피하기 위해 `DATA_URL` 보다 `FILE_URI` `Camera.destinationType` 설정. + +#### 지원 되는 플랫폼 + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### 예를 들어 + +촬영 및 base64 인코딩 이미지로 검색: + + 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); + } + + +촬영 하 고 이미지의 파일 위치를 검색: + + 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); + } + + +#### 환경 설정 (iOS) + + * **CameraUsesGeolocation** (boolean, 기본값: false)입니다. 캡처 Jpeg, EXIF 헤더에 지리적 데이터를 true로 설정 합니다. 이 경우 위치 정보 사용 권한에 대 한 요청을 일으킬 것 이다 true로 설정 합니다. + + + + +#### 아마존 화재 OS 단점 + +아마존 화재 OS 의도 사용 하 여 이미지 캡처 장치에서 카메라 활동을 시작 하 고 낮은 메모리와 휴대 전화에 코르 도우 바 활동 살해 수 있습니다. 코르도바 활동 복원 되 면이 시나리오에서는 이미지가 나타나지 않을 수 있습니다. + +#### 안 드 로이드 단점 + +안 드 로이드 의도 사용 하 여 이미지 캡처 장치에서 카메라 활동을 시작 하 고 낮은 메모리와 휴대 전화에 코르 도우 바 활동 살해 수 있습니다. 코르도바 활동 복원 되 면이 시나리오에서는 이미지가 나타나지 않을 수 있습니다. + +#### 브라우저 만지면 + +수 base64 인코딩 이미지로 사진을 반환 합니다. + +#### 파이어 폭스 OS 단점 + +카메라 플러그인은 현재 [웹 활동](https://hacks.mozilla.org/2013/01/introducing-web-activities/)를 사용 하 여 구현. + +#### iOS 단점 + +자바 `alert()`를 포함 하 여 콜백 함수 중 하나에 문제가 발생할 수 있습니다. 포장 허용 iOS 이미지 피커 또는 popover를 완벽 하 게 경고를 표시 하기 전에 닫습니다 `setTimeout()` 내에서 경고: + + setTimeout(function() { + // do your thing here! + }, 0); + + +#### Windows Phone 7 단점 + +장치 Zune 통해 연결 된 동안 네이티브 카메라 응용 프로그램을 호출 하면 작동 하지 않습니다 하 고 오류 콜백 트리거합니다. + +#### Tizen 특수 + +`Camera.DestinationType.FILE_URI`의 `destinationType`와 `Camera.PictureSourceType.PHOTOLIBRARY`의 `sourceType` Tizen 지원. + +## CameraOptions + +카메라 설정을 사용자 지정 하는 선택적 매개 변수. + + { 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 }; + + + * **품질**: 범위 0-100, 100은 파일 압축에서 손실 없이 일반적으로 전체 해상도 저장된 된 이미지의 품질. 기본값은 50입니다. *(수)* (Note 카메라의 해상도 대 한 정보는 사용할 수 없습니다.) + + * **destinationType**: 반환 값의 형식을 선택 합니다. 기본값은 FILE_URI입니다. 에 정의 된 `navigator.camera.DestinationType` *(수)* + + 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**: 그림의 소스를 설정 합니다. 기본값은 카메라입니다. 에 정의 된 `navigator.camera.PictureSourceType` *(수)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **allowEdit**: 선택 하기 전에 이미지의 간단한 편집을 허용 합니다. *(부울)* + + * **encodingType**: 반환 된 이미지 파일의 인코딩을 선택 합니다. 기본값은 JPEG입니다. 에 정의 된 `navigator.camera.EncodingType` *(수)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **targetWidth**: 스케일 이미지를 픽셀 너비. **TargetHeight**와 함께 사용 해야 합니다. 가로 세로 비율이 일정 하 게 유지 합니다. *(수)* + + * **targetHeight**: 스케일 이미지를 픽셀 단위로 높이. **TargetWidth**와 함께 사용 해야 합니다. 가로 세로 비율이 일정 하 게 유지 합니다. *(수)* + + * **mediaType**:에서 선택 미디어 유형을 설정 합니다. 때에 작동 `PictureSourceType` 는 `PHOTOLIBRARY` 또는 `SAVEDPHOTOALBUM` . 에 정의 된 `nagivator.camera.MediaType` *(수)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. 기본입니다. 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**: 캡처 도중 장치의 방향에 대 한 해결 하기 위해 이미지를 회전 합니다. *(부울)* + + * **saveToPhotoAlbum**: 캡처 후 장치에서 사진 앨범에 이미지를 저장 합니다. *(부울)* + + * **popoverOptions**: iPad에 popover 위치를 지정 하는 iOS 전용 옵션. 에 정의 된`CameraPopoverOptions`. + + * **cameraDirection**: (앞 이나 뒤로-연결)를 사용 하 여 카메라를 선택 하십시오. 기본값은 다시. 에 정의 된 `navigator.camera.Direction` *(수)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### 아마존 화재 OS 단점 + + * 어떤 `cameraDirection` 다시 연결 사진에 결과 값. + + * 무시는 `allowEdit` 매개 변수. + + * `Camera.PictureSourceType.PHOTOLIBRARY`그리고 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 둘 다 동일한 사진 앨범을 표시 합니다. + +#### 안 드 로이드 단점 + + * 어떤 `cameraDirection` 다시 연결 사진에 결과 값. + + * 안 드 로이드도 사용 자르기 활동 allowEdit, 비록 작물 작업과 실제로 코르도바, 유일 하 게 작품 지속적으로 구글 플러스 사진 응용 프로그램과 함께 번들로 제공 하는 것은 등을 맞댄 자른된 이미지를 전달 해야 합니다. 다른 작물은 작동 하지 않을 수 있습니다. + + * `Camera.PictureSourceType.PHOTOLIBRARY`그리고 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 둘 다 동일한 사진 앨범을 표시 합니다. + +#### 블랙베리 10 단점 + + * 무시는 `quality` 매개 변수. + + * 무시는 `allowEdit` 매개 변수. + + * `Camera.MediaType`지원 되지 않습니다. + + * 무시는 `correctOrientation` 매개 변수. + + * 무시는 `cameraDirection` 매개 변수. + +#### 파이어 폭스 OS 단점 + + * 무시는 `quality` 매개 변수. + + * `Camera.DestinationType`무시 되 고 `1` (이미지 파일 URI) + + * 무시는 `allowEdit` 매개 변수. + + * 무시는 `PictureSourceType` 매개 변수 (사용자가 선택 그것 대화 창에서) + + * 무시 하는`encodingType` + + * 무시는 `targetWidth` 와`targetHeight` + + * `Camera.MediaType`지원 되지 않습니다. + + * 무시는 `correctOrientation` 매개 변수. + + * 무시는 `cameraDirection` 매개 변수. + +#### iOS 단점 + + * 설정 `quality` 일부 장치 메모리 오류를 피하기 위해 50 아래. + + * 사용 하는 경우 `destinationType.FILE_URI` , 사진 응용 프로그램의 임시 디렉터리에 저장 됩니다. 응용 프로그램이 종료 될 때 응용 프로그램의 임시 디렉터리의 내용은 삭제 됩니다. + +#### Tizen 특수 + + * 지원 되지 않는 옵션 + + * 항상 파일 URI를 반환 합니다. + +#### Windows Phone 7, 8 특수 + + * 무시는 `allowEdit` 매개 변수. + + * 무시는 `correctOrientation` 매개 변수. + + * 무시는 `cameraDirection` 매개 변수. + + * 무시는 `saveToPhotoAlbum` 매개 변수. 중요: 모든 이미지 API wp7/8 코르도바 카메라로 촬영 항상 복사 됩니다 휴대 전화의 카메라 롤에. 사용자의 설정에 따라이 또한 그들의 OneDrive에 자동 업로드 이미지는 의미. 이 잠재적으로 이미지는 당신의 애플 리 케이 션을 위한 보다 넓은 청중에 게 사용할 수 있는 의미. 이 경우 응용 프로그램에 대 한 차단, 당신은 msdn에 설명 대로 단말기를 구현 해야 합니다: 수 있습니다 또한 의견 또는 [이슈 트래커](https://issues.apache.org/jira/browse/CB-2083) 에서 업-투표 관련된 문제 + + * 무시는 `mediaType` 속성을 `cameraOptions` 으로 Windows Phone SDK PHOTOLIBRARY에서 비디오를 선택 하는 방법을 제공 하지 않습니다. + +## CameraError + +오류 메시지를 제공 하는 onError 콜백 함수. + + function(message) { + // Show a helpful message + } + + +#### 설명 + + * **메시지**: 메시지는 장치의 네이티브 코드에 의해 제공 됩니다. *(문자열)* + +## cameraSuccess + +이미지 데이터를 제공 하는 onSuccess 콜백 함수. + + function(imageData) { + // Do something with the image + } + + +#### 설명 + + * **imageData**: Base64 인코딩은 이미지 데이터, *또는* 이미지 파일에 따라 URI의 `cameraOptions` 적용. *(문자열)* + +#### 예를 들어 + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +`navigator.camera.getPicture`에 의해 만들어진 popover 대화에 대 한 핸들. + +#### 설명 + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### 지원 되는 플랫폼 + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### 예를 들어 + + 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 전용 매개 변수 iPad의 보관 함 또는 앨범에서 이미지를 선택 하면 앵커 요소 위치와 화살표의 방향으로 popover 지정 하는. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +#### 설명 + + * **x**: x는 popover 앵커는 화면 요소의 픽셀 좌표. *(수)* + + * **y**: y 픽셀 좌표는 popover 앵커는 화면 요소입니다. *(수)* + + * **폭**: 폭 (픽셀)는 popover 앵커는 화면 요소. *(수)* + + * **높이**: 높이 (픽셀)는 popover 앵커는 화면 요소. *(수)* + + * **arrowDir**: 방향 화살표는 popover 가리켜야 합니다. 에 정의 된 `Camera.PopoverArrowDirection` *(수)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +참고는 popover의 크기 조정 화살표 방향 및 화면 방향 변경 될 수 있습니다. 앵커 요소 위치를 지정 하는 경우 방향 변경에 대 한 계정에 있는지 확인 합니다. + +## navigator.camera.cleanup + +제거 임시 저장소에서 카메라로 찍은 사진을 중간. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +#### 설명 + +`camera.getPicture`를 호출한 후 임시 저장소에 보관 됩니다 중간 이미지 파일을 제거 합니다. `Camera.sourceType` 값은 `Camera.PictureSourceType.CAMERA` 및 `Camera.destinationType`와 `Camera.DestinationType.FILE_URI` 때만 적용 됩니다.. + +#### 지원 되는 플랫폼 + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### 예를 들어 + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/ko/index.md b/plugins/cordova-plugin-camera/doc/ko/index.md new file mode 100644 index 0000000..794aa97 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/ko/index.md @@ -0,0 +1,434 @@ + + +# cordova-plugin-camera + +이 플러그인 시스템의 이미지 라이브러리에서 이미지를 선택 및 사진 촬영을 위한 API를 제공 하는 글로벌 `navigator.camera` 개체를 정의 합니다. + +개체 `navigator` 글로벌 범위 첨부 아니에요 때까지 사용할 수 있는 `deviceready` 이벤트 후. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## 설치 + + cordova plugin add cordova-plugin-camera + + +## navigator.camera.getPicture + +카메라를 사용 하 여 사진을 걸립니다 또는 소자의 이미지 갤러리에서 사진을 검색 합니다. 이미지는 성공 콜백에 전달 base64 인코딩된 `문자열` 또는 URI로 이미지 파일에 대 한. 방법 자체는 파일 선택 popover 위치를 사용할 수 있는 `CameraPopoverHandle` 개체를 반환 합니다. + + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); + + +### 설명 + +`Camera.getPicture` 함수 스냅 사진을 사용자가 소자의 기본 카메라 응용 프로그램을 엽니다. 이 문제는 `Camera.sourceType` `Camera.PictureSourceType.CAMERA` 경우 기본적으로 발생 합니다. 일단 사용자 스냅 사진, 카메라 응용 프로그램 종료 하 고 응용 프로그램 복원 됩니다. + +`Camera.sourceType`은 `Camera.PictureSourceType.PHOTOLIBRARY` 또는 `Camera.PictureSourceType.SAVEDPHOTOALBUM`, 대화 상자가 사용자가 기존 이미지를 선택할 수 있도록 표시 됩니다. `camera.getPicture` 함수는 장치 방향 변경 될 때 이미지 선택 대화 상자, 예를 들어, 위치를 변경 하려면 사용할 수 있는 `CameraPopoverHandle` 개체를 반환 합니다. + +반환 값은 `cameraSuccess` 콜백 함수 지정된 `cameraOptions`에 따라 다음 형식 중 하나에 전송 됩니다. + +* A `String` base64 인코딩된 사진 이미지를 포함 합니다. + +* A `String` 로컬 저장소 (기본값)의 이미지 파일 위치를 나타내는. + +할 수 있는 당신이 원하는대로 인코딩된 이미지 또는 URI, 예를 들면: + +* 렌더링 이미지는 `` 아래 예제와 같이 태그 + +* 로컬로 데이터를 저장 ( `LocalStorage` , [Lawnchair][1], 등.) + +* 원격 서버에 데이터 게시 + + [1]: http://brianleroux.github.com/lawnchair/ + +**참고**: 더 새로운 장치에 사진 해상도 아주 좋은. 소자의 갤러리에서 선택 된 사진 `품질` 매개 변수를 지정 하는 경우에 낮은 품질에 관하여 하지는. 일반적인 메모리 문제를 피하기 위해 `DATA_URL` 보다 `FILE_URI` `Camera.destinationType` 설정. + +### 지원 되는 플랫폼 + +* 아마존 화재 운영 체제 +* 안 드 로이드 +* 블랙베리 10 +* 브라우저 +* Firefox 운영 체제 +* iOS +* Tizen +* Windows Phone 7과 8 +* 윈도우 8 + +### 환경 설정 (iOS) + +* **CameraUsesGeolocation** (boolean, 기본값: false)입니다. 캡처 Jpeg, EXIF 헤더에 지리적 데이터를 true로 설정 합니다. 이 경우 위치 정보 사용 권한에 대 한 요청을 일으킬 것 이다 true로 설정 합니다. + + + + +### 아마존 화재 OS 단점 + +아마존 화재 OS 의도 사용 하 여 이미지 캡처 장치에서 카메라 활동을 시작 하 고 낮은 메모리와 휴대 전화에 코르 도우 바 활동 살해 수 있습니다. 코르도바 활동 복원 되 면이 시나리오에서는 이미지가 나타나지 않을 수 있습니다. + +### 안 드 로이드 단점 + +안 드 로이드 의도 사용 하 여 이미지 캡처 장치에서 카메라 활동을 시작 하 고 낮은 메모리와 휴대 전화에 코르 도우 바 활동 살해 수 있습니다. 코르도바 활동 복원 되 면이 시나리오에서는 이미지가 나타나지 않을 수 있습니다. + +### 브라우저 만지면 + +수 base64 인코딩 이미지로 사진을 반환 합니다. + +### 파이어 폭스 OS 단점 + +카메라 플러그인은 현재 [웹 활동][2]를 사용 하 여 구현. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### iOS 단점 + +자바 `alert()`를 포함 하 여 콜백 함수 중 하나에 문제가 발생할 수 있습니다. 포장 허용 iOS 이미지 피커 또는 popover를 완벽 하 게 경고를 표시 하기 전에 닫습니다 `setTimeout()` 내에서 경고: + + setTimeout(function() { + // do your thing here! + }, 0); + + +### Windows Phone 7 단점 + +장치 Zune 통해 연결 된 동안 네이티브 카메라 응용 프로그램을 호출 하면 작동 하지 않습니다 하 고 오류 콜백 트리거합니다. + +### Tizen 특수 + +`Camera.DestinationType.FILE_URI`의 `destinationType`와 `Camera.PictureSourceType.PHOTOLIBRARY`의 `sourceType` Tizen 지원. + +### 예를 들어 + +촬영 및 base64 인코딩 이미지로 검색: + + 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); + } + + +촬영 하 고 이미지의 파일 위치를 검색: + + 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 + +카메라 설정을 사용자 지정 하는 선택적 매개 변수. + + { 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 }; + + +### 옵션 + +* **품질**: 범위 0-100, 100은 파일 압축에서 손실 없이 일반적으로 전체 해상도 저장된 된 이미지의 품질. 기본값은 50입니다. *(수)* (Note 카메라의 해상도 대 한 정보는 사용할 수 없습니다.) + +* **destinationType**: 반환 값의 형식을 선택 합니다. 기본값은 FILE_URI입니다. 에 정의 된 `navigator.camera.DestinationType` *(수)* + + 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**: 그림의 소스를 설정 합니다. 기본값은 카메라입니다. 에 정의 된 `navigator.camera.PictureSourceType` *(수)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **allowEdit**: 선택 하기 전에 이미지의 간단한 편집을 허용 합니다. *(부울)* + +* **encodingType**: 반환 된 이미지 파일의 인코딩을 선택 합니다. 기본값은 JPEG입니다. 에 정의 된 `navigator.camera.EncodingType` *(수)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **targetWidth**: 스케일 이미지를 픽셀 너비. **TargetHeight**와 함께 사용 해야 합니다. 가로 세로 비율이 일정 하 게 유지 합니다. *(수)* + +* **targetHeight**: 스케일 이미지를 픽셀 단위로 높이. **TargetWidth**와 함께 사용 해야 합니다. 가로 세로 비율이 일정 하 게 유지 합니다. *(수)* + +* **mediaType**:에서 선택 미디어 유형을 설정 합니다. 때에 작동 `PictureSourceType` 는 `PHOTOLIBRARY` 또는 `SAVEDPHOTOALBUM` . 에 정의 된 `nagivator.camera.MediaType` *(수)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. 기본입니다. 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**: 캡처 도중 장치의 방향에 대 한 해결 하기 위해 이미지를 회전 합니다. *(부울)* + +* **saveToPhotoAlbum**: 캡처 후 장치에서 사진 앨범에 이미지를 저장 합니다. *(부울)* + +* **popoverOptions**: iPad에 popover 위치를 지정 하는 iOS 전용 옵션. 에 정의 된`CameraPopoverOptions`. + +* **cameraDirection**: (앞 이나 뒤로-연결)를 사용 하 여 카메라를 선택 하십시오. 기본값은 다시. 에 정의 된 `navigator.camera.Direction` *(수)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### 아마존 화재 OS 단점 + +* 어떤 `cameraDirection` 다시 연결 사진에 결과 값. + +* 무시는 `allowEdit` 매개 변수. + +* `Camera.PictureSourceType.PHOTOLIBRARY`그리고 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 둘 다 동일한 사진 앨범을 표시 합니다. + +### 안 드 로이드 단점 + +* 어떤 `cameraDirection` 다시 연결 사진에 결과 값. + +* 무시는 `allowEdit` 매개 변수. + +* `Camera.PictureSourceType.PHOTOLIBRARY`그리고 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 둘 다 동일한 사진 앨범을 표시 합니다. + +### 블랙베리 10 단점 + +* 무시는 `quality` 매개 변수. + +* 무시는 `allowEdit` 매개 변수. + +* `Camera.MediaType`지원 되지 않습니다. + +* 무시는 `correctOrientation` 매개 변수. + +* 무시는 `cameraDirection` 매개 변수. + +### 파이어 폭스 OS 단점 + +* 무시는 `quality` 매개 변수. + +* `Camera.DestinationType`무시 되 고 `1` (이미지 파일 URI) + +* 무시는 `allowEdit` 매개 변수. + +* 무시는 `PictureSourceType` 매개 변수 (사용자가 선택 그것 대화 창에서) + +* 무시 하는`encodingType` + +* 무시는 `targetWidth` 와`targetHeight` + +* `Camera.MediaType`지원 되지 않습니다. + +* 무시는 `correctOrientation` 매개 변수. + +* 무시는 `cameraDirection` 매개 변수. + +### iOS 단점 + +* 설정 `quality` 일부 장치 메모리 오류를 피하기 위해 50 아래. + +* 사용 하는 경우 `destinationType.FILE_URI` , 사진 응용 프로그램의 임시 디렉터리에 저장 됩니다. 응용 프로그램이 종료 될 때 응용 프로그램의 임시 디렉터리의 내용은 삭제 됩니다. + +### Tizen 특수 + +* 지원 되지 않는 옵션 + +* 항상 파일 URI를 반환 합니다. + +### Windows Phone 7, 8 특수 + +* 무시는 `allowEdit` 매개 변수. + +* 무시는 `correctOrientation` 매개 변수. + +* 무시는 `cameraDirection` 매개 변수. + +* 무시는 `saveToPhotoAlbum` 매개 변수. 중요: 모든 이미지 API wp7/8 코르도바 카메라로 촬영 항상 복사 됩니다 휴대 전화의 카메라 롤에. 사용자의 설정에 따라이 또한 그들의 OneDrive에 자동 업로드 이미지는 의미. 이 잠재적으로 이미지는 당신의 애플 리 케이 션을 위한 보다 넓은 청중에 게 사용할 수 있는 의미. 이 경우 응용 프로그램에 대 한 차단, 당신은 msdn에 설명 대로 단말기를 구현 해야 합니다: 수 있습니다 또한 의견 또는 [이슈 트래커][3] 에서 업-투표 관련된 문제 + +* 무시는 `mediaType` 속성을 `cameraOptions` 으로 Windows Phone SDK PHOTOLIBRARY에서 비디오를 선택 하는 방법을 제공 하지 않습니다. + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +오류 메시지를 제공 하는 onError 콜백 함수. + + function(message) { + // Show a helpful message + } + + +### 매개 변수 + +* **메시지**: 메시지는 장치의 네이티브 코드에 의해 제공 됩니다. *(문자열)* + +## cameraSuccess + +이미지 데이터를 제공 하는 onSuccess 콜백 함수. + + function(imageData) { + // Do something with the image + } + + +### 매개 변수 + +* **imageData**: Base64 인코딩은 이미지 데이터, *또는* 이미지 파일에 따라 URI의 `cameraOptions` 적용. *(문자열)* + +### 예를 들어 + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +`navigator.camera.getPicture`에 의해 만들어진 popover 대화에 대 한 핸들. + +### 메서드 + +* **setPosition**:는 popover의 위치를 설정 합니다. + +### 지원 되는 플랫폼 + +* iOS + +### setPosition + +popover의 위치를 설정 합니다. + +**매개 변수**: + +* `cameraPopoverOptions`:는 `CameraPopoverOptions` 새 위치를 지정 하는 + +### 예를 들어 + + 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 전용 매개 변수 iPad의 보관 함 또는 앨범에서 이미지를 선택 하면 앵커 요소 위치와 화살표의 방향으로 popover 지정 하는. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +### CameraPopoverOptions + +* **x**: x는 popover 앵커는 화면 요소의 픽셀 좌표. *(수)* + +* **y**: y 픽셀 좌표는 popover 앵커는 화면 요소입니다. *(수)* + +* **폭**: 폭 (픽셀)는 popover 앵커는 화면 요소. *(수)* + +* **높이**: 높이 (픽셀)는 popover 앵커는 화면 요소. *(수)* + +* **arrowDir**: 방향 화살표는 popover 가리켜야 합니다. 에 정의 된 `Camera.PopoverArrowDirection` *(수)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +참고는 popover의 크기 조정 화살표 방향 및 화면 방향 변경 될 수 있습니다. 앵커 요소 위치를 지정 하는 경우 방향 변경에 대 한 계정에 있는지 확인 합니다. + +## navigator.camera.cleanup + +제거 임시 저장소에서 카메라로 찍은 사진을 중간. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +### 설명 + +`camera.getPicture`를 호출한 후 임시 저장소에 보관 됩니다 중간 이미지 파일을 제거 합니다. `Camera.sourceType` 값은 `Camera.PictureSourceType.CAMERA` 및 `Camera.destinationType`와 `Camera.DestinationType.FILE_URI` 때만 적용 됩니다.. + +### 지원 되는 플랫폼 + +* iOS + +### 예를 들어 + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } diff --git a/plugins/cordova-plugin-camera/doc/pl/README.md b/plugins/cordova-plugin-camera/doc/pl/README.md new file mode 100644 index 0000000..e7b9d44 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/pl/README.md @@ -0,0 +1,421 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +Ten plugin definiuje obiekt globalny `navigator.camera`, który dostarcza API do robienia zdjęć i wybór zdjęć z biblioteki obrazów systemu. + +Mimo, że obiekt jest dołączony do globalnego zakresu `navigator`, to nie dostępne dopiero po zdarzeniu `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## Instalacja + + cordova plugin add cordova-plugin-camera + + +## API + + * Aparat + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * navigator.camera.cleanup + +## navigator.camera.getPicture + +Ma zdjęcia za pomocą aparatu, lub pobiera zdjęcia z urządzenia Galeria zdjęć. Obraz jest przekazywany do wywołania zwrotnego sukces jako kodowane algorytmem base64 `ciąg`, lub identyfikator URI dla pliku obrazu. Sama metoda zwraca obiekt `CameraPopoverHandle`, który może służyć do zmiany położenia pliku wyboru popover. + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### Opis + +Funkcja `camera.getPicture` otwiera urządzenia domyślnej aplikacji aparat fotograficzny ów pozwala użytkownik wobec chwycić zębami kino. To zachowanie występuje domyślnie, gdy `Camera.sourceType` jest równa `Camera.PictureSourceType.CAMERA`. Gdy użytkownik zaskoczy zdjęcie, ten aparat fotograficzny applicationâ zamyka i aplikacji jest przywracany. + +Jeśli `Camera.sourceType` jest równe `Camera.PictureSourceType.PHOTOLIBRARY` lub `Camera.PictureSourceType.SAVEDPHOTOALBUM`, wtedy zostanie wyświetlone okno dialogowe pozwalające użytkownikowi na wybór istniejącego obrazu. Funkcja `camera.getPicture` zwraca obiekt `CameraPopoverHandle`, który obsługuje zmianę położenia okna wyboru obrazu, np. po zmianie orientacji urządzenia. + +Zwracana wartość jest wysyłany do funkcji wywołania zwrotnego `cameraSuccess`, w jednym z następujących formatów, w zależności od określonego `cameraOptions`: + + * `String` zawierający obraz zakodowany przy pomocy base64. + + * `String` reprezentujący lokalizację pliku obrazu w lokalnym magazynie (domyślnie). + +Może rób, co chcesz z zakodowany obraz lub identyfikatora URI, na przykład: + + * Przedstawić obraz w tagu ``, jak w przykładzie poniżej + + * Zapisać lokalnie dane (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.) + + * Wysłać dane na zdalny serwer + +**Uwaga**: zdjęcie rozdzielczości na nowsze urządzenia jest bardzo dobry. Zdjęcia wybrane z galerii urządzenia są nie przeskalowanych w dół do niższej jakości, nawet jeśli określono parametr `quality`. Aby uniknąć typowych problemów z pamięci, zestaw `Camera.destinationType` `FILE_URI` zamiast `DATA_URL`. + +#### Obsługiwane platformy + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### Przykład + +Zrób zdjęcie i pobrać go jako kodowane algorytmem base64 obrazu: + + 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); + } + + +Zrób zdjęcie i pobrać lokalizacji pliku obrazu: + + 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); + } + + +#### Preferencje (iOS) + + * **CameraUsesGeolocation** (boolean, wartość domyślna to false). Do przechwytywania JPEG, zestaw do true, aby uzyskać danych geolokalizacyjnych w nagłówku EXIF. To spowoduje wniosek o geolokalizacji uprawnienia, jeśli zestaw na wartość true. + + + + +#### Amazon ogień OS dziwactwa + +Amazon ogień OS używa intencje do rozpoczęcia działalności aparatu na urządzenie do przechwytywania obrazów, i na telefony z pamięci, Cordova aktywność może zostać zabity. W tym scenariuszu obraz mogą nie być wyświetlane po przywróceniu aktywności cordova. + +#### Dziwactwa Androida + +Android używa intencje do rozpoczęcia działalności aparatu na urządzenie do przechwytywania obrazów, i na telefony z pamięci, Cordova aktywność może zostać zabity. W tym scenariuszu obraz mogą nie być wyświetlane po przywróceniu aktywności Cordova. + +#### Quirks przeglądarki + +Może zwracać tylko zdjęcia jako obraz w formacie algorytmem base64. + +#### Firefox OS dziwactwa + +Aparat plugin jest obecnie implementowane za pomocą [Działania sieci Web](https://hacks.mozilla.org/2013/01/introducing-web-activities/). + +#### Dziwactwa iOS + +W jednej z funkcji wywołania zwrotnego w tym JavaScript `alert()` może powodować problemy. Owinąć w `setTimeout()` umożliwia wybór obrazu iOS lub popover całkowicie zamknąć zanim wyświetli alert alert: + + setTimeout(function() { + // do your thing here! + }, 0); + + +#### Dziwactwa Windows Phone 7 + +Wywoływanie aparat native aplikacji, podczas gdy urządzenie jest podłączone przez Zune nie działa i powoduje błąd wywołania zwrotnego. + +#### Dziwactwa Tizen + +Tizen obsługuje tylko `destinationType` z `Camera.DestinationType.FILE_URI` i `sourceType` z `Camera.PictureSourceType.PHOTOLIBRARY`. + +## CameraOptions + +Opcjonalne parametry, aby dostosować ustawienia aparatu. + + { 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 }; + + + * **quality**: Jakość zapisywanego obrazu, wyrażona w przedziale 0-100, gdzie 100 zazwyczaj jest maksymalną rozdzielczością bez strat w czasie kompresji pliku. Wartością domyślną jest 50. *(Liczba)* (Pamiętaj, że informacja o rozdzielczości aparatu jest niedostępna.) + + * **destinationType**: Wybierz format zwracanej wartości. Wartością domyślną jest FILE_URI. Zdefiniowane w `navigator.camera.DestinationType` *(numer)* + + 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**: Ustaw źródło obrazu. Wartością domyślną jest aparat fotograficzny. Zdefiniowane w `navigator.camera.PictureSourceType` *(numer)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **allowEdit**: Pozwala na prostą edycję obrazu przed zaznaczeniem. *(Boolean)* + + * **encodingType**: Wybierz plik obrazu zwracany jest kodowanie. Domyślnie jest JPEG. Zdefiniowane w `navigator.camera.EncodingType` *(numer)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **targetWidth**: Szerokość w pikselach skalowanego obrazu. Musi być użyte z **targetHeight**. Współczynnik proporcji pozostaje stały. *(Liczba)* + + * **targetHeight**: Wysokość w pikselach skalowanego obrazu. Musi być użyte z **targetWidth**. Współczynnik proporcji pozostaje stały. *(Liczba)* + + * **mediaType**: Ustawia typ nośnika, z którego będzie wybrany. Działa tylko wtedy, gdy `PictureSourceType` jest `PHOTOLIBRARY` lub `SAVEDPHOTOALBUM`. Zdefiniowane w `nagivator.camera.MediaType` *(Liczba)* + + 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**: Obraca obraz aby skorygować orientację urządzenia podczas przechwytywania. *(Boolean)* + + * **saveToPhotoAlbum**: Po przechwyceniu zapisuje na urządzeniu obraz w albumie na zdjęcia. *(Boolean)* + + * **popoverOptions**: Opcja tylko dla platformy iOS, która określa położenie wyskakującego okna na iPadzie. Zdefiniowane w `CameraPopoverOptions`. + + * **cameraDirection**: Wybierz aparat do korzystania (lub z powrotem przodem). Wartością domyślną jest z powrotem. Zdefiniowane w `navigator.camera.Direction` *(numer)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### Amazon ogień OS dziwactwa + + * Jakakolwiek wartość w `cameraDirection` skutkuje użyciem tylnej kamery. + + * Parametr `allowEdit` jest ignorowany. + + * Oba parametry `Camera.PictureSourceType.PHOTOLIBRARY` oraz `Camera.PictureSourceType.SAVEDPHOTOALBUM` wyświetlają ten sam album ze zdjęciami. + +#### Dziwactwa Androida + + * Jakakolwiek wartość w `cameraDirection` skutkuje użyciem tylnej kamery. + + * Android również używa aktywność upraw dla allowEdit, choć upraw powinien pracować i faktycznie przejść przycięte zdjęcie Wróć do Cordova, ten tylko jeden który działa konsekwentnie jest ten, wiązany z aplikacji Google Plus zdjęcia. Inne rośliny mogą nie działać. + + * Oba parametry `Camera.PictureSourceType.PHOTOLIBRARY` oraz `Camera.PictureSourceType.SAVEDPHOTOALBUM` wyświetlają ten sam album ze zdjęciami. + +#### Jeżyna 10 dziwactwa + + * Parametr `quality` jest ignorowany. + + * Parametr `allowEdit` jest ignorowany. + + * Nie jest wspierane `Camera.MediaType`. + + * Parametr `correctOrientation` jest ignorowany. + + * Parametr `cameraDirection` jest ignorowany. + +#### Firefox OS dziwactwa + + * Parametr `quality` jest ignorowany. + + * `Camera.DestinationType`jest ignorowane i jest równa `1` (plik obrazu URI) + + * Parametr `allowEdit` jest ignorowany. + + * Ignoruje `PictureSourceType` parametr (użytkownik wybiera go w oknie dialogowym) + + * Ignoruje`encodingType` + + * Ignoruje `targetWidth` i`targetHeight` + + * Nie jest wspierane `Camera.MediaType`. + + * Parametr `correctOrientation` jest ignorowany. + + * Parametr `cameraDirection` jest ignorowany. + +#### Dziwactwa iOS + + * Ustaw `quality` poniżej 50 aby uniknąć błędów pamięci na niektórych urządzeniach. + + * Podczas korzystania z `destinationType.FILE_URI` , zdjęcia są zapisywane w katalogu tymczasowego stosowania. Zawartość katalogu tymczasowego stosowania jest usuwany po zakończeniu aplikacji. + +#### Dziwactwa Tizen + + * opcje nie są obsługiwane + + * zawsze zwraca FILE URI + +#### Windows Phone 7 i 8 dziwactwa + + * Parametr `allowEdit` jest ignorowany. + + * Parametr `correctOrientation` jest ignorowany. + + * Parametr `cameraDirection` jest ignorowany. + + * Ignoruje `saveToPhotoAlbum` parametr. Ważne: Wszystkie zdjęcia zrobione aparatem wp7/8 cordova API są zawsze kopiowane do telefonu w kamerze. W zależności od ustawień użytkownika może to też oznaczać że obraz jest automatycznie przesłane do ich OneDrive. Potencjalnie może to oznaczać, że obraz jest dostępne dla szerszego grona odbiorców niż Twoja aplikacja przeznaczona. Jeśli ten bloker aplikacji, trzeba będzie wdrożenie CameraCaptureTask, opisane na msdn: można także komentarz lub górę głosowanie powiązanych kwestii w [śledzenia błędów](https://issues.apache.org/jira/browse/CB-2083) + + * Ignoruje `mediaType` Właściwość `cameraOptions` jako SDK Windows Phone nie umożliwiają wybór filmów z PHOTOLIBRARY. + +## CameraError + +funkcja wywołania zwrotnego PrzyBłędzie, która zawiera komunikat o błędzie. + + function(message) { + // Show a helpful message + } + + +#### Opis + + * **message**: Natywny kod komunikatu zapewniany przez urządzenie. *(Ciąg znaków)* + +## cameraSuccess + +onSuccess funkcji wywołania zwrotnego, który dostarcza dane obrazu. + + function(imageData) { + // Do something with the image + } + + +#### Opis + + * **imageData**: Dane obrazu kodowane przy pomocy Base64 *lub* URI pliku obrazu, w zależności od użycia `cameraOptions`. *(Ciąg znaków)* + +#### Przykład + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Uchwyt do okna dialogowego popover, stworzony przez `navigator.camera.getPicture`. + +#### Opis + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### Obsługiwane platformy + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Przykład + + 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 + +tylko do iOS parametrami, które określić kotwicy element lokalizacji i strzałka kierunku popover, przy wyborze zdjęć z iPad biblioteki lub album. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +#### Opis + + * **x**: współrzędna piksela x elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + + * **y**: współrzędna piksela y elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + + * **width**: szerokość w pikselach elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + + * **height**: wysokość w pikselach elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + + * **arrowDir**: Kierunek, który powinna wskazywać strzałka na wyskakującym oknie. Zdefiniowane w `Camera.PopoverArrowDirection` *(Liczba)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Należy pamiętać, że rozmiar popover może zmienić aby zmienić kierunek strzałki i orientacji ekranu. Upewnij się uwzględnić zmiany orientacji podczas określania położenia elementu kotwicy. + +## navigator.camera.cleanup + +Usuwa pośrednie zdjęcia zrobione przez aparat z czasowego składowania. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +#### Opis + +Usuwa pliki obrazów pośrednich, które są przechowywane w pamięci tymczasowej po wywołaniu `camera.getPicture`. Ma zastosowanie tylko, gdy wartość `Camera.sourceType` jest równa `Camera.PictureSourceType.CAMERA` i `Camera.destinationType` jest równa `Camera.DestinationType.FILE_URI`. + +#### Obsługiwane platformy + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### Przykład + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/pl/index.md b/plugins/cordova-plugin-camera/doc/pl/index.md new file mode 100644 index 0000000..f226698 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/pl/index.md @@ -0,0 +1,434 @@ + + +# cordova-plugin-camera + +Ten plugin definiuje obiekt globalny `navigator.camera`, który dostarcza API do robienia zdjęć i wybór zdjęć z biblioteki obrazów systemu. + +Mimo, że obiekt jest dołączony do globalnego zakresu `navigator`, to nie dostępne dopiero po zdarzeniu `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## Instalacja + + cordova plugin add cordova-plugin-camera + + +## navigator.camera.getPicture + +Ma zdjęcia za pomocą aparatu, lub pobiera zdjęcia z urządzenia Galeria zdjęć. Obraz jest przekazywany do wywołania zwrotnego sukces jako kodowane algorytmem base64 `ciąg`, lub identyfikator URI dla pliku obrazu. Sama metoda zwraca obiekt `CameraPopoverHandle`, który może służyć do zmiany położenia pliku wyboru popover. + + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); + + +### Opis + +Funkcja `camera.getPicture` otwiera urządzenia domyślnej aplikacji aparat fotograficzny ów pozwala użytkownik wobec chwycić zębami kino. To zachowanie występuje domyślnie, gdy `Camera.sourceType` jest równa `Camera.PictureSourceType.CAMERA`. Gdy użytkownik zaskoczy zdjęcie, ten aparat fotograficzny applicationâ zamyka i aplikacji jest przywracany. + +Jeśli `Camera.sourceType` jest równe `Camera.PictureSourceType.PHOTOLIBRARY` lub `Camera.PictureSourceType.SAVEDPHOTOALBUM`, wtedy zostanie wyświetlone okno dialogowe pozwalające użytkownikowi na wybór istniejącego obrazu. Funkcja `camera.getPicture` zwraca obiekt `CameraPopoverHandle`, który obsługuje zmianę położenia okna wyboru obrazu, np. po zmianie orientacji urządzenia. + +Zwracana wartość jest wysyłany do funkcji wywołania zwrotnego `cameraSuccess`, w jednym z następujących formatów, w zależności od określonego `cameraOptions`: + +* `String` zawierający obraz zakodowany przy pomocy base64. + +* `String` reprezentujący lokalizację pliku obrazu w lokalnym magazynie (domyślnie). + +Może rób, co chcesz z zakodowany obraz lub identyfikatora URI, na przykład: + +* Przedstawić obraz w tagu ``, jak w przykładzie poniżej + +* Zapisać lokalnie dane (`LocalStorage`, [Lawnchair][1], etc.) + +* Wysłać dane na zdalny serwer + + [1]: http://brianleroux.github.com/lawnchair/ + +**Uwaga**: zdjęcie rozdzielczości na nowsze urządzenia jest bardzo dobry. Zdjęcia wybrane z galerii urządzenia są nie przeskalowanych w dół do niższej jakości, nawet jeśli określono parametr `quality`. Aby uniknąć typowych problemów z pamięci, zestaw `Camera.destinationType` `FILE_URI` zamiast `DATA_URL`. + +### Obsługiwane platformy + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Przeglądarka +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 i 8 +* Windows 8 + +### Preferencje (iOS) + +* **CameraUsesGeolocation** (boolean, wartość domyślna to false). Do przechwytywania JPEG, zestaw do true, aby uzyskać danych geolokalizacyjnych w nagłówku EXIF. To spowoduje wniosek o geolokalizacji uprawnienia, jeśli zestaw na wartość true. + + + + +### Amazon ogień OS dziwactwa + +Amazon ogień OS używa intencje do rozpoczęcia działalności aparatu na urządzenie do przechwytywania obrazów, i na telefony z pamięci, Cordova aktywność może zostać zabity. W tym scenariuszu obraz mogą nie być wyświetlane po przywróceniu aktywności cordova. + +### Dziwactwa Androida + +Android używa intencje do rozpoczęcia działalności aparatu na urządzenie do przechwytywania obrazów, i na telefony z pamięci, Cordova aktywność może zostać zabity. W tym scenariuszu obraz mogą nie być wyświetlane po przywróceniu aktywności Cordova. + +### Quirks przeglądarki + +Może zwracać tylko zdjęcia jako obraz w formacie algorytmem base64. + +### Firefox OS dziwactwa + +Aparat plugin jest obecnie implementowane za pomocą [Działania sieci Web][2]. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### Dziwactwa iOS + +W jednej z funkcji wywołania zwrotnego w tym JavaScript `alert()` może powodować problemy. Owinąć w `setTimeout()` umożliwia wybór obrazu iOS lub popover całkowicie zamknąć zanim wyświetli alert alert: + + setTimeout(function() { + // do your thing here! + }, 0); + + +### Dziwactwa Windows Phone 7 + +Wywoływanie aparat native aplikacji, podczas gdy urządzenie jest podłączone przez Zune nie działa i powoduje błąd wywołania zwrotnego. + +### Dziwactwa Tizen + +Tizen obsługuje tylko `destinationType` z `Camera.DestinationType.FILE_URI` i `sourceType` z `Camera.PictureSourceType.PHOTOLIBRARY`. + +### Przykład + +Zrób zdjęcie i pobrać go jako kodowane algorytmem base64 obrazu: + + 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); + } + + +Zrób zdjęcie i pobrać lokalizacji pliku obrazu: + + 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 + +Opcjonalne parametry, aby dostosować ustawienia aparatu. + + { 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 }; + + +### Opcje + +* **quality**: Jakość zapisywanego obrazu, wyrażona w przedziale 0-100, gdzie 100 zazwyczaj jest maksymalną rozdzielczością bez strat w czasie kompresji pliku. Wartością domyślną jest 50. *(Liczba)* (Pamiętaj, że informacja o rozdzielczości aparatu jest niedostępna.) + +* **destinationType**: Wybierz format zwracanej wartości. Wartością domyślną jest FILE_URI. Zdefiniowane w `navigator.camera.DestinationType` *(numer)* + + 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**: Ustaw źródło obrazu. Wartością domyślną jest aparat fotograficzny. Zdefiniowane w `navigator.camera.PictureSourceType` *(numer)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **allowEdit**: Pozwala na prostą edycję obrazu przed zaznaczeniem. *(Boolean)* + +* **encodingType**: Wybierz plik obrazu zwracany jest kodowanie. Domyślnie jest JPEG. Zdefiniowane w `navigator.camera.EncodingType` *(numer)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **targetWidth**: Szerokość w pikselach skalowanego obrazu. Musi być użyte z **targetHeight**. Współczynnik proporcji pozostaje stały. *(Liczba)* + +* **targetHeight**: Wysokość w pikselach skalowanego obrazu. Musi być użyte z **targetWidth**. Współczynnik proporcji pozostaje stały. *(Liczba)* + +* **mediaType**: Ustawia typ nośnika, z którego będzie wybrany. Działa tylko wtedy, gdy `PictureSourceType` jest `PHOTOLIBRARY` lub `SAVEDPHOTOALBUM`. Zdefiniowane w `nagivator.camera.MediaType` *(Liczba)* + + 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**: Obraca obraz aby skorygować orientację urządzenia podczas przechwytywania. *(Boolean)* + +* **saveToPhotoAlbum**: Po przechwyceniu zapisuje na urządzeniu obraz w albumie na zdjęcia. *(Boolean)* + +* **popoverOptions**: Opcja tylko dla platformy iOS, która określa położenie wyskakującego okna na iPadzie. Zdefiniowane w `CameraPopoverOptions`. + +* **cameraDirection**: Wybierz aparat do korzystania (lub z powrotem przodem). Wartością domyślną jest z powrotem. Zdefiniowane w `navigator.camera.Direction` *(numer)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### Amazon ogień OS dziwactwa + +* Jakakolwiek wartość w `cameraDirection` skutkuje użyciem tylnej kamery. + +* Parametr `allowEdit` jest ignorowany. + +* Oba parametry `Camera.PictureSourceType.PHOTOLIBRARY` oraz `Camera.PictureSourceType.SAVEDPHOTOALBUM` wyświetlają ten sam album ze zdjęciami. + +### Dziwactwa Androida + +* Jakakolwiek wartość w `cameraDirection` skutkuje użyciem tylnej kamery. + +* Parametr `allowEdit` jest ignorowany. + +* Oba parametry `Camera.PictureSourceType.PHOTOLIBRARY` oraz `Camera.PictureSourceType.SAVEDPHOTOALBUM` wyświetlają ten sam album ze zdjęciami. + +### Jeżyna 10 dziwactwa + +* Parametr `quality` jest ignorowany. + +* Parametr `allowEdit` jest ignorowany. + +* Nie jest wspierane `Camera.MediaType`. + +* Parametr `correctOrientation` jest ignorowany. + +* Parametr `cameraDirection` jest ignorowany. + +### Firefox OS dziwactwa + +* Parametr `quality` jest ignorowany. + +* `Camera.DestinationType`jest ignorowane i jest równa `1` (plik obrazu URI) + +* Parametr `allowEdit` jest ignorowany. + +* Ignoruje `PictureSourceType` parametr (użytkownik wybiera go w oknie dialogowym) + +* Ignoruje`encodingType` + +* Ignoruje `targetWidth` i`targetHeight` + +* Nie jest wspierane `Camera.MediaType`. + +* Parametr `correctOrientation` jest ignorowany. + +* Parametr `cameraDirection` jest ignorowany. + +### Dziwactwa iOS + +* Ustaw `quality` poniżej 50 aby uniknąć błędów pamięci na niektórych urządzeniach. + +* Podczas korzystania z `destinationType.FILE_URI` , zdjęcia są zapisywane w katalogu tymczasowego stosowania. Zawartość katalogu tymczasowego stosowania jest usuwany po zakończeniu aplikacji. + +### Dziwactwa Tizen + +* opcje nie są obsługiwane + +* zawsze zwraca FILE URI + +### Windows Phone 7 i 8 dziwactwa + +* Parametr `allowEdit` jest ignorowany. + +* Parametr `correctOrientation` jest ignorowany. + +* Parametr `cameraDirection` jest ignorowany. + +* Ignoruje `saveToPhotoAlbum` parametr. Ważne: Wszystkie zdjęcia zrobione aparatem wp7/8 cordova API są zawsze kopiowane do telefonu w kamerze. W zależności od ustawień użytkownika może to też oznaczać że obraz jest automatycznie przesłane do ich OneDrive. Potencjalnie może to oznaczać, że obraz jest dostępne dla szerszego grona odbiorców niż Twoja aplikacja przeznaczona. Jeśli ten bloker aplikacji, trzeba będzie wdrożenie CameraCaptureTask, opisane na msdn: można także komentarz lub górę głosowanie powiązanych kwestii w [śledzenia błędów][3] + +* Ignoruje `mediaType` Właściwość `cameraOptions` jako SDK Windows Phone nie umożliwiają wybór filmów z PHOTOLIBRARY. + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +funkcja wywołania zwrotnego PrzyBłędzie, która zawiera komunikat o błędzie. + + function(message) { + // Show a helpful message + } + + +### Parametry + +* **message**: Natywny kod komunikatu zapewniany przez urządzenie. *(Ciąg znaków)* + +## cameraSuccess + +onSuccess funkcji wywołania zwrotnego, który dostarcza dane obrazu. + + function(imageData) { + // Do something with the image + } + + +### Parametry + +* **imageData**: Dane obrazu kodowane przy pomocy Base64 *lub* URI pliku obrazu, w zależności od użycia `cameraOptions`. *(Ciąg znaków)* + +### Przykład + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Uchwyt do okna dialogowego popover, stworzony przez `navigator.camera.getPicture`. + +### Metody + +* **setPosition**: Ustawia pozycję wyskakującego okna. + +### Obsługiwane platformy + +* iOS + +### setPosition + +Ustaw pozycję popover. + +**Parametry**: + +* `cameraPopoverOptions`: `CameraPopoverOptions`, która określa nową pozycję + +### Przykład + + 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 + +tylko do iOS parametrami, które określić kotwicy element lokalizacji i strzałka kierunku popover, przy wyborze zdjęć z iPad biblioteki lub album. + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +### CameraPopoverOptions + +* **x**: współrzędna piksela x elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + +* **y**: współrzędna piksela y elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + +* **width**: szerokość w pikselach elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + +* **height**: wysokość w pikselach elementu ekranu, na którym zakotwiczone jest wyskakujące okno. *(Liczba)* + +* **arrowDir**: Kierunek, który powinna wskazywać strzałka na wyskakującym oknie. Zdefiniowane w `Camera.PopoverArrowDirection` *(Liczba)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Należy pamiętać, że rozmiar popover może zmienić aby zmienić kierunek strzałki i orientacji ekranu. Upewnij się uwzględnić zmiany orientacji podczas określania położenia elementu kotwicy. + +## navigator.camera.cleanup + +Usuwa pośrednie zdjęcia zrobione przez aparat z czasowego składowania. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +### Opis + +Usuwa pliki obrazów pośrednich, które są przechowywane w pamięci tymczasowej po wywołaniu `camera.getPicture`. Ma zastosowanie tylko, gdy wartość `Camera.sourceType` jest równa `Camera.PictureSourceType.CAMERA` i `Camera.destinationType` jest równa `Camera.DestinationType.FILE_URI`. + +### Obsługiwane platformy + +* iOS + +### Przykład + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } diff --git a/plugins/cordova-plugin-camera/doc/ru/index.md b/plugins/cordova-plugin-camera/doc/ru/index.md new file mode 100644 index 0000000..f93609c --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/ru/index.md @@ -0,0 +1,417 @@ + + +# cordova-plugin-camera + +Этот плагин предоставляет API для съемки и для выбора изображения из библиотеки изображений системы. + + cordova plugin add cordova-plugin-camera + + +## navigator.camera.getPicture + +Снимает фотографию с помощью камеры, или получает фотографию из галереи изображений устройства. Изображение передается на функцию обратного вызова успешного завершения как `String` в base64-кодировке, или как URI указывающего на файл изображения. Метод возвращает объект `CameraPopoverHandle`, который может использоваться для перемещения инструмента выбора файла. + + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); + + +### Описание + +Функция `camera.getPicture` открывает приложение камеры устройства, которое позволяет снимать фотографии. Это происходит по умолчанию, когда `Camera.sourceType` равно `Camera.PictureSourceType.CAMERA` . Как только пользователь делает снимок,приложение камеры закрывается и приложение восстанавливается. + +Если `Camera.sourceType` является `Camera.PictureSourceType.PHOTOLIBRARY` или `Camera.PictureSourceType.SAVEDPHOTOALBUM` , то показывается диалоговое окно, которое позволяет пользователям выбрать существующее изображение. Функция `camera.getPicture` возвращает объект `CameraPopoverHandle` объект, который может использоваться для перемещения диалога выбора изображения, например, при изменении ориентации устройства. + +Возвращаемое значение отправляется в функцию обратного вызова `cameraSuccess` в одном из следующих форматов, в зависимости от параметра `cameraOptions` : + +* A объект `String` содержащий фото изображение в base64-кодировке. + +* Объект `String` представляющий расположение файла изображения на локальном хранилище (по умолчанию). + +Вы можете сделать все, что угодно вы хотите с закодированным изображением или URI, например: + +* Отобразить изображение с помощью тега ``, как показано в примере ниже + +* Сохранять данные локально (`LocalStorage`, [Lawnchair][1], и т.д.) + +* Отправлять данные на удаленный сервер + + [1]: http://brianleroux.github.com/lawnchair/ + +**Примечание**: разрешение фото на более новых устройствах является достаточно хорошим. Фотографии из галереи устройства не масштабируются к более низкому качеству, даже если указан параметр `quality`. Чтобы избежать общих проблем с памятью, установите `Camera.destinationType` в `FILE_URI` вместо `DATA_URL`. + +### Поддерживаемые платформы + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Обозреватель +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 и 8 +* Windows 8 + +### Предпочтения (iOS) + +* **CameraUsesGeolocation** (логическое значение, по умолчанию false). Для захвата изображения JPEG, значение true, чтобы получить данные геопозиционирования в заголовке EXIF. Это вызовет запрос на разрешения геолокации, если задано значение true. + + + + +### Особенности Amazon Fire OS + +Amazon Fire OS используют намерения для запуска активности камеры на устройстве для съемки фотографий, и на устройствах с низким объемам памяти, активность Cordova может быть завершена. В этом случае изображение может не появиться при восстановлении активности Cordova. + +### Особенности Android + +Android используют намерения для запуска активности камеры на устройстве для съемки фотографий, и на устройствах с низким объемам памяти, активность Cordova может быть завершена. В этом случае изображение может не появиться при восстановлении активности Cordova. + +### Браузер причуды + +Может возвращать только фотографии как изображения в кодировке base64. + +### Особенности Firefox OS + +Плагин Camera на данный момент реализован с использованием [Web Activities][2]. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### Особенности iOS + +Включение функции JavaScript `alert()` в любой из функций обратного вызова функции может вызвать проблемы. Оберните вызов alert в `setTimeout()` для позволения окну выбора изображений iOS полностью закрыться перед отображение оповещения: + + setTimeout(function() {/ / ваши вещи!}, 0); + + +### Особенности Windows Phone 7 + +Вызов встроенного приложения камеры, в то время как устройство подключено к Zune не работает, и инициирует обратный вызов для ошибки. + +### Особенности Tizen + +Tizen поддерживает только значение `destinationType` равное `Camera.DestinationType.FILE_URI` и значение `sourceType` равное `Camera.PictureSourceType.PHOTOLIBRARY`. + +### Пример + +Сделайте фотографию и получите его как изображение в base64-кодировке: + + 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); + } + + +Сделайте фотографию и получить расположение файла с изображением: + + 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 + +Необязательные параметры для настройки параметров камеры. + + { 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 }; + + +### Параметры + +* **quality**: качество сохраняемого изображения, выражается в виде числа в диапазоне от 0 до 100, где 100 является обычно полным изображением без потери качества при сжатии. Значение по умолчанию — 50. *(Число)* (Обратите внимание, что информация о разрешении камеры недоступна.) + +* **параметр destinationType**: выберите формат возвращаемого значения. Значение по умолчанию — FILE_URI. Определяется в `navigator.camera.DestinationType` *(число)* + + Camera.DestinationType = { + DATA_URL: 0, / / возвращение изображения в base64-кодировке строки + FILE_URI: 1, / / возврат файла изображения URI + NATIVE_URI: 2 / / возвращение образа собственного URI (например, Библиотека активов: / / на iOS или содержание: / / на андроиде) + }; + + +* **тип источника**: установить источник рисунка. По умолчанию используется камера. Определяется в `navigator.camera.PictureSourceType` *(число)* + + Camera.PictureSourceType = { + PHOTOLIBRARY: 0, + CAMERA: 1, + SAVEDPHOTOALBUM: 2 + }; + + +* **allowEdit**: позволит редактирование изображения средствами телефона перед окончательным выбором изображения. *(Логический)* + +* **Тип_шифрования**: выберите возвращенный файл в кодировку. Значение по умолчанию — JPEG. Определяется в `navigator.camera.EncodingType` *(число)* + + Camera.EncodingType = { + JPEG: 0, // возвращает изображение в формате JPEG + PNG: 1 // возвращает рисунок в формате PNG + }; + + +* **targetWidth**: ширина изображения в пикселах к которой необходимо осуществить масштабирование. Это значение должно использоваться совместно с **targetHeight**. Пропорции изображения останутся неизменными. *(Число)* + +* **targetHeight**: высота изображения в пикселах к которой необходимо осуществить масштабирование. Это значение должно использоваться совместно с **targetWidth**. Пропорции изображения останутся неизменными. *(Число)* + +* **тип носителя**: Установите источник получения изображения, из которого надо выбрать изображение. Работает только если `PictureSourceType` равно `PHOTOLIBRARY` или `SAVEDPHOTOALBUM` . Определяется в `nagivator.camera.MediaType` *(число)* + + Camera.MediaType = { + PICTURE: 0, / / разрешить выбор только сохраненных изображений. 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**: вращает изображение, чтобы внести исправления к ориентации устройства во время захвата. *(Логический)* + +* **saveToPhotoAlbum**: сохранить изображение в фотоальбом на устройстве после захвата. *(Логическое)* + +* **popoverOptions**: только для iOS параметры, которые определяют местоположение инструмента в iPad. Определены в`CameraPopoverOptions`. + +* **cameraDirection**: выбрать камеру для использования (передней или задней стороне). Значение по умолчанию — обратно. Определяется в `navigator.camera.Direction` *(число)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### Особенности Amazon Fire OS + +* Любое значение `cameraDirection` возвращает фотографию сделанную задней камерой. + +* Игнорирует параметр `allowEdit`. + +* Оба параметра `Camera.PictureSourceType.PHOTOLIBRARY` и `Camera.PictureSourceType.SAVEDPHOTOALBUM` отображают один и тот же фотоальбом. + +### Особенности Android + +* Любое значение `cameraDirection` возвращает фотографию сделанную задней камерой. + +* Игнорирует параметр `allowEdit`. + +* Оба параметра `Camera.PictureSourceType.PHOTOLIBRARY` и `Camera.PictureSourceType.SAVEDPHOTOALBUM` отображают один и тот же фотоальбом. + +### Особенности BlackBerry 10 + +* Игнорирует `quality` параметр. + +* Игнорирует параметр `allowEdit`. + +* `Camera.MediaType` не поддерживается. + +* Игнорирует параметр `correctOrientation`. + +* Игнорирует параметр `cameraDirection`. + +### Особенности Firefox OS + +* Игнорирует `quality` параметр. + +* Значение `Camera.DestinationType` игнорируется и равно `1` (URI для файла изображения) + +* Игнорирует параметр `allowEdit`. + +* Игнорирует параметр `PictureSourceType` (пользователь выбирает его в диалоговом окне) + +* Игнорирует параметр `encodingType` + +* Игнорирует `targetWidth` и `targetHeight` + +* `Camera.MediaType` не поддерживается. + +* Игнорирует параметр `correctOrientation`. + +* Игнорирует параметр `cameraDirection`. + +### Особенности iOS + +* Установите `quality` ниже 50, для того чтобы избежать ошибок памяти на некоторых устройствах. + +* При использовании `destinationType.FILE_URI` , фотографии сохраняются во временном каталоге приложения. Содержимое приложения временного каталога удаляется при завершении приложения. + +### Особенности Tizen + +* options, не поддерживается + +* всегда возвращает URI файла + +### Особенности Windows Phone 7 и 8 + +* Игнорирует параметр `allowEdit`. + +* Игнорирует параметр `correctOrientation`. + +* Игнорирует параметр `cameraDirection`. + +* Игнорирует `saveToPhotoAlbum` параметр. Важно: Все изображения, снятые камерой wp7/8 cordova API всегда копируются в рулон камеры телефона. В зависимости от параметров пользователя это также может означать, что изображение автоматически загружены на их OneDrive. Потенциально это может означать, что этот образ доступен для более широкой аудитории, чем ваше приложение предназначено. Если этот блокатор для вашего приложения, вам нужно будет осуществить CameraCaptureTask, как описано на сайте msdn: вы можете также комментарий или вверх голосование связанный с этим вопрос [отслеживания][3] + +* Игнорирует свойство `mediaType` объекта `cameraOptions` так как Windows Phone SDK не предоставляет способ выбрать видео из PHOTOLIBRARY. + + [3]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +Функция обратного вызова вызываемая в случае возникновения ошибки. + + function(message) { + // Show a helpful message + } + + +### Параметры + +* **сообщение**: сообщение об ошибке предоставляемое платформой устройства. *(Строка)* + +## cameraSuccess + +Функция обратного вызова onSuccess, получающая данные изображения. + + function(imageData) { + // Do something with the image + } + + +### Параметры + +* **imageData**: Данные изображения в Base64 кодировке, *или* URI, в зависимости от применяемых параметров `cameraOptions`. *(Строка)* + +### Пример + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +Дескриптор диалогового окна инструмента, созданный `navigator.camera.getPicture`. + +### Методы + +* **setPosition**: Задайте положение инструмента выбора изображения. + +### Поддерживаемые платформы + +* iOS + +### setPosition + +Устанавливает положение инструмента выбора изображения. + +**Параметры**: + +* `cameraPopoverOptions`: Объект `CameraPopoverOptions`, определяющий новое положение + +### Пример + + 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, которые определяют расположение элемента привязки и направление стрелки инструмента при выборе изображений из библиотеки изображений iPad или альбома. + + {x: 0, y: 32, ширина: 320, высота: 480, arrowDir: Camera.PopoverArrowDirection.ARROW_ANY}; + + +### CameraPopoverOptions + +* **x**: x координата в пикселях элемента экрана, на котором закрепить инструмента. *(Число)* + +* **x**: y координата в пикселях элемента экрана, на котором закрепить инструмента. *(Число)* + +* **width**: ширина в пикселях элемента экрана, на котором закрепить инструмент выбора изображения. *(Число)* + +* **height**: высота в пикселях элемента экрана, на котором закрепить инструмент выбора изображения. *(Число)* + +* **arrowDir**: Направление, куда должна указывать стрелка на инструменте. Определено в `Camera.PopoverArrowDirection` *(число)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +Обратите внимание, что размер инструмента может изменяться для корректировки в зависимости направлении стрелки и ориентации экрана. Убедитесь, что учитываете возможные изменения ориентации при указании расположения элемента привязки. + +## navigator.camera.cleanup + +Удаляет промежуточные фотографии, сделанные камерой из временного хранилища. + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +### Описание + +Удаляет промежуточные файлы изображений, которые хранятся во временном хранилище после вызова метода `camera.getPicture` . Применяется только тогда, когда значение `Camera.sourceType` равно `Camera.PictureSourceType.CAMERA` и `Camera.destinationType` равняется `Camera.DestinationType.FILE_URI`. + +### Поддерживаемые платформы + +* iOS + +### Пример + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } diff --git a/plugins/cordova-plugin-camera/doc/zh/README.md b/plugins/cordova-plugin-camera/doc/zh/README.md new file mode 100644 index 0000000..2f7c9e6 --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/zh/README.md @@ -0,0 +1,421 @@ + + +# cordova-plugin-camera + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg)](https://travis-ci.org/apache/cordova-plugin-camera) + +這個外掛程式定義了一個全球 `navigator.camera` 物件,它提供了 API,拍照,從系統的圖像庫中選擇圖像。 + +雖然該物件附加到全球範圍內 `導航器`,它不可用直到 `deviceready` 事件之後。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## 安裝 + + cordova plugin add cordova-plugin-camera + + +## API + + * 相機 + * navigator.camera.getPicture(success, fail, options) + * CameraOptions + * CameraPopoverHandle + * CameraPopoverOptions + * navigator.camera.cleanup + +## navigator.camera.getPicture + +需要一張照片,使用相機,或從設備的圖像庫檢索一張照片。 圖像被傳遞給成功回檔的 base64 編碼 `String`,或作為 URI 為影像檔。 該方法本身返回一個 `CameraPopoverHandle` 物件,它可以用來重新置放檔選擇氣泡框。 + + navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + + +#### 說明 + +`camera.getPicture` 函數打開該設備的預設攝像頭應用程式,允許使用者拍照。 `Camera.sourceType` 等於 `Camera.PictureSourceType.CAMERA` 時,預設情況下,發生此行為。 一旦使用者打斷了他的照片,相機應用程式關閉,且應用程式還原。 + +如果 `Camera.sourceType` 是 `Camera.PictureSourceType.PHOTOLIBRARY` 或 `Camera.PictureSourceType.SAVEDPHOTOALBUM`,然後顯示一個對話方塊,允許使用者選擇一個現有的圖像。 `camera.getPicture` 函數返回一個 `CameraPopoverHandle` 物件,它可以用於重新置放圖像選擇的對話方塊,例如,當設備的方向變化。 + +傳回值是發送到 `cameraSuccess` 回呼函數中,在以下的格式,具體取決於指定的 `cameraOptions` 之一: + + * A `String` 包含的 base64 編碼的照片圖像。 + + * A `String` 表示在本機存放區 (預設值) 上的影像檔位置。 + +你可以做任何你想要的編碼的圖像或 URI,例如: + + * 呈現在圖像 `` 標記,如下面的示例所示 + + * 保存本地的資料 ( `LocalStorage` , [Lawnchair](http://brianleroux.github.com/lawnchair/),等等.) + + * 將資料發佈到遠端伺服器 + +**注**: 在更新設備上的照片解析度是很好。 選擇從設備的庫的照片是不壓縮螢幕使其以較低的品質,即使指定了一個 `quality` 參數。 要避免常見的記憶體問題,請將 `Camera.destinationType` 設置為 `FILE_URI`,而不是 `DATA_URL`. + +#### 支援的平臺 + +![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png) + +#### 示例 + +拍一張照片,並檢索它作為一個 base64 編碼的圖像: + + 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); + } + + +拍一張照片和檢索圖像的檔位置: + + 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); + } + + +#### 首選項 (iOS) + + * **CameraUsesGeolocation**(布林值,預設值為 false)。 用於捕獲 jpeg 檔,設置為 true,以在 EXIF 頭資訊中獲取地理定位資料。 這將觸發請求的地理位置的許可權,如果設置為 true。 + + + + +#### 亞馬遜火 OS 怪癖 + +亞馬遜火 OS 使用意圖啟動相機活動設備來捕捉圖像上, 和手機上記憶體不足,科爾多瓦活動可能被殺害。 在這種情況下,可能不會顯示圖像時恢復了科爾多瓦活動。 + +#### Android 的怪癖 + +Android 使用意圖以啟動相機活動設備來捕捉圖像上, 和手機上記憶體不足,科爾多瓦活動可能被殺害。 在這種情況下,可能不會顯示圖像時恢復了科爾多瓦活動。 + +#### 瀏覽器的怪癖 + +可以只返回照片作為 base64 編碼的圖像。 + +#### 火狐瀏覽器作業系統的怪癖 + +觀景窗外掛程式目前實施使用 [Web 活動](https://hacks.mozilla.org/2013/01/introducing-web-activities/). + +#### iOS 的怪癖 + +包括 JavaScript `alert ()` 中的回呼函數會導致問題。 包裝內 `setTimeout()` 允許 iOS 圖像選取器或氣泡框以完全關閉之前,警報將顯示警報: + + setTimeout(function() { + // do your thing here! + }, 0); + + +#### Windows Phone 7 的怪癖 + +調用本機攝像頭應用程式,而通過 Zune 所連接的設備不能工作,並且觸發錯誤回檔。 + +#### Tizen 怪癖 + +泰只支援 `destinationType` 的 `Camera.DestinationType.FILE_URI` 和 `Camera.PictureSourceType.PHOTOLIBRARY` 的 `sourceType`. + +## CameraOptions + +要自訂相機設置的可選參數。 + + { 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 }; + + + * **品質**: 保存的圖像,表示為範圍 0-100,100,是通常全解析度,無損失從檔案壓縮的品質。 預設值為 50。 *(人數)*(請注意相機的解析度有關的資訊是不可用)。 + + * **可**: 選擇傳回值的格式。預設值是 FILE_URI。定義在 `navigator.camera.DestinationType` *(人數)* + + 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) + }; + + + * **時**: 設置圖片的來源。預設值是觀景窗。定義在 `navigator.camera.PictureSourceType` *(人數)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + + * **allowEdit**: 允許簡單編輯前選擇圖像。*(布林)* + + * **encodingType**: 選擇返回的影像檔的編碼。預設值為 JPEG。定義在 `navigator.camera.EncodingType` *(人數)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + + * **targetWidth**: 向尺度圖像的圖元寬度。必須用**targetHeight**。縱橫比保持不變。*(人數)* + + * **targetHeight**: 以圖元為單位向尺度圖像的高度。必須用**targetWidth**。縱橫比保持不變。*(人數)* + + * **媒體類型**: 設置的媒體,從選擇類型。 時才起作用 `PictureSourceType` 是 `PHOTOLIBRARY` 或 `SAVEDPHOTOALBUM` 。 定義在 `nagivator.camera.MediaType` *(人數)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. 預設情況。 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**: 旋轉圖像,該設備時捕獲的定向的正確。*(布林)* + + * **saveToPhotoAlbum**: 將圖像保存到相冊在設備上捕獲後。*(布林)* + + * **popoverOptions**: 只有 iOS 在 iPad 中指定氣泡框位置的選項。在中定義`CameraPopoverOptions`. + + * **cameraDirection**: 選擇相機以使用 (前面或後面-面向)。預設值是背。定義在 `navigator.camera.Direction` *(人數)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +#### 亞馬遜火 OS 怪癖 + + * 任何 `cameraDirection` 值回朝的照片中的結果。 + + * 忽略 `allowEdit` 參數。 + + * `Camera.PictureSourceType.PHOTOLIBRARY`和 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 都顯示相同的相冊。 + +#### Android 的怪癖 + + * 任何 `cameraDirection` 值回朝的照片中的結果。 + + * 安卓也用於作物活動 allowEdit,即使作物應工作,實際上將裁剪的圖像傳回給科爾多瓦,那個唯一的作品一直是一個與谷歌加上照片應用程式捆綁在一起。 其他作物可能無法工作。 + + * `Camera.PictureSourceType.PHOTOLIBRARY`和 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 都顯示相同的相冊。 + +#### 黑莓 10 怪癖 + + * 忽略 `quality` 參數。 + + * 忽略 `allowEdit` 參數。 + + * `Camera.MediaType`不受支援。 + + * 忽略 `correctOrientation` 參數。 + + * 忽略 `cameraDirection` 參數。 + +#### 火狐瀏覽器作業系統的怪癖 + + * 忽略 `quality` 參數。 + + * `Camera.DestinationType`將被忽略並且等於 `1` (影像檔的 URI) + + * 忽略 `allowEdit` 參數。 + + * 忽略 `PictureSourceType` 參數 (使用者選擇它在對話方塊視窗中) + + * 忽略`encodingType` + + * 忽略了 `targetWidth` 和`targetHeight` + + * `Camera.MediaType`不受支援。 + + * 忽略 `correctOrientation` 參數。 + + * 忽略 `cameraDirection` 參數。 + +#### iOS 的怪癖 + + * 設置 `quality` 低於 50,避免在某些設備上的記憶體不足錯誤。 + + * 當使用 `destinationType.FILE_URI` ,照片都保存在應用程式的臨時目錄。應用程式結束時,將刪除該應用程式的臨時目錄中的內容。 + +#### Tizen 怪癖 + + * 不支援的選項 + + * 總是返回一個檔的 URI + +#### Windows Phone 7 和 8 怪癖 + + * 忽略 `allowEdit` 參數。 + + * 忽略 `correctOrientation` 參數。 + + * 忽略 `cameraDirection` 參數。 + + * 忽略 `saveToPhotoAlbum` 參數。 重要: 使用 wp7/8 科爾多瓦攝像頭 API 拍攝的所有圖像總是都複製到手機的相機膠捲。 根據使用者的設置,這可能也意味著圖像是自動上傳到他們另。 這有可能意味著的圖像,可以比你的應用程式的目的更多的觀眾。 如果此阻滯劑您的應用程式,您將需要實現 CameraCaptureTask 在 msdn 上記載: [HTTP://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx](http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx)你可能還評論或在[問題追蹤器](https://issues.apache.org/jira/browse/CB-2083)的向上投票的相關的問題 + + * 忽略了 `mediaType` 屬性的 `cameraOptions` 作為 Windows Phone SDK 並不提供從 PHOTOLIBRARY 中選擇視頻的方法。 + +## CameraError + +onError 的回呼函數提供了一條錯誤訊息。 + + function(message) { + // Show a helpful message + } + + +#### 說明 + + * **message**: 消息提供的設備的本機代碼。*(String)* + +## cameraSuccess + +提供的圖像資料的 onSuccess 回呼函數。 + + function(imageData) { + // Do something with the image + } + + +#### 說明 + + * **imageData**: Base64 編碼進行編碼的圖像資料,*或*影像檔的 URI,取決於 `cameraOptions` 效果。*(String)* + +#### 示例 + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +由 `navigator.camera.getPicture` 創建的氣泡框對話方塊的控制碼. + +#### 說明 + + * **setPosition**: Set the position of the popover. Takes the `CameraPopoverOptions` that specify the new position. + +#### 支援的平臺 + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### 示例 + + 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 僅指定氣泡框的錨元素的位置和箭頭方向,從 iPad 庫或專輯選擇圖像時的參數。 + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +#### 說明 + + * **x**: x 螢幕元素到其錨定氣泡框上的圖元座標。*(人數)* + + * **y**: 螢幕元素到其錨定氣泡框上的 y 圖元座標。*(人數)* + + * **width**: 寬度以圖元為單位),到其錨定氣泡框上的螢幕元素。*(人數)* + + * **height**: 高度以圖元為單位),到其錨定氣泡框上的螢幕元素。*(人數)* + + * **arrowDir**: 氣泡框上的箭頭應指向的方向。定義在 `Camera.PopoverArrowDirection` *(人數)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +請注意氣泡框的大小可能會更改箭頭的方向和螢幕的方向進行調整。 請確保帳戶方向更改時指定錨元素位置。 + +## navigator.camera.cleanup + +刪除中間從臨時存儲攝像機所拍攝的照片。 + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +#### 說明 + +刪除保留在臨時存儲在調用 `camera.getPicture` 後的中間的影像檔。 適用只有當 `Camera.sourceType` 的值等於 `Camera.PictureSourceType.CAMERA` 和 `Camera.destinationType` 等於 `Camera.DestinationType.FILE_URI`. + +#### 支援的平臺 + +![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png) + +#### 示例 + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/doc/zh/index.md b/plugins/cordova-plugin-camera/doc/zh/index.md new file mode 100644 index 0000000..ab719ab --- /dev/null +++ b/plugins/cordova-plugin-camera/doc/zh/index.md @@ -0,0 +1,435 @@ + + +# cordova-plugin-camera + +這個外掛程式定義了一個全球 `navigator.camera` 物件,它提供了 API,拍照,從系統的圖像庫中選擇圖像。 + +雖然該物件附加到全球範圍內 `導航器`,它不可用直到 `deviceready` 事件之後。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(navigator.camera); + } + + +## 安裝 + + cordova plugin add cordova-plugin-camera + + +## navigator.camera.getPicture + +需要一張照片,使用相機,或從設備的圖像庫檢索一張照片。 圖像被傳遞給成功回檔的 base64 編碼 `String`,或作為 URI 為影像檔。 該方法本身返回一個 `CameraPopoverHandle` 物件,它可以用來重新置放檔選擇氣泡框。 + + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); + + +### 說明 + +`camera.getPicture` 函數打開該設備的預設攝像頭應用程式,允許使用者拍照。 `Camera.sourceType` 等於 `Camera.PictureSourceType.CAMERA` 時,預設情況下,發生此行為。 一旦使用者打斷了他的照片,相機應用程式關閉,且應用程式還原。 + +如果 `Camera.sourceType` 是 `Camera.PictureSourceType.PHOTOLIBRARY` 或 `Camera.PictureSourceType.SAVEDPHOTOALBUM`,然後顯示一個對話方塊,允許使用者選擇一個現有的圖像。 `camera.getPicture` 函數返回一個 `CameraPopoverHandle` 物件,它可以用於重新置放圖像選擇的對話方塊,例如,當設備的方向變化。 + +傳回值是發送到 `cameraSuccess` 回呼函數中,在以下的格式,具體取決於指定的 `cameraOptions` 之一: + +* A `String` 包含的 base64 編碼的照片圖像。 + +* A `String` 表示在本機存放區 (預設值) 上的影像檔位置。 + +你可以做任何你想要的編碼的圖像或 URI,例如: + +* 呈現在圖像 `` 標記,如下面的示例所示 + +* 保存本地的資料 ( `LocalStorage` , [Lawnchair][1],等等.) + +* 將資料發佈到遠端伺服器 + + [1]: http://brianleroux.github.com/lawnchair/ + +**注**: 在更新設備上的照片解析度是很好。 選擇從設備的庫的照片是不壓縮螢幕使其以較低的品質,即使指定了一個 `quality` 參數。 要避免常見的記憶體問題,請將 `Camera.destinationType` 設置為 `FILE_URI`,而不是 `DATA_URL`. + +### 支援的平臺 + +* 亞馬遜火 OS +* Android 系統 +* 黑莓 10 +* 瀏覽器 +* 火狐瀏覽器的作業系統 +* iOS +* 泰 +* Windows Phone 7 和 8 +* Windows 8 + +### 首選項 (iOS) + +* **CameraUsesGeolocation**(布林值,預設值為 false)。 用於捕獲 jpeg 檔,設置為 true,以在 EXIF 頭資訊中獲取地理定位資料。 這將觸發請求的地理位置的許可權,如果設置為 true。 + + + + +### 亞馬遜火 OS 怪癖 + +亞馬遜火 OS 使用意圖啟動相機活動設備來捕捉圖像上, 和手機上記憶體不足,科爾多瓦活動可能被殺害。 在這種情況下,可能不會顯示圖像時恢復了科爾多瓦活動。 + +### Android 的怪癖 + +Android 使用意圖以啟動相機活動設備來捕捉圖像上, 和手機上記憶體不足,科爾多瓦活動可能被殺害。 在這種情況下,可能不會顯示圖像時恢復了科爾多瓦活動。 + +### 瀏覽器的怪癖 + +可以只返回照片作為 base64 編碼的圖像。 + +### 火狐瀏覽器作業系統的怪癖 + +觀景窗外掛程式目前實施使用 [Web 活動][2]. + + [2]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ + +### iOS 的怪癖 + +包括 JavaScript `alert ()` 中的回呼函數會導致問題。 包裝內 `setTimeout()` 允許 iOS 圖像選取器或氣泡框以完全關閉之前,警報將顯示警報: + + setTimeout(function() { + // do your thing here! + }, 0); + + +### Windows Phone 7 的怪癖 + +調用本機攝像頭應用程式,而通過 Zune 所連接的設備不能工作,並且觸發錯誤回檔。 + +### 泰怪癖 + +泰只支援 `destinationType` 的 `Camera.DestinationType.FILE_URI` 和 `Camera.PictureSourceType.PHOTOLIBRARY` 的 `sourceType`. + +### 示例 + +拍一張照片,並檢索它作為一個 base64 編碼的圖像: + + 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); + } + + +拍一張照片和檢索圖像的檔位置: + + 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 + +要自訂相機設置的可選參數。 + + { 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 }; + + +### 選項 + +* **品質**: 保存的圖像,表示為範圍 0-100,100,是通常全解析度,無損失從檔案壓縮的品質。 預設值為 50。 *(人數)*(請注意相機的解析度有關的資訊是不可用)。 + +* **可**: 選擇傳回值的格式。預設值是 FILE_URI。定義在 `navigator.camera.DestinationType` *(人數)* + + 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) + }; + + +* **時**: 設置圖片的來源。預設值是觀景窗。定義在 `navigator.camera.PictureSourceType` *(人數)* + + Camera.PictureSourceType = { + PHOTOLIBRARY : 0, + CAMERA : 1, + SAVEDPHOTOALBUM : 2 + }; + + +* **allowEdit**: 允許簡單編輯前選擇圖像。*(布林)* + +* **encodingType**: 選擇返回的影像檔的編碼。預設值為 JPEG。定義在 `navigator.camera.EncodingType` *(人數)* + + Camera.EncodingType = { + JPEG : 0, // Return JPEG encoded image + PNG : 1 // Return PNG encoded image + }; + + +* **targetWidth**: 向尺度圖像的圖元寬度。必須用**targetHeight**。縱橫比保持不變。*(人數)* + +* **targetHeight**: 以圖元為單位向尺度圖像的高度。必須用**targetWidth**。縱橫比保持不變。*(人數)* + +* **媒體類型**: 設置的媒體,從選擇類型。 時才起作用 `PictureSourceType` 是 `PHOTOLIBRARY` 或 `SAVEDPHOTOALBUM` 。 定義在 `nagivator.camera.MediaType` *(人數)* + + Camera.MediaType = { + PICTURE: 0, // allow selection of still pictures only. 預設情況。 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**: 旋轉圖像,該設備時捕獲的定向的正確。*(布林)* + +* **saveToPhotoAlbum**: 將圖像保存到相冊在設備上捕獲後。*(布林)* + +* **popoverOptions**: 只有 iOS 在 iPad 中指定氣泡框位置的選項。在中定義`CameraPopoverOptions`. + +* **cameraDirection**: 選擇相機以使用 (前面或後面-面向)。預設值是背。定義在 `navigator.camera.Direction` *(人數)* + + Camera.Direction = { + BACK : 0, // Use the back-facing camera + FRONT : 1 // Use the front-facing camera + }; + + +### 亞馬遜火 OS 怪癖 + +* 任何 `cameraDirection` 值回朝的照片中的結果。 + +* 忽略 `allowEdit` 參數。 + +* `Camera.PictureSourceType.PHOTOLIBRARY`和 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 都顯示相同的相冊。 + +### Android 的怪癖 + +* 任何 `cameraDirection` 值結果在背面的照片。 + +* 忽略 `allowEdit` 參數。 + +* `Camera.PictureSourceType.PHOTOLIBRARY`和 `Camera.PictureSourceType.SAVEDPHOTOALBUM` 都顯示相同的寫真集。 + +### 黑莓 10 的怪癖 + +* 忽略 `quality` 參數。 + +* 忽略 `allowEdit` 參數。 + +* `Camera.MediaType`不受支援。 + +* 忽略 `correctOrientation` 參數。 + +* 忽略 `cameraDirection` 參數。 + +### 火狐瀏覽器作業系統的怪癖 + +* 忽略 `quality` 參數。 + +* `Camera.DestinationType`將被忽略並且等於 `1` (影像檔的 URI) + +* 忽略 `allowEdit` 參數。 + +* 忽略 `PictureSourceType` 參數 (使用者選擇它在對話方塊視窗中) + +* 忽略`encodingType` + +* 忽略了 `targetWidth` 和`targetHeight` + +* `Camera.MediaType`不受支援。 + +* 忽略 `correctOrientation` 參數。 + +* 忽略 `cameraDirection` 參數。 + +### iOS 的怪癖 + +* 設置 `quality` 低於 50,避免在某些設備上的記憶體不足錯誤。 + +* 當使用 `destinationType.FILE_URI` ,照片都保存在應用程式的臨時目錄。應用程式結束時,將刪除該應用程式的臨時目錄中的內容。 + +### 泰怪癖 + +* 不支援的選項 + +* 總是返回一個檔的 URI + +### Windows Phone 7 和 8 的怪癖 + +* 忽略 `allowEdit` 參數。 + +* 忽略 `correctOrientation` 參數。 + +* 忽略 `cameraDirection` 參數。 + +* 忽略 `saveToPhotoAlbum` 參數。 重要: 使用 wp7/8 科爾多瓦攝像頭 API 拍攝的所有圖像總是都複製到手機的相機膠捲。 根據使用者的設置,這可能也意味著圖像是自動上傳到他們另。 這有可能意味著的圖像,可以比你的應用程式的目的更多的觀眾。 如果此阻滯劑您的應用程式,您將需要實現 CameraCaptureTask 在 msdn 上記載: [HTTP://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx][3]你可能還評論或在[問題追蹤器][4]的向上投票的相關的問題 + +* 忽略了 `mediaType` 屬性的 `cameraOptions` 作為 Windows Phone SDK 並不提供從 PHOTOLIBRARY 中選擇視頻的方法。 + + [3]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx + [4]: https://issues.apache.org/jira/browse/CB-2083 + +## CameraError + +onError 的回呼函數提供了一條錯誤訊息。 + + function(message) { + // Show a helpful message + } + + +### 參數 + +* **message**: 消息提供的設備的本機代碼。*(String)* + +## cameraSuccess + +提供的圖像資料的 onSuccess 回呼函數。 + + function(imageData) { + // Do something with the image + } + + +### 參數 + +* **imageData**: Base64 編碼進行編碼的圖像資料,*或*影像檔的 URI,取決於 `cameraOptions` 效果。*(String)* + +### 示例 + + // Show image + // + function cameraCallback(imageData) { + var image = document.getElementById('myImage'); + image.src = "data:image/jpeg;base64," + imageData; + } + + +## CameraPopoverHandle + +由 `navigator.camera.getPicture` 創建的氣泡框對話方塊的控制碼. + +### 方法 + +* **setPosition**: 設置氣泡框的位置。 + +### 支援的平臺 + +* iOS + +### setPosition + +設置氣泡框的位置。 + +**參數**: + +* `cameraPopoverOptions`: `CameraPopoverOptions` ,指定新的位置 + +### 示例 + + 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 僅指定氣泡框的錨元素的位置和箭頭方向,從 iPad 庫或專輯選擇圖像時的參數。 + + { x : 0, + y : 32, + width : 320, + height : 480, + arrowDir : Camera.PopoverArrowDirection.ARROW_ANY + }; + + +### CameraPopoverOptions + +* **x**: x 螢幕元素到其錨定氣泡框上的圖元座標。*(人數)* + +* **y**: 螢幕元素到其錨定氣泡框上的 y 圖元座標。*(人數)* + +* **width**: 寬度以圖元為單位),到其錨定氣泡框上的螢幕元素。*(人數)* + +* **height**: 高度以圖元為單位),到其錨定氣泡框上的螢幕元素。*(人數)* + +* **arrowDir**: 氣泡框上的箭頭應指向的方向。定義在 `Camera.PopoverArrowDirection` *(人數)* + + Camera.PopoverArrowDirection = { + ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }; + + +請注意氣泡框的大小可能會更改箭頭的方向和螢幕的方向進行調整。 請確保帳戶方向更改時指定錨元素位置。 + +## navigator.camera.cleanup + +刪除中間從臨時存儲攝像機所拍攝的照片。 + + navigator.camera.cleanup( cameraSuccess, cameraError ); + + +### 描述 + +刪除保留在臨時存儲在調用 `camera.getPicture` 後的中間的影像檔。 適用只有當 `Camera.sourceType` 的值等於 `Camera.PictureSourceType.CAMERA` 和 `Camera.destinationType` 等於 `Camera.DestinationType.FILE_URI`. + +### 支援的平臺 + +* iOS + +### 示例 + + navigator.camera.cleanup(onSuccess, onFail); + + function onSuccess() { + console.log("Camera cleanup success.") + } + + function onFail(message) { + alert('Failed because: ' + message); + } diff --git a/plugins/cordova-plugin-camera/jsdoc2md/TEMPLATE.md b/plugins/cordova-plugin-camera/jsdoc2md/TEMPLATE.md new file mode 100644 index 0000000..687b0fd --- /dev/null +++ b/plugins/cordova-plugin-camera/jsdoc2md/TEMPLATE.md @@ -0,0 +1,205 @@ +{{>cdv-license~}} + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-camera) + +# cordova-plugin-camera + +This plugin defines a global `navigator.camera` object, which provides an API for taking pictures and for choosing images from +the system's image library. + +{{>cdv-header device-ready-warning-obj='navigator.camera' npmName='cordova-plugin-camera' cprName='org.apache.cordova.camera' pluginName='Plugin Camera' repoUrl='https://github.com/apache/cordova-plugin-camera' }} + +--- + +# API Reference + +{{#orphans~}} +{{>member-index}} +{{/orphans}} +* [CameraPopoverHandle](#module_CameraPopoverHandle) +* [CameraPopoverOptions](#module_CameraPopoverOptions) + +--- + +{{#modules~}} +{{>header~}} +{{>body~}} +{{>members~}} + +--- + +{{/modules}} + +## `camera.getPicture` Errata + +#### Example + +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); + } + +Take a photo and retrieve it as a Base64-encoded image: + + /** + * Warning: Using DATA_URL is not recommended! The DATA_URL destination + * type is very memory intensive, even with a low quality setting. Using it + * can result in out of memory errors and application crashes. Use FILE_URI + * or NATIVE_URI instead. + */ + navigator.camera.getPicture(onSuccess, onFail, { quality: 25, + 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); + } + +#### Preferences (iOS) + +- __CameraUsesGeolocation__ (boolean, defaults to false). For capturing JPEGs, set to true to get geolocation data in the EXIF header. This will trigger a request for geolocation permissions if set to true. + + + +#### 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 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 result from the plugin call will be delivered via the resume event. +See [the Android Lifecycle guide][android_lifecycle] +for more information. The `pendingResult.result` value will contain the value that +would be passed to the callbacks (either the URI/URL or an error message). Check +the `pendingResult.pluginStatus` to determine whether or not the call was +successful. + +#### Browser Quirks + +Can only return photos as Base64-encoded image. + +#### Firefox OS Quirks + +Camera plugin is currently implemented using [Web Activities][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`. + + +## `CameraOptions` Errata + +#### Amazon Fire OS 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. + +#### Android Quirks + +- Any `cameraDirection` value results in a back-facing photo. + +- **`allowEdit` is unpredictable on Android and it should not be used!** The Android implementation of this plugin tries to find and use an application on the user's device to do image cropping. The plugin has no control over what application the user selects to perform the image cropping and it is very possible that the user could choose an incompatible option and cause the plugin to fail. This sometimes works because most devices come with an application that handles cropping in a way that is compatible with this plugin (Google Plus Photos), but it is unwise to rely on that being the case. If image editing is essential to your application, consider seeking a third party library or plugin that provides its own image editing utility for a more robust solution. + +- `Camera.PictureSourceType.PHOTOLIBRARY` and `Camera.PictureSourceType.SAVEDPHOTOALBUM` both display the same photo album. + +- Ignores the `encodingType` parameter if the image is unedited (i.e. `quality` is 100, `correctOrientation` is false, and no `targetHeight` or `targetWidth` are specified). The `CAMERA` source will always return the JPEG file given by the native camera and the `PHOTOLIBRARY` and `SAVEDPHOTOALBUM` sources will return the selected file in its existing encoding. + +#### BlackBerry 10 Quirks + +- Ignores the `quality` 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 + +- When using `destinationType.FILE_URI`, photos are saved in the application's temporary directory. The contents of the application's temporary directory is deleted when the application ends. + +- When using `destinationType.NATIVE_URI` and `sourceType.CAMERA`, photos are saved in the saved photo album regardless on the value of `saveToPhotoAlbum` parameter. + +#### 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 `saveToPhotoAlbum` parameter. IMPORTANT: All images taken with the WP8/8 Cordova camera API are always copied to the phone's camera roll. Depending on the user's settings, this could also mean the image is auto-uploaded to their OneDrive. This could potentially mean the image is available to a wider audience than your app intended. If this is a blocker for your application, you will need to implement the CameraCaptureTask as [documented on MSDN][msdn_wp8_docs]. You may also comment or up-vote the related issue in the [issue tracker][wp8_bug]. + +- Ignores the `mediaType` property of `cameraOptions` as the Windows Phone SDK does not provide a way to choose videos from PHOTOLIBRARY. + +[android_lifecycle]: http://cordova.apache.org/docs/en/dev/guide/platforms/android/lifecycle.html +[web_activities]: https://hacks.mozilla.org/2013/01/introducing-web-activities/ +[wp8_bug]: https://issues.apache.org/jira/browse/CB-2083 +[msdn_wp8_docs]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx diff --git a/plugins/cordova-plugin-camera/package.json b/plugins/cordova-plugin-camera/package.json new file mode 100644 index 0000000..03256ee --- /dev/null +++ b/plugins/cordova-plugin-camera/package.json @@ -0,0 +1,58 @@ +{ + "name": "cordova-plugin-camera", + "version": "2.1.2-dev", + "description": "Cordova Camera Plugin", + "cordova": { + "id": "cordova-plugin-camera", + "platforms": [ + "firefoxos", + "android", + "amazon-fireos", + "ubuntu", + "ios", + "blackberry10", + "wp7", + "wp8", + "windows8", + "browser", + "windows" + ] + }, + "repository": { + "type": "git", + "url": "https://github.com/apache/cordova-plugin-camera" + }, + "keywords": [ + "cordova", + "camera", + "ecosystem:cordova", + "cordova-firefoxos", + "cordova-android", + "cordova-amazon-fireos", + "cordova-ubuntu", + "cordova-ios", + "cordova-blackberry10", + "cordova-wp7", + "cordova-wp8", + "cordova-windows8", + "cordova-browser", + "cordova-windows" + ], + "peerDependencies": { + "cordova-plugin-file": ">=2.0.0" + }, + "scripts": { + "precommit": "npm run gen-docs && git add README.md", + "gen-docs": "jsdoc2md --template \"jsdoc2md/TEMPLATE.md\" \"www/**/*.js\" --plugin \"dmd-plugin-cordova-plugin\" > README.md", + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, + "author": "Apache Software Foundation", + "license": "Apache-2.0", + "devDependencies": { + "dmd-plugin-cordova-plugin": "^0.1.0", + "husky": "^0.10.1", + "jsdoc-to-markdown": "^1.2.0", + "jshint": "^2.6.0" + } +} diff --git a/plugins/cordova-plugin-camera/plugin.xml b/plugins/cordova-plugin-camera/plugin.xml new file mode 100644 index 0000000..aceeb13 --- /dev/null +++ b/plugins/cordova-plugin-camera/plugin.xml @@ -0,0 +1,260 @@ + + + + + Camera + Cordova Camera Plugin + Apache 2.0 + cordova,camera + https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git + https://issues.apache.org/jira/browse/CB/component/12320645 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + access_shared + use_camera + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-camera/src/android/CameraLauncher.java b/plugins/cordova-plugin-camera/src/android/CameraLauncher.java new file mode 100644 index 0000000..4d15bdf --- /dev/null +++ b/plugins/cordova-plugin-camera/src/android/CameraLauncher.java @@ -0,0 +1,1291 @@ +/* + 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.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CordovaResourceApi; +import org.apache.cordova.LOG; +import org.apache.cordova.PermissionHelper; +import org.apache.cordova.PluginResult; +import org.json.JSONArray; +import org.json.JSONException; + +import android.Manifest; +import android.app.Activity; +import android.content.ActivityNotFoundException; +import android.content.ContentValues; +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.Bitmap.CompressFormat; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.media.MediaScannerConnection; +import android.media.MediaScannerConnection.MediaScannerConnectionClient; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; +import android.util.Base64; +import android.util.Log; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.PermissionInfo; + +/** + * 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"; + + public static final int PERMISSION_DENIED_ERROR = 20; + public static final int TAKE_PIC_SEC = 0; + public static final int SAVE_TO_ALBUM_SEC = 1; + + private static final String LOG_TAG = "CameraLauncher"; + + //Where did this come from? + private static final int CROP_CAMERA = 100; + + 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 int destType; // Source type (needs to be saved for the permission handling) + private int srcType; // Destination type (needs to be saved for permission handling) + 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. + + protected final static String[] permissions = { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE }; + + 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 + private Uri croppedUri; + + + /** + * 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")) { + this.srcType = CAMERA; + this.destType = FILE_URI; + this.saveToPhotoAlbum = false; + this.targetHeight = 0; + this.targetWidth = 0; + this.encodingType = JPEG; + this.mediaType = PICTURE; + this.mQuality = 80; + + //Take the values from the arguments if they're not already defined (this is tricky) + this.destType = args.getInt(1); + this.srcType = args.getInt(2); + this.mQuality = args.getInt(0); + 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.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; + } + + // We don't return full-quality PNG files. The camera outputs a JPEG + // so requesting it as a PNG provides no actual benefit + if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 && + !this.correctOrientation && this.encodingType == PNG && this.srcType == CAMERA) { + this.encodingType = JPEG; + } + + try { + if (this.srcType == CAMERA) { + this.callTakePicture(destType, encodingType); + } + else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) { + // FIXME: Stop always requesting the permission + if(!PermissionHelper.hasPermission(this, permissions[0])) { + PermissionHelper.requestPermission(this, SAVE_TO_ALBUM_SEC, Manifest.permission.READ_EXTERNAL_STORAGE); + } else { + this.getImage(this.srcType, destType, encodingType); + } + } + } + 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 = cordova.getActivity().getExternalCacheDir(); + } + // 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 callTakePicture(int returnType, int encodingType) { + boolean saveAlbumPermission = PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE); + boolean takePicturePermission = PermissionHelper.hasPermission(this, Manifest.permission.CAMERA); + + // CB-10120: The CAMERA permission does not need to be requested unless it is declared + // in AndroidManifest.xml. This plugin does not declare it, but others may and so we must + // check the package info to determine if the permission is present. + + if (!takePicturePermission) { + takePicturePermission = true; + try { + PackageManager packageManager = this.cordova.getActivity().getPackageManager(); + String[] permissionsInPackage = packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), PackageManager.GET_PERMISSIONS).requestedPermissions; + if (permissionsInPackage != null) { + for (String permission : permissionsInPackage) { + if (permission.equals(Manifest.permission.CAMERA)) { + takePicturePermission = false; + break; + } + } + } + } catch (NameNotFoundException e) { + // We are requesting the info for our package, so this should + // never be caught + } + } + + if (takePicturePermission && saveAlbumPermission) { + takePicture(returnType, encodingType); + } else if (saveAlbumPermission && !takePicturePermission) { + PermissionHelper.requestPermission(this, TAKE_PIC_SEC, Manifest.permission.CAMERA); + } else if (!saveAlbumPermission && takePicturePermission) { + PermissionHelper.requestPermission(this, TAKE_PIC_SEC, Manifest.permission.READ_EXTERNAL_STORAGE); + } else { + PermissionHelper.requestPermissions(this, TAKE_PIC_SEC, permissions); + } + } + + public void takePicture(int returnType, int encodingType) + { + // Save the number of images currently on disk for later + this.numPics = queryImgDB(whichContentStore()).getCount(); + + // Let's use the intent and see what happens + Intent intent = new Intent(MediaStore.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) { + // Let's check to make sure the camera is actually installed. (Legacy Nexus 7 code) + PackageManager mPm = this.cordova.getActivity().getPackageManager(); + if(intent.resolveActivity(mPm) != null) + { + + this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); + } + else + { + LOG.d(LOG_TAG, "Error: You don't have a default camera. Your device may not be CTS complaint."); + } + } +// 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) { + return createCaptureFile(encodingType, ""); + } + + /** + * Create a file in the applications temporary directory based upon the supplied encoding. + * + * @param encodingType of the image to be taken + * @param fileName or resultant File object. + * @return a File object pointing to the temporary picture + */ + private File createCaptureFile(int encodingType, String fileName) { + if (fileName.isEmpty()) { + fileName = ".Pic"; + } + + if (encodingType == JPEG) { + fileName = fileName + ".jpg"; + } else if (encodingType == PNG) { + fileName = fileName + ".png"; + } else { + throw new IllegalArgumentException("Invalid Encoding Type: " + encodingType); + } + + return new File(getTempDirectoryPath(), fileName); + } + + + + /** + * 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. + * @param encodingType + */ + // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! + // TODO: Images from kitkat filechooser not going into crop function + public void getImage(int srcType, int returnType, int encodingType) { + Intent intent = new Intent(); + String title = GET_PICTURE; + croppedUri = null; + if (this.mediaType == PICTURE) { + intent.setType("image/*"); + if (this.allowEdit) { + intent.setAction(Intent.ACTION_PICK); + intent.putExtra("crop", "true"); + if (targetWidth > 0) { + intent.putExtra("outputX", targetWidth); + } + if (targetHeight > 0) { + intent.putExtra("outputY", targetHeight); + } + if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { + intent.putExtra("aspectX", 1); + intent.putExtra("aspectY", 1); + } + File photo = createCaptureFile(encodingType); + croppedUri = Uri.fromFile(photo); + intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, croppedUri); + } else { + intent.setAction(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + } + } else if (this.mediaType == VIDEO) { + intent.setType("video/*"); + title = GET_VIDEO; + intent.setAction(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + } 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); + } + } + + /** + * Brings up the UI to perform crop on passed image URI + * + * @param picUri + */ + private void performCrop(Uri picUri, int destType, Intent cameraIntent) { + try { + Intent cropIntent = new Intent("com.android.camera.action.CROP"); + // indicate image type and Uri + cropIntent.setDataAndType(picUri, "image/*"); + // set crop properties + cropIntent.putExtra("crop", "true"); + + // indicate output X and Y + if (targetWidth > 0) { + cropIntent.putExtra("outputX", targetWidth); + } + if (targetHeight > 0) { + cropIntent.putExtra("outputY", targetHeight); + } + if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { + cropIntent.putExtra("aspectX", 1); + cropIntent.putExtra("aspectY", 1); + } + // create new file handle to get full resolution crop + croppedUri = Uri.fromFile(createCaptureFile(this.encodingType, System.currentTimeMillis() + "")); + cropIntent.putExtra("output", croppedUri); + + // start the activity - we handle returning in onActivityResult + + if (this.cordova != null) { + this.cordova.startActivityForResult((CordovaPlugin) this, + cropIntent, CROP_CAMERA + destType); + } + } catch (ActivityNotFoundException anfe) { + Log.e(LOG_TAG, "Crop operation not supported on this device"); + try { + processResultFromCamera(destType, cameraIntent); + } + catch (IOException e) + { + e.printStackTrace(); + Log.e(LOG_TAG, "Unable to write to file"); + } + } + } + + /** + * 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(); + String sourcePath = (this.allowEdit && this.croppedUri != null) ? + FileHelper.stripFileProtocol(this.croppedUri.toString()) : + FileHelper.stripFileProtocol(this.imageUri.toString()); + + if (this.encodingType == JPEG) { + try { + //We don't support PNG, so let's not pretend we do + exif.createInFile(sourcePath); + exif.readExifData(); + rotate = exif.getOrientation(); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + Bitmap bitmap = null; + Uri galleryUri = null; + + // CB-5479 When this option is given the unchanged image should be saved + // in the gallery and the modified image is saved in the temporary + // directory + if (this.saveToPhotoAlbum) { + galleryUri = Uri.fromFile(new File(getPicutresPath())); + + if(this.allowEdit && this.croppedUri != null) { + writeUncompressedImage(this.croppedUri, galleryUri); + } else { + writeUncompressedImage(this.imageUri, galleryUri); + } + + refreshGallery(galleryUri); + } + + // If sending base64 image back + if (destType == DATA_URL) { + bitmap = getScaledBitmap(sourcePath); + + 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, this.encodingType); + + if (!this.saveToPhotoAlbum) { + checkForDuplicateImage(DATA_URL); + } + } + + // If sending filename back + else if (destType == FILE_URI || destType == NATIVE_URI) { + // If all this is true we shouldn't compress the image. + if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 && + !this.correctOrientation) { + + // If we saved the uncompressed photo to the album, we can just + // return the URI we already created + if (this.saveToPhotoAlbum) { + this.callbackContext.success(galleryUri.toString()); + } else { + Uri uri = Uri.fromFile(createCaptureFile(this.encodingType, System.currentTimeMillis() + "")); + + if(this.allowEdit && this.croppedUri != null) { + writeUncompressedImage(this.croppedUri, uri); + } else { + writeUncompressedImage(this.imageUri, uri); + } + + this.callbackContext.success(uri.toString()); + } + } else { + Uri uri = Uri.fromFile(createCaptureFile(this.encodingType, System.currentTimeMillis() + "")); + bitmap = getScaledBitmap(sourcePath); + + // 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); + } + + // Add compressed version of captured image to returned media store Uri + OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); + CompressFormat compressFormat = encodingType == JPEG ? + CompressFormat.JPEG : + CompressFormat.PNG; + + bitmap.compress(compressFormat, this.mQuality, os); + os.close(); + + // Restore exif data to file + if (this.encodingType == JPEG) { + String exifPath; + exifPath = uri.getPath(); + exif.createOutFile(exifPath); + exif.writeExifData(); + } + + // Send Uri back to JavaScript for viewing image + this.callbackContext.success(uri.toString()); + + } + } else { + throw new IllegalStateException(); + } + + this.cleanup(FILE_URI, this.imageUri, galleryUri, bitmap); + bitmap = null; + } + +private String getPicutresPath() +{ + String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + String imageFileName = "IMG_" + timeStamp + (this.encodingType == JPEG ? ".jpg" : ".png"); + File storageDir = Environment.getExternalStoragePublicDirectory( + Environment.DIRECTORY_PICTURES); + String galleryPath = storageDir.getAbsolutePath() + "/" + imageFileName; + return galleryPath; +} + +private void refreshGallery(Uri contentUri) +{ + Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + mediaScanIntent.setData(contentUri); + this.cordova.getActivity().sendBroadcast(mediaScanIntent); +} + + +private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException { + // Some content: URIs do not map to file paths (e.g. picasa). + String realPath = FileHelper.getRealPath(uri, this.cordova); + + // Get filename from uri + String fileName = realPath != null ? + realPath.substring(realPath.lastIndexOf('/') + 1) : + "modified." + (this.encodingType == JPEG ? "jpg" : "png"); + + String modifiedPath = getTempDirectoryPath() + "/" + fileName; + + OutputStream os = new FileOutputStream(modifiedPath); + CompressFormat compressFormat = this.encodingType == JPEG ? + CompressFormat.JPEG : + CompressFormat.PNG; + + bitmap.compress(compressFormat, this.mQuality, os); + os.close(); + + if (realPath != null && this.encodingType == JPEG) { + // Create an ExifHelper to save the exif data that is lost during compression + ExifHelper exif = new ExifHelper(); + + 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(); + if (uri == null) { + if (croppedUri != null) { + uri = croppedUri; + } else { + this.failPicture("null data from photo library"); + return; + } + } + int rotate = 0; + + String fileLocation = FileHelper.getRealPath(uri, this.cordova); + Log.d(LOG_TAG, "File locaton is: " + fileLocation); + + // 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(fileLocation); + } + 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, this.encodingType); + } + + // 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(fileLocation); + } + } + 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 for a Camera Activity + int srcType = (requestCode / 16) - 1; + int destType = (requestCode % 16) - 1; + + // If Camera Crop + if (requestCode >= CROP_CAMERA) { + if (resultCode == Activity.RESULT_OK) { + + // Because of the inability to pass through multiple intents, this hack will allow us + // to pass arcane codes back. + destType = requestCode - CROP_CAMERA; + try { + processResultFromCamera(destType, intent); + } catch (IOException e) { + e.printStackTrace(); + Log.e(LOG_TAG, "Unable to write to file"); + } + + }// If cancelled + else if (resultCode == Activity.RESULT_CANCELED) { + this.failPicture("Camera cancelled."); + } + + // If something else + else { + this.failPicture("Did not complete!"); + } + } + // If CAMERA + else if (srcType == CAMERA) { + // If image available + if (resultCode == Activity.RESULT_OK) { + try { + if(this.allowEdit) + { + Uri tmpFile = Uri.fromFile(createCaptureFile(this.encodingType)); + performCrop(tmpFile, destType, intent); + } + else { + 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 && intent != null) { + final Intent i = intent; + final int finalDestType = destType; + cordova.getThreadPool().execute(new Runnable() { + public void run() { + processResultFromGallery(finalDestType, i); + } + }); + } + 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 src, Uri dest) throws FileNotFoundException, + IOException { + FileInputStream fis = null; + OutputStream os = null; + try { + fis = new FileInputStream(FileHelper.stripFileProtocol(src.toString())); + os = this.cordova.getActivity().getContentResolver().openOutputStream(dest); + byte[] buffer = new byte[4096]; + int len; + while ((len = fis.read(buffer)) != -1) { + os.write(buffer, 0, len); + } + os.flush(); + } finally { + if (os != null) { + try { + os.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing output stream."); + } + } + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + } + + /** + * 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 (RuntimeException 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 (RuntimeException 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) { + InputStream fileStream = null; + Bitmap image = null; + try { + fileStream = FileHelper.getInputStreamFromUriString(imageUrl, cordova); + image = BitmapFactory.decodeStream(fileStream); + } finally { + if (fileStream != null) { + try { + fileStream.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + return image; + } + + // figure out the original width and height of the image + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + InputStream fileStream = null; + try { + fileStream = FileHelper.getInputStreamFromUriString(imageUrl, cordova); + BitmapFactory.decodeStream(fileStream, null, options); + } finally { + if (fileStream != null) { + try { + fileStream.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + + //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 = null; + try { + fileStream = FileHelper.getInputStreamFromUriString(imageUrl, cordova); + unscaledBitmap = BitmapFactory.decodeStream(fileStream, null, options); + } finally { + if (fileStream != null) { + try { + fileStream.close(); + } catch (IOException e) { + LOG.d(LOG_TAG,"Exception while closing file input stream."); + } + } + } + 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, int encodingType) { + ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream(); + CompressFormat compressFormat = encodingType == JPEG ? + CompressFormat.JPEG : + CompressFormat.PNG; + + try { + if (bitmap.compress(compressFormat, 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(); + } + + + public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException + { + for(int r:grantResults) + { + if(r == PackageManager.PERMISSION_DENIED) + { + this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR)); + return; + } + } + switch(requestCode) + { + case TAKE_PIC_SEC: + takePicture(this.destType, this.encodingType); + break; + case SAVE_TO_ALBUM_SEC: + this.getImage(this.srcType, this.destType, this.encodingType); + break; + } + } + + /** + * Taking or choosing a picture launches another Activity, so we need to implement the + * save/restore APIs to handle the case where the CordovaActivity is killed by the OS + * before we get the launched Activity's result. + */ + public Bundle onSaveInstanceState() { + Bundle state = new Bundle(); + state.putInt("destType", this.destType); + state.putInt("srcType", this.srcType); + state.putInt("mQuality", this.mQuality); + state.putInt("targetWidth", this.targetWidth); + state.putInt("targetHeight", this.targetHeight); + state.putInt("encodingType", this.encodingType); + state.putInt("mediaType", this.mediaType); + state.putInt("numPics", this.numPics); + state.putBoolean("allowEdit", this.allowEdit); + state.putBoolean("correctOrientation", this.correctOrientation); + state.putBoolean("saveToPhotoAlbum", this.saveToPhotoAlbum); + + if(this.croppedUri != null) { + state.putString("croppedUri", this.croppedUri.toString()); + } + + if(this.imageUri != null) { + state.putString("imageUri", this.imageUri.toString()); + } + + return state; + } + + public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) { + this.destType = state.getInt("destType"); + this.srcType = state.getInt("srcType"); + this.mQuality = state.getInt("mQuality"); + this.targetWidth = state.getInt("targetWidth"); + this.targetHeight = state.getInt("targetHeight"); + this.encodingType = state.getInt("encodingType"); + this.mediaType = state.getInt("mediaType"); + this.numPics = state.getInt("numPics"); + this.allowEdit = state.getBoolean("allowEdit"); + this.correctOrientation = state.getBoolean("correctOrientation"); + this.saveToPhotoAlbum = state.getBoolean("saveToPhotoAlbum"); + + if(state.containsKey("croppedUri")) { + this.croppedUri = Uri.parse(state.getString("croppedUri")); + } + + if(state.containsKey("imageUri")) { + this.imageUri = Uri.parse(state.getString("imageUri")); + } + + this.callbackContext = callbackContext; + } +} diff --git a/plugins/cordova-plugin-camera/src/android/ExifHelper.java b/plugins/cordova-plugin-camera/src/android/ExifHelper.java new file mode 100644 index 0000000..5160a2f --- /dev/null +++ b/plugins/cordova-plugin-camera/src/android/ExifHelper.java @@ -0,0 +1,185 @@ +/* + 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; + } +} diff --git a/plugins/cordova-plugin-camera/src/android/FileHelper.java b/plugins/cordova-plugin-camera/src/android/FileHelper.java new file mode 100644 index 0000000..ccc5e3e --- /dev/null +++ b/plugins/cordova-plugin-camera/src/android/FileHelper.java @@ -0,0 +1,319 @@ +/* + 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 android.annotation.SuppressLint; +import android.content.ContentUris; +import android.content.Context; +import android.content.CursorLoader; +import android.database.Cursor; +import android.net.Uri; +import android.os.Build; +import android.os.Environment; +import android.provider.DocumentsContract; +import android.provider.MediaStore; +import android.webkit.MimeTypeMap; + +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.LOG; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; + +public class FileHelper { + private static final String LOG_TAG = "FileUtils"; + private static final String _DATA = "_data"; + + /** + * Returns the real path of the given URI string. + * If the given URI string represents a content:// URI, the real path is retrieved from the media store. + * + * @param uriString the URI string of the audio/image/video + * @param cordova the current application context + * @return the full path to the file + */ + @SuppressWarnings("deprecation") + public static String getRealPath(Uri uri, CordovaInterface cordova) { + String realPath = null; + + if (Build.VERSION.SDK_INT < 11) + realPath = FileHelper.getRealPathFromURI_BelowAPI11(cordova.getActivity(), uri); + + // SDK >= 11 + else + realPath = FileHelper.getRealPathFromURI_API11_And_Above(cordova.getActivity(), uri); + + return realPath; + } + + /** + * Returns the real path of the given URI. + * If the given URI is a content:// URI, the real path is retrieved from the media store. + * + * @param uri the URI of the audio/image/video + * @param cordova the current application context + * @return the full path to the file + */ + public static String getRealPath(String uriString, CordovaInterface cordova) { + return FileHelper.getRealPath(Uri.parse(uriString), cordova); + } + + @SuppressLint("NewApi") + public static String getRealPathFromURI_API11_And_Above(final Context context, final Uri uri) { + + final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; + // DocumentProvider + if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { + + // ExternalStorageProvider + if (isExternalStorageDocument(uri)) { + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; + + if ("primary".equalsIgnoreCase(type)) { + return Environment.getExternalStorageDirectory() + "/" + split[1]; + } + + // TODO handle non-primary volumes + } + // DownloadsProvider + else if (isDownloadsDocument(uri)) { + + final String id = DocumentsContract.getDocumentId(uri); + final Uri contentUri = ContentUris.withAppendedId( + Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); + + return getDataColumn(context, contentUri, null, null); + } + // MediaProvider + else if (isMediaDocument(uri)) { + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; + + Uri contentUri = null; + if ("image".equals(type)) { + contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; + } else if ("video".equals(type)) { + contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; + } else if ("audio".equals(type)) { + contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; + } + + final String selection = "_id=?"; + final String[] selectionArgs = new String[] { + split[1] + }; + + return getDataColumn(context, contentUri, selection, selectionArgs); + } + } + // MediaStore (and general) + else if ("content".equalsIgnoreCase(uri.getScheme())) { + + // Return the remote address + if (isGooglePhotosUri(uri)) + return uri.getLastPathSegment(); + + return getDataColumn(context, uri, null, null); + } + // File + else if ("file".equalsIgnoreCase(uri.getScheme())) { + return uri.getPath(); + } + + return null; + } + + public static String getRealPathFromURI_BelowAPI11(Context context, Uri contentUri) { + String[] proj = { MediaStore.Images.Media.DATA }; + String result = null; + + try { + Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null); + int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); + cursor.moveToFirst(); + result = cursor.getString(column_index); + + } catch (Exception e) { + result = null; + } + return result; + } + + /** + * Returns an input stream based on given URI string. + * + * @param uriString the URI string from which to obtain the input stream + * @param cordova the current application context + * @return an input stream into the data at the given URI or null if given an invalid URI string + * @throws IOException + */ + public static InputStream getInputStreamFromUriString(String uriString, CordovaInterface cordova) + throws IOException { + InputStream returnValue = null; + if (uriString.startsWith("content")) { + Uri uri = Uri.parse(uriString); + returnValue = cordova.getActivity().getContentResolver().openInputStream(uri); + } else if (uriString.startsWith("file://")) { + int question = uriString.indexOf("?"); + if (question > -1) { + uriString = uriString.substring(0, question); + } + if (uriString.startsWith("file:///android_asset/")) { + Uri uri = Uri.parse(uriString); + String relativePath = uri.getPath().substring(15); + returnValue = cordova.getActivity().getAssets().open(relativePath); + } else { + // might still be content so try that first + try { + returnValue = cordova.getActivity().getContentResolver().openInputStream(Uri.parse(uriString)); + } catch (Exception e) { + returnValue = null; + } + if (returnValue == null) { + returnValue = new FileInputStream(getRealPath(uriString, cordova)); + } + } + } else { + returnValue = new FileInputStream(uriString); + } + return returnValue; + } + + /** + * Removes the "file://" prefix from the given URI string, if applicable. + * If the given URI string doesn't have a "file://" prefix, it is returned unchanged. + * + * @param uriString the URI string to operate on + * @return a path without the "file://" prefix + */ + public static String stripFileProtocol(String uriString) { + if (uriString.startsWith("file://")) { + uriString = uriString.substring(7); + } + return uriString; + } + + public static String getMimeTypeForExtension(String path) { + String extension = path; + int lastDot = extension.lastIndexOf('.'); + if (lastDot != -1) { + extension = extension.substring(lastDot + 1); + } + // Convert the URI string to lower case to ensure compatibility with MimeTypeMap (see CB-2185). + extension = extension.toLowerCase(Locale.getDefault()); + if (extension.equals("3ga")) { + return "audio/3gpp"; + } + return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + + /** + * Returns the mime type of the data specified by the given URI string. + * + * @param uriString the URI string of the data + * @return the mime type of the specified data + */ + public static String getMimeType(String uriString, CordovaInterface cordova) { + String mimeType = null; + + Uri uri = Uri.parse(uriString); + if (uriString.startsWith("content://")) { + mimeType = cordova.getActivity().getContentResolver().getType(uri); + } else { + mimeType = getMimeTypeForExtension(uri.getPath()); + } + + return mimeType; + } + + /** + * Get the value of the data column for this Uri. This is useful for + * MediaStore Uris, and other file-based ContentProviders. + * + * @param context The context. + * @param uri The Uri to query. + * @param selection (Optional) Filter used in the query. + * @param selectionArgs (Optional) Selection arguments used in the query. + * @return The value of the _data column, which is typically a file path. + * @author paulburke + */ + public static String getDataColumn(Context context, Uri uri, String selection, + String[] selectionArgs) { + + Cursor cursor = null; + final String column = "_data"; + final String[] projection = { + column + }; + + try { + cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, + null); + if (cursor != null && cursor.moveToFirst()) { + + final int column_index = cursor.getColumnIndexOrThrow(column); + return cursor.getString(column_index); + } + } catch (Exception e) { + return null; + } finally { + if (cursor != null) + cursor.close(); + } + return null; + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is ExternalStorageProvider. + * @author paulburke + */ + public static boolean isExternalStorageDocument(Uri uri) { + return "com.android.externalstorage.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is DownloadsProvider. + * @author paulburke + */ + public static boolean isDownloadsDocument(Uri uri) { + return "com.android.providers.downloads.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is MediaProvider. + * @author paulburke + */ + public static boolean isMediaDocument(Uri uri) { + return "com.android.providers.media.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is Google Photos. + */ + public static boolean isGooglePhotosUri(Uri uri) { + return "com.google.android.apps.photos.content".equals(uri.getAuthority()); + } +} diff --git a/plugins/cordova-plugin-camera/src/blackberry10/index.js b/plugins/cordova-plugin-camera/src/blackberry10/index.js new file mode 100644 index 0000000..afc3539 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/blackberry10/index.js @@ -0,0 +1,227 @@ +/* + * + * 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. + * +*/ + +/* globals qnx, FileError, PluginResult */ + +var PictureSourceType = { + PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android) + CAMERA : 1, // Take picture from camera + SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android) + }, + DestinationType = { + DATA_URL: 0, // Return base64 encoded string + FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android) + NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS) + }, + savePath = window.qnx.webplatform.getApplication().getEnv("HOME").replace('/data', '') + '/shared/camera/', + invokeAvailable = true; + +//check for camera card - it isn't currently availble in work perimeter +window.qnx.webplatform.getApplication().invocation.queryTargets( + { + type: 'image/jpeg', + action: 'bb.action.CAPTURE', + target_type: 'CARD' + }, + function (error, targets) { + invokeAvailable = !error && targets && targets instanceof Array && + targets.filter(function (t) { return t.default === 'sys.camera.card'; }).length > 0; + } +); + +//open a webview with getUserMedia camera card implementation when camera card not available +function showCameraDialog (done, cancel, fail) { + var wv = qnx.webplatform.createWebView(function () { + wv.url = 'local:///chrome/camera.html'; + wv.allowQnxObject = true; + wv.allowRpc = true; + wv.zOrder = 1; + wv.setGeometry(0, 0, screen.width, screen.height); + wv.backgroundColor = 0x00000000; + wv.active = true; + wv.visible = true; + wv.on('UserMediaRequest', function (evt, args) { + wv.allowUserMedia(JSON.parse(args).id, 'CAMERA_UNIT_REAR'); + }); + wv.on('JavaScriptCallback', function (evt, data) { + var args = JSON.parse(data).args; + if (args[0] === 'cordova-plugin-camera') { + if (args[1] === 'cancel') { + cancel('User canceled'); + } else if (args[1] === 'error') { + fail(args[2]); + } else { + saveImage(args[1], done, fail); + } + wv.un('JavaScriptCallback', arguments.callee); + wv.visible = false; + wv.destroy(); + qnx.webplatform.getApplication().unlockRotation(); + } + }); + wv.on('Destroyed', function () { + wv.delete(); + }); + qnx.webplatform.getApplication().lockRotation(); + qnx.webplatform.getController().dispatchEvent('webview.initialized', [wv]); + }); +} + +//create unique name for saved file (same pattern as BB10 camera app) +function imgName() { + var date = new Date(), + pad = function (n) { return n < 10 ? '0' + n : n; }; + return 'IMG_' + date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) + '_' + + pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + '.png'; +} + +//convert dataURI to Blob +function dataURItoBlob(dataURI) { + var byteString = atob(dataURI.split(',')[1]), + mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0], + arrayBuffer = new ArrayBuffer(byteString.length), + ia = new Uint8Array(arrayBuffer), + i; + for (i = 0; i < byteString.length; i++) { + ia[i] = byteString.charCodeAt(i); + } + return new Blob([new DataView(arrayBuffer)], { type: mimeString }); +} + +//save dataURI to file system and call success with path +function saveImage(data, success, fail) { + var name = savePath + imgName(); + require('lib/webview').setSandbox(false); + window.webkitRequestFileSystem(window.PERSISTENT, 0, function (fs) { + fs.root.getFile(name, { create: true }, function (entry) { + entry.createWriter(function (writer) { + writer.onwriteend = function () { + success(name); + }; + writer.onerror = fail; + writer.write(dataURItoBlob(data)); + }); + }, fail); + }, fail); +} + +function encodeBase64(filePath, callback) { + var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox, // save original sandbox value + errorHandler = function (err) { + var msg = "An error occured: "; + + switch (err.code) { + case FileError.NOT_FOUND_ERR: + msg += "File or directory not found"; + break; + + case FileError.NOT_READABLE_ERR: + msg += "File or directory not readable"; + break; + + case FileError.PATH_EXISTS_ERR: + msg += "File or directory already exists"; + break; + + case FileError.TYPE_MISMATCH_ERR: + msg += "Invalid file type"; + break; + + default: + msg += "Unknown Error"; + break; + } + + // set it back to original value + window.qnx.webplatform.getController().setFileSystemSandbox = sandbox; + callback(msg); + }, + gotFile = function (fileEntry) { + fileEntry.file(function (file) { + var reader = new FileReader(); + + reader.onloadend = function (e) { + // set it back to original value + window.qnx.webplatform.getController().setFileSystemSandbox = sandbox; + callback(this.result); + }; + + reader.readAsDataURL(file); + }, errorHandler); + }, + onInitFs = function (fs) { + window.qnx.webplatform.getController().setFileSystemSandbox = false; + fs.root.getFile(filePath, {create: false}, gotFile, errorHandler); + }; + + window.webkitRequestFileSystem(window.TEMPORARY, 10 * 1024 * 1024, onInitFs, errorHandler); // set size to 10MB max +} + +module.exports = { + takePicture: function (success, fail, args, env) { + var destinationType = JSON.parse(decodeURIComponent(args[1])), + sourceType = JSON.parse(decodeURIComponent(args[2])), + result = new PluginResult(args, env), + done = function (data) { + if (destinationType === DestinationType.FILE_URI) { + data = "file://" + data; + result.callbackOk(data, false); + } else { + encodeBase64(data, function (data) { + if (/^data:/.test(data)) { + data = data.slice(data.indexOf(",") + 1); + result.callbackOk(data, false); + } else { + result.callbackError(data, false); + } + }); + } + }, + cancel = function (reason) { + result.callbackError(reason, false); + }, + invoked = function (error) { + if (error) { + result.callbackError(error, false); + } + }; + + switch(sourceType) { + case PictureSourceType.CAMERA: + if (invokeAvailable) { + window.qnx.webplatform.getApplication().cards.camera.open("photo", done, cancel, invoked); + } else { + showCameraDialog(done, cancel, fail); + } + break; + + case PictureSourceType.PHOTOLIBRARY: + case PictureSourceType.SAVEDPHOTOALBUM: + window.qnx.webplatform.getApplication().cards.filePicker.open({ + mode: "Picker", + type: ["picture"] + }, done, cancel, invoked); + break; + } + + result.noResult(true); + } +}; diff --git a/plugins/cordova-plugin-camera/src/browser/CameraProxy.js b/plugins/cordova-plugin-camera/src/browser/CameraProxy.js new file mode 100644 index 0000000..8f95c6f --- /dev/null +++ b/plugins/cordova-plugin-camera/src/browser/CameraProxy.js @@ -0,0 +1,114 @@ +/* + * + * 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. + * + */ + +var HIGHEST_POSSIBLE_Z_INDEX = 2147483647; + +function takePicture(success, error, opts) { + if (opts && opts[2] === 1) { + capture(success, error); + } else { + var input = document.createElement('input'); + input.style.position = 'relative'; + input.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX; + input.type = 'file'; + input.name = 'files[]'; + + input.onchange = function(inputEvent) { + var reader = new FileReader(); + reader.onload = function(readerEvent) { + input.parentNode.removeChild(input); + + var imageData = readerEvent.target.result; + + return success(imageData.substr(imageData.indexOf(',') + 1)); + }; + + reader.readAsDataURL(inputEvent.target.files[0]); + }; + + document.body.appendChild(input); + } +} + +function capture(success, errorCallback) { + var localMediaStream; + + var video = document.createElement('video'); + var button = document.createElement('button'); + var parent = document.createElement('div'); + parent.style.position = 'relative'; + parent.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX; + parent.appendChild(video); + parent.appendChild(button); + + video.width = 320; + video.height = 240; + button.innerHTML = 'Capture!'; + + button.onclick = function() { + // create a canvas and capture a frame from video stream + var canvas = document.createElement('canvas'); + canvas.getContext('2d').drawImage(video, 0, 0, 320, 240); + + // convert image stored in canvas to base64 encoded image + var imageData = canvas.toDataURL('img/png'); + imageData = imageData.replace('data:image/png;base64,', ''); + + // stop video stream, remove video and button. + // Note that MediaStream.stop() is deprecated as of Chrome 47. + if (localMediaStream.stop) { + localMediaStream.stop(); + } else { + localMediaStream.getTracks().forEach(function (track) { + track.stop(); + }); + } + parent.parentNode.removeChild(parent); + + return success(imageData); + }; + + navigator.getUserMedia = navigator.getUserMedia || + navigator.webkitGetUserMedia || + navigator.mozGetUserMedia || + navigator.msGetUserMedia; + + var successCallback = function(stream) { + localMediaStream = stream; + video.src = window.URL.createObjectURL(localMediaStream); + video.play(); + + document.body.appendChild(parent); + }; + + if (navigator.getUserMedia) { + navigator.getUserMedia({video: true, audio: true}, successCallback, errorCallback); + } else { + alert('Browser does not support camera :('); + } +} + +module.exports = { + takePicture: takePicture, + cleanup: function(){} +}; + +require("cordova/exec/proxy").add("Camera",module.exports); diff --git a/plugins/cordova-plugin-camera/src/firefoxos/CameraProxy.js b/plugins/cordova-plugin-camera/src/firefoxos/CameraProxy.js new file mode 100644 index 0000000..1e3018e --- /dev/null +++ b/plugins/cordova-plugin-camera/src/firefoxos/CameraProxy.js @@ -0,0 +1,53 @@ +/* + * + * 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. + * + */ + +/* globals MozActivity */ + +function takePicture(success, error, opts) { + var pick = new MozActivity({ + name: "pick", + data: { + type: ["image/*"] + } + }); + + pick.onerror = error || function() {}; + + pick.onsuccess = function() { + // image is returned as Blob in this.result.blob + // we need to call success with url or base64 encoded image + if (opts && opts.destinationType === 0) { + // TODO: base64 + return; + } + if (!opts || !opts.destinationType || opts.destinationType > 0) { + // url + return success(window.URL.createObjectURL(this.result.blob)); + } + }; +} + +module.exports = { + takePicture: takePicture, + cleanup: function(){} +}; + +require("cordova/exec/proxy").add("Camera", module.exports); diff --git a/plugins/cordova-plugin-camera/src/ios/CDVCamera.h b/plugins/cordova-plugin-camera/src/ios/CDVCamera.h new file mode 100644 index 0000000..f64f66c --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ios/CDVCamera.h @@ -0,0 +1,116 @@ +/* + 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. + */ + +#import +#import +#import +#import + +enum CDVDestinationType { + DestinationTypeDataUrl = 0, + DestinationTypeFileUri, + DestinationTypeNativeUri +}; +typedef NSUInteger CDVDestinationType; + +enum CDVEncodingType { + EncodingTypeJPEG = 0, + EncodingTypePNG +}; +typedef NSUInteger CDVEncodingType; + +enum CDVMediaType { + MediaTypePicture = 0, + MediaTypeVideo, + MediaTypeAll +}; +typedef NSUInteger CDVMediaType; + +@interface CDVPictureOptions : NSObject + +@property (strong) NSNumber* quality; +@property (assign) CDVDestinationType destinationType; +@property (assign) UIImagePickerControllerSourceType sourceType; +@property (assign) CGSize targetSize; +@property (assign) CDVEncodingType encodingType; +@property (assign) CDVMediaType mediaType; +@property (assign) BOOL allowsEditing; +@property (assign) BOOL correctOrientation; +@property (assign) BOOL saveToPhotoAlbum; +@property (strong) NSDictionary* popoverOptions; +@property (assign) UIImagePickerControllerCameraDevice cameraDirection; + +@property (assign) BOOL popoverSupported; +@property (assign) BOOL usesGeolocation; +@property (assign) BOOL cropToSize; + ++ (instancetype) createFromTakePictureArguments:(CDVInvokedUrlCommand*)command; + +@end + +@interface CDVCameraPicker : UIImagePickerController + +@property (strong) CDVPictureOptions* pictureOptions; + +@property (copy) NSString* callbackId; +@property (copy) NSString* postUrl; +@property (strong) UIPopoverController* pickerPopoverController; +@property (assign) BOOL cropToSize; +@property (strong) UIView* webView; + ++ (instancetype) createFromPictureOptions:(CDVPictureOptions*)options; + +@end + +// ======================================================================= // + +@interface CDVCamera : CDVPlugin +{} + +@property (strong) CDVCameraPicker* pickerController; +@property (strong) NSMutableDictionary *metadata; +@property (strong, nonatomic) CLLocationManager *locationManager; +@property (strong) NSData* data; + +/* + * getPicture + * + * arguments: + * 1: this is the javascript function that will be called with the results, the first parameter passed to the + * javascript function is the picture as a Base64 encoded string + * 2: this is the javascript function to be called if there was an error + * options: + * quality: integer between 1 and 100 + */ +- (void)takePicture:(CDVInvokedUrlCommand*)command; +- (void)cleanup:(CDVInvokedUrlCommand*)command; +- (void)repositionPopover:(CDVInvokedUrlCommand*)command; + +- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info; +- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo; +- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker; +- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated; + +- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation; +- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error; + +@end diff --git a/plugins/cordova-plugin-camera/src/ios/CDVCamera.m b/plugins/cordova-plugin-camera/src/ios/CDVCamera.m new file mode 100644 index 0000000..1fae2e2 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ios/CDVCamera.m @@ -0,0 +1,765 @@ +/* + 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. + */ + +#import "CDVCamera.h" +#import "CDVJpegHeaderWriter.h" +#import "UIImage+CropScaleOrientation.h" +#import +#import +#import +#import +#import +#import +#import +#import +#import + +#ifndef __CORDOVA_4_0_0 + #import +#endif + +#define CDV_PHOTO_PREFIX @"cdv_photo_" + +static NSSet* org_apache_cordova_validArrowDirections; + +static NSString* toBase64(NSData* data) { + SEL s1 = NSSelectorFromString(@"cdv_base64EncodedString"); + SEL s2 = NSSelectorFromString(@"base64EncodedString"); + SEL s3 = NSSelectorFromString(@"base64EncodedStringWithOptions:"); + + if ([data respondsToSelector:s1]) { + NSString* (*func)(id, SEL) = (void *)[data methodForSelector:s1]; + return func(data, s1); + } else if ([data respondsToSelector:s2]) { + NSString* (*func)(id, SEL) = (void *)[data methodForSelector:s2]; + return func(data, s2); + } else if ([data respondsToSelector:s3]) { + NSString* (*func)(id, SEL, NSUInteger) = (void *)[data methodForSelector:s3]; + return func(data, s3, 0); + } else { + return nil; + } +} + +@implementation CDVPictureOptions + ++ (instancetype) createFromTakePictureArguments:(CDVInvokedUrlCommand*)command +{ + CDVPictureOptions* pictureOptions = [[CDVPictureOptions alloc] init]; + + pictureOptions.quality = [command argumentAtIndex:0 withDefault:@(50)]; + pictureOptions.destinationType = [[command argumentAtIndex:1 withDefault:@(DestinationTypeFileUri)] unsignedIntegerValue]; + pictureOptions.sourceType = [[command argumentAtIndex:2 withDefault:@(UIImagePickerControllerSourceTypeCamera)] unsignedIntegerValue]; + + NSNumber* targetWidth = [command argumentAtIndex:3 withDefault:nil]; + NSNumber* targetHeight = [command argumentAtIndex:4 withDefault:nil]; + pictureOptions.targetSize = CGSizeMake(0, 0); + if ((targetWidth != nil) && (targetHeight != nil)) { + pictureOptions.targetSize = CGSizeMake([targetWidth floatValue], [targetHeight floatValue]); + } + + pictureOptions.encodingType = [[command argumentAtIndex:5 withDefault:@(EncodingTypeJPEG)] unsignedIntegerValue]; + pictureOptions.mediaType = [[command argumentAtIndex:6 withDefault:@(MediaTypePicture)] unsignedIntegerValue]; + pictureOptions.allowsEditing = [[command argumentAtIndex:7 withDefault:@(NO)] boolValue]; + pictureOptions.correctOrientation = [[command argumentAtIndex:8 withDefault:@(NO)] boolValue]; + pictureOptions.saveToPhotoAlbum = [[command argumentAtIndex:9 withDefault:@(NO)] boolValue]; + pictureOptions.popoverOptions = [command argumentAtIndex:10 withDefault:nil]; + pictureOptions.cameraDirection = [[command argumentAtIndex:11 withDefault:@(UIImagePickerControllerCameraDeviceRear)] unsignedIntegerValue]; + + pictureOptions.popoverSupported = NO; + pictureOptions.usesGeolocation = NO; + + return pictureOptions; +} + +@end + + +@interface CDVCamera () + +@property (readwrite, assign) BOOL hasPendingOperation; + +@end + +@implementation CDVCamera + ++ (void)initialize +{ + org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown], [NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil]; +} + +@synthesize hasPendingOperation, pickerController, locationManager; + +- (NSURL*) urlTransformer:(NSURL*)url +{ + NSURL* urlToTransform = url; + + // for backwards compatibility - we check if this property is there + SEL sel = NSSelectorFromString(@"urlTransformer"); + if ([self.commandDelegate respondsToSelector:sel]) { + // grab the block from the commandDelegate + NSURL* (^urlTransformer)(NSURL*) = ((id(*)(id, SEL))objc_msgSend)(self.commandDelegate, sel); + // if block is not null, we call it + if (urlTransformer) { + urlToTransform = urlTransformer(url); + } + } + + return urlToTransform; +} + +- (BOOL)usesGeolocation +{ + id useGeo = [self.commandDelegate.settings objectForKey:[@"CameraUsesGeolocation" lowercaseString]]; + return [(NSNumber*)useGeo boolValue]; +} + +- (BOOL)popoverSupported +{ + return (NSClassFromString(@"UIPopoverController") != nil) && + (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); +} + +- (void)takePicture:(CDVInvokedUrlCommand*)command +{ + self.hasPendingOperation = YES; + + __weak CDVCamera* weakSelf = self; + + [self.commandDelegate runInBackground:^{ + + CDVPictureOptions* pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command]; + pictureOptions.popoverSupported = [weakSelf popoverSupported]; + pictureOptions.usesGeolocation = [weakSelf usesGeolocation]; + pictureOptions.cropToSize = NO; + + BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType]; + if (!hasCamera) { + NSLog(@"Camera.getPicture: source type %lu not available.", (unsigned long)pictureOptions.sourceType); + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No camera available"]; + [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId]; + return; + } + + // Validate the app has permission to access the camera + if (pictureOptions.sourceType == UIImagePickerControllerSourceTypeCamera && [AVCaptureDevice respondsToSelector:@selector(authorizationStatusForMediaType:)]) { + AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; + if (authStatus == AVAuthorizationStatusDenied || + authStatus == AVAuthorizationStatusRestricted) { + // If iOS 8+, offer a link to the Settings app +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-pointer-compare" + NSString* settingsButton = (&UIApplicationOpenSettingsURLString != NULL) + ? NSLocalizedString(@"Settings", nil) + : nil; +#pragma clang diagnostic pop + + // Denied; show an alert + dispatch_async(dispatch_get_main_queue(), ^{ + [[[UIAlertView alloc] initWithTitle:[[NSBundle mainBundle] + objectForInfoDictionaryKey:@"CFBundleDisplayName"] + message:NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.", nil) + delegate:weakSelf + cancelButtonTitle:NSLocalizedString(@"OK", nil) + otherButtonTitles:settingsButton, nil] show]; + }); + } + } + + CDVCameraPicker* cameraPicker = [CDVCameraPicker createFromPictureOptions:pictureOptions]; + weakSelf.pickerController = cameraPicker; + + cameraPicker.delegate = weakSelf; + cameraPicker.callbackId = command.callbackId; + // we need to capture this state for memory warnings that dealloc this object + cameraPicker.webView = weakSelf.webView; + + // Perform UI operations on the main thread + dispatch_async(dispatch_get_main_queue(), ^{ + // If a popover is already open, close it; we only want one at a time. + if (([[weakSelf pickerController] pickerPopoverController] != nil) && [[[weakSelf pickerController] pickerPopoverController] isPopoverVisible]) { + [[[weakSelf pickerController] pickerPopoverController] dismissPopoverAnimated:YES]; + [[[weakSelf pickerController] pickerPopoverController] setDelegate:nil]; + [[weakSelf pickerController] setPickerPopoverController:nil]; + } + + if ([weakSelf popoverSupported] && (pictureOptions.sourceType != UIImagePickerControllerSourceTypeCamera)) { + if (cameraPicker.pickerPopoverController == nil) { + cameraPicker.pickerPopoverController = [[NSClassFromString(@"UIPopoverController") alloc] initWithContentViewController:cameraPicker]; + } + [weakSelf displayPopover:pictureOptions.popoverOptions]; + weakSelf.hasPendingOperation = NO; + } else { + [weakSelf.viewController presentViewController:cameraPicker animated:YES completion:^{ + weakSelf.hasPendingOperation = NO; + }]; + } + }); + }]; +} + +// Delegate for camera permission UIAlertView +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + // If Settings button (on iOS 8), open the settings app + if (buttonIndex == 1) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-pointer-compare" + if (&UIApplicationOpenSettingsURLString != NULL) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; + } +#pragma clang diagnostic pop + } + + // Dismiss the view + [[self.pickerController presentingViewController] dismissViewControllerAnimated:YES completion:nil]; + + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"has no access to camera"]; // error callback expects string ATM + + [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId]; + + self.hasPendingOperation = NO; + self.pickerController = nil; +} + +- (void)repositionPopover:(CDVInvokedUrlCommand*)command +{ + NSDictionary* options = [command argumentAtIndex:0 withDefault:nil]; + + [self displayPopover:options]; +} + +- (NSInteger)integerValueForKey:(NSDictionary*)dict key:(NSString*)key defaultValue:(NSInteger)defaultValue +{ + NSInteger value = defaultValue; + + NSNumber* val = [dict valueForKey:key]; // value is an NSNumber + + if (val != nil) { + value = [val integerValue]; + } + return value; +} + +- (void)displayPopover:(NSDictionary*)options +{ + NSInteger x = 0; + NSInteger y = 32; + NSInteger width = 320; + NSInteger height = 480; + UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny; + + if (options) { + x = [self integerValueForKey:options key:@"x" defaultValue:0]; + y = [self integerValueForKey:options key:@"y" defaultValue:32]; + width = [self integerValueForKey:options key:@"width" defaultValue:320]; + height = [self integerValueForKey:options key:@"height" defaultValue:480]; + arrowDirection = [self integerValueForKey:options key:@"arrowDir" defaultValue:UIPopoverArrowDirectionAny]; + if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithUnsignedInteger:arrowDirection]]) { + arrowDirection = UIPopoverArrowDirectionAny; + } + } + + [[[self pickerController] pickerPopoverController] setDelegate:self]; + [[[self pickerController] pickerPopoverController] presentPopoverFromRect:CGRectMake(x, y, width, height) + inView:[self.webView superview] + permittedArrowDirections:arrowDirection + animated:YES]; +} + +- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated +{ + if([navigationController isKindOfClass:[UIImagePickerController class]]){ + UIImagePickerController* cameraPicker = (UIImagePickerController*)navigationController; + + if(![cameraPicker.mediaTypes containsObject:(NSString*)kUTTypeImage]){ + [viewController.navigationItem setTitle:NSLocalizedString(@"Videos", nil)]; + } + } +} + +- (void)cleanup:(CDVInvokedUrlCommand*)command +{ + // empty the tmp directory + NSFileManager* fileMgr = [[NSFileManager alloc] init]; + NSError* err = nil; + BOOL hasErrors = NO; + + // clear contents of NSTemporaryDirectory + NSString* tempDirectoryPath = NSTemporaryDirectory(); + NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath]; + NSString* fileName = nil; + BOOL result; + + while ((fileName = [directoryEnumerator nextObject])) { + // only delete the files we created + if (![fileName hasPrefix:CDV_PHOTO_PREFIX]) { + continue; + } + NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName]; + result = [fileMgr removeItemAtPath:filePath error:&err]; + if (!result && err) { + NSLog(@"Failed to delete: %@ (error: %@)", filePath, err); + hasErrors = YES; + } + } + + CDVPluginResult* pluginResult; + if (hasErrors) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:@"One or more files failed to be deleted."]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + } + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (void)popoverControllerDidDismissPopover:(id)popoverController +{ + UIPopoverController* pc = (UIPopoverController*)popoverController; + + [pc dismissPopoverAnimated:YES]; + pc.delegate = nil; + if (self.pickerController && self.pickerController.callbackId && self.pickerController.pickerPopoverController) { + self.pickerController.pickerPopoverController = nil; + NSString* callbackId = self.pickerController.callbackId; + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + } + self.hasPendingOperation = NO; +} + +- (NSData*)processImage:(UIImage*)image info:(NSDictionary*)info options:(CDVPictureOptions*)options +{ + NSData* data = nil; + + switch (options.encodingType) { + case EncodingTypePNG: + data = UIImagePNGRepresentation(image); + break; + case EncodingTypeJPEG: + { + if ((options.allowsEditing == NO) && (options.targetSize.width <= 0) && (options.targetSize.height <= 0) && (options.correctOrientation == NO) && (([options.quality integerValue] == 100) || (options.sourceType != UIImagePickerControllerSourceTypeCamera))){ + // use image unedited as requested , don't resize + data = UIImageJPEGRepresentation(image, 1.0); + } else { + if (options.usesGeolocation) { + NSDictionary* controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"]; + if (controllerMetadata) { + self.data = data; + self.metadata = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* EXIFDictionary = [[controllerMetadata objectForKey:(NSString*)kCGImagePropertyExifDictionary]mutableCopy]; + if (EXIFDictionary) { + [self.metadata setObject:EXIFDictionary forKey:(NSString*)kCGImagePropertyExifDictionary]; + } + + if (IsAtLeastiOSVersion(@"8.0")) { + [[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0]; + } + [[self locationManager] startUpdatingLocation]; + } + } else { + data = UIImageJPEGRepresentation(image, [options.quality floatValue] / 100.0f); + } + } + } + break; + default: + break; + }; + + return data; +} + +- (NSString*)tempFilePath:(NSString*)extension +{ + NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; + NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by Apple (vs [NSFileManager defaultManager]) to be threadsafe + NSString* filePath; + + // generate unique file name + int i = 1; + do { + filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, extension]; + } while ([fileMgr fileExistsAtPath:filePath]); + + return filePath; +} + +- (UIImage*)retrieveImage:(NSDictionary*)info options:(CDVPictureOptions*)options +{ + // get the image + UIImage* image = nil; + if (options.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]) { + image = [info objectForKey:UIImagePickerControllerEditedImage]; + } else { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; + } + + if (options.correctOrientation) { + image = [image imageCorrectedForCaptureOrientation]; + } + + UIImage* scaledImage = nil; + + if ((options.targetSize.width > 0) && (options.targetSize.height > 0)) { + // if cropToSize, resize image and crop to target size, otherwise resize to fit target without cropping + if (options.cropToSize) { + scaledImage = [image imageByScalingAndCroppingForSize:options.targetSize]; + } else { + scaledImage = [image imageByScalingNotCroppingForSize:options.targetSize]; + } + } + + return (scaledImage == nil ? image : scaledImage); +} + +- (void)resultForImage:(CDVPictureOptions*)options info:(NSDictionary*)info completion:(void (^)(CDVPluginResult* res))completion +{ + CDVPluginResult* result = nil; + BOOL saveToPhotoAlbum = options.saveToPhotoAlbum; + UIImage* image = nil; + + switch (options.destinationType) { + case DestinationTypeNativeUri: + { + NSURL* url = [info objectForKey:UIImagePickerControllerReferenceURL]; + saveToPhotoAlbum = NO; + // If, for example, we use sourceType = Camera, URL might be nil because image is stored in memory. + // In this case we must save image to device before obtaining an URI. + if (url == nil) { + image = [self retrieveImage:info options:options]; + ALAssetsLibrary* library = [ALAssetsLibrary new]; + [library writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)(image.imageOrientation) completionBlock:^(NSURL *assetURL, NSError *error) { + CDVPluginResult* resultToReturn = nil; + if (error) { + resultToReturn = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]]; + } else { + NSString* nativeUri = [[self urlTransformer:assetURL] absoluteString]; + resultToReturn = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri]; + } + completion(resultToReturn); + }]; + return; + } else { + NSString* nativeUri = [[self urlTransformer:url] absoluteString]; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri]; + } + } + break; + case DestinationTypeFileUri: + { + image = [self retrieveImage:info options:options]; + NSData* data = [self processImage:image info:info options:options]; + if (data) { + + NSString* extension = options.encodingType == EncodingTypePNG? @"png" : @"jpg"; + NSString* filePath = [self tempFilePath:extension]; + NSError* err = nil; + + // save file + if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]]; + } else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[self urlTransformer:[NSURL fileURLWithPath:filePath]] absoluteString]]; + } + } + } + break; + case DestinationTypeDataUrl: + { + image = [self retrieveImage:info options:options]; + NSData* data = [self processImage:image info:info options:options]; + if (data) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:toBase64(data)]; + } + } + break; + default: + break; + }; + + if (saveToPhotoAlbum && image) { + ALAssetsLibrary* library = [ALAssetsLibrary new]; + [library writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)(image.imageOrientation) completionBlock:nil]; + } + + completion(result); +} + +- (CDVPluginResult*)resultForVideo:(NSDictionary*)info +{ + NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString]; + return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath]; +} + +- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info +{ + __weak CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker; + __weak CDVCamera* weakSelf = self; + + dispatch_block_t invoke = ^(void) { + __block CDVPluginResult* result = nil; + + NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType]; + if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) { + [weakSelf resultForImage:cameraPicker.pictureOptions info:info completion:^(CDVPluginResult* res) { + [weakSelf.commandDelegate sendPluginResult:res callbackId:cameraPicker.callbackId]; + weakSelf.hasPendingOperation = NO; + weakSelf.pickerController = nil; + }]; + } + else { + result = [weakSelf resultForVideo:info]; + [weakSelf.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId]; + weakSelf.hasPendingOperation = NO; + weakSelf.pickerController = nil; + } + }; + + if (cameraPicker.pictureOptions.popoverSupported && (cameraPicker.pickerPopoverController != nil)) { + [cameraPicker.pickerPopoverController dismissPopoverAnimated:YES]; + cameraPicker.pickerPopoverController.delegate = nil; + cameraPicker.pickerPopoverController = nil; + invoke(); + } else { + [[cameraPicker presentingViewController] dismissViewControllerAnimated:YES completion:invoke]; + } +} + +// older api calls newer didFinishPickingMediaWithInfo +- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo +{ + NSDictionary* imageInfo = [NSDictionary dictionaryWithObject:image forKey:UIImagePickerControllerOriginalImage]; + + [self imagePickerController:picker didFinishPickingMediaWithInfo:imageInfo]; +} + +- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker +{ + __weak CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker; + __weak CDVCamera* weakSelf = self; + + dispatch_block_t invoke = ^ (void) { + CDVPluginResult* result; + if (picker.sourceType == UIImagePickerControllerSourceTypeCamera && [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo] != ALAuthorizationStatusAuthorized) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"has no access to camera"]; + } else if (picker.sourceType != UIImagePickerControllerSourceTypeCamera && [ALAssetsLibrary authorizationStatus] != ALAuthorizationStatusAuthorized) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"has no access to assets"]; + } else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; + } + + + [weakSelf.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId]; + + weakSelf.hasPendingOperation = NO; + weakSelf.pickerController = nil; + }; + + [[cameraPicker presentingViewController] dismissViewControllerAnimated:YES completion:invoke]; +} + +- (CLLocationManager*)locationManager +{ + if (locationManager != nil) { + return locationManager; + } + + locationManager = [[CLLocationManager alloc] init]; + [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; + [locationManager setDelegate:self]; + + return locationManager; +} + +- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation +{ + if (locationManager == nil) { + return; + } + + [self.locationManager stopUpdatingLocation]; + self.locationManager = nil; + + NSMutableDictionary *GPSDictionary = [[NSMutableDictionary dictionary] init]; + + CLLocationDegrees latitude = newLocation.coordinate.latitude; + CLLocationDegrees longitude = newLocation.coordinate.longitude; + + // latitude + if (latitude < 0.0) { + latitude = latitude * -1.0f; + [GPSDictionary setObject:@"S" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef]; + } else { + [GPSDictionary setObject:@"N" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef]; + } + [GPSDictionary setObject:[NSNumber numberWithFloat:latitude] forKey:(NSString*)kCGImagePropertyGPSLatitude]; + + // longitude + if (longitude < 0.0) { + longitude = longitude * -1.0f; + [GPSDictionary setObject:@"W" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef]; + } + else { + [GPSDictionary setObject:@"E" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef]; + } + [GPSDictionary setObject:[NSNumber numberWithFloat:longitude] forKey:(NSString*)kCGImagePropertyGPSLongitude]; + + // altitude + CGFloat altitude = newLocation.altitude; + if (!isnan(altitude)){ + if (altitude < 0) { + altitude = -altitude; + [GPSDictionary setObject:@"1" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef]; + } else { + [GPSDictionary setObject:@"0" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef]; + } + [GPSDictionary setObject:[NSNumber numberWithFloat:altitude] forKey:(NSString *)kCGImagePropertyGPSAltitude]; + } + + // Time and date + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setDateFormat:@"HH:mm:ss.SSSSSS"]; + [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSTimeStamp]; + [formatter setDateFormat:@"yyyy:MM:dd"]; + [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSDateStamp]; + + [self.metadata setObject:GPSDictionary forKey:(NSString *)kCGImagePropertyGPSDictionary]; + [self imagePickerControllerReturnImageResult]; +} + +- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error +{ + if (locationManager == nil) { + return; + } + + [self.locationManager stopUpdatingLocation]; + self.locationManager = nil; + + [self imagePickerControllerReturnImageResult]; +} + +- (void)imagePickerControllerReturnImageResult +{ + CDVPictureOptions* options = self.pickerController.pictureOptions; + CDVPluginResult* result = nil; + + if (self.metadata) { + CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge CFDataRef)self.data, NULL); + CFStringRef sourceType = CGImageSourceGetType(sourceImage); + + CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)self.data, sourceType, 1, NULL); + CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata); + CGImageDestinationFinalize(destinationImage); + + CFRelease(sourceImage); + CFRelease(destinationImage); + } + + switch (options.destinationType) { + case DestinationTypeFileUri: + { + NSError* err = nil; + NSString* extension = self.pickerController.pictureOptions.encodingType == EncodingTypePNG ? @"png":@"jpg"; + NSString* filePath = [self tempFilePath:extension]; + + // save file + if (![self.data writeToFile:filePath options:NSAtomicWrite error:&err]) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]]; + } + else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[self urlTransformer:[NSURL fileURLWithPath:filePath]] absoluteString]]; + } + } + break; + case DestinationTypeDataUrl: + { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:toBase64(self.data)]; + } + break; + case DestinationTypeNativeUri: + default: + break; + }; + + if (result) { + [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId]; + } + + self.hasPendingOperation = NO; + self.pickerController = nil; + self.data = nil; + self.metadata = nil; + + if (options.saveToPhotoAlbum) { + ALAssetsLibrary *library = [ALAssetsLibrary new]; + [library writeImageDataToSavedPhotosAlbum:self.data metadata:self.metadata completionBlock:nil]; + } +} + +@end + +@implementation CDVCameraPicker + +- (BOOL)prefersStatusBarHidden +{ + return YES; +} + +- (UIViewController*)childViewControllerForStatusBarHidden +{ + return nil; +} + +- (void)viewWillAppear:(BOOL)animated +{ + SEL sel = NSSelectorFromString(@"setNeedsStatusBarAppearanceUpdate"); + if ([self respondsToSelector:sel]) { + [self performSelector:sel withObject:nil afterDelay:0]; + } + + [super viewWillAppear:animated]; +} + ++ (instancetype) createFromPictureOptions:(CDVPictureOptions*)pictureOptions; +{ + CDVCameraPicker* cameraPicker = [[CDVCameraPicker alloc] init]; + cameraPicker.pictureOptions = pictureOptions; + cameraPicker.sourceType = pictureOptions.sourceType; + cameraPicker.allowsEditing = pictureOptions.allowsEditing; + + if (cameraPicker.sourceType == UIImagePickerControllerSourceTypeCamera) { + // We only allow taking pictures (no video) in this API. + cameraPicker.mediaTypes = @[(NSString*)kUTTypeImage]; + // We can only set the camera device if we're actually using the camera. + cameraPicker.cameraDevice = pictureOptions.cameraDirection; + } else if (pictureOptions.mediaType == MediaTypeAll) { + cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:cameraPicker.sourceType]; + } else { + NSArray* mediaArray = @[(NSString*)(pictureOptions.mediaType == MediaTypeVideo ? kUTTypeMovie : kUTTypeImage)]; + cameraPicker.mediaTypes = mediaArray; + } + + return cameraPicker; +} + +@end \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/src/ios/CDVExif.h b/plugins/cordova-plugin-camera/src/ios/CDVExif.h new file mode 100644 index 0000000..3e8adbd --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ios/CDVExif.h @@ -0,0 +1,43 @@ +/* + 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. + */ + +#ifndef CordovaLib_ExifData_h +#define CordovaLib_ExifData_h + +// exif data types +typedef enum exifDataTypes { + EDT_UBYTE = 1, // 8 bit unsigned integer + EDT_ASCII_STRING, // 8 bits containing 7 bit ASCII code, null terminated + EDT_USHORT, // 16 bit unsigned integer + EDT_ULONG, // 32 bit unsigned integer + EDT_URATIONAL, // 2 longs, first is numerator and second is denominator + EDT_SBYTE, + EDT_UNDEFINED, // 8 bits + EDT_SSHORT, + EDT_SLONG, // 32bit signed integer (2's complement) + EDT_SRATIONAL, // 2 SLONGS, first long is numerator, second is denominator + EDT_SINGLEFLOAT, + EDT_DOUBLEFLOAT +} ExifDataTypes; + +// maps integer code for exif data types to width in bytes +static const int DataTypeToWidth[] = {1,1,2,4,8,1,1,2,4,8,4,8}; + +static const int RECURSE_HORIZON = 8; +#endif diff --git a/plugins/cordova-plugin-camera/src/ios/CDVJpegHeaderWriter.h b/plugins/cordova-plugin-camera/src/ios/CDVJpegHeaderWriter.h new file mode 100644 index 0000000..3b43ef0 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ios/CDVJpegHeaderWriter.h @@ -0,0 +1,62 @@ +/* + 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. + */ + +#import + +@interface CDVJpegHeaderWriter : NSObject { + NSDictionary * SubIFDTagFormatDict; + NSDictionary * IFD0TagFormatDict; +} + +- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata + withExifBlock: (NSString*) exifstr; +- (NSString*) createExifAPP1 : (NSDictionary*) datadict; +- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb + withPlaces: (NSNumber*) width; +- (NSString*) formatNumberWithLeadingZeroes: (NSNumber*) numb + withPlaces: (NSNumber*) places; +- (NSString*) decimalToUnsignedRational: (NSNumber*) numb + withResultNumerator: (NSNumber**) numerator + withResultDenominator: (NSNumber**) denominator; +- (void) continuedFraction: (double) val + withFractionList: (NSMutableArray*) fractionlist + withHorizon: (int) horizon; +//- (void) expandContinuedFraction: (NSArray*) fractionlist; +- (void) splitDouble: (double) val + withIntComponent: (int*) rightside + withFloatRemainder: (double*) leftside; +- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator + withDenominator: (NSNumber*) denominator + asSigned: (Boolean) signedFlag; +- (NSString*) hexStringFromData : (NSData*) data; +- (NSNumber*) numericFromHexString : (NSString *) hexstring; + +/* +- (void) readExifMetaData : (NSData*) imgdata; +- (void) spliceImageData : (NSData*) imgdata withExifData: (NSDictionary*) exifdata; +- (void) locateExifMetaData : (NSData*) imgdata; +- (NSString*) createExifAPP1 : (NSDictionary*) datadict; +- (void) createExifDataString : (NSDictionary*) datadict; +- (NSString*) createDataElement : (NSString*) element + withElementData: (NSString*) data + withExternalDataBlock: (NSDictionary*) memblock; +- (NSString*) hexStringFromData : (NSData*) data; +- (NSNumber*) numericFromHexString : (NSString *) hexstring; +*/ +@end diff --git a/plugins/cordova-plugin-camera/src/ios/CDVJpegHeaderWriter.m b/plugins/cordova-plugin-camera/src/ios/CDVJpegHeaderWriter.m new file mode 100644 index 0000000..4d3ea24 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ios/CDVJpegHeaderWriter.m @@ -0,0 +1,547 @@ +/* + 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. + */ + +#import "CDVJpegHeaderWriter.h" +#include "CDVExif.h" + +/* macros for tag info shorthand: + tagno : tag number + typecode : data type + components : number of components + appendString (TAGINF_W_APPEND only) : string to append to data + Exif date data format include an extra 0x00 to the end of the data + */ +#define TAGINF(tagno, typecode, components) [NSArray arrayWithObjects: tagno, typecode, components, nil] +#define TAGINF_W_APPEND(tagno, typecode, components, appendString) [NSArray arrayWithObjects: tagno, typecode, components, appendString, nil] + +const uint mJpegId = 0xffd8; // JPEG format marker +const uint mExifMarker = 0xffe1; // APP1 jpeg header marker +const uint mExif = 0x45786966; // ASCII 'Exif', first characters of valid exif header after size +const uint mMotorallaByteAlign = 0x4d4d; // 'MM', motorola byte align, msb first or 'sane' +const uint mIntelByteAlgin = 0x4949; // 'II', Intel byte align, lsb first or 'batshit crazy reverso world' +const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a(MM) or 0x2a00(II), tiff version number + + +@implementation CDVJpegHeaderWriter + +- (id) init { + self = [super init]; + // supported tags for exif IFD + IFD0TagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys: + // TAGINF(@"010e", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"ImageDescription", + TAGINF_W_APPEND(@"0132", [NSNumber numberWithInt:EDT_ASCII_STRING], @20, @"00"), @"DateTime", + TAGINF(@"010f", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Make", + TAGINF(@"0110", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Model", + TAGINF(@"0131", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Software", + TAGINF(@"011a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"XResolution", + TAGINF(@"011b", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"YResolution", + // currently supplied outside of Exif data block by UIImagePickerControllerMediaMetadata, this is set manually in CDVCamera.m + /* TAGINF(@"0112", [NSNumber numberWithInt:EDT_USHORT], @1), @"Orientation", + + // rest of the tags are supported by exif spec, but are not specified by UIImagePickerControllerMediaMedadata + // should camera hardware supply these values in future versions, or if they can be derived, ImageHeaderWriter will include them gracefully + TAGINF(@"0128", [NSNumber numberWithInt:EDT_USHORT], @1), @"ResolutionUnit", + TAGINF(@"013e", [NSNumber numberWithInt:EDT_URATIONAL], @2), @"WhitePoint", + TAGINF(@"013f", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"PrimaryChromaticities", + TAGINF(@"0211", [NSNumber numberWithInt:EDT_URATIONAL], @3), @"YCbCrCoefficients", + TAGINF(@"0213", [NSNumber numberWithInt:EDT_USHORT], @1), @"YCbCrPositioning", + TAGINF(@"0214", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"ReferenceBlackWhite", + TAGINF(@"8298", [NSNumber numberWithInt:EDT_URATIONAL], @0), @"Copyright", + + // offset to exif subifd, we determine this dynamically based on the size of the main exif IFD + TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset",*/ + nil]; + + + // supported tages for exif subIFD + SubIFDTagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys: + //TAGINF(@"9000", [NSNumber numberWithInt:], @), @"ExifVersion", + //TAGINF(@"9202",[NSNumber numberWithInt:EDT_URATIONAL],@1), @"ApertureValue", + //TAGINF(@"9203",[NSNumber numberWithInt:EDT_SRATIONAL],@1), @"BrightnessValue", + TAGINF(@"a001",[NSNumber numberWithInt:EDT_USHORT],@1), @"ColorSpace", + TAGINF_W_APPEND(@"9004",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeDigitized", + TAGINF_W_APPEND(@"9003",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeOriginal", + TAGINF(@"a402", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureMode", + TAGINF(@"8822", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureProgram", + //TAGINF(@"829a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"ExposureTime", + //TAGINF(@"829d", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FNumber", + TAGINF(@"9209", [NSNumber numberWithInt:EDT_USHORT], @1), @"Flash", + // FocalLengthIn35mmFilm + TAGINF(@"a405", [NSNumber numberWithInt:EDT_USHORT], @1), @"FocalLenIn35mmFilm", + //TAGINF(@"920a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FocalLength", + //TAGINF(@"8827", [NSNumber numberWithInt:EDT_USHORT], @2), @"ISOSpeedRatings", + TAGINF(@"9207", [NSNumber numberWithInt:EDT_USHORT],@1), @"MeteringMode", + // specific to compressed data + TAGINF(@"a002", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelXDimension", + TAGINF(@"a003", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelYDimension", + // data type undefined, but this is a DSC camera, so value is always 1, treat as ushort + TAGINF(@"a301", [NSNumber numberWithInt:EDT_USHORT],@1), @"SceneType", + TAGINF(@"a217",[NSNumber numberWithInt:EDT_USHORT],@1), @"SensingMethod", + //TAGINF(@"9201", [NSNumber numberWithInt:EDT_SRATIONAL], @1), @"ShutterSpeedValue", + // specifies location of main subject in scene (x,y,wdith,height) expressed before rotation processing + //TAGINF(@"9214", [NSNumber numberWithInt:EDT_USHORT], @4), @"SubjectArea", + TAGINF(@"a403", [NSNumber numberWithInt:EDT_USHORT], @1), @"WhiteBalance", + nil]; + return self; +} + +- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata withExifBlock: (NSString*) exifstr { + + CDVJpegHeaderWriter * exifWriter = [[CDVJpegHeaderWriter alloc] init]; + + NSMutableData * exifdata = [NSMutableData dataWithCapacity: [exifstr length]/2]; + int idx; + for (idx = 0; idx+1 < [exifstr length]; idx+=2) { + NSRange range = NSMakeRange(idx, 2); + NSString* hexStr = [exifstr substringWithRange:range]; + NSScanner* scanner = [NSScanner scannerWithString:hexStr]; + unsigned int intValue; + [scanner scanHexInt:&intValue]; + [exifdata appendBytes:&intValue length:1]; + } + + NSMutableData * ddata = [NSMutableData dataWithCapacity: [jpegdata length]]; + NSMakeRange(0,4); + int loc = 0; + bool done = false; + // read the jpeg data until we encounter the app1==0xFFE1 marker + while (loc+1 < [jpegdata length]) { + NSData * blag = [jpegdata subdataWithRange: NSMakeRange(loc,2)]; + if( [[blag description] isEqualToString : @""]) { + // read the APP1 block size bits + NSString * the = [exifWriter hexStringFromData:[jpegdata subdataWithRange: NSMakeRange(loc+2,2)]]; + NSNumber * app1width = [exifWriter numericFromHexString:the]; + //consume the original app1 block + [ddata appendData:exifdata]; + // advance our loc marker past app1 + loc += [app1width intValue] + 2; + done = true; + } else { + if(!done) { + [ddata appendData:blag]; + loc += 2; + } else { + break; + } + } + } + // copy the remaining data + [ddata appendData:[jpegdata subdataWithRange: NSMakeRange(loc,[jpegdata length]-loc)]]; + return ddata; +} + + + +/** + * Create the Exif data block as a hex string + * jpeg uses Application Markers (APP's) as markers for application data + * APP1 is the application marker reserved for exif data + * + * (NSDictionary*) datadict - with subdictionaries marked '{TIFF}' and '{EXIF}' as returned by imagePickerController with a valid + * didFinishPickingMediaWithInfo data dict, under key @"UIImagePickerControllerMediaMetadata" + * + * the following constructs a hex string to Exif specifications, and is therefore brittle + * altering the order of arguments to the string constructors, modifying field sizes or formats, + * and any other minor change will likely prevent the exif data from being read + */ +- (NSString*) createExifAPP1 : (NSDictionary*) datadict { + NSMutableString * app1; // holds finalized product + NSString * exifIFD; // exif information file directory + NSString * subExifIFD; // subexif information file directory + + // FFE1 is the hex APP1 marker code, and will allow client apps to read the data + NSString * app1marker = @"ffe1"; + // SSSS size, to be determined + // EXIF ascii characters followed by 2bytes of zeros + NSString * exifmarker = @"457869660000"; + // Tiff header: 4d4d is motorolla byte align (big endian), 002a is hex for 42 + NSString * tiffheader = @"4d4d002a"; + //first IFD offset from the Tiff header to IFD0. Since we are writing it, we know it's address 0x08 + NSString * ifd0offset = @"00000008"; + // current offset to next data area + int currentDataOffset = 0; + + //data labeled as TIFF in UIImagePickerControllerMediaMetaData is part of the EXIF IFD0 portion of APP1 + exifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{TIFF}"] withFormatDict: IFD0TagFormatDict isIFD0:YES currentDataOffset:¤tDataOffset]; + + //data labeled as EXIF in UIImagePickerControllerMediaMetaData is part of the EXIF Sub IFD portion of APP1 + subExifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{Exif}"] withFormatDict: SubIFDTagFormatDict isIFD0:NO currentDataOffset:¤tDataOffset]; + /* + NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",exifIFD,[exifIFD length]); + + NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",subExifIFD,[subExifIFD length]); + */ + // construct the complete app1 data block + app1 = [[NSMutableString alloc] initWithFormat: @"%@%04x%@%@%@%@%@", + app1marker, + (unsigned int)(16 + ([exifIFD length]/2) + ([subExifIFD length]/2)) /*16+[exifIFD length]/2*/, + exifmarker, + tiffheader, + ifd0offset, + exifIFD, + subExifIFD]; + + return app1; +} + +// returns hex string representing a valid exif information file directory constructed from the datadict and formatdict +- (NSString*) createExifIFDFromDict : (NSDictionary*) datadict + withFormatDict : (NSDictionary*) formatdict + isIFD0 : (BOOL) ifd0flag + currentDataOffset : (int*) dataoffset { + NSArray * datakeys = [datadict allKeys]; // all known data keys + NSArray * knownkeys = [formatdict allKeys]; // only keys in knowkeys are considered for entry in this IFD + NSMutableArray * ifdblock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // all ifd entries + NSMutableArray * ifddatablock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // data block entries + // ifd0flag = NO; // ifd0 requires a special flag and has offset to next ifd appended to end + + // iterate through known provided data keys + for (int i = 0; i < [datakeys count]; i++) { + NSString * key = [datakeys objectAtIndex:i]; + // don't muck about with unknown keys + if ([knownkeys indexOfObject: key] != NSNotFound) { + // create new IFD entry + NSString * entry = [self createIFDElement: key + withFormat: [formatdict objectForKey:key] + withElementData: [datadict objectForKey:key]]; + // create the IFD entry's data block + NSString * data = [self createIFDElementDataWithFormat: [formatdict objectForKey:key] + withData: [datadict objectForKey:key]]; + if (entry) { + [ifdblock addObject:entry]; + if(!data) { + [ifdblock addObject:@""]; + } else { + [ifddatablock addObject:data]; + } + } + } + } + + NSMutableString * exifstr = [[NSMutableString alloc] initWithCapacity: [ifdblock count] * 24]; + NSMutableString * dbstr = [[NSMutableString alloc] initWithCapacity: 100]; + + int addr=*dataoffset; // current offset/address in datablock + if (ifd0flag) { + // calculate offset to datablock based on ifd file entry count + addr += 14+(12*([ifddatablock count]+1)); // +1 for tag 0x8769, exifsubifd offset + } else { + // current offset + numSubIFDs (2-bytes) + 12*numSubIFDs + endMarker (4-bytes) + addr += 2+(12*[ifddatablock count])+4; + } + + for (int i = 0; i < [ifdblock count]; i++) { + NSString * entry = [ifdblock objectAtIndex:i]; + NSString * data = [ifddatablock objectAtIndex:i]; + + // check if the data fits into 4 bytes + if( [data length] <= 8) { + // concatenate the entry and the (4byte) data entry into the final IFD entry and append to exif ifd string + [exifstr appendFormat : @"%@%@", entry, data]; + } else { + [exifstr appendFormat : @"%@%08x", entry, addr]; + [dbstr appendFormat: @"%@", data]; + addr+= [data length] / 2; + /* + NSLog(@"=====data-length[%i]=======",[data length]); + NSLog(@"addr-offset[%i]",addr); + NSLog(@"entry[%@]",entry); + NSLog(@"data[%@]",data); + */ + } + } + + // calculate IFD0 terminal offset tags, currently ExifSubIFD + unsigned int entrycount = (unsigned int)[ifdblock count]; + if (ifd0flag) { + // 18 accounts for 8769's width + offset to next ifd, 8 accounts for start of header + NSNumber * offset = [NSNumber numberWithUnsignedInteger:[exifstr length] / 2 + [dbstr length] / 2 + 18+8]; + + [self appendExifOffsetTagTo: exifstr + withOffset : offset]; + entrycount++; + } + *dataoffset = addr; + return [[NSString alloc] initWithFormat: @"%04x%@%@%@", + entrycount, + exifstr, + @"00000000", // offset to next IFD, 0 since there is none + dbstr]; // lastly, the datablock +} + +// Creates an exif formatted exif information file directory entry +- (NSString*) createIFDElement: (NSString*) elementName withFormat: (NSArray*) formtemplate withElementData: (NSString*) data { + //NSArray * fielddata = [formatdict objectForKey: elementName];// format data of desired field + if (formtemplate) { + // format string @"%@%@%@%@", tag number, data format, components, value + NSNumber * dataformat = [formtemplate objectAtIndex:1]; + NSNumber * components = [formtemplate objectAtIndex:2]; + if([components intValue] == 0) { + components = [NSNumber numberWithUnsignedInteger:[data length] * DataTypeToWidth[[dataformat intValue]-1]]; + } + + return [[NSString alloc] initWithFormat: @"%@%@%08x", + [formtemplate objectAtIndex:0], // the field code + [self formatNumberWithLeadingZeroes: dataformat withPlaces: @4], // the data type code + [components intValue]]; // number of components + } + return NULL; +} + +/** + * appends exif IFD0 tag 8769 "ExifOffset" to the string provided + * (NSMutableString*) str - string you wish to append the 8769 tag to: APP1 or IFD0 hex data string + * // TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset", + */ +- (void) appendExifOffsetTagTo: (NSMutableString*) str withOffset : (NSNumber*) offset { + NSArray * format = TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1); + + NSString * entry = [self createIFDElement: @"ExifOffset" + withFormat: format + withElementData: [offset stringValue]]; + + NSString * data = [self createIFDElementDataWithFormat: format + withData: [offset stringValue]]; + [str appendFormat:@"%@%@", entry, data]; +} + +// formats the Information File Directory Data to exif format +- (NSString*) createIFDElementDataWithFormat: (NSArray*) dataformat withData: (NSString*) data { + NSMutableString * datastr = nil; + NSNumber * tmp = nil; + NSNumber * formatcode = [dataformat objectAtIndex:1]; + NSUInteger formatItemsCount = [dataformat count]; + NSNumber * num = @0; + NSNumber * denom = @0; + + switch ([formatcode intValue]) { + case EDT_UBYTE: + break; + case EDT_ASCII_STRING: + datastr = [[NSMutableString alloc] init]; + for (int i = 0; i < [data length]; i++) { + [datastr appendFormat:@"%02x",[data characterAtIndex:i]]; + } + if (formatItemsCount > 3) { + // We have additional data to append. + // currently used by Date format to append final 0x00 but can be used by other data types as well in the future + [datastr appendString:[dataformat objectAtIndex:3]]; + } + if ([datastr length] < 8) { + NSString * format = [NSString stringWithFormat:@"%%0%dd", (int)(8 - [datastr length])]; + [datastr appendFormat:format,0]; + } + return datastr; + case EDT_USHORT: + return [[NSString alloc] initWithFormat : @"%@%@", + [self formattedHexStringFromDecimalNumber: [NSNumber numberWithInt: [data intValue]] withPlaces: @4], + @"0000"]; + case EDT_ULONG: + tmp = [NSNumber numberWithUnsignedLong:[data intValue]]; + return [NSString stringWithFormat : @"%@", + [self formattedHexStringFromDecimalNumber: tmp withPlaces: @8]]; + case EDT_URATIONAL: + return [self decimalToUnsignedRational: [NSNumber numberWithDouble:[data doubleValue]] + withResultNumerator: &num + withResultDenominator: &denom]; + case EDT_SBYTE: + + break; + case EDT_UNDEFINED: + break; // 8 bits + case EDT_SSHORT: + break; + case EDT_SLONG: + break; // 32bit signed integer (2's complement) + case EDT_SRATIONAL: + break; // 2 SLONGS, first long is numerator, second is denominator + case EDT_SINGLEFLOAT: + break; + case EDT_DOUBLEFLOAT: + break; + } + return datastr; +} + +//====================================================================================================================== +// Utility Methods +//====================================================================================================================== + +// creates a formatted little endian hex string from a number and width specifier +- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb withPlaces: (NSNumber*) width { + NSMutableString * str = [[NSMutableString alloc] initWithCapacity:[width intValue]]; + NSString * formatstr = [[NSString alloc] initWithFormat: @"%%%@%dx", @"0", [width intValue]]; + [str appendFormat:formatstr, [numb intValue]]; + return str; +} + +// format number as string with leading 0's +- (NSString*) formatNumberWithLeadingZeroes: (NSNumber *) numb withPlaces: (NSNumber *) places { + NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init]; + NSString *formatstr = [@"" stringByPaddingToLength:[places unsignedIntegerValue] withString:@"0" startingAtIndex:0]; + [formatter setPositiveFormat:formatstr]; + return [formatter stringFromNumber:numb]; +} + +// approximate a decimal with a rational by method of continued fraction +// can be collasped into decimalToUnsignedRational after testing +- (void) decimalToRational: (NSNumber *) numb + withResultNumerator: (NSNumber**) numerator + withResultDenominator: (NSNumber**) denominator { + NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8]; + + [self continuedFraction: [numb doubleValue] + withFractionList: fractionlist + withHorizon: 8]; + + // simplify complex fraction represented by partial fraction list + [self expandContinuedFraction: fractionlist + withResultNumerator: numerator + withResultDenominator: denominator]; + +} + +// approximate a decimal with an unsigned rational by method of continued fraction +- (NSString*) decimalToUnsignedRational: (NSNumber *) numb + withResultNumerator: (NSNumber**) numerator + withResultDenominator: (NSNumber**) denominator { + NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8]; + + // generate partial fraction list + [self continuedFraction: [numb doubleValue] + withFractionList: fractionlist + withHorizon: 8]; + + // simplify complex fraction represented by partial fraction list + [self expandContinuedFraction: fractionlist + withResultNumerator: numerator + withResultDenominator: denominator]; + + return [self formatFractionList: fractionlist]; +} + +// recursive implementation of decimal approximation by continued fraction +- (void) continuedFraction: (double) val + withFractionList: (NSMutableArray*) fractionlist + withHorizon: (int) horizon { + int whole; + double remainder; + // 1. split term + [self splitDouble: val withIntComponent: &whole withFloatRemainder: &remainder]; + [fractionlist addObject: [NSNumber numberWithInt:whole]]; + + // 2. calculate reciprocal of remainder + if (!remainder) return; // early exit, exact fraction found, avoids recip/0 + double recip = 1 / remainder; + + // 3. exit condition + if ([fractionlist count] > horizon) { + return; + } + + // 4. recurse + [self continuedFraction:recip withFractionList: fractionlist withHorizon: horizon]; + +} + +// expand continued fraction list, creating a single level rational approximation +-(void) expandContinuedFraction: (NSArray*) fractionlist + withResultNumerator: (NSNumber**) numerator + withResultDenominator: (NSNumber**) denominator { + NSUInteger i = 0; + int den = 0; + int num = 0; + if ([fractionlist count] == 1) { + *numerator = [NSNumber numberWithInt:[[fractionlist objectAtIndex:0] intValue]]; + *denominator = @1; + return; + } + + //begin at the end of the list + i = [fractionlist count] - 1; + num = 1; + den = [[fractionlist objectAtIndex:i] intValue]; + + while (i > 0) { + int t = [[fractionlist objectAtIndex: i-1] intValue]; + num = t * den + num; + if (i==1) { + break; + } else { + t = num; + num = den; + den = t; + } + i--; + } + // set result parameters values + *numerator = [NSNumber numberWithInt: num]; + *denominator = [NSNumber numberWithInt: den]; +} + +// formats expanded fraction list to string matching exif specification +- (NSString*) formatFractionList: (NSArray *) fractionlist { + NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16]; + + if ([fractionlist count] == 1){ + [str appendFormat: @"%08x00000001", [[fractionlist objectAtIndex:0] intValue]]; + } + return str; +} + +// format rational as +- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator withDenominator: (NSNumber*) denominator asSigned: (Boolean) signedFlag { + NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16]; + if (signedFlag) { + long num = [numerator longValue]; + long den = [denominator longValue]; + [str appendFormat: @"%08lx%08lx", num >= 0 ? num : ~ABS(num) + 1, num >= 0 ? den : ~ABS(den) + 1]; + } else { + [str appendFormat: @"%08lx%08lx", [numerator unsignedLongValue], [denominator unsignedLongValue]]; + } + return str; +} + +// split a floating point number into two integer values representing the left and right side of the decimal +- (void) splitDouble: (double) val withIntComponent: (int*) rightside withFloatRemainder: (double*) leftside { + *rightside = val; // convert numb to int representation, which truncates the decimal portion + *leftside = val - *rightside; +} + + +// +- (NSString*) hexStringFromData : (NSData*) data { + //overflow detection + const unsigned char *dataBuffer = [data bytes]; + return [[NSString alloc] initWithFormat: @"%02x%02x", + (unsigned char)dataBuffer[0], + (unsigned char)dataBuffer[1]]; +} + +// convert a hex string to a number +- (NSNumber*) numericFromHexString : (NSString *) hexstring { + NSScanner * scan = NULL; + unsigned int numbuf= 0; + + scan = [NSScanner scannerWithString:hexstring]; + [scan scanHexInt:&numbuf]; + return [NSNumber numberWithInt:numbuf]; +} + +@end diff --git a/plugins/cordova-plugin-camera/src/ios/UIImage+CropScaleOrientation.h b/plugins/cordova-plugin-camera/src/ios/UIImage+CropScaleOrientation.h new file mode 100644 index 0000000..31bc42f --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ios/UIImage+CropScaleOrientation.h @@ -0,0 +1,29 @@ +/* + 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. + */ + +#import + +@interface UIImage (CropScaleOrientation) + +- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize; +- (UIImage*)imageCorrectedForCaptureOrientation; +- (UIImage*)imageCorrectedForCaptureOrientation:(UIImageOrientation)imageOrientation; +- (UIImage*)imageByScalingNotCroppingForSize:(CGSize)targetSize; + +@end \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/src/ios/UIImage+CropScaleOrientation.m b/plugins/cordova-plugin-camera/src/ios/UIImage+CropScaleOrientation.m new file mode 100644 index 0000000..a66a5d8 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ios/UIImage+CropScaleOrientation.m @@ -0,0 +1,175 @@ +/* + 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. + */ + +#import "UIImage+CropScaleOrientation.h" + +@implementation UIImage (CropScaleOrientation) + +- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize +{ + UIImage* sourceImage = self; + UIImage* newImage = nil; + CGSize imageSize = sourceImage.size; + CGFloat width = imageSize.width; + CGFloat height = imageSize.height; + CGFloat targetWidth = targetSize.width; + CGFloat targetHeight = targetSize.height; + CGFloat scaleFactor = 0.0; + CGFloat scaledWidth = targetWidth; + CGFloat scaledHeight = targetHeight; + CGPoint thumbnailPoint = CGPointMake(0.0, 0.0); + + if (CGSizeEqualToSize(imageSize, targetSize) == NO) { + CGFloat widthFactor = targetWidth / width; + CGFloat heightFactor = targetHeight / height; + + if (widthFactor > heightFactor) { + scaleFactor = widthFactor; // scale to fit height + } else { + scaleFactor = heightFactor; // scale to fit width + } + scaledWidth = width * scaleFactor; + scaledHeight = height * scaleFactor; + + // center the image + if (widthFactor > heightFactor) { + thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; + } else if (widthFactor < heightFactor) { + thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5; + } + } + + UIGraphicsBeginImageContext(targetSize); // this will crop + + CGRect thumbnailRect = CGRectZero; + thumbnailRect.origin = thumbnailPoint; + thumbnailRect.size.width = scaledWidth; + thumbnailRect.size.height = scaledHeight; + + [sourceImage drawInRect:thumbnailRect]; + + newImage = UIGraphicsGetImageFromCurrentImageContext(); + if (newImage == nil) { + NSLog(@"could not scale image"); + } + + // pop the context to get back to the default + UIGraphicsEndImageContext(); + return newImage; +} + +- (UIImage*)imageCorrectedForCaptureOrientation:(UIImageOrientation)imageOrientation +{ + float rotation_radians = 0; + bool perpendicular = false; + + switch (imageOrientation) { + case UIImageOrientationUp : + rotation_radians = 0.0; + break; + + case UIImageOrientationDown: + rotation_radians = M_PI; // don't be scared of radians, if you're reading this, you're good at math + break; + + case UIImageOrientationRight: + rotation_radians = M_PI_2; + perpendicular = true; + break; + + case UIImageOrientationLeft: + rotation_radians = -M_PI_2; + perpendicular = true; + break; + + default: + break; + } + + UIGraphicsBeginImageContext(CGSizeMake(self.size.width, self.size.height)); + CGContextRef context = UIGraphicsGetCurrentContext(); + + // Rotate around the center point + CGContextTranslateCTM(context, self.size.width / 2, self.size.height / 2); + CGContextRotateCTM(context, rotation_radians); + + CGContextScaleCTM(context, 1.0, -1.0); + float width = perpendicular ? self.size.height : self.size.width; + float height = perpendicular ? self.size.width : self.size.height; + CGContextDrawImage(context, CGRectMake(-width / 2, -height / 2, width, height), [self CGImage]); + + // Move the origin back since the rotation might've change it (if its 90 degrees) + if (perpendicular) { + CGContextTranslateCTM(context, -self.size.height / 2, -self.size.width / 2); + } + + UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return newImage; +} + +- (UIImage*)imageCorrectedForCaptureOrientation +{ + return [self imageCorrectedForCaptureOrientation:[self imageOrientation]]; +} + +- (UIImage*)imageByScalingNotCroppingForSize:(CGSize)targetSize +{ + UIImage* sourceImage = self; + UIImage* newImage = nil; + CGSize imageSize = sourceImage.size; + CGFloat width = imageSize.width; + CGFloat height = imageSize.height; + CGFloat targetWidth = targetSize.width; + CGFloat targetHeight = targetSize.height; + CGFloat scaleFactor = 0.0; + CGSize scaledSize = targetSize; + + if (CGSizeEqualToSize(imageSize, targetSize) == NO) { + CGFloat widthFactor = targetWidth / width; + CGFloat heightFactor = targetHeight / height; + + // opposite comparison to imageByScalingAndCroppingForSize in order to contain the image within the given bounds + if (widthFactor > heightFactor) { + scaleFactor = heightFactor; // scale to fit height + } else { + scaleFactor = widthFactor; // scale to fit width + } + scaledSize = CGSizeMake(MIN(width * scaleFactor, targetWidth), MIN(height * scaleFactor, targetHeight)); + } + + // If the pixels are floats, it causes a white line in iOS8 and probably other versions too + scaledSize.width = (int)scaledSize.width; + scaledSize.height = (int)scaledSize.height; + + UIGraphicsBeginImageContext(scaledSize); // this will resize + + [sourceImage drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)]; + + newImage = UIGraphicsGetImageFromCurrentImageContext(); + if (newImage == nil) { + NSLog(@"could not scale image"); + } + + // pop the context to get back to the default + UIGraphicsEndImageContext(); + return newImage; +} + +@end diff --git a/plugins/cordova-plugin-camera/src/ubuntu/CaptureWidget.qml b/plugins/cordova-plugin-camera/src/ubuntu/CaptureWidget.qml new file mode 100644 index 0000000..0a332e2 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ubuntu/CaptureWidget.qml @@ -0,0 +1,118 @@ +/* + * + * Copyright 2013 Canonical Ltd. + * + * 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. + * +*/ +import QtQuick 2.0 +import QtMultimedia 5.0 + +Rectangle { + property string shootImagePath: "shoot.png" + function isSuffix(str, suffix) { + return String(str).substr(String(str).length - suffix.length) == suffix + } + + id: ui + color: "#252423" + anchors.fill: parent + + Camera { + objectName: "camera" + id: camera + onError: { + console.log(errorString); + } + videoRecorder.audioBitRate: 128000 + imageCapture { + onImageSaved: { + root.exec("Camera", "onImageSaved", [path]); + ui.destroy(); + } + } + } + VideoOutput { + id: output + source: camera + width: parent.width + height: parent.height + } + + Item { + anchors.bottom: parent.bottom + width: parent.width + height: shootButton.height + BorderImage { + id: leftBackground + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: middle.left + anchors.topMargin: units.dp(2) + anchors.bottomMargin: units.dp(2) + source: "toolbar-left.png" + Image { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: parent.iconSpacing + source: "back.png" + width: units.gu(6) + height: units.gu(5) + MouseArea { + anchors.fill: parent + onClicked: { + root.exec("Camera", "cancel"); + } + } + } + } + BorderImage { + id: middle + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + height: shootButton.height + units.gu(1) + width: shootButton.width + source: "toolbar-middle.png" + Image { + id: shootButton + width: units.gu(8) + height: width + anchors.horizontalCenter: parent.horizontalCenter + source: shootImagePath + MouseArea { + anchors.fill: parent + onClicked: { + camera.imageCapture.captureToLocation(ui.parent.plugin('Camera').generateLocation("jpg")); + } + } + } + } + BorderImage { + id: rightBackground + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: middle.right + anchors.topMargin: units.dp(2) + anchors.bottomMargin: units.dp(2) + source: "toolbar-right.png" + } + } +} diff --git a/plugins/cordova-plugin-camera/src/ubuntu/back.png b/plugins/cordova-plugin-camera/src/ubuntu/back.png new file mode 100644 index 0000000..af78faa Binary files /dev/null and b/plugins/cordova-plugin-camera/src/ubuntu/back.png differ diff --git a/plugins/cordova-plugin-camera/src/ubuntu/camera.cpp b/plugins/cordova-plugin-camera/src/ubuntu/camera.cpp new file mode 100644 index 0000000..c58af32 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ubuntu/camera.cpp @@ -0,0 +1,140 @@ +/* + * + * 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. + * +*/ + +#include "camera.h" +#include + +#include +#include +#include +#include +#include + +const char code[] = "\ +var component, object; \ +function createObject() { \ + component = Qt.createComponent(%1); \ + if (component.status == Component.Ready) \ + finishCreation(); \ + else \ + component.statusChanged.connect(finishCreation); \ +} \ +function finishCreation() { \ + CordovaWrapper.global.cameraPluginWidget = component.createObject(root, \ + {root: root, cordova: cordova}); \ +} \ +createObject()"; + + +Camera::Camera(Cordova *cordova): + CPlugin(cordova), + _lastScId(0), + _lastEcId(0) { +} + +bool Camera::preprocessImage(QString &path) { + bool convertToPNG = (*_options.find("encodingType")).toInt() == Camera::PNG; + int quality = (*_options.find("quality")).toInt(); + int width = (*_options.find("targetWidth")).toInt(); + int height = (*_options.find("targetHeight")).toInt(); + + QImage image(path); + if (width <= 0) + width = image.width(); + if (height <= 0) + height = image.height(); + image = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); + + QFile oldImage(path); + QTemporaryFile newImage; + + const char *type; + if (convertToPNG) { + path = generateLocation("png"); + type = "png"; + } else { + path = generateLocation("jpg"); + type = "jpg"; + } + + image.save(path, type, quality); + + oldImage.remove(); + + return true; +} + +void Camera::onImageSaved(QString path) { + bool dataURL = _options.find("destinationType")->toInt() == Camera::DATA_URL; + + QString cbParams; + if (preprocessImage(path)) { + QString absolutePath = QFileInfo(path).absoluteFilePath(); + if (dataURL) { + QFile image(absolutePath); + image.open(QIODevice::ReadOnly); + QByteArray content = image.readAll().toBase64(); + cbParams = QString("\"%1\"").arg(content.data()); + image.remove(); + } else { + cbParams = CordovaInternal::format(QString("file://localhost") + absolutePath); + } + } + + this->callback(_lastScId, cbParams); + + _lastEcId = _lastScId = 0; +} + +void Camera::takePicture(int scId, int ecId, int quality, int destinationType, int/*sourceType*/, int targetWidth, int targetHeight, int encodingType, + int/*mediaType*/, bool/*allowEdit*/, bool/*correctOrientation*/, bool/*saveToPhotoAlbum*/, const QVariantMap &/*popoverOptions*/, int/*cameraDirection*/) { + if (_camera.isNull()) { + _camera = QSharedPointer(new QCamera()); + } + + if (((_lastScId || _lastEcId) && (_lastScId != scId && _lastEcId != ecId)) || !_camera->isAvailable() || _camera->lockStatus() != QCamera::Unlocked) { + this->cb(_lastEcId, "Device is busy"); + return; + } + + _options.clear(); + _options.insert("quality", quality); + _options.insert("destinationType", destinationType); + _options.insert("targetWidth", targetWidth); + _options.insert("targetHeight", targetHeight); + _options.insert("encodingType", encodingType); + + _lastScId = scId; + _lastEcId = ecId; + + QString path = m_cordova->get_app_dir() + "/../qml/CaptureWidget.qml"; + + // TODO: relative url + QString qml = QString(code).arg(CordovaInternal::format(path)); + m_cordova->execQML(qml); +} + +void Camera::cancel() { + m_cordova->execQML("CordovaWrapper.global.cameraPluginWidget.destroy()"); + this->cb(_lastEcId, "canceled"); + + _lastEcId = _lastScId = 0; +} diff --git a/plugins/cordova-plugin-camera/src/ubuntu/camera.h b/plugins/cordova-plugin-camera/src/ubuntu/camera.h new file mode 100644 index 0000000..6d96038 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/ubuntu/camera.h @@ -0,0 +1,86 @@ +/* + * + * 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. + * +*/ + +#ifndef CAMERA_H +#define CAMERA_H + +#include + +#include +#include +#include +#include +#include + +class Camera: public CPlugin { + Q_OBJECT +public: + explicit Camera(Cordova *cordova); + + virtual const QString fullName() override { + return Camera::fullID(); + } + + virtual const QString shortName() override { + return "Camera"; + } + + static const QString fullID() { + return "Camera"; + } + +public slots: + void takePicture(int scId, int ecId, int quality, int destinationType, int/*sourceType*/, int targetWidth, int targetHeight, int encodingType, + int/*mediaType*/, bool/*allowEdit*/, bool/*correctOrientation*/, bool/*saveToPhotoAlbum*/, const QVariantMap &popoverOptions, int cameraDirection); + void cancel(); + + void onImageSaved(QString path); + + QString generateLocation(const QString &extension) { + int i = 1; + for (;;++i) { + QString path = QString("%1/.local/share/%2/persistent/%3.%4").arg(QDir::homePath()) + .arg(QCoreApplication::applicationName()).arg(i).arg(extension); + + if (!QFileInfo(path).exists()) + return path; + } + } +private: + bool preprocessImage(QString &path); + + int _lastScId; + int _lastEcId; + QSharedPointer _camera; + + QVariantMap _options; +protected: + enum DestinationType { + DATA_URL = 0, + FILE_URI = 1 + }; + enum EncodingType { + JPEG = 0, + PNG = 1 + }; +}; + +#endif // CAMERA_H diff --git a/plugins/cordova-plugin-camera/src/ubuntu/shoot.png b/plugins/cordova-plugin-camera/src/ubuntu/shoot.png new file mode 100644 index 0000000..c093b63 Binary files /dev/null and b/plugins/cordova-plugin-camera/src/ubuntu/shoot.png differ diff --git a/plugins/cordova-plugin-camera/src/ubuntu/toolbar-left.png b/plugins/cordova-plugin-camera/src/ubuntu/toolbar-left.png new file mode 100644 index 0000000..720d7f6 Binary files /dev/null and b/plugins/cordova-plugin-camera/src/ubuntu/toolbar-left.png differ diff --git a/plugins/cordova-plugin-camera/src/ubuntu/toolbar-middle.png b/plugins/cordova-plugin-camera/src/ubuntu/toolbar-middle.png new file mode 100644 index 0000000..77595bb Binary files /dev/null and b/plugins/cordova-plugin-camera/src/ubuntu/toolbar-middle.png differ diff --git a/plugins/cordova-plugin-camera/src/ubuntu/toolbar-right.png b/plugins/cordova-plugin-camera/src/ubuntu/toolbar-right.png new file mode 100644 index 0000000..e4e6aa6 Binary files /dev/null and b/plugins/cordova-plugin-camera/src/ubuntu/toolbar-right.png differ diff --git a/plugins/cordova-plugin-camera/src/windows/CameraProxy.js b/plugins/cordova-plugin-camera/src/windows/CameraProxy.js new file mode 100644 index 0000000..0862f35 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/windows/CameraProxy.js @@ -0,0 +1,878 @@ +/* + * + * 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. + * +*/ + +/*jshint unused:true, undef:true, browser:true */ +/*global Windows:true, URL:true, module:true, require:true, WinJS:true */ + + +var Camera = require('./Camera'); + + +var getAppData = function () { + return Windows.Storage.ApplicationData.current; +}; +var encodeToBase64String = function (buffer) { + return Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer); +}; +var OptUnique = Windows.Storage.CreationCollisionOption.generateUniqueName; +var CapMSType = Windows.Media.Capture.MediaStreamType; +var webUIApp = Windows.UI.WebUI.WebUIApplication; +var fileIO = Windows.Storage.FileIO; +var pickerLocId = Windows.Storage.Pickers.PickerLocationId; + +module.exports = { + + // args will contain : + // ... it is an array, so be careful + // 0 quality:50, + // 1 destinationType:Camera.DestinationType.FILE_URI, + // 2 sourceType:Camera.PictureSourceType.CAMERA, + // 3 targetWidth:-1, + // 4 targetHeight:-1, + // 5 encodingType:Camera.EncodingType.JPEG, + // 6 mediaType:Camera.MediaType.PICTURE, + // 7 allowEdit:false, + // 8 correctOrientation:false, + // 9 saveToPhotoAlbum:false, + // 10 popoverOptions:null + // 11 cameraDirection:0 + + takePicture: function (successCallback, errorCallback, args) { + var sourceType = args[2]; + + if (sourceType != Camera.PictureSourceType.CAMERA) { + takePictureFromFile(successCallback, errorCallback, args); + } else { + takePictureFromCamera(successCallback, errorCallback, args); + } + } +}; + +// https://msdn.microsoft.com/en-us/library/windows/apps/ff462087(v=vs.105).aspx +var windowsVideoContainers = [".avi", ".flv", ".asx", ".asf", ".mov", ".mp4", ".mpg", ".rm", ".srt", ".swf", ".wmv", ".vob"]; +var windowsPhoneVideoContainers = [".avi", ".3gp", ".3g2", ".wmv", ".3gp", ".3g2", ".mp4", ".m4v"]; + +// Default aspect ratio 1.78 (16:9 hd video standard) +var DEFAULT_ASPECT_RATIO = '1.8'; + +// Highest possible z-index supported across browsers. Anything used above is converted to this value. +var HIGHEST_POSSIBLE_Z_INDEX = 2147483647; + +// Resize method +function resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType) { + var tempPhotoFileName = ""; + if (encodingType == Camera.EncodingType.PNG) { + tempPhotoFileName = "camera_cordova_temp_return.png"; + } else { + tempPhotoFileName = "camera_cordova_temp_return.jpg"; + } + + var storageFolder = getAppData().localFolder; + file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting) + .then(function (storageFile) { + return fileIO.readBufferAsync(storageFile); + }) + .then(function(buffer) { + var strBase64 = encodeToBase64String(buffer); + var imageData = "data:" + file.contentType + ";base64," + strBase64; + var image = new Image(); + image.src = imageData; + image.onload = function() { + var ratio = Math.min(targetWidth / this.width, targetHeight / this.height); + var imageWidth = ratio * this.width; + var imageHeight = ratio * this.height; + + var canvas = document.createElement('canvas'); + var storageFileName; + + canvas.width = imageWidth; + canvas.height = imageHeight; + + canvas.getContext("2d").drawImage(this, 0, 0, imageWidth, imageHeight); + + var fileContent = canvas.toDataURL(file.contentType).split(',')[1]; + + var storageFolder = getAppData().localFolder; + + storageFolder.createFileAsync(tempPhotoFileName, OptUnique) + .then(function (storagefile) { + var content = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(fileContent); + storageFileName = storagefile.name; + return fileIO.writeBufferAsync(storagefile, content); + }) + .done(function () { + successCallback("ms-appdata:///local/" + storageFileName); + }, errorCallback); + }; + }) + .done(null, function(err) { + errorCallback(err); + } + ); +} + +// Because of asynchronous method, so let the successCallback be called in it. +function resizeImageBase64(successCallback, errorCallback, file, targetWidth, targetHeight) { + fileIO.readBufferAsync(file).done( function(buffer) { + var strBase64 = encodeToBase64String(buffer); + var imageData = "data:" + file.contentType + ";base64," + strBase64; + + var image = new Image(); + image.src = imageData; + + image.onload = function() { + var ratio = Math.min(targetWidth / this.width, targetHeight / this.height); + var imageWidth = ratio * this.width; + var imageHeight = ratio * this.height; + var canvas = document.createElement('canvas'); + + canvas.width = imageWidth; + canvas.height = imageHeight; + + var ctx = canvas.getContext("2d"); + ctx.drawImage(this, 0, 0, imageWidth, imageHeight); + + // The resized file ready for upload + var finalFile = canvas.toDataURL(file.contentType); + + // Remove the prefix such as "data:" + contentType + ";base64," , in order to meet the Cordova API. + var arr = finalFile.split(","); + var newStr = finalFile.substr(arr[0].length + 1); + successCallback(newStr); + }; + }, function(err) { errorCallback(err); }); +} + +function takePictureFromFile(successCallback, errorCallback, args) { + // Detect Windows Phone + if (navigator.appVersion.indexOf('Windows Phone 8.1') >= 0) { + takePictureFromFileWP(successCallback, errorCallback, args); + } else { + takePictureFromFileWindows(successCallback, errorCallback, args); + } +} + +function takePictureFromFileWP(successCallback, errorCallback, args) { + var mediaType = args[6], + destinationType = args[1], + targetWidth = args[3], + targetHeight = args[4], + encodingType = args[5]; + + /* + Need to add and remove an event listener to catch activation state + Using FileOpenPicker will suspend the app and it's required to catch the PickSingleFileAndContinue + https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631755.aspx + */ + var filePickerActivationHandler = function(eventArgs) { + if (eventArgs.kind === Windows.ApplicationModel.Activation.ActivationKind.pickFileContinuation) { + var file = eventArgs.files[0]; + if (!file) { + errorCallback("User didn't choose a file."); + webUIApp.removeEventListener("activated", filePickerActivationHandler); + return; + } + if (destinationType == Camera.DestinationType.FILE_URI || destinationType == Camera.DestinationType.NATIVE_URI) { + if (targetHeight > 0 && targetWidth > 0) { + resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType); + } + else { + var storageFolder = getAppData().localFolder; + file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).done(function (storageFile) { + if(destinationType == Camera.DestinationType.NATIVE_URI) { + successCallback("ms-appdata:///local/" + storageFile.name); + } + else { + successCallback(URL.createObjectURL(storageFile)); + } + }, function () { + errorCallback("Can't access localStorage folder."); + }); + } + } + else { + if (targetHeight > 0 && targetWidth > 0) { + resizeImageBase64(successCallback, errorCallback, file, targetWidth, targetHeight); + } else { + fileIO.readBufferAsync(file).done(function (buffer) { + var strBase64 =encodeToBase64String(buffer); + successCallback(strBase64); + }, errorCallback); + } + } + webUIApp.removeEventListener("activated", filePickerActivationHandler); + } + }; + + var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker(); + if (mediaType == Camera.MediaType.PICTURE) { + fileOpenPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]); + fileOpenPicker.suggestedStartLocation = pickerLocId.picturesLibrary; + } + else if (mediaType == Camera.MediaType.VIDEO) { + fileOpenPicker.fileTypeFilter.replaceAll(windowsPhoneVideoContainers); + fileOpenPicker.suggestedStartLocation = pickerLocId.videosLibrary; + } + else { + fileOpenPicker.fileTypeFilter.replaceAll(["*"]); + fileOpenPicker.suggestedStartLocation = pickerLocId.documentsLibrary; + } + + webUIApp.addEventListener("activated", filePickerActivationHandler); + fileOpenPicker.pickSingleFileAndContinue(); +} + +function takePictureFromFileWindows(successCallback, errorCallback, args) { + var mediaType = args[6], + destinationType = args[1], + targetWidth = args[3], + targetHeight = args[4], + encodingType = args[5]; + + var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker(); + if (mediaType == Camera.MediaType.PICTURE) { + fileOpenPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]); + fileOpenPicker.suggestedStartLocation = pickerLocId.picturesLibrary; + } + else if (mediaType == Camera.MediaType.VIDEO) { + fileOpenPicker.fileTypeFilter.replaceAll(windowsVideoContainers); + fileOpenPicker.suggestedStartLocation = pickerLocId.videosLibrary; + } + else { + fileOpenPicker.fileTypeFilter.replaceAll(["*"]); + fileOpenPicker.suggestedStartLocation = pickerLocId.documentsLibrary; + } + + fileOpenPicker.pickSingleFileAsync().done(function (file) { + if (!file) { + errorCallback("User didn't choose a file."); + return; + } + if (destinationType == Camera.DestinationType.FILE_URI || destinationType == Camera.DestinationType.NATIVE_URI) { + if (targetHeight > 0 && targetWidth > 0) { + resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType); + } + else { + var storageFolder = getAppData().localFolder; + file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).done(function (storageFile) { + if(destinationType == Camera.DestinationType.NATIVE_URI) { + successCallback("ms-appdata:///local/" + storageFile.name); + } + else { + successCallback(URL.createObjectURL(storageFile)); + } + }, function () { + errorCallback("Can't access localStorage folder."); + }); + } + } + else { + if (targetHeight > 0 && targetWidth > 0) { + resizeImageBase64(successCallback, errorCallback, file, targetWidth, targetHeight); + } else { + fileIO.readBufferAsync(file).done(function (buffer) { + var strBase64 =encodeToBase64String(buffer); + successCallback(strBase64); + }, errorCallback); + } + } + }, function () { + errorCallback("User didn't choose a file."); + }); +} + +function takePictureFromCamera(successCallback, errorCallback, args) { + // Check if necessary API available + if (!Windows.Media.Capture.CameraCaptureUI) { + takePictureFromCameraWP(successCallback, errorCallback, args); + } else { + takePictureFromCameraWindows(successCallback, errorCallback, args); + } +} + +function takePictureFromCameraWP(successCallback, errorCallback, args) { + // We are running on WP8.1 which lacks CameraCaptureUI class + // so we need to use MediaCapture class instead and implement custom UI for camera + var destinationType = args[1], + targetWidth = args[3], + targetHeight = args[4], + encodingType = args[5], + saveToPhotoAlbum = args[9], + cameraDirection = args[11], + capturePreview = null, + cameraCaptureButton = null, + cameraCancelButton = null, + capture = null, + captureSettings = null, + CaptureNS = Windows.Media.Capture, + sensor = null; + + function createCameraUI() { + // create style for take and cancel buttons + var buttonStyle = "width:45%;padding: 10px 16px;font-size: 18px;line-height: 1.3333333;color: #333;background-color: #fff;border-color: #ccc; border: 1px solid transparent;border-radius: 6px; display: block; margin: 20px; z-index: 1000;border-color: #adadad;"; + + // Create fullscreen preview + // z-order style element for capturePreview and cameraCancelButton elts + // is necessary to avoid overriding by another page elements, -1 sometimes is not enough + capturePreview = document.createElement("video"); + capturePreview.style.cssText = "position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: " + (HIGHEST_POSSIBLE_Z_INDEX - 1) + ";"; + + // Create capture button + cameraCaptureButton = document.createElement("button"); + cameraCaptureButton.innerText = "Take"; + cameraCaptureButton.style.cssText = buttonStyle + "position: fixed; left: 0; bottom: 0; margin: 20px; z-index: " + HIGHEST_POSSIBLE_Z_INDEX + ";"; + + // Create cancel button + cameraCancelButton = document.createElement("button"); + cameraCancelButton.innerText = "Cancel"; + cameraCancelButton.style.cssText = buttonStyle + "position: fixed; right: 0; bottom: 0; margin: 20px; z-index: " + HIGHEST_POSSIBLE_Z_INDEX + ";"; + + capture = new CaptureNS.MediaCapture(); + + captureSettings = new CaptureNS.MediaCaptureInitializationSettings(); + captureSettings.streamingCaptureMode = CaptureNS.StreamingCaptureMode.video; + } + + function continueVideoOnFocus() { + // if preview is defined it would be stuck, play it + if (capturePreview) { + capturePreview.play(); + } + } + + function startCameraPreview() { + // Search for available camera devices + // This is necessary to detect which camera (front or back) we should use + var DeviceEnum = Windows.Devices.Enumeration; + var expectedPanel = cameraDirection === 1 ? DeviceEnum.Panel.front : DeviceEnum.Panel.back; + + // Add focus event handler to capture the event when user suspends the app and comes back while the preview is on + window.addEventListener("focus", continueVideoOnFocus); + + DeviceEnum.DeviceInformation.findAllAsync(DeviceEnum.DeviceClass.videoCapture).then(function (devices) { + if (devices.length <= 0) { + destroyCameraPreview(); + errorCallback('Camera not found'); + return; + } + + devices.forEach(function(currDev) { + if (currDev.enclosureLocation.panel && currDev.enclosureLocation.panel == expectedPanel) { + captureSettings.videoDeviceId = currDev.id; + } + }); + + captureSettings.photoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.photo; + + return capture.initializeAsync(captureSettings); + }).then(function () { + + // create focus control if available + var VideoDeviceController = capture.videoDeviceController; + var FocusControl = VideoDeviceController.focusControl; + + if (FocusControl.supported === true) { + capturePreview.addEventListener('click', function () { + // Make sure function isn't called again before previous focus is completed + if (this.getAttribute('clicked') === '1') { + return false; + } else { + this.setAttribute('clicked', '1'); + } + var preset = Windows.Media.Devices.FocusPreset.autoNormal; + var parent = this; + FocusControl.setPresetAsync(preset).done(function () { + // set the clicked attribute back to '0' to allow focus again + parent.setAttribute('clicked', '0'); + }); + }); + } + + // msdn.microsoft.com/en-us/library/windows/apps/hh452807.aspx + capturePreview.msZoom = true; + capturePreview.src = URL.createObjectURL(capture); + capturePreview.play(); + + // Bind events to controls + sensor = Windows.Devices.Sensors.SimpleOrientationSensor.getDefault(); + if (sensor !== null) { + sensor.addEventListener("orientationchanged", onOrientationChange); + } + + // add click events to capture and cancel buttons + cameraCaptureButton.addEventListener('click', onCameraCaptureButtonClick); + cameraCancelButton.addEventListener('click', onCameraCancelButtonClick); + + // Change default orientation + if (sensor) { + setPreviewRotation(sensor.getCurrentOrientation()); + } else { + setPreviewRotation(Windows.Graphics.Display.DisplayInformation.getForCurrentView().currentOrientation); + } + + // Get available aspect ratios + var aspectRatios = getAspectRatios(capture); + + // Couldn't find a good ratio + if (aspectRatios.length === 0) { + destroyCameraPreview(); + errorCallback('There\'s not a good aspect ratio available'); + return; + } + + // add elements to body + document.body.appendChild(capturePreview); + document.body.appendChild(cameraCaptureButton); + document.body.appendChild(cameraCancelButton); + + if (aspectRatios.indexOf(DEFAULT_ASPECT_RATIO) > -1) { + return setAspectRatio(capture, DEFAULT_ASPECT_RATIO); + } else { + // Doesn't support 16:9 - pick next best + return setAspectRatio(capture, aspectRatios[0]); + } + }).done(null, function (err) { + destroyCameraPreview(); + errorCallback('Camera intitialization error ' + err); + }); + } + + function destroyCameraPreview() { + // If sensor is available, remove event listener + if (sensor !== null) { + sensor.removeEventListener('orientationchanged', onOrientationChange); + } + + // Pause and dispose preview element + capturePreview.pause(); + capturePreview.src = null; + + // Remove event listeners from buttons + cameraCaptureButton.removeEventListener('click', onCameraCaptureButtonClick); + cameraCancelButton.removeEventListener('click', onCameraCancelButtonClick); + + // Remove the focus event handler + window.removeEventListener("focus", continueVideoOnFocus); + + // Remove elements + [capturePreview, cameraCaptureButton, cameraCancelButton].forEach(function (elem) { + if (elem /* && elem in document.body.childNodes */) { + document.body.removeChild(elem); + } + }); + + // Stop and dispose media capture manager + if (capture) { + capture.stopRecordAsync(); + capture = null; + } + } + + function captureAction() { + + var encodingProperties, + fileName, + tempFolder = getAppData().temporaryFolder; + + if (encodingType == Camera.EncodingType.PNG) { + fileName = 'photo.png'; + encodingProperties = Windows.Media.MediaProperties.ImageEncodingProperties.createPng(); + } else { + fileName = 'photo.jpg'; + encodingProperties = Windows.Media.MediaProperties.ImageEncodingProperties.createJpeg(); + } + + tempFolder.createFileAsync(fileName, OptUnique) + .then(function(tempCapturedFile) { + return new WinJS.Promise(function (complete) { + var photoStream = new Windows.Storage.Streams.InMemoryRandomAccessStream(); + var finalStream = new Windows.Storage.Streams.InMemoryRandomAccessStream(); + capture.capturePhotoToStreamAsync(encodingProperties, photoStream) + .then(function() { + return Windows.Graphics.Imaging.BitmapDecoder.createAsync(photoStream); + }) + .then(function(dec) { + finalStream.size = 0; // BitmapEncoder requires the output stream to be empty + return Windows.Graphics.Imaging.BitmapEncoder.createForTranscodingAsync(finalStream, dec); + }) + .then(function(enc) { + // We need to rotate the photo wrt sensor orientation + enc.bitmapTransform.rotation = orientationToRotation(sensor.getCurrentOrientation()); + return enc.flushAsync(); + }) + .then(function() { + return tempCapturedFile.openAsync(Windows.Storage.FileAccessMode.readWrite); + }) + .then(function(fileStream) { + return Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(finalStream, fileStream); + }) + .done(function() { + photoStream.close(); + finalStream.close(); + complete(tempCapturedFile); + }, function() { + photoStream.close(); + finalStream.close(); + throw new Error("An error has occured while capturing the photo."); + }); + }); + }) + .done(function(capturedFile) { + destroyCameraPreview(); + savePhoto(capturedFile, { + destinationType: destinationType, + targetHeight: targetHeight, + targetWidth: targetWidth, + encodingType: encodingType, + saveToPhotoAlbum: saveToPhotoAlbum + }, successCallback, errorCallback); + }, function(err) { + destroyCameraPreview(); + errorCallback(err); + }); + } + + function getAspectRatios(capture) { + var videoDeviceController = capture.videoDeviceController; + var photoAspectRatios = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.photo).map(function (element) { + return (element.width / element.height).toFixed(1); + }).filter(function (element, index, array) { return (index === array.indexOf(element)); }); + + var videoAspectRatios = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.videoRecord).map(function (element) { + return (element.width / element.height).toFixed(1); + }).filter(function (element, index, array) { return (index === array.indexOf(element)); }); + + var videoPreviewAspectRatios = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.videoPreview).map(function (element) { + return (element.width / element.height).toFixed(1); + }).filter(function (element, index, array) { return (index === array.indexOf(element)); }); + + var allAspectRatios = [].concat(photoAspectRatios, videoAspectRatios, videoPreviewAspectRatios); + + var aspectObj = allAspectRatios.reduce(function (map, item) { + if (!map[item]) { + map[item] = 0; + } + map[item]++; + return map; + }, {}); + + return Object.keys(aspectObj).filter(function (k) { + return aspectObj[k] === 3; + }); + } + + function setAspectRatio(capture, aspect) { + // Max photo resolution with desired aspect ratio + var videoDeviceController = capture.videoDeviceController; + var photoResolution = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.photo) + .filter(function (elem) { + return ((elem.width / elem.height).toFixed(1) === aspect); + }) + .reduce(function (prop1, prop2) { + return (prop1.width * prop1.height) > (prop2.width * prop2.height) ? prop1 : prop2; + }); + + // Max video resolution with desired aspect ratio + var videoRecordResolution = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.videoRecord) + .filter(function (elem) { + return ((elem.width / elem.height).toFixed(1) === aspect); + }) + .reduce(function (prop1, prop2) { + return (prop1.width * prop1.height) > (prop2.width * prop2.height) ? prop1 : prop2; + }); + + // Max video preview resolution with desired aspect ratio + var videoPreviewResolution = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.videoPreview) + .filter(function (elem) { + return ((elem.width / elem.height).toFixed(1) === aspect); + }) + .reduce(function (prop1, prop2) { + return (prop1.width * prop1.height) > (prop2.width * prop2.height) ? prop1 : prop2; + }); + + return videoDeviceController.setMediaStreamPropertiesAsync(CapMSType.photo, photoResolution) + .then(function () { + return videoDeviceController.setMediaStreamPropertiesAsync(CapMSType.videoPreview, videoPreviewResolution); + }) + .then(function () { + return videoDeviceController.setMediaStreamPropertiesAsync(CapMSType.videoRecord, videoRecordResolution); + }); + } + + /** + * When Capture button is clicked, try to capture a picture and return + */ + function onCameraCaptureButtonClick() { + // Make sure user can't click more than once + if (this.getAttribute('clicked') === '1') { + return false; + } else { + this.setAttribute('clicked', '1'); + } + captureAction(); + } + + /** + * When Cancel button is clicked, destroy camera preview and return with error callback + */ + function onCameraCancelButtonClick() { + // Make sure user can't click more than once + if (this.getAttribute('clicked') === '1') { + return false; + } else { + this.setAttribute('clicked', '1'); + } + destroyCameraPreview(); + errorCallback('no image selected'); + } + + /** + * When the phone orientation change, get the event and change camera preview rotation + * @param {Object} e - SimpleOrientationSensorOrientationChangedEventArgs + */ + function onOrientationChange(e) { + setPreviewRotation(e.orientation); + } + + /** + * Converts SimpleOrientation to a VideoRotation to remove difference between camera sensor orientation + * and video orientation + * @param {number} orientation - Windows.Devices.Sensors.SimpleOrientation + * @return {number} - Windows.Media.Capture.VideoRotation + */ + function orientationToRotation(orientation) { + // VideoRotation enumerable and BitmapRotation enumerable have the same values + // https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.videorotation.aspx + // https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.imaging.bitmaprotation.aspx + + switch (orientation) { + // portrait + case Windows.Devices.Sensors.SimpleOrientation.notRotated: + return Windows.Media.Capture.VideoRotation.clockwise90Degrees; + // landscape + case Windows.Devices.Sensors.SimpleOrientation.rotated90DegreesCounterclockwise: + return Windows.Media.Capture.VideoRotation.none; + // portrait-flipped (not supported by WinPhone Apps) + case Windows.Devices.Sensors.SimpleOrientation.rotated180DegreesCounterclockwise: + // Falling back to portrait default + return Windows.Media.Capture.VideoRotation.clockwise90Degrees; + // landscape-flipped + case Windows.Devices.Sensors.SimpleOrientation.rotated270DegreesCounterclockwise: + return Windows.Media.Capture.VideoRotation.clockwise180Degrees; + // faceup & facedown + default: + // Falling back to portrait default + return Windows.Media.Capture.VideoRotation.clockwise90Degrees; + } + } + + /** + * Rotates the current MediaCapture's video + * @param {number} orientation - Windows.Devices.Sensors.SimpleOrientation + */ + function setPreviewRotation(orientation) { + capture.setPreviewRotation(orientationToRotation(orientation)); + } + + try { + createCameraUI(); + startCameraPreview(); + } catch (ex) { + errorCallback(ex); + } +} + +function takePictureFromCameraWindows(successCallback, errorCallback, args) { + var destinationType = args[1], + targetWidth = args[3], + targetHeight = args[4], + encodingType = args[5], + allowCrop = !!args[7], + saveToPhotoAlbum = args[9], + WMCapture = Windows.Media.Capture, + cameraCaptureUI = new WMCapture.CameraCaptureUI(); + + cameraCaptureUI.photoSettings.allowCropping = allowCrop; + + if (encodingType == Camera.EncodingType.PNG) { + cameraCaptureUI.photoSettings.format = WMCapture.CameraCaptureUIPhotoFormat.png; + } else { + cameraCaptureUI.photoSettings.format = WMCapture.CameraCaptureUIPhotoFormat.jpeg; + } + + // decide which max pixels should be supported by targetWidth or targetHeight. + var maxRes = null; + var UIMaxRes = WMCapture.CameraCaptureUIMaxPhotoResolution; + var totalPixels = targetWidth * targetHeight; + + if (targetWidth == -1 && targetHeight == -1) { + maxRes = UIMaxRes.highestAvailable; + } + // Temp fix for CB-10539 + /*else if (totalPixels <= 320 * 240) { + maxRes = UIMaxRes.verySmallQvga; + }*/ + else if (totalPixels <= 640 * 480) { + maxRes = UIMaxRes.smallVga; + } else if (totalPixels <= 1024 * 768) { + maxRes = UIMaxRes.mediumXga; + } else if (totalPixels <= 3 * 1000 * 1000) { + maxRes = UIMaxRes.large3M; + } else if (totalPixels <= 5 * 1000 * 1000) { + maxRes = UIMaxRes.veryLarge5M; + } else { + maxRes = UIMaxRes.highestAvailable; + } + + cameraCaptureUI.photoSettings.maxResolution = maxRes; + + var cameraPicture; + + // define focus handler for windows phone 10.0 + var savePhotoOnFocus = function () { + window.removeEventListener("focus", savePhotoOnFocus); + // call only when the app is in focus again + savePhoto(cameraPicture, { + destinationType: destinationType, + targetHeight: targetHeight, + targetWidth: targetWidth, + encodingType: encodingType, + saveToPhotoAlbum: saveToPhotoAlbum + }, successCallback, errorCallback); + }; + + // if windows phone 10, add and delete focus eventHandler to capture the focus back from cameraUI to app + if (navigator.appVersion.indexOf('Windows Phone 10.0') >= 0) { + window.addEventListener("focus", savePhotoOnFocus); + } + + cameraCaptureUI.captureFileAsync(WMCapture.CameraCaptureUIMode.photo).done(function (picture) { + if (!picture) { + errorCallback("User didn't capture a photo."); + // Remove the focus handler if present + window.removeEventListener("focus", savePhotoOnFocus); + return; + } + cameraPicture = picture; + + // If not windows 10, call savePhoto() now. If windows 10, wait for the app to be in focus again + if (navigator.appVersion.indexOf('Windows Phone 10.0') < 0) { + savePhoto(cameraPicture, { + destinationType: destinationType, + targetHeight: targetHeight, + targetWidth: targetWidth, + encodingType: encodingType, + saveToPhotoAlbum: saveToPhotoAlbum + }, successCallback, errorCallback); + } + }, function () { + errorCallback("Fail to capture a photo."); + window.removeEventListener("focus", savePhotoOnFocus); + }); +} + +function savePhoto(picture, options, successCallback, errorCallback) { + // success callback for capture operation + var success = function(picture) { + if (options.destinationType == Camera.DestinationType.FILE_URI || options.destinationType == Camera.DestinationType.NATIVE_URI) { + if (options.targetHeight > 0 && options.targetWidth > 0) { + resizeImage(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight, options.encodingType); + } else { + picture.copyAsync(getAppData().localFolder, picture.name, OptUnique).done(function (copiedFile) { + successCallback("ms-appdata:///local/" + copiedFile.name); + },errorCallback); + } + } else { + if (options.targetHeight > 0 && options.targetWidth > 0) { + resizeImageBase64(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight); + } else { + fileIO.readBufferAsync(picture).done(function(buffer) { + var strBase64 = encodeToBase64String(buffer); + picture.deleteAsync().done(function() { + successCallback(strBase64); + }, function(err) { + errorCallback(err); + }); + }, errorCallback); + } + } + }; + + if (!options.saveToPhotoAlbum) { + success(picture); + return; + } else { + var savePicker = new Windows.Storage.Pickers.FileSavePicker(); + var saveFile = function(file) { + if (file) { + // Prevent updates to the remote version of the file until we're done + Windows.Storage.CachedFileManager.deferUpdates(file); + picture.moveAndReplaceAsync(file) + .then(function() { + // Let Windows know that we're finished changing the file so + // the other app can update the remote version of the file. + return Windows.Storage.CachedFileManager.completeUpdatesAsync(file); + }) + .done(function(updateStatus) { + if (updateStatus === Windows.Storage.Provider.FileUpdateStatus.complete) { + success(picture); + } else { + errorCallback("File update status is not complete."); + } + }, errorCallback); + } else { + errorCallback("Failed to select a file."); + } + }; + savePicker.suggestedStartLocation = pickerLocId.picturesLibrary; + + if (options.encodingType === Camera.EncodingType.PNG) { + savePicker.fileTypeChoices.insert("PNG", [".png"]); + savePicker.suggestedFileName = "photo.png"; + } else { + savePicker.fileTypeChoices.insert("JPEG", [".jpg"]); + savePicker.suggestedFileName = "photo.jpg"; + } + + // If Windows Phone 8.1 use pickSaveFileAndContinue() + if (navigator.appVersion.indexOf('Windows Phone 8.1') >= 0) { + /* + Need to add and remove an event listener to catch activation state + Using FileSavePicker will suspend the app and it's required to catch the pickSaveFileContinuation + https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631755.aspx + */ + var fileSaveHandler = function(eventArgs) { + if (eventArgs.kind === Windows.ApplicationModel.Activation.ActivationKind.pickSaveFileContinuation) { + var file = eventArgs.file; + saveFile(file); + webUIApp.removeEventListener("activated", fileSaveHandler); + } + }; + webUIApp.addEventListener("activated", fileSaveHandler); + savePicker.pickSaveFileAndContinue(); + } else { + savePicker.pickSaveFileAsync() + .done(saveFile, errorCallback); + } + } +} + +require("cordova/exec/proxy").add("Camera",module.exports); diff --git a/plugins/cordova-plugin-camera/src/wp/Camera.cs b/plugins/cordova-plugin-camera/src/wp/Camera.cs new file mode 100644 index 0000000..264a205 --- /dev/null +++ b/plugins/cordova-plugin-camera/src/wp/Camera.cs @@ -0,0 +1,534 @@ +/* + 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. +*/ + +using System; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Collections.Generic; +using Microsoft.Phone.Tasks; +using System.Runtime.Serialization; +using System.IO; +using System.IO.IsolatedStorage; +using System.Windows.Media.Imaging; +using Microsoft.Phone; +using Microsoft.Xna.Framework.Media; +using System.Diagnostics; + +namespace WPCordovaClassLib.Cordova.Commands +{ + public class Camera : BaseCommand + { + + /// + /// Return base64 encoded string + /// + private const int DATA_URL = 0; + + /// + /// Return file uri + /// + private const int FILE_URI = 1; + + /// + /// Return native uri + /// + private const int NATIVE_URI = 2; + + /// + /// Choose image from picture library + /// + private const int PHOTOLIBRARY = 0; + + /// + /// Take picture from camera + /// + + private const int CAMERA = 1; + + /// + /// Choose image from picture library + /// + private const int SAVEDPHOTOALBUM = 2; + + /// + /// Take a picture of type JPEG + /// + private const int JPEG = 0; + + /// + /// Take a picture of type PNG + /// + private const int PNG = 1; + + /// + /// Folder to store captured images + /// + private const string isoFolder = "CapturedImagesCache"; + + /// + /// Represents captureImage action options. + /// + [DataContract] + public class CameraOptions + { + /// + /// Source to getPicture from. + /// + [DataMember(IsRequired = false, Name = "sourceType")] + public int PictureSourceType { get; set; } + + /// + /// Format of image that returned from getPicture. + /// + [DataMember(IsRequired = false, Name = "destinationType")] + public int DestinationType { get; set; } + + /// + /// Quality of saved image + /// + [DataMember(IsRequired = false, Name = "quality")] + public int Quality { get; set; } + + /// + /// Controls whether or not the image is also added to the device photo album. + /// + [DataMember(IsRequired = false, Name = "saveToPhotoAlbum")] + public bool SaveToPhotoAlbum { get; set; } + + /// + /// Ignored + /// + [DataMember(IsRequired = false, Name = "correctOrientation")] + public bool CorrectOrientation { get; set; } + + /// + /// Ignored + /// + [DataMember(IsRequired = false, Name = "allowEdit")] + public bool AllowEdit { get; set; } + + /// + /// Height in pixels to scale image + /// + [DataMember(IsRequired = false, Name = "encodingType")] + public int EncodingType { get; set; } + + /// + /// Height in pixels to scale image + /// + [DataMember(IsRequired = false, Name = "mediaType")] + public int MediaType { get; set; } + + + /// + /// Height in pixels to scale image + /// + [DataMember(IsRequired = false, Name = "targetHeight")] + public int TargetHeight { get; set; } + + + /// + /// Width in pixels to scale image + /// + [DataMember(IsRequired = false, Name = "targetWidth")] + public int TargetWidth { get; set; } + + /// + /// Creates options object with default parameters + /// + public CameraOptions() + { + this.SetDefaultValues(new StreamingContext()); + } + + /// + /// Initializes default values for class fields. + /// Implemented in separate method because default constructor is not invoked during deserialization. + /// + /// + [OnDeserializing()] + public void SetDefaultValues(StreamingContext context) + { + PictureSourceType = CAMERA; + DestinationType = FILE_URI; + Quality = 80; + TargetHeight = -1; + TargetWidth = -1; + SaveToPhotoAlbum = false; + CorrectOrientation = true; + AllowEdit = false; + MediaType = -1; + EncodingType = -1; + } + } + + /// + /// Camera options + /// + CameraOptions cameraOptions; + + public void takePicture(string options) + { + try + { + string[] args = JSON.JsonHelper.Deserialize(options); + // ["quality", "destinationType", "sourceType", "targetWidth", "targetHeight", "encodingType", + // "mediaType", "allowEdit", "correctOrientation", "saveToPhotoAlbum" ] + cameraOptions = new CameraOptions(); + cameraOptions.Quality = int.Parse(args[0]); + cameraOptions.DestinationType = int.Parse(args[1]); + cameraOptions.PictureSourceType = int.Parse(args[2]); + cameraOptions.TargetWidth = int.Parse(args[3]); + cameraOptions.TargetHeight = int.Parse(args[4]); + cameraOptions.EncodingType = int.Parse(args[5]); + cameraOptions.MediaType = int.Parse(args[6]); + cameraOptions.AllowEdit = bool.Parse(args[7]); + cameraOptions.CorrectOrientation = bool.Parse(args[8]); + cameraOptions.SaveToPhotoAlbum = bool.Parse(args[9]); + + // a very large number will force the other value to be the bound + if (cameraOptions.TargetWidth > -1 && cameraOptions.TargetHeight == -1) + { + cameraOptions.TargetHeight = 100000; + } + else if (cameraOptions.TargetHeight > -1 && cameraOptions.TargetWidth == -1) + { + cameraOptions.TargetWidth = 100000; + } + } + catch (Exception ex) + { + DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); + return; + } + + // Api supports FILE_URI, DATA_URL, NATIVE_URI destination types. + // Treat all other destination types as an error. + switch (cameraOptions.DestinationType) + { + case Camera.FILE_URI: + case Camera.DATA_URL: + case Camera.NATIVE_URI: + break; + default: + DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType")); + return; + } + + ChooserBase chooserTask = null; + if (cameraOptions.PictureSourceType == CAMERA) + { + chooserTask = new CameraCaptureTask(); + } + else if ((cameraOptions.PictureSourceType == PHOTOLIBRARY) || (cameraOptions.PictureSourceType == SAVEDPHOTOALBUM)) + { + chooserTask = new PhotoChooserTask(); + } + // if chooserTask is still null, then PictureSourceType was invalid + if (chooserTask != null) + { + chooserTask.Completed += onTaskCompleted; + chooserTask.Show(); + } + else + { + Debug.WriteLine("Unrecognized PictureSourceType :: " + cameraOptions.PictureSourceType.ToString()); + DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT)); + } + } + + public void onTaskCompleted(object sender, PhotoResult e) + { + var task = sender as ChooserBase; + if (task != null) + { + task.Completed -= onTaskCompleted; + } + + if (e.Error != null) + { + DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR)); + return; + } + + switch (e.TaskResult) + { + case TaskResult.OK: + try + { + string imagePathOrContent = string.Empty; + + // Save image back to media library + // only save to photoalbum if it didn't come from there ... + if (cameraOptions.PictureSourceType == CAMERA && cameraOptions.SaveToPhotoAlbum) + { + MediaLibrary library = new MediaLibrary(); + Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ... + } + + int newAngle = 0; + // There's bug in Windows Phone 8.1 causing Seek on a DssPhotoStream not working properly. + // https://connect.microsoft.com/VisualStudio/feedback/details/783252 + // But a mis-oriented file is better than nothing, so try and catch. + try { + int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto); + switch (orient) { + case ImageExifOrientation.LandscapeLeft: + newAngle = 90; + break; + case ImageExifOrientation.PortraitUpsideDown: + newAngle = 180; + break; + case ImageExifOrientation.LandscapeRight: + newAngle = 270; + break; + case ImageExifOrientation.Portrait: + default: break; // 0 default already set + } + } catch { + Debug.WriteLine("Error fetching orientation from Exif"); + } + + if (newAngle != 0) + { + using (Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle)) + { + // we should reset stream position after saving stream to media library + rotImageStream.Seek(0, SeekOrigin.Begin); + if (cameraOptions.DestinationType == DATA_URL) + { + imagePathOrContent = GetImageContent(rotImageStream); + } + else // FILE_URL or NATIVE_URI (both use the same resultant uri format) + { + imagePathOrContent = SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName)); + } + } + } + else // no need to reorient + { + if (cameraOptions.DestinationType == DATA_URL) + { + imagePathOrContent = GetImageContent(e.ChosenPhoto); + } + else // FILE_URL or NATIVE_URI (both use the same resultant uri format) + { + imagePathOrContent = SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName)); + } + } + + DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent)); + } + catch (Exception) + { + DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image.")); + } + break; + case TaskResult.Cancel: + DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled.")); + break; + default: + DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!")); + break; + } + } + + /// + /// Returns image content in a form of base64 string + /// + /// Image stream + /// Base64 representation of the image + private string GetImageContent(Stream stream) + { + byte[] imageContent = null; + + try + { + // Resize photo and convert to JPEG + imageContent = ResizePhoto(stream); + } + finally + { + stream.Dispose(); + } + + return Convert.ToBase64String(imageContent); + } + + /// + /// Resize image + /// + /// Image stream + /// resized image + private byte[] ResizePhoto(Stream stream) + { + //output + byte[] resizedFile; + + BitmapImage objBitmap = new BitmapImage(); + objBitmap.SetSource(stream); + objBitmap.CreateOptions = BitmapCreateOptions.None; + + WriteableBitmap objWB = new WriteableBitmap(objBitmap); + objBitmap.UriSource = null; + + // Calculate resultant image size + int width, height; + if (cameraOptions.TargetWidth >= 0 && cameraOptions.TargetHeight >= 0) + { + // Keep proportionally + double ratio = Math.Min( + (double)cameraOptions.TargetWidth / objWB.PixelWidth, + (double)cameraOptions.TargetHeight / objWB.PixelHeight); + width = Convert.ToInt32(ratio * objWB.PixelWidth); + height = Convert.ToInt32(ratio * objWB.PixelHeight); + } + else + { + width = objWB.PixelWidth; + height = objWB.PixelHeight; + } + + //Hold the result stream + using (MemoryStream objBitmapStreamResized = new MemoryStream()) + { + + try + { + // resize the photo with user defined TargetWidth & TargetHeight + Extensions.SaveJpeg(objWB, objBitmapStreamResized, width, height, 0, cameraOptions.Quality); + } + finally + { + //Dispose bitmaps immediately, they are memory expensive + DisposeImage(objBitmap); + DisposeImage(objWB); + GC.Collect(); + } + + //Convert the resized stream to a byte array. + int streamLength = (int)objBitmapStreamResized.Length; + resizedFile = new Byte[streamLength]; //-1 + objBitmapStreamResized.Position = 0; + + //for some reason we have to set Position to zero, but we don't have to earlier when we get the bytes from the chosen photo... + objBitmapStreamResized.Read(resizedFile, 0, streamLength); + } + + return resizedFile; + } + + /// + /// Util: Dispose a bitmap resource + /// + /// BitmapSource subclass to dispose + private void DisposeImage(BitmapSource image) + { + if (image != null) + { + try + { + using (var ms = new MemoryStream(new byte[] { 0x0 })) + { + image.SetSource(ms); + } + } + catch (Exception) + { + } + } + } + + /// + /// Saves captured image in isolated storage + /// + /// image file name + /// Image path + private string SaveImageToLocalStorage(Stream stream, string imageFileName) + { + + if (stream == null) + { + throw new ArgumentNullException("imageBytes"); + } + try + { + var isoFile = IsolatedStorageFile.GetUserStoreForApplication(); + + if (!isoFile.DirectoryExists(isoFolder)) + { + isoFile.CreateDirectory(isoFolder); + } + + string filePath = System.IO.Path.Combine("///" + isoFolder + "/", imageFileName); + + using (IsolatedStorageFileStream outputStream = isoFile.CreateFile(filePath)) + { + BitmapImage objBitmap = new BitmapImage(); + objBitmap.SetSource(stream); + objBitmap.CreateOptions = BitmapCreateOptions.None; + + WriteableBitmap objWB = new WriteableBitmap(objBitmap); + objBitmap.UriSource = null; + + try + { + + //use photo's actual width & height if user doesn't provide width & height + if (cameraOptions.TargetWidth < 0 && cameraOptions.TargetHeight < 0) + { + objWB.SaveJpeg(outputStream, objWB.PixelWidth, objWB.PixelHeight, 0, cameraOptions.Quality); + } + else + { + //Resize + //Keep proportionally + double ratio = Math.Min((double)cameraOptions.TargetWidth / objWB.PixelWidth, (double)cameraOptions.TargetHeight / objWB.PixelHeight); + int width = Convert.ToInt32(ratio * objWB.PixelWidth); + int height = Convert.ToInt32(ratio * objWB.PixelHeight); + + // resize the photo with user defined TargetWidth & TargetHeight + objWB.SaveJpeg(outputStream, width, height, 0, cameraOptions.Quality); + } + } + finally + { + //Dispose bitmaps immediately, they are memory expensive + DisposeImage(objBitmap); + DisposeImage(objWB); + GC.Collect(); + } + } + + return new Uri(filePath, UriKind.Relative).ToString(); + } + catch (Exception) + { + //TODO: log or do something else + throw; + } + finally + { + stream.Dispose(); + } + } + + } +} diff --git a/plugins/cordova-plugin-camera/tests/ios/.gitignore b/plugins/cordova-plugin-camera/tests/ios/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/contents.xcworkspacedata b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..22fcf41 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/CDVCameraTest.xccheckout b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/CDVCameraTest.xccheckout new file mode 100644 index 0000000..c8a5605 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/CDVCameraTest.xccheckout @@ -0,0 +1,41 @@ + + + + + IDESourceControlProjectFavoriteDictionaryKey + + IDESourceControlProjectIdentifier + 6BE9AD73-1B9F-4362-98D7-DC631BEC6185 + IDESourceControlProjectName + CDVCameraTest + IDESourceControlProjectOriginsDictionary + + 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C + github.com:shazron/cordova-plugin-camera.git + + IDESourceControlProjectPath + tests/ios/CDVCameraTest.xcworkspace + IDESourceControlProjectRelativeInstallPathDictionary + + 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C + ../../.. + + IDESourceControlProjectURL + github.com:shazron/cordova-plugin-camera.git + IDESourceControlProjectVersion + 111 + IDESourceControlProjectWCCIdentifier + 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C + IDESourceControlWCCName + cordova-plugin-camera + + + + diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/xcschemes/CordovaLib.xcscheme b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/xcschemes/CordovaLib.xcscheme new file mode 100644 index 0000000..3e8cd2c --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/xcschemes/CordovaLib.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraLibTests/CameraTest.m b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraLibTests/CameraTest.m new file mode 100644 index 0000000..b9439d1 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraLibTests/CameraTest.m @@ -0,0 +1,511 @@ +/* + 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. + */ + +#import +#import +#import "CDVCamera.h" +#import "UIImage+CropScaleOrientation.h" +#import + + +@interface CameraTest : XCTestCase + +@property (nonatomic, strong) CDVCamera* plugin; + +@end + +@interface CDVCamera () + +// expose private interface +- (NSData*)processImage:(UIImage*)image info:(NSDictionary*)info options:(CDVPictureOptions*)options; +- (UIImage*)retrieveImage:(NSDictionary*)info options:(CDVPictureOptions*)options; +- (CDVPluginResult*)resultForImage:(CDVPictureOptions*)options info:(NSDictionary*)info; +- (CDVPluginResult*)resultForVideo:(NSDictionary*)info; + +@end + +@implementation CameraTest + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. + + self.plugin = [[CDVCamera alloc] init]; +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void) testPictureOptionsCreate +{ + NSArray* args; + CDVPictureOptions* options; + NSDictionary* popoverOptions; + + // No arguments, check whether the defaults are set + args = @[]; + CDVInvokedUrlCommand* command = [[CDVInvokedUrlCommand alloc] initWithArguments:args callbackId:@"dummy" className:@"myclassname" methodName:@"mymethodname"]; + + options = [CDVPictureOptions createFromTakePictureArguments:command]; + + XCTAssertEqual([options.quality intValue], 50); + XCTAssertEqual(options.destinationType, (int)DestinationTypeFileUri); + XCTAssertEqual(options.sourceType, (int)UIImagePickerControllerSourceTypeCamera); + XCTAssertEqual(options.targetSize.width, 0); + XCTAssertEqual(options.targetSize.height, 0); + XCTAssertEqual(options.encodingType, (int)EncodingTypeJPEG); + XCTAssertEqual(options.mediaType, (int)MediaTypePicture); + XCTAssertEqual(options.allowsEditing, NO); + XCTAssertEqual(options.correctOrientation, NO); + XCTAssertEqual(options.saveToPhotoAlbum, NO); + XCTAssertEqualObjects(options.popoverOptions, nil); + XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceRear); + XCTAssertEqual(options.popoverSupported, NO); + XCTAssertEqual(options.usesGeolocation, NO); + + // Set each argument, check whether they are set. different from defaults + popoverOptions = @{ @"x" : @1, @"y" : @2, @"width" : @3, @"height" : @4 }; + + args = @[ + @(49), + @(DestinationTypeDataUrl), + @(UIImagePickerControllerSourceTypePhotoLibrary), + @(120), + @(240), + @(EncodingTypePNG), + @(MediaTypeVideo), + @YES, + @YES, + @YES, + popoverOptions, + @(UIImagePickerControllerCameraDeviceFront), + ]; + + command = [[CDVInvokedUrlCommand alloc] initWithArguments:args callbackId:@"dummy" className:@"myclassname" methodName:@"mymethodname"]; + options = [CDVPictureOptions createFromTakePictureArguments:command]; + + XCTAssertEqual([options.quality intValue], 49); + XCTAssertEqual(options.destinationType, (int)DestinationTypeDataUrl); + XCTAssertEqual(options.sourceType, (int)UIImagePickerControllerSourceTypePhotoLibrary); + XCTAssertEqual(options.targetSize.width, 120); + XCTAssertEqual(options.targetSize.height, 240); + XCTAssertEqual(options.encodingType, (int)EncodingTypePNG); + XCTAssertEqual(options.mediaType, (int)MediaTypeVideo); + XCTAssertEqual(options.allowsEditing, YES); + XCTAssertEqual(options.correctOrientation, YES); + XCTAssertEqual(options.saveToPhotoAlbum, YES); + XCTAssertEqualObjects(options.popoverOptions, popoverOptions); + XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceFront); + XCTAssertEqual(options.popoverSupported, NO); + XCTAssertEqual(options.usesGeolocation, NO); +} + +- (void) testCameraPickerCreate +{ + NSDictionary* popoverOptions; + NSArray* args; + CDVPictureOptions* pictureOptions; + CDVCameraPicker* picker; + + // Souce is Camera, and image type + + popoverOptions = @{ @"x" : @1, @"y" : @2, @"width" : @3, @"height" : @4 }; + args = @[ + @(49), + @(DestinationTypeDataUrl), + @(UIImagePickerControllerSourceTypeCamera), + @(120), + @(240), + @(EncodingTypePNG), + @(MediaTypeAll), + @YES, + @YES, + @YES, + popoverOptions, + @(UIImagePickerControllerCameraDeviceFront), + ]; + + CDVInvokedUrlCommand* command = [[CDVInvokedUrlCommand alloc] initWithArguments:args callbackId:@"dummy" className:@"myclassname" methodName:@"mymethodname"]; + pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command]; + + if ([UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType]) { + picker = [CDVCameraPicker createFromPictureOptions:pictureOptions]; + + XCTAssertEqualObjects(picker.pictureOptions, pictureOptions); + + XCTAssertEqual(picker.sourceType, pictureOptions.sourceType); + XCTAssertEqual(picker.allowsEditing, pictureOptions.allowsEditing); + XCTAssertEqualObjects(picker.mediaTypes, @[(NSString*)kUTTypeImage]); + XCTAssertEqual(picker.cameraDevice, pictureOptions.cameraDirection); + } + + // Souce is not Camera, and all media types + + args = @[ + @(49), + @(DestinationTypeDataUrl), + @(UIImagePickerControllerSourceTypePhotoLibrary), + @(120), + @(240), + @(EncodingTypePNG), + @(MediaTypeAll), + @YES, + @YES, + @YES, + popoverOptions, + @(UIImagePickerControllerCameraDeviceFront), + ]; + + command = [[CDVInvokedUrlCommand alloc] initWithArguments:args callbackId:@"dummy" className:@"myclassname" methodName:@"mymethodname"]; + pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command]; + + if ([UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType]) { + picker = [CDVCameraPicker createFromPictureOptions:pictureOptions]; + + XCTAssertEqualObjects(picker.pictureOptions, pictureOptions); + + XCTAssertEqual(picker.sourceType, pictureOptions.sourceType); + XCTAssertEqual(picker.allowsEditing, pictureOptions.allowsEditing); + XCTAssertEqualObjects(picker.mediaTypes, [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType]); + } + + // Souce is not Camera, and either Image or Movie media type + + args = @[ + @(49), + @(DestinationTypeDataUrl), + @(UIImagePickerControllerSourceTypePhotoLibrary), + @(120), + @(240), + @(EncodingTypePNG), + @(MediaTypeVideo), + @YES, + @YES, + @YES, + popoverOptions, + @(UIImagePickerControllerCameraDeviceFront), + ]; + + command = [[CDVInvokedUrlCommand alloc] initWithArguments:args callbackId:@"dummy" className:@"myclassname" methodName:@"mymethodname"]; + pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command]; + + if ([UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType]) { + picker = [CDVCameraPicker createFromPictureOptions:pictureOptions]; + + XCTAssertEqualObjects(picker.pictureOptions, pictureOptions); + + XCTAssertEqual(picker.sourceType, pictureOptions.sourceType); + XCTAssertEqual(picker.allowsEditing, pictureOptions.allowsEditing); + XCTAssertEqualObjects(picker.mediaTypes, @[(NSString*)kUTTypeMovie]); + } +} + +- (UIImage*) createImage:(CGRect)rect orientation:(UIImageOrientation)imageOrientation { + UIGraphicsBeginImageContext(rect.size); + CGContextRef context = UIGraphicsGetCurrentContext(); + + CGContextSetFillColorWithColor(context, [[UIColor greenColor] CGColor]); + CGContextFillRect(context, rect); + + CGImageRef result = CGBitmapContextCreateImage(UIGraphicsGetCurrentContext()); + UIImage* image = [UIImage imageWithCGImage:result scale:1.0f orientation:imageOrientation]; + + UIGraphicsEndImageContext(); + + return image; +} + +- (void) testImageScaleCropForSize { + + UIImage *sourceImagePortrait, *sourceImageLandscape, *targetImage; + CGSize targetSize = CGSizeZero; + + sourceImagePortrait = [self createImage:CGRectMake(0, 0, 2448, 3264) orientation:UIImageOrientationUp]; + sourceImageLandscape = [self createImage:CGRectMake(0, 0, 3264, 2448) orientation:UIImageOrientationUp]; + + // test 640x480 + + targetSize = CGSizeMake(640, 480); + + targetImage = [sourceImagePortrait imageByScalingAndCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetImage = [sourceImageLandscape imageByScalingAndCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + + // test 800x600 + + targetSize = CGSizeMake(800, 600); + + targetImage = [sourceImagePortrait imageByScalingAndCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetImage = [sourceImageLandscape imageByScalingAndCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + // test 1024x768 + + targetSize = CGSizeMake(1024, 768); + + targetImage = [sourceImagePortrait imageByScalingAndCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetImage = [sourceImageLandscape imageByScalingAndCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); +} + +- (void) testImageScaleNoCropForSize { + UIImage *sourceImagePortrait, *sourceImageLandscape, *targetImage; + CGSize targetSize = CGSizeZero; + + sourceImagePortrait = [self createImage:CGRectMake(0, 0, 2448, 3264) orientation:UIImageOrientationUp]; + sourceImageLandscape = [self createImage:CGRectMake(0, 0, 3264, 2448) orientation:UIImageOrientationUp]; + + // test 640x480 + + targetSize = CGSizeMake(480, 640); + + targetImage = [sourceImagePortrait imageByScalingNotCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetSize = CGSizeMake(640, 480); + + targetImage = [sourceImageLandscape imageByScalingNotCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + + // test 800x600 + + targetSize = CGSizeMake(600, 800); + + targetImage = [sourceImagePortrait imageByScalingNotCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetSize = CGSizeMake(800, 600); + + targetImage = [sourceImageLandscape imageByScalingNotCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + // test 1024x768 + + targetSize = CGSizeMake(768, 1024); + + targetImage = [sourceImagePortrait imageByScalingNotCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetSize = CGSizeMake(1024, 768); + + targetImage = [sourceImageLandscape imageByScalingNotCroppingForSize:targetSize]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); +} + +- (void) testImageCorrectedForOrientation { + UIImage *sourceImagePortrait, *sourceImageLandscape, *targetImage; + CGSize targetSize = CGSizeZero; + + sourceImagePortrait = [self createImage:CGRectMake(0, 0, 2448, 3264) orientation:UIImageOrientationDown]; + sourceImageLandscape = [self createImage:CGRectMake(0, 0, 3264, 2448) orientation:UIImageOrientationDown]; + + // PORTRAIT - image size should be unchanged + + targetSize = CGSizeMake(2448, 3264); + + targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationUp]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp); + + targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationDown]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp); + + targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationRight]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp); + + targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationLeft]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp); + + // LANDSCAPE - image size should be unchanged + + targetSize = CGSizeMake(3264, 2448); + + targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationUp]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationDown]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationRight]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); + + targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationLeft]; + XCTAssertEqual(targetImage.size.width, targetSize.width); + XCTAssertEqual(targetImage.size.height, targetSize.height); +} + + +- (void) testRetrieveImage +{ + CDVPictureOptions* pictureOptions = [[CDVPictureOptions alloc] init]; + NSDictionary *infoDict1, *infoDict2; + UIImage* resultImage; + + UIImage* originalImage = [self createImage:CGRectMake(0, 0, 1024, 768) orientation:UIImageOrientationDown]; + UIImage* originalCorrectedForOrientation = [originalImage imageCorrectedForCaptureOrientation]; + + UIImage* editedImage = [self createImage:CGRectMake(0, 0, 800, 600) orientation:UIImageOrientationDown]; + UIImage* scaledImageWithCrop = [originalImage imageByScalingAndCroppingForSize:CGSizeMake(640, 480)]; + UIImage* scaledImageNoCrop = [originalImage imageByScalingNotCroppingForSize:CGSizeMake(640, 480)]; + + infoDict1 = @{ + UIImagePickerControllerOriginalImage : originalImage + }; + + infoDict2 = @{ + UIImagePickerControllerOriginalImage : originalImage, + UIImagePickerControllerEditedImage : editedImage + }; + + // Original with no options + + pictureOptions.allowsEditing = YES; + pictureOptions.targetSize = CGSizeZero; + pictureOptions.cropToSize = NO; + pictureOptions.correctOrientation = NO; + + resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions]; + XCTAssertEqualObjects(resultImage, originalImage); + + // Original with no options + + pictureOptions.allowsEditing = YES; + pictureOptions.targetSize = CGSizeZero; + pictureOptions.cropToSize = NO; + pictureOptions.correctOrientation = NO; + + resultImage = [self.plugin retrieveImage:infoDict2 options:pictureOptions]; + XCTAssertEqualObjects(resultImage, editedImage); + + // Original with corrected orientation + + pictureOptions.allowsEditing = YES; + pictureOptions.targetSize = CGSizeZero; + pictureOptions.cropToSize = NO; + pictureOptions.correctOrientation = YES; + + resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions]; + XCTAssertNotEqual(resultImage.imageOrientation, originalImage.imageOrientation); + XCTAssertEqual(resultImage.imageOrientation, originalCorrectedForOrientation.imageOrientation); + XCTAssertEqual(resultImage.size.width, originalCorrectedForOrientation.size.width); + XCTAssertEqual(resultImage.size.height, originalCorrectedForOrientation.size.height); + + // Original with targetSize, no crop + + pictureOptions.allowsEditing = YES; + pictureOptions.targetSize = CGSizeMake(640, 480); + pictureOptions.cropToSize = NO; + pictureOptions.correctOrientation = NO; + + resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions]; + XCTAssertEqual(resultImage.size.width, scaledImageNoCrop.size.width); + XCTAssertEqual(resultImage.size.height, scaledImageNoCrop.size.height); + + // Original with targetSize, plus crop + + pictureOptions.allowsEditing = YES; + pictureOptions.targetSize = CGSizeMake(640, 480); + pictureOptions.cropToSize = YES; + pictureOptions.correctOrientation = NO; + + resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions]; + XCTAssertEqual(resultImage.size.width, scaledImageWithCrop.size.width); + XCTAssertEqual(resultImage.size.height, scaledImageWithCrop.size.height); +} + +- (void) testProcessImage +{ + CDVPictureOptions* pictureOptions = [[CDVPictureOptions alloc] init]; + NSData* resultData; + + UIImage* originalImage = [self createImage:CGRectMake(0, 0, 1024, 768) orientation:UIImageOrientationDown]; + NSData* originalImageDataPNG = UIImagePNGRepresentation(originalImage); + NSData* originalImageDataJPEG = UIImageJPEGRepresentation(originalImage, 1.0); + + // Original, PNG + + pictureOptions.allowsEditing = YES; + pictureOptions.targetSize = CGSizeZero; + pictureOptions.cropToSize = NO; + pictureOptions.correctOrientation = NO; + pictureOptions.encodingType = EncodingTypePNG; + + resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions]; + XCTAssertEqualObjects([resultData base64EncodedStringWithOptions:0], [originalImageDataPNG base64EncodedStringWithOptions:0]); + + // Original, JPEG, full quality + + pictureOptions.allowsEditing = NO; + pictureOptions.targetSize = CGSizeZero; + pictureOptions.cropToSize = NO; + pictureOptions.correctOrientation = NO; + pictureOptions.encodingType = EncodingTypeJPEG; + + resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions]; + XCTAssertEqualObjects([resultData base64EncodedStringWithOptions:0], [originalImageDataJPEG base64EncodedStringWithOptions:0]); + + // Original, JPEG, with quality value + + pictureOptions.allowsEditing = YES; + pictureOptions.targetSize = CGSizeZero; + pictureOptions.cropToSize = NO; + pictureOptions.correctOrientation = NO; + pictureOptions.encodingType = EncodingTypeJPEG; + pictureOptions.quality = @(57); + + NSData* originalImageDataJPEGWithQuality = UIImageJPEGRepresentation(originalImage, [pictureOptions.quality floatValue]/ 100.f); + resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions]; + XCTAssertEqualObjects([resultData base64EncodedStringWithOptions:0], [originalImageDataJPEGWithQuality base64EncodedStringWithOptions:0]); + + // TODO: usesGeolocation is not tested +} + +@end diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraLibTests/Info.plist b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraLibTests/Info.plist new file mode 100644 index 0000000..95c8add --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraLibTests/Info.plist @@ -0,0 +1,44 @@ + + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + org.apache.cordova.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.pbxproj b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3e5a4c0 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.pbxproj @@ -0,0 +1,561 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 30486FEB1A40DC350065C233 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FEA1A40DC350065C233 /* UIKit.framework */; }; + 30486FED1A40DC3B0065C233 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FEC1A40DC3A0065C233 /* Foundation.framework */; }; + 30486FF91A40DCC70065C233 /* CDVCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = 30486FF31A40DCC70065C233 /* CDVCamera.m */; }; + 30486FFA1A40DCC70065C233 /* CDVJpegHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 30486FF61A40DCC70065C233 /* CDVJpegHeaderWriter.m */; }; + 30486FFB1A40DCC70065C233 /* UIImage+CropScaleOrientation.m in Sources */ = {isa = PBXBuildFile; fileRef = 30486FF81A40DCC70065C233 /* UIImage+CropScaleOrientation.m */; }; + 304870011A40DD620065C233 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FFE1A40DD180065C233 /* CoreGraphics.framework */; }; + 304870021A40DD860065C233 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FFE1A40DD180065C233 /* CoreGraphics.framework */; }; + 304870031A40DD8C0065C233 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FEA1A40DC350065C233 /* UIKit.framework */; }; + 304870051A40DD9A0065C233 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 304870041A40DD9A0065C233 /* MobileCoreServices.framework */; }; + 304870071A40DDAC0065C233 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 304870061A40DDAC0065C233 /* AssetsLibrary.framework */; }; + 304870091A40DDB90065C233 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 304870081A40DDB90065C233 /* CoreLocation.framework */; }; + 3048700B1A40DDF30065C233 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3048700A1A40DDF30065C233 /* ImageIO.framework */; }; + 308F59B11A4228730031A4D4 /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E9F519019DA0F8300DA31AC /* libCordova.a */; }; + 7E9F51B119DA114400DA31AC /* CameraTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9F51B019DA114400DA31AC /* CameraTest.m */; }; + 7E9F51B919DA1B1600DA31AC /* libCDVCameraLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 30486FFC1A40DCE80065C233 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = CordovaLib; + }; + 7E9F518F19DA0F8300DA31AC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 68A32D7114102E1C006B237C; + remoteInfo = CordovaLib; + }; + 7E9F51AC19DA10DE00DA31AC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7E9F517219DA09CE00DA31AC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7E9F519419DA102000DA31AC; + remoteInfo = CDVCameraLib; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 7E9F519319DA102000DA31AC /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 30486FEA1A40DC350065C233 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 30486FEC1A40DC3A0065C233 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + 30486FF21A40DCC70065C233 /* CDVCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVCamera.h; sourceTree = ""; }; + 30486FF31A40DCC70065C233 /* CDVCamera.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVCamera.m; sourceTree = ""; }; + 30486FF41A40DCC70065C233 /* CDVExif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVExif.h; sourceTree = ""; }; + 30486FF51A40DCC70065C233 /* CDVJpegHeaderWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVJpegHeaderWriter.h; sourceTree = ""; }; + 30486FF61A40DCC70065C233 /* CDVJpegHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVJpegHeaderWriter.m; sourceTree = ""; }; + 30486FF71A40DCC70065C233 /* UIImage+CropScaleOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+CropScaleOrientation.h"; sourceTree = ""; }; + 30486FF81A40DCC70065C233 /* UIImage+CropScaleOrientation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+CropScaleOrientation.m"; sourceTree = ""; }; + 30486FFE1A40DD180065C233 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; + 304870041A40DD9A0065C233 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; }; + 304870061A40DDAC0065C233 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/AssetsLibrary.framework; sourceTree = DEVELOPER_DIR; }; + 304870081A40DDB90065C233 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/CoreLocation.framework; sourceTree = DEVELOPER_DIR; }; + 3048700A1A40DDF30065C233 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; + 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = "../node_modules/cordova-ios/CordovaLib/CordovaLib.xcodeproj"; sourceTree = ""; }; + 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCDVCameraLib.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 7E9F519F19DA102000DA31AC /* CDVCameraLibTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CDVCameraLibTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 7E9F51A219DA102000DA31AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7E9F51B019DA114400DA31AC /* CameraTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CameraTest.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 7E9F519219DA102000DA31AC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 308F59B11A4228730031A4D4 /* libCordova.a in Frameworks */, + 304870011A40DD620065C233 /* CoreGraphics.framework in Frameworks */, + 30486FED1A40DC3B0065C233 /* Foundation.framework in Frameworks */, + 30486FEB1A40DC350065C233 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 7E9F519C19DA102000DA31AC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3048700B1A40DDF30065C233 /* ImageIO.framework in Frameworks */, + 304870091A40DDB90065C233 /* CoreLocation.framework in Frameworks */, + 304870071A40DDAC0065C233 /* AssetsLibrary.framework in Frameworks */, + 304870051A40DD9A0065C233 /* MobileCoreServices.framework in Frameworks */, + 304870031A40DD8C0065C233 /* UIKit.framework in Frameworks */, + 304870021A40DD860065C233 /* CoreGraphics.framework in Frameworks */, + 7E9F51B919DA1B1600DA31AC /* libCDVCameraLib.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 30486FF11A40DCC70065C233 /* CDVCameraLib */ = { + isa = PBXGroup; + children = ( + 30486FF21A40DCC70065C233 /* CDVCamera.h */, + 30486FF31A40DCC70065C233 /* CDVCamera.m */, + 30486FF41A40DCC70065C233 /* CDVExif.h */, + 30486FF51A40DCC70065C233 /* CDVJpegHeaderWriter.h */, + 30486FF61A40DCC70065C233 /* CDVJpegHeaderWriter.m */, + 30486FF71A40DCC70065C233 /* UIImage+CropScaleOrientation.h */, + 30486FF81A40DCC70065C233 /* UIImage+CropScaleOrientation.m */, + ); + name = CDVCameraLib; + path = ../../../src/ios; + sourceTree = ""; + }; + 308F59B01A4227A60031A4D4 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3048700A1A40DDF30065C233 /* ImageIO.framework */, + 304870081A40DDB90065C233 /* CoreLocation.framework */, + 304870061A40DDAC0065C233 /* AssetsLibrary.framework */, + 304870041A40DD9A0065C233 /* MobileCoreServices.framework */, + 30486FFE1A40DD180065C233 /* CoreGraphics.framework */, + 30486FEC1A40DC3A0065C233 /* Foundation.framework */, + 30486FEA1A40DC350065C233 /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7E9F517119DA09CE00DA31AC = { + isa = PBXGroup; + children = ( + 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */, + 308F59B01A4227A60031A4D4 /* Frameworks */, + 30486FF11A40DCC70065C233 /* CDVCameraLib */, + 7E9F51A019DA102000DA31AC /* CDVCameraLibTests */, + 7E9F517D19DA0A0A00DA31AC /* Products */, + ); + sourceTree = ""; + }; + 7E9F517D19DA0A0A00DA31AC /* Products */ = { + isa = PBXGroup; + children = ( + 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */, + 7E9F519F19DA102000DA31AC /* CDVCameraLibTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 7E9F518C19DA0F8300DA31AC /* Products */ = { + isa = PBXGroup; + children = ( + 7E9F519019DA0F8300DA31AC /* libCordova.a */, + ); + name = Products; + sourceTree = ""; + }; + 7E9F51A019DA102000DA31AC /* CDVCameraLibTests */ = { + isa = PBXGroup; + children = ( + 7E9F51A119DA102000DA31AC /* Supporting Files */, + 7E9F51B019DA114400DA31AC /* CameraTest.m */, + ); + path = CDVCameraLibTests; + sourceTree = ""; + }; + 7E9F51A119DA102000DA31AC /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 7E9F51A219DA102000DA31AC /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 7E9F519419DA102000DA31AC /* CDVCameraLib */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7E9F51A319DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLib" */; + buildPhases = ( + 7E9F519119DA102000DA31AC /* Sources */, + 7E9F519219DA102000DA31AC /* Frameworks */, + 7E9F519319DA102000DA31AC /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 30486FFD1A40DCE80065C233 /* PBXTargetDependency */, + ); + name = CDVCameraLib; + productName = CDVCameraLib; + productReference = 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */; + productType = "com.apple.product-type.library.static"; + }; + 7E9F519E19DA102000DA31AC /* CDVCameraLibTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7E9F51A619DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLibTests" */; + buildPhases = ( + 7E9F519B19DA102000DA31AC /* Sources */, + 7E9F519C19DA102000DA31AC /* Frameworks */, + 7E9F519D19DA102000DA31AC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 7E9F51AD19DA10DE00DA31AC /* PBXTargetDependency */, + ); + name = CDVCameraLibTests; + productName = CDVCameraLibTests; + productReference = 7E9F519F19DA102000DA31AC /* CDVCameraLibTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 7E9F517219DA09CE00DA31AC /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + TargetAttributes = { + 7E9F519419DA102000DA31AC = { + CreatedOnToolsVersion = 6.0; + }; + 7E9F519E19DA102000DA31AC = { + CreatedOnToolsVersion = 6.0; + }; + }; + }; + buildConfigurationList = 7E9F517519DA09CE00DA31AC /* Build configuration list for PBXProject "CDVCameraTest" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7E9F517119DA09CE00DA31AC; + productRefGroup = 7E9F517D19DA0A0A00DA31AC /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 7E9F518C19DA0F8300DA31AC /* Products */; + ProjectRef = 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 7E9F519419DA102000DA31AC /* CDVCameraLib */, + 7E9F519E19DA102000DA31AC /* CDVCameraLibTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 7E9F519019DA0F8300DA31AC /* libCordova.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libCordova.a; + remoteRef = 7E9F518F19DA0F8300DA31AC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 7E9F519D19DA102000DA31AC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 7E9F519119DA102000DA31AC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 30486FF91A40DCC70065C233 /* CDVCamera.m in Sources */, + 30486FFB1A40DCC70065C233 /* UIImage+CropScaleOrientation.m in Sources */, + 30486FFA1A40DCC70065C233 /* CDVJpegHeaderWriter.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 7E9F519B19DA102000DA31AC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E9F51B119DA114400DA31AC /* CameraTest.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 30486FFD1A40DCE80065C233 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = CordovaLib; + targetProxy = 30486FFC1A40DCE80065C233 /* PBXContainerItemProxy */; + }; + 7E9F51AD19DA10DE00DA31AC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 7E9F519419DA102000DA31AC /* CDVCameraLib */; + targetProxy = 7E9F51AC19DA10DE00DA31AC /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 7E9F517619DA09CE00DA31AC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ONLY_ACTIVE_ARCH = YES; + }; + name = Debug; + }; + 7E9F517719DA09CE00DA31AC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Release; + }; + 7E9F51A419DA102000DA31AC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"$(TARGET_BUILD_DIR)/usr/local/lib/include\"", + "\"$(OBJROOT)/UninstalledProducts/include\"", + "\"$(BUILT_PRODUCTS_DIR)\"", + ); + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 7E9F51A519DA102000DA31AC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"$(TARGET_BUILD_DIR)/usr/local/lib/include\"", + "\n\"$(OBJROOT)/UninstalledProducts/include\"\n\"$(BUILT_PRODUCTS_DIR)\"", + ); + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 7E9F51A719DA102000DA31AC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = CDVCameraLibTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + XCTest, + "-all_load", + "-ObjC", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 7E9F51A819DA102000DA31AC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = CDVCameraLibTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + XCTest, + "-all_load", + "-ObjC", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 7E9F517519DA09CE00DA31AC /* Build configuration list for PBXProject "CDVCameraTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E9F517619DA09CE00DA31AC /* Debug */, + 7E9F517719DA09CE00DA31AC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7E9F51A319DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLib" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E9F51A419DA102000DA31AC /* Debug */, + 7E9F51A519DA102000DA31AC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7E9F51A619DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLibTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E9F51A719DA102000DA31AC /* Debug */, + 7E9F51A819DA102000DA31AC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 7E9F517219DA09CE00DA31AC /* Project object */; +} diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..98498f8 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/xcshareddata/CDVCameraTest.xccheckout b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/xcshareddata/CDVCameraTest.xccheckout new file mode 100644 index 0000000..2a654cb --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/xcshareddata/CDVCameraTest.xccheckout @@ -0,0 +1,41 @@ + + + + + IDESourceControlProjectFavoriteDictionaryKey + + IDESourceControlProjectIdentifier + 6BE9AD73-1B9F-4362-98D7-DC631BEC6185 + IDESourceControlProjectName + CDVCameraTest + IDESourceControlProjectOriginsDictionary + + BEF5A5D0FF64801E558286389440357A9233D7DB + https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git + + IDESourceControlProjectPath + tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj + IDESourceControlProjectRelativeInstallPathDictionary + + BEF5A5D0FF64801E558286389440357A9233D7DB + ../../../../.. + + IDESourceControlProjectURL + https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git + IDESourceControlProjectVersion + 111 + IDESourceControlProjectWCCIdentifier + BEF5A5D0FF64801E558286389440357A9233D7DB + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + BEF5A5D0FF64801E558286389440357A9233D7DB + IDESourceControlWCCName + cordova-plugin-camera + + + + diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLib.xcscheme b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLib.xcscheme new file mode 100644 index 0000000..f0a8304 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLib.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLibTests.xcscheme b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLibTests.xcscheme new file mode 100644 index 0000000..b5d2603 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLibTests.xcscheme @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-camera/tests/ios/README.md b/plugins/cordova-plugin-camera/tests/ios/README.md new file mode 100644 index 0000000..b839310 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/README.md @@ -0,0 +1,40 @@ + + +# iOS Tests for CDVCamera + +You need to install `node.js` to pull in `cordova-ios`. + +First install cordova-ios: + + npm install + +... in the current folder. + + +# Testing from Xcode + +1. Launch the `CDVCameraTest.xcworkspace` file. +2. Choose "CDVCameraLibTests" from the scheme drop-down menu +3. Click and hold on the `Play` button, and choose the `Wrench` icon to run the tests + + +# Testing from the command line + + npm test diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/de/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/de/README.md new file mode 100644 index 0000000..0b3ae96 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/de/README.md @@ -0,0 +1,39 @@ + + +# iOS-Tests für CDVCamera + +Sie müssen installieren `node.js` in `Cordova-Ios` zu ziehen. + +Installieren Sie Cordova-Ios zum ersten Mal: + + npm install + + +... im aktuellen Ordner. + +# Testen von Xcode + + 1. Starten Sie die Datei `CDVCameraTest.xcworkspace` . + 2. Wählen Sie im Dropdown-Schema "CDVCameraLibTests" + 3. Klicken Sie und halten Sie auf den `Play` -Button und wählen Sie das `Schraubenschlüssel` -Symbol zum Ausführen der tests + +# Tests von der Befehlszeile aus + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/es/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/es/README.md new file mode 100644 index 0000000..7240746 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/es/README.md @@ -0,0 +1,39 @@ + + +# Pruebas de iOS para CDVCamera + +Necesita instalar `node.js` en `Córdoba-ios`. + +Primero instalar cordova-ios: + + npm install + + +... en la carpeta actual. + +# Prueba de Xcode + + 1. Iniciar el archivo `CDVCameraTest.xcworkspace` . + 2. Elija "CDVCameraLibTests" en el menú de lista desplegable esquema + 3. Haga clic y mantenga el botón de `Play` y elegir el icono de `llave inglesa` para ejecutar las pruebas + +# Pruebas desde la línea de comandos + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/fr/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/fr/README.md new file mode 100644 index 0000000..4c656a3 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/fr/README.md @@ -0,0 +1,39 @@ + + +# Tests d'iOS pour CDVCamera + +Vous devez installer `node.js` à `cordova-ios`. + +Commencez par installer cordova-ios : + + npm install + + +... dans le dossier actuel. + +# Tests de Xcode + + 1. Lancez le fichier `CDVCameraTest.xcworkspace` . + 2. Choisissez « CDVCameraLibTests » dans le menu déroulant de régime + 3. Cliquez et maintenez sur la touche `Play` et cliquez sur l'icône de `clé` pour exécuter les tests + +# Test de la ligne de commande + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/it/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/it/README.md new file mode 100644 index 0000000..af02253 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/it/README.md @@ -0,0 +1,39 @@ + + +# Test di iOS per CDVCamera + +È necessario installare `node. js` per tirare in `cordova-ios`. + +In primo luogo installare cordova-ios: + + npm install + + +... nella cartella corrente. + +# Test da Xcode + + 1. Lanciare il file `CDVCameraTest.xcworkspace` . + 2. Scegli "CDVCameraLibTests" dal menu a discesa Schema + 3. Fare clic e tenere premuto il pulsante `Play` e scegliere l'icona della `chiave inglese` per eseguire i test + +# Test dalla riga di comando + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/ja/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/ja/README.md new file mode 100644 index 0000000..ca0fe84 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/ja/README.md @@ -0,0 +1,39 @@ + + +# CDVCamera の iOS のテスト + +`Node.js` `コルドバ`ios をプルするをインストールする必要があります。. + +コルドバ ios をインストールします。 + + npm install + + +現在のフォルダーに. + +# Xcode からテスト + + 1. `CDVCameraTest.xcworkspace`ファイルを起動します。 + 2. スキーム] ドロップダウン メニューから"CDVCameraLibTests"を選択します。 + 3. クリックし、`再生`ボタンを押し、テストを実行する`レンチ`のアイコンを選択 + +# コマンドラインからテスト + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/ko/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/ko/README.md new file mode 100644 index 0000000..3ad9cfc --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/ko/README.md @@ -0,0 +1,39 @@ + + +# CDVCamera에 대 한 iOS 테스트 + +`Node.js` `코르도바` ios에서를 설치 해야. + +코르도바-ios를 설치 하는 첫번째는: + + npm install + + +현재 폴더에.... + +# Xcode에서 테스트 + + 1. `CDVCameraTest.xcworkspace` 파일을 시작 합니다. + 2. 구성표 드롭 다운 메뉴에서 "CDVCameraLibTests"를 선택 + 3. 클릭 하 고 `재생` 버튼에는 테스트를 실행 하려면 `공구 모양` 아이콘을 선택 + +# 명령줄에서 테스트 + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/pl/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/pl/README.md new file mode 100644 index 0000000..82caa41 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/pl/README.md @@ -0,0 +1,39 @@ + + +# iOS testy dla CDVCamera + +Musisz zainstalować `node.js` ciągnąć w `cordova-ios`. + +Najpierw zainstalować cordova-ios: + + npm install + + +... w folderze bieżącym. + +# Badania z Xcode + + 1. Uruchom plik `CDVCameraTest.xcworkspace` . + 2. Wybierz z menu rozwijanego systemu "CDVCameraLibTests" + 3. Kliknij i przytrzymaj przycisk `Play` i wybrać ikonę `klucz` do testów + +# Badania z wiersza polecenia + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/doc/zh/README.md b/plugins/cordova-plugin-camera/tests/ios/doc/zh/README.md new file mode 100644 index 0000000..5312987 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/doc/zh/README.md @@ -0,0 +1,39 @@ + + +# CDVCamera 的 iOS 測試 + +您需要安裝`node.js`拉`科爾多瓦 ios`中. + +第一次安裝科爾多瓦 ios: + + npm install + + +在當前資料夾中。 + +# 從 Xcode 測試 + + 1. 啟動`CDVCameraTest.xcworkspace`檔。 + 2. 從方案下拉式功能表中選擇"CDVCameraLibTests" + 3. 按一下並堅持`播放`按鈕,然後選擇要運行的測試的`扳手`圖示 + +# 從命令列測試 + + npm test \ No newline at end of file diff --git a/plugins/cordova-plugin-camera/tests/ios/package.json b/plugins/cordova-plugin-camera/tests/ios/package.json new file mode 100644 index 0000000..4b9486f --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/ios/package.json @@ -0,0 +1,13 @@ +{ + "name": "cordova-plugin-camera-test-ios", + "version": "1.0.0", + "description": "iOS Unit Tests for Camera Plugin", + "author": "Apache Software Foundation", + "license": "Apache Version 2.0", + "dependencies": { + "cordova-ios": "*" + }, + "scripts": { + "test": "xcodebuild -scheme CordovaLib && xcodebuild test -scheme CDVCameraLibTests -destination 'platform=iOS Simulator,name=iPhone 5'" + } +} diff --git a/plugins/cordova-plugin-camera/tests/plugin.xml b/plugins/cordova-plugin-camera/tests/plugin.xml new file mode 100644 index 0000000..6fd19fd --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/plugin.xml @@ -0,0 +1,33 @@ + + + + + Cordova Camera Plugin Tests + Apache 2.0 + + + + + + diff --git a/plugins/cordova-plugin-camera/tests/tests.js b/plugins/cordova-plugin-camera/tests/tests.js new file mode 100644 index 0000000..1513f14 --- /dev/null +++ b/plugins/cordova-plugin-camera/tests/tests.js @@ -0,0 +1,510 @@ +/* + * + * 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. + * +*/ + +/* globals Camera, resolveLocalFileSystemURI, FileEntry, CameraPopoverOptions, FileTransfer, FileUploadOptions, LocalFileSystem, MSApp */ +/* jshint jasmine: true */ + +exports.defineAutoTests = function () { + describe('Camera (navigator.camera)', function () { + it("should exist", function () { + expect(navigator.camera).toBeDefined(); + }); + + it("should contain a getPicture function", function () { + expect(navigator.camera.getPicture).toBeDefined(); + expect(typeof navigator.camera.getPicture == 'function').toBe(true); + }); + }); + + describe('Camera Constants (window.Camera + navigator.camera)', function () { + it("camera.spec.1 window.Camera should exist", function () { + expect(window.Camera).toBeDefined(); + }); + + it("camera.spec.2 should contain three DestinationType constants", function () { + expect(Camera.DestinationType.DATA_URL).toBe(0); + expect(Camera.DestinationType.FILE_URI).toBe(1); + expect(Camera.DestinationType.NATIVE_URI).toBe(2); + expect(navigator.camera.DestinationType.DATA_URL).toBe(0); + expect(navigator.camera.DestinationType.FILE_URI).toBe(1); + expect(navigator.camera.DestinationType.NATIVE_URI).toBe(2); + }); + + it("camera.spec.3 should contain two EncodingType constants", function () { + expect(Camera.EncodingType.JPEG).toBe(0); + expect(Camera.EncodingType.PNG).toBe(1); + expect(navigator.camera.EncodingType.JPEG).toBe(0); + expect(navigator.camera.EncodingType.PNG).toBe(1); + }); + + it("camera.spec.4 should contain three MediaType constants", function () { + expect(Camera.MediaType.PICTURE).toBe(0); + expect(Camera.MediaType.VIDEO).toBe(1); + expect(Camera.MediaType.ALLMEDIA).toBe(2); + expect(navigator.camera.MediaType.PICTURE).toBe(0); + expect(navigator.camera.MediaType.VIDEO).toBe(1); + expect(navigator.camera.MediaType.ALLMEDIA).toBe(2); + }); + + it("camera.spec.5 should contain three PictureSourceType constants", function () { + expect(Camera.PictureSourceType.PHOTOLIBRARY).toBe(0); + expect(Camera.PictureSourceType.CAMERA).toBe(1); + expect(Camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2); + expect(navigator.camera.PictureSourceType.PHOTOLIBRARY).toBe(0); + expect(navigator.camera.PictureSourceType.CAMERA).toBe(1); + expect(navigator.camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2); + }); + }); +}; + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ + +exports.defineManualTests = function (contentEl, createActionButton) { + var pictureUrl = null; + var fileObj = null; + var fileEntry = null; + var pageStartTime = +new Date(); + + //default camera options + var camQualityDefault = ['50', 50]; + var camDestinationTypeDefault = ['FILE_URI', 1]; + var camPictureSourceTypeDefault = ['CAMERA', 1]; + var camAllowEditDefault = ['allowEdit', false]; + var camEncodingTypeDefault = ['JPEG', 0]; + var camMediaTypeDefault = ['mediaType', 0]; + var camCorrectOrientationDefault = ['correctOrientation', false]; + var camSaveToPhotoAlbumDefault = ['saveToPhotoAlbum', true]; + + function log(value) { + console.log(value); + document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n'; + } + + function clearStatus() { + document.getElementById('camera_status').innerHTML = ''; + document.getElementById('camera_image').src = 'about:blank'; + var canvas = document.getElementById('canvas'); + canvas.width = canvas.height = 1; + pictureUrl = null; + fileObj = null; + fileEntry = null; + } + + function setPicture(url, callback) { + try { + window.atob(url); + // if we got here it is a base64 string (DATA_URL) + url = "data:image/jpeg;base64," + url; + } catch (e) { + // not DATA_URL + } + log('URL: "' + url.slice(0, 90) + '"'); + + pictureUrl = url; + var img = document.getElementById('camera_image'); + var startTime = new Date(); + img.src = url; + img.onload = function () { + log('Img size: ' + img.naturalWidth + 'x' + img.naturalHeight); + log('Image tag load time: ' + (new Date() - startTime)); + if (callback) { + callback(); + } + }; + } + + function onGetPictureError(e) { + log('Error getting picture: ' + (e.code || e)); + } + + function getPictureWin(data) { + setPicture(data); + // TODO: Fix resolveLocalFileSystemURI to work with native-uri. + if (pictureUrl.indexOf('file:') === 0 || pictureUrl.indexOf('content:') === 0 || pictureUrl.indexOf('ms-appdata:') === 0 || pictureUrl.indexOf('assets-library:') === 0) { + resolveLocalFileSystemURI(data, function (e) { + fileEntry = e; + logCallback('resolveLocalFileSystemURI()', true)(e.toURL()); + readFile(); + }, logCallback('resolveLocalFileSystemURI()', false)); + } else if (pictureUrl.indexOf('data:image/jpeg;base64') === 0) { + // do nothing + } else { + var path = pictureUrl.replace(/^file:\/\/(localhost)?/, '').replace(/%20/g, ' '); + fileEntry = new FileEntry('image_name.png', path); + } + } + + function getPicture() { + clearStatus(); + var options = extractOptions(); + log('Getting picture with options: ' + JSON.stringify(options)); + var popoverHandle = navigator.camera.getPicture(getPictureWin, onGetPictureError, options); + + // Reposition the popover if the orientation changes. + window.onorientationchange = function () { + var newPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, 0); + popoverHandle.setPosition(newPopoverOptions); + }; + } + + function uploadImage() { + var ft = new FileTransfer(), + options = new FileUploadOptions(); + options.fileKey = "photo"; + options.fileName = 'test.jpg'; + options.mimeType = "image/jpeg"; + ft.onprogress = function (progressEvent) { + console.log('progress: ' + progressEvent.loaded + ' of ' + progressEvent.total); + }; + var server = "http://cordova-filetransfer.jitsu.com"; + + ft.upload(pictureUrl, server + '/upload', win, fail, options); + function win(information_back) { + log('upload complete'); + } + function fail(message) { + log('upload failed: ' + JSON.stringify(message)); + } + } + + function logCallback(apiName, success) { + return function () { + log('Call to ' + apiName + (success ? ' success: ' : ' failed: ') + JSON.stringify([].slice.call(arguments))); + }; + } + + /** + * Select image from library using a NATIVE_URI destination type + * This calls FileEntry.getMetadata, FileEntry.setMetadata, FileEntry.getParent, FileEntry.file, and FileReader.readAsDataURL. + */ + function readFile() { + function onFileReadAsDataURL(evt) { + var img = document.getElementById('camera_image'); + img.style.visibility = "visible"; + img.style.display = "block"; + img.src = evt.target.result; + log("FileReader.readAsDataURL success"); + } + + function onFileReceived(file) { + log('Got file: ' + JSON.stringify(file)); + fileObj = file; + + var reader = new FileReader(); + reader.onload = function () { + log('FileReader.readAsDataURL() - length = ' + reader.result.length); + }; + reader.onerror = logCallback('FileReader.readAsDataURL', false); + reader.onloadend = onFileReadAsDataURL; + reader.readAsDataURL(file); + } + + // Test out onFileReceived when the file object was set via a native elements. + if (fileObj) { + onFileReceived(fileObj); + } else { + fileEntry.file(onFileReceived, logCallback('FileEntry.file', false)); + } + } + + function getFileInfo() { + // Test FileEntry API here. + fileEntry.getMetadata(logCallback('FileEntry.getMetadata', true), logCallback('FileEntry.getMetadata', false)); + fileEntry.setMetadata(logCallback('FileEntry.setMetadata', true), logCallback('FileEntry.setMetadata', false), { "com.apple.MobileBackup": 1 }); + fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false)); + fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false)); + } + + /** + * Copy image from library using a NATIVE_URI destination type + * This calls FileEntry.copyTo and FileEntry.moveTo. + */ + function copyImage() { + var onFileSystemReceived = function (fileSystem) { + var destDirEntry = fileSystem.root; + var origName = fileEntry.name; + + // Test FileEntry API here. + fileEntry.copyTo(destDirEntry, 'copied_file.png', logCallback('FileEntry.copyTo', true), logCallback('FileEntry.copyTo', false)); + fileEntry.moveTo(destDirEntry, 'moved_file.png', logCallback('FileEntry.moveTo', true), logCallback('FileEntry.moveTo', false)); + + //cleanup + //rename moved file back to original name so other tests can reference image + resolveLocalFileSystemURI(destDirEntry.nativeURL+'moved_file.png', function(fileEntry) { + fileEntry.moveTo(destDirEntry, origName, logCallback('FileEntry.moveTo', true), logCallback('FileEntry.moveTo', false)); + console.log('Cleanup: successfully renamed file back to original name'); + }, function () { + console.log('Cleanup: failed to rename file back to original name'); + }); + + //remove copied file + resolveLocalFileSystemURI(destDirEntry.nativeURL+'copied_file.png', function(fileEntry) { + fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false)); + console.log('Cleanup: successfully removed copied file'); + }, function () { + console.log('Cleanup: failed to remove copied file'); + }); + }; + + window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onFileSystemReceived, null); + } + + /** + * Write image to library using a NATIVE_URI destination type + * This calls FileEntry.createWriter, FileWriter.write, and FileWriter.truncate. + */ + function writeImage() { + var onFileWriterReceived = function (fileWriter) { + fileWriter.onwrite = logCallback('FileWriter.write', true); + fileWriter.onerror = logCallback('FileWriter.write', false); + fileWriter.write("some text!"); + }; + + var onFileTruncateWriterReceived = function (fileWriter) { + fileWriter.onwrite = logCallback('FileWriter.truncate', true); + fileWriter.onerror = logCallback('FileWriter.truncate', false); + fileWriter.truncate(10); + }; + + fileEntry.createWriter(onFileWriterReceived, logCallback('FileEntry.createWriter', false)); + fileEntry.createWriter(onFileTruncateWriterReceived, null); + } + + function displayImageUsingCanvas() { + var canvas = document.getElementById('canvas'); + var img = document.getElementById('camera_image'); + var w = img.width; + var h = img.height; + h = 100 / w * h; + w = 100; + canvas.width = w; + canvas.height = h; + var context = canvas.getContext('2d'); + context.drawImage(img, 0, 0, w, h); + } + + /** + * Remove image from library using a NATIVE_URI destination type + * This calls FileEntry.remove. + */ + function removeImage() { + fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false)); + } + + function testInputTag(inputEl) { + clearStatus(); + // iOS 6 likes to dead-lock in the onchange context if you + // do any alerts or try to remote-debug. + window.setTimeout(function () { + testNativeFile2(inputEl); + }, 0); + } + + function testNativeFile2(inputEl) { + if (!inputEl.value) { + alert('No file selected.'); + return; + } + fileObj = inputEl.files[0]; + if (!fileObj) { + alert('Got value but no file.'); + return; + } + var URLApi = window.URL || window.webkitURL; + if (URLApi) { + var blobURL = URLApi.createObjectURL(fileObj); + if (blobURL) { + setPicture(blobURL, function () { + URLApi.revokeObjectURL(blobURL); + }); + } else { + log('URL.createObjectURL returned null'); + } + } else { + log('URL.createObjectURL() not supported.'); + } + } + + function extractOptions() { + var els = document.querySelectorAll('#image-options select'); + var ret = {}; + /*jshint -W084 */ + for (var i = 0, el; el = els[i]; ++i) { + var value = el.value; + if (value === '') continue; + value = +value; + + if (el.isBool) { + ret[el.getAttribute("name")] = !!value; + } else { + ret[el.getAttribute("name")] = value; + } + } + /*jshint +W084 */ + return ret; + } + + function createOptionsEl(name, values, selectionDefault) { + var openDiv = '
' + name + ': '; + var select = '
'; + + return openDiv + select + defaultOption + options + closeDiv; + } + + /******************************************************************************/ + + var info_div = '

Camera

' + + '
' + + 'Status:
' + + 'img: ' + + 'canvas: ' + + '
', + options_div = '

Cordova Camera API Options

' + + '
' + + createOptionsEl('sourceType', Camera.PictureSourceType, camPictureSourceTypeDefault) + + createOptionsEl('destinationType', Camera.DestinationType, camDestinationTypeDefault) + + createOptionsEl('encodingType', Camera.EncodingType, camEncodingTypeDefault) + + createOptionsEl('mediaType', Camera.MediaType, camMediaTypeDefault) + + createOptionsEl('quality', { '0': 0, '50': 50, '80': 80, '100': 100 }, camQualityDefault) + + createOptionsEl('targetWidth', { '50': 50, '200': 200, '800': 800, '2048': 2048 }) + + createOptionsEl('targetHeight', { '50': 50, '200': 200, '800': 800, '2048': 2048 }) + + createOptionsEl('allowEdit', true, camAllowEditDefault) + + createOptionsEl('correctOrientation', true, camCorrectOrientationDefault) + + createOptionsEl('saveToPhotoAlbum', true, camSaveToPhotoAlbumDefault) + + createOptionsEl('cameraDirection', Camera.Direction) + + '
', + getpicture_div = '
', + test_procedure = '

Recommended Test Procedure

' + + 'Options not specified should be the default value' + + '
Status box should update with image and info whenever an image is taken or selected from library' + + '

' + + '
  1. All default options. Should be able to edit once picture is taken and will be saved to library.
  2. ' + + '

  3. sourceType=PHOTOLIBRARY
    Should be able to see picture that was just taken in previous test and edit when selected
  4. ' + + '

  5. sourceType=Camera
    allowEdit=false
    saveToPhotoAlbum=false
    Should not be able to edit when taken and will not save to library
  6. ' + + '

  7. encodingType=PNG
    allowEdit=true
    saveToPhotoAlbum=true
    cameraDirection=FRONT
    Should bring up front camera. Verify in status box info URL that image is encoded as PNG.
  8. ' + + '

  9. sourceType=SAVEDPHOTOALBUM
    mediaType=VIDEO
    Should only be able to select a video
  10. ' + + '

  11. sourceType=SAVEDPHOTOALBUM
    mediaType=PICTURE
    allowEdit=false
    Should only be able to select a picture and not edit
  12. ' + + '

  13. sourceType=PHOTOLIBRARY
    mediaType=ALLMEDIA
    allowEdit=true
    Should be able to select pics and videos and edit picture if selected
  14. ' + + '

  15. sourceType=CAMERA
    targetWidth & targetHeight=50
    allowEdit=false
    Do Get File Metadata test below and take note of size
    Repeat test but with width and height=800. Size should be significantly larger.
  16. ' + + '

  17. quality=0
    targetWidth & targetHeight=default
    allowEdit=false
    Do Get File Metadata test below and take note of size
    Repeat test but with quality=80. Size should be significantly larger.
  18. ' + + '
', + inputs_div = '

Native File Inputs

' + + 'For the following tests, status box should update with file selected' + + '

input type=file
' + + '
capture=camera
' + + '
capture=camcorder
' + + '
capture=microphone
', + actions_div = '

Actions

' + + 'For the following tests, ensure that an image is set in status box' + + '

' + + 'Expected result: Get metadata about file selected.
Status box will show, along with the metadata, "Call to FileEntry.getMetadata success, Call to FileEntry.setMetadata success, Call to FileEntry.getParent success"' + + '

' + + 'Expected result: Read contents of file.
Status box will show "Got file: {some metadata}, FileReader.readAsDataURL() - length = someNumber"' + + '

' + + 'Expected result: Copy image to new location and move file to different location.
Status box will show "Call to FileEntry.copyTo success:{some metadata}, Call to FileEntry.moveTo success:{some metadata}"' + + '

' + + 'Expected result: Write image to library.
Status box will show "Call to FileWriter.write success:{some metadata}, Call to FileWriter.truncate success:{some metadata}"' + + '

' + + 'Expected result: Upload image to server.
Status box may print out progress. Once finished will show "upload complete"' + + '

' + + 'Expected result: Display image using canvas.
Image will be displayed in status box under "canvas:"' + + '

' + + 'Expected result: Remove image from library.
Status box will show "FileEntry.remove success:["OK"]'; + + // We need to wrap this code due to Windows security restrictions + // see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details + if (window.MSApp && window.MSApp.execUnsafeLocalFunction) { + MSApp.execUnsafeLocalFunction(function() { + contentEl.innerHTML = info_div + options_div + getpicture_div + test_procedure + inputs_div + actions_div; + }); + } else { + contentEl.innerHTML = info_div + options_div + getpicture_div + test_procedure + inputs_div + actions_div; + } + + var elements = document.getElementsByClassName("testInputTag"); + var listener = function (e) { + testInputTag(e.target); + }; + for (var i = 0; i < elements.length; ++i) { + var item = elements[i]; + item.addEventListener("change", listener, false); + } + + createActionButton('Get picture', function () { + getPicture(); + }, 'getpicture'); + + createActionButton('Clear Status', function () { + clearStatus(); + }, 'getpicture'); + + createActionButton('Get File Metadata', function () { + getFileInfo(); + }, 'metadata'); + + createActionButton('Read with FileReader', function () { + readFile(); + }, 'reader'); + + createActionButton('Copy Image', function () { + copyImage(); + }, 'copy'); + + createActionButton('Write Image', function () { + writeImage(); + }, 'write'); + + createActionButton('Upload Image', function () { + uploadImage(); + }, 'upload'); + + createActionButton('Draw Using Canvas', function () { + displayImageUsingCanvas(); + }, 'draw_canvas'); + + createActionButton('Remove Image', function () { + removeImage(); + }, 'remove'); +}; diff --git a/plugins/cordova-plugin-camera/www/Camera.js b/plugins/cordova-plugin-camera/www/Camera.js new file mode 100644 index 0000000..2f9154b --- /dev/null +++ b/plugins/cordova-plugin-camera/www/Camera.js @@ -0,0 +1,191 @@ +/* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + exec = require('cordova/exec'), + Camera = require('./Camera'); + // XXX: commented out + //CameraPopoverHandle = require('./CameraPopoverHandle'); + +/** + * @namespace navigator + */ + +/** + * @exports camera + */ +var cameraExport = {}; + +// Tack on the Camera Constants to the base camera plugin. +for (var key in Camera) { + cameraExport[key] = Camera[key]; +} + +/** + * Callback function that provides an error message. + * @callback module:camera.onError + * @param {string} message - The message is provided by the device's native code. + */ + +/** + * Callback function that provides the image data. + * @callback module:camera.onSuccess + * @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect. + * @example + * // Show image + * // + * function cameraCallback(imageData) { + * var image = document.getElementById('myImage'); + * image.src = "data:image/jpeg;base64," + imageData; + * } + */ + +/** + * Optional parameters to customize the camera settings. + * * [Quirks](#CameraOptions-quirks) + * @typedef module:camera.CameraOptions + * @type {Object} + * @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.) + * @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value. + * @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture. + * @property {Boolean} [allowEdit=true] - Allow simple editing of image before selection. + * @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding. + * @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant. + * @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant. + * @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. + * @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture. + * @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture. + * @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad. + * @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing). + */ + +/** + * @description 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 `camera.getPicture` function opens the device's default camera + * application that allows users to snap pictures by default - this behavior occurs, + * when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}. + * 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`]{@link module: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`]{@link module:camera.onSuccess} 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 `` 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__ + * + * - Android + * - BlackBerry + * - Browser + * - Firefox + * - FireOS + * - iOS + * - Windows + * - WP8 + * - Ubuntu + * + * More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks). + * + * @example + * navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions); + * @param {module:camera.onSuccess} successCallback + * @param {module:camera.onError} errorCallback + * @param {module:camera.CameraOptions} options CameraOptions + */ +cameraExport.getPicture = function(successCallback, errorCallback, options) { + argscheck.checkArgs('fFO', 'Camera.getPicture', arguments); + options = options || {}; + var getValue = argscheck.getValue; + + var quality = getValue(options.quality, 50); + var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI); + var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA); + var targetWidth = getValue(options.targetWidth, -1); + var targetHeight = getValue(options.targetHeight, -1); + var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG); + var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE); + var allowEdit = !!options.allowEdit; + var correctOrientation = !!options.correctOrientation; + var saveToPhotoAlbum = !!options.saveToPhotoAlbum; + var popoverOptions = getValue(options.popoverOptions, null); + var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK); + + var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, + mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection]; + + exec(successCallback, errorCallback, "Camera", "takePicture", args); + // XXX: commented out + //return new CameraPopoverHandle(); +}; + +/** + * Removes intermediate image files that are kept in temporary storage + * after calling [`camera.getPicture`]{@link module: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); + * } + */ +cameraExport.cleanup = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "Camera", "cleanup", []); +}; + +module.exports = cameraExport; diff --git a/plugins/cordova-plugin-camera/www/CameraConstants.js b/plugins/cordova-plugin-camera/www/CameraConstants.js new file mode 100644 index 0000000..f4b0694 --- /dev/null +++ b/plugins/cordova-plugin-camera/www/CameraConstants.js @@ -0,0 +1,88 @@ +/* + * + * 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. + * +*/ + +/** + * @module Camera + */ +module.exports = { + /** + * @enum {number} + */ + DestinationType:{ + /** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */ + DATA_URL: 0, + /** Return file uri (content://media/external/images/media/2 for Android) */ + FILE_URI: 1, + /** Return native uri (eg. asset-library://... for iOS) */ + NATIVE_URI: 2 + }, + /** + * @enum {number} + */ + EncodingType:{ + /** Return JPEG encoded image */ + JPEG: 0, + /** Return PNG encoded image */ + PNG: 1 + }, + /** + * @enum {number} + */ + MediaType:{ + /** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */ + PICTURE: 0, + /** Allow selection of video only, ONLY RETURNS URL */ + VIDEO: 1, + /** Allow selection from all media types */ + ALLMEDIA : 2 + }, + /** + * @enum {number} + */ + PictureSourceType:{ + /** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */ + PHOTOLIBRARY : 0, + /** Take picture from camera */ + CAMERA : 1, + /** Choose image from picture library (same as PHOTOLIBRARY for Android) */ + SAVEDPHOTOALBUM : 2 + }, + /** + * Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover. + * @enum {number} + */ + PopoverArrowDirection:{ + ARROW_UP : 1, + ARROW_DOWN : 2, + ARROW_LEFT : 4, + ARROW_RIGHT : 8, + ARROW_ANY : 15 + }, + /** + * @enum {number} + */ + Direction:{ + /** Use the back-facing camera */ + BACK: 0, + /** Use the front-facing camera */ + FRONT: 1 + } +}; diff --git a/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js b/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js new file mode 100644 index 0000000..ba1063a --- /dev/null +++ b/plugins/cordova-plugin-camera/www/CameraPopoverHandle.js @@ -0,0 +1,32 @@ +/* + * + * 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. + * +*/ + +/** + * @ignore in favour of iOS' one + * A handle to an image picker popover. + */ +var CameraPopoverHandle = function() { + this.setPosition = function(popoverOptions) { + console.log('CameraPopoverHandle.setPosition is only supported on iOS.'); + }; +}; + +module.exports = CameraPopoverHandle; diff --git a/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js b/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js new file mode 100644 index 0000000..27998b6 --- /dev/null +++ b/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js @@ -0,0 +1,52 @@ +/* + * + * 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. + * +*/ + +var Camera = require('./Camera'); + +/** + * @namespace navigator + */ + +/** + * 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. + * 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. + * @module CameraPopoverOptions + * @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover. + * @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover. + * @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover. + * @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point. + */ +var CameraPopoverOptions = function (x, y, width, height, arrowDir) { + // information of rectangle that popover should be anchored to + this.x = x || 0; + this.y = y || 32; + this.width = width || 320; + this.height = height || 480; + this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY; +}; + +module.exports = CameraPopoverOptions; diff --git a/plugins/cordova-plugin-camera/www/blackberry10/assets/camera.html b/plugins/cordova-plugin-camera/www/blackberry10/assets/camera.html new file mode 100644 index 0000000..2ebd9d1 --- /dev/null +++ b/plugins/cordova-plugin-camera/www/blackberry10/assets/camera.html @@ -0,0 +1,82 @@ + + + + + + + + + + +
+ +
+
+ +
+
+
+
+
+
+ + diff --git a/plugins/cordova-plugin-camera/www/blackberry10/assets/camera.js b/plugins/cordova-plugin-camera/www/blackberry10/assets/camera.js new file mode 100644 index 0000000..8a245e5 --- /dev/null +++ b/plugins/cordova-plugin-camera/www/blackberry10/assets/camera.js @@ -0,0 +1,46 @@ +/* + * 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. + * + */ + +document.addEventListener('DOMContentLoaded', function () { + document.getElementById('back').onclick = function () { + window.qnx.callExtensionMethod('cordova-plugin-camera', 'cancel'); + }; + window.navigator.webkitGetUserMedia( + { video: true }, + function (stream) { + var video = document.getElementById('v'), + canvas = document.getElementById('c'), + camera = document.getElementById('camera'); + video.autoplay = true; + video.width = window.innerWidth; + video.height = window.innerHeight - 100; + video.src = window.webkitURL.createObjectURL(stream); + camera.onclick = function () { + canvas.width = video.videoWidth; + canvas.height = video.videoHeight; + canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight); + window.qnx.callExtensionMethod('cordova-plugin-camera', canvas.toDataURL('img/png')); + }; + }, + function () { + window.qnx.callExtensionMethod('cordova-plugin-camera', 'error', 'getUserMedia failed'); + } + ); +}); diff --git a/plugins/cordova-plugin-camera/www/ios/CameraPopoverHandle.js b/plugins/cordova-plugin-camera/www/ios/CameraPopoverHandle.js new file mode 100644 index 0000000..3990e18 --- /dev/null +++ b/plugins/cordova-plugin-camera/www/ios/CameraPopoverHandle.js @@ -0,0 +1,60 @@ +/* + * + * 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. + * +*/ + +var exec = require('cordova/exec'); + +/** + * @namespace navigator + */ + +/** + * A handle to an image picker popover. + * + * __Supported Platforms__ + * + * - iOS + * + * @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); + * } + * @module CameraPopoverHandle + */ +var CameraPopoverHandle = function() { + /** Set the position of the popover. + * @param {module:CameraPopoverOptions} popoverOptions + */ + this.setPosition = function(popoverOptions) { + var args = [ popoverOptions ]; + exec(null, null, "Camera", "repositionPopover", args); + }; +}; + +module.exports = CameraPopoverHandle; diff --git a/plugins/cordova-plugin-compat/README.md b/plugins/cordova-plugin-compat/README.md new file mode 100644 index 0000000..1b3c89f --- /dev/null +++ b/plugins/cordova-plugin-compat/README.md @@ -0,0 +1,25 @@ + + +cordova-plugin-compat +------------------------ + +This repo is for remaining backwards compatible with previous versions of Cordova. diff --git a/plugins/cordova-plugin-compat/package.json b/plugins/cordova-plugin-compat/package.json new file mode 100644 index 0000000..42f817e --- /dev/null +++ b/plugins/cordova-plugin-compat/package.json @@ -0,0 +1,32 @@ +{ + "name": "cordova-plugin-compat", + "description": "This repo is for remaining backwards compatible with previous versions of Cordova.", + "version": "1.0.0", + "homepage": "http://github.com/apache/cordova-plugin-compat#readme", + "repository": { + "type": "git", + "url": "git://github.com/apache/cordova-plugin-compat.git" + }, + "bugs": { + "url": "https://github.com/apache/cordova-plugin-compat/issues" + }, + "cordova": { + "id": "cordova-plugin-compat", + "platforms": [ + "android" + ] + }, + "keywords": [ + "ecosystem:cordova", + "ecosystem:phonegap", + "cordova-android" + ], + "engines": [ + { + "name": "cordova", + "version": ">=5.0.0" + } + ], + "author": "Apache Software Foundation", + "license": "Apache-2.0" +} diff --git a/plugins/cordova-plugin-compat/plugin.xml b/plugins/cordova-plugin-compat/plugin.xml new file mode 100644 index 0000000..996d962 --- /dev/null +++ b/plugins/cordova-plugin-compat/plugin.xml @@ -0,0 +1,36 @@ + + + + + + Compat + Cordova Compatibility Plugin + Apache 2.0 + cordova,compat + https://git-wip-us.apache.org/repos/asf/cordova-plugin-compat.git + + + + + + + diff --git a/plugins/cordova-plugin-compat/src/android/PermissionHelper.java b/plugins/cordova-plugin-compat/src/android/PermissionHelper.java new file mode 100644 index 0000000..bbd7911 --- /dev/null +++ b/plugins/cordova-plugin-compat/src/android/PermissionHelper.java @@ -0,0 +1,138 @@ +/* + 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; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; + +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.LOG; + +import android.content.pm.PackageManager; + +/** + * This class provides reflective methods for permission requesting and checking so that plugins + * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. + */ +public class PermissionHelper { + private static final String LOG_TAG = "CordovaPermissionHelper"; + + /** + * Requests a "dangerous" permission for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermission() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permission request + * @param permission The permission to be requested + */ + public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { + PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); + } + + /** + * Requests "dangerous" permissions for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermissions() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permissions are being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permissions request + * @param permissions The permissions to be requested + */ + public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { + try { + Method requestPermission = CordovaInterface.class.getDeclaredMethod( + "requestPermissions", CordovaPlugin.class, int.class, String[].class); + + // If there is no exception, then this is cordova-android 5.0.0+ + requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); + + // Notify the plugin that all were granted by using more reflection + deliverPermissionResult(plugin, requestCode, permissions); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); + } + } + + /** + * Checks at runtime to see if the application has been granted a permission. This is a helper + * method alternative to cordovaInterface.hasPermission() that does not require the project to + * be built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being checked against + * @param permission The permission to be checked + * + * @return True if the permission has already been granted and false otherwise + */ + public static boolean hasPermission(CordovaPlugin plugin, String permission) { + try { + Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); + + // If there is no exception, then this is cordova-android 5.0.0+ + return (Boolean) hasPermission.invoke(plugin.cordova, permission); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to check for permission " + permission); + return true; + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); + } + return false; + } + + private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { + // Generate the request results + int[] requestResults = new int[permissions.length]; + Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); + + try { + Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( + "onRequestPermissionResult", int.class, String[].class, int[].class); + + onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); + } catch (NoSuchMethodException noSuchMethodException) { + // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it + // made it to this point + LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method may throw a JSONException. We are just duplicating cordova-android's + // exception handling behavior here; all it does is log the exception in CordovaActivity, + // print the stacktrace, and ignore it + LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); + } + } +} diff --git a/plugins/cordova-plugin-file-transfer/CONTRIBUTING.md b/plugins/cordova-plugin-console/CONTRIBUTING.md similarity index 100% rename from plugins/cordova-plugin-file-transfer/CONTRIBUTING.md rename to plugins/cordova-plugin-console/CONTRIBUTING.md diff --git a/plugins/cordova-plugin-file-transfer/LICENSE b/plugins/cordova-plugin-console/LICENSE similarity index 100% rename from plugins/cordova-plugin-file-transfer/LICENSE rename to plugins/cordova-plugin-console/LICENSE diff --git a/plugins/cordova-plugin-console/NOTICE b/plugins/cordova-plugin-console/NOTICE new file mode 100644 index 0000000..8ec56a5 --- /dev/null +++ b/plugins/cordova-plugin-console/NOTICE @@ -0,0 +1,5 @@ +Apache Cordova +Copyright 2012 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/plugins/cordova-plugin-console/README.md b/plugins/cordova-plugin-console/README.md new file mode 100644 index 0000000..e5f845b --- /dev/null +++ b/plugins/cordova-plugin-console/README.md @@ -0,0 +1,100 @@ + + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-console) + +# cordova-plugin-console + +This plugin is meant to ensure that console.log() is as useful as it can be. +It adds additional function for iOS, Ubuntu, Windows Phone 8, and Windows. If +you are happy with how console.log() works for you, then you probably +don't need this plugin. + +This plugin defines a global `console` object. + +Although the object is in the global scope, features provided by this plugin +are not available until after the `deviceready` event. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + +## Installation + + cordova plugin add cordova-plugin-console + +### Android Quirks + +On some platforms other than Android, console.log() will act on multiple +arguments, such as console.log("1", "2", "3"). However, Android will act only +on the first argument. Subsequent arguments to console.log() will be ignored. +This plugin is not the cause of that, it is a limitation of Android itself. + +## Supported Methods + +The plugin support following methods of the `console` object: + +- `console.log` +- `console.error` +- `console.exception` +- `console.warn` +- `console.info` +- `console.debug` +- `console.assert` +- `console.dir` +- `console.dirxml` +- `console.time` +- `console.timeEnd` +- `console.table` + +## Partially supported Methods + +Methods of the `console` object which implemented, but behave different from browser implementation: + +- `console.group` +- `console.groupCollapsed` + +The grouping methods are just log name of the group and don't actually indicate grouping for later +calls to `console` object methods. + +## Not supported Methods + +Methods of the `console` object which are implemented, but do nothing: + +- `console.clear` +- `console.trace` +- `console.groupEnd` +- `console.timeStamp` +- `console.profile` +- `console.profileEnd` +- `console.count` + +## Supported formatting + +The following formatting options available: + +Format chars: + +* `%j` - format arg as JSON +* `%o` - format arg as JSON +* `%c` - format arg as `''`. No color formatting could be done. +* `%%` - replace with `'%'` + +Any other char following `%` will format its arg via `toString()`. diff --git a/plugins/cordova-plugin-console/RELEASENOTES.md b/plugins/cordova-plugin-console/RELEASENOTES.md new file mode 100644 index 0000000..6327ba7 --- /dev/null +++ b/plugins/cordova-plugin-console/RELEASENOTES.md @@ -0,0 +1,93 @@ + +# Release Notes + +### 1.0.2 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* Fixing contribute link. +* Document formatting options for the console object +* [CB-5089](https://issues.apache.org/jira/browse/CB-5089) Document supported methods for console object +* reverted `d58f218b9149d362ebb0b8ce697cf403569d14cd` because `logger` is not needed on **Android** + +### 1.0.1 (Jun 17, 2015) +* move logger.js and console-via-logger.js to common modules, instead of the numerous repeats that were there. +* clean up tests, info is below log level so it does not exist by default. +* add a couple tests +* [CB-9191](https://issues.apache.org/jira/browse/CB-9191) Add basic test +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-console documentation translation: cordova-plugin-console +* attempt to fix npm markdown issue + +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* docs: renamed Windows8 to Windows +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8560](https://issues.apache.org/jira/browse/CB-8560) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-console documentation translation: cordova-plugin-console +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file +* [CB-8362](https://issues.apache.org/jira/browse/CB-8362) Add Windows platform section to Console plugin + +### 0.2.13 (Feb 04, 2015) +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension + +### 0.2.12 (Dec 02, 2014) +* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-console documentation translation: cordova-plugin-console + +### 0.2.11 (Sep 17, 2014) +* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-console documentation translation + +### 0.2.10 (Aug 06, 2014) +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs + +### 0.2.9 (Jun 05, 2014) +* [CB-6848](https://issues.apache.org/jira/browse/CB-6848) Add Android quirk, list applicable platforms +* [CB-6796](https://issues.apache.org/jira/browse/CB-6796) Add license +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md + +### 0.2.8 (Apr 17, 2014) +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* Add NOTICE file + +### 0.2.7 (Feb 05, 2014) +* Native console needs to be called DebugConsole to avoid ambiguous reference. This commit requires the 3.4.0 version of the native class factory +* [CB-4718](https://issues.apache.org/jira/browse/CB-4718) fixed Console plugin not working on wp + +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Console plugin + +### 0.2.5 (Dec 4, 2013) +* add ubuntu platform + +### 0.2.4 (Oct 28, 2013) +* [CB-5154](https://issues.apache.org/jira/browse/CB-5154) log formatting incorrectly to native +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for console plugin +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.console to org.apache.cordova.console +* Rename CHANGELOG.md -> RELEASENOTES.md +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. + + diff --git a/plugins/cordova-plugin-console/doc/de/README.md b/plugins/cordova-plugin-console/doc/de/README.md new file mode 100644 index 0000000..933c1b7 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/de/README.md @@ -0,0 +1,43 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +Dieses Plugin stellt sicher, dass der Befehl console.log() so hilfreich ist, wie er sein kann. Es fügt zusätzliche Funktion für iOS, Ubuntu, Windows Phone 8 und Windows. Teilweise kann es vorkommen, dass der Befehl console.log() nicht korrekt erkannt wird, und es zu Fehlern bzw. zu nicht angezeigten Logs in der Console kommt. Wenn Sie mit der derzeitigen Funktionsweise zufrieden sind, kann es sein, dass Sie dieses Plugin nicht benötigen. + +Dieses Plugin wird ein global-`console`-Objekt definiert. + +Obwohl das Objekt im globalen Gültigkeitsbereich ist, stehen Features von diesem Plugin nicht bis nach dem `deviceready`-Ereignis. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## Installation + + cordova plugin add cordova-plugin-console + + +### Android Eigenarten + +Auf einigen Plattformen als Android fungieren console.log() auf mehrere Argumente wie console.log ("1", "2", "3"). Android wird jedoch nur auf das erste Argument fungieren. Nachfolgende Argumente zu console.log() werden ignoriert. Dieses Plugin ist nicht die Verantwortung dafür, es ist eine Einschränkung von Android selbst. \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/de/index.md b/plugins/cordova-plugin-console/doc/de/index.md new file mode 100644 index 0000000..9551782 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/de/index.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +Dieses Plugin stellt sicher, dass der Befehl console.log() so hilfreich ist, wie er sein kann. Es fügt zusätzliche Funktion für iOS, Ubuntu, Windows Phone 8 und Windows 8 hinzu. Teilweise kann es vorkommen, dass der Befehl console.log() nicht korrekt erkannt wird, und es zu Fehlern bzw. zu nicht angezeigten Logs in der Console kommt. Wenn Sie mit der derzeitigen Funktionsweise zufrieden sind, kann es sein, dass Sie dieses Plugin nicht benötigen. + +Dieses Plugin wird ein global-`console`-Objekt definiert. + +Obwohl das Objekt im globalen Gültigkeitsbereich ist, stehen Features von diesem Plugin nicht bis nach dem `deviceready`-Ereignis. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## Installation + + cordova plugin add cordova-plugin-console + + +### Android Eigenarten + +Auf einigen Plattformen als Android fungieren console.log() auf mehrere Argumente wie console.log ("1", "2", "3"). Android wird jedoch nur auf das erste Argument fungieren. Nachfolgende Argumente zu console.log() werden ignoriert. Dieses Plugin ist nicht die Verantwortung dafür, es ist eine Einschränkung von Android selbst. diff --git a/plugins/cordova-plugin-console/doc/es/README.md b/plugins/cordova-plugin-console/doc/es/README.md new file mode 100644 index 0000000..b089d63 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/es/README.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +Este plugin es para asegurarse de que console.log() es tan útil como puede ser. Agrega la función adicional para iOS, Ubuntu, Windows Phone 8 y Windows. Si estás contento con cómo funciona console.log() para ti, entonces probablemente no necesitas este plugin. + +Este plugin define un global `console` objeto. + +Aunque el objeto está en el ámbito global, características proporcionadas por este plugin no están disponibles hasta después de la `deviceready` evento. + + document.addEventListener ("deviceready", onDeviceReady, false); + function onDeviceReady() {console.log ("console.log funciona bien");} + + +## Instalación + + cordova plugin add cordova-plugin-console + + +### Rarezas Android + +En algunas plataformas que no sean Android, console.log() actuará en varios argumentos, como console.log ("1", "2", "3"). Sin embargo, Android actuará sólo en el primer argumento. Se omitirá posteriores argumentos para console.log(). Este plugin no es la causa de eso, es una limitación propia de Android. \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/es/index.md b/plugins/cordova-plugin-console/doc/es/index.md new file mode 100644 index 0000000..e6b8e68 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/es/index.md @@ -0,0 +1,39 @@ + + +# cordova-plugin-console + +Este plugin es para asegurarse de que console.log() es tan útil como puede ser. Añade función adicional para iOS, Windows Phone 8, Ubuntu y Windows 8. Si estás contento con cómo funciona console.log() para ti, entonces probablemente no necesitas este plugin. + +Este plugin define un global `console` objeto. + +Aunque el objeto está en el ámbito global, características proporcionadas por este plugin no están disponibles hasta después de la `deviceready` evento. + + document.addEventListener ("deviceready", onDeviceReady, false); + function onDeviceReady() {console.log ("console.log funciona bien");} + + +## Instalación + + Cordova plugin agregar cordova-plugin-console + + +### Rarezas Android + +En algunas plataformas que no sean Android, console.log() actuará en varios argumentos, como console.log ("1", "2", "3"). Sin embargo, Android actuará sólo en el primer argumento. Se omitirá posteriores argumentos para console.log(). Este plugin no es la causa de eso, es una limitación propia de Android. diff --git a/plugins/cordova-plugin-console/doc/fr/README.md b/plugins/cordova-plugin-console/doc/fr/README.md new file mode 100644 index 0000000..74207ac --- /dev/null +++ b/plugins/cordova-plugin-console/doc/fr/README.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +Ce plugin est destiné à faire en sorte que console.log() est aussi utile que possible. Il ajoute une fonction supplémentaire pour iOS, Ubuntu, Windows Phone 8 et Windows. Si vous êtes satisfait du fonctionnement de console.log() pour vous, alors vous avez probablement pas besoin ce plugin. + +Ce plugin définit un global `console` objet. + +Bien que l'objet est dans la portée globale, les fonctions offertes par ce plugin ne sont pas disponibles jusqu'après la `deviceready` événement. + + document.addEventListener (« deviceready », onDeviceReady, false) ; + function onDeviceReady() {console.log ("console.log fonctionne bien");} + + +## Installation + + cordova plugin add cordova-plugin-console + + +### Quirks Android + +Sur certaines plateformes autres que Android, console.log() va agir sur plusieurs arguments, tels que console.log ("1", "2", "3"). Toutefois, Android doit agir uniquement sur le premier argument. Les arguments suivants à console.log() seront ignorées. Ce plugin n'est pas la cause de cela, il s'agit d'une limitation d'Android lui-même. \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/fr/index.md b/plugins/cordova-plugin-console/doc/fr/index.md new file mode 100644 index 0000000..d0dbba5 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/fr/index.md @@ -0,0 +1,39 @@ + + +# cordova-plugin-console + +Ce plugin est destiné à faire en sorte que console.log() est aussi utile que possible. Il ajoute une fonction supplémentaire pour iOS, Ubuntu, Windows Phone 8 et Windows 8. Si vous êtes satisfait du fonctionnement de console.log() pour vous, alors vous avez probablement pas besoin ce plugin. + +Ce plugin définit un global `console` objet. + +Bien que l'objet est dans la portée globale, les fonctions offertes par ce plugin ne sont pas disponibles jusqu'après la `deviceready` événement. + + document.addEventListener (« deviceready », onDeviceReady, false) ; + function onDeviceReady() {console.log ("console.log fonctionne bien");} + + +## Installation + + Cordova plugin ajouter cordova-plugin-console + + +### Quirks Android + +Sur certaines plateformes autres que Android, console.log() va agir sur plusieurs arguments, tels que console.log ("1", "2", "3"). Toutefois, Android doit agir uniquement sur le premier argument. Les arguments suivants à console.log() seront ignorées. Ce plugin n'est pas la cause de cela, il s'agit d'une limitation d'Android lui-même. diff --git a/plugins/cordova-plugin-console/doc/it/README.md b/plugins/cordova-plugin-console/doc/it/README.md new file mode 100644 index 0000000..5394d55 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/it/README.md @@ -0,0 +1,43 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +Questo plugin è intesa a garantire che console.log() è tanto utile quanto può essere. Aggiunge una funzione aggiuntiva per iOS, Ubuntu, Windows Phone 8 e Windows. Se sei soddisfatto di come console.log() funziona per voi, quindi probabilmente non è necessario questo plugin. + +Questo plugin definisce un oggetto globale `console`. + +Sebbene l'oggetto sia in ambito globale, funzionalità fornite da questo plugin non sono disponibili fino a dopo l'evento `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## Installazione + + cordova plugin add cordova-plugin-console + + +### Stranezze Android + +Su alcune piattaforme diverse da Android, console.log() agirà su più argomenti, come ad esempio console ("1", "2", "3"). Tuttavia, Android agirà solo sul primo argomento. Argomenti successivi a console.log() verranno ignorati. Questo plugin non è la causa di ciò, è una limitazione di Android stesso. \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/it/index.md b/plugins/cordova-plugin-console/doc/it/index.md new file mode 100644 index 0000000..f0625b3 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/it/index.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +Questo plugin è intesa a garantire che console.log() è tanto utile quanto può essere. Aggiunge una funzione aggiuntiva per iOS, Ubuntu, Windows 8 e Windows Phone 8. Se sei soddisfatto di come console.log() funziona per voi, quindi probabilmente non è necessario questo plugin. + +Questo plugin definisce un oggetto globale `console`. + +Sebbene l'oggetto sia in ambito globale, funzionalità fornite da questo plugin non sono disponibili fino a dopo l'evento `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## Installazione + + cordova plugin add cordova-plugin-console + + +### Stranezze Android + +Su alcune piattaforme diverse da Android, console.log() agirà su più argomenti, come ad esempio console ("1", "2", "3"). Tuttavia, Android agirà solo sul primo argomento. Argomenti successivi a console.log() verranno ignorati. Questo plugin non è la causa di ciò, è una limitazione di Android stesso. diff --git a/plugins/cordova-plugin-console/doc/ja/README.md b/plugins/cordova-plugin-console/doc/ja/README.md new file mode 100644 index 0000000..059c373 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/ja/README.md @@ -0,0 +1,43 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +このプラグインは、その console.log() がすることができます便利なことを確認するものです。 それは iOS、Ubuntu、Windows Phone 8 は、Windows に追加の関数を追加します。 場合はあなたのための console.log() の作品に満足しているし、おそらく必要はありませんこのプラグイン。 + +このプラグインでは、グローバル ・ `console` オブジェクトを定義します。 + +オブジェクトは、グローバル スコープでですが、このプラグインによって提供される機能は、`deviceready` イベントの後まで使用できません。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## インストール + + cordova plugin add cordova-plugin-console + + +### Android の癖 + +アンドロイド以外のいくつかのプラットフォームで console.log() は console.log (「1」、「2」、「3」) など、複数の引数に動作します。 しかし、アンドロイドは、最初の引数でのみ動作します。 console.log() に後続の引数は無視されます。 このプラグインが原因ではない、それは Android の自体の制限です。 \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/ja/index.md b/plugins/cordova-plugin-console/doc/ja/index.md new file mode 100644 index 0000000..413593c --- /dev/null +++ b/plugins/cordova-plugin-console/doc/ja/index.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +このプラグインは、その console.log() がすることができます便利なことを確認するものです。 それは、iOS、Ubuntu、Windows Phone 8 および Windows 8 の追加関数を追加します。 場合はあなたのための console.log() の作品に満足しているし、おそらく必要はありませんこのプラグイン。 + +このプラグインでは、グローバル ・ `console` オブジェクトを定義します。 + +オブジェクトは、グローバル スコープでですが、このプラグインによって提供される機能は、`deviceready` イベントの後まで使用できません。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## インストール + + cordova plugin add cordova-plugin-console + + +### Android の癖 + +アンドロイド以外のいくつかのプラットフォームで console.log() は console.log (「1」、「2」、「3」) など、複数の引数に動作します。 しかし、アンドロイドは、最初の引数でのみ動作します。 console.log() に後続の引数は無視されます。 このプラグインが原因ではない、それは Android の自体の制限です。 diff --git a/plugins/cordova-plugin-console/doc/ko/README.md b/plugins/cordova-plugin-console/doc/ko/README.md new file mode 100644 index 0000000..d03ee5a --- /dev/null +++ b/plugins/cordova-plugin-console/doc/ko/README.md @@ -0,0 +1,43 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +이 플러그인을 console.log()로 수 유용 되도록 의미입니다. 그것은 iOS, 우분투, Windows Phone 8, 및 창에 대 한 추가 기능을 추가합니다. Console.log() 당신을 위해 작동 하는 어떻게 행복 한 경우에, 그때 당신은 아마 필요 하지 않습니다이 플러그인. + +이 플러그인 글로벌 `console` 개체를 정의합니다. + +개체가 전역 범위에 있지만,이 플러그인에 의해 제공 되는 기능 하지 사용할 수 있습니다까지 `deviceready` 이벤트 후. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## 설치 + + cordova plugin add cordova-plugin-console + + +### 안 드 로이드 단점 + +안 드 로이드 이외의 일부 플랫폼에서 console.log() console.log ("1", "2", "3")와 같이 여러 인수에 작동할 것 이다. 그러나, 안 드 로이드는 첫 번째 인수에만 작동할 것 이다. Console.log() 후속 인수는 무시 됩니다. 이 플러그인의 원인이 되지 않습니다, 그리고 그것은 안 드 로이드 자체의 한계입니다. \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/ko/index.md b/plugins/cordova-plugin-console/doc/ko/index.md new file mode 100644 index 0000000..ca631e4 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/ko/index.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +이 플러그인을 console.log()로 수 유용 되도록 의미입니다. IOS, 우분투, Windows Phone 8 및 윈도우 8에 대 한 추가 기능을 추가 하 고 합니다. Console.log() 당신을 위해 작동 하는 어떻게 행복 한 경우에, 그때 당신은 아마 필요 하지 않습니다이 플러그인. + +이 플러그인 글로벌 `console` 개체를 정의합니다. + +개체가 전역 범위에 있지만,이 플러그인에 의해 제공 되는 기능 하지 사용할 수 있습니다까지 `deviceready` 이벤트 후. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## 설치 + + cordova plugin add cordova-plugin-console + + +### 안 드 로이드 단점 + +안 드 로이드 이외의 일부 플랫폼에서 console.log() console.log ("1", "2", "3")와 같이 여러 인수에 작동할 것 이다. 그러나, 안 드 로이드는 첫 번째 인수에만 작동할 것 이다. Console.log() 후속 인수는 무시 됩니다. 이 플러그인의 원인이 되지 않습니다, 그리고 그것은 안 드 로이드 자체의 한계입니다. diff --git a/plugins/cordova-plugin-console/doc/pl/README.md b/plugins/cordova-plugin-console/doc/pl/README.md new file mode 100644 index 0000000..78ab9d2 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/pl/README.md @@ -0,0 +1,43 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +Ten plugin jest przeznaczona do zapewnienia, że console.log() jest tak przydatne, jak to może być. To dodaje dodatkową funkcję dla iOS, Ubuntu, Windows Phone 8 i Windows. Jeśli jesteś zadowolony z jak console.log() pracuje dla Ciebie, wtedy prawdopodobnie nie potrzebują tej wtyczki. + +Ten plugin definiuje obiekt globalny `console`. + +Mimo, że obiekt jest w globalnym zasięgu, funkcji oferowanych przez ten plugin nie są dostępne dopiero po turnieju `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## Instalacja + + cordova plugin add cordova-plugin-console + + +### Dziwactwa Androida + +Na niektórych platformach innych niż Android console.log() będzie działać na wielu argumentów, takich jak console.log ("1", "2", "3"). Jednak Android będzie działać tylko na pierwszy argument. Kolejne argumenty do console.log() będą ignorowane. Ten plugin nie jest przyczyną, że, jest to ograniczenie Androida, sam. \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/pl/index.md b/plugins/cordova-plugin-console/doc/pl/index.md new file mode 100644 index 0000000..922b577 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/pl/index.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +Ten plugin jest przeznaczona do zapewnienia, że console.log() jest tak przydatne, jak to może być. To dodaje dodatkową funkcję dla iOS, Ubuntu, Windows Phone 8 i Windows 8. Jeśli jesteś zadowolony z jak console.log() pracuje dla Ciebie, wtedy prawdopodobnie nie potrzebują tej wtyczki. + +Ten plugin definiuje obiekt globalny `console`. + +Mimo, że obiekt jest w globalnym zasięgu, funkcji oferowanych przez ten plugin nie są dostępne dopiero po turnieju `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## Instalacja + + cordova plugin add cordova-plugin-console + + +### Dziwactwa Androida + +Na niektórych platformach innych niż Android console.log() będzie działać na wielu argumentów, takich jak console.log ("1", "2", "3"). Jednak Android będzie działać tylko na pierwszy argument. Kolejne argumenty do console.log() będą ignorowane. Ten plugin nie jest przyczyną, że, jest to ograniczenie Androida, sam. diff --git a/plugins/cordova-plugin-console/doc/ru/index.md b/plugins/cordova-plugin-console/doc/ru/index.md new file mode 100644 index 0000000..3cfe15d --- /dev/null +++ b/plugins/cordova-plugin-console/doc/ru/index.md @@ -0,0 +1,31 @@ + + +# cordova-plugin-console + +Этот плагин предназначен для обеспечения как полезным, поскольку это может быть что console.log(). Он добавляет дополнительные функции для iOS, Ubuntu, Windows Phone 8 и Windows 8. Если вы не довольны как console.log() работает для вас, то вы вероятно не нужен этот плагин. + +## Установка + + cordova plugin add cordova-plugin-console + + +### Особенности Android + +На некоторых платформах, отличных от Android console.log() будет действовать на нескольких аргументов, например console.log («1», «2», «3»). Тем не менее Android будет действовать только на первого аргумента. Последующие аргументы для console.log() будет игнорироваться. Этот плагин не является причиной этого, это ограничение Android сам. diff --git a/plugins/cordova-plugin-console/doc/zh/README.md b/plugins/cordova-plugin-console/doc/zh/README.md new file mode 100644 index 0000000..ce27c3e --- /dev/null +++ b/plugins/cordova-plugin-console/doc/zh/README.md @@ -0,0 +1,43 @@ + + +# cordova-plugin-console + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) + +這個外掛程式是為了確保該 console.log() 是一樣有用,它可以是。 它將添加附加功能的 iOS,Ubuntu,Windows Phone 8 和視窗。 如果你是快樂與 console.log() 是如何為你工作,那麼可能不需要這個外掛程式。 + +這個外掛程式定義了一個全域 `console` 物件。 + +儘管物件是在全球範圍內,提供這個外掛程式的功能不可用直到 `deviceready` 事件之後。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## 安裝 + + cordova plugin add cordova-plugin-console + + +### Android 的怪癖 + +在一些平臺上除了 Android,console.log() 亦會根據多個參數,如 console.log ("1"、"2"、"3")。 然而,安卓系統只亦會根據第一個參數。 對 console.log() 的後續參數將被忽略。 這個外掛程式不是的原因,它是一個 android 作業系統本身的限制。 \ No newline at end of file diff --git a/plugins/cordova-plugin-console/doc/zh/index.md b/plugins/cordova-plugin-console/doc/zh/index.md new file mode 100644 index 0000000..e18a141 --- /dev/null +++ b/plugins/cordova-plugin-console/doc/zh/index.md @@ -0,0 +1,41 @@ + + +# cordova-plugin-console + +這個外掛程式是為了確保該 console.log() 是一樣有用,它可以是。 它將添加附加功能的 iOS、 Ubuntu,Windows Phone 8 和 Windows 8。 如果你是快樂與 console.log() 是如何為你工作,那麼可能不需要這個外掛程式。 + +這個外掛程式定義了一個全域 `console` 物件。 + +儘管物件是在全球範圍內,提供這個外掛程式的功能不可用直到 `deviceready` 事件之後。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log("console.log works well"); + } + + +## 安裝 + + cordova plugin add cordova-plugin-console + + +### Android 的怪癖 + +在一些平臺上除了 Android,console.log() 亦會根據多個參數,如 console.log ("1"、"2"、"3")。 然而,安卓系統只亦會根據第一個參數。 對 console.log() 的後續參數將被忽略。 這個外掛程式不是的原因,它是一個 android 作業系統本身的限制。 diff --git a/plugins/cordova-plugin-console/package.json b/plugins/cordova-plugin-console/package.json new file mode 100644 index 0000000..8f72168 --- /dev/null +++ b/plugins/cordova-plugin-console/package.json @@ -0,0 +1,40 @@ +{ + "name": "cordova-plugin-console", + "version": "1.0.3-dev", + "description": "Cordova Console Plugin", + "cordova": { + "id": "cordova-plugin-console", + "platforms": [ + "ios", + "ubuntu", + "wp7", + "wp8", + "windows8", + "windows" + ] + }, + "repository": { + "type": "git", + "url": "https://github.com/apache/cordova-plugin-console" + }, + "keywords": [ + "cordova", + "console", + "ecosystem:cordova", + "cordova-ios", + "cordova-ubuntu", + "cordova-wp7", + "cordova-wp8", + "cordova-windows8", + "cordova-windows" + ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, + "author": "Apache Software Foundation", + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } +} diff --git a/plugins/cordova-plugin-console/plugin.xml b/plugins/cordova-plugin-console/plugin.xml new file mode 100644 index 0000000..a1e60b6 --- /dev/null +++ b/plugins/cordova-plugin-console/plugin.xml @@ -0,0 +1,127 @@ + + + + + + Console + Cordova Console Plugin + Apache 2.0 + cordova,console + https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git + https://issues.apache.org/jira/browse/CB/component/12320644 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-console/src/ios/CDVLogger.h b/plugins/cordova-plugin-console/src/ios/CDVLogger.h new file mode 100644 index 0000000..7cfb306 --- /dev/null +++ b/plugins/cordova-plugin-console/src/ios/CDVLogger.h @@ -0,0 +1,26 @@ +/* + 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. + */ + +#import + +@interface CDVLogger : CDVPlugin + +- (void)logLevel:(CDVInvokedUrlCommand*)command; + +@end diff --git a/plugins/cordova-plugin-console/src/ios/CDVLogger.m b/plugins/cordova-plugin-console/src/ios/CDVLogger.m new file mode 100644 index 0000000..ccfa3a5 --- /dev/null +++ b/plugins/cordova-plugin-console/src/ios/CDVLogger.m @@ -0,0 +1,38 @@ +/* + 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. + */ + +#import "CDVLogger.h" +#import + +@implementation CDVLogger + +/* log a message */ +- (void)logLevel:(CDVInvokedUrlCommand*)command +{ + id level = [command argumentAtIndex:0]; + id message = [command argumentAtIndex:1]; + + if ([level isEqualToString:@"LOG"]) { + NSLog(@"%@", message); + } else { + NSLog(@"%@: %@", level, message); + } +} + +@end diff --git a/plugins/cordova-plugin-console/src/ubuntu/console.cpp b/plugins/cordova-plugin-console/src/ubuntu/console.cpp new file mode 100644 index 0000000..9de09f4 --- /dev/null +++ b/plugins/cordova-plugin-console/src/ubuntu/console.cpp @@ -0,0 +1,29 @@ +/* + * 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. + */ + +#include "console.h" + +#include + +Console::Console(Cordova *cordova) : CPlugin(cordova) { +} + +void Console::logLevel(int scId, int ecId, QString level, QString message) { + Q_UNUSED(scId) + Q_UNUSED(ecId) + + if (level != "LOG") + std::cout << "[" << level.toStdString() << "] "; + std::cout << message.toStdString() << std::endl; +} diff --git a/plugins/cordova-plugin-console/src/ubuntu/console.h b/plugins/cordova-plugin-console/src/ubuntu/console.h new file mode 100644 index 0000000..3f3d163 --- /dev/null +++ b/plugins/cordova-plugin-console/src/ubuntu/console.h @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#ifndef CONSOLE_H_FDSVCXGFRS +#define CONSOLE_H_FDSVCXGFRS + +#include + +#include + +class Console : public CPlugin { + Q_OBJECT +public: + explicit Console(Cordova *cordova); + + virtual const QString fullName() override { + return Console::fullID(); + } + + virtual const QString shortName() override { + return "Console"; + } + + static const QString fullID() { + return "Console"; + } + +public slots: + void logLevel(int scId, int ecId, QString level, QString message); +}; + +#endif diff --git a/plugins/cordova-plugin-console/src/wp/DebugConsole.cs b/plugins/cordova-plugin-console/src/wp/DebugConsole.cs new file mode 100644 index 0000000..9bb5476 --- /dev/null +++ b/plugins/cordova-plugin-console/src/wp/DebugConsole.cs @@ -0,0 +1,47 @@ +/* + 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. +*/ + +using System; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Shapes; +using System.Diagnostics; + +namespace WPCordovaClassLib.Cordova.Commands +{ + public class DebugConsole : BaseCommand + { + public void logLevel(string options) + { + string[] args = JSON.JsonHelper.Deserialize(options); + string level = args[0]; + string msg = args[1]; + + if (level.Equals("LOG")) + { + Debug.WriteLine(msg); + } + else + { + Debug.WriteLine(level + ": " + msg); + } + } + } +} diff --git a/plugins/cordova-plugin-console/tests/plugin.xml b/plugins/cordova-plugin-console/tests/plugin.xml new file mode 100644 index 0000000..9e88136 --- /dev/null +++ b/plugins/cordova-plugin-console/tests/plugin.xml @@ -0,0 +1,31 @@ + + + + + Cordova Console Plugin Tests + Apache 2.0 + + + + diff --git a/plugins/cordova-plugin-console/tests/tests.js b/plugins/cordova-plugin-console/tests/tests.js new file mode 100644 index 0000000..74765d9 --- /dev/null +++ b/plugins/cordova-plugin-console/tests/tests.js @@ -0,0 +1,43 @@ +/* + * + * 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. + * +*/ + +/* jshint jasmine: true */ + +exports.defineAutoTests = function () { + describe("Console", function () { + it("console.spec.1 should exist", function() { + expect(window.console).toBeDefined(); + }); + + it("console.spec.2 has required methods log|warn|error", function(){ + expect(window.console.log).toBeDefined(); + expect(typeof window.console.log).toBe('function'); + + expect(window.console.warn).toBeDefined(); + expect(typeof window.console.warn).toBe('function'); + + expect(window.console.error).toBeDefined(); + expect(typeof window.console.error).toBe('function'); + }); + }); +}; + +exports.defineManualTests = function (contentEl, createActionButton) {}; diff --git a/plugins/cordova-plugin-console/www/console-via-logger.js b/plugins/cordova-plugin-console/www/console-via-logger.js new file mode 100644 index 0000000..ffee326 --- /dev/null +++ b/plugins/cordova-plugin-console/www/console-via-logger.js @@ -0,0 +1,186 @@ +/* + * + * 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. + * +*/ + +//------------------------------------------------------------------------------ + +var logger = require("./logger"); + +//------------------------------------------------------------------------------ +// object that we're exporting +//------------------------------------------------------------------------------ +var console = module.exports; + +//------------------------------------------------------------------------------ +// copy of the original console object +//------------------------------------------------------------------------------ +var WinConsole = window.console; + +//------------------------------------------------------------------------------ +// whether to use the logger +//------------------------------------------------------------------------------ +var UseLogger = false; + +//------------------------------------------------------------------------------ +// Timers +//------------------------------------------------------------------------------ +var Timers = {}; + +//------------------------------------------------------------------------------ +// used for unimplemented methods +//------------------------------------------------------------------------------ +function noop() {} + +//------------------------------------------------------------------------------ +// used for unimplemented methods +//------------------------------------------------------------------------------ +console.useLogger = function (value) { + if (arguments.length) UseLogger = !!value; + + if (UseLogger) { + if (logger.useConsole()) { + throw new Error("console and logger are too intertwingly"); + } + } + + return UseLogger; +}; + +//------------------------------------------------------------------------------ +console.log = function() { + if (logger.useConsole()) return; + logger.log.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.error = function() { + if (logger.useConsole()) return; + logger.error.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.warn = function() { + if (logger.useConsole()) return; + logger.warn.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.info = function() { + if (logger.useConsole()) return; + logger.info.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.debug = function() { + if (logger.useConsole()) return; + logger.debug.apply(logger, [].slice.call(arguments)); +}; + +//------------------------------------------------------------------------------ +console.assert = function(expression) { + if (expression) return; + + var message = logger.format.apply(logger.format, [].slice.call(arguments, 1)); + console.log("ASSERT: " + message); +}; + +//------------------------------------------------------------------------------ +console.clear = function() {}; + +//------------------------------------------------------------------------------ +console.dir = function(object) { + console.log("%o", object); +}; + +//------------------------------------------------------------------------------ +console.dirxml = function(node) { + console.log(node.innerHTML); +}; + +//------------------------------------------------------------------------------ +console.trace = noop; + +//------------------------------------------------------------------------------ +console.group = console.log; + +//------------------------------------------------------------------------------ +console.groupCollapsed = console.log; + +//------------------------------------------------------------------------------ +console.groupEnd = noop; + +//------------------------------------------------------------------------------ +console.time = function(name) { + Timers[name] = new Date().valueOf(); +}; + +//------------------------------------------------------------------------------ +console.timeEnd = function(name) { + var timeStart = Timers[name]; + if (!timeStart) { + console.warn("unknown timer: " + name); + return; + } + + var timeElapsed = new Date().valueOf() - timeStart; + console.log(name + ": " + timeElapsed + "ms"); +}; + +//------------------------------------------------------------------------------ +console.timeStamp = noop; + +//------------------------------------------------------------------------------ +console.profile = noop; + +//------------------------------------------------------------------------------ +console.profileEnd = noop; + +//------------------------------------------------------------------------------ +console.count = noop; + +//------------------------------------------------------------------------------ +console.exception = console.log; + +//------------------------------------------------------------------------------ +console.table = function(data, columns) { + console.log("%o", data); +}; + +//------------------------------------------------------------------------------ +// return a new function that calls both functions passed as args +//------------------------------------------------------------------------------ +function wrappedOrigCall(orgFunc, newFunc) { + return function() { + var args = [].slice.call(arguments); + try { orgFunc.apply(WinConsole, args); } catch (e) {} + try { newFunc.apply(console, args); } catch (e) {} + }; +} + +//------------------------------------------------------------------------------ +// For every function that exists in the original console object, that +// also exists in the new console object, wrap the new console method +// with one that calls both +//------------------------------------------------------------------------------ +for (var key in console) { + if (typeof WinConsole[key] == "function") { + console[key] = wrappedOrigCall(WinConsole[key], console[key]); + } +} diff --git a/plugins/cordova-plugin-console/www/logger.js b/plugins/cordova-plugin-console/www/logger.js new file mode 100644 index 0000000..430d887 --- /dev/null +++ b/plugins/cordova-plugin-console/www/logger.js @@ -0,0 +1,354 @@ +/* + * + * 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. + * +*/ + +//------------------------------------------------------------------------------ +// The logger module exports the following properties/functions: +// +// LOG - constant for the level LOG +// ERROR - constant for the level ERROR +// WARN - constant for the level WARN +// INFO - constant for the level INFO +// DEBUG - constant for the level DEBUG +// logLevel() - returns current log level +// logLevel(value) - sets and returns a new log level +// useConsole() - returns whether logger is using console +// useConsole(value) - sets and returns whether logger is using console +// log(message,...) - logs a message at level LOG +// error(message,...) - logs a message at level ERROR +// warn(message,...) - logs a message at level WARN +// info(message,...) - logs a message at level INFO +// debug(message,...) - logs a message at level DEBUG +// logLevel(level,message,...) - logs a message specified level +// +//------------------------------------------------------------------------------ + +var logger = exports; + +var exec = require('cordova/exec'); + +var UseConsole = false; +var UseLogger = true; +var Queued = []; +var DeviceReady = false; +var CurrentLevel; + +var originalConsole = console; + +/** + * Logging levels + */ + +var Levels = [ + "LOG", + "ERROR", + "WARN", + "INFO", + "DEBUG" +]; + +/* + * add the logging levels to the logger object and + * to a separate levelsMap object for testing + */ + +var LevelsMap = {}; +for (var i=0; i 0){ + formatArgs.unshift(fmtString); // add formatString + } + + var message = logger.format.apply(logger.format, formatArgs); + + if (LevelsMap[level] === null) { + throw new Error("invalid logging level: " + level); + } + + if (LevelsMap[level] > CurrentLevel) return; + + // queue the message if not yet at deviceready + if (!DeviceReady && !UseConsole) { + Queued.push([level, message]); + return; + } + + // Log using the native logger if that is enabled + if (UseLogger) { + exec(null, null, "Console", "logLevel", [level, message]); + } + + // Log using the console if that is enabled + if (UseConsole) { + // make sure console is not using logger + if (console.useLogger()) { + throw new Error("console and logger are too intertwingly"); + } + + // log to the console + switch (level) { + case logger.LOG: originalConsole.log(message); break; + case logger.ERROR: originalConsole.log("ERROR: " + message); break; + case logger.WARN: originalConsole.log("WARN: " + message); break; + case logger.INFO: originalConsole.log("INFO: " + message); break; + case logger.DEBUG: originalConsole.log("DEBUG: " + message); break; + } + } +}; + + +/** + * Formats a string and arguments following it ala console.log() + * + * Any remaining arguments will be appended to the formatted string. + * + * for rationale, see FireBug's Console API: + * http://getfirebug.com/wiki/index.php/Console_API + */ +logger.format = function(formatString, args) { + return __format(arguments[0], [].slice.call(arguments,1)).join(' '); +}; + + +//------------------------------------------------------------------------------ +/** + * Formats a string and arguments following it ala vsprintf() + * + * format chars: + * %j - format arg as JSON + * %o - format arg as JSON + * %c - format arg as '' + * %% - replace with '%' + * any other char following % will format it's + * arg via toString(). + * + * Returns an array containing the formatted string and any remaining + * arguments. + */ +function __format(formatString, args) { + if (formatString === null || formatString === undefined) return [""]; + if (arguments.length == 1) return [formatString.toString()]; + + if (typeof formatString != "string") + formatString = formatString.toString(); + + var pattern = /(.*?)%(.)(.*)/; + var rest = formatString; + var result = []; + + while (args.length) { + var match = pattern.exec(rest); + if (!match) break; + + var arg = args.shift(); + rest = match[3]; + result.push(match[1]); + + if (match[2] == '%') { + result.push('%'); + args.unshift(arg); + continue; + } + + result.push(__formatted(arg, match[2])); + } + + result.push(rest); + + var remainingArgs = [].slice.call(args); + remainingArgs.unshift(result.join('')); + return remainingArgs; +} + +function __formatted(object, formatChar) { + + try { + switch(formatChar) { + case 'j': + case 'o': return JSON.stringify(object); + case 'c': return ''; + } + } + catch (e) { + return "error JSON.stringify()ing argument: " + e; + } + + if ((object === null) || (object === undefined)) { + return Object.prototype.toString.call(object); + } + + return object.toString(); +} + + +//------------------------------------------------------------------------------ +// when deviceready fires, log queued messages +logger.__onDeviceReady = function() { + if (DeviceReady) return; + + DeviceReady = true; + + for (var i=0; i - -# cordova-plugin-device-orientation - - -This plugin provides access to the device's compass. The compass is a sensor -that detects the direction or heading that the device is pointed, typically -from the top of the device. It measures the heading in degrees from 0 to -359.99, where 0 is north. - -Access is via a global `navigator.compass` object. - -Although the object is attached to the global scoped `navigator`, it is not available until after the `deviceready` event. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%20Orientation%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) - -## Installation - - cordova plugin add cordova-plugin-device-orientation - -## Supported Platforms - -- Amazon Fire OS -- Android -- BlackBerry 10 -- Browser -- Firefox OS -- iOS -- Tizen -- Windows Phone 7 and 8 (if available in hardware) -- Windows 8 - -## Methods - -- navigator.compass.getCurrentHeading -- navigator.compass.watchHeading -- navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Get the current compass heading. The compass heading is returned via a `CompassHeading` -object using the `compassSuccess` callback function. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - -### Example - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - -## navigator.compass.watchHeading - -Gets the device's current heading at a regular interval. Each time the heading -is retrieved, the `headingSuccess` callback function is executed. - -The returned watch ID references the compass watch interval. The watch -ID can be used with `navigator.compass.clearWatch` to stop watching the navigator.compass. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - -`compassOptions` may contain the following keys: - -- __frequency__: How often to retrieve the compass heading in milliseconds. _(Number)_ (Default: 100) -- __filter__: The change in degrees required to initiate a watchHeading success callback. When this value is set, __frequency__ is ignored. _(Number)_ - -### Example - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Browser Quirks - -Values for current heading are randomly generated in order to simulate the compass. - -### iOS Quirks - -Only one `watchHeading` can be in effect at one time in iOS. If a -`watchHeading` uses a filter, calling `getCurrentHeading` or -`watchHeading` uses the existing filter value to specify heading -changes. Watching heading changes with a filter is more efficient than -with time intervals. - -### Amazon Fire OS Quirks - -- `filter` is not supported. - -### Android Quirks - -- No support for `filter`. - -### Firefox OS Quirks - -- No support for `filter`. - -### Tizen Quirks - -- No support for `filter`. - -### Windows Phone 7 and 8 Quirks - -- No support for `filter`. - -## navigator.compass.clearWatch - -Stop watching the compass referenced by the watch ID parameter. - - navigator.compass.clearWatch(watchID); - -- __watchID__: The ID returned by `navigator.compass.watchHeading`. - -### Example - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - -## CompassHeading - -A `CompassHeading` object is returned to the `compassSuccess` callback function. - -### Properties - -- __magneticHeading__: The heading in degrees from 0-359.99 at a single moment in time. _(Number)_ - -- __trueHeading__: The heading relative to the geographic North Pole in degrees 0-359.99 at a single moment in time. A negative value indicates that the true heading can't be determined. _(Number)_ - -- __headingAccuracy__: The deviation in degrees between the reported heading and the true heading. _(Number)_ - -- __timestamp__: The time at which this heading was determined. _(DOMTimeStamp)_ - - -### Amazon Fire OS Quirks - -- `trueHeading` is not supported, but reports the same value as `magneticHeading` - -- `headingAccuracy` is always 0 because there is no difference between the `magneticHeading` and `trueHeading` - -### Android Quirks - -- The `trueHeading` property is not supported, but reports the same value as `magneticHeading`. - -- The `headingAccuracy` property is always 0 because there is no difference between the `magneticHeading` and `trueHeading`. - -### Firefox OS Quirks - -- The `trueHeading` property is not supported, but reports the same value as `magneticHeading`. - -- The `headingAccuracy` property is always 0 because there is no difference between the `magneticHeading` and `trueHeading`. - -### iOS Quirks - -- The `trueHeading` property is only returned for location services enabled via `navigator.geolocation.watchLocation()`. - -- For iOS 4 devices and above, heading factors in the device's current orientation, and does not reference its absolute position, for apps that supports that orientation. - -## CompassError - -A `CompassError` object is returned to the `compassError` callback function when an error occurs. - -### Properties - -- __code__: One of the predefined error codes listed below. - -### Constants - -- `CompassError.COMPASS_INTERNAL_ERR` -- `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/RELEASENOTES.md b/plugins/cordova-plugin-device-orientation/RELEASENOTES.md deleted file mode 100644 index 9320954..0000000 --- a/plugins/cordova-plugin-device-orientation/RELEASENOTES.md +++ /dev/null @@ -1,118 +0,0 @@ - -# Release Notes - -### 1.0.2 (Nov 18, 2015) -* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest -* [CB-4596](https://issues.apache.org/jira/browse/CB-4596) Fix `timestamp` to be `DOMTimeStamp` across the board -* Fixing contribute link. -* [CB-9426](https://issues.apache.org/jira/browse/CB-9426) Fix exception when using device orientation plugin on **browser** platform. - -### 1.0.1 (Jun 17, 2015) -* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-device-orientation documentation translation: cordova-plugin-device-orientation -* fix npm md issue -* Remove console log message from test - -### 1.0.0 (Apr 15, 2015) -* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump -* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) updated windows and tizen specific references of old id to new id -* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name -* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id -* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme -* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of initWebView method -* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of deprecated headers -* force async callbacks -* Updated plugin to be 'windows' instead of 'windows8' -* [CB-8614](https://issues.apache.org/jira/browse/CB-8614) Fixed getCurrentHeading and watchHeading on windows platform -* [CB-8563](https://issues.apache.org/jira/browse/CB-8563) Integrate TravisCI -* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-device-orientation documentation translation: cordova-plugin-device-orientation -* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file -* [CB-8458](https://issues.apache.org/jira/browse/CB-8458) Fixes false failure of test, when compass hardware is not available - -### 0.3.11 (Feb 04, 2015) -* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension - -### 0.3.10 (Dec 02, 2014) -* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs -* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-device-orientation documentation translation: cordova-plugin-device-orientation -* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin - -### 0.3.9 (Sep 17, 2014) -* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-device-orientation documentation translation: cordova-plugin-device-orientation -* Fixed problem with watchCompass if pressed twice -* [CB-7086](https://issues.apache.org/jira/browse/CB-7086) Renamed dir, added nested plugin.xml -* added documentation for manual tests -* Fixed problem with watchCompass if pressed twice -* [CB-7086](https://issues.apache.org/jira/browse/CB-7086) Renamed dir, added nested plugin.xml -* added documentation for manual tests -* Updated docs for browser -* Add support for the browser -* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-device-orientation documentation translation -* [CB-6960](https://issues.apache.org/jira/browse/CB-6960) Added manual tests -* [CB-6960](https://issues.apache.org/jira/browse/CB-6960) Port compass tests to plugin-test-framework - -### 0.3.8 (Aug 06, 2014) -* **FFOS** update compass.js -* [CB-7187](https://issues.apache.org/jira/browse/CB-7187) ios: Add explicit dependency on CoreLocation.framework -* [CB-7187](https://issues.apache.org/jira/browse/CB-7187) Delete unused #import of CDVShared.h - -### 0.3.7 (Jun 05, 2014) -* [CB-6799](https://issues.apache.org/jira/browse/CB-6799) Add license -* windows8. makes getHeading callback spec compliant -* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md - -### 0.3.6 (Apr 17, 2014) -* [CB-6381](https://issues.apache.org/jira/browse/CB-6381): [WP8] unexpected error object -* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy -* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers -* [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code -* Add NOTICE file - -### 0.3.5 (Feb 05, 2014) -* [ubuntu] request sensors permission -* [ubuntu] add missing files -* Add support for Tizen. -* FFOS info added - -### 0.3.4 (Jan 02, 2014) -* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Compass plugin - -### 0.3.3 (Dec 4, 2013) -* add ubuntu platform -* 1. Added amazon-fireos platform. 2. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'. - -### 0.3.2 (Oct 28, 2013) -* orientation plugin -* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for device orientation plugin -* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. - -### 0.3.1 (Sept 25, 2013) -* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming id -* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming core in CompassProxy -* [CB-4900](https://issues.apache.org/jira/browse/CB-4900) Windows 8 Compass plugin have extra define breaks plugin loading -* [windows8] commandProxy was moved -* Rename CHANGELOG.md -> RELEASENOTES.md -* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. - -### 0.3.0 (Sept 5, 2013) -* [CB-3687](https://issues.apache.org/jira/browse/CB-3687) Added blackberry10 support diff --git a/plugins/cordova-plugin-device-orientation/doc/de/README.md b/plugins/cordova-plugin-device-orientation/doc/de/README.md deleted file mode 100644 index 8658879..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/de/README.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -Dieses Plugin ermöglicht den Zugriff auf das Gerät Kompass. Der Kompass ist ein Sensor, der erkennt die Richtung oder Position, dass das Gerät in der Regel von der Oberseite des Geräts gezeigt wird. Er misst die Überschrift im Grad von 0 bis 359.99, 0 wo Norden ist. - -Der Zugang ist über eine globale `navigator.compass`-Objekt. - -Obwohl das Objekt mit der globalen Gültigkeitsbereich `navigator` verbunden ist, steht es nicht bis nach dem `Deviceready`-Ereignis. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## Installation - - cordova plugin add cordova-plugin-device-orientation - - -## Unterstützte Plattformen - - * Amazon Fire OS - * Android - * BlackBerry 10 - * Browser - * Firefox OS - * iOS - * Tizen - * Windows Phone 7 und 8 (falls verfügbar in Hardware) - * Windows 8 - -## Methoden - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Erhalten Sie aktuelle Kompassrichtung. Die Kompassrichtung wird über ein `CompassHeading`-Objekt mithilfe der `compassSuccess`-Callback-Funktion zurückgegeben. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### Beispiel - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Ruft das Gerät an den aktuellen Kurs in regelmäßigen Abständen. Jedes Mal, wenn die Überschrift abgerufen wird, wird die Callback-Funktion `headingSuccess` ausgeführt. - -Die zurückgegebenen Watch-ID verweist das Kompass-Uhr-Intervall. Die Uhr ID mit `navigator.compass.clearWatch` einsetzbar, um gerade die navigator.compass zu stoppen. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` enthalten die folgenden Schlüssel: - - * **Häufigkeit**: wie oft die Kompassrichtung in Millisekunden abrufen. *(Anzahl)* (Default: 100) - * **Filter**: die Veränderung der Grad benötigt, um einen WatchHeading Erfolg Rückruf initiiert. Wenn dieser Wert festgelegt ist, wird die **Häufigkeit** ignoriert. *(Anzahl)* - -### Beispiel - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Browser-Eigenheiten - -Werte für aktuelle Überschrift werden nach dem Zufallsprinzip generiert, um den Kompass zu simulieren. - -### iOS Macken - -Nur ein `watchHeading` kann in der Tat auf einmal in iOS sein. Wenn ein `watchHeading` einen Filter verwendet, wird durch Aufrufen von `getCurrentHeading` oder `watchHeading` den vorhandenen Filterwert Überschrift Änderungen angegeben. Überschrift Veränderungen beobachten, mit einem Filter ist effizienter als mit Zeitintervallen. - -### Amazon Fire OS Macken - - * `filter`wird nicht unterstützt. - -### Android Eigenarten - - * Keine Unterstützung für`filter`. - -### Firefox OS Macken - - * Keine Unterstützung für`filter`. - -### Tizen Macken - - * Keine Unterstützung für`filter`. - -### Windows Phone 7 und 8 Eigenarten - - * Keine Unterstützung für`filter`. - -## navigator.compass.clearWatch - -Stoppen Sie, beobachten den Kompass auf der Watch-ID-Parameter verweist. - - navigator.compass.clearWatch(watchID); - - - * **WatchID**: die ID von zurückgegeben`navigator.compass.watchHeading`. - -### Beispiel - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -Ein `CompassHeading`-Objekt wird an die `compassSuccess`-Callback-Funktion zurückgegeben. - -### Eigenschaften - - * **MagneticHeading**: die Überschrift in Grad von 0-359.99 zu einem einzigen Zeitpunkt. *(Anzahl)* - - * **TrueHeading**: die Überschrift im Verhältnis zu den geografischen Nordpol in Grad 0-359.99 zu einem einzigen Zeitpunkt. Ein negativer Wert bedeutet, dass die wahre Überschrift nicht bestimmt werden kann. *(Anzahl)* - - * **HeadingAccuracy**: die Abweichung in Grad zwischen der gemeldeten Überschrift und die wahre Richtung. *(Anzahl)* - - * **Timestamp**: die Zeit, an dem dieser Rubrik bestimmt war. *(Millisekunden)* - -### Amazon Fire OS Macken - - * `trueHeading`wird nicht unterstützt, aber meldet den gleichen Wert wie`magneticHeading` - - * `headingAccuracy`ist immer 0 da es keinen Unterschied zwischen gibt der `magneticHeading` und`trueHeading` - -### Android Eigenarten - - * Die `trueHeading` -Eigenschaft wird nicht unterstützt, jedoch meldet den gleichen Wert wie`magneticHeading`. - - * Die `headingAccuracy` -Eigenschaft ist immer 0 da es keinen Unterschied zwischen gibt der `magneticHeading` und`trueHeading`. - -### Firefox OS Macken - - * Die `trueHeading` -Eigenschaft wird nicht unterstützt, jedoch meldet den gleichen Wert wie`magneticHeading`. - - * Die `headingAccuracy` -Eigenschaft ist immer 0 da es keinen Unterschied zwischen gibt der `magneticHeading` und`trueHeading`. - -### iOS Macken - - * Die `trueHeading` -Eigenschaft nur für Ortungsdienste aktiviert über zurückgegeben`navigator.geolocation.watchLocation()`. - - * Für iOS 4 Geräte oben Rubrik Faktoren in das Gerät aktuelle Ausrichtung und verweist nicht auf die absolute Position für Anwendungen, die diese Ausrichtung unterstützt. - -## CompassError - -Ein `CompassError`-Objekt wird an die `compassError`-Callback-Funktion zurückgegeben, wenn ein Fehler auftritt. - -### Eigenschaften - - * **Code**: einer der vordefinierten Fehlercodes aufgeführt. - -### Konstanten - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/de/index.md b/plugins/cordova-plugin-device-orientation/doc/de/index.md deleted file mode 100644 index b16d916..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/de/index.md +++ /dev/null @@ -1,204 +0,0 @@ - - -# cordova-plugin-device-orientation - -Dieses Plugin ermöglicht den Zugriff auf das Gerät Kompass. Der Kompass ist ein Sensor, der erkennt die Richtung oder Position, dass das Gerät in der Regel von der Oberseite des Geräts gezeigt wird. Er misst die Überschrift im Grad von 0 bis 359.99, 0 wo Norden ist. - -Der Zugang ist über eine globale `navigator.compass`-Objekt. - -Obwohl das Objekt mit der globalen Gültigkeitsbereich `navigator` verbunden ist, steht es nicht bis nach dem `Deviceready`-Ereignis. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## Installation - - cordova plugin add cordova-plugin-device-orientation - - -## Unterstützte Plattformen - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Browser -* Firefox OS -* iOS -* Tizen -* Windows Phone 7 und 8 (falls verfügbar in Hardware) -* Windows 8 - -## Methoden - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Erhalten Sie aktuelle Kompassrichtung. Die Kompassrichtung wird über ein `CompassHeading`-Objekt mithilfe der `compassSuccess`-Callback-Funktion zurückgegeben. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### Beispiel - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Ruft das Gerät an den aktuellen Kurs in regelmäßigen Abständen. Jedes Mal, wenn die Überschrift abgerufen wird, wird die Callback-Funktion `headingSuccess` ausgeführt. - -Die zurückgegebenen Watch-ID verweist das Kompass-Uhr-Intervall. Die Uhr ID mit `navigator.compass.clearWatch` einsetzbar, um gerade die navigator.compass zu stoppen. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` enthalten die folgenden Schlüssel: - -* **Häufigkeit**: wie oft die Kompassrichtung in Millisekunden abrufen. *(Anzahl)* (Default: 100) -* **Filter**: die Veränderung der Grad benötigt, um einen WatchHeading Erfolg Rückruf initiiert. Wenn dieser Wert festgelegt ist, wird die **Häufigkeit** ignoriert. *(Anzahl)* - -### Beispiel - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Browser-Eigenheiten - -Werte für aktuelle Überschrift werden nach dem Zufallsprinzip generiert, um den Kompass zu simulieren. - -### iOS Macken - -Nur ein `watchHeading` kann in der Tat auf einmal in iOS sein. Wenn ein `watchHeading` einen Filter verwendet, wird durch Aufrufen von `getCurrentHeading` oder `watchHeading` den vorhandenen Filterwert Überschrift Änderungen angegeben. Überschrift Veränderungen beobachten, mit einem Filter ist effizienter als mit Zeitintervallen. - -### Amazon Fire OS Macken - -* `filter`wird nicht unterstützt. - -### Android Eigenarten - -* Keine Unterstützung für`filter`. - -### Firefox OS Macken - -* Keine Unterstützung für`filter`. - -### Tizen Macken - -* Keine Unterstützung für`filter`. - -### Windows Phone 7 und 8 Eigenarten - -* Keine Unterstützung für`filter`. - -## navigator.compass.clearWatch - -Stoppen Sie, beobachten den Kompass auf der Watch-ID-Parameter verweist. - - navigator.compass.clearWatch(watchID); - - -* **WatchID**: die ID von zurückgegeben`navigator.compass.watchHeading`. - -### Beispiel - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -Ein `CompassHeading`-Objekt wird an die `compassSuccess`-Callback-Funktion zurückgegeben. - -### Eigenschaften - -* **MagneticHeading**: die Überschrift in Grad von 0-359.99 zu einem einzigen Zeitpunkt. *(Anzahl)* - -* **TrueHeading**: die Überschrift im Verhältnis zu den geografischen Nordpol in Grad 0-359.99 zu einem einzigen Zeitpunkt. Ein negativer Wert bedeutet, dass die wahre Überschrift nicht bestimmt werden kann. *(Anzahl)* - -* **HeadingAccuracy**: die Abweichung in Grad zwischen der gemeldeten Überschrift und die wahre Richtung. *(Anzahl)* - -* **Timestamp**: die Zeit, an dem dieser Rubrik bestimmt war. *(Millisekunden)* - -### Amazon Fire OS Macken - -* `trueHeading`wird nicht unterstützt, aber meldet den gleichen Wert wie`magneticHeading` - -* `headingAccuracy`ist immer 0 da es keinen Unterschied zwischen gibt der `magneticHeading` und`trueHeading` - -### Android Eigenarten - -* Die `trueHeading` -Eigenschaft wird nicht unterstützt, jedoch meldet den gleichen Wert wie`magneticHeading`. - -* Die `headingAccuracy` -Eigenschaft ist immer 0 da es keinen Unterschied zwischen gibt der `magneticHeading` und`trueHeading`. - -### Firefox OS Macken - -* Die `trueHeading` -Eigenschaft wird nicht unterstützt, jedoch meldet den gleichen Wert wie`magneticHeading`. - -* Die `headingAccuracy` -Eigenschaft ist immer 0 da es keinen Unterschied zwischen gibt der `magneticHeading` und`trueHeading`. - -### iOS Macken - -* Die `trueHeading` -Eigenschaft nur für Ortungsdienste aktiviert über zurückgegeben`navigator.geolocation.watchLocation()`. - -* Für iOS 4 Geräte oben Rubrik Faktoren in das Gerät aktuelle Ausrichtung und verweist nicht auf die absolute Position für Anwendungen, die diese Ausrichtung unterstützt. - -## CompassError - -Ein `CompassError`-Objekt wird an die `compassError`-Callback-Funktion zurückgegeben, wenn ein Fehler auftritt. - -### Eigenschaften - -* **Code**: einer der vordefinierten Fehlercodes aufgeführt. - -### Konstanten - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/es/README.md b/plugins/cordova-plugin-device-orientation/doc/es/README.md deleted file mode 100644 index 72bd63a..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/es/README.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -Este plugin proporciona acceso al compás del dispositivo. La brújula es un sensor que detecta la dirección o rumbo que el dispositivo está apuntado, normalmente desde la parte superior del dispositivo. Mide el rumbo en grados de 0 a 359.99, donde 0 es el norte. - -El acceso es por un global `navigator.compass` objeto. - -Aunque el objeto está unido al ámbito global `navigator` , no estará disponible hasta después de la `deviceready` evento. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## Instalación - - cordova plugin add cordova-plugin-device-orientation - - -## Plataformas soportadas - - * Amazon fire OS - * Android - * BlackBerry 10 - * Explorador - * Firefox OS - * iOS - * Tizen - * Windows Phone 7 y 8 (si está disponible en el hardware) - * Windows 8 - -## Métodos - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Conseguir el actual rumbo de la brújula. El rumbo de la brújula es devuelto vía un `CompassHeading` objeto usando la `compassSuccess` función de callback. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### Ejemplo - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Obtiene el título actual del dispositivo a intervalos regulares. Cada vez que se recupera el título, el `headingSuccess` se ejecuta la función callback. - -El identificador devuelto reloj referencias el intervalo reloj brújula. El reloj ID puede utilizarse con `navigator.compass.clearWatch` para dejar de ver la navigator.compass. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions`puede contener las siguientes claves: - - * **frecuencia**: frecuencia con la que recuperar el rumbo de la brújula en milisegundos. *(Número)* (Por defecto: 100) - * **filtro**: el cambio de grados necesarios para iniciar una devolución de llamada de éxito watchHeading. Cuando se establece este valor, **frecuencia** es ignorado. *(Número)* - -### Ejemplo - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Navegador rarezas - -Los valores de partida actual son generados al azar para simular la brújula. - -### iOS rarezas - -Solamente un `watchHeading` puede ser en efecto a la vez en iOS. Si un `watchHeading` utiliza un filtro, llamando a `getCurrentHeading` o `watchHeading` utiliza el valor existente del filtro para especificar los cambios de rumbo. Observando los cambios de rumbo con un filtro es más eficiente que con intervalos de tiempo. - -### Amazon fuego OS rarezas - - * `filter`No se admite. - -### Rarezas Android - - * No hay soporte para`filter`. - -### Firefox OS rarezas - - * No hay soporte para`filter`. - -### Rarezas Tizen - - * No hay soporte para`filter`. - -### Windows Phone 7 y 8 rarezas - - * No hay soporte para`filter`. - -## navigator.compass.clearWatch - -Deja de mirar la brújula al que hace referencia el parámetro ID de reloj. - - navigator.compass.clearWatch(watchID); - - - * **watchID**: el identificador devuelto por`navigator.compass.watchHeading`. - -### Ejemplo - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -A `CompassHeading` objeto es devuelto a la `compassSuccess` función de callback. - -### Propiedades - - * **magneticHeading**: el rumbo en grados de 0-359.99 en un solo momento. *(Número)* - - * **trueHeading**: el título en relación con el polo norte geográfico en grados 0-359.99 en un solo momento. Un valor negativo indica que no se puede determinar el rumbo verdadero. *(Número)* - - * **headingAccuracy**: la desviación en grados entre el rumbo divulgado y el rumbo verdadero. *(Número)* - - * **timestamp**: el momento en el cual se determinó esta partida. *(milisegundos)* - -### Amazon fuego OS rarezas - - * `trueHeading`No es compatible, pero el mismo valor que los informes`magneticHeading` - - * `headingAccuracy`es siempre 0 porque no hay ninguna diferencia entre el `magneticHeading` y`trueHeading` - -### Rarezas Android - - * El `trueHeading` propiedad no es compatible, pero el mismo valor que los informes`magneticHeading`. - - * El `headingAccuracy` propiedad es siempre 0 porque no hay ninguna diferencia entre el `magneticHeading` y`trueHeading`. - -### Firefox OS rarezas - - * El `trueHeading` propiedad no es compatible, pero el mismo valor que los informes`magneticHeading`. - - * El `headingAccuracy` propiedad es siempre 0 porque no hay ninguna diferencia entre el `magneticHeading` y`trueHeading`. - -### iOS rarezas - - * El `trueHeading` propiedad es devuelto sólo para servicios de localización habilitados mediante`navigator.geolocation.watchLocation()`. - - * Para los dispositivos iOS 4 arriba, rumbo factores en la orientación actual del dispositivo y no hace referencia a su posición absoluta, para aplicaciones que apoya esa orientación. - -## CompassError - -A `CompassError` objeto es devuelto a la `compassError` función de devolución de llamada cuando se produce un error. - -### Propiedades - - * **code**: uno de los códigos de error predefinido enumerados a continuación. - -### Constantes - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/es/index.md b/plugins/cordova-plugin-device-orientation/doc/es/index.md deleted file mode 100644 index fc889af..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/es/index.md +++ /dev/null @@ -1,191 +0,0 @@ - - -# cordova-plugin-device-orientation - -Este plugin proporciona acceso al compás del dispositivo. La brújula es un sensor que detecta la dirección o rumbo que el dispositivo está apuntado, normalmente desde la parte superior del dispositivo. Mide el rumbo en grados de 0 a 359.99, donde 0 es el norte. - -El acceso es por un global `navigator.compass` objeto. - -Aunque el objeto está unido al ámbito global `navigator` , no estará disponible hasta después de la `deviceready` evento. - - document.addEventListener ("deviceready", onDeviceReady, false); - function onDeviceReady() {console.log(navigator.compass)}; - - -## Instalación - - Cordova plugin añade cordova-plugin-device-orientación - - -## Plataformas soportadas - -* Amazon fire OS -* Android -* BlackBerry 10 -* Explorador -* Firefox OS -* iOS -* Tizen -* Windows Phone 7 y 8 (si está disponible en el hardware) -* Windows 8 - -## Métodos - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Conseguir el actual rumbo de la brújula. El rumbo de la brújula es devuelto vía un `CompassHeading` objeto usando la `compassSuccess` función de callback. - - navigator.compass.getCurrentHeading (compassSuccess, compassError); - - -### Ejemplo - - function onSuccess(heading) {alert (' dirige: ' + heading.magneticHeading);}; - - function onError(error) {alert ('CompassError: "+ error.code);}; - - navigator.compass.getCurrentHeading (onSuccess, onError); - - -## navigator.compass.watchHeading - -Obtiene el título actual del dispositivo a intervalos regulares. Cada vez que se recupera el título, el `headingSuccess` se ejecuta la función callback. - -El identificador devuelto reloj referencias el intervalo reloj brújula. El reloj ID puede utilizarse con `navigator.compass.clearWatch` para dejar de ver la navigator.compass. - - var watchID = navigator.compass.watchHeading (compassSuccess, compassError, [compassOptions]); - - -`compassOptions`puede contener las siguientes claves: - -* **frecuencia**: frecuencia con la que recuperar el rumbo de la brújula en milisegundos. *(Número)* (Por defecto: 100) -* **filtro**: el cambio de grados necesarios para iniciar una devolución de llamada de éxito watchHeading. Cuando se establece este valor, **frecuencia** es ignorado. *(Número)* - -### Ejemplo - - function onSuccess(heading) {var elemento = document.getElementById('heading'); - element.innerHTML = ' Dirección: "+ heading.magneticHeading; - }; - - function onError(compassError) {alert (' error del compás: ' + compassError.code);}; - - var opciones = { - frequency: 3000 - }; Actualizar cada 3 segundos var watchID = navigator.compass.watchHeading (onSuccess, onError, opciones); - - -### Navegador rarezas - -Los valores de partida actual son generados al azar para simular la brújula. - -### iOS rarezas - -Solamente un `watchHeading` puede ser en efecto a la vez en iOS. Si un `watchHeading` utiliza un filtro, llamando a `getCurrentHeading` o `watchHeading` utiliza el valor existente del filtro para especificar los cambios de rumbo. Observando los cambios de rumbo con un filtro es más eficiente que con intervalos de tiempo. - -### Amazon fuego OS rarezas - -* `filter`No se admite. - -### Rarezas Android - -* No hay soporte para`filter`. - -### Firefox OS rarezas - -* No hay soporte para`filter`. - -### Rarezas Tizen - -* No hay soporte para`filter`. - -### Windows Phone 7 y 8 rarezas - -* No hay soporte para`filter`. - -## navigator.compass.clearWatch - -Deja de mirar la brújula al que hace referencia el parámetro ID de reloj. - - navigator.compass.clearWatch(watchID); - - -* **watchID**: el identificador devuelto por`navigator.compass.watchHeading`. - -### Ejemplo - - var watchID = navigator.compass.watchHeading (onSuccess, onError, opciones); - - ... adelante... navigator.compass.clearWatch(watchID); - - -## CompassHeading - -A `CompassHeading` objeto es devuelto a la `compassSuccess` función de callback. - -### Propiedades - -* **magneticHeading**: el rumbo en grados de 0-359.99 en un solo momento. *(Número)* - -* **trueHeading**: el título en relación con el polo norte geográfico en grados 0-359.99 en un solo momento. Un valor negativo indica que no se puede determinar el rumbo verdadero. *(Número)* - -* **headingAccuracy**: la desviación en grados entre el rumbo divulgado y el rumbo verdadero. *(Número)* - -* **timestamp**: el momento en el cual se determinó esta partida. *(milisegundos)* - -### Amazon fuego OS rarezas - -* `trueHeading`No es compatible, pero el mismo valor que los informes`magneticHeading` - -* `headingAccuracy`es siempre 0 porque no hay ninguna diferencia entre el `magneticHeading` y`trueHeading` - -### Rarezas Android - -* El `trueHeading` propiedad no es compatible, pero el mismo valor que los informes`magneticHeading`. - -* El `headingAccuracy` propiedad es siempre 0 porque no hay ninguna diferencia entre el `magneticHeading` y`trueHeading`. - -### Firefox OS rarezas - -* El `trueHeading` propiedad no es compatible, pero el mismo valor que los informes`magneticHeading`. - -* El `headingAccuracy` propiedad es siempre 0 porque no hay ninguna diferencia entre el `magneticHeading` y`trueHeading`. - -### iOS rarezas - -* El `trueHeading` propiedad es devuelto sólo para servicios de localización habilitados mediante`navigator.geolocation.watchLocation()`. - -* Para los dispositivos iOS 4 arriba, rumbo factores en la orientación actual del dispositivo y no hace referencia a su posición absoluta, para aplicaciones que apoya esa orientación. - -## CompassError - -A `CompassError` objeto es devuelto a la `compassError` función de devolución de llamada cuando se produce un error. - -### Propiedades - -* **code**: uno de los códigos de error predefinido enumerados a continuación. - -### Constantes - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/fr/README.md b/plugins/cordova-plugin-device-orientation/doc/fr/README.md deleted file mode 100644 index 51d86ee..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/fr/README.md +++ /dev/null @@ -1,193 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -Ce plugin permet d'accéder à la boussole de l'appareil. La boussole est un capteur qui détecte la direction ou la position que l'appareil est pointé, généralement par le haut de l'appareil. Il mesure la position en degrés de 0 à 359.99, où 0 est vers le Nord. - -Accès se fait par un global `navigator.compass` objet. - -Bien que l'objet est attaché à la portée globale `navigator` , il n'est pas disponible jusqu'après la `deviceready` événement. - - document.addEventListener (« deviceready », onDeviceReady, false) ; - function onDeviceReady() {console.log(navigator.compass);} - - -## Installation - - cordova plugin add cordova-plugin-device-orientation - - -## Plates-formes supportées - - * Amazon Fire OS - * Android - * BlackBerry 10 - * Navigateur - * Firefox OS - * iOS - * Paciarelli - * Windows Phone 7 et 8 (s'il est disponible dans le matériel) - * Windows 8 - -## Méthodes - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Téléchargez la cours de la boussole. La boussole est renvoyé via un `CompassHeading` s'opposer à l'aide de la `compassSuccess` fonction de rappel. - - navigator.compass.getCurrentHeading (compassSuccess, compassError) ; - - -### Exemple - - function onSuccess(heading) {alert (' intitulé: "+ heading.magneticHeading);} ; - - function onError(error) {alert ('CompassError: ' + error.code);} ; - - navigator.compass.getCurrentHeading (onSuccess, onError) ; - - -## navigator.compass.watchHeading - -Obtient la position actuelle de l'appareil à intervalle régulier. Chaque fois que le titre est récupéré, la `headingSuccess` fonction de rappel est exécutée. - -Le code retourné montre fait référence à l'intervalle montre boussole. La montre ID peut être utilisé avec `navigator.compass.clearWatch` d'arrêter de regarder le navigator.compass. - - var watchID = navigator.compass.watchHeading (compassSuccess, compassError, [compassOptions]) ; - - -`compassOptions`peut contenir les clés suivantes : - - * **fréquence** : la fréquence de récupération de la boussole en millisecondes. *(Nombre)* (Par défaut : 100) - * **filtre**: le changement en degrés nécessaires pour lancer un rappel de succès watchHeading. Lorsque cette valeur est définie, la **fréquence** est ignoré. *(Nombre)* - -### Exemple - - function onSuccess(heading) {var element = document.getElementById('heading') ; - element.innerHTML = "intitulé:" + heading.magneticHeading ; - }; - - function onError(compassError) {alert (' erreur de boussole: "+ compassError.code);} ; - - options de var = { - frequency: 3000 - } ; Mise à jour chaque 3 secondes var watchID = navigator.compass.watchHeading (onSuccess, onError, options) ; - - -### Bizarreries navigateur - -Valeurs pour la rubrique actuelle sont générés au hasard afin de simuler la boussole. - -### Notes au sujet d'iOS - -Seul `watchHeading` peut être en effet à un moment donné dans l'iOS. Si un `watchHeading` utilise un filtre, appeler `getCurrentHeading` ou `watchHeading` utilise la valeur existante de filtre pour spécifier des changements de position. En regardant les changements de position avec un filtre est plus efficace qu'avec des intervalles de temps. - -### Amazon Fire OS Quirks - - * `filter`n'est pas pris en charge. - -### Quirks Android - - * Pas de support pour`filter`. - -### Firefox OS Quirks - - * Pas de support pour`filter`. - -### Bizarreries de paciarelli - - * Pas de support pour`filter`. - -### Notes au sujet de Windows Phone 7 et 8 - - * Pas de support pour`filter`. - -## navigator.compass.clearWatch - -Arrêter de regarder la boussole référencée par le paramètre ID de montre. - - navigator.compass.clearWatch(watchID) ; - - - * **watchID**: l'ID retourné par`navigator.compass.watchHeading`. - -### Exemple - - var watchID = navigator.compass.watchHeading (onSuccess, onError, options) ; - - ... plus tard... navigator.compass.clearWatch(watchID) ; - - -## CompassHeading - -A `CompassHeading` objet est retourné à la `compassSuccess` fonction de rappel. - -### Propriétés - - * **magneticHeading**: la position en degrés de 0-359,99 à un instant donné. *(Nombre)* - - * **trueHeading**: la position par rapport au pôle Nord géographique en degrés 0-359,99 à un instant donné. Une valeur négative indique que le cap vrai ne peut être déterminée. *(Nombre)* - - * **headingAccuracy**: la déviation en degrés entre la direction signalée et la véritable direction. *(Nombre)* - - * **horodatage**: l'heure à laquelle cette direction a été déterminée. *(millisecondes)* - -### Amazon Fire OS Quirks - - * `trueHeading`n'est pas pris en charge, mais la même valeur que les rapports`magneticHeading` - - * `headingAccuracy`est toujours 0 car il n'y a pas de différence entre la `magneticHeading` et`trueHeading` - -### Quirks Android - - * La `trueHeading` propriété n'est pas pris en charge, mais la même valeur que des rapports`magneticHeading`. - - * La `headingAccuracy` propriété est toujours 0 car il n'y a pas de différence entre la `magneticHeading` et`trueHeading`. - -### Firefox OS Quirks - - * La `trueHeading` propriété n'est pas pris en charge, mais la même valeur que des rapports`magneticHeading`. - - * La `headingAccuracy` propriété est toujours 0 car il n'y a pas de différence entre la `magneticHeading` et`trueHeading`. - -### Notes au sujet d'iOS - - * La `trueHeading` propriété est retournée uniquement pour les services de localisation activées via`navigator.geolocation.watchLocation()`. - - * Pour les appareils iOS 4 et au-dessus, rubrique facteurs dans l'orientation actuelle de l'appareil et ne fait pas référence à sa position absolue, pour les applications prenant en charge cette orientation. - -## CompassError - -A `CompassError` objet est retourné à la `compassError` fonction de rappel lorsqu'une erreur survient. - -### Propriétés - - * **code**: l'un des codes d'erreur prédéfinis énumérés ci-dessous. - -### Constantes - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/fr/index.md b/plugins/cordova-plugin-device-orientation/doc/fr/index.md deleted file mode 100644 index 4f48c77..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/fr/index.md +++ /dev/null @@ -1,191 +0,0 @@ - - -# cordova-plugin-device-orientation - -Ce plugin permet d'accéder à la boussole de l'appareil. La boussole est un capteur qui détecte la direction ou la position que l'appareil est pointé, généralement par le haut de l'appareil. Il mesure la position en degrés de 0 à 359.99, où 0 est vers le Nord. - -Accès se fait par un global `navigator.compass` objet. - -Bien que l'objet est attaché à la portée globale `navigator` , il n'est pas disponible jusqu'après la `deviceready` événement. - - document.addEventListener (« deviceready », onDeviceReady, false) ; - function onDeviceReady() {console.log(navigator.compass);} - - -## Installation - - Cordova plugin ajouter cordova-plugin-device-orientation - - -## Plates-formes prises en charge - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Navigateur -* Firefox OS -* iOS -* Paciarelli -* Windows Phone 7 et 8 (s'il est disponible dans le matériel) -* Windows 8 - -## Méthodes - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Téléchargez la cours de la boussole. La boussole est renvoyé via un `CompassHeading` s'opposer à l'aide de la `compassSuccess` fonction de rappel. - - navigator.compass.getCurrentHeading (compassSuccess, compassError) ; - - -### Exemple - - function onSuccess(heading) {alert (' intitulé: "+ heading.magneticHeading);} ; - - function onError(error) {alert ('CompassError: ' + error.code);} ; - - navigator.compass.getCurrentHeading (onSuccess, onError) ; - - -## navigator.compass.watchHeading - -Obtient la position actuelle de l'appareil à intervalle régulier. Chaque fois que le titre est récupéré, la `headingSuccess` fonction de rappel est exécutée. - -Le code retourné montre fait référence à l'intervalle montre boussole. La montre ID peut être utilisé avec `navigator.compass.clearWatch` d'arrêter de regarder le navigator.compass. - - var watchID = navigator.compass.watchHeading (compassSuccess, compassError, [compassOptions]) ; - - -`compassOptions`peut contenir les clés suivantes : - -* **fréquence** : la fréquence de récupération de la boussole en millisecondes. *(Nombre)* (Par défaut : 100) -* **filtre**: le changement en degrés nécessaires pour lancer un rappel de succès watchHeading. Lorsque cette valeur est définie, la **fréquence** est ignoré. *(Nombre)* - -### Exemple - - function onSuccess(heading) {var element = document.getElementById('heading') ; - element.innerHTML = "intitulé:" + heading.magneticHeading ; - }; - - function onError(compassError) {alert (' erreur de boussole: "+ compassError.code);} ; - - options de var = { - frequency: 3000 - } ; Mise à jour chaque 3 secondes var watchID = navigator.compass.watchHeading (onSuccess, onError, options) ; - - -### Bizarreries navigateur - -Valeurs pour la rubrique actuelle sont générés au hasard afin de simuler la boussole. - -### iOS Quirks - -Seul `watchHeading` peut être en effet à un moment donné dans l'iOS. Si un `watchHeading` utilise un filtre, appeler `getCurrentHeading` ou `watchHeading` utilise la valeur existante de filtre pour spécifier des changements de position. En regardant les changements de position avec un filtre est plus efficace qu'avec des intervalles de temps. - -### Amazon Fire OS Quirks - -* `filter`n'est pas pris en charge. - -### Quirks Android - -* Pas de support pour`filter`. - -### Firefox OS Quirks - -* Pas de support pour`filter`. - -### Bizarreries de paciarelli - -* Pas de support pour`filter`. - -### Windows Phone 7 et 8 Quirks - -* Pas de support pour`filter`. - -## navigator.compass.clearWatch - -Arrêter de regarder la boussole référencée par le paramètre ID de montre. - - navigator.compass.clearWatch(watchID) ; - - -* **watchID**: l'ID retourné par`navigator.compass.watchHeading`. - -### Exemple - - var watchID = navigator.compass.watchHeading (onSuccess, onError, options) ; - - ... plus tard... navigator.compass.clearWatch(watchID) ; - - -## CompassHeading - -A `CompassHeading` objet est retourné à la `compassSuccess` fonction de rappel. - -### Propriétés - -* **magneticHeading**: la position en degrés de 0-359,99 à un instant donné. *(Nombre)* - -* **trueHeading**: la position par rapport au pôle Nord géographique en degrés 0-359,99 à un instant donné. Une valeur négative indique que le cap vrai ne peut être déterminée. *(Nombre)* - -* **headingAccuracy**: la déviation en degrés entre la direction signalée et la véritable direction. *(Nombre)* - -* **horodatage**: l'heure à laquelle cette direction a été déterminée. *(millisecondes)* - -### Amazon Fire OS Quirks - -* `trueHeading`n'est pas pris en charge, mais la même valeur que les rapports`magneticHeading` - -* `headingAccuracy`est toujours 0 car il n'y a pas de différence entre la `magneticHeading` et`trueHeading` - -### Quirks Android - -* La `trueHeading` propriété n'est pas pris en charge, mais la même valeur que des rapports`magneticHeading`. - -* La `headingAccuracy` propriété est toujours 0 car il n'y a pas de différence entre la `magneticHeading` et`trueHeading`. - -### Firefox OS Quirks - -* La `trueHeading` propriété n'est pas pris en charge, mais la même valeur que des rapports`magneticHeading`. - -* La `headingAccuracy` propriété est toujours 0 car il n'y a pas de différence entre la `magneticHeading` et`trueHeading`. - -### iOS Quirks - -* La `trueHeading` propriété est retournée uniquement pour les services de localisation activées via`navigator.geolocation.watchLocation()`. - -* Pour les appareils iOS 4 et au-dessus, rubrique facteurs dans l'orientation actuelle de l'appareil et ne fait pas référence à sa position absolue, pour les applications prenant en charge cette orientation. - -## CompassError - -A `CompassError` objet est retourné à la `compassError` fonction de rappel lorsqu'une erreur survient. - -### Propriétés - -* **code**: l'un des codes d'erreur prédéfinis énumérés ci-dessous. - -### Constantes - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/it/README.md b/plugins/cordova-plugin-device-orientation/doc/it/README.md deleted file mode 100644 index 170f63e..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/it/README.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -Questo plugin consente di accedere alla bussola del dispositivo. La bussola è un sensore che rileva la direzione o la voce che il dispositivo è puntato, in genere dalla parte superiore del dispositivo. Esso misura la rotta in gradi da 0 a 359.99, dove 0 è a nord. - -L'accesso avviene tramite un oggetto globale `navigator.compass`. - -Anche se l'oggetto è associato con ambito globale del `navigator`, non è disponibile fino a dopo l'evento `deviceready`. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## Installazione - - cordova plugin add cordova-plugin-device-orientation - - -## Piattaforme supportate - - * Amazon fuoco OS - * Android - * BlackBerry 10 - * Browser - * Firefox OS - * iOS - * Tizen - * Windows Phone 7 e 8 (se disponibili nell'hardware) - * Windows 8 - -## Metodi - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Ottenere la corrente della bussola. La bussola viene restituita tramite un oggetto `CompassHeading` utilizzando la funzione di callback `compassSuccess`. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### Esempio - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Ottiene il titolo attuale del dispositivo a intervalli regolari. Ogni volta che viene recuperato il titolo, viene eseguita la funzione di callback `headingSuccess`. - -L'orologio restituito ID fa riferimento l'intervallo orologio bussola. L'ID di orologio utilizzabile con `navigator.compass.clearWatch` a smettere di guardare la navigator.compass. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` può contenere i seguenti tasti: - - * **frequency**: la frequenza di recuperare la bussola in millisecondi. *(Numero)* (Default: 100) - * **filter**: il cambiamento in gradi necessari per avviare un callback di successo watchHeading. Quando questo valore è impostato, la **frequency** viene ignorata. *(Numero)* - -### Esempio - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Stranezze browser - -I valori per la rubrica attuale sono generati casualmente al fine di simulare la bussola. - -### iOS stranezze - -Solo un `watchHeading` può essere in effetti una volta in iOS. Se un `watchHeading` utilizza un filtro, chiamata `getCurrentHeading` o `watchHeading` utilizza il valore di filtro esistenti per specificare le modifiche intestazione. Guardando i cambiamenti di direzione con un filtro è più efficiente con intervalli di tempo. - -### Amazon fuoco OS stranezze - - * `filter`non è supportato. - -### Stranezze Android - - * Nessun supporto per`filter`. - -### Firefox OS stranezze - - * Nessun supporto per`filter`. - -### Tizen stranezze - - * Nessun supporto per`filter`. - -### Windows Phone 7 e 8 stranezze - - * Nessun supporto per`filter`. - -## navigator.compass.clearWatch - -Smettere di guardare la bussola a cui fa riferimento il parametro ID orologio. - - navigator.compass.clearWatch(watchID); - - - * **watchID**: l'ID restituito da`navigator.compass.watchHeading`. - -### Esempio - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -Alla funzione di callback `compassSuccess` viene restituito un oggetto `CompassHeading`. - -### Proprietà - - * **magneticHeading**: la rotta in gradi da 0-359.99 in un unico momento. *(Numero)* - - * **trueHeading**: la voce rispetto al Polo Nord geografico in gradi 0-359.99 in un unico momento. Un valore negativo indica che non è possibile determinare la vera voce. *(Numero)* - - * **headingAccuracy**: lo scostamento in gradi tra il titolo segnalato e la vera voce. *(Numero)* - - * **timestamp**: il tempo in cui questa voce è stata determinata. *(millisecondi)* - -### Amazon fuoco OS stranezze - - * `trueHeading`non è supportato, ma riporta lo stesso valore`magneticHeading` - - * `headingAccuracy`è sempre 0 perché non non c'è alcuna differenza tra la `magneticHeading` e`trueHeading` - -### Stranezze Android - - * La `trueHeading` proprietà non è supportata, ma riporta lo stesso valore`magneticHeading`. - - * La `headingAccuracy` proprietà è sempre 0 perché non non c'è alcuna differenza tra la `magneticHeading` e`trueHeading`. - -### Firefox OS stranezze - - * La `trueHeading` proprietà non è supportata, ma riporta lo stesso valore`magneticHeading`. - - * La `headingAccuracy` proprietà è sempre 0 perché non non c'è alcuna differenza tra la `magneticHeading` e`trueHeading`. - -### iOS stranezze - - * La `trueHeading` proprietà viene restituito solo per servizi di localizzazione attivate tramite`navigator.geolocation.watchLocation()`. - - * Per i dispositivi iOS 4 sopra, voce fattori nell'orientamento corrente del dispositivo e non fa riferimento la sua posizione assoluta, per le app che supporta tale orientamento. - -## CompassError - -Un oggetto `CompassError` viene restituito alla funzione di callback `compassError` quando si verifica un errore. - -### Proprietà - - * **codice**: uno dei codici di errore predefiniti elencati di seguito. - -### Costanti - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/it/index.md b/plugins/cordova-plugin-device-orientation/doc/it/index.md deleted file mode 100644 index 89bee22..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/it/index.md +++ /dev/null @@ -1,204 +0,0 @@ - - -# cordova-plugin-device-orientation - -Questo plugin consente di accedere alla bussola del dispositivo. La bussola è un sensore che rileva la direzione o la voce che il dispositivo è puntato, in genere dalla parte superiore del dispositivo. Esso misura la rotta in gradi da 0 a 359.99, dove 0 è a nord. - -L'accesso avviene tramite un oggetto globale `navigator.compass`. - -Anche se l'oggetto è associato con ambito globale del `navigator`, non è disponibile fino a dopo l'evento `deviceready`. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## Installazione - - cordova plugin add cordova-plugin-device-orientation - - -## Piattaforme supportate - -* Amazon fuoco OS -* Android -* BlackBerry 10 -* Browser -* Firefox OS -* iOS -* Tizen -* Windows Phone 7 e 8 (se disponibili nell'hardware) -* Windows 8 - -## Metodi - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Ottenere la corrente della bussola. La bussola viene restituita tramite un oggetto `CompassHeading` utilizzando la funzione di callback `compassSuccess`. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### Esempio - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Ottiene il titolo attuale del dispositivo a intervalli regolari. Ogni volta che viene recuperato il titolo, viene eseguita la funzione di callback `headingSuccess`. - -L'orologio restituito ID fa riferimento l'intervallo orologio bussola. L'ID di orologio utilizzabile con `navigator.compass.clearWatch` a smettere di guardare la navigator.compass. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` può contenere i seguenti tasti: - -* **frequency**: la frequenza di recuperare la bussola in millisecondi. *(Numero)* (Default: 100) -* **filter**: il cambiamento in gradi necessari per avviare un callback di successo watchHeading. Quando questo valore è impostato, la **frequency** viene ignorata. *(Numero)* - -### Esempio - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Stranezze browser - -I valori per la rubrica attuale sono generati casualmente al fine di simulare la bussola. - -### iOS stranezze - -Solo un `watchHeading` può essere in effetti una volta in iOS. Se un `watchHeading` utilizza un filtro, chiamata `getCurrentHeading` o `watchHeading` utilizza il valore di filtro esistenti per specificare le modifiche intestazione. Guardando i cambiamenti di direzione con un filtro è più efficiente con intervalli di tempo. - -### Amazon fuoco OS stranezze - -* `filter`non è supportato. - -### Stranezze Android - -* Nessun supporto per`filter`. - -### Firefox OS stranezze - -* Nessun supporto per`filter`. - -### Tizen stranezze - -* Nessun supporto per`filter`. - -### Windows Phone 7 e 8 stranezze - -* Nessun supporto per`filter`. - -## navigator.compass.clearWatch - -Smettere di guardare la bussola a cui fa riferimento il parametro ID orologio. - - navigator.compass.clearWatch(watchID); - - -* **watchID**: l'ID restituito da`navigator.compass.watchHeading`. - -### Esempio - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -Alla funzione di callback `compassSuccess` viene restituito un oggetto `CompassHeading`. - -### Proprietà - -* **magneticHeading**: la rotta in gradi da 0-359.99 in un unico momento. *(Numero)* - -* **trueHeading**: la voce rispetto al Polo Nord geografico in gradi 0-359.99 in un unico momento. Un valore negativo indica che non è possibile determinare la vera voce. *(Numero)* - -* **headingAccuracy**: lo scostamento in gradi tra il titolo segnalato e la vera voce. *(Numero)* - -* **timestamp**: il tempo in cui questa voce è stata determinata. *(millisecondi)* - -### Amazon fuoco OS stranezze - -* `trueHeading`non è supportato, ma riporta lo stesso valore`magneticHeading` - -* `headingAccuracy`è sempre 0 perché non non c'è alcuna differenza tra la `magneticHeading` e`trueHeading` - -### Stranezze Android - -* La `trueHeading` proprietà non è supportata, ma riporta lo stesso valore`magneticHeading`. - -* La `headingAccuracy` proprietà è sempre 0 perché non non c'è alcuna differenza tra la `magneticHeading` e`trueHeading`. - -### Firefox OS stranezze - -* La `trueHeading` proprietà non è supportata, ma riporta lo stesso valore`magneticHeading`. - -* La `headingAccuracy` proprietà è sempre 0 perché non non c'è alcuna differenza tra la `magneticHeading` e`trueHeading`. - -### iOS stranezze - -* La `trueHeading` proprietà viene restituito solo per servizi di localizzazione attivate tramite`navigator.geolocation.watchLocation()`. - -* Per i dispositivi iOS 4 sopra, voce fattori nell'orientamento corrente del dispositivo e non fa riferimento la sua posizione assoluta, per le app che supporta tale orientamento. - -## CompassError - -Un oggetto `CompassError` viene restituito alla funzione di callback `compassError` quando si verifica un errore. - -### Proprietà - -* **codice**: uno dei codici di errore predefiniti elencati di seguito. - -### Costanti - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/ja/README.md b/plugins/cordova-plugin-device-orientation/doc/ja/README.md deleted file mode 100644 index 1c06fe0..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/ja/README.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -このプラグインは、デバイスのコンパスへのアクセスを提供します。 コンパスは方向またはというデバイスは、通常から指摘装置の上部の見出しを検出するセンサーです。 359.99、0 は北に 0 からの角度で見出しを測定します。 - -アクセスは、グローバル `navigator.compass` オブジェクトを介して。 - -オブジェクトは、グローバル スコープの `ナビゲーター` に添付、それがないまで `deviceready` イベントの後。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## インストール - - cordova plugin add cordova-plugin-device-orientation - - -## サポートされているプラットフォーム - - * アマゾン火 OS - * アンドロイド - * ブラックベリー 10 - * ブラウザー - * Firefox の OS - * iOS - * Tizen - * Windows Phone 7 および 8 (可能な場合ハードウェアで) - * Windows 8 - -## メソッド - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -現在のコンパス方位を取得します。コンパス針路が `compassSuccess` コールバック関数を使用して `CompassHeading` オブジェクトを介して返されます。 - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### 例 - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -デバイスの定期的な間隔で現在の方位を取得します。見出しを取り出すたびに `headingSuccess` コールバック関数が実行されます。 - -返される時計 ID コンパス時計腕時計間隔を参照します。時計 ID は、navigator.compass を見て停止する `navigator.compass.clearWatch` を使用できます。 - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` は、次のキーを含めることができます。 - - * **周波数**: 多くの場合、コンパス針路 (ミリ秒単位) を取得する方法。*(数)*(デフォルト: 100) - * **フィルター**: watchHeading 成功時のコールバックを開始する必要度の変化。この値を設定すると、**頻度**は無視されます。*(数)* - -### 例 - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### ブラウザーの癖 - -現在の見出しの値は、コンパスをシミュレートするためにランダムに生成されます。 - -### iOS の癖 - -1 つだけ `watchHeading` は iOS の効果を同時にすることができます。 `watchHeading` はフィルターを使用して、`getCurrentHeading` または `watchHeading` を呼び出す見出しの変更を指定する既存のフィルター値を使用します。 フィルターを使用して見出しの変更を見て時間間隔よりも効率的にファイルです。 - -### アマゾン火 OS 癖 - - * `filter`サポートされていません。 - -### Android の癖 - - * サポートされていません`filter`. - -### Firefox OS 癖 - - * サポートされていません`filter`. - -### Tizen の癖 - - * サポートされていません`filter`. - -### Windows Phone 7 と 8 癖 - - * サポートされていません`filter`. - -## navigator.compass.clearWatch - -時計 ID パラメーターによって参照されるコンパスを見て停止します。 - - navigator.compass.clearWatch(watchID); - - - * **watchID**: によって返される ID`navigator.compass.watchHeading`. - -### 例 - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -`CompassHeading` オブジェクトは、`compassSuccess` コールバック関数に返されます。 - -### プロパティ - - * **magneticHeading**: 1 つの時点で 0 359.99 から角度での見出し。*(数)* - - * **trueHeading**: 度 0 359.99 で地理的な北極を基準にして、1 つの時点での見出し。 負の値は真針路を特定できないことを示します。 *(数)* - - * **headingAccuracy**: 報告された見出しと真方位角度偏差。*(数)* - - * **タイムスタンプ**: この見出しを決定した時。*(ミリ秒)* - -### アマゾン火 OS 癖 - - * `trueHeading`レポートと同じ値はサポートされていません`magneticHeading` - - * `headingAccuracy`常に 0 の間の違いはありませんので、 `magneticHeading` と`trueHeading` - -### Android の癖 - - * `trueHeading`プロパティはサポートされていませんと同じ値を報告`magneticHeading`. - - * `headingAccuracy`プロパティは常に 0 の間の違いはありませんので、 `magneticHeading` と`trueHeading`. - -### Firefox OS 癖 - - * `trueHeading`プロパティはサポートされていませんと同じ値を報告`magneticHeading`. - - * `headingAccuracy`プロパティは常に 0 の間の違いはありませんので、 `magneticHeading` と`trueHeading`. - -### iOS の癖 - - * `trueHeading`経由で有効になっている位置情報サービスのプロパティが返されますのみ`navigator.geolocation.watchLocation()`. - - * IOS 4 デバイス上見出しデバイスの現在の向きの要因そして、その向きをサポートするアプリケーションのための絶対位置を参照していません。 - -## CompassError - -`CompassError` オブジェクトにエラーが発生したときに `compassError` コールバック関数に返されます。 - -### プロパティ - - * **コード**: 次のいずれかの定義済みのエラー コード。 - -### 定数 - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/ja/index.md b/plugins/cordova-plugin-device-orientation/doc/ja/index.md deleted file mode 100644 index 6b0b740..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/ja/index.md +++ /dev/null @@ -1,204 +0,0 @@ - - -# cordova-plugin-device-orientation - -このプラグインは、デバイスのコンパスへのアクセスを提供します。 コンパスは方向またはというデバイスは、通常から指摘装置の上部の見出しを検出するセンサーです。 359.99、0 は北に 0 からの角度で見出しを測定します。 - -アクセスは、グローバル `navigator.compass` オブジェクトを介して。 - -オブジェクトは、グローバル スコープの `ナビゲーター` に添付、それがないまで `deviceready` イベントの後。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## インストール - - cordova plugin add cordova-plugin-device-orientation - - -## サポートされているプラットフォーム - -* アマゾン火 OS -* アンドロイド -* ブラックベリー 10 -* ブラウザー -* Firefox の OS -* iOS -* Tizen -* Windows Phone 7 および 8 (可能な場合ハードウェアで) -* Windows 8 - -## メソッド - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -現在のコンパス方位を取得します。コンパス針路が `compassSuccess` コールバック関数を使用して `CompassHeading` オブジェクトを介して返されます。 - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### 例 - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -デバイスの定期的な間隔で現在の方位を取得します。見出しを取り出すたびに `headingSuccess` コールバック関数が実行されます。 - -返される時計 ID コンパス時計腕時計間隔を参照します。時計 ID は、navigator.compass を見て停止する `navigator.compass.clearWatch` を使用できます。 - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` は、次のキーを含めることができます。 - -* **周波数**: 多くの場合、コンパス針路 (ミリ秒単位) を取得する方法。*(数)*(デフォルト: 100) -* **フィルター**: watchHeading 成功時のコールバックを開始する必要度の変化。この値を設定すると、**頻度**は無視されます。*(数)* - -### 例 - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### ブラウザーの癖 - -現在の見出しの値は、コンパスをシミュレートするためにランダムに生成されます。 - -### iOS の癖 - -1 つだけ `watchHeading` は iOS の効果を同時にすることができます。 `watchHeading` はフィルターを使用して、`getCurrentHeading` または `watchHeading` を呼び出す見出しの変更を指定する既存のフィルター値を使用します。 フィルターを使用して見出しの変更を見て時間間隔よりも効率的にファイルです。 - -### アマゾン火 OS 癖 - -* `filter`サポートされていません。 - -### Android の癖 - -* サポートされていません`filter`. - -### Firefox OS 癖 - -* サポートされていません`filter`. - -### Tizen の癖 - -* サポートされていません`filter`. - -### Windows Phone 7 と 8 癖 - -* サポートされていません`filter`. - -## navigator.compass.clearWatch - -時計 ID パラメーターによって参照されるコンパスを見て停止します。 - - navigator.compass.clearWatch(watchID); - - -* **watchID**: によって返される ID`navigator.compass.watchHeading`. - -### 例 - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -`CompassHeading` オブジェクトは、`compassSuccess` コールバック関数に返されます。 - -### プロパティ - -* **magneticHeading**: 1 つの時点で 0 359.99 から角度での見出し。*(数)* - -* **trueHeading**: 度 0 359.99 で地理的な北極を基準にして、1 つの時点での見出し。 負の値は真針路を特定できないことを示します。 *(数)* - -* **headingAccuracy**: 報告された見出しと真方位角度偏差。*(数)* - -* **タイムスタンプ**: この見出しを決定した時。*(ミリ秒)* - -### アマゾン火 OS 癖 - -* `trueHeading`レポートと同じ値はサポートされていません`magneticHeading` - -* `headingAccuracy`常に 0 の間の違いはありませんので、 `magneticHeading` と`trueHeading` - -### Android の癖 - -* `trueHeading`プロパティはサポートされていませんと同じ値を報告`magneticHeading`. - -* `headingAccuracy`プロパティは常に 0 の間の違いはありませんので、 `magneticHeading` と`trueHeading`. - -### Firefox OS 癖 - -* `trueHeading`プロパティはサポートされていませんと同じ値を報告`magneticHeading`. - -* `headingAccuracy`プロパティは常に 0 の間の違いはありませんので、 `magneticHeading` と`trueHeading`. - -### iOS の癖 - -* `trueHeading`経由で有効になっている位置情報サービスのプロパティが返されますのみ`navigator.geolocation.watchLocation()`. - -* IOS 4 デバイス上見出しデバイスの現在の向きの要因そして、その向きをサポートするアプリケーションのための絶対位置を参照していません。 - -## CompassError - -`CompassError` オブジェクトにエラーが発生したときに `compassError` コールバック関数に返されます。 - -### プロパティ - -* **コード**: 次のいずれかの定義済みのエラー コード。 - -### 定数 - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/ko/README.md b/plugins/cordova-plugin-device-orientation/doc/ko/README.md deleted file mode 100644 index c20cef5..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/ko/README.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -이 플러그인 디바이스의 나침반에 대 한 액세스를 제공합니다. 나침반 방향 또는 표제는 장치 지적 이다, 일반적으로 장치 위에서 감지 하는 센서입니다. 359.99, 0가 북쪽을 0에서도에서 머리글을 측정 합니다. - -글로벌 `navigator.compass` 개체를 통해 액세스가입니다. - -개체 `navigator` 글로벌 범위 첨부 아니에요 때까지 사용할 수 있는 `deviceready` 이벤트 후. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## 설치 - - cordova plugin add cordova-plugin-device-orientation - - -## 지원 되는 플랫폼 - - * 아마존 화재 운영 체제 - * 안 드 로이드 - * 블랙베리 10 - * 브라우저 - * Firefox 운영 체제 - * iOS - * Tizen - * Windows Phone 7, 8 (사용 가능한 경우 하드웨어) - * 윈도우 8 - -## 메서드 - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -현재 나침반 제목 좀. 나침반 제목 `compassSuccess` 콜백 함수를 사용 하 여 `CompassHeading` 개체를 통해 반환 됩니다. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### 예를 들어 - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -정기적 장치의 현재 머리글을 가져옵니다. 제목 검색 때마다 `headingSuccess` 콜백 함수가 실행 됩니다. - -반환 된 시계 ID 나침반 시계 간격을 참조합니다. 시계 ID는 navigator.compass를 보는 중지 하 `navigator.compass.clearWatch`와 함께 사용할 수 있습니다. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions`는 다음 키를 포함할 수 있습니다. - - * **frequency**: 자주 밀리초에서 나침반 머리글을 검색 하는 방법. *(수)* (기본값: 100) - * **filter**:도 watchHeading 성공 콜백을 시작 하는 데 필요한 변경. 이 값을 설정 하는 경우 **주파수** 는 무시 됩니다. *(수)* - -### 예를 들어 - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### 브라우저 만지면 - -현재 제목에 대 한 값은 나침반을 시뮬레이션 하기 위해 임의로 생성 됩니다. - -### iOS 단점 - -하나의 `watchHeading` iOS에서 한 번에 적용에서 될 수 있습니다. `watchHeading` 필터를 사용 하는 경우 `getCurrentHeading` 또는 `watchHeading` 호출 사용 하 여 기존 필터 값 지정 제목 변경. 필터와 제목 변화를 보고 시간을 간격으로 보다 더 효율적입니다. - -### 아마존 화재 OS 단점 - - * `filter`지원 되지 않습니다. - -### 안 드 로이드 단점 - - * 대 한 지원`filter`. - -### 파이어 폭스 OS 단점 - - * 대 한 지원`filter`. - -### Tizen 특수 - - * 대 한 지원`filter`. - -### Windows Phone 7, 8 특수 - - * 대 한 지원`filter`. - -## navigator.compass.clearWatch - -시계 ID 매개 변수에서 참조 하는 나침반을 보고 중지 합니다. - - navigator.compass.clearWatch(watchID); - - - * **watchID**: ID 반환`navigator.compass.watchHeading`. - -### 예를 들어 - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -`CompassHeading` 개체는 `compassSuccess` 콜백 함수에 반환 됩니다. - -### 속성 - - * **magneticHeading**: 단일 시점에서 0-359.99에서도 제목. *(수)* - - * **trueHeading**: 단일 시점에서 0-359.99에서에서 지리적 북극을 기준으로 향하고. 음수 값을 나타냅니다 진정한 표제를 확인할 수 없습니다. *(수)* - - * **headingAccuracy**: 보고 된 머리글 사이의 진정한 제목도 편차. *(수)* - - * **타임 스탬프**:이 제목 결정 하는 시간. *(밀리초)* - -### 아마존 화재 OS 단점 - - * `trueHeading`지원 되지 않습니다 하지만 같은 값으로 보고`magneticHeading` - - * `headingAccuracy`항상 0 사이 차이가 있기 때문에 `magneticHeading` 와`trueHeading` - -### 안 드 로이드 단점 - - * `trueHeading`속성은 지원 되지 않습니다 하지만 같은 값으로 보고`magneticHeading`. - - * `headingAccuracy`속성은 항상 0 사이 차이가 있기 때문에 `magneticHeading` 와`trueHeading`. - -### 파이어 폭스 OS 단점 - - * `trueHeading`속성은 지원 되지 않습니다 하지만 같은 값으로 보고`magneticHeading`. - - * `headingAccuracy`속성은 항상 0 사이 차이가 있기 때문에 `magneticHeading` 와`trueHeading`. - -### iOS 단점 - - * `trueHeading`속성을 통해 위치 서비스에 대 한 반환만`navigator.geolocation.watchLocation()`. - - * IOS 4 장치에 대 한 위의 제목 소자의 현재 방향에서 요인 그리고, 그 방향을 지 원하는 애플 리 케이 션에 대 한 그것의 절대 위치를 참조 하지 않습니다. - -## CompassError - -`CompassError` 개체는 오류가 발생 하면 `compassError` 콜백 함수에 반환 됩니다. - -### 속성 - - * **코드**: 미리 정의 된 오류 코드 중 하나가 아래에 나열 된. - -### 상수 - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/ko/index.md b/plugins/cordova-plugin-device-orientation/doc/ko/index.md deleted file mode 100644 index 421b979..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/ko/index.md +++ /dev/null @@ -1,204 +0,0 @@ - - -# cordova-plugin-device-orientation - -이 플러그인 디바이스의 나침반에 대 한 액세스를 제공합니다. 나침반 방향 또는 표제는 장치 지적 이다, 일반적으로 장치 위에서 감지 하는 센서입니다. 359.99, 0가 북쪽을 0에서도에서 머리글을 측정 합니다. - -글로벌 `navigator.compass` 개체를 통해 액세스가입니다. - -개체 `navigator` 글로벌 범위 첨부 아니에요 때까지 사용할 수 있는 `deviceready` 이벤트 후. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## 설치 - - cordova plugin add cordova-plugin-device-orientation - - -## 지원 되는 플랫폼 - -* 아마존 화재 운영 체제 -* 안 드 로이드 -* 블랙베리 10 -* 브라우저 -* Firefox 운영 체제 -* iOS -* Tizen -* Windows Phone 7, 8 (사용 가능한 경우 하드웨어) -* 윈도우 8 - -## 메서드 - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -현재 나침반 제목 좀. 나침반 제목 `compassSuccess` 콜백 함수를 사용 하 여 `CompassHeading` 개체를 통해 반환 됩니다. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### 예를 들어 - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -정기적 장치의 현재 머리글을 가져옵니다. 제목 검색 때마다 `headingSuccess` 콜백 함수가 실행 됩니다. - -반환 된 시계 ID 나침반 시계 간격을 참조합니다. 시계 ID는 navigator.compass를 보는 중지 하 `navigator.compass.clearWatch`와 함께 사용할 수 있습니다. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions`는 다음 키를 포함할 수 있습니다. - -* **frequency**: 자주 밀리초에서 나침반 머리글을 검색 하는 방법. *(수)* (기본값: 100) -* **filter**:도 watchHeading 성공 콜백을 시작 하는 데 필요한 변경. 이 값을 설정 하는 경우 **주파수** 는 무시 됩니다. *(수)* - -### 예를 들어 - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### 브라우저 만지면 - -현재 제목에 대 한 값은 나침반을 시뮬레이션 하기 위해 임의로 생성 됩니다. - -### iOS 단점 - -하나의 `watchHeading` iOS에서 한 번에 적용에서 될 수 있습니다. `watchHeading` 필터를 사용 하는 경우 `getCurrentHeading` 또는 `watchHeading` 호출 사용 하 여 기존 필터 값 지정 제목 변경. 필터와 제목 변화를 보고 시간을 간격으로 보다 더 효율적입니다. - -### 아마존 화재 OS 단점 - -* `filter`지원 되지 않습니다. - -### 안 드 로이드 단점 - -* 대 한 지원`filter`. - -### 파이어 폭스 OS 단점 - -* 대 한 지원`filter`. - -### Tizen 특수 - -* 대 한 지원`filter`. - -### Windows Phone 7, 8 특수 - -* 대 한 지원`filter`. - -## navigator.compass.clearWatch - -시계 ID 매개 변수에서 참조 하는 나침반을 보고 중지 합니다. - - navigator.compass.clearWatch(watchID); - - -* **watchID**: ID 반환`navigator.compass.watchHeading`. - -### 예를 들어 - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -`CompassHeading` 개체는 `compassSuccess` 콜백 함수에 반환 됩니다. - -### 속성 - -* **magneticHeading**: 단일 시점에서 0-359.99에서도 제목. *(수)* - -* **trueHeading**: 단일 시점에서 0-359.99에서에서 지리적 북극을 기준으로 향하고. 음수 값을 나타냅니다 진정한 표제를 확인할 수 없습니다. *(수)* - -* **headingAccuracy**: 보고 된 머리글 사이의 진정한 제목도 편차. *(수)* - -* **타임 스탬프**:이 제목 결정 하는 시간. *(밀리초)* - -### 아마존 화재 OS 단점 - -* `trueHeading`지원 되지 않습니다 하지만 같은 값으로 보고`magneticHeading` - -* `headingAccuracy`항상 0 사이 차이가 있기 때문에 `magneticHeading` 와`trueHeading` - -### 안 드 로이드 단점 - -* `trueHeading`속성은 지원 되지 않습니다 하지만 같은 값으로 보고`magneticHeading`. - -* `headingAccuracy`속성은 항상 0 사이 차이가 있기 때문에 `magneticHeading` 와`trueHeading`. - -### 파이어 폭스 OS 단점 - -* `trueHeading`속성은 지원 되지 않습니다 하지만 같은 값으로 보고`magneticHeading`. - -* `headingAccuracy`속성은 항상 0 사이 차이가 있기 때문에 `magneticHeading` 와`trueHeading`. - -### iOS 단점 - -* `trueHeading`속성을 통해 위치 서비스에 대 한 반환만`navigator.geolocation.watchLocation()`. - -* IOS 4 장치에 대 한 위의 제목 소자의 현재 방향에서 요인 그리고, 그 방향을 지 원하는 애플 리 케이 션에 대 한 그것의 절대 위치를 참조 하지 않습니다. - -## CompassError - -`CompassError` 개체는 오류가 발생 하면 `compassError` 콜백 함수에 반환 됩니다. - -### 속성 - -* **코드**: 미리 정의 된 오류 코드 중 하나가 아래에 나열 된. - -### 상수 - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/pl/README.md b/plugins/cordova-plugin-device-orientation/doc/pl/README.md deleted file mode 100644 index 87cb323..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/pl/README.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -Ten plugin umożliwia dostęp do urządzenia kompas. Kompas jest czujnik, który wykrywa kierunek lub pozycji, że urządzenie jest wskazywany, zazwyczaj z górnej części urządzenia. Mierzy on nagłówek w stopniach od 0 do 359.99, gdzie 0 jest północ. - -Dostęp odbywa się za pomocą obiektu globalnego `navigator.compass`. - -Mimo, że obiekt jest dołączony do globalnego zakresu `navigator`, to nie dostępne dopiero po zdarzeniu `deviceready`. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## Instalacja - - cordova plugin add cordova-plugin-device-orientation - - -## Obsługiwane platformy - - * Amazon Fire OS - * Android - * BlackBerry 10 - * Przeglądarka - * Firefox OS - * iOS - * Tizen - * Windows Phone 7 i 8 (jeśli jest dostępny w sprzęcie) - * Windows 8 - -## Metody - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Uzyskać bieżącej pozycji kompas. Kompas pozycji jest zwracana za pośrednictwem obiektu `CompassHeading` za pomocą funkcji wywołania zwrotnego `compassSuccess`. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### Przykład - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Pobiera bieżący nagłówek urządzenia w regularnych odstępach czasu. Każdym razem, gdy nagłówek jest źródło, funkcja wywołania zwrotnego `headingSuccess` jest wykonywany. - -Identyfikator zwrócony zegarek odwołuje interwał kompas zegarek. Oglądaj identyfikator może być używany z `navigator.compass.clearWatch`, aby przestać oglądać navigator.compass. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` może zawierać następujące klucze: - - * **częstotliwość**: jak często pobrać kompas pozycji w milisekundach. *(Liczba)* (Domyślnie: 100) - * **Filtr**: zmiana stopni wymagane zainicjować wywołania zwrotnego watchHeading sukces. Gdy ta wartość jest ustawiona, **częstotliwość** jest ignorowana. *(Liczba)* - -### Przykład - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Quirks przeglądarki - -Wartości dla bieżącej pozycji są losowo generowane w celu symulacji kompas. - -### Dziwactwa iOS - -Tylko jeden `watchHeading` może być efekt w tym samym czasie w iOS. Jeśli `watchHeading` używa filtru, `getCurrentHeading` lub `watchHeading` używa istniejących wartości filtru określić zmiany pozycji. Obserwując zmiany pozycji z filtrem jest bardziej efektywne niż z odstępach czasu. - -### Amazon ogień OS dziwactwa - - * `filter`nie jest obsługiwane. - -### Dziwactwa Androida - - * Brak wsparcia dla`filter`. - -### Firefox OS dziwactwa - - * Brak wsparcia dla`filter`. - -### Dziwactwa Tizen - - * Brak wsparcia dla`filter`. - -### Windows Phone 7 i 8 dziwactwa - - * Brak wsparcia dla`filter`. - -## navigator.compass.clearWatch - -Przestać oglądać określany przez parametr ID Zegarek kompas. - - navigator.compass.clearWatch(watchID); - - - * **watchID**: Identyfikator zwrócony przez`navigator.compass.watchHeading`. - -### Przykład - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -Obiekt `CompassHeading` jest zwracany do funkcji wywołania zwrotnego `compassSuccess`. - -### Właściwości - - * **magneticHeading**: pozycja w stopniach od 0-359.99 w jednym momencie. *(Liczba)* - - * **trueHeading**: nagłówek do geograficznego Bieguna Północnego w stopniu 0-359.99 w jednym momencie. Wartość ujemna wskazuje, że prawda pozycji nie może być ustalona. *(Liczba)* - - * **headingAccuracy**: odchylenie w stopniach między zgłoszonych pozycji i pozycji prawda. *(Liczba)* - - * **sygnatura czasowa**: czas, w którym pozycja ta została ustalona. *(w milisekundach)* - -### Amazon ogień OS dziwactwa - - * `trueHeading`nie jest obsługiwane, ale raporty taką samą wartość jak`magneticHeading` - - * `headingAccuracy`jest zawsze 0, ponieważ nie ma żadnej różnicy między `magneticHeading` i`trueHeading` - -### Dziwactwa Androida - - * `trueHeading`Właściwość nie jest obsługiwany, ale raporty taką samą wartość jak`magneticHeading`. - - * `headingAccuracy`Właściwość jest zawsze 0, ponieważ nie ma żadnej różnicy między `magneticHeading` i`trueHeading`. - -### Firefox OS dziwactwa - - * `trueHeading`Właściwość nie jest obsługiwany, ale raporty taką samą wartość jak`magneticHeading`. - - * `headingAccuracy`Właściwość jest zawsze 0, ponieważ nie ma żadnej różnicy między `magneticHeading` i`trueHeading`. - -### Dziwactwa iOS - - * `trueHeading`Właściwość jest zwracana tylko dla lokalizacji usług włączone za pomocą`navigator.geolocation.watchLocation()`. - - * Urządzeń iOS 4 i powyżej pozycji czynniki w orientacji bieżącego urządzenia, a nie odwołuje się do pozycji absolutnej, dla aplikacji, które obsługuje tej orientacji. - -## CompassError - -Gdy wystąpi błąd, funkcja wywołania zwrotnego `compassError` zwracany jest obiekt `CompassError`. - -### Właściwości - - * **Kod**: jeden z kodów błędów wstępnie zdefiniowanych poniżej. - -### Stałe - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/pl/index.md b/plugins/cordova-plugin-device-orientation/doc/pl/index.md deleted file mode 100644 index e1a7250..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/pl/index.md +++ /dev/null @@ -1,204 +0,0 @@ - - -# cordova-plugin-device-orientation - -Ten plugin umożliwia dostęp do urządzenia kompas. Kompas jest czujnik, który wykrywa kierunek lub pozycji, że urządzenie jest wskazywany, zazwyczaj z górnej części urządzenia. Mierzy on nagłówek w stopniach od 0 do 359.99, gdzie 0 jest północ. - -Dostęp odbywa się za pomocą obiektu globalnego `navigator.compass`. - -Mimo, że obiekt jest dołączony do globalnego zakresu `navigator`, to nie dostępne dopiero po zdarzeniu `deviceready`. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## Instalacja - - cordova plugin add cordova-plugin-device-orientation - - -## Obsługiwane platformy - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Przeglądarka -* Firefox OS -* iOS -* Tizen -* Windows Phone 7 i 8 (jeśli jest dostępny w sprzęcie) -* Windows 8 - -## Metody - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Uzyskać bieżącej pozycji kompas. Kompas pozycji jest zwracana za pośrednictwem obiektu `CompassHeading` za pomocą funkcji wywołania zwrotnego `compassSuccess`. - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### Przykład - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Pobiera bieżący nagłówek urządzenia w regularnych odstępach czasu. Każdym razem, gdy nagłówek jest źródło, funkcja wywołania zwrotnego `headingSuccess` jest wykonywany. - -Identyfikator zwrócony zegarek odwołuje interwał kompas zegarek. Oglądaj identyfikator może być używany z `navigator.compass.clearWatch`, aby przestać oglądać navigator.compass. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` może zawierać następujące klucze: - -* **częstotliwość**: jak często pobrać kompas pozycji w milisekundach. *(Liczba)* (Domyślnie: 100) -* **Filtr**: zmiana stopni wymagane zainicjować wywołania zwrotnego watchHeading sukces. Gdy ta wartość jest ustawiona, **częstotliwość** jest ignorowana. *(Liczba)* - -### Przykład - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Quirks przeglądarki - -Wartości dla bieżącej pozycji są losowo generowane w celu symulacji kompas. - -### Dziwactwa iOS - -Tylko jeden `watchHeading` może być efekt w tym samym czasie w iOS. Jeśli `watchHeading` używa filtru, `getCurrentHeading` lub `watchHeading` używa istniejących wartości filtru określić zmiany pozycji. Obserwując zmiany pozycji z filtrem jest bardziej efektywne niż z odstępach czasu. - -### Amazon ogień OS dziwactwa - -* `filter`nie jest obsługiwane. - -### Dziwactwa Androida - -* Brak wsparcia dla`filter`. - -### Firefox OS dziwactwa - -* Brak wsparcia dla`filter`. - -### Dziwactwa Tizen - -* Brak wsparcia dla`filter`. - -### Windows Phone 7 i 8 dziwactwa - -* Brak wsparcia dla`filter`. - -## navigator.compass.clearWatch - -Przestać oglądać określany przez parametr ID Zegarek kompas. - - navigator.compass.clearWatch(watchID); - - -* **watchID**: Identyfikator zwrócony przez`navigator.compass.watchHeading`. - -### Przykład - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -Obiekt `CompassHeading` jest zwracany do funkcji wywołania zwrotnego `compassSuccess`. - -### Właściwości - -* **magneticHeading**: pozycja w stopniach od 0-359.99 w jednym momencie. *(Liczba)* - -* **trueHeading**: nagłówek do geograficznego Bieguna Północnego w stopniu 0-359.99 w jednym momencie. Wartość ujemna wskazuje, że prawda pozycji nie może być ustalona. *(Liczba)* - -* **headingAccuracy**: odchylenie w stopniach między zgłoszonych pozycji i pozycji prawda. *(Liczba)* - -* **sygnatura czasowa**: czas, w którym pozycja ta została ustalona. *(w milisekundach)* - -### Amazon ogień OS dziwactwa - -* `trueHeading`nie jest obsługiwane, ale raporty taką samą wartość jak`magneticHeading` - -* `headingAccuracy`jest zawsze 0, ponieważ nie ma żadnej różnicy między `magneticHeading` i`trueHeading` - -### Dziwactwa Androida - -* `trueHeading`Właściwość nie jest obsługiwany, ale raporty taką samą wartość jak`magneticHeading`. - -* `headingAccuracy`Właściwość jest zawsze 0, ponieważ nie ma żadnej różnicy między `magneticHeading` i`trueHeading`. - -### Firefox OS dziwactwa - -* `trueHeading`Właściwość nie jest obsługiwany, ale raporty taką samą wartość jak`magneticHeading`. - -* `headingAccuracy`Właściwość jest zawsze 0, ponieważ nie ma żadnej różnicy między `magneticHeading` i`trueHeading`. - -### Dziwactwa iOS - -* `trueHeading`Właściwość jest zwracana tylko dla lokalizacji usług włączone za pomocą`navigator.geolocation.watchLocation()`. - -* Urządzeń iOS 4 i powyżej pozycji czynniki w orientacji bieżącego urządzenia, a nie odwołuje się do pozycji absolutnej, dla aplikacji, które obsługuje tej orientacji. - -## CompassError - -Gdy wystąpi błąd, funkcja wywołania zwrotnego `compassError` zwracany jest obiekt `CompassError`. - -### Właściwości - -* **Kod**: jeden z kodów błędów wstępnie zdefiniowanych poniżej. - -### Stałe - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/ru/index.md b/plugins/cordova-plugin-device-orientation/doc/ru/index.md deleted file mode 100644 index 4b38960..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/ru/index.md +++ /dev/null @@ -1,194 +0,0 @@ - - -# cordova-plugin-device-orientation - -Этот плагин обеспечивает доступ к устройства компас. Компас-это датчик, который определяет направление или заголовок, что устройство указывает, как правило в верхней части устройства. Он измеряет направление в градусах от 0 до 359,99 градусов, где 0 — север. - -## Установка - - cordova plugin add cordova-plugin-device-orientation - - -## Поддерживаемые платформы - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Обозреватель -* Firefox OS -* iOS -* Tizen -* Windows Phone 7 и 8 (при наличии оборудования) -* Windows 8 - -## Методы - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -Получите текущий курс. Курс возвращается через `CompassHeading` объекта с помощью `compassSuccess` функции обратного вызова. - - navigator.compass.getCurrentHeading (compassSuccess, compassError); - - -### Пример - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -Получает текущий заголовок устройства в регулярном интервале. Каждый раз, когда извлекаются заголовок, `headingSuccess` выполняется функция обратного вызова. - -Идентификатор возвращаемой смотреть ссылки компас часы интервал. Часы, ID может быть использован с `navigator.compass.clearWatch` чтобы остановить просмотр navigator.compass. - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions`может содержать следующие разделы: - -* **Частота**: как часто получить курс в миллисекундах. *(Число)* (По умолчанию: 100) -* **Фильтр**: изменения в градусах, требуемых для инициирования обратного вызова watchHeading успех. Если это значение задано, **Частота** учитывается. *(Число)* - -### Пример - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### Браузер причуды - -Для того, чтобы имитировать компас генерируются случайным образом значения для текущего заголовка. - -### Особенности iOS - -Только один `watchHeading` может быть в одно время эффекта в iOS. Если `watchHeading` использует фильтр, вызов `getCurrentHeading` или `watchHeading` для указания изменения заголовка используется существующее значение фильтра. Наблюдая изменения заголовка с помощью фильтра является более эффективным, чем с интервалов времени. - -### Особенности Amazon Fire OS - -* `filter`не поддерживается. - -### Особенности Android - -* Поддержка отсутствует`filter`. - -### Особенности Firefox OS - -* Поддержка отсутствует`filter`. - -### Особенности Tizen - -* Поддержка отсутствует`filter`. - -### Особенности Windows Phone 7 и 8 - -* Поддержка отсутствует`filter`. - -## navigator.compass.clearWatch - -Перестать смотреть компас, на который ссылается параметр ID смотреть. - - navigator.compass.clearWatch(watchID); - - -* **watchID**: идентификатор, возвращенный`navigator.compass.watchHeading`. - -### Пример - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -A `CompassHeading` объект возвращается к `compassSuccess` функции обратного вызова. - -### Параметры - -* **magneticHeading**: направление в градусах от 0-359,99 в один момент времени. *(Число)* - -* **trueHeading**: заголовок относительно географического Северного полюса в градусах 0-359,99 в один момент времени. Отрицательное значение указывает, что заголовок правда не может быть определено. *(Число)* - -* **headingAccuracy**: отклонение в градусах между сообщил заголовок и заголовок верно. *(Число)* - -* **отметка времени**: время, на котором был определен этот заголовок. *(в миллисекундах)* - -### Особенности Amazon Fire OS - -* `trueHeading`не поддерживается, но сообщает то же значение`magneticHeading` - -* `headingAccuracy`Это всегда 0 потому, что нет никакой разницы между `magneticHeading` и`trueHeading` - -### Особенности Android - -* `trueHeading`Свойство не поддерживается, но сообщает то же значение`magneticHeading`. - -* `headingAccuracy`Свойство всегда имеет 0 потому, что нет никакой разницы между `magneticHeading` и`trueHeading`. - -### Особенности Firefox OS - -* `trueHeading`Свойство не поддерживается, но сообщает то же значение`magneticHeading`. - -* `headingAccuracy`Свойство всегда имеет 0 потому, что нет никакой разницы между `magneticHeading` и`trueHeading`. - -### Особенности iOS - -* `trueHeading`Свойства возвращается только для служб определения местоположения включена через`navigator.geolocation.watchLocation()`. - -* Для устройств iOS 4 и выше заголовок факторы в текущей ориентации устройства и не ссылаться на его абсолютное положение, для приложений, которые поддерживает эту ориентацию. - -## CompassError - -A `CompassError` объект возвращается к `compassError` функцию обратного вызова при возникновении ошибки. - -### Параметры - -* **code**: один из стандартных кодов ошибок, перечисленных ниже. - -### Константы - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/doc/zh/README.md b/plugins/cordova-plugin-device-orientation/doc/zh/README.md deleted file mode 100644 index 2634555..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/zh/README.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# cordova-plugin-device-orientation - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device-orientation.svg)](https://travis-ci.org/apache/cordova-plugin-device-orientation) - -這個外掛程式提供了對設備的指南針的訪問。 羅盤是感應器,可檢測的方向或設備通常指從設備的頂部的標題。 它的措施中從 0 度到 359.99,其中 0 是北部的標題。 - -訪問是通過一個全球 `navigator.compass` 物件。 - -雖然該物件附加到全球範圍內 `導航器`,它不可用直到 `deviceready` 事件之後。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## 安裝 - - cordova plugin add cordova-plugin-device-orientation - - -## 支援的平臺 - - * 亞馬遜火 OS - * Android 系統 - * 黑莓 10 - * 瀏覽器 - * 火狐瀏覽器作業系統 - * iOS - * Tizen - * Windows Phone 7 和第 8 (如果在硬體中可用) - * Windows 8 - -## 方法 - - * navigator.compass.getCurrentHeading - * navigator.compass.watchHeading - * navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -獲取當前的羅經航向。羅經航向被經由一個 `CompassHeading` 物件,使用 `compassSuccess` 回呼函數。 - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### 示例 - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -獲取設備的當前標題的間隔時間定期。檢索到的標題,每次執行 `headingSuccess` 回呼函數。 - -返回的表 ID 引用的指南針手錶的時間間隔。表 ID 可用於與 `navigator.compass.clearWatch` 停止看 navigator.compass。 - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` 可能包含以下項: - - * **frequency**: 經常如何檢索以毫秒為單位的羅經航向。*(Number)*(預設值: 100) - * **filter**: 啟動 watchHeading 成功回檔所需的度的變化。當設置此值時,**frequency**將被忽略。*(Number)* - -### 示例 - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### 瀏覽器的怪癖 - -隨機生成當前標題的值,以便類比羅盤。 - -### iOS 的怪癖 - -只有一個 `watchHeading` 可以在 iOS 中一次的效果。 如果 `watchHeading` 使用一個篩選器,致電 `getCurrentHeading` 或 `watchHeading` 使用現有的篩選器值來指定標題的變化。 帶有篩選器看標題的變化是與時間間隔比效率更高。 - -### 亞馬遜火 OS 怪癖 - - * `filter`不受支援。 - -### Android 的怪癖 - - * 不支援`filter`. - -### 火狐瀏覽器作業系統的怪癖 - - * 不支援`filter`. - -### Tizen 怪癖 - - * 不支援`filter`. - -### Windows Phone 7 和 8 怪癖 - - * 不支援`filter`. - -## navigator.compass.clearWatch - -別看手錶 ID 參數所引用的指南針。 - - navigator.compass.clearWatch(watchID); - - - * **watchID**: 由返回的 ID`navigator.compass.watchHeading`. - -### 示例 - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -`CompassSuccess` 回呼函數返回一個 `CompassHeading` 物件。 - -### 屬性 - - * **magneticHeading**: 在某一時刻在時間中從 0-359.99 度的標題。*(人數)* - - * **trueHeading**: 在某一時刻的時間與地理北極在 0-359.99 度標題。 負值表示不能確定真正的標題。 *(人數)* - - * **headingAccuracy**: 中度報告的標題和真正標題之間的偏差。*(人數)* - - * **timestamp**: 本項決定在其中的時間。*(毫秒)* - -### 亞馬遜火 OS 怪癖 - - * `trueHeading`不受支援,但報告相同的值`magneticHeading` - - * `headingAccuracy`是始終為 0 因為有沒有區別 `magneticHeading` 和`trueHeading` - -### Android 的怪癖 - - * `trueHeading`屬性不受支援,但報告相同的值`magneticHeading`. - - * `headingAccuracy`屬性始終是 0 因為有沒有區別 `magneticHeading` 和`trueHeading`. - -### 火狐瀏覽器作業系統的怪癖 - - * `trueHeading`屬性不受支援,但報告相同的值`magneticHeading`. - - * `headingAccuracy`屬性始終是 0 因為有沒有區別 `magneticHeading` 和`trueHeading`. - -### iOS 的怪癖 - - * `trueHeading`屬性只返回位置服務通過以下方式啟用`navigator.geolocation.watchLocation()`. - - * IOS 4 設備及以上,標題中設備的當前方向的因素,也不引用其絕對的位置,用於支援該方向的應用程式。 - -## CompassError - -當發生錯誤時,`compassError` 回呼函數情況下會返回一個 `CompassError` 物件。 - -### 屬性 - - * **code**: 下面列出的預定義的錯誤代碼之一。 - -### 常量 - - * `CompassError.COMPASS_INTERNAL_ERR` - * `CompassError.COMPASS_NOT_SUPPORTED` \ No newline at end of file diff --git a/plugins/cordova-plugin-device-orientation/doc/zh/index.md b/plugins/cordova-plugin-device-orientation/doc/zh/index.md deleted file mode 100644 index 567a615..0000000 --- a/plugins/cordova-plugin-device-orientation/doc/zh/index.md +++ /dev/null @@ -1,204 +0,0 @@ - - -# cordova-plugin-device-orientation - -這個外掛程式提供了對設備的指南針的訪問。 羅盤是感應器,可檢測的方向或設備通常指從設備的頂部的標題。 它的措施中從 0 度到 359.99,其中 0 是北部的標題。 - -訪問是通過一個全球 `navigator.compass` 物件。 - -雖然該物件附加到全球範圍內 `導航器`,它不可用直到 `deviceready` 事件之後。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(navigator.compass); - } - - -## 安裝 - - cordova plugin add cordova-plugin-device-orientation - - -## 支援的平臺 - -* 亞馬遜火 OS -* Android 系統 -* 黑莓 10 -* 瀏覽器 -* 火狐瀏覽器的作業系統 -* iOS -* 泰 -* Windows Phone 7 和第 8 (如果在硬體中可用) -* Windows 8 - -## 方法 - -* navigator.compass.getCurrentHeading -* navigator.compass.watchHeading -* navigator.compass.clearWatch - -## navigator.compass.getCurrentHeading - -獲取當前的羅經航向。羅經航向被經由一個 `CompassHeading` 物件,使用 `compassSuccess` 回呼函數。 - - navigator.compass.getCurrentHeading(compassSuccess, compassError); - - -### 示例 - - function onSuccess(heading) { - alert('Heading: ' + heading.magneticHeading); - }; - - function onError(error) { - alert('CompassError: ' + error.code); - }; - - navigator.compass.getCurrentHeading(onSuccess, onError); - - -## navigator.compass.watchHeading - -獲取設備的當前標題的間隔時間定期。檢索到的標題,每次執行 `headingSuccess` 回呼函數。 - -返回的表 ID 引用的指南針手錶的時間間隔。表 ID 可用於與 `navigator.compass.clearWatch` 停止看 navigator.compass。 - - var watchID = navigator.compass.watchHeading(compassSuccess, compassError, [compassOptions]); - - -`compassOptions` 可能包含以下項: - -* **frequency**: 經常如何檢索以毫秒為單位的羅經航向。*(Number)*(預設值: 100) -* **filter**: 啟動 watchHeading 成功回檔所需的度的變化。當設置此值時,**frequency**將被忽略。*(Number)* - -### 示例 - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { - frequency: 3000 - }; // Update every 3 seconds - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - -### 瀏覽器的怪癖 - -隨機生成當前標題的值,以便類比羅盤。 - -### iOS 的怪癖 - -只有一個 `watchHeading` 可以在 iOS 中一次的效果。 如果 `watchHeading` 使用一個篩選器,致電 `getCurrentHeading` 或 `watchHeading` 使用現有的篩選器值來指定標題的變化。 帶有篩選器看標題的變化是與時間間隔比效率更高。 - -### 亞馬遜火 OS 怪癖 - -* `filter`不受支援。 - -### Android 的怪癖 - -* 不支援`filter`. - -### 火狐瀏覽器作業系統的怪癖 - -* 不支援`filter`. - -### 泰怪癖 - -* 不支援`filter`. - -### Windows Phone 7 和 8 的怪癖 - -* 不支援`filter`. - -## navigator.compass.clearWatch - -別看手錶 ID 參數所引用的指南針。 - - navigator.compass.clearWatch(watchID); - - -* **watchID**: 由返回的 ID`navigator.compass.watchHeading`. - -### 示例 - - var watchID = navigator.compass.watchHeading(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatch(watchID); - - -## CompassHeading - -`CompassSuccess` 回呼函數返回一個 `CompassHeading` 物件。 - -### 屬性 - -* **magneticHeading**: 在某一時刻在時間中從 0-359.99 度的標題。*(人數)* - -* **trueHeading**: 在某一時刻的時間與地理北極在 0-359.99 度標題。 負值表示不能確定真正的標題。 *(人數)* - -* **headingAccuracy**: 中度報告的標題和真正標題之間的偏差。*(人數)* - -* **timestamp**: 本項決定在其中的時間。*(毫秒)* - -### 亞馬遜火 OS 怪癖 - -* `trueHeading`不受支援,但報告相同的值`magneticHeading` - -* `headingAccuracy`是始終為 0 因為有沒有區別 `magneticHeading` 和`trueHeading` - -### Android 的怪癖 - -* `trueHeading`屬性不受支援,但報告相同的值`magneticHeading`. - -* `headingAccuracy`屬性始終是 0 因為有沒有區別 `magneticHeading` 和`trueHeading`. - -### 火狐瀏覽器作業系統的怪癖 - -* `trueHeading`屬性不受支援,但報告相同的值`magneticHeading`. - -* `headingAccuracy`屬性始終是 0 因為有沒有區別 `magneticHeading` 和`trueHeading`. - -### iOS 的怪癖 - -* `trueHeading`屬性只返回位置服務通過以下方式啟用`navigator.geolocation.watchLocation()`. - -* IOS 4 設備及以上,標題中設備的當前方向的因素,也不引用其絕對的位置,用於支援該方向的應用程式。 - -## CompassError - -當發生錯誤時,`compassError` 回呼函數情況下會返回一個 `CompassError` 物件。 - -### 屬性 - -* **code**: 下面列出的預定義的錯誤代碼之一。 - -### 常量 - -* `CompassError.COMPASS_INTERNAL_ERR` -* `CompassError.COMPASS_NOT_SUPPORTED` diff --git a/plugins/cordova-plugin-device-orientation/package.json b/plugins/cordova-plugin-device-orientation/package.json deleted file mode 100644 index 78a20bf..0000000 --- a/plugins/cordova-plugin-device-orientation/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "cordova-plugin-device-orientation", - "version": "1.0.3-dev", - "description": "Cordova Device Orientation Plugin", - "cordova": { - "id": "cordova-plugin-device-orientation", - "platforms": [ - "firefoxos", - "android", - "amazon-fireos", - "ubuntu", - "blackberry10", - "ios", - "wp7", - "wp8", - "windows8", - "tizen", - "browser" - ] - }, - "repository": { - "type": "git", - "url": "https://github.com/apache/cordova-plugin-device-orientation" - }, - "keywords": [ - "cordova", - "device", - "orientation", - "ecosystem:cordova", - "cordova-firefoxos", - "cordova-android", - "cordova-amazon-fireos", - "cordova-ubuntu", - "cordova-blackberry10", - "cordova-ios", - "cordova-wp7", - "cordova-wp8", - "cordova-windows8", - "cordova-tizen", - "cordova-browser" - ], - "author": "Apache Software Foundation", - "license": "Apache-2.0" -} diff --git a/plugins/cordova-plugin-device-orientation/plugin.xml b/plugins/cordova-plugin-device-orientation/plugin.xml deleted file mode 100644 index 502b70b..0000000 --- a/plugins/cordova-plugin-device-orientation/plugin.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - Device Orientation - Cordova Device Orientation Plugin - Apache 2.0 - cordova,device,orientation - https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git - https://issues.apache.org/jira/browse/CB/component/12320637 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/cordova-plugin-device-orientation/src/android/CompassListener.java b/plugins/cordova-plugin-device-orientation/src/android/CompassListener.java deleted file mode 100644 index 194db0d..0000000 --- a/plugins/cordova-plugin-device-orientation/src/android/CompassListener.java +++ /dev/null @@ -1,296 +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.deviceorientation; - -import java.util.List; - -import org.apache.cordova.CordovaWebView; -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.PluginResult; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.content.Context; - -import android.os.Handler; -import android.os.Looper; - -/** - * This class listens to the compass sensor and stores the latest heading value. - */ -public class CompassListener extends CordovaPlugin implements SensorEventListener { - - public static int STOPPED = 0; - public static int STARTING = 1; - public static int RUNNING = 2; - public static int ERROR_FAILED_TO_START = 3; - - public long TIMEOUT = 30000; // Timeout in msec to shut off listener - - int status; // status of listener - float heading; // most recent heading value - long timeStamp; // time of most recent value - long lastAccessTime; // time the value was last retrieved - int accuracy; // accuracy of the sensor - - private SensorManager sensorManager;// Sensor manager - Sensor mSensor; // Compass sensor returned by sensor manager - - private CallbackContext callbackContext; - - /** - * Constructor. - */ - public CompassListener() { - this.heading = 0; - this.timeStamp = 0; - this.setStatus(CompassListener.STOPPED); - } - - /** - * Sets the context of the Command. This can then be used to do things like - * get file paths associated with the Activity. - * - * @param cordova The context of the main Activity. - * @param webView The CordovaWebView Cordova is running in. - */ - public void initialize(CordovaInterface cordova, CordovaWebView webView) { - super.initialize(cordova, webView); - this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE); - } - - /** - * Executes the request and returns PluginResult. - * - * @param action The action to execute. - * @param args JSONArry of arguments for the plugin. - * @param callbackS=Context The callback id used when calling back into JavaScript. - * @return True if the action was valid. - * @throws JSONException - */ - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("start")) { - this.start(); - } - else if (action.equals("stop")) { - this.stop(); - } - else if (action.equals("getStatus")) { - int i = this.getStatus(); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, i)); - } - else if (action.equals("getHeading")) { - // If not running, then this is an async call, so don't worry about waiting - if (this.status != CompassListener.RUNNING) { - int r = this.start(); - if (r == CompassListener.ERROR_FAILED_TO_START) { - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, CompassListener.ERROR_FAILED_TO_START)); - return true; - } - // Set a timeout callback on the main thread. - Handler handler = new Handler(Looper.getMainLooper()); - handler.postDelayed(new Runnable() { - public void run() { - CompassListener.this.timeout(); - } - }, 2000); - } - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, getCompassHeading())); - } - else if (action.equals("setTimeout")) { - this.setTimeout(args.getLong(0)); - } - else if (action.equals("getTimeout")) { - long l = this.getTimeout(); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, l)); - } else { - // Unsupported action - return false; - } - return true; - } - - /** - * Called when listener is to be shut down and object is being destroyed. - */ - public void onDestroy() { - this.stop(); - } - - /** - * Called when app has navigated and JS listeners have been destroyed. - */ - public void onReset() { - this.stop(); - } - - //-------------------------------------------------------------------------- - // LOCAL METHODS - //-------------------------------------------------------------------------- - - /** - * Start listening for compass sensor. - * - * @return status of listener - */ - public int start() { - - // If already starting or running, then just return - if ((this.status == CompassListener.RUNNING) || (this.status == CompassListener.STARTING)) { - return this.status; - } - - // Get compass sensor from sensor manager - @SuppressWarnings("deprecation") - List list = this.sensorManager.getSensorList(Sensor.TYPE_ORIENTATION); - - // If found, then register as listener - if (list != null && list.size() > 0) { - this.mSensor = list.get(0); - this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL); - this.lastAccessTime = System.currentTimeMillis(); - this.setStatus(CompassListener.STARTING); - } - - // If error, then set status to error - else { - this.setStatus(CompassListener.ERROR_FAILED_TO_START); - } - - return this.status; - } - - /** - * Stop listening to compass sensor. - */ - public void stop() { - if (this.status != CompassListener.STOPPED) { - this.sensorManager.unregisterListener(this); - } - this.setStatus(CompassListener.STOPPED); - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - /** - * Called after a delay to time out if the listener has not attached fast enough. - */ - private void timeout() { - if (this.status == CompassListener.STARTING) { - this.setStatus(CompassListener.ERROR_FAILED_TO_START); - if (this.callbackContext != null) { - this.callbackContext.error("Compass listener failed to start."); - } - } - } - - /** - * Sensor listener event. - * - * @param SensorEvent event - */ - public void onSensorChanged(SensorEvent event) { - - // We only care about the orientation as far as it refers to Magnetic North - float heading = event.values[0]; - - // Save heading - this.timeStamp = System.currentTimeMillis(); - this.heading = heading; - this.setStatus(CompassListener.RUNNING); - - // If heading hasn't been read for TIMEOUT time, then turn off compass sensor to save power - if ((this.timeStamp - this.lastAccessTime) > this.TIMEOUT) { - this.stop(); - } - } - - /** - * Get status of compass sensor. - * - * @return status - */ - public int getStatus() { - return this.status; - } - - /** - * Get the most recent compass heading. - * - * @return heading - */ - public float getHeading() { - this.lastAccessTime = System.currentTimeMillis(); - return this.heading; - } - - /** - * Set the timeout to turn off compass sensor if getHeading() hasn't been called. - * - * @param timeout Timeout in msec. - */ - public void setTimeout(long timeout) { - this.TIMEOUT = timeout; - } - - /** - * Get the timeout to turn off compass sensor if getHeading() hasn't been called. - * - * @return timeout in msec - */ - public long getTimeout() { - return this.TIMEOUT; - } - - /** - * Set the status and send it to JavaScript. - * @param status - */ - private void setStatus(int status) { - this.status = status; - } - - /** - * Create the CompassHeading JSON object to be returned to JavaScript - * - * @return a compass heading - */ - private JSONObject getCompassHeading() throws JSONException { - JSONObject obj = new JSONObject(); - - obj.put("magneticHeading", this.getHeading()); - obj.put("trueHeading", this.getHeading()); - // Since the magnetic and true heading are always the same our and accuracy - // is defined as the difference between true and magnetic always return zero - obj.put("headingAccuracy", 0); - obj.put("timestamp", this.timeStamp); - - return obj; - } - -} diff --git a/plugins/cordova-plugin-device-orientation/src/blackberry10/index.js b/plugins/cordova-plugin-device-orientation/src/blackberry10/index.js deleted file mode 100644 index 8f0278d..0000000 --- a/plugins/cordova-plugin-device-orientation/src/blackberry10/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013 Research In Motion Limited. - * - * 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. - */ - -module.exports = { - getHeading: function (success, fail, args, env) { - var result = new PluginResult(args, env), - callback = function (orientation) { - var info = { - magneticHeading: orientation.alpha, - trueHeading: 360-orientation.alpha, - headingAccuracy: 360-(2*orientation.alpha), - timestamp: new Date().getTime() - }; - window.removeEventListener("deviceorientation", callback); - result.callbackOk(info, false); - }; - window.addEventListener("deviceorientation", callback); - result.noResult(true); - } -}; diff --git a/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js b/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js deleted file mode 100644 index 1b22111..0000000 --- a/plugins/cordova-plugin-device-orientation/src/browser/CompassProxy.js +++ /dev/null @@ -1,45 +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. - * -*/ - -var Compass = { - getHeading: function(success, error) { - var listener = function() { - var orient = {}; - var heading = (Math.round((Math.random() * 360) * 100) / 100); - - orient.trueHeading = heading; - orient.magneticHeading = heading; - orient.headingAccuracy = 0; - orient.timestamp = new Date().getTime(); - - success(orient); - - window.removeEventListener('deviceorientation', listener, false); - }; - - return window.addEventListener('deviceorientation', listener, false); - } -}; - -var browser = require('cordova/platform'); - -module.exports = Compass; -require('cordova/exec/proxy').add('Compass', Compass); diff --git a/plugins/cordova-plugin-device-orientation/src/firefoxos/compass.js b/plugins/cordova-plugin-device-orientation/src/firefoxos/compass.js deleted file mode 100644 index ce392d4..0000000 --- a/plugins/cordova-plugin-device-orientation/src/firefoxos/compass.js +++ /dev/null @@ -1,43 +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. - * -*/ - -var Compass = { - getHeading: function(success, error) { - var listener = function(ev) { - var orient = { - trueHeading: ev.alpha, - magneticHeading: ev.alpha, - headingAccuracy: 0, - timestamp: new Date().getTime() - } - success(orient); - // remove listener after first response - window.removeEventListener('deviceorientation', listener, false); - } - return window.addEventListener('deviceorientation', listener, false); - }, -}; - -var firefoxos = require('cordova/platform'); - -module.exports = Compass; -require('cordova/exec/proxy').add('Compass', Compass); - diff --git a/plugins/cordova-plugin-device-orientation/src/ios/CDVCompass.h b/plugins/cordova-plugin-device-orientation/src/ios/CDVCompass.h deleted file mode 100644 index 529e11b..0000000 --- a/plugins/cordova-plugin-device-orientation/src/ios/CDVCompass.h +++ /dev/null @@ -1,68 +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. - */ - -#import -#import -#import - -enum CDVHeadingStatus { - HEADINGSTOPPED = 0, - HEADINGSTARTING, - HEADINGRUNNING, - HEADINGERROR -}; -typedef NSUInteger CDVHeadingStatus; - -// simple object to keep track of heading information -@interface CDVHeadingData : NSObject {} - -@property (nonatomic, assign) CDVHeadingStatus headingStatus; -@property (nonatomic, strong) CLHeading* headingInfo; -@property (nonatomic, strong) NSMutableArray* headingCallbacks; -@property (nonatomic, copy) NSString* headingFilter; -@property (nonatomic, strong) NSDate* headingTimestamp; -@property (assign) NSInteger timeout; - -@end - -@interface CDVCompass : CDVPlugin { - @private BOOL __locationStarted; - @private BOOL __highAccuracyEnabled; - CDVHeadingData* headingData; -} - -@property (nonatomic, strong) CLLocationManager* locationManager; -@property (strong) CDVHeadingData* headingData; - -- (BOOL)hasHeadingSupport; - -- (void)locationManager:(CLLocationManager*)manager - didFailWithError:(NSError*)error; - -- (void)getHeading:(CDVInvokedUrlCommand*)command; -- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain; -- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command; -- (void)stopHeading:(CDVInvokedUrlCommand*)command; -- (void)startHeadingWithFilter:(CLLocationDegrees)filter; -- (void)locationManager:(CLLocationManager*)manager - didUpdateHeading:(CLHeading*)heading; - -- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager; - -@end diff --git a/plugins/cordova-plugin-device-orientation/src/ios/CDVCompass.m b/plugins/cordova-plugin-device-orientation/src/ios/CDVCompass.m deleted file mode 100644 index ebe6b60..0000000 --- a/plugins/cordova-plugin-device-orientation/src/ios/CDVCompass.m +++ /dev/null @@ -1,290 +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. - */ - -#import "CDVCompass.h" - -#pragma mark Constants - -#define kPGLocationErrorDomain @"kPGLocationErrorDomain" -#define kPGLocationDesiredAccuracyKey @"desiredAccuracy" -#define kPGLocationForcePromptKey @"forcePrompt" -#define kPGLocationDistanceFilterKey @"distanceFilter" -#define kPGLocationFrequencyKey @"frequency" - -#pragma mark - -#pragma mark CDVHeadingData - -@implementation CDVHeadingData - -@synthesize headingStatus, headingInfo, headingCallbacks, headingFilter, headingTimestamp, timeout; -- (CDVHeadingData*)init -{ - self = (CDVHeadingData*)[super init]; - if (self) { - self.headingStatus = HEADINGSTOPPED; - self.headingInfo = nil; - self.headingCallbacks = nil; - self.headingFilter = nil; - self.headingTimestamp = nil; - self.timeout = 10; - } - return self; -} - -@end - -#pragma mark - -#pragma mark CDVLocation - -@implementation CDVCompass - -@synthesize locationManager, headingData; - -- (void)pluginInitialize -{ - self.locationManager = [[CLLocationManager alloc] init]; - self.locationManager.delegate = self; // Tells the location manager to send updates to this object - __locationStarted = NO; - __highAccuracyEnabled = NO; - self.headingData = nil; -} - -- (BOOL)hasHeadingSupport -{ - BOOL headingInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(headingAvailable)]; // iOS 3.x - BOOL headingClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(headingAvailable)]; // iOS 4.x - - if (headingInstancePropertyAvailable) { // iOS 3.x - return [(id)self.locationManager headingAvailable]; - } else if (headingClassPropertyAvailable) { // iOS 4.x - return [CLLocationManager headingAvailable]; - } else { // iOS 2.x - return NO; - } -} - -// called to get the current heading -// Will call location manager to startUpdatingHeading if necessary - -- (void)getHeading:(CDVInvokedUrlCommand*)command -{ - NSString* callbackId = command.callbackId; - NSDictionary* options = [command argumentAtIndex:0 withDefault:nil]; - NSNumber* filter = [options valueForKey:@"filter"]; - - if (filter) { - [self watchHeadingFilter:command]; - return; - } - if ([self hasHeadingSupport] == NO) { - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } else { - // heading retrieval does is not affected by disabling locationServices and authorization of app for location services - if (!self.headingData) { - self.headingData = [[CDVHeadingData alloc] init]; - } - CDVHeadingData* hData = self.headingData; - - if (!hData.headingCallbacks) { - hData.headingCallbacks = [NSMutableArray arrayWithCapacity:1]; - } - // add the callbackId into the array so we can call back when get data - [hData.headingCallbacks addObject:callbackId]; - - if ((hData.headingStatus != HEADINGRUNNING) && (hData.headingStatus != HEADINGERROR)) { - // Tell the location manager to start notifying us of heading updates - [self startHeadingWithFilter:0.2]; - } else { - [self returnHeadingInfo:callbackId keepCallback:NO]; - } - } -} - -// called to request heading updates when heading changes by a certain amount (filter) -- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command -{ - NSString* callbackId = command.callbackId; - NSDictionary* options = [command argumentAtIndex:0 withDefault:nil]; - NSNumber* filter = [options valueForKey:@"filter"]; - CDVHeadingData* hData = self.headingData; - - if ([self hasHeadingSupport] == NO) { - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } else { - if (!hData) { - self.headingData = [[CDVHeadingData alloc] init]; - hData = self.headingData; - } - if (hData.headingStatus != HEADINGRUNNING) { - // Tell the location manager to start notifying us of heading updates - [self startHeadingWithFilter:[filter doubleValue]]; - } else { - // if already running check to see if due to existing watch filter - if (hData.headingFilter && ![hData.headingFilter isEqualToString:callbackId]) { - // new watch filter being specified - // send heading data one last time to clear old successCallback - [self returnHeadingInfo:hData.headingFilter keepCallback:NO]; - } - } - // save the new filter callback and update the headingFilter setting - hData.headingFilter = callbackId; - // check if need to stop and restart in order to change value??? - self.locationManager.headingFilter = [filter doubleValue]; - } -} - -- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain -{ - CDVPluginResult* result = nil; - CDVHeadingData* hData = self.headingData; - - self.headingData.headingTimestamp = [NSDate date]; - - if (hData && (hData.headingStatus == HEADINGERROR)) { - // return error - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0]; - } else if (hData && (hData.headingStatus == HEADINGRUNNING) && hData.headingInfo) { - // if there is heading info, return it - CLHeading* hInfo = hData.headingInfo; - NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:4]; - NSNumber* timestamp = [NSNumber numberWithDouble:([hInfo.timestamp timeIntervalSince1970] * 1000)]; - [returnInfo setObject:timestamp forKey:@"timestamp"]; - [returnInfo setObject:[NSNumber numberWithDouble:hInfo.magneticHeading] forKey:@"magneticHeading"]; - id trueHeading = __locationStarted ? (id)[NSNumber numberWithDouble : hInfo.trueHeading] : (id)[NSNull null]; - [returnInfo setObject:trueHeading forKey:@"trueHeading"]; - [returnInfo setObject:[NSNumber numberWithDouble:hInfo.headingAccuracy] forKey:@"headingAccuracy"]; - - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo]; - [result setKeepCallbackAsBool:bRetain]; - } - if (result) { - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } -} - -- (void)stopHeading:(CDVInvokedUrlCommand*)command -{ - // CDVHeadingData* hData = self.headingData; - if (self.headingData && (self.headingData.headingStatus != HEADINGSTOPPED)) { - if (self.headingData.headingFilter) { - // callback one last time to clear callback - [self returnHeadingInfo:self.headingData.headingFilter keepCallback:NO]; - self.headingData.headingFilter = nil; - } - [self.locationManager stopUpdatingHeading]; - NSLog(@"heading STOPPED"); - self.headingData = nil; - } -} - -// helper method to check the orientation and start updating headings -- (void)startHeadingWithFilter:(CLLocationDegrees)filter -{ - // FYI UIDeviceOrientation and CLDeviceOrientation enums are currently the same - self.locationManager.headingOrientation = (CLDeviceOrientation)self.viewController.interfaceOrientation; - self.locationManager.headingFilter = filter; - [self.locationManager startUpdatingHeading]; - self.headingData.headingStatus = HEADINGSTARTING; -} - -- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager -{ - return YES; -} - -- (void)locationManager:(CLLocationManager*)manager - didUpdateHeading:(CLHeading*)heading -{ - CDVHeadingData* hData = self.headingData; - - // normally we would clear the delegate to stop getting these notifications, but - // we are sharing a CLLocationManager to get location data as well, so we do a nil check here - // ideally heading and location should use their own CLLocationManager instances - if (hData == nil) { - return; - } - - // save the data for next call into getHeadingData - hData.headingInfo = heading; - BOOL bTimeout = NO; - if (!hData.headingFilter && hData.headingTimestamp) { - bTimeout = fabs([hData.headingTimestamp timeIntervalSinceNow]) > hData.timeout; - } - - if (hData.headingStatus == HEADINGSTARTING) { - hData.headingStatus = HEADINGRUNNING; // so returnHeading info will work - - // this is the first update - for (NSString* callbackId in hData.headingCallbacks) { - [self returnHeadingInfo:callbackId keepCallback:NO]; - } - - [hData.headingCallbacks removeAllObjects]; - } - if (hData.headingFilter) { - [self returnHeadingInfo:hData.headingFilter keepCallback:YES]; - } else if (bTimeout) { - [self stopHeading:nil]; - } - hData.headingStatus = HEADINGRUNNING; // to clear any error -} - -- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error -{ - NSLog(@"locationManager::didFailWithError %@", [error localizedFailureReason]); - - // Compass Error - if ([error code] == kCLErrorHeadingFailure) { - CDVHeadingData* hData = self.headingData; - if (hData) { - if (hData.headingStatus == HEADINGSTARTING) { - // heading error during startup - report error - for (NSString* callbackId in hData.headingCallbacks) { - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } - - [hData.headingCallbacks removeAllObjects]; - } // else for frequency watches next call to getCurrentHeading will report error - if (hData.headingFilter) { - CDVPluginResult* resultFilter = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0]; - [self.commandDelegate sendPluginResult:resultFilter callbackId:hData.headingFilter]; - } - hData.headingStatus = HEADINGERROR; - } - } - - [self.locationManager stopUpdatingLocation]; - __locationStarted = NO; -} - -- (void)dealloc -{ - self.locationManager.delegate = nil; -} - -- (void)onReset -{ - [self.locationManager stopUpdatingHeading]; - self.headingData = nil; -} - -@end diff --git a/plugins/cordova-plugin-device-orientation/src/tizen/CompassProxy.js b/plugins/cordova-plugin-device-orientation/src/tizen/CompassProxy.js deleted file mode 100644 index 5afb2d5..0000000 --- a/plugins/cordova-plugin-device-orientation/src/tizen/CompassProxy.js +++ /dev/null @@ -1,57 +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. - * -*/ - -var cordova = require('cordova'), - CompassHeading = require('cordova-plugin-device-orientation.CompassHeading'), - CompassError = require('cordova-plugin-device-orientation.CompassError'); - -var compassCallback = null, - compassReady = false; - - -module.exports = { - getHeading: function (successCallback, errorCallback) { - if (window.DeviceOrientationEvent !== undefined) { - compassCallback = function (orientation) { - var heading = 360 - orientation.alpha; - - if (compassReady) { - if (successCallback) - successCallback( new CompassHeading (heading, heading, 0, 0)); - window.removeEventListener("deviceorientation", compassCallback, true); - } - compassReady = true; - }; - compassReady = false; // workaround invalid first event value returned by WRT - window.addEventListener("deviceorientation", compassCallback, true); - } - else { - if (errorCallback) - errorCallback(CompassError.COMPASS_NOT_SUPPORTED); - } - }, - - stopHeading: function (successCallback, errorCallback) { - console.log("Compass stopHeading: not implemented yet."); - } -}; - -require("cordova/tizen/commandProxy").add("Compass", module.exports); diff --git a/plugins/cordova-plugin-device-orientation/src/ubuntu/compass.cpp b/plugins/cordova-plugin-device-orientation/src/ubuntu/compass.cpp deleted file mode 100644 index a2c3bee..0000000 --- a/plugins/cordova-plugin-device-orientation/src/ubuntu/compass.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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. - */ - -#include "compass.h" - -DeviceOrientation::DeviceOrientation(Cordova *cordova): CPlugin(cordova), _validData(false) { - _compass.connectToBackend(); - connect(&_compass, SIGNAL(readingChanged()), SLOT(updateSensor())); - connect(&_compass, SIGNAL(sensorError(int)), SLOT(sensorError(int))); -} - -void DeviceOrientation::getHeading(int scId, int ecId, QVariantMap options) { - Q_UNUSED(options); - if (_compass.isConnectedToBackend() || !_compass.start()) { - this->callback(ecId, "CompassError.COMPASS_NOT_SUPPORTED"); - return; - } - - _successCallbacks << scId; - _errorCallbacks << ecId; - - if (_validData) { - reportResult(); - return; - } -} - -void DeviceOrientation::sensorError(int error) { - Q_UNUSED(error); - - for (int ecId: _errorCallbacks) { - this->callback(ecId, "CompassError.COMPASS_INTERNAL_ERR"); - } - - _errorCallbacks.clear(); - _successCallbacks.clear(); - _validData = false; -} - -void DeviceOrientation::reportResult() { - QVariantMap obj; - - obj.insert("magneticHeading", _azymuth); - obj.insert("trueHeading", _azymuth); - obj.insert("headingAccuracy", _accuracy); - obj.insert("timestamp", _timestamp); - - for (int scId: _successCallbacks) { - this->cb(scId, obj); - } - - _errorCallbacks.clear(); - _successCallbacks.clear(); -} - -void DeviceOrientation::updateSensor(){ - QCompassReading *heading = _compass.reading(); - _azymuth = heading->azimuth(); - _accuracy = heading->calibrationLevel(); - _timestamp = QDateTime::currentDateTime().toMSecsSinceEpoch(); - - _validData = true; - reportResult(); -} diff --git a/plugins/cordova-plugin-device-orientation/src/ubuntu/compass.h b/plugins/cordova-plugin-device-orientation/src/ubuntu/compass.h deleted file mode 100644 index a1f421e..0000000 --- a/plugins/cordova-plugin-device-orientation/src/ubuntu/compass.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - */ - -#ifndef COMPASS_H_HKFSAHKDFAS -#define COMPASS_H_HKFSAHKDFAS - -#include -#include -#include - -class DeviceOrientation: public CPlugin { - Q_OBJECT -public: - explicit DeviceOrientation(Cordova *cordova); - - virtual const QString fullName() override { - return DeviceOrientation::fullID(); - } - - virtual const QString shortName() override { - return "Compass"; - } - - static const QString fullID() { - return "Compass"; - } - -public slots: - void getHeading(int scId, int ecId, QVariantMap options); - -protected slots: - void updateSensor(); - void sensorError(int error); - -private: - void reportResult(); - QCompass _compass; - QList _successCallbacks; - QList _errorCallbacks; - - double _azymuth; - double _accuracy; - qtimestamp _timestamp; - bool _validData; -}; - -#endif diff --git a/plugins/cordova-plugin-device-orientation/src/windows/CompassProxy.js b/plugins/cordova-plugin-device-orientation/src/windows/CompassProxy.js deleted file mode 100644 index ee04acb..0000000 --- a/plugins/cordova-plugin-device-orientation/src/windows/CompassProxy.js +++ /dev/null @@ -1,54 +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. - * -*/ - -/*jslint sloppy:true */ -/*global Windows:true, require, module, setTimeout */ - -var cordova = require('cordova'), - CompassHeading = require('cordova-plugin-device-orientation.CompassHeading'), - CompassError = require('cordova-plugin-device-orientation.CompassError'); - - -module.exports = { - - onReadingChanged: null, - getHeading: function (win, lose) { - var deviceCompass = Windows.Devices.Sensors.Compass.getDefault(); - if (!deviceCompass) { - setTimeout(function () { - lose(CompassError.COMPASS_NOT_SUPPORTED); - }, 0); - } else { - var reading = deviceCompass.getCurrentReading(), - heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth, null, reading.timestamp.getTime()); - setTimeout(function () { - win(heading); - }, 0); - } - }, - stopHeading: function (win, lose) { - setTimeout(function () { - win(); - }, 0); - } -}; - -require("cordova/exec/proxy").add("Compass", module.exports); diff --git a/plugins/cordova-plugin-device-orientation/src/wp/Compass.cs b/plugins/cordova-plugin-device-orientation/src/wp/Compass.cs deleted file mode 100644 index d1ce894..0000000 --- a/plugins/cordova-plugin-device-orientation/src/wp/Compass.cs +++ /dev/null @@ -1,362 +0,0 @@ -/* - 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. -*/ - -using System; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Ink; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; -using DeviceCompass = Microsoft.Devices.Sensors.Compass; -using System.Windows.Threading; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Threading; -using Microsoft.Devices.Sensors; - -namespace WPCordovaClassLib.Cordova.Commands -{ - - public class Compass : BaseCommand - { - #region Static members - - /// - /// Status of listener - /// - private static int currentStatus; - - /// - /// Id for get getCompass method - /// - private static string getCompassId = "getCompassId"; - - /// - /// Compass - /// - private static DeviceCompass compass = new DeviceCompass(); - - /// - /// Listeners for callbacks - /// - private static Dictionary watchers = new Dictionary(); - - #endregion - - #region Status codes - - public const int Stopped = 0; - public const int Starting = 1; - public const int Running = 2; - public const int ErrorFailedToStart = 4; - public const int Not_Supported = 20; - - /* - * // Capture error codes - CompassError.COMPASS_INTERNAL_ERR = 0; - CompassError.COMPASS_NOT_SUPPORTED = 20; - * */ - - #endregion - - #region CompassOptions class - /// - /// Represents Accelerometer options. - /// - [DataContract] - public class CompassOptions - { - /// - /// How often to retrieve the Acceleration in milliseconds - /// - [DataMember(IsRequired = false, Name = "frequency")] - public int Frequency { get; set; } - - /// - /// The change in degrees required to initiate a watchHeadingFilter success callback. - /// - [DataMember(IsRequired = false, Name = "filter")] - public int Filter { get; set; } - - /// - /// Watcher id - /// - [DataMember(IsRequired = false, Name = "id")] - public string Id { get; set; } - - } - #endregion - - - /// - /// Time the value was last changed - /// - //private DateTime lastValueChangedTime; - - /// - /// Accelerometer options - /// - private CompassOptions compassOptions; - - //bool isDataValid; - - //bool calibrating = false; - - public Compass() - { - - } - - /// - /// Formats current coordinates into JSON format - /// - /// Coordinates in JSON format - private string GetHeadingFormatted(CompassReading reading) - { - // NOTE: timestamp is generated on the JS side, to avoid issues with format conversions - string result = String.Format("\"magneticHeading\":{0},\"headingAccuracy\":{1},\"trueHeading\":{2}", - reading.MagneticHeading.ToString("0.0", CultureInfo.InvariantCulture), - reading.HeadingAccuracy.ToString("0.0", CultureInfo.InvariantCulture), - reading.TrueHeading.ToString("0.0", CultureInfo.InvariantCulture)); - return "{" + result + "}"; - } - - public void getHeading(string options) - { - if (!DeviceCompass.IsSupported) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, Not_Supported)); - } - else - { - //if (compass == null) - //{ - // // Instantiate the compass. - // compass = new DeviceCompass(); - // compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(40); - // compass.CurrentValueChanged += new EventHandler>(compass_CurrentValueChanged); - // compass.Calibrate += new EventHandler(compass_Calibrate); - //} - - - //compass.Start(); - - } - - try - { - if (currentStatus != Running) - { - lock (compass) - { - compass.CurrentValueChanged += compass_SingleHeadingValueChanged; - compass.Start(); - this.SetStatus(Starting); - } - - long timeout = 2000; - while ((currentStatus == Starting) && (timeout > 0)) - { - timeout = timeout - 100; - Thread.Sleep(100); - } - - if (currentStatus != Running) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart)); - return; - } - } - lock (compass) - { - compass.CurrentValueChanged -= compass_SingleHeadingValueChanged; - if (watchers.Count < 1) - { - compass.Stop(); - this.SetStatus(Stopped); - } - } - } - catch (UnauthorizedAccessException) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION, ErrorFailedToStart)); - } - catch (Exception) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart)); - } - } - - void compass_SingleHeadingValueChanged(object sender, Microsoft.Devices.Sensors.SensorReadingEventArgs e) - { - this.SetStatus(Running); - if (compass.IsDataValid) - { - // trueHeading :: The heading in degrees from 0 - 359.99 at a single moment in time. - // magneticHeading:: The heading relative to the geographic North Pole in degrees 0 - 359.99 at a single moment in time. - // A negative value indicates that the true heading could not be determined. - // headingAccuracy :: The deviation in degrees between the reported heading and the true heading. - //rawMagnetometerReading = e.SensorReading.MagnetometerReading; - - //Debug.WriteLine("Compass Result :: " + GetHeadingFormatted(e.SensorReading)); - - PluginResult result = new PluginResult(PluginResult.Status.OK, GetHeadingFormatted(e.SensorReading)); - - DispatchCommandResult(result); - } - } - - /// - /// Starts listening for compass sensor - /// - /// status of listener - private int start() - { - if ((currentStatus == Running) || (currentStatus == Starting)) - { - return currentStatus; - } - try - { - lock (compass) - { - watchers.Add(getCompassId, this); - compass.CurrentValueChanged += watchers[getCompassId].compass_CurrentValueChanged; - compass.Start(); - this.SetStatus(Starting); - } - } - catch (Exception) - { - this.SetStatus(ErrorFailedToStart); - } - return currentStatus; - } - - public void startWatch(string options) - { - if (!DeviceCompass.IsSupported) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, Not_Supported)); - } - - try - { - compassOptions = JSON.JsonHelper.Deserialize(options); - } - catch (Exception ex) - { - this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); - return; - } - - if (string.IsNullOrEmpty(compassOptions.Id)) - { - this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - return; - } - - try - { - lock (compass) - { - watchers.Add(compassOptions.Id, this); - compass.CurrentValueChanged += watchers[compassOptions.Id].compass_CurrentValueChanged; - compass.Start(); - this.SetStatus(Starting); - } - } - catch (Exception) - { - this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart)); - return; - } - } - - public void stopWatch(string options) - { - try - { - compassOptions = JSON.JsonHelper.Deserialize(options); - } - catch (Exception ex) - { - this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); - return; - } - - if (string.IsNullOrEmpty(compassOptions.Id)) - { - this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - return; - } - - if (currentStatus != Stopped) - { - lock (compass) - { - Compass watcher = watchers[compassOptions.Id]; - compass.CurrentValueChanged -= watcher.compass_CurrentValueChanged; - watchers.Remove(compassOptions.Id); - watcher.Dispose(); - } - } - this.SetStatus(Stopped); - - this.DispatchCommandResult(); - } - - void compass_Calibrate(object sender, Microsoft.Devices.Sensors.CalibrationEventArgs e) - { - //throw new NotImplementedException(); - // TODO: pass calibration error to JS - } - - void compass_CurrentValueChanged(object sender, Microsoft.Devices.Sensors.SensorReadingEventArgs e) - { - this.SetStatus(Running); - if (compass.IsDataValid) - { - // trueHeading :: The heading in degrees from 0 - 359.99 at a single moment in time. - // magneticHeading:: The heading relative to the geographic North Pole in degrees 0 - 359.99 at a single moment in time. - // A negative value indicates that the true heading could not be determined. - // headingAccuracy :: The deviation in degrees between the reported heading and the true heading. - //rawMagnetometerReading = e.SensorReading.MagnetometerReading; - - //Debug.WriteLine("Compass Result :: " + GetHeadingFormatted(e.SensorReading)); - - PluginResult result = new PluginResult(PluginResult.Status.OK, GetHeadingFormatted(e.SensorReading)); - result.KeepCallback = true; - - DispatchCommandResult(result); - } - } - - /// - /// Sets current status - /// - /// current status - private void SetStatus(int status) - { - currentStatus = status; - } - - } -} diff --git a/plugins/cordova-plugin-device-orientation/tests/plugin.xml b/plugins/cordova-plugin-device-orientation/tests/plugin.xml deleted file mode 100644 index 2e69462..0000000 --- a/plugins/cordova-plugin-device-orientation/tests/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Cordova Device Orientation Plugin Tests - Apache 2.0 - - - - diff --git a/plugins/cordova-plugin-device-orientation/tests/tests.js b/plugins/cordova-plugin-device-orientation/tests/tests.js deleted file mode 100644 index 7353178..0000000 --- a/plugins/cordova-plugin-device-orientation/tests/tests.js +++ /dev/null @@ -1,252 +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. -* -*/ - -exports.defineAutoTests = function () { - var fail = function (done, message) { - message = (typeof message !== 'string') ? "Forced failure: wrong callback called" : message; - expect(true).toFailWithMessage(message); - done(); - }, - unexpectedSuccess = "Forced failure: success callback should not have been called", - unexpectedFailure = "Forced failure: error callback should not have been called"; - - describe('Compass (navigator.compass)', function () { - beforeEach(function () { - jasmine.Expectation.addMatchers({ - toFailWithMessage: function () { - return { - compare: function (actual, customMessage) { - var pass = false; - if (customMessage === undefined) { - customMessage = "Forced failure: wrong callback called"; - } - return { - pass: pass, - message: customMessage - }; - } - }; - } - }); - }); - - var isCompassAvailable = true; - - beforeEach(function (done) { - if (!isCompassAvailable) { - // if we're already ensured that compass is not available, no need to check it again - done(); - return; - } - // Try to access compass device, and if it is not available - // set hardwarefailure flag to mark some tests pending - navigator.compass.getCurrentHeading(done, function (error) { - if (error.code == CompassError.COMPASS_NOT_SUPPORTED) { - isCompassAvailable = false; - } - done(); - }); - }); - - it("compass.spec.1 should exist", function () { - expect(navigator.compass).toBeDefined(); - }); - - it("compass.spec.2 should contain a getCurrentHeading function", function () { - expect(navigator.compass.getCurrentHeading).toBeDefined(); - expect(typeof navigator.compass.getCurrentHeading == 'function').toBe(true); - }); - - it("compass.spec.3 getCurrentHeading success callback should be called with a Heading object", function (done) { - if (!isCompassAvailable) { - pending(); - } - navigator.compass.getCurrentHeading(function (a) { - expect(a instanceof CompassHeading).toBe(true); - expect(a.magneticHeading).toBeDefined(); - expect(typeof a.magneticHeading == 'number').toBe(true); - expect(a.trueHeading).not.toBe(undefined); - expect(typeof a.trueHeading == 'number' || a.trueHeading === null).toBe(true); - expect(a.headingAccuracy).not.toBe(undefined); - expect(typeof a.headingAccuracy == 'number' || a.headingAccuracy === null).toBe(true); - expect(typeof a.timestamp == 'number').toBe(true); - done(); - }, fail.bind(null, done, unexpectedFailure)); - }); - - it("compass.spec.4 should contain a watchHeading function", function () { - expect(navigator.compass.watchHeading).toBeDefined(); - expect(typeof navigator.compass.watchHeading == 'function').toBe(true); - }); - - it("compass.spec.5 should contain a clearWatch function", function () { - expect(navigator.compass.clearWatch).toBeDefined(); - expect(typeof navigator.compass.clearWatch == 'function').toBe(true); - }); - - describe('Compass Constants (window.CompassError)', function () { - it("compass.spec.1 should exist", function () { - expect(window.CompassError).toBeDefined(); - expect(window.CompassError.COMPASS_INTERNAL_ERR).toBe(0); - expect(window.CompassError.COMPASS_NOT_SUPPORTED).toBe(20); - }); - }); - - describe('Compass Heading model (CompassHeading)', function () { - it("compass.spec.1 should exist", function () { - expect(CompassHeading).toBeDefined(); - }); - - it("compass.spec.8 should be able to create a new CompassHeading instance with no parameters", function () { - var h = new CompassHeading(); - expect(h).toBeDefined(); - expect(h.magneticHeading).toBeUndefined(); - expect(h.trueHeading).toBeUndefined(); - expect(h.headingAccuracy).toBeUndefined(); - expect(typeof h.timestamp == 'number').toBe(true); - }); - - it("compass.spec.9 should be able to create a new CompassHeading instance with parameters", function () { - var h = new CompassHeading(1, 2, 3, 4); - expect(h.magneticHeading).toBe(1); - expect(h.trueHeading).toBe(2); - expect(h.headingAccuracy).toBe(3); - expect(h.timestamp.valueOf()).toBe(4); - expect(typeof h.timestamp == 'number').toBe(true); - }); - }); - }); -}; - -/******************************************************************************/ -/******************************************************************************/ -/******************************************************************************/ - -exports.defineManualTests = function (contentEl, createActionButton) { - function roundNumber(num) { - var dec = 3; - var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); - return result; - } - - var watchCompassId = null; - - /** - * Start watching compass - */ - var watchCompass = function () { - console.log("watchCompass()"); - - // Success callback - var success = function (a) { - document.getElementById('compassHeading').innerHTML = roundNumber(a.magneticHeading); - }; - - // Fail callback - var fail = function (e) { - console.log("watchCompass fail callback with error code " + e); - stopCompass(); - setCompassStatus(e); - }; - - // Stop compass if running - stopCompass(); - - // Update heading every 1 sec - var opt = {}; - opt.frequency = 1000; - watchCompassId = navigator.compass.watchHeading(success, fail, opt); - - setCompassStatus("Running"); - }; - - /** - * Stop watching the acceleration - */ - var stopCompass = function () { - setCompassStatus("Stopped"); - if (watchCompassId) { - navigator.compass.clearWatch(watchCompassId); - watchCompassId = null; - } - }; - - /** - * Get current compass - */ - var getCompass = function () { - console.log("getCompass()"); - - // Stop compass if running - stopCompass(); - - // Success callback - var success = function (a) { - document.getElementById('compassHeading').innerHTML = roundNumber(a.magneticHeading); - }; - - // Fail callback - var fail = function (e) { - console.log("getCompass fail callback with error code " + e.toString); - setCompassStatus(e); - }; - - // Make call - var opt = {}; - navigator.compass.getCurrentHeading(success, fail, opt); - }; - - /** - * Set compass status - */ - var setCompassStatus = function (status) { - document.getElementById('compass_status').innerHTML = status; - }; - - /******************************************************************************/ - - var orientation_tests = '

iOS devices may bring up a calibration screen when initiating these tests

' + - '
' + - 'Expected result: Will update the status box with current heading. Status will read "Stopped"' + - '

' + - 'Expected result: When pressed, will start a watch on the compass and update the heading value when heading changes. Status will read "Running"' + - '

' + - 'Expected result: Will clear the compass watch, so heading value will no longer be updated. Status will read "Stopped"'; - - contentEl.innerHTML = '
Status: ' + - 'Stopped' + - '' + - '
Heading: ' + - '
' + - orientation_tests; - - createActionButton('Get Compass', function () { - getCompass(); - }, 'getCompass'); - - createActionButton('Start Watching Compass', function () { - watchCompass(); - }, 'watchCompass'); - - createActionButton('Stop Watching Compass', function () { - stopCompass(); - }, 'stopCompass'); -}; diff --git a/plugins/cordova-plugin-device-orientation/www/CompassError.js b/plugins/cordova-plugin-device-orientation/www/CompassError.js deleted file mode 100644 index 7b5b485..0000000 --- a/plugins/cordova-plugin-device-orientation/www/CompassError.js +++ /dev/null @@ -1,34 +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. - * -*/ - -/** - * CompassError. - * An error code assigned by an implementation when an error has occurred - * @constructor - */ -var CompassError = function(err) { - this.code = (err !== undefined ? err : null); -}; - -CompassError.COMPASS_INTERNAL_ERR = 0; -CompassError.COMPASS_NOT_SUPPORTED = 20; - -module.exports = CompassError; diff --git a/plugins/cordova-plugin-device-orientation/www/CompassHeading.js b/plugins/cordova-plugin-device-orientation/www/CompassHeading.js deleted file mode 100644 index 70343ee..0000000 --- a/plugins/cordova-plugin-device-orientation/www/CompassHeading.js +++ /dev/null @@ -1,29 +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. - * -*/ - -var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) { - this.magneticHeading = magneticHeading; - this.trueHeading = trueHeading; - this.headingAccuracy = headingAccuracy; - this.timestamp = timestamp || new Date().getTime(); -}; - -module.exports = CompassHeading; diff --git a/plugins/cordova-plugin-device-orientation/www/compass.js b/plugins/cordova-plugin-device-orientation/www/compass.js deleted file mode 100644 index 603e727..0000000 --- a/plugins/cordova-plugin-device-orientation/www/compass.js +++ /dev/null @@ -1,118 +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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - utils = require('cordova/utils'), - CompassHeading = require('./CompassHeading'), - CompassError = require('./CompassError'), - - timers = {}, - eventTimerId = null, - compass = { - /** - * Asynchronously acquires the current heading. - * @param {Function} successCallback The function to call when the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {CompassOptions} options The options for getting the heading data (not used). - */ - getCurrentHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments); - - var win = function(result) { - var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp); - successCallback(ch); - }; - var fail = errorCallback && function(code) { - var ce = new CompassError(code); - errorCallback(ce); - }; - - // Get heading - exec(win, fail, "Compass", "getHeading", [options]); - }, - - /** - * Asynchronously acquires the heading repeatedly at a given interval. - * @param {Function} successCallback The function to call each time the heading - * data is available - * @param {Function} errorCallback The function to call when there is an error - * getting the heading data. - * @param {HeadingOptions} options The options for getting the heading data - * such as timeout and the frequency of the watch. For iOS, filter parameter - * specifies to watch via a distance filter rather than time. - */ - watchHeading:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'compass.watchHeading', arguments); - // Default interval (100 msec) - var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100; - var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0; - - var id = utils.createUUID(); - if (filter > 0) { - // is an iOS request for watch by filter, no timer needed - timers[id] = "iOS"; - compass.getCurrentHeading(successCallback, errorCallback, options); - } else { - // Start watch timer to get headings - timers[id] = window.setInterval(function() { - compass.getCurrentHeading(successCallback, errorCallback); - }, frequency); - } - - if (cordova.platformId === 'browser' && !eventTimerId) { - // Start firing deviceorientation events if haven't already - var deviceorientationEvent = new Event('deviceorientation'); - eventTimerId = window.setInterval(function() { - window.dispatchEvent(deviceorientationEvent); - }, 200); - } - - return id; - }, - - /** - * Clears the specified heading watch. - * @param {String} id The ID of the watch returned from #watchHeading. - */ - clearWatch:function(id) { - // Stop javascript timer & remove from timer list - if (id && timers[id]) { - if (timers[id] != "iOS") { - clearInterval(timers[id]); - } else { - // is iOS watch by filter so call into device to stop - exec(null, null, "Compass", "stopHeading", []); - } - delete timers[id]; - - if (eventTimerId && Object.keys(timers).length === 0) { - // No more watchers, so stop firing 'deviceorientation' events - window.clearInterval(eventTimerId); - eventTimerId = null; - } - } - } - }; - -module.exports = compass; diff --git a/plugins/cordova-plugin-device/CONTRIBUTING.md b/plugins/cordova-plugin-device/CONTRIBUTING.md new file mode 100644 index 0000000..4c8e6a5 --- /dev/null +++ b/plugins/cordova-plugin-device/CONTRIBUTING.md @@ -0,0 +1,37 @@ + + +# Contributing to Apache Cordova + +Anyone can contribute to Cordova. And we need your contributions. + +There are multiple ways to contribute: report bugs, improve the docs, and +contribute code. + +For instructions on this, start with the +[contribution overview](http://cordova.apache.org/contribute/). + +The details are explained there, but the important items are: + - Sign and submit an Apache ICLA (Contributor License Agreement). + - Have a Jira issue open that corresponds to your contribution. + - Run the tests so your patch doesn't break existing functionality. + +We look forward to your contributions! diff --git a/plugins/cordova-plugin-device/LICENSE b/plugins/cordova-plugin-device/LICENSE new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/plugins/cordova-plugin-device/LICENSE @@ -0,0 +1,202 @@ + + 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 diff --git a/plugins/cordova-plugin-device/NOTICE b/plugins/cordova-plugin-device/NOTICE new file mode 100644 index 0000000..8ec56a5 --- /dev/null +++ b/plugins/cordova-plugin-device/NOTICE @@ -0,0 +1,5 @@ +Apache Cordova +Copyright 2012 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/plugins/cordova-plugin-device/README.md b/plugins/cordova-plugin-device/README.md new file mode 100644 index 0000000..6ef4657 --- /dev/null +++ b/plugins/cordova-plugin-device/README.md @@ -0,0 +1,286 @@ + + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +# cordova-plugin-device + +This plugin defines a global `device` object, which describes the device's hardware and software. +Although the object is in the global scope, it is not available until after the `deviceready` event. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + +Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) + + +## Installation + + cordova plugin add cordova-plugin-device + +## Properties + +- device.cordova +- device.model +- device.platform +- device.uuid +- device.version +- device.manufacturer +- device.isVirtual +- device.serial + +## device.cordova + +Get the version of Cordova running on the device. + +### Supported Platforms + +- Amazon Fire OS +- Android +- BlackBerry 10 +- Browser +- Firefox OS +- iOS +- Tizen +- Windows Phone 7 and 8 +- Windows +- OSX + +## device.model + +The `device.model` returns the name of the device's model or +product. The value is set by the device manufacturer and may be +different across versions of the same product. + +### Supported Platforms + +- Android +- BlackBerry 10 +- Browser +- iOS +- Tizen +- Windows Phone 7 and 8 +- Windows +- OSX + +### Quick Example + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models + // OSX: returns "x86_64" + // + var model = device.model; + +### Android Quirks + +- Gets the [product name](http://developer.android.com/reference/android/os/Build.html#PRODUCT) instead of the [model name](http://developer.android.com/reference/android/os/Build.html#MODEL), which is often the production code name. For example, the Nexus One returns `Passion`, and Motorola Droid returns `voles`. + +### Tizen Quirks + +- Returns the device model assigned by the vendor, for example, `TIZEN` + +### Windows Phone 7 and 8 Quirks + +- Returns the device model specified by the manufacturer. For example, the Samsung Focus returns `SGH-i917`. + +## device.platform + +Get the device's operating system name. + + var string = device.platform; + +### Supported Platforms + +- Android +- BlackBerry 10 +- Browser +- Firefox OS +- iOS +- Tizen +- Windows Phone 7 and 8 +- Windows +- OSX + +### Quick Example + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - "browser" + // - "iOS" + // - "WinCE" + // - "Tizen" + // - "Mac OS X" + var devicePlatform = device.platform; + +### Windows Phone 7 Quirks + +Windows Phone 7 devices report the platform as `WinCE`. + +### Windows Phone 8 Quirks + +Windows Phone 8 devices report the platform as `Win32NT`. + +## device.uuid + +Get the device's Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). + + var string = device.uuid; + +### Description + +The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model. + +### Supported Platforms + +- Android +- BlackBerry 10 +- iOS +- Tizen +- Windows Phone 7 and 8 +- Windows +- OSX + +### Quick Example + + // Android: Returns a random 64-bit integer (as a string, again!) + // The integer is generated on the device's first boot + // + // BlackBerry: Returns the PIN number of the device + // This is a nine-digit unique integer (as a string, though!) + // + // iPhone: (Paraphrased from the UIDevice Class documentation) + // Returns the [UIDevice identifierForVendor] UUID which is unique and the same for all apps installed by the same vendor. However the UUID can be different if the user deletes all apps from the vendor and then reinstalls it. + // Windows Phone 7 : Returns a hash of device+current user, + // if the user is not defined, a guid is generated and will persist until the app is uninstalled + // Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number + // unique to every GSM and UMTS mobile phone. + var deviceID = device.uuid; + +### iOS Quirk + +The `uuid` on iOS uses the identifierForVendor property. It is unique to the device across the same vendor, but will be different for different vendors and will change if all apps from the vendor are deleted and then reinstalled. +Refer [here](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor) for details. +The UUID will be the same if app is restored from a backup or iCloud as it is saved in preferences. Users using older versions of this plugin will still receive the same previous UUID generated by another means as it will be retrieved from preferences. + +### OSX Quirk + +The `uuid` on OSX is generated automatically if it does not exist yet and is stored in the `standardUserDefaults` in the `CDVUUID` property. + +### Windows Phone 7 and 8 Quirks + +The `uuid` for Windows Phone 7 requires the permission +`ID_CAP_IDENTITY_DEVICE`. Microsoft will likely deprecate this +property soon. If the capability is not available, the application +generates a persistent guid that is maintained for the duration of the +application's installation on the device. + +## device.version + +Get the operating system version. + + var string = device.version; + +### Supported Platforms + +- Android 2.1+ +- BlackBerry 10 +- Browser +- iOS +- Tizen +- Windows Phone 7 and 8 +- Windows +- OSX + +### Quick Example + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384 + // Tizen: returns "TIZEN_20120425_2" + // OSX: El Capitan would return "10.11.2" + // + var deviceVersion = device.version; + +## device.manufacturer + +Get the device's manufacturer. + + var string = device.manufacturer; + +### Supported Platforms + +- Android +- BlackBerry 10 +- iOS +- Windows Phone 7 and 8 +- Windows + +### Quick Example + + // Android: Motorola XT1032 would return "motorola" + // BlackBerry: returns "BlackBerry" + // iPhone: returns "Apple" + // + var deviceManufacturer = device.manufacturer; + +## device.isVirtual + +whether the device is running on a simulator. + + var isSim = device.isVirtual; + +### Supported Platforms + +- Android 2.1+ +- iOS +- Windows Phone 8 +- Windows +- OSX + +### OSX Quirk + +The `isVirtual` property on OS X always returns false. + +## device.serial + +Get the device hardware serial number ([SERIAL](http://developer.android.com/reference/android/os/Build.html#SERIAL)). + + var string = device.serial; + +### Supported Platforms + +- Android +- OSX + diff --git a/plugins/cordova-plugin-device/RELEASENOTES.md b/plugins/cordova-plugin-device/RELEASENOTES.md new file mode 100644 index 0000000..96376cf --- /dev/null +++ b/plugins/cordova-plugin-device/RELEASENOTES.md @@ -0,0 +1,134 @@ + +# Release Notes + +### 1.1.1 (Jan 15, 2016) +* CB-10238 **OSX** Move `device-plugin` out from `cordovalib` to the plugin repository +* CB-9923 Update `device.platform` documentation for **Browser** platform + +### 1.1.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* Add `isVirtual` for **Windows Phone 8.x** +* Added basic **Android** support for hardware serial number +* [CB-9865](https://issues.apache.org/jira/browse/CB-9865) Better simulator detection for **iOS** +* Fixing contribute link. +* Added **WP8** implementation +* update to use `TARGET_OS_SIMULATOR` as `TARGET_IPHONE_SIMULATOR` is deprecated. +* update code to use 'isVirtual' +* create test to verify existence and type of new property 'isVirtual' +* add `isSimulator` for **iOS** & **Android** device +* Updated documentation to mention backwards compatibility +* Updated **README** to reflect new behaviour and quirks on **iOS** +* Check user defaults first to maintain backwards compatibility +* Changed `UUID` to use `[UIDevice identifierForVendor]` + +### 1.0.1 (Jun 17, 2015) +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-device documentation translation: cordova-plugin-device +* Attempts to corrent npm markdown issue + +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* remove defunct windows8 version +* add travis badge +* Add cross-plugin ios paramedic test running for TravisCI +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file + +### 0.3.0 (Feb 04, 2015) +* Added device.manufacturer property for Android, iOS, Blackberry, WP8 +* Support for Windows Phone 8 ANID2 ANID is only supported up to Windows Phone 7.5 +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) Use a local copy of uniqueAppInstanceIdentifier rather than CordovaLib's version +* browser: Fixed a bug that caused an "cannot call method of undefined" error if the browser's user agent wasn't recognized + +### 0.2.13 (Dec 02, 2014) +* Changing `device.platform` to always report the platform as "browser". +* [CB-5892](https://issues.apache.org/jira/browse/CB-5892) - Remove deprecated `window.Settings` +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-device documentation translation: cordova-plugin-device +* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin + +### 0.2.12 (Sep 17, 2014) +* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-device documentation translation +* [CB-7552](https://issues.apache.org/jira/browse/CB-7552) device.name docs have not been removed +* [fxos] Fix cordova version +* added status box and documentation to manual tests +* [fxos] Fix cordova version +* added status box and documentation to manual tests +* Added plugin support for the browser +* [CB-7262](https://issues.apache.org/jira/browse/CB-7262) Adds support for universal windows apps. + +### 0.2.11 (Aug 06, 2014) +* [FFOS] update DeviceProxy.js +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs +* Use Windows system calls to get better info + +### 0.2.10 (Jun 05, 2014) +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #12 +* Changing 1.5 to 2.0 +* added firefoxos version - conversion +* added firefoxos version +* [CB-6800](https://issues.apache.org/jira/browse/CB-6800) Add license +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md + +### 0.2.9 (Apr 17, 2014) +* [CB-5105](https://issues.apache.org/jira/browse/CB-5105): [Android, windows8, WP, BlackBerry10] Removed dead code for device.version +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* Add NOTICE file + +### 0.2.8 (Feb 05, 2014) +* Tizen support added + +### 0.2.7 (Jan 07, 2014) +* [CB-5737](https://issues.apache.org/jira/browse/CB-5737) Fix exception on close caused by left over telephony code from [CB-5504](https://issues.apache.org/jira/browse/CB-5504) + +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Device plugin +* [CB-5504](https://issues.apache.org/jira/browse/CB-5504) Moving Telephony Logic out of Device + +### 0.2.5 (Dec 4, 2013) +* [CB-5316](https://issues.apache.org/jira/browse/CB-5316) Spell Cordova as a brand unless it's a command or script +* [ubuntu] use cordova/exec/proxy +* add ubuntu platform +* Modify Device.platform logic to use amazon-fireos as the platform for Amazon Devices +* 1. Added amazon-fireos platform. 2. Change to use cordova-amazon-fireos as the platform if user agent contains 'cordova-amazon-fireos' + +### 0.2.4 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag in plugin.xml for device plugin +* [CB-5085](https://issues.apache.org/jira/browse/CB-5085) device.cordova returning wrong value +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [windows8] commandProxy has moved +* [BlackBerry10] removed uneeded permission tags in plugin.xml +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.device to org.apache.cordova.device +* Rename CHANGELOG.md -> RELEASENOTES.md +* updated to use commandProxy for ffos +* add firefoxos support +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. + +### 0.2.1 (Sept 5, 2013) +* removed extraneous print statement +* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change diff --git a/plugins/cordova-plugin-device/doc/de/README.md b/plugins/cordova-plugin-device/doc/de/README.md new file mode 100644 index 0000000..81f89e9 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/de/README.md @@ -0,0 +1,203 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +Dieses Plugin definiert eine globale `device` -Objekt, das des Geräts Hard- und Software beschreibt. Das Objekt im globalen Gültigkeitsbereich ist es zwar nicht verfügbar bis nach dem `deviceready` Ereignis. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Installation + + cordova plugin add cordova-plugin-device + + +## Eigenschaften + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +Rufen Sie die Version von Cordova, die auf dem Gerät ausgeführt. + +### Unterstützte Plattformen + + * Amazon Fire OS + * Android + * BlackBerry 10 + * Browser + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 und 8 + * Windows 8 + +## device.model + +Die `device.model` gibt den Namen der Modell- oder des Geräts zurück. Der Wert wird vom Gerätehersteller festgelegt und kann zwischen den Versionen des gleichen Produkts unterschiedlich sein. + +### Unterstützte Plattformen + + * Android + * BlackBerry 10 + * Browser + * iOS + * Tizen + * Windows Phone 7 und 8 + * Windows 8 + +### Kurzes Beispiel + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Finden Sie unter http://theiphonewiki.com/wiki/index.php?title=Models / / Var-Modell = device.model; + + +### Android Eigenarten + + * Ruft den [Produktname](http://developer.android.com/reference/android/os/Build.html#PRODUCT) anstelle des [Modellnamens](http://developer.android.com/reference/android/os/Build.html#MODEL), das ist oft der Codename für die Produktion. Beispielsweise das Nexus One gibt `Passion` , und Motorola Droid gibt`voles`. + +### Tizen Macken + + * Gibt z. B. das Gerätemodell von dem Kreditor zugeordnet,`TIZEN` + +### Windows Phone 7 und 8 Eigenarten + + * Gibt das vom Hersteller angegebenen Gerätemodell zurück. Beispielsweise gibt der Samsung-Fokus`SGH-i917`. + +## device.platform + +Name des Betriebssystems des Geräts zu erhalten. + + var string = device.platform; + + +### Unterstützte Plattformen + + * Android + * BlackBerry 10 + * Browser4 + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 und 8 + * Windows 8 + +### Kurzes Beispiel + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 Macken + +Windows Phone 7 Geräte melden die Plattform als`WinCE`. + +### Windows Phone 8 Macken + +Windows Phone 8 Geräte melden die Plattform als`Win32NT`. + +## device.uuid + +Des Geräts Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier) zu erhalten). + + var string = device.uuid; + + +### Beschreibung + +Die Details wie eine UUID generiert wird werden vom Gerätehersteller und beziehen sich auf die Plattform oder das Modell des Geräts. + +### Unterstützte Plattformen + + * Android + * BlackBerry 10 + * iOS + * Tizen + * Windows Phone 7 und 8 + * Windows 8 + +### Kurzes Beispiel + + / / Android: wird eine zufällige 64-Bit-Ganzzahl (als Zeichenfolge, wieder!) / / die ganze Zahl wird beim ersten Start des Geräts erzeugt / / / / BlackBerry: gibt die PIN-Nummer des Gerätes / / Dies ist eine neunstellige eindeutige Ganzzahl (als String, obwohl!) / / / / iPhone: (paraphrasiert aus der Dokumentation zur UIDevice-Klasse) / / liefert eine Reihe von Hash-Werte, die aus mehreren Hardware erstellt identifiziert. + / / Es ist gewährleistet, dass für jedes Gerät eindeutig sein und kann nicht gebunden werden / / an den Benutzer weitergeleitet. + / / Windows Phone 7: gibt einen Hash des Gerät + aktueller Benutzer, / / wenn der Benutzer nicht definiert ist, eine Guid generiert und wird weiter bestehen, bis die app deinstalliert wird / / Tizen: gibt das Gerät IMEI (International Mobile Equipment Identity oder IMEI ist eine Zahl / / einzigartig für jedes GSM- und UMTS-Handy. + var deviceID = device.uuid; + + +### iOS Quirk + +Die `uuid` auf iOS ist nicht eindeutig zu einem Gerät, aber für jede Anwendung, für jede Installation variiert. Es ändert sich, wenn Sie löschen und neu die app installieren, und möglicherweise auch beim iOS zu aktualisieren, oder auch ein Upgrade möglich die app pro Version (scheinbaren in iOS 5.1). Die `uuid` ist kein zuverlässiger Wert. + +### Windows Phone 7 und 8 Eigenarten + +Die `uuid` für Windows Phone 7 die Berechtigung erfordert `ID_CAP_IDENTITY_DEVICE` . Microsoft wird diese Eigenschaft wahrscheinlich bald abzuschaffen. Wenn die Funktion nicht verfügbar ist, generiert die Anwendung eine persistente Guid, die für die Dauer der Installation der Anwendung auf dem Gerät gewährleistet ist. + +## device.version + +Version des Betriebssystems zu erhalten. + + var string = device.version; + + +### Unterstützte Plattformen + + * Android 2.1 + + * BlackBerry 10 + * Browser + * iOS + * Tizen + * Windows Phone 7 und 8 + * Windows 8 + +### Kurzes Beispiel + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/de/index.md b/plugins/cordova-plugin-device/doc/de/index.md new file mode 100644 index 0000000..e3a537e --- /dev/null +++ b/plugins/cordova-plugin-device/doc/de/index.md @@ -0,0 +1,206 @@ + + +# cordova-plugin-device + +Dieses Plugin definiert eine globale `device` -Objekt, das des Geräts Hard- und Software beschreibt. Das Objekt im globalen Gültigkeitsbereich ist es zwar nicht verfügbar bis nach dem `deviceready` Ereignis. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Installation + + cordova plugin add cordova-plugin-device + + +## Eigenschaften + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +Rufen Sie die Version von Cordova, die auf dem Gerät ausgeführt. + +### Unterstützte Plattformen + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Browser +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 und 8 +* Windows 8 + +## device.model + +Die `device.model` gibt den Namen der Modell- oder des Geräts zurück. Der Wert wird vom Gerätehersteller festgelegt und kann zwischen den Versionen des gleichen Produkts unterschiedlich sein. + +### Unterstützte Plattformen + +* Android +* BlackBerry 10 +* Browser +* iOS +* Tizen +* Windows Phone 7 und 8 +* Windows 8 + +### Kurzes Beispiel + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Finden Sie unter http://theiphonewiki.com/wiki/index.php?title=Models / / Var-Modell = device.model; + + +### Android Eigenarten + +* Ruft den [Produktname][1] anstelle des [Modellnamens][2], das ist oft der Codename für die Produktion. Beispielsweise das Nexus One gibt `Passion` , und Motorola Droid gibt`voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + [2]: http://developer.android.com/reference/android/os/Build.html#MODEL + +### Tizen Macken + +* Gibt z. B. das Gerätemodell von dem Kreditor zugeordnet,`TIZEN` + +### Windows Phone 7 und 8 Eigenarten + +* Gibt das vom Hersteller angegebenen Gerätemodell zurück. Beispielsweise gibt der Samsung-Fokus`SGH-i917`. + +## device.platform + +Name des Betriebssystems des Geräts zu erhalten. + + var string = device.platform; + + +### Unterstützte Plattformen + +* Android +* BlackBerry 10 +* Browser4 +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 und 8 +* Windows 8 + +### Kurzes Beispiel + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 Macken + +Windows Phone 7 Geräte melden die Plattform als`WinCE`. + +### Windows Phone 8 Macken + +Windows Phone 8 Geräte melden die Plattform als`Win32NT`. + +## device.uuid + +Des Geräts Universally Unique Identifier ([UUID][3] zu erhalten). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### Beschreibung + +Die Details wie eine UUID generiert wird werden vom Gerätehersteller und beziehen sich auf die Plattform oder das Modell des Geräts. + +### Unterstützte Plattformen + +* Android +* BlackBerry 10 +* iOS +* Tizen +* Windows Phone 7 und 8 +* Windows 8 + +### Kurzes Beispiel + + / / Android: wird eine zufällige 64-Bit-Ganzzahl (als Zeichenfolge, wieder!) / / die ganze Zahl wird beim ersten Start des Geräts erzeugt / / / / BlackBerry: gibt die PIN-Nummer des Gerätes / / Dies ist eine neunstellige eindeutige Ganzzahl (als String, obwohl!) / / / / iPhone: (paraphrasiert aus der Dokumentation zur UIDevice-Klasse) / / liefert eine Reihe von Hash-Werte, die aus mehreren Hardware erstellt identifiziert. + / / Es ist gewährleistet, dass für jedes Gerät eindeutig sein und kann nicht gebunden werden / / an den Benutzer weitergeleitet. + / / Windows Phone 7: gibt einen Hash des Gerät + aktueller Benutzer, / / wenn der Benutzer nicht definiert ist, eine Guid generiert und wird weiter bestehen, bis die app deinstalliert wird / / Tizen: gibt das Gerät IMEI (International Mobile Equipment Identity oder IMEI ist eine Zahl / / einzigartig für jedes GSM- und UMTS-Handy. + var deviceID = device.uuid; + + +### iOS Quirk + +Die `uuid` auf iOS ist nicht eindeutig zu einem Gerät, aber für jede Anwendung, für jede Installation variiert. Es ändert sich, wenn Sie löschen und neu die app installieren, und möglicherweise auch beim iOS zu aktualisieren, oder auch ein Upgrade möglich die app pro Version (scheinbaren in iOS 5.1). Die `uuid` ist kein zuverlässiger Wert. + +### Windows Phone 7 und 8 Eigenarten + +Die `uuid` für Windows Phone 7 die Berechtigung erfordert `ID_CAP_IDENTITY_DEVICE` . Microsoft wird diese Eigenschaft wahrscheinlich bald abzuschaffen. Wenn die Funktion nicht verfügbar ist, generiert die Anwendung eine persistente Guid, die für die Dauer der Installation der Anwendung auf dem Gerät gewährleistet ist. + +## device.version + +Version des Betriebssystems zu erhalten. + + var string = device.version; + + +### Unterstützte Plattformen + +* Android 2.1 + +* BlackBerry 10 +* Browser +* iOS +* Tizen +* Windows Phone 7 und 8 +* Windows 8 + +### Kurzes Beispiel + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/es/README.md b/plugins/cordova-plugin-device/doc/es/README.md new file mode 100644 index 0000000..a27abfb --- /dev/null +++ b/plugins/cordova-plugin-device/doc/es/README.md @@ -0,0 +1,216 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +Este plugin define un global `device` objeto que describe del dispositivo hardware y software. Aunque el objeto está en el ámbito global, no está disponible hasta después de la `deviceready` evento. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Instalación + + cordova plugin add cordova-plugin-device + + +## Propiedades + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +Obtener la versión de Cordova que se ejecuta en el dispositivo. + +### Plataformas soportadas + + * Amazon fire OS + * Android + * BlackBerry 10 + * Explorador + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 y 8 + * Windows 8 + +## device.model + +El `device.model` devuelve el nombre de modelo del dispositivo o producto. El valor es fijado por el fabricante del dispositivo y puede ser diferente a través de versiones del mismo producto. + +### Plataformas soportadas + + * Android + * BlackBerry 10 + * Explorador + * iOS + * Tizen + * Windows Phone 7 y 8 + * Windows 8 + +### Ejemplo rápido + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models + // + var model = device.model; + + +### Rarezas Android + + * Obtiene el [nombre del producto](http://developer.android.com/reference/android/os/Build.html#PRODUCT) en lugar del [nombre de la modelo](http://developer.android.com/reference/android/os/Build.html#MODEL), que es a menudo el nombre de código de producción. Por ejemplo, el Nexus One devuelve `Passion` y Motorola Droid devuelve `voles`. + +### Rarezas Tizen + + * Devuelve que el modelo de dispositivo asignado por el proveedor, por ejemplo, `TIZEN` + +### Windows Phone 7 y 8 rarezas + + * Devuelve el modelo de dispositivo especificado por el fabricante. Por ejemplo, el Samsung Focus devuelve `SGH-i917`. + +## device.platform + +Obtener el nombre del sistema operativo del dispositivo. + + var string = device.platform; + + +### Plataformas soportadas + + * Android + * BlackBerry 10 + * Browser4 + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 y 8 + * Windows 8 + +### Ejemplo rápido + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 rarezas + +Dispositivos Windows Phone 7 informe de la plataforma como `WinCE`. + +### Windows Phone 8 rarezas + +Dispositivos Windows Phone 8 Informe la plataforma como `Win32NT`. + +## device.uuid + +Obtener identificador universalmente única del dispositivo ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). + + var string = device.uuid; + + +### Descripción + +Los detalles de cómo se genera un UUID son determinados por el fabricante del dispositivo y son específicos a la plataforma del dispositivo o modelo. + +### Plataformas soportadas + + * Android + * BlackBerry 10 + * iOS + * Tizen + * Windows Phone 7 y 8 + * Windows 8 + +### Ejemplo rápido + + // Android: Returns a random 64-bit integer (as a string, again!) + // The integer is generated on the device's first boot + // + // BlackBerry: Returns the PIN number of the device + // This is a nine-digit unique integer (as a string, though!) + // + // iPhone: (Paraphrased from the UIDevice Class documentation) + // Returns a string of hash values created from multiple hardware identifies. + // It is guaranteed to be unique for every device and can't be tied + // to the user account. + // Windows Phone 7 : Returns a hash of device+current user, + // if the user is not defined, a guid is generated and will persist until the app is uninstalled + // Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number + // unique to every GSM and UMTS mobile phone. + var deviceID = device.uuid; + + +### Rarezas de iOS + +El `uuid` en iOS no es exclusiva de un dispositivo, pero varía para cada aplicación, para cada instalación. Cambia si puedes borrar y volver a instalar la aplicación, y posiblemente también cuándo actualizar iOS, o incluso mejorar la aplicación por la versión (evidente en iOS 5.1). El `uuid` no es un valor confiable. + +### Windows Phone 7 y 8 rarezas + +El `uuid` para Windows Phone 7 requiere el permiso `ID_CAP_IDENTITY_DEVICE`. Microsoft pronto probablemente desaprueban esta propiedad. Si la capacidad no está disponible, la aplicación genera un guid persistente que se mantiene durante la duración de la instalación de la aplicación en el dispositivo. + +## device.version + +Obtener la versión del sistema operativo. + + var string = device.version; + + +### Plataformas soportadas + + * Android 2.1 + + * BlackBerry 10 + * Explorador + * iOS + * Tizen + * Windows Phone 7 y 8 + * Windows 8 + +### Ejemplo rápido + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/es/index.md b/plugins/cordova-plugin-device/doc/es/index.md new file mode 100644 index 0000000..f4a5897 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/es/index.md @@ -0,0 +1,220 @@ + + +# cordova-plugin-device + +Este plugin define un global `device` objeto que describe del dispositivo hardware y software. Aunque el objeto está en el ámbito global, no está disponible hasta después de la `deviceready` evento. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Instalación + + cordova plugin add cordova-plugin-device + + +## Propiedades + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +Obtener la versión de Cordova que se ejecuta en el dispositivo. + +### Plataformas soportadas + +* Amazon fire OS +* Android +* BlackBerry 10 +* Explorador +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 y 8 +* Windows 8 + +## device.model + +El `device.model` devuelve el nombre de modelo del dispositivo o producto. El valor es fijado por el fabricante del dispositivo y puede ser diferente a través de versiones del mismo producto. + +### Plataformas soportadas + +* Android +* BlackBerry 10 +* Explorador +* iOS +* Tizen +* Windows Phone 7 y 8 +* Windows 8 + +### Ejemplo rápido + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models + // + var model = device.model; + + +### Rarezas Android + +* Obtiene el [nombre del producto][1] en lugar del [nombre de la modelo][2], que es a menudo el nombre de código de producción. Por ejemplo, el Nexus One devuelve `Passion` y Motorola Droid devuelve `voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + [2]: http://developer.android.com/reference/android/os/Build.html#MODEL + +### Rarezas Tizen + +* Devuelve que el modelo de dispositivo asignado por el proveedor, por ejemplo, `TIZEN` + +### Windows Phone 7 y 8 rarezas + +* Devuelve el modelo de dispositivo especificado por el fabricante. Por ejemplo, el Samsung Focus devuelve `SGH-i917`. + +## device.platform + +Obtener el nombre del sistema operativo del dispositivo. + + var string = device.platform; + + +### Plataformas soportadas + +* Android +* BlackBerry 10 +* Browser4 +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 y 8 +* Windows 8 + +### Ejemplo rápido + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 rarezas + +Dispositivos Windows Phone 7 informe de la plataforma como `WinCE`. + +### Windows Phone 8 rarezas + +Dispositivos Windows Phone 8 Informe la plataforma como `Win32NT`. + +## device.uuid + +Obtener identificador universalmente única del dispositivo ([UUID][3]). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### Descripción + +Los detalles de cómo se genera un UUID son determinados por el fabricante del dispositivo y son específicos a la plataforma del dispositivo o modelo. + +### Plataformas soportadas + +* Android +* BlackBerry 10 +* iOS +* Tizen +* Windows Phone 7 y 8 +* Windows 8 + +### Ejemplo rápido + + // Android: devuelve un entero de 64 bits al azar (como una cadena, otra vez!) + // el entero es generado en el primer arranque del dispositivo + // + // BlackBerry: devuelve el número PIN del dispositivo + // este es un entero único de nueve dígitos (como una cadena, aunque!) + // + // iPhone: (parafraseado de la documentación de la clase UIDevice) + // devuelve una cadena de valores hash creado a partir + // de múltiples hardware identifica. + / / Está garantizado para ser único para cada dispositivo y no puede ser atado / / a la cuenta de usuario. + // Windows Phone 7: devuelve un hash de dispositivo + usuario actual, + // si el usuario no está definido, un guid generado y persistirá hasta que se desinstala la aplicación + // + // Tizen: devuelve el dispositivo IMEI (identidad de equipo móvil internacional o IMEI es un número + // único para cada teléfono móvil GSM y UMTS. + var deviceID = device.uuid; + + +### iOS chanfle + +El `uuid` en iOS no es exclusiva de un dispositivo, pero varía para cada aplicación, para cada instalación. Cambia si puedes borrar y volver a instalar la aplicación, y posiblemente también cuándo actualizar iOS, o incluso mejorar la aplicación por la versión (evidente en iOS 5.1). El `uuid` no es un valor confiable. + +### Windows Phone 7 y 8 rarezas + +El `uuid` para Windows Phone 7 requiere el permiso `ID_CAP_IDENTITY_DEVICE`. Microsoft pronto probablemente desaprueban esta propiedad. Si la capacidad no está disponible, la aplicación genera un guid persistente que se mantiene durante la duración de la instalación de la aplicación en el dispositivo. + +## device.version + +Obtener la versión del sistema operativo. + + var string = device.version; + + +### Plataformas soportadas + +* Android 2.1 + +* BlackBerry 10 +* Explorador +* iOS +* Tizen +* Windows Phone 7 y 8 +* Windows 8 + +### Ejemplo rápido + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. el Mango se vuelve 7.10.7720 + // Tizen: devuelve "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/fr/README.md b/plugins/cordova-plugin-device/doc/fr/README.md new file mode 100644 index 0000000..4101fd9 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/fr/README.md @@ -0,0 +1,215 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +Ce plugin définit un global `device` objet qui décrit le matériel et les logiciels de l'appareil. Bien que l'objet est dans la portée globale, il n'est pas disponible jusqu'après la `deviceready` événement. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Installation + + cordova plugin add cordova-plugin-device + + +## Propriétés + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +Retourne la version de Cordova en cours d'exécution sur l'appareil. + +### Plates-formes supportées + + * Amazon Fire OS + * Android + * BlackBerry 10 + * Navigateur + * Firefox OS + * iOS + * Paciarelli + * Windows Phone 7 et 8 + * Windows 8 + +## device.model + +L'objet `device.model` retourne le nom du modèle de l'appareil/produit. Cette valeur est définie par le fabricant du périphérique et peut varier entre les différentes versions d'un même produit. + +### Plates-formes supportées + + * Android + * BlackBerry 10 + * Navigateur + * iOS + * Paciarelli + * Windows Phone 7 et 8 + * Windows 8 + +### Exemple court + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Voir http://theiphonewiki.com/wiki/index.php?title=Models + // + var model = device.model; + + +### Quirks Android + + * Retourne le [nom du produit](http://developer.android.com/reference/android/os/Build.html#PRODUCT) au lieu du [nom du modèle](http://developer.android.com/reference/android/os/Build.html#MODEL), ce qui équivaut souvent au nom de code de production. Par exemple, `Passion` pour le Nexus One et `voles` pour le Motorola Droid. + +### Bizarreries de paciarelli + + * Retourne le modèle du dispositif, assigné par le vendeur, par exemple `TIZEN` + +### Notes au sujet de Windows Phone 7 et 8 + + * Retourne le modèle de l'appareil spécifié par le fabricant. Par exemple `SGH-i917` pour le Samsung Focus. + +## device.platform + +Obtenir le nom de système d'exploitation de l'appareil. + + var string = device.platform; + + +### Plates-formes supportées + + * Android + * BlackBerry 10 + * Browser4 + * Firefox OS + * iOS + * Paciarelli + * Windows Phone 7 et 8 + * Windows 8 + +### Exemple court + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 Quirks + +Appareils Windows Phone 7 rapport de la plate-forme comme`WinCE`. + +### Notes au sujet de Windows Phone 8 + +Appareils Windows Phone 8 rapport de la plate-forme comme`Win32NT`. + +## device.uuid + +Obtenir Universally Unique Identifier de l'appareil ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). + + var string = device.uuid; + + +### Description + +Les détails de comment un UUID généré sont déterminées par le fabricant du périphérique et sont spécifiques à la plate-forme ou le modèle de l'appareil. + +### Plates-formes supportées + + * Android + * BlackBerry 10 + * iOS + * Paciarelli + * Windows Phone 7 et 8 + * Windows 8 + +### Exemple court + + // Android : retourne un nombre entier 64-bit aléatoire (sous la forme d'une chaîne de caractères, encore !) + // Ce nombre entier est généré lors du premier démarrage de l'appareil + // + // BlackBerry : retourne le numéro PIN de l'appareil + // Il s'agit d'un nombre entier unique à neuf chiffres (sous la forme d'une chaîne de caractères cependant !) + // + // iPhone : (copié depuis la documentation de la classe UIDevice) + // Retourne une chaîne de caractères générée à partir de plusieurs caractéristiques matérielles. + / / Il est garanti pour être unique pour chaque appareil et ne peut pas être lié / / pour le compte d'utilisateur. + // Windows Phone 7 : retourne un hashage généré à partir de appareil+utilisateur actuel, + // si aucun utilisateur n'est défini, un guid est généré persistera jusqu'à ce que l'application soit désinstallée + // Tizen : retourne le numéro IMEI (International Mobile Equipment Identity) de l'appareil, ce numéro est + // unique pour chaque téléphone GSM et UMTS. + var deviceID = device.uuid; + + +### Spécificités iOS + +Le `uuid` sur iOS n'est pas propre à un périphérique, mais varie pour chaque application, pour chaque installation. Elle change si vous supprimez, puis réinstallez l'application, et éventuellement aussi quand vous mettre à jour d'iOS, ou même mettre à jour le soft par version (apparent dans iOS 5.1). Le `uuid` n'est pas une valeur fiable. + +### Notes au sujet de Windows Phone 7 et 8 + +Le `uuid` pour Windows Phone 7 requiert l'autorisation `ID_CAP_IDENTITY_DEVICE` . Microsoft va probablement bientôt obsolète de cette propriété. Si la capacité n'est pas disponible, l'application génère un guid persistant qui est maintenu pendant toute la durée de l'installation de l'application sur le périphérique. + +## device.version + +Téléchargez la version de système d'exploitation. + + var string = device.version; + + +### Plates-formes supportées + + * Android 2.1+ + * BlackBerry 10 + * Navigateur + * iOS + * Paciarelli + * Windows Phone 7 et 8 + * Windows 8 + +### Exemple court + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/fr/index.md b/plugins/cordova-plugin-device/doc/fr/index.md new file mode 100644 index 0000000..163e498 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/fr/index.md @@ -0,0 +1,218 @@ + + +# cordova-plugin-device + +Ce plugin définit un global `device` objet qui décrit le matériel et les logiciels de l'appareil. Bien que l'objet est dans la portée globale, il n'est pas disponible jusqu'après la `deviceready` événement. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Installation + + cordova plugin add cordova-plugin-device + + +## Propriétés + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +Retourne la version de Cordova en cours d'exécution sur l'appareil. + +### Plates-formes prises en charge + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Navigateur +* Firefox OS +* iOS +* Paciarelli +* Windows Phone 7 et 8 +* Windows 8 + +## device.model + +L'objet `device.model` retourne le nom du modèle de l'appareil/produit. Cette valeur est définie par le fabricant du périphérique et peut varier entre les différentes versions d'un même produit. + +### Plates-formes prises en charge + +* Android +* BlackBerry 10 +* Navigateur +* iOS +* Paciarelli +* Windows Phone 7 et 8 +* Windows 8 + +### Petit exemple + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Voir http://theiphonewiki.com/wiki/index.php?title=Models + // + var model = device.model; + + +### Quirks Android + +* Retourne le [nom du produit][1] au lieu du [nom du modèle][2], ce qui équivaut souvent au nom de code de production. Par exemple, `Passion` pour le Nexus One et `voles` pour le Motorola Droid. + + [1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + [2]: http://developer.android.com/reference/android/os/Build.html#MODEL + +### Bizarreries de paciarelli + +* Retourne le modèle du dispositif, assigné par le vendeur, par exemple `TIZEN` + +### Windows Phone 7 et 8 Quirks + +* Retourne le modèle de l'appareil spécifié par le fabricant. Par exemple `SGH-i917` pour le Samsung Focus. + +## device.platform + +Obtenir le nom de système d'exploitation de l'appareil. + + var string = device.platform; + + +### Plates-formes prises en charge + +* Android +* BlackBerry 10 +* Browser4 +* Firefox OS +* iOS +* Paciarelli +* Windows Phone 7 et 8 +* Windows 8 + +### Petit exemple + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 Quirks + +Appareils Windows Phone 7 rapport de la plate-forme comme`WinCE`. + +### Notes au sujet de Windows Phone 8 + +Appareils Windows Phone 8 rapport de la plate-forme comme`Win32NT`. + +## device.uuid + +Obtenir Universally Unique Identifier de l'appareil ([UUID][3]). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### Description + +Les détails de comment un UUID généré sont déterminées par le fabricant du périphérique et sont spécifiques à la plate-forme ou le modèle de l'appareil. + +### Plates-formes prises en charge + +* Android +* BlackBerry 10 +* iOS +* Paciarelli +* Windows Phone 7 et 8 +* Windows 8 + +### Petit exemple + + // Android : retourne un nombre entier 64-bit aléatoire (sous la forme d'une chaîne de caractères, encore !) + // Ce nombre entier est généré lors du premier démarrage de l'appareil + // + // BlackBerry : retourne le numéro PIN de l'appareil + // Il s'agit d'un nombre entier unique à neuf chiffres (sous la forme d'une chaîne de caractères cependant !) + // + // iPhone : (copié depuis la documentation de la classe UIDevice) + // Retourne une chaîne de caractères générée à partir de plusieurs caractéristiques matérielles. + / / Il est garanti pour être unique pour chaque appareil et ne peut pas être lié / / pour le compte d'utilisateur. + // Windows Phone 7 : retourne un hashage généré à partir de appareil+utilisateur actuel, + // si aucun utilisateur n'est défini, un guid est généré persistera jusqu'à ce que l'application soit désinstallée + // Tizen : retourne le numéro IMEI (International Mobile Equipment Identity) de l'appareil, ce numéro est + // unique pour chaque téléphone GSM et UMTS. + var deviceID = device.uuid; + + +### Spécificités iOS + +Le `uuid` sur iOS n'est pas propre à un périphérique, mais varie pour chaque application, pour chaque installation. Elle change si vous supprimez, puis réinstallez l'application, et éventuellement aussi quand vous mettre à jour d'iOS, ou même mettre à jour le soft par version (apparent dans iOS 5.1). Le `uuid` n'est pas une valeur fiable. + +### Windows Phone 7 et 8 Quirks + +Le `uuid` pour Windows Phone 7 requiert l'autorisation `ID_CAP_IDENTITY_DEVICE` . Microsoft va probablement bientôt obsolète de cette propriété. Si la capacité n'est pas disponible, l'application génère un guid persistant qui est maintenu pendant toute la durée de l'installation de l'application sur le périphérique. + +## device.version + +Téléchargez la version de système d'exploitation. + + var string = device.version; + + +### Plates-formes prises en charge + +* Android 2.1+ +* BlackBerry 10 +* Navigateur +* iOS +* Paciarelli +* Windows Phone 7 et 8 +* Windows 8 + +### Petit exemple + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/it/README.md b/plugins/cordova-plugin-device/doc/it/README.md new file mode 100644 index 0000000..7974962 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/it/README.md @@ -0,0 +1,203 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +Questo plugin definisce un global `device` oggetto che descrive il dispositivo hardware e software. Sebbene l'oggetto sia in ambito globale, non è disponibile fino a dopo il `deviceready` evento. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Installazione + + cordova plugin add cordova-plugin-device + + +## Proprietà + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +Ottenere la versione di Cordova in esecuzione nel dispositivo. + +### Piattaforme supportate + + * Amazon fuoco OS + * Android + * BlackBerry 10 + * Browser + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 e 8 + * Windows 8 + +## device.model + +Il `device.model` restituisce il nome del modello del dispositivo o del prodotto. Il valore viene impostato dal produttore del dispositivo e può essere differente tra le versioni dello stesso prodotto. + +### Piattaforme supportate + + * Android + * BlackBerry 10 + * Browser + * iOS + * Tizen + * Windows Phone 7 e 8 + * Windows 8 + +### Esempio rapido + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Vedi http://theiphonewiki.com/wiki/index.php?title=Models / / modello var = device.model; + + +### Stranezze Android + + * Ottiene il [nome del prodotto](http://developer.android.com/reference/android/os/Build.html#PRODUCT) anziché il [nome del modello](http://developer.android.com/reference/android/os/Build.html#MODEL), che è spesso il nome di codice di produzione. Ad esempio, restituisce il Nexus One `Passion` , e Motorola Droid restituisce`voles`. + +### Tizen stranezze + + * Restituisce il modello di dispositivo assegnato dal fornitore, ad esempio,`TIZEN` + +### Windows Phone 7 e 8 stranezze + + * Restituisce il modello di dispositivo specificato dal produttore. Ad esempio, restituisce il Samsung Focus`SGH-i917`. + +## device.platform + +Ottenere il nome del sistema operativo del dispositivo. + + var string = device.platform; + + +### Piattaforme supportate + + * Android + * BlackBerry 10 + * Browser4 + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 e 8 + * Windows 8 + +### Esempio rapido + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 capricci + +Windows Phone 7 dispositivi segnalano la piattaforma come`WinCE`. + +### Windows Phone 8 stranezze + +Dispositivi Windows Phone 8 segnalano la piattaforma come`Win32NT`. + +## device.uuid + +Ottenere identificatore del dispositivo univoco universale ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). + + var string = device.uuid; + + +### Descrizione + +I dettagli di come viene generato un UUID sono determinati dal produttore del dispositivo e sono specifici per la piattaforma o il modello del dispositivo. + +### Piattaforme supportate + + * Android + * BlackBerry 10 + * iOS + * Tizen + * Windows Phone 7 e 8 + * Windows 8 + +### Esempio rapido + + / / Android: restituisce un intero casuale di 64 bit (come stringa, ancora una volta!) / / il numero intero è generato al primo avvio del dispositivo / / / / BlackBerry: restituisce il numero PIN del dispositivo / / questo è un valore integer univoco a nove cifre (come stringa, benchè!) / / / / iPhone: (parafrasato dalla documentazione della classe UIDevice) / / restituisce una stringa di valori hash creata dall'hardware più identifica. + / / È garantito per essere unica per ogni dispositivo e non può essere legato / / per l'account utente. + / / Windows Phone 7: restituisce un hash dell'utente corrente, + dispositivo / / se l'utente non è definito, un guid generato e persisterà fino a quando l'applicazione viene disinstallata / / Tizen: restituisce il dispositivo IMEI (International Mobile Equipment Identity o IMEI è un numero / / unico per ogni cellulare GSM e UMTS. + var deviceID = device.uuid; + + +### iOS Quirk + +Il `uuid` su iOS non è univoco per un dispositivo, ma varia per ogni applicazione, per ogni installazione. Cambia se si elimina e re-installare l'app, e possibilmente anche quando aggiornare iOS o anche aggiornare l'app per ogni versione (apparente in iOS 5.1). Il `uuid` non è un valore affidabile. + +### Windows Phone 7 e 8 stranezze + +Il `uuid` per Windows Phone 7 richiede l'autorizzazione `ID_CAP_IDENTITY_DEVICE` . Microsoft probabilmente sarà presto deprecare questa proprietà. Se la funzionalità non è disponibile, l'applicazione genera un guid persistente che viene mantenuto per la durata dell'installazione dell'applicazione sul dispositivo. + +## device.version + +Ottenere la versione del sistema operativo. + + var string = device.version; + + +### Piattaforme supportate + + * Android 2.1 + + * BlackBerry 10 + * Browser + * iOS + * Tizen + * Windows Phone 7 e 8 + * Windows 8 + +### Esempio rapido + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/it/index.md b/plugins/cordova-plugin-device/doc/it/index.md new file mode 100644 index 0000000..98c6200 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/it/index.md @@ -0,0 +1,206 @@ + + +# cordova-plugin-device + +Questo plugin definisce un global `device` oggetto che descrive il dispositivo hardware e software. Sebbene l'oggetto sia in ambito globale, non è disponibile fino a dopo il `deviceready` evento. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Installazione + + cordova plugin add cordova-plugin-device + + +## Proprietà + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +Ottenere la versione di Cordova in esecuzione nel dispositivo. + +### Piattaforme supportate + +* Amazon fuoco OS +* Android +* BlackBerry 10 +* Browser +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 e 8 +* Windows 8 + +## device.model + +Il `device.model` restituisce il nome del modello del dispositivo o del prodotto. Il valore viene impostato dal produttore del dispositivo e può essere differente tra le versioni dello stesso prodotto. + +### Piattaforme supportate + +* Android +* BlackBerry 10 +* Browser +* iOS +* Tizen +* Windows Phone 7 e 8 +* Windows 8 + +### Esempio rapido + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Vedi http://theiphonewiki.com/wiki/index.php?title=Models / / modello var = device.model; + + +### Stranezze Android + +* Ottiene il [nome del prodotto][1] anziché il [nome del modello][2], che è spesso il nome di codice di produzione. Ad esempio, restituisce il Nexus One `Passion` , e Motorola Droid restituisce`voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + [2]: http://developer.android.com/reference/android/os/Build.html#MODEL + +### Tizen stranezze + +* Restituisce il modello di dispositivo assegnato dal fornitore, ad esempio,`TIZEN` + +### Windows Phone 7 e 8 stranezze + +* Restituisce il modello di dispositivo specificato dal produttore. Ad esempio, restituisce il Samsung Focus`SGH-i917`. + +## device.platform + +Ottenere il nome del sistema operativo del dispositivo. + + var string = device.platform; + + +### Piattaforme supportate + +* Android +* BlackBerry 10 +* Browser4 +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 e 8 +* Windows 8 + +### Esempio rapido + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 capricci + +Windows Phone 7 dispositivi segnalano la piattaforma come`WinCE`. + +### Windows Phone 8 stranezze + +Dispositivi Windows Phone 8 segnalano la piattaforma come`Win32NT`. + +## device.uuid + +Ottenere identificatore del dispositivo univoco universale ([UUID][3]). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### Descrizione + +I dettagli di come viene generato un UUID sono determinati dal produttore del dispositivo e sono specifici per la piattaforma o il modello del dispositivo. + +### Piattaforme supportate + +* Android +* BlackBerry 10 +* iOS +* Tizen +* Windows Phone 7 e 8 +* Windows 8 + +### Esempio rapido + + / / Android: restituisce un intero casuale di 64 bit (come stringa, ancora una volta!) / / il numero intero è generato al primo avvio del dispositivo / / / / BlackBerry: restituisce il numero PIN del dispositivo / / questo è un valore integer univoco a nove cifre (come stringa, benchè!) / / / / iPhone: (parafrasato dalla documentazione della classe UIDevice) / / restituisce una stringa di valori hash creata dall'hardware più identifica. + / / È garantito per essere unica per ogni dispositivo e non può essere legato / / per l'account utente. + / / Windows Phone 7: restituisce un hash dell'utente corrente, + dispositivo / / se l'utente non è definito, un guid generato e persisterà fino a quando l'applicazione viene disinstallata / / Tizen: restituisce il dispositivo IMEI (International Mobile Equipment Identity o IMEI è un numero / / unico per ogni cellulare GSM e UMTS. + var deviceID = device.uuid; + + +### iOS Quirk + +Il `uuid` su iOS non è univoco per un dispositivo, ma varia per ogni applicazione, per ogni installazione. Cambia se si elimina e re-installare l'app, e possibilmente anche quando aggiornare iOS o anche aggiornare l'app per ogni versione (apparente in iOS 5.1). Il `uuid` non è un valore affidabile. + +### Windows Phone 7 e 8 stranezze + +Il `uuid` per Windows Phone 7 richiede l'autorizzazione `ID_CAP_IDENTITY_DEVICE` . Microsoft probabilmente sarà presto deprecare questa proprietà. Se la funzionalità non è disponibile, l'applicazione genera un guid persistente che viene mantenuto per la durata dell'installazione dell'applicazione sul dispositivo. + +## device.version + +Ottenere la versione del sistema operativo. + + var string = device.version; + + +### Piattaforme supportate + +* Android 2.1 + +* BlackBerry 10 +* Browser +* iOS +* Tizen +* Windows Phone 7 e 8 +* Windows 8 + +### Esempio rapido + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/ja/README.md b/plugins/cordova-plugin-device/doc/ja/README.md new file mode 100644 index 0000000..5a345f8 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/ja/README.md @@ -0,0 +1,203 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +このプラグインをグローバル定義します `device` オブジェクトは、デバイスのハードウェアとソフトウェアについて説明します。 それは後まで利用可能なオブジェクトがグローバル スコープでは、 `deviceready` イベント。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## インストール + + cordova plugin add cordova-plugin-device + + +## プロパティ + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +デバイスで実行されているコルドバのバージョンを取得します。 + +### サポートされているプラットフォーム + + * アマゾン火 OS + * アンドロイド + * ブラックベリー 10 + * ブラウザー + * Firefox の OS + * iOS + * Tizen + * Windows Phone 7 と 8 + * Windows 8 + +## device.model + +`device.model`、デバイスのモデルまたは製品の名前を返します。値は、デバイスの製造元によって設定され、同じ製品のバージョン間で異なる可能性があります。 + +### サポートされているプラットフォーム + + * アンドロイド + * ブラックベリー 10 + * ブラウザー + * iOS + * Tizen + * Windows Phone 7 と 8 + * Windows 8 + +### 簡単な例 + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models を参照してください//var モデル = device.model; + + +### Android の癖 + + * 生産コード名は[モデル名](http://developer.android.com/reference/android/os/Build.html#MODEL)の代わりに[製品名](http://developer.android.com/reference/android/os/Build.html#PRODUCT)を取得します。 たとえば、ネクサス 1 つを返します `Passion` 、Motorola のドロイドを返します`voles`. + +### Tizen の癖 + + * たとえば、ベンダーによって割り当てられているデバイスのモデルを返します`TIZEN` + +### Windows Phone 7 と 8 癖 + + * 製造元によって指定されたデバイスのモデルを返します。たとえば、三星フォーカスを返します`SGH-i917`. + +## device.platform + +デバイスのオペレーティング システム名を取得します。 + + var string = device.platform; + + +### サポートされているプラットフォーム + + * アンドロイド + * ブラックベリー 10 + * Browser4 + * Firefox の OS + * iOS + * Tizen + * Windows Phone 7 と 8 + * Windows 8 + +### 簡単な例 + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 の癖 + +Windows Phone 7 デバイスとプラットフォームを報告します。`WinCE`. + +### Windows Phone 8 癖 + +Windows Phone 8 デバイスとプラットフォームを報告します。`Win32NT`. + +## device.uuid + +デバイスのユニバーサル ・ ユニーク識別子 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)を取得します。). + + var string = device.uuid; + + +### 解説 + +UUID を生成する方法の詳細は、デバイスの製造元によって決定され、デバイスのプラットフォームやモデルに固有です。 + +### サポートされているプラットフォーム + + * アンドロイド + * ブラックベリー 10 + * iOS + * Tizen + * Windows Phone 7 と 8 + * Windows 8 + +### 簡単な例 + + //アンドロイド: ランダムな 64 ビットの整数 (を文字列として返します、再び !)/デバイスの最初の起動時に生成される整数/////ブラックベリー: デバイスのピン番号を返します//これは 9 桁の一意な整数 (を文字列としても !)////iPhone: (UIDevice クラスのドキュメントから言い換え)//識別複数のハードウェアから作成されたハッシュ値の文字列を返します。。 + //それはすべてのデバイスに対して一意であることが保証され、接続することはできません//ユーザー アカウント。 + //Windows Phone 7: デバイス + 現在のユーザーのハッシュを返します//ユーザーが定義されていない場合 guid が生成され、アプリがアンインストールされるまで保持されます//Tizen: デバイスの IMEI を返します (国際モバイル機器アイデンティティまたは IMEI は番号です//すべての GSM および UMTS の携帯電話に固有です。 + var deviceID = device.uuid; + + +### iOS の気まぐれ + +`uuid`IOS で、デバイスに固有ではないインストールごと、アプリケーションごとに異なります。 削除、アプリを再インストールした場合に変更と多分またときアップグレード iOS の, またはもアップグレードするアプリ (iOS の 5.1 で明らかに) バージョンごと。 `uuid`は信頼性の高い値ではありません。 + +### Windows Phone 7 と 8 癖 + +`uuid`のために Windows Phone 7 には、権限が必要です `ID_CAP_IDENTITY_DEVICE` 。 Microsoft はすぐにこのプロパティを廃止して可能性があります。 機能が利用できない場合、アプリケーションはデバイスへのアプリケーションのインストールの持続期間のために保持されている永続的な guid を生成します。 + +## device.version + +オペレーティング システムのバージョンを取得します。 + + var string = device.version; + + +### サポートされているプラットフォーム + + * アンドロイド 2.1 + + * ブラックベリー 10 + * ブラウザー + * iOS + * Tizen + * Windows Phone 7 と 8 + * Windows 8 + +### 簡単な例 + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/ja/index.md b/plugins/cordova-plugin-device/doc/ja/index.md new file mode 100644 index 0000000..b4030fd --- /dev/null +++ b/plugins/cordova-plugin-device/doc/ja/index.md @@ -0,0 +1,206 @@ + + +# cordova-plugin-device + +このプラグインをグローバル定義します `device` オブジェクトは、デバイスのハードウェアとソフトウェアについて説明します。 それは後まで利用可能なオブジェクトがグローバル スコープでは、 `deviceready` イベント。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## インストール + + cordova plugin add cordova-plugin-device + + +## プロパティ + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +デバイスで実行されているコルドバのバージョンを取得します。 + +### サポートされているプラットフォーム + +* アマゾン火 OS +* アンドロイド +* ブラックベリー 10 +* ブラウザー +* Firefox の OS +* iOS +* Tizen +* Windows Phone 7 と 8 +* Windows 8 + +## device.model + +`device.model`、デバイスのモデルまたは製品の名前を返します。値は、デバイスの製造元によって設定され、同じ製品のバージョン間で異なる可能性があります。 + +### サポートされているプラットフォーム + +* アンドロイド +* ブラックベリー 10 +* ブラウザー +* iOS +* Tizen +* Windows Phone 7 と 8 +* Windows 8 + +### 簡単な例 + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models を参照してください//var モデル = device.model; + + +### Android の癖 + +* 生産コード名は[モデル名][1]の代わりに[製品名][2]を取得します。 たとえば、ネクサス 1 つを返します `Passion` 、Motorola のドロイドを返します`voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#MODEL + [2]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + +### Tizen の癖 + +* たとえば、ベンダーによって割り当てられているデバイスのモデルを返します`TIZEN` + +### Windows Phone 7 と 8 癖 + +* 製造元によって指定されたデバイスのモデルを返します。たとえば、三星フォーカスを返します`SGH-i917`. + +## device.platform + +デバイスのオペレーティング システム名を取得します。 + + var string = device.platform; + + +### サポートされているプラットフォーム + +* アンドロイド +* ブラックベリー 10 +* Browser4 +* Firefox の OS +* iOS +* Tizen +* Windows Phone 7 と 8 +* Windows 8 + +### 簡単な例 + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 の癖 + +Windows Phone 7 デバイスとプラットフォームを報告します。`WinCE`. + +### Windows Phone 8 癖 + +Windows Phone 8 デバイスとプラットフォームを報告します。`Win32NT`. + +## device.uuid + +デバイスのユニバーサル ・ ユニーク識別子 ([UUID][3]を取得します。). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### 説明 + +UUID を生成する方法の詳細は、デバイスの製造元によって決定され、デバイスのプラットフォームやモデルに固有です。 + +### サポートされているプラットフォーム + +* アンドロイド +* ブラックベリー 10 +* iOS +* Tizen +* Windows Phone 7 と 8 +* Windows 8 + +### 簡単な例 + + //アンドロイド: ランダムな 64 ビットの整数 (を文字列として返します、再び !)/デバイスの最初の起動時に生成される整数/////ブラックベリー: デバイスのピン番号を返します//これは 9 桁の一意な整数 (を文字列としても !)////iPhone: (UIDevice クラスのドキュメントから言い換え)//識別複数のハードウェアから作成されたハッシュ値の文字列を返します。。 + //それはすべてのデバイスに対して一意であることが保証され、接続することはできません//ユーザー アカウント。 + //Windows Phone 7: デバイス + 現在のユーザーのハッシュを返します//ユーザーが定義されていない場合 guid が生成され、アプリがアンインストールされるまで保持されます//Tizen: デバイスの IMEI を返します (国際モバイル機器アイデンティティまたは IMEI は番号です//すべての GSM および UMTS の携帯電話に固有です。 + var deviceID = device.uuid; + + +### iOS の気まぐれ + +`uuid`IOS で、デバイスに固有ではないインストールごと、アプリケーションごとに異なります。 削除、アプリを再インストールした場合に変更と多分またときアップグレード iOS の, またはもアップグレードするアプリ (iOS の 5.1 で明らかに) バージョンごと。 `uuid`は信頼性の高い値ではありません。 + +### Windows Phone 7 と 8 癖 + +`uuid`のために Windows Phone 7 には、権限が必要です `ID_CAP_IDENTITY_DEVICE` 。 Microsoft はすぐにこのプロパティを廃止して可能性があります。 機能が利用できない場合、アプリケーションはデバイスへのアプリケーションのインストールの持続期間のために保持されている永続的な guid を生成します。 + +## device.version + +オペレーティング システムのバージョンを取得します。 + + var string = device.version; + + +### サポートされているプラットフォーム + +* アンドロイド 2.1 + +* ブラックベリー 10 +* ブラウザー +* iOS +* Tizen +* Windows Phone 7 と 8 +* Windows 8 + +### 簡単な例 + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/ko/README.md b/plugins/cordova-plugin-device/doc/ko/README.md new file mode 100644 index 0000000..a818aac --- /dev/null +++ b/plugins/cordova-plugin-device/doc/ko/README.md @@ -0,0 +1,203 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +이 플러그인 정의 전역 `device` 개체, 디바이스의 하드웨어 및 소프트웨어에 설명 합니다. 개체는 전역 범위에서 비록 그것은 후까지 사용할 수 있는 `deviceready` 이벤트. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## 설치 + + cordova plugin add cordova-plugin-device + + +## 속성 + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +코르도바는 장치에서 실행 중인 버전을 얻을. + +### 지원 되는 플랫폼 + + * 아마존 화재 운영 체제 + * 안 드 로이드 + * 블랙베리 10 + * 브라우저 + * Firefox 운영 체제 + * iOS + * Tizen + * Windows Phone 7과 8 + * 윈도우 8 + +## device.model + +`device.model`소자의 모델 또는 제품의 이름을 반환 합니다. 값 장치 제조업체에서 설정 되 고 동일 제품의 버전 간에 다를 수 있습니다. + +### 지원 되는 플랫폼 + + * 안 드 로이드 + * 블랙베리 10 + * 브라우저 + * iOS + * Tizen + * Windows Phone 7과 8 + * 윈도우 8 + +### 빠른 예제 + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models 참조 / / var 모델 = device.model; + + +### 안 드 로이드 단점 + + * 어떤은 종종 프로덕션 코드 이름 대신 [제품 모델 이름](http://developer.android.com/reference/android/os/Build.html#MODEL), [제품 이름](http://developer.android.com/reference/android/os/Build.html#PRODUCT) 을 가져옵니다. 예를 들어 넥서스 하나 반환 합니다 `Passion` , 모토로라 Droid를 반환 합니다`voles`. + +### Tizen 특수 + + * 예를 들어, 공급 업체에 의해 할당 된 디바이스 모델을 반환 합니다.`TIZEN` + +### Windows Phone 7, 8 특수 + + * 제조업체에서 지정 하는 장치 모델을 반환 합니다. 예를 들어 삼성 포커스를 반환 합니다.`SGH-i917`. + +## device.platform + +장치의 운영 체제 이름을 얻을. + + var string = device.platform; + + +### 지원 되는 플랫폼 + + * 안 드 로이드 + * 블랙베리 10 + * Browser4 + * Firefox 운영 체제 + * iOS + * Tizen + * Windows Phone 7과 8 + * 윈도우 8 + +### 빠른 예제 + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 단점 + +Windows Phone 7 장치 보고 플랫폼으로`WinCE`. + +### Windows Phone 8 단점 + +Windows Phone 8 장치 보고 플랫폼으로`Win32NT`. + +## device.uuid + +소자의 보편적으로 고유 식별자 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier) 를 얻을합니다). + + var string = device.uuid; + + +### 설명 + +UUID 생성 방법의 자세한 내용은 장치 제조업체에 의해 결정 됩니다 및 소자의 플랫폼 이나 모델. + +### 지원 되는 플랫폼 + + * 안 드 로이드 + * 블랙베리 10 + * iOS + * Tizen + * Windows Phone 7과 8 + * 윈도우 8 + +### 빠른 예제 + + / / 안 드 로이드: (문자열로 다시!) 임의의 64 비트 정수를 반환 합니다 / / 정수 장치의 첫 번째 부팅에서 생성 / / / / 블랙베리: 디바이스의 핀 번호를 반환 합니다 / / 이것은 9 자리 고유 정수 (문자열로 비록!) / / / / 아이폰: (UIDevice 클래스 설명서에서 읊 었) / / 문자열 여러 하드웨어에서 생성 하는 해시 값을 식별 하는 반환 합니다. + / 그것은 모든 장치에 대 한 고유 해야 보장 되 고 묶일 수 없습니다 / / / 사용자 계정에. + / / Windows Phone 7: 장치 + 현재 사용자의 해시를 반환 합니다 / / 사용자 정의 되지 않은 경우 guid 생성 되 고 응용 프로그램을 제거할 때까지 유지 됩니다 / / Tizen: 반환 장치 IMEI (국제 모바일 기기 식별 또는 IMEI 숫자입니다 / / 모든 GSM와 UMTS 휴대 전화 고유. + var deviceID = device.uuid; + + +### iOS 특질 + +`uuid`ios 장치에 고유 하지 않습니다 하지만 각 설치에 대 한 응용 프로그램 마다 다릅니다. 삭제 하 고 다시 애플 리 케이 션을 설치 하는 경우 변경 가능 하 게 또한 iOS를 업그레이드 하거나 때 버전 (iOS 5.1에에서 명백한) 당 응용 프로그램 업그레이드도 하 고. `uuid`은 신뢰할 수 있는 값이 아닙니다. + +### Windows Phone 7, 8 특수 + +`uuid`Windows Phone 7 필요 허가 `ID_CAP_IDENTITY_DEVICE` . Microsoft는 곧이 속성을 세웁니다 가능성이 것입니다. 기능을 사용할 수 없는 경우 응용 프로그램 장치에 응용 프로그램의 설치 하는 동안 유지 하는 영구 guid를 생성 합니다. + +## device.version + +운영 체제 버전을 얻을. + + var string = device.version; + + +### 지원 되는 플랫폼 + + * 안 드 로이드 2.1 + + * 블랙베리 10 + * 브라우저 + * iOS + * Tizen + * Windows Phone 7과 8 + * 윈도우 8 + +### 빠른 예제 + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/ko/index.md b/plugins/cordova-plugin-device/doc/ko/index.md new file mode 100644 index 0000000..0fe38a7 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/ko/index.md @@ -0,0 +1,206 @@ + + +# cordova-plugin-device + +이 플러그인 정의 전역 `device` 개체, 디바이스의 하드웨어 및 소프트웨어에 설명 합니다. 개체는 전역 범위에서 비록 그것은 후까지 사용할 수 있는 `deviceready` 이벤트. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## 설치 + + cordova plugin add cordova-plugin-device + + +## 속성 + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +코르도바는 장치에서 실행 중인 버전을 얻을. + +### 지원 되는 플랫폼 + +* 아마존 화재 운영 체제 +* 안 드 로이드 +* 블랙베리 10 +* 브라우저 +* Firefox 운영 체제 +* iOS +* Tizen +* Windows Phone 7과 8 +* 윈도우 8 + +## device.model + +`device.model`소자의 모델 또는 제품의 이름을 반환 합니다. 값 장치 제조업체에서 설정 되 고 동일 제품의 버전 간에 다를 수 있습니다. + +### 지원 되는 플랫폼 + +* 안 드 로이드 +* 블랙베리 10 +* 브라우저 +* iOS +* Tizen +* Windows Phone 7과 8 +* 윈도우 8 + +### 빠른 예제 + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models 참조 / / var 모델 = device.model; + + +### 안 드 로이드 단점 + +* 어떤은 종종 프로덕션 코드 이름 대신 [제품 모델 이름][1], [제품 이름][2] 을 가져옵니다. 예를 들어 넥서스 하나 반환 합니다 `Passion` , 모토로라 Droid를 반환 합니다`voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#MODEL + [2]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + +### Tizen 특수 + +* 예를 들어, 공급 업체에 의해 할당 된 디바이스 모델을 반환 합니다.`TIZEN` + +### Windows Phone 7, 8 특수 + +* 제조업체에서 지정 하는 장치 모델을 반환 합니다. 예를 들어 삼성 포커스를 반환 합니다.`SGH-i917`. + +## device.platform + +장치의 운영 체제 이름을 얻을. + + var string = device.platform; + + +### 지원 되는 플랫폼 + +* 안 드 로이드 +* 블랙베리 10 +* Browser4 +* Firefox 운영 체제 +* iOS +* Tizen +* Windows Phone 7과 8 +* 윈도우 8 + +### 빠른 예제 + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 단점 + +Windows Phone 7 장치 보고 플랫폼으로`WinCE`. + +### Windows Phone 8 단점 + +Windows Phone 8 장치 보고 플랫폼으로`Win32NT`. + +## device.uuid + +소자의 보편적으로 고유 식별자 ([UUID][3] 를 얻을합니다). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### 설명 + +UUID 생성 방법의 자세한 내용은 장치 제조업체에 의해 결정 됩니다 및 소자의 플랫폼 이나 모델. + +### 지원 되는 플랫폼 + +* 안 드 로이드 +* 블랙베리 10 +* iOS +* Tizen +* Windows Phone 7과 8 +* 윈도우 8 + +### 빠른 예제 + + / / 안 드 로이드: (문자열로 다시!) 임의의 64 비트 정수를 반환 합니다 / / 정수 장치의 첫 번째 부팅에서 생성 / / / / 블랙베리: 디바이스의 핀 번호를 반환 합니다 / / 이것은 9 자리 고유 정수 (문자열로 비록!) / / / / 아이폰: (UIDevice 클래스 설명서에서 읊 었) / / 문자열 여러 하드웨어에서 생성 하는 해시 값을 식별 하는 반환 합니다. + / 그것은 모든 장치에 대 한 고유 해야 보장 되 고 묶일 수 없습니다 / / / 사용자 계정에. + / / Windows Phone 7: 장치 + 현재 사용자의 해시를 반환 합니다 / / 사용자 정의 되지 않은 경우 guid 생성 되 고 응용 프로그램을 제거할 때까지 유지 됩니다 / / Tizen: 반환 장치 IMEI (국제 모바일 기기 식별 또는 IMEI 숫자입니다 / / 모든 GSM와 UMTS 휴대 전화 고유. + var deviceID = device.uuid; + + +### iOS 특질 + +`uuid`ios 장치에 고유 하지 않습니다 하지만 각 설치에 대 한 응용 프로그램 마다 다릅니다. 삭제 하 고 다시 애플 리 케이 션을 설치 하는 경우 변경 가능 하 게 또한 iOS를 업그레이드 하거나 때 버전 (iOS 5.1에에서 명백한) 당 응용 프로그램 업그레이드도 하 고. `uuid`은 신뢰할 수 있는 값이 아닙니다. + +### Windows Phone 7, 8 특수 + +`uuid`Windows Phone 7 필요 허가 `ID_CAP_IDENTITY_DEVICE` . Microsoft는 곧이 속성을 세웁니다 가능성이 것입니다. 기능을 사용할 수 없는 경우 응용 프로그램 장치에 응용 프로그램의 설치 하는 동안 유지 하는 영구 guid를 생성 합니다. + +## device.version + +운영 체제 버전을 얻을. + + var string = device.version; + + +### 지원 되는 플랫폼 + +* 안 드 로이드 2.1 + +* 블랙베리 10 +* 브라우저 +* iOS +* Tizen +* Windows Phone 7과 8 +* 윈도우 8 + +### 빠른 예제 + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/pl/README.md b/plugins/cordova-plugin-device/doc/pl/README.md new file mode 100644 index 0000000..c38832d --- /dev/null +++ b/plugins/cordova-plugin-device/doc/pl/README.md @@ -0,0 +1,214 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +Ten plugin określa globalne `device` obiekt, który opisuje urządzenia sprzętowe i programowe. Mimo, że obiekt jest w globalnym zasięgu, nie jest dostępne dopiero po `deviceready` zdarzenie. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Instalacja + + cordova plugin add cordova-plugin-device + + +## Właściwości + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +Pobierz wersję Cordova działa na urządzeniu. + +### Obsługiwane platformy + + * Amazon Fire OS + * Android + * BlackBerry 10 + * Przeglądarka + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 i 8 + * Windows 8 + +## device.model + +`device.model`Zwraca nazwę modelu lub produktu. Wartość jest zestaw przez producenta urządzenia i mogą się różnić między wersjami tego samego produktu. + +### Obsługiwane platformy + + * Android + * BlackBerry 10 + * Przeglądarka + * iOS + * Tizen + * Windows Phone 7 i 8 + * Windows 8 + +### Szybki przykład + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Zobacz http://theiphonewiki.com/wiki/index.php?title=Models / / modelu var = device.model; + + +### Dziwactwa Androida + + * Pobiera [nazwę produktu](http://developer.android.com/reference/android/os/Build.html#PRODUCT) zamiast [nazwy modelu](http://developer.android.com/reference/android/os/Build.html#MODEL), który często jest nazwą kod produkcji. Na przykład, Nexus One zwraca `Passion` , i zwraca Motorola Droid`voles`. + +### Dziwactwa Tizen + + * Zwraca modelu urządzenia przypisane przez dostawcę, na przykład,`TIZEN` + +### Windows Phone 7 i 8 dziwactwa + + * Zwraca modelu urządzenia, określonej przez producenta. Na przykład Samsung ostrości zwraca`SGH-i917`. + +## device.platform + +Uzyskać nazwę systemu operacyjnego urządzenia. + + var string = device.platform; + + +### Obsługiwane platformy + + * Android + * BlackBerry 10 + * Browser4 + * Firefox OS + * iOS + * Tizen + * Windows Phone 7 i 8 + * Windows 8 + +### Szybki przykład + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Dziwactwa Windows Phone 7 + +Urządzenia Windows Phone 7 raport platformy jako`WinCE`. + +### Windows Phone 8 dziwactwa + +Urządzenia Windows Phone 8 raport platformy jako`Win32NT`. + +## device.uuid + +Się urządzenia uniwersalnie unikatowy identyfikator ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). + + var string = device.uuid; + + +### Opis + +Szczegóły jak UUID jest generowane są określane przez producenta urządzenia i są specyficzne dla platformy lub modelu urządzenia. + +### Obsługiwane platformy + + * Android + * BlackBerry 10 + * iOS + * Tizen + * Windows Phone 7 i 8 + * Windows 8 + +### Szybki przykład + + // Android: Returns a random 64-bit integer (as a string, again!) + // The integer is generated on the device's first boot + // + // BlackBerry: Returns the PIN number of the device + // This is a nine-digit unique integer (as a string, though!) + // + // iPhone: (Paraphrased from the UIDevice Class documentation) + // Returns a string of hash values created from multiple hardware identifies. + // It is guaranteed to be unique for every device and can't be tied + // to the user account. + // Windows Phone 7 : Returns a hash of device+current user, + // if the user is not defined, a guid is generated and will persist until the app is uninstalled + // Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number + // unique to every GSM and UMTS mobile phone. + var deviceID = device.uuid; + + +### iOS dziwactwo + +`uuid`Na iOS nie jest przypisany do urządzenia, ale różni się dla każdej aplikacji, dla każdej instalacji. Zmienia się jeśli możesz usunąć i ponownie zainstalować aplikację, a ewentualnie także po aktualizacji iOS czy nawet uaktualnienia aplikacji dla wersji (widoczny w iOS 5.1). `uuid`Jest nie wiarygodne wartości. + +### Windows Phone 7 i 8 dziwactwa + +`uuid`Dla Windows Phone 7 wymaga uprawnień `ID_CAP_IDENTITY_DEVICE` . Microsoft będzie prawdopodobnie potępiać ten wkrótce. Jeśli funkcja nie jest dostępna, aplikacja generuje trwałe identyfikator guid, który jest utrzymywany przez czas trwania instalacji aplikacji na urządzeniu. + +## device.version + +Pobierz wersję systemu operacyjnego. + + var string = device.version; + + +### Obsługiwane platformy + + * Android 2.1 + + * BlackBerry 10 + * Przeglądarka + * iOS + * Tizen + * Windows Phone 7 i 8 + * Windows 8 + +### Szybki przykład + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/pl/index.md b/plugins/cordova-plugin-device/doc/pl/index.md new file mode 100644 index 0000000..acc8f9c --- /dev/null +++ b/plugins/cordova-plugin-device/doc/pl/index.md @@ -0,0 +1,206 @@ + + +# cordova-plugin-device + +Ten plugin określa globalne `device` obiekt, który opisuje urządzenia sprzętowe i programowe. Mimo, że obiekt jest w globalnym zasięgu, nie jest dostępne dopiero po `deviceready` zdarzenie. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Instalacja + + cordova plugin add cordova-plugin-device + + +## Właściwości + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +Pobierz wersję Cordova działa na urządzeniu. + +### Obsługiwane platformy + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Przeglądarka +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 i 8 +* Windows 8 + +## device.model + +`device.model`Zwraca nazwę modelu lub produktu. Wartość jest zestaw przez producenta urządzenia i mogą się różnić między wersjami tego samego produktu. + +### Obsługiwane platformy + +* Android +* BlackBerry 10 +* Przeglądarka +* iOS +* Tizen +* Windows Phone 7 i 8 +* Windows 8 + +### Szybki przykład + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Zobacz http://theiphonewiki.com/wiki/index.php?title=Models / / modelu var = device.model; + + +### Dziwactwa Androida + +* Pobiera [nazwę produktu][1] zamiast [nazwy modelu][2], który często jest nazwą kod produkcji. Na przykład, Nexus One zwraca `Passion` , i zwraca Motorola Droid`voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + [2]: http://developer.android.com/reference/android/os/Build.html#MODEL + +### Dziwactwa Tizen + +* Zwraca modelu urządzenia przypisane przez dostawcę, na przykład,`TIZEN` + +### Windows Phone 7 i 8 dziwactwa + +* Zwraca modelu urządzenia, określonej przez producenta. Na przykład Samsung ostrości zwraca`SGH-i917`. + +## device.platform + +Uzyskać nazwę systemu operacyjnego urządzenia. + + var string = device.platform; + + +### Obsługiwane platformy + +* Android +* BlackBerry 10 +* Browser4 +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 i 8 +* Windows 8 + +### Szybki przykład + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Dziwactwa Windows Phone 7 + +Urządzenia Windows Phone 7 raport platformy jako`WinCE`. + +### Windows Phone 8 dziwactwa + +Urządzenia Windows Phone 8 raport platformy jako`Win32NT`. + +## device.uuid + +Się urządzenia uniwersalnie unikatowy identyfikator ([UUID][3]). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### Opis + +Szczegóły jak UUID jest generowane są określane przez producenta urządzenia i są specyficzne dla platformy lub modelu urządzenia. + +### Obsługiwane platformy + +* Android +* BlackBerry 10 +* iOS +* Tizen +* Windows Phone 7 i 8 +* Windows 8 + +### Szybki przykład + + / / Android: zwraca losowe 64-bitowa liczba całkowita (jako ciąg, znowu!) / / liczba całkowita jest generowany na pierwszego uruchomienia urządzenia / / / / BlackBerry: zwraca numer PIN urządzenia / / to jest unikatową liczbą całkowitą dziewięciu cyfr (jako ciąg, choć!) / / / / iPhone: (zacytowana w dokumentacji klasy UIDevice) / / zwraca ciąg wartości mieszania utworzone z wielu sprzętu identyfikuje. + Zapewniona jest unikatowy dla każdego urządzenia i nie może być związane z / do konta użytkownika. + / / Windows Phone 7: zwraca wartość mieszania urządzenia + bieżący użytkownik, / / jeśli nie zdefiniowane przez użytkownika, identyfikator guid jest generowany i będzie trwać do czasu odinstalowania aplikacji / / Tizen: zwraca urządzenia IMEI (International Mobile Equipment Identity lub IMEI jest liczbą / / unikatowe dla każdego telefonu komórkowego GSM i UMTS. + var deviceID = device.uuid; + + +### iOS dziwactwo + +`uuid`Na iOS nie jest przypisany do urządzenia, ale różni się dla każdej aplikacji, dla każdej instalacji. Zmienia się jeśli możesz usunąć i ponownie zainstalować aplikację, a ewentualnie także po aktualizacji iOS czy nawet uaktualnienia aplikacji dla wersji (widoczny w iOS 5.1). `uuid`Jest nie wiarygodne wartości. + +### Windows Phone 7 i 8 dziwactwa + +`uuid`Dla Windows Phone 7 wymaga uprawnień `ID_CAP_IDENTITY_DEVICE` . Microsoft będzie prawdopodobnie potępiać ten wkrótce. Jeśli funkcja nie jest dostępna, aplikacja generuje trwałe identyfikator guid, który jest utrzymywany przez czas trwania instalacji aplikacji na urządzeniu. + +## device.version + +Pobierz wersję systemu operacyjnego. + + var string = device.version; + + +### Obsługiwane platformy + +* Android 2.1 + +* BlackBerry 10 +* Przeglądarka +* iOS +* Tizen +* Windows Phone 7 i 8 +* Windows 8 + +### Szybki przykład + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/ru/index.md b/plugins/cordova-plugin-device/doc/ru/index.md new file mode 100644 index 0000000..263b1cd --- /dev/null +++ b/plugins/cordova-plugin-device/doc/ru/index.md @@ -0,0 +1,219 @@ + + +# cordova-plugin-device + +Этот плагин определяет глобальный объект `device`, который описывает оборудование и программное обеспечение устройства. Несмотря на то что объект в глобальной области видимости, он не доступен до того момента пока не произойдет событие `deviceready`. + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## Установка + + cordova plugin add cordova-plugin-device + + +## Параметры + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +Возвращает версию Cordova, работающую на устройстве. + +### Поддерживаемые платформы + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Обозреватель +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 и 8 +* Windows 8 + +## device.model + +Свойство `device.model` возвращает имя устройства модели или продукта. Значение устанавливается производителем устройства и могут отличаться в разных версиях одного и того же продукта. + +### Поддерживаемые платформы + +* Android +* BlackBerry 10 +* Обозреватель +* iOS +* Tizen +* Windows Phone 7 и 8 +* Windows 8 + +### Краткий пример + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models + // + var model = device.model; + + +### Особенности Android + +* Возвращает [имя продукта][1] , а не [имя модели][2], которое часто является производственным кодом. Например, Nexus One из них возвращает `Passion` , и Motorola Droid возвращает `voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + [2]: http://developer.android.com/reference/android/os/Build.html#MODEL + +### Особенности Tizen + +* Возвращает модель устройства, назначенного вендором, например,`TIZEN` + +### Особенности Windows Phone 7 и 8 + +* Возвращает модель устройства, указанной заводом-изготовителем. Например Samsung Focus возвращает `SGH-i917`. + +## device.platform + +Получите имя операционной системы устройства. + + var string = device.platform; + + +### Поддерживаемые платформы + +* Android +* BlackBerry 10 +* Браузером4 +* Firefox OS +* iOS +* Tizen +* Windows Phone 7 и 8 +* Windows 8 + +### Краткий пример + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Особенности Windows Phone 7 + +Windows Phone 7 устройства сообщают платформу как `WinCE`. + +### Особенности Windows Phone 8 + +Устройства Windows Phone 8 сообщают платформу как `Win32NT`. + +## device.uuid + +Возвращает универсальный уникального идентификатора ([UUID][3] устройства). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### Описание + +Подробная информация о том как UUID генерируется, определяются изготовителем устройства и являются специфическими для платформы или модели устройства. + +### Поддерживаемые платформы + +* Android +* BlackBerry 10 +* iOS +* Tizen +* Windows Phone 7 и 8 +* Windows 8 + +### Краткий пример + + // Android: Возвращает случайное 64-разрядное целое число (в виде строки, опять!) + // целое число генерируется при первой загрузке устройства + // + // BlackBerry: Возвращает номер PIN устройства + // это 9 значный уникальный целочисленный (как строка, хотя!) + // + // iPhone: (Перефразировано из документации класса UIDevice) + // возвращает строку хэш-значения, созданные из нескольких аппаратных определяет. + // Это значение гарантированно является уникальным для каждого устройства и не может быть привязано + // к учетной записи пользователя. + // Windows Phone 7: Возвращает хэш устройство + текущего пользователя, + // если пользователь не определен, формируется guid который и будет сохраняться до тех пор, пока приложение не удалиться + // Tizen: возвращает IMEI устройства (Международный идентификатор мобильного оборудования или IMEI это число + // уникальное для каждого мобильного телефона GSM и UMTS. + var deviceID = device.uuid; + + +### Особенности iOS + +На iOS `uuid` не является уникальным для устройства, но варьируется для каждого приложения, и для каждой установки. Значение меняется, если удалить и повторно установить приложение, и возможно также когда вы обновите iOS, или даже обновить приложение до следующей версии (очевидно в iOS 5.1). Значение `uuid` не является надежным. + +### Особенности Windows Phone 7 и 8 + +Для Windows Phone 7 `uuid` требует разрешения `ID_CAP_IDENTITY_DEVICE` . Microsoft скорее всего скоро сделает это свойство устаревшим. Если возможность недоступна, приложение создает постоянные guid, который сохраняется на все время установки приложения на устройстве. + +## device.version + +Возвращает версию операционной системы. + + var string = device.version; + + +### Поддерживаемые платформы + +* Android 2.1 + +* BlackBerry 10 +* Обозреватель +* iOS +* Tizen +* Windows Phone 7 и 8 +* Windows 8 + +### Краткий пример + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/doc/zh/README.md b/plugins/cordova-plugin-device/doc/zh/README.md new file mode 100644 index 0000000..9a18a55 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/zh/README.md @@ -0,0 +1,203 @@ + + +# cordova-plugin-device + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) + +這個外掛程式定義全球 `device` 物件,描述該設備的硬體和軟體。 雖然物件是在全球範圍內,但不是可用,直到後 `deviceready` 事件。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## 安裝 + + cordova plugin add cordova-plugin-device + + +## 屬性 + + * device.cordova + * device.model + * device.platform + * device.uuid + * device.version + +## device.cordova + +獲取科爾多瓦在設備上運行的版本。 + +### 支援的平臺 + + * 亞馬遜火 OS + * Android 系統 + * 黑莓 10 + * 瀏覽器 + * 火狐瀏覽器作業系統 + * iOS + * Tizen + * Windows Phone 7 和 8 + * Windows 8 + +## device.model + +`device.model`返回設備的模型或產品的名稱。值由設備製造商設置和同一產品的不同版本可能不同。 + +### 支援的平臺 + + * Android 系統 + * 黑莓 10 + * 瀏覽器 + * iOS + * Tizen + * Windows Phone 7 和 8 + * Windows 8 + +### 快速的示例 + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. 請參閱 HTTP://theiphonewiki.com/wiki/index.php?title=Models / / var 模型 = device.model ; + + +### Android 的怪癖 + + * 獲取[產品名稱](http://developer.android.com/reference/android/os/Build.html#PRODUCT)而不是[產品型號名稱](http://developer.android.com/reference/android/os/Build.html#MODEL),這往往是生產代碼名稱。 例如,Nexus One 返回 `Passion` ,和摩托羅拉 Droid 返回`voles`. + +### Tizen 怪癖 + + * 例如,返回與供應商指派的設備模型`TIZEN` + +### Windows Phone 7 和 8 怪癖 + + * 返回由製造商指定的設備模型。例如,三星焦點返回`SGH-i917`. + +## device.platform + +獲取設備的作業系統名稱。 + + var string = device.platform; + + +### 支援的平臺 + + * Android 系統 + * 黑莓 10 + * Browser4 + * 火狐瀏覽器作業系統 + * iOS + * Tizen + * Windows Phone 7 和 8 + * Windows 8 + +### 快速的示例 + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 的怪癖 + +Windows Phone 7 設備報告作為平臺`WinCE`. + +### Windows Phone 8 怪癖 + +Windows Phone 8 設備報告作為平臺`Win32NT`. + +## device.uuid + +獲取設備的通用唯一識別碼 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). + + var string = device.uuid; + + +### 說明 + +如何生成一個 UUID 的細節由設備製造商和特定于設備的平臺或模型。 + +### 支援的平臺 + + * Android 系統 + * 黑莓 10 + * iOS + * Tizen + * Windows Phone 7 和 8 + * Windows 8 + +### 快速的示例 + + / / Android: 一個隨機的 64 位整數 (作為字串返回,再次!) / / 上設備的第一次啟動生成的整數 / / / / 黑莓手機: 返回設備的 PIN 號碼 / / 這是九個數字的唯一整數 (作為字串,雖然!) / / / / iPhone: (從 UIDevice 類文檔解釋) / / 返回一個字串的雜湊值創建的多個硬體標識。 + / / 它保證是唯一的每個設備並不能綁 / / 到使用者帳戶。 + / / Windows Phone 7: 返回的雜湊代碼的設備 + 當前使用者,/ / 如果未定義使用者,則一個 guid 生成的並且將會保留直到卸載該應用程式 / / Tizen: 返回設備 IMEI (國際行動裝置身份或 IMEI 是一個數位 / / 獨有的每一個 UMTS 和 GSM 行動電話。 + var deviceID = device.uuid; + + +### iOS 怪癖 + +`uuid`在 iOS 不是唯一的一種裝置,但對於每個應用程式,為每個安裝而異。 如果您刪除並重新安裝該應用程式,它更改和可能還當你升級 iOS,或甚至升級每個版本 (iOS 5.1 中存在明顯的) 的應用程式。 `uuid`不是一個可靠的值。 + +### Windows Phone 7 和 8 怪癖 + +`uuid`為 Windows Phone 7 須經許可 `ID_CAP_IDENTITY_DEVICE` 。 Microsoft 可能會很快棄用此屬性。 如果沒有可用的能力,應用程式將生成設備上應用程式的安裝過程中保持持續的 guid。 + +## device.version + +獲取作業系統版本。 + + var string = device.version; + + +### 支援的平臺 + + * Android 2.1 + + * 黑莓 10 + * 瀏覽器 + * iOS + * Tizen + * Windows Phone 7 和 8 + * Windows 8 + +### 快速的示例 + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; \ No newline at end of file diff --git a/plugins/cordova-plugin-device/doc/zh/index.md b/plugins/cordova-plugin-device/doc/zh/index.md new file mode 100644 index 0000000..5626d69 --- /dev/null +++ b/plugins/cordova-plugin-device/doc/zh/index.md @@ -0,0 +1,206 @@ + + +# cordova-plugin-device + +這個外掛程式定義全球 `device` 物件,描述該設備的硬體和軟體。 雖然物件是在全球範圍內,但不是可用,直到後 `deviceready` 事件。 + + document.addEventListener("deviceready", onDeviceReady, false); + function onDeviceReady() { + console.log(device.cordova); + } + + +## 安裝 + + cordova plugin add cordova-plugin-device + + +## 屬性 + +* device.cordova +* device.model +* device.platform +* device.uuid +* device.version + +## device.cordova + +獲取科爾多瓦在設備上運行的版本。 + +### 支援的平臺 + +* 亞馬遜火 OS +* Android 系統 +* 黑莓 10 +* 瀏覽器 +* 火狐瀏覽器的作業系統 +* iOS +* 泰 +* Windows Phone 7 和 8 +* Windows 8 + +## device.model + +`device.model`返回設備的模型或產品的名稱。值由設備製造商設置和同一產品的不同版本可能不同。 + +### 支援的平臺 + +* Android 系統 +* 黑莓 10 +* 瀏覽器 +* iOS +* 泰 +* Windows Phone 7 和 8 +* Windows 8 + +### 快速的示例 + + // Android: Nexus One returns "Passion" (Nexus One code name) + // Motorola Droid returns "voles" + // BlackBerry: Torch 9800 returns "9800" + // Browser: Google Chrome returns "Chrome" + // Safari returns "Safari" + // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. 請參閱 HTTP://theiphonewiki.com/wiki/index.php?title=Models / / var 模型 = device.model ; + + +### Android 的怪癖 + +* 獲取[產品名稱][1]而不是[產品型號名稱][2],這往往是生產代碼名稱。 例如,Nexus One 返回 `Passion` ,和摩托羅拉 Droid 返回`voles`. + + [1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT + [2]: http://developer.android.com/reference/android/os/Build.html#MODEL + +### Tizen 怪癖 + +* 例如,返回與供應商指派的設備模型`TIZEN` + +### Windows Phone 7 和 8 怪癖 + +* 返回由製造商指定的設備模型。例如,三星焦點返回`SGH-i917`. + +## device.platform + +獲取設備的作業系統名稱。 + + var string = device.platform; + + +### 支援的平臺 + +* Android 系統 +* 黑莓 10 +* Browser4 +* 火狐瀏覽器的作業系統 +* iOS +* 泰 +* Windows Phone 7 和 8 +* Windows 8 + +### 快速的示例 + + // Depending on the device, a few examples are: + // - "Android" + // - "BlackBerry 10" + // - Browser: returns "MacIntel" on Mac + // returns "Win32" on Windows + // - "iOS" + // - "WinCE" + // - "Tizen" + var devicePlatform = device.platform; + + +### Windows Phone 7 的怪癖 + +Windows Phone 7 設備報告作為平臺`WinCE`. + +### Windows Phone 8 怪癖 + +Windows Phone 8 設備報告作為平臺`Win32NT`. + +## device.uuid + +獲取設備的通用唯一識別碼 ([UUID][3]). + + [3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier + + var string = device.uuid; + + +### 說明 + +如何生成一個 UUID 的細節由設備製造商和特定于設備的平臺或模型。 + +### 支援的平臺 + +* Android 系統 +* 黑莓 10 +* iOS +* Tizen +* Windows Phone 7 和 8 +* Windows 8 + +### 快速的示例 + + / / Android: 一個隨機的 64 位整數 (作為字串返回,再次!) / / 上設備的第一次啟動生成的整數 / / / / 黑莓手機: 返回設備的 PIN 號碼 / / 這是九個數字的唯一整數 (作為字串,雖然!) / / / / iPhone: (從 UIDevice 類文檔解釋) / / 返回一個字串的雜湊值創建的多個硬體標識。 + / / 它保證是唯一的每個設備並不能綁 / / 到使用者帳戶。 + / / Windows Phone 7: 返回的雜湊代碼的設備 + 當前使用者,/ / 如果未定義使用者,則一個 guid 生成的並且將會保留直到卸載該應用程式 / / Tizen: 返回設備 IMEI (國際行動裝置身份或 IMEI 是一個數位 / / 獨有的每一個 UMTS 和 GSM 行動電話。 + var deviceID = device.uuid; + + +### iOS 怪癖 + +`uuid`在 iOS 不是唯一的一種裝置,但對於每個應用程式,為每個安裝而異。 如果您刪除並重新安裝該應用程式,它更改和可能還當你升級 iOS,或甚至升級每個版本 (iOS 5.1 中存在明顯的) 的應用程式。 `uuid`不是一個可靠的值。 + +### Windows Phone 7 和 8 怪癖 + +`uuid`為 Windows Phone 7 須經許可 `ID_CAP_IDENTITY_DEVICE` 。 Microsoft 可能會很快棄用此屬性。 如果沒有可用的能力,應用程式將生成設備上應用程式的安裝過程中保持持續的 guid。 + +## device.version + +獲取作業系統版本。 + + var string = device.version; + + +### 支援的平臺 + +* Android 2.1 + +* 黑莓 10 +* 瀏覽器 +* iOS +* 泰 +* Windows Phone 7 和 8 +* Windows 8 + +### 快速的示例 + + // Android: Froyo OS would return "2.2" + // Eclair OS would return "2.1", "2.0.1", or "2.0" + // Version can also return update level "2.1-update1" + // + // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" + // + // Browser: Returns version number for the browser + // + // iPhone: iOS 3.2 returns "3.2" + // + // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 + // Tizen: returns "TIZEN_20120425_2" + var deviceVersion = device.version; diff --git a/plugins/cordova-plugin-device/package.json b/plugins/cordova-plugin-device/package.json new file mode 100644 index 0000000..0719f86 --- /dev/null +++ b/plugins/cordova-plugin-device/package.json @@ -0,0 +1,54 @@ +{ + "name": "cordova-plugin-device", + "version": "1.1.2-dev", + "description": "Cordova Device Plugin", + "cordova": { + "id": "cordova-plugin-device", + "platforms": [ + "firefoxos", + "tizen", + "android", + "amazon-fireos", + "ubuntu", + "ios", + "blackberry10", + "wp7", + "wp8", + "windows8", + "windows", + "browser", + "osx" + ] + }, + "repository": { + "type": "git", + "url": "https://github.com/apache/cordova-plugin-device" + }, + "keywords": [ + "cordova", + "device", + "ecosystem:cordova", + "cordova-firefoxos", + "cordova-tizen", + "cordova-android", + "cordova-amazon-fireos", + "cordova-ubuntu", + "cordova-ios", + "cordova-blackberry10", + "cordova-wp7", + "cordova-wp8", + "cordova-windows8", + "cordova-windows", + "cordova-browser", + "cordova-osx" + ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, + "author": "Apache Software Foundation", + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } +} diff --git a/plugins/cordova-plugin-device/plugin.xml b/plugins/cordova-plugin-device/plugin.xml new file mode 100644 index 0000000..97cdd26 --- /dev/null +++ b/plugins/cordova-plugin-device/plugin.xml @@ -0,0 +1,174 @@ + + + + + Device + Cordova Device Plugin + Apache 2.0 + cordova,device + https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git + https://issues.apache.org/jira/browse/CB/component/12320648 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + read_device_identifying_information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-device/src/android/Device.java b/plugins/cordova-plugin-device/src/android/Device.java new file mode 100644 index 0000000..e9efcb4 --- /dev/null +++ b/plugins/cordova-plugin-device/src/android/Device.java @@ -0,0 +1,174 @@ +/* + 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.device; + +import java.util.TimeZone; + +import org.apache.cordova.CordovaWebView; +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CordovaInterface; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import android.provider.Settings; + +public class Device extends CordovaPlugin { + public static final String TAG = "Device"; + + public static String platform; // Device OS + public static String uuid; // Device UUID + + private static final String ANDROID_PLATFORM = "Android"; + private static final String AMAZON_PLATFORM = "amazon-fireos"; + private static final String AMAZON_DEVICE = "Amazon"; + + /** + * Constructor. + */ + public Device() { + } + + /** + * Sets the context of the Command. This can then be used to do things like + * get file paths associated with the Activity. + * + * @param cordova The context of the main Activity. + * @param webView The CordovaWebView Cordova is running in. + */ + public void initialize(CordovaInterface cordova, CordovaWebView webView) { + super.initialize(cordova, webView); + Device.uuid = getUuid(); + } + + /** + * 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 True if the action was valid, false if not. + */ + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + if ("getDeviceInfo".equals(action)) { + JSONObject r = new JSONObject(); + r.put("uuid", Device.uuid); + r.put("version", this.getOSVersion()); + r.put("platform", this.getPlatform()); + r.put("model", this.getModel()); + r.put("manufacturer", this.getManufacturer()); + r.put("isVirtual", this.isVirtual()); + r.put("serial", this.getSerialNumber()); + callbackContext.success(r); + } + else { + return false; + } + return true; + } + + //-------------------------------------------------------------------------- + // LOCAL METHODS + //-------------------------------------------------------------------------- + + /** + * Get the OS name. + * + * @return + */ + public String getPlatform() { + String platform; + if (isAmazonDevice()) { + platform = AMAZON_PLATFORM; + } else { + platform = ANDROID_PLATFORM; + } + return platform; + } + + /** + * Get the device's Universally Unique Identifier (UUID). + * + * @return + */ + public String getUuid() { + String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); + return uuid; + } + + public String getModel() { + String model = android.os.Build.MODEL; + return model; + } + + public String getProductName() { + String productname = android.os.Build.PRODUCT; + return productname; + } + + public String getManufacturer() { + String manufacturer = android.os.Build.MANUFACTURER; + return manufacturer; + } + + public String getSerialNumber() { + String serial = android.os.Build.SERIAL; + return serial; + } + + /** + * Get the OS version. + * + * @return + */ + public String getOSVersion() { + String osversion = android.os.Build.VERSION.RELEASE; + return osversion; + } + + public String getSDKVersion() { + @SuppressWarnings("deprecation") + String sdkversion = android.os.Build.VERSION.SDK; + return sdkversion; + } + + public String getTimeZoneID() { + TimeZone tz = TimeZone.getDefault(); + return (tz.getID()); + } + + /** + * Function to check if the device is manufactured by Amazon + * + * @return + */ + public boolean isAmazonDevice() { + if (android.os.Build.MANUFACTURER.equals(AMAZON_DEVICE)) { + return true; + } + return false; + } + + public boolean isVirtual() { + return android.os.Build.FINGERPRINT.contains("generic") || + android.os.Build.PRODUCT.contains("sdk"); + } + +} diff --git a/plugins/cordova-plugin-device/src/blackberry10/index.js b/plugins/cordova-plugin-device/src/blackberry10/index.js new file mode 100644 index 0000000..ef0543b --- /dev/null +++ b/plugins/cordova-plugin-device/src/blackberry10/index.js @@ -0,0 +1,71 @@ +/* + * + * 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. + * +*/ + +/* global PluginResult */ + +function getModelName () { + var modelName = window.qnx.webplatform.device.modelName; + //Pre 10.2 (meaning Z10 or Q10) + if (typeof modelName === "undefined") { + if (window.screen.height === 720 && window.screen.width === 720) { + if ( window.matchMedia("(-blackberry-display-technology: -blackberry-display-oled)").matches) { + modelName = "Q10"; + } else { + modelName = "Q5"; + } + } else if ((window.screen.height === 1280 && window.screen.width === 768) || + (window.screen.height === 768 && window.screen.width === 1280)) { + modelName = "Z10"; + } else { + modelName = window.qnx.webplatform.deviceName; + } + } + + return modelName; +} + +function getUUID () { + var uuid = ""; + try { + //Must surround by try catch because this will throw if the app is missing permissions + uuid = window.qnx.webplatform.device.devicePin; + } catch (e) { + //DO Nothing + } + return uuid; +} + +module.exports = { + getDeviceInfo: function (success, fail, args, env) { + var result = new PluginResult(args, env), + modelName = getModelName(), + uuid = getUUID(), + info = { + manufacturer: 'BlackBerry', + platform: "blackberry10", + version: window.qnx.webplatform.device.scmBundle, + model: modelName, + uuid: uuid + }; + + result.ok(info); + } +}; diff --git a/plugins/cordova-plugin-device/src/browser/DeviceProxy.js b/plugins/cordova-plugin-device/src/browser/DeviceProxy.js new file mode 100644 index 0000000..a863201 --- /dev/null +++ b/plugins/cordova-plugin-device/src/browser/DeviceProxy.js @@ -0,0 +1,82 @@ +/* + * + * 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. + * + */ +var browser = require('cordova/platform'); + +function getPlatform() { + return "browser"; +} + +function getModel() { + return getBrowserInfo(true); +} + +function getVersion() { + return getBrowserInfo(false); +} + +function getBrowserInfo(getModel) { + var userAgent = navigator.userAgent; + var returnVal = ''; + var offset; + + if ((offset = userAgent.indexOf('Chrome')) !== -1) { + returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); + } else if ((offset = userAgent.indexOf('Safari')) !== -1) { + if (getModel) { + returnVal = 'Safari'; + } else { + returnVal = userAgent.substring(offset + 7); + + if ((offset = userAgent.indexOf('Version')) !== -1) { + returnVal = userAgent.substring(offset + 8); + } + } + } else if ((offset = userAgent.indexOf('Firefox')) !== -1) { + returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8); + } else if ((offset = userAgent.indexOf('MSIE')) !== -1) { + returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5); + } else if ((offset = userAgent.indexOf('Trident')) !== -1) { + returnVal = (getModel) ? 'MSIE' : '11'; + } + + if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) { + returnVal = returnVal.substring(0, offset); + } + + return returnVal; +} + + +module.exports = { + getDeviceInfo: function (success, error) { + setTimeout(function () { + success({ + cordova: browser.cordovaVersion, + platform: getPlatform(), + model: getModel(), + version: getVersion(), + uuid: null + }); + }, 0); + } +}; + +require("cordova/exec/proxy").add("Device", module.exports); diff --git a/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js b/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js new file mode 100644 index 0000000..a05d7ca --- /dev/null +++ b/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js @@ -0,0 +1,77 @@ +/* + * + * 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. + * + */ +//example UA String for Firefox OS +//Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 + +//UA parsing not recommended but currently this is the only way to get the Firefox OS version +//https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference + +//Should be replaced when better conversion to Firefox OS Version is available +function convertVersionNumber(ver) { + var hashVersion = { + '18.0': '1.0.1', + '18.1': '1.1', + '26.0': '1.2', + '28.0': '1.3', + '30.0': '1.4', + '32.0': '2.0' + }; + var rver = ver; + var sStr = ver.substring(0, 4); + if (hashVersion[sStr]) { + rver = hashVersion[sStr]; + } + return (rver); + +} +function getVersion() { + if (navigator.userAgent.match(/(mobile|tablet)/i)) { + var ffVersionArray = (navigator.userAgent.match(/Firefox\/([\d]+\.[\w]?\.?[\w]+)/)); + if (ffVersionArray.length === 2) { + return (convertVersionNumber(ffVersionArray[1])); + } + } + return (null); +} + +function getModel() { + var uaArray = navigator.userAgent.split(/\s*[;)(]\s*/); + if (navigator.userAgent.match(/(mobile|tablet)/i)) { + if (uaArray.length === 5) { + return (uaArray[2]); + } + } + return (null); +} +module.exports = { + getDeviceInfo: function (success, error) { + setTimeout(function () { + success({ + platform: 'firefoxos', + model: getModel(), + version: getVersion(), + uuid: null + }); + }, 0); + } +}; + +require("cordova/exec/proxy").add("Device", module.exports); diff --git a/plugins/cordova-plugin-device/src/ios/CDVDevice.h b/plugins/cordova-plugin-device/src/ios/CDVDevice.h new file mode 100644 index 0000000..a146d88 --- /dev/null +++ b/plugins/cordova-plugin-device/src/ios/CDVDevice.h @@ -0,0 +1,30 @@ +/* + 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. + */ + +#import +#import + +@interface CDVDevice : CDVPlugin +{} + ++ (NSString*)cordovaVersion; + +- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command; + +@end diff --git a/plugins/cordova-plugin-device/src/ios/CDVDevice.m b/plugins/cordova-plugin-device/src/ios/CDVDevice.m new file mode 100644 index 0000000..4d75a57 --- /dev/null +++ b/plugins/cordova-plugin-device/src/ios/CDVDevice.m @@ -0,0 +1,112 @@ +/* + 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. + */ + +#include +#include +#include "TargetConditionals.h" + +#import +#import "CDVDevice.h" + +@implementation UIDevice (ModelVersion) + +- (NSString*)modelVersion +{ + size_t size; + + sysctlbyname("hw.machine", NULL, &size, NULL, 0); + char* machine = malloc(size); + sysctlbyname("hw.machine", machine, &size, NULL, 0); + NSString* platform = [NSString stringWithUTF8String:machine]; + free(machine); + + return platform; +} + +@end + +@interface CDVDevice () {} +@end + +@implementation CDVDevice + +- (NSString*)uniqueAppInstanceIdentifier:(UIDevice*)device +{ + NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; + static NSString* UUID_KEY = @"CDVUUID"; + + // Check user defaults first to maintain backwards compaitibility with previous versions + // which didn't user identifierForVendor + NSString* app_uuid = [userDefaults stringForKey:UUID_KEY]; + if (app_uuid == nil) { + if ([device respondsToSelector:@selector(identifierForVendor)]) { + app_uuid = [[device identifierForVendor] UUIDString]; + } else { + CFUUIDRef uuid = CFUUIDCreate(NULL); + app_uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid); + CFRelease(uuid); + } + + [userDefaults setObject:app_uuid forKey:UUID_KEY]; + [userDefaults synchronize]; + } + + return app_uuid; +} + +- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command +{ + NSDictionary* deviceProperties = [self deviceProperties]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties]; + + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (NSDictionary*)deviceProperties +{ + UIDevice* device = [UIDevice currentDevice]; + + return @{ + @"manufacturer": @"Apple", + @"model": [device modelVersion], + @"platform": @"iOS", + @"version": [device systemVersion], + @"uuid": [self uniqueAppInstanceIdentifier:device], + @"cordova": [[self class] cordovaVersion], + @"isVirtual": @([self isVirtual]) + }; +} + ++ (NSString*)cordovaVersion +{ + return CDV_VERSION; +} + +- (BOOL)isVirtual +{ + #if TARGET_OS_SIMULATOR + return true; + #elif TARGET_IPHONE_SIMULATOR + return true; + #else + return false; + #endif +} + +@end diff --git a/plugins/cordova-plugin-device/src/osx/CDVDevice.h b/plugins/cordova-plugin-device/src/osx/CDVDevice.h new file mode 100644 index 0000000..9def254 --- /dev/null +++ b/plugins/cordova-plugin-device/src/osx/CDVDevice.h @@ -0,0 +1,28 @@ +/* + 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. + */ + +#import + +@interface CDVDevice : CDVPlugin + ++ (NSString*) cordovaVersion; + +- (void) getDeviceInfo:(CDVInvokedUrlCommand*)command; + +@end diff --git a/plugins/cordova-plugin-device/src/osx/CDVDevice.m b/plugins/cordova-plugin-device/src/osx/CDVDevice.m new file mode 100644 index 0000000..3a63588 --- /dev/null +++ b/plugins/cordova-plugin-device/src/osx/CDVDevice.m @@ -0,0 +1,113 @@ +/* + 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. + */ + +#include + +#import "CDVDevice.h" + +#define SYSTEM_VERSION_PLIST @"/System/Library/CoreServices/SystemVersion.plist" + +@implementation CDVDevice + +- (NSString*) modelVersion { + size_t size; + + sysctlbyname("hw.machine", NULL, &size, NULL, 0); + char* machine = malloc(size); + sysctlbyname("hw.machine", machine, &size, NULL, 0); + NSString* modelVersion = [NSString stringWithUTF8String:machine]; + free(machine); + + return modelVersion; +} + + +- (NSString*) getSerialNr { + NSString* serialNr; + io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + if (platformExpert) { + CFTypeRef serialNumberAsCFString = + IORegistryEntryCreateCFProperty(platformExpert, + CFSTR(kIOPlatformSerialNumberKey), + kCFAllocatorDefault, 0); + if (serialNumberAsCFString) { + serialNr = (__bridge NSString*) serialNumberAsCFString; + } + IOObjectRelease(platformExpert); + } + return serialNr; +} + +- (NSString*) uniqueAppInstanceIdentifier { + NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; + static NSString* UUID_KEY = @"CDVUUID"; + + NSString* app_uuid = [userDefaults stringForKey:UUID_KEY]; + + if (app_uuid == nil) { + CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); + CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); + + app_uuid = [NSString stringWithString:(__bridge NSString*) uuidString]; + [userDefaults setObject:app_uuid forKey:UUID_KEY]; + [userDefaults synchronize]; + + CFRelease(uuidString); + CFRelease(uuidRef); + } + + return app_uuid; +} + +- (NSString*) platform { + return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductName"]; +} + +- (NSString*) systemVersion { + return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductVersion"]; +} + +- (void) getDeviceInfo:(CDVInvokedUrlCommand*) command { + NSDictionary* deviceProperties = [self deviceProperties]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties]; + + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (NSDictionary*) deviceProperties { + NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4]; + + devProps[@"manufacturer"] = @"Apple"; + devProps[@"model"] = [self modelVersion]; + devProps[@"platform"] = [self platform]; + devProps[@"version"] = [self systemVersion]; + devProps[@"uuid"] = [self uniqueAppInstanceIdentifier]; + devProps[@"cordova"] = [[self class] cordovaVersion]; + devProps[@"serial"] = [self getSerialNr]; + devProps[@"isVirtual"] = @NO; + + NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps]; + return devReturn; +} + ++ (NSString*) cordovaVersion { + return CDV_VERSION; +} + +@end diff --git a/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js b/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js new file mode 100644 index 0000000..973b716 --- /dev/null +++ b/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js @@ -0,0 +1,38 @@ +/* + * + * 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. + * +*/ + +var tizen = require('cordova/platform'); + +module.exports = { + getDeviceInfo: function(success, error) { + setTimeout(function () { + success({ + cordova: tizen.cordovaVersion, + platform: 'tizen', + model: null, + version: null, + uuid: null + }); + }, 0); + } +}; + +require("cordova/tizen/commandProxy").add("Device", module.exports); diff --git a/plugins/cordova-plugin-device/src/ubuntu/device.cpp b/plugins/cordova-plugin-device/src/ubuntu/device.cpp new file mode 100644 index 0000000..eb5a012 --- /dev/null +++ b/plugins/cordova-plugin-device/src/ubuntu/device.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ + * + * 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. + */ + +#include +#include + +#include"device.h" + +#define CORDOVA "3.0.0" + +Device::Device(Cordova *cordova) : CPlugin(cordova) { +} + +static QString getOSName() { +#ifdef Q_OS_SYMBIAN + QString platform = "Symbian"; +#endif +#ifdef Q_OS_WIN + QString platform = "Windows"; +#endif +#ifdef Q_OS_WINCE + QString platform = "Windows CE"; +#endif +#ifdef Q_OS_LINUX + QString platform = "Linux"; +#endif + return platform; +} + +void Device::getInfo(int scId, int ecId) { + Q_UNUSED(ecId) + + QDeviceInfo systemDeviceInfo; + QDeviceInfo systemInfo; + + QString platform = getOSName(); + + QString uuid = systemDeviceInfo.uniqueDeviceID(); + if (uuid.isEmpty()) { + QString deviceDescription = systemInfo.imei(0) + ";" + systemInfo.manufacturer() + ";" + systemInfo.model() + ";" + systemInfo.productName() + ";" + platform; + QString user = qgetenv("USER"); + if (user.isEmpty()) { + user = qgetenv("USERNAME"); + if (user.isEmpty()) + user = QDir::homePath(); + } + uuid = QString(QCryptographicHash::hash((deviceDescription + ";" + user).toUtf8(), QCryptographicHash::Md5).toHex()); + } + + this->cb(scId, systemDeviceInfo.model(), CORDOVA, platform, uuid, systemInfo.version(QDeviceInfo::Os)); +} diff --git a/plugins/cordova-plugin-device/src/ubuntu/device.h b/plugins/cordova-plugin-device/src/ubuntu/device.h new file mode 100644 index 0000000..91cb937 --- /dev/null +++ b/plugins/cordova-plugin-device/src/ubuntu/device.h @@ -0,0 +1,47 @@ +/* + * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ + * + * 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. + */ + +#ifndef DEVICE_H_FDSAFAS +#define DEVICE_H_FDSAFAS + +#include + +#include + +class Device: public CPlugin { + Q_OBJECT +public: + explicit Device(Cordova *cordova); + + virtual const QString fullName() override { + return Device::fullID(); + } + + virtual const QString shortName() override { + return "Device"; + } + + static const QString fullID() { + return "com.cordova.Device"; + } + +signals: + +public slots: + void getInfo(int scId, int ecId); +}; + +#endif diff --git a/plugins/cordova-plugin-device/src/ubuntu/device.js b/plugins/cordova-plugin-device/src/ubuntu/device.js new file mode 100644 index 0000000..838586c --- /dev/null +++ b/plugins/cordova-plugin-device/src/ubuntu/device.js @@ -0,0 +1,33 @@ +/* + * + * 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. + * +*/ + +/* global Cordova */ + +module.exports = { + getInfo:function(win,fail,args) { + Cordova.exec(function (model, cordova, platform, uuid, version) { + win({name: name, model: model, cordova: cordova, + platform: platform, uuid: uuid, version: version}); + }, null, "com.cordova.Device", "getInfo", []); + } +}; + +require("cordova/exec/proxy").add("Device", module.exports); diff --git a/plugins/cordova-plugin-device/src/windows/DeviceProxy.js b/plugins/cordova-plugin-device/src/windows/DeviceProxy.js new file mode 100644 index 0000000..f338ad3 --- /dev/null +++ b/plugins/cordova-plugin-device/src/windows/DeviceProxy.js @@ -0,0 +1,98 @@ +/* + * + * 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. + * +*/ + +/* global Windows, createUUID */ + +var ROOT_CONTAINER = "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}"; +var DEVICE_CLASS_KEY = "{A45C254E-DF1C-4EFD-8020-67D146A850E0},10"; +var DEVICE_CLASS_KEY_NO_SEMICOLON = "{A45C254E-DF1C-4EFD-8020-67D146A850E0}10"; +var ROOT_CONTAINER_QUERY = "System.Devices.ContainerId:=\"" + ROOT_CONTAINER + "\""; +var HAL_DEVICE_CLASS = "4d36e966-e325-11ce-bfc1-08002be10318"; +var DEVICE_DRIVER_VERSION_KEY = "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3"; + +module.exports = { + + getDeviceInfo:function(win, fail, args) { + + // deviceId aka uuid, stored in Windows.Storage.ApplicationData.current.localSettings.values.deviceId + var deviceId; + // get deviceId, or create and store one + var localSettings = Windows.Storage.ApplicationData.current.localSettings; + if (localSettings.values.deviceId) { + deviceId = localSettings.values.deviceId; + } + else { + // App-specific hardware id could be used as uuid, but it changes if the hardware changes... + try { + var ASHWID = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(null).id; + deviceId = Windows.Storage.Streams.DataReader.fromBuffer(ASHWID).readGuid(); + } catch (e) { + // Couldn't get the hardware UUID + deviceId = createUUID(); + } + //...so cache it per-install + localSettings.values.deviceId = deviceId; + } + + + var userAgent = window.clientInformation.userAgent; + // this will report "windows" in windows8.1 and windows phone 8.1 apps + // and "windows8" in windows 8.0 apps similar to cordova.js + // See https://github.com/apache/cordova-js/blob/master/src/windows/platform.js#L25 + var devicePlatform = userAgent.indexOf("MSAppHost/1.0") == -1 ? "windows" : "windows8"; + var versionString = userAgent.match(/Windows (?:Phone |NT )?([0-9.]+)/)[1]; + + var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation(); + // Running in the Windows Simulator is a remote session. + // Running in the Windows Phone Emulator has the systemProductName set to "Virtual" + var isVirtual = Windows.System.RemoteDesktop.InteractiveSession.isRemote || deviceInfo.systemProductName == "Virtual"; + var manufacturer = deviceInfo.systemManufacturer; + var model = deviceInfo.systemProductName; + + var Pnp = Windows.Devices.Enumeration.Pnp; + + Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.device, + [DEVICE_DRIVER_VERSION_KEY, DEVICE_CLASS_KEY], + ROOT_CONTAINER_QUERY) + .then(function (rootDevices) { + for (var i = 0; i < rootDevices.length; i++) { + var rootDevice = rootDevices[i]; + if (!rootDevice.properties) continue; + if (rootDevice.properties[DEVICE_CLASS_KEY_NO_SEMICOLON] == HAL_DEVICE_CLASS) { + versionString = rootDevice.properties[DEVICE_DRIVER_VERSION_KEY]; + break; + } + } + + setTimeout(function () { + win({ platform: devicePlatform, + version: versionString, + uuid: deviceId, + isVirtual: isVirtual, + model: model, + manufacturer:manufacturer}); + }, 0); + }); + } + +}; // exports + +require("cordova/exec/proxy").add("Device", module.exports); diff --git a/plugins/cordova-plugin-device/src/wp/Device.cs b/plugins/cordova-plugin-device/src/wp/Device.cs new file mode 100644 index 0000000..76fe8cf --- /dev/null +++ b/plugins/cordova-plugin-device/src/wp/Device.cs @@ -0,0 +1,87 @@ +/* + 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. +*/ + +using Microsoft.Phone.Info; +using System; +using System.IO; +using System.IO.IsolatedStorage; + +namespace WPCordovaClassLib.Cordova.Commands +{ + public class Device : BaseCommand + { + public void getDeviceInfo(string notused) + { + string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\",\"manufacturer\":\"{5}\",\"isVirtual\":{6}", + DeviceStatus.DeviceName, + Environment.OSVersion.Platform.ToString(), + UUID, + Environment.OSVersion.Version.ToString(), + DeviceStatus.DeviceName, + DeviceStatus.DeviceManufacturer, + IsVirtual ? "true" : "false"); + DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "{" + res + "}")); + } + + + public bool IsVirtual + { + get + { + return (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator); + } + } + + public string UUID + { + get + { + object id; + + UserExtendedProperties.TryGetValue("ANID", out id); + if (id != null) + { + return id.ToString().Substring(2, 32); + } + + UserExtendedProperties.TryGetValue("ANID2", out id); + if (id != null) + { + return id.ToString(); + } + + string returnVal = "???unknown???"; + + using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication()) + { + try + { + IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage); + + using (StreamReader reader = new StreamReader(fileStream)) + { + returnVal = reader.ReadLine(); + } + } + catch (Exception /*ex*/) + { + + } + } + + return returnVal; + } + } + } +} diff --git a/plugins/cordova-plugin-device/tests/plugin.xml b/plugins/cordova-plugin-device/tests/plugin.xml new file mode 100644 index 0000000..89c75a0 --- /dev/null +++ b/plugins/cordova-plugin-device/tests/plugin.xml @@ -0,0 +1,31 @@ + + + + + Cordova Device Plugin Tests + Apache 2.0 + + + + diff --git a/plugins/cordova-plugin-device/tests/tests.js b/plugins/cordova-plugin-device/tests/tests.js new file mode 100644 index 0000000..ac9a281 --- /dev/null +++ b/plugins/cordova-plugin-device/tests/tests.js @@ -0,0 +1,113 @@ +/* + * + * 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. + * +*/ + +/* jshint jasmine: true */ + +exports.defineAutoTests = function() { + describe('Device Information (window.device)', function () { + it("should exist", function() { + expect(window.device).toBeDefined(); + }); + + it("should contain a platform specification that is a string", function() { + expect(window.device.platform).toBeDefined(); + expect((String(window.device.platform)).length > 0).toBe(true); + }); + + it("should contain a version specification that is a string", function() { + expect(window.device.version).toBeDefined(); + expect((String(window.device.version)).length > 0).toBe(true); + }); + + it("should contain a UUID specification that is a string or a number", function() { + expect(window.device.uuid).toBeDefined(); + if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') { + expect((String(window.device.uuid)).length > 0).toBe(true); + } else { + expect(window.device.uuid > 0).toBe(true); + } + }); + + it("should contain a cordova specification that is a string", function() { + expect(window.device.cordova).toBeDefined(); + expect((String(window.device.cordova)).length > 0).toBe(true); + }); + + it("should depend on the presence of cordova.version string", function() { + expect(window.cordova.version).toBeDefined(); + expect((String(window.cordova.version)).length > 0).toBe(true); + }); + + it("should contain device.cordova equal to cordova.version", function() { + expect(window.device.cordova).toBe(window.cordova.version); + }); + + it("should contain a model specification that is a string", function() { + expect(window.device.model).toBeDefined(); + expect((String(window.device.model)).length > 0).toBe(true); + }); + + it("should contain a manufacturer property that is a string", function() { + expect(window.device.manufacturer).toBeDefined(); + expect((String(window.device.manufacturer)).length > 0).toBe(true); + }); + + it("should contain an isVirtual property that is a boolean", function() { + expect(window.device.isVirtual).toBeDefined(); + expect(typeof window.device.isVirtual).toBe("boolean"); + }); + + it("should contain a serial number specification that is a string", function() { + expect(window.device.serial).toBeDefined(); + expect((String(window.device.serial)).length > 0).toBe(true); + + }); + + }); +}; + +exports.defineManualTests = function(contentEl, createActionButton) { + var logMessage = function (message, color) { + var log = document.getElementById('info'); + var logLine = document.createElement('div'); + if (color) { + logLine.style.color = color; + } + logLine.innerHTML = message; + log.appendChild(logLine); + }; + + var clearLog = function () { + var log = document.getElementById('info'); + log.innerHTML = ''; + }; + + var device_tests = '

Press Dump Device button to get device information

' + + '
' + + 'Expected result: Status box will get updated with device info. (i.e. platform, version, uuid, model, etc)'; + + contentEl.innerHTML = '
' + device_tests; + + createActionButton('Dump device', function() { + clearLog(); + logMessage(JSON.stringify(window.device, null, '\t')); + }, "dump_device"); +}; diff --git a/plugins/cordova-plugin-device/www/device.js b/plugins/cordova-plugin-device/www/device.js new file mode 100644 index 0000000..f7ed19f --- /dev/null +++ b/plugins/cordova-plugin-device/www/device.js @@ -0,0 +1,83 @@ +/* + * + * 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. + * +*/ + +var argscheck = require('cordova/argscheck'), + channel = require('cordova/channel'), + utils = require('cordova/utils'), + exec = require('cordova/exec'), + cordova = require('cordova'); + +channel.createSticky('onCordovaInfoReady'); +// Tell cordova channel to wait on the CordovaInfoReady event +channel.waitForInitialization('onCordovaInfoReady'); + +/** + * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the + * phone, etc. + * @constructor + */ +function Device() { + this.available = false; + this.platform = null; + this.version = null; + this.uuid = null; + this.cordova = null; + this.model = null; + this.manufacturer = null; + this.isVirtual = null; + this.serial = null; + + var me = this; + + channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js + //TODO: CB-5105 native implementations should not return info.cordova + var buildLabel = cordova.version; + me.available = true; + me.platform = info.platform; + me.version = info.version; + me.uuid = info.uuid; + me.cordova = buildLabel; + me.model = info.model; + me.isVirtual = info.isVirtual; + me.manufacturer = info.manufacturer || 'unknown'; + me.serial = info.serial || 'unknown'; + channel.onCordovaInfoReady.fire(); + },function(e) { + me.available = false; + utils.alert("[ERROR] Error initializing Cordova: " + e); + }); + }); +} + +/** + * Get device info + * + * @param {Function} successCallback The function to call when the heading data is available + * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL) + */ +Device.prototype.getInfo = function(successCallback, errorCallback) { + argscheck.checkArgs('fF', 'Device.getInfo', arguments); + exec(successCallback, errorCallback, "Device", "getDeviceInfo", []); +}; + +module.exports = new Device(); diff --git a/plugins/cordova-plugin-dialogs/README.md b/plugins/cordova-plugin-dialogs/README.md index 02eb1b2..5598ab3 100644 --- a/plugins/cordova-plugin-dialogs/README.md +++ b/plugins/cordova-plugin-dialogs/README.md @@ -17,6 +17,8 @@ # under the License. --> +[![Build Status](https://travis-ci.org/apache/cordova-plugin-dialogs.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-dialogs) + # cordova-plugin-dialogs This plugin provides access to some native dialog UI elements @@ -29,7 +31,7 @@ Although the object is attached to the global scoped `navigator`, it is not avai console.log(navigator.notification); } -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Dialogs%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) +Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Dialogs%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) ## Installation diff --git a/plugins/cordova-plugin-dialogs/package.json b/plugins/cordova-plugin-dialogs/package.json index a106c89..9b5b884 100644 --- a/plugins/cordova-plugin-dialogs/package.json +++ b/plugins/cordova-plugin-dialogs/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-dialogs", - "version": "1.2.0", + "version": "1.2.1-dev", "description": "Cordova Notification Plugin", "cordova": { "id": "cordova-plugin-dialogs", @@ -38,6 +38,13 @@ "cordova-windows8", "cordova-windows" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/plugins/cordova-plugin-dialogs/plugin.xml b/plugins/cordova-plugin-dialogs/plugin.xml index e3d936c..263baf2 100644 --- a/plugins/cordova-plugin-dialogs/plugin.xml +++ b/plugins/cordova-plugin-dialogs/plugin.xml @@ -20,7 +20,7 @@ + version="1.2.1-dev"> Notification Cordova Notification Plugin diff --git a/plugins/cordova-plugin-dialogs/src/blackberry10/index.js b/plugins/cordova-plugin-dialogs/src/blackberry10/index.js index 3660f66..4969a77 100644 --- a/plugins/cordova-plugin-dialogs/src/blackberry10/index.js +++ b/plugins/cordova-plugin-dialogs/src/blackberry10/index.js @@ -14,6 +14,8 @@ * limitations under the License. */ +/* global qnx, PluginResult */ + function showDialog(args, dialogType, result) { //Unpack and map the args var msg = JSON.parse(decodeURIComponent(args[0])), diff --git a/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js b/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js index 18bce8b..aea562d 100644 --- a/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js +++ b/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js @@ -84,12 +84,12 @@ function modal(message, callback, title, buttonLabels, domObjects) { result = { input1: '', buttonIndex: 0 - } + }; } mainWindow.setTimeout(function() { callback(result); }, 10); - }; + } modalWindow.addEventListener('unload', onUnload, false); // call callback and destroy modal @@ -110,7 +110,7 @@ function modal(message, callback, title, buttonLabels, domObjects) { } response = response || labelIndex; callback(response); - } + }; } } diff --git a/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m b/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m index a4c95e9..d1f1e33 100644 --- a/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m +++ b/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m @@ -40,7 +40,7 @@ static NSMutableArray *alertList = nil; - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType { - NSUInteger count = [buttons count]; + int count = (int)[buttons count]; #ifdef __IPHONE_8_0 if (NSClassFromString(@"UIAlertController")) { @@ -63,8 +63,9 @@ static NSMutableArray *alertList = nil; __weak CDVNotification* weakNotif = self; for (int n = 0; n < count; n++) { - - UIAlertAction* action = [UIAlertAction actionWithTitle:[buttons objectAtIndex:n] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) + [alertController addAction:[UIAlertAction actionWithTitle:[buttons objectAtIndex:n] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { CDVPluginResult* result; @@ -83,10 +84,7 @@ static NSMutableArray *alertList = nil; } [weakNotif.commandDelegate sendPluginResult:result callbackId:callbackId]; - - }]; - [alertController addAction:action]; - + }]]; } if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) { @@ -222,7 +220,7 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data) { -(UIViewController *)getTopPresentedViewController { UIViewController *presentingViewController = self.viewController; - while(presentingViewController.presentedViewController != nil) + while(presentingViewController.presentedViewController != nil && ![presentingViewController.presentedViewController isBeingDismissed]) { presentingViewController = presentingViewController.presentedViewController; } diff --git a/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js b/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js index a8c5987..c9c9233 100644 --- a/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js +++ b/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js @@ -19,7 +19,7 @@ * */ -/*global Windows:true */ +/*global Windows:true, WinJS, toStaticHTML */ var cordova = require('cordova'); @@ -27,7 +27,7 @@ var isAlertShowing = false; var alertStack = []; // CB-8928: When toStaticHTML is undefined, prompt fails to run -function _cleanHtml(html) { return html; } +var _cleanHtml = function(html) { return html; }; if (typeof toStaticHTML !== 'undefined') { _cleanHtml = toStaticHTML; } @@ -36,7 +36,7 @@ if (typeof toStaticHTML !== 'undefined') { // simple html-based implementation until it is available function createPromptDialog(title, message, buttons, defaultText, callback) { - var isPhone = cordova.platformId == "windows" && WinJS.Utilities.isPhone;; + var isPhone = cordova.platformId == "windows" && WinJS.Utilities.isPhone; var dlgWrap = document.createElement("div"); dlgWrap.style.position = "absolute"; @@ -64,9 +64,9 @@ function createPromptDialog(title, message, buttons, defaultText, callback) { } // dialog layout template - dlg.innerHTML = _cleanHtml("
" // title - + "
" // message - + "
"); // input fields + dlg.innerHTML = _cleanHtml("
" + // title + "
" + // message + "
"); // input fields dlg.querySelector('#lbl-title').appendChild(document.createTextNode(title)); dlg.querySelector('#lbl-message').appendChild(document.createTextNode(message)); @@ -74,13 +74,13 @@ function createPromptDialog(title, message, buttons, defaultText, callback) { function makeButtonCallback(idx) { return function () { - var value = promptInput = dlg.querySelector('#prompt-input').value; + var value = dlg.querySelector('#prompt-input').value; dlgWrap.parentNode.removeChild(dlgWrap); if (callback) { callback({ input1: value, buttonIndex: idx }); } - } + }; } function addButton(idx, label) { @@ -90,7 +90,7 @@ function createPromptDialog(title, message, buttons, defaultText, callback) { button.style.fontSize = "12pt"; button.tabIndex = idx; button.onclick = makeButtonCallback(idx + 1); - if (idx == 0) { + if (idx === 0) { button.style.color = "white"; button.style.backgroundColor = "#464646"; } else { @@ -135,7 +135,9 @@ module.exports = { md.commands.append(new Windows.UI.Popups.UICommand(_buttonLabel)); md.showAsync().then(function() { isAlertShowing = false; - win && win(); + if (win) { + win(); + } if (alertStack.length) { setTimeout(alertStack.shift(), 0); @@ -205,7 +207,9 @@ module.exports = { md.showAsync().then(function(res) { isAlertShowing = false; var result = res ? buttons.indexOf(res.label) + 1 : 0; - win && win(result); + if (win) { + win(result); + } if (alertStack.length) { setTimeout(alertStack.shift(), 0); } @@ -237,7 +241,9 @@ module.exports = { } else { snd.removeEventListener("ended", onEvent); snd = null; - winX && winX(); // notification.js just sends null, but this is future friendly + if (winX) { + winX(); // notification.js just sends null, but this is future friendly + } } count--; }; diff --git a/plugins/cordova-plugin-dialogs/tests/plugin.xml b/plugins/cordova-plugin-dialogs/tests/plugin.xml index 0fb7fd7..639d007 100644 --- a/plugins/cordova-plugin-dialogs/tests/plugin.xml +++ b/plugins/cordova-plugin-dialogs/tests/plugin.xml @@ -20,7 +20,7 @@ + version="1.2.1-dev"> Cordova Notification Plugin Tests Apache 2.0 diff --git a/plugins/cordova-plugin-dialogs/tests/tests.js b/plugins/cordova-plugin-dialogs/tests/tests.js index 16e9cd9..a4cf382 100644 --- a/plugins/cordova-plugin-dialogs/tests/tests.js +++ b/plugins/cordova-plugin-dialogs/tests/tests.js @@ -19,6 +19,9 @@ * */ +/* jshint jasmine: true */ +/* global cordova */ + exports.defineAutoTests = function () { describe('Notification (navigator.notification)', function () { it("should exist", function () { @@ -57,12 +60,12 @@ exports.defineManualTests = function (contentEl, createActionButton) { var logLine = document.createElement('div'); logLine.innerHTML = message; log.appendChild(logLine); - } + }; var clearLog = function () { var log = document.getElementById('info'); log.innerHTML = ''; - } + }; var beep = function () { console.log("beep()"); @@ -118,7 +121,7 @@ exports.defineManualTests = function (contentEl, createActionButton) { if (r && r.buttonIndex === 0) { var msg = "Dismissed dialog"; if (r.input1) { - msg += " with input: " + r.input1 + msg += " with input: " + r.input1; } logMessage(msg); console.log(msg); @@ -181,14 +184,20 @@ exports.defineManualTests = function (contentEl, createActionButton) { }, 'prompt'); createActionButton('Built-in Alert Dialog', function () { - typeof alert === 'function' && alert('You pressed alert'); + if (typeof alert === 'function') { + alert('You pressed alert'); + } }, 'built_in_alert'); createActionButton('Built-in Confirm Dialog', function () { - typeof confirm === 'function' && confirm('You selected confirm'); + if (typeof confirm === 'function') { + confirm('You selected confirm'); + } }, 'built_in_confirm'); createActionButton('Built-in Prompt Dialog', function () { - typeof prompt === 'function' && prompt('This is a prompt', 'Default value'); + if (typeof prompt === 'function') { + prompt('This is a prompt', 'Default value'); + } }, 'built_in_prompt'); }; diff --git a/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js b/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js index 401049e..da2e75d 100644 --- a/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js +++ b/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js @@ -21,20 +21,24 @@ module.exports = function (quantity) { var count = 0, - beepObj, - play = function () { - //create new object every time due to strage playback behaviour - beepObj = new Audio('local:///chrome/plugin/cordova-plugin-dialogs/notification-beep.wav'); - beepObj.addEventListener("ended", callback); - beepObj.play(); - }, - callback = function () { - if (--count > 0) { - play(); - } else { - delete beepObj; - } - }; + beepObj; + + function callback() { + if (--count > 0) { + play(); + } else { + beepObj.removeEventListener("ended", callback); + beepObj = null; + } + } + + function play() { + //create new object every time due to strage playback behaviour + beepObj = new Audio('local:///chrome/plugin/cordova-plugin-dialogs/notification-beep.wav'); + beepObj.addEventListener("ended", callback); + beepObj.play(); + } + count += quantity || 1; if (count > 0) { play(); diff --git a/plugins/cordova-plugin-dialogs/www/browser/notification.js b/plugins/cordova-plugin-dialogs/www/browser/notification.js index e875309..1fdfafd 100644 --- a/plugins/cordova-plugin-dialogs/www/browser/notification.js +++ b/plugins/cordova-plugin-dialogs/www/browser/notification.js @@ -65,6 +65,21 @@ module.exports.prompt = window.navigator.notification.prompt = function(message, }; +var audioContext = (function() { + // Determine if the Audio API is supported by this browser + var AudioApi = window.AudioContext; + if (!AudioApi) { + AudioApi = window.webkitAudioContext; + } + + if (AudioApi) { + // The Audio API is supported, so create a singleton instance of the AudioContext + return new AudioApi(); + } + + return undefined; +}()); + module.exports.beep = window.navigator.notification.beep = function(times) { if (times > 0) { var BEEP_DURATION = 700; @@ -98,18 +113,3 @@ module.exports.beep = window.navigator.notification.beep = function(times) { } } }; - -var audioContext = (function() { - // Determine if the Audio API is supported by this browser - var AudioApi = window.AudioContext; - if (!AudioApi) { - AudioApi = window.webkitAudioContext; - } - - if (AudioApi) { - // The Audio API is supported, so create a singleton instance of the AudioContext - return new AudioApi(); - } - - return undefined; -}()); diff --git a/plugins/cordova-plugin-file-transfer/NOTICE b/plugins/cordova-plugin-file-transfer/NOTICE deleted file mode 100644 index 46fed23..0000000 --- a/plugins/cordova-plugin-file-transfer/NOTICE +++ /dev/null @@ -1,8 +0,0 @@ -Apache Cordova -Copyright 2012 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - -This product includes a copy of OkHttp from: -https://github.com/square/okhttp diff --git a/plugins/cordova-plugin-file-transfer/README.md b/plugins/cordova-plugin-file-transfer/README.md deleted file mode 100644 index 9b10c60..0000000 --- a/plugins/cordova-plugin-file-transfer/README.md +++ /dev/null @@ -1,314 +0,0 @@ - - -# cordova-plugin-file-transfer - -This plugin allows you to upload and download files. - -This plugin defines global `FileTransfer`, `FileUploadOptions` Constructors. - -Although in the global scope, they are not available until after the `deviceready` event. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20File%20Transfer%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) - -## Installation - - cordova plugin add cordova-plugin-file-transfer - -## Supported Platforms - -- Amazon Fire OS -- Android -- BlackBerry 10 -- Browser -- Firefox OS** -- iOS -- Windows Phone 7 and 8* -- Windows 8 -- Windows - -\* _Do not support `onprogress` nor `abort()`_ - -\** _Do not support `onprogress`_ - -# FileTransfer - -The `FileTransfer` object provides a way to upload files using an HTTP -multi-part POST or PUT request, and to download files as well. - -## Properties - -- __onprogress__: Called with a `ProgressEvent` whenever a new chunk of data is transferred. _(Function)_ - -## Methods - -- __upload__: sends a file to a server. - -- __download__: downloads a file from server. - -- __abort__: Aborts an in-progress transfer. - - -## upload - -__Parameters__: - -- __fileURL__: Filesystem URL representing the file on the device or a [data: URI](https://en.wikipedia.org/wiki/Data_URI_scheme). For backwards compatibility, this can also be the full path of the file on the device. (See [Backwards Compatibility Notes](#backwards-compatibility-notes) below) - -- __server__: URL of the server to receive the file, as encoded by `encodeURI()`. - -- __successCallback__: A callback that is passed a `FileUploadResult` object. _(Function)_ - -- __errorCallback__: A callback that executes if an error occurs retrieving the `FileUploadResult`. Invoked with a `FileTransferError` object. _(Function)_ - -- __options__: Optional parameters _(Object)_. Valid keys: - - __fileKey__: The name of the form element. Defaults to `file`. (DOMString) - - __fileName__: The file name to use when saving the file on the server. Defaults to `image.jpg`. (DOMString) - - __httpMethod__: The HTTP method to use - either `PUT` or `POST`. Defaults to `POST`. (DOMString) - - __mimeType__: The mime type of the data to upload. Defaults to `image/jpeg`. (DOMString) - - __params__: A set of optional key/value pairs to pass in the HTTP request. (Object, key/value - DOMString) - - __chunkedMode__: Whether to upload the data in chunked streaming mode. Defaults to `true`. (Boolean) - - __headers__: A map of header name/header values. Use an array to specify more than one value. On iOS, FireOS, and Android, if a header named Content-Type is present, multipart form data will NOT be used. (Object) - -- __trustAllHosts__: Optional parameter, defaults to `false`. If set to `true`, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. _(boolean)_ - -### Example - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - -### Example with Upload Headers and Progress Events (Android and iOS only) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - -## FileUploadResult - -A `FileUploadResult` object is passed to the success callback of the -`FileTransfer` object's `upload()` method. - -### Properties - -- __bytesSent__: The number of bytes sent to the server as part of the upload. (long) - -- __responseCode__: The HTTP response code returned by the server. (long) - -- __response__: The HTTP response returned by the server. (DOMString) - -- __headers__: The HTTP response headers by the server. (Object) - - Currently supported on iOS only. - -### iOS Quirks - -- Does not support `responseCode` or `bytesSent`. - -### Browser Quirks - -- __withCredentials__: _boolean_ that tells the browser to set the withCredentials flag on the XMLHttpRequest - -## download - -__Parameters__: - -- __source__: URL of the server to download the file, as encoded by `encodeURI()`. - -- __target__: Filesystem url representing the file on the device. For backwards compatibility, this can also be the full path of the file on the device. (See [Backwards Compatibility Notes] below) - -- __successCallback__: A callback that is passed a `FileEntry` object. _(Function)_ - -- __errorCallback__: A callback that executes if an error occurs when retrieving the `FileEntry`. Invoked with a `FileTransferError` object. _(Function)_ - -- __trustAllHosts__: Optional parameter, defaults to `false`. If set to `true`, it accepts all security certificates. This is useful because Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. _(boolean)_ - -- __options__: Optional parameters, currently only supports headers (such as Authorization (Basic Authentication), etc). - -### Example - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - -### WP8 Quirks - -- Download requests is being cached by native implementation. To avoid caching, pass `if-Modified-Since` header to download method. - -### Browser Quirks - -- __withCredentials__: _boolean_ that tells the browser to set the withCredentials flag on the XMLHttpRequest - -## abort - -Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object which has an error code of FileTransferError.ABORT_ERR. - -### Example - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -A `FileTransferError` object is passed to an error callback when an error occurs. - -### Properties - -- __code__: One of the predefined error codes listed below. (Number) - -- __source__: URL to the source. (String) - -- __target__: URL to the target. (String) - -- __http_status__: HTTP status code. This attribute is only available when a response code is received from the HTTP connection. (Number) - -- __body__ Response body. This attribute is only available when a response is received from the HTTP connection. (String) - -- __exception__: Either e.getMessage or e.toString (String) - -### Constants - -- 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -- 2 = `FileTransferError.INVALID_URL_ERR` -- 3 = `FileTransferError.CONNECTION_ERR` -- 4 = `FileTransferError.ABORT_ERR` -- 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Windows Quirks - -- The plugin implementation is based on [BackgroundDownloader](https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.backgroundtransfer.backgrounddownloader.aspx)/[BackgroundUploader](https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.backgroundtransfer.backgrounduploader.aspx), which entails the latency issues on Windows devices (creation/starting of an operation can take up to a few seconds). You can use XHR or [HttpClient](https://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.httpclient.aspx) as a quicker alternative for small downloads. - -## Backwards Compatibility Notes - -Previous versions of this plugin would only accept device-absolute-file-paths as the source for uploads, or as the target for downloads. These paths would typically be of the form - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - -For backwards compatibility, these paths are still accepted, and if your application has recorded paths like these in persistent storage, then they can continue to be used. - -These paths were previously exposed in the `fullPath` property of `FileEntry` and `DirectoryEntry` objects returned by the File plugin. New versions of the File plugin, however, no longer expose these paths to JavaScript. - -If you are upgrading to a new (1.0.0 or newer) version of File, and you have previously been using `entry.fullPath` as arguments to `download()` or `upload()`, then you will need to change your code to use filesystem URLs instead. - -`FileEntry.toURL()` and `DirectoryEntry.toURL()` return a filesystem URL of the form - - cdvfile://localhost/persistent/path/to/file - -which can be used in place of the absolute file path in both `download()` and `upload()` methods. diff --git a/plugins/cordova-plugin-file-transfer/RELEASENOTES.md b/plugins/cordova-plugin-file-transfer/RELEASENOTES.md deleted file mode 100644 index 86c5d8b..0000000 --- a/plugins/cordova-plugin-file-transfer/RELEASENOTES.md +++ /dev/null @@ -1,259 +0,0 @@ - -# Release Notes - -### 1.5.0 (Jan 15, 2016) -* CB-10208 Fix `file-transfer` multipart form data upload format on **Windows** -* CB-9837 Add data `URI` support to `file-transfer` upload on **iOS** -* CB-9600 `FileUploadOptions` params not posted on **iOS** -* CB-9840 Fallback `file-transfer` `uploadResponse` encoding to `latin1` in case not encoded with `UTF-8` on **iOS** -* CB-9840 Fallback `file-transfer` upload/download response encoding to `latin1` in case not encoded with `UTF-8` on **iOS** -* CB-8641 **Windows Phone 8.1** Some `file-transfer` plugin tests occasionally fail in `mobilespec` -* Adding linting and fixing linter warnings. Reducing timeouts to 7 seconds. -* CB-10100 updated file dependency to not grab new majors -* CB-7006 Empty file is created on file transfer if server response is 304 -* CB-10098 `filetransfer.spec.33` is faulty -* CB-9969 Filetransfer upload error deletes original file -* CB-10088 `filetransfer spec.10` and `spec.11` test is faulty -* CB-9969 Filetransfer upload error deletes original file -* CB-10086 There are two `spec.31` tests for `file-transfer` tests -* CB-10037 Add progress indicator to file-transfer manual tests -* CB-9563 Mulptipart form data is used even a header named `Content-Type` is present -* CB-8863 fix block usage of self - -### 1.4.0 (Nov 18, 2015) -* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest -* [CB-9879](https://issues.apache.org/jira/browse/CB-9879) `getCookie`s can cause unhandled `NullPointerException` -* [CB-6928](https://issues.apache.org/jira/browse/CB-6928) Wrong behaviour transferring cacheable content -* [CB-51](https://issues.apache.org/jira/browse/CB-51) FileTransfer - Support `PUT` Method -* [CB-9906](https://issues.apache.org/jira/browse/CB-9906) cleanup duplicate code, removed 2nd `isWP8` declaration. -* [CB-9950](https://issues.apache.org/jira/browse/CB-9950) Unpend Filetransfer spec.27 on **wp8** as custom headers are now supported -* [CB-9843](https://issues.apache.org/jira/browse/CB-9843) Added **wp8** quirk to test spec 12 -* Fixing contribute link. -* [CB-8431](https://issues.apache.org/jira/browse/CB-8431) File Transfer tests crash on **Android Lolipop** -* [CB-9790](https://issues.apache.org/jira/browse/CB-9790) Align `FileUploadOptions` `fileName` and `mimeType` default parameter values to the docs on **iOS** -* [CB-9385](https://issues.apache.org/jira/browse/CB-9385) Return `FILE_NOT_FOUND_ERR` when receiving `404` code on **iOS** -* [CB-9791](https://issues.apache.org/jira/browse/CB-9791) Decreased download and upload tests timeout - -### 1.3.0 (Sep 18, 2015) -* Found issue where : is accepted as a valid header, this is obviously wrong -* [CB-9562](https://issues.apache.org/jira/browse/CB-9562) Fixed incorrect headers handling on Android -* Fixing headers so they don't accept non-ASCII -* updated tests to use cordova apache vm -* [CB-9493](https://issues.apache.org/jira/browse/CB-9493) Fix file paths in file-transfer manual tests -* [CB-8816](https://issues.apache.org/jira/browse/CB-8816) Add cdvfile:// support on windows -* [CB-9376](https://issues.apache.org/jira/browse/CB-9376) Fix FileTransfer plugin manual tests issue - 'undefined' in paths - -### 1.2.1 (Jul 7, 2015) -* [CB-9275](https://issues.apache.org/jira/browse/CB-9275) [WP8] Fix build failure on WP8 by using reflection to detect presence of JSON.NET based serialization -* Updated code per code review. -* Updated documentation for browser -* Added option to allow for passing cookies automatically in the browser - -### 1.2.0 (Jun 17, 2015) -* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-file-transfer documentation translation: cordova-plugin-file-transfer -* [CB-6503](https://issues.apache.org/jira/browse/CB-6503): Null pointer check for headers in upload (This closes #27) -* [CB-6503](https://issues.apache.org/jira/browse/CB-6503): Allow payload content-types other than multipart/form-data to be used for upload -* Fix NoSuchMethodException looking up cookies. -* fix npm md issue -* [CB-8951](https://issues.apache.org/jira/browse/CB-8951) (wp8) Handle exceptions in download() and upload() again -* [wp8] Relaxed engine version requirement, using reflection to see if methods are available -* Check for the existence of Json.net assembly to determin how we deserialize our headers. -* relax engine requirement to allow -dev versions -* Remove verbose console log messages -* fix bad commit (mine) for cordova-wp8@4.0.0 engine req -* bump required cordova-wp8 version to 4.0.0 -* This closes #80, This closes #12 -* fix failing test resulting from overlapping async calls -* [CB-8721](https://issues.apache.org/jira/browse/CB-8721) Fixes incorrect headers and upload params parsing on wp8 -* Replace all slashes in windows path - -### 1.1.0 (May 06, 2015) -* [CB-8951](https://issues.apache.org/jira/browse/CB-8951) Fixed crash related to headers parsing on **wp8** -* [CB-8933](https://issues.apache.org/jira/browse/CB-8933) Increased download and upload test timeout -* [CB-6313](https://issues.apache.org/jira/browse/CB-6313) **wp8**: Extra boundary in upload -* [CB-8761](https://issues.apache.org/jira/browse/CB-8761) **wp8**: Copy cookies from WebBrowser - -### 1.0.0 (Apr 15, 2015) -* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) bumped version of file dependency -* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump -* [CB-8641](https://issues.apache.org/jira/browse/CB-8641) Fixed tests to pass on windows and wp8 -* [CB-8583](https://issues.apache.org/jira/browse/CB-8583) Forces download to overwrite existing target file -* [CB-8589](https://issues.apache.org/jira/browse/CB-8589) Fixes upload failure when server's response doesn't contain any data -* [CB-8747](https://issues.apache.org/jira/browse/CB-8747) updated dependency, added peer dependency -* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name -* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id -* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme -* [CB-8654](https://issues.apache.org/jira/browse/CB-8654) Note WP8 download requests caching in docs -* [CB-8590](https://issues.apache.org/jira/browse/CB-8590) (Windows) Fixed download.onprogress.lengthComputable -* [CB-8566](https://issues.apache.org/jira/browse/CB-8566) Integrate TravisCI -* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-file-transfer documentation translation: cordova-plugin-file-transfer -* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file -* [CB-8495](https://issues.apache.org/jira/browse/CB-8495) Fixed wp8 and wp81 test failures -* [CB-7957](https://issues.apache.org/jira/browse/CB-7957) Adds support for `browser` platform -* [CB-8429](https://issues.apache.org/jira/browse/CB-8429) Updated version and RELEASENOTES.md for release 0.5.0 (take 2) -* Fixes typo, introduced in https://github.com/apache/cordova-plugin-file-transfer/commit/bc43b46 -* [CB-8407](https://issues.apache.org/jira/browse/CB-8407) Use File proxy to construct valid FileEntry for download success callback -* [CB-8407](https://issues.apache.org/jira/browse/CB-8407) Removes excess path to native path conversion in download method -* [CB-8429](https://issues.apache.org/jira/browse/CB-8429) Updated version and RELEASENOTES.md for release 0.5.0 -* [CB-7957](https://issues.apache.org/jira/browse/CB-7957) Adds support for `browser` platform -* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) Fixes JSHint and formatting issues -* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) Updates tests and documentation -* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) Rewrite upload method to support progress events properly -* android: Fix error reporting for unknown uri type on sourceUri instead of targetUri - -### 0.5.0 (Feb 04, 2015) -* [CB-8407](https://issues.apache.org/jira/browse/CB-8407) windows: Fix download of `ms-appdata:///` URIs -* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) windows: Rewrite upload method to support progress events properly -* [CB-5059](https://issues.apache.org/jira/browse/CB-5059) android: Add a CookieManager abstraction for pluggable webviews -* ios: Fix compile warning about implicity int conversion -* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension -* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use a local copy of DLog macro rather than CordovaLib version -* [CB-8296](https://issues.apache.org/jira/browse/CB-8296) ios: Fix crash when upload fails and file is not yet created (close #57) -* Document "body" property on FileTransferError -* [CB-7912](https://issues.apache.org/jira/browse/CB-7912) ios, android: Update to work with whitelist plugins in Cordova 4.x -* Error callback should always be called with the FileTransferError object, and not just the code -* windows: alias appData to Windows.Storage.ApplicationData.current -* [CB-8093](https://issues.apache.org/jira/browse/CB-8093) Fixes incorrect FileTransferError returned in case of download failure - -### 0.4.8 (Dec 02, 2014) -* [CB-8021](https://issues.apache.org/jira/browse/CB-8021) - adds documentation for `httpMethod` to `doc/index.md`. However, translations still need to be addressed. -* [CB-7223](https://issues.apache.org/jira/browse/CB-7223) spec.27 marked pending for **wp8** -* [CB-6900](https://issues.apache.org/jira/browse/CB-6900) fixed `spec.7` for **wp8** -* [CB-7944](https://issues.apache.org/jira/browse/CB-7944) Pended unsupported auto tests for *Windows* -* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs -* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-file-transfer documentation translation: cordova-plugin-file-transfer - -### 0.4.7 (Oct 03, 2014) -* Construct proper FileEntry with nativeURL property set -* [CB-7532](https://issues.apache.org/jira/browse/CB-7532) Handle non-existent download dirs properly -* [CB-7529](https://issues.apache.org/jira/browse/CB-7529) Adds support for 'ms-appdata' URIs for windows - -### 0.4.6 (Sep 17, 2014) -* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-file-transfer documentation translation -* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-file-transfer documentation translation -* [CB-7423](https://issues.apache.org/jira/browse/CB-7423) fix spec28,29 lastProgressEvent not visible to afterEach function -* Amazon related changes. -* Remove dupe file windows+windows8 both use the same one -* [CB-7316](https://issues.apache.org/jira/browse/CB-7316) Updates docs with actual information. -* [CB-7316](https://issues.apache.org/jira/browse/CB-7316) Adds support for Windows platform, moves \*Proxy files to proper directory. -* [CB-7316](https://issues.apache.org/jira/browse/CB-7316) Improves current specs compatibility: -* added documentation for new test -* [CB-6466](https://issues.apache.org/jira/browse/CB-6466) Fix failing test due to recent url change -* [CB-6466](https://issues.apache.org/jira/browse/CB-6466) created mobile-spec test -* Renamed test dir, added nested plugin.xml and test -* Fixed failing spec.19 on wp8 -* added documentation to manual tests -* [CB-6961](https://issues.apache.org/jira/browse/CB-6961) port file-transfer tests to framework - -### 0.4.5 (Aug 06, 2014) -* Upload parameters out of order -* **FirefoxOS** initial implementation -* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): Expose FileTransferError.exception to application -* [CB-6928](https://issues.apache.org/jira/browse/CB-6928): Add new error code to documentation -* [CB-6928](https://issues.apache.org/jira/browse/CB-6928): Handle 304 status code -* [CB-6928](https://issues.apache.org/jira/browse/CB-6928): Open output stream only if it's necessary. -* [BlackBerry10] Minor doc correction -* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs -* [Windows8] upload uses the provided fileName or the actual fileName -* [CB-2420](https://issues.apache.org/jira/browse/CB-2420) [Windows8] honor fileKey and param options. This closes #15 -* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): Update new docs to match AlexNennker's changes in PR30 -* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): Continue previous commit with one new instance (This closes #30) -* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): add the exception text to the error object -* [CB-6890](https://issues.apache.org/jira/browse/CB-6890): Fix pluginManager access for 4.0.x branch - -### 0.4.4 (Jun 05, 2014) -* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #21 -* ubuntu: support 'cdvfile' URI -* [CB-6802](https://issues.apache.org/jira/browse/CB-6802) Add license -* Upload progress now works also for second file -* [CB-6706](https://issues.apache.org/jira/browse/CB-6706): Relax dependency on file plugin -* [CB-3440](https://issues.apache.org/jira/browse/CB-3440) [BlackBerry10] Update implementation to use modules from file plugin -* [CB-6378](https://issues.apache.org/jira/browse/CB-6378) Use connection.disconnect() instead of stream.close() for thread-safety -* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md -* [CB-6466](https://issues.apache.org/jira/browse/CB-6466) Auto-create directories in download -* [CB-6494](https://issues.apache.org/jira/browse/CB-6494) android: Fix upload of KitKat content URIs -* Upleveled from android port with following commits: 3c1ff16 Andrew Grieve - [CB-5762](https://issues.apache.org/jira/browse/CB-5762) android: Fix lengthComputable set wrong for gzip downloads 8374b3d Colin Mahoney - [CB-5631](https://issues.apache.org/jira/browse/CB-5631) Removed SimpleTrackingInputStream.read(byte[] buffer) 6f91ac3 Bas Bosman - [CB-4907](https://issues.apache.org/jira/browse/CB-4907) Close stream when we're finished with it 651460f Christoph Neumann - [CB-6000](https://issues.apache.org/jira/browse/CB-6000) Nginx rejects Content-Type without a space before "boundary". 35f80e4 Ian Clelland - [CB-6050](https://issues.apache.org/jira/browse/CB-6050): Use instance method on actual file plugin object to get FileEntry to return on download -* [CB-5980](https://issues.apache.org/jira/browse/CB-5980) Updated version and RELEASENOTES.md for release 0.4.1 - -### 0.4.3 (Apr 17, 2014) -* [CB-6422](https://issues.apache.org/jira/browse/CB-6422) [windows8] use cordova/exec/proxy -* iOS: Fix error where files were not removed on abort -* [CB-5175](https://issues.apache.org/jira/browse/CB-5175): [ios] CDVFileTransfer asynchronous download (Fixes #24) -* [ios] Cast id references to NSURL to avoid compiler warnings (Fixes: apache/cordova-plugin-file-transfer#18) -* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit -* [CB-5762](https://issues.apache.org/jira/browse/CB-5762): [FireOS] android: Fix lengthComputable set wrong for gzip downloads -* [CB-5631](https://issues.apache.org/jira/browse/CB-5631): [FireOS] Removed SimpleTrackingInputStream.read(byte[] buffer) -* [CB-4907](https://issues.apache.org/jira/browse/CB-4907): [FireOS] Close stream when we're finished with it -* [CB-6000](https://issues.apache.org/jira/browse/CB-6000): [FireOS] Nginx rejects Content-Type without a space before "boundary". -* [CB-6050](https://issues.apache.org/jira/browse/CB-6050): [FireOS] Use instance method on actual file plugin object to get FileEntry to return on download -* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers - -### 0.4.2 (Feb 28, 2014) -* [CB-6106](https://issues.apache.org/jira/browse/CB-6106) Ensure that nativeURL is used by file transfer download -* iOS: Fix default value for trustAllHosts on iOS (YES->NO) -* [CB-6059](https://issues.apache.org/jira/browse/CB-6059) iOS: Stop FileTransfer.download doing IO on the UI thread. -* [CB-5588](https://issues.apache.org/jira/browse/CB-5588) iOS: Add response headers to upload result -* [CB-2190](https://issues.apache.org/jira/browse/CB-2190) iOS: Make backgroundTaskId apply to downloads as well. Move backgroundTaskId to the delegate. -* [CB-6050](https://issues.apache.org/jira/browse/CB-6050) Android: Use instance method on actual file plugin object to get FileEntry to return on download -* [CB-6000](https://issues.apache.org/jira/browse/CB-6000) Android: Nginx rejects Content-Type without a space before "boundary". -* [CB-4907](https://issues.apache.org/jira/browse/CB-4907) Android: Close stream when we're finished with it -* [CB-6022](https://issues.apache.org/jira/browse/CB-6022) Add backwards-compatibility notes to doc - -### 0.4.1 (Feb 05, 2014) -* [CB-5365](https://issues.apache.org/jira/browse/CB-5365) Remove unused exception var to prevent warnings? -* [CB-2421](https://issues.apache.org/jira/browse/CB-2421) explicitly write the bytesSent,responseCode,result to the FileUploadResult pending release of cordova-plugin-file dependency, added some sanity checks for callbacks -* iOS: Update for new file plugin api -* [CB-5631](https://issues.apache.org/jira/browse/CB-5631) Removed SimpleTrackingInputStream.read(byte[] buffer) -* [CB-5762](https://issues.apache.org/jira/browse/CB-5762) android: Fix lengthComputable set wrong for gzip downloads -* [CB-4899](https://issues.apache.org/jira/browse/CB-4899) [BlackBerry10] Improve binary file transfer download -* Delete stale test/ directory -* [CB-5722](https://issues.apache.org/jira/browse/CB-5722) [BlackBerry10] Update upload function to use native file object -* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Delete stale snapshot of plugin docs -* Remove @1 designation from file plugin dependency until pushed to npm -* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Update to work with filesystem URLs - -### 0.4.0 (Dec 4, 2013) -* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Partial revert; we're not ready yet for FS urls -* add ubuntu platform -* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Minor version bump -* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Update FileTransfer plugin to accept filesystem urls -* Added amazon-fireos platform. Change to use amazon-fireos as the platform if the user agen string contains 'cordova-amazon-fireos' - -### 0.3.4 (Oct 28, 2013) -* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for file transfer plugin -* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch. - -### 0.3.3 (Oct 9, 2013) -* removed un-needed undef check -* Fix missing headers in Windows 8 upload proxy -* Fix missing headers in Windows 8 Proxy -* Fix Windows 8 HTMLAnchorElement return host:80 which force Basic Auth Header to replace options Auth Header -* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. - -### 0.3.2 (Sept 25, 2013) -* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version -* [windows8] commandProxy was moved -* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) updating core references -* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.file-transfer to org.apache.cordova.file-transfer and updating dependency -* Rename CHANGELOG.md -> RELEASENOTES.md diff --git a/plugins/cordova-plugin-file-transfer/doc/de/README.md b/plugins/cordova-plugin-file-transfer/doc/de/README.md deleted file mode 100644 index 03191cb..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/de/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -Plugin-Dokumentation: - -Dieses Plugin ermöglicht Ihnen zum Hochladen und Herunterladen von Dateien. - -Dieses Plugin wird global `FileTransfer`, `FileUploadOptions` Konstruktoren definiert. - -Obwohl im globalen Gültigkeitsbereich, sind sie nicht bis nach dem `deviceready`-Ereignis. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## Installation - - cordova plugin add cordova-plugin-file-transfer - - -## Unterstützte Plattformen - - * Amazon Fire OS - * Android - * BlackBerry 10 - * Browser - * Firefox OS ** - * iOS - * Windows Phone 7 und 8 * - * Windows 8 - * Windows - -\ * *Unterstützen keine `Onprogress` noch `abort()` * - -\ ** * `Onprogress` nicht unterstützt* - -# FileTransfer - -Das `FileTransfer` -Objekt stellt eine Möglichkeit zum Hochladen von Dateien, die mithilfe einer HTTP-mehrteiligen POST oder PUT-Anforderung, und auch Dateien herunterladen. - -## Eigenschaften - - * **OnProgress**: aufgerufen, wobei ein `ProgressEvent` wann wird eine neue Datenmenge übertragen. *(Funktion)* - -## Methoden - - * **Upload**: sendet eine Datei an einen Server. - - * **Download**: lädt eine Datei vom Server. - - * **abort**: Abbruch eine Übertragung in Bearbeitung. - -## Upload - -**Parameter**: - - * **FileURL**: Dateisystem-URL, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten) - - * **Server**: URL des Servers, die Datei zu empfangen, wie kodiert`encodeURI()`. - - * **successCallback**: ein Rückruf, der ein `FileUploadResult`-Objekt übergeben wird. *(Funktion)* - - * **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileUploadResult`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)* - - * **Optionen**: optionale Parameter *(Objekt)*. Gültige Schlüssel: - - * **FileKey**: der Name des Form-Elements. Wird standardmäßig auf `file` . (DOM-String und enthält) - * **Dateiname**: der Dateiname beim Speichern der Datei auf dem Server verwendet. Wird standardmäßig auf `image.jpg` . (DOM-String und enthält) - * **httpMethod**: die HTTP-Methode, die-entweder `PUT` oder `POST`. Der Standardwert ist `POST`. (DOM-String und enthält) - * **mimeType**: den Mime-Typ der Daten hochzuladen. Standardwerte auf `Image/Jpeg`. (DOM-String und enthält) - * **params**: eine Reihe von optionalen Schlüssel/Wert-Paaren in der HTTP-Anforderung übergeben. (Objekt) - * **chunkedMode**: ob die Daten in "Chunked" streaming-Modus hochladen. Der Standardwert ist `true`. (Boolean) - * **headers**: eine Karte von Header-Name-Header-Werte. Verwenden Sie ein Array, um mehr als einen Wert anzugeben. Auf iOS, FireOS und Android wenn ein Content-Type-Header vorhanden ist, werden mehrteilige Formulardaten nicht verwendet werden. (Object) - * **httpMethod**: die HTTP-Methode zu verwenden, z.B. POST oder PUT. Der Standardwert ist `POST`. (DOM-String enthält) - - * **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)* - -### Beispiel - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Beispiel mit hochladen Kopf- und Progress-Ereignisse (Android und iOS nur) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -Ein `FileUploadResult`-Objekt wird an den Erfolg-Rückruf des `Objekts FileTransfer`-Upload()-Methode übergeben. - -### Eigenschaften - - * **BytesSent**: die Anzahl der Bytes, die als Teil des Uploads an den Server gesendet. (lange) - - * **ResponseCode**: die HTTP-Response-Code vom Server zurückgegeben. (lange) - - * **response**: der HTTP-Antwort vom Server zurückgegeben. (DOM-String und enthält) - - * **Header**: die HTTP-Response-Header vom Server. (Objekt) - - * Derzeit unterstützt auf iOS nur. - -### iOS Macken - - * Unterstützt keine `responseCode` oder`bytesSent`. - -## Download - -**Parameter**: - - * **source**: URL des Servers, um die Datei herunterzuladen, wie kodiert`encodeURI()`. - - * **target**: Dateisystem-Url, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten) - - * **SuccessCallback**: ein Rückruf, der übergeben wird ein `FileEntry` Objekt. *(Funktion)* - - * **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileEntry`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)* - - * **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)* - - * **Options**: optionale Parameter, derzeit nur unterstützt Kopfzeilen (z. B. Autorisierung (Standardauthentifizierung), etc.). - -### Beispiel - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -### WP8 Macken - - * Downloaden anfordert, wird von native Implementierung zwischengespeichert wird. Um zu vermeiden, Zwischenspeicherung, übergeben `If-Modified-Since` Header Methode herunterladen. - -## abort - -Bricht einen in-Progress-Transfer. Der Onerror-Rückruf wird ein FileTransferError-Objekt übergeben, die einen Fehlercode FileTransferError.ABORT_ERR hat. - -### Beispiel - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -Ein `FileTransferError`-Objekt wird an eine Fehler-Callback übergeben, wenn ein Fehler auftritt. - -### Eigenschaften - - * **Code**: einer der vordefinierten Fehlercodes aufgeführt. (Anzahl) - - * **Quelle**: URL der Quelle. (String) - - * **Ziel**: URL zum Ziel. (String) - - * **HTTP_STATUS**: HTTP-Statuscode. Dieses Attribut ist nur verfügbar, wenn ein Response-Code aus der HTTP-Verbindung eingeht. (Anzahl) - - * **body** Antworttext. Dieses Attribut ist nur verfügbar, wenn eine Antwort von der HTTP-Verbindung eingeht. (String) - - * **exception**: entweder e.getMessage oder e.toString (String) - -### Konstanten - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Hinweise rückwärts Kompatibilität - -Frühere Versionen des Plugins würde nur Gerät-Absolute-Dateipfade als Quelle für Uploads oder als Ziel für Downloads übernehmen. Diese Pfade wäre in der Regel der form - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Für rückwärts Kompatibilität, diese Pfade noch akzeptiert werden, und wenn Ihre Anwendung Pfade wie diese im permanenten Speicher aufgezeichnet hat, dann sie können weiter verwendet werden. - -Diese Pfade waren zuvor in der Eigenschaft `fullPath` `FileEntry` und `DirectoryEntry`-Objekte, die durch das Plugin Datei zurückgegeben ausgesetzt. Neue Versionen der die Datei-Erweiterung, jedoch nicht länger werden diese Pfade zu JavaScript. - -Wenn Sie ein auf eine neue Upgrade (1.0.0 oder neuere) Version der Datei, und Sie haben zuvor mit `entry.fullPath` als Argumente `download()` oder `upload()`, dann ändern Sie den Code, um die Dateisystem-URLs verwenden müssen. - -`FileEntry.toURL()` und `DirectoryEntry.toURL()` zurück, eine Dateisystem-URL in der form - - cdvfile://localhost/persistent/path/to/file - - -die anstelle der absoluten Dateipfad in `download()` und `upload()` Methode verwendet werden kann. \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/de/index.md b/plugins/cordova-plugin-file-transfer/doc/de/index.md deleted file mode 100644 index 4081503..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/de/index.md +++ /dev/null @@ -1,302 +0,0 @@ - - -# cordova-plugin-file-transfer - -Dieses Plugin ermöglicht Ihnen zum Hochladen und Herunterladen von Dateien. - -Dieses Plugin wird global `FileTransfer`, `FileUploadOptions` Konstruktoren definiert. - -Obwohl im globalen Gültigkeitsbereich, sind sie nicht bis nach dem `deviceready`-Ereignis. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## Installation - - cordova plugin add cordova-plugin-file-transfer - - -## Unterstützte Plattformen - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Browser -* Firefox OS ** -* iOS -* Windows Phone 7 und 8 * -* Windows 8 -* Windows - -* *Unterstützen keine `onprogress` noch `abort()`* - -* * *`onprogress` nicht unterstützt* - -# FileTransfer - -Das `FileTransfer`-Objekt bietet eine Möglichkeit zum Hochladen von Dateien, die mithilfe einer HTTP-Anforderung für mehrteiligen POST sowie Informationen zum Herunterladen von Dateien sowie. - -## Eigenschaften - -* **OnProgress**: aufgerufen, wobei ein `ProgressEvent` wann wird eine neue Datenmenge übertragen. *(Funktion)* - -## Methoden - -* **Upload**: sendet eine Datei an einen Server. - -* **Download**: lädt eine Datei vom Server. - -* **abort**: Abbruch eine Übertragung in Bearbeitung. - -## Upload - -**Parameter**: - -* **FileURL**: Dateisystem-URL, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten) - -* **Server**: URL des Servers, die Datei zu empfangen, wie kodiert`encodeURI()`. - -* **successCallback**: ein Rückruf, der ein `FileUploadResult`-Objekt übergeben wird. *(Funktion)* - -* **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileUploadResult`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)* - -* **Optionen**: optionale Parameter *(Objekt)*. Gültige Schlüssel: - - * **FileKey**: der Name des Form-Elements. Wird standardmäßig auf `file` . (DOM-String und enthält) - * **Dateiname**: der Dateiname beim Speichern der Datei auf dem Server verwendet. Wird standardmäßig auf `image.jpg` . (DOM-String und enthält) - * **httpMethod**: die HTTP-Methode, die-entweder `PUT` oder `POST`. Der Standardwert ist `POST`. (DOM-String und enthält) - * **mimeType**: den Mime-Typ der Daten hochzuladen. Standardwerte auf `Image/Jpeg`. (DOM-String und enthält) - * **params**: eine Reihe von optionalen Schlüssel/Wert-Paaren in der HTTP-Anforderung übergeben. (Objekt) - * **chunkedMode**: ob die Daten in "Chunked" streaming-Modus hochladen. Der Standardwert ist `true`. (Boolean) - * **headers**: eine Karte von Header-Name-Header-Werte. Verwenden Sie ein Array, um mehr als einen Wert anzugeben. (Objekt) - -* **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)* - -### Beispiel - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Beispiel mit hochladen Kopf- und Progress-Ereignisse (Android und iOS nur) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -Ein `FileUploadResult`-Objekt wird an den Erfolg-Rückruf des `Objekts FileTransfer`-Upload()-Methode übergeben. - -### Eigenschaften - -* **BytesSent**: die Anzahl der Bytes, die als Teil des Uploads an den Server gesendet. (lange) - -* **ResponseCode**: die HTTP-Response-Code vom Server zurückgegeben. (lange) - -* **response**: der HTTP-Antwort vom Server zurückgegeben. (DOM-String und enthält) - -* **Header**: die HTTP-Response-Header vom Server. (Objekt) - - * Derzeit unterstützt auf iOS nur. - -### iOS Macken - -* Unterstützt keine `responseCode` oder`bytesSent`. - -## Download - -**Parameter**: - -* **source**: URL des Servers, um die Datei herunterzuladen, wie kodiert`encodeURI()`. - -* **target**: Dateisystem-Url, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten) - -* **SuccessCallback**: ein Rückruf, der übergeben wird ein `FileEntry` Objekt. *(Funktion)* - -* **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileEntry`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)* - -* **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)* - -* **Options**: optionale Parameter, derzeit nur unterstützt Kopfzeilen (z. B. Autorisierung (Standardauthentifizierung), etc.). - -### Beispiel - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -## abort - -Bricht einen in-Progress-Transfer. Der Onerror-Rückruf wird ein FileTransferError-Objekt übergeben, die einen Fehlercode FileTransferError.ABORT_ERR hat. - -### Beispiel - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -Ein `FileTransferError`-Objekt wird an eine Fehler-Callback übergeben, wenn ein Fehler auftritt. - -### Eigenschaften - -* **Code**: einer der vordefinierten Fehlercodes aufgeführt. (Anzahl) - -* **Quelle**: URL der Quelle. (String) - -* **Ziel**: URL zum Ziel. (String) - -* **HTTP_STATUS**: HTTP-Statuscode. Dieses Attribut ist nur verfügbar, wenn ein Response-Code aus der HTTP-Verbindung eingeht. (Anzahl) - -* **body** Antworttext. Dieses Attribut ist nur verfügbar, wenn eine Antwort von der HTTP-Verbindung eingeht. (String) - -* **exception**: entweder e.getMessage oder e.toString (String) - -### Konstanten - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Hinweise rückwärts Kompatibilität - -Frühere Versionen des Plugins würde nur Gerät-Absolute-Dateipfade als Quelle für Uploads oder als Ziel für Downloads übernehmen. Diese Pfade wäre in der Regel der form - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Für rückwärts Kompatibilität, diese Pfade noch akzeptiert werden, und wenn Ihre Anwendung Pfade wie diese im permanenten Speicher aufgezeichnet hat, dann sie können weiter verwendet werden. - -Diese Pfade waren zuvor in der Eigenschaft `fullPath` `FileEntry` und `DirectoryEntry`-Objekte, die durch das Plugin Datei zurückgegeben ausgesetzt. Neue Versionen der die Datei-Erweiterung, jedoch nicht länger werden diese Pfade zu JavaScript. - -Wenn Sie ein auf eine neue Upgrade (1.0.0 oder neuere) Version der Datei, und Sie haben zuvor mit `entry.fullPath` als Argumente `download()` oder `upload()`, dann ändern Sie den Code, um die Dateisystem-URLs verwenden müssen. - -`FileEntry.toURL()` und `DirectoryEntry.toURL()` zurück, eine Dateisystem-URL in der form - - cdvfile://localhost/persistent/path/to/file - - -die anstelle der absoluten Dateipfad in `download()` und `upload()` Methode verwendet werden kann. diff --git a/plugins/cordova-plugin-file-transfer/doc/es/README.md b/plugins/cordova-plugin-file-transfer/doc/es/README.md deleted file mode 100644 index 1c8ee3f..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/es/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -Documentación del plugin: - -Este plugin te permite cargar y descargar archivos. - -Este plugin define global `FileTransfer` , `FileUploadOptions` constructores. - -Aunque en el ámbito global, no están disponibles hasta después de la `deviceready` evento. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## Instalación - - cordova plugin add cordova-plugin-file-transfer - - -## Plataformas soportadas - - * Amazon fire OS - * Android - * BlackBerry 10 - * Explorador - * Firefox OS ** - * iOS - * Windows Phone 7 y 8 * - * Windows 8 - * Windows - -\ * *No soporta `onprogress` ni `abort()` * - -\ ** *No soporta `onprogress` * - -# FileTransfer - -El objeto `FileTransfer` proporciona una manera para subir archivos utilizando una varias parte solicitud HTTP POST o PUT y descargar archivos, así. - -## Propiedades - - * **OnProgress**: llama con un `ProgressEvent` cuando se transfiere un nuevo paquete de datos. *(Función)* - -## Métodos - - * **cargar**: envía un archivo a un servidor. - - * **Descargar**: descarga un archivo del servidor. - - * **abortar**: aborta una transferencia en curso. - -## subir - -**Parámetros**: - - * **fileURL**: URL de Filesystem que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo) - - * **servidor**: dirección URL del servidor para recibir el archivo, como codificada por`encodeURI()`. - - * **successCallback**: una devolución de llamada que se pasa un `FileUploadResult` objeto. *(Función)* - - * **errorCallback**: una devolución de llamada que se ejecuta si se produce un error recuperar la `FileUploadResult` . Invocado con un `FileTransferError` objeto. *(Función)* - - * **Opciones**: parámetros opcionales *(objeto)*. Teclas válidas: - - * **fileKey**: el nombre del elemento de formulario. Por defecto es `file` . (DOMString) - * **nombre de archivo**: el nombre del archivo a utilizar al guardar el archivo en el servidor. Por defecto es `image.jpg` . (DOMString) - * **httpMethod**: método HTTP el utilizar - o `PUT` o `POST` . Por defecto es `POST` . (DOMString) - * **mimeType**: el tipo mime de los datos para cargar. Por defecto es `image/jpeg` . (DOMString) - * **params**: un conjunto de pares clave/valor opcional para pasar en la petición HTTP. (Objeto) - * **chunkedMode**: Si desea cargar los datos en modo de transmisión fragmentado. Por defecto es `true` . (Boolean) - * **headers**: un mapa de nombre de encabezado/valores de encabezado Utilice una matriz para especificar más de un valor. En iOS FireOS y Android, si existe un encabezado llamado Content-Type, datos de un formulario multipart no se utilizará. (Object) - * **httpMethod**: HTTP el método a utilizar por ejemplo POST o poner. Por defecto `el POST`. (DOMString) - - * **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil ya que Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)* - -### Ejemplo - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Ejemplo con cabeceras de subir y eventos de progreso (Android y iOS solamente) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -A `FileUploadResult` objeto se pasa a la devolución del éxito de la `FileTransfer` del objeto `upload()` método. - -### Propiedades - - * **bytesSent**: el número de bytes enviados al servidor como parte de la carga. (largo) - - * **responseCode**: código de respuesta HTTP el devuelto por el servidor. (largo) - - * **respuesta**: respuesta el HTTP devuelto por el servidor. (DOMString) - - * **cabeceras**: cabeceras de respuesta HTTP el por el servidor. (Objeto) - - * Actualmente compatible con iOS solamente. - -### iOS rarezas - - * No es compatible con `responseCode` o`bytesSent`. - -## descargar - -**Parámetros**: - - * **fuente**: dirección URL del servidor para descargar el archivo, como codificada por`encodeURI()`. - - * **objetivo**: Filesystem url que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo) - - * **successCallback**: una devolución de llamada que se pasa un `FileEntry` objeto. *(Función)* - - * **errorCallback**: una devolución de llamada que se ejecuta si se produce un error al recuperar los `FileEntry` . Invocado con un `FileTransferError` objeto. *(Función)* - - * **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil porque Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)* - - * **Opciones**: parámetros opcionales, actualmente sólo soporta cabeceras (como autorización (autenticación básica), etc.). - -### Ejemplo - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -### Rarezas de WP8 - - * Descargar pide se almacena en caché por aplicación nativa. Para evitar el almacenamiento en caché, pasar `if-Modified-Since` encabezado para descargar el método. - -## abortar - -Aborta a una transferencia en curso. El callback onerror se pasa un objeto FileTransferError que tiene un código de error de FileTransferError.ABORT_ERR. - -### Ejemplo - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -A `FileTransferError` objeto se pasa a un callback de error cuando se produce un error. - -### Propiedades - - * **código**: uno de los códigos de error predefinido enumerados a continuación. (Número) - - * **fuente**: URL a la fuente. (String) - - * **objetivo**: URL a la meta. (String) - - * **HTTP_STATUS**: código de estado HTTP. Este atributo sólo está disponible cuando se recibe un código de respuesta de la conexión HTTP. (Número) - - * **cuerpo** Cuerpo de la respuesta. Este atributo sólo está disponible cuando se recibe una respuesta de la conexión HTTP. (String) - - * **excepción**: cualquier e.getMessage o e.toString (String) - -### Constantes - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Al revés notas de compatibilidad - -Versiones anteriores de este plugin sólo aceptaría dispositivo-absoluto-archivo-rutas como la fuente de carga, o como destino para las descargas. Estos caminos normalmente sería de la forma - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Para atrás compatibilidad, estos caminos son aceptados todavía, y si su solicitud ha grabado caminos como éstos en almacenamiento persistente, entonces pueden seguir utilizarse. - -Estos caminos fueron expuestos anteriormente en el `fullPath` propiedad de `FileEntry` y `DirectoryEntry` objetos devueltos por el plugin de archivo. Las nuevas versiones del archivo plugin, sin embargo, ya no exponen estos caminos a JavaScript. - -Si va a actualizar a una nueva (1.0.0 o más reciente) versión del archivo y previamente han estado utilizando `entry.fullPath` como argumentos para `download()` o `upload()` , entonces tendrá que cambiar su código para usar URLs de sistema de archivos en su lugar. - -`FileEntry.toURL()`y `DirectoryEntry.toURL()` devolver un filesystem dirección URL de la forma - - cdvfile://localhost/persistent/path/to/file - - -que puede ser utilizado en lugar de la ruta del archivo absoluta tanto en `download()` y `upload()` los métodos. \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/es/index.md b/plugins/cordova-plugin-file-transfer/doc/es/index.md deleted file mode 100644 index 981c991..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/es/index.md +++ /dev/null @@ -1,262 +0,0 @@ - - -# cordova-plugin-file-transfer - -Este plugin te permite cargar y descargar archivos. - -Este plugin define global `FileTransfer` , `FileUploadOptions` constructores. - -Aunque en el ámbito global, no están disponibles hasta después de la `deviceready` evento. - - document.addEventListener ("deviceready", onDeviceReady, false); - function onDeviceReady() {console.log(FileTransfer)}; - - -## Instalación - - Cordova plugin añade cordova-plugin-file-transferencia - - -## Plataformas soportadas - -* Amazon fire OS -* Android -* BlackBerry 10 -* Explorador -* Firefox OS ** -* iOS -* Windows Phone 7 y 8 * -* Windows 8 -* Windows - -* *No son compatibles con `onprogress` ni `abort()` * - -** *No son compatibles con `onprogress` * - -# FileTransfer - -El `FileTransfer` objeto proporciona una manera de subir archivos mediante una solicitud HTTP de POST varias parte y para descargar archivos. - -## Propiedades - -* **OnProgress**: llama con un `ProgressEvent` cuando se transfiere un nuevo paquete de datos. *(Función)* - -## Métodos - -* **cargar**: envía un archivo a un servidor. - -* **Descargar**: descarga un archivo del servidor. - -* **abortar**: aborta una transferencia en curso. - -## subir - -**Parámetros**: - -* **fileURL**: URL de Filesystem que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo) - -* **servidor**: dirección URL del servidor para recibir el archivo, como codificada por`encodeURI()`. - -* **successCallback**: una devolución de llamada que se pasa un `FileUploadResult` objeto. *(Función)* - -* **errorCallback**: una devolución de llamada que se ejecuta si se produce un error recuperar la `FileUploadResult` . Invocado con un `FileTransferError` objeto. *(Función)* - -* **Opciones**: parámetros opcionales *(objeto)*. Teclas válidas: - - * **fileKey**: el nombre del elemento de formulario. Por defecto es `file` . (DOMString) - * **nombre de archivo**: el nombre del archivo a utilizar al guardar el archivo en el servidor. Por defecto es `image.jpg` . (DOMString) - * **httpMethod**: método HTTP el utilizar - o `PUT` o `POST` . Por defecto es `POST` . (DOMString) - * **mimeType**: el tipo mime de los datos para cargar. Por defecto es `image/jpeg` . (DOMString) - * **params**: un conjunto de pares clave/valor opcional para pasar en la petición HTTP. (Objeto) - * **chunkedMode**: Si desea cargar los datos en modo de transmisión fragmentado. Por defecto es `true` . (Boolean) - * **cabeceras**: un mapa de valores de encabezado nombre/cabecera. Utilice una matriz para especificar más de un valor. (Objeto) - -* **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil ya que Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)* - -### Ejemplo - - // !! Asume fileURL variable contiene una dirección URL válida a un archivo de texto en el dispositivo, / / por ejemplo, ganar var cdvfile://localhost/persistent/path/to/file.txt = function (r) {console.log ("código =" + r.responseCode); - Console.log ("respuesta =" + r.response); - Console.log ("Sent =" + r.bytesSent);} - - var fallar = function (error) {alert ("ha ocurrido un error: código =" + error.code); - Console.log ("error al cargar el origen" + error.source); - Console.log ("upload error objetivo" + error.target);} - - var opciones = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "prueba"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - Ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, opciones); - - -### Ejemplo con cabeceras de subir y eventos de progreso (Android y iOS solamente) - - function win(r) {console.log ("código =" + r.responseCode); - Console.log ("respuesta =" + r.response); - Console.log ("Sent =" + r.bytesSent);} - - function fail(error) {alert ("ha ocurrido un error: código =" + error.code); - Console.log ("error al cargar el origen" + error.source); - Console.log ("upload error objetivo" + error.target);} - - var uri = encodeURI ("http://some.server.com/upload.php"); - - var opciones = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - cabeceras de var ={'headerParam':'headerValue'}; - - options.headers = encabezados; - - var ft = new FileTransfer(); - Ft.OnProgress = function(progressEvent) {si (progressEvent.lengthComputable) {loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } {loadingStatus.increment() más; - } - }; - Ft.upload (fileURL, uri, win, fail, opciones); - - -## FileUploadResult - -A `FileUploadResult` objeto se pasa a la devolución del éxito de la `FileTransfer` del objeto `upload()` método. - -### Propiedades - -* **bytesSent**: el número de bytes enviados al servidor como parte de la carga. (largo) - -* **responseCode**: código de respuesta HTTP el devuelto por el servidor. (largo) - -* **respuesta**: respuesta el HTTP devuelto por el servidor. (DOMString) - -* **cabeceras**: cabeceras de respuesta HTTP el por el servidor. (Objeto) - - * Actualmente compatible con iOS solamente. - -### iOS rarezas - -* No es compatible con `responseCode` o`bytesSent`. - -## descargar - -**Parámetros**: - -* **fuente**: dirección URL del servidor para descargar el archivo, como codificada por`encodeURI()`. - -* **objetivo**: Filesystem url que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo) - -* **successCallback**: una devolución de llamada que se pasa un `FileEntry` objeto. *(Función)* - -* **errorCallback**: una devolución de llamada que se ejecuta si se produce un error al recuperar los `FileEntry` . Invocado con un `FileTransferError` objeto. *(Función)* - -* **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil porque Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)* - -* **Opciones**: parámetros opcionales, actualmente sólo soporta cabeceras (como autorización (autenticación básica), etc.). - -### Ejemplo - - // !! Asume fileURL variable contiene una dirección URL válida a un camino en el dispositivo, / / por ejemplo, File Transfer var cdvfile://localhost/persistent/path/to/downloads/ = new FileTransfer(); - var uri = encodeURI ("http://some.server.com/download.php"); - - fileTransfer.download (uri, fileURL, function(entry) {console.log ("descarga completa:" + entry.toURL()); - }, function(error) {console.log ("error al descargar el origen" + error.source); - Console.log ("descargar error objetivo" + error.target); - Console.log ("código de error de carga" + error.code); - }, falso, {encabezados: {"Autorización": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA =="}}); - - -## abortar - -Aborta a una transferencia en curso. El callback onerror se pasa un objeto FileTransferError que tiene un código de error de FileTransferError.ABORT_ERR. - -### Ejemplo - - // !! Asume fileURL variable contiene una dirección URL válida a un archivo de texto en el dispositivo, / / por ejemplo, ganar cdvfile://localhost/persistent/path/to/file.txt var function(r) = {console.log ("no se debe llamar.");} - - var fallar = function(error) {/ / error.code == FileTransferError.ABORT_ERR alert ("ha ocurrido un error: código =" + error.code); - Console.log ("error al cargar el origen" + error.source); - Console.log ("upload error objetivo" + error.target);} - - var opciones = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - Ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, opciones); - Ft.Abort(); - - -## FileTransferError - -A `FileTransferError` objeto se pasa a un callback de error cuando se produce un error. - -### Propiedades - -* **código**: uno de los códigos de error predefinido enumerados a continuación. (Número) - -* **fuente**: URL a la fuente. (String) - -* **objetivo**: URL a la meta. (String) - -* **HTTP_STATUS**: código de estado HTTP. Este atributo sólo está disponible cuando se recibe un código de respuesta de la conexión HTTP. (Número) - -* **cuerpo** Cuerpo de la respuesta. Este atributo sólo está disponible cuando se recibe una respuesta de la conexión HTTP. (String) - -* **excepción**: cualquier e.getMessage o e.toString (String) - -### Constantes - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Al revés notas de compatibilidad - -Versiones anteriores de este plugin sólo aceptaría dispositivo-absoluto-archivo-rutas como la fuente de carga, o como destino para las descargas. Estos caminos normalmente sería de la forma - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Para atrás compatibilidad, estos caminos son aceptados todavía, y si su solicitud ha grabado caminos como éstos en almacenamiento persistente, entonces pueden seguir utilizarse. - -Estos caminos fueron expuestos anteriormente en el `fullPath` propiedad de `FileEntry` y `DirectoryEntry` objetos devueltos por el plugin de archivo. Las nuevas versiones del archivo plugin, sin embargo, ya no exponen estos caminos a JavaScript. - -Si va a actualizar a una nueva (1.0.0 o más reciente) versión del archivo y previamente han estado utilizando `entry.fullPath` como argumentos para `download()` o `upload()` , entonces tendrá que cambiar su código para usar URLs de sistema de archivos en su lugar. - -`FileEntry.toURL()`y `DirectoryEntry.toURL()` devolver un filesystem dirección URL de la forma - - cdvfile://localhost/persistent/path/to/file - - -que puede ser utilizado en lugar de la ruta del archivo absoluta tanto en `download()` y `upload()` los métodos. diff --git a/plugins/cordova-plugin-file-transfer/doc/fr/README.md b/plugins/cordova-plugin-file-transfer/doc/fr/README.md deleted file mode 100644 index ca3e18a..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/fr/README.md +++ /dev/null @@ -1,270 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -Documentation du plugin : - -Ce plugin vous permet de télécharger des fichiers. - -Ce plugin définit global `FileTransfer` , `FileUploadOptions` constructeurs. - -Bien que dans la portée globale, ils ne sont pas disponibles jusqu'après la `deviceready` événement. - - document.addEventListener (« deviceready », onDeviceReady, false) ; - function onDeviceReady() {console.log(FileTransfer);} - - -## Installation - - cordova plugin add cordova-plugin-file-transfer - - -## Plates-formes supportées - - * Amazon Fire OS - * Android - * BlackBerry 10 - * Navigateur - * Firefox OS ** - * iOS - * Windows Phone 7 et 8 * - * Windows 8 - * Windows - -\ * *Ne supportent pas `onprogress` ni `abort()` * - -\ ** *Ne prennent pas en charge les `onprogress` * - -# Transfert de fichiers - -L'objet de `FileTransfer` fournit un moyen de télécharger des fichiers à l'aide d'une requête HTTP multi-part POST ou PUT et pour télécharger des fichiers. - -## Propriétés - - * **onprogress** : fonction appelée avec un `ProgressEvent` à chaque fois qu'un nouveau segment de données est transféré. *(Function)* - -## Méthodes - - * **upload** : envoie un fichier à un serveur. - - * **download** : télécharge un fichier depuis un serveur. - - * **abort** : annule le transfert en cours. - -## upload - -**Paramètres**: - - * **fileURL** : système de fichiers URL représentant le fichier sur le périphérique. Pour la compatibilité ascendante, cela peut aussi être le chemin complet du fichier sur le périphérique. (Voir [Backwards Compatibility Notes] ci-dessous) - - * **server** : l'URL du serveur destiné à recevoir le fichier, encodée via `encodeURI()`. - - * **successCallback**: un rappel passé un `FileUploadResult` objet. *(Fonction)* - - * **errorCallback**: un rappel qui s'exécute si une erreur survient récupérer la `FileUploadResult` . Appelée avec un `FileTransferError` objet. *(Fonction)* - - * **options**: paramètres facultatifs *(objet)*. Clés valides : - - * **fileKey**: le nom de l'élément form. Valeur par défaut est `file` . (DOMString) - * **fileName**: le nom de fichier à utiliser lorsque vous enregistrez le fichier sur le serveur. Valeur par défaut est `image.jpg` . (DOMString) - * **httpMethod**: méthode de The HTTP à utiliser - soit `PUT` ou `POST` . Valeur par défaut est `POST` . (DOMString) - * **type MIME**: le type mime des données à télécharger. Valeur par défaut est `image/jpeg` . (DOMString) - * **params**: un ensemble de paires clé/valeur facultative pour passer dans la requête HTTP. (Objet) - * **chunkedMode**: s'il faut télécharger les données en mode streaming mémorisé en bloc. Valeur par défaut est `true` . (Boolean) - * **headers**: une carte des valeurs d'en-tête en-tête/nom. Un tableau permet de spécifier plusieurs valeurs. Sur iOS, FireOS et Android, si un en-tête nommé Content-Type n'est présent, les données de formulaire multipart servira pas. (Object) - * **httpMethod**: The HTTP méthode à utiliser par exemple poster ou mis. Par défaut, `message`. (DOMString) - - * **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur est `true` , il accepte tous les certificats de sécurité. Ceci est utile car Android rejette des certificats auto-signés. N'est pas recommandé pour une utilisation en production. Supporté sur Android et iOS. *(booléen)* - -### Exemple - - // !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function (r) {console.log ("Code =" + r.responseCode) ; - Console.log ("réponse =" + r.response) ; - Console.log ("envoyés =" + r.bytesSent);} - - échouer var = function (erreur) {alert ("une erreur est survenue : Code =" + error.code) ; - Console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log ("erreur de téléchargement cible" + error.target);} - - options de var = new FileUploadOptions() ; - options.fileKey = « fichier » ; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1) ; - options.mimeType = « text/plain » ; - - var params = {} ; - params.value1 = « test » ; - params.Value2 = « param » ; - - options.params = params ; - - ft var = new FileTransfer() ; - ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ; - - -### Exemple avec téléchargement du Header et des Progress Events (Android et iOS uniquement) - - function win(r) {console.log ("Code =" + r.responseCode) ; - Console.log ("réponse =" + r.response) ; - Console.log ("envoyés =" + r.bytesSent);} - - function fail(error) {alert ("une erreur est survenue : Code =" + error.code) ; - Console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log ("erreur de téléchargement cible" + error.target);} - - var uri = encodeURI ("http://some.server.com/upload.php") ; - - options de var = new FileUploadOptions() ; - options.fileKey="file" ; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1) ; - options.mimeType="text/plain" ; - - en-têtes var ={'headerParam':'headerValue'} ; - - options.Headers = en-têtes ; - - ft var = new FileTransfer() ; - ft.OnProgress = function(progressEvent) {si (progressEvent.lengthComputable) {loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total) ; - } else {loadingStatus.increment() ; - } - }; - ft.upload (fileURL, uri, win, fail, options) ; - - -## FileUploadResult - -A `FileUploadResult` objet est passé au rappel de succès la `FileTransfer` de l'objet `upload()` méthode. - -### Propriétés - - * **bytesSent** : le nombre d'octets envoyés au serveur dans le cadre du téléchargement. (long) - - * **responseCode** : le code de réponse HTTP retourné par le serveur. (long) - - * **response** : la réponse HTTP renvoyée par le serveur. (DOMString) - - * **en-têtes** : en-têtes de réponse HTTP par le serveur. (Objet) - - * Actuellement pris en charge sur iOS seulement. - -### Notes au sujet d'iOS - - * Ne prend pas en charge les propriétés `responseCode` et `bytesSent`. - -## download - -**Paramètres**: - - * **source** : l'URL du serveur depuis lequel télécharger le fichier, encodée via `encodeURI()`. - - * **target** : système de fichiers url représentant le fichier sur le périphérique. Pour la compatibilité ascendante, cela peut aussi être le chemin complet du fichier sur le périphérique. (Voir [Backwards Compatibility Notes] ci-dessous) - - * **successCallback** : une callback de succès à laquelle est passée un objet `FileEntry`. *(Function)* - - * **errorCallback**: un rappel qui s'exécute si une erreur se produit lors de la récupération du `FileEntry` . Appelée avec un `FileTransferError` objet. *(Fonction)* - - * **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur est `true` , il accepte tous les certificats de sécurité. Ceci peut être utile car Android rejette les certificats auto-signés. N'est pas recommandé pour une utilisation en production. Supporté sur Android et iOS. *(booléen)* - - * **options** : paramètres facultatifs, seules les en-têtes sont actuellement supportées (par exemple l'autorisation (authentification basique), etc.). - -### Exemple - - // !! Suppose fileURL variable contient une URL valide vers un chemin d'accès sur le périphérique, / / par exemple, transfert de fichiers var cdvfile://localhost/persistent/path/to/downloads/ = new FileTransfer() ; - var uri = encodeURI ("http://some.server.com/download.php") ; - - fileTransfer.download (uri, fileURL, function(entry) {console.log ("téléchargement complet:" + entry.toURL()) ; - }, function(error) {console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log (« erreur de téléchargement cible » + error.target) ; - Console.log (« code d'erreur de téléchargement » + error.code) ; - }, faux, {en-têtes: {« Autorisation »: « dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA base == "}}) ; - - -### Quirks wp8 - - * Télécharger demande est mis en cache par l'implémentation native. Pour éviter la mise en cache, pass `if-Modified-Since` en-tête Télécharger méthode. - -## abort - -Abandonne un transfert en cours. Le rappel onerror est passé à un objet FileTransferError qui a un code d'erreur de FileTransferError.ABORT_ERR. - -### Exemple - - // !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function(r) {console.log ("ne devrait pas être appelée.");} - - var fail = function(error) {/ / error.code == FileTransferError.ABORT_ERR alert ("une erreur est survenue : Code =" + error.code) ; - Console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log ("erreur de téléchargement cible" + error.target);} - - options de var = new FileUploadOptions() ; - options.fileKey="file" ; - options.fileName="myphoto.jpg" ; - options.mimeType="image/jpeg" ; - - ft var = new FileTransfer() ; - ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ; - ft.Abort() ; - - -## FileTransferError - -A `FileTransferError` objet est passé à un rappel d'erreur lorsqu'une erreur survient. - -### Propriétés - - * **code** : l'un des codes d'erreur prédéfinis énumérés ci-dessous. (Number) - - * **source** : l'URI de la source. (String) - - * **target**: l'URI de la destination. (String) - - * **http_status** : code d'état HTTP. Cet attribut n'est disponible que lorsqu'un code de réponse est fourni via la connexion HTTP. (Number) - - * **corps** Corps de réponse. Cet attribut n'est disponible que lorsqu'une réponse est reçue de la connexion HTTP. (String) - - * **exception**: soit e.getMessage ou e.toString (String) - -### Constantes - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Backwards Compatibility Notes - -Les versions précédentes de ce plugin n'accepterait périphérique--fichier-chemins d'accès absolus comme source pour les téléchargements, ou comme cible pour les téléchargements. Ces chemins seraient généralement de la forme - - / var/mobile/Applications/< application UUID >/Documents/chemin/vers/fichier (iOS), /storage/emulated/0/path/to/file (Android) - - -Pour vers l'arrière la compatibilité, ces chemins sont toujours acceptés, et si votre application a enregistré des chemins comme celles-ci dans un stockage persistant, alors ils peuvent continuer à être utilisé. - -Ces chemins ont été précédemment exposés dans le `fullPath` propriété de `FileEntry` et `DirectoryEntry` les objets retournés par le fichier plugin. Nouvelles versions du fichier plugin, cependant, ne plus exposent ces chemins à JavaScript. - -Si vous migrez vers une nouvelle (1.0.0 ou plus récent) version de fichier et vous avez précédemment utilisé `entry.fullPath` comme arguments à `download()` ou `upload()` , alors vous aurez besoin de modifier votre code pour utiliser le système de fichiers URL au lieu de cela. - -`FileEntry.toURL()`et `DirectoryEntry.toURL()` retournent une URL de système de fichiers du formulaire - - cdvfile://localhost/persistent/path/to/file - - -qui peut être utilisé à la place le chemin d'accès absolu au fichier dans les deux `download()` et `upload()` méthodes. \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/fr/index.md b/plugins/cordova-plugin-file-transfer/doc/fr/index.md deleted file mode 100644 index 6b2bce0..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/fr/index.md +++ /dev/null @@ -1,261 +0,0 @@ - - -# cordova-plugin-file-transfer - -Ce plugin vous permet de télécharger des fichiers. - -Ce plugin définit global `FileTransfer` , `FileUploadOptions` constructeurs. - -Bien que dans la portée globale, ils ne sont pas disponibles jusqu'après la `deviceready` événement. - - document.addEventListener (« deviceready », onDeviceReady, false) ; - function onDeviceReady() {console.log(FileTransfer);} - - -## Installation - - Cordova plugin ajouter cordova-plugin-file-transfert - - -## Plates-formes prises en charge - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Navigateur -* Firefox OS ** -* iOS -* Windows Phone 7 et 8 * -* Windows 8 -* Windows - -* *Ne supportent pas `onprogress` ni `abort()` * - -** *Ne prennent pas en charge `onprogress` * - -# Transfert de fichiers - -Le `FileTransfer` objet fournit un moyen de télécharger des fichiers à l'aide d'une requête HTTP de la poste plusieurs partie et pour télécharger des fichiers aussi bien. - -## Propriétés - -* **onprogress** : fonction appelée avec un `ProgressEvent` à chaque fois qu'un nouveau segment de données est transféré. *(Function)* - -## Méthodes - -* **upload** : envoie un fichier à un serveur. - -* **download** : télécharge un fichier depuis un serveur. - -* **abort** : annule le transfert en cours. - -## upload - -**Paramètres**: - -* **fileURL** : système de fichiers URL représentant le fichier sur le périphérique. Pour la compatibilité ascendante, cela peut aussi être le chemin complet du fichier sur le périphérique. (Voir [Backwards Compatibility Notes] ci-dessous) - -* **server** : l'URL du serveur destiné à recevoir le fichier, encodée via `encodeURI()`. - -* **successCallback**: un rappel passé un `FileUploadResult` objet. *(Fonction)* - -* **errorCallback**: un rappel qui s'exécute si une erreur survient récupérer la `FileUploadResult` . Appelée avec un `FileTransferError` objet. *(Fonction)* - -* **options**: paramètres facultatifs *(objet)*. Clés valides : - - * **fileKey**: le nom de l'élément form. Valeur par défaut est `file` . (DOMString) - * **fileName**: le nom de fichier à utiliser lorsque vous enregistrez le fichier sur le serveur. Valeur par défaut est `image.jpg` . (DOMString) - * **httpMethod**: méthode de The HTTP à utiliser - soit `PUT` ou `POST` . Valeur par défaut est `POST` . (DOMString) - * **type MIME**: le type mime des données à télécharger. Valeur par défaut est `image/jpeg` . (DOMString) - * **params**: un ensemble de paires clé/valeur facultative pour passer dans la requête HTTP. (Objet) - * **chunkedMode**: s'il faut télécharger les données en mode streaming mémorisé en bloc. Valeur par défaut est `true` . (Boolean) - * **en-têtes**: une carte des valeurs d'en-tête en-tête/nom. Un tableau permet de spécifier plusieurs valeurs. (Objet) - -* **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur `true` , il accepte tous les certificats de sécurité. Ceci est utile car Android rejette des certificats auto-signés. Non recommandé pour une utilisation de production. Supporté sur Android et iOS. *(boolean)* - -### Exemple - - // !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function (r) {console.log ("Code =" + r.responseCode) ; - Console.log ("réponse =" + r.response) ; - Console.log ("envoyés =" + r.bytesSent);} - - échouer var = function (erreur) {alert ("une erreur est survenue : Code =" + error.code) ; - Console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log ("erreur de téléchargement cible" + error.target);} - - options de var = new FileUploadOptions() ; - options.fileKey = « fichier » ; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1) ; - options.mimeType = « text/plain » ; - - var params = {} ; - params.value1 = « test » ; - params.Value2 = « param » ; - - options.params = params ; - - ft var = new FileTransfer() ; - ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ; - - -### Exemple avec téléchargement du Header et des Progress Events (Android et iOS uniquement) - - function win(r) {console.log ("Code =" + r.responseCode) ; - Console.log ("réponse =" + r.response) ; - Console.log ("envoyés =" + r.bytesSent);} - - function fail(error) {alert ("une erreur est survenue : Code =" + error.code) ; - Console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log ("erreur de téléchargement cible" + error.target);} - - var uri = encodeURI ("http://some.server.com/upload.php") ; - - options de var = new FileUploadOptions() ; - options.fileKey="file" ; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1) ; - options.mimeType="text/plain" ; - - en-têtes var ={'headerParam':'headerValue'} ; - - options.Headers = en-têtes ; - - ft var = new FileTransfer() ; - ft.OnProgress = function(progressEvent) {si (progressEvent.lengthComputable) {loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total) ; - } else {loadingStatus.increment() ; - } - }; - ft.upload (fileURL, uri, win, fail, options) ; - - -## FileUploadResult - -A `FileUploadResult` objet est passé au rappel de succès la `FileTransfer` de l'objet `upload()` méthode. - -### Propriétés - -* **bytesSent** : le nombre d'octets envoyés au serveur dans le cadre du téléchargement. (long) - -* **responseCode** : le code de réponse HTTP retourné par le serveur. (long) - -* **response** : la réponse HTTP renvoyée par le serveur. (DOMString) - -* **en-têtes** : en-têtes de réponse HTTP par le serveur. (Objet) - - * Actuellement pris en charge sur iOS seulement. - -### iOS Remarques - -* Ne prend pas en charge les propriétés `responseCode` et `bytesSent`. - -## download - -**Paramètres**: - -* **source** : l'URL du serveur depuis lequel télécharger le fichier, encodée via `encodeURI()`. - -* **target** : système de fichiers url représentant le fichier sur le périphérique. Pour vers l'arrière la compatibilité, cela peut aussi être le chemin d'accès complet du fichier sur le périphérique. (Voir [vers l'arrière compatibilité note] ci-dessous) - -* **successCallback** : une callback de succès à laquelle est passée un objet `FileEntry`. *(Function)* - -* **errorCallback**: un rappel qui s'exécute si une erreur se produit lors de la récupération du `FileEntry` . Appelée avec un `FileTransferError` objet. *(Fonction)* - -* **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur est `true` , il accepte tous les certificats de sécurité. Ceci peut être utile car Android rejette les certificats auto-signés. N'est pas recommandé pour une utilisation en production. Supporté sur Android et iOS. *(booléen)* - -* **options** : paramètres facultatifs, seules les en-têtes sont actuellement supportées (par exemple l'autorisation (authentification basique), etc.). - -### Exemple - - // !! Suppose fileURL variable contient une URL valide vers un chemin d'accès sur le périphérique, / / par exemple, transfert de fichiers var cdvfile://localhost/persistent/path/to/downloads/ = new FileTransfer() ; - var uri = encodeURI ("http://some.server.com/download.php") ; - - fileTransfer.download (uri, fileURL, function(entry) {console.log ("téléchargement complet:" + entry.toURL()) ; - }, function(error) {console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log (« erreur de téléchargement cible » + error.target) ; - Console.log (« code d'erreur de téléchargement » + error.code) ; - }, faux, {en-têtes: {« Autorisation »: « dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA base == "}}) ; - - -## abort - -Abandonne un transfert en cours. Le rappel onerror est passé à un objet FileTransferError qui a un code d'erreur de FileTransferError.ABORT_ERR. - -### Exemple - - // !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function(r) {console.log ("ne devrait pas être appelée.");} - - var fail = function(error) {/ / error.code == FileTransferError.ABORT_ERR alert ("une erreur est survenue : Code =" + error.code) ; - Console.log (« source de l'erreur de téléchargement » + error.source) ; - Console.log ("erreur de téléchargement cible" + error.target);} - - options de var = new FileUploadOptions() ; - options.fileKey="file" ; - options.fileName="myphoto.jpg" ; - options.mimeType="image/jpeg" ; - - ft var = new FileTransfer() ; - ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ; - ft.Abort() ; - - -## FileTransferError - -A `FileTransferError` objet est passé à un rappel d'erreur lorsqu'une erreur survient. - -### Propriétés - -* **code** : l'un des codes d'erreur prédéfinis énumérés ci-dessous. (Number) - -* **source** : l'URI de la source. (String) - -* **target**: l'URI de la destination. (String) - -* **http_status** : code d'état HTTP. Cet attribut n'est disponible que lorsqu'un code de réponse est fourni via la connexion HTTP. (Number) - -* **corps** Corps de réponse. Cet attribut n'est disponible que lorsqu'une réponse est reçue de la connexion HTTP. (String) - -* **exception**: soit e.getMessage ou e.toString (String) - -### Constantes - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Backwards Compatibility Notes - -Les versions précédentes de ce plugin n'accepterait périphérique--fichier-chemins d'accès absolus comme source pour les téléchargements, ou comme cible pour les téléchargements. Ces chemins seraient généralement de la forme - - / var/mobile/Applications/< application UUID >/Documents/chemin/vers/fichier (iOS), /storage/emulated/0/path/to/file (Android) - - -Pour vers l'arrière la compatibilité, ces chemins sont toujours acceptés, et si votre application a enregistré des chemins comme celles-ci dans un stockage persistant, alors ils peuvent continuer à être utilisé. - -Ces chemins ont été précédemment exposés dans le `fullPath` propriété de `FileEntry` et `DirectoryEntry` les objets retournés par le fichier plugin. Nouvelles versions du fichier plugin, cependant, ne plus exposent ces chemins à JavaScript. - -Si vous migrez vers une nouvelle (1.0.0 ou plus récent) version de fichier et vous avez précédemment utilisé `entry.fullPath` comme arguments à `download()` ou `upload()` , alors vous aurez besoin de modifier votre code pour utiliser le système de fichiers URL au lieu de cela. - -`FileEntry.toURL()`et `DirectoryEntry.toURL()` retournent une URL de système de fichiers du formulaire - - cdvfile://localhost/persistent/path/to/file - - -qui peut être utilisé à la place le chemin d'accès absolu au fichier dans les deux `download()` et `upload()` méthodes. diff --git a/plugins/cordova-plugin-file-transfer/doc/it/README.md b/plugins/cordova-plugin-file-transfer/doc/it/README.md deleted file mode 100644 index 74d4ef5..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/it/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -Documentazione plugin: - -Questo plugin permette di caricare e scaricare file. - -Questo plugin definisce globale `FileTransfer`, costruttori di `FileUploadOptions`. - -Anche se in ambito globale, non sono disponibili fino a dopo l'evento `deviceready`. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## Installazione - - cordova plugin add cordova-plugin-file-transfer - - -## Piattaforme supportate - - * Amazon fuoco OS - * Android - * BlackBerry 10 - * Browser - * Firefox OS** - * iOS - * Windows Phone 7 e 8 * - * Windows 8 - * Windows - -\ * *Non supportano `onprogress` né `abort()` * - -\ * * *Non supportano `onprogress` * - -# FileTransfer - -L'oggetto `FileTransfer` fornisce un modo per caricare i file utilizzando una richiesta HTTP multiparte POST o PUT e scaricare file pure. - -## Proprietà - - * **OnProgress**: chiamata con un `ProgressEvent` ogni volta che un nuovo blocco di dati viene trasferito. *(Funzione)* - -## Metodi - - * **caricare**: invia un file a un server. - - * **Scarica**: Scarica un file dal server. - - * **Abort**: interrompe un trasferimento in corso. - -## upload - -**Parametri**: - - * **fileURL**: Filesystem URL che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto) - - * **server**: URL del server per ricevere il file, come codificato dal`encodeURI()`. - - * **successCallback**: un callback che viene passato un oggetto `FileUploadResult`. *(Funzione)* - - * **errorCallback**: un callback che viene eseguito se si verifica un errore di recupero `FileUploadResult`. Richiamato con un oggetto `FileTransferError`. *(Funzione)* - - * **opzioni**: parametri facoltativi *(oggetto)*. Chiavi valide: - - * **fileKey**: il nome dell'elemento form. Valore predefinito è `file` . (DOMString) - * **nome file**: il nome del file da utilizzare quando si salva il file sul server. Valore predefinito è `image.jpg` . (DOMString) - * **httpMethod**: metodo HTTP da utilizzare - `PUT` o `POST`. Impostazioni predefinite per `POST`. (DOMString) - * **mimeType**: il tipo mime dei dati da caricare. Impostazioni predefinite su `image/jpeg`. (DOMString) - * **params**: un insieme di coppie chiave/valore opzionale per passare nella richiesta HTTP. (Object) - * **chunkedMode**: se a caricare i dati in modalità streaming chunked. Impostazione predefinita è `true`. (Boolean) - * **headers**: una mappa di valori di intestazione e nome dell'intestazione. Utilizzare una matrice per specificare più di un valore. Su iOS, FireOS e Android, se è presente, un'intestazione Content-Type il nome dati form multipart non verranno utilizzati. (Object) - * **httpMethod**: metodo HTTP da utilizzare per esempio POST o PUT. Il valore predefinito è `POST`. (DOMString) - - * **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile poiché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)* - -### Esempio - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Esempio con intestazioni di caricare ed eventi Progress (Android e iOS solo) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -Un oggetto `FileUploadResult` viene passato al metodo di callback del metodo `upload()` dell'oggetto `FileTransfer` successo. - -### Proprietà - - * **bytesSent**: il numero di byte inviati al server come parte dell'upload. (lungo) - - * **responseCode**: codice di risposta HTTP restituito dal server. (lungo) - - * **risposta**: risposta HTTP restituito dal server. (DOMString) - - * **intestazioni**: intestazioni di risposta HTTP dal server. (Oggetto) - - * Attualmente supportato solo iOS. - -### iOS stranezze - - * Non supporta `responseCode` o`bytesSent`. - -## Scarica - -**Parametri**: - - * **fonte**: URL del server per scaricare il file, come codificato dal`encodeURI()`. - - * **destinazione**: Filesystem url che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto) - - * **successCallback**: un callback passato un `FileEntry` oggetto. *(Funzione)* - - * **errorCallback**: un callback che viene eseguito se si verifica un errore durante il recupero `FileEntry`. Richiamato con un oggetto `FileTransferError`. *(Function)* - - * **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile perché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)* - - * **opzioni**: parametri facoltativi, attualmente solo supporti intestazioni (ad esempio autorizzazione (autenticazione di base), ecc.). - -### Esempio - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -### WP8 stranezze - - * Il download richiede è nella cache di implementazione nativa. Per evitare la memorizzazione nella cache, passare `if-Modified-Since` intestazione per metodo di download. - -## Abort - -Interrompe un trasferimento in corso. Il callback onerror viene passato un oggetto FileTransferError che presenta un codice di errore di FileTransferError.ABORT_ERR. - -### Esempio - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -Un oggetto `FileTransferError` viene passato a un callback di errore quando si verifica un errore. - -### Proprietà - - * **codice**: uno dei codici di errore predefiniti elencati di seguito. (Numero) - - * **fonte**: URL all'origine. (String) - - * **destinazione**: URL di destinazione. (String) - - * **http_status**: codice di stato HTTP. Questo attributo è disponibile solo quando viene ricevuto un codice di risposta della connessione HTTP. (Numero) - - * **body** Corpo della risposta. Questo attributo è disponibile solo quando viene ricevuta una risposta dalla connessione HTTP. (String) - - * **exception**: O e.getMessage o e.toString (String) - -### Costanti - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Note di compatibilità all'indietro - -Versioni precedenti di questo plugin accetterebbe solo dispositivo-assoluto-percorsi di file come origine per upload, o come destinazione per il download. Questi percorsi si sarebbero generalmente di forma - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Per indietro compatibilità, questi percorsi sono ancora accettati, e se l'applicazione ha registrato percorsi come questi in un archivio permanente, quindi possono continuare a essere utilizzato. - -Questi percorsi sono stati precedentemente esposti nella proprietà `fullPath` di `FileEntry` e oggetti `DirectoryEntry` restituiti dal File plugin. Nuove versioni del File plugin, tuttavia, non è più espongono questi percorsi a JavaScript. - -Se si esegue l'aggiornamento a una nuova (1.0.0 o più recente) versione del File e si hanno precedentemente utilizzato `entry.fullPath` come argomenti per `download()` o `upload()`, quindi sarà necessario cambiare il codice per utilizzare gli URL filesystem invece. - -`FileEntry.toURL()` e `DirectoryEntry.toURL()` restituiscono un filesystem URL del modulo - - cdvfile://localhost/persistent/path/to/file - - -che può essere utilizzato al posto del percorso assoluto nei metodi sia `download()` e `upload()`. \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/it/index.md b/plugins/cordova-plugin-file-transfer/doc/it/index.md deleted file mode 100644 index e1b74e3..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/it/index.md +++ /dev/null @@ -1,302 +0,0 @@ - - -# cordova-plugin-file-transfer - -Questo plugin permette di caricare e scaricare file. - -Questo plugin definisce globale `FileTransfer`, costruttori di `FileUploadOptions`. - -Anche se in ambito globale, non sono disponibili fino a dopo l'evento `deviceready`. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## Installazione - - cordova plugin add cordova-plugin-file-transfer - - -## Piattaforme supportate - -* Amazon fuoco OS -* Android -* BlackBerry 10 -* Browser -* Firefox OS** -* iOS -* Windows Phone 7 e 8 * -* Windows 8 -* Windows - -* *Supporto `onprogress` né `abort()`* - -** *Non supportano `onprogress`* - -# FileTransfer - -L'oggetto `FileTransfer` fornisce un modo per caricare i file utilizzando una richiesta HTTP di POST più parte e scaricare file pure. - -## Proprietà - -* **OnProgress**: chiamata con un `ProgressEvent` ogni volta che un nuovo blocco di dati viene trasferito. *(Funzione)* - -## Metodi - -* **caricare**: invia un file a un server. - -* **Scarica**: Scarica un file dal server. - -* **Abort**: interrompe un trasferimento in corso. - -## caricare - -**Parametri**: - -* **fileURL**: Filesystem URL che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto) - -* **server**: URL del server per ricevere il file, come codificato dal`encodeURI()`. - -* **successCallback**: un callback che viene passato un oggetto `FileUploadResult`. *(Funzione)* - -* **errorCallback**: un callback che viene eseguito se si verifica un errore di recupero `FileUploadResult`. Richiamato con un oggetto `FileTransferError`. *(Funzione)* - -* **opzioni**: parametri facoltativi *(oggetto)*. Chiavi valide: - - * **fileKey**: il nome dell'elemento form. Valore predefinito è `file` . (DOMString) - * **nome file**: il nome del file da utilizzare quando si salva il file sul server. Valore predefinito è `image.jpg` . (DOMString) - * **httpMethod**: metodo HTTP da utilizzare - `PUT` o `POST`. Impostazioni predefinite per `POST`. (DOMString) - * **mimeType**: il tipo mime dei dati da caricare. Impostazioni predefinite su `image/jpeg`. (DOMString) - * **params**: un insieme di coppie chiave/valore opzionale per passare nella richiesta HTTP. (Object) - * **chunkedMode**: se a caricare i dati in modalità streaming chunked. Impostazione predefinita è `true`. (Boolean) - * **headers**: mappa di valori nome/intestazione intestazione. Utilizzare una matrice per specificare più valori. (Object) - -* **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile poiché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)* - -### Esempio - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Esempio con intestazioni di caricare ed eventi Progress (Android e iOS solo) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -Un oggetto `FileUploadResult` viene passato al metodo di callback del metodo `upload()` dell'oggetto `FileTransfer` successo. - -### Proprietà - -* **bytesSent**: il numero di byte inviati al server come parte dell'upload. (lungo) - -* **responseCode**: codice di risposta HTTP restituito dal server. (lungo) - -* **risposta**: risposta HTTP restituito dal server. (DOMString) - -* **intestazioni**: intestazioni di risposta HTTP dal server. (Oggetto) - - * Attualmente supportato solo iOS. - -### iOS stranezze - -* Non supporta `responseCode` o`bytesSent`. - -## Scarica - -**Parametri**: - -* **fonte**: URL del server per scaricare il file, come codificato dal`encodeURI()`. - -* **destinazione**: Filesystem url che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto) - -* **successCallback**: un callback passato un `FileEntry` oggetto. *(Funzione)* - -* **errorCallback**: un callback che viene eseguito se si verifica un errore durante il recupero `FileEntry`. Richiamato con un oggetto `FileTransferError`. *(Function)* - -* **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile perché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)* - -* **opzioni**: parametri facoltativi, attualmente solo supporti intestazioni (ad esempio autorizzazione (autenticazione di base), ecc.). - -### Esempio - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -## Abort - -Interrompe un trasferimento in corso. Il callback onerror viene passato un oggetto FileTransferError che presenta un codice di errore di FileTransferError.ABORT_ERR. - -### Esempio - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -Un oggetto `FileTransferError` viene passato a un callback di errore quando si verifica un errore. - -### Proprietà - -* **codice**: uno dei codici di errore predefiniti elencati di seguito. (Numero) - -* **fonte**: URL all'origine. (String) - -* **destinazione**: URL di destinazione. (String) - -* **http_status**: codice di stato HTTP. Questo attributo è disponibile solo quando viene ricevuto un codice di risposta della connessione HTTP. (Numero) - -* **body** Corpo della risposta. Questo attributo è disponibile solo quando viene ricevuta una risposta dalla connessione HTTP. (String) - -* **exception**: O e.getMessage o e.toString (String) - -### Costanti - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Note di compatibilità all'indietro - -Versioni precedenti di questo plugin accetterebbe solo dispositivo-assoluto-percorsi di file come origine per upload, o come destinazione per il download. Questi percorsi si sarebbero generalmente di forma - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Per indietro compatibilità, questi percorsi sono ancora accettati, e se l'applicazione ha registrato percorsi come questi in un archivio permanente, quindi possono continuare a essere utilizzato. - -Questi percorsi sono stati precedentemente esposti nella proprietà `fullPath` di `FileEntry` e oggetti `DirectoryEntry` restituiti dal File plugin. Nuove versioni del File plugin, tuttavia, non è più espongono questi percorsi a JavaScript. - -Se si esegue l'aggiornamento a una nuova (1.0.0 o più recente) versione del File e si hanno precedentemente utilizzato `entry.fullPath` come argomenti per `download()` o `upload()`, quindi sarà necessario cambiare il codice per utilizzare gli URL filesystem invece. - -`FileEntry.toURL()` e `DirectoryEntry.toURL()` restituiscono un filesystem URL del modulo - - cdvfile://localhost/persistent/path/to/file - - -che può essere utilizzato al posto del percorso assoluto nei metodi sia `download()` e `upload()`. diff --git a/plugins/cordova-plugin-file-transfer/doc/ja/README.md b/plugins/cordova-plugin-file-transfer/doc/ja/README.md deleted file mode 100644 index a8156a2..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/ja/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -プラグインのマニュアル: - -このプラグインは、アップロードし、ファイルをダウンロードすることができます。 - -このプラグインでは、グローバル `FileTransfer`、`FileUploadOptions` コンス トラクターを定義します。 - -グローバル スコープでは使用できませんまで `deviceready` イベントの後です。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## インストール - - cordova plugin add cordova-plugin-file-transfer - - -## サポートされているプラットフォーム - - * アマゾン火 OS - * アンドロイド - * ブラックベリー 10 - * ブラウザー - * Firefox の OS * * - * iOS - * Windows Phone 7 と 8 * - * Windows 8 - * Windows - -\ * * `Onprogress`も`abort()`をサポートしていません。* - -\ * * * `Onprogress`をサポートしていません。* - -# 出色 - -`出色`オブジェクトは、HTTP マルチパート POST または PUT 要求を使用してファイルをアップロードし、同様にファイルをダウンロードする方法を提供します。 - -## プロパティ - - * **onprogress**: と呼ばれる、 `ProgressEvent` データの新しいチャンクが転送されるたびに。*(機能)* - -## メソッド - - * **アップロード**: サーバーにファイルを送信します。 - - * **ダウンロード**: サーバーからファイルをダウンロードします。 - - * **中止**: 進行中の転送を中止します。 - -## upload - -**パラメーター**: - - * **fileURL**: デバイス上のファイルを表すファイルシステム URL。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下) - - * **サーバー**: によって符号化されるように、ファイルを受信するサーバーの URL`encodeURI()`. - - * **successCallback**: `FileUploadResult` オブジェクトが渡されるコールバック。*(機能)* - - * **errorCallback**: エラー `FileUploadResult` を取得するが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)* - - * **オプション**: 省略可能なパラメーター *(オブジェクト)*。有効なキー: - - * **fileKey**: フォーム要素の名前。既定値は `file` です。(,) - * **ファイル名**: ファイル名、サーバー上のファイルを保存するときに使用します。既定値は `image.jpg` です。(,) - * **httpMethod**: - `を置く` または `POST` のいずれかを使用する HTTP メソッド。デフォルト `のポスト` です。(,) - * **mimeType**: アップロードするデータの mime タイプ。`イメージ/jpeg` のデフォルトです。(,) - * **params**: HTTP リクエストに渡すために任意のキー/値ペアのセット。(オブジェクト) - * **chunkedMode**: チャンク ストリーミング モードでデータをアップロードするかどうか。デフォルトは `true` です。(ブール値) - * **headers**: ヘッダー名/ヘッダー値のマップ。 配列を使用して、1 つ以上の値を指定します。 IOS、FireOS、アンドロイドではという名前のコンテンツ タイプ ヘッダーが存在する場合、マルチパート フォーム データは使用されません。 (Object) - * **httpMethod**: 例えばを使用する HTTP メソッドを POST または PUT です。 デフォルト`のポスト`です。(DOMString) - - * **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 これは Android の自己署名入りセキュリティ証明書を拒否するので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)* - -### 例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### サンプルのアップロード ヘッダーと進行状況のイベント (Android と iOS のみ) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -`FileUploadResult` オブジェクトは `FileTransfer` オブジェクト `upload()` メソッドの成功時のコールバックに渡されます。 - -### プロパティ - - * **bytesSent**: アップロードの一部としてサーバーに送信されたバイト数。(ロング) - - * **記述**: サーバーによって返される HTTP 応答コード。(ロング) - - * **応答**: サーバーによって返される HTTP 応答。(,) - - * **ヘッダー**: HTTP 応答ヘッダー サーバーによって。(オブジェクト) - - * 現在 iOS のみでサポートされます。 - -### iOS の癖 - - * サポートしていない `responseCode` または`bytesSent`. - -## download - -**パラメーター**: - - * **ソース**: によって符号化されるように、ファイルをダウンロードするサーバーの URL`encodeURI()`. - - * **ターゲット**: デバイス上のファイルを表すファイルシステム url。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下) - - * **successCallback**: 渡されたコールバックを `FileEntry` オブジェクト。*(機能)* - - * **errorCallback**: `FileEntry` を取得するときにエラーが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)* - - * **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 Android は、自己署名入りセキュリティ証明書を拒否しますので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)* - - * **オプション**: 省略可能なパラメーターは、現在サポートするヘッダーのみ (認証 (基本認証) など)。 - -### 例 - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -### WP8 癖 - - * ダウンロード要求するネイティブ実装によってキャッシュに格納されています。キャッシュされないように、渡す`以来変更された if`ヘッダー メソッドをダウンロードします。 - -## abort - -進行中の転送を中止します。Onerror コールバックが FileTransferError.ABORT_ERR のエラー コードを持っている FileTransferError オブジェクトに渡されます。 - -### 例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -`FileTransferError` オブジェクトは、エラーが発生したときにエラー コールバックに渡されます。 - -### プロパティ - - * **コード**: 次のいずれかの定義済みのエラー コード。(数) - - * **ソース**: ソースの URL。(文字列) - - * **ターゲット**: 先の URL。(文字列) - - * **http_status**: HTTP ステータス コード。この属性は、HTTP 接続から応答コードを受信したときにのみ使用できます。(数) - - * **body**応答本体。この属性は、HTTP 接続から応答を受信したときにのみ使用できます。(文字列) - - * **exception**: どちらか e.getMessage または e.toString (文字列) - -### 定数 - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## 後方互換性をノートします。 - -このプラグインの以前のバージョンまたはダウンロードのターゲットとして、アップロードのソースとしてのみデバイス絶対ファイル パスを受け入れるでしょう。これらのパスの形式は、通常 - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -下位互換性、これらのパスを使用しても、アプリケーションは、永続的なストレージでこのようなパスを記録している場合、し彼らが引き続き使用されます。 - -これらのパスの `FileEntry` やファイル プラグインによって返される `DirectoryEntry` オブジェクトの `fullPath` プロパティで公開されていなかった。 新しいプラグインのバージョン、ファイル、ただし、もはや java スクリプトの設定をこれらのパスを公開します。 - -新しいにアップグレードする場合 (1.0.0 以降) ファイルのバージョン以前を使用している `entry.fullPath` `download()` または `upload()` への引数として、ファイルシステムの Url を代わりに使用するコードを変更する必要があります。 - -`FileEntry.toURL()` と `DirectoryEntry.toURL()` ファイルシステムの URL を返すフォーム - - cdvfile://localhost/persistent/path/to/file - - -`download()`、`upload()` メソッドの絶対ファイル パスの代わりに使用できます。 \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/ja/index.md b/plugins/cordova-plugin-file-transfer/doc/ja/index.md deleted file mode 100644 index f885b3c..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/ja/index.md +++ /dev/null @@ -1,302 +0,0 @@ - - -# cordova-plugin-file-transfer - -このプラグインは、アップロードし、ファイルをダウンロードすることができます。 - -このプラグインでは、グローバル `FileTransfer`、`FileUploadOptions` コンス トラクターを定義します。 - -グローバル スコープでは使用できませんまで `deviceready` イベントの後です。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## インストール - - cordova plugin add cordova-plugin-file-transfer - - -## サポートされているプラットフォーム - -* アマゾン火 OS -* アンドロイド -* ブラックベリー 10 -* ブラウザー -* Firefox の OS * * -* iOS -* Windows Phone 7 と 8 * -* Windows 8 -* Windows - -* *`onprogress` も `abort()` をサポートしていません* - -* * *`onprogress` をサポートしていません* - -# FileTransfer - -`FileTransfer` オブジェクトはマルチパートのポスト、HTTP 要求を使用してファイルをアップロードして同様にファイルをダウンロードする方法を提供します。 - -## プロパティ - -* **onprogress**: と呼ばれる、 `ProgressEvent` データの新しいチャンクが転送されるたびに。*(機能)* - -## メソッド - -* **アップロード**: サーバーにファイルを送信します。 - -* **ダウンロード**: サーバーからファイルをダウンロードします。 - -* **中止**: 進行中の転送を中止します。 - -## upload - -**パラメーター**: - -* **fileURL**: デバイス上のファイルを表すファイルシステム URL。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下) - -* **サーバー**: によって符号化されるように、ファイルを受信するサーバーの URL`encodeURI()`. - -* **successCallback**: `FileUploadResult` オブジェクトが渡されるコールバック。*(機能)* - -* **errorCallback**: エラー `FileUploadResult` を取得するが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)* - -* **オプション**: 省略可能なパラメーター *(オブジェクト)*。有効なキー: - - * **fileKey**: フォーム要素の名前。既定値は `file` です。(,) - * **ファイル名**: ファイル名、サーバー上のファイルを保存するときに使用します。既定値は `image.jpg` です。(,) - * **httpMethod**: - `を置く` または `POST` のいずれかを使用する HTTP メソッド。デフォルト `のポスト` です。(,) - * **mimeType**: アップロードするデータの mime タイプ。`イメージ/jpeg` のデフォルトです。(,) - * **params**: HTTP リクエストに渡すために任意のキー/値ペアのセット。(オブジェクト) - * **chunkedMode**: チャンク ストリーミング モードでデータをアップロードするかどうか。デフォルトは `true` です。(ブール値) - * **headers**: ヘッダーの名前/ヘッダー値のマップ。1 つ以上の値を指定するには、配列を使用します。(オブジェクト) - -* **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 これは Android の自己署名入りセキュリティ証明書を拒否するので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)* - -### 例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### サンプルのアップロード ヘッダーと進行状況のイベント (Android と iOS のみ) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -`FileUploadResult` オブジェクトは `FileTransfer` オブジェクト `upload()` メソッドの成功時のコールバックに渡されます。 - -### プロパティ - -* **bytesSent**: アップロードの一部としてサーバーに送信されたバイト数。(ロング) - -* **記述**: サーバーによって返される HTTP 応答コード。(ロング) - -* **応答**: サーバーによって返される HTTP 応答。(,) - -* **ヘッダー**: HTTP 応答ヘッダー サーバーによって。(オブジェクト) - - * 現在 iOS のみでサポートされます。 - -### iOS の癖 - -* サポートしていない `responseCode` または`bytesSent`. - -## download - -**パラメーター**: - -* **ソース**: によって符号化されるように、ファイルをダウンロードするサーバーの URL`encodeURI()`. - -* **ターゲット**: デバイス上のファイルを表すファイルシステム url。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下) - -* **successCallback**: 渡されたコールバックを `FileEntry` オブジェクト。*(機能)* - -* **errorCallback**: `FileEntry` を取得するときにエラーが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)* - -* **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 Android は、自己署名入りセキュリティ証明書を拒否しますので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)* - -* **オプション**: 省略可能なパラメーターは、現在サポートするヘッダーのみ (認証 (基本認証) など)。 - -### 例 - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -## abort - -進行中の転送を中止します。Onerror コールバックが FileTransferError.ABORT_ERR のエラー コードを持っている FileTransferError オブジェクトに渡されます。 - -### 例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -`FileTransferError` オブジェクトは、エラーが発生したときにエラー コールバックに渡されます。 - -### プロパティ - -* **コード**: 次のいずれかの定義済みのエラー コード。(数) - -* **ソース**: ソースの URL。(文字列) - -* **ターゲット**: 先の URL。(文字列) - -* **http_status**: HTTP ステータス コード。この属性は、HTTP 接続から応答コードを受信したときにのみ使用できます。(数) - -* **body**応答本体。この属性は、HTTP 接続から応答を受信したときにのみ使用できます。(文字列) - -* **exception**: どちらか e.getMessage または e.toString (文字列) - -### 定数 - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## 後方互換性をノートします。 - -このプラグインの以前のバージョンまたはダウンロードのターゲットとして、アップロードのソースとしてのみデバイス絶対ファイル パスを受け入れるでしょう。これらのパスの形式は、通常 - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -下位互換性、これらのパスを使用しても、アプリケーションは、永続的なストレージでこのようなパスを記録している場合、し彼らが引き続き使用されます。 - -これらのパスの `FileEntry` やファイル プラグインによって返される `DirectoryEntry` オブジェクトの `fullPath` プロパティで公開されていなかった。 新しいプラグインのバージョン、ファイル、ただし、もはや java スクリプトの設定をこれらのパスを公開します。 - -新しいにアップグレードする場合 (1.0.0 以降) ファイルのバージョン以前を使用している `entry.fullPath` `download()` または `upload()` への引数として、ファイルシステムの Url を代わりに使用するコードを変更する必要があります。 - -`FileEntry.toURL()` と `DirectoryEntry.toURL()` ファイルシステムの URL を返すフォーム - - cdvfile://localhost/persistent/path/to/file - - -`download()`、`upload()` メソッドの絶対ファイル パスの代わりに使用できます。 diff --git a/plugins/cordova-plugin-file-transfer/doc/ko/README.md b/plugins/cordova-plugin-file-transfer/doc/ko/README.md deleted file mode 100644 index f91e8a2..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/ko/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -플러그인 문서: - -이 플러그인을 사용 하면 업로드 및 다운로드 파일 수 있습니다. - -이 플러그인 글로벌 `FileTransfer`, `FileUploadOptions` 생성자를 정의합니다. - -전역 범위에서 그들은 제공 되지 않습니다 때까지 `deviceready` 이벤트 후. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## 설치 - - cordova plugin add cordova-plugin-file-transfer - - -## 지원 되는 플랫폼 - - * 아마존 화재 운영 체제 - * 안 드 로이드 - * 블랙베리 10 - * 브라우저 - * 파이어 폭스 OS * * - * iOS - * Windows Phone 7과 8 * - * 윈도우 8 - * 윈도우 - -\** `Onprogress` 도 `abort()` 를 지원 하지 않습니다* - -\*** `Onprogress` 를 지원 하지 않습니다* - -# FileTransfer - -`FileTransfer` 개체는 HTTP 다중 파트 POST 또는 PUT 요청을 사용 하 여 파일을 업로드 하 고 또한 파일을 다운로드 하는 방법을 제공 합니다. - -## 속성 - - * **onprogress**:로 불리는 `ProgressEvent` 새로운 양의 데이터를 전송 하는 때마다. *(기능)* - -## 메서드 - - * **업로드**: 파일을 서버에 보냅니다. - - * **다운로드**: 서버에서 파일을 다운로드 합니다. - - * **중단**: 진행 중인 전송 중단. - -## 업로드 - -**매개 변수**: - - * **fileURL**: 장치에 파일을 나타내는 파일 시스템 URL. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래) - - * **서버**: 인코딩 파일 수신 서버의 URL`encodeURI()`. - - * **successCallback**: `FileUploadResult` 개체를 전달 하는 콜백. *(기능)* - - * **errorCallback**: `FileUploadResult` 검색에 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)* - - * **옵션**: 선택적 매개 변수 *(개체)*. 유효한 키: - - * **fileKey**: form 요소의 이름. 기본값은 `file` . (DOMString) - * **파일 이름**: 파일 이름을 서버에 파일을 저장할 때 사용 합니다. 기본값은 `image.jpg` . (DOMString) - * **httpMethod**: `넣어` 또는 `게시물`-사용 하도록 HTTP 메서드. `게시물` 기본값입니다. (DOMString) - * **mimeType**: 업로드 데이터의 mime 형식을. `이미지/jpeg`의 기본값입니다. (DOMString) - * **params**: HTTP 요청에 전달할 선택적 키/값 쌍의 집합. (개체) - * **chunkedMode**: 청크 스트리밍 모드에서 데이터 업로드를 합니다. 기본값은 `true`입니다. (부울) - * **headers**: 헤더 이름 및 헤더 값의 지도. 배열을 사용 하 여 하나 이상의 값을 지정. IOS, FireOS, 안 드 로이드에 있으면 라는 콘텐츠 형식 헤더, 다중 양식 데이터는 사용할 수 없습니다. (Object) - * **httpMethod**: HTTP 메서드 예를 사용 하 여 게시 하거나 넣어. `게시물`기본값입니다. (DOMString) - - * **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 이 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)* - -### 예를 들어 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### 예를 들어 헤더 업로드 및 진행 이벤트 (안 드 로이드와 iOS만) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -`FileUploadResult` 개체 `FileTransfer` 개체의 `원래` 방법의 성공 콜백에 전달 됩니다. - -### 속성 - - * **bytesSent**: 업로드의 일부로 서버에 보낸 바이트 수. (긴) - - * **responseCode**: 서버에서 반환 된 HTTP 응답 코드. (긴) - - * **response**: 서버에서 반환 되는 HTTP 응답. (DOMString) - - * **headers**: 서버에서 HTTP 응답 헤더. (개체) - - * 현재 ios만 지원 합니다. - -### iOS 단점 - - * 지원 하지 않는 `responseCode` 또는`bytesSent`. - -## download - -**매개 변수**: - - * **source**: URL로 인코딩된 파일, 다운로드 서버`encodeURI()`. - - * **target**: 장치에 파일을 나타내는 파일 시스템 url. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래) - - * **successCallback**: 콜백 전달 되는 `FileEntry` 개체. *(기능)* - - * **errorCallback**: `FileEntry`를 검색할 때 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)* - - * **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)* - - * **options**: 선택적 매개 변수를 현재 지 원하는 머리글만 (예: 인증 (기본 인증), 등). - -### 예를 들어 - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -### WP8 특수 - - * 다운로드 요청 기본 구현에 의해 캐시 되 고. 캐싱을 방지 하려면 전달 `if-수정-이후` 헤더를 다운로드 하는 방법. - -## abort - -진행 중인 전송을 중단합니다. onerror 콜백 FileTransferError.ABORT_ERR의 오류 코드는 FileTransferError 개체를 전달 합니다. - -### 예를 들어 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -`FileTransferError` 개체 오류가 발생 하면 오류 콜백에 전달 됩니다. - -### 속성 - - * **code**: 미리 정의 된 오류 코드 중 하나가 아래에 나열 된. (수) - - * **source**: 소스 URL. (문자열) - - * **target**: 대상 URL. (문자열) - - * **http_status**: HTTP 상태 코드. 이 특성은 응답 코드를 HTTP 연결에서 수신에 사용할 수 있습니다. (수) - - * **body** 응답 본문입니다. 이 특성은 HTTP 연결에서 응답을 받을 때에 사용할 수 있습니다. (문자열) - - * **exception**: 어느 e.getMessage 또는 e.toString (문자열) - -### 상수 - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## 이전 버전과 호환성 노트 - -이 플러그인의 이전 버전만 업로드에 대 한 소스 또는 다운로드에 대 한 대상 장치 절대 파일 경로 받아들일 것 이다. 이러한 경로 일반적으로 폼의 것 - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -대 한 뒤 호환성, 이러한 경로 여전히 허용, 그리고 응용 프로그램이 영구 저장소에서 이와 같은 경로 기록 했다, 그때 그들은 계속할 수 있다면 사용할 수. - -이러한 경로 `FileEntry` 및 파일 플러그인에 의해 반환 된 `DirectoryEntry` 개체의 `fullPath` 속성에 노출 되었던. 그러나 파일 플러그인의,, 더 이상 새로운 버전 자바 스크립트이 경로 노출. - -새로 업그레이드 하는 경우 (1.0.0 이상) 버전의 파일, 및 이전 사용 하 고 `entry.fullPath` `download()` 또는 `upload()` 인수로 다음 대신 파일 시스템 Url을 사용 하 여 코드를 변경 해야 합니다. - -폼의 파일 URL을 반환 하는 `FileEntry.toURL()` 및 `DirectoryEntry.toURL()` - - cdvfile://localhost/persistent/path/to/file - - -어떤 `download()` 및 `upload()` 방법에서 절대 파일 경로 대신 사용할 수 있습니다. \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/ko/index.md b/plugins/cordova-plugin-file-transfer/doc/ko/index.md deleted file mode 100644 index a6e39c0..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/ko/index.md +++ /dev/null @@ -1,302 +0,0 @@ - - -# cordova-plugin-file-transfer - -이 플러그인을 사용 하면 업로드 및 다운로드 파일 수 있습니다. - -이 플러그인 글로벌 `FileTransfer`, `FileUploadOptions` 생성자를 정의합니다. - -전역 범위에서 그들은 제공 되지 않습니다 때까지 `deviceready` 이벤트 후. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## 설치 - - cordova plugin add cordova-plugin-file-transfer - - -## 지원 되는 플랫폼 - -* 아마존 화재 운영 체제 -* 안 드 로이드 -* 블랙베리 10 -* 브라우저 -* 파이어 폭스 OS * * -* iOS -* Windows Phone 7과 8 * -* 윈도우 8 -* 윈도우 - -* *`onprogress`도 `abort()`를 지원 하지 않습니다* - -* * *`onprogress`를 지원 하지 않습니다* - -# FileTransfer - -`FileTransfer` 개체는 HTTP 다중 파트 POST 요청을 사용 하 여 파일 업로드 뿐만 아니라 파일을 다운로드 하는 방법을 제공 합니다. - -## 속성 - -* **onprogress**:로 불리는 `ProgressEvent` 새로운 양의 데이터를 전송 하는 때마다. *(기능)* - -## 메서드 - -* **업로드**: 파일을 서버에 보냅니다. - -* **다운로드**: 서버에서 파일을 다운로드 합니다. - -* **중단**: 진행 중인 전송 중단. - -## 업로드 - -**매개 변수**: - -* **fileURL**: 장치에 파일을 나타내는 파일 시스템 URL. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래) - -* **서버**: 인코딩 파일 수신 서버의 URL`encodeURI()`. - -* **successCallback**: `FileUploadResult` 개체를 전달 하는 콜백. *(기능)* - -* **errorCallback**: `FileUploadResult` 검색에 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)* - -* **옵션**: 선택적 매개 변수 *(개체)*. 유효한 키: - - * **fileKey**: form 요소의 이름. 기본값은 `file` . (DOMString) - * **파일 이름**: 파일 이름을 서버에 파일을 저장할 때 사용 합니다. 기본값은 `image.jpg` . (DOMString) - * **httpMethod**: `넣어` 또는 `게시물`-사용 하도록 HTTP 메서드. `게시물` 기본값입니다. (DOMString) - * **mimeType**: 업로드 데이터의 mime 형식을. `이미지/jpeg`의 기본값입니다. (DOMString) - * **params**: HTTP 요청에 전달할 선택적 키/값 쌍의 집합. (개체) - * **chunkedMode**: 청크 스트리밍 모드에서 데이터 업로드를 합니다. 기본값은 `true`입니다. (부울) - * **headers**: 헤더 이름/헤더 값의 지도. 배열을 사용 하 여 하나 이상의 값을 지정 합니다. (개체) - -* **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 이 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)* - -### 예를 들어 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### 예를 들어 헤더 업로드 및 진행 이벤트 (안 드 로이드와 iOS만) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -`FileUploadResult` 개체 `FileTransfer` 개체의 `원래` 방법의 성공 콜백에 전달 됩니다. - -### 속성 - -* **bytesSent**: 업로드의 일부로 서버에 보낸 바이트 수. (긴) - -* **responseCode**: 서버에서 반환 된 HTTP 응답 코드. (긴) - -* **response**: 서버에서 반환 되는 HTTP 응답. (DOMString) - -* **headers**: 서버에서 HTTP 응답 헤더. (개체) - - * 현재 ios만 지원 합니다. - -### iOS 단점 - -* 지원 하지 않는 `responseCode` 또는`bytesSent`. - -## download - -**매개 변수**: - -* **source**: URL로 인코딩된 파일, 다운로드 서버`encodeURI()`. - -* **target**: 장치에 파일을 나타내는 파일 시스템 url. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래) - -* **successCallback**: 콜백 전달 되는 `FileEntry` 개체. *(기능)* - -* **errorCallback**: `FileEntry`를 검색할 때 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)* - -* **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)* - -* **options**: 선택적 매개 변수를 현재 지 원하는 머리글만 (예: 인증 (기본 인증), 등). - -### 예를 들어 - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -## abort - -진행 중인 전송을 중단합니다. onerror 콜백 FileTransferError.ABORT_ERR의 오류 코드는 FileTransferError 개체를 전달 합니다. - -### 예를 들어 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -`FileTransferError` 개체 오류가 발생 하면 오류 콜백에 전달 됩니다. - -### 속성 - -* **code**: 미리 정의 된 오류 코드 중 하나가 아래에 나열 된. (수) - -* **source**: 소스 URL. (문자열) - -* **target**: 대상 URL. (문자열) - -* **http_status**: HTTP 상태 코드. 이 특성은 응답 코드를 HTTP 연결에서 수신에 사용할 수 있습니다. (수) - -* **body** 응답 본문입니다. 이 특성은 HTTP 연결에서 응답을 받을 때에 사용할 수 있습니다. (문자열) - -* **exception**: 어느 e.getMessage 또는 e.toString (문자열) - -### 상수 - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## 이전 버전과 호환성 노트 - -이 플러그인의 이전 버전만 업로드에 대 한 소스 또는 다운로드에 대 한 대상 장치 절대 파일 경로 받아들일 것 이다. 이러한 경로 일반적으로 폼의 것 - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -대 한 뒤 호환성, 이러한 경로 여전히 허용, 그리고 응용 프로그램이 영구 저장소에서 이와 같은 경로 기록 했다, 그때 그들은 계속할 수 있다면 사용할 수. - -이러한 경로 `FileEntry` 및 파일 플러그인에 의해 반환 된 `DirectoryEntry` 개체의 `fullPath` 속성에 노출 되었던. 그러나 파일 플러그인의,, 더 이상 새로운 버전 자바 스크립트이 경로 노출. - -새로 업그레이드 하는 경우 (1.0.0 이상) 버전의 파일, 및 이전 사용 하 고 `entry.fullPath` `download()` 또는 `upload()` 인수로 다음 대신 파일 시스템 Url을 사용 하 여 코드를 변경 해야 합니다. - -폼의 파일 URL을 반환 하는 `FileEntry.toURL()` 및 `DirectoryEntry.toURL()` - - cdvfile://localhost/persistent/path/to/file - - -어떤 `download()` 및 `upload()` 방법에서 절대 파일 경로 대신 사용할 수 있습니다. diff --git a/plugins/cordova-plugin-file-transfer/doc/pl/README.md b/plugins/cordova-plugin-file-transfer/doc/pl/README.md deleted file mode 100644 index c430979..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/pl/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -Plugin dokumentacja: - -Plugin pozwala na przesyłanie i pobieranie plików. - -Ten plugin określa globalne `FileTransfer`, `FileUploadOptions` konstruktorów. - -Chociaż w globalnym zasięgu, są nie dostępne dopiero po `deviceready` imprezie. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## Instalacja - - cordova plugin add cordova-plugin-file-transfer - - -## Obsługiwane platformy - - * Amazon Fire OS - * Android - * BlackBerry 10 - * Przeglądarka - * Firefox OS ** - * iOS - * Windows Phone 7 i 8 * - * Windows 8 - * Windows - -\ * *Nie obsługują `onprogress` ani `abort()` * - -\ ** *Nie obsługują `onprogress` * - -# FileTransfer - -Obiekt `FileTransfer` zapewnia sposób wgrać pliki za pomocą Multi-część POST lub PUT żądania HTTP i pobierania plików, jak również. - -## Właściwości - - * **OnProgress**: o nazwie `ProgressEvent` gdy nowy kawałek danych jest przenoszona. *(Funkcja)* - -## Metody - - * **wgraj**: wysyła plik na serwer. - - * **do pobrania**: pliki do pobrania pliku z serwera. - - * **przerwać**: przerywa w toku transferu. - -## upload - -**Parametry**: - - * **fileURL**: URL plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej) - - * **serwer**: adres URL serwera, aby otrzymać plik, jak kodowane przez`encodeURI()`. - - * **successCallback**: wywołania zwrotnego, który jest przekazywany obiekt `FileUploadResult`. *(Funkcja)* - - * **errorCallback**: wywołanie zwrotne, które wykonuje, jeżeli wystąpi błąd pobierania `FileUploadResult`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)* - - * **Opcje**: parametry opcjonalne *(obiektu)*. Ważne klucze: - - * **fileKey**: nazwa elementu form. Domyślnie `file` . (DOMString) - * **Nazwa pliku**: nazwy pliku, aby użyć podczas zapisywania pliku na serwerze. Domyślnie `image.jpg` . (DOMString) - * **element httpMethod**: Metoda HTTP do użycia - `umieścić` lub `POST`. Domyślnie `POST`. (DOMString) - * **mimeType**: Typ mime danych do przesłania. Domyślnie do `image/jpeg`. (DOMString) - * **params**: zestaw par opcjonalny klucz/wartość w żądaniu HTTP. (Obiekt) - * **chunkedMode**: czy przekazać dane w trybie pakietowego przesyłania strumieniowego. Wartością domyślną jest `true`. (Wartość logiczna) - * **headers**: Mapa wartości Nazwa/nagłówka nagłówek. Aby określić więcej niż jedną wartość, należy użyć tablicę. Na iOS, FireOS i Android jeśli nagłówek o nazwie Content-Type jest obecny, wieloczęściowa forma nie danych. (Object) - * **element httpMethod**: Metoda HTTP np. POST lub PUT. Ustawienia domyślne do `POST`. (DOMString) - - * **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)* - -### Przykład - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Przykład z Prześlij nagłówki i zdarzeń postępu (Android i iOS tylko) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -Obiekt `FileUploadResult` jest przekazywana do sukcesu wywołania zwrotnego metody `upload() służącą` obiektu `FileTransfer`. - -### Właściwości - - * **bytesSent**: liczba bajtów wysłanych do serwera jako część upload. (długie) - - * **responseCode**: kod odpowiedzi HTTP, zwracane przez serwer. (długie) - - * **odpowiedź**: HTTP odpowiedzi zwracane przez serwer. (DOMString) - - * **nagłówki**: nagłówki HTTP odpowiedzi przez serwer. (Obiekt) - - * Obecnie obsługiwane na iOS tylko. - -### Dziwactwa iOS - - * Nie obsługuje `responseCode` lub`bytesSent`. - -## download - -**Parametry**: - - * **Źródło**: adres URL serwera, aby pobrać plik, jak kodowane przez`encodeURI()`. - - * **cel**: url plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej) - - * **successCallback**: wywołania zwrotnego, który jest przekazywany `FileEntry` obiektu. *(Funkcja)* - - * **errorCallback**: wywołanie zwrotne, które wykonuje, jeśli wystąpi błąd podczas pobierania `FileEntry`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)* - - * **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)* - - * **Opcje**: parametry opcjonalne, obecnie tylko obsługuje nagłówki (takie jak autoryzacja (uwierzytelnianie podstawowe), itp.). - -### Przykład - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -### WP8 dziwactwa - - * Pobierz wnioski są buforowane przez rodzimych realizacji. Aby uniknąć, buforowanie, przekazać `if-Modified-Since` nagłówka do pobrania Metoda. - -## abort - -Przerywa w toku transferu. Onerror callback jest przekazywany obiekt FileTransferError, który kod błędu z FileTransferError.ABORT_ERR. - -### Przykład - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -Obiekt `FileTransferError` jest przekazywana do błąd wywołania zwrotnego, gdy wystąpi błąd. - -### Właściwości - - * **Kod**: jeden z kodów błędów wstępnie zdefiniowanych poniżej. (Liczba) - - * **Źródło**: URL do źródła. (String) - - * **cel**: adres URL do docelowego. (String) - - * **HTTP_STATUS**: kod stanu HTTP. Ten atrybut jest dostępna tylko po otrzymaniu kodu odpowiedzi z połączenia HTTP. (Liczba) - - * **body** Treść odpowiedzi. Ten atrybut jest dostępna tylko wtedy, gdy odpowiedź jest otrzymanych od połączenia HTTP. (String) - - * **exception**: albo e.getMessage lub e.toString (String) - -### Stałe - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Do tyłu zgodności stwierdza - -Poprzednie wersje tego pluginu tylko zaakceptować urządzenia bezwzględnych ścieżek jako źródło dla przekazywania, lub w celu pobrania. Te ścieżki będzie zazwyczaj formy - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Do tyłu zgodności, akceptowane są jeszcze te ścieżki, i jeśli aplikacja nagrał ścieżki, jak te w trwałej pamięci, następnie można nadal stosować. - -Te ścieżki były narażone wcześniej we właściwości `fullPath` `FileEntry` i `DirectoryEntry` obiektów zwróconych przez wtyczki pliku. Nowe wersje pliku plugin, jednak już wystawiać te ścieżki do JavaScript. - -Jeśli uaktualniasz nowy (1.0.0 lub nowsza) wersja pliku i mieć wcześniej przy `entry.fullPath` jako argumenty `download()` lub `upload() służącą`, a następnie trzeba będzie zmienić kod aby używać adresów URL plików zamiast. - -`FileEntry.toURL()` i `DirectoryEntry.toURL()` zwraca adres URL plików formularza - - cdvfile://localhost/persistent/path/to/file - - -które mogą być używane zamiast bezwzględna ścieżka zarówno `download()` i `metody upload()` metody. \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/pl/index.md b/plugins/cordova-plugin-file-transfer/doc/pl/index.md deleted file mode 100644 index ff9b557..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/pl/index.md +++ /dev/null @@ -1,302 +0,0 @@ - - -# cordova-plugin-file-transfer - -Plugin pozwala na przesyłanie i pobieranie plików. - -Ten plugin określa globalne `FileTransfer`, `FileUploadOptions` konstruktorów. - -Chociaż w globalnym zasięgu, są nie dostępne dopiero po `deviceready` imprezie. - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## Instalacja - - cordova plugin add cordova-plugin-file-transfer - - -## Obsługiwane platformy - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Przeglądarka -* Firefox OS ** -* iOS -* Windows Phone 7 i 8 * -* Windows 8 -* Windows - -* *Nie obsługują `onprogress` ani `abort()`* - -* * *Nie obsługują `onprogress`* - -# FileTransfer - -Obiekt `FileTransfer` zapewnia sposób wgrać pliki przy użyciu żądania HTTP wieloczęściowe POST i pobierania plików, jak również. - -## Właściwości - -* **OnProgress**: o nazwie `ProgressEvent` gdy nowy kawałek danych jest przenoszona. *(Funkcja)* - -## Metody - -* **wgraj**: wysyła plik na serwer. - -* **do pobrania**: pliki do pobrania pliku z serwera. - -* **przerwać**: przerywa w toku transferu. - -## upload - -**Parametry**: - -* **fileURL**: URL plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej) - -* **serwer**: adres URL serwera, aby otrzymać plik, jak kodowane przez`encodeURI()`. - -* **successCallback**: wywołania zwrotnego, który jest przekazywany obiekt `FileUploadResult`. *(Funkcja)* - -* **errorCallback**: wywołanie zwrotne, które wykonuje, jeżeli wystąpi błąd pobierania `FileUploadResult`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)* - -* **Opcje**: parametry opcjonalne *(obiektu)*. Ważne klucze: - - * **fileKey**: nazwa elementu form. Domyślnie `file` . (DOMString) - * **Nazwa pliku**: nazwy pliku, aby użyć podczas zapisywania pliku na serwerze. Domyślnie `image.jpg` . (DOMString) - * **element httpMethod**: Metoda HTTP do użycia - `umieścić` lub `POST`. Domyślnie `POST`. (DOMString) - * **mimeType**: Typ mime danych do przesłania. Domyślnie do `image/jpeg`. (DOMString) - * **params**: zestaw par opcjonalny klucz/wartość w żądaniu HTTP. (Obiekt) - * **chunkedMode**: czy przekazać dane w trybie pakietowego przesyłania strumieniowego. Wartością domyślną jest `true`. (Wartość logiczna) - * **headers**: Mapa wartości Nazwa/nagłówka nagłówek. Aby określić więcej niż jedną wartość, należy użyć tablicę. (Obiekt) - -* **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)* - -### Przykład - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Przykład z Prześlij nagłówki i zdarzeń postępu (Android i iOS tylko) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -Obiekt `FileUploadResult` jest przekazywana do sukcesu wywołania zwrotnego metody `upload() służącą` obiektu `FileTransfer`. - -### Właściwości - -* **bytesSent**: liczba bajtów wysłanych do serwera jako część upload. (długie) - -* **responseCode**: kod odpowiedzi HTTP, zwracane przez serwer. (długie) - -* **odpowiedź**: HTTP odpowiedzi zwracane przez serwer. (DOMString) - -* **nagłówki**: nagłówki HTTP odpowiedzi przez serwer. (Obiekt) - - * Obecnie obsługiwane na iOS tylko. - -### Dziwactwa iOS - -* Nie obsługuje `responseCode` lub`bytesSent`. - -## download - -**Parametry**: - -* **Źródło**: adres URL serwera, aby pobrać plik, jak kodowane przez`encodeURI()`. - -* **cel**: url plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej) - -* **successCallback**: wywołania zwrotnego, który jest przekazywany `FileEntry` obiektu. *(Funkcja)* - -* **errorCallback**: wywołanie zwrotne, które wykonuje, jeśli wystąpi błąd podczas pobierania `FileEntry`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)* - -* **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)* - -* **Opcje**: parametry opcjonalne, obecnie tylko obsługuje nagłówki (takie jak autoryzacja (uwierzytelnianie podstawowe), itp.). - -### Przykład - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -## abort - -Przerywa w toku transferu. Onerror callback jest przekazywany obiekt FileTransferError, który kod błędu z FileTransferError.ABORT_ERR. - -### Przykład - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -Obiekt `FileTransferError` jest przekazywana do błąd wywołania zwrotnego, gdy wystąpi błąd. - -### Właściwości - -* **Kod**: jeden z kodów błędów wstępnie zdefiniowanych poniżej. (Liczba) - -* **Źródło**: URL do źródła. (String) - -* **cel**: adres URL do docelowego. (String) - -* **HTTP_STATUS**: kod stanu HTTP. Ten atrybut jest dostępna tylko po otrzymaniu kodu odpowiedzi z połączenia HTTP. (Liczba) - -* **body** Treść odpowiedzi. Ten atrybut jest dostępna tylko wtedy, gdy odpowiedź jest otrzymanych od połączenia HTTP. (String) - -* **exception**: albo e.getMessage lub e.toString (String) - -### Stałe - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Do tyłu zgodności stwierdza - -Poprzednie wersje tego pluginu tylko zaakceptować urządzenia bezwzględnych ścieżek jako źródło dla przekazywania, lub w celu pobrania. Te ścieżki będzie zazwyczaj formy - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Do tyłu zgodności, akceptowane są jeszcze te ścieżki, i jeśli aplikacja nagrał ścieżki, jak te w trwałej pamięci, następnie można nadal stosować. - -Te ścieżki były narażone wcześniej we właściwości `fullPath` `FileEntry` i `DirectoryEntry` obiektów zwróconych przez wtyczki pliku. Nowe wersje pliku plugin, jednak już wystawiać te ścieżki do JavaScript. - -Jeśli uaktualniasz nowy (1.0.0 lub nowsza) wersja pliku i mieć wcześniej przy `entry.fullPath` jako argumenty `download()` lub `upload() służącą`, a następnie trzeba będzie zmienić kod aby używać adresów URL plików zamiast. - -`FileEntry.toURL()` i `DirectoryEntry.toURL()` zwraca adres URL plików formularza - - cdvfile://localhost/persistent/path/to/file - - -które mogą być używane zamiast bezwzględna ścieżka zarówno `download()` i `metody upload()` metody. diff --git a/plugins/cordova-plugin-file-transfer/doc/ru/index.md b/plugins/cordova-plugin-file-transfer/doc/ru/index.md deleted file mode 100644 index cdd5a15..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/ru/index.md +++ /dev/null @@ -1,290 +0,0 @@ - - -# cordova-plugin-file-transfer - -Этот плагин позволяет вам загружать и скачивать файлы. - -## Установка - - cordova plugin add cordova-plugin-file-transfer - - -## Поддерживаемые платформы - -* Amazon Fire OS -* Android -* BlackBerry 10 -* Firefox OS ** -* iOS -* Windows Phone 7 и 8 * -* Windows 8 ***| -* Windows ***| - -* *Не поддерживают `onprogress` , ни `abort()` * - -** *Не поддерживает `onprogress` * - -Частичная поддержка `onprogress` для закачки метод. `onprogress` вызывается с пустой ход событий благодаря Windows limitations_ - -# FileTransfer - -`FileTransfer`Объект предоставляет способ для загрузки файлов с помощью нескольких частей запроса POST HTTP и для загрузки файлов, а также. - -## Параметры - -* **OnProgress**: называется с `ProgressEvent` всякий раз, когда новый фрагмент данных передается. *(Функция)* - -## Методы - -* **добавлено**: отправляет файл на сервер. - -* **скачать**: Скачать файл с сервера. - -* **прервать**: прерывает передачу в прогресс. - -## загрузить - -**Параметры**: - -* **fileURL**: файловой системы URL-адрес, представляющий файл на устройстве. Для обратной совместимости, это также может быть полный путь к файлу на устройстве. (См. [обратной совместимости отмечает] ниже) - -* **сервер**: URL-адрес сервера, чтобы получить файл, как закодированные`encodeURI()`. - -* **successCallback**: обратного вызова, передаваемого `Metadata` объект. *(Функция)* - -* **errorCallback**: обратного вызова, который выполняется в случае получения ошибки `Metadata` . Вызываемый с `FileTransferError` объект. *(Функция)* - -* **опции**: необязательные параметры *(объект)*. Допустимые ключи: - - * **fileKey**: имя элемента form. По умолчанию `file` . (DOMString) - * **имя файла**: имя файла для использования при сохранении файла на сервере. По умолчанию `image.jpg` . (DOMString) - * **mimeType**: mime-тип данных для загрузки. По умолчанию `image/jpeg` . (DOMString) - * **params**: набор пар дополнительный ключ/значение для передачи в HTTP-запросе. (Объект) - * **chunkedMode**: следует ли загружать данные в фрагментарности потоковом режиме. По умолчанию `true` . (Логическое значение) - * **заголовки**: Карта значений заголовок имя заголовка. Используйте массив для указания более одного значения. (Объект) - -* **trustAllHosts**: необязательный параметр, по умолчанию `false` . Если значение `true` , она принимает все сертификаты безопасности. Это полезно, поскольку Android отвергает самозаверяющие сертификаты. Не рекомендуется для использования в производстве. Поддерживается на Android и iOS. *(логическое значение)* - -### Пример - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### Пример с загружать заголовки и события Progress (Android и iOS только) - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -Объект `FileUploadResult` передается на успех обратного вызова метода `upload()` объекта `FileTransfer`. - -### Параметры - -* **bytesSent**: количество байт, отправленных на сервер как часть загрузки. (длинная) - -* **responseCode**: код ответа HTTP, возвращаемых сервером. (длинная) - -* **ответ**: ответ HTTP, возвращаемых сервером. (DOMString) - -* **заголовки**: заголовки ответов HTTP-сервером. (Объект) - - * В настоящее время поддерживается только для iOS. - -### Особенности iOS - -* Не поддерживает `responseCode` или`bytesSent`. - -## Скачать - -**Параметры**: - -* **источник**: URL-адрес сервера для загрузки файла, как закодированные`encodeURI()`. - -* **Цель**: файловой системы URL-адрес, представляющий файл на устройстве. Для обратной совместимости, это также может быть полный путь к файлу на устройстве. (См. [обратной совместимости отмечает] ниже) - -* **successCallback**: обратного вызова, передаваемого `FileEntry` объект. *(Функция)* - -* **errorCallback**: обратного вызова, который выполняется, если возникает ошибка при получении `Metadata` . Вызываемый с `FileTransferError` объект. *(Функция)* - -* **trustAllHosts**: необязательный параметр, по умолчанию `false` . Если значение `true` , она принимает все сертификаты безопасности. Это полезно, потому что Android отвергает самозаверяющие сертификаты. Не рекомендуется для использования в производстве. Поддерживается на Android и iOS. *(логическое значение)* - -* **опции**: необязательные параметры, в настоящее время только поддерживает заголовки (например авторизации (базовая аутентификация) и т.д.). - -### Пример - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -## прервать - -Прерывает передачу в прогресс. Onerror обратного вызова передается объект FileTransferError, который имеет код ошибки FileTransferError.ABORT_ERR. - -### Пример - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -A `FileTransferError` при ошибке обратного вызова передается объект, при возникновении ошибки. - -### Параметры - -* **код**: один из кодов стандартных ошибок, перечисленные ниже. (Число) - -* **источник**: URL-адрес источника. (Строка) - -* **Цель**: URL-адрес к целевому объекту. (Строка) - -* **http_status**: код состояния HTTP. Этот атрибут доступен только при код ответа от HTTP-соединения. (Число) - -* **исключение**: либо e.getMessage или e.toString (строка) - -### Константы - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## Обратной совместимости отмечает - -Предыдущие версии этого плагина будет принимать только устройства Абсолют файлам как источник для закачки, или как целевых для загрузок. Обычно эти пути бы формы - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -Для обратной совместимости, по-прежнему принимаются эти пути, и если ваше приложение зарегистрировано пути как в постоянное хранилище, то они могут продолжать использоваться. - -Эти пути ранее были видны в `fullPath` свойства `FileEntry` и `DirectoryEntry` объекты, возвращаемые файл плагина. Новые версии файла плагина, однако, не подвергать эти пути в JavaScript. - -Если вы переходите на новый (1.0.0 или новее) версию файла и вы ранее использовали `entry.fullPath` в качестве аргументов `download()` или `upload()` , то вам необходимо будет изменить код для использования файловой системы URL вместо. - -`FileEntry.toURL()`и `DirectoryEntry.toURL()` возвращает URL-адрес формы файловой системы - - cdvfile://localhost/persistent/path/to/file - - -которые могут быть использованы вместо абсолютного пути в обоих `download()` и `upload()` методы. diff --git a/plugins/cordova-plugin-file-transfer/doc/zh/README.md b/plugins/cordova-plugin-file-transfer/doc/zh/README.md deleted file mode 100644 index 5399b04..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/zh/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# cordova-plugin-file-transfer - -[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer) - -外掛程式檔: - -這個外掛程式允許你上傳和下載檔案。 - -這個外掛程式定義全域 `FileTransfer`,`FileUploadOptions` 的建構函式。 - -雖然在全球範圍內,他們不可用直到 `deviceready` 事件之後。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## 安裝 - - cordova plugin add cordova-plugin-file-transfer - - -## 支援的平臺 - - * 亞馬遜火 OS - * Android 系統 - * 黑莓 10 - * 瀏覽器 - * 火狐瀏覽器的作業系統 * * - * iOS - * Windows Phone 7 和 8 * - * Windows 8 - * Windows - -\ **不支援`onprogress`也`abort()` * - -\ * **不支援`onprogress` * - -# 檔案傳輸 - -`FileTransfer`物件提供上傳檔使用 HTTP 多部分職位或付諸表決的請求,並將檔以及下載的方式。 - -## 屬性 - - * **onprogress**: 使用調用 `ProgressEvent` 每當一塊新的資料傳輸。*(函數)* - -## 方法 - - * **upload**: 將檔發送到伺服器。 - - * **download**: 從伺服器上下載檔案。 - - * **abort**: 中止正在進行轉讓。 - -## upload - -**參數**: - - * **fileURL**: 表示檔在設備上的檔案系統 URL。 為向後相容性,這也可以將設備上的檔的完整路徑。 (請參見 [向後相容性注意到] 下面) - - * **server**: 伺服器以接收該檔,由編碼的 URL`encodeURI()`. - - * **successCallback**: 一個通過一個 `FileUploadResult` 物件的回檔。*(函數)* - - * **errorCallback**: 如果發生錯誤,檢索 `FileUploadResult` 執行一個回檔。使用 `FileTransferError` 物件調用。*(函數)* - - * **options**: 可選參數*(物件)*。有效的金鑰: - - * **fileKey**: 表單元素的名稱。預設值為 `file` 。() DOMString - * **fileName**: 要保存在伺服器上的檔時使用的檔案名稱。預設值為 `image.jpg` 。() DOMString - * **httpMethod**: HTTP 方法使用-`PUT` 或 `POST`。預設值為 `POST`。() DOMString - * **mimeType**: 要上載的資料的 mime 類型。預設設置為 `image/jpeg`。() DOMString - * **params**: 一組要在 HTTP 要求中傳遞的可選的鍵值對。(物件) - * **chunkedMode**: 是否要分塊的流式處理模式中的資料上載。預設值為 `true`。(布林值) - * **headers**: 地圖的標頭名稱/標頭值。 使用陣列來指定多個值。 IOS、 FireOS,和安卓系統,如果已命名的內容類型標頭存在,多部分表單資料不被使用。 (Object) - * **httpMethod**: HTTP 方法,例如使用張貼或放。 預設為`開機自檢`。() DOMString - - * **trustAllHosts**: 可選參數,預設值為 `false` 。 如果設置為 `true` ,它可以接受的所有安全證書。 這是有用的因為 android 系統拒絕自簽名的安全證書。 不建議供生產使用。 在 Android 和 iOS 上受支援。 *(布林值)* - -### 示例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### 與上傳的標頭和進度事件 (Android 和 iOS 只) 的示例 - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -`FileUploadResult` 物件將傳遞給該 `檔案傳輸` 物件的 `upload()` 方法的成功回檔。 - -### 屬性 - - * **bytesSent**: 作為上載的一部分發送到伺服器的位元組數。(長) - - * **responseCode**: 由伺服器返回的 HTTP 回應代碼。(長) - - * **response**: 由伺服器返回的 HTTP 回應。() DOMString - - * **headers**: 由伺服器的 HTTP 回應標頭。(物件) - - * 目前支援的 iOS 只。 - -### iOS 的怪癖 - - * 不支援 `responseCode` 或`bytesSent`. - -## download - -**參數**: - - * **source**: 要下載的檔,如由編碼的伺服器的 URL`encodeURI()`. - - * **target**: 表示檔在設備上的檔案系統 url。 為向後相容性,這也可以將設備上的檔的完整路徑。 (請參見 [向後相容性注意到] 下面) - - * **successCallback**: 傳遞一個回檔 `FileEntry` 物件。*(函數)* - - * **errorCallback**: 如果檢索 `FileEntry` 時發生錯誤,則執行一個回檔。使用 `FileTransferError` 物件調用。*(函數)* - - * **trustAllHosts**: 可選參數,預設值為 `false` 。 如果設置為 `true` ,它可以接受的所有安全證書。 這是有用的因為 Android 拒絕自行簽署式安全證書。 不建議供生產使用。 在 Android 和 iOS 上受支援。 *(布林值)* - - * **options**: 可選參數,目前只支援標題 (如授權 (基本驗證) 等)。 - -### 示例 - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -### WP8 的怪癖 - - * 下載請求由本機實現被緩存。若要避免緩存,傳遞`如果修改自`郵件頭以下載方法。 - -## abort - -中止正在進行轉讓。Onerror 回檔傳遞一個 FileTransferError 物件具有 FileTransferError.ABORT_ERR 錯誤代碼。 - -### 示例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -當發生錯誤時,`FileTransferError` 物件將傳遞給錯誤回檔。 - -### 屬性 - - * **code**: 下面列出的預定義的錯誤代碼之一。(人數) - - * **source**: 源的 URL。(字串) - - * **target**: 到目標 URL。(字串) - - * **HTTP_status**: HTTP 狀態碼。從 HTTP 連接收到一個回應代碼時,此屬性才可用。(人數) - - * **body**回應正文。此屬性只能是可用的當該 HTTP 連接收到答覆。(字串) - - * **exception**: 要麼 e.getMessage 或 e.toString (字串) - -### 常量 - - * 1 = `FileTransferError.FILE_NOT_FOUND_ERR` - * 2 = `FileTransferError.INVALID_URL_ERR` - * 3 = `FileTransferError.CONNECTION_ERR` - * 4 = `FileTransferError.ABORT_ERR` - * 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## 向後相容性注意到 - -以前版本的這個外掛程式才會接受設備-絕對檔路徑作為源對於上載,或用於下載的目標。這些路徑通常會在表單 - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -為向後相容性,這些路徑仍會被接受,和如果您的應用程式已錄得像這些在持久性存儲的路徑,然後他們可以繼續使用。 - -這些路徑被以前暴露在 `FileEntry` 和由檔外掛程式返回的 `DirectoryEntry` 物件的 `fullPath` 屬性中。 新版本的檔的外掛程式,但是,不再公開這些 JavaScript 的路徑。 - -如果您要升級到新 (1.0.0 或更高版本) 版本的檔,和你以前一直在使用 `entry.fullPath` 作為參數到 `download()` 或 `upload()`,那麼你將需要更改代碼以使用檔案系統的 Url 來代替。 - -`FileEntry.toURL()` 和 `DirectoryEntry.toURL()` 返回的表單檔案 URL - - cdvfile://localhost/persistent/path/to/file - - -它可以用在 `download()` 和 `upload()` 兩種方法中的絕對檔路徑位置。 \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/doc/zh/index.md b/plugins/cordova-plugin-file-transfer/doc/zh/index.md deleted file mode 100644 index b3af1eb..0000000 --- a/plugins/cordova-plugin-file-transfer/doc/zh/index.md +++ /dev/null @@ -1,302 +0,0 @@ - - -# cordova-plugin-file-transfer - -這個外掛程式允許你上傳和下載檔案。 - -這個外掛程式定義全域 `FileTransfer`,`FileUploadOptions` 的建構函式。 - -雖然在全球範圍內,他們不可用直到 `deviceready` 事件之後。 - - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(FileTransfer); - } - - -## 安裝 - - cordova plugin add cordova-plugin-file-transfer - - -## 支援的平臺 - -* 亞馬遜火 OS -* Android 系統 -* 黑莓 10 -* 瀏覽器 -* 火狐瀏覽器的作業系統 * * -* iOS -* Windows Phone 7 和 8 * -* Windows 8 -* Windows - -* *不支援 `onprogress` 也 `abort()`* - -* * *不支援 `onprogress`* - -# FileTransfer - -`FileTransfer` 物件提供一種使用 HTTP 多部分 POST 請求的檔上傳,下載檔案以及方式。 - -## 屬性 - -* **onprogress**: 使用調用 `ProgressEvent` 每當一塊新的資料傳輸。*(函數)* - -## 方法 - -* **upload**: 將檔發送到伺服器。 - -* **download**: 從伺服器上下載檔案。 - -* **abort**: 中止正在進行轉讓。 - -## upload - -**參數**: - -* **fileURL**: 表示檔在設備上的檔案系統 URL。 為向後相容性,這也可以將設備上的檔的完整路徑。 (請參見 [向後相容性注意到] 下面) - -* **server**: 伺服器以接收該檔,由編碼的 URL`encodeURI()`. - -* **successCallback**: 一個通過一個 `FileUploadResult` 物件的回檔。*(函數)* - -* **errorCallback**: 如果發生錯誤,檢索 `FileUploadResult` 執行一個回檔。使用 `FileTransferError` 物件調用。*(函數)* - -* **options**: 可選參數*(物件)*。有效的金鑰: - - * **fileKey**: 表單元素的名稱。預設值為 `file` 。() DOMString - * **fileName**: 要保存在伺服器上的檔時使用的檔案名稱。預設值為 `image.jpg` 。() DOMString - * **httpMethod**: HTTP 方法使用-`PUT` 或 `POST`。預設值為 `POST`。() DOMString - * **mimeType**: 要上載的資料的 mime 類型。預設設置為 `image/jpeg`。() DOMString - * **params**: 一組要在 HTTP 要求中傳遞的可選的鍵值對。(物件) - * **chunkedMode**: 是否要分塊的流式處理模式中的資料上載。預設值為 `true`。(布林值) - * **headers**: 地圖的標頭名稱/標頭值。使用陣列來指定多個值。(物件) - -* **trustAllHosts**: 可選參數,預設值為 `false` 。 如果設置為 `true` ,它接受的所有安全證書。 這是有用的因為 android 系統拒絕自簽名的安全證書。 不建議供生產使用。 支援 Android 和 iOS。 *(布林值)* - -### 示例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function (r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - var fail = function (error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey = "file"; - options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); - options.mimeType = "text/plain"; - - var params = {}; - params.value1 = "test"; - params.value2 = "param"; - - options.params = params; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - - -### 與上傳的標頭和進度事件 (Android 和 iOS 只) 的示例 - - function win(r) { - console.log("Code = " + r.responseCode); - console.log("Response = " + r.response); - console.log("Sent = " + r.bytesSent); - } - - function fail(error) { - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var uri = encodeURI("http://some.server.com/upload.php"); - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); - options.mimeType="text/plain"; - - var headers={'headerParam':'headerValue'}; - - options.headers = headers; - - var ft = new FileTransfer(); - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); - } else { - loadingStatus.increment(); - } - }; - ft.upload(fileURL, uri, win, fail, options); - - -## FileUploadResult - -`FileUploadResult` 物件將傳遞給該 `檔案傳輸` 物件的 `upload()` 方法的成功回檔。 - -### 屬性 - -* **bytesSent**: 作為上載的一部分發送到伺服器的位元組數。(長) - -* **responseCode**: 由伺服器返回的 HTTP 回應代碼。(長) - -* **response**: 由伺服器返回的 HTTP 回應。() DOMString - -* **headers**: 由伺服器的 HTTP 回應標頭。(物件) - - * 目前支援的 iOS 只。 - -### iOS 的怪癖 - -* 不支援 `responseCode` 或`bytesSent`. - -## download - -**參數**: - -* **source**: 要下載的檔,如由編碼的伺服器的 URL`encodeURI()`. - -* **target**: 表示檔在設備上的檔案系統 url。 為向後相容性,這也可以將設備上的檔的完整路徑。 (請參見 [向後相容性注意到] 下面) - -* **successCallback**: 傳遞一個回檔 `FileEntry` 物件。*(函數)* - -* **errorCallback**: 如果檢索 `FileEntry` 時發生錯誤,則執行一個回檔。使用 `FileTransferError` 物件調用。*(函數)* - -* **trustAllHosts**: 可選參數,預設值為 `false` 。 如果設置為 `true` ,它可以接受的所有安全證書。 這是有用的因為 Android 拒絕自行簽署式安全證書。 不建議供生產使用。 在 Android 和 iOS 上受支援。 *(布林值)* - -* **options**: 可選參數,目前只支援標題 (如授權 (基本驗證) 等)。 - -### 示例 - - // !! Assumes variable fileURL contains a valid URL to a path on the device, - // for example, cdvfile://localhost/persistent/path/to/downloads/ - - var fileTransfer = new FileTransfer(); - var uri = encodeURI("http://some.server.com/download.php"); - - fileTransfer.download( - uri, - fileURL, - function(entry) { - console.log("download complete: " + entry.toURL()); - }, - function(error) { - console.log("download error source " + error.source); - console.log("download error target " + error.target); - console.log("upload error code" + error.code); - }, - false, - { - headers: { - "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" - } - } - ); - - -## abort - -中止正在進行轉讓。Onerror 回檔傳遞一個 FileTransferError 物件具有 FileTransferError.ABORT_ERR 錯誤代碼。 - -### 示例 - - // !! Assumes variable fileURL contains a valid URL to a text file on the device, - // for example, cdvfile://localhost/persistent/path/to/file.txt - - var win = function(r) { - console.log("Should not be called."); - } - - var fail = function(error) { - // error.code == FileTransferError.ABORT_ERR - alert("An error has occurred: Code = " + error.code); - console.log("upload error source " + error.source); - console.log("upload error target " + error.target); - } - - var options = new FileUploadOptions(); - options.fileKey="file"; - options.fileName="myphoto.jpg"; - options.mimeType="image/jpeg"; - - var ft = new FileTransfer(); - ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options); - ft.abort(); - - -## FileTransferError - -當發生錯誤時,`FileTransferError` 物件將傳遞給錯誤回檔。 - -### 屬性 - -* **code**: 下面列出的預定義的錯誤代碼之一。(人數) - -* **source**: 源的 URL。(字串) - -* **target**: 到目標 URL。(字串) - -* **HTTP_status**: HTTP 狀態碼。從 HTTP 連接收到一個回應代碼時,此屬性才可用。(人數) - -* **body**回應正文。此屬性只能是可用的當該 HTTP 連接收到答覆。(字串) - -* **exception**: 要麼 e.getMessage 或 e.toString (字串) - -### 常量 - -* 1 = `FileTransferError.FILE_NOT_FOUND_ERR` -* 2 = `FileTransferError.INVALID_URL_ERR` -* 3 = `FileTransferError.CONNECTION_ERR` -* 4 = `FileTransferError.ABORT_ERR` -* 5 = `FileTransferError.NOT_MODIFIED_ERR` - -## 向後相容性注意到 - -以前版本的這個外掛程式才會接受設備-絕對檔路徑作為源對於上載,或用於下載的目標。這些路徑通常會在表單 - - /var/mobile/Applications//Documents/path/to/file (iOS) - /storage/emulated/0/path/to/file (Android) - - -為向後相容性,這些路徑仍會被接受,和如果您的應用程式已錄得像這些在持久性存儲的路徑,然後他們可以繼續使用。 - -這些路徑被以前暴露在 `FileEntry` 和由檔外掛程式返回的 `DirectoryEntry` 物件的 `fullPath` 屬性中。 新版本的檔的外掛程式,但是,不再公開這些 JavaScript 的路徑。 - -如果您要升級到新 (1.0.0 或更高版本) 版本的檔,和你以前一直在使用 `entry.fullPath` 作為參數到 `download()` 或 `upload()`,那麼你將需要更改代碼以使用檔案系統的 Url 來代替。 - -`FileEntry.toURL()` 和 `DirectoryEntry.toURL()` 返回的表單檔案 URL - - cdvfile://localhost/persistent/path/to/file - - -它可以用在 `download()` 和 `upload()` 兩種方法中的絕對檔路徑位置。 diff --git a/plugins/cordova-plugin-file-transfer/package.json b/plugins/cordova-plugin-file-transfer/package.json deleted file mode 100644 index 0551d22..0000000 --- a/plugins/cordova-plugin-file-transfer/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "cordova-plugin-file-transfer", - "version": "1.5.1-dev", - "description": "Cordova File Transfer Plugin", - "cordova": { - "id": "cordova-plugin-file-transfer", - "platforms": [ - "android", - "amazon-fireos", - "ubuntu", - "blackberry10", - "ios", - "wp7", - "wp8", - "windows8", - "windows", - "firefoxos", - "browser" - ] - }, - "scripts": { - "test": "npm run lint && npm run style", - "style": "node_modules/.bin/jscs tests/tests.js", - "lint": "node_modules/.bin/jshint tests/tests.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/apache/cordova-plugin-file-transfer" - }, - "keywords": [ - "cordova", - "file", - "transfer", - "ecosystem:cordova", - "cordova-android", - "cordova-amazon-fireos", - "cordova-ubuntu", - "cordova-blackberry10", - "cordova-ios", - "cordova-wp7", - "cordova-wp8", - "cordova-windows8", - "cordova-windows", - "cordova-firefoxos", - "cordova-browser" - ], - "peerDependencies": { - "cordova-plugin-file": "^3.0.0" - }, - "author": "Apache Software Foundation", - "license": "Apache-2.0", - "devDependencies": { - "jscs": "^2.6.0", - "jshint": "^2.8.0" - } -} diff --git a/plugins/cordova-plugin-file-transfer/plugin.xml b/plugins/cordova-plugin-file-transfer/plugin.xml deleted file mode 100644 index b7cd6fe..0000000 --- a/plugins/cordova-plugin-file-transfer/plugin.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - File Transfer - Cordova File Transfer Plugin - Apache 2.0 - cordova,file,transfer - https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git - https://issues.apache.org/jira/browse/CB/component/12320650 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/cordova-plugin-file-transfer/src/amazon/FileTransfer.java b/plugins/cordova-plugin-file-transfer/src/amazon/FileTransfer.java deleted file mode 100644 index 1563a39..0000000 --- a/plugins/cordova-plugin-file-transfer/src/amazon/FileTransfer.java +++ /dev/null @@ -1,898 +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.filetransfer; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URLConnection; -import java.net.URLDecoder; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.Iterator; -import java.util.zip.GZIPInputStream; -import java.util.zip.Inflater; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.apache.cordova.Config; -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CordovaResourceApi; -import org.apache.cordova.CordovaResourceApi.OpenForReadResult; -import org.apache.cordova.PluginResult; -import org.apache.cordova.file.FileUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.net.Uri; -import android.os.Build; -import android.util.Log; -import com.amazon.android.webkit.AmazonCookieManager; - -public class FileTransfer extends CordovaPlugin { - - private static final String LOG_TAG = "FileTransfer"; - private static final String LINE_START = "--"; - private static final String LINE_END = "\r\n"; - private static final String BOUNDARY = "+++++"; - - public static int FILE_NOT_FOUND_ERR = 1; - public static int INVALID_URL_ERR = 2; - public static int CONNECTION_ERR = 3; - public static int ABORTED_ERR = 4; - - private static HashMap activeRequests = new HashMap(); - private static final int MAX_BUFFER_SIZE = 16 * 1024; - - private static final class RequestContext { - String source; - String target; - File targetFile; - CallbackContext callbackContext; - InputStream currentInputStream; - OutputStream currentOutputStream; - boolean aborted; - RequestContext(String source, String target, CallbackContext callbackContext) { - this.source = source; - this.target = target; - this.callbackContext = callbackContext; - } - void sendPluginResult(PluginResult pluginResult) { - synchronized (this) { - if (!aborted) { - callbackContext.sendPluginResult(pluginResult); - } - } - } - } - - /** - * Adds an interface method to an InputStream to return the number of bytes - * read from the raw stream. This is used to track total progress against - * the HTTP Content-Length header value from the server. - */ - private static abstract class TrackingInputStream extends FilterInputStream { - public TrackingInputStream(final InputStream in) { - super(in); - } - public abstract long getTotalRawBytesRead(); - } - - private static class ExposedGZIPInputStream extends GZIPInputStream { - public ExposedGZIPInputStream(final InputStream in) throws IOException { - super(in); - } - public Inflater getInflater() { - return inf; - } - } - - /** - * Provides raw bytes-read tracking for a GZIP input stream. Reports the - * total number of compressed bytes read from the input, rather than the - * number of uncompressed bytes. - */ - private static class TrackingGZIPInputStream extends TrackingInputStream { - private ExposedGZIPInputStream gzin; - public TrackingGZIPInputStream(final ExposedGZIPInputStream gzin) throws IOException { - super(gzin); - this.gzin = gzin; - } - public long getTotalRawBytesRead() { - return gzin.getInflater().getBytesRead(); - } - } - - /** - * Provides simple total-bytes-read tracking for an existing InputStream - */ - private static class SimpleTrackingInputStream extends TrackingInputStream { - private long bytesRead = 0; - public SimpleTrackingInputStream(InputStream stream) { - super(stream); - } - - private int updateBytesRead(int newBytesRead) { - if (newBytesRead != -1) { - bytesRead += newBytesRead; - } - return newBytesRead; - } - - @Override - public int read() throws IOException { - return updateBytesRead(super.read()); - } - - // Note: FilterInputStream delegates read(byte[] bytes) to the below method, - // so we don't override it or else double count (CB-5631). - @Override - public int read(byte[] bytes, int offset, int count) throws IOException { - return updateBytesRead(super.read(bytes, offset, count)); - } - - public long getTotalRawBytesRead() { - return bytesRead; - } - } - - @Override - public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - if (action.equals("upload") || action.equals("download")) { - String source = args.getString(0); - String target = args.getString(1); - - if (action.equals("upload")) { - try { - source = URLDecoder.decode(source, "UTF-8"); - upload(source, target, args, callbackContext); - } catch (UnsupportedEncodingException e) { - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.MALFORMED_URL_EXCEPTION, "UTF-8 error.")); - } - } else { - download(source, target, args, callbackContext); - } - return true; - } else if (action.equals("abort")) { - String objectId = args.getString(0); - abort(objectId); - callbackContext.success(); - return true; - } - return false; - } - - private static void addHeadersToRequest(URLConnection connection, JSONObject headers) { - try { - for (Iterator iter = headers.keys(); iter.hasNext(); ) { - String headerKey = iter.next().toString(); - JSONArray headerValues = headers.optJSONArray(headerKey); - if (headerValues == null) { - headerValues = new JSONArray(); - headerValues.put(headers.getString(headerKey)); - } - connection.setRequestProperty(headerKey, headerValues.getString(0)); - for (int i = 1; i < headerValues.length(); ++i) { - connection.addRequestProperty(headerKey, headerValues.getString(i)); - } - } - } catch (JSONException e1) { - // No headers to be manipulated! - } - } - - /** - * Uploads the specified file to the server URL provided using an HTTP multipart request. - * @param source Full path of the file on the file system - * @param target URL of the server to receive the file - * @param args JSON Array of args - * @param callbackContext callback id for optional progress reports - * - * args[2] fileKey Name of file request parameter - * args[3] fileName File name to be used on server - * args[4] mimeType Describes file content type - * args[5] params key:value pairs of user-defined parameters - * @return FileUploadResult containing result of upload request - */ - private void upload(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException { - Log.d(LOG_TAG, "upload " + source + " to " + target); - - // Setup the options - final String fileKey = getArgument(args, 2, "file"); - final String fileName = getArgument(args, 3, "image.jpg"); - final String mimeType = getArgument(args, 4, "image/jpeg"); - final JSONObject params = args.optJSONObject(5) == null ? new JSONObject() : args.optJSONObject(5); - final boolean trustEveryone = args.optBoolean(6); - // Always use chunked mode unless set to false as per API - final boolean chunkedMode = args.optBoolean(7) || args.isNull(7); - // Look for headers on the params map for backwards compatibility with older Cordova versions. - final JSONObject headers = args.optJSONObject(8) == null ? params.optJSONObject("headers") : args.optJSONObject(8); - final String objectId = args.getString(9); - final String httpMethod = getArgument(args, 10, "POST"); - - final CordovaResourceApi resourceApi = webView.getResourceApi(); - - Log.d(LOG_TAG, "fileKey: " + fileKey); - Log.d(LOG_TAG, "fileName: " + fileName); - Log.d(LOG_TAG, "mimeType: " + mimeType); - Log.d(LOG_TAG, "params: " + params); - Log.d(LOG_TAG, "trustEveryone: " + trustEveryone); - Log.d(LOG_TAG, "chunkedMode: " + chunkedMode); - Log.d(LOG_TAG, "headers: " + headers); - Log.d(LOG_TAG, "objectId: " + objectId); - Log.d(LOG_TAG, "httpMethod: " + httpMethod); - - final Uri targetUri = resourceApi.remapUri(Uri.parse(target)); - // Accept a path or a URI for the source. - Uri tmpSrc = Uri.parse(source); - final Uri sourceUri = resourceApi.remapUri( - tmpSrc.getScheme() != null ? tmpSrc : Uri.fromFile(new File(source))); - - int uriType = CordovaResourceApi.getUriType(targetUri); - final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS; - if (uriType != CordovaResourceApi.URI_TYPE_HTTP && !useHttps) { - JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target, null, 0); - Log.e(LOG_TAG, "Unsupported URI: " + targetUri); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - final RequestContext context = new RequestContext(source, target, callbackContext); - synchronized (activeRequests) { - activeRequests.put(objectId, context); - } - - cordova.getThreadPool().execute(new Runnable() { - public void run() { - if (context.aborted) { - return; - } - HttpURLConnection conn = null; - HostnameVerifier oldHostnameVerifier = null; - SSLSocketFactory oldSocketFactory = null; - int totalBytes = 0; - int fixedLength = -1; - try { - // Create return object - FileUploadResult result = new FileUploadResult(); - FileProgressResult progress = new FileProgressResult(); - - //------------------ CLIENT REQUEST - // Open a HTTP connection to the URL based on protocol - conn = resourceApi.createHttpConnection(targetUri); - if (useHttps && trustEveryone) { - // Setup the HTTPS connection class to trust everyone - HttpsURLConnection https = (HttpsURLConnection)conn; - oldSocketFactory = trustAllHosts(https); - // Save the current hostnameVerifier - oldHostnameVerifier = https.getHostnameVerifier(); - // Setup the connection not to verify hostnames - https.setHostnameVerifier(DO_NOT_VERIFY); - } - - // Allow Inputs - conn.setDoInput(true); - - // Allow Outputs - conn.setDoOutput(true); - - // Don't use a cached copy. - conn.setUseCaches(false); - - // Use a post method. - conn.setRequestMethod(httpMethod); - - // if we specified a Content-Type header, don't do multipart form upload - boolean multipartFormUpload = (headers == null) || !headers.has("Content-Type"); - if (multipartFormUpload) { - conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); - } - // Set the cookies on the response - String cookie = AmazonCookieManager.getInstance().getCookie(target); - if (cookie != null) { - conn.setRequestProperty("Cookie", cookie); - } - - // Handle the other headers - if (headers != null) { - addHeadersToRequest(conn, headers); - } - - /* - * Store the non-file portions of the multipart data as a string, so that we can add it - * to the contentSize, since it is part of the body of the HTTP request. - */ - StringBuilder beforeData = new StringBuilder(); - try { - for (Iterator iter = params.keys(); iter.hasNext();) { - Object key = iter.next(); - if(!String.valueOf(key).equals("headers")) - { - beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END); - beforeData.append("Content-Disposition: form-data; name=\"").append(key.toString()).append('"'); - beforeData.append(LINE_END).append(LINE_END); - beforeData.append(params.getString(key.toString())); - beforeData.append(LINE_END); - } - } - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - - beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END); - beforeData.append("Content-Disposition: form-data; name=\"").append(fileKey).append("\";"); - beforeData.append(" filename=\"").append(fileName).append('"').append(LINE_END); - beforeData.append("Content-Type: ").append(mimeType).append(LINE_END).append(LINE_END); - byte[] beforeDataBytes = beforeData.toString().getBytes("UTF-8"); - byte[] tailParamsBytes = (LINE_END + LINE_START + BOUNDARY + LINE_START + LINE_END).getBytes("UTF-8"); - - - // Get a input stream of the file on the phone - OpenForReadResult readResult = resourceApi.openForRead(sourceUri); - - int stringLength = beforeDataBytes.length + tailParamsBytes.length; - if (readResult.length >= 0) { - fixedLength = (int)readResult.length; - if (multipartFormUpload) - fixedLength += stringLength; - progress.setLengthComputable(true); - progress.setTotal(fixedLength); - } - Log.d(LOG_TAG, "Content Length: " + fixedLength); - // setFixedLengthStreamingMode causes and OutOfMemoryException on pre-Froyo devices. - // http://code.google.com/p/android/issues/detail?id=3164 - // It also causes OOM if HTTPS is used, even on newer devices. - boolean useChunkedMode = chunkedMode && (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO || useHttps); - useChunkedMode = useChunkedMode || (fixedLength == -1); - - if (useChunkedMode) { - conn.setChunkedStreamingMode(MAX_BUFFER_SIZE); - // Although setChunkedStreamingMode sets this header, setting it explicitly here works - // around an OutOfMemoryException when using https. - conn.setRequestProperty("Transfer-Encoding", "chunked"); - } else { - conn.setFixedLengthStreamingMode(fixedLength); - } - - conn.connect(); - - OutputStream sendStream = null; - try { - sendStream = conn.getOutputStream(); - synchronized (context) { - if (context.aborted) { - return; - } - context.currentOutputStream = sendStream; - } - - if (multipartFormUpload) { - //We don't want to change encoding, we just want this to write for all Unicode. - sendStream.write(beforeDataBytes); - totalBytes += beforeDataBytes.length; - } - // create a buffer of maximum size - int bytesAvailable = readResult.inputStream.available(); - int bufferSize = Math.min(bytesAvailable, MAX_BUFFER_SIZE); - byte[] buffer = new byte[bufferSize]; - - // read file and write it into form... - int bytesRead = readResult.inputStream.read(buffer, 0, bufferSize); - - long prevBytesRead = 0; - while (bytesRead > 0) { - result.setBytesSent(totalBytes); - sendStream.write(buffer, 0, bytesRead); - totalBytes += bytesRead; - if (totalBytes > prevBytesRead + 102400) { - prevBytesRead = totalBytes; - Log.d(LOG_TAG, "Uploaded " + totalBytes + " of " + fixedLength + " bytes"); - } - bytesAvailable = readResult.inputStream.available(); - bufferSize = Math.min(bytesAvailable, MAX_BUFFER_SIZE); - bytesRead = readResult.inputStream.read(buffer, 0, bufferSize); - - // Send a progress event. - progress.setLoaded(totalBytes); - PluginResult progressResult = new PluginResult(PluginResult.Status.OK, progress.toJSONObject()); - progressResult.setKeepCallback(true); - context.sendPluginResult(progressResult); - } - - if (multipartFormUpload) { - // send multipart form data necessary after file data... - sendStream.write(tailParamsBytes); - totalBytes += tailParamsBytes.length; - } - sendStream.flush(); - } finally { - safeClose(readResult.inputStream); - safeClose(sendStream); - } - context.currentOutputStream = null; - Log.d(LOG_TAG, "Sent " + totalBytes + " of " + fixedLength); - - //------------------ read the SERVER RESPONSE - String responseString; - int responseCode = conn.getResponseCode(); - Log.d(LOG_TAG, "response code: " + responseCode); - Log.d(LOG_TAG, "response headers: " + conn.getHeaderFields()); - TrackingInputStream inStream = null; - try { - inStream = getInputStream(conn); - synchronized (context) { - if (context.aborted) { - return; - } - context.currentInputStream = inStream; - } - - ByteArrayOutputStream out = new ByteArrayOutputStream(Math.max(1024, conn.getContentLength())); - byte[] buffer = new byte[1024]; - int bytesRead = 0; - // write bytes to file - while ((bytesRead = inStream.read(buffer)) > 0) { - out.write(buffer, 0, bytesRead); - } - responseString = out.toString("UTF-8"); - } finally { - context.currentInputStream = null; - safeClose(inStream); - } - - Log.d(LOG_TAG, "got response from server"); - Log.d(LOG_TAG, responseString.substring(0, Math.min(256, responseString.length()))); - - // send request and retrieve response - result.setResponseCode(responseCode); - result.setResponse(responseString); - - context.sendPluginResult(new PluginResult(PluginResult.Status.OK, result.toJSONObject())); - } catch (FileNotFoundException e) { - JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, conn); - Log.e(LOG_TAG, error.toString(), e); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } catch (IOException e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn); - Log.e(LOG_TAG, error.toString(), e); - Log.e(LOG_TAG, "Failed after uploading " + totalBytes + " of " + fixedLength + " bytes."); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - context.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - } catch (Throwable t) { - // Shouldn't happen, but will - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn); - Log.e(LOG_TAG, error.toString(), t); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } finally { - synchronized (activeRequests) { - activeRequests.remove(objectId); - } - - if (conn != null) { - // Revert back to the proper verifier and socket factories - // Revert back to the proper verifier and socket factories - if (trustEveryone && useHttps) { - HttpsURLConnection https = (HttpsURLConnection) conn; - https.setHostnameVerifier(oldHostnameVerifier); - https.setSSLSocketFactory(oldSocketFactory); - } - } - } - } - }); - } - - private static void safeClose(Closeable stream) { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - } - } - } - - private static TrackingInputStream getInputStream(URLConnection conn) throws IOException { - String encoding = conn.getContentEncoding(); - if (encoding != null && encoding.equalsIgnoreCase("gzip")) { - return new TrackingGZIPInputStream(new ExposedGZIPInputStream(conn.getInputStream())); - } - return new SimpleTrackingInputStream(conn.getInputStream()); - } - - // always verify the host - don't check for certificate - private static final HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - // Create a trust manager that does not validate certificate chains - private static final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[] {}; - } - - public void checkClientTrusted(X509Certificate[] chain, - String authType) throws CertificateException { - } - - public void checkServerTrusted(X509Certificate[] chain, - String authType) throws CertificateException { - } - } }; - - /** - * This function will install a trust manager that will blindly trust all SSL - * certificates. The reason this code is being added is to enable developers - * to do development using self signed SSL certificates on their web server. - * - * The standard HttpsURLConnection class will throw an exception on self - * signed certificates if this code is not run. - */ - private static SSLSocketFactory trustAllHosts(HttpsURLConnection connection) { - // Install the all-trusting trust manager - SSLSocketFactory oldFactory = connection.getSSLSocketFactory(); - try { - // Install our all trusting manager - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - SSLSocketFactory newFactory = sc.getSocketFactory(); - connection.setSSLSocketFactory(newFactory); - } catch (Exception e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - return oldFactory; - } - - private static JSONObject createFileTransferError(int errorCode, String source, String target, URLConnection connection) { - - int httpStatus = 0; - StringBuilder bodyBuilder = new StringBuilder(); - String body = null; - if (connection != null) { - try { - if (connection instanceof HttpURLConnection) { - httpStatus = ((HttpURLConnection)connection).getResponseCode(); - InputStream err = ((HttpURLConnection) connection).getErrorStream(); - if(err != null) - { - BufferedReader reader = new BufferedReader(new InputStreamReader(err, "UTF-8")); - try { - String line = reader.readLine(); - while(line != null) { - bodyBuilder.append(line); - line = reader.readLine(); - if(line != null) { - bodyBuilder.append('\n'); - } - } - body = bodyBuilder.toString(); - } finally { - reader.close(); - } - } - } - // IOException can leave connection object in a bad state, so catch all exceptions. - } catch (Throwable e) { - Log.w(LOG_TAG, "Error getting HTTP status code from connection.", e); - } - } - - return createFileTransferError(errorCode, source, target, body, httpStatus); - } - - /** - * Create an error object based on the passed in errorCode - * @param errorCode the error - * @return JSONObject containing the error - */ - private static JSONObject createFileTransferError(int errorCode, String source, String target, String body, Integer httpStatus) { - JSONObject error = null; - try { - error = new JSONObject(); - error.put("code", errorCode); - error.put("source", source); - error.put("target", target); - if(body != null) - { - error.put("body", body); - } - if (httpStatus != null) { - error.put("http_status", httpStatus); - } - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - return error; - } - - /** - * Convenience method to read a parameter from the list of JSON args. - * @param args the args passed to the Plugin - * @param position the position to retrieve the arg from - * @param defaultString the default to be used if the arg does not exist - * @return String with the retrieved value - */ - private static String getArgument(JSONArray args, int position, String defaultString) { - String arg = defaultString; - if (args.length() > position) { - arg = args.optString(position); - if (arg == null || "null".equals(arg)) { - arg = defaultString; - } - } - return arg; - } - - /** - * Downloads a file form a given URL and saves it to the specified directory. - * - * @param source URL of the server to receive the file - * @param target Full path of the file on the file system - */ - private void download(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException { - Log.d(LOG_TAG, "download " + source + " to " + target); - - final CordovaResourceApi resourceApi = webView.getResourceApi(); - - final boolean trustEveryone = args.optBoolean(2); - final String objectId = args.getString(3); - final JSONObject headers = args.optJSONObject(4); - - final Uri sourceUri = resourceApi.remapUri(Uri.parse(source)); - // Accept a path or a URI for the source. - Uri tmpTarget = Uri.parse(target); - final Uri targetUri = resourceApi.remapUri( - tmpTarget.getScheme() != null ? tmpTarget : Uri.fromFile(new File(target))); - - int uriType = CordovaResourceApi.getUriType(sourceUri); - final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS; - final boolean isLocalTransfer = !useHttps && uriType != CordovaResourceApi.URI_TYPE_HTTP; - if (uriType == CordovaResourceApi.URI_TYPE_UNKNOWN) { - JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target, null, 0); - Log.e(LOG_TAG, "Unsupported URI: " + targetUri); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - // TODO: refactor to also allow resources & content: - if (!isLocalTransfer && !Config.isUrlWhiteListed(source)) { - Log.w(LOG_TAG, "Source URL is not in white list: '" + source + "'"); - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, null, 401); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - - final RequestContext context = new RequestContext(source, target, callbackContext); - synchronized (activeRequests) { - activeRequests.put(objectId, context); - } - - cordova.getThreadPool().execute(new Runnable() { - public void run() { - if (context.aborted) { - return; - } - HttpURLConnection connection = null; - HostnameVerifier oldHostnameVerifier = null; - SSLSocketFactory oldSocketFactory = null; - File file = null; - PluginResult result = null; - TrackingInputStream inputStream = null; - - OutputStream outputStream = null; - try { - OpenForReadResult readResult = null; - outputStream = resourceApi.openOutputStream(targetUri); - - file = resourceApi.mapUriToFile(targetUri); - context.targetFile = file; - - Log.d(LOG_TAG, "Download file:" + sourceUri); - - FileProgressResult progress = new FileProgressResult(); - - if (isLocalTransfer) { - readResult = resourceApi.openForRead(sourceUri); - if (readResult.length != -1) { - progress.setLengthComputable(true); - progress.setTotal(readResult.length); - } - inputStream = new SimpleTrackingInputStream(readResult.inputStream); - } else { - // connect to server - // Open a HTTP connection to the URL based on protocol - connection = resourceApi.createHttpConnection(sourceUri); - if (useHttps && trustEveryone) { - // Setup the HTTPS connection class to trust everyone - HttpsURLConnection https = (HttpsURLConnection)connection; - oldSocketFactory = trustAllHosts(https); - // Save the current hostnameVerifier - oldHostnameVerifier = https.getHostnameVerifier(); - // Setup the connection not to verify hostnames - https.setHostnameVerifier(DO_NOT_VERIFY); - } - - connection.setRequestMethod("GET"); - - // TODO: Make OkHttp use this AmazonCookieManager by default. - String cookie = AmazonCookieManager.getInstance().getCookie(sourceUri.toString()); - if(cookie != null) - { - connection.setRequestProperty("cookie", cookie); - } - - // This must be explicitly set for gzip progress tracking to work. - connection.setRequestProperty("Accept-Encoding", "gzip"); - - // Handle the other headers - if (headers != null) { - addHeadersToRequest(connection, headers); - } - - connection.connect(); - - if (connection.getContentEncoding() == null || connection.getContentEncoding().equalsIgnoreCase("gzip")) { - // Only trust content-length header if we understand - // the encoding -- identity or gzip - if (connection.getContentLength() != -1) { - progress.setLengthComputable(true); - progress.setTotal(connection.getContentLength()); - } - } - inputStream = getInputStream(connection); - } - - try { - synchronized (context) { - if (context.aborted) { - return; - } - context.currentInputStream = inputStream; - } - - // write bytes to file - byte[] buffer = new byte[MAX_BUFFER_SIZE]; - int bytesRead = 0; - while ((bytesRead = inputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, bytesRead); - // Send a progress event. - progress.setLoaded(inputStream.getTotalRawBytesRead()); - PluginResult progressResult = new PluginResult(PluginResult.Status.OK, progress.toJSONObject()); - progressResult.setKeepCallback(true); - context.sendPluginResult(progressResult); - } - } finally { - context.currentInputStream = null; - safeClose(inputStream); - safeClose(outputStream); - } - - Log.d(LOG_TAG, "Saved file: " + target); - - // create FileEntry object - FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); - if (filePlugin != null) { - JSONObject fileEntry = filePlugin.getEntryForFile(file); - if (fileEntry != null) { - result = new PluginResult(PluginResult.Status.OK, fileEntry); - } else { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection); - Log.e(LOG_TAG, "File plugin cannot represent download path"); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } - } else { - Log.e(LOG_TAG, "File plugin not found; cannot save downloaded file"); - result = new PluginResult(PluginResult.Status.ERROR, "File plugin not found; cannot save downloaded file"); - } - - } catch (FileNotFoundException e) { - JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } catch (IOException e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - result = new PluginResult(PluginResult.Status.JSON_EXCEPTION); - } catch (Throwable e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } finally { - safeClose(outputStream); - synchronized (activeRequests) { - activeRequests.remove(objectId); - } - - if (connection != null) { - // Revert back to the proper verifier and socket factories - if (trustEveryone && useHttps) { - HttpsURLConnection https = (HttpsURLConnection) connection; - https.setHostnameVerifier(oldHostnameVerifier); - https.setSSLSocketFactory(oldSocketFactory); - } - } - - if (result == null) { - result = new PluginResult(PluginResult.Status.ERROR, createFileTransferError(CONNECTION_ERR, source, target, connection)); - } - // Remove incomplete download. - if (result.getStatus() != PluginResult.Status.OK.ordinal() && file != null) { - file.delete(); - } - context.sendPluginResult(result); - } - } - }); - } - - /** - * Abort an ongoing upload or download. - */ - private void abort(String objectId) { - final RequestContext context; - synchronized (activeRequests) { - context = activeRequests.remove(objectId); - } - if (context != null) { - File file = context.targetFile; - if (file != null) { - file.delete(); - } - // Trigger the abort callback immediately to minimize latency between it and abort() being called. - JSONObject error = createFileTransferError(ABORTED_ERR, context.source, context.target, null, -1); - synchronized (context) { - context.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, error)); - context.aborted = true; - } - // Closing the streams can block, so execute on a background thread. - cordova.getThreadPool().execute(new Runnable() { - public void run() { - synchronized (context) { - safeClose(context.currentInputStream); - safeClose(context.currentOutputStream); - } - } - }); - } - } -} diff --git a/plugins/cordova-plugin-file-transfer/src/android/FileProgressResult.java b/plugins/cordova-plugin-file-transfer/src/android/FileProgressResult.java deleted file mode 100644 index 76a7b13..0000000 --- a/plugins/cordova-plugin-file-transfer/src/android/FileProgressResult.java +++ /dev/null @@ -1,63 +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.filetransfer; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Encapsulates in-progress status of uploading or downloading a file to a remote server. - */ -public class FileProgressResult { - - private boolean lengthComputable = false; // declares whether total is known - private long loaded = 0; // bytes sent so far - private long total = 0; // bytes total, if known - - public boolean getLengthComputable() { - return lengthComputable; - } - - public void setLengthComputable(boolean computable) { - this.lengthComputable = computable; - } - - public long getLoaded() { - return loaded; - } - - public void setLoaded(long bytes) { - this.loaded = bytes; - } - - public long getTotal() { - return total; - } - - public void setTotal(long bytes) { - this.total = bytes; - } - - public JSONObject toJSONObject() throws JSONException { - return new JSONObject( - "{loaded:" + loaded + - ",total:" + total + - ",lengthComputable:" + (lengthComputable ? "true" : "false") + "}"); - } -} diff --git a/plugins/cordova-plugin-file-transfer/src/android/FileTransfer.java b/plugins/cordova-plugin-file-transfer/src/android/FileTransfer.java deleted file mode 100644 index b9b99dc..0000000 --- a/plugins/cordova-plugin-file-transfer/src/android/FileTransfer.java +++ /dev/null @@ -1,1024 +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.filetransfer; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.net.HttpURLConnection; -import java.net.URLConnection; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.Iterator; -import java.util.zip.GZIPInputStream; -import java.util.zip.Inflater; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.apache.cordova.Config; -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CordovaResourceApi; -import org.apache.cordova.CordovaResourceApi.OpenForReadResult; -import org.apache.cordova.PluginManager; -import org.apache.cordova.PluginResult; -import org.apache.cordova.Whitelist; -import org.apache.cordova.file.FileUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.net.Uri; -import android.os.Build; -import android.util.Log; -import android.webkit.CookieManager; - -public class FileTransfer extends CordovaPlugin { - - private static final String LOG_TAG = "FileTransfer"; - private static final String LINE_START = "--"; - private static final String LINE_END = "\r\n"; - private static final String BOUNDARY = "+++++"; - - public static int FILE_NOT_FOUND_ERR = 1; - public static int INVALID_URL_ERR = 2; - public static int CONNECTION_ERR = 3; - public static int ABORTED_ERR = 4; - public static int NOT_MODIFIED_ERR = 5; - - private static HashMap activeRequests = new HashMap(); - private static final int MAX_BUFFER_SIZE = 16 * 1024; - - private static final class RequestContext { - String source; - String target; - File targetFile; - CallbackContext callbackContext; - HttpURLConnection connection; - boolean aborted; - RequestContext(String source, String target, CallbackContext callbackContext) { - this.source = source; - this.target = target; - this.callbackContext = callbackContext; - } - void sendPluginResult(PluginResult pluginResult) { - synchronized (this) { - if (!aborted) { - callbackContext.sendPluginResult(pluginResult); - } - } - } - } - - /** - * Adds an interface method to an InputStream to return the number of bytes - * read from the raw stream. This is used to track total progress against - * the HTTP Content-Length header value from the server. - */ - private static abstract class TrackingInputStream extends FilterInputStream { - public TrackingInputStream(final InputStream in) { - super(in); - } - public abstract long getTotalRawBytesRead(); - } - - private static class ExposedGZIPInputStream extends GZIPInputStream { - public ExposedGZIPInputStream(final InputStream in) throws IOException { - super(in); - } - public Inflater getInflater() { - return inf; - } - } - - /** - * Provides raw bytes-read tracking for a GZIP input stream. Reports the - * total number of compressed bytes read from the input, rather than the - * number of uncompressed bytes. - */ - private static class TrackingGZIPInputStream extends TrackingInputStream { - private ExposedGZIPInputStream gzin; - public TrackingGZIPInputStream(final ExposedGZIPInputStream gzin) throws IOException { - super(gzin); - this.gzin = gzin; - } - public long getTotalRawBytesRead() { - return gzin.getInflater().getBytesRead(); - } - } - - /** - * Provides simple total-bytes-read tracking for an existing InputStream - */ - private static class SimpleTrackingInputStream extends TrackingInputStream { - private long bytesRead = 0; - public SimpleTrackingInputStream(InputStream stream) { - super(stream); - } - - private int updateBytesRead(int newBytesRead) { - if (newBytesRead != -1) { - bytesRead += newBytesRead; - } - return newBytesRead; - } - - @Override - public int read() throws IOException { - return updateBytesRead(super.read()); - } - - // Note: FilterInputStream delegates read(byte[] bytes) to the below method, - // so we don't override it or else double count (CB-5631). - @Override - public int read(byte[] bytes, int offset, int count) throws IOException { - return updateBytesRead(super.read(bytes, offset, count)); - } - - public long getTotalRawBytesRead() { - return bytesRead; - } - } - - @Override - public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - if (action.equals("upload") || action.equals("download")) { - String source = args.getString(0); - String target = args.getString(1); - - if (action.equals("upload")) { - upload(source, target, args, callbackContext); - } else { - download(source, target, args, callbackContext); - } - return true; - } else if (action.equals("abort")) { - String objectId = args.getString(0); - abort(objectId); - callbackContext.success(); - return true; - } - return false; - } - - private static void addHeadersToRequest(URLConnection connection, JSONObject headers) { - try { - for (Iterator iter = headers.keys(); iter.hasNext(); ) { - /* RFC 2616 says that non-ASCII characters and control - * characters are not allowed in header names or values. - * Additionally, spaces are not allowed in header names. - * RFC 2046 Quoted-printable encoding may be used to encode - * arbitrary characters, but we donon- not do that encoding here. - */ - String headerKey = iter.next().toString(); - String cleanHeaderKey = headerKey.replaceAll("\\n","") - .replaceAll("\\s+","") - .replaceAll(":", "") - .replaceAll("[^\\x20-\\x7E]+", ""); - - JSONArray headerValues = headers.optJSONArray(headerKey); - if (headerValues == null) { - headerValues = new JSONArray(); - - /* RFC 2616 also says that any amount of consecutive linear - * whitespace within a header value can be replaced with a - * single space character, without affecting the meaning of - * that value. - */ - - String headerValue = headers.getString(headerKey); - String finalValue = headerValue.replaceAll("\\s+", " ").replaceAll("\\n"," ").replaceAll("[^\\x20-\\x7E]+", " "); - headerValues.put(finalValue); - } - - //Use the clean header key, not the one that we passed in - connection.setRequestProperty(cleanHeaderKey, headerValues.getString(0)); - for (int i = 1; i < headerValues.length(); ++i) { - connection.addRequestProperty(headerKey, headerValues.getString(i)); - } - } - } catch (JSONException e1) { - // No headers to be manipulated! - } - } - - private String getCookies(final String target) { - boolean gotCookie = false; - String cookie = null; - Class webViewClass = webView.getClass(); - try { - Method gcmMethod = webViewClass.getMethod("getCookieManager"); - Class iccmClass = gcmMethod.getReturnType(); - Method gcMethod = iccmClass.getMethod("getCookie", String.class); - - cookie = (String)gcMethod.invoke( - iccmClass.cast( - gcmMethod.invoke(webView) - ), target); - - gotCookie = true; - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } catch (ClassCastException e) { - } - - if (!gotCookie && CookieManager.getInstance() != null) { - cookie = CookieManager.getInstance().getCookie(target); - } - - return cookie; - } - - /** - * Uploads the specified file to the server URL provided using an HTTP multipart request. - * @param source Full path of the file on the file system - * @param target URL of the server to receive the file - * @param args JSON Array of args - * @param callbackContext callback id for optional progress reports - * - * args[2] fileKey Name of file request parameter - * args[3] fileName File name to be used on server - * args[4] mimeType Describes file content type - * args[5] params key:value pairs of user-defined parameters - * @return FileUploadResult containing result of upload request - */ - private void upload(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException { - Log.d(LOG_TAG, "upload " + source + " to " + target); - - // Setup the options - final String fileKey = getArgument(args, 2, "file"); - final String fileName = getArgument(args, 3, "image.jpg"); - final String mimeType = getArgument(args, 4, "image/jpeg"); - final JSONObject params = args.optJSONObject(5) == null ? new JSONObject() : args.optJSONObject(5); - final boolean trustEveryone = args.optBoolean(6); - // Always use chunked mode unless set to false as per API - final boolean chunkedMode = args.optBoolean(7) || args.isNull(7); - // Look for headers on the params map for backwards compatibility with older Cordova versions. - final JSONObject headers = args.optJSONObject(8) == null ? params.optJSONObject("headers") : args.optJSONObject(8); - final String objectId = args.getString(9); - final String httpMethod = getArgument(args, 10, "POST"); - - final CordovaResourceApi resourceApi = webView.getResourceApi(); - - Log.d(LOG_TAG, "fileKey: " + fileKey); - Log.d(LOG_TAG, "fileName: " + fileName); - Log.d(LOG_TAG, "mimeType: " + mimeType); - Log.d(LOG_TAG, "params: " + params); - Log.d(LOG_TAG, "trustEveryone: " + trustEveryone); - Log.d(LOG_TAG, "chunkedMode: " + chunkedMode); - Log.d(LOG_TAG, "headers: " + headers); - Log.d(LOG_TAG, "objectId: " + objectId); - Log.d(LOG_TAG, "httpMethod: " + httpMethod); - - final Uri targetUri = resourceApi.remapUri(Uri.parse(target)); - // Accept a path or a URI for the source. - Uri tmpSrc = Uri.parse(source); - final Uri sourceUri = resourceApi.remapUri( - tmpSrc.getScheme() != null ? tmpSrc : Uri.fromFile(new File(source))); - - int uriType = CordovaResourceApi.getUriType(targetUri); - final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS; - if (uriType != CordovaResourceApi.URI_TYPE_HTTP && !useHttps) { - JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target, null, 0, null); - Log.e(LOG_TAG, "Unsupported URI: " + targetUri); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - final RequestContext context = new RequestContext(source, target, callbackContext); - synchronized (activeRequests) { - activeRequests.put(objectId, context); - } - - cordova.getThreadPool().execute(new Runnable() { - public void run() { - if (context.aborted) { - return; - } - HttpURLConnection conn = null; - HostnameVerifier oldHostnameVerifier = null; - SSLSocketFactory oldSocketFactory = null; - int totalBytes = 0; - int fixedLength = -1; - try { - // Create return object - FileUploadResult result = new FileUploadResult(); - FileProgressResult progress = new FileProgressResult(); - - //------------------ CLIENT REQUEST - // Open a HTTP connection to the URL based on protocol - conn = resourceApi.createHttpConnection(targetUri); - if (useHttps && trustEveryone) { - // Setup the HTTPS connection class to trust everyone - HttpsURLConnection https = (HttpsURLConnection)conn; - oldSocketFactory = trustAllHosts(https); - // Save the current hostnameVerifier - oldHostnameVerifier = https.getHostnameVerifier(); - // Setup the connection not to verify hostnames - https.setHostnameVerifier(DO_NOT_VERIFY); - } - - // Allow Inputs - conn.setDoInput(true); - - // Allow Outputs - conn.setDoOutput(true); - - // Don't use a cached copy. - conn.setUseCaches(false); - - // Use a post method. - conn.setRequestMethod(httpMethod); - - // if we specified a Content-Type header, don't do multipart form upload - boolean multipartFormUpload = (headers == null) || !headers.has("Content-Type"); - if (multipartFormUpload) { - conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); - } - - // Set the cookies on the response - String cookie = getCookies(target); - - if (cookie != null) { - conn.setRequestProperty("Cookie", cookie); - } - - // Handle the other headers - if (headers != null) { - addHeadersToRequest(conn, headers); - } - - /* - * Store the non-file portions of the multipart data as a string, so that we can add it - * to the contentSize, since it is part of the body of the HTTP request. - */ - StringBuilder beforeData = new StringBuilder(); - try { - for (Iterator iter = params.keys(); iter.hasNext();) { - Object key = iter.next(); - if(!String.valueOf(key).equals("headers")) - { - beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END); - beforeData.append("Content-Disposition: form-data; name=\"").append(key.toString()).append('"'); - beforeData.append(LINE_END).append(LINE_END); - beforeData.append(params.getString(key.toString())); - beforeData.append(LINE_END); - } - } - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - - beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END); - beforeData.append("Content-Disposition: form-data; name=\"").append(fileKey).append("\";"); - beforeData.append(" filename=\"").append(fileName).append('"').append(LINE_END); - beforeData.append("Content-Type: ").append(mimeType).append(LINE_END).append(LINE_END); - byte[] beforeDataBytes = beforeData.toString().getBytes("UTF-8"); - byte[] tailParamsBytes = (LINE_END + LINE_START + BOUNDARY + LINE_START + LINE_END).getBytes("UTF-8"); - - - // Get a input stream of the file on the phone - OpenForReadResult readResult = resourceApi.openForRead(sourceUri); - - int stringLength = beforeDataBytes.length + tailParamsBytes.length; - if (readResult.length >= 0) { - fixedLength = (int)readResult.length; - if (multipartFormUpload) - fixedLength += stringLength; - progress.setLengthComputable(true); - progress.setTotal(fixedLength); - } - Log.d(LOG_TAG, "Content Length: " + fixedLength); - // setFixedLengthStreamingMode causes and OutOfMemoryException on pre-Froyo devices. - // http://code.google.com/p/android/issues/detail?id=3164 - // It also causes OOM if HTTPS is used, even on newer devices. - boolean useChunkedMode = chunkedMode && (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO || useHttps); - useChunkedMode = useChunkedMode || (fixedLength == -1); - - if (useChunkedMode) { - conn.setChunkedStreamingMode(MAX_BUFFER_SIZE); - // Although setChunkedStreamingMode sets this header, setting it explicitly here works - // around an OutOfMemoryException when using https. - conn.setRequestProperty("Transfer-Encoding", "chunked"); - } else { - conn.setFixedLengthStreamingMode(fixedLength); - } - - conn.connect(); - - OutputStream sendStream = null; - try { - sendStream = conn.getOutputStream(); - synchronized (context) { - if (context.aborted) { - return; - } - context.connection = conn; - } - - if (multipartFormUpload) { - //We don't want to change encoding, we just want this to write for all Unicode. - sendStream.write(beforeDataBytes); - totalBytes += beforeDataBytes.length; - } - - // create a buffer of maximum size - int bytesAvailable = readResult.inputStream.available(); - int bufferSize = Math.min(bytesAvailable, MAX_BUFFER_SIZE); - byte[] buffer = new byte[bufferSize]; - - // read file and write it into form... - int bytesRead = readResult.inputStream.read(buffer, 0, bufferSize); - - long prevBytesRead = 0; - while (bytesRead > 0) { - totalBytes += bytesRead; - result.setBytesSent(totalBytes); - sendStream.write(buffer, 0, bytesRead); - if (totalBytes > prevBytesRead + 102400) { - prevBytesRead = totalBytes; - Log.d(LOG_TAG, "Uploaded " + totalBytes + " of " + fixedLength + " bytes"); - } - bytesAvailable = readResult.inputStream.available(); - bufferSize = Math.min(bytesAvailable, MAX_BUFFER_SIZE); - bytesRead = readResult.inputStream.read(buffer, 0, bufferSize); - - // Send a progress event. - progress.setLoaded(totalBytes); - PluginResult progressResult = new PluginResult(PluginResult.Status.OK, progress.toJSONObject()); - progressResult.setKeepCallback(true); - context.sendPluginResult(progressResult); - } - - if (multipartFormUpload) { - // send multipart form data necessary after file data... - sendStream.write(tailParamsBytes); - totalBytes += tailParamsBytes.length; - } - sendStream.flush(); - } finally { - safeClose(readResult.inputStream); - safeClose(sendStream); - } - synchronized (context) { - context.connection = null; - } - Log.d(LOG_TAG, "Sent " + totalBytes + " of " + fixedLength); - - //------------------ read the SERVER RESPONSE - String responseString; - int responseCode = conn.getResponseCode(); - Log.d(LOG_TAG, "response code: " + responseCode); - Log.d(LOG_TAG, "response headers: " + conn.getHeaderFields()); - TrackingInputStream inStream = null; - try { - inStream = getInputStream(conn); - synchronized (context) { - if (context.aborted) { - return; - } - context.connection = conn; - } - - ByteArrayOutputStream out = new ByteArrayOutputStream(Math.max(1024, conn.getContentLength())); - byte[] buffer = new byte[1024]; - int bytesRead = 0; - // write bytes to file - while ((bytesRead = inStream.read(buffer)) > 0) { - out.write(buffer, 0, bytesRead); - } - responseString = out.toString("UTF-8"); - } finally { - synchronized (context) { - context.connection = null; - } - safeClose(inStream); - } - - Log.d(LOG_TAG, "got response from server"); - Log.d(LOG_TAG, responseString.substring(0, Math.min(256, responseString.length()))); - - // send request and retrieve response - result.setResponseCode(responseCode); - result.setResponse(responseString); - - context.sendPluginResult(new PluginResult(PluginResult.Status.OK, result.toJSONObject())); - } catch (FileNotFoundException e) { - JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, conn, e); - Log.e(LOG_TAG, error.toString(), e); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } catch (IOException e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn, e); - Log.e(LOG_TAG, error.toString(), e); - Log.e(LOG_TAG, "Failed after uploading " + totalBytes + " of " + fixedLength + " bytes."); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - context.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - } catch (Throwable t) { - // Shouldn't happen, but will - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn, t); - Log.e(LOG_TAG, error.toString(), t); - context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - } finally { - synchronized (activeRequests) { - activeRequests.remove(objectId); - } - - if (conn != null) { - // Revert back to the proper verifier and socket factories - // Revert back to the proper verifier and socket factories - if (trustEveryone && useHttps) { - HttpsURLConnection https = (HttpsURLConnection) conn; - https.setHostnameVerifier(oldHostnameVerifier); - https.setSSLSocketFactory(oldSocketFactory); - } - } - } - } - }); - } - - private static void safeClose(Closeable stream) { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - } - } - } - - private static TrackingInputStream getInputStream(URLConnection conn) throws IOException { - String encoding = conn.getContentEncoding(); - if (encoding != null && encoding.equalsIgnoreCase("gzip")) { - return new TrackingGZIPInputStream(new ExposedGZIPInputStream(conn.getInputStream())); - } - return new SimpleTrackingInputStream(conn.getInputStream()); - } - - // always verify the host - don't check for certificate - private static final HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - // Create a trust manager that does not validate certificate chains - private static final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[] {}; - } - - public void checkClientTrusted(X509Certificate[] chain, - String authType) throws CertificateException { - } - - public void checkServerTrusted(X509Certificate[] chain, - String authType) throws CertificateException { - } - } }; - - /** - * This function will install a trust manager that will blindly trust all SSL - * certificates. The reason this code is being added is to enable developers - * to do development using self signed SSL certificates on their web server. - * - * The standard HttpsURLConnection class will throw an exception on self - * signed certificates if this code is not run. - */ - private static SSLSocketFactory trustAllHosts(HttpsURLConnection connection) { - // Install the all-trusting trust manager - SSLSocketFactory oldFactory = connection.getSSLSocketFactory(); - try { - // Install our all trusting manager - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - SSLSocketFactory newFactory = sc.getSocketFactory(); - connection.setSSLSocketFactory(newFactory); - } catch (Exception e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - return oldFactory; - } - - private static JSONObject createFileTransferError(int errorCode, String source, String target, URLConnection connection, Throwable throwable) { - - int httpStatus = 0; - StringBuilder bodyBuilder = new StringBuilder(); - String body = null; - if (connection != null) { - try { - if (connection instanceof HttpURLConnection) { - httpStatus = ((HttpURLConnection)connection).getResponseCode(); - InputStream err = ((HttpURLConnection) connection).getErrorStream(); - if(err != null) - { - BufferedReader reader = new BufferedReader(new InputStreamReader(err, "UTF-8")); - try { - String line = reader.readLine(); - while(line != null) { - bodyBuilder.append(line); - line = reader.readLine(); - if(line != null) { - bodyBuilder.append('\n'); - } - } - body = bodyBuilder.toString(); - } finally { - reader.close(); - } - } - } - // IOException can leave connection object in a bad state, so catch all exceptions. - } catch (Throwable e) { - Log.w(LOG_TAG, "Error getting HTTP status code from connection.", e); - } - } - - return createFileTransferError(errorCode, source, target, body, httpStatus, throwable); - } - - /** - * Create an error object based on the passed in errorCode - * @param errorCode the error - * @return JSONObject containing the error - */ - private static JSONObject createFileTransferError(int errorCode, String source, String target, String body, Integer httpStatus, Throwable throwable) { - JSONObject error = null; - try { - error = new JSONObject(); - error.put("code", errorCode); - error.put("source", source); - error.put("target", target); - if(body != null) - { - error.put("body", body); - } - if (httpStatus != null) { - error.put("http_status", httpStatus); - } - if (throwable != null) { - String msg = throwable.getMessage(); - if (msg == null || "".equals(msg)) { - msg = throwable.toString(); - } - error.put("exception", msg); - } - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - } - return error; - } - - /** - * Convenience method to read a parameter from the list of JSON args. - * @param args the args passed to the Plugin - * @param position the position to retrieve the arg from - * @param defaultString the default to be used if the arg does not exist - * @return String with the retrieved value - */ - private static String getArgument(JSONArray args, int position, String defaultString) { - String arg = defaultString; - if (args.length() > position) { - arg = args.optString(position); - if (arg == null || "null".equals(arg)) { - arg = defaultString; - } - } - return arg; - } - - /** - * Downloads a file form a given URL and saves it to the specified directory. - * - * @param source URL of the server to receive the file - * @param target Full path of the file on the file system - */ - private void download(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException { - Log.d(LOG_TAG, "download " + source + " to " + target); - - final CordovaResourceApi resourceApi = webView.getResourceApi(); - - final boolean trustEveryone = args.optBoolean(2); - final String objectId = args.getString(3); - final JSONObject headers = args.optJSONObject(4); - - final Uri sourceUri = resourceApi.remapUri(Uri.parse(source)); - // Accept a path or a URI for the source. - Uri tmpTarget = Uri.parse(target); - final Uri targetUri = resourceApi.remapUri( - tmpTarget.getScheme() != null ? tmpTarget : Uri.fromFile(new File(target))); - - int uriType = CordovaResourceApi.getUriType(sourceUri); - final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS; - final boolean isLocalTransfer = !useHttps && uriType != CordovaResourceApi.URI_TYPE_HTTP; - if (uriType == CordovaResourceApi.URI_TYPE_UNKNOWN) { - JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target, null, 0, null); - Log.e(LOG_TAG, "Unsupported URI: " + sourceUri); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - /* This code exists for compatibility between 3.x and 4.x versions of Cordova. - * Previously the CordovaWebView class had a method, getWhitelist, which would - * return a Whitelist object. Since the fixed whitelist is removed in Cordova 4.x, - * the correct call now is to shouldAllowRequest from the plugin manager. - */ - Boolean shouldAllowRequest = null; - if (isLocalTransfer) { - shouldAllowRequest = true; - } - if (shouldAllowRequest == null) { - try { - Method gwl = webView.getClass().getMethod("getWhitelist"); - Whitelist whitelist = (Whitelist)gwl.invoke(webView); - shouldAllowRequest = whitelist.isUrlWhiteListed(source); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - } - if (shouldAllowRequest == null) { - try { - Method gpm = webView.getClass().getMethod("getPluginManager"); - PluginManager pm = (PluginManager)gpm.invoke(webView); - Method san = pm.getClass().getMethod("shouldAllowRequest", String.class); - shouldAllowRequest = (Boolean)san.invoke(pm, source); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - } - - if (!Boolean.TRUE.equals(shouldAllowRequest)) { - Log.w(LOG_TAG, "Source URL is not in white list: '" + source + "'"); - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, null, 401, null); - callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); - return; - } - - - final RequestContext context = new RequestContext(source, target, callbackContext); - synchronized (activeRequests) { - activeRequests.put(objectId, context); - } - - cordova.getThreadPool().execute(new Runnable() { - public void run() { - if (context.aborted) { - return; - } - HttpURLConnection connection = null; - HostnameVerifier oldHostnameVerifier = null; - SSLSocketFactory oldSocketFactory = null; - File file = null; - PluginResult result = null; - TrackingInputStream inputStream = null; - boolean cached = false; - - OutputStream outputStream = null; - try { - OpenForReadResult readResult = null; - - file = resourceApi.mapUriToFile(targetUri); - context.targetFile = file; - - Log.d(LOG_TAG, "Download file:" + sourceUri); - - FileProgressResult progress = new FileProgressResult(); - - if (isLocalTransfer) { - readResult = resourceApi.openForRead(sourceUri); - if (readResult.length != -1) { - progress.setLengthComputable(true); - progress.setTotal(readResult.length); - } - inputStream = new SimpleTrackingInputStream(readResult.inputStream); - } else { - // connect to server - // Open a HTTP connection to the URL based on protocol - connection = resourceApi.createHttpConnection(sourceUri); - if (useHttps && trustEveryone) { - // Setup the HTTPS connection class to trust everyone - HttpsURLConnection https = (HttpsURLConnection)connection; - oldSocketFactory = trustAllHosts(https); - // Save the current hostnameVerifier - oldHostnameVerifier = https.getHostnameVerifier(); - // Setup the connection not to verify hostnames - https.setHostnameVerifier(DO_NOT_VERIFY); - } - - connection.setRequestMethod("GET"); - - // TODO: Make OkHttp use this CookieManager by default. - String cookie = getCookies(sourceUri.toString()); - - if(cookie != null) - { - connection.setRequestProperty("cookie", cookie); - } - - // This must be explicitly set for gzip progress tracking to work. - connection.setRequestProperty("Accept-Encoding", "gzip"); - - // Handle the other headers - if (headers != null) { - addHeadersToRequest(connection, headers); - } - - connection.connect(); - if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) { - cached = true; - connection.disconnect(); - Log.d(LOG_TAG, "Resource not modified: " + source); - JSONObject error = createFileTransferError(NOT_MODIFIED_ERR, source, target, connection, null); - result = new PluginResult(PluginResult.Status.ERROR, error); - } else { - if (connection.getContentEncoding() == null || connection.getContentEncoding().equalsIgnoreCase("gzip")) { - // Only trust content-length header if we understand - // the encoding -- identity or gzip - if (connection.getContentLength() != -1) { - progress.setLengthComputable(true); - progress.setTotal(connection.getContentLength()); - } - } - inputStream = getInputStream(connection); - } - } - - if (!cached) { - try { - synchronized (context) { - if (context.aborted) { - return; - } - context.connection = connection; - } - - // write bytes to file - byte[] buffer = new byte[MAX_BUFFER_SIZE]; - int bytesRead = 0; - outputStream = resourceApi.openOutputStream(targetUri); - while ((bytesRead = inputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, bytesRead); - // Send a progress event. - progress.setLoaded(inputStream.getTotalRawBytesRead()); - PluginResult progressResult = new PluginResult(PluginResult.Status.OK, progress.toJSONObject()); - progressResult.setKeepCallback(true); - context.sendPluginResult(progressResult); - } - } finally { - synchronized (context) { - context.connection = null; - } - safeClose(inputStream); - safeClose(outputStream); - } - - Log.d(LOG_TAG, "Saved file: " + target); - - - // create FileEntry object - Class webViewClass = webView.getClass(); - PluginManager pm = null; - try { - Method gpm = webViewClass.getMethod("getPluginManager"); - pm = (PluginManager) gpm.invoke(webView); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - if (pm == null) { - try { - Field pmf = webViewClass.getField("pluginManager"); - pm = (PluginManager)pmf.get(webView); - } catch (NoSuchFieldException e) { - } catch (IllegalAccessException e) { - } - } - file = resourceApi.mapUriToFile(targetUri); - context.targetFile = file; - FileUtils filePlugin = (FileUtils) pm.getPlugin("File"); - if (filePlugin != null) { - JSONObject fileEntry = filePlugin.getEntryForFile(file); - if (fileEntry != null) { - result = new PluginResult(PluginResult.Status.OK, fileEntry); - } else { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection, null); - Log.e(LOG_TAG, "File plugin cannot represent download path"); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } - } else { - Log.e(LOG_TAG, "File plugin not found; cannot save downloaded file"); - result = new PluginResult(PluginResult.Status.ERROR, "File plugin not found; cannot save downloaded file"); - } - } - } catch (FileNotFoundException e) { - JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection, e); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } catch (IOException e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection, e); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - result = new PluginResult(PluginResult.Status.JSON_EXCEPTION); - } catch (Throwable e) { - JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection, e); - Log.e(LOG_TAG, error.toString(), e); - result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); - } finally { - synchronized (activeRequests) { - activeRequests.remove(objectId); - } - - if (connection != null) { - // Revert back to the proper verifier and socket factories - if (trustEveryone && useHttps) { - HttpsURLConnection https = (HttpsURLConnection) connection; - https.setHostnameVerifier(oldHostnameVerifier); - https.setSSLSocketFactory(oldSocketFactory); - } - } - - if (result == null) { - result = new PluginResult(PluginResult.Status.ERROR, createFileTransferError(CONNECTION_ERR, source, target, connection, null)); - } - // Remove incomplete download. - if (!cached && result.getStatus() != PluginResult.Status.OK.ordinal() && file != null) { - file.delete(); - } - context.sendPluginResult(result); - } - } - }); - } - - /** - * Abort an ongoing upload or download. - */ - private void abort(String objectId) { - final RequestContext context; - synchronized (activeRequests) { - context = activeRequests.remove(objectId); - } - if (context != null) { - // Closing the streams can block, so execute on a background thread. - cordova.getThreadPool().execute(new Runnable() { - public void run() { - synchronized (context) { - File file = context.targetFile; - if (file != null) { - file.delete(); - } - // Trigger the abort callback immediately to minimize latency between it and abort() being called. - JSONObject error = createFileTransferError(ABORTED_ERR, context.source, context.target, null, -1, null); - context.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, error)); - context.aborted = true; - if (context.connection != null) { - try { - context.connection.disconnect(); - } catch (Exception e) { - Log.e(LOG_TAG, "CB-8431 Catch workaround for fatal exception", e); - } - } - } - } - }); - } - } -} diff --git a/plugins/cordova-plugin-file-transfer/src/android/FileUploadResult.java b/plugins/cordova-plugin-file-transfer/src/android/FileUploadResult.java deleted file mode 100644 index c24ea78..0000000 --- a/plugins/cordova-plugin-file-transfer/src/android/FileUploadResult.java +++ /dev/null @@ -1,73 +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.filetransfer; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Encapsulates the result and/or status of uploading a file to a remote server. - */ -public class FileUploadResult { - - private long bytesSent = 0; // bytes sent - private int responseCode = -1; // HTTP response code - private String response = null; // HTTP response - private String objectId = null; // FileTransfer object id - - public long getBytesSent() { - return bytesSent; - } - - public void setBytesSent(long bytes) { - this.bytesSent = bytes; - } - - public int getResponseCode() { - return responseCode; - } - - public void setResponseCode(int responseCode) { - this.responseCode = responseCode; - } - - public String getResponse() { - return response; - } - - public void setResponse(String response) { - this.response = response; - } - - public String getObjectId() { - return objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public JSONObject toJSONObject() throws JSONException { - return new JSONObject( - "{bytesSent:" + bytesSent + - ",responseCode:" + responseCode + - ",response:" + JSONObject.quote(response) + - ",objectId:" + JSONObject.quote(objectId) + "}"); - } -} diff --git a/plugins/cordova-plugin-file-transfer/src/ios/CDVFileTransfer.h b/plugins/cordova-plugin-file-transfer/src/ios/CDVFileTransfer.h deleted file mode 100644 index bb5fa13..0000000 --- a/plugins/cordova-plugin-file-transfer/src/ios/CDVFileTransfer.h +++ /dev/null @@ -1,88 +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. - */ - -#import -#import -#import "CDVFile.h" - -enum CDVFileTransferError { - FILE_NOT_FOUND_ERR = 1, - INVALID_URL_ERR = 2, - CONNECTION_ERR = 3, - CONNECTION_ABORTED = 4, - NOT_MODIFIED = 5 -}; -typedef int CDVFileTransferError; - -enum CDVFileTransferDirection { - CDV_TRANSFER_UPLOAD = 1, - CDV_TRANSFER_DOWNLOAD = 2, -}; -typedef int CDVFileTransferDirection; - -// Magic value within the options dict used to set a cookie. -extern NSString* const kOptionsKeyCookie; - -@interface CDVFileTransfer : CDVPlugin {} - -- (void)upload:(CDVInvokedUrlCommand*)command; -- (void)download:(CDVInvokedUrlCommand*)command; -- (NSString*)escapePathComponentForUrlString:(NSString*)urlString; - -// Visible for testing. -- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData; -- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target; - -- (NSMutableDictionary*)createFileTransferError:(int)code - AndSource:(NSString*)source - AndTarget:(NSString*)target - AndHttpStatus:(int)httpStatus - AndBody:(NSString*)body; -@property (nonatomic, strong) NSOperationQueue* queue; -@property (readonly) NSMutableDictionary* activeTransfers; -@end - -@class CDVFileTransferEntityLengthRequest; - -@interface CDVFileTransferDelegate : NSObject {} - -- (void)updateBytesExpected:(long long)newBytesExpected; -- (void)cancelTransfer:(NSURLConnection*)connection; - -@property (strong) NSMutableData* responseData; // atomic -@property (nonatomic, strong) NSDictionary* responseHeaders; -@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTaskID; -@property (nonatomic, strong) CDVFileTransfer* command; -@property (nonatomic, assign) CDVFileTransferDirection direction; -@property (nonatomic, strong) NSURLConnection* connection; -@property (nonatomic, copy) NSString* callbackId; -@property (nonatomic, copy) NSString* objectId; -@property (nonatomic, copy) NSString* source; -@property (nonatomic, copy) NSString* target; -@property (nonatomic, copy) NSURL* targetURL; -@property (nonatomic, copy) NSString* mimeType; -@property (assign) int responseCode; // atomic -@property (nonatomic, assign) long long bytesTransfered; -@property (nonatomic, assign) long long bytesExpected; -@property (nonatomic, assign) BOOL trustAllHosts; -@property (strong) NSFileHandle* targetFileHandle; -@property (nonatomic, strong) CDVFileTransferEntityLengthRequest* entityLengthRequest; -@property (nonatomic, strong) CDVFile *filePlugin; - -@end diff --git a/plugins/cordova-plugin-file-transfer/src/ios/CDVFileTransfer.m b/plugins/cordova-plugin-file-transfer/src/ios/CDVFileTransfer.m deleted file mode 100644 index 4775a6d..0000000 --- a/plugins/cordova-plugin-file-transfer/src/ios/CDVFileTransfer.m +++ /dev/null @@ -1,845 +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. - */ - -#import -#import "CDVFileTransfer.h" -#import "CDVLocalFilesystem.h" - -#import -#import -#import -#import - -#ifndef DLog -#ifdef DEBUG - #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) -#else - #define DLog(...) -#endif -#endif - -@interface CDVFileTransfer () -// Sets the requests headers for the request. -- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req; -// Creates a delegate to handle an upload. -- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command; -// Creates an NSData* for the file for the given upload arguments. -- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command; -@end - -// Buffer size to use for streaming uploads. -static const NSUInteger kStreamBufferSize = 32768; -// Magic value within the options dict used to set a cookie. -NSString* const kOptionsKeyCookie = @"__cookie"; -// Form boundary for multi-part requests. -NSString* const kFormBoundary = @"+++++org.apache.cordova.formBoundary"; - -// Writes the given data to the stream in a blocking way. -// If successful, returns bytesToWrite. -// If the stream was closed on the other end, returns 0. -// If there was an error, returns -1. -static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) -{ - UInt8* bytes = (UInt8*)[data bytes]; - long long bytesToWrite = [data length]; - long long totalBytesWritten = 0; - - while (totalBytesWritten < bytesToWrite) { - CFIndex result = CFWriteStreamWrite(stream, - bytes + totalBytesWritten, - bytesToWrite - totalBytesWritten); - if (result < 0) { - CFStreamError error = CFWriteStreamGetError(stream); - NSLog(@"WriteStreamError domain: %ld error: %ld", error.domain, (long)error.error); - return result; - } else if (result == 0) { - return result; - } - totalBytesWritten += result; - } - - return totalBytesWritten; -} - -@implementation CDVFileTransfer -@synthesize activeTransfers; - -- (void)pluginInitialize { - activeTransfers = [[NSMutableDictionary alloc] init]; -} - -- (NSString*)escapePathComponentForUrlString:(NSString*)urlString -{ - NSRange schemeAndHostRange = [urlString rangeOfString:@"://.*?/" options:NSRegularExpressionSearch]; - - if (schemeAndHostRange.length == 0) { - return urlString; - } - - NSInteger schemeAndHostEndIndex = NSMaxRange(schemeAndHostRange); - NSString* schemeAndHost = [urlString substringToIndex:schemeAndHostEndIndex]; - NSString* pathComponent = [urlString substringFromIndex:schemeAndHostEndIndex]; - pathComponent = [pathComponent stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; - - return [schemeAndHost stringByAppendingString:pathComponent]; -} - -- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req -{ - [req setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"]; - - NSString* userAgent = [self.commandDelegate userAgent]; - if (userAgent) { - [req setValue:userAgent forHTTPHeaderField:@"User-Agent"]; - } - - for (NSString* headerName in headers) { - id value = [headers objectForKey:headerName]; - if (!value || (value == [NSNull null])) { - value = @"null"; - } - - // First, remove an existing header if one exists. - [req setValue:nil forHTTPHeaderField:headerName]; - - if (![value isKindOfClass:[NSArray class]]) { - value = [NSArray arrayWithObject:value]; - } - - // Then, append all header values. - for (id __strong subValue in value) { - // Convert from an NSNumber -> NSString. - if ([subValue respondsToSelector:@selector(stringValue)]) { - subValue = [subValue stringValue]; - } - if ([subValue isKindOfClass:[NSString class]]) { - [req addValue:subValue forHTTPHeaderField:headerName]; - } - } - } -} - -- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData -{ - // arguments order from js: [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode] - // however, params is a JavaScript object and during marshalling is put into the options dict, - // thus debug and chunkedMode are the 6th and 7th arguments - NSString* target = [command argumentAtIndex:0]; - NSString* server = [command argumentAtIndex:1]; - NSString* fileKey = [command argumentAtIndex:2 withDefault:@"file"]; - NSString* fileName = [command argumentAtIndex:3 withDefault:@"image.jpg"]; - NSString* mimeType = [command argumentAtIndex:4 withDefault:@"image/jpeg"]; - NSDictionary* options = [command argumentAtIndex:5 withDefault:nil]; - // BOOL trustAllHosts = [[command argumentAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs - BOOL chunkedMode = [[command argumentAtIndex:7 withDefault:[NSNumber numberWithBool:YES]] boolValue]; - NSDictionary* headers = [command argumentAtIndex:8 withDefault:nil]; - // Allow alternative http method, default to POST. JS side checks - // for allowed methods, currently PUT or POST (forces POST for - // unrecognised values) - NSString* httpMethod = [command argumentAtIndex:10 withDefault:@"POST"]; - CDVPluginResult* result = nil; - CDVFileTransferError errorCode = 0; - - // NSURL does not accepts URLs with spaces in the path. We escape the path in order - // to be more lenient. - NSURL* url = [NSURL URLWithString:server]; - - if (!url) { - errorCode = INVALID_URL_ERR; - NSLog(@"File Transfer Error: Invalid server URL %@", server); - } else if (!fileData) { - errorCode = FILE_NOT_FOUND_ERR; - } - - if (errorCode > 0) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:target AndTarget:server]]; - [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; - return nil; - } - - NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url]; - - [req setHTTPMethod:httpMethod]; - - // Magic value to set a cookie - if ([options objectForKey:kOptionsKeyCookie]) { - [req setValue:[options objectForKey:kOptionsKeyCookie] forHTTPHeaderField:@"Cookie"]; - [req setHTTPShouldHandleCookies:NO]; - } - - // if we specified a Content-Type header, don't do multipart form upload - BOOL multipartFormUpload = [headers objectForKey:@"Content-Type"] == nil; - if (multipartFormUpload) { - NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kFormBoundary]; - [req setValue:contentType forHTTPHeaderField:@"Content-Type"]; - } - [self applyRequestHeaders:headers toRequest:req]; - - NSData* formBoundaryData = [[NSString stringWithFormat:@"--%@\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding]; - NSMutableData* postBodyBeforeFile = [NSMutableData data]; - - for (NSString* key in options) { - id val = [options objectForKey:key]; - if (!val || (val == [NSNull null]) || [key isEqualToString:kOptionsKeyCookie]) { - continue; - } - // if it responds to stringValue selector (eg NSNumber) get the NSString - if ([val respondsToSelector:@selector(stringValue)]) { - val = [val stringValue]; - } - // finally, check whether it is a NSString (for dataUsingEncoding selector below) - if (![val isKindOfClass:[NSString class]]) { - continue; - } - - [postBodyBeforeFile appendData:formBoundaryData]; - [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]]; - [postBodyBeforeFile appendData:[val dataUsingEncoding:NSUTF8StringEncoding]]; - [postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding : NSUTF8StringEncoding]]; - } - - [postBodyBeforeFile appendData:formBoundaryData]; - [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]]; - if (mimeType != nil) { - [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]]; - } - [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %ld\r\n\r\n", (long)[fileData length]] dataUsingEncoding:NSUTF8StringEncoding]]; - - DLog(@"fileData length: %d", [fileData length]); - NSData* postBodyAfterFile = [[NSString stringWithFormat:@"\r\n--%@--\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding]; - - long long totalPayloadLength = [fileData length]; - if (multipartFormUpload) { - totalPayloadLength += [postBodyBeforeFile length] + [postBodyAfterFile length]; - } - - [req setValue:[[NSNumber numberWithLongLong:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"]; - - if (chunkedMode) { - CFReadStreamRef readStream = NULL; - CFWriteStreamRef writeStream = NULL; - CFStreamCreateBoundPair(NULL, &readStream, &writeStream, kStreamBufferSize); - [req setHTTPBodyStream:CFBridgingRelease(readStream)]; - - [self.commandDelegate runInBackground:^{ - if (CFWriteStreamOpen(writeStream)) { - if (multipartFormUpload) { - NSData* chunks[] = { postBodyBeforeFile, fileData, postBodyAfterFile }; - int numChunks = sizeof(chunks) / sizeof(chunks[0]); - - for (int i = 0; i < numChunks; ++i) { - // Allow uploading of an empty file - if (chunks[i].length == 0) { - continue; - } - - CFIndex result = WriteDataToStream(chunks[i], writeStream); - if (result <= 0) { - break; - } - } - } else { - WriteDataToStream(fileData, writeStream); - } - } else { - NSLog(@"FileTransfer: Failed to open writeStream"); - } - CFWriteStreamClose(writeStream); - CFRelease(writeStream); - }]; - } else { - if (multipartFormUpload) { - [postBodyBeforeFile appendData:fileData]; - [postBodyBeforeFile appendData:postBodyAfterFile]; - [req setHTTPBody:postBodyBeforeFile]; - } else { - [req setHTTPBody:fileData]; - } - } - return req; -} - -- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command -{ - NSString* source = [command argumentAtIndex:0]; - NSString* server = [command argumentAtIndex:1]; - BOOL trustAllHosts = [[command argumentAtIndex:6 withDefault:[NSNumber numberWithBool:NO]] boolValue]; // allow self-signed certs - NSString* objectId = [command argumentAtIndex:9]; - - CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init]; - - delegate.command = self; - delegate.callbackId = command.callbackId; - delegate.direction = CDV_TRANSFER_UPLOAD; - delegate.objectId = objectId; - delegate.source = source; - delegate.target = server; - delegate.trustAllHosts = trustAllHosts; - delegate.filePlugin = [self.commandDelegate getCommandInstance:@"File"]; - - return delegate; -} - -- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command -{ - NSString* source = (NSString*)[command argumentAtIndex:0]; - NSString* server = [command argumentAtIndex:1]; - NSError* __autoreleasing err = nil; - - if ([source hasPrefix:@"data:"] && [source rangeOfString:@"base64"].location != NSNotFound) { - NSRange commaRange = [source rangeOfString: @","]; - if (commaRange.location == NSNotFound) { - // Return error is there is no comma - __weak CDVFileTransfer* weakSelf = self; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[weakSelf createFileTransferError:INVALID_URL_ERR AndSource:source AndTarget:server]]; - [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId]; - return; - } - - if (commaRange.location + 1 > source.length - 1) { - // Init as an empty data - NSData *fileData = [[NSData alloc] init]; - [self uploadData:fileData command:command]; - return; - } - - NSData *fileData = [[NSData alloc] initWithBase64EncodedString:[source substringFromIndex:(commaRange.location + 1)] options:NSDataBase64DecodingIgnoreUnknownCharacters]; - [self uploadData:fileData command:command]; - return; - } - - CDVFilesystemURL *sourceURL = [CDVFilesystemURL fileSystemURLWithString:source]; - NSObject *fs; - if (sourceURL) { - // Try to get a CDVFileSystem which will handle this file. - // This requires talking to the current CDVFile plugin. - fs = [[self.commandDelegate getCommandInstance:@"File"] filesystemForURL:sourceURL]; - } - if (fs) { - __weak CDVFileTransfer* weakSelf = self; - [fs readFileAtURL:sourceURL start:0 end:-1 callback:^(NSData *fileData, NSString *mimeType, CDVFileError err) { - if (err) { - // We couldn't find the asset. Send the appropriate error. - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[weakSelf createFileTransferError:NOT_FOUND_ERR AndSource:source AndTarget:server]]; - [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId]; - } else { - [weakSelf uploadData:fileData command:command]; - } - }]; - return; - } else { - // Extract the path part out of a file: URL. - NSString* filePath = [source hasPrefix:@"/"] ? [source copy] : [(NSURL *)[NSURL URLWithString:source] path]; - if (filePath == nil) { - // We couldn't find the asset. Send the appropriate error. - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:NOT_FOUND_ERR AndSource:source AndTarget:server]]; - [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; - return; - } - - // Memory map the file so that it can be read efficiently even if it is large. - NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err]; - - if (err != nil) { - NSLog(@"Error opening file %@: %@", source, err); - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:NOT_FOUND_ERR AndSource:source AndTarget:server]]; - [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; - } else { - [self uploadData:fileData command:command]; - } - } -} - -- (void)upload:(CDVInvokedUrlCommand*)command -{ - // fileData and req are split into helper functions to ease the unit testing of delegateForUpload. - // First, get the file data. This method will call `uploadData:command`. - [self fileDataForUploadCommand:command]; -} - -- (void)uploadData:(NSData*)fileData command:(CDVInvokedUrlCommand*)command -{ - NSURLRequest* req = [self requestForUploadCommand:command fileData:fileData]; - - if (req == nil) { - return; - } - CDVFileTransferDelegate* delegate = [self delegateForUploadCommand:command]; - delegate.connection = [[NSURLConnection alloc] initWithRequest:req delegate:delegate startImmediately:NO]; - if (self.queue == nil) { - self.queue = [[NSOperationQueue alloc] init]; - } - [delegate.connection setDelegateQueue:self.queue]; - - // sets a background task ID for the transfer object. - delegate.backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - [delegate cancelTransfer:delegate.connection]; - }]; - - @synchronized (activeTransfers) { - activeTransfers[delegate.objectId] = delegate; - } - [delegate.connection start]; -} - -- (void)abort:(CDVInvokedUrlCommand*)command -{ - NSString* objectId = [command argumentAtIndex:0]; - - @synchronized (activeTransfers) { - CDVFileTransferDelegate* delegate = activeTransfers[objectId]; - if (delegate != nil) { - [delegate cancelTransfer:delegate.connection]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:CONNECTION_ABORTED AndSource:delegate.source AndTarget:delegate.target]]; - [self.commandDelegate sendPluginResult:result callbackId:delegate.callbackId]; - } - } -} - -- (void)download:(CDVInvokedUrlCommand*)command -{ - DLog(@"File Transfer downloading file..."); - NSString* source = [command argumentAtIndex:0]; - NSString* target = [command argumentAtIndex:1]; - BOOL trustAllHosts = [[command argumentAtIndex:2 withDefault:[NSNumber numberWithBool:NO]] boolValue]; // allow self-signed certs - NSString* objectId = [command argumentAtIndex:3]; - NSDictionary* headers = [command argumentAtIndex:4 withDefault:nil]; - - CDVPluginResult* result = nil; - CDVFileTransferError errorCode = 0; - - NSURL* targetURL; - - if ([target hasPrefix:@"/"]) { - /* Backwards-compatibility: - * Check here to see if it looks like the user passed in a raw filesystem path. (Perhaps they had the path saved, and were previously using it with the old version of File). If so, normalize it by removing empty path segments, and check with File to see if any of the installed filesystems will handle it. If so, then we will end up with a filesystem url to use for the remainder of this operation. - */ - target = [target stringByReplacingOccurrencesOfString:@"//" withString:@"/"]; - targetURL = [[self.commandDelegate getCommandInstance:@"File"] fileSystemURLforLocalPath:target].url; - } else { - targetURL = [NSURL URLWithString:target]; - } - - NSURL* sourceURL = [NSURL URLWithString:source]; - - if (!sourceURL) { - errorCode = INVALID_URL_ERR; - NSLog(@"File Transfer Error: Invalid server URL %@", source); - } else if (![targetURL isFileURL]) { - CDVFilesystemURL *fsURL = [CDVFilesystemURL fileSystemURLWithString:target]; - if (!fsURL) { - errorCode = FILE_NOT_FOUND_ERR; - NSLog(@"File Transfer Error: Invalid file path or URL %@", target); - } - } - - if (errorCode > 0) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:source AndTarget:target]]; - [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; - return; - } - - NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:sourceURL]; - [self applyRequestHeaders:headers toRequest:req]; - - CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init]; - delegate.command = self; - delegate.direction = CDV_TRANSFER_DOWNLOAD; - delegate.callbackId = command.callbackId; - delegate.objectId = objectId; - delegate.source = source; - delegate.target = [targetURL absoluteString]; - delegate.targetURL = targetURL; - delegate.trustAllHosts = trustAllHosts; - delegate.filePlugin = [self.commandDelegate getCommandInstance:@"File"]; - delegate.backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - [delegate cancelTransfer:delegate.connection]; - }]; - - delegate.connection = [[NSURLConnection alloc] initWithRequest:req delegate:delegate startImmediately:NO]; - - if (self.queue == nil) { - self.queue = [[NSOperationQueue alloc] init]; - } - [delegate.connection setDelegateQueue:self.queue]; - - @synchronized (activeTransfers) { - activeTransfers[delegate.objectId] = delegate; - } - // Downloads can take time - // sending this to a new thread calling the download_async method - dispatch_async( - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), - ^(void) { [delegate.connection start];} - ); -} - -- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target -{ - NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:3]; - - [result setObject:[NSNumber numberWithInt:code] forKey:@"code"]; - if (source != nil) { - [result setObject:source forKey:@"source"]; - } - if (target != nil) { - [result setObject:target forKey:@"target"]; - } - NSLog(@"FileTransferError %@", result); - - return result; -} - -- (NSMutableDictionary*)createFileTransferError:(int)code - AndSource:(NSString*)source - AndTarget:(NSString*)target - AndHttpStatus:(int)httpStatus - AndBody:(NSString*)body -{ - NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:5]; - - [result setObject:[NSNumber numberWithInt:code] forKey:@"code"]; - if (source != nil) { - [result setObject:source forKey:@"source"]; - } - if (target != nil) { - [result setObject:target forKey:@"target"]; - } - [result setObject:[NSNumber numberWithInt:httpStatus] forKey:@"http_status"]; - if (body != nil) { - [result setObject:body forKey:@"body"]; - } - NSLog(@"FileTransferError %@", result); - - return result; -} - -- (void)onReset { - @synchronized (activeTransfers) { - while ([activeTransfers count] > 0) { - CDVFileTransferDelegate* delegate = [activeTransfers allValues][0]; - [delegate cancelTransfer:delegate.connection]; - } - } -} - -@end - -@interface CDVFileTransferEntityLengthRequest : NSObject { - NSURLConnection* _connection; - CDVFileTransferDelegate* __weak _originalDelegate; -} - -- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate; - -@end - -@implementation CDVFileTransferEntityLengthRequest - -- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate -{ - if (self) { - DLog(@"Requesting entity length for GZIPped content..."); - - NSMutableURLRequest* req = [originalRequest mutableCopy]; - [req setHTTPMethod:@"HEAD"]; - [req setValue:@"identity" forHTTPHeaderField:@"Accept-Encoding"]; - - _originalDelegate = originalDelegate; - _connection = [NSURLConnection connectionWithRequest:req delegate:self]; - } - return self; -} - -- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response -{ - DLog(@"HEAD request returned; content-length is %lld", [response expectedContentLength]); - [_originalDelegate updateBytesExpected:[response expectedContentLength]]; -} - -- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data -{} - -- (void)connectionDidFinishLoading:(NSURLConnection*)connection -{} - -@end - -@implementation CDVFileTransferDelegate - -@synthesize callbackId, connection = _connection, source, target, responseData, responseHeaders, command, bytesTransfered, bytesExpected, direction, responseCode, objectId, targetFileHandle, filePlugin; - -- (void)connectionDidFinishLoading:(NSURLConnection*)connection -{ - NSString* uploadResponse = nil; - NSString* downloadResponse = nil; - NSMutableDictionary* uploadResult; - CDVPluginResult* result = nil; - - NSLog(@"File Transfer Finished with response code %d", self.responseCode); - - if (self.direction == CDV_TRANSFER_UPLOAD) { - uploadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding]; - if (uploadResponse == nil) { - uploadResponse = [[NSString alloc] initWithData: self.responseData encoding:NSISOLatin1StringEncoding]; - } - - if ((self.responseCode >= 200) && (self.responseCode < 300)) { - // create dictionary to return FileUploadResult object - uploadResult = [NSMutableDictionary dictionaryWithCapacity:3]; - if (uploadResponse != nil) { - [uploadResult setObject:uploadResponse forKey:@"response"]; - [uploadResult setObject:self.responseHeaders forKey:@"headers"]; - } - [uploadResult setObject:[NSNumber numberWithLongLong:self.bytesTransfered] forKey:@"bytesSent"]; - [uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey:@"responseCode"]; - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadResult]; - } else { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:uploadResponse]]; - } - } - if (self.direction == CDV_TRANSFER_DOWNLOAD) { - if (self.targetFileHandle) { - [self.targetFileHandle closeFile]; - self.targetFileHandle = nil; - DLog(@"File Transfer Download success"); - - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self.filePlugin makeEntryForURL:self.targetURL]]; - } else { - downloadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding]; - if (downloadResponse == nil) { - downloadResponse = [[NSString alloc] initWithData: self.responseData encoding:NSISOLatin1StringEncoding]; - } - - CDVFileTransferError errorCode = self.responseCode == 404 ? FILE_NOT_FOUND_ERR - : (self.responseCode == 304 ? NOT_MODIFIED : CONNECTION_ERR); - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:errorCode AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:downloadResponse]]; - } - } - - [self.command.commandDelegate sendPluginResult:result callbackId:callbackId]; - - // remove connection for activeTransfers - @synchronized (command.activeTransfers) { - [command.activeTransfers removeObjectForKey:objectId]; - // remove background id task in case our upload was done in the background - [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskID]; - self.backgroundTaskID = UIBackgroundTaskInvalid; - } -} - -- (void)removeTargetFile -{ - NSFileManager* fileMgr = [NSFileManager defaultManager]; - - NSString *targetPath = [self targetFilePath]; - if ([fileMgr fileExistsAtPath:targetPath]) - { - [fileMgr removeItemAtPath:targetPath error:nil]; - } -} - -- (void)cancelTransfer:(NSURLConnection*)connection -{ - [connection cancel]; - @synchronized (self.command.activeTransfers) { - CDVFileTransferDelegate* delegate = self.command.activeTransfers[self.objectId]; - [self.command.activeTransfers removeObjectForKey:self.objectId]; - [[UIApplication sharedApplication] endBackgroundTask:delegate.backgroundTaskID]; - delegate.backgroundTaskID = UIBackgroundTaskInvalid; - } - - if (self.direction == CDV_TRANSFER_DOWNLOAD) { - [self removeTargetFile]; - } -} - -- (void)cancelTransferWithError:(NSURLConnection*)connection errorMessage:(NSString*)errorMessage -{ - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsDictionary:[self.command createFileTransferError:FILE_NOT_FOUND_ERR AndSource:self.source AndTarget:self.target AndHttpStatus:self.responseCode AndBody:errorMessage]]; - - NSLog(@"File Transfer Error: %@", errorMessage); - [self cancelTransfer:connection]; - [self.command.commandDelegate sendPluginResult:result callbackId:callbackId]; -} - -- (NSString *)targetFilePath -{ - NSString *path = nil; - CDVFilesystemURL *sourceURL = [CDVFilesystemURL fileSystemURLWithString:self.target]; - if (sourceURL && sourceURL.fileSystemName != nil) { - // This requires talking to the current CDVFile plugin - NSObject *fs = [self.filePlugin filesystemForURL:sourceURL]; - path = [fs filesystemPathForURL:sourceURL]; - } else { - // Extract the path part out of a file: URL. - path = [self.target hasPrefix:@"/"] ? [self.target copy] : [(NSURL *)[NSURL URLWithString:self.target] path]; - } - return path; -} - -- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response -{ - NSError* __autoreleasing error = nil; - - self.mimeType = [response MIMEType]; - self.targetFileHandle = nil; - - // required for iOS 4.3, for some reason; response is - // a plain NSURLResponse, not the HTTP subclass - if ([response isKindOfClass:[NSHTTPURLResponse class]]) { - NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; - - self.responseCode = (int)[httpResponse statusCode]; - self.bytesExpected = [response expectedContentLength]; - self.responseHeaders = [httpResponse allHeaderFields]; - if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode == 200) && (self.bytesExpected == NSURLResponseUnknownLength)) { - // Kick off HEAD request to server to get real length - // bytesExpected will be updated when that response is returned - self.entityLengthRequest = [[CDVFileTransferEntityLengthRequest alloc] initWithOriginalRequest:connection.currentRequest andDelegate:self]; - } - } else if ([response.URL isFileURL]) { - NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[response.URL path] error:nil]; - self.responseCode = 200; - self.bytesExpected = [attr[NSFileSize] longLongValue]; - } else { - self.responseCode = 200; - self.bytesExpected = NSURLResponseUnknownLength; - } - if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode >= 200) && (self.responseCode < 300)) { - // Download response is okay; begin streaming output to file - NSString *filePath = [self targetFilePath]; - if (filePath == nil) { - // We couldn't find the asset. Send the appropriate error. - [self cancelTransferWithError:connection errorMessage:[NSString stringWithFormat:@"Could not create target file"]]; - return; - } - - NSString* parentPath = [filePath stringByDeletingLastPathComponent]; - - // create parent directories if needed - if ([[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:&error] == NO) { - if (error) { - [self cancelTransferWithError:connection errorMessage:[NSString stringWithFormat:@"Could not create path to save downloaded file: %@", [error localizedDescription]]]; - } else { - [self cancelTransferWithError:connection errorMessage:@"Could not create path to save downloaded file"]; - } - return; - } - // create target file - if ([[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil] == NO) { - [self cancelTransferWithError:connection errorMessage:@"Could not create target file"]; - return; - } - // open target file for writing - self.targetFileHandle = [NSFileHandle fileHandleForWritingAtPath:filePath]; - if (self.targetFileHandle == nil) { - [self cancelTransferWithError:connection errorMessage:@"Could not open target file for writing"]; - } - DLog(@"Streaming to file %@", filePath); - } -} - -- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error -{ - NSString* body = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:body]]; - - NSLog(@"File Transfer Error: %@", [error localizedDescription]); - - [self cancelTransfer:connection]; - [self.command.commandDelegate sendPluginResult:result callbackId:callbackId]; -} - -- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data -{ - self.bytesTransfered += data.length; - if (self.targetFileHandle) { - [self.targetFileHandle writeData:data]; - } else { - [self.responseData appendData:data]; - } - [self updateProgress]; -} - -- (void)updateBytesExpected:(long long)newBytesExpected -{ - DLog(@"Updating bytesExpected to %lld", newBytesExpected); - self.bytesExpected = newBytesExpected; - [self updateProgress]; -} - -- (void)updateProgress -{ - if (self.direction == CDV_TRANSFER_DOWNLOAD) { - BOOL lengthComputable = (self.bytesExpected != NSURLResponseUnknownLength); - // If the response is GZipped, and we have an outstanding HEAD request to get - // the length, then hold off on sending progress events. - if (!lengthComputable && (self.entityLengthRequest != nil)) { - return; - } - NSMutableDictionary* downloadProgress = [NSMutableDictionary dictionaryWithCapacity:3]; - [downloadProgress setObject:[NSNumber numberWithBool:lengthComputable] forKey:@"lengthComputable"]; - [downloadProgress setObject:[NSNumber numberWithLongLong:self.bytesTransfered] forKey:@"loaded"]; - [downloadProgress setObject:[NSNumber numberWithLongLong:self.bytesExpected] forKey:@"total"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:downloadProgress]; - [result setKeepCallbackAsBool:true]; - [self.command.commandDelegate sendPluginResult:result callbackId:callbackId]; - } -} - -- (void)connection:(NSURLConnection*)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite -{ - if (self.direction == CDV_TRANSFER_UPLOAD) { - NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3]; - - [uploadProgress setObject:[NSNumber numberWithBool:true] forKey:@"lengthComputable"]; - [uploadProgress setObject:[NSNumber numberWithLongLong:totalBytesWritten] forKey:@"loaded"]; - [uploadProgress setObject:[NSNumber numberWithLongLong:totalBytesExpectedToWrite] forKey:@"total"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadProgress]; - [result setKeepCallbackAsBool:true]; - [self.command.commandDelegate sendPluginResult:result callbackId:callbackId]; - } - self.bytesTransfered = totalBytesWritten; -} - -// for self signed certificates -- (void)connection:(NSURLConnection*)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge -{ - if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - if (self.trustAllHosts) { - NSURLCredential* credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; - [challenge.sender useCredential:credential forAuthenticationChallenge:challenge]; - } - [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; - } else { - [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge]; - } -} - -- (id)init -{ - if ((self = [super init])) { - self.responseData = [NSMutableData data]; - self.targetFileHandle = nil; - } - return self; -} - -@end diff --git a/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.cpp b/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.cpp deleted file mode 100644 index 5b1adea..0000000 --- a/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * - * Copyright 2013 Canonical Ltd. - * - * 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. - * -*/ - -#include "file-transfer.h" -#include -#include - -static void SetHeaders(QNetworkRequest &request, const QVariantMap &headers) { - for (const QString &key: headers.keys()) { - QVariant val = *headers.find(key); - QString value = val.toString(); - if (val.userType() == QMetaType::QVariantList || val.userType() == QMetaType::QStringList) { - QList list = val.toList(); - for (QVariant v: list) { - if (value.size()) - value += ", "; - value += v.toString(); - } - } - request.setRawHeader(key.toUtf8(), value.toUtf8()); - } -} - -void FileTransfer::download(int scId, int ecId, const QString& url, const QString &target, bool /*trustAllHost*/, int id, const QVariantMap &headers) { - QSharedPointer request(new FileTransferRequest(_manager, scId, ecId, id, this)); - - assert(_id2request.find(id) == _id2request.end()); - - _id2request.insert(id, request); - - request->connect(request.data(), &FileTransferRequest::done, [&]() { - auto it = _id2request.find(id); - while (it != _id2request.end() && it.key() == id) { - if (it.value().data() == request.data()) { - _id2request.erase(it); - break; - } - it++; - } - }); - request->download(url, target, headers); -} - -void FileTransfer::upload(int scId, int ecId, const QString &fileURI, const QString& url, const QString& fileKey, const QString& fileName, const QString& mimeType, - const QVariantMap & params, bool /*trustAllHosts*/, bool /*chunkedMode*/, const QVariantMap &headers, int id, const QString &/*httpMethod*/) { - QSharedPointer request(new FileTransferRequest(_manager, scId, ecId, id, this)); - - assert(_id2request.find(id) == _id2request.end()); - - _id2request.insert(id, request); - - request->connect(request.data(), &FileTransferRequest::done, [&]() { - auto it = _id2request.find(id); - while (it != _id2request.end() && it.key() == id) { - if (it.value().data() == request.data()) { - _id2request.erase(it); - break; - } - it++; - } - }); - request->upload(url, fileURI, fileKey, fileName, mimeType, params, headers); -} - -void FileTransfer::abort(int scId, int ecId, int id) { - Q_UNUSED(scId) - Q_UNUSED(ecId) - - auto it = _id2request.find(id); - while (it != _id2request.end() && it.key() == id) { - (*it)->abort(); - it++; - } -} - -void FileTransferRequest::download(const QString& uri, const QString &targetURI, const QVariantMap &headers) { - QUrl url(uri); - QNetworkRequest request; - - QSharedPointer filePlugin(_plugin->cordova()->getPlugin()); - - if (!filePlugin.data()) - return; - - if (!url.isValid()) { - QVariantMap map; - map.insert("code", INVALID_URL_ERR); - map.insert("source", uri); - map.insert("target", targetURI); - _plugin->cb(_ecId, map); - emit done(); - return; - } - - request.setUrl(url); - if (url.password().size() || url.userName().size()) { - QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64(); - request.setRawHeader("Authorization", headerData.toLocal8Bit()); - } - SetHeaders(request, headers); - _reply = QSharedPointer(_manager.get(request)); - - _reply->connect(_reply.data(), &QNetworkReply::finished, [this, targetURI, uri, filePlugin]() { - if (!_scId || _reply->error() != QNetworkReply::NoError) - return; - - QPair f1(dynamic_cast(filePlugin.data())->resolveURI(targetURI)); - - QFile res(f1.second.absoluteFilePath()); - if (!f1.first || !res.open(QIODevice::WriteOnly)) { - QVariantMap map; - map.insert("code", INVALID_URL_ERR); - map.insert("source", uri); - map.insert("target", targetURI); - _plugin->cb(_ecId, map); - emit done(); - return; - } - res.write(_reply->readAll()); - - _plugin->cb(_scId, dynamic_cast(filePlugin.data())->file2map(f1.second)); - - emit done(); - }); - _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); - _reply->connect(_reply.data(), SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); -} - -void FileTransferRequest::upload(const QString& _url, const QString& fileURI, QString fileKey, QString fileName, QString mimeType, const QVariantMap ¶ms, const QVariantMap &headers) { - QUrl url(_url); - QNetworkRequest request; - - QSharedPointer filePlugin(_plugin->cordova()->getPlugin()); - - if (!filePlugin.data()) - return; - - if (!url.isValid()) { - QVariantMap map; - map.insert("code", INVALID_URL_ERR); - map.insert("source", fileURI); - map.insert("target", _url); - _plugin->cb(_ecId, map); - emit done(); - return; - } - - QPair f1(dynamic_cast(filePlugin.data())->resolveURI(fileURI)); - QFile file(f1.second.absoluteFilePath()); - if (!f1.first || !file.open(QIODevice::ReadOnly)) { - QVariantMap map; - map.insert("code", FILE_NOT_FOUND_ERR); - map.insert("source", fileURI); - map.insert("target", _url); - _plugin->cb(_ecId, map); - emit done(); - return; - } - QString content{file.readAll()}; - - request.setUrl(url); - if (url.password().size() || url.userName().size()) { - QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64(); - request.setRawHeader("Authorization", headerData.toLocal8Bit()); - } - SetHeaders(request, headers); - - QString boundary = QString("CORDOVA-QT-%1A").arg(qrand()); - while (content.contains(boundary)) { - boundary += QString("B%1A").arg(qrand()); - } - - request.setHeader(QNetworkRequest::ContentTypeHeader, QString("multipart/form-data; boundary=") + boundary); - - fileKey.replace("\"", ""); - fileName.replace("\"", ""); - mimeType.replace("\"", ""); - QString part = "--" + boundary + "\r\n"; - - part += "Content-Disposition: form-data; name=\"" + fileKey +"\"; filename=\"" + fileName + "\"\r\n"; - part += "Content-Type: " + mimeType + "\r\n\r\n"; - part += content + "\r\n"; - - for (QString key: params.keys()) { - part += "--" + boundary + "\r\n"; - part += "Content-Disposition: form-data; name=\"" + key + "\";\r\n\r\n"; - part += params.find(key)->toString(); - part += "\r\n"; - } - - part += QString("--") + boundary + "--" + "\r\n"; - - _reply = QSharedPointer(_manager.post(request, QByteArray(part.toUtf8()))); - - _reply->connect(_reply.data(), &QNetworkReply::finished, [this, content]() { - if (_reply->error() != QNetworkReply::NoError) - return; - int status = 200; - QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); - - if (statusCode.isValid()) { - status = statusCode.toInt(); - } - - QVariantMap map; - map.insert("responseCode", status); - map.insert("response", QString(_reply->readAll())); - map.insert("bytesSent", content.size()); - _plugin->cb(_scId, map); - emit done(); - }); - _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); - _reply->connect(_reply.data(), SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); -} - -void FileTransferRequest::abort() { - QVariantMap map; - map.insert("code", ABORT_ERR); - _plugin->cb(_ecId, map); - _scId = 0; - emit done(); -} - -void FileTransferRequest::error(QNetworkReply::NetworkError code) { - Q_UNUSED(code); - - int status = 404; - QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); - if (statusCode.isValid()) { - status = statusCode.toInt(); - } - - QVariantMap map; - map.insert("http_status", status); - map.insert("body", QString(_reply->readAll())); - map.insert("code", CONNECTION_ERR); - _plugin->cb(_ecId, map); - emit done(); -} - -void FileTransferRequest::progress(qint64 bytesReceived, qint64 bytesTotal) { - QVariantMap map; - map.insert("lengthComputable", true); - map.insert("total", bytesTotal); - map.insert("loaded", bytesReceived); - - if (bytesReceived && bytesTotal && _scId) - _plugin->callbackWithoutRemove(_scId, CordovaInternal::format(map)); -} diff --git a/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.h b/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.h deleted file mode 100644 index 75822cb..0000000 --- a/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * Copyright 2013 Canonical Ltd. - * - * 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. - * -*/ - -#ifndef FILE_TRANSFER_H_SDASDASDAS -#define FILE_TRANSFER_H_SDASDASDAS - -#include -#include - -#include - -class FileTransfer; - -class FileTransferRequest: public QObject { - Q_OBJECT - - QNetworkAccessManager &_manager; - int _scId, _ecId; - int _id; - QSharedPointer _reply; - - enum FileTransferError { - FILE_NOT_FOUND_ERR = 1, - INVALID_URL_ERR = 2, - CONNECTION_ERR = 3, - ABORT_ERR = 4 - }; - -public: - FileTransferRequest(QNetworkAccessManager &manager, int scId, int ecId, int id, FileTransfer *plugin): - _manager(manager), - _scId(scId), - _ecId(ecId), - _id(id), - _plugin(plugin) { - } - - void download(const QString& url, const QString &targetURI, const QVariantMap &headers); - void upload(const QString& _url, const QString& fileURI, QString fileKey, QString fileName, QString mimeType, const QVariantMap ¶ms, const QVariantMap &headers); - void abort(); - -signals: - void done(); - -private slots: - void progress(qint64 bytesReceived, qint64 bytesTotal); - void error(QNetworkReply::NetworkError code); -private: - FileTransfer *_plugin; - Q_DISABLE_COPY(FileTransferRequest); -}; - -class FileTransfer : public CPlugin { - Q_OBJECT -public: - explicit FileTransfer(Cordova *cordova): CPlugin(cordova) { - } - - Cordova* cordova() { - return m_cordova; - } - - virtual const QString fullName() override { - return FileTransfer::fullID(); - } - - virtual const QString shortName() override { - return "FileTransfer"; - } - - static const QString fullID() { - return "FileTransfer"; - } - -public slots: - void abort(int scId, int ecId, int id); - void download(int scId, int ecId, const QString& url, const QString &target, bool /*trustAllHost*/, int id, const QVariantMap &/*headers*/); - void upload(int scId, int ecId, const QString &filePath, const QString& url, const QString& fileKey, const QString& fileName, const QString& mimeType, - const QVariantMap & params, bool /*trustAllHosts*/, bool /*chunkedMode*/, const QVariantMap &headers, int id, const QString &httpMethod); - -private: - QNetworkAccessManager _manager; - QMultiMap > _id2request; - int lastRequestId; -}; - -#endif diff --git a/plugins/cordova-plugin-file-transfer/src/windows/FileTransferProxy.js b/plugins/cordova-plugin-file-transfer/src/windows/FileTransferProxy.js deleted file mode 100644 index d5ef9ba..0000000 --- a/plugins/cordova-plugin-file-transfer/src/windows/FileTransferProxy.js +++ /dev/null @@ -1,578 +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. - * -*/ - -/*jshint -W030 */ -/*global Windows, WinJS*/ -/*global module, require*/ - -var FTErr = require('./FileTransferError'), - ProgressEvent = require('cordova-plugin-file.ProgressEvent'), - FileUploadResult = require('cordova-plugin-file.FileUploadResult'), - FileProxy = require('cordova-plugin-file.FileProxy'), - FileEntry = require('cordova-plugin-file.FileEntry'); - -var appData = Windows.Storage.ApplicationData.current; - -var LINE_START = "--"; -var LINE_END = "\r\n"; -var BOUNDARY = '+++++'; - -// Some private helper functions, hidden by the module -function cordovaPathToNative(path) { - - var cleanPath = String(path); - // turn / into \\ - cleanPath = cleanPath.replace(/\//g, '\\'); - // turn \\ into \ - cleanPath = cleanPath.replace(/\\\\/g, '\\'); - // strip end \\ characters - cleanPath = cleanPath.replace(/\\+$/g, ''); - return cleanPath; -} - -function nativePathToCordova(path) { - return String(path).replace(/\\/g, '/'); -} - -function alreadyCancelled(opId) { - var op = fileTransferOps[opId]; - return op && op.state === FileTransferOperation.CANCELLED; -} - -function doUpload (upload, uploadId, filePath, server, successCallback, errorCallback) { - if (alreadyCancelled(uploadId)) { - errorCallback(new FTErr(FTErr.ABORT_ERR, nativePathToCordova(filePath), server)); - return; - } - - // update internal TransferOperation object with newly created promise - var uploadOperation = upload.startAsync(); - fileTransferOps[uploadId].promise = uploadOperation; - - uploadOperation.then( - function (result) { - // Update TransferOperation object with new state, delete promise property - // since it is not actual anymore - var currentUploadOp = fileTransferOps[uploadId]; - if (currentUploadOp) { - currentUploadOp.state = FileTransferOperation.DONE; - currentUploadOp.promise = null; - } - - var response = result.getResponseInformation(); - var ftResult = new FileUploadResult(result.progress.bytesSent, response.statusCode, ''); - - // if server's response doesn't contain any data, then resolve operation now - if (result.progress.bytesReceived === 0) { - successCallback(ftResult); - return; - } - - // otherwise create a data reader, attached to response stream to get server's response - var reader = new Windows.Storage.Streams.DataReader(result.getResultStreamAt(0)); - reader.loadAsync(result.progress.bytesReceived).then(function (size) { - ftResult.response = reader.readString(size); - successCallback(ftResult); - reader.close(); - }); - }, - function (error) { - var source = nativePathToCordova(filePath); - - // Handle download error here. - // Wrap this routines into promise due to some async methods - var getTransferError = new WinJS.Promise(function (resolve) { - if (error.message === 'Canceled') { - // If download was cancelled, message property will be specified - resolve(new FTErr(FTErr.ABORT_ERR, source, server, null, null, error)); - } else { - // in the other way, try to get response property - var response = upload.getResponseInformation(); - if (!response) { - resolve(new FTErr(FTErr.CONNECTION_ERR, source, server)); - } else { - var reader = new Windows.Storage.Streams.DataReader(upload.getResultStreamAt(0)); - reader.loadAsync(upload.progress.bytesReceived).then(function (size) { - var responseText = reader.readString(size); - resolve(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, server, response.statusCode, responseText, error)); - reader.close(); - }); - } - } - }); - - // Update TransferOperation object with new state, delete promise property - // since it is not actual anymore - var currentUploadOp = fileTransferOps[uploadId]; - if (currentUploadOp) { - currentUploadOp.state = FileTransferOperation.CANCELLED; - currentUploadOp.promise = null; - } - - // Report the upload error back - getTransferError.then(function (transferError) { - errorCallback(transferError); - }); - }, - function (evt) { - var progressEvent = new ProgressEvent('progress', { - loaded: evt.progress.bytesSent, - total: evt.progress.totalBytesToSend, - target: evt.resultFile - }); - progressEvent.lengthComputable = true; - successCallback(progressEvent, { keepCallback: true }); - } - ); -} - -var fileTransferOps = []; - -function FileTransferOperation(state, promise) { - this.state = state; - this.promise = promise; -} - -FileTransferOperation.PENDING = 0; -FileTransferOperation.DONE = 1; -FileTransferOperation.CANCELLED = 2; - -var HTTP_E_STATUS_NOT_MODIFIED = -2145844944; - -module.exports = { - -/* -exec(win, fail, 'FileTransfer', 'upload', -[filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); -*/ - upload: function (successCallback, errorCallback, options) { - var filePath = options[0]; - var server = options[1]; - var fileKey = options[2] || 'source'; - var fileName = options[3]; - var mimeType = options[4]; - var params = options[5]; - // var trustAllHosts = options[6]; // todo - // var chunkedMode = options[7]; // todo - var headers = options[8] || {}; - var uploadId = options[9]; - var httpMethod = options[10]; - - var isMultipart = typeof headers["Content-Type"] === 'undefined'; - - if (!filePath || (typeof filePath !== 'string')) { - errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, null, server)); - return; - } - - if (filePath.indexOf("data:") === 0 && filePath.indexOf("base64") !== -1) { - // First a DataWriter object is created, backed by an in-memory stream where - // the data will be stored. - var writer = Windows.Storage.Streams.DataWriter(new Windows.Storage.Streams.InMemoryRandomAccessStream()); - writer.unicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.utf8; - writer.byteOrder = Windows.Storage.Streams.ByteOrder.littleEndian; - - var commaIndex = filePath.indexOf(","); - if (commaIndex === -1) { - errorCallback(new FTErr(FTErr.INVALID_URL_ERR, fileName, server, null, null, "No comma in data: URI")); - return; - } - - // Create internal download operation object - fileTransferOps[uploadId] = new FileTransferOperation(FileTransferOperation.PENDING, null); - - var fileDataString = filePath.substr(commaIndex + 1); - - function stringToByteArray(str) { - var byteCharacters = atob(str); - var byteNumbers = new Array(byteCharacters.length); - for (var i = 0; i < byteCharacters.length; i++) { - byteNumbers[i] = byteCharacters.charCodeAt(i); - } - return new Uint8Array(byteNumbers); - }; - - // setting request headers for uploader - var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader(); - uploader.method = httpMethod; - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - uploader.setRequestHeader(header, headers[header]); - } - } - - if (isMultipart) { - // adding params supplied to request payload - var multipartParams = ''; - for (var key in params) { - if (params.hasOwnProperty(key)) { - multipartParams += LINE_START + BOUNDARY + LINE_END; - multipartParams += "Content-Disposition: form-data; name=\"" + key + "\""; - multipartParams += LINE_END + LINE_END; - multipartParams += params[key]; - multipartParams += LINE_END; - } - } - - var multipartFile = LINE_START + BOUNDARY + LINE_END; - multipartFile += "Content-Disposition: form-data; name=\"file\";"; - multipartFile += " filename=\"" + fileName + "\"" + LINE_END; - multipartFile += "Content-Type: " + mimeType + LINE_END + LINE_END; - - var bound = LINE_END + LINE_START + BOUNDARY + LINE_START + LINE_END; - - uploader.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); - writer.writeString(multipartParams); - writer.writeString(multipartFile); - writer.writeBytes(stringToByteArray(fileDataString)); - writer.writeString(bound); - } else { - writer.writeBytes(stringToByteArray(fileDataString)); - } - - var stream; - - // The call to store async sends the actual contents of the writer - // to the backing stream. - writer.storeAsync().then(function () { - // For the in-memory stream implementation we are using, the flushAsync call - // is superfluous, but other types of streams may require it. - return writer.flushAsync(); - }).then(function () { - // We detach the stream to prolong its useful lifetime. Were we to fail - // to detach the stream, the call to writer.close() would close the underlying - // stream, preventing its subsequent use by the DataReader below. Most clients - // of DataWriter will have no reason to use the underlying stream after - // writer.close() is called, and will therefore have no reason to call - // writer.detachStream(). Note that once we detach the stream, we assume - // responsibility for closing the stream subsequently; after the stream - // has been detached, a call to writer.close() will have no effect on the stream. - stream = writer.detachStream(); - // Make sure the stream is read from the beginning in the reader - // we are creating below. - stream.seek(0); - // Most DataWriter clients will not call writer.detachStream(), - // and furthermore will be working with a file-backed or network-backed stream, - // rather than an in-memory-stream. In such cases, it would be particularly - // important to call writer.close(). Doing so is always a best practice. - writer.close(); - - if (alreadyCancelled(uploadId)) { - errorCallback(new FTErr(FTErr.ABORT_ERR, nativePathToCordova(filePath), server)); - return; - } - - // create download object. This will throw an exception if URL is malformed - var uri = new Windows.Foundation.Uri(server); - - var createUploadOperation; - try { - createUploadOperation = uploader.createUploadFromStreamAsync(uri, stream); - } catch (e) { - errorCallback(new FTErr(FTErr.INVALID_URL_ERR)); - return; - } - - createUploadOperation.then( - function (upload) { - doUpload(upload, uploadId, filePath, server, successCallback, errorCallback); - }, - function (err) { - var errorObj = new FTErr(FTErr.INVALID_URL_ERR); - errorObj.exception = err; - errorCallback(errorObj); - }); - }); - - return; - } - - if (filePath.substr(0, 8) === "file:///") { - filePath = appData.localFolder.path + filePath.substr(8).split("/").join("\\"); - } else if (filePath.indexOf('ms-appdata:///') === 0) { - // Handle 'ms-appdata' scheme - filePath = filePath.replace('ms-appdata:///local', appData.localFolder.path) - .replace('ms-appdata:///temp', appData.temporaryFolder.path); - } else if (filePath.indexOf('cdvfile://') === 0) { - filePath = filePath.replace('cdvfile://localhost/persistent', appData.localFolder.path) - .replace('cdvfile://localhost/temporary', appData.temporaryFolder.path); - } - - // normalize path separators - filePath = cordovaPathToNative(filePath); - - // Create internal download operation object - fileTransferOps[uploadId] = new FileTransferOperation(FileTransferOperation.PENDING, null); - - Windows.Storage.StorageFile.getFileFromPathAsync(filePath) - .then(function (storageFile) { - - if (!fileName) { - fileName = storageFile.name; - } - if (!mimeType) { - // use the actual content type of the file, probably this should be the default way. - // other platforms probably can't look this up. - mimeType = storageFile.contentType; - } - - if (alreadyCancelled(uploadId)) { - errorCallback(new FTErr(FTErr.ABORT_ERR, nativePathToCordova(filePath), server)); - return; - } - - // setting request headers for uploader - var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader(); - uploader.method = httpMethod; - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - uploader.setRequestHeader(header, headers[header]); - } - } - - // create download object. This will throw an exception if URL is malformed - var uri = new Windows.Foundation.Uri(server); - - var createUploadOperation; - try { - if (isMultipart) { - // adding params supplied to request payload - var transferParts = []; - for (var key in params) { - if (params.hasOwnProperty(key)) { - var contentPart = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart(); - contentPart.setHeader("Content-Disposition", "form-data; name=\"" + key + "\""); - contentPart.setText(params[key]); - transferParts.push(contentPart); - } - } - - // Adding file to upload to request payload - var fileToUploadPart = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart(fileKey, fileName); - fileToUploadPart.setFile(storageFile); - transferParts.push(fileToUploadPart); - - createUploadOperation = uploader.createUploadAsync(uri, transferParts); - } else { - createUploadOperation = WinJS.Promise.wrap(uploader.createUpload(uri, storageFile)); - } - } catch (e) { - errorCallback(new FTErr(FTErr.INVALID_URL_ERR)); - return; - } - - createUploadOperation.then( - function (upload) { - doUpload(upload, uploadId, filePath, server, successCallback, errorCallback); - }, - function (err) { - var errorObj = new FTErr(FTErr.INVALID_URL_ERR); - errorObj.exception = err; - errorCallback(errorObj); - } - ); - }, function (err) { - errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, fileName, server, null, null, err)); - }); - }, - - // [source, target, trustAllHosts, id, headers] - download:function(successCallback, errorCallback, options) { - var source = options[0]; - var target = options[1]; - var downloadId = options[3]; - var headers = options[4] || {}; - - if (!target) { - errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR)); - return; - } - if (target.substr(0, 8) === "file:///") { - target = appData.localFolder.path + target.substr(8).split("/").join("\\"); - } else if (target.indexOf('ms-appdata:///') === 0) { - // Handle 'ms-appdata' scheme - target = target.replace('ms-appdata:///local', appData.localFolder.path) - .replace('ms-appdata:///temp', appData.temporaryFolder.path); - } else if (target.indexOf('cdvfile://') === 0) { - target = target.replace('cdvfile://localhost/persistent', appData.localFolder.path) - .replace('cdvfile://localhost/temporary', appData.temporaryFolder.path); - } - target = cordovaPathToNative(target); - - var path = target.substr(0, target.lastIndexOf("\\")); - var fileName = target.substr(target.lastIndexOf("\\") + 1); - if (path === null || fileName === null) { - errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR)); - return; - } - // Download to a temp file to avoid the file deletion on 304 - // CB-7006 Empty file is created on file transfer if server response is 304 - var tempFileName = '~' + fileName; - - var download = null; - - // Create internal download operation object - fileTransferOps[downloadId] = new FileTransferOperation(FileTransferOperation.PENDING, null); - - var downloadCallback = function(storageFolder) { - storageFolder.createFileAsync(tempFileName, Windows.Storage.CreationCollisionOption.replaceExisting).then(function (storageFile) { - - if (alreadyCancelled(downloadId)) { - errorCallback(new FTErr(FTErr.ABORT_ERR, source, target)); - return; - } - - // if download isn't cancelled, contunue with creating and preparing download operation - var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader(); - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - downloader.setRequestHeader(header, headers[header]); - } - } - - // create download object. This will throw an exception if URL is malformed - try { - var uri = Windows.Foundation.Uri(source); - download = downloader.createDownload(uri, storageFile); - } catch (e) { - // so we handle this and call errorCallback - errorCallback(new FTErr(FTErr.INVALID_URL_ERR)); - return; - } - - var downloadOperation = download.startAsync(); - // update internal TransferOperation object with newly created promise - fileTransferOps[downloadId].promise = downloadOperation; - - downloadOperation.then(function () { - - // Update TransferOperation object with new state, delete promise property - // since it is not actual anymore - var currentDownloadOp = fileTransferOps[downloadId]; - if (currentDownloadOp) { - currentDownloadOp.state = FileTransferOperation.DONE; - currentDownloadOp.promise = null; - } - - storageFile.renameAsync(fileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(function () { - var nativeURI = storageFile.path.replace(appData.localFolder.path, 'ms-appdata:///local') - .replace(appData.temporaryFolder.path, 'ms-appdata:///temp') - .replace(/\\/g, '/'); - - // Passing null as error callback here because downloaded file should exist in any case - // otherwise the error callback will be hit during file creation in another place - FileProxy.resolveLocalFileSystemURI(successCallback, null, [nativeURI]); - }, function(error) { - errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, null, null, error)); - }); - }, function(error) { - - var getTransferError = new WinJS.Promise(function (resolve) { - // Handle download error here. If download was cancelled, - // message property will be specified - if (error.message === 'Canceled') { - resolve(new FTErr(FTErr.ABORT_ERR, source, target, null, null, error)); - } else if (error && error.number === HTTP_E_STATUS_NOT_MODIFIED) { - resolve(new FTErr(FTErr.NOT_MODIFIED_ERR, source, target, 304, null, error)); - } else { - // in the other way, try to get response property - var response = download.getResponseInformation(); - if (!response) { - resolve(new FTErr(FTErr.CONNECTION_ERR, source, target)); - } else { - var reader = new Windows.Storage.Streams.DataReader(download.getResultStreamAt(0)); - reader.loadAsync(download.progress.bytesReceived).then(function (bytesLoaded) { - var payload = reader.readString(bytesLoaded); - resolve(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, response.statusCode, payload, error)); - }); - } - } - }); - getTransferError.then(function (fileTransferError) { - - // Update TransferOperation object with new state, delete promise property - // since it is not actual anymore - var currentDownloadOp = fileTransferOps[downloadId]; - if (currentDownloadOp) { - currentDownloadOp.state = FileTransferOperation.CANCELLED; - currentDownloadOp.promise = null; - } - - // Cleanup, remove incompleted file - storageFile.deleteAsync().then(function() { - errorCallback(fileTransferError); - }); - }); - - }, function(evt) { - - var progressEvent = new ProgressEvent('progress', { - loaded: evt.progress.bytesReceived, - total: evt.progress.totalBytesToReceive, - target: evt.resultFile - }); - // when bytesReceived == 0, BackgroundDownloader has not yet differentiated whether it could get file length or not, - // when totalBytesToReceive == 0, BackgroundDownloader is unable to get file length - progressEvent.lengthComputable = (evt.progress.bytesReceived > 0) && (evt.progress.totalBytesToReceive > 0); - - successCallback(progressEvent, { keepCallback: true }); - }); - }, function(error) { - errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, null, null, error)); - }); - }; - - var fileNotFoundErrorCallback = function(error) { - errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, null, null, error)); - }; - - Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(downloadCallback, function (error) { - // Handle non-existent directory - if (error.number === -2147024894) { - var parent = path.substr(0, path.lastIndexOf('\\')), - folderNameToCreate = path.substr(path.lastIndexOf('\\') + 1); - - Windows.Storage.StorageFolder.getFolderFromPathAsync(parent).then(function(parentFolder) { - parentFolder.createFolderAsync(folderNameToCreate).then(downloadCallback, fileNotFoundErrorCallback); - }, fileNotFoundErrorCallback); - } else { - fileNotFoundErrorCallback(); - } - }); - }, - - abort: function (successCallback, error, options) { - var fileTransferOpId = options[0]; - - // Try to find transferOperation with id specified, and cancel its' promise - var currentOp = fileTransferOps[fileTransferOpId]; - if (currentOp) { - currentOp.state = FileTransferOperation.CANCELLED; - currentOp.promise && currentOp.promise.cancel(); - } else if (typeof fileTransferOpId !== 'undefined') { - // Create the operation in cancelled state to be aborted right away - fileTransferOps[fileTransferOpId] = new FileTransferOperation(FileTransferOperation.CANCELLED, null); - } - } - -}; - -require("cordova/exec/proxy").add("FileTransfer",module.exports); diff --git a/plugins/cordova-plugin-file-transfer/src/wp/FileTransfer.cs b/plugins/cordova-plugin-file-transfer/src/wp/FileTransfer.cs deleted file mode 100644 index 4be46e8..0000000 --- a/plugins/cordova-plugin-file-transfer/src/wp/FileTransfer.cs +++ /dev/null @@ -1,994 +0,0 @@ -/* - 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. -*/ - -using Microsoft.Phone.Controls; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.IsolatedStorage; -using System.Linq; -using System.Net; -using System.Runtime.Serialization; -using System.Windows; -using System.Security; -using System.Diagnostics; -using System.Threading.Tasks; -using WPCordovaClassLib.Cordova.JSON; -using System.Reflection; - -namespace WPCordovaClassLib.Cordova.Commands -{ - public class FileTransfer : BaseCommand - { - public class DownloadRequestState - { - // This class stores the State of the request. - public HttpWebRequest request; - public TransferOptions options; - public bool isCancelled; - - public DownloadRequestState() - { - request = null; - options = null; - isCancelled = false; - } - } - - public class TransferOptions - { - /// File path to upload OR File path to download to - public string FilePath { get; set; } - - public string Url { get; set; } - /// Flag to recognize if we should trust every host (only in debug environments) - public bool TrustAllHosts { get; set; } - public string Id { get; set; } - public string Headers { get; set; } - public string CallbackId { get; set; } - public bool ChunkedMode { get; set; } - /// Server address - public string Server { get; set; } - /// File key - public string FileKey { get; set; } - /// File name on the server - public string FileName { get; set; } - /// File Mime type - public string MimeType { get; set; } - /// Additional options - public string Params { get; set; } - public string Method { get; set; } - - public TransferOptions() - { - FileKey = "file"; - FileName = "image.jpg"; - MimeType = "image/jpeg"; - } - } - - /// - /// Boundary symbol - /// - private string Boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x"); - - // Error codes - public const int FileNotFoundError = 1; - public const int InvalidUrlError = 2; - public const int ConnectionError = 3; - public const int AbortError = 4; // not really an error, but whatevs - - private static Dictionary InProcDownloads = new Dictionary(); - - // Private instance of the main WebBrowser instance - // NOTE: Any access to this object needs to occur on the UI thread via the Dispatcher - private WebBrowser browser; - - - - /// - /// Uploading response info - /// - [DataContract] - public class FileUploadResult - { - /// - /// Amount of sent bytes - /// - [DataMember(Name = "bytesSent")] - public long BytesSent { get; set; } - - /// - /// Server response code - /// - [DataMember(Name = "responseCode")] - public long ResponseCode { get; set; } - - /// - /// Server response - /// - [DataMember(Name = "response", EmitDefaultValue = false)] - public string Response { get; set; } - - /// - /// Creates FileUploadResult object with response values - /// - /// Amount of sent bytes - /// Server response code - /// Server response - public FileUploadResult(long bytesSent, long responseCode, string response) - { - this.BytesSent = bytesSent; - this.ResponseCode = responseCode; - this.Response = response; - } - } - /// - /// Represents transfer error codes for callback - /// - [DataContract] - public class FileTransferError - { - /// - /// Error code - /// - [DataMember(Name = "code", IsRequired = true)] - public int Code { get; set; } - - /// - /// The source URI - /// - [DataMember(Name = "source", IsRequired = true)] - public string Source { get; set; } - - /// - /// The target URI - /// - /// - [DataMember(Name = "target", IsRequired = true)] - public string Target { get; set; } - - [DataMember(Name = "body", IsRequired = true)] - public string Body { get; set; } - - /// - /// The http status code response from the remote URI - /// - [DataMember(Name = "http_status", IsRequired = true)] - public int HttpStatus { get; set; } - - /// - /// Creates FileTransferError object - /// - /// Error code - public FileTransferError(int errorCode) - { - this.Code = errorCode; - this.Source = null; - this.Target = null; - this.HttpStatus = 0; - this.Body = ""; - } - public FileTransferError(int errorCode, string source, string target, int status, string body = "") - { - this.Code = errorCode; - this.Source = source; - this.Target = target; - this.HttpStatus = status; - this.Body = body; - } - } - - /// - /// Represents a singular progress event to be passed back to javascript - /// - [DataContract] - public class FileTransferProgress - { - /// - /// Is the length of the response known? - /// - [DataMember(Name = "lengthComputable", IsRequired = true)] - public bool LengthComputable { get; set; } - /// - /// amount of bytes loaded - /// - [DataMember(Name = "loaded", IsRequired = true)] - public long BytesLoaded { get; set; } - /// - /// Total bytes - /// - [DataMember(Name = "total", IsRequired = false)] - public long BytesTotal { get; set; } - - public FileTransferProgress(long bTotal = 0, long bLoaded = 0) - { - LengthComputable = bTotal > 0; - BytesLoaded = bLoaded; - BytesTotal = bTotal; - } - } - - /// - /// Represents a request header passed from Javascript to upload/download operations - /// - [DataContract] - protected struct Header - { - [DataMember(Name = "name")] - public string Name; - - [DataMember(Name = "value")] - public string Value; - } - - private static MethodInfo JsonDeserializeUsingJsonNet; - - public FileTransfer() - { - if (JsonDeserializeUsingJsonNet == null) - { - var method = typeof(JsonHelper).GetMethod("Deserialize", new Type[] { typeof(string), typeof(bool) }); - if (method != null) - { - JsonDeserializeUsingJsonNet = method.MakeGenericMethod(new Type[] { typeof(Header[]) }); - } - } - } - - /// Helper method to copy all relevant cookies from the WebBrowser control into a header on - /// the HttpWebRequest - /// - /// The source browser to copy the cookies from - /// The destination HttpWebRequest to add the cookie header to - /// Nothing - private async Task CopyCookiesFromWebBrowser(HttpWebRequest webRequest) - { - var tcs = new TaskCompletionSource(); - - // Accessing WebBrowser needs to happen on the UI thread - Deployment.Current.Dispatcher.BeginInvoke(() => - { - // Get the WebBrowser control - if (this.browser == null) - { - PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; - if (frame != null) - { - PhoneApplicationPage page = frame.Content as PhoneApplicationPage; - if (page != null) - { - CordovaView cView = page.FindName("CordovaView") as CordovaView; - if (cView != null) - { - this.browser = cView.Browser; - } - } - } - } - - try - { - // Only copy the cookies if the scheme and host match (to avoid any issues with secure/insecure cookies) - // NOTE: since the returned CookieCollection appears to munge the original cookie's domain value in favor of the actual Source domain, - // we can't know for sure whether the cookies would be applicable to any other hosts, so best to play it safe and skip for now. - if (this.browser != null && this.browser.Source.IsAbsoluteUri == true && - this.browser.Source.Scheme == webRequest.RequestUri.Scheme && this.browser.Source.Host == webRequest.RequestUri.Host) - { - string cookieHeader = ""; - string requestPath = webRequest.RequestUri.PathAndQuery; - CookieCollection cookies = this.browser.GetCookies(); - - // Iterate over the cookies and add to the header - foreach (Cookie cookie in cookies) - { - // Check that the path is allowed, first - // NOTE: Path always seems to be empty for now, even if the cookie has a path set by the server. - if (cookie.Path.Length == 0 || requestPath.IndexOf(cookie.Path, StringComparison.InvariantCultureIgnoreCase) == 0) - { - cookieHeader += cookie.Name + "=" + cookie.Value + "; "; - } - } - - // Finally, set the header if we found any cookies - if (cookieHeader.Length > 0) - { - webRequest.Headers["Cookie"] = cookieHeader; - } - } - } - catch (Exception) - { - // Swallow the exception - } - - // Complete the task - tcs.SetResult(Type.Missing); - }); - - await tcs.Task; - } - - /// - /// Upload options - /// - //private TransferOptions uploadOptions; - - /// - /// Bytes sent - /// - private long bytesSent; - - /// - /// sends a file to a server - /// - /// Upload options - /// exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); - public void upload(string options) - { - options = options.Replace("{}", ""); // empty objects screw up the Deserializer - string callbackId = ""; - - TransferOptions uploadOptions = null; - HttpWebRequest webRequest = null; - - try - { - try - { - string[] args = JSON.JsonHelper.Deserialize(options); - uploadOptions = new TransferOptions(); - uploadOptions.FilePath = args[0]; - uploadOptions.Server = args[1]; - uploadOptions.FileKey = args[2]; - uploadOptions.FileName = args[3]; - uploadOptions.MimeType = args[4]; - uploadOptions.Params = args[5]; - - bool trustAll = false; - bool.TryParse(args[6],out trustAll); - uploadOptions.TrustAllHosts = trustAll; - - bool doChunked = false; - bool.TryParse(args[7], out doChunked); - uploadOptions.ChunkedMode = doChunked; - - //8 : Headers - //9 : id - //10: method - - uploadOptions.Headers = args[8]; - uploadOptions.Id = args[9]; - uploadOptions.Method = args[10]; - - uploadOptions.CallbackId = callbackId = args[11]; - } - catch (Exception) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - return; - } - - Uri serverUri; - try - { - serverUri = new Uri(uploadOptions.Server); - } - catch (Exception) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(InvalidUrlError, uploadOptions.Server, null, 0))); - return; - } - webRequest = (HttpWebRequest)WebRequest.Create(serverUri); - webRequest.ContentType = "multipart/form-data; boundary=" + Boundary; - webRequest.Method = uploadOptions.Method; - - DownloadRequestState reqState = new DownloadRequestState(); - InProcDownloads[uploadOptions.Id] = reqState; - reqState.options = uploadOptions; - reqState.request = webRequest; - - try - { - // Associate cookies with the request - // This is an async call, so we need to await it in order to preserve proper control flow - Task cookieTask = CopyCookiesFromWebBrowser(webRequest); - cookieTask.Wait(); - } - catch (AggregateException ae) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, - new FileTransferError(FileTransfer.ConnectionError, uploadOptions.FilePath, uploadOptions.Server, 0, ae.InnerException.Message))); - return; - } - - if (!string.IsNullOrEmpty(uploadOptions.Headers)) - { - Dictionary headers = parseHeaders(uploadOptions.Headers); - if (headers != null) - { - foreach (string key in headers.Keys) - { - webRequest.Headers[key] = headers[key]; - } - } - } - - webRequest.BeginGetRequestStream(uploadCallback, reqState); - } - catch (Exception /*ex*/) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(ConnectionError)),callbackId); - } - } - - // example : "{\"Authorization\":\"Basic Y29yZG92YV91c2VyOmNvcmRvdmFfcGFzc3dvcmQ=\"}" - protected Dictionary parseHeaders(string jsonHeaders) - { - try - { - if (FileTransfer.JsonDeserializeUsingJsonNet != null) - { - return ((Header[])FileTransfer.JsonDeserializeUsingJsonNet.Invoke(null, new object[] { jsonHeaders, true })) - .ToDictionary(header => header.Name, header => header.Value); - } - else - { - return JsonHelper.Deserialize(jsonHeaders) - .ToDictionary(header => header.Name, header => header.Value); - } - } - catch (Exception) - { - Debug.WriteLine("Failed to parseHeaders from string :: " + jsonHeaders); - } - return new Dictionary(); - } - - public void download(string options) - { - TransferOptions downloadOptions = null; - HttpWebRequest webRequest = null; - string callbackId; - - try - { - // source, target, trustAllHosts, this._id, headers - string[] optionStrings = JSON.JsonHelper.Deserialize(options); - - downloadOptions = new TransferOptions(); - downloadOptions.Url = optionStrings[0]; - downloadOptions.FilePath = optionStrings[1]; - - bool trustAll = false; - bool.TryParse(optionStrings[2],out trustAll); - downloadOptions.TrustAllHosts = trustAll; - - downloadOptions.Id = optionStrings[3]; - downloadOptions.Headers = optionStrings[4]; - downloadOptions.CallbackId = callbackId = optionStrings[5]; - } - catch (Exception) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - return; - } - - try - { - // is the URL a local app file? - if (downloadOptions.Url.StartsWith("x-wmapp0") || downloadOptions.Url.StartsWith("file:")) - { - using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication()) - { - string cleanUrl = downloadOptions.Url.Replace("x-wmapp0:", "").Replace("file:", "").Replace("//",""); - - // pre-emptively create any directories in the FilePath that do not exist - string directoryName = getDirectoryName(downloadOptions.FilePath); - if (!string.IsNullOrEmpty(directoryName) && !isoFile.DirectoryExists(directoryName)) - { - isoFile.CreateDirectory(directoryName); - } - - // just copy from one area of iso-store to another ... - if (isoFile.FileExists(downloadOptions.Url)) - { - isoFile.CopyFile(downloadOptions.Url, downloadOptions.FilePath); - } - else - { - // need to unpack resource from the dll - Uri uri = new Uri(cleanUrl, UriKind.Relative); - var resource = Application.GetResourceStream(uri); - - if (resource != null) - { - // create the file destination - if (!isoFile.FileExists(downloadOptions.FilePath)) - { - var destFile = isoFile.CreateFile(downloadOptions.FilePath); - destFile.Close(); - } - - using (FileStream fileStream = new IsolatedStorageFileStream(downloadOptions.FilePath, FileMode.Open, FileAccess.Write, isoFile)) - { - long totalBytes = resource.Stream.Length; - int bytesRead = 0; - using (BinaryReader reader = new BinaryReader(resource.Stream)) - { - using (BinaryWriter writer = new BinaryWriter(fileStream)) - { - int BUFFER_SIZE = 1024; - byte[] buffer; - - while (true) - { - buffer = reader.ReadBytes(BUFFER_SIZE); - // fire a progress event ? - bytesRead += buffer.Length; - if (buffer.Length > 0) - { - writer.Write(buffer); - DispatchFileTransferProgress(bytesRead, totalBytes, callbackId); - } - else - { - writer.Close(); - reader.Close(); - fileStream.Close(); - break; - } - } - } - } - } - } - } - } - - File.FileEntry entry = File.FileEntry.GetEntry(downloadOptions.FilePath); - if (entry != null) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry), callbackId); - } - else - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, File.NOT_FOUND_ERR), callbackId); - } - - return; - } - else - { - // otherwise it is web-bound, we will actually download it - //Debug.WriteLine("Creating WebRequest for url : " + downloadOptions.Url); - webRequest = (HttpWebRequest)WebRequest.Create(downloadOptions.Url); - } - } - catch (Exception /*ex*/) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, - new FileTransferError(InvalidUrlError, downloadOptions.Url, null, 0))); - return; - } - - if (downloadOptions != null && webRequest != null) - { - DownloadRequestState state = new DownloadRequestState(); - state.options = downloadOptions; - state.request = webRequest; - InProcDownloads[downloadOptions.Id] = state; - - try - { - // Associate cookies with the request - // This is an async call, so we need to await it in order to preserve proper control flow - Task cookieTask = CopyCookiesFromWebBrowser(webRequest); - cookieTask.Wait(); - } - catch (AggregateException ae) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, - new FileTransferError(FileTransfer.ConnectionError, downloadOptions.Url, downloadOptions.FilePath, 0, ae.InnerException.Message))); - return; - } - - if (!string.IsNullOrEmpty(downloadOptions.Headers)) - { - Dictionary headers = parseHeaders(downloadOptions.Headers); - foreach (string key in headers.Keys) - { - webRequest.Headers[key] = headers[key]; - } - } - - try - { - webRequest.BeginGetResponse(new AsyncCallback(downloadCallback), state); - } - catch (WebException) - { - // eat it - } - // dispatch an event for progress ( 0 ) - lock (state) - { - if (!state.isCancelled) - { - var plugRes = new PluginResult(PluginResult.Status.OK, new FileTransferProgress()); - plugRes.KeepCallback = true; - plugRes.CallbackId = callbackId; - DispatchCommandResult(plugRes, callbackId); - } - } - } - } - - public void abort(string options) - { - Debug.WriteLine("Abort :: " + options); - string[] optionStrings = JSON.JsonHelper.Deserialize(options); - string id = optionStrings[0]; - string callbackId = optionStrings[1]; - - if (id != null && InProcDownloads.ContainsKey(id)) - { - DownloadRequestState state = InProcDownloads[id]; - if (!state.isCancelled) - { // prevent multiple callbacks for the same abort - state.isCancelled = true; - if (!state.request.HaveResponse) - { - state.request.Abort(); - InProcDownloads.Remove(id); - //callbackId = state.options.CallbackId; - //state = null; - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, - new FileTransferError(FileTransfer.AbortError)), - state.options.CallbackId); - } - } - } - else - { - DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION), callbackId); // TODO: is it an IO exception? - } - } - - private void DispatchFileTransferProgress(long bytesLoaded, long bytesTotal, string callbackId, bool keepCallback = true) - { - Debug.WriteLine("DispatchFileTransferProgress : " + callbackId); - // send a progress change event - FileTransferProgress progEvent = new FileTransferProgress(bytesTotal); - progEvent.BytesLoaded = bytesLoaded; - PluginResult plugRes = new PluginResult(PluginResult.Status.OK, progEvent); - plugRes.KeepCallback = keepCallback; - plugRes.CallbackId = callbackId; - DispatchCommandResult(plugRes, callbackId); - } - - /// - /// - /// - /// - private void downloadCallback(IAsyncResult asynchronousResult) - { - DownloadRequestState reqState = (DownloadRequestState)asynchronousResult.AsyncState; - HttpWebRequest request = reqState.request; - - string callbackId = reqState.options.CallbackId; - try - { - HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); - - // send a progress change event - DispatchFileTransferProgress(0, response.ContentLength, callbackId); - - using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication()) - { - // create any directories in the path that do not exist - string directoryName = getDirectoryName(reqState.options.FilePath); - if (!string.IsNullOrEmpty(directoryName) && !isoFile.DirectoryExists(directoryName)) - { - isoFile.CreateDirectory(directoryName); - } - - // create the file if not exists - if (!isoFile.FileExists(reqState.options.FilePath)) - { - var file = isoFile.CreateFile(reqState.options.FilePath); - file.Close(); - } - - using (FileStream fileStream = new IsolatedStorageFileStream(reqState.options.FilePath, FileMode.Open, FileAccess.Write, isoFile)) - { - long totalBytes = response.ContentLength; - int bytesRead = 0; - using (BinaryReader reader = new BinaryReader(response.GetResponseStream())) - { - using (BinaryWriter writer = new BinaryWriter(fileStream)) - { - int BUFFER_SIZE = 1024; - byte[] buffer; - - while (true) - { - buffer = reader.ReadBytes(BUFFER_SIZE); - // fire a progress event ? - bytesRead += buffer.Length; - if (buffer.Length > 0 && !reqState.isCancelled) - { - writer.Write(buffer); - DispatchFileTransferProgress(bytesRead, totalBytes, callbackId); - } - else - { - writer.Close(); - reader.Close(); - fileStream.Close(); - break; - } - System.Threading.Thread.Sleep(1); - } - } - } - } - if (reqState.isCancelled) - { - isoFile.DeleteFile(reqState.options.FilePath); - } - } - - if (reqState.isCancelled) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(AbortError)), - callbackId); - } - else - { - File.FileEntry entry = new File.FileEntry(reqState.options.FilePath); - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry), callbackId); - } - } - catch (IsolatedStorageException) - { - // Trying to write the file somewhere within the IsoStorage. - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(FileNotFoundError)), - callbackId); - } - catch (SecurityException) - { - // Trying to write the file somewhere not allowed. - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(FileNotFoundError)), - callbackId); - } - catch (WebException webex) - { - // TODO: probably need better work here to properly respond with all http status codes back to JS - // Right now am jumping through hoops just to detect 404. - HttpWebResponse response = (HttpWebResponse)webex.Response; - if ((webex.Status == WebExceptionStatus.ProtocolError && response.StatusCode == HttpStatusCode.NotFound) - || webex.Status == WebExceptionStatus.UnknownError) - { - // Weird MSFT detection of 404... seriously... just give us the f(*&#$@ status code as a number ffs!!! - // "Numbers for HTTP status codes? Nah.... let's create our own set of enums/structs to abstract that stuff away." - // FACEPALM - // Or just cast it to an int, whiner ... -jm - int statusCode = (int)response.StatusCode; - string body = ""; - - using (Stream streamResponse = response.GetResponseStream()) - { - using (StreamReader streamReader = new StreamReader(streamResponse)) - { - body = streamReader.ReadToEnd(); - } - } - FileTransferError ftError = new FileTransferError(ConnectionError, null, null, statusCode, body); - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ftError), - callbackId); - } - else - { - lock (reqState) - { - if (!reqState.isCancelled) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, - new FileTransferError(ConnectionError)), - callbackId); - } - else - { - Debug.WriteLine("It happened"); - } - } - } - } - catch (Exception) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, - new FileTransferError(FileNotFoundError)), - callbackId); - } - - //System.Threading.Thread.Sleep(1000); - if (InProcDownloads.ContainsKey(reqState.options.Id)) - { - InProcDownloads.Remove(reqState.options.Id); - } - } - - /// - /// Read file from Isolated Storage and sends it to server - /// - /// - private void uploadCallback(IAsyncResult asynchronousResult) - { - DownloadRequestState reqState = (DownloadRequestState)asynchronousResult.AsyncState; - HttpWebRequest webRequest = reqState.request; - string callbackId = reqState.options.CallbackId; - - try - { - using (Stream requestStream = (webRequest.EndGetRequestStream(asynchronousResult))) - { - string lineStart = "--"; - string lineEnd = Environment.NewLine; - byte[] boundaryBytes = System.Text.Encoding.UTF8.GetBytes(lineStart + Boundary + lineEnd); - string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"" + lineEnd + lineEnd + "{1}" + lineEnd; - - if (!string.IsNullOrEmpty(reqState.options.Params)) - { - Dictionary paramMap = parseHeaders(reqState.options.Params); - foreach (string key in paramMap.Keys) - { - requestStream.Write(boundaryBytes, 0, boundaryBytes.Length); - string formItem = string.Format(formdataTemplate, key, paramMap[key]); - byte[] formItemBytes = System.Text.Encoding.UTF8.GetBytes(formItem); - requestStream.Write(formItemBytes, 0, formItemBytes.Length); - } - } - using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication()) - { - if (!isoFile.FileExists(reqState.options.FilePath)) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(FileNotFoundError, reqState.options.Server, reqState.options.FilePath, 0))); - return; - } - - byte[] endRequest = System.Text.Encoding.UTF8.GetBytes(lineEnd + lineStart + Boundary + lineStart + lineEnd); - long totalBytesToSend = 0; - - using (FileStream fileStream = new IsolatedStorageFileStream(reqState.options.FilePath, FileMode.Open, isoFile)) - { - string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + lineEnd + "Content-Type: {2}" + lineEnd + lineEnd; - string header = string.Format(headerTemplate, reqState.options.FileKey, reqState.options.FileName, reqState.options.MimeType); - byte[] headerBytes = System.Text.Encoding.UTF8.GetBytes(header); - - byte[] buffer = new byte[4096]; - int bytesRead = 0; - //sent bytes needs to be reseted before new upload - bytesSent = 0; - totalBytesToSend = fileStream.Length; - - requestStream.Write(boundaryBytes, 0, boundaryBytes.Length); - - requestStream.Write(headerBytes, 0, headerBytes.Length); - - while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0) - { - if (!reqState.isCancelled) - { - requestStream.Write(buffer, 0, bytesRead); - bytesSent += bytesRead; - DispatchFileTransferProgress(bytesSent, totalBytesToSend, callbackId); - System.Threading.Thread.Sleep(1); - } - else - { - throw new Exception("UploadCancelledException"); - } - } - } - - requestStream.Write(endRequest, 0, endRequest.Length); - } - } - // webRequest - - webRequest.BeginGetResponse(ReadCallback, reqState); - } - catch (Exception /*ex*/) - { - if (!reqState.isCancelled) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(ConnectionError)), callbackId); - } - } - } - - /// - /// Reads response into FileUploadResult - /// - /// - private void ReadCallback(IAsyncResult asynchronousResult) - { - DownloadRequestState reqState = (DownloadRequestState)asynchronousResult.AsyncState; - try - { - HttpWebRequest webRequest = reqState.request; - string callbackId = reqState.options.CallbackId; - - if (InProcDownloads.ContainsKey(reqState.options.Id)) - { - InProcDownloads.Remove(reqState.options.Id); - } - - using (HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult)) - { - using (Stream streamResponse = response.GetResponseStream()) - { - using (StreamReader streamReader = new StreamReader(streamResponse)) - { - string responseString = streamReader.ReadToEnd(); - Deployment.Current.Dispatcher.BeginInvoke(() => - { - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileUploadResult(bytesSent, (long)response.StatusCode, responseString))); - }); - } - } - } - } - catch (WebException webex) - { - // TODO: probably need better work here to properly respond with all http status codes back to JS - // Right now am jumping through hoops just to detect 404. - if ((webex.Status == WebExceptionStatus.ProtocolError && ((HttpWebResponse)webex.Response).StatusCode == HttpStatusCode.NotFound) - || webex.Status == WebExceptionStatus.UnknownError) - { - int statusCode = (int)((HttpWebResponse)webex.Response).StatusCode; - FileTransferError ftError = new FileTransferError(ConnectionError, null, null, statusCode); - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ftError), reqState.options.CallbackId); - } - else - { - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, - new FileTransferError(ConnectionError)), - reqState.options.CallbackId); - } - } - catch (Exception /*ex*/) - { - FileTransferError transferError = new FileTransferError(ConnectionError, reqState.options.Server, reqState.options.FilePath, 403); - DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, transferError), reqState.options.CallbackId); - } - } - - // Gets the full path without the filename - private string getDirectoryName(String filePath) - { - string directoryName; - try - { - directoryName = filePath.Substring(0, filePath.LastIndexOf('/')); - } - catch - { - directoryName = ""; - } - return directoryName; - } - } -} diff --git a/plugins/cordova-plugin-file-transfer/tests/plugin.xml b/plugins/cordova-plugin-file-transfer/tests/plugin.xml deleted file mode 100644 index 9cb77c9..0000000 --- a/plugins/cordova-plugin-file-transfer/tests/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Cordova File Transfer Plugin Tests - Apache 2.0 - - - - diff --git a/plugins/cordova-plugin-file-transfer/tests/tests.js b/plugins/cordova-plugin-file-transfer/tests/tests.js deleted file mode 100644 index 1a1ffbb..0000000 --- a/plugins/cordova-plugin-file-transfer/tests/tests.js +++ /dev/null @@ -1,1356 +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. -* -*/ - -/* global exports, cordova, FileTransfer, FileTransferError, FileUploadOptions, LocalFileSystem */ - -/* global describe, it, expect, beforeEach, afterEach, spyOn, jasmine, pending */ - -exports.defineAutoTests = function () { - - "use strict"; - - // constants - var ONE_SECOND = 1000; // in milliseconds - var GRACE_TIME_DELTA = 600; // in milliseconds - var DEFAULT_FILESYSTEM_SIZE = 1024 * 50; // filesystem size in bytes - var WINDOWS_GRACE_TIME_DELTA = 5 * ONE_SECOND; // Some Windows devices need a few seconds to create an upload/download operation. - var UNKNOWN_HOST = "http://foobar.apache.org"; - var HEADERS_ECHO = "http://whatheaders.com"; // NOTE: this site is very useful! - var DOWNLOAD_TIMEOUT = 7 * ONE_SECOND; - var WINDOWS_UNKNOWN_HOST_TIMEOUT = 35 * ONE_SECOND; - var UPLOAD_TIMEOUT = 7 * ONE_SECOND; - var ABORT_DELAY = 100; // for abort() tests - var LATIN1_SYMBOLS = '¥§©ÆÖÑøøø¼'; - var DATA_URI_PREFIX = "data:image/png;base64,"; - var DATA_URI_CONTENT = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; - var DATA_URI_CONTENT_LENGTH = 85; // bytes. (This is the raw file size: used https://en.wikipedia.org/wiki/File:Red-dot-5px.png from https://en.wikipedia.org/wiki/Data_URI_scheme) - - // config for upload test server - // NOTE: - // more info at https://github.com/apache/cordova-labs/tree/cordova-filetransfer - var SERVER = "http://cordova-vm.apache.org:5000"; - var SERVER_WITH_CREDENTIALS = "http://cordova_user:cordova_password@cordova-vm.apache.org:5000"; - - // flags - var isWindows = cordova.platformId === "windows8" || cordova.platformId === "windows"; - var isWP8 = cordova.platformId === "windowsphone"; - var isBrowser = cordova.platformId === "browser"; - var isIE = isBrowser && navigator.userAgent.indexOf("Trident") >= 0; - var isIos = cordova.platformId === "ios"; - - // tests - describe("FileTransferError", function () { - - it("should exist", function () { - expect(FileTransferError).toBeDefined(); - }); - - it("should be constructable", function () { - var transferError = new FileTransferError(); - expect(transferError).toBeDefined(); - }); - - it("filetransfer.spec.3 should expose proper constants", function () { - - expect(FileTransferError.FILE_NOT_FOUND_ERR).toBeDefined(); - expect(FileTransferError.INVALID_URL_ERR).toBeDefined(); - expect(FileTransferError.CONNECTION_ERR).toBeDefined(); - expect(FileTransferError.ABORT_ERR).toBeDefined(); - expect(FileTransferError.NOT_MODIFIED_ERR).toBeDefined(); - - expect(FileTransferError.FILE_NOT_FOUND_ERR).toBe(1); - expect(FileTransferError.INVALID_URL_ERR).toBe(2); - expect(FileTransferError.CONNECTION_ERR).toBe(3); - expect(FileTransferError.ABORT_ERR).toBe(4); - expect(FileTransferError.NOT_MODIFIED_ERR).toBe(5); - }); - }); - - describe("FileUploadOptions", function () { - - it("should exist", function () { - expect(FileUploadOptions).toBeDefined(); - }); - - it("should be constructable", function () { - var transferOptions = new FileUploadOptions(); - expect(transferOptions).toBeDefined(); - }); - }); - - describe("FileTransfer", function () { - - var persistentRoot, tempRoot; - - // named callbacks - var unexpectedCallbacks = { - httpFail: function () {}, - httpWin: function () {}, - fileSystemFail: function () {}, - fileSystemWin: function () {}, - fileOperationFail: function () {}, - fileOperationWin: function () {}, - }; - - var expectedCallbacks = { - unsupportedOperation: function (response) { - console.log("spec called unsupported functionality; response:", response); - }, - }; - - // helpers - var deleteFile = function (fileSystem, name, done) { - fileSystem.getFile(name, null, - function (fileEntry) { - fileEntry.remove( - function () { - done(); - }, - function () { - throw new Error("failed to delete: '" + name + "'"); - } - ); - }, - function () { - done(); - } - ); - }; - - var writeFile = function (fileSystem, name, content, success) { - fileSystem.getFile(name, { create: true }, - function (fileEntry) { - fileEntry.createWriter(function (writer) { - - writer.onwrite = function () { - success(fileEntry); - }; - - writer.onabort = function (evt) { - throw new Error("aborted creating test file '" + name + "': " + evt); - }; - - writer.error = function (evt) { - throw new Error("aborted creating test file '" + name + "': " + evt); - }; - - if (cordova.platformId === "browser") { - var blob = new Blob([content + "\n"], { type: "text/plain" }); - writer.write(blob); - } else { - writer.write(content + "\n"); - } - - }, unexpectedCallbacks.fileOperationFail); - }, - function () { - throw new Error("could not create test file '" + name + "'"); - } - ); - }; - - // according to documentation, wp8 does not support onProgress: - // https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#supported-platforms - var wp8OnProgressHandler = function () {}; - - var defaultOnProgressHandler = function (event) { - if (event.lengthComputable) { - expect(event.loaded).toBeGreaterThan(1); - expect(event.total).toBeGreaterThan(0); - expect(event.total).not.toBeLessThan(event.loaded); - expect(event.lengthComputable).toBe(true, "lengthComputable"); - } else { - // In IE, when lengthComputable === false, event.total somehow is equal to 2^64 - if (isIE) { - expect(event.total).toBe(Math.pow(2, 64)); - } else { - // iOS returns -1, and other platforms return 0 - expect(event.total).toBeLessThan(1); - } - } - }; - - var getMalformedUrl = function () { - if (cordova.platformId === "android" || cordova.platformId === "amazon-fireos") { - // bad protocol causes a MalformedUrlException on Android - return "httpssss://example.com"; - } else { - // iOS doesn't care about protocol, space in hostname causes error - return "httpssss://exa mple.com"; - } - }; - - // NOTE: - // there are several beforeEach calls, one per async call; since calling done() - // signifies a completed async call, each async call needs its own done(), and - // therefore its own beforeEach - beforeEach(function (done) { - window.requestFileSystem(LocalFileSystem.PERSISTENT, DEFAULT_FILESYSTEM_SIZE, - function (fileSystem) { - persistentRoot = fileSystem.root; - done(); - }, - function () { - throw new Error("Failed to initialize persistent file system."); - } - ); - }); - - beforeEach(function (done) { - window.requestFileSystem(LocalFileSystem.TEMPORARY, DEFAULT_FILESYSTEM_SIZE, - function (fileSystem) { - tempRoot = fileSystem.root; - done(); - }, - function () { - throw new Error("Failed to initialize temporary file system."); - } - ); - }); - - // spy on all named callbacks - beforeEach(function() { - - // ignore the actual implementations of the unexpected callbacks - for (var callback in unexpectedCallbacks) { - if (unexpectedCallbacks.hasOwnProperty(callback)) { - spyOn(unexpectedCallbacks, callback); - } - } - - // but run the implementations of the expected callbacks - for (callback in expectedCallbacks) { // jshint ignore: line - if (expectedCallbacks.hasOwnProperty(callback)) { - spyOn(expectedCallbacks, callback).and.callThrough(); - } - } - }); - - // at the end, check that none of the unexpected callbacks got called, - // and act on the expected callbacks - afterEach(function() { - for (var callback in unexpectedCallbacks) { - if (unexpectedCallbacks.hasOwnProperty(callback)) { - expect(unexpectedCallbacks[callback]).not.toHaveBeenCalled(); - } - } - - if (expectedCallbacks.unsupportedOperation.calls.any()) { - pending(); - } - }); - - it("should initialise correctly", function() { - expect(persistentRoot).toBeDefined(); - expect(tempRoot).toBeDefined(); - }); - - it("should exist", function () { - expect(FileTransfer).toBeDefined(); - }); - - it("filetransfer.spec.1 should be constructable", function () { - var transfer = new FileTransfer(); - expect(transfer).toBeDefined(); - }); - - it("filetransfer.spec.2 should expose proper functions", function () { - - var transfer = new FileTransfer(); - - expect(transfer.upload).toBeDefined(); - expect(transfer.download).toBeDefined(); - - expect(transfer.upload).toEqual(jasmine.any(Function)); - expect(transfer.download).toEqual(jasmine.any(Function)); - }); - - describe("methods", function() { - - var transfer; - - var root; - var fileName; - var localFilePath; - - beforeEach(function() { - - transfer = new FileTransfer(); - - // assign onprogress handler - transfer.onprogress = isWP8 ? wp8OnProgressHandler : defaultOnProgressHandler; - - // spy on the onprogress handler, but still call through to it - spyOn(transfer, "onprogress").and.callThrough(); - - root = persistentRoot; - fileName = "testFile.txt"; - localFilePath = root.toURL() + fileName; - }); - - // NOTE: - // if download tests are failing, check the - // URL white list for the following URLs: - // - 'httpssss://example.com' - // - 'apache.org', with subdomains="true" - // - 'cordova-filetransfer.jitsu.com' - describe("download", function () { - - // helpers - var verifyDownload = function (fileEntry) { - expect(fileEntry.name).toBe(fileName); - }; - - // delete the downloaded file - afterEach(function (done) { - deleteFile(root, fileName, done); - }); - - it("ensures that test file does not exist", function (done) { - deleteFile(root, fileName, done); - }); - - it("filetransfer.spec.4 should download a file", function (done) { - - var fileURL = SERVER + "/robots.txt"; - - var fileWin = function (blob) { - - if (transfer.onprogress.calls.any()) { - var lastProgressEvent = transfer.onprogress.calls.mostRecent().args[0]; - expect(lastProgressEvent.loaded).not.toBeGreaterThan(blob.size); - } else { - console.log("no progress events were emitted"); - } - - done(); - }; - - var downloadWin = function (entry) { - - verifyDownload(entry); - - // verify the FileEntry representing this file - entry.file(fileWin, unexpectedCallbacks.fileSystemFail); - }; - - transfer.download(fileURL, localFilePath, downloadWin, unexpectedCallbacks.httpFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.5 should download a file using http basic auth", function (done) { - - var fileURL = SERVER_WITH_CREDENTIALS + "/download_basic_auth"; - - var downloadWin = function (entry) { - verifyDownload(entry); - done(); - }; - - transfer.download(fileURL, localFilePath, downloadWin, unexpectedCallbacks.httpFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.6 should get 401 status on http basic auth failure", function (done) { - - // NOTE: - // using server without credentials - var fileURL = SERVER + "/download_basic_auth"; - - var downloadFail = function (error) { - expect(error.http_status).toBe(401); - expect(error.http_status).not.toBe(404, "Ensure " + fileURL + " is in the white list"); - done(); - }; - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail, null, - { - headers: { - "If-Modified-Since": "Thu, 19 Mar 2015 00:00:00 GMT" - } - }); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.7 should download a file using file:// (when hosted from file://)", function (done) { - - // for Windows platform it's ms-appdata:/// by default, not file:// - if (isWindows) { - pending(); - return; - } - - var fileURL = window.location.protocol + "//" + window.location.pathname.replace(/ /g, "%20"); - - if (!/^file:/.exec(fileURL) && cordova.platformId !== "blackberry10") { - if (cordova.platformId === "windowsphone") { - expect(fileURL).toMatch(/^x-wmapp0:/); - } - done(); - return; - } - - var downloadWin = function (entry) { - verifyDownload(entry); - done(); - }; - - transfer.download(fileURL, localFilePath, downloadWin, unexpectedCallbacks.httpFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.8 should download a file using https://", function (done) { - - var fileURL = "https://www.apache.org/licenses/"; - - var fileWin = function (file) { - - var reader = new FileReader(); - - reader.onerror = unexpectedCallbacks.fileOperationFail; - reader.onload = function () { - expect(reader.result).toMatch(/The Apache Software Foundation/); - done(); - }; - - reader.readAsText(file); - }; - - var downloadWin = function (entry) { - verifyDownload(entry); - entry.file(fileWin, unexpectedCallbacks.fileSystemFail); - }; - - transfer.download(fileURL, localFilePath, downloadWin, unexpectedCallbacks.httpFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.11 should call the error callback on abort()", function (done) { - - var fileURL = "http://cordova.apache.org/downloads/BlueZedEx.mp3"; - fileURL = fileURL + "?q=" + (new Date()).getTime(); - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, done); - setTimeout(function() { - transfer.abort(); - }, ABORT_DELAY); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.9 should not leave partial file due to abort", function (done) { - - var fileURL = "http://cordova.apache.org/downloads/logos_2.zip"; - - var downloadFail = function (error) { - - expect(error.code).toBe(FileTransferError.ABORT_ERR); - expect(transfer.onprogress).toHaveBeenCalled(); - - // check that there is no file - root.getFile(fileName, null, unexpectedCallbacks.fileSystemWin, done); - }; - - // abort at the first onprogress event - transfer.onprogress = function (event) { - if (event.loaded > 0) { - transfer.abort(); - } - }; - - spyOn(transfer, "onprogress").and.callThrough(); - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.10 should be stopped by abort() right away", function (done) { - - var fileURL = "http://cordova.apache.org/downloads/BlueZedEx.mp3"; - fileURL = fileURL + "?q=" + (new Date()).getTime(); - - expect(transfer.abort).not.toThrow(); // should be a no-op. - - var startTime = +new Date(); - - var downloadFail = function (error) { - - expect(error.code).toBe(FileTransferError.ABORT_ERR); - expect(new Date() - startTime).toBeLessThan(isWindows ? WINDOWS_GRACE_TIME_DELTA : GRACE_TIME_DELTA); - - // delay calling done() to wait for the bogus abort() - setTimeout(done, GRACE_TIME_DELTA * 2); - }; - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail); - setTimeout(function() { - transfer.abort(); - }, ABORT_DELAY); - - // call abort() again, after a time greater than the grace period - setTimeout(function () { - expect(transfer.abort).not.toThrow(); - }, GRACE_TIME_DELTA); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.12 should get http status on failure", function (done) { - - var fileURL = SERVER + "/404"; - - var downloadFail = function (error) { - - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - expect(error.http_status).toBe(404); - - // wp8 does not make difference between 404 and unknown host - if (isWP8) { - expect(error.code).toBe(FileTransferError.CONNECTION_ERR); - } else { - expect(error.code).toBe(FileTransferError.FILE_NOT_FOUND_ERR); - } - - done(); - }; - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.13 should get http body on failure", function (done) { - - var fileURL = SERVER + "/404"; - - var downloadFail = function (error) { - - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - expect(error.http_status).toBe(404); - - expect(error.body).toBeDefined(); - expect(error.body).toMatch("You requested a 404"); - - done(); - }; - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.14 should handle malformed urls", function (done) { - - var fileURL = getMalformedUrl(); - - var downloadFail = function (error) { - - // Note: Android needs the bad protocol to be added to the access list - // won't match because ^https?:// is prepended to the regex - // The bad protocol must begin with http to avoid automatic prefix - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - expect(error.code).toBe(FileTransferError.INVALID_URL_ERR); - - done(); - }; - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail); - }); - - it("filetransfer.spec.15 should handle unknown host", function (done) { - var fileURL = UNKNOWN_HOST; - - var downloadFail = function (error) { - expect(error.code).toBe(FileTransferError.CONNECTION_ERR); - done(); - }; - - // turn off the onprogress handler - transfer.onprogress = function () {}; - - transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail); - }, isWindows ? WINDOWS_UNKNOWN_HOST_TIMEOUT : DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.16 should handle bad file path", function (done) { - var fileURL = SERVER; - transfer.download(fileURL, "c:\\54321", unexpectedCallbacks.httpWin, done); - }); - - it("filetransfer.spec.17 progress should work with gzip encoding", function (done) { - - // lengthComputable false on bb10 when downloading gzip - if (cordova.platformId === "blackberry10") { - pending(); - return; - } - - var fileURL = "http://www.apache.org/"; - - var downloadWin = function (entry) { - verifyDownload(entry); - done(); - }; - - transfer.download(fileURL, localFilePath, downloadWin, unexpectedCallbacks.httpFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.30 downloaded file entries should have a toNativeURL method", function (done) { - - if (cordova.platformId === "browser") { - pending(); - return; - } - - var fileURL = SERVER + "/robots.txt"; - - var downloadWin = function (entry) { - - expect(entry.toNativeURL).toBeDefined(); - expect(entry.toNativeURL).toEqual(jasmine.any(Function)); - - var nativeURL = entry.toNativeURL(); - - expect(nativeURL).toBeTruthy(); - expect(nativeURL).toEqual(jasmine.any(String)); - - if (isWindows) { - expect(nativeURL.substring(0, 14)).toBe("ms-appdata:///"); - } else if (isWP8) { - expect(nativeURL.substring(0, 1)).toBe("/"); - } else { - expect(nativeURL.substring(0, 7)).toBe("file://"); - } - - done(); - }; - - transfer.download(fileURL, localFilePath, downloadWin, unexpectedCallbacks.httpFail); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.28 (compatibility) should be able to download a file using local paths", function (done) { - - var fileURL = SERVER + "/robots.txt"; - - var unsupported = function (response) { - expectedCallbacks.unsupportedOperation(response); - done(); - }; - - var downloadWin = function (entry) { - verifyDownload(entry); - done(); - }; - - var internalFilePath; - if (root.toInternalURL) { - internalFilePath = root.toInternalURL() + fileName; - } else { - internalFilePath = localFilePath; - } - - // This is an undocumented interface to File which exists only for testing - // backwards compatibilty. By obtaining the raw filesystem path of the download - // location, we can pass that to transfer.download() to make sure that previously-stored - // paths are still valid. - cordova.exec(function (localPath) { - transfer.download(fileURL, localPath, downloadWin, unexpectedCallbacks.httpFail); - }, unsupported, "File", "_getLocalFilesystemPath", [internalFilePath]); - }); - - it("filetransfer.spec.33 should properly handle 304", function (done) { - - if (isWP8) { - pending(); - return; - } - - var imageURL = "http://apache.org/images/feather-small.gif"; - var lastModified = new Date(); - - var downloadFail = function (error) { - expect(error.http_status).toBe(304); - expect(error.code).toBe(FileTransferError.NOT_MODIFIED_ERR); - done(); - }; - - transfer.download(imageURL + "?q=" + lastModified.getTime(), localFilePath, unexpectedCallbacks.httpWin, downloadFail, null, - { - headers: { - "If-Modified-Since": lastModified.toUTCString() - } - }); - }, DOWNLOAD_TIMEOUT); - - it("filetransfer.spec.35 304 should not result in the deletion of a cached file", function (done) { - - if (isWP8) { - pending(); - return; - } - - var imageURL = "http://apache.org/images/feather-small.gif"; - var lastModified = new Date(); - - var downloadFail = function (error) { - expect(error.http_status).toBe(304); - expect(error.code).toBe(FileTransferError.NOT_MODIFIED_ERR); - - persistentRoot.getFile(fileName, { create: false }, - function (entry) { - var fileWin = function (file) { - var reader = new FileReader(); - - reader.onerror = unexpectedCallbacks.fileOperationFail; - reader.onloadend = function () { - - expect(reader.result).toBeTruthy(); - if (reader.result !== null) { - expect(reader.result.length).toBeGreaterThan(0); - } - - done(); - }; - - reader.readAsBinaryString(file); - }; - - entry.file(fileWin, unexpectedCallbacks.fileSystemFail); - }, - function (err) { - expect("Could not open test file '" + fileName + "': " + JSON.stringify(err)).not.toBeDefined(); - done(); - } - ); - }; - - // Adding parameters to the requests to avoid caching on iOS, which leads to 200 - // instead of 304 in result of the second request. (a similar issue is described in CB-8606, CB-10088) - transfer.download(imageURL + "?q=" + lastModified.getTime(), localFilePath, function () { - transfer.download(imageURL + "?q=" + (lastModified.getTime() + 1), localFilePath, unexpectedCallbacks.httpWin, downloadFail, null, - { - headers: { - "If-Modified-Since": lastModified.toUTCString() - } - }); - }, unexpectedCallbacks.httpFail); - }, DOWNLOAD_TIMEOUT * 2); - - it("filetransfer.spec.36 should handle non-UTF8 encoded download response", function (done) { - - // Only iOS is supported: https://issues.apache.org/jira/browse/CB-9840 - if (!isIos) { - pending(); - } - - var fileURL = SERVER + '/download_non_utf'; - - var fileWin = function (blob) { - - if (transfer.onprogress.calls.any()) { - var lastProgressEvent = transfer.onprogress.calls.mostRecent().args[0]; - expect(lastProgressEvent.loaded).not.toBeGreaterThan(blob.size); - } else { - console.log("no progress events were emitted"); - } - - expect(blob.size).toBeGreaterThan(0); - - var reader = new FileReader(); - - reader.onerror = unexpectedCallbacks.fileOperationFail; - reader.onloadend = function () { - expect(reader.result.indexOf(LATIN1_SYMBOLS)).not.toBe(-1); - done(); - }; - - reader.readAsBinaryString(blob); - }; - - var downloadWin = function (entry) { - - verifyDownload(entry); - - // verify the FileEntry representing this file - entry.file(fileWin, unexpectedCallbacks.fileSystemFail); - }; - - transfer.download(fileURL, localFilePath, downloadWin, unexpectedCallbacks.httpFail); - }, UPLOAD_TIMEOUT); - }); - - describe("upload", function() { - - var uploadParams; - var uploadOptions; - - var fileName; - var fileContents; - var localFilePath; - - // helpers - var verifyUpload = function (uploadResult) { - - expect(uploadResult.bytesSent).toBeGreaterThan(0); - expect(uploadResult.responseCode).toBe(200); - - var obj = null; - try { - obj = JSON.parse(uploadResult.response); - expect(obj.fields).toBeDefined(); - expect(obj.fields.value1).toBe("test"); - expect(obj.fields.value2).toBe("param"); - } catch (e) { - expect(obj).not.toBeNull("returned data from server should be valid json"); - } - - expect(transfer.onprogress).toHaveBeenCalled(); - }; - - beforeEach(function(done) { - - fileName = "fileToUpload.txt"; - fileContents = "upload test file"; - - uploadParams = {}; - uploadParams.value1 = "test"; - uploadParams.value2 = "param"; - - uploadOptions = new FileUploadOptions(); - uploadOptions.fileKey = "file"; - uploadOptions.fileName = fileName; - uploadOptions.mimeType = "text/plain"; - uploadOptions.params = uploadParams; - - var fileWin = function (entry) { - localFilePath = entry.toURL(); - done(); - }; - - // create a file to upload - writeFile(root, fileName, fileContents, fileWin); - }); - - // delete the uploaded file - afterEach(function (done) { - deleteFile(root, fileName, done); - }); - - it("filetransfer.spec.18 should be able to upload a file", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadWin = function (uploadResult) { - - verifyUpload(uploadResult); - - if (cordova.platformId === "ios") { - expect(uploadResult.headers).toBeDefined("Expected headers to be defined."); - expect(uploadResult.headers["Content-Type"]).toBeDefined("Expected content-type header to be defined."); - } - - done(); - }; - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.19 should be able to upload a file with http basic auth", function (done) { - - var fileURL = SERVER_WITH_CREDENTIALS + "/upload_basic_auth"; - - var uploadWin = function (uploadResult) { - verifyUpload(uploadResult); - done(); - }; - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.21 should be stopped by abort() right away", function (done) { - - var fileURL = SERVER + "/upload"; - var startTime; - - var uploadFail = function (e) { - expect(e.code).toBe(FileTransferError.ABORT_ERR); - expect(new Date() - startTime).toBeLessThan(isWindows ? WINDOWS_GRACE_TIME_DELTA : GRACE_TIME_DELTA); - - // delay calling done() to wait for the bogus abort() - setTimeout(done, GRACE_TIME_DELTA * 2); - }; - - var fileWin = function () { - - startTime = +new Date(); - - expect(transfer.abort).not.toThrow(); - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, unexpectedCallbacks.httpWin, uploadFail, uploadOptions); - setTimeout(function() { - transfer.abort(); - }, ABORT_DELAY); - - setTimeout(function () { - expect(transfer.abort).not.toThrow(); - }, GRACE_TIME_DELTA); - }; - - writeFile(root, fileName, new Array(200000).join("aborttest!"), fileWin); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.22 should get http status and body on failure", function (done) { - - var fileURL = SERVER + "/403"; - - var uploadFail = function (error) { - expect(error.http_status).toBe(403); - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - done(); - }; - - transfer.upload(localFilePath, fileURL, unexpectedCallbacks.httpWin, uploadFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.24 should handle malformed urls", function (done) { - - var fileURL = getMalformedUrl(); - - var uploadFail = function (error) { - expect(error.code).toBe(FileTransferError.INVALID_URL_ERR); - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - done(); - }; - - transfer.upload(localFilePath, fileURL, unexpectedCallbacks.httpWin, uploadFail, {}); - }); - - it("filetransfer.spec.25 should handle unknown host", function (done) { - - var fileURL = UNKNOWN_HOST; - - var uploadFail = function (error) { - expect(error.code).toBe(FileTransferError.CONNECTION_ERR); - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - done(); - }; - - transfer.upload(localFilePath, fileURL, unexpectedCallbacks.httpWin, uploadFail, {}); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.25 should handle missing file", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadFail = function (error) { - expect(error.code).toBe(FileTransferError.FILE_NOT_FOUND_ERR); - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - done(); - }; - - transfer.upload("does_not_exist.txt", fileURL, unexpectedCallbacks.httpWin, uploadFail); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.26 should handle bad file path", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadFail = function (error) { - expect(error.http_status).not.toBe(401, "Ensure " + fileURL + " is in the white list"); - done(); - }; - - transfer.upload("c:\\54321", fileURL, unexpectedCallbacks.httpWin, uploadFail); - }); - - it("filetransfer.spec.27 should be able to set custom headers", function (done) { - - var fileURL = HEADERS_ECHO; - - var uploadWin = function (uploadResult) { - - expect(uploadResult.bytesSent).toBeGreaterThan(0); - expect(uploadResult.responseCode).toBe(200); - expect(uploadResult.response).toBeDefined(); - - var responseHtml = decodeURIComponent(uploadResult.response); - - expect(responseHtml).toMatch(/CustomHeader1[\s\S]*CustomValue1/i); - expect(responseHtml).toMatch(/CustomHeader2[\s\S]*CustomValue2[\s\S]*CustomValue3/i, "Should allow array values"); - - done(); - }; - - uploadOptions.headers = { - "CustomHeader1": "CustomValue1", - "CustomHeader2": ["CustomValue2", "CustomValue3"], - }; - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.29 (compatibility) should be able to upload a file using local paths", function (done) { - - var fileURL = SERVER + "/upload"; - - var unsupported = function (response) { - expectedCallbacks.unsupportedOperation(response); - done(); - }; - - var uploadWin = function (uploadResult) { - verifyUpload(uploadResult); - done(); - }; - - var internalFilePath; - if (root.toInternalURL) { - internalFilePath = root.toInternalURL() + fileName; - } else { - internalFilePath = localFilePath; - } - - // This is an undocumented interface to File which exists only for testing - // backwards compatibilty. By obtaining the raw filesystem path of the download - // location, we can pass that to transfer.download() to make sure that previously-stored - // paths are still valid. - cordova.exec(function (localPath) { - transfer.upload(localPath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, unsupported, "File", "_getLocalFilesystemPath", [internalFilePath]); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.31 should be able to upload a file using PUT method", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadWin = function (uploadResult) { - - verifyUpload(uploadResult); - - if (cordova.platformId === "ios") { - expect(uploadResult.headers).toBeDefined("Expected headers to be defined."); - expect(uploadResult.headers["Content-Type"]).toBeDefined("Expected content-type header to be defined."); - } - - done(); - }; - - uploadOptions.httpMethod = "PUT"; - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.32 should be able to upload a file (non-multipart)", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadWin = function (uploadResult) { - - expect(uploadResult.bytesSent).toBeGreaterThan(0); - expect(uploadResult.responseCode).toBe(200); - expect(uploadResult.response).toBeDefined(); - if (uploadResult.response) { - expect(uploadResult.response).toEqual(fileContents + "\n"); - } - expect(transfer.onprogress).toHaveBeenCalled(); - - if (cordova.platformId === "ios") { - expect(uploadResult.headers).toBeDefined("Expected headers to be defined."); - expect(uploadResult.headers["Content-Type"]).toBeDefined("Expected content-type header to be defined."); - } - - done(); - }; - - // Content-Type header disables multipart - uploadOptions.headers = { - "Content-Type": "text/plain" - }; - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.34 should not delete a file on upload error", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadFail = function (e) { - expect(e.code).toBe(FileTransferError.ABORT_ERR); - expect(transfer.onprogress).toHaveBeenCalled(); - - // check that the file is there - root.getFile(fileName, null, function(entry) { - expect(entry).toBeDefined(); - - // delay calling done() to wait for the bogus abort() - setTimeout(done, GRACE_TIME_DELTA * 2); - }, function(err) { - expect(err).not.toBeDefined(err && err.code); - done(); - }); - }; - - var fileWin = function () { - - expect(transfer.abort).not.toThrow(); - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, unexpectedCallbacks.httpWin, uploadFail, uploadOptions); - - // abort at the first onprogress event - transfer.onprogress = function (event) { - if (event.loaded > 0) { - transfer.abort(); - } - }; - - spyOn(transfer, "onprogress").and.callThrough(); - }; - - writeFile(root, fileName, new Array(100000).join("aborttest!"), fileWin); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.37 should handle non-UTF8 encoded upload response", function (done) { - - // Only iOS is supported: https://issues.apache.org/jira/browse/CB-9840 - if (!isIos) { - pending(); - } - - var fileURL = SERVER + '/upload_non_utf'; - - var uploadWin = function (uploadResult) { - - verifyUpload(uploadResult); - - var obj = null; - try { - obj = JSON.parse(uploadResult.response); - expect(obj.latin1Symbols).toBe(LATIN1_SYMBOLS); - } catch (e) { - expect(obj).not.toBeNull("returned data from server should be valid json"); - } - - if (cordova.platformId === 'ios') { - expect(uploadResult.headers).toBeDefined('Expected headers to be defined.'); - expect(uploadResult.headers['Content-Type']).toBeDefined('Expected content-type header to be defined.'); - } - - done(); - }; - - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(localFilePath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.38 should be able to upload a file using data: source uri", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadWin = function (uploadResult) { - - verifyUpload(uploadResult); - - var obj = null; - try { - obj = JSON.parse(uploadResult.response); - expect(obj.files.file.size).toBe(DATA_URI_CONTENT_LENGTH); - } catch (e) { - expect(obj).not.toBeNull("returned data from server should be valid json"); - } - - if (cordova.platformId === "ios") { - expect(uploadResult.headers).toBeDefined("Expected headers to be defined."); - expect(uploadResult.headers["Content-Type"]).toBeDefined("Expected content-type header to be defined."); - } - - done(); - }; - - var dataUri = DATA_URI_PREFIX + DATA_URI_CONTENT; - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(dataUri, fileURL, uploadWin, function (err) { - console.error('err: ' + JSON.stringify(err)); - expect(err).not.toBeDefined(); - done(); - }, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.39 should be able to upload a file using data: source uri (non-multipart)", function (done) { - - var fileURL = SERVER + "/upload"; - - var uploadWin = function (uploadResult) { - - expect(uploadResult.responseCode).toBe(200); - expect(uploadResult.bytesSent).toBeGreaterThan(0); - - if (cordova.platformId === "ios") { - expect(uploadResult.headers).toBeDefined("Expected headers to be defined."); - expect(uploadResult.headers["Content-Type"]).toBeDefined("Expected content-type header to be defined."); - } - - done(); - }; - - // Content-Type header disables multipart - uploadOptions.headers = { - "Content-Type": "image/png" - }; - - var dataUri = DATA_URI_PREFIX + DATA_URI_CONTENT; - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(dataUri, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.40 should not fail to upload a file using data: source uri when the data is empty", function (done) { - - var fileURL = SERVER + "/upload"; - - var dataUri = DATA_URI_PREFIX; - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(dataUri, fileURL, done, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - - it("filetransfer.spec.41 should not fail to upload a file using data: source uri when the data is empty (non-multipart)", function (done) { - - var fileURL = SERVER + "/upload"; - - // Content-Type header disables multipart - uploadOptions.headers = { - "Content-Type": "image/png" - }; - - // turn off the onprogress handler - transfer.onprogress = function () { }; - - var dataUri = DATA_URI_PREFIX; - // NOTE: removing uploadOptions cause Android to timeout - transfer.upload(dataUri, fileURL, done, unexpectedCallbacks.httpFail, uploadOptions); - }, UPLOAD_TIMEOUT); - }); - }); - }); -}; - -/******************************************************************************/ -/******************************************************************************/ -/******************************************************************************/ - -exports.defineManualTests = function (contentEl, createActionButton) { - - "use strict"; - - var imageURL = "http://apache.org/images/feather-small.gif"; - var videoURL = "http://techslides.com/demos/sample-videos/small.mp4"; - - function clearResults() { - var results = document.getElementById("info"); - results.innerHTML = ""; - } - - function downloadImg(source, urlFn, element, directory) { - var filename = source.substring(source.lastIndexOf("/") + 1); - filename = (directory || "") + filename; - - function download(fileSystem) { - var ft = new FileTransfer(); - console.log("Starting download"); - - var progress = document.getElementById("loadingStatus"); - progress.value = 0; - - ft.onprogress = function(progressEvent) { - if (progressEvent.lengthComputable) { - var currPercents = parseInt(100 * (progressEvent.loaded / progressEvent.total), 10); - if (currPercents > progress.value) { - progress.value = currPercents; - } - } else { - progress.value = null; - } - }; - - ft.download(source, fileSystem.root.toURL() + filename, function (entry) { - console.log("Download complete"); - element.src = urlFn(entry); - console.log("Src URL is " + element.src); - console.log("Inserting element"); - document.getElementById("info").appendChild(element); - }, function (e) { console.log("ERROR: ft.download " + e.code); }); - } - console.log("Requesting filesystem"); - clearResults(); - window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function (fileSystem) { - console.log("Checking for existing file"); - if (typeof directory !== "undefined") { - console.log("Checking for existing directory."); - fileSystem.root.getDirectory(directory, {}, function (dirEntry) { - dirEntry.removeRecursively(function () { - download(fileSystem); - }, function () { console.log("ERROR: dirEntry.removeRecursively"); }); - }, function () { - download(fileSystem); - }); - } else { - fileSystem.root.getFile(filename, { create: false }, function (entry) { - console.log("Removing existing file"); - entry.remove(function () { - download(fileSystem); - }, function () { console.log("ERROR: entry.remove"); }); - }, function () { - download(fileSystem); - }); - } - }, function () { console.log("ERROR: requestFileSystem"); }); - } - - /******************************************************************************/ - - var progress_tag = ""; - var file_transfer_tests = "

Image File Transfer Tests

" + - "

The following tests should display an image of the Apache feather in the status box

" + - "
" + - "
" + - "
" + - "

Video File Transfer Tests

" + - "

The following tests should display a video in the status box. The video should play when play is pressed

" + - "
" + - "
"; - - contentEl.innerHTML = "
" + "
" + progress_tag + - file_transfer_tests; - - createActionButton("Download and display img (cdvfile)", function () { - downloadImg(imageURL, function (entry) { return entry.toInternalURL(); }, new Image()); - }, "cdv_image"); - - createActionButton("Download and display img (native)", function () { - downloadImg(imageURL, function (entry) { return entry.toURL(); }, new Image()); - }, "native_image"); - - createActionButton("Download to a non-existent dir (should work)", function () { - downloadImg(imageURL, function (entry) { return entry.toURL(); }, new Image(), "/nonExistentDirTest/"); - }, "non-existent_dir"); - - createActionButton("Download and play video (cdvfile)", function () { - var videoElement = document.createElement("video"); - videoElement.controls = "controls"; - downloadImg(videoURL, function (entry) { return entry.toInternalURL(); }, videoElement); - }, "cdv_video"); - - createActionButton("Download and play video (native)", function () { - var videoElement = document.createElement("video"); - videoElement.controls = "controls"; - downloadImg(videoURL, function (entry) { return entry.toURL(); }, videoElement); - }, "native_video"); -}; diff --git a/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/plugins/cordova-plugin-file-transfer/www/FileTransfer.js deleted file mode 100644 index add97da..0000000 --- a/plugins/cordova-plugin-file-transfer/www/FileTransfer.js +++ /dev/null @@ -1,235 +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. - * -*/ - -var argscheck = require('cordova/argscheck'), - exec = require('cordova/exec'), - FileTransferError = require('./FileTransferError'), - ProgressEvent = require('cordova-plugin-file.ProgressEvent'); - -function newProgressEvent(result) { - var pe = new ProgressEvent(); - pe.lengthComputable = result.lengthComputable; - pe.loaded = result.loaded; - pe.total = result.total; - return pe; -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function convertHeadersToArray(headers) { - var result = []; - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - var headerValue = headers[header]; - result.push({ - name: header, - value: headerValue.toString() - }); - } - } - return result; -} - -var idCounter = 0; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** -* Given an absolute file path, uploads a file on the device to a remote server -* using a multipart HTTP request. -* @param filePath {String} Full path of the file on the device -* @param server {String} URL of the server to receive the file -* @param successCallback (Function} Callback to be invoked when upload has completed -* @param errorCallback {Function} Callback to be invoked upon error -* @param options {FileUploadOptions} Optional parameters such as file name and mimetype -* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false -*/ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - // check for options - var fileKey = null; - var fileName = null; - var mimeType = null; - var params = null; - var chunkedMode = true; - var headers = null; - var httpMethod = null; - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - if (options) { - fileKey = options.fileKey; - fileName = options.fileName; - mimeType = options.mimeType; - headers = options.headers; - httpMethod = options.httpMethod || "POST"; - if (httpMethod.toUpperCase() == "PUT"){ - httpMethod = "PUT"; - } else { - httpMethod = "POST"; - } - if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { - chunkedMode = options.chunkedMode; - } - if (options.params) { - params = options.params; - } - else { - params = {}; - } - } - - if (cordova.platformId === "windowsphone") { - headers = headers && convertHeadersToArray(headers); - params = params && convertHeadersToArray(params); - } - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - var self = this; - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - self.onprogress(newProgressEvent(result)); - } - } else { - successCallback && successCallback(result); - } - }; - exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - var self = this; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var headers = null; - if (options) { - headers = options.headers || null; - } - - if (cordova.platformId === "windowsphone" && headers) { - headers = convertHeadersToArray(headers); - } - - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - return self.onprogress(newProgressEvent(result)); - } - } else if (successCallback) { - var entry = null; - if (result.isDirectory) { - entry = new (require('cordova-plugin-file.DirectoryEntry'))(); - } - else if (result.isFile) { - entry = new (require('cordova-plugin-file.FileEntry'))(); - } - entry.isDirectory = result.isDirectory; - entry.isFile = result.isFile; - entry.name = result.name; - entry.fullPath = result.fullPath; - entry.filesystem = new FileSystem(result.filesystemName || (result.filesystem == window.PERSISTENT ? 'persistent' : 'temporary')); - entry.nativeURL = result.nativeURL; - successCallback(entry); - } - }; - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception); - errorCallback(error); - }; - - exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - exec(null, null, 'FileTransfer', 'abort', [this._id]); -}; - -module.exports = FileTransfer; diff --git a/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/plugins/cordova-plugin-file-transfer/www/FileTransferError.js deleted file mode 100644 index 07ca831..0000000 --- a/plugins/cordova-plugin-file-transfer/www/FileTransferError.js +++ /dev/null @@ -1,41 +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. - * -*/ - -/** - * FileTransferError - * @constructor - */ -var FileTransferError = function(code, source, target, status, body, exception) { - this.code = code || null; - this.source = source || null; - this.target = target || null; - this.http_status = status || null; - this.body = body || null; - this.exception = exception || null; -}; - -FileTransferError.FILE_NOT_FOUND_ERR = 1; -FileTransferError.INVALID_URL_ERR = 2; -FileTransferError.CONNECTION_ERR = 3; -FileTransferError.ABORT_ERR = 4; -FileTransferError.NOT_MODIFIED_ERR = 5; - -module.exports = FileTransferError; diff --git a/plugins/cordova-plugin-file-transfer/www/blackberry10/FileTransfer.js b/plugins/cordova-plugin-file-transfer/www/blackberry10/FileTransfer.js deleted file mode 100644 index f74914a..0000000 --- a/plugins/cordova-plugin-file-transfer/www/blackberry10/FileTransfer.js +++ /dev/null @@ -1,188 +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. - * -*/ - -var argscheck = require('cordova/argscheck'), - FileTransferError = require('./FileTransferError'); - xhrImpl = require('./BB10XHRImplementation'); - - -function getBasicAuthHeader(urlString) { - var header = null; - - if (window.btoa) { - // parse the url using the Location object - var url = document.createElement('a'); - url.href = urlString; - - var credentials = null; - var protocol = url.protocol + "//"; - var origin = protocol + url.host; - - // check whether there are the username:password credentials in the url - if (url.href.indexOf(origin) !== 0) { // credentials found - var atIndex = url.href.indexOf("@"); - credentials = url.href.substring(protocol.length, atIndex); - } - - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -var idCounter = 0; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** -* Given an absolute file path, uploads a file on the device to a remote server -* using a multipart HTTP request. -* @param filePath {String} Full path of the file on the device -* @param server {String} URL of the server to receive the file -* @param successCallback (Function} Callback to be invoked when upload has completed -* @param errorCallback {Function} Callback to be invoked upon error -* @param options {FileUploadOptions} Optional parameters such as file name and mimetype -* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false -*/ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - // check for options - var fileKey = null; - var fileName = null; - var mimeType = null; - var params = null; - var chunkedMode = true; - var headers = null; - var httpMethod = null; - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - if (options) { - fileKey = options.fileKey; - fileName = options.fileName; - mimeType = options.mimeType; - headers = options.headers; - httpMethod = options.httpMethod || "POST"; - if (httpMethod.toUpperCase() == "PUT"){ - httpMethod = "PUT"; - } else { - httpMethod = "POST"; - } - if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { - chunkedMode = options.chunkedMode; - } - if (options.params) { - params = options.params; - } - else { - params = {}; - } - } - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body); - errorCallback(error); - }; - - var self = this; - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - self.onprogress(result); - } - } else { - successCallback && successCallback(result); - } - }; - xhrImpl.upload(win, fail, [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - var self = this; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - options = options || {}; - options.headers = options.headers || {}; - options.headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var headers = null; - if (options) { - headers = options.headers || null; - } - - var win = function(result) { - if (typeof result.lengthComputable != "undefined") { - if (self.onprogress) { - return self.onprogress(result); - } - } else if (successCallback) { - successCallback(result); - } - }; - - var fail = errorCallback && function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body); - errorCallback(error); - }; - - xhrImpl.download(win, fail, [source, target, trustAllHosts, this._id, headers]); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - xhrImpl.abort(null, null, [this._id]); -}; - -module.exports = FileTransfer; diff --git a/plugins/cordova-plugin-file-transfer/www/blackberry10/FileTransferProxy.js b/plugins/cordova-plugin-file-transfer/www/blackberry10/FileTransferProxy.js deleted file mode 100644 index a363f07..0000000 --- a/plugins/cordova-plugin-file-transfer/www/blackberry10/FileTransferProxy.js +++ /dev/null @@ -1,36 +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. - * -*/ - -/* - * FileTransferProxy - * - * Register all FileTransfer exec calls to be handled by proxy - */ - -var xhrFileTransfer = require('cordova-plugin-file-transfer.xhrFileTransfer'); - -module.exports = { - abort: xhrFileTransfer.abort, - download: xhrFileTransfer.download, - upload: xhrFileTransfer.upload -}; - -require('cordova/exec/proxy').add('FileTransfer', module.exports); diff --git a/plugins/cordova-plugin-file-transfer/www/blackberry10/xhrFileTransfer.js b/plugins/cordova-plugin-file-transfer/www/blackberry10/xhrFileTransfer.js deleted file mode 100644 index 7eba7af..0000000 --- a/plugins/cordova-plugin-file-transfer/www/blackberry10/xhrFileTransfer.js +++ /dev/null @@ -1,259 +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. - * -*/ - -/*global Blob:false */ -var cordova = require('cordova'), - resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'), - requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame'), - xhr = {}; - -function getParentPath(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(0, pos + 1); -} - -function getFileName(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(pos + 1); -} - -function checkURL(url) { - return url.indexOf(' ') === -1 ? true : false; -} - -module.exports = { - abort: function (win, fail, args) { - var id = args[0]; - if (xhr[id]) { - xhr[id].abort(); - if (typeof(win) === 'function') { - win(); - } - } else if (typeof(fail) === 'function') { - fail(); - } - }, - - upload: function(win, fail, args) { - var filePath = args[0], - server = args[1], - fileKey = args[2], - fileName = args[3], - mimeType = args[4], - params = args[5], - /*trustAllHosts = args[6],*/ - chunkedMode = args[7], - headers = args[8], - onSuccess = function (data) { - if (typeof(win) === 'function') { - win(data); - } - }, - onFail = function (code) { - delete xhr[fileKey]; - if (typeof(fail) === 'function') { - fail(code); - } - }; - - if (!checkURL(server)) { - onFail(new FileTransferError(FileTransferError.INVALID_URL_ERR, server, filePath)); - } - - xhr[fileKey] = new XMLHttpRequest(); - xhr[fileKey].onabort = function () { - onFail(new FileTransferError(FileTransferError.ABORT_ERR, server, filePath, this.status, xhr[fileKey].response)); - }; - - resolve(function(entry) { - requestAnimationFrame(function () { - entry.nativeEntry.file(function(file) { - function uploadFile(blobFile) { - var fd = new FormData(); - - fd.append(fileKey, blobFile, fileName); - for (var prop in params) { - if(params.hasOwnProperty(prop)) { - fd.append(prop, params[prop]); - } - } - - xhr[fileKey].open("POST", server); - xhr[fileKey].onload = function(evt) { - if (xhr[fileKey].status === 200) { - var result = new FileUploadResult(); - result.bytesSent = file.size; - result.responseCode = xhr[fileKey].status; - result.response = xhr[fileKey].response; - delete xhr[fileKey]; - onSuccess(result); - } else if (xhr[fileKey].status === 404) { - onFail(new FileTransferError(FileTransferError.INVALID_URL_ERR, server, filePath, xhr[fileKey].status, xhr[fileKey].response)); - } else { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr[fileKey].status, xhr[fileKey].response)); - } - }; - xhr[fileKey].ontimeout = function(evt) { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr[fileKey].status, xhr[fileKey].response)); - }; - xhr[fileKey].onerror = function () { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, this.status, xhr[fileKey].response)); - }; - xhr[fileKey].upload.onprogress = function (evt) { - if (evt.loaded > 0) { - onSuccess(evt); - } - }; - - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr[fileKey].setRequestHeader(header, headers[header]); - } - } - - requestAnimationFrame(function () { - xhr[fileKey].send(fd); - }); - } - - var bytesPerChunk; - if (chunkedMode === true) { - bytesPerChunk = 1024 * 1024; // 1MB chunk sizes. - } else { - bytesPerChunk = file.size; - } - var start = 0; - var end = bytesPerChunk; - while (start < file.size) { - var chunk = file.slice(start, end, mimeType); - uploadFile(chunk); - start = end; - end = start + bytesPerChunk; - } - }, function(error) { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, server, filePath)); - }); - }); - }, function(error) { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, server, filePath)); - }, [filePath]); - }, - - download: function (win, fail, args) { - var source = args[0], - target = args[1], - id = args[3], - headers = args[4], - fileWriter, - onSuccess = function (entry) { - if (typeof(win) === 'function') { - win(entry); - } - }, - onFail = function (error) { - var reader; - delete xhr[id]; - if (typeof(fail) === 'function') { - if (error && error.body && typeof(error.body) === 'object') { - reader = new FileReader()._realReader; - reader.onloadend = function () { - error.body = this.result; - fail(error); - }; - reader.onerror = function () { - fail(error); - }; - reader.readAsText(error.body); - } else { - fail(error); - } - } - }; - - if (!checkURL(source)) { - onFail(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target)); - } - - xhr[id] = new XMLHttpRequest(); - - function writeFile(entry) { - entry.createWriter(function (writer) { - fileWriter = writer; - fileWriter.onwriteend = function (evt) { - if (!evt.target.error) { - entry.filesystemName = entry.filesystem.name; - delete xhr[id]; - onSuccess(entry); - } else { - onFail(evt.target.error); - } - }; - fileWriter.onerror = function (evt) { - onFail(evt.target.error); - }; - fileWriter.write(new Blob([xhr[id].response])); - }, function (error) { - onFail(error); - }); - } - - xhr[id].onerror = function (e) { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr[id].status, xhr[id].response)); - }; - - xhr[id].onabort = function (e) { - onFail(new FileTransferError(FileTransferError.ABORT_ERR, source, target, xhr[id].status, xhr[id].response)); - } - - xhr[id].onload = function () { - if (xhr[id].readyState === xhr[id].DONE) { - if (xhr[id].status === 200 && xhr[id].response) { - resolveLocalFileSystemURI(getParentPath(target), function (dir) { - dir.getFile(getFileName(target), {create: true}, writeFile, function (error) { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, source, target, xhr[id].status, xhr[id].response)); - }); - }, function (error) { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, source, target, xhr[id].status, xhr[id].response)); - }); - } else if (xhr[id].status === 404) { - onFail(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target, xhr[id].status, xhr[id].response)); - } else { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr[id].status, xhr[id].response)); - } - } - }; - xhr[id].onprogress = function (evt) { - onSuccess(evt); - }; - xhr[id].open("GET", source, true); - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr[id].setRequestHeader(header, headers[header]); - } - } - xhr[id].responseType = "blob"; - requestAnimationFrame(function () { - if (xhr[id]) { - xhr[id].send(); - } - }); - } -}; diff --git a/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js b/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js deleted file mode 100644 index 2146ed1..0000000 --- a/plugins/cordova-plugin-file-transfer/www/browser/FileTransfer.js +++ /dev/null @@ -1,328 +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. - * -*/ - -/*global module, require*/ - -var argscheck = require('cordova/argscheck'), - FileTransferError = require('./FileTransferError'); - -function getParentPath(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(0, pos + 1); -} - -function getFileName(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(pos + 1); -} - -function getUrlCredentials(urlString) { - var credentialsPattern = /^https?\:\/\/(?:(?:(([^:@\/]*)(?::([^@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?).*$/, - credentials = credentialsPattern.exec(urlString); - - return credentials && credentials[1]; -} - -function getBasicAuthHeader(urlString) { - var header = null; - - - // This is changed due to MS Windows doesn't support credentials in http uris - // so we detect them by regexp and strip off from result url - // Proof: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/a327cf3c-f033-4a54-8b7f-03c56ba3203f/windows-foundation-uri-security-problem - - if (window.btoa) { - var credentials = getUrlCredentials(urlString); - if (credentials) { - var authHeader = "Authorization"; - var authHeaderValue = "Basic " + window.btoa(credentials); - - header = { - name : authHeader, - value : authHeaderValue - }; - } - } - - return header; -} - -function checkURL(url) { - return url.indexOf(' ') === -1 ? true : false; -} - -var idCounter = 0; - -var transfers = {}; - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() { - this._id = ++idCounter; - this.onprogress = null; // optional callback -}; - -/** - * Given an absolute file path, uploads a file on the device to a remote server - * using a multipart HTTP request. - * @param filePath {String} Full path of the file on the device - * @param server {String} URL of the server to receive the file - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param options {FileUploadOptions} Optional parameters such as file name and mimetype - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - */ -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options) { - // check for arguments - argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments); - - // Check if target URL doesn't contain spaces. If contains, it should be escaped first - // (see https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#upload) - if (!checkURL(server)) { - errorCallback && errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR, filePath, server)); - return; - } - - options = options || {}; - - var fileKey = options.fileKey || "file"; - var fileName = options.fileName || "image.jpg"; - var mimeType = options.mimeType || "image/jpeg"; - var params = options.params || {}; - var withCredentials = options.withCredentials || false; - // var chunkedMode = !!options.chunkedMode; // Not supported - var headers = options.headers || {}; - var httpMethod = options.httpMethod && options.httpMethod.toUpperCase() === "PUT" ? "PUT" : "POST"; - - var basicAuthHeader = getBasicAuthHeader(server); - if (basicAuthHeader) { - server = server.replace(getUrlCredentials(server) + '@', ''); - headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var that = this; - var xhr = transfers[this._id] = new XMLHttpRequest(); - xhr.withCredentials = withCredentials; - - var fail = errorCallback && function(code, status, response) { - transfers[this._id] && delete transfers[this._id]; - var error = new FileTransferError(code, filePath, server, status, response); - errorCallback && errorCallback(error); - }; - - window.resolveLocalFileSystemURL(filePath, function(entry) { - entry.file(function(file) { - var reader = new FileReader(); - reader.onloadend = function() { - var blob = new Blob([this.result], {type: mimeType}); - - // Prepare form data to send to server - var fd = new FormData(); - fd.append(fileKey, blob, fileName); - for (var prop in params) { - if (params.hasOwnProperty(prop)) { - fd.append(prop, params[prop]); - } - } - - xhr.open(httpMethod, server); - - // Fill XHR headers - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr.setRequestHeader(header, headers[header]); - } - } - - xhr.onload = function() { - if (this.status === 200) { - var result = new FileUploadResult(); // jshint ignore:line - result.bytesSent = blob.size; - result.responseCode = this.status; - result.response = this.response; - delete transfers[that._id]; - successCallback(result); - } else if (this.status === 404) { - fail(FileTransferError.INVALID_URL_ERR, this.status, this.response); - } else { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - } - }; - - xhr.ontimeout = function() { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onerror = function() { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onabort = function () { - fail(FileTransferError.ABORT_ERR, this.status, this.response); - }; - - xhr.upload.onprogress = function (e) { - that.onprogress && that.onprogress(e); - }; - - xhr.send(fd); - // Special case when transfer already aborted, but XHR isn't sent. - // In this case XHR won't fire an abort event, so we need to check if transfers record - // isn't deleted by filetransfer.abort and if so, call XHR's abort method again - if (!transfers[that._id]) { - xhr.abort(); - } - }; - reader.readAsArrayBuffer(file); - }, function() { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }); - }, function() { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false - * @param options {FileDownloadOptions} Optional parameters such as headers - */ -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) { - argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments); - - // Check if target URL doesn't contain spaces. If contains, it should be escaped first - // (see https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#download) - if (!checkURL(source)) { - errorCallback && errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target)); - return; - } - - options = options || {}; - - var headers = options.headers || {}; - var withCredentials = options.withCredentials || false; - - var basicAuthHeader = getBasicAuthHeader(source); - if (basicAuthHeader) { - source = source.replace(getUrlCredentials(source) + '@', ''); - headers[basicAuthHeader.name] = basicAuthHeader.value; - } - - var that = this; - var xhr = transfers[this._id] = new XMLHttpRequest(); - xhr.withCredentials = withCredentials; - var fail = errorCallback && function(code, status, response) { - transfers[that._id] && delete transfers[that._id]; - // In XHR GET reqests we're setting response type to Blob - // but in case of error we need to raise event with plain text response - if (response instanceof Blob) { - var reader = new FileReader(); - reader.readAsText(response); - reader.onloadend = function(e) { - var error = new FileTransferError(code, source, target, status, e.target.result); - errorCallback(error); - }; - } else { - var error = new FileTransferError(code, source, target, status, response); - errorCallback(error); - } - }; - - xhr.onload = function (e) { - - var fileNotFound = function () { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }; - - var req = e.target; - // req.status === 0 is special case for local files with file:// URI scheme - if ((req.status === 200 || req.status === 0) && req.response) { - window.resolveLocalFileSystemURL(getParentPath(target), function (dir) { - dir.getFile(getFileName(target), {create: true}, function writeFile(entry) { - entry.createWriter(function (fileWriter) { - fileWriter.onwriteend = function (evt) { - if (!evt.target.error) { - entry.filesystemName = entry.filesystem.name; - delete transfers[that._id]; - successCallback && successCallback(entry); - } else { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - } - }; - fileWriter.onerror = function () { - fail(FileTransferError.FILE_NOT_FOUND_ERR); - }; - fileWriter.write(req.response); - }, fileNotFound); - }, fileNotFound); - }, fileNotFound); - } else if (req.status === 404) { - fail(FileTransferError.INVALID_URL_ERR, req.status, req.response); - } else { - fail(FileTransferError.CONNECTION_ERR, req.status, req.response); - } - }; - - xhr.onprogress = function (e) { - that.onprogress && that.onprogress(e); - }; - - xhr.onerror = function () { - fail(FileTransferError.CONNECTION_ERR, this.status, this.response); - }; - - xhr.onabort = function () { - fail(FileTransferError.ABORT_ERR, this.status, this.response); - }; - - xhr.open("GET", source, true); - - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr.setRequestHeader(header, headers[header]); - } - } - - xhr.responseType = "blob"; - - xhr.send(); -}; - -/** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. - */ -FileTransfer.prototype.abort = function() { - if (this instanceof FileTransfer) { - if (transfers[this._id]) { - transfers[this._id].abort(); - delete transfers[this._id]; - } - } -}; - -module.exports = FileTransfer; diff --git a/plugins/cordova-plugin-file-transfer/www/firefoxos/FileTransferProxy.js b/plugins/cordova-plugin-file-transfer/www/firefoxos/FileTransferProxy.js deleted file mode 100644 index 164da1a..0000000 --- a/plugins/cordova-plugin-file-transfer/www/firefoxos/FileTransferProxy.js +++ /dev/null @@ -1,223 +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. - * -*/ - -var cordova = require('cordova'), - FileTransferError = require('./FileTransferError'), - xhr = {}; - -function getParentPath(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(0, pos + 1); -} - -function getFileName(filePath) { - var pos = filePath.lastIndexOf('/'); - return filePath.substring(pos + 1); -} - -module.exports = { - abort: function (successCallback, errorCallback, args) { - var id = args[0]; - if (xhr[id]) { - xhr[id].abort(); - if (typeof(successCallback) === 'function') { - successCallback(); - } - } else if (typeof(errorCallback) === 'function') { - errorCallback(); - } - }, - - upload: function(successCallback, errorCallback, args) { - var filePath = args[0], - server = args[1], - fileKey = args[2], - fileName = args[3], - mimeType = args[4], - params = args[5], - /*trustAllHosts = args[6],*/ - /*chunkedMode = args[7],*/ - headers = args[8]; - - xhr[fileKey] = new XMLHttpRequest({mozSystem: true}); - xhr[fileKey].onabort = function() { - onFail(new FileTransferError(FileTransferError.ABORT_ERR, server, filePath, this.status, xhr[fileKey].response)); - }; - - window.resolveLocalFileSystemURL(filePath, function(entry) { - entry.file(function(file) { - var reader = new FileReader(); - - reader.onloadend = function() { - var blob = new Blob([this.result], {type: mimeType}); - var fd = new FormData(); - - fd.append(fileKey, blob, fileName); - - for (var prop in params) { - if (params.hasOwnProperty(prop)) { - fd.append(prop, params[prop]); - } - } - - xhr[fileKey].open("POST", server); - - xhr[fileKey].onload = function(evt) { - if (xhr[fileKey].status === 200) { - var result = new FileUploadResult(); - result.bytesSent = blob.size; - result.responseCode = xhr[fileKey].status; - result.response = xhr[fileKey].response; - delete xhr[fileKey]; - onSuccess(result); - } else if (xhr[fileKey].status === 404) { - onFail(new FileTransferError(FileTransferError.INVALID_URL_ERR, server, filePath, xhr[fileKey].status, xhr[fileKey].response)); - } else { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr[fileKey].status, xhr[fileKey].response)); - } - }; - - xhr[fileKey].ontimeout = function() { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr[fileKey].status, xhr[fileKey].response)); - }; - - xhr[fileKey].onerror = function() { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, this.status, xhr[fileKey].response)); - }; - - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr[fileKey].setRequestHeader(header, headers[header]); - } - } - - xhr[fileKey].send(fd); - }; - - reader.readAsArrayBuffer(file); - - }, function() { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, server, filePath)); - }); - }, function() { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, server, filePath)); - }); - - function onSuccess(data) { - if (typeof(successCallback) === 'function') { - successCallback(data); - } - } - - function onFail(code) { - delete xhr[fileKey]; - if (typeof(errorCallback) === 'function') { - errorCallback(code); - } - } - }, - - download: function (successCallback, errorCallback, args) { - var source = args[0], - target = args[1], - id = args[3], - headers = args[4]; - - xhr[id] = new XMLHttpRequest({mozSystem: true}); - - xhr[id].onload = function () { - if (xhr[id].readyState === xhr[id].DONE) { - if (xhr[id].status === 200 && xhr[id].response) { - window.resolveLocalFileSystemURL(getParentPath(target), function (dir) { - dir.getFile(getFileName(target), {create: true}, writeFile, function (error) { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, source, target, xhr[id].status, xhr[id].response)); - }); - }, function () { - onFail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, source, target, xhr[id].status, xhr[id].response)); - }); - } else if (xhr[id].status === 404) { - onFail(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target, xhr[id].status, xhr[id].response)); - } else { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr[id].status, xhr[id].response)); - } - } - }; - - function writeFile(entry) { - entry.createWriter(function (fileWriter) { - fileWriter.onwriteend = function (evt) { - if (!evt.target.error) { - entry.filesystemName = entry.filesystem.name; - delete xhr[id]; - onSuccess(entry); - } else { - onFail(evt.target.error); - } - }; - fileWriter.onerror = function (evt) { - onFail(evt.target.error); - }; - fileWriter.write(new Blob([xhr[id].response])); - }, function (error) { - onFail(error); - }); - } - - xhr[id].onerror = function (e) { - onFail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr[id].status, xhr[id].response)); - }; - - xhr[id].onabort = function (e) { - onFail(new FileTransferError(FileTransferError.ABORT_ERR, source, target, xhr[id].status, xhr[id].response)); - }; - - xhr[id].open("GET", source, true); - - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - xhr[id].setRequestHeader(header, headers[header]); - } - } - - xhr[id].responseType = "blob"; - - setTimeout(function () { - if (xhr[id]) { - xhr[id].send(); - } - }, 0); - - function onSuccess(entry) { - if (typeof(successCallback) === 'function') { - successCallback(entry); - } - } - - function onFail(error) { - delete xhr[id]; - if (typeof(errorCallback) === 'function') { - errorCallback(error); - } - } - } -}; - -require('cordova/exec/proxy').add('FileTransfer', module.exports); diff --git a/plugins/cordova-plugin-file-transfer/www/wp7/base64.js b/plugins/cordova-plugin-file-transfer/www/wp7/base64.js deleted file mode 100644 index 6c211e7..0000000 --- a/plugins/cordova-plugin-file-transfer/www/wp7/base64.js +++ /dev/null @@ -1,71 +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. - * -*/ - -var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', - INVALID_CHARACTER_ERR = (function () { - // fabricate a suitable error object - try { document.createElement('$'); } - catch (error) { return error; } - }()); - - // encoder - // [https://gist.github.com/999166] by [https://github.com/nignag] - window.btoa || ( - window.btoa = function (input) { - for ( - // initialize result and counter - var block, charCode, idx = 0, map = chars, output = ''; - // if the next input index does not exist: - // change the mapping table to "=" - // check if d has no fractional digits - input.charAt(idx | 0) || (map = '=', idx % 1) ; - // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 - output += map.charAt(63 & block >> 8 - idx % 1 * 8) - ) { - charCode = input.charCodeAt(idx += 3 / 4); - if (charCode > 0xFF) throw INVALID_CHARACTER_ERR; - block = block << 8 | charCode; - } - return output; - }); - - // decoder - // [https://gist.github.com/1020396] by [https://github.com/atk] - window.atob || ( - window.atob = function (input) { - input = input.replace(/=+$/, '') - if (input.length % 4 == 1) throw INVALID_CHARACTER_ERR; - for ( - // initialize result and counters - var bc = 0, bs, buffer, idx = 0, output = ''; - // get next character - buffer = input.charAt(idx++) ; - // character found in table? initialize bit storage and add its ascii value; - ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, - // and if not first of each 4 characters, - // convert the first 8 bits to one ascii character - bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 - ) { - // try to find character in table (0-63, not found => -1) - buffer = chars.indexOf(buffer); - } - return output; - }); \ No newline at end of file diff --git a/plugins/cordova-plugin-file/package.json b/plugins/cordova-plugin-file/package.json index 2d48d89..7f46694 100644 --- a/plugins/cordova-plugin-file/package.json +++ b/plugins/cordova-plugin-file/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-file", - "version": "4.1.2-dev", + "version": "4.1.1", "description": "Cordova File Plugin", "cordova": { "id": "cordova-plugin-file", diff --git a/plugins/cordova-plugin-file/plugin.xml b/plugins/cordova-plugin-file/plugin.xml index 4c79325..07a4dce 100644 --- a/plugins/cordova-plugin-file/plugin.xml +++ b/plugins/cordova-plugin-file/plugin.xml @@ -21,7 +21,7 @@ + version="4.1.1"> File Cordova File Plugin Apache 2.0 diff --git a/plugins/cordova-plugin-file/src/android/PermissionHelper.java b/plugins/cordova-plugin-file/src/android/PermissionHelper.java index 089da03..778e5ce 100644 --- a/plugins/cordova-plugin-file/src/android/PermissionHelper.java +++ b/plugins/cordova-plugin-file/src/android/PermissionHelper.java @@ -1,138 +1,138 @@ -/* - 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.file; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; - -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.LOG; - -import android.content.pm.PackageManager; - -/** - * This class provides reflective methods for permission requesting and checking so that plugins - * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. - */ -public class PermissionHelper { - private static final String LOG_TAG = "CordovaPermissionHelper"; - - /** - * Requests a "dangerous" permission for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermission() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permission request - * @param permission The permission to be requested - */ - public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { - PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); - } - - /** - * Requests "dangerous" permissions for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermissions() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permissions are being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permissions request - * @param permissions The permissions to be requested - */ - public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { - try { - Method requestPermission = CordovaInterface.class.getDeclaredMethod( - "requestPermissions", CordovaPlugin.class, int.class, String[].class); - - // If there is no exception, then this is cordova-android 5.0.0+ - requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); - - // Notify the plugin that all were granted by using more reflection - deliverPermissionResult(plugin, requestCode, permissions); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); - } - } - - /** - * Checks at runtime to see if the application has been granted a permission. This is a helper - * method alternative to cordovaInterface.hasPermission() that does not require the project to - * be built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being checked against - * @param permission The permission to be checked - * - * @return True if the permission has already been granted and false otherwise - */ - public static boolean hasPermission(CordovaPlugin plugin, String permission) { - try { - Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); - - // If there is no exception, then this is cordova-android 5.0.0+ - return (Boolean) hasPermission.invoke(plugin.cordova, permission); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to check for permission " + permission); - return true; - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); - } - return false; - } - - private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { - // Generate the request results - int[] requestResults = new int[permissions.length]; - Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); - - try { - Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( - "onRequestPermissionResult", int.class, String[].class, int[].class); - - onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); - } catch (NoSuchMethodException noSuchMethodException) { - // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it - // made it to this point - LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method may throw a JSONException. We are just duplicating cordova-android's - // exception handling behavior here; all it does is log the exception in CordovaActivity, - // print the stacktrace, and ignore it - LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); - } - } -} +/* + 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.file; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; + +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.LOG; + +import android.content.pm.PackageManager; + +/** + * This class provides reflective methods for permission requesting and checking so that plugins + * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. + */ +public class PermissionHelper { + private static final String LOG_TAG = "CordovaPermissionHelper"; + + /** + * Requests a "dangerous" permission for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermission() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permission request + * @param permission The permission to be requested + */ + public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { + PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); + } + + /** + * Requests "dangerous" permissions for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermissions() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permissions are being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permissions request + * @param permissions The permissions to be requested + */ + public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { + try { + Method requestPermission = CordovaInterface.class.getDeclaredMethod( + "requestPermissions", CordovaPlugin.class, int.class, String[].class); + + // If there is no exception, then this is cordova-android 5.0.0+ + requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); + + // Notify the plugin that all were granted by using more reflection + deliverPermissionResult(plugin, requestCode, permissions); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); + } + } + + /** + * Checks at runtime to see if the application has been granted a permission. This is a helper + * method alternative to cordovaInterface.hasPermission() that does not require the project to + * be built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being checked against + * @param permission The permission to be checked + * + * @return True if the permission has already been granted and false otherwise + */ + public static boolean hasPermission(CordovaPlugin plugin, String permission) { + try { + Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); + + // If there is no exception, then this is cordova-android 5.0.0+ + return (Boolean) hasPermission.invoke(plugin.cordova, permission); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to check for permission " + permission); + return true; + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); + } + return false; + } + + private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { + // Generate the request results + int[] requestResults = new int[permissions.length]; + Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); + + try { + Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( + "onRequestPermissionResult", int.class, String[].class, int[].class); + + onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); + } catch (NoSuchMethodException noSuchMethodException) { + // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it + // made it to this point + LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method may throw a JSONException. We are just duplicating cordova-android's + // exception handling behavior here; all it does is log the exception in CordovaActivity, + // print the stacktrace, and ignore it + LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); + } + } +} diff --git a/plugins/cordova-plugin-file/tests/plugin.xml b/plugins/cordova-plugin-file/tests/plugin.xml index f1c96dc..bdfc348 100644 --- a/plugins/cordova-plugin-file/tests/plugin.xml +++ b/plugins/cordova-plugin-file/tests/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-file-tests" - version="4.1.2-dev"> + version="4.1.1"> Cordova File Plugin Tests Apache 2.0 diff --git a/plugins/cordova-plugin-file/tests/tests.js b/plugins/cordova-plugin-file/tests/tests.js index c4c9012..432febe 100644 --- a/plugins/cordova-plugin-file/tests/tests.js +++ b/plugins/cordova-plugin-file/tests/tests.js @@ -3316,11 +3316,7 @@ exports.defineAutoTests = function () { it("file.spec.129 cordova.file.*Directory are set", function () { var expectedPaths = ['applicationDirectory', 'applicationStorageDirectory', 'dataDirectory', 'cacheDirectory']; if (cordova.platformId == 'android' || cordova.platformId == 'amazon-fireos') { - if (cordova.file.externalApplicationStorageDirectory !== null) { - // https://issues.apache.org/jira/browse/CB-10411 - // If external storage can't be mounted, the cordova.file.external* properties are null. - expectedPaths.push('externalApplicationStorageDirectory', 'externalRootDirectory', 'externalCacheDirectory', 'externalDataDirectory'); - } + expectedPaths.push('externalApplicationStorageDirectory', 'externalRootDirectory', 'externalCacheDirectory', 'externalDataDirectory'); } else if (cordova.platformId == 'blackberry10') { expectedPaths.push('externalRootDirectory', 'sharedDirectory'); } else if (cordova.platformId == 'ios') { diff --git a/plugins/cordova-plugin-file/www/browser/isChrome.js b/plugins/cordova-plugin-file/www/browser/isChrome.js index 853277d..d5b0eff 100644 --- a/plugins/cordova-plugin-file/www/browser/isChrome.js +++ b/plugins/cordova-plugin-file/www/browser/isChrome.js @@ -1,26 +1,26 @@ -/* - * - * 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. - * - */ - -module.exports = function () { - // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and - // possibly a good flag to indicate that we're running in Chrome - return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; -}; +/* + * + * 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. + * + */ + +module.exports = function () { + // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and + // possibly a good flag to indicate that we're running in Chrome + return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL; +}; diff --git a/plugins/cordova-plugin-geolocation/README.md b/plugins/cordova-plugin-geolocation/README.md index 74695ea..a70db39 100644 --- a/plugins/cordova-plugin-geolocation/README.md +++ b/plugins/cordova-plugin-geolocation/README.md @@ -17,6 +17,8 @@ # under the License. --> +[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation) + # cordova-plugin-geolocation This plugin provides information about the device's location, such as @@ -43,7 +45,7 @@ accesses geolocation data (if the device operating system doesn't do so already). That notice should provide the same information noted above, as well as obtaining the user's permission (e.g., by presenting choices for __OK__ and __No Thanks__). For more information, please -see the Privacy Guide. +see the [Privacy Guide](http://cordova.apache.org/docs/en/latest/guide/appdev/privacy/index.html). This plugin defines a global `navigator.geolocation` object (for platforms where it is otherwise missing). @@ -79,7 +81,6 @@ It is also possible to install via repo url directly ( unstable ) - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 - Windows ## Methods diff --git a/plugins/cordova-plugin-geolocation/package.json b/plugins/cordova-plugin-geolocation/package.json index fa62fb3..984899d 100644 --- a/plugins/cordova-plugin-geolocation/package.json +++ b/plugins/cordova-plugin-geolocation/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-geolocation", - "version": "2.1.0", + "version": "2.1.1-dev", "description": "Cordova Geolocation Plugin", "cordova": { "id": "cordova-plugin-geolocation", @@ -36,6 +36,13 @@ "cordova-windows", "cordova-firefoxos" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/plugins/cordova-plugin-geolocation/plugin.xml b/plugins/cordova-plugin-geolocation/plugin.xml index a724b52..dce8caf 100644 --- a/plugins/cordova-plugin-geolocation/plugin.xml +++ b/plugins/cordova-plugin-geolocation/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geolocation" - version="2.1.0"> + version="2.1.1-dev"> Geolocation Cordova Geolocation Plugin @@ -31,6 +31,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git https://issues.apache.org/jira/browse/CB/component/12320638 + + @@ -46,7 +48,6 @@ xmlns:android="http://schemas.android.com/apk/res/android" - diff --git a/plugins/cordova-plugin-geolocation/src/android/Geolocation.java b/plugins/cordova-plugin-geolocation/src/android/Geolocation.java index 79f0684..3e0bd8a 100644 --- a/plugins/cordova-plugin-geolocation/src/android/Geolocation.java +++ b/plugins/cordova-plugin-geolocation/src/android/Geolocation.java @@ -21,10 +21,12 @@ package org.apache.cordova.geolocation; import android.content.pm.PackageManager; import android.Manifest; import android.os.Build; +import android.util.Log; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaArgs; import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PermissionHelper; import org.apache.cordova.PluginResult; import org.apache.cordova.LOG; import org.json.JSONArray; @@ -41,6 +43,7 @@ public class Geolocation extends CordovaPlugin { public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + Log.d(TAG, "We are entering execute"); context = callbackContext; if(action.equals("getPermission")) { @@ -63,18 +66,20 @@ public class Geolocation extends CordovaPlugin { int[] grantResults) throws JSONException { PluginResult result; - for(int r:grantResults) - { - if(r == PackageManager.PERMISSION_DENIED) - { - LOG.d(TAG, "Permission Denied!"); - result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION); - context.sendPluginResult(result); - return; + //This is important if we're using Cordova without using Cordova, but we have the geolocation plugin installed + if(context != null) { + for (int r : grantResults) { + if (r == PackageManager.PERMISSION_DENIED) { + LOG.d(TAG, "Permission Denied!"); + result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION); + context.sendPluginResult(result); + return; + } + } + result = new PluginResult(PluginResult.Status.OK); + context.sendPluginResult(result); } - result = new PluginResult(PluginResult.Status.OK); - context.sendPluginResult(result); } public boolean hasPermisssion() { diff --git a/plugins/cordova-plugin-geolocation/src/android/PermissionHelper.java b/plugins/cordova-plugin-geolocation/src/android/PermissionHelper.java deleted file mode 100644 index 50fc4a8..0000000 --- a/plugins/cordova-plugin-geolocation/src/android/PermissionHelper.java +++ /dev/null @@ -1,138 +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.geolocation; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; - -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.LOG; - -import android.content.pm.PackageManager; - -/** - * This class provides reflective methods for permission requesting and checking so that plugins - * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. - */ -public class PermissionHelper { - private static final String LOG_TAG = "CordovaPermissionHelper"; - - /** - * Requests a "dangerous" permission for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermission() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permission request - * @param permission The permission to be requested - */ - public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { - PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); - } - - /** - * Requests "dangerous" permissions for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermissions() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permissions are being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permissions request - * @param permissions The permissions to be requested - */ - public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { - try { - Method requestPermission = CordovaInterface.class.getDeclaredMethod( - "requestPermissions", CordovaPlugin.class, int.class, String[].class); - - // If there is no exception, then this is cordova-android 5.0.0+ - requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); - - // Notify the plugin that all were granted by using more reflection - deliverPermissionResult(plugin, requestCode, permissions); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); - } - } - - /** - * Checks at runtime to see if the application has been granted a permission. This is a helper - * method alternative to cordovaInterface.hasPermission() that does not require the project to - * be built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being checked against - * @param permission The permission to be checked - * - * @return True if the permission has already been granted and false otherwise - */ - public static boolean hasPermission(CordovaPlugin plugin, String permission) { - try { - Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); - - // If there is no exception, then this is cordova-android 5.0.0+ - return (Boolean) hasPermission.invoke(plugin.cordova, permission); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to check for permission " + permission); - return true; - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); - } - return false; - } - - private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { - // Generate the request results - int[] requestResults = new int[permissions.length]; - Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); - - try { - Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( - "onRequestPermissionResult", int.class, String[].class, int[].class); - - onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); - } catch (NoSuchMethodException noSuchMethodException) { - // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it - // made it to this point - LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method may throw a JSONException. We are just duplicating cordova-android's - // exception handling behavior here; all it does is log the exception in CordovaActivity, - // print the stacktrace, and ignore it - LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); - } - } -} diff --git a/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js b/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js index f6188bc..03ed495 100644 --- a/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js +++ b/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js @@ -14,47 +14,48 @@ * limitations under the License. */ -var PositionError = require('./PositionError'), - ids = {}, - loc; +/* global Windows, WinJS */ -function ensureLocator() { +var PositionError = require('./PositionError'); +var callbacks = {}; +var locs = {}; + +// constants +var FALLBACK_EPSILON = 0.001; + +function ensureAndCreateLocator() { var deferral; - if (!loc) { - loc = new Windows.Devices.Geolocation.Geolocator(); + var loc = new Windows.Devices.Geolocation.Geolocator(); - if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') { - deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) { - if (result === Windows.Devices.Geolocation.GeolocationAccessStatus.allowed) { - return loc; - } + if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') { + deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) { + if (result === Windows.Devices.Geolocation.GeolocationAccessStatus.allowed) { + return loc; + } - return WinJS.Promise.wrapError({ - code: PositionError.PERMISSION_DENIED, - message: 'Geolocation access has not been allowed by user.' - }); + return WinJS.Promise.wrapError({ + code: PositionError.PERMISSION_DENIED, + message: 'Geolocation access has not been allowed by user.' }); - } else { - deferral = WinJS.Promise.wrap(loc); - } + }); } else { deferral = WinJS.Promise.wrap(loc); - } + } return deferral; } -function createErrorCode() { +function createErrorCode(loc) { switch (loc.locationStatus) { case Windows.Devices.Geolocation.PositionStatus.initializing: // This status indicates that a location device is still initializing case Windows.Devices.Geolocation.PositionStatus.noData: - // No location data is currently available + // No location data is currently available case Windows.Devices.Geolocation.PositionStatus.notInitialized: // This status indicates that the app has not yet requested - // location data by calling GetGeolocationAsync() or - // registering an event handler for the positionChanged event. + // location data by calling GetGeolocationAsync() or + // registering an event handler for the positionChanged event. case Windows.Devices.Geolocation.PositionStatus.notAvailable: // Location is not available on this version of Windows return PositionError.POSITION_UNAVAILABLE; @@ -76,7 +77,7 @@ function createResult(pos) { altitudeAccuracy: pos.coordinate.altitudeAccuracy, timestamp: pos.coordinate.timestamp }; - + if (pos.coordinate.point) { res.latitude = pos.coordinate.point.position.latitude; res.longitude = pos.coordinate.point.position.longitude; @@ -86,13 +87,13 @@ function createResult(pos) { res.longitude = pos.coordinate.longitude; res.altitude = pos.coordinate.altitude; } - + return res; } module.exports = { getLocation: function (success, fail, args, env) { - ensureLocator().done(function () { + ensureAndCreateLocator().done(function (loc) { if (loc) { var highAccuracy = args[0], maxAge = args[1]; @@ -109,7 +110,7 @@ module.exports = { }, function (err) { fail({ - code: createErrorCode(), + code: createErrorCode(loc), message: err.message }); } @@ -125,15 +126,15 @@ module.exports = { }, addWatch: function (success, fail, args, env) { - ensureLocator().done(function () { - var clientId = args[0], - highAccuracy = args[1], + ensureAndCreateLocator().done(function (loc) { + var clientId = args[0]; + var highAccuracy = args[1]; - onPositionChanged = function (e) { + var onPositionChanged = function (e) { success(createResult(e.position), { keepCallback: true }); - }, + }; - onStatusChanged = function (e) { + var onStatusChanged = function (e) { switch (e.status) { case Windows.Devices.Geolocation.PositionStatus.noData: case Windows.Devices.Geolocation.PositionStatus.notAvailable: @@ -166,29 +167,36 @@ module.exports = { // JavaScript runtime error: Operation aborted // You must set the MovementThreshold property or the ReportInterval property before adding event handlers. // WinRT information: You must set the MovementThreshold property or the ReportInterval property before adding event handlers - loc.movementThreshold = Number.EPSILON; + if (Number.EPSILON) { + loc.movementThreshold = Number.EPSILON; + } else { + loc.movementThreshold = FALLBACK_EPSILON; + } } loc.addEventListener("positionchanged", onPositionChanged); loc.addEventListener("statuschanged", onStatusChanged); - ids[clientId] = { pos: onPositionChanged, status: onStatusChanged }; - }, fail); + callbacks[clientId] = { pos: onPositionChanged, status: onStatusChanged }; + locs[clientId] = loc; + }, fail); }, clearWatch: function (success, fail, args, env) { - var clientId = args[0], - callbacks = ids[clientId]; + var clientId = args[0]; + var callback = callbacks[clientId]; + var loc = locs[clientId]; - if (callbacks) { - loc.removeEventListener("positionchanged", callbacks.pos); - loc.removeEventListener("statuschanged", callbacks.status); + if (callback && loc) { + loc.removeEventListener("positionchanged", callback.pos); + loc.removeEventListener("statuschanged", callback.status); - delete ids[clientId]; + delete callbacks[clientId]; + delete locs[clientId]; } success(); } }; -require("cordova/exec/proxy").add("Geolocation", module.exports); \ No newline at end of file +require("cordova/exec/proxy").add("Geolocation", module.exports); diff --git a/plugins/cordova-plugin-geolocation/tests/plugin.xml b/plugins/cordova-plugin-geolocation/tests/plugin.xml index 10db7c1..255a939 100644 --- a/plugins/cordova-plugin-geolocation/tests/plugin.xml +++ b/plugins/cordova-plugin-geolocation/tests/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geolocation-tests" - version="2.1.0"> + version="2.1.1-dev"> Cordova Geolocation Plugin Tests Apache 2.0 diff --git a/plugins/cordova-plugin-geolocation/tests/tests.js b/plugins/cordova-plugin-geolocation/tests/tests.js index 65a9c69..50c5bfb 100644 --- a/plugins/cordova-plugin-geolocation/tests/tests.js +++ b/plugins/cordova-plugin-geolocation/tests/tests.js @@ -18,6 +18,10 @@ * under the License. * */ + +/* jshint jasmine: true */ +/* global WinJS, device */ + exports.defineAutoTests = function () { var fail = function (done, context, message) { // prevents done() to be called several times @@ -266,6 +270,40 @@ exports.defineAutoTests = function () { exports.defineManualTests = function (contentEl, createActionButton) { var watchLocationId = null; + /** + * Set location status + */ + function setLocationStatus(status) { + document.getElementById('location_status').innerHTML = status; + } + function setLocationDetails(p) { + var date = (new Date(p.timestamp)); + document.getElementById('latitude').innerHTML = p.coords.latitude; + document.getElementById('longitude').innerHTML = p.coords.longitude; + document.getElementById('altitude').innerHTML = p.coords.altitude; + document.getElementById('accuracy').innerHTML = p.coords.accuracy; + document.getElementById('heading').innerHTML = p.coords.heading; + document.getElementById('speed').innerHTML = p.coords.speed; + document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy; + document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString(); + } + + /** + * Stop watching the location + */ + function stopLocation() { + var geo = navigator.geolocation; + if (!geo) { + alert('navigator.geolocation object is missing.'); + return; + } + setLocationStatus("Stopped"); + if (watchLocationId) { + geo.clearWatch(watchLocationId); + watchLocationId = null; + } + } + /** * Start watching location */ @@ -292,22 +330,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { setLocationStatus("Running"); }; - /** - * Stop watching the location - */ - var stopLocation = function () { - var geo = navigator.geolocation; - if (!geo) { - alert('navigator.geolocation object is missing.'); - return; - } - setLocationStatus("Stopped"); - if (watchLocationId) { - geo.clearWatch(watchLocationId); - watchLocationId = null; - } - }; - /** * Get current location */ @@ -340,24 +362,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { }; - /** - * Set location status - */ - var setLocationStatus = function (status) { - document.getElementById('location_status').innerHTML = status; - }; - var setLocationDetails = function (p) { - var date = (new Date(p.timestamp)); - document.getElementById('latitude').innerHTML = p.coords.latitude; - document.getElementById('longitude').innerHTML = p.coords.longitude; - document.getElementById('altitude').innerHTML = p.coords.altitude; - document.getElementById('accuracy').innerHTML = p.coords.accuracy; - document.getElementById('heading').innerHTML = p.coords.heading; - document.getElementById('speed').innerHTML = p.coords.speed; - document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy; - document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString(); - }; - /******************************************************************************/ var location_div = '
' + @@ -423,8 +427,8 @@ exports.defineManualTests = function (contentEl, createActionButton) { note = '

Allow use of current location, if prompted

'; - contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed - + altitude_accuracy + time + note + actions; + contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed + + altitude_accuracy + time + note + actions; createActionButton('Get Location', function () { getLocation(); diff --git a/plugins/cordova-plugin-geolocation/www/android/geolocation.js b/plugins/cordova-plugin-geolocation/www/android/geolocation.js index 57b8122..7265bec 100644 --- a/plugins/cordova-plugin-geolocation/www/android/geolocation.js +++ b/plugins/cordova-plugin-geolocation/www/android/geolocation.js @@ -19,13 +19,15 @@ * */ - var exec = cordova.require('cordova/exec'); var utils = require('cordova/utils'); var PositionError = require('./PositionError'); -module.exports = { +// Native watchPosition method is called async after permissions prompt. +// So we use additional map and own ids to return watch id synchronously. +var pluginToNativeWatchMap = {}; +module.exports = { getCurrentPosition: function(success, error, args) { var win = function() { var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); @@ -67,7 +69,3 @@ module.exports = { exec(win, null, "Geolocation", "getPermission", []); } }; - -// Native watchPosition method is called async after permissions prompt. -// So we use additional map and own ids to return watch id synchronously. -var pluginToNativeWatchMap = {}; diff --git a/plugins/cordova-plugin-media-capture/README.md b/plugins/cordova-plugin-media-capture/README.md index d02f992..4bdc3da 100644 --- a/plugins/cordova-plugin-media-capture/README.md +++ b/plugins/cordova-plugin-media-capture/README.md @@ -17,6 +17,8 @@ # under the License. --> +[![Build Status](https://travis-ci.org/apache/cordova-plugin-media-capture.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-media-capture) + # cordova-plugin-media-capture This plugin provides access to the device's audio, image, and video capture capabilities. @@ -45,6 +47,8 @@ Although in the global scope, it is not available until after the `deviceready` console.log(navigator.device.capture); } +Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Media%20Capture%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) + ## Installation cordova plugin add cordova-plugin-media-capture @@ -151,40 +155,6 @@ code. - Windows Phone 7 does not have a default audio recording application, so a simple user interface is provided. -## CaptureAudioOptions - -> Encapsulates audio capture configuration options. - -### Properties - -- __limit__: The maximum number of audio clips the device user can record in a single capture operation. The value must be greater than or equal to 1 (defaults to 1). - -- __duration__: The maximum duration of an audio sound clip, in seconds. - -### Example - - // limit capture operation to 3 media files, no longer than 10 seconds each - var options = { limit: 3, duration: 10 }; - - navigator.device.capture.captureAudio(captureSuccess, captureError, options); - -### Amazon Fire OS Quirks - -- The `duration` parameter is not supported. Recording lengths cannot be limited programmatically. - -### Android Quirks - -- The `duration` parameter is not supported. Recording lengths can't be limited programmatically. - -### BlackBerry 10 Quirks - -- The `duration` parameter is not supported. Recording lengths can't be limited programmatically. -- The `limit` parameter is not supported, so only one recording can be created for each invocation. - -### iOS Quirks - -- The `limit` parameter is not supported, so only one recording can be created for each invocation. - ## capture.captureImage > Start the camera application and return information about captured image files. @@ -201,7 +171,7 @@ one image in a single session. The capture operation ends either when the user closes the camera application, or the maximum number of recordings specified by -`CaptureAudioOptions.limit` is reached. If no `limit` value is +`CaptureImageOptions.limit` is reached. If no `limit` value is specified, it defaults to one (1), and the capture operation terminates after the user captures a single image. @@ -232,7 +202,7 @@ via Zune does not work, and the error callback executes. Works in Chrome, Firefox and Opera only (since IE and Safari doesn't supports navigator.getUserMedia API) -Displaying images using captured file's URL available in Chrome/Opera only. +Displaying images using captured file's URL available in Chrome/Opera only. Firefox stores captured images in IndexedDB storage (see File plugin documentation), and due to this the only way to show captured image is to read it and show using its DataURL. @@ -255,27 +225,6 @@ and due to this the only way to show captured image is to read it and show using // start image capture navigator.device.capture.captureImage(captureSuccess, captureError, {limit:2}); - - -## CaptureImageOptions - -> Encapsulates image capture configuration options. - -### Properties - -- __limit__: The maximum number of images the user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1). - -### Example - - // limit capture operation to 3 images - var options = { limit: 3 }; - - navigator.device.capture.captureImage(captureSuccess, captureError, options); - -### iOS Quirks - -- The __limit__ parameter is not supported, and only one image is taken per invocation. - ## capture.captureVideo > Start the video recorder application and return information about captured video clip files. @@ -338,6 +287,61 @@ capturing a video clip, the `CaptureErrorCB` callback executes with a - Cordova for BlackBerry 10 attempts to launch the __Video Recorder__ application, provided by RIM, to capture video recordings. The app receives a `CaptureError.CAPTURE_NOT_SUPPORTED` error code if the application is not installed on the device. +## CaptureAudioOptions + +> Encapsulates audio capture configuration options. + +### Properties + +- __limit__: The maximum number of audio clips the device user can record in a single capture operation. The value must be greater than or equal to 1 (defaults to 1). + +- __duration__: The maximum duration of an audio sound clip, in seconds. + +### Example + + // limit capture operation to 3 media files, no longer than 10 seconds each + var options = { limit: 3, duration: 10 }; + + navigator.device.capture.captureAudio(captureSuccess, captureError, options); + +### Amazon Fire OS Quirks + +- The `duration` parameter is not supported. Recording lengths cannot be limited programmatically. + +### Android Quirks + +- The `duration` parameter is not supported. Recording lengths can't be limited programmatically. + +### BlackBerry 10 Quirks + +- The `duration` parameter is not supported. Recording lengths can't be limited programmatically. +- The `limit` parameter is not supported, so only one recording can be created for each invocation. + +### iOS Quirks + +- The `limit` parameter is not supported, so only one recording can be created for each invocation. + + +## CaptureImageOptions + +> Encapsulates image capture configuration options. + +### Properties + +- __limit__: The maximum number of images the user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1). + +### Example + + // limit capture operation to 3 images + var options = { limit: 3 }; + + navigator.device.capture.captureImage(captureSuccess, captureError, options); + +### iOS Quirks + +- The __limit__ parameter is not supported, and only one image is taken per invocation. + + ## CaptureVideoOptions > Encapsulates video capture configuration options. @@ -365,8 +369,8 @@ capturing a video clip, the `CaptureErrorCB` callback executes with a ### Android Quirks -- Android supports an additional __quality__ property, to allow capturing video at different qualities. A value of `1` ( the default ) means high quality and value of `0` means low quality, suitable for MMS messages. - See http://developer.android.com/reference/android/provider/MediaStore.html#EXTRA_VIDEO_QUALITY for more details. +- Android supports an additional __quality__ property, to allow capturing video at different qualities. A value of `1` ( the default ) means high quality and value of `0` means low quality, suitable for MMS messages. + See [here](http://developer.android.com/reference/android/provider/MediaStore.html#EXTRA_VIDEO_QUALITY) for more details. ### Example ( Android w/ quality ) @@ -419,6 +423,8 @@ Each `MediaFile` object describes a captured media file. - `CaptureError.CAPTURE_NO_MEDIA_FILES`: The user exits the camera or audio capture application before capturing anything. +- `CaptureError.CAPTURE_PERMISSION_DENIED`: The user denied a permission required to perform the given capture request. + - `CaptureError.CAPTURE_NOT_SUPPORTED`: The requested capture operation is not supported. ## CaptureErrorCB diff --git a/plugins/cordova-plugin-media-capture/package.json b/plugins/cordova-plugin-media-capture/package.json index 654abe8..47ffb9e 100644 --- a/plugins/cordova-plugin-media-capture/package.json +++ b/plugins/cordova-plugin-media-capture/package.json @@ -35,9 +35,16 @@ "cordova-windows8", "cordova-windows" ], + "scripts": { + "test": "npm run jshint", + "jshint": "jshint www && jshint src && jshint tests" + }, "peerDependencies": { "cordova-plugin-file": "^3.0.0" }, "author": "Apache Software Foundation", - "license": "Apache-2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/plugins/cordova-plugin-media-capture/plugin.xml b/plugins/cordova-plugin-media-capture/plugin.xml index 37679f3..f8734ad 100644 --- a/plugins/cordova-plugin-media-capture/plugin.xml +++ b/plugins/cordova-plugin-media-capture/plugin.xml @@ -30,13 +30,14 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" cordova,media,capture https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git https://issues.apache.org/jira/browse/CB/component/12320646 - + + - + @@ -44,7 +45,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" - + @@ -52,11 +53,11 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" - + - + @@ -68,7 +69,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" - + @@ -77,8 +78,9 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" + - + @@ -86,7 +88,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" - + @@ -96,7 +98,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" - + @@ -122,16 +124,16 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" - + - + - + diff --git a/plugins/cordova-plugin-media-capture/src/android/Capture.java b/plugins/cordova-plugin-media-capture/src/android/Capture.java index 8afed36..0fb0edb 100644 --- a/plugins/cordova-plugin-media-capture/src/android/Capture.java +++ b/plugins/cordova-plugin-media-capture/src/android/Capture.java @@ -34,15 +34,19 @@ import org.apache.cordova.file.LocalFilesystemURL; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.LOG; +import org.apache.cordova.PermissionHelper; import org.apache.cordova.PluginManager; -import org.apache.cordova.PluginResult; +import org.apache.cordova.mediacapture.PendingRequests.Request; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import android.Manifest; import android.app.Activity; import android.content.ContentValues; import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.database.Cursor; import android.graphics.BitmapFactory; import android.media.MediaPlayer; @@ -67,14 +71,13 @@ public class Capture extends CordovaPlugin { // private static final int CAPTURE_APPLICATION_BUSY = 1; // private static final int CAPTURE_INVALID_ARGUMENT = 2; private static final int CAPTURE_NO_MEDIA_FILES = 3; + private static final int CAPTURE_PERMISSION_DENIED = 4; + + private boolean cameraPermissionInManifest; // Whether or not the CAMERA permission is declared in AndroidManifest.xml + + private final PendingRequests pendingRequests = new PendingRequests(); - private CallbackContext callbackContext; // The callback context from which we were invoked. - private long limit; // the number of pics/vids/clips to take - private int duration; // optional max duration of video recording in seconds - private JSONArray results; // The array of results to be returned to the user private int numPics; // Number of pictures before capture activity - private int quality; // Quality level for video capture 0 low, 1 high - //private CordovaInterface cordova; // public void setContext(Context mCtx) // { @@ -85,33 +88,50 @@ public class Capture extends CordovaPlugin { // } @Override - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - this.callbackContext = callbackContext; - this.limit = 1; - this.duration = 0; - this.results = new JSONArray(); - this.quality = 1; + protected void pluginInitialize() { + super.pluginInitialize(); - JSONObject options = args.optJSONObject(0); - if (options != null) { - limit = options.optLong("limit", 1); - duration = options.optInt("duration", 0); - quality = options.optInt("quality", 1); + // CB-10670: The CAMERA permission does not need to be requested unless it is declared + // in AndroidManifest.xml. This plugin does not declare it, but others may and so we must + // check the package info to determine if the permission is present. + + cameraPermissionInManifest = false; + try { + PackageManager packageManager = this.cordova.getActivity().getPackageManager(); + String[] permissionsInPackage = packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), PackageManager.GET_PERMISSIONS).requestedPermissions; + if (permissionsInPackage != null) { + for (String permission : permissionsInPackage) { + if (permission.equals(Manifest.permission.CAMERA)) { + cameraPermissionInManifest = true; + break; + } + } + } + } catch (NameNotFoundException e) { + // We are requesting the info for our package, so this should + // never be caught + LOG.e(LOG_TAG, "Failed checking for CAMERA permission in manifest", e); } + } + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("getFormatData")) { JSONObject obj = getFormatData(args.getString(0), args.getString(1)); callbackContext.success(obj); return true; } - else if (action.equals("captureAudio")) { - this.captureAudio(); + + JSONObject options = args.optJSONObject(0); + + if (action.equals("captureAudio")) { + this.captureAudio(pendingRequests.createRequest(CAPTURE_AUDIO, options, callbackContext)); } else if (action.equals("captureImage")) { - this.captureImage(); + this.captureImage(pendingRequests.createRequest(CAPTURE_IMAGE, options, callbackContext)); } else if (action.equals("captureVideo")) { - this.captureVideo(duration, quality); + this.captureVideo(pendingRequests.createRequest(CAPTURE_VIDEO, options, callbackContext)); } else { return false; @@ -201,10 +221,10 @@ public class Capture extends CordovaPlugin { /** * Sets up an intent to capture audio. Result handled by onActivityResult() */ - private void captureAudio() { + private void captureAudio(Request req) { Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION); - this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_AUDIO); + this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode); } private String getTempDirectoryPath() { @@ -221,24 +241,40 @@ public class Capture extends CordovaPlugin { /** * Sets up an intent to capture images. Result handled by onActivityResult() */ - private void captureImage() { - // Save the number of images currently on disk for later - this.numPics = queryImgDB(whichContentStore()).getCount(); + private void captureImage(Request req) { + boolean needExternalStoragePermission = + !PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE); + + boolean needCameraPermission = cameraPermissionInManifest && + !PermissionHelper.hasPermission(this, Manifest.permission.CAMERA); + + if (needExternalStoragePermission || needCameraPermission) { + if (needExternalStoragePermission && needCameraPermission) { + PermissionHelper.requestPermissions(this, req.requestCode, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA}); + } else if (needExternalStoragePermission) { + PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.READ_EXTERNAL_STORAGE); + } else { + PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.CAMERA); + } + } else { + // Save the number of images currently on disk for later + this.numPics = queryImgDB(whichContentStore()).getCount(); - Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); + Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); - // Specify file so that large image is captured and returned - File photo = new File(getTempDirectoryPath(), "Capture.jpg"); - try { - // the ACTION_IMAGE_CAPTURE is run under different credentials and has to be granted write permissions - createWritableFile(photo); - } catch (IOException ex) { - this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, ex.toString())); - return; - } - intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); + // Specify file so that large image is captured and returned + File photo = new File(getTempDirectoryPath(), "Capture.jpg"); + try { + // the ACTION_IMAGE_CAPTURE is run under different credentials and has to be granted write permissions + createWritableFile(photo); + } catch (IOException ex) { + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_INTERNAL_ERR, ex.toString())); + return; + } + intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); - this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_IMAGE); + this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode); + } } private static void createWritableFile(File file) throws IOException { @@ -249,14 +285,18 @@ public class Capture extends CordovaPlugin { /** * Sets up an intent to capture video. Result handled by onActivityResult() */ - private void captureVideo(int duration, int quality) { - Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); + private void captureVideo(Request req) { + if(cameraPermissionInManifest && !PermissionHelper.hasPermission(this, Manifest.permission.CAMERA)) { + PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.CAMERA); + } else { + Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); - if(Build.VERSION.SDK_INT > 7){ - intent.putExtra("android.intent.extra.durationLimit", duration); - intent.putExtra("android.intent.extra.videoQuality", quality); + if(Build.VERSION.SDK_INT > 7){ + intent.putExtra("android.intent.extra.durationLimit", req.duration); + intent.putExtra("android.intent.extra.videoQuality", req.quality); + } + this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode); } - this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO); } /** @@ -269,153 +309,147 @@ public class Capture extends CordovaPlugin { * @throws JSONException */ public void onActivityResult(int requestCode, int resultCode, final Intent intent) { + final Request req = pendingRequests.get(requestCode); // Result received okay if (resultCode == Activity.RESULT_OK) { - // An audio clip was requested - if (requestCode == CAPTURE_AUDIO) { - - final Capture that = this; - Runnable captureAudio = new Runnable() { - - @Override - public void run() { - // Get the uri of the audio clip - Uri data = intent.getData(); - // create a file object from the uri - results.put(createMediaFile(data)); - - if (results.length() >= limit) { - // Send Uri back to JavaScript for listening to audio - that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); - } else { - // still need to capture more audio clips - captureAudio(); - } - } - }; - this.cordova.getThreadPool().execute(captureAudio); - } else if (requestCode == CAPTURE_IMAGE) { - // For some reason if I try to do: - // Uri data = intent.getData(); - // It crashes in the emulator and on my phone with a null pointer exception - // To work around it I had to grab the code from CameraLauncher.java - - final Capture that = this; - Runnable captureImage = new Runnable() { - @Override - public void run() { - try { - // TODO Auto-generated method stub - // Create entry in media store for image - // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it) - ContentValues values = new ContentValues(); - values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG); - Uri uri = null; - try { - uri = that.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 = that.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."); - that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found.")); - return; - } - } - FileInputStream fis = new FileInputStream(getTempDirectoryPath() + "/Capture.jpg"); - OutputStream os = that.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(); - - // Add image to results - results.put(createMediaFile(uri)); - - checkForDuplicateImage(); - - if (results.length() >= limit) { - // Send Uri back to JavaScript for viewing image - that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); - } else { - // still need to capture more images - captureImage(); - } - } catch (IOException e) { - e.printStackTrace(); - that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image.")); - } + Runnable processActivityResult = new Runnable() { + @Override + public void run() { + switch(req.action) { + case CAPTURE_AUDIO: + onAudioActivityResult(req, intent); + break; + case CAPTURE_IMAGE: + onImageActivityResult(req); + break; + case CAPTURE_VIDEO: + onVideoActivityResult(req, intent); + break; } - }; - this.cordova.getThreadPool().execute(captureImage); - } else if (requestCode == CAPTURE_VIDEO) { - - final Capture that = this; - Runnable captureVideo = new Runnable() { - - @Override - public void run() { - - Uri data = null; - - if (intent != null){ - // Get the uri of the video clip - data = intent.getData(); - } - - if( data == null){ - File movie = new File(getTempDirectoryPath(), "Capture.avi"); - data = Uri.fromFile(movie); - } - - // create a file object from the uri - if(data == null) - { - that.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null")); - } - else - { - results.put(createMediaFile(data)); - - if (results.length() >= limit) { - // Send Uri back to JavaScript for viewing video - that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); - } else { - // still need to capture more video clips - captureVideo(duration, quality); - } - } - } - }; - this.cordova.getThreadPool().execute(captureVideo); - } + } + }; + + this.cordova.getThreadPool().execute(processActivityResult); } // If canceled else if (resultCode == Activity.RESULT_CANCELED) { // If we have partial results send them back to the user - if (results.length() > 0) { - this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); + if (req.results.length() > 0) { + pendingRequests.resolveWithSuccess(req); } // user canceled the action else { - this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled.")); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled.")); } } // If something else else { // If we have partial results send them back to the user - if (results.length() > 0) { - this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results)); + if (req.results.length() > 0) { + pendingRequests.resolveWithSuccess(req); } // something bad happened else { - this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!")); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!")); + } + } + } + + + public void onAudioActivityResult(Request req, Intent intent) { + // Get the uri of the audio clip + Uri data = intent.getData(); + // create a file object from the uri + req.results.put(createMediaFile(data)); + + if (req.results.length() >= req.limit) { + // Send Uri back to JavaScript for listening to audio + pendingRequests.resolveWithSuccess(req); + } else { + // still need to capture more audio clips + captureAudio(req); + } + } + + public void onImageActivityResult(Request req) { + // For some reason if I try to do: + // Uri data = intent.getData(); + // It crashes in the emulator and on my phone with a null pointer exception + // To work around it I had to grab the code from CameraLauncher.java + try { + // Create entry in media store for image + // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it) + ContentValues values = new ContentValues(); + values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG); + Uri uri = null; + 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."); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found.")); + return; + } + } + FileInputStream fis = new FileInputStream(getTempDirectoryPath() + "/Capture.jpg"); + 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(); + + // Add image to results + req.results.put(createMediaFile(uri)); + + checkForDuplicateImage(); + + if (req.results.length() >= req.limit) { + // Send Uri back to JavaScript for viewing image + pendingRequests.resolveWithSuccess(req); + } else { + // still need to capture more images + captureImage(req); + } + } catch (IOException e) { + e.printStackTrace(); + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image.")); + } + } + + public void onVideoActivityResult(Request req, Intent intent) { + Uri data = null; + + if (intent != null){ + // Get the uri of the video clip + data = intent.getData(); + } + + if( data == null){ + File movie = new File(getTempDirectoryPath(), "Capture.avi"); + data = Uri.fromFile(movie); + } + + // create a file object from the uri + if(data == null) { + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null")); + } + else { + req.results.put(createMediaFile(data)); + + if (req.results.length() >= req.limit) { + // Send Uri back to JavaScript for viewing video + pendingRequests.resolveWithSuccess(req); + } else { + // still need to capture more video clips + captureVideo(req); } } } @@ -491,16 +525,6 @@ public class Capture extends CordovaPlugin { return obj; } - /** - * Send error message to JavaScript. - * - * @param err - */ - public void fail(JSONObject err) { - this.callbackContext.error(err); - } - - /** * Creates a cursor that can be used to determine how many images we have. * @@ -544,4 +568,39 @@ public class Capture extends CordovaPlugin { return android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI; } } + + private void executeRequest(Request req) { + switch (req.action) { + case CAPTURE_AUDIO: + this.captureAudio(req); + break; + case CAPTURE_IMAGE: + this.captureImage(req); + break; + case CAPTURE_VIDEO: + this.captureVideo(req); + break; + } + } + + public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException { + Request req = pendingRequests.get(requestCode); + + if (req != null) { + boolean success = true; + for(int r:grantResults) { + if (r == PackageManager.PERMISSION_DENIED) { + success = false; + break; + } + } + + if (success) { + executeRequest(req); + } else { + pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_PERMISSION_DENIED, "Permission denied.")); + } + } + } } diff --git a/plugins/cordova-plugin-media-capture/src/android/PendingRequests.java b/plugins/cordova-plugin-media-capture/src/android/PendingRequests.java new file mode 100644 index 0000000..5676bd9 --- /dev/null +++ b/plugins/cordova-plugin-media-capture/src/android/PendingRequests.java @@ -0,0 +1,132 @@ +/* + 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.mediacapture; + +import android.util.SparseArray; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.PluginResult; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Holds the pending javascript requests for the plugin + */ +public class PendingRequests { + private int currentReqId = 0; + private SparseArray requests = new SparseArray(); + + /** + * Creates a request and adds it to the array of pending requests. Each created request gets a + * unique result code for use with startActivityForResult() and requestPermission() + * @param action The action this request corresponds to (capture image, capture audio, etc.) + * @param options The options for this request passed from the javascript + * @param callbackContext The CallbackContext to return the result to + * @return The newly created Request object with a unique result code + * @throws JSONException + */ + public synchronized Request createRequest(int action, JSONObject options, CallbackContext callbackContext) throws JSONException { + Request req = new Request(action, options, callbackContext); + requests.put(req.requestCode, req); + return req; + } + + /** + * Gets the request corresponding to this request code + * @param requestCode The request code for the desired request + * @return The request corresponding to the given request code or null if such a + * request is not found + */ + public synchronized Request get(int requestCode) { + return requests.get(requestCode); + } + + /** + * Removes the request from the array of pending requests and sends an error plugin result + * to the CallbackContext that contains the given error object + * @param req The request to be resolved + * @param error The error to be returned to the CallbackContext + */ + public synchronized void resolveWithFailure(Request req, JSONObject error) { + req.callbackContext.error(error); + requests.remove(req.requestCode); + } + + /** + * Removes the request from the array of pending requests and sends a successful plugin result + * to the CallbackContext that contains the result of the request + * @param req The request to be resolved + */ + public synchronized void resolveWithSuccess(Request req) { + req.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, req.results)); + requests.remove(req.requestCode); + } + + + /** + * Each request gets a unique ID that represents its request code when calls are made to + * Activities and for permission requests + * @return A unique request code + */ + private synchronized int incrementCurrentReqId() { + return currentReqId ++; + } + + /** + * Holds the options and CallbackContext for a capture request made to the plugin. + */ + public class Request { + + // Unique int used to identify this request in any Android Permission or Activity callbacks + public int requestCode; + + // The action that this request is performing + public int action; + + // The number of pics/vids/audio clips to take (CAPTURE_IMAGE, CAPTURE_VIDEO, CAPTURE_AUDIO) + public long limit = 1; + + // Optional max duration of recording in seconds (CAPTURE_VIDEO only) + public int duration = 0; + + // Quality level for video capture 0 low, 1 high (CAPTURE_VIDEO only) + public int quality = 1; + + // The array of results to be returned to the javascript callback on success + public JSONArray results = new JSONArray(); + + // The callback context for this plugin request + private CallbackContext callbackContext; + + private Request(int action, JSONObject options, CallbackContext callbackContext) throws JSONException { + this.callbackContext = callbackContext; + this.action = action; + + if (options != null) { + this.limit = options.optLong("limit", 1); + this.duration = options.optInt("duration", 0); + this.quality = options.optInt("quality", 1); + } + + this.requestCode = incrementCurrentReqId(); + } + } +} diff --git a/plugins/cordova-plugin-media-capture/src/blackberry10/index.js b/plugins/cordova-plugin-media-capture/src/blackberry10/index.js index ea78137..7ceb838 100644 --- a/plugins/cordova-plugin-media-capture/src/blackberry10/index.js +++ b/plugins/cordova-plugin-media-capture/src/blackberry10/index.js @@ -19,16 +19,16 @@ * */ +/* global PluginResult */ + //cordova-js/lib/common/plugin/CaptureError.js var INTERNAL_ERROR_CODE = 0, APPLICATION_BUSY_ERROR_CODE = 1, INVALID_ARGUMENT_ERROR_CODE = 2, - NO_MEDIA_FILES_ERROR_CODE = 3, - NOT_SUPPORTED_ERROR_CODE = 20; + NO_MEDIA_FILES_ERROR_CODE = 3; function capture(action, options, result, webview) { - var noop = function () {}, - limit = options.limit || 1, + var limit = options.limit || 1, fail = function (error) { result.callbackError({code: INTERNAL_ERROR_CODE}); }, @@ -52,7 +52,7 @@ function capture(action, options, result, webview) { } else { result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE }); } - } + }, onCancelled = function () { result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE }); }, diff --git a/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js b/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js index 1682994..6c7cf4b 100644 --- a/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js +++ b/plugins/cordova-plugin-media-capture/src/browser/CaptureProxy.js @@ -92,6 +92,7 @@ function CameraUI() { * @param {Function} errorCB Error callback */ CameraUI.prototype.startPreview = function(count, successCB, errorCB) { + var that = this; this.preview.onclick = function (e) { // proceed with capture here @@ -113,7 +114,6 @@ CameraUI.prototype.startPreview = function(count, successCB, errorCB) { errorCB(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }; - var that = this; navigator.getUserMedia({video: true}, function (previewStream) { // Save video stream to be able to stop it later that._previewStream = previewStream; @@ -133,24 +133,31 @@ CameraUI.prototype.destroyPreview = function () { this.preview.src = null; this._previewStream.stop(); this._previewStream = null; - this.container && document.body.removeChild(this.container); + if (this.container) { + document.body.removeChild(this.container); + } }; module.exports = { - captureAudio:function(successCallback, errorCallback) { - errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + if (errorCallback) { + errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + } }, captureVideo:function (successCallback, errorCallback) { - errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + if (errorCallback) { + errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED)); + } }, captureImage:function (successCallback, errorCallback, args) { var fail = function (code) { - errorCallback && errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR)); + if (errorCallback) { + errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR)); + } }; var options = args[0]; @@ -217,7 +224,9 @@ module.exports = { var img = document.createElement('img'); img.src = args[0]; img.onload = function () { - successCallback && successCallback(new MediaFileData(null, 0, img.height, img.width, 0)); + if (successCallback) { + successCallback(new MediaFileData(null, 0, img.height, img.width, 0)); + } }; } }; diff --git a/plugins/cordova-plugin-media-capture/src/windows/CaptureProxy.js b/plugins/cordova-plugin-media-capture/src/windows/CaptureProxy.js index 7b5ab56..3b9689e 100644 --- a/plugins/cordova-plugin-media-capture/src/windows/CaptureProxy.js +++ b/plugins/cordova-plugin-media-capture/src/windows/CaptureProxy.js @@ -19,12 +19,11 @@ * */ -/*global Windows:true */ +/* global Windows:true */ var MediaFile = require('cordova-plugin-media-capture.MediaFile'); var CaptureError = require('cordova-plugin-media-capture.CaptureError'); var CaptureAudioOptions = require('cordova-plugin-media-capture.CaptureAudioOptions'); -var CaptureImageOptions = require('cordova-plugin-media-capture.CaptureImageOptions'); var CaptureVideoOptions = require('cordova-plugin-media-capture.CaptureVideoOptions'); var MediaFileData = require('cordova-plugin-media-capture.MediaFileData'); @@ -150,7 +149,9 @@ function MediaCaptureProxy() { function destroyCameraPreview() { capturePreview.pause(); capturePreview.src = null; - previewContainer && document.body.removeChild(previewContainer); + if (previewContainer) { + document.body.removeChild(previewContainer); + } if (capture) { capture.stopRecordAsync(); capture = null; @@ -340,20 +341,19 @@ module.exports = { }, captureImage:function (successCallback, errorCallback, args) { - var options = args[0]; - var CaptureNS = Windows.Media.Capture; + + function fail(code, data) { + var err = new CaptureError(code); + err.message = data; + errorCallback(err); + } + // Check if necessary API available if (!CaptureNS.CameraCaptureUI) { // We are running on WP8.1 which lacks CameraCaptureUI class // so we need to use MediaCapture class instead and implement custom UI for camera - function fail(code, data) { - var err = new CaptureError(code); - err.message = data; - errorCallback(err); - } - var proxy = new MediaCaptureProxy(); proxy.capturePhoto(function (photoFile) { @@ -369,23 +369,26 @@ module.exports = { }); } else { - var imageOptions = new CaptureImageOptions(); var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI(); cameraCaptureUI.photoSettings.allowCropping = true; cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.highestAvailable; cameraCaptureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.jpeg; cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(function (file) { - file.moveAsync(Windows.Storage.ApplicationData.current.localFolder, "cameraCaptureImage.jpg", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () { - file.getBasicPropertiesAsync().then(function (basicProperties) { - var result = new MediaFile(file.name, 'ms-appdata:///local/' + file.name, file.contentType, basicProperties.dateModified, basicProperties.size); - result.fullPath = file.path; - successCallback([result]); + if (file) { + file.moveAsync(Windows.Storage.ApplicationData.current.localFolder, "cameraCaptureImage.jpg", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () { + file.getBasicPropertiesAsync().then(function (basicProperties) { + var result = new MediaFile(file.name, 'ms-appdata:///local/' + file.name, file.contentType, basicProperties.dateModified, basicProperties.size); + result.fullPath = file.path; + successCallback([result]); + }, function () { + errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); + }); }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }); - }, function () { + } else { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); - }); + } }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }); @@ -394,19 +397,19 @@ module.exports = { captureVideo:function (successCallback, errorCallback, args) { var options = args[0]; - var CaptureNS = Windows.Media.Capture; + + function fail(code, data) { + var err = new CaptureError(code); + err.message = data; + errorCallback(err); + } + // Check if necessary API available if (!CaptureNS.CameraCaptureUI) { // We are running on WP8.1 which lacks CameraCaptureUI class // so we need to use MediaCapture class instead and implement custom UI for camera - function fail(code, data) { - var err = new CaptureError(code); - err.message = data; - errorCallback(err); - } - var proxy = new MediaCaptureProxy(); proxy.captureVideo(function (videoFile) { @@ -433,17 +436,21 @@ module.exports = { cameraCaptureUI.videoSettings.format = Windows.Media.Capture.CameraCaptureUIVideoFormat.mp4; cameraCaptureUI.videoSettings.maxDurationInSeconds = videoOptions.duration; cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.video).then(function(file) { - file.moveAsync(Windows.Storage.ApplicationData.current.localFolder, "cameraCaptureVideo.mp4", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () { - file.getBasicPropertiesAsync().then(function(basicProperties) { - var result = new MediaFile(file.name, 'ms-appdata:///local/' + file.name, file.contentType, basicProperties.dateModified, basicProperties.size); - result.fullPath = file.path; - successCallback([result]); + if (file) { + file.moveAsync(Windows.Storage.ApplicationData.current.localFolder, "cameraCaptureVideo.mp4", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () { + file.getBasicPropertiesAsync().then(function(basicProperties) { + var result = new MediaFile(file.name, 'ms-appdata:///local/' + file.name, file.contentType, basicProperties.dateModified, basicProperties.size); + result.fullPath = file.path; + successCallback([result]); + }, function() { + errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); + }); }, function() { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }); - }, function() { + } else { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); - }); + } }, function() { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); }); } }, diff --git a/plugins/cordova-plugin-media-capture/tests/plugin.xml b/plugins/cordova-plugin-media-capture/tests/plugin.xml index 5c0ba77..d45600b 100644 --- a/plugins/cordova-plugin-media-capture/tests/plugin.xml +++ b/plugins/cordova-plugin-media-capture/tests/plugin.xml @@ -26,6 +26,8 @@ Cordova Media Capture Plugin Tests Apache 2.0 + + diff --git a/plugins/cordova-plugin-media-capture/tests/tests.js b/plugins/cordova-plugin-media-capture/tests/tests.js index 28c3dd2..7336b8a 100644 --- a/plugins/cordova-plugin-media-capture/tests/tests.js +++ b/plugins/cordova-plugin-media-capture/tests/tests.js @@ -19,6 +19,10 @@ * */ +/* jshint jasmine: true */ +/* global CaptureAudioOptions, CaptureImageOptions, CaptureVideoOptions, CaptureError */ +/* global Media, MediaFile, MediaFileData, resolveLocalFileSystemURL */ + exports.defineAutoTests = function () { describe('Capture (navigator.device.capture)', function () { it("capture.spec.1 should exist", function () { @@ -118,7 +122,6 @@ exports.defineAutoTests = function () { /******************************************************************************/ exports.defineManualTests = function (contentEl, createActionButton) { - var platformId = cordova.require('cordova/platform').id; var pageStartTime = +new Date(); function log(value) { diff --git a/plugins/cordova-plugin-media-capture/www/CaptureError.js b/plugins/cordova-plugin-media-capture/www/CaptureError.js index 6fb7a47..9892709 100644 --- a/plugins/cordova-plugin-media-capture/www/CaptureError.js +++ b/plugins/cordova-plugin-media-capture/www/CaptureError.js @@ -34,6 +34,8 @@ CaptureError.CAPTURE_APPLICATION_BUSY = 1; CaptureError.CAPTURE_INVALID_ARGUMENT = 2; // User exited camera application or audio capture application before capturing anything. CaptureError.CAPTURE_NO_MEDIA_FILES = 3; +// User denied permissions required to perform the capture request. +CaptureError.CAPTURE_PERMISSION_DENIED = 4; // The requested capture operation is not supported. CaptureError.CAPTURE_NOT_SUPPORTED = 20; diff --git a/plugins/cordova-plugin-media/README.md b/plugins/cordova-plugin-media/README.md index e5bb4a4..6ea4956 100644 --- a/plugins/cordova-plugin-media/README.md +++ b/plugins/cordova-plugin-media/README.md @@ -17,6 +17,8 @@ # under the License. --> +[![Build Status](https://travis-ci.org/apache/cordova-plugin-media.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-media) + # cordova-plugin-media @@ -36,7 +38,7 @@ Although in the global scope, it is not available until after the `deviceready` console.log(Media); } -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Media%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) +Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Media%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) ## Installation @@ -58,10 +60,6 @@ Although in the global scope, it is not available until after the `deviceready` - Only one media file can be played back at a time. -- There are strict restrictions on how your application interacts with other media. See the [Microsoft documentation for details][url]. - -[url]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh184838(v=vs.92).aspx - ## Media var media = new Media(src, mediaSuccess, [mediaError], [mediaStatus]); @@ -94,6 +92,8 @@ The following constants are reported as the only parameter to the ### Methods +- `media.getCurrentAmplitude`: Returns the current position within an audio file. + - `media.getCurrentPosition`: Returns the current position within an audio file. - `media.getDuration`: Returns the duration of an audio file. @@ -122,6 +122,47 @@ The following constants are reported as the only parameter to the - __duration__: The duration of the media, in seconds. +## media.getCurrentAmplitude + +Returns the current amplitude of the current recording. + + media.getCurrentAmplitude(mediaSuccess, [mediaError]); + +### Supported Platforms + +- Android +- iOS + +### Parameters + +- __mediaSuccess__: The callback that is passed the current amplitude (0.0 - 1.0). + +- __mediaError__: (Optional) The callback to execute if an error occurs. + +### Quick Example + + // Audio player + // + var my_media = new Media(src, onSuccess, onError); + + // Record audio + my_media.startRecord(); + + mediaTimer = setInterval(function () { + // get media amplitude + my_media.getCurrentAmplitude( + // success callback + function (amp) { + console.log(amp + "%"); + }, + // error callback + function (e) { + console.log("Error getting amp=" + e); + } + ); + }, 1000); + + ## media.getCurrentPosition Returns the current position within an audio file. Also updates the `Media` object's `position` parameter. @@ -415,7 +456,7 @@ Starts recording an audio file. - Windows devices can use MP3, M4A and WMA formats for recorded audio. However in most cases it is not possible to use MP3 for audio recording on _Windows Phone 8.1_ devices, because an MP3 encoder is [not shipped with Windows Phone](https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.mediaproperties.mediaencodingprofile.createmp3.aspx). -- If a full path is not provided, the recording is placed in the AppData/temp directory. This can be accessed via the `File` API using `LocalFileSystem.TEMPORARY` or 'ms-appdata:///temp/' URI. +- If a full path is not provided, the recording is placed in the `AppData/temp` directory. This can be accessed via the `File` API using `LocalFileSystem.TEMPORARY` or `ms-appdata:///temp/` URI. - Any subdirectory specified at record time must already exist. diff --git a/plugins/cordova-plugin-media/package.json b/plugins/cordova-plugin-media/package.json index 5021bc5..f8d7a47 100644 --- a/plugins/cordova-plugin-media/package.json +++ b/plugins/cordova-plugin-media/package.json @@ -36,9 +36,16 @@ "cordova-windows", "cordova-tizen" ], + "scripts": { + "test": "npm run jshint", + "jshint": "jshint www && jshint src && jshint tests" + }, "peerDependencies": { "cordova-plugin-file": "^4.0.0" }, "author": "Apache Software Foundation", - "license": "Apache-2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/plugins/cordova-plugin-media/plugin.xml b/plugins/cordova-plugin-media/plugin.xml index 746ea78..6c7862d 100644 --- a/plugins/cordova-plugin-media/plugin.xml +++ b/plugins/cordova-plugin-media/plugin.xml @@ -31,6 +31,7 @@ id="cordova-plugin-media" https://issues.apache.org/jira/browse/CB/component/12320647 + @@ -58,7 +59,6 @@ id="cordova-plugin-media" - diff --git a/plugins/cordova-plugin-media/src/android/AudioHandler.java b/plugins/cordova-plugin-media/src/android/AudioHandler.java index 2ff601d..39702a1 100644 --- a/plugins/cordova-plugin-media/src/android/AudioHandler.java +++ b/plugins/cordova-plugin-media/src/android/AudioHandler.java @@ -21,11 +21,13 @@ package org.apache.cordova.media; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaResourceApi; +import org.apache.cordova.PermissionHelper; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.media.AudioManager; +import android.media.AudioManager.OnAudioFocusChangeListener; import android.net.Uri; import android.os.Build; import android.util.Log; @@ -54,8 +56,9 @@ import java.util.HashMap; public class AudioHandler extends CordovaPlugin { public static String TAG = "AudioHandler"; - HashMap players; // Audio player object - ArrayList pausedForPhone; // Audio players that were paused when phone call came in + HashMap players; // Audio player object + ArrayList pausedForPhone; // Audio players that were paused when phone call came in + ArrayList pausedForFocus; // Audio players that were paused when focus was lost private int origVolumeStream = -1; private CallbackContext messageChannel; @@ -75,6 +78,7 @@ public class AudioHandler extends CordovaPlugin { public AudioHandler() { this.players = new HashMap(); this.pausedForPhone = new ArrayList(); + this.pausedForFocus = new ArrayList(); } @@ -164,6 +168,10 @@ public class AudioHandler extends CordovaPlugin { else if (action.equals("messageChannel")) { messageChannel = callbackContext; return true; + } else if (action.equals("getCurrentAmplitudeAudio")) { + float f = this.getCurrentAmplitudeAudio(args.getString(0)); + callbackContext.sendPluginResult(new PluginResult(status, f)); + return true; } else { // Unrecognized action. return false; @@ -292,6 +300,7 @@ public class AudioHandler extends CordovaPlugin { public void startPlayingAudio(String id, String file) { AudioPlayer audio = getOrCreatePlayer(id, file); audio.startPlaying(file); + getAudioFocus(); } /** @@ -371,6 +380,55 @@ public class AudioHandler extends CordovaPlugin { } } + public void pauseAllLostFocus() { + for (AudioPlayer audio : this.players.values()) { + if (audio.getState() == AudioPlayer.STATE.MEDIA_RUNNING.ordinal()) { + this.pausedForFocus.add(audio); + audio.pausePlaying(); + } + } + } + + public void resumeAllGainedFocus() { + for (AudioPlayer audio : this.pausedForFocus) { + audio.startPlaying(null); + } + this.pausedForFocus.clear(); + } + + /** + * Get the the audio focus + */ + private OnAudioFocusChangeListener focusChangeListener = new OnAudioFocusChangeListener() { + public void onAudioFocusChange(int focusChange) { + switch (focusChange) { + case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) : + case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT) : + case (AudioManager.AUDIOFOCUS_LOSS) : + pauseAllLostFocus(); + break; + case (AudioManager.AUDIOFOCUS_GAIN): + resumeAllGainedFocus(); + break; + default: + break; + } + } + }; + + public void getAudioFocus() { + AudioManager am = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE); + int result = am.requestAudioFocus(focusChangeListener, + AudioManager.STREAM_MUSIC, + AudioManager.AUDIOFOCUS_GAIN); + + if (result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { + System.out.println("AudioHandler.getAudioFocus() Error: Got " + result + " instead of " + AudioManager.AUDIOFOCUS_REQUEST_GRANTED); + } + + } + + /** * Get the audio device to be used for playback. * @@ -471,5 +529,16 @@ public class AudioHandler extends CordovaPlugin { } - + /** + * Get current amplitude of recording. + * @param id The id of the audio player + * @return amplitude + */ + public float getCurrentAmplitudeAudio(String id) { + AudioPlayer audio = this.players.get(id); + if (audio != null) { + return (audio.getCurrentAmplitude()); + } + return 0; + } } diff --git a/plugins/cordova-plugin-media/src/android/AudioPlayer.java b/plugins/cordova-plugin-media/src/android/AudioPlayer.java index ede9330..26248e5 100644 --- a/plugins/cordova-plugin-media/src/android/AudioPlayer.java +++ b/plugins/cordova-plugin-media/src/android/AudioPlayer.java @@ -501,13 +501,13 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On sendErrorStatus(MEDIA_ERR_ABORTED); } return false;//we´re not ready yet - } + } else { //reset the audio file player.seekTo(0); player.pause(); - return true; - } + return true; + } } else { //reset the player this.player.reset(); @@ -598,4 +598,23 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On this.handler.sendEventMessage("status", statusDetails); } + + /** + * Get current amplitude of recording. + * + * @return amplitude or 0 if not recording + */ + public float getCurrentAmplitude() { + if (this.recorder != null) { + try{ + if (this.state == STATE.MEDIA_RUNNING) { + return (float) this.recorder.getMaxAmplitude() / 32762; + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + return 0; + } } diff --git a/plugins/cordova-plugin-media/src/android/PermissionHelper.java b/plugins/cordova-plugin-media/src/android/PermissionHelper.java deleted file mode 100644 index aa0ed97..0000000 --- a/plugins/cordova-plugin-media/src/android/PermissionHelper.java +++ /dev/null @@ -1,138 +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.media; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; - -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.LOG; - -import android.content.pm.PackageManager; - -/** - * This class provides reflective methods for permission requesting and checking so that plugins - * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. - */ -public class PermissionHelper { - private static final String LOG_TAG = "CordovaPermissionHelper"; - - /** - * Requests a "dangerous" permission for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermission() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permission request - * @param permission The permission to be requested - */ - public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { - PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); - } - - /** - * Requests "dangerous" permissions for the application at runtime. This is a helper method - * alternative to cordovaInterface.requestPermissions() that does not require the project to be - * built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permissions are being requested for - * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() - * along with the result of the permissions request - * @param permissions The permissions to be requested - */ - public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { - try { - Method requestPermission = CordovaInterface.class.getDeclaredMethod( - "requestPermissions", CordovaPlugin.class, int.class, String[].class); - - // If there is no exception, then this is cordova-android 5.0.0+ - requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); - - // Notify the plugin that all were granted by using more reflection - deliverPermissionResult(plugin, requestCode, permissions); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); - } - } - - /** - * Checks at runtime to see if the application has been granted a permission. This is a helper - * method alternative to cordovaInterface.hasPermission() that does not require the project to - * be built with cordova-android 5.0.0+ - * - * @param plugin The plugin the permission is being checked against - * @param permission The permission to be checked - * - * @return True if the permission has already been granted and false otherwise - */ - public static boolean hasPermission(CordovaPlugin plugin, String permission) { - try { - Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); - - // If there is no exception, then this is cordova-android 5.0.0+ - return (Boolean) hasPermission.invoke(plugin.cordova, permission); - } catch (NoSuchMethodException noSuchMethodException) { - // cordova-android version is less than 5.0.0, so permission is implicitly granted - LOG.d(LOG_TAG, "No need to check for permission " + permission); - return true; - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method does not throw any exceptions, so this should never be caught - LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); - } - return false; - } - - private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { - // Generate the request results - int[] requestResults = new int[permissions.length]; - Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); - - try { - Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( - "onRequestPermissionResult", int.class, String[].class, int[].class); - - onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); - } catch (NoSuchMethodException noSuchMethodException) { - // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it - // made it to this point - LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); - } catch (IllegalAccessException illegalAccessException) { - // Should never be caught; this is a public method - LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); - } catch(InvocationTargetException invocationTargetException) { - // This method may throw a JSONException. We are just duplicating cordova-android's - // exception handling behavior here; all it does is log the exception in CordovaActivity, - // print the stacktrace, and ignore it - LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); - } - } -} diff --git a/plugins/cordova-plugin-media/src/blackberry10/index.js b/plugins/cordova-plugin-media/src/blackberry10/index.js index 1b9b786..e48fafa 100644 --- a/plugins/cordova-plugin-media/src/blackberry10/index.js +++ b/plugins/cordova-plugin-media/src/blackberry10/index.js @@ -19,6 +19,8 @@ * */ +/* global qnx, PluginResult */ + var audioObjects = {}, mediaErrorsHandled = false; diff --git a/plugins/cordova-plugin-media/src/ios/CDVSound.h b/plugins/cordova-plugin-media/src/ios/CDVSound.h index 90da62e..5e795cc 100644 --- a/plugins/cordova-plugin-media/src/ios/CDVSound.h +++ b/plugins/cordova-plugin-media/src/ios/CDVSound.h @@ -110,8 +110,9 @@ typedef NSUInteger CDVMediaMsg; - (void)startRecordingAudio:(CDVInvokedUrlCommand*)command; - (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command; +- (void)getCurrentAmplitudeAudio:(CDVInvokedUrlCommand*)command; - (void)setVolume:(CDVInvokedUrlCommand*)command; - (void)setRate:(CDVInvokedUrlCommand*)command; -@end \ No newline at end of file +@end diff --git a/plugins/cordova-plugin-media/src/ios/CDVSound.m b/plugins/cordova-plugin-media/src/ios/CDVSound.m index b12c0fb..d99f181 100644 --- a/plugins/cordova-plugin-media/src/ios/CDVSound.m +++ b/plugins/cordova-plugin-media/src/ios/CDVSound.m @@ -206,7 +206,7 @@ [errorDict setObject:[NSNumber numberWithUnsignedInteger:code] forKey:@"code"]; [errorDict setObject:message ? message:@"" forKey:@"message"]; - + NSData* jsonData = [NSJSONSerialization dataWithJSONObject:errorDict options:0 error:nil]; return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } @@ -216,14 +216,14 @@ NSString* mediaId = [command argumentAtIndex:0]; NSString* resourcePath = [command argumentAtIndex:1]; - CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:NO forRecording:NO]; + CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES forRecording:NO]; if (audioFile == nil) { NSString* errorMessage = [NSString stringWithFormat:@"Failed to initialize Media file with path %@", resourcePath]; NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMessage]]; [self.commandDelegate evalJs:jsString]; } else { - NSURL* resourceUrl = [[NSURL alloc] initWithString:resourcePath]; + NSURL* resourceUrl = audioFile.resourceURL; if (![resourceUrl isFileURL] && ![resourcePath hasPrefix:CDVFILE_PREFIX]) { // First create an AVPlayerItem @@ -290,7 +290,7 @@ float customRate = [rate floatValue]; [avPlayer setRate:customRate]; } - + [[self soundCache] setObject:audioFile forKey:mediaId]; } } @@ -420,7 +420,7 @@ if ([resourceURL isFileURL]) { audioFile.player = [[CDVAudioPlayer alloc] initWithContentsOfURL:resourceURL error:&playerError]; } else { - /* + /* NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:resourceURL]; NSString* userAgent = [self.commandDelegate userAgent]; if (userAgent) { @@ -541,10 +541,10 @@ } else if (avPlayer != nil) { int32_t timeScale = avPlayer.currentItem.asset.duration.timescale; CMTime timeToSeek = CMTimeMakeWithSeconds(posInSeconds, timeScale); - + BOOL isPlaying = (avPlayer.rate > 0 && !avPlayer.error); BOOL isReadyToSeek = (avPlayer.status == AVPlayerStatusReadyToPlay) && (avPlayer.currentItem.status == AVPlayerItemStatusReadyToPlay); - + // CB-10535: // When dealing with remote files, we can get into a situation where we start playing before AVPlayer has had the time to buffer the file to be played. // To avoid the app crashing in such a situation, we only seek if both the player and the player item are ready to play. If not ready, we send an error back to JS land. @@ -613,7 +613,7 @@ } CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:position]; - + NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_POSITION, position]; [self.commandDelegate evalJs:jsString]; [self.commandDelegate sendPluginResult:result callbackId:callbackId]; @@ -636,7 +636,7 @@ void (^startRecording)(void) = ^{ NSError* __autoreleasing error = nil; - + if (audioFile.recorder != nil) { [audioFile.recorder stop]; audioFile.recorder = nil; @@ -656,14 +656,20 @@ return; } } - + // create a new recorder for each start record + NSDictionary *audioSettings = @{AVFormatIDKey: @(kAudioFormatMPEG4AAC), + AVSampleRateKey: @(44100), + AVNumberOfChannelsKey: @(1), + AVEncoderAudioQualityKey: @(AVAudioQualityMedium) + }; audioFile.recorder = [[CDVAudioRecorder alloc] initWithURL:audioFile.resourceURL settings:nil error:&error]; - + bool recordingSuccess = NO; if (error == nil) { audioFile.recorder.delegate = weakSelf; audioFile.recorder.mediaId = mediaId; + audioFile.recorder.meteringEnabled = YES; recordingSuccess = [audioFile.recorder record]; if (recordingSuccess) { NSLog(@"Started recording audio sample '%@'", audioFile.resourcePath); @@ -671,7 +677,7 @@ [weakSelf.commandDelegate evalJs:jsString]; } } - + if ((error != nil) || (recordingSuccess == NO)) { if (error != nil) { errorMsg = [NSString stringWithFormat:@"Failed to initialize AVAudioRecorder: %@\n", [error localizedFailureReason]]; @@ -686,7 +692,7 @@ [weakSelf.commandDelegate evalJs:jsString]; } }; - + SEL rrpSel = NSSelectorFromString(@"requestRecordPermission:"); if ([self hasAudioSession] && [self.avSession respondsToSelector:rrpSel]) { @@ -710,7 +716,7 @@ } else { startRecording(); } - + } else { // file did not validate NSString* errorMsg = [NSString stringWithFormat:@"Could not record audio at '%@'", audioFile.resourcePath]; @@ -831,6 +837,39 @@ [[self soundCache] removeAllObjects]; } +- (void)getCurrentAmplitudeAudio:(CDVInvokedUrlCommand*)command +{ + NSString* callbackId = command.callbackId; + NSString* mediaId = [command argumentAtIndex:0]; + +#pragma unused(mediaId) + CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId]; + float amplitude = 0; // The linear 0.0 .. 1.0 value + + if ((audioFile != nil) && (audioFile.recorder != nil) && [audioFile.recorder isRecording]) { + [audioFile.recorder updateMeters]; + float minDecibels = -60.0f; // Or use -60dB, which I measured in a silent room. + float decibels = [audioFile.recorder averagePowerForChannel:0]; + if (decibels < minDecibels) { + amplitude = 0.0f; + } else if (decibels >= 0.0f) { + amplitude = 1.0f; + } else { + float root = 2.0f; + float minAmp = powf(10.0f, 0.05f * minDecibels); + float inverseAmpRange = 1.0f / (1.0f - minAmp); + float amp = powf(10.0f, 0.05f * decibels); + float adjAmp = (amp - minAmp) * inverseAmpRange; + amplitude = powf(adjAmp, 1.0f / root); + } + } + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:amplitude]; + + NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_POSITION, amplitude]; + [self.commandDelegate evalJs:jsString]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + } + @end @implementation CDVAudioFile @@ -849,4 +888,4 @@ @implementation CDVAudioRecorder @synthesize mediaId; -@end \ No newline at end of file +@end diff --git a/plugins/cordova-plugin-media/src/tizen/MediaProxy.js b/plugins/cordova-plugin-media/src/tizen/MediaProxy.js index 96665f0..15ab7f0 100644 --- a/plugins/cordova-plugin-media/src/tizen/MediaProxy.js +++ b/plugins/cordova-plugin-media/src/tizen/MediaProxy.js @@ -19,8 +19,9 @@ * */ -var cordova = require('cordova'), - Media = require('cordova-plugin-media.Media'); +/* global webkitURL */ + +var Media = require('cordova-plugin-media.Media'); var MediaError = require('cordova-plugin-media.MediaError'), audioObjects = {}; diff --git a/plugins/cordova-plugin-media/src/windows/MediaProxy.js b/plugins/cordova-plugin-media/src/windows/MediaProxy.js index fddec2c..d7fe294 100644 --- a/plugins/cordova-plugin-media/src/windows/MediaProxy.js +++ b/plugins/cordova-plugin-media/src/windows/MediaProxy.js @@ -34,6 +34,11 @@ var PARAMETER_IS_INCORRECT = -2147024809; var SUPPORTED_EXTENSIONS = ['.mp3', '.wma', '.wav', '.cda', '.adx', '.wm', '.m3u', '.wmx', '.m4a']; var SUPPORTED_PREFIXES = ['http', 'https', 'rstp']; +var fsTypes = { + PERSISTENT: 'PERSISTENT', + TEMPORARY: 'TEMPORARY' +}; + module.exports = { mediaCaptureMrg:null, @@ -52,7 +57,9 @@ module.exports = { var extension = srcUri.extension; if (thisM.node === null) { if (SUPPORTED_EXTENSIONS.indexOf(extension) === -1 && SUPPORTED_PREFIXES.indexOf(prefix) === -1) { - lose && lose({ code: MediaError.MEDIA_ERR_ABORTED }); + if (lose) { + lose({ code: MediaError.MEDIA_ERR_ABORTED }); + } return false; // unable to create } @@ -116,7 +123,9 @@ module.exports = { try { thisM.node.play(); } catch (err) { - lose && lose({code:MediaError.MEDIA_ERR_ABORTED}); + if (lose) { + lose({code:MediaError.MEDIA_ERR_ABORTED}); + } } }, @@ -371,11 +380,6 @@ function processUri(src) { return uri; } -var fsTypes = { - PERSISTENT: 'PERSISTENT', - TEMPORARY: 'TEMPORARY' -}; - /** * Extracts path, filename and filesystem type from Uri * @param {Object} uri Windows.Foundation.Uri diff --git a/plugins/cordova-plugin-media/tests/tests.js b/plugins/cordova-plugin-media/tests/tests.js index 0497293..b546638 100644 --- a/plugins/cordova-plugin-media/tests/tests.js +++ b/plugins/cordova-plugin-media/tests/tests.js @@ -18,10 +18,14 @@ * under the License. * */ + +/* jshint jasmine: true */ +/* global Windows, Media, MediaError, LocalFileSystem, halfSpeedBtn */ + // increased timeout for actual playback to give device chance to download and play mp3 file // some emulators can be REALLY slow at this, so two minutes var ACTUAL_PLAYBACK_TEST_TIMEOUT = 2 * 60 * 1000; - + var isWindows = cordova.platformId == 'windows8' || cordova.platformId == 'windows'; // detect whether audio hardware is available and enabled var isAudioSupported = isWindows ? Windows.Media.Devices.MediaDevice.getDefaultAudioRenderId(Windows.Media.Devices.AudioDeviceRole.default) : true; @@ -164,7 +168,14 @@ exports.defineAutoTests = function () { media1.release(); }); - it("media.spec.15 should return MediaError for bad filename", function (done) { + it("media.spec.15 should contain a getCurrentAmplitude function", function () { + var media1 = new Media("dummy"); + expect(media1.getCurrentAmplitude).toBeDefined(); + expect(typeof media1.getCurrentAmplitude).toBe('function'); + media1.release(); + }); + + it("media.spec.16 should return MediaError for bad filename", function (done) { //bb10 dialog pops up, preventing tests from running if (cordova.platformId === 'blackberry10') { pending(); @@ -199,7 +210,7 @@ exports.defineAutoTests = function () { } }); - it("media.spec.16 position should be set properly", function (done) { + it("media.spec.17 position should be set properly", function (done) { // no audio hardware available if (!isAudioSupported) { pending(); @@ -225,11 +236,11 @@ exports.defineAutoTests = function () { }, 1000); } }; - media = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); + media = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); media.play(); }, ACTUAL_PLAYBACK_TEST_TIMEOUT); - it("media.spec.17 duration should be set properly", function (done) { + it("media.spec.18 duration should be set properly", function (done) { if (!isAudioSupported || cordova.platformId === 'blackberry10') { pending(); } @@ -254,11 +265,11 @@ exports.defineAutoTests = function () { }, 1000); } }; - media = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); + media = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); media.play(); }, ACTUAL_PLAYBACK_TEST_TIMEOUT); - it("media.spec.20 should be able to resume playback after pause", function (done) { + it("media.spec.19 should be able to resume playback after pause", function (done) { if (!isAudioSupported || cordova.platformId === 'blackberry10') { pending(); } @@ -284,7 +295,7 @@ exports.defineAutoTests = function () { expect(position).toBeCloseTo(20, 0); context.done = true; done(); - }, failed.bind(null, done, 'media1.getCurrentPosition - Error getting media current position', context)) + }, failed.bind(null, done, 'media1.getCurrentPosition - Error getting media current position', context)); } if (statusCode == Media.MEDIA_PAUSED) { @@ -292,16 +303,16 @@ exports.defineAutoTests = function () { media.play(); } }; - media = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); - + media = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); + // CB-10535: Play after a few secs, to give allow enough buffering of media file before seeking setTimeout(function() { media.play(); }, 4000); - + }, ACTUAL_PLAYBACK_TEST_TIMEOUT); - it("media.spec.21 should be able to seek through file", function (done) { + it("media.spec.20 should be able to seek through file", function (done) { if (!isAudioSupported || cordova.platformId === 'blackberry10') { pending(); } @@ -325,31 +336,30 @@ exports.defineAutoTests = function () { }, 1000); } }; - media = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); - + media = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); + // CB-10535: Play after a few secs, to give allow enough buffering of media file before seeking setTimeout(function() { media.play(); }, 4000); - + }, ACTUAL_PLAYBACK_TEST_TIMEOUT); }); - it("media.spec.18 should contain a setRate function", function () { + it("media.spec.21 should contain a setRate function", function () { var media1 = new Media("dummy"); expect(media1.setRate).toBeDefined(); expect(typeof media1.setRate).toBe('function'); media1.release(); }); - it("media.spec.19 playback rate should be set properly using setRate", function (done) { + it("media.spec.22 playback rate should be set properly using setRate", function (done) { if (cordova.platformId !== 'ios') { expect(true).toFailWithMessage('Platform does not supported this feature'); pending(); return; } var mediaFile = 'https://cordova.apache.org/downloads/BlueZedEx.mp3', - mediaState = Media.MEDIA_STOPPED, successCallback, context = this, flag = true, @@ -362,8 +372,9 @@ exports.defineAutoTests = function () { flag = false; setTimeout(function () { media1.getCurrentPosition(function (position) { - //in four seconds expect position to be two times greater with some degree (1 sec) of accuracy - expect(position).toBeGreaterThan(7); + //in four seconds expect position to be between 4 & 10. Here, the values are chosen to give + //a large enough buffer range for the position to fall in and are not based on any calculation. + expect(position >= 4 && position < 10).toBeTruthy(); media1.stop(); media1.release(); done(); @@ -371,8 +382,8 @@ exports.defineAutoTests = function () { }, 4000); } }; - - var media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); + + var media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange); // jshint ignore:line //make audio playback two times faster media1.setRate(2); media1.play(); @@ -901,7 +912,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { pauseAudio(); }, 'pauseBtn'); createActionButton('HalfSpeed', function() { - if(halfSpeedBtn.firstChild.firstChild.innerText == 'HalfSpeed') { halfSpeedBtn.firstChild.firstChild.innerText = 'FullSpeed'; media1.setRate(0.5); diff --git a/plugins/cordova-plugin-media/www/Media.js b/plugins/cordova-plugin-media/www/Media.js index 37b1511..192d4b3 100644 --- a/plugins/cordova-plugin-media/www/Media.js +++ b/plugins/cordova-plugin-media/www/Media.js @@ -159,10 +159,18 @@ Media.prototype.setRate = function(rate) { if (cordova.platformId === 'ios'){ exec(null, null, "Media", "setRate", [this.id, rate]); } else { - console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.') + console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.'); } }; +/** + * Get amplitude of audio. + */ +Media.prototype.getCurrentAmplitude = function(success, fail) { + exec(function(p) { + success(p); + }, fail, "Media", "getCurrentAmplitudeAudio", [this.id]); +}; /** * Audio has status update. @@ -176,30 +184,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value == Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value == Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } - else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/plugins/cordova-plugin-media/www/browser/Media.js b/plugins/cordova-plugin-media/www/browser/Media.js index 855faac..2e3da7f 100644 --- a/plugins/cordova-plugin-media/www/browser/Media.js +++ b/plugins/cordova-plugin-media/www/browser/Media.js @@ -19,13 +19,45 @@ * */ -/*global MediaError, module, require*/ +/* global MediaError */ var argscheck = require('cordova/argscheck'), utils = require('cordova/utils'); var mediaObjects = {}; +/** + * This class provides access to the device media, interfaces to both sound and video + * + * @constructor + * @param src The file name or url to play + * @param successCallback The callback to be called when the file is done playing or recording. + * successCallback() + * @param errorCallback The callback to be called if there is an error. + * errorCallback(int errorCode) - OPTIONAL + * @param statusCallback The callback to be called when media status has changed. + * statusCallback(int statusCode) - OPTIONAL + */ +var Media = function(src, successCallback, errorCallback, statusCallback) { + argscheck.checkArgs('SFFF', 'Media', arguments); + this.id = utils.createUUID(); + mediaObjects[this.id] = this; + this.src = src; + this.successCallback = successCallback; + this.errorCallback = errorCallback; + this.statusCallback = statusCallback; + this._duration = -1; + this._position = -1; + + Media.onStatus(this.id, Media.MEDIA_STATE, Media.MEDIA_STARTING); + + try { + this.node = createNode(this); + } catch (err) { + Media.onStatus(this.id, Media.MEDIA_ERROR, { code: MediaError.MEDIA_ERR_ABORTED }); + } +}; + /** * Creates new Audio node and with necessary event listeners attached * @param {Media} media Media object @@ -66,38 +98,6 @@ function createNode (media) { return node; } -/** - * This class provides access to the device media, interfaces to both sound and video - * - * @constructor - * @param src The file name or url to play - * @param successCallback The callback to be called when the file is done playing or recording. - * successCallback() - * @param errorCallback The callback to be called if there is an error. - * errorCallback(int errorCode) - OPTIONAL - * @param statusCallback The callback to be called when media status has changed. - * statusCallback(int statusCode) - OPTIONAL - */ -var Media = function(src, successCallback, errorCallback, statusCallback) { - argscheck.checkArgs('SFFF', 'Media', arguments); - this.id = utils.createUUID(); - mediaObjects[this.id] = this; - this.src = src; - this.successCallback = successCallback; - this.errorCallback = errorCallback; - this.statusCallback = statusCallback; - this._duration = -1; - this._position = -1; - - Media.onStatus(this.id, Media.MEDIA_STATE, Media.MEDIA_STARTING); - - try { - this.node = createNode(this); - } catch (err) { - Media.onStatus(this.id, Media.MEDIA_ERROR, { code: MediaError.MEDIA_ERR_ABORTED }); - } -}; - // Media messages Media.MEDIA_STATE = 1; Media.MEDIA_DURATION = 2; @@ -230,29 +230,37 @@ Media.onStatus = function(id, msgType, value) { var media = mediaObjects[id]; - if(media) { + if (media) { switch(msgType) { case Media.MEDIA_STATE : - media.statusCallback && media.statusCallback(value); - if(value === Media.MEDIA_STOPPED) { - media.successCallback && media.successCallback(); + if (media.statusCallback) { + media.statusCallback(value); + } + if (value === Media.MEDIA_STOPPED) { + if (media.successCallback) { + media.successCallback(); + } } break; case Media.MEDIA_DURATION : media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + if (media.errorCallback) { + media.errorCallback(value); + } break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console.error && console.error("Unhandled Media.onStatus :: " + msgType); + if (console.error) { + console.error("Unhandled Media.onStatus :: " + msgType); + } break; } - } else { - console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); + } else if (console.error) { + console.error("Received Media.onStatus callback for unknown media :: " + id); } }; diff --git a/plugins/cordova-plugin-network-information/CONTRIBUTING.md b/plugins/cordova-plugin-network-information/CONTRIBUTING.md new file mode 100644 index 0000000..4c8e6a5 --- /dev/null +++ b/plugins/cordova-plugin-network-information/CONTRIBUTING.md @@ -0,0 +1,37 @@ + + +# Contributing to Apache Cordova + +Anyone can contribute to Cordova. And we need your contributions. + +There are multiple ways to contribute: report bugs, improve the docs, and +contribute code. + +For instructions on this, start with the +[contribution overview](http://cordova.apache.org/contribute/). + +The details are explained there, but the important items are: + - Sign and submit an Apache ICLA (Contributor License Agreement). + - Have a Jira issue open that corresponds to your contribution. + - Run the tests so your patch doesn't break existing functionality. + +We look forward to your contributions! diff --git a/plugins/cordova-plugin-network-information/LICENSE b/plugins/cordova-plugin-network-information/LICENSE new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/plugins/cordova-plugin-network-information/LICENSE @@ -0,0 +1,202 @@ + + 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 diff --git a/plugins/cordova-plugin-network-information/NOTICE b/plugins/cordova-plugin-network-information/NOTICE new file mode 100644 index 0000000..fb19cbd --- /dev/null +++ b/plugins/cordova-plugin-network-information/NOTICE @@ -0,0 +1,8 @@ +Apache Cordova +Copyright 2012 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +This product includes software developed by Apple Inc. License can be found in the header of the affected files. (src/ios/CDVReachability.h, src/ios/CDVReachability.m) + diff --git a/plugins/cordova-plugin-network-information/README.md b/plugins/cordova-plugin-network-information/README.md new file mode 100644 index 0000000..2eabd1e --- /dev/null +++ b/plugins/cordova-plugin-network-information/README.md @@ -0,0 +1,213 @@ + + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-network-information) + +# cordova-plugin-network-information + + +This plugin provides an implementation of an old version of the +[Network Information API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). +It provides information about the device's cellular and +wifi connection, and whether the device has an internet connection. + +Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cordova issue tracker]. + +## Installation + + cordova plugin add cordova-plugin-network-information + +## Supported Platforms + +- Amazon Fire OS +- Android +- BlackBerry 10 +- Browser +- iOS +- Windows Phone 7 and 8 +- Tizen +- Windows +- Firefox OS + +# Connection + +> The `connection` object, exposed via `navigator.connection`, provides information about the device's cellular and wifi connection. + +## Properties + +- connection.type + +## Constants + +- Connection.UNKNOWN +- Connection.ETHERNET +- Connection.WIFI +- Connection.CELL_2G +- Connection.CELL_3G +- Connection.CELL_4G +- Connection.CELL +- Connection.NONE + +## connection.type + +This property offers a fast way to determine the device's network +connection state, and type of connection. + +### Quick Example + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API Change + +Until Cordova 2.3.0, the `Connection` object was accessed via +`navigator.network.connection`, after which it was changed to +`navigator.connection` to match the W3C specification. It's still +available at its original location, but is deprecated and will +eventually be removed. + +### iOS Quirks + +- +# Release Notes + +### 1.2.0 (Jan 15, 2016) +* Adding `CoreTelephony` to `plugin.xml` +* Adding notification for `CT radio` information +* Adding `CT radio` information +* CB-10160: Fixed the case mismatch issue + +### 1.1.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* Fixing contribute link. +* These notifications are objects so their address always evaluates to true. +* Update `NetworkManager.java` +* [CB-9542](https://issues.apache.org/jira/browse/CB-9542) `Browser Proxy` not defined correctly +* Solved `toLowerCase` issue with `Locale.US` + +### 1.0.1 (Jun 17, 2015) +* Adding .ratignore file. +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-network-information documentation translation: cordova-plugin-network-information +* fix npm md issue + +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Fixes typo in `cordova.platformId` +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Use `navigator.onLine` as connection information source on browser platform +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of initWebView method +* [CB-8573](https://issues.apache.org/jira/browse/CB-8573) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-network-information documentation translation: cordova-plugin-network-information +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file + +### 0.2.15 (Feb 04, 2015) +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Network status change support on Windows +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Fixes the way we detect online status on Windows +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows platform quirks +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows section to Network Information plugin + +### 0.2.14 (Dec 02, 2014) +* [CB-7976](https://issues.apache.org/jira/browse/CB-7976) **Android**: Use webView's context rather than Activity's context for intent receiver +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-network-information documentation translation: cordova-plugin-network-information + +### 0.2.13 (Oct 03, 2014) +* [CB-7595](https://issues.apache.org/jira/browse/CB-7595): Android L changes the type from Mobile to Cellular, I'm pretty sure this isn't documented + +### 0.2.12 (Sep 17, 2014) +* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-network-information documentation translation +* Fix network information type exception on fxos 2 +* Added support for the browser +* [CB-6724](https://issues.apache.org/jira/browse/CB-6724) added documentation for manual tests +* remove reference to test assets, they are optional +* Renamed test dir and added nested plugin.xml +* [CB-6964](https://issues.apache.org/jira/browse/CB-6964) ported manual tests +* Port network tests to plugin-test-framework +* Fix naviagtor typo + +### 0.2.11 (Aug 06, 2014) +* **FFOS** update NetworkProxy.js +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs +* [CB-7019](https://issues.apache.org/jira/browse/CB-7019) Updated version and RELEASENOTES.md for release 0.2.10 +* Fixed docs for online/offline event being backwards + +### 0.2.10 (Jun 24, 2014) +* [CB-6907](https://issues.apache.org/jira/browse/CB-6907): [android] Don't crash on startup if no networks available + +### 0.2.9 (Jun 05, 2014) +* updated notice file to include missing license +* Cached extra info to better detect changes. +* [CB-6809](https://issues.apache.org/jira/browse/CB-6809) Add license to CONTRIBUTING.md +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md +* [CB-6350](https://issues.apache.org/jira/browse/CB-6350) - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8) +* Initial version of firefox os network information plugin +* there was an error in the object definition + +### 0.2.8 (Apr 17, 2014) +* [CB-6342](https://issues.apache.org/jira/browse/CB-6342): [iOS] iOS reports a cellular connection even when in Airplane mode +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code +* Add NOTICE file + +### 0.2.7 (Feb 05, 2014) +* Initial implementation of Tizen plugin. + +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for netinfo plugin + +### 0.2.5 (Dec 4, 2013) +* [ubuntu] specify policy_group +* add ubuntu platform +* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos' + +### 0.2.4 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to plugin.xml for network information plugin +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [windows8] commandProxy was moved +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.network-information to org.apache.cordova.network-information +* removed duplicate comment line from plugin.xml +* added Network APIs for FirefoxOS +* Rename CHANGELOG.md -> RELEASENOTES.md +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. + +### 0.2.1 (Sept 5, 2013) +* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change diff --git a/plugins/cordova-plugin-network-information/doc/de/README.md b/plugins/cordova-plugin-network-information/doc/de/README.md new file mode 100644 index 0000000..f6292b2 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/de/README.md @@ -0,0 +1,190 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +Dieses Plugin stellt eine Implementierung einer alten Version der [Netzwerk-Informationen-API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). Es werden Informationen über das Gerät Mobilfunk und Wifi-Anschluss, und ob das Gerät über eine Internetverbindung verfügt. + +## Installation + + cordova plugin add cordova-plugin-network-information + + +## Unterstützte Plattformen + + * Amazon Fire OS + * Android + * BlackBerry 10 + * Browser + * iOS + * Windows Phone 7 und 8 + * Tizen + * Windows + * Firefox OS + +# Connection + +> Das `connection` Objekt, verfügbar gemachten über `navigator.connection`, enthält Informationen über die Mobilfunk- und Wi-Fi-Verbindung des Gerätes. + +## Eigenschaften + + * connection.type + +## Konstanten + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## connection.type + +Diese Eigenschaft bietet eine schnelle Möglichkeit, um den Netzwerkverbindungsstatus und die Art der Verbindung zu bestimmen. + +### Kurzes Beispiel + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API Änderung + +Bis Cordova 2.3.0 wurde auf das `Connection` Objekt über `navigator.network.connection` zugegriffen, danach wurde der Zugriff auf `navigator.connection` geändert, um der W3C-Spezifikation zu entsprechen. Es steht immer noch an seiner ursprünglichen Stelle, aber ist veraltet und wird schliesslich entfernt. + +### iOS Macken + + * iOS kann Mobilfunknetz Verbindungstyp nicht erkennen. + * `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten. + +### Windows Phone Macken + + * Wenn im Emulator ausgeführt wird, erkennt immer `navigator.connection.type` als`Connection.UNKNOWN`. + + * Windows Phone kann Mobilfunknetz Verbindungstyp nicht erkennen. + + * `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten. + +### Windows-Eigenheiten + + * Wenn im Telefon 8.1 Emulator ausgeführt wird, erkennt immer `navigator.connection.type` als `Connection.ETHERNET`. + +### Tizen Macken + + * Tizen kann nur ein WiFi oder Mobilfunkverbindung erkennen. + * `Navigator.Connection.Type` ist für alle Handy-Daten auf `Connection.CELL_2G` festgelegt. + +### Firefox OS Macken + + * Firefox-OS kann Mobilfunknetz Verbindungstyp nicht erkennen. + * `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten. + +### Browser-Eigenheiten + + * Browser kann die Art der Netzwerkverbindung nicht erkennen. `navigator.connection.type` ist immer auf `Connection.UNKNOWN` beim online gesetzt. + +# Netzwerk-Veranstaltungen + +## offline + +Das Ereignis wird ausgelöst, wenn eine Anwendung offline geht, und das Gerät nicht mit dem Internet verbunden ist. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Details + +Das `offline` -Ereignis wird ausgelöst, wenn ein bereits angeschlossenes Gerät eine Netzwerkverbindung verliert, so dass eine Anwendung nicht mehr auf das Internet zugreifen kann. Es stützt sich auf die gleichen Informationen wie die Verbindung-API und wird ausgelöst, wenn der Wert des `connection.type` wird`NONE`. + +Anwendungen sollten in der Regel verwenden `document.addEventListener` einmal einen Ereignis-Listener hinzufügen das `deviceready` -Ereignis ausgelöst. + +### Kurzes Beispiel + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS Macken + +Beim ersten Start dauert das erste offline-Event (falls zutreffend) mindestens eine Sekunde zu schießen. + +### Windows Phone 7 Macken + +Bei der Ausführung im Emulator, der `connection.status` ist immer unbekannt, so dass dieses Ereignis *nicht* Feuer. + +### Windows Phone 8 Macken + +Der Emulator meldet den Verbindungstyp als `Cellular` , die wird nicht geändert, so dass das Ereignis *nicht* Feuer. + +## online + +Dieses Ereignis wird ausgelöst, wenn eine Anwendung online geht, und das Gerät wird mit dem Internet verbunden. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Details + +Das `online` -Ereignis wird ausgelöst, wenn ein zuvor unverbundenen Gerät eine Netzwerkverbindung zu einem Anwendung Zugriff auf das Internet empfängt. Es stützt sich auf die gleichen Informationen wie die Verbindung-API und wird ausgelöst, wenn die `connection.type` ändert sich von `NONE` auf einen anderen Wert. + +Anwendungen sollten in der Regel verwenden `document.addEventListener` einmal einen Ereignis-Listener hinzufügen das `deviceready` -Ereignis ausgelöst. + +### Kurzes Beispiel + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS Macken + +Beim ersten Start die erste `online` Ereignis (falls zutreffend) dauert mindestens eine Sekunde vor dem Feuer `connection.type` ist`UNKNOWN`. + +### Windows Phone 7 Macken + +Bei der Ausführung im Emulator, der `connection.status` ist immer unbekannt, so dass dieses Ereignis *nicht* Feuer. + +### Windows Phone 8 Macken + +Der Emulator meldet den Verbindungstyp als `Cellular` , die wird nicht geändert, so dass Ereignisse *nicht* Feuer. \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/de/index.md b/plugins/cordova-plugin-network-information/doc/de/index.md new file mode 100644 index 0000000..537328a --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/de/index.md @@ -0,0 +1,186 @@ + + +# cordova-plugin-network-information + +Dieses Plugin stellt eine Implementierung einer alten Version der [Netzwerk-Informationen-API][1]. Es werden Informationen über das Gerät Mobilfunk und Wifi-Anschluss, und ob das Gerät über eine Internetverbindung verfügt. + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## Installation + + cordova plugin add cordova-plugin-network-information + + +## Unterstützte Plattformen + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Browser +* iOS +* Windows Phone 7 und 8 +* Tizen +* Windows +* Firefox OS + +# Connection + +> Das `connection` Objekt, verfügbar gemachten über `navigator.connection`, enthält Informationen über die Mobilfunk- und Wi-Fi-Verbindung des Gerätes. + +## Eigenschaften + +* connection.type + +## Konstanten + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## connection.type + +Diese Eigenschaft bietet eine schnelle Möglichkeit, um den Netzwerkverbindungsstatus und die Art der Verbindung zu bestimmen. + +### Kurzes Beispiel + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API Änderung + +Bis Cordova 2.3.0 wurde auf das `Connection` Objekt über `navigator.network.connection` zugegriffen, danach wurde der Zugriff auf `navigator.connection` geändert, um der W3C-Spezifikation zu entsprechen. Es steht immer noch an seiner ursprünglichen Stelle, aber ist veraltet und wird schliesslich entfernt. + +### iOS Macken + +* iOS kann Mobilfunknetz Verbindungstyp nicht erkennen. + * `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten. + +### Windows Phone Macken + +* Wenn im Emulator ausgeführt wird, erkennt immer `navigator.connection.type` als`Connection.UNKNOWN`. + +* Windows Phone kann Mobilfunknetz Verbindungstyp nicht erkennen. + + * `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten. + +### Windows-Eigenheiten + +* Wenn im Telefon 8.1 Emulator ausgeführt wird, erkennt immer `navigator.connection.type` als `Connection.ETHERNET`. + +### Tizen Macken + +* Tizen kann nur ein WiFi oder Mobilfunkverbindung erkennen. + * `Navigator.Connection.Type` ist für alle Handy-Daten auf `Connection.CELL_2G` festgelegt. + +### Firefox OS Macken + +* Firefox-OS kann Mobilfunknetz Verbindungstyp nicht erkennen. + * `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten. + +# Netzwerk-Veranstaltungen + +## offline + +Das Ereignis wird ausgelöst, wenn eine Anwendung offline geht, und das Gerät nicht mit dem Internet verbunden ist. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Details + +Das `offline` -Ereignis wird ausgelöst, wenn ein bereits angeschlossenes Gerät eine Netzwerkverbindung verliert, so dass eine Anwendung nicht mehr auf das Internet zugreifen kann. Es stützt sich auf die gleichen Informationen wie die Verbindung-API und wird ausgelöst, wenn der Wert des `connection.type` wird`NONE`. + +Anwendungen sollten in der Regel verwenden `document.addEventListener` einmal einen Ereignis-Listener hinzufügen das `deviceready` -Ereignis ausgelöst. + +### Kurzes Beispiel + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS Macken + +Beim ersten Start dauert das erste offline-Event (falls zutreffend) mindestens eine Sekunde zu schießen. + +### Windows Phone 7 Macken + +Bei der Ausführung im Emulator, der `connection.status` ist immer unbekannt, so dass dieses Ereignis *nicht* Feuer. + +### Windows Phone 8 Macken + +Der Emulator meldet den Verbindungstyp als `Cellular` , die wird nicht geändert, so dass das Ereignis *nicht* Feuer. + +## online + +Dieses Ereignis wird ausgelöst, wenn eine Anwendung online geht, und das Gerät wird mit dem Internet verbunden. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Details + +Das `online` -Ereignis wird ausgelöst, wenn ein zuvor unverbundenen Gerät eine Netzwerkverbindung zu einem Anwendung Zugriff auf das Internet empfängt. Es stützt sich auf die gleichen Informationen wie die Verbindung-API und wird ausgelöst, wenn die `connection.type` ändert sich von `NONE` auf einen anderen Wert. + +Anwendungen sollten in der Regel verwenden `document.addEventListener` einmal einen Ereignis-Listener hinzufügen das `deviceready` -Ereignis ausgelöst. + +### Kurzes Beispiel + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS Macken + +Beim ersten Start die erste `online` Ereignis (falls zutreffend) dauert mindestens eine Sekunde vor dem Feuer `connection.type` ist`UNKNOWN`. + +### Windows Phone 7 Macken + +Bei der Ausführung im Emulator, der `connection.status` ist immer unbekannt, so dass dieses Ereignis *nicht* Feuer. + +### Windows Phone 8 Macken + +Der Emulator meldet den Verbindungstyp als `Cellular` , die wird nicht geändert, so dass Ereignisse *nicht* Feuer. diff --git a/plugins/cordova-plugin-network-information/doc/es/README.md b/plugins/cordova-plugin-network-information/doc/es/README.md new file mode 100644 index 0000000..4e30593 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/es/README.md @@ -0,0 +1,190 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +Este plugin proporciona una implementación de una versión antigua de la [Red de información API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). Proporciona información acerca del dispositivo móvil y conexión wifi, y si el dispositivo tiene una conexión a internet. + +## Instalación + + cordova plugin add cordova-plugin-network-information + + +## Plataformas soportadas + + * Amazon fire OS + * Android + * BlackBerry 10 + * Explorador + * iOS + * Windows Phone 7 y 8 + * Tizen + * Windows + * Firefox OS + +# Connection + +> El objeto de `connection`, expuesto a través de `navigator.connection`, proporciona información sobre conexión celular y wifi del dispositivo. + +## Propiedades + + * connection.type + +## Constantes + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## connection.type + +Esta propiedad ofrece una forma rápida de determinar el estado de conexión de red del dispositivo y el tipo de conexión. + +### Ejemplo rápido + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Cambio de API + +Hasta Cordova 2.3.0, el objeto de `conexión` era acceder a través de `navigator.network.connection`, tras lo cual fue cambiada a `navigator.connection` para que coincida con la especificación del W3C. Sigue estando disponible en su ubicación original, pero es obsoleto y eventualmente desaparecerá. + +### iOS rarezas + + * iOS no puede detectar el tipo de conexión de red celular. + * `navigator.connection.type` está establecido en `Connection.CELL` para todos los datos de celulares. + +### Windows Phone rarezas + + * Cuando se ejecuta en el emulador, siempre detecta `navigator.connection.type` como `Connection.UNKNOWN`. + + * Windows Phone no puede detectar el tipo de conexión de red celular. + + * `navigator.connection.type` está establecido en `Connection.CELL` para todos los datos de celulares. + +### Windows rarezas + + * Cuando se ejecuta en el emulador de teléfono 8.1, siempre detecta `navigator.connection.type` como`Connection.ETHERNET`. + +### Rarezas Tizen + + * Tizen sólo puede detectar un Wi-Fi o conexión celular. + * `navigator.connection.type`se establece en `Connection.CELL_2G` para todos los datos celulares. + +### Firefox OS rarezas + + * Firefox OS no puede detectar el tipo de conexión de red celular. + * `navigator.connection.type` está establecido en `Connection.CELL` para todos los datos de celulares. + +### Navegador rarezas + + * Navegador no puede detectar el tipo de conexión de red. `Navigator.Connection.Type` se encuentra siempre a `Connection.UNKNOWN` cuando en línea. + +# Eventos relacionados con la red + +## offline + +El evento se desencadena cuando una aplicación está desconectada, y el dispositivo no está conectado a Internet. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Detalles + +El evento `offline` se desencadena cuando un dispositivo conectado previamente pierde una conexión de red para que una aplicación no puede acceder a Internet. Se basa en la misma información que la API de conexión y cuando se dispara el valor del `connection.type` se convierte`NONE`. + +Las aplicaciones normalmente deben utilizar `document.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`. + +### Ejemplo rápido + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS rarezas + +Durante el arranque inicial, el primer evento offline (si es aplicable) tarda al menos un segundo en fuego. + +### Windows Phone 7 rarezas + +Cuando se ejecuta en el emulador, la `connection.status` siempre es desconocido, así que este evento no se ** fuego. + +### Windows Phone 8 rarezas + +El emulador informa el tipo de conexión como `celular`, que no cambia, así que el evento *no se* fuego. + +## online + +Este evento se desencadena cuando una aplicación va en línea, y el dispositivo se conecta a Internet. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Detalles + +El evento `online` se desencadena cuando un dispositivo previamente inconexos recibe una conexión de red para permitir un acceso a las aplicaciones para Internet. Se basa en la misma información que la API de conexión y se desencadena cuando el `connection.type` cambia de `ninguno` a cualquier otro valor. + +Las aplicaciones normalmente deben utilizar `document.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`. + +### Ejemplo rápido + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS rarezas + +Durante el arranque inicial, el primer evento `en línea` (si procede) al menos toma un segundo para disparar, antes de que `connection.type` es `desconocido`. + +### Windows Phone 7 rarezas + +Cuando se ejecuta en el emulador, la `connection.status` siempre es desconocido, así que este evento no se ** fuego. + +### Windows Phone 8 rarezas + +El emulador, informa el tipo de conexión como `Cellular` , que no cambia, así que se lo eventos *no* fuego. \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/es/index.md b/plugins/cordova-plugin-network-information/doc/es/index.md new file mode 100644 index 0000000..65158ef --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/es/index.md @@ -0,0 +1,186 @@ + + +# cordova-plugin-network-information + +Este plugin proporciona una implementación de una versión antigua de la [Red de información API][1]. Proporciona información acerca del dispositivo móvil y conexión wifi, y si el dispositivo tiene una conexión a internet. + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## Instalación + + cordova plugin add cordova-plugin-network-information + + +## Plataformas soportadas + +* Amazon fire OS +* Android +* BlackBerry 10 +* Explorador +* iOS +* Windows Phone 7 y 8 +* Tizen +* Windows +* Firefox OS + +# Conexión + +> El objeto de `connection`, expuesto a través de `navigator.connection`, proporciona información sobre conexión celular y wifi del dispositivo. + +## Propiedades + +* connection.type + +## Constantes + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_4G +* Connection.CELL_3G +* Connection.CELL +* Connection.NONE + +## connection.type + +Esta propiedad ofrece una forma rápida de determinar el estado de conexión de red del dispositivo y el tipo de conexión. + +### Ejemplo rápido + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Cambio de API + +Hasta Cordova 2.3.0, el objeto de `conexión` era acceder a través de `navigator.network.connection`, tras lo cual fue cambiada a `navigator.connection` para que coincida con la especificación del W3C. Sigue estando disponible en su ubicación original, pero es obsoleto y eventualmente desaparecerá. + +### iOS rarezas + +* iOS no puede detectar el tipo de conexión de red celular. + * `navigator.connection.type` está establecido en `Connection.CELL` para todos los datos de celulares. + +### Windows Phone rarezas + +* Cuando se ejecuta en el emulador, siempre detecta `navigator.connection.type` como `Connection.UNKNOWN`. + +* Windows Phone no puede detectar el tipo de conexión de red celular. + + * `navigator.connection.type` está establecido en `Connection.CELL` para todos los datos de celulares. + +### Windows rarezas + +* Cuando se ejecuta en el emulador de teléfono 8.1, siempre detecta `navigator.connection.type` como`Connection.ETHERNET`. + +### Rarezas Tizen + +* Tizen sólo puede detectar un Wi-Fi o conexión celular. + * `navigator.connection.type`se establece en `Connection.CELL_2G` para todos los datos celulares. + +### Firefox OS rarezas + +* Firefox OS no puede detectar el tipo de conexión de red celular. + * `navigator.connection.type`se establece en `Connection.CELL` para todos los datos celulares. + +# Eventos relacionados con la red + +## offline + +El evento se desencadena cuando una aplicación está desconectada, y el dispositivo no está conectado a Internet. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Detalles + +El evento `offline` se desencadena cuando un dispositivo conectado previamente pierde una conexión de red para que una aplicación no puede acceder a Internet. Se basa en la misma información que la API de conexión y cuando se dispara el valor del `connection.type` se convierte`NONE`. + +Las aplicaciones normalmente deben utilizar `document.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`. + +### Ejemplo rápido + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS rarezas + +Durante el arranque inicial, el primer evento offline (si es aplicable) tarda al menos un segundo en fuego. + +### Windows Phone 7 rarezas + +Cuando se ejecuta en el emulador, la `connection.status` siempre es desconocido, así que este evento no se ** fuego. + +### Windows Phone 8 rarezas + +El emulador informa el tipo de conexión como `celular`, que no cambia, así que el evento *no se* fuego. + +## online + +Este evento se desencadena cuando una aplicación va en línea, y el dispositivo se conecta a Internet. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Detalles + +El evento `online` se desencadena cuando un dispositivo previamente inconexos recibe una conexión de red para permitir un acceso a las aplicaciones para Internet. Se basa en la misma información que la API de conexión y se desencadena cuando el `connection.type` cambia de `ninguno` a cualquier otro valor. + +Las aplicaciones normalmente deben utilizar `document.addEventListener` para conectar un detector de eventos una vez que se desencadene el evento `deviceready`. + +### Ejemplo rápido + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS rarezas + +Durante el arranque inicial, el primer evento `en línea` (si procede) al menos toma un segundo para disparar, antes de que `connection.type` es `desconocido`. + +### Windows Phone 7 rarezas + +Cuando se ejecuta en el emulador, la `connection.status` siempre es desconocido, así que este evento no se ** fuego. + +### Windows Phone 8 rarezas + +El emulador, informa el tipo de conexión como `Cellular` , que no cambia, así que se lo eventos *no* fuego. diff --git a/plugins/cordova-plugin-network-information/doc/fr/README.md b/plugins/cordova-plugin-network-information/doc/fr/README.md new file mode 100644 index 0000000..8f2b82c --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/fr/README.md @@ -0,0 +1,188 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +Ce plugin fournit une implémentation d'une ancienne version de l' [API Information Network](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). Il fournit des informations sur l'appareil cellulaire et connexion wifi, et si l'appareil dispose d'une connexion internet. + +## Installation + + cordova plugin add cordova-plugin-network-information + + +## Plates-formes supportées + + * Amazon Fire OS + * Android + * BlackBerry 10 + * Navigateur + * iOS + * Windows Phone 7 et 8 + * Paciarelli + * Windows + * Firefox OS + +# Connexion + +> L'objet `connection`, disponible via `navigator.connection`, fournit des informations sur la connection cellulaire/wifi de l'appareil. + +## Propriétés + + * connection.type + +## Constantes + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## connection.type + +Cette propriété offre un moyen rapide pour déterminer l'état et le type de la connexion réseau de l'appareil. + +### Exemple court + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Changement d'API + +Jusqu'à Cordova 2.3.0, l'objet `Connection` était accessible via `navigator.network.connection` ; ceci a été changé pour `navigator.connection` afin de concorder avec la spécification du W3C. L'accès est toujours possible à l'emplacement d'origine, mais est considéré comme obsolète et sera bientôt supprimé. + +### Notes au sujet d'iOS + + * iOS ne peut pas détecter le type de connexion au réseau cellulaire. + * `navigator.connection.type`a la valeur `Connection.CELL` pour toutes les données cellulaires. + +### Windows Phone Quirks + + * Lors de l'exécution dans l'émulateur, détecte toujours `navigator.connection.type` comme`Connection.UNKNOWN`. + + * Windows Phone ne peut pas détecter le type de connexion au réseau cellulaire. + + * `navigator.connection.type`a la valeur `Connection.CELL` pour toutes les données cellulaires. + +### Bizarreries de Windows + + * Lors de l'exécution dans l'émulateur de téléphone 8.1, `Connection.ETHERNET` détecte toujours `navigator.connection.type`. + +### Bizarreries de paciarelli + + * Paciarelli ne peut détecter une connexion cellulaire ou le WiFi. + * `navigator.connection.type` a la valeur `Connection.CELL_2G` pour toutes les données cellulaires. + +### Firefox OS Quirks + + * Firefox OS ne peut pas détecter le type de connexion au réseau cellulaire. + * `navigator.connection.type`a la valeur `Connection.CELL` pour toutes les données cellulaires. + +### Bizarreries navigateur + + * Navigateur ne peut pas détecter le type de connexion réseau. `navigator.connection.type` est toujours définie sur `Connection.UNKNOWN` en ligne. + +# Événements liés au réseau + +## offline + +L'évènement se déclenche lorsqu'une application se déconnecte, quand l'appareil n'est pas connecté à Internet. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Détails + +L'évènement `offline` se déclenche lorsqu'un appareil précédemment connecté perd sa connexion au réseau, empêchant ainsi l'application d'accéder à Internet. Il s'appuie sur les mêmes informations que l'API de connexion et se déclenche lorsque la valeur de `connection.type` devient`NONE`. + +Les applications devraient en général utiliser `document.addEventListener` pour attacher un écouteur d'évènements, une fois l'évènement `deviceready` déclenché. + +### Exemple court + + document.addEventListener (« hors ligne », onOffline, false) ; + + function onOffline() {/ / gestion de l'événement en mode hors connexion} + + +### Notes au sujet d'iOS + +Lors du démarrage initial, le déclenchement du premier évènement offline (si applicable) prend au moins une seconde. + +### Windows Phone 7 Quirks + +Lors de l'exécution dans l'émulateur, le `connection.status` est toujours inconnu, ainsi cet événement ne fait *pas* de feu. + +### Notes au sujet de Windows Phone 8 + +L'émulateur signale le type de connexion comme `Cellular`, type qui ne change jamais, ainsi l'évènement n'est *pas* déclenché. + +## online + +L'évènement se déclenche lorsqu'une application se connecte, quand l'appareil est connecté à Internet. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Détails + +L'évènement `online` se déclenche lorsqu'un appareil précédemment non-connecté se connecte au réseau, permettant ainsi à l'application d'accéder à Internet. Il s'appuie sur les mêmes informations que l'API de connexion et se déclenche quand le `connection.type` passe de `NONE` à une autre valeur. + +Les applications devraient en général utiliser `document.addEventListener` pour attacher un écouteur d'évènements, une fois l'évènement `deviceready` déclenché. + +### Exemple court + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### Notes au sujet d'iOS + +Lors du démarrage initial, le déclenchement du premier évènement `online` (si applicable) prend au moins une seconde avant quoi `connection.type` vaut `UNKNOWN`. + +### Windows Phone 7 Quirks + +Lors de l'exécution dans l'émulateur, le `connection.status` est toujours inconnu, ainsi cet événement ne fait *pas* de feu. + +### Notes au sujet de Windows Phone 8 + +L'émulateur signale le type de connexion comme `Cellular` , qui ne change pas, aussi des événements ne fait *pas* de feu. \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/fr/index.md b/plugins/cordova-plugin-network-information/doc/fr/index.md new file mode 100644 index 0000000..e49c5d5 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/fr/index.md @@ -0,0 +1,184 @@ + + +# cordova-plugin-network-information + +Ce plugin fournit une implémentation d'une ancienne version de l' [API Information Network][1]. Il fournit des informations sur l'appareil cellulaire et connexion wifi, et si l'appareil dispose d'une connexion internet. + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## Installation + + cordova plugin add cordova-plugin-network-information + + +## Plates-formes prises en charge + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Navigateur +* iOS +* Windows Phone 7 et 8 +* Paciarelli +* Windows +* Firefox OS + +# Connexion + +> L'objet `connection`, disponible via `navigator.connection`, fournit des informations sur la connection cellulaire/wifi de l'appareil. + +## Propriétés + +* connection.type + +## Constantes + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## connection.type + +Cette propriété offre un moyen rapide pour déterminer l'état et le type de la connexion réseau de l'appareil. + +### Petit exemple + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Changement d'API + +Jusqu'à Cordova 2.3.0, l'objet `Connection` était accessible via `navigator.network.connection` ; ceci a été changé pour `navigator.connection` afin de concorder avec la spécification du W3C. L'accès est toujours possible à l'emplacement d'origine, mais est considéré comme obsolète et sera bientôt supprimé. + +### iOS Quirks + +* iOS ne peut pas détecter le type de connexion au réseau cellulaire. + * `navigator.connection.type`a la valeur `Connection.CELL` pour toutes les données cellulaires. + +### Windows Phone Quirks + +* Lors de l'exécution dans l'émulateur, détecte toujours `navigator.connection.type` comme`Connection.UNKNOWN`. + +* Windows Phone ne peut pas détecter le type de connexion au réseau cellulaire. + + * `navigator.connection.type`a la valeur `Connection.CELL` pour toutes les données cellulaires. + +### Bizarreries de Windows + +* Lors de l'exécution dans l'émulateur de téléphone 8.1, `Connection.ETHERNET` détecte toujours `navigator.connection.type`. + +### Bizarreries de paciarelli + +* Paciarelli ne peut détecter une connexion cellulaire ou le WiFi. + * `navigator.connection.type` a la valeur `Connection.CELL_2G` pour toutes les données cellulaires. + +### Firefox OS Quirks + +* Firefox OS ne peut pas détecter le type de connexion au réseau cellulaire. + * `navigator.connection.type` a la valeur `Connection.CELL` pour toutes les données cellulaires. + +# Événements liés au réseau + +## offline + +L'évènement se déclenche lorsqu'une application se déconnecte, quand l'appareil n'est pas connecté à Internet. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Détails + +L'évènement `offline` se déclenche lorsqu'un appareil précédemment connecté perd sa connexion au réseau, empêchant ainsi l'application d'accéder à Internet. Il s'appuie sur les mêmes informations que l'API de connexion et se déclenche lorsque la valeur de `connection.type` devient`NONE`. + +Les applications doivent généralement utiliser `document.addEventListener` pour attacher un écouteur d'événements une fois le `deviceready` événement se déclenche. + +### Exemple court + + document.addEventListener (« hors ligne », onOffline, false) ; + + function onOffline() {/ / gestion de l'événement en mode hors connexion} + + +### Notes au sujet d'iOS + +Lors du démarrage initial, le déclenchement du premier évènement offline (si applicable) prend au moins une seconde. + +### Windows Phone 7 Quirks + +Lors de l'exécution dans l'émulateur, le `connection.status` est toujours inconnu, ainsi cet événement ne fait *pas* de feu. + +### Notes au sujet de Windows Phone 8 + +L'émulateur signale le type de connexion comme `Cellular`, type qui ne change jamais, ainsi l'évènement n'est *pas* déclenché. + +## online + +L'évènement se déclenche lorsqu'une application se connecte, quand l'appareil est connecté à Internet. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Détails + +L'évènement `online` se déclenche lorsqu'un appareil précédemment non-connecté se connecte au réseau, permettant ainsi à l'application d'accéder à Internet. Il s'appuie sur les mêmes informations que l'API de connexion et se déclenche quand le `connection.type` passe de `NONE` à une autre valeur. + +Les applications doivent généralement utiliser `document.addEventListener` pour attacher un écouteur d'événements une fois le `deviceready` événement se déclenche. + +### Exemple court + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### Notes au sujet d'iOS + +Lors du démarrage initial, le déclenchement du premier évènement `online` (si applicable) prend au moins une seconde avant quoi `connection.type` vaut `UNKNOWN`. + +### Windows Phone 7 Quirks + +Lors de l'exécution dans l'émulateur, le `connection.status` est toujours inconnu, ainsi cet événement ne fait *pas* de feu. + +### Notes au sujet de Windows Phone 8 + +L'émulateur signale le type de connexion comme `Cellular` , qui ne change pas, aussi des événements ne fait *pas* de feu. diff --git a/plugins/cordova-plugin-network-information/doc/it/README.md b/plugins/cordova-plugin-network-information/doc/it/README.md new file mode 100644 index 0000000..f434359 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/it/README.md @@ -0,0 +1,190 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +Questo plugin fornisce un'implementazione di una vecchia versione dell' [API di informazioni di rete](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). Fornisce informazioni sul dispositivo cellulare e connessione wifi, e se il dispositivo dispone di una connessione internet. + +## Installazione + + cordova plugin add cordova-plugin-network-information + + +## Piattaforme supportate + + * Amazon fuoco OS + * Android + * BlackBerry 10 + * Browser + * iOS + * Windows Phone 7 e 8 + * Tizen + * Windows + * Firefox OS + +# Connessione + +> Il `connection` oggetto, esposto tramite `navigator.connection` , fornisce informazioni sulla connessione wifi e cellulare del dispositivo. + +## Proprietà + + * connection.type + +## Costanti + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## connection.type + +Questa proprietà offre un modo rapido per determinare stato della connessione di rete del dispositivo e il tipo di connessione. + +### Esempio rapido + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Cambiamento di API + +Fino a Cordova 2.3.0, il `Connection` oggetto era accessibile tramite `navigator.network.connection` , dopo che è stato cambiato in `navigator.connection` per abbinare la specifica W3C. È ancora disponibile nella sua posizione originale, ma è obsoleto e verrà rimosso alla fine. + +### iOS stranezze + + * iOS non è possibile rilevare il tipo di connessione di rete cellulare. + * `navigator.connection.type`è impostata su `Connection.CELL` per tutti i dati cellulare. + +### Stranezze di Windows Phone + + * Quando è in esecuzione nell'emulatore, rileva sempre `navigator.connection.type` come`Connection.UNKNOWN`. + + * Windows Phone non riesce a rilevare il tipo di connessione di rete cellulare. + + * `navigator.connection.type`è impostata su `Connection.CELL` per tutti i dati cellulare. + +### Stranezze di Windows + + * Quando è in esecuzione nell'emulatore Phone 8.1, sempre rileva `navigator.connection.type` come `Connection.ETHERNET`. + +### Tizen stranezze + + * Tizen può rilevare solo un WiFi o una connessione cellulare. + * `navigator.connection.type` è impostata su `Connection.CELL_2G` per tutti i dati cellulare. + +### Firefox OS stranezze + + * Sistema operativo Firefox non riesce a rilevare il tipo di connessione di rete cellulare. + * `navigator.connection.type`è impostata su `Connection.CELL` per tutti i dati cellulare. + +### Stranezze browser + + * Browser non è in grado di rilevare il tipo di connessione di rete. `navigator.connection.type` è sempre impostata su `Connection.UNKNOWN` quando si è online. + +# Eventi relativi alla rete + +## offline + +L'evento viene generato quando un'applicazione passa alla modalità offline, e il dispositivo non è connesso a Internet. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Dettagli + +Il `offline` evento viene generato quando un dispositivo precedentemente connesso perde una connessione di rete in modo che un'applicazione non è più possibile accedere a Internet. Esso si basa sulle stesse informazioni come l'API di connessione e viene generato quando il valore di `connection.type` diventa`NONE`. + +Applicazioni in genere è necessario utilizzare `document.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi. + +### Esempio rapido + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS stranezze + +Durante l'avvio iniziale, il primo evento offline (se applicabile) richiede almeno un secondo al fuoco. + +### Windows Phone 7 capricci + +Quando è in esecuzione nell'emulatore, il `connection.status` è sempre sconosciuto, così fa di questo evento *non* fuoco. + +### Windows Phone 8 stranezze + +L'emulatore riporta il tipo di connessione come `Cellular` , che non cambia, così fa l'evento *non* fuoco. + +## online + +Questo evento viene generato quando un'applicazione va online, e il dispositivo diventa collegato a Internet. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Dettagli + +Il `online` evento viene generato quando un dispositivo precedentemente scollegato riceve una connessione di rete per consentire un'accesso di applicazione a Internet. Esso si basa sulle stesse informazioni come l'API di connessione e viene attivato quando il `connection.type` cambia da `NONE` a qualsiasi altro valore. + +Applicazioni in genere è necessario utilizzare `document.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi. + +### Esempio rapido + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS stranezze + +Durante l'avvio iniziale, il primo `online` evento (se applicabile) richiede almeno un secondo al fuoco, prima che `connection.type` è`UNKNOWN`. + +### Windows Phone 7 capricci + +Quando è in esecuzione nell'emulatore, il `connection.status` è sempre sconosciuto, così fa di questo evento *non* fuoco. + +### Windows Phone 8 stranezze + +L'emulatore riporta il tipo di connessione come `Cellular` , che non cambia, quindi, non gli eventi *non* a fuoco. \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/it/index.md b/plugins/cordova-plugin-network-information/doc/it/index.md new file mode 100644 index 0000000..e191719 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/it/index.md @@ -0,0 +1,186 @@ + + +# cordova-plugin-network-information + +Questo plugin fornisce un'implementazione di una vecchia versione dell' [API di informazioni di rete][1]. Fornisce informazioni sul dispositivo cellulare e connessione wifi, e se il dispositivo dispone di una connessione internet. + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## Installazione + + cordova plugin add cordova-plugin-network-information + + +## Piattaforme supportate + +* Amazon fuoco OS +* Android +* BlackBerry 10 +* Browser +* iOS +* Windows Phone 7 e 8 +* Tizen +* Windows +* Firefox OS + +# Connessione + +> Il `connection` oggetto, esposto tramite `navigator.connection` , fornisce informazioni sulla connessione wifi e cellulare del dispositivo. + +## Proprietà + +* connection.type + +## Costanti + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## connection.type + +Questa proprietà offre un modo rapido per determinare stato della connessione di rete del dispositivo e il tipo di connessione. + +### Esempio rapido + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Cambiamento di API + +Fino a Cordova 2.3.0, il `Connection` oggetto era accessibile tramite `navigator.network.connection` , dopo che è stato cambiato in `navigator.connection` per abbinare la specifica W3C. È ancora disponibile nella sua posizione originale, ma è obsoleto e verrà rimosso alla fine. + +### iOS stranezze + +* iOS non è possibile rilevare il tipo di connessione di rete cellulare. + * `navigator.connection.type`è impostata su `Connection.CELL` per tutti i dati cellulare. + +### Stranezze di Windows Phone + +* Quando è in esecuzione nell'emulatore, rileva sempre `navigator.connection.type` come`Connection.UNKNOWN`. + +* Windows Phone non riesce a rilevare il tipo di connessione di rete cellulare. + + * `navigator.connection.type`è impostata su `Connection.CELL` per tutti i dati cellulare. + +### Stranezze di Windows + +* Quando è in esecuzione nell'emulatore Phone 8.1, sempre rileva `navigator.connection.type` come `Connection.ETHERNET`. + +### Tizen stranezze + +* Tizen può rilevare solo un WiFi o una connessione cellulare. + * `navigator.connection.type` è impostata su `Connection.CELL_2G` per tutti i dati cellulare. + +### Firefox OS stranezze + +* Sistema operativo Firefox non riesce a rilevare il tipo di connessione di rete cellulare. + * `navigator.connection.type`è impostata su `Connection.CELL` per tutti i dati cellulare. + +# Eventi relativi alla rete + +## offline + +L'evento viene generato quando un'applicazione passa alla modalità offline, e il dispositivo non è connesso a Internet. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Dettagli + +Il `offline` evento viene generato quando un dispositivo precedentemente connesso perde una connessione di rete in modo che un'applicazione non è più possibile accedere a Internet. Esso si basa sulle stesse informazioni come l'API di connessione e viene generato quando il valore di `connection.type` diventa`NONE`. + +Applicazioni in genere è necessario utilizzare `document.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi. + +### Esempio rapido + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS stranezze + +Durante l'avvio iniziale, il primo evento offline (se applicabile) richiede almeno un secondo al fuoco. + +### Windows Phone 7 capricci + +Quando è in esecuzione nell'emulatore, il `connection.status` è sempre sconosciuto, così fa di questo evento *non* fuoco. + +### Windows Phone 8 stranezze + +L'emulatore riporta il tipo di connessione come `Cellular` , che non cambia, così fa l'evento *non* fuoco. + +## online + +Questo evento viene generato quando un'applicazione va online, e il dispositivo diventa collegato a Internet. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Dettagli + +Il `online` evento viene generato quando un dispositivo precedentemente scollegato riceve una connessione di rete per consentire un'accesso di applicazione a Internet. Esso si basa sulle stesse informazioni come l'API di connessione e viene attivato quando il `connection.type` cambia da `NONE` a qualsiasi altro valore. + +Applicazioni in genere è necessario utilizzare `document.addEventListener` per fissare un listener di eventi una volta il `deviceready` evento incendi. + +### Esempio rapido + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS stranezze + +Durante l'avvio iniziale, il primo `online` evento (se applicabile) richiede almeno un secondo al fuoco, prima che `connection.type` è`UNKNOWN`. + +### Windows Phone 7 capricci + +Quando è in esecuzione nell'emulatore, il `connection.status` è sempre sconosciuto, così fa di questo evento *non* fuoco. + +### Windows Phone 8 stranezze + +L'emulatore riporta il tipo di connessione come `Cellular` , che non cambia, quindi, non gli eventi *non* a fuoco. diff --git a/plugins/cordova-plugin-network-information/doc/ja/README.md b/plugins/cordova-plugin-network-information/doc/ja/README.md new file mode 100644 index 0000000..797b741 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/ja/README.md @@ -0,0 +1,190 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +このプラグインは、古いバージョンの[ネットワーク情報 API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/)の実装を提供します。 デバイスの携帯電話や wifi 接続に関する情報を提供し、かどうか、デバイスがインターネットに接続します。 + +## インストール + + cordova plugin add cordova-plugin-network-information + + +## サポートされているプラットフォーム + + * アマゾン火 OS + * アンドロイド + * ブラックベリー 10 + * ブラウザー + * iOS + * Windows Phone 7 と 8 + * Tizen + * Windows + * Firefox の OS + +# Connection + +> `connection`オブジェクトによって公開されて `navigator.connection` 、デバイスの携帯電話や wifi 接続に関する情報を提供します。 + +## プロパティ + + * connection.type + +## 定数 + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## connection.type + +このプロパティはデバイスのネットワーク接続状態を確認する速い方法を提供し、接続の種類。 + +### 簡単な例 + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API の変更 + +コルドバ 2.3.0、まで、 `Connection` 経由でアクセスされたオブジェクトが `navigator.network.connection` 、それに変更されましたが後 `navigator.connection` W3C の仕様に一致します。 それはまだ元の場所は廃止され、最終的に削除されます。 + +### iOS の癖 + + * iOS は、携帯電話のネットワーク接続の種類を検出できません。 + * `navigator.connection.type`設定する `Connection.CELL` すべての携帯電話データの。 + +### Windows Phone の癖 + + * エミュレーターで実行しているときを常に検出 `navigator.connection.type` として`Connection.UNKNOWN`. + + * Windows Phone 携帯電話ネットワーク接続の種類を検出できません。 + + * `navigator.connection.type`設定する `Connection.CELL` すべての携帯電話データの。 + +### Windows の癖 + + * 電話 8.1 エミュレーターで実行する場合は、常に `Connection.ETHERNET` として `navigator.connection.type` を検出します. + +### Tizen の癖 + + * Tizen には、WiFi または携帯電話の接続だけを検出できます。 + * `navigator.connection.type` は、すべての携帯電話のデータを `Connection.CELL_2G` に設定されます。 + +### Firefox OS 癖 + + * Firefox の OS は、携帯電話のネットワーク接続の種類を検出できません。 + * `navigator.connection.type`設定する `Connection.CELL` すべての携帯電話データの。 + +### ブラウザーの癖 + + * ブラウザーは、ネットワーク接続の種類を検出できません。 `navigator.connection.type`は、 `Connection.UNKNOWN`オンライン時に常に設定されます。 + +# ネットワーク関連のイベント + +## offline + +アプリケーションがオフラインになり、デバイスがインターネットに接続されていないときに発生します。 + + document.addEventListener("offline", yourCallbackFunction, false); + + +### 詳細 + +`offline`アプリケーションはもはや、インターネットにアクセスできるように、以前接続されたデバイスは、ネットワーク接続が失われたときに発生します。 接続 API と同じ情報に依存しており、火災時の値 `connection.type` になります。`NONE`. + +通常アプリケーションに使用する必要があります `document.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。 + +### 簡単な例 + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS の癖 + +初回起動時 (当てはまる場合) の最初のオフライン イベントは火に 1 秒以上かかります。 + +### Windows Phone 7 の癖 + +エミュレーターで実行しているとき、 `connection.status` は常に知られている、このイベントは*ない*火。 + +### Windows Phone 8 癖 + +エミュレーターと接続の種類のレポート `Cellular` は変化しません、イベントは*ない*火。 + +## online + +アプリケーションは、オンラインになるし、デバイスがインターネットに接続するときに発生します。 + + document.addEventListener("online", yourCallbackFunction, false); + + +### 詳細 + +`online`以前接続されていないデバイスが、インターネットへのアプリケーション アクセスを許可するネットワーク接続を受信するときに発生します。 接続 API と同じ情報に依存しており、場合に適用されます、 `connection.type` から変更 `NONE` 以外の値にします。 + +通常アプリケーションに使用する必要があります `document.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。 + +### 簡単な例 + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS の癖 + +初回起動時には、最初の `online` (当てはまる場合) イベントが少なくとも火を前に第 2 `connection.type` は`UNKNOWN`. + +### Windows Phone 7 の癖 + +エミュレーターで実行しているとき、 `connection.status` は常に知られている、このイベントは*ない*火。 + +### Windows Phone 8 癖 + +エミュレーターと接続の種類のレポート `Cellular` は変化しません、イベントは*ない*火。 \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/ja/index.md b/plugins/cordova-plugin-network-information/doc/ja/index.md new file mode 100644 index 0000000..71b6f82 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/ja/index.md @@ -0,0 +1,186 @@ + + +# cordova-plugin-network-information + +このプラグインは、古いバージョンの[ネットワーク情報 API][1]の実装を提供します。 デバイスの携帯電話や wifi 接続に関する情報を提供し、かどうか、デバイスがインターネットに接続します。 + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## インストール + + cordova plugin add cordova-plugin-network-information + + +## サポートされているプラットフォーム + +* アマゾン火 OS +* アンドロイド +* ブラックベリー 10 +* ブラウザー +* iOS +* Windows Phone 7 と 8 +* Tizen +* Windows +* Firefox の OS + +# Connection + +> `connection`オブジェクトによって公開されて `navigator.connection` 、デバイスの携帯電話や wifi 接続に関する情報を提供します。 + +## プロパティ + +* connection.type + +## 定数 + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## connection.type + +このプロパティはデバイスのネットワーク接続状態を確認する速い方法を提供し、接続の種類。 + +### 簡単な例 + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API の変更 + +コルドバ 2.3.0、まで、 `Connection` 経由でアクセスされたオブジェクトが `navigator.network.connection` 、それに変更されましたが後 `navigator.connection` W3C の仕様に一致します。 それはまだ元の場所は廃止され、最終的に削除されます。 + +### iOS の癖 + +* iOS は、携帯電話のネットワーク接続の種類を検出できません。 + * `navigator.connection.type`設定する `Connection.CELL` すべての携帯電話データの。 + +### Windows Phone の癖 + +* エミュレーターで実行しているときを常に検出 `navigator.connection.type` として`Connection.UNKNOWN`. + +* Windows Phone 携帯電話ネットワーク接続の種類を検出できません。 + + * `navigator.connection.type`設定する `Connection.CELL` すべての携帯電話データの。 + +### Windows の癖 + +* 電話 8.1 エミュレーターで実行する場合は、常に `Connection.ETHERNET` として `navigator.connection.type` を検出します. + +### Tizen の癖 + +* Tizen には、WiFi または携帯電話の接続だけを検出できます。 + * `navigator.connection.type` は、すべての携帯電話のデータを `Connection.CELL_2G` に設定されます。 + +### Firefox OS 癖 + +* Firefox の OS は、携帯電話のネットワーク接続の種類を検出できません。 + * `navigator.connection.type`設定する `Connection.CELL` すべての携帯電話データの。 + +# ネットワーク関連のイベント + +## offline + +アプリケーションがオフラインになり、デバイスがインターネットに接続されていないときに発生します。 + + document.addEventListener("offline", yourCallbackFunction, false); + + +### 詳細 + +`offline`アプリケーションはもはや、インターネットにアクセスできるように、以前接続されたデバイスは、ネットワーク接続が失われたときに発生します。 接続 API と同じ情報に依存しており、火災時の値 `connection.type` になります。`NONE`. + +通常アプリケーションに使用する必要があります `document.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。 + +### 簡単な例 + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS の癖 + +初回起動時 (当てはまる場合) の最初のオフライン イベントは火に 1 秒以上かかります。 + +### Windows Phone 7 の癖 + +エミュレーターで実行しているとき、 `connection.status` は常に知られている、このイベントは*ない*火。 + +### Windows Phone 8 癖 + +エミュレーターと接続の種類のレポート `Cellular` は変化しません、イベントは*ない*火。 + +## online + +アプリケーションは、オンラインになるし、デバイスがインターネットに接続するときに発生します。 + + document.addEventListener("online", yourCallbackFunction, false); + + +### 詳細 + +`online`以前接続されていないデバイスが、インターネットへのアプリケーション アクセスを許可するネットワーク接続を受信するときに発生します。 接続 API と同じ情報に依存しており、場合に適用されます、 `connection.type` から変更 `NONE` 以外の値にします。 + +通常アプリケーションに使用する必要があります `document.addEventListener` 一度のイベント リスナーをアタッチし、 `deviceready` イベントが発生します。 + +### 簡単な例 + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS の癖 + +初回起動時には、最初の `online` (当てはまる場合) イベントが少なくとも火を前に第 2 `connection.type` は`UNKNOWN`. + +### Windows Phone 7 の癖 + +エミュレーターで実行しているとき、 `connection.status` は常に知られている、このイベントは*ない*火。 + +### Windows Phone 8 癖 + +エミュレーターと接続の種類のレポート `Cellular` は変化しません、イベントは*ない*火。 diff --git a/plugins/cordova-plugin-network-information/doc/ko/README.md b/plugins/cordova-plugin-network-information/doc/ko/README.md new file mode 100644 index 0000000..a667539 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/ko/README.md @@ -0,0 +1,190 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +이 플러그인 [네트워크 정보 API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/)의 이전 버전에 대 한 구현을 제공합니다. 소자의 셀룰러와 와이파이 연결에 대 한 정보를 제공 합니다 장치는 인터넷 연결에 있는지 여부. + +## 설치 + + cordova plugin add cordova-plugin-network-information + + +## 지원 되는 플랫폼 + + * 아마존 화재 운영 체제 + * 안 드 로이드 + * 블랙베리 10 + * 브라우저 + * iOS + * Windows Phone 7과 8 + * Tizen + * 윈도우 + * Firefox 운영 체제 + +# 연결 + +> `connection`개체를 통해 노출 `navigator.connection` , 소자의 셀룰러와 와이파이 연결에 대 한 정보를 제공 합니다. + +## 속성 + + * connection.type + +## 상수 + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## connection.type + +이 디바이스의 네트워크 연결 상태를 확인 하는 빠른 방법을 제공 합니다 및 연결의 종류. + +### 빠른 예제 + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API 변경 + +코르 도우 바 2.3.0까지 `Connection` 개체를 통해 액세스 했습니다 `navigator.network.connection` , 후에 변경 된 `navigator.connection` W3C 사양에 맞게. 그것은 그것의 원래 위치에 계속 사용할 수 하지만 사용 되지 않습니다 및 결국 제거 될 것 이다. + +### iOS 단점 + + * iOS는 셀룰러 네트워크 연결의 종류를 감지할 수 없습니다. + * `navigator.connection.type`로 설정 된 `Connection.CELL` 모든 셀룰러 데이터에 대 한. + +### Windows Phone 단점 + + * 에뮬레이터에서 실행할 때 항상 검색 `navigator.connection.type` 으로`Connection.UNKNOWN`. + + * Windows Phone 셀룰러 네트워크 연결 유형을 검색할 수 없습니다. + + * `navigator.connection.type`로 설정 된 `Connection.CELL` 모든 셀룰러 데이터에 대 한. + +### 윈도우 특수 + + * 전화 8.1 에뮬레이터에서 실행 하는 경우 항상 `Connection.ETHERNET`로 `navigator.connection.type`를 감지합니다. + +### Tizen 특수 + + * Tizen은 와이파이 또는 휴대 전화 연결에만 검색할 수 있습니다. + * `navigator.connection.type`는 모든 셀룰러 데이터에 대 한 `Connection.CELL_2G`로 설정 됩니다. + +### 파이어 폭스 OS 단점 + + * 파이어 폭스 OS 셀룰러 네트워크 연결 유형을 검색할 수 없습니다. + * `navigator.connection.type`로 설정 된 `Connection.CELL` 모든 셀룰러 데이터에 대 한. + +### 브라우저 만지면 + + * 브라우저는 네트워크 연결의 종류를 검색할 수 없습니다. `navigator.connection.type` `Connection.UNKNOWN` 때 온라인으로 항상 설정 됩니다. + +# 네트워크 관련 이벤트 + +## offline + +이벤트가 발생 하면 응용 프로그램 오프 라인, 이동 및 장치가 인터넷에 연결 되어 있지. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### 세부 정보 + +`offline`이벤트가 발생 하면 응용 프로그램이 더 이상 인터넷에 액세스할 수 있도록 이전 연결 된 장치가 네트워크 연결 손실. 그것은 연결 API와 동일한 정보에 의존 하 고 경우의 값 `connection.type` 된다`NONE`. + +일반적으로 응용 프로그램을 사용 해야 합니다 `document.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다. + +### 빠른 예제 + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS 단점 + +처음 시작 하는 동안 첫 번째 오프 라인 이벤트 (있는 경우)를 적어도 초를 걸립니다. + +### Windows Phone 7 단점 + +에뮬레이터에서 실행 하는 경우는 `connection.status` 항상 불명 하다, 그래서이 이벤트는 *없는* 불. + +### Windows Phone 8 단점 + +에뮬레이터도 연결 형식을 보고 `Cellular` 는 변경 되지 않습니다, 그래서 이벤트 않습니다 *하지* 불. + +## online + +응용 프로그램은 온라인 및 장치가 인터넷에 연결 된다 때이 이벤트가 발생 합니다. + + document.addEventListener("online", yourCallbackFunction, false); + + +### 세부 정보 + +`online`이전 연결 되지 않은 장치는 인터넷에 대 한 응용 프로그램 액세스를 허용 하도록 네트워크 연결을 받을 때 이벤트가 발생 합니다. 그것은 연결 API와 동일한 정보에 의존 하 고 경우에 `connection.type` 에서 변경 `NONE` 다른 값으로. + +일반적으로 응용 프로그램을 사용 해야 합니다 `document.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다. + +### 빠른 예제 + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS 단점 + +처음 시작 하는 동안 첫 번째 `online` 이벤트 (있는 경우) 이전에 불 초 걸립니다 이상 `connection.type` 입니다`UNKNOWN`. + +### Windows Phone 7 단점 + +에뮬레이터에서 실행 하는 경우는 `connection.status` 항상 불명 하다, 그래서이 이벤트는 *없는* 불. + +### Windows Phone 8 단점 + +에뮬레이터도 연결 형식을 보고 `Cellular` 는 변경 되지 않습니다, 그래서 이벤트 않습니다 *하지* 불. \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/ko/index.md b/plugins/cordova-plugin-network-information/doc/ko/index.md new file mode 100644 index 0000000..cb4c727 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/ko/index.md @@ -0,0 +1,186 @@ + + +# cordova-plugin-network-information + +이 플러그인 [네트워크 정보 API][1]의 이전 버전에 대 한 구현을 제공합니다. 소자의 셀룰러와 와이파이 연결에 대 한 정보를 제공 합니다 장치는 인터넷 연결에 있는지 여부. + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## 설치 + + cordova plugin add cordova-plugin-network-information + + +## 지원 되는 플랫폼 + +* 아마존 화재 운영 체제 +* 안 드 로이드 +* 블랙베리 10 +* 브라우저 +* iOS +* Windows Phone 7과 8 +* Tizen +* 윈도우 +* Firefox 운영 체제 + +# 연결 + +> `connection`개체를 통해 노출 `navigator.connection` , 소자의 셀룰러와 와이파이 연결에 대 한 정보를 제공 합니다. + +## 속성 + +* connection.type + +## 상수 + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## connection.type + +이 디바이스의 네트워크 연결 상태를 확인 하는 빠른 방법을 제공 합니다 및 연결의 종류. + +### 빠른 예제 + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API 변경 + +코르 도우 바 2.3.0까지 `Connection` 개체를 통해 액세스 했습니다 `navigator.network.connection` , 후에 변경 된 `navigator.connection` W3C 사양에 맞게. 그것은 그것의 원래 위치에 계속 사용할 수 하지만 사용 되지 않습니다 및 결국 제거 될 것 이다. + +### iOS 단점 + +* iOS는 셀룰러 네트워크 연결의 종류를 감지할 수 없습니다. + * `navigator.connection.type`로 설정 된 `Connection.CELL` 모든 셀룰러 데이터에 대 한. + +### Windows Phone 단점 + +* 에뮬레이터에서 실행할 때 항상 검색 `navigator.connection.type` 으로`Connection.UNKNOWN`. + +* Windows Phone 셀룰러 네트워크 연결 유형을 검색할 수 없습니다. + + * `navigator.connection.type`로 설정 된 `Connection.CELL` 모든 셀룰러 데이터에 대 한. + +### 윈도우 특수 + +* 전화 8.1 에뮬레이터에서 실행 하는 경우 항상 `Connection.ETHERNET`로 `navigator.connection.type`를 감지합니다. + +### Tizen 특수 + +* Tizen은 와이파이 또는 휴대 전화 연결에만 검색할 수 있습니다. + * `navigator.connection.type`는 모든 셀룰러 데이터에 대 한 `Connection.CELL_2G`로 설정 됩니다. + +### 파이어 폭스 OS 단점 + +* 파이어 폭스 OS 셀룰러 네트워크 연결 유형을 검색할 수 없습니다. + * `navigator.connection.type`로 설정 된 `Connection.CELL` 모든 셀룰러 데이터에 대 한. + +# 네트워크 관련 이벤트 + +## offline + +이벤트가 발생 하면 응용 프로그램 오프 라인, 이동 및 장치가 인터넷에 연결 되어 있지. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### 세부 정보 + +`offline`이벤트가 발생 하면 응용 프로그램이 더 이상 인터넷에 액세스할 수 있도록 이전 연결 된 장치가 네트워크 연결 손실. 그것은 연결 API와 동일한 정보에 의존 하 고 경우의 값 `connection.type` 된다`NONE`. + +일반적으로 응용 프로그램을 사용 해야 합니다 `document.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다. + +### 빠른 예제 + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS 단점 + +처음 시작 하는 동안 첫 번째 오프 라인 이벤트 (있는 경우)를 적어도 초를 걸립니다. + +### Windows Phone 7 단점 + +에뮬레이터에서 실행 하는 경우는 `connection.status` 항상 불명 하다, 그래서이 이벤트는 *없는* 불. + +### Windows Phone 8 단점 + +에뮬레이터도 연결 형식을 보고 `Cellular` 는 변경 되지 않습니다, 그래서 이벤트 않습니다 *하지* 불. + +## online + +응용 프로그램은 온라인 및 장치가 인터넷에 연결 된다 때이 이벤트가 발생 합니다. + + document.addEventListener("online", yourCallbackFunction, false); + + +### 세부 정보 + +`online`이전 연결 되지 않은 장치는 인터넷에 대 한 응용 프로그램 액세스를 허용 하도록 네트워크 연결을 받을 때 이벤트가 발생 합니다. 그것은 연결 API와 동일한 정보에 의존 하 고 경우에 `connection.type` 에서 변경 `NONE` 다른 값으로. + +일반적으로 응용 프로그램을 사용 해야 합니다 `document.addEventListener` 한번 이벤트 리스너를 연결 하는 `deviceready` 이벤트가 발생 합니다. + +### 빠른 예제 + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS 단점 + +처음 시작 하는 동안 첫 번째 `online` 이벤트 (있는 경우) 이전에 불 초 걸립니다 이상 `connection.type` 입니다`UNKNOWN`. + +### Windows Phone 7 단점 + +에뮬레이터에서 실행 하는 경우는 `connection.status` 항상 불명 하다, 그래서이 이벤트는 *없는* 불. + +### Windows Phone 8 단점 + +에뮬레이터도 연결 형식을 보고 `Cellular` 는 변경 되지 않습니다, 그래서 이벤트 않습니다 *하지* 불. diff --git a/plugins/cordova-plugin-network-information/doc/pl/README.md b/plugins/cordova-plugin-network-information/doc/pl/README.md new file mode 100644 index 0000000..4b66cbb --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/pl/README.md @@ -0,0 +1,190 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +Wtyczka stanowi implementację starą wersję [API informacji w sieci](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). Udostępnia informacje na temat urządzenia komórkowe i wifi połączenie, i czy urządzenie ma połączenie z Internetem. + +## Instalacja + + cordova plugin add cordova-plugin-network-information + + +## Obsługiwane platformy + + * Amazon Fire OS + * Android + * BlackBerry 10 + * Przeglądarka + * iOS + * Windows Phone 7 i 8 + * Tizen + * Windows + * Firefox OS + +# Połączenie + +> `connection`Obiektu, wystawiony przez `navigator.connection` , zawiera informacje o połączeniu urządzenia komórkowe i wifi. + +## Właściwości + + * Connection.Type + +## Stałe + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## Connection.Type + +Oferuje szybki sposób ustalić stan połączenia sieciowego urządzenia i typ połączenia. + +### Szybki przykład + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Zmiana interfejsu API + +Do Cordova 2.3.0 `Connection` obiekt uzyskano za pośrednictwem `navigator.network.connection` , po którym został zmieniony na `navigator.connection` odpowiadać specyfikacji W3C. To jest nadal dostępne w jego oryginalnej lokalizacji, ale jest niezalecane i zostaną ostatecznie usunięte. + +### Dziwactwa iOS + + * iOS nie może wykryć typ połączenia w sieci komórkowej. + * `navigator.connection.type`jest zestaw `Connection.CELL` dla wszystkich komórek danych. + +### Windows Phone dziwactwa + + * Po uruchomieniu w emulatorze, zawsze wykrywa `navigator.connection.type` jako`Connection.UNKNOWN`. + + * Windows Phone nie może wykryć typ połączenia w sieci komórkowej. + + * `navigator.connection.type`jest zestaw `Connection.CELL` dla wszystkich komórek danych. + +### Windows dziwactwa + + * Po uruchomieniu w emulatorze telefonu 8.1, zawsze wykrywa `navigator.connection.type` jako `Connection.ETHERNET`. + +### Dziwactwa Tizen + + * Tizen można tylko dostrzegać Wi-Fi lub połączenia komórkowe. + * `Navigator.Connection.Type` jest zestaw do `Connection.CELL_2G` dla wszystkich komórek danych. + +### Firefox OS dziwactwa + + * Firefox OS nie można wykryć typ połączenia w sieci komórkowej. + * `navigator.connection.type`jest zestaw `Connection.CELL` dla wszystkich komórek danych. + +### Quirks przeglądarki + + * Przeglądarka nie może wykryć typ połączenia sieciowego. `Navigator.Connection.Type` jest zawsze zestaw do `Connection.UNKNOWN` podczas online. + +# Zdarzenia związane z sieci + +## offline + +Zdarzenie odpala gdy aplikacja przejdzie do trybu offline, a urządzenie nie jest podłączone do Internetu. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Szczegóły + +`offline`Zdarzenie fires po wcześniej podłączone urządzenie traci połączenia z siecią, dzięki czemu aplikacja może już dostęp do Internetu. Opiera się na te same informacje połączenia API i gdy odpalam wartość `connection.type` staje się`NONE`. + +Aplikacje zwykle należy użyć `document.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia. + +### Szybki przykład + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### Dziwactwa iOS + +Podczas uruchamiania systemu pierwsza impreza offline (jeśli dotyczy) trwa co najmniej drugi ognia. + +### Dziwactwa Windows Phone 7 + +Po uruchomieniu w emulatorze, `connection.status` zawsze jest nieznana, więc to wydarzenie *nie* ogień. + +### Windows Phone 8 dziwactwa + +Emulator raporty typ połączenia, jako `Cellular` , co nie zmienia, więc zdarzenie *nie* ogień. + +## online + +Wydarzenie to odpala gdy aplikacja przechodzi w tryb online i urządzenie staje się połączenie z Internetem. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Szczegóły + +`online`Zdarzenie odpala gdy wcześniej niezwiązane urządzenie odbiera połączenie sieciowe, aby umożliwić aplikacji dostęp do Internetu. Opiera się na te same informacje połączenia API i gdy odpalam `connection.type` zmienia się z `NONE` na inną wartość. + +Aplikacje zwykle należy użyć `document.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia. + +### Szybki przykład + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### Dziwactwa iOS + +Podczas uruchamiania systemu pierwszy `online` zdarzenia (w stosownych przypadkach) zajmuje co najmniej drugie ognia, przed którym `connection.type` jest`UNKNOWN`. + +### Dziwactwa Windows Phone 7 + +Po uruchomieniu w emulatorze, `connection.status` zawsze jest nieznana, więc to wydarzenie *nie* ogień. + +### Windows Phone 8 dziwactwa + +Emulator sprawozdania jako typ połączenia `Cellular` , które nie zmienia, więc wydarzenia czy *nie* ogień. \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/pl/index.md b/plugins/cordova-plugin-network-information/doc/pl/index.md new file mode 100644 index 0000000..a42b973 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/pl/index.md @@ -0,0 +1,186 @@ + + +# cordova-plugin-network-information + +Wtyczka stanowi implementację starą wersję [API informacji w sieci][1]. Udostępnia informacje na temat urządzenia komórkowe i wifi połączenie, i czy urządzenie ma połączenie z Internetem. + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## Instalacja + + cordova plugin add cordova-plugin-network-information + + +## Obsługiwane platformy + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Przeglądarka +* iOS +* Windows Phone 7 i 8 +* Tizen +* Windows +* Firefox OS + +# Połączenie + +> `connection`Obiektu, wystawiony przez `navigator.connection` , zawiera informacje o połączeniu urządzenia komórkowe i wifi. + +## Właściwości + +* Connection.Type + +## Stałe + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## Connection.Type + +Oferuje szybki sposób ustalić stan połączenia sieciowego urządzenia i typ połączenia. + +### Szybki przykład + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Zmiana interfejsu API + +Do Cordova 2.3.0 `Connection` obiekt uzyskano za pośrednictwem `navigator.network.connection` , po którym został zmieniony na `navigator.connection` odpowiadać specyfikacji W3C. To jest nadal dostępne w jego oryginalnej lokalizacji, ale jest niezalecane i zostaną ostatecznie usunięte. + +### Dziwactwa iOS + +* iOS nie może wykryć typ połączenia w sieci komórkowej. + * `navigator.connection.type`jest zestaw `Connection.CELL` dla wszystkich komórek danych. + +### Windows Phone dziwactwa + +* Po uruchomieniu w emulatorze, zawsze wykrywa `navigator.connection.type` jako`Connection.UNKNOWN`. + +* Windows Phone nie może wykryć typ połączenia w sieci komórkowej. + + * `navigator.connection.type`jest zestaw `Connection.CELL` dla wszystkich komórek danych. + +### Windows dziwactwa + +* Po uruchomieniu w emulatorze telefonu 8.1, zawsze wykrywa `navigator.connection.type` jako `Connection.ETHERNET`. + +### Dziwactwa Tizen + +* Tizen można tylko dostrzegać Wi-Fi lub połączenia komórkowe. + * `Navigator.Connection.Type` jest zestaw do `Connection.CELL_2G` dla wszystkich komórek danych. + +### Firefox OS dziwactwa + +* Firefox OS nie można wykryć typ połączenia w sieci komórkowej. + * `navigator.connection.type`jest zestaw `Connection.CELL` dla wszystkich komórek danych. + +# Zdarzenia związane z sieci + +## offline + +Zdarzenie odpala gdy aplikacja przejdzie do trybu offline, a urządzenie nie jest podłączone do Internetu. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Szczegóły + +`offline`Zdarzenie fires po wcześniej podłączone urządzenie traci połączenia z siecią, dzięki czemu aplikacja może już dostęp do Internetu. Opiera się na te same informacje połączenia API i gdy odpalam wartość `connection.type` staje się`NONE`. + +Aplikacje zwykle należy użyć `document.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia. + +### Szybki przykład + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### Dziwactwa iOS + +Podczas uruchamiania systemu pierwsza impreza offline (jeśli dotyczy) trwa co najmniej drugi ognia. + +### Dziwactwa Windows Phone 7 + +Po uruchomieniu w emulatorze, `connection.status` zawsze jest nieznana, więc to wydarzenie *nie* ogień. + +### Windows Phone 8 dziwactwa + +Emulator raporty typ połączenia, jako `Cellular` , co nie zmienia, więc zdarzenie *nie* ogień. + +## online + +Wydarzenie to odpala gdy aplikacja przechodzi w tryb online i urządzenie staje się połączenie z Internetem. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Szczegóły + +`online`Zdarzenie odpala gdy wcześniej niezwiązane urządzenie odbiera połączenie sieciowe, aby umożliwić aplikacji dostęp do Internetu. Opiera się na te same informacje połączenia API i gdy odpalam `connection.type` zmienia się z `NONE` na inną wartość. + +Aplikacje zwykle należy użyć `document.addEventListener` Aby dołączyć słuchacza raz `deviceready` pożary zdarzenia. + +### Szybki przykład + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### Dziwactwa iOS + +Podczas uruchamiania systemu pierwszy `online` zdarzenia (w stosownych przypadkach) zajmuje co najmniej drugie ognia, przed którym `connection.type` jest`UNKNOWN`. + +### Dziwactwa Windows Phone 7 + +Po uruchomieniu w emulatorze, `connection.status` zawsze jest nieznana, więc to wydarzenie *nie* ogień. + +### Windows Phone 8 dziwactwa + +Emulator sprawozdania jako typ połączenia `Cellular` , które nie zmienia, więc wydarzenia czy *nie* ogień. diff --git a/plugins/cordova-plugin-network-information/doc/ru/index.md b/plugins/cordova-plugin-network-information/doc/ru/index.md new file mode 100644 index 0000000..481c1b1 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/ru/index.md @@ -0,0 +1,182 @@ + + +# cordova-plugin-network-information + +Этот плагин обеспечивает реализацию старой версии [API Сетевой информации][1]. Он предоставляет информацию о сотовых и Wi-Fi подключениях устройства, и информацию имеет ли устройство подключение к Интернету. + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## Установка + + cordova plugin add cordova-plugin-network-information + + +## Поддерживаемые платформы + +* Amazon Fire OS +* Android +* BlackBerry 10 +* Браузер +* iOS +* Windows Phone 7 и 8 +* Tizen +* Windows 8 +* Firefox OS + +# Connection + +> Объект `connection`, доступный через `navigator.connection`, предоставляет информацию о сотовых и wifi подключениях устройства. + +## Свойства + +* connection.type + +## Константы + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## connection.type + +Это свойство предоставляет быстрый способ для определения состояния подключения устройства к сети и тип этого подключения. + +### Краткий пример + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### Изменения в API + +До Cordova 2.3.0 объект `Connection` был доступен через `navigator.network.connection`, после чего это свойство было изменено на `navigator.connection` в соответствии со спецификацией консорциума W3C. Он все еще доступен в его исходном расположении, но это расположение является устаревшим и в конечном итоге будет удалено. + +### Особенности iOS + +* iOS не может определить тип подключения к сотовой сети. + * `navigator.connection.type` имеет значение `Connection.CELL` для всех сотовых данных. + +### Особенности Windows Phone + +* Когда работает в эмуляторе, тип подключения всегда определяется `navigator.connection.type` как `Connection.UNKNOWN`. + +* Windows Phone не может определить тип подключения к сотовой сети. + + * `navigator.connection.type` имеет значение `Connection.CELL` для всех сотовых данных. + +### Особенности Tizen + +* Tizen может обнаружить только соединения Wi-Fi или наличие сотовой связи. + * `navigator.connection.type` имеет значение `Connection.CELL_2G` для всех сотовых данных. + +### Особенности Firefox OS + +* Firefox OS не может определить тип подключения к сотовой сети. + * `navigator.connection.type` имеет значение `Connection.CELL` для всех сотовых данных. + +# События, связанные с сетью + +## offline + +Событие возникает, когда приложение переходит в автономный режим, и устройство не подключено к сети Интернет. + + document.addEventListener("offline", yourCallbackFunction, false); + + +### Подробности + +Событие `offline` возникает, когда ранее подключенное устройство теряет подключение к сети, так что приложение больше не может получить доступ к Интернет. Он опирается на ту же информацию, что и Connection API и срабатывает, когда значение `connection.type` становится равным `NONE`. + +Приложения обычно должно использовать `window.addEventListener` чтобы добавить обработчик события после того как произойдет событие `deviceready`. + +### Краткий пример + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### Особенности iOS + +Во время первоначального запуска первому событию offline (если применимо) требуется по крайней мере секунду на срабатывание. + +### Особенности Windows Phone 7 + +Когда работает в эмуляторе, `connection.status` всегда неизвестен, так что это событие *не* срабатывает. + +### Особенности Windows Phone 8 + +Эмулятор сообщает тип подключения как `Cellular` , которое не меняется, поэтому событие не *не* срабатывает. + +## online + +Это событие возникает, когда приложение выходит в онлайн, и устройство подключается к Интернету. + + document.addEventListener("online", yourCallbackFunction, false); + + +### Подробности + +Событие `online` возникает, когда ранее не подключенное к сети устройство получает сетевое подключение, разрешающее приложению доступ к Интернету. Оно опирается на ту же информацию, Connection API и вызывается когда `connection.type` меняется с `NONE` в любое другое значение. + +Приложения обычно должны использовать `window.addEventListener` чтобы добавить обработчик события после того как произойдет событие `deviceready`. + +### Краткий пример + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### Особенности iOS + +Во время первоначального запуска первое событие `online` (если применимо) занимает по меньшей мере секунду на срабатывание, до этого момента `connection.type` является равным `UNKNOWN`. + +### Особенности Windows Phone 7 + +Когда работает в эмуляторе, `connection.status` всегда неизвестен, так что это событие *не* срабатывает. + +### Особенности Windows Phone 8 + +Эмулятор сообщает тип подключения как `Cellular` , которое не меняется, поэтому событие не *не* срабатывает. diff --git a/plugins/cordova-plugin-network-information/doc/zh/README.md b/plugins/cordova-plugin-network-information/doc/zh/README.md new file mode 100644 index 0000000..09e11e7 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/zh/README.md @@ -0,0 +1,190 @@ + + +# cordova-plugin-network-information + +[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) + +這個外掛程式提供的舊版本的[網路資訊 API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/)實現的。 它提供了有關該設備的行動電話和無線網路連接的資訊和設備是否已連接到 internet。 + +## 安裝 + + cordova plugin add cordova-plugin-network-information + + +## 支援的平臺 + + * 亞馬遜火 OS + * Android 系統 + * 黑莓 10 + * 瀏覽器 + * iOS + * Windows Phone 7 和 8 + * Tizen + * Windows + * 火狐瀏覽器作業系統 + +# 連接 + +> `connection`物件,通過公開 `navigator.connection` ,提供了有關該設備的行動電話和無線網路連接的資訊。 + +## 屬性 + + * connection.type + +## 常量 + + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + +## connection.type + +此屬性提供快速的方法來確定設備的網路連接狀態,和連線類型。 + +### 快速的示例 + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API 更改 + +科爾多瓦 2.3.0,直到 `Connection` 物件的訪問通過 `navigator.network.connection` 後才改為其中, `navigator.connection` 以匹配的 W3C 規範。 它在其原始位置,是仍然可用,但已廢棄,最終將被刪除。 + +### iOS 的怪癖 + + * iOS 無法檢測到蜂窩網路連接的類型。 + * `navigator.connection.type`設置為 `Connection.CELL` 為所有蜂窩資料。 + +### Windows Phone 怪癖 + + * 當運行在模擬器中,總能檢測到 `navigator.connection.type` 作為`Connection.UNKNOWN`. + + * Windows Phone 不能檢測的蜂窩網路連接的類型。 + + * `navigator.connection.type`設置為 `Connection.CELL` 為所有蜂窩資料。 + +### Windows 的怪癖 + + * 當電話 8.1 在模擬器中運行,總能檢測到 `navigator.connection.type` 作為 `Connection.ETHERNET`. + +### Tizen 怪癖 + + * 泰只能檢測一個 WiFi 或細胞連接。 + * `navigator.connection.type` 是所有蜂窩資料設置為 `Connection.CELL_2G`。 + +### 火狐瀏覽器作業系統的怪癖 + + * 火狐瀏覽器作業系統無法檢測到蜂窩網路連接的類型。 + * `navigator.connection.type`設置為 `Connection.CELL` 為所有蜂窩資料。 + +### 瀏覽器的怪癖 + + * 瀏覽器無法檢測到網路連接的類型。 `navigator.connection.type`總是被設置為`Connection.UNKNOWN`時線上。 + +# 與網路相關的事件 + +## offline + +當一個應用程式離線時,與該設備未連接到互聯網時,將觸發該事件。 + + document.addEventListener("offline", yourCallbackFunction, false); + + +### 詳細資訊 + +`offline`以前連接的設備失去網路連接,這樣,應用程式不再可以訪問互聯網時激發的事件。 它依賴于連接 API,相同的資訊和火災時的值 `connection.type` 變得`NONE`. + +應用程式通常應使用 `document.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。 + +### 快速的示例 + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS 的怪癖 + +在初始啟動期間,第一次離線事件 (如果適用) 需至少一秒的火。 + +### Windows Phone 7 的怪癖 + +當運行在模擬器中, `connection.status` 始終是未知的因此此事件不會*不*火。 + +### Windows Phone 8 怪癖 + +模擬程式報告連線類型為 `Cellular` ,而不會更改,所以該事件不會*不*火。 + +## online + +當應用程式進入線上狀態,和該設備將成為連接到互聯網時觸發此事件。 + + document.addEventListener("online", yourCallbackFunction, false); + + +### 詳細資訊 + +`online`當先前連接的行動裝置接收到一個網路連接以允許應用程式訪問互聯網時激發的事件。 它依賴于連接 API,相同的資訊,則會激發 `connection.type` 從更改 `NONE` 為任何其他值。 + +應用程式通常應使用 `document.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。 + +### 快速的示例 + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS 的怪癖 + +在初始啟動期間第一次 `online` 事件 (如果適用),至少需一秒的火災之前的, `connection.type` 是`UNKNOWN`. + +### Windows Phone 7 的怪癖 + +當運行在模擬器中, `connection.status` 始終是未知的因此此事件不會*不*火。 + +### Windows Phone 8 怪癖 + +模擬程式報告連線類型為 `Cellular` ,而不會更改,所以事件不**火。 \ No newline at end of file diff --git a/plugins/cordova-plugin-network-information/doc/zh/index.md b/plugins/cordova-plugin-network-information/doc/zh/index.md new file mode 100644 index 0000000..2041467 --- /dev/null +++ b/plugins/cordova-plugin-network-information/doc/zh/index.md @@ -0,0 +1,186 @@ + + +# cordova-plugin-network-information + +這個外掛程式提供的舊版本的[網路資訊 API][1]實現的。 它提供了有關該設備的行動電話和無線網路連接的資訊和設備是否已連接到 internet。 + + [1]: http://www.w3.org/TR/2011/WD-netinfo-api-20110607/ + +## 安裝 + + cordova plugin add cordova-plugin-network-information + + +## 支援的平臺 + +* 亞馬遜火 OS +* Android 系統 +* 黑莓 10 +* 瀏覽器 +* iOS +* Windows Phone 7 和 8 +* 泰 +* Windows +* 火狐瀏覽器的作業系統 + +# 連接 + +> `connection`物件,通過公開 `navigator.connection` ,提供了有關該設備的行動電話和無線網路連接的資訊。 + +## 屬性 + +* connection.type + +## 常量 + +* Connection.UNKNOWN +* Connection.ETHERNET +* Connection.WIFI +* Connection.CELL_2G +* Connection.CELL_3G +* Connection.CELL_4G +* Connection.CELL +* Connection.NONE + +## connection.type + +此屬性提供快速的方法來確定設備的網路連接狀態,和連線類型。 + +### 快速的示例 + + function checkConnection() { + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; + + alert('Connection type: ' + states[networkState]); + } + + checkConnection(); + + +### API 更改 + +科爾多瓦 2.3.0,直到 `Connection` 物件的訪問通過 `navigator.network.connection` 後才改為其中, `navigator.connection` 以匹配的 W3C 規範。 它在其原始位置,是仍然可用,但已廢棄,最終將被刪除。 + +### iOS 的怪癖 + +* iOS 無法檢測到蜂窩網路連接的類型。 + * `navigator.connection.type`設置為 `Connection.CELL` 為所有蜂窩資料。 + +### Windows Phone 怪癖 + +* 當運行在模擬器中,總能檢測到 `navigator.connection.type` 作為`Connection.UNKNOWN`. + +* Windows Phone 不能檢測的蜂窩網路連接的類型。 + + * `navigator.connection.type`設置為 `Connection.CELL` 為所有蜂窩資料。 + +### Windows 的怪癖 + +* 當電話 8.1 在模擬器中運行,總能檢測到 `navigator.connection.type` 作為 `Connection.ETHERNET`. + +### Tizen 怪癖 + +* 泰只能檢測一個 WiFi 或細胞連接。 + * `navigator.connection.type` 是所有蜂窩資料設置為 `Connection.CELL_2G`。 + +### 火狐瀏覽器作業系統的怪癖 + +* 火狐瀏覽器作業系統無法檢測到蜂窩網路連接的類型。 + * `navigator.connection.type`設置為 `Connection.CELL` 為所有蜂窩資料。 + +# 與網路相關的事件 + +## offline + +當一個應用程式離線時,與該設備未連接到互聯網時,將觸發該事件。 + + document.addEventListener("offline", yourCallbackFunction, false); + + +### 詳細資訊 + +`offline`以前連接的設備失去網路連接,這樣,應用程式不再可以訪問互聯網時激發的事件。 它依賴于連接 API,相同的資訊和火災時的值 `connection.type` 變得`NONE`. + +應用程式通常應使用 `document.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。 + +### 快速的示例 + + document.addEventListener("offline", onOffline, false); + + function onOffline() { + // Handle the offline event + } + + +### iOS 的怪癖 + +在初始啟動期間,第一次離線事件 (如果適用) 需至少一秒的火。 + +### Windows Phone 7 的怪癖 + +當運行在模擬器中, `connection.status` 始終是未知的因此此事件不會*不*火。 + +### Windows Phone 8 怪癖 + +模擬程式報告連線類型為 `Cellular` ,而不會更改,所以該事件不會*不*火。 + +## online + +當應用程式進入線上狀態,和該設備將成為連接到互聯網時觸發此事件。 + + document.addEventListener("online", yourCallbackFunction, false); + + +### 詳細資訊 + +`online`當先前連接的行動裝置接收到一個網路連接以允許應用程式訪問互聯網時激發的事件。 它依賴于連接 API,相同的資訊,則會激發 `connection.type` 從更改 `NONE` 為任何其他值。 + +應用程式通常應使用 `document.addEventListener` 將一個事件攔截器附加一次 `deviceready` 事件火災。 + +### 快速的示例 + + document.addEventListener("online", onOnline, false); + + function onOnline() { + // Handle the online event + } + + +### iOS 的怪癖 + +在初始啟動期間第一次 `online` 事件 (如果適用),至少需一秒的火災之前的, `connection.type` 是`UNKNOWN`. + +### Windows Phone 7 的怪癖 + +當運行在模擬器中, `connection.status` 始終是未知的因此此事件不會*不*火。 + +### Windows Phone 8 怪癖 + +模擬程式報告連線類型為 `Cellular` ,而不會更改,所以事件不**火。 diff --git a/plugins/cordova-plugin-network-information/package.json b/plugins/cordova-plugin-network-information/package.json new file mode 100644 index 0000000..bbc5bde --- /dev/null +++ b/plugins/cordova-plugin-network-information/package.json @@ -0,0 +1,53 @@ +{ + "name": "cordova-plugin-network-information", + "version": "1.2.1-dev", + "description": "Cordova Network Information Plugin", + "cordova": { + "id": "cordova-plugin-network-information", + "platforms": [ + "firefoxos", + "android", + "amazon-fireos", + "ubuntu", + "ios", + "blackberry10", + "wp7", + "wp8", + "windows8", + "windows", + "tizen", + "browser" + ] + }, + "repository": { + "type": "git", + "url": "https://github.com/apache/cordova-plugin-network-information" + }, + "keywords": [ + "cordova", + "network", + "information", + "ecosystem:cordova", + "cordova-firefoxos", + "cordova-android", + "cordova-amazon-fireos", + "cordova-ubuntu", + "cordova-ios", + "cordova-blackberry10", + "cordova-wp7", + "cordova-wp8", + "cordova-windows8", + "cordova-windows", + "cordova-tizen", + "cordova-browser" + ], + "scripts": { + "test": "npm run jshint", + "jshint": "jshint www && jshint src && jshint tests" + }, + "author": "Apache Software Foundation", + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } +} diff --git a/plugins/cordova-plugin-network-information/plugin.xml b/plugins/cordova-plugin-network-information/plugin.xml new file mode 100644 index 0000000..20eea08 --- /dev/null +++ b/plugins/cordova-plugin-network-information/plugin.xml @@ -0,0 +1,174 @@ + + + + + + Network Information + Cordova Network Information Plugin + Apache 2.0 + cordova,network,information + https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git + https://issues.apache.org/jira/browse/CB/component/12320640 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-network-information/src/android/NetworkManager.java b/plugins/cordova-plugin-network-information/src/android/NetworkManager.java new file mode 100644 index 0000000..59965bd --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/android/NetworkManager.java @@ -0,0 +1,274 @@ +/* + 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.networkinformation; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PluginResult; +import org.apache.cordova.CordovaWebView; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.util.Log; + +import java.util.Locale; + +public class NetworkManager extends CordovaPlugin { + + public static int NOT_REACHABLE = 0; + public static int REACHABLE_VIA_CARRIER_DATA_NETWORK = 1; + public static int REACHABLE_VIA_WIFI_NETWORK = 2; + + public static final String WIFI = "wifi"; + public static final String WIMAX = "wimax"; + // mobile + public static final String MOBILE = "mobile"; + + // Android L calls this Cellular, because I have no idea! + public static final String CELLULAR = "cellular"; + // 2G network types + public static final String GSM = "gsm"; + public static final String GPRS = "gprs"; + public static final String EDGE = "edge"; + // 3G network types + public static final String CDMA = "cdma"; + public static final String UMTS = "umts"; + public static final String HSPA = "hspa"; + public static final String HSUPA = "hsupa"; + public static final String HSDPA = "hsdpa"; + public static final String ONEXRTT = "1xrtt"; + public static final String EHRPD = "ehrpd"; + // 4G network types + public static final String LTE = "lte"; + public static final String UMB = "umb"; + public static final String HSPA_PLUS = "hspa+"; + // return type + public static final String TYPE_UNKNOWN = "unknown"; + public static final String TYPE_ETHERNET = "ethernet"; + public static final String TYPE_WIFI = "wifi"; + public static final String TYPE_2G = "2g"; + public static final String TYPE_3G = "3g"; + public static final String TYPE_4G = "4g"; + public static final String TYPE_NONE = "none"; + + private static final String LOG_TAG = "NetworkManager"; + + private CallbackContext connectionCallbackContext; + + ConnectivityManager sockMan; + BroadcastReceiver receiver; + private JSONObject lastInfo = null; + + /** + * Sets the context of the Command. This can then be used to do things like + * get file paths associated with the Activity. + * + * @param cordova The context of the main Activity. + * @param webView The CordovaWebView Cordova is running in. + */ + public void initialize(CordovaInterface cordova, CordovaWebView webView) { + super.initialize(cordova, webView); + this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); + this.connectionCallbackContext = null; + + // We need to listen to connectivity events to update navigator.connection + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + if (this.receiver == null) { + this.receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + // (The null check is for the ARM Emulator, please use Intel Emulator for better results) + if(NetworkManager.this.webView != null) + updateConnectionInfo(sockMan.getActiveNetworkInfo()); + } + }; + webView.getContext().registerReceiver(this.receiver, intentFilter); + } + + } + + /** + * 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 True if the action was valid, false otherwise. + */ + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { + if (action.equals("getConnectionInfo")) { + this.connectionCallbackContext = callbackContext; + NetworkInfo info = sockMan.getActiveNetworkInfo(); + String connectionType = ""; + try { + connectionType = this.getConnectionInfo(info).get("type").toString(); + } catch (JSONException e) { } + + PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, connectionType); + pluginResult.setKeepCallback(true); + callbackContext.sendPluginResult(pluginResult); + return true; + } + return false; + } + + /** + * Stop network receiver. + */ + public void onDestroy() { + if (this.receiver != null) { + try { + webView.getContext().unregisterReceiver(this.receiver); + } catch (Exception e) { + Log.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e); + } finally { + receiver = null; + } + } + } + + //-------------------------------------------------------------------------- + // LOCAL METHODS + //-------------------------------------------------------------------------- + + /** + * Updates the JavaScript side whenever the connection changes + * + * @param info the current active network info + * @return + */ + private void updateConnectionInfo(NetworkInfo info) { + // send update to javascript "navigator.network.connection" + // Jellybean sends its own info + JSONObject thisInfo = this.getConnectionInfo(info); + if(!thisInfo.equals(lastInfo)) + { + String connectionType = ""; + try { + connectionType = thisInfo.get("type").toString(); + } catch (JSONException e) { } + + sendUpdate(connectionType); + lastInfo = thisInfo; + } + } + + /** + * Get the latest network connection information + * + * @param info the current active network info + * @return a JSONObject that represents the network info + */ + private JSONObject getConnectionInfo(NetworkInfo info) { + String type = TYPE_NONE; + String extraInfo = ""; + if (info != null) { + // If we are not connected to any network set type to none + if (!info.isConnected()) { + type = TYPE_NONE; + } + else { + type = getType(info); + } + extraInfo = info.getExtraInfo(); + } + + Log.d("CordovaNetworkManager", "Connection Type: " + type); + Log.d("CordovaNetworkManager", "Connection Extra Info: " + extraInfo); + + JSONObject connectionInfo = new JSONObject(); + + try { + connectionInfo.put("type", type); + connectionInfo.put("extraInfo", extraInfo); + } catch (JSONException e) { } + + return connectionInfo; + } + + /** + * Create a new plugin result and send it back to JavaScript + * + * @param connection the network info to set as navigator.connection + */ + private void sendUpdate(String type) { + if (connectionCallbackContext != null) { + PluginResult result = new PluginResult(PluginResult.Status.OK, type); + result.setKeepCallback(true); + connectionCallbackContext.sendPluginResult(result); + } + webView.postMessage("networkconnection", type); + } + + /** + * Determine the type of connection + * + * @param info the network info so we can determine connection type. + * @return the type of mobile network we are on + */ + private String getType(NetworkInfo info) { + if (info != null) { + String type = info.getTypeName().toLowerCase(Locale.US); + + Log.d("CordovaNetworkManager", "toLower : " + type.toLowerCase()); + Log.d("CordovaNetworkManager", "wifi : " + WIFI); + if (type.equals(WIFI)) { + return TYPE_WIFI; + } + else if (type.toLowerCase().equals(TYPE_ETHERNET)) { + return TYPE_ETHERNET; + } + else if (type.equals(MOBILE) || type.equals(CELLULAR)) { + type = info.getSubtypeName().toLowerCase(Locale.US); + if (type.equals(GSM) || + type.equals(GPRS) || + type.equals(EDGE)) { + return TYPE_2G; + } + else if (type.startsWith(CDMA) || + type.equals(UMTS) || + type.equals(ONEXRTT) || + type.equals(EHRPD) || + type.equals(HSUPA) || + type.equals(HSDPA) || + type.equals(HSPA)) { + return TYPE_3G; + } + else if (type.equals(LTE) || + type.equals(UMB) || + type.equals(HSPA_PLUS)) { + return TYPE_4G; + } + } + } + else { + return TYPE_NONE; + } + return TYPE_UNKNOWN; + } +} diff --git a/plugins/cordova-plugin-network-information/src/blackberry10/index.js b/plugins/cordova-plugin-network-information/src/blackberry10/index.js new file mode 100644 index 0000000..c6cd00a --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/blackberry10/index.js @@ -0,0 +1,66 @@ +/* + * + * 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. + * +*/ + +/* global PluginResult */ + +//map from BB10 to cordova connection types: +//https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js +function mapConnectionType(con) { + switch (con.type) { + case 'wired': + return 'ethernet'; + case 'wifi': + return 'wifi'; + case 'none': + return 'none'; + case 'cellular': + switch (con.technology) { + case 'edge': + case 'gsm': + return '2g'; + case 'evdo': + return '3g'; + case 'umts': + return '3g'; + case 'lte': + return '4g'; + } + return "cellular"; + } + return 'unknown'; +} + +function currentConnectionType() { + try { + //possible for webplatform to throw pps exception + return mapConnectionType(window.qnx.webplatform.device.activeConnection || { type : 'none' }); + } + catch (e) { + return 'unknown'; + } +} + +module.exports = { + getConnectionInfo: function (success, fail, args, env) { + var result = new PluginResult(args, env); + result.ok(currentConnectionType()); + } +}; diff --git a/plugins/cordova-plugin-network-information/src/browser/network.js b/plugins/cordova-plugin-network-information/src/browser/network.js new file mode 100644 index 0000000..8a6ddb0 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/browser/network.js @@ -0,0 +1,48 @@ +/* + * 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. + * +*/ + +var cordova = require('cordova'), + proxy = require("cordova/exec/proxy"), + Connection = require('./Connection'); + +var type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + +// Subscribe to 'native' online/offline events +function onStatusChange(evt) { + type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + // force async + setTimeout(function(){ + cordova.fireDocumentEvent(evt.type); + },0); +} + +window.addEventListener('online', onStatusChange); +window.addEventListener('offline', onStatusChange); + +proxy.add("NetworkStatus", { + getConnectionInfo:function(cbSuccess) { + // force async + setTimeout(function(){ + cbSuccess(type); + },0); + } +}); + + diff --git a/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js b/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js new file mode 100644 index 0000000..8c82557 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js @@ -0,0 +1,96 @@ +/* + * + * 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. + * + */ + +/* + Network API overview: http://www.w3.org/TR/netinfo-api/ + and http://w3c.github.io/netinfo/ +*/ + +var Connection = require('./Connection'), + modulemapper = require('cordova/modulemapper'); + +var origConnection = modulemapper.getOriginalSymbol(window, 'navigator.connection'); + +module.exports = { + + getConnectionInfo: function(successCallback, errorCallback) { + var connection = origConnection || navigator.mozConnection, + connectionType = Connection.UNKNOWN; + + if (!connection) { + setTimeout(function() { + successCallback(connectionType); + }, 0); + return; + } + + var bandwidth = connection.bandwidth, + metered = connection.metered, + type = connection.type; + + if (type !== undefined) { + // For more information see: + // https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API + + switch(type) { + case "cellular": + connectionType = Connection.CELL; + break; + case "ethernet": + connectionType = Connection.ETHERNET; + break; + case "wifi": + connectionType = Connection.WIFI; + break; + case "none": + connectionType = Connection.NONE; + break; + } + } else if (bandwidth !== undefined && metered !== undefined) { + /* + bandwidth of type double, readonly + The user agent must set the value of the bandwidth attribute to: + 0 if the user is currently offline; + Infinity if the bandwidth is unknown; + an estimation of the current bandwidth in MB/s (Megabytes per seconds) + available for communication with the browsing context active document's + domain. + + For more information see: + https://developer.mozilla.org/en-US/docs/Web/API/Connection + */ + + if (bandwidth === 0) { + connectionType = Connection.NONE; + } else if (metered && isFinite(bandwidth)) { + connectionType = Connection.CELL; + } else if (!metered && isFinite(bandwidth)) { + connectionType = Connection.WIFI; + } + } + + setTimeout(function() { + successCallback(connectionType); + }, 0); + } +}; + +require("cordova/exec/proxy").add("NetworkStatus", module.exports); diff --git a/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h b/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h new file mode 100644 index 0000000..8add027 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h @@ -0,0 +1,34 @@ +/* + 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. + */ + +#import +#import +#import "CDVReachability.h" + +@interface CDVConnection : CDVPlugin { + NSString* type; + NSString* _callbackId; + + CDVReachability* internetReach; +} + +@property (copy) NSString* connectionType; +@property (strong) CDVReachability* internetReach; + +@end diff --git a/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m b/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m new file mode 100644 index 0000000..6715322 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m @@ -0,0 +1,156 @@ +/* + 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. + */ +#import + +#import "CDVConnection.h" +#import "CDVReachability.h" + +@interface CDVConnection (PrivateMethods) +- (void)updateOnlineStatus; +- (void)sendPluginResult; +@end + +@implementation CDVConnection + +@synthesize connectionType, internetReach; + +- (void)getConnectionInfo:(CDVInvokedUrlCommand*)command +{ + _callbackId = command.callbackId; + [self sendPluginResult]; +} + +- (void)sendPluginResult +{ + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:self.connectionType]; + + [result setKeepCallbackAsBool:YES]; + [self.commandDelegate sendPluginResult:result callbackId:_callbackId]; +} + +- (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability +{ + NetworkStatus networkStatus = [reachability currentReachabilityStatus]; + + switch (networkStatus) { + case NotReachable: + return @"none"; + + case ReachableViaWWAN: + { + BOOL isConnectionRequired = [reachability connectionRequired]; + if (isConnectionRequired) { + return @"none"; + } else { + if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) { + CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new]; + if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) { + return @"2g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) { + return @"2g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) { + return @"4g"; + } + } + return @"cellular"; + } + } + case ReachableViaWiFi: + return @"wifi"; + + default: + return @"unknown"; + } +} + +- (BOOL)isCellularConnection:(NSString*)theConnectionType +{ + return [theConnectionType isEqualToString:@"2g"] || + [theConnectionType isEqualToString:@"3g"] || + [theConnectionType isEqualToString:@"4g"] || + [theConnectionType isEqualToString:@"cellular"]; +} + +- (void)updateReachability:(CDVReachability*)reachability +{ + if (reachability) { + // check whether the connection type has changed + NSString* newConnectionType = [self w3cConnectionTypeFor:reachability]; + if ([newConnectionType isEqualToString:self.connectionType]) { // the same as before, remove dupes + return; + } else { + self.connectionType = [self w3cConnectionTypeFor:reachability]; + } + } + [self sendPluginResult]; +} + +- (void)updateConnectionType:(NSNotification*)note +{ + CDVReachability* curReach = [note object]; + + if ((curReach != nil) && [curReach isKindOfClass:[CDVReachability class]]) { + [self updateReachability:curReach]; + } +} + +- (void)onPause +{ + [self.internetReach stopNotifier]; +} + +- (void)onResume +{ + [self.internetReach startNotifier]; + [self updateReachability:self.internetReach]; +} + +- (void)pluginInitialize +{ + self.connectionType = @"none"; + self.internetReach = [CDVReachability reachabilityForInternetConnection]; + self.connectionType = [self w3cConnectionTypeFor:self.internetReach]; + [self.internetReach startNotifier]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:) + name:kReachabilityChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:) + name:CTRadioAccessTechnologyDidChangeNotification object:nil]; + if (UIApplicationDidEnterBackgroundNotification && UIApplicationWillEnterForegroundNotification) { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil]; + } +} + +@end diff --git a/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h b/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h new file mode 100644 index 0000000..01a95c3 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h @@ -0,0 +1,85 @@ +/* + + File: Reachability.h + Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs. + Version: 2.2 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. + ("Apple") in consideration of your agreement to the following terms, and your + use, installation, modification or redistribution of this Apple software + constitutes acceptance of these terms. If you do not agree with these terms, + please do not use, install, modify or redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and subject + to these terms, Apple grants you a personal, non-exclusive license, under + Apple's copyrights in this original Apple software (the "Apple Software"), to + use, reproduce, modify and redistribute the Apple Software, with or without + modifications, in source and/or binary forms; provided that if you redistribute + the Apple Software in its entirety and without modifications, you must retain + this notice and the following text and disclaimers in all such redistributions + of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may be used + to endorse or promote products derived from the Apple Software without specific + prior written permission from Apple. Except as expressly stated in this notice, + no other rights or licenses, express or implied, are granted by Apple herein, + including but not limited to any patent rights that may be infringed by your + derivative works or by other works in which the Apple Software may be + incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN + COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR + DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF + CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF + APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2010 Apple Inc. All Rights Reserved. + +*/ + +#import +#import +#import + +typedef enum { + NotReachable = 0, + ReachableViaWWAN, // this value has been swapped with ReachableViaWiFi for Cordova backwards compat. reasons + ReachableViaWiFi // this value has been swapped with ReachableViaWWAN for Cordova backwards compat. reasons +} NetworkStatus; +#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification" + +@interface CDVReachability : NSObject +{ + BOOL localWiFiRef; + SCNetworkReachabilityRef reachabilityRef; +} + +// reachabilityWithHostName- Use to check the reachability of a particular host name. ++ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName; + +// reachabilityWithAddress- Use to check the reachability of a particular IP address. ++ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress; + +// reachabilityForInternetConnection- checks whether the default route is available. +// Should be used by applications that do not connect to a particular host ++ (CDVReachability*)reachabilityForInternetConnection; + +// reachabilityForLocalWiFi- checks whether a local wifi connection is available. ++ (CDVReachability*)reachabilityForLocalWiFi; + +// Start listening for reachability notifications on the current run loop +- (BOOL)startNotifier; +- (void)stopNotifier; + +- (NetworkStatus)currentReachabilityStatus; +// WWAN may be available, but not active until a connection has been established. +// WiFi may require a connection for VPN on Demand. +- (BOOL)connectionRequired; +@end diff --git a/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m b/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m new file mode 100644 index 0000000..c60261a --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m @@ -0,0 +1,260 @@ +/* + + File: Reachability.m + Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs. + Version: 2.2 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. + ("Apple") in consideration of your agreement to the following terms, and your + use, installation, modification or redistribution of this Apple software + constitutes acceptance of these terms. If you do not agree with these terms, + please do not use, install, modify or redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and subject + to these terms, Apple grants you a personal, non-exclusive license, under + Apple's copyrights in this original Apple software (the "Apple Software"), to + use, reproduce, modify and redistribute the Apple Software, with or without + modifications, in source and/or binary forms; provided that if you redistribute + the Apple Software in its entirety and without modifications, you must retain + this notice and the following text and disclaimers in all such redistributions + of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may be used + to endorse or promote products derived from the Apple Software without specific + prior written permission from Apple. Except as expressly stated in this notice, + no other rights or licenses, express or implied, are granted by Apple herein, + including but not limited to any patent rights that may be infringed by your + derivative works or by other works in which the Apple Software may be + incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN + COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR + DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF + CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF + APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2010 Apple Inc. All Rights Reserved. + +*/ + +#import +#import +#import +#import +#import +#import + +#import + +#import "CDVReachability.h" + +#define kShouldPrintReachabilityFlags 0 + +static void CDVPrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment) +{ +#if kShouldPrintReachabilityFlags + NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n", + (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', + (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', + + (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', + (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', + (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', + (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-', + comment + ); +#endif +} + +@implementation CDVReachability + +static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) +{ +#pragma unused (target, flags) + // NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback"); + // NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback"); + + // Converted the asserts above to conditionals, with safe return from the function + if (info == NULL) { + NSLog(@"info was NULL in ReachabilityCallback"); + return; + } + + if (![(__bridge NSObject*)info isKindOfClass :[CDVReachability class]]) { + NSLog(@"info was wrong class in ReachabilityCallback"); + return; + } + + // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively + // in case someon uses the Reachability object in a different thread. + @autoreleasepool { + CDVReachability* noteObject = (__bridge CDVReachability*)info; + // Post a notification to notify the client that the network reachability changed. + [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject]; + } +} + +- (BOOL)startNotifier +{ + BOOL retVal = NO; + SCNetworkReachabilityContext context = {0, (__bridge void*)(self), NULL, NULL, NULL}; + + if (SCNetworkReachabilitySetCallback(reachabilityRef, CDVReachabilityCallback, &context)) { + if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) { + retVal = YES; + } + } + return retVal; +} + +- (void)stopNotifier +{ + if (reachabilityRef != NULL) { + SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + } +} + +- (void)dealloc +{ + [self stopNotifier]; + if (reachabilityRef != NULL) { + CFRelease(reachabilityRef); + } +} + ++ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName; +{ + CDVReachability* retVal = NULL; + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]); + if (reachability != NULL) { + retVal = [[self alloc] init]; + if (retVal != NULL) { + retVal->reachabilityRef = reachability; + retVal->localWiFiRef = NO; + } + } + return retVal; +} + ++ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress; +{ + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress); + CDVReachability* retVal = NULL; + if (reachability != NULL) { + retVal = [[self alloc] init]; + if (retVal != NULL) { + retVal->reachabilityRef = reachability; + retVal->localWiFiRef = NO; + } + } + return retVal; +} + ++ (CDVReachability*)reachabilityForInternetConnection; +{ + struct sockaddr_in zeroAddress; + bzero(&zeroAddress, sizeof(zeroAddress)); + zeroAddress.sin_len = sizeof(zeroAddress); + zeroAddress.sin_family = AF_INET; + return [self reachabilityWithAddress:&zeroAddress]; +} + ++ (CDVReachability*)reachabilityForLocalWiFi; +{ + struct sockaddr_in localWifiAddress; + bzero(&localWifiAddress, sizeof(localWifiAddress)); + localWifiAddress.sin_len = sizeof(localWifiAddress); + localWifiAddress.sin_family = AF_INET; + // IN_LINKLOCALNETNUM is defined in as 169.254.0.0 + localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); + CDVReachability* retVal = [self reachabilityWithAddress:&localWifiAddress]; + if (retVal != NULL) { + retVal->localWiFiRef = YES; + } + return retVal; +} + +#pragma mark Network Flag Handling + +- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags +{ + CDVPrintReachabilityFlags(flags, "localWiFiStatusForFlags"); + + BOOL retVal = NotReachable; + if ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect)) { + retVal = ReachableViaWiFi; + } + return retVal; +} + +- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags +{ + CDVPrintReachabilityFlags(flags, "networkStatusForFlags"); + if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) { + // if target host is not reachable + return NotReachable; + } + + NetworkStatus retVal = NotReachable; + + if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) { + // if target host is reachable and no connection is required + // then we'll assume (for now) that your on Wi-Fi + retVal = ReachableViaWiFi; + } + + if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) || + ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))) { + // ... and the connection is on-demand (or on-traffic) if the + // calling application is using the CFSocketStream or higher APIs + + if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) { + // ... and no [user] intervention is needed + retVal = ReachableViaWiFi; + } + } + + if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) { + // ... but WWAN connections are OK if the calling application + // is using the CFNetwork (CFSocketStream?) APIs. + retVal = ReachableViaWWAN; + } + return retVal; +} + +- (BOOL)connectionRequired; +{ + NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef"); + SCNetworkReachabilityFlags flags; + if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { + return flags & kSCNetworkReachabilityFlagsConnectionRequired; + } + return NO; +} + +- (NetworkStatus)currentReachabilityStatus +{ + NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef"); + NetworkStatus retVal = NotReachable; + SCNetworkReachabilityFlags flags; + if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { + if (localWiFiRef) { + retVal = [self localWiFiStatusForFlags:flags]; + } else { + retVal = [self networkStatusForFlags:flags]; + } + } + return retVal; +} + +@end diff --git a/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js b/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js new file mode 100644 index 0000000..d2de2cc --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js @@ -0,0 +1,93 @@ +/* + * + * 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. + * +*/ + +/* global tizen */ + +var Connection = require('./Connection'); + +module.exports = { + getConnectionInfo: function(successCallback, errorCallback) { + var cncType = Connection.NONE; + var infoCount = 0; + var deviceCapabilities = null; + var timerId = 0; + var timeout = 300; + + + function connectionCB() { + if (timerId !== null) { + clearTimeout(timerId); + timerId = null; + } + + infoCount++; + + if (infoCount > 1) { + if (successCallback) { + successCallback(cncType); + } + } + } + + function errorCB(error) { + console.log("Error: " + error.code + "," + error.name + "," + error.message); + + if (errorCallback) { + errorCallback(); + } + } + + function wifiSuccessCB(wifi) { + if ((wifi.status === "ON") && (wifi.ipAddress.length !== 0)) { + cncType = Connection.WIFI; + } + connectionCB(); + } + + function cellularSuccessCB(cell) { + if ((cncType === Connection.NONE) && (cell.status === "ON") && (cell.ipAddress.length !== 0)) { + cncType = Connection.CELL_2G; + } + connectionCB(); + } + + + deviceCapabilities = tizen.systeminfo.getCapabilities(); + + + timerId = setTimeout(function() { + timerId = null; + infoCount = 1; + connectionCB(); + }, timeout); + + + if (deviceCapabilities.wifi) { + tizen.systeminfo.getPropertyValue("WIFI_NETWORK", wifiSuccessCB, errorCB); + } + + if (deviceCapabilities.telephony) { + tizen.systeminfo.getPropertyValue("CELLULAR_NETWORK", cellularSuccessCB, errorCB); + } + } +}; + +require("cordova/tizen/commandProxy").add("NetworkStatus", module.exports); diff --git a/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp b/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp new file mode 100644 index 0000000..8fdb494 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp @@ -0,0 +1,63 @@ +/* + * 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. + */ + +#include "network_information.h" + +void NetworkInformation::getConnectionInfo(int scId, int ecId) { + Q_UNUSED(ecId); + + QString result; + QNetworkInfo::NetworkMode networkMode = m_systemNetworkInfo.currentNetworkMode(); + QNetworkInfo::NetworkStatus networkStatus = m_systemNetworkInfo.networkStatus(networkMode, 0); + QNetworkInfo::CellDataTechnology cellDataTechnology = m_systemNetworkInfo.currentCellDataTechnology(0); + + if (networkStatus == QNetworkInfo::NoNetworkAvailable) + result = "Connection.NONE"; + + switch (networkMode) { + case QNetworkInfo::WimaxMode: + case QNetworkInfo::WlanMode: + result = "Connection.WIFI"; + break; + case QNetworkInfo::EthernetMode: + result = "Connection.ETHERNET"; + break; + case QNetworkInfo::LteMode: + result = "Connection.CELL_4G"; + break; + case QNetworkInfo::GsmMode: + case QNetworkInfo::CdmaMode: + case QNetworkInfo::TdscdmaMode: + case QNetworkInfo::WcdmaMode: + switch (cellDataTechnology) { + case QNetworkInfo::UmtsDataTechnology: + case QNetworkInfo::HspaDataTechnology: + result = "Connection.CELL_3G"; + break; + case QNetworkInfo::EdgeDataTechnology: + case QNetworkInfo::GprsDataTechnology: + result = "Connection.CELL_2G"; + break; + case QNetworkInfo::UnknownDataTechnology: + result = "Connection.UNKNOWN"; + break; + } + case QNetworkInfo::BluetoothMode: + case QNetworkInfo::UnknownMode: + result = "Connection.UNKNOWN"; + break; + } + + this->callback(scId, result); +} diff --git a/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h b/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h new file mode 100644 index 0000000..aca20e7 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h @@ -0,0 +1,47 @@ +/* + * 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. + */ + +#ifndef NETWORK_INFORMATION_H +#define NETWORK_INFORMATION_H + +#include + +#include +#include + +class NetworkInformation: public CPlugin { + Q_OBJECT +public: + explicit NetworkInformation(Cordova *cordova): CPlugin(cordova) {} + + virtual const QString fullName() override { + return NetworkInformation::fullID(); + } + + virtual const QString shortName() override { + return "Connection"; + } + + static const QString fullID() { + return "NetworkStatus"; + } + +public slots: + void getConnectionInfo(int scId, int ecId); + +private: + QNetworkInfo m_systemNetworkInfo; +}; + +#endif diff --git a/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js b/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js new file mode 100644 index 0000000..92153c7 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js @@ -0,0 +1,83 @@ +/* + * + * 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. + * +*/ + +/*global Windows:true */ + +var Connection = require('./Connection'); + +var winNetConn = Windows.Networking.Connectivity; +var networkInfo = winNetConn.NetworkInformation; + +function getCurrrentConnectionType() { + + var profile = networkInfo.getInternetConnectionProfile(); + + if (!profile) { + return Connection.NONE; + } + + var conLevel = profile.getNetworkConnectivityLevel(); + var interfaceType = profile.networkAdapter.ianaInterfaceType; + + // since we use this to detect whether we are online or offline we do check agains InternetAccess + // localAccess (airplane mode as an example) or constrainedInternetAccess mean there is no access to the internet available + // https://msdn.microsoft.com/library/windows/apps/windows.networking.connectivity.networkconnectivitylevel.aspx + if (conLevel != Windows.Networking.Connectivity.NetworkConnectivityLevel.internetAccess) { + return Connection.NONE; + } + + var connectionType; + + switch (interfaceType) { + case 71: + connectionType = Connection.WIFI; + break; + case 6: + connectionType = Connection.ETHERNET; + break; + case 243: // (3GPP WWAN) // Fallthrough is intentional + case 244: // (3GPP2 WWAN) + connectionType = Connection.CELL_3G; + break; + default: + connectionType = Connection.UNKNOWN; + break; + } + + return connectionType; +} + +module.exports = { + + getConnectionInfo:function(win,fail,args) + { + var reportConnectionInfoOnce = function () { + win(getCurrrentConnectionType(), { keepCallback: true }); + }; + + // report current connection type + setTimeout(reportConnectionInfoOnce, 0); + // start traking future changes + networkInfo.addEventListener("networkstatuschanged", reportConnectionInfoOnce); + } +}; + +require("cordova/exec/proxy").add("NetworkStatus",module.exports); diff --git a/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs b/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs new file mode 100644 index 0000000..12eb061 --- /dev/null +++ b/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs @@ -0,0 +1,129 @@ +/* + 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. +*/ + +using System; +using System.Diagnostics; +using System.Net; +using System.Net.NetworkInformation; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Shapes; +using Microsoft.Phone.Net.NetworkInformation; + +namespace WPCordovaClassLib.Cordova.Commands +{ + + // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation(v=VS.92).aspx + // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation(v=VS.92).aspx + + public class NetworkStatus : BaseCommand + { + const string UNKNOWN = "unknown"; + const string ETHERNET = "ethernet"; + const string WIFI = "wifi"; + const string CELL_2G = "2g"; + const string CELL_3G = "3g"; + const string CELL_4G = "4g"; + const string NONE = "none"; + const string CELL = "cellular"; + + private bool HasCallback = false; + + public NetworkStatus() + { + DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler(ChangeDetected); + } + + public override void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e) + { + this.getConnectionInfo(""); + } + + public void getConnectionInfo(string empty) + { + HasCallback = true; + updateConnectionType(checkConnectionType()); + } + + private string checkConnectionType() + { + if (DeviceNetworkInformation.IsNetworkAvailable) + { + if (DeviceNetworkInformation.IsWiFiEnabled) + { + return WIFI; + } + else + { + return DeviceNetworkInformation.IsCellularDataEnabled ? CELL : UNKNOWN; + } + } + return NONE; + } + + private string checkConnectionType(NetworkInterfaceSubType type) + { + switch (type) + { + case NetworkInterfaceSubType.Cellular_1XRTT: //cell + case NetworkInterfaceSubType.Cellular_GPRS: //cell + return CELL; + case NetworkInterfaceSubType.Cellular_EDGE: //2 + return CELL_2G; + case NetworkInterfaceSubType.Cellular_3G: + case NetworkInterfaceSubType.Cellular_EVDO: //3 + case NetworkInterfaceSubType.Cellular_EVDV: //3 + case NetworkInterfaceSubType.Cellular_HSPA: //3 + return CELL_3G; + case NetworkInterfaceSubType.WiFi: + return WIFI; + case NetworkInterfaceSubType.Unknown: + case NetworkInterfaceSubType.Desktop_PassThru: + default: + return UNKNOWN; + } + } + + void ChangeDetected(object sender, NetworkNotificationEventArgs e) + { + switch (e.NotificationType) + { + case NetworkNotificationType.InterfaceConnected: + updateConnectionType(checkConnectionType(e.NetworkInterface.InterfaceSubtype)); + break; + case NetworkNotificationType.InterfaceDisconnected: + updateConnectionType(NONE); + break; + default: + break; + } + } + + private void updateConnectionType(string type) + { + // This should also implicitly fire offline/online events as that is handled on the JS side + if (this.HasCallback) + { + PluginResult result = new PluginResult(PluginResult.Status.OK, type); + result.KeepCallback = true; + DispatchCommandResult(result); + } + } + } +} diff --git a/plugins/cordova-plugin-network-information/tests/plugin.xml b/plugins/cordova-plugin-network-information/tests/plugin.xml new file mode 100644 index 0000000..25ff0fc --- /dev/null +++ b/plugins/cordova-plugin-network-information/tests/plugin.xml @@ -0,0 +1,30 @@ + + + + + Cordova Network Information Plugin Tests + Apache 2.0 + + + + diff --git a/plugins/cordova-plugin-network-information/tests/tests.js b/plugins/cordova-plugin-network-information/tests/tests.js new file mode 100644 index 0000000..07f4b27 --- /dev/null +++ b/plugins/cordova-plugin-network-information/tests/tests.js @@ -0,0 +1,104 @@ +/* + * + * 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. + * +*/ + +/* jshint jasmine: true */ +/* global Connection */ + +exports.defineAutoTests = function () { + describe('Network (navigator.connection)', function () { + it("network.spec.1 should exist", function () { + expect(navigator.network && navigator.network.connection).toBeDefined(); + expect(navigator.connection).toBeDefined(); + }); + + it("network.spec.2 should be set to a valid value", function () { + var validValues = { + 'unknown': 1, + 'ethernet': 1, + 'wifi': 1, + '2g': 1, + 'cellular': 1, + '3g': 1, + '4g': 1, + 'none': 1 + }; + expect(validValues[navigator.connection.type]).toBe(1); + }); + + it("network.spec.3 should have the same value in deprecated and non-deprecated apis", function () { + expect(navigator.network.connection.type).toBe(navigator.connection.type); + }); + + it("network.spec.4 should define constants for connection status", function () { + expect(Connection.UNKNOWN).toBe("unknown"); + expect(Connection.ETHERNET).toBe("ethernet"); + expect(Connection.WIFI).toBe("wifi"); + expect(Connection.CELL_2G).toBe("2g"); + expect(Connection.CELL_3G).toBe("3g"); + expect(Connection.CELL_4G).toBe("4g"); + expect(Connection.NONE).toBe("none"); + expect(Connection.CELL).toBe("cellular"); + }); + }); +}; + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ + +exports.defineManualTests = function (contentEl, createActionButton) { + function eventOutput(s) { + var el = document.getElementById("results"); + el.innerHTML = el.innerHTML + s + "
"; + } + + function printNetwork() { + eventOutput("navigator.connection.type=" + navigator.connection.type); + eventOutput("navigator.network.connection.type=" + navigator.network.connection.type); + } + + function onEvent(e) { + eventOutput('Event of type: ' + e.type); + printNetwork(); + } + + /******************************************************************************/ + + var html = '
' + + 'Results:
' + + '' + + '
' + + 'Expected result: Status box will update with type of connection using two different methods. Both values must match.' + + ' The result will be unknown, ethernet, wifi, 2g, 3g, 4g, none, or cellular. Make sure it matches what the device is connected to.' + + '

'; + + document.addEventListener("online", onEvent, false); + document.addEventListener("offline", onEvent, false); + contentEl.innerHTML = html; + + createActionButton('Show Network Connection', function () { + printNetwork(); + }, 'connection'); + + createActionButton('Clear Log', function () { + document.getElementById('results').innerHTML = ''; + }, 'actions'); +}; diff --git a/plugins/cordova-plugin-network-information/www/Connection.js b/plugins/cordova-plugin-network-information/www/Connection.js new file mode 100644 index 0000000..f20a485 --- /dev/null +++ b/plugins/cordova-plugin-network-information/www/Connection.js @@ -0,0 +1,34 @@ +/* + * + * 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. + * +*/ + +/** + * Network status + */ +module.exports = { + UNKNOWN: "unknown", + ETHERNET: "ethernet", + WIFI: "wifi", + CELL_2G: "2g", + CELL_3G: "3g", + CELL_4G: "4g", + CELL:"cellular", + NONE: "none" +}; diff --git a/plugins/cordova-plugin-network-information/www/network.js b/plugins/cordova-plugin-network-information/www/network.js new file mode 100644 index 0000000..ac792d8 --- /dev/null +++ b/plugins/cordova-plugin-network-information/www/network.js @@ -0,0 +1,91 @@ +/* + * 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. + * +*/ + +var exec = require('cordova/exec'), + cordova = require('cordova'), + channel = require('cordova/channel'), + utils = require('cordova/utils'); + +// Link the onLine property with the Cordova-supplied network info. +// This works because we clobber the navigator object with our own +// object in bootstrap.js. +// Browser platform do not need to define this property, because +// it is already supported by modern browsers +if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') { + utils.defineGetter(navigator, 'onLine', function() { + return this.connection.type != 'none'; + }); +} + +function NetworkConnection() { + this.type = 'unknown'; +} + +/** + * Get connection info + * + * @param {Function} successCallback The function to call when the Connection data is available + * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL) + */ +NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []); +}; + +var me = new NetworkConnection(); +var timerId = null; +var timeout = 500; + +channel.createSticky('onCordovaConnectionReady'); +channel.waitForInitialization('onCordovaConnectionReady'); + +channel.onCordovaReady.subscribe(function() { + me.getInfo(function(info) { + me.type = info; + if (info === "none") { + // set a timer if still offline at the end of timer send the offline event + timerId = setTimeout(function(){ + cordova.fireDocumentEvent("offline"); + timerId = null; + }, timeout); + } else { + // If there is a current offline event pending clear it + if (timerId !== null) { + clearTimeout(timerId); + timerId = null; + } + cordova.fireDocumentEvent("online"); + } + + // should only fire this once + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + }, + function (e) { + // If we can't get the network info we should still tell Cordova + // to fire the deviceready event. + if (channel.onCordovaConnectionReady.state !== 2) { + channel.onCordovaConnectionReady.fire(); + } + console.log("Error initializing Network Connection: " + e); + }); +}); + +module.exports = me; diff --git a/plugins/cordova-plugin-splashscreen/README.md b/plugins/cordova-plugin-splashscreen/README.md index 113a1b2..ebdf237 100644 --- a/plugins/cordova-plugin-splashscreen/README.md +++ b/plugins/cordova-plugin-splashscreen/README.md @@ -17,11 +17,13 @@ # under the License. --> +[![Build Status](https://travis-ci.org/apache/cordova-plugin-splashscreen.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-splashscreen) + # cordova-plugin-splashscreen -This plugin displays and hides a splash screen during application launch. +This plugin is required to work with splash screens. This plugin displays and hides a splash screen during application launch. -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Splashscreen%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) +Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cordova issue tracker]. ## Installation @@ -42,34 +44,81 @@ This plugin displays and hides a splash screen during application launch. - Windows - Browser +## Example Configuration +In the top-level `config.xml` file (not the one in `platforms`), add configuration elements like those specified here. + +Please notice that the value of the "src" attribute is relative to the project directory and not to the www directory. You can name the source image whatever you like. The internal name in the app is determined by Cordova. + +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + ## Preferences #### config.xml -- __SplashScreen__ (string). The resource name which is used for the displaying splash screen. Different platforms use values for this. - - +- __AutoHideSplashScreen__ (boolean, default to `true`). Indicates whether to hide splash screen automatically or not. Splash screen hidden after amount of time specified in the `SplashScreenDelay` preference. -- __AutoHideSplashScreen__ (boolean, default to `true`). Indicates wherether hide splash screen automatically or not. Splash screen hidden after amount of time specified in the `SplashScreenDelay` preference. - - +```xml + +``` - __SplashScreenDelay__ (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen. - - +```xml + +``` ### Android Quirks In your `config.xml`, you need to add the following preferences: - - - - +```xml + + + +``` -Where foo is the name of the splashscreen file, preferably a 9 patch file. Make sure to add your splashcreen files to your res/xml directory under the appropriate folders. The second parameter represents how long the splashscreen will appear in milliseconds. It defaults to 3000 ms. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) -for more information. +The first parameter represents how long the splashscreen will appear in milliseconds. It defaults to 3000 ms. "SplashMaintainAspectRatio" preference is optional. If set to true, splash screen drawable is not stretched to fit screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios. @@ -81,28 +130,37 @@ The plugin reloads splash drawable whenever orientation changes, so you can spec You can use the following preferences in your `config.xml`: - - - - - - - - +```xml + + + + + + + + +``` +__Note__: `SplashScreen` value should be absolute in order to work in a sub-page. The `SplashScreen` value is used only for the browser platform. The value will be ignored for other platforms. ### Android and iOS Quirks +- In iOS, the splashscreen images are called launch images. These images are mandatory on iOS. + - `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to prevent the splash screen from fading in and out when its display state changes. - +```xml + +``` - `FadeSplashScreenDuration` (float, defaults to `3000`): Specifies the number of milliseconds for the splash screen fade effect to execute. - +```xml + +``` Note also that this value used to be seconds, and not milliseconds, so values less than 30 will still be treated as seconds. ( Consider this a deprecated patch that will disapear in some future version. ) @@ -123,12 +181,12 @@ window.setTimeout(function () { }, splashDuration - fadeDuration); ``` -### iOS Quirks - - `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false` to hide the splash-screen spinner. - +```xml + +``` ## Methods @@ -139,7 +197,9 @@ window.setTimeout(function () { Dismiss the splash screen. - navigator.splashscreen.hide(); +```js +navigator.splashscreen.hide(); +``` ### BlackBerry 10, WP8, iOS Quirk @@ -148,16 +208,19 @@ The `config.xml` file's `AutoHideSplashScreen` setting must be `false`. To delay hiding the splash screen for two seconds, add a timer such as the following in the `deviceready` event handler: - setTimeout(function() { - navigator.splashscreen.hide(); - }, 2000); +```js +setTimeout(function() { + navigator.splashscreen.hide(); +}, 2000); +``` ## splashscreen.show Displays the splash screen. - navigator.splashscreen.show(); - +```js +navigator.splashscreen.show(); +``` Your application cannot call `navigator.splashscreen.show()` until the app has started and the `deviceready` event has fired. But since typically the splash @@ -165,7 +228,7 @@ screen is meant to be visible before your app has started, that would seem to defeat the purpose of the splash screen. Providing some configuration in `config.xml` will automatically `show` the splash screen immediately after your app launch and before it has fully started and received the `deviceready` -event. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) -for more information on doing this configuration. For this reason, it is -unlikely you need to call `navigator.splashscreen.show()` to make the splash +event. For this reason, it is unlikely you need to call `navigator.splashscreen.show()` to make the splash screen visible for app startup. + +[Apache Cordova issue tracker]: https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Splashscreen%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC diff --git a/plugins/cordova-plugin-splashscreen/RELEASENOTES.md b/plugins/cordova-plugin-splashscreen/RELEASENOTES.md index 3b9fe2e..c746250 100644 --- a/plugins/cordova-plugin-splashscreen/RELEASENOTES.md +++ b/plugins/cordova-plugin-splashscreen/RELEASENOTES.md @@ -20,6 +20,20 @@ --> # Release Notes +### 3.2.1 (Mar 09, 2016) +* [CB-10764](https://issues.apache.org/jira/browse/CB-10764) Remove emoji in cordova-plugin-splashscreen +* [CB-10650](https://issues.apache.org/jira/browse/CB-10650) Non-index content.src causes Splashscreen to be not displayed on **Browser** +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins +* [CB-10606](https://issues.apache.org/jira/browse/CB-10606) fix deprecation warning for interfaceOrientation on **iOS** +* chore: edit package.json license to match SPDX id + +### 3.2.0 (Feb 09, 2016) +* [CB-10422](https://issues.apache.org/jira/browse/CB-10422) Splashscreen displays black screen with no image on Android +* [CB-10412](https://issues.apache.org/jira/browse/CB-10412) AutoHideSplashScreen "false" isn't taken in account on iOS +* [CB-9516](https://issues.apache.org/jira/browse/CB-9516) Android SplashScreen - Spinner Does Not Display +* [CB-9094](https://issues.apache.org/jira/browse/CB-9094) Smarter autohide logic on Android +* [CB-8396](https://issues.apache.org/jira/browse/CB-8396) Add AutoHideSplashScreen logic to Android's Splashscreen + ### 3.1.0 (Jan 15, 2016) * CB-9538 Implementing `FadeSplashScreen` feature for **Android** * CB-9240 Cordova splash screen plugin **iPad** landscape mode issue diff --git a/plugins/cordova-plugin-splashscreen/package.json b/plugins/cordova-plugin-splashscreen/package.json index ef04135..945f45a 100644 --- a/plugins/cordova-plugin-splashscreen/package.json +++ b/plugins/cordova-plugin-splashscreen/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-splashscreen", - "version": "3.1.0", + "version": "3.2.2-dev", "description": "Cordova Splashscreen Plugin", "cordova": { "id": "cordova-plugin-splashscreen", @@ -34,6 +34,10 @@ "cordova-windows", "cordova-tizen" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "engines": [ { "name": "cordova-android", @@ -41,5 +45,8 @@ } ], "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/plugins/cordova-plugin-splashscreen/plugin.xml b/plugins/cordova-plugin-splashscreen/plugin.xml index 3994803..574289c 100644 --- a/plugins/cordova-plugin-splashscreen/plugin.xml +++ b/plugins/cordova-plugin-splashscreen/plugin.xml @@ -20,7 +20,7 @@ + version="3.2.2-dev"> Splashscreen Cordova Splashscreen Plugin Apache 2.0 diff --git a/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java b/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java index 7f91147..d9ac66a 100644 --- a/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java +++ b/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java @@ -25,8 +25,10 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.Configuration; import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.os.Handler; import android.view.Display; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; @@ -35,6 +37,8 @@ import android.view.animation.AlphaAnimation; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; @@ -51,6 +55,7 @@ public class SplashScreen extends CordovaPlugin { private static Dialog splashDialog; private static ProgressDialog spinnerDialog; private static boolean firstShow = true; + private static boolean lastHideAfterDelay; // https://issues.apache.org/jira/browse/CB-9094 /** * Displays the splash drawable. @@ -73,7 +78,7 @@ public class SplashScreen extends CordovaPlugin { @Override protected void pluginInitialize() { - if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) { + if (HAS_BUILT_IN_SPLASH_SCREEN) { return; } // Make WebView invisible while loading URL @@ -93,12 +98,14 @@ public class SplashScreen extends CordovaPlugin { // Save initial orientation. orientation = cordova.getActivity().getResources().getConfiguration().orientation; + if (firstShow) { + boolean autoHide = preferences.getBoolean("AutoHideSplashScreen", true); + showSplashScreen(autoHide); + } + if (preferences.getBoolean("SplashShowOnlyFirstTime", true)) { firstShow = false; } - - loadSpinner(); - showSplashScreen(true); } /** @@ -109,7 +116,7 @@ public class SplashScreen extends CordovaPlugin { } private int getFadeDuration () { - int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) == true ? + int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ? preferences.getInteger("FadeSplashScreenDuration", DEFAULT_SPLASHSCREEN_DURATION) : 0; if (fadeSplashScreenDuration < 30) { @@ -127,7 +134,7 @@ public class SplashScreen extends CordovaPlugin { return; } // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); + this.removeSplashScreen(true); } @Override @@ -136,7 +143,7 @@ public class SplashScreen extends CordovaPlugin { return; } // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); + this.removeSplashScreen(true); // If we set this to true onDestroy, we lose track when we go from page to page! //firstShow = true; } @@ -155,16 +162,6 @@ public class SplashScreen extends CordovaPlugin { webView.postMessage("splashscreen", "show"); } }); - } else if (action.equals("spinnerStart")) { - if (!HAS_BUILT_IN_SPLASH_SCREEN) { - final String title = args.getString(0); - final String message = args.getString(1); - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - spinnerStart(title, message); - } - }); - } } else { return false; } @@ -180,17 +177,16 @@ public class SplashScreen extends CordovaPlugin { } if ("splashscreen".equals(id)) { if ("hide".equals(data.toString())) { - this.removeSplashScreen(); + this.removeSplashScreen(false); } else { this.showSplashScreen(false); } } else if ("spinner".equals(id)) { if ("stop".equals(data.toString())) { - this.spinnerStop(); getView().setVisibility(View.VISIBLE); } } else if ("onReceivedError".equals(id)) { - spinnerStop(); + this.spinnerStop(); } return null; } @@ -210,12 +206,13 @@ public class SplashScreen extends CordovaPlugin { } } - private void removeSplashScreen() { + private void removeSplashScreen(final boolean forceHideImmediately) { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { if (splashDialog != null && splashDialog.isShowing()) { final int fadeSplashScreenDuration = getFadeDuration(); - if (fadeSplashScreenDuration > 0) { + // CB-10692 If the plugin is being paused/destroyed, skip the fading and hide it immediately + if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) { AlphaAnimation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.setDuration(fadeSplashScreenDuration); @@ -226,6 +223,7 @@ public class SplashScreen extends CordovaPlugin { fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { + spinnerStop(); } @Override @@ -242,6 +240,7 @@ public class SplashScreen extends CordovaPlugin { } }); } else { + spinnerStop(); splashDialog.dismiss(); splashDialog = null; splashImageView = null; @@ -260,13 +259,15 @@ public class SplashScreen extends CordovaPlugin { final int drawableId = preferences.getInteger("SplashDrawableId", 0); final int fadeSplashScreenDuration = getFadeDuration(); - final int effectiveSplashDuration = splashscreenTime - fadeSplashScreenDuration; + final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration); + + lastHideAfterDelay = hideAfterDelay; // If the splash dialog is showing don't try to show it again if (splashDialog != null && splashDialog.isShowing()) { return; } - if (drawableId == 0 || (effectiveSplashDuration <= 0 && hideAfterDelay)) { + if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { return; } @@ -309,12 +310,18 @@ public class SplashScreen extends CordovaPlugin { splashDialog.setCancelable(false); splashDialog.show(); + if (preferences.getBoolean("ShowSplashScreenSpinner", true)) { + spinnerStart(); + } + // Set Runnable to remove splash screen just in case if (hideAfterDelay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { - removeSplashScreen(); + if (lastHideAfterDelay) { + removeSplashScreen(false); + } } }, effectiveSplashDuration); } @@ -322,47 +329,38 @@ public class SplashScreen extends CordovaPlugin { }); } - /* - * Load the spinner - */ - private void loadSpinner() { - // If loadingDialog property, then show the App loading dialog for first page of app - String loading = null; - if (webView.canGoBack()) { - loading = preferences.getString("LoadingDialog", null); - } - else { - loading = preferences.getString("LoadingPageDialog", null); - } - if (loading != null) { - String title = ""; - String message = "Loading Application..."; - - if (loading.length() > 0) { - int comma = loading.indexOf(','); - if (comma > 0) { - title = loading.substring(0, comma); - message = loading.substring(comma + 1); - } - else { - title = ""; - message = loading; - } - } - spinnerStart(title, message); - } - } - - private void spinnerStart(final String title, final String message) { + // Show only spinner in the center of the screen + private void spinnerStart() { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { spinnerStop(); - spinnerDialog = ProgressDialog.show(webView.getContext(), title, message, true, true, - new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { - spinnerDialog = null; - } - }); + + spinnerDialog = new ProgressDialog(webView.getContext()); + spinnerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { + public void onCancel(DialogInterface dialog) { + spinnerDialog = null; + } + }); + + spinnerDialog.setCancelable(false); + spinnerDialog.setIndeterminate(true); + + RelativeLayout centeredLayout = new RelativeLayout(cordova.getActivity()); + centeredLayout.setGravity(Gravity.CENTER); + centeredLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + + ProgressBar progressBar = new ProgressBar(webView.getContext()); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + progressBar.setLayoutParams(layoutParams); + + centeredLayout.addView(progressBar); + + spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + spinnerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + + spinnerDialog.show(); + spinnerDialog.setContentView(centeredLayout); } }); } diff --git a/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js b/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js index bd7e48c..c682506 100644 --- a/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js +++ b/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js @@ -14,6 +14,8 @@ * limitations under the License. */ +/* global PluginResult */ + module.exports = { show: function (success, fail, args, env) { var result = new PluginResult(args, env); diff --git a/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js b/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js index d19f8c8..6cf9309 100644 --- a/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js +++ b/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js @@ -18,17 +18,18 @@ * under the License. * */ + // Default parameter values including image size can be changed in `config.xml` var splashImageWidth = 170; var splashImageHeight = 200; var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight }; -var splash = null; // var localSplash; // the image to display var localSplashImage; var bgColor = "#464646"; -var imageSrc = 'img/logo.png'; +var imageSrc = '/img/logo.png'; var splashScreenDelay = 3000; // in milliseconds var showSplashScreen = true; // show splashcreen by default +var cordova = require('cordova'); var configHelper = cordova.require('cordova/confighelper'); function updateImageLocation() { @@ -103,7 +104,6 @@ function readPreferencesFromCfg(cfg) { } catch(e) { var msg = '[Browser][SplashScreen] Error occured on loading preferences from config.xml: ' + JSON.stringify(e); console.error(msg); - error(msg); } } diff --git a/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h b/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h index 4802a30..ec5d602 100644 --- a/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h +++ b/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h @@ -36,6 +36,7 @@ typedef struct { UIImageView* _imageView; NSString* _curImageName; BOOL _visible; + BOOL _destroyed; } - (void)show:(CDVInvokedUrlCommand*)command; diff --git a/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m b/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m index 3e195b9..1d7b955 100644 --- a/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m +++ b/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m @@ -41,7 +41,7 @@ - (void)hide:(CDVInvokedUrlCommand*)command { - [self setVisible:NO]; + [self setVisible:NO andForce:YES]; } - (void)pageDidLoad @@ -120,6 +120,7 @@ [parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil]; [self updateImage]; + _destroyed = NO; } - (void)hideViews @@ -130,6 +131,7 @@ - (void)destroyViews { + _destroyed = YES; [(CDVViewController *)self.viewController setEnabledAutorotation:[(CDVViewController *)self.viewController shouldAutorotateDefaultValue]]; [_imageView removeFromSuperview]; @@ -327,7 +329,7 @@ CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero; CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size; - UIInterfaceOrientation orientation = self.viewController.interfaceOrientation; + UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; CGAffineTransform imgTransform = CGAffineTransformIdentity; /* If and only if an iPhone application is landscape-only as per @@ -376,7 +378,12 @@ - (void)setVisible:(BOOL)visible { - if (visible != _visible) + [self setVisible:visible andForce:NO]; +} + +- (void)setVisible:(BOOL)visible andForce:(BOOL)force +{ + if (visible != _visible || force) { _visible = visible; @@ -388,6 +395,19 @@ id splashDurationString = [self.commandDelegate.settings objectForKey: [@"SplashScreenDelay" lowercaseString]]; float splashDuration = splashDurationString == nil ? kSplashScreenDurationDefault : [splashDurationString floatValue]; + id autoHideSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"AutoHideSplashScreen" lowercaseString]]; + BOOL autoHideSplashScreen = true; + + if (autoHideSplashScreenValue != nil) { + autoHideSplashScreen = [autoHideSplashScreenValue boolValue]; + } + + if (!autoHideSplashScreen) { + // CB-10412 SplashScreenDelay does not make sense if the splashscreen is hidden manually + splashDuration = 0; + } + + if (fadeSplashScreenValue == nil) { fadeSplashScreenValue = @"true"; @@ -418,21 +438,34 @@ else { __weak __typeof(self) weakSelf = self; - float effectiveSplashDuration = (splashDuration - fadeDuration) / 1000; + float effectiveSplashDuration; + + // [CB-10562] AutoHideSplashScreen may be "true" but we should still be able to hide the splashscreen manually. + if (!autoHideSplashScreen || force) { + effectiveSplashDuration = (fadeDuration) / 1000; + } else { + effectiveSplashDuration = (splashDuration - fadeDuration) / 1000; + } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t) effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(), CFBridgingRelease(CFBridgingRetain(^(void) { - [UIView transitionWithView:self.viewController.view - duration:(fadeDuration / 1000) - options:UIViewAnimationOptionTransitionNone - animations:^(void) { - [weakSelf hideViews]; - } - completion:^(BOOL finished) { - if (finished) { - [weakSelf destroyViews]; - // TODO: It might also be nice to have a js event happen here -jm - } - } + if (!_destroyed) { + [UIView transitionWithView:self.viewController.view + duration:(fadeDuration / 1000) + options:UIViewAnimationOptionTransitionNone + animations:^(void) { + [weakSelf hideViews]; + } + completion:^(BOOL finished) { + // Always destroy views, otherwise you could have an + // invisible splashscreen that is overlayed over your active views + // which causes that no touch events are passed + if (!_destroyed) { + [weakSelf destroyViews]; + // TODO: It might also be nice to have a js event happen here -jm + } + } ]; + } }))); } } diff --git a/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js b/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js index fbd9f35..06c0697 100644 --- a/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js +++ b/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js @@ -21,7 +21,7 @@ ( function() { -win = null; +var win = null; module.exports = { show: function() { diff --git a/plugins/cordova-plugin-splashscreen/tests/ios/CDVSplashScreenTest/.gitignore b/plugins/cordova-plugin-splashscreen/tests/ios/CDVSplashScreenTest/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/plugins/cordova-plugin-splashscreen/tests/ios/CDVSplashScreenTest/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/plugins/cordova-plugin-splashscreen/tests/ios/package.json b/plugins/cordova-plugin-splashscreen/tests/ios/package.json index d8b2385..67f0edc 100644 --- a/plugins/cordova-plugin-splashscreen/tests/ios/package.json +++ b/plugins/cordova-plugin-splashscreen/tests/ios/package.json @@ -5,9 +5,9 @@ "author": "Apache Software Foundation", "license": "Apache Version 2.0", "dependencies": { - "cordova-ios": "^3.6.0" + "cordova-ios": "*" }, "scripts": { - "test": "xcodebuild test -workspace CDVSplashScreenTest.xcworkspace -scheme CDVSplashScreenLibTests -destination 'platform=iOS Simulator,name=iPhone 5' CONFIGURATION_BUILD_DIR='/tmp'" - } -} \ No newline at end of file + "test": "xcodebuild test -workspace CDVSplashScreenTest.xcworkspace -scheme CDVSplashScreenLibTests -destination 'platform=iOS Simulator,name=iPhone 5' CONFIGURATION_BUILD_DIR='/tmp' HEADER_SEARCH_PATHS='$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include'" + } +} diff --git a/plugins/cordova-plugin-splashscreen/tests/plugin.xml b/plugins/cordova-plugin-splashscreen/tests/plugin.xml index 487073b..162620e 100644 --- a/plugins/cordova-plugin-splashscreen/tests/plugin.xml +++ b/plugins/cordova-plugin-splashscreen/tests/plugin.xml @@ -20,7 +20,7 @@ + version="3.2.2-dev"> Cordova Splashscreen Plugin Tests Apache 2.0 diff --git a/plugins/cordova-plugin-splashscreen/tests/tests.js b/plugins/cordova-plugin-splashscreen/tests/tests.js index 8c4d22b..7b55a81 100644 --- a/plugins/cordova-plugin-splashscreen/tests/tests.js +++ b/plugins/cordova-plugin-splashscreen/tests/tests.js @@ -19,18 +19,20 @@ * */ -exports.defineAutoTest = function () { +/* jshint jasmine: true */ + +exports.defineAutoTests = function () { describe('Splashscreen (cordova)', function () { it("splashscreen.spec.1 should exist", function () { expect(navigator.splashscreen).toBeDefined(); }); - it("splashscreen.spec.2 exec method should exist", function () { + it("splashscreen.spec.2 show method should exist", function () { expect(navigator.splashscreen.show).toBeDefined(); expect(typeof navigator.splashscreen.show).toBe('function'); }); - it("splashscreen.spec.3 exec method should exist", function () { + it("splashscreen.spec.3 hide method should exist", function () { expect(navigator.splashscreen.hide).toBeDefined(); expect(typeof navigator.splashscreen.hide).toBe('function'); }); diff --git a/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js b/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js index 271a14c..1c54883 100644 --- a/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js +++ b/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js @@ -20,17 +20,16 @@ */ /*jslint sloppy:true */ -/*global Windows:true, require, module, window, document, WinJS */ +/*global WinJS */ -var cordova = require('cordova'), - channel = require('cordova/channel'); +var cordova = require('cordova'); var isPhone = (cordova.platformId == "windows") && WinJS.Utilities.isPhone; var isHosted = window.location.protocol.indexOf('http') === 0; -var localSplash = null; +var localSplash = null, localSplashImage = null; var bgColor = "#464646"; // default backgrond color; TDOO - read it from .appxmanifest -var splashImageSrc = (isHosted ? "ms-appx-web" : "ms-appx") + ":///images/" - + (isPhone ? "splashscreenphone.png" : "splashscreen.png"); +var splashImageSrc = (isHosted ? "ms-appx-web" : "ms-appx") + ":///images/" + + (isPhone ? "splashscreenphone.png" : "splashscreen.png"); var SplashScreen = { setBGColor: function (cssBGColor) { diff --git a/plugins/fetch.json b/plugins/fetch.json index 9fe494e..bb76783 100644 --- a/plugins/fetch.json +++ b/plugins/fetch.json @@ -1,86 +1,114 @@ { - "cordova-plugin-geolocation": { + "cordova-plugin-compat": { + "source": { + "type": "registry", + "id": "cordova-plugin-compat" + }, + "is_top_level": false, + "variables": {} + }, + "cordova-plugin-whitelist": { "source": { "type": "registry", - "id": "cordova-plugin-geolocation@~2.1.0" + "id": "cordova-plugin-whitelist" }, "is_top_level": true, "variables": {} }, - "cordova-plugin-file": { + "cordova-plugin-console": { "source": { "type": "git", - "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git", "subdir": "." }, "is_top_level": true, "variables": {} }, - "cordova-plugin-media": { + "cordova-plugin-device": { "source": { "type": "git", - "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git", "subdir": "." }, "is_top_level": true, "variables": {} }, - "cordova-plugin-media-capture": { + "cordova-plugin-camera": { "source": { "type": "git", - "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git", "subdir": "." }, "is_top_level": true, "variables": {} }, - "cordova-plugin-file-transfer": { + "cordova-plugin-splashscreen": { "source": { "type": "git", - "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git", "subdir": "." }, "is_top_level": true, "variables": {} }, - "cordova-plugin-device-orientation": { + "cordova-plugin-network-information": { "source": { "type": "git", - "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git", "subdir": "." }, "is_top_level": true, "variables": {} }, - "phonegap-plugin-barcodescanner": { + "cordova-plugin-dialogs": { "source": { "type": "git", - "url": "https://github.com/phonegap/phonegap-plugin-barcodescanner.git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git", "subdir": "." }, "is_top_level": true, "variables": {} }, - "cordova-plugin-dialogs": { + "cordova-plugin-media": { "source": { - "type": "registry", - "id": "cordova-plugin-dialogs@~1.2.0" + "type": "git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git", + "subdir": "." }, "is_top_level": true, "variables": {} }, - "cordova-plugin-splashscreen": { + "cordova-plugin-file": { "source": { "type": "registry", - "id": "cordova-plugin-splashscreen@~3.1.0" + "id": "cordova-plugin-file" + }, + "is_top_level": false, + "variables": {} + }, + "cordova-plugin-media-capture": { + "source": { + "type": "git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git", + "subdir": "." }, "is_top_level": true, "variables": {} }, - "cordova-plugin-whitelist": { + "cordova-plugin-geolocation": { "source": { - "type": "registry", - "id": "cordova-plugin-whitelist@~1.2.1" + "type": "git", + "url": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git", + "subdir": "." + }, + "is_top_level": true, + "variables": {} + }, + "phonegap-plugin-barcodescanner": { + "source": { + "type": "git", + "url": "https://github.com/phonegap/phonegap-plugin-barcodescanner.git", + "subdir": "." }, "is_top_level": true, "variables": {} diff --git a/plugins/phonegap-plugin-barcodescanner/plugin.xml b/plugins/phonegap-plugin-barcodescanner/plugin.xml index c7b552f..96e59ec 100644 --- a/plugins/phonegap-plugin-barcodescanner/plugin.xml +++ b/plugins/phonegap-plugin-barcodescanner/plugin.xml @@ -96,6 +96,8 @@ + + diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/.gitignore b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/.gitignore index 403acf4..19ed728 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/.gitignore +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/.gitignore @@ -1 +1 @@ -/libs +/libs diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/FakeR.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/FakeR.java index 31b5f0d..b350868 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/FakeR.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/FakeR.java @@ -1,35 +1,35 @@ -package com.google.zxing; - -import android.app.Activity; -import android.content.Context; - -/** - * R replacement for PhoneGap Build. - * - * ([^.\w])R\.(\w+)\.(\w+) - * $1fakeR("$2", "$3") - * - * @author Maciej Nux Jaros - */ -public class FakeR { - private Context context; - private String packageName; - - public FakeR(Activity activity) { - context = activity.getApplicationContext(); - packageName = context.getPackageName(); - } - - public FakeR(Context context) { - this.context = context; - packageName = context.getPackageName(); - } - - public int getId(String group, String key) { - return context.getResources().getIdentifier(key, group, packageName); - } - - public static int getId(Context context, String group, String key) { - return context.getResources().getIdentifier(key, group, context.getPackageName()); - } -} +package com.google.zxing; + +import android.app.Activity; +import android.content.Context; + +/** + * R replacement for PhoneGap Build. + * + * ([^.\w])R\.(\w+)\.(\w+) + * $1fakeR("$2", "$3") + * + * @author Maciej Nux Jaros + */ +public class FakeR { + private Context context; + private String packageName; + + public FakeR(Activity activity) { + context = activity.getApplicationContext(); + packageName = context.getPackageName(); + } + + public FakeR(Context context) { + this.context = context; + packageName = context.getPackageName(); + } + + public int getId(String group, String key) { + return context.getResources().getIdentifier(key, group, packageName); + } + + public static int getId(Context context, String group, String key) { + return context.getResources().getIdentifier(key, group, context.getPackageName()); + } +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/AztecDetectorResult.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/AztecDetectorResult.java index f262e0e..ee27af8 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/AztecDetectorResult.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/AztecDetectorResult.java @@ -1,52 +1,52 @@ -/* - * Copyright 2010 ZXing authors - * - * 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. - */ - -package com.google.zxing.aztec; - -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DetectorResult; - -public final class AztecDetectorResult extends DetectorResult { - - private final boolean compact; - private final int nbDatablocks; - private final int nbLayers; - - public AztecDetectorResult(BitMatrix bits, - ResultPoint[] points, - boolean compact, - int nbDatablocks, - int nbLayers) { - super(bits, points); - this.compact = compact; - this.nbDatablocks = nbDatablocks; - this.nbLayers = nbLayers; - } - - public int getNbLayers() { - return nbLayers; - } - - public int getNbDatablocks() { - return nbDatablocks; - } - - public boolean isCompact() { - return compact; - } - -} +/* + * Copyright 2010 ZXing authors + * + * 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. + */ + +package com.google.zxing.aztec; + +import com.google.zxing.ResultPoint; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.DetectorResult; + +public final class AztecDetectorResult extends DetectorResult { + + private final boolean compact; + private final int nbDatablocks; + private final int nbLayers; + + public AztecDetectorResult(BitMatrix bits, + ResultPoint[] points, + boolean compact, + int nbDatablocks, + int nbLayers) { + super(bits, points); + this.compact = compact; + this.nbDatablocks = nbDatablocks; + this.nbLayers = nbLayers; + } + + public int getNbLayers() { + return nbLayers; + } + + public int getNbDatablocks() { + return nbDatablocks; + } + + public boolean isCompact() { + return compact; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/decoder/Decoder.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/decoder/Decoder.java index 9404c2a..5f5667e 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/decoder/Decoder.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/aztec/decoder/Decoder.java @@ -1,472 +1,472 @@ -/* - * Copyright 2010 ZXing authors - * - * 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. - */ - -package com.google.zxing.aztec.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.aztec.AztecDetectorResult; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -/** - *

The main class which implements Aztec Code decoding -- as opposed to locating and extracting - * the Aztec Code from an image.

- * - * @author David Olivier - */ -public final class Decoder { - - private enum Table { - UPPER, - LOWER, - MIXED, - DIGIT, - PUNCT, - BINARY - } - - private static final int[] NB_BITS_COMPACT = { - 0, 104, 240, 408, 608 - }; - - private static final int[] NB_BITS = { - 0, 128, 288, 480, 704, 960, 1248, 1568, 1920, 2304, 2720, 3168, 3648, 4160, 4704, 5280, 5888, 6528, - 7200, 7904, 8640, 9408, 10208, 11040, 11904, 12800, 13728, 14688, 15680, 16704, 17760, 18848, 19968 - }; - - private static final int[] NB_DATABLOCK_COMPACT = { - 0, 17, 40, 51, 76 - }; - - private static final int[] NB_DATABLOCK = { - 0, 21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790, 864, - 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664 - }; - - private static final String[] UPPER_TABLE = { - "CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS" - }; - - private static final String[] LOWER_TABLE = { - "CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", - "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS" - }; - - private static final String[] MIXED_TABLE = { - "CTRL_PS", " ", "\1", "\2", "\3", "\4", "\5", "\6", "\7", "\b", "\t", "\n", - "\13", "\f", "\r", "\33", "\34", "\35", "\36", "\37", "@", "\\", "^", "_", - "`", "|", "~", "\177", "CTRL_LL", "CTRL_UL", "CTRL_PL", "CTRL_BS" - }; - - private static final String[] PUNCT_TABLE = { - "", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", - "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL" - }; - - private static final String[] DIGIT_TABLE = { - "CTRL_PS", " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".", "CTRL_UL", "CTRL_US" - }; - - private int numCodewords; - private int codewordSize; - private AztecDetectorResult ddata; - private int invertedBitCount; - - public DecoderResult decode(AztecDetectorResult detectorResult) throws FormatException { - ddata = detectorResult; - BitMatrix matrix = detectorResult.getBits(); - - if (!ddata.isCompact()) { - matrix = removeDashedLines(ddata.getBits()); - } - - boolean[] rawbits = extractBits(matrix); - - boolean[] correctedBits = correctBits(rawbits); - - String result = getEncodedData(correctedBits); - - return new DecoderResult(null, result, null, null); - } - - /** - * Gets the string encoded in the aztec code bits - * - * @return the decoded string - * @throws FormatException if the input is not valid - */ - private String getEncodedData(boolean[] correctedBits) throws FormatException { - - int endIndex = codewordSize * ddata.getNbDatablocks() - invertedBitCount; - if (endIndex > correctedBits.length) { - throw FormatException.getFormatInstance(); - } - - Table lastTable = Table.UPPER; - Table table = Table.UPPER; - int startIndex = 0; - StringBuilder result = new StringBuilder(20); - boolean end = false; - boolean shift = false; - boolean switchShift = false; - boolean binaryShift = false; - - while (!end) { - - if (shift) { - // the table is for the next character only - switchShift = true; - } else { - // save the current table in case next one is a shift - lastTable = table; - } - - int code; - if (binaryShift) { - if (endIndex - startIndex < 5) { - break; - } - - int length = readCode(correctedBits, startIndex, 5); - startIndex += 5; - if (length == 0) { - if (endIndex - startIndex < 11) { - break; - } - - length = readCode(correctedBits, startIndex, 11) + 31; - startIndex += 11; - } - for (int charCount = 0; charCount < length; charCount++) { - if (endIndex - startIndex < 8) { - end = true; - break; - } - - code = readCode(correctedBits, startIndex, 8); - result.append((char) code); - startIndex += 8; - } - binaryShift = false; - } else { - if (table == Table.BINARY) { - if (endIndex - startIndex < 8) { - break; - } - code = readCode(correctedBits, startIndex, 8); - startIndex += 8; - - result.append((char) code); - - } else { - int size = 5; - - if (table == Table.DIGIT) { - size = 4; - } - - if (endIndex - startIndex < size) { - break; - } - - code = readCode(correctedBits, startIndex, size); - startIndex += size; - - String str = getCharacter(table, code); - if (str.startsWith("CTRL_")) { - // Table changes - table = getTable(str.charAt(5)); - - if (str.charAt(6) == 'S') { - shift = true; - if (str.charAt(5) == 'B') { - binaryShift = true; - } - } - } else { - result.append(str); - } - - - } - } - - if (switchShift) { - table = lastTable; - shift = false; - switchShift = false; - } - - } - return result.toString(); - } - - - /** - * gets the table corresponding to the char passed - */ - private static Table getTable(char t) { - switch (t) { - case 'L': - return Table.LOWER; - case 'P': - return Table.PUNCT; - case 'M': - return Table.MIXED; - case 'D': - return Table.DIGIT; - case 'B': - return Table.BINARY; - case 'U': - default: - return Table.UPPER; - } - } - - /** - * Gets the character (or string) corresponding to the passed code in the given table - * - * @param table the table used - * @param code the code of the character - */ - private static String getCharacter(Table table, int code) { - switch (table) { - case UPPER: - return UPPER_TABLE[code]; - case LOWER: - return LOWER_TABLE[code]; - case MIXED: - return MIXED_TABLE[code]; - case PUNCT: - return PUNCT_TABLE[code]; - case DIGIT: - return DIGIT_TABLE[code]; - default: - return ""; - } - } - - /** - *

Performs RS error correction on an array of bits.

- * - * @return the corrected array - * @throws FormatException if the input contains too many errors - */ - private boolean[] correctBits(boolean[] rawbits) throws FormatException { - GenericGF gf; - - if (ddata.getNbLayers() <= 2) { - codewordSize = 6; - gf = GenericGF.AZTEC_DATA_6; - } else if (ddata.getNbLayers() <= 8) { - codewordSize = 8; - gf = GenericGF.AZTEC_DATA_8; - } else if (ddata.getNbLayers() <= 22) { - codewordSize = 10; - gf = GenericGF.AZTEC_DATA_10; - } else { - codewordSize = 12; - gf = GenericGF.AZTEC_DATA_12; - } - - int numDataCodewords = ddata.getNbDatablocks(); - int numECCodewords; - int offset; - - if (ddata.isCompact()) { - offset = NB_BITS_COMPACT[ddata.getNbLayers()] - numCodewords * codewordSize; - numECCodewords = NB_DATABLOCK_COMPACT[ddata.getNbLayers()] - numDataCodewords; - } else { - offset = NB_BITS[ddata.getNbLayers()] - numCodewords * codewordSize; - numECCodewords = NB_DATABLOCK[ddata.getNbLayers()] - numDataCodewords; - } - - int[] dataWords = new int[numCodewords]; - for (int i = 0; i < numCodewords; i++) { - int flag = 1; - for (int j = 1; j <= codewordSize; j++) { - if (rawbits[codewordSize * i + codewordSize - j + offset]) { - dataWords[i] += flag; - } - flag <<= 1; - } - - //if (dataWords[i] >= flag) { - // flag++; - //} - } - - try { - ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(gf); - rsDecoder.decode(dataWords, numECCodewords); - } catch (ReedSolomonException rse) { - throw FormatException.getFormatInstance(); - } - - offset = 0; - invertedBitCount = 0; - - boolean[] correctedBits = new boolean[numDataCodewords * codewordSize]; - for (int i = 0; i < numDataCodewords; i++) { - - boolean seriesColor = false; - int seriesCount = 0; - int flag = 1 << (codewordSize - 1); - - for (int j = 0; j < codewordSize; j++) { - - boolean color = (dataWords[i] & flag) == flag; - - if (seriesCount == codewordSize - 1) { - - if (color == seriesColor) { - //bit must be inverted - throw FormatException.getFormatInstance(); - } - - seriesColor = false; - seriesCount = 0; - offset++; - invertedBitCount++; - } else { - - if (seriesColor == color) { - seriesCount++; - } else { - seriesCount = 1; - seriesColor = color; - } - - correctedBits[i * codewordSize + j - offset] = color; - - } - - flag >>>= 1; - } - } - - return correctedBits; - } - - /** - * Gets the array of bits from an Aztec Code matrix - * - * @return the array of bits - * @throws FormatException if the matrix is not a valid aztec code - */ - private boolean[] extractBits(BitMatrix matrix) throws FormatException { - - boolean[] rawbits; - if (ddata.isCompact()) { - if (ddata.getNbLayers() > NB_BITS_COMPACT.length) { - throw FormatException.getFormatInstance(); - } - rawbits = new boolean[NB_BITS_COMPACT[ddata.getNbLayers()]]; - numCodewords = NB_DATABLOCK_COMPACT[ddata.getNbLayers()]; - } else { - if (ddata.getNbLayers() > NB_BITS.length) { - throw FormatException.getFormatInstance(); - } - rawbits = new boolean[NB_BITS[ddata.getNbLayers()]]; - numCodewords = NB_DATABLOCK[ddata.getNbLayers()]; - } - - int layer = ddata.getNbLayers(); - int size = matrix.getHeight(); - int rawbitsOffset = 0; - int matrixOffset = 0; - - while (layer != 0) { - - int flip = 0; - for (int i = 0; i < 2 * size - 4; i++) { - rawbits[rawbitsOffset + i] = matrix.get(matrixOffset + flip, matrixOffset + i / 2); - rawbits[rawbitsOffset + 2 * size - 4 + i] = matrix.get(matrixOffset + i / 2, matrixOffset + size - 1 - flip); - flip = (flip + 1) % 2; - } - - flip = 0; - for (int i = 2 * size + 1; i > 5; i--) { - rawbits[rawbitsOffset + 4 * size - 8 + (2 * size - i) + 1] = - matrix.get(matrixOffset + size - 1 - flip, matrixOffset + i / 2 - 1); - rawbits[rawbitsOffset + 6 * size - 12 + (2 * size - i) + 1] = - matrix.get(matrixOffset + i / 2 - 1, matrixOffset + flip); - flip = (flip + 1) % 2; - } - - matrixOffset += 2; - rawbitsOffset += 8 * size - 16; - layer--; - size -= 4; - } - - return rawbits; - } - - /** - * Transforms an Aztec code matrix by removing the control dashed lines - */ - private static BitMatrix removeDashedLines(BitMatrix matrix) { - int nbDashed = 1 + 2 * ((matrix.getWidth() - 1) / 2 / 16); - BitMatrix newMatrix = new BitMatrix(matrix.getWidth() - nbDashed, matrix.getHeight() - nbDashed); - - int nx = 0; - - for (int x = 0; x < matrix.getWidth(); x++) { - - if ((matrix.getWidth() / 2 - x) % 16 == 0) { - continue; - } - - int ny = 0; - for (int y = 0; y < matrix.getHeight(); y++) { - - if ((matrix.getWidth() / 2 - y) % 16 == 0) { - continue; - } - - if (matrix.get(x, y)) { - newMatrix.set(nx, ny); - } - ny++; - } - nx++; - } - - return newMatrix; - } - - /** - * Reads a code of given length and at given index in an array of bits - */ - private static int readCode(boolean[] rawbits, int startIndex, int length) { - int res = 0; - - for (int i = startIndex; i < startIndex + length; i++) { - res <<= 1; - if (rawbits[i]) { - res++; - } - } - - return res; - } - -} +/* + * Copyright 2010 ZXing authors + * + * 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. + */ + +package com.google.zxing.aztec.decoder; + +import com.google.zxing.FormatException; +import com.google.zxing.aztec.AztecDetectorResult; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.DecoderResult; +import com.google.zxing.common.reedsolomon.GenericGF; +import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; +import com.google.zxing.common.reedsolomon.ReedSolomonException; + +/** + *

The main class which implements Aztec Code decoding -- as opposed to locating and extracting + * the Aztec Code from an image.

+ * + * @author David Olivier + */ +public final class Decoder { + + private enum Table { + UPPER, + LOWER, + MIXED, + DIGIT, + PUNCT, + BINARY + } + + private static final int[] NB_BITS_COMPACT = { + 0, 104, 240, 408, 608 + }; + + private static final int[] NB_BITS = { + 0, 128, 288, 480, 704, 960, 1248, 1568, 1920, 2304, 2720, 3168, 3648, 4160, 4704, 5280, 5888, 6528, + 7200, 7904, 8640, 9408, 10208, 11040, 11904, 12800, 13728, 14688, 15680, 16704, 17760, 18848, 19968 + }; + + private static final int[] NB_DATABLOCK_COMPACT = { + 0, 17, 40, 51, 76 + }; + + private static final int[] NB_DATABLOCK = { + 0, 21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790, 864, + 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664 + }; + + private static final String[] UPPER_TABLE = { + "CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", + "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS" + }; + + private static final String[] LOWER_TABLE = { + "CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", + "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS" + }; + + private static final String[] MIXED_TABLE = { + "CTRL_PS", " ", "\1", "\2", "\3", "\4", "\5", "\6", "\7", "\b", "\t", "\n", + "\13", "\f", "\r", "\33", "\34", "\35", "\36", "\37", "@", "\\", "^", "_", + "`", "|", "~", "\177", "CTRL_LL", "CTRL_UL", "CTRL_PL", "CTRL_BS" + }; + + private static final String[] PUNCT_TABLE = { + "", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", + "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL" + }; + + private static final String[] DIGIT_TABLE = { + "CTRL_PS", " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".", "CTRL_UL", "CTRL_US" + }; + + private int numCodewords; + private int codewordSize; + private AztecDetectorResult ddata; + private int invertedBitCount; + + public DecoderResult decode(AztecDetectorResult detectorResult) throws FormatException { + ddata = detectorResult; + BitMatrix matrix = detectorResult.getBits(); + + if (!ddata.isCompact()) { + matrix = removeDashedLines(ddata.getBits()); + } + + boolean[] rawbits = extractBits(matrix); + + boolean[] correctedBits = correctBits(rawbits); + + String result = getEncodedData(correctedBits); + + return new DecoderResult(null, result, null, null); + } + + /** + * Gets the string encoded in the aztec code bits + * + * @return the decoded string + * @throws FormatException if the input is not valid + */ + private String getEncodedData(boolean[] correctedBits) throws FormatException { + + int endIndex = codewordSize * ddata.getNbDatablocks() - invertedBitCount; + if (endIndex > correctedBits.length) { + throw FormatException.getFormatInstance(); + } + + Table lastTable = Table.UPPER; + Table table = Table.UPPER; + int startIndex = 0; + StringBuilder result = new StringBuilder(20); + boolean end = false; + boolean shift = false; + boolean switchShift = false; + boolean binaryShift = false; + + while (!end) { + + if (shift) { + // the table is for the next character only + switchShift = true; + } else { + // save the current table in case next one is a shift + lastTable = table; + } + + int code; + if (binaryShift) { + if (endIndex - startIndex < 5) { + break; + } + + int length = readCode(correctedBits, startIndex, 5); + startIndex += 5; + if (length == 0) { + if (endIndex - startIndex < 11) { + break; + } + + length = readCode(correctedBits, startIndex, 11) + 31; + startIndex += 11; + } + for (int charCount = 0; charCount < length; charCount++) { + if (endIndex - startIndex < 8) { + end = true; + break; + } + + code = readCode(correctedBits, startIndex, 8); + result.append((char) code); + startIndex += 8; + } + binaryShift = false; + } else { + if (table == Table.BINARY) { + if (endIndex - startIndex < 8) { + break; + } + code = readCode(correctedBits, startIndex, 8); + startIndex += 8; + + result.append((char) code); + + } else { + int size = 5; + + if (table == Table.DIGIT) { + size = 4; + } + + if (endIndex - startIndex < size) { + break; + } + + code = readCode(correctedBits, startIndex, size); + startIndex += size; + + String str = getCharacter(table, code); + if (str.startsWith("CTRL_")) { + // Table changes + table = getTable(str.charAt(5)); + + if (str.charAt(6) == 'S') { + shift = true; + if (str.charAt(5) == 'B') { + binaryShift = true; + } + } + } else { + result.append(str); + } + + + } + } + + if (switchShift) { + table = lastTable; + shift = false; + switchShift = false; + } + + } + return result.toString(); + } + + + /** + * gets the table corresponding to the char passed + */ + private static Table getTable(char t) { + switch (t) { + case 'L': + return Table.LOWER; + case 'P': + return Table.PUNCT; + case 'M': + return Table.MIXED; + case 'D': + return Table.DIGIT; + case 'B': + return Table.BINARY; + case 'U': + default: + return Table.UPPER; + } + } + + /** + * Gets the character (or string) corresponding to the passed code in the given table + * + * @param table the table used + * @param code the code of the character + */ + private static String getCharacter(Table table, int code) { + switch (table) { + case UPPER: + return UPPER_TABLE[code]; + case LOWER: + return LOWER_TABLE[code]; + case MIXED: + return MIXED_TABLE[code]; + case PUNCT: + return PUNCT_TABLE[code]; + case DIGIT: + return DIGIT_TABLE[code]; + default: + return ""; + } + } + + /** + *

Performs RS error correction on an array of bits.

+ * + * @return the corrected array + * @throws FormatException if the input contains too many errors + */ + private boolean[] correctBits(boolean[] rawbits) throws FormatException { + GenericGF gf; + + if (ddata.getNbLayers() <= 2) { + codewordSize = 6; + gf = GenericGF.AZTEC_DATA_6; + } else if (ddata.getNbLayers() <= 8) { + codewordSize = 8; + gf = GenericGF.AZTEC_DATA_8; + } else if (ddata.getNbLayers() <= 22) { + codewordSize = 10; + gf = GenericGF.AZTEC_DATA_10; + } else { + codewordSize = 12; + gf = GenericGF.AZTEC_DATA_12; + } + + int numDataCodewords = ddata.getNbDatablocks(); + int numECCodewords; + int offset; + + if (ddata.isCompact()) { + offset = NB_BITS_COMPACT[ddata.getNbLayers()] - numCodewords * codewordSize; + numECCodewords = NB_DATABLOCK_COMPACT[ddata.getNbLayers()] - numDataCodewords; + } else { + offset = NB_BITS[ddata.getNbLayers()] - numCodewords * codewordSize; + numECCodewords = NB_DATABLOCK[ddata.getNbLayers()] - numDataCodewords; + } + + int[] dataWords = new int[numCodewords]; + for (int i = 0; i < numCodewords; i++) { + int flag = 1; + for (int j = 1; j <= codewordSize; j++) { + if (rawbits[codewordSize * i + codewordSize - j + offset]) { + dataWords[i] += flag; + } + flag <<= 1; + } + + //if (dataWords[i] >= flag) { + // flag++; + //} + } + + try { + ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(gf); + rsDecoder.decode(dataWords, numECCodewords); + } catch (ReedSolomonException rse) { + throw FormatException.getFormatInstance(); + } + + offset = 0; + invertedBitCount = 0; + + boolean[] correctedBits = new boolean[numDataCodewords * codewordSize]; + for (int i = 0; i < numDataCodewords; i++) { + + boolean seriesColor = false; + int seriesCount = 0; + int flag = 1 << (codewordSize - 1); + + for (int j = 0; j < codewordSize; j++) { + + boolean color = (dataWords[i] & flag) == flag; + + if (seriesCount == codewordSize - 1) { + + if (color == seriesColor) { + //bit must be inverted + throw FormatException.getFormatInstance(); + } + + seriesColor = false; + seriesCount = 0; + offset++; + invertedBitCount++; + } else { + + if (seriesColor == color) { + seriesCount++; + } else { + seriesCount = 1; + seriesColor = color; + } + + correctedBits[i * codewordSize + j - offset] = color; + + } + + flag >>>= 1; + } + } + + return correctedBits; + } + + /** + * Gets the array of bits from an Aztec Code matrix + * + * @return the array of bits + * @throws FormatException if the matrix is not a valid aztec code + */ + private boolean[] extractBits(BitMatrix matrix) throws FormatException { + + boolean[] rawbits; + if (ddata.isCompact()) { + if (ddata.getNbLayers() > NB_BITS_COMPACT.length) { + throw FormatException.getFormatInstance(); + } + rawbits = new boolean[NB_BITS_COMPACT[ddata.getNbLayers()]]; + numCodewords = NB_DATABLOCK_COMPACT[ddata.getNbLayers()]; + } else { + if (ddata.getNbLayers() > NB_BITS.length) { + throw FormatException.getFormatInstance(); + } + rawbits = new boolean[NB_BITS[ddata.getNbLayers()]]; + numCodewords = NB_DATABLOCK[ddata.getNbLayers()]; + } + + int layer = ddata.getNbLayers(); + int size = matrix.getHeight(); + int rawbitsOffset = 0; + int matrixOffset = 0; + + while (layer != 0) { + + int flip = 0; + for (int i = 0; i < 2 * size - 4; i++) { + rawbits[rawbitsOffset + i] = matrix.get(matrixOffset + flip, matrixOffset + i / 2); + rawbits[rawbitsOffset + 2 * size - 4 + i] = matrix.get(matrixOffset + i / 2, matrixOffset + size - 1 - flip); + flip = (flip + 1) % 2; + } + + flip = 0; + for (int i = 2 * size + 1; i > 5; i--) { + rawbits[rawbitsOffset + 4 * size - 8 + (2 * size - i) + 1] = + matrix.get(matrixOffset + size - 1 - flip, matrixOffset + i / 2 - 1); + rawbits[rawbitsOffset + 6 * size - 12 + (2 * size - i) + 1] = + matrix.get(matrixOffset + i / 2 - 1, matrixOffset + flip); + flip = (flip + 1) % 2; + } + + matrixOffset += 2; + rawbitsOffset += 8 * size - 16; + layer--; + size -= 4; + } + + return rawbits; + } + + /** + * Transforms an Aztec code matrix by removing the control dashed lines + */ + private static BitMatrix removeDashedLines(BitMatrix matrix) { + int nbDashed = 1 + 2 * ((matrix.getWidth() - 1) / 2 / 16); + BitMatrix newMatrix = new BitMatrix(matrix.getWidth() - nbDashed, matrix.getHeight() - nbDashed); + + int nx = 0; + + for (int x = 0; x < matrix.getWidth(); x++) { + + if ((matrix.getWidth() / 2 - x) % 16 == 0) { + continue; + } + + int ny = 0; + for (int y = 0; y < matrix.getHeight(); y++) { + + if ((matrix.getWidth() / 2 - y) % 16 == 0) { + continue; + } + + if (matrix.get(x, y)) { + newMatrix.set(nx, ny); + } + ny++; + } + nx++; + } + + return newMatrix; + } + + /** + * Reads a code of given length and at given index in an array of bits + */ + private static int readCode(boolean[] rawbits, int startIndex, int length) { + int res = 0; + + for (int i = startIndex; i < startIndex + length; i++) { + res <<= 1; + if (rawbits[i]) { + res++; + } + } + + return res; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitArray.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitArray.java index 2b33bce..77d237a 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitArray.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitArray.java @@ -1,321 +1,321 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.common; - -/** - *

A simple, fast array of bits, represented compactly by an array of ints internally.

- * - * @author Sean Owen - */ -public final class BitArray { - - private int[] bits; - private int size; - - public BitArray() { - this.size = 0; - this.bits = new int[1]; - } - - public BitArray(int size) { - this.size = size; - this.bits = makeArray(size); - } - - public int getSize() { - return size; - } - - public int getSizeInBytes() { - return (size + 7) >> 3; - } - - private void ensureCapacity(int size) { - if (size > bits.length << 5) { - int[] newBits = makeArray(size); - System.arraycopy(bits, 0, newBits, 0, bits.length); - this.bits = newBits; - } - } - - /** - * @param i bit to get - * @return true iff bit i is set - */ - public boolean get(int i) { - return (bits[i >> 5] & (1 << (i & 0x1F))) != 0; - } - - /** - * Sets bit i. - * - * @param i bit to set - */ - public void set(int i) { - bits[i >> 5] |= 1 << (i & 0x1F); - } - - /** - * Flips bit i. - * - * @param i bit to set - */ - public void flip(int i) { - bits[i >> 5] ^= 1 << (i & 0x1F); - } - - /** - * @param from first bit to check - * @return index of first bit that is set, starting from the given index, or size if none are set - * at or beyond this given index - * @see #getNextUnset(int) - */ - public int getNextSet(int from) { - if (from >= size) { - return size; - } - int bitsOffset = from >> 5; - int currentBits = bits[bitsOffset]; - // mask off lesser bits first - currentBits &= ~((1 << (from & 0x1F)) - 1); - while (currentBits == 0) { - if (++bitsOffset == bits.length) { - return size; - } - currentBits = bits[bitsOffset]; - } - int result = (bitsOffset << 5) + Integer.numberOfTrailingZeros(currentBits); - return result > size ? size : result; - } - - /** - * @see #getNextSet(int) - */ - public int getNextUnset(int from) { - if (from >= size) { - return size; - } - int bitsOffset = from >> 5; - int currentBits = ~bits[bitsOffset]; - // mask off lesser bits first - currentBits &= ~((1 << (from & 0x1F)) - 1); - while (currentBits == 0) { - if (++bitsOffset == bits.length) { - return size; - } - currentBits = ~bits[bitsOffset]; - } - int result = (bitsOffset << 5) + Integer.numberOfTrailingZeros(currentBits); - return result > size ? size : result; - } - - /** - * Sets a block of 32 bits, starting at bit i. - * - * @param i first bit to set - * @param newBits the new value of the next 32 bits. Note again that the least-significant bit - * corresponds to bit i, the next-least-significant to i+1, and so on. - */ - public void setBulk(int i, int newBits) { - bits[i >> 5] = newBits; - } - - /** - * Sets a range of bits. - * - * @param start start of range, inclusive. - * @param end end of range, exclusive - */ - public void setRange(int start, int end) { - if (end < start) { - throw new IllegalArgumentException(); - } - if (end == start) { - return; - } - end--; // will be easier to treat this as the last actually set bit -- inclusive - int firstInt = start >> 5; - int lastInt = end >> 5; - for (int i = firstInt; i <= lastInt; i++) { - int firstBit = i > firstInt ? 0 : start & 0x1F; - int lastBit = i < lastInt ? 31 : end & 0x1F; - int mask; - if (firstBit == 0 && lastBit == 31) { - mask = -1; - } else { - mask = 0; - for (int j = firstBit; j <= lastBit; j++) { - mask |= 1 << j; - } - } - bits[i] |= mask; - } - } - - /** - * Clears all bits (sets to false). - */ - public void clear() { - int max = bits.length; - for (int i = 0; i < max; i++) { - bits[i] = 0; - } - } - - /** - * Efficient method to check if a range of bits is set, or not set. - * - * @param start start of range, inclusive. - * @param end end of range, exclusive - * @param value if true, checks that bits in range are set, otherwise checks that they are not set - * @return true iff all bits are set or not set in range, according to value argument - * @throws IllegalArgumentException if end is less than or equal to start - */ - public boolean isRange(int start, int end, boolean value) { - if (end < start) { - throw new IllegalArgumentException(); - } - if (end == start) { - return true; // empty range matches - } - end--; // will be easier to treat this as the last actually set bit -- inclusive - int firstInt = start >> 5; - int lastInt = end >> 5; - for (int i = firstInt; i <= lastInt; i++) { - int firstBit = i > firstInt ? 0 : start & 0x1F; - int lastBit = i < lastInt ? 31 : end & 0x1F; - int mask; - if (firstBit == 0 && lastBit == 31) { - mask = -1; - } else { - mask = 0; - for (int j = firstBit; j <= lastBit; j++) { - mask |= 1 << j; - } - } - - // Return false if we're looking for 1s and the masked bits[i] isn't all 1s (that is, - // equals the mask, or we're looking for 0s and the masked portion is not all 0s - if ((bits[i] & mask) != (value ? mask : 0)) { - return false; - } - } - return true; - } - - public void appendBit(boolean bit) { - ensureCapacity(size + 1); - if (bit) { - bits[size >> 5] |= 1 << (size & 0x1F); - } - size++; - } - - /** - * Appends the least-significant bits, from value, in order from most-significant to - * least-significant. For example, appending 6 bits from 0x000001E will append the bits - * 0, 1, 1, 1, 1, 0 in that order. - */ - public void appendBits(int value, int numBits) { - if (numBits < 0 || numBits > 32) { - throw new IllegalArgumentException("Num bits must be between 0 and 32"); - } - ensureCapacity(size + numBits); - for (int numBitsLeft = numBits; numBitsLeft > 0; numBitsLeft--) { - appendBit(((value >> (numBitsLeft - 1)) & 0x01) == 1); - } - } - - public void appendBitArray(BitArray other) { - int otherSize = other.size; - ensureCapacity(size + otherSize); - for (int i = 0; i < otherSize; i++) { - appendBit(other.get(i)); - } - } - - public void xor(BitArray other) { - if (bits.length != other.bits.length) { - throw new IllegalArgumentException("Sizes don't match"); - } - for (int i = 0; i < bits.length; i++) { - // The last byte could be incomplete (i.e. not have 8 bits in - // it) but there is no problem since 0 XOR 0 == 0. - bits[i] ^= other.bits[i]; - } - } - - /** - * - * @param bitOffset first bit to start writing - * @param array array to write into. Bytes are written most-significant byte first. This is the opposite - * of the internal representation, which is exposed by {@link #getBitArray()} - * @param offset position in array to start writing - * @param numBytes how many bytes to write - */ - public void toBytes(int bitOffset, byte[] array, int offset, int numBytes) { - for (int i = 0; i < numBytes; i++) { - int theByte = 0; - for (int j = 0; j < 8; j++) { - if (get(bitOffset)) { - theByte |= 1 << (7 - j); - } - bitOffset++; - } - array[offset + i] = (byte) theByte; - } - } - - /** - * @return underlying array of ints. The first element holds the first 32 bits, and the least - * significant bit is bit 0. - */ - public int[] getBitArray() { - return bits; - } - - /** - * Reverses all bits in the array. - */ - public void reverse() { - int[] newBits = new int[bits.length]; - int size = this.size; - for (int i = 0; i < size; i++) { - if (get(size - i - 1)) { - newBits[i >> 5] |= 1 << (i & 0x1F); - } - } - bits = newBits; - } - - private static int[] makeArray(int size) { - return new int[(size + 31) >> 5]; - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(size); - for (int i = 0; i < size; i++) { - if ((i & 0x07) == 0) { - result.append(' '); - } - result.append(get(i) ? 'X' : '.'); - } - return result.toString(); - } - +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.common; + +/** + *

A simple, fast array of bits, represented compactly by an array of ints internally.

+ * + * @author Sean Owen + */ +public final class BitArray { + + private int[] bits; + private int size; + + public BitArray() { + this.size = 0; + this.bits = new int[1]; + } + + public BitArray(int size) { + this.size = size; + this.bits = makeArray(size); + } + + public int getSize() { + return size; + } + + public int getSizeInBytes() { + return (size + 7) >> 3; + } + + private void ensureCapacity(int size) { + if (size > bits.length << 5) { + int[] newBits = makeArray(size); + System.arraycopy(bits, 0, newBits, 0, bits.length); + this.bits = newBits; + } + } + + /** + * @param i bit to get + * @return true iff bit i is set + */ + public boolean get(int i) { + return (bits[i >> 5] & (1 << (i & 0x1F))) != 0; + } + + /** + * Sets bit i. + * + * @param i bit to set + */ + public void set(int i) { + bits[i >> 5] |= 1 << (i & 0x1F); + } + + /** + * Flips bit i. + * + * @param i bit to set + */ + public void flip(int i) { + bits[i >> 5] ^= 1 << (i & 0x1F); + } + + /** + * @param from first bit to check + * @return index of first bit that is set, starting from the given index, or size if none are set + * at or beyond this given index + * @see #getNextUnset(int) + */ + public int getNextSet(int from) { + if (from >= size) { + return size; + } + int bitsOffset = from >> 5; + int currentBits = bits[bitsOffset]; + // mask off lesser bits first + currentBits &= ~((1 << (from & 0x1F)) - 1); + while (currentBits == 0) { + if (++bitsOffset == bits.length) { + return size; + } + currentBits = bits[bitsOffset]; + } + int result = (bitsOffset << 5) + Integer.numberOfTrailingZeros(currentBits); + return result > size ? size : result; + } + + /** + * @see #getNextSet(int) + */ + public int getNextUnset(int from) { + if (from >= size) { + return size; + } + int bitsOffset = from >> 5; + int currentBits = ~bits[bitsOffset]; + // mask off lesser bits first + currentBits &= ~((1 << (from & 0x1F)) - 1); + while (currentBits == 0) { + if (++bitsOffset == bits.length) { + return size; + } + currentBits = ~bits[bitsOffset]; + } + int result = (bitsOffset << 5) + Integer.numberOfTrailingZeros(currentBits); + return result > size ? size : result; + } + + /** + * Sets a block of 32 bits, starting at bit i. + * + * @param i first bit to set + * @param newBits the new value of the next 32 bits. Note again that the least-significant bit + * corresponds to bit i, the next-least-significant to i+1, and so on. + */ + public void setBulk(int i, int newBits) { + bits[i >> 5] = newBits; + } + + /** + * Sets a range of bits. + * + * @param start start of range, inclusive. + * @param end end of range, exclusive + */ + public void setRange(int start, int end) { + if (end < start) { + throw new IllegalArgumentException(); + } + if (end == start) { + return; + } + end--; // will be easier to treat this as the last actually set bit -- inclusive + int firstInt = start >> 5; + int lastInt = end >> 5; + for (int i = firstInt; i <= lastInt; i++) { + int firstBit = i > firstInt ? 0 : start & 0x1F; + int lastBit = i < lastInt ? 31 : end & 0x1F; + int mask; + if (firstBit == 0 && lastBit == 31) { + mask = -1; + } else { + mask = 0; + for (int j = firstBit; j <= lastBit; j++) { + mask |= 1 << j; + } + } + bits[i] |= mask; + } + } + + /** + * Clears all bits (sets to false). + */ + public void clear() { + int max = bits.length; + for (int i = 0; i < max; i++) { + bits[i] = 0; + } + } + + /** + * Efficient method to check if a range of bits is set, or not set. + * + * @param start start of range, inclusive. + * @param end end of range, exclusive + * @param value if true, checks that bits in range are set, otherwise checks that they are not set + * @return true iff all bits are set or not set in range, according to value argument + * @throws IllegalArgumentException if end is less than or equal to start + */ + public boolean isRange(int start, int end, boolean value) { + if (end < start) { + throw new IllegalArgumentException(); + } + if (end == start) { + return true; // empty range matches + } + end--; // will be easier to treat this as the last actually set bit -- inclusive + int firstInt = start >> 5; + int lastInt = end >> 5; + for (int i = firstInt; i <= lastInt; i++) { + int firstBit = i > firstInt ? 0 : start & 0x1F; + int lastBit = i < lastInt ? 31 : end & 0x1F; + int mask; + if (firstBit == 0 && lastBit == 31) { + mask = -1; + } else { + mask = 0; + for (int j = firstBit; j <= lastBit; j++) { + mask |= 1 << j; + } + } + + // Return false if we're looking for 1s and the masked bits[i] isn't all 1s (that is, + // equals the mask, or we're looking for 0s and the masked portion is not all 0s + if ((bits[i] & mask) != (value ? mask : 0)) { + return false; + } + } + return true; + } + + public void appendBit(boolean bit) { + ensureCapacity(size + 1); + if (bit) { + bits[size >> 5] |= 1 << (size & 0x1F); + } + size++; + } + + /** + * Appends the least-significant bits, from value, in order from most-significant to + * least-significant. For example, appending 6 bits from 0x000001E will append the bits + * 0, 1, 1, 1, 1, 0 in that order. + */ + public void appendBits(int value, int numBits) { + if (numBits < 0 || numBits > 32) { + throw new IllegalArgumentException("Num bits must be between 0 and 32"); + } + ensureCapacity(size + numBits); + for (int numBitsLeft = numBits; numBitsLeft > 0; numBitsLeft--) { + appendBit(((value >> (numBitsLeft - 1)) & 0x01) == 1); + } + } + + public void appendBitArray(BitArray other) { + int otherSize = other.size; + ensureCapacity(size + otherSize); + for (int i = 0; i < otherSize; i++) { + appendBit(other.get(i)); + } + } + + public void xor(BitArray other) { + if (bits.length != other.bits.length) { + throw new IllegalArgumentException("Sizes don't match"); + } + for (int i = 0; i < bits.length; i++) { + // The last byte could be incomplete (i.e. not have 8 bits in + // it) but there is no problem since 0 XOR 0 == 0. + bits[i] ^= other.bits[i]; + } + } + + /** + * + * @param bitOffset first bit to start writing + * @param array array to write into. Bytes are written most-significant byte first. This is the opposite + * of the internal representation, which is exposed by {@link #getBitArray()} + * @param offset position in array to start writing + * @param numBytes how many bytes to write + */ + public void toBytes(int bitOffset, byte[] array, int offset, int numBytes) { + for (int i = 0; i < numBytes; i++) { + int theByte = 0; + for (int j = 0; j < 8; j++) { + if (get(bitOffset)) { + theByte |= 1 << (7 - j); + } + bitOffset++; + } + array[offset + i] = (byte) theByte; + } + } + + /** + * @return underlying array of ints. The first element holds the first 32 bits, and the least + * significant bit is bit 0. + */ + public int[] getBitArray() { + return bits; + } + + /** + * Reverses all bits in the array. + */ + public void reverse() { + int[] newBits = new int[bits.length]; + int size = this.size; + for (int i = 0; i < size; i++) { + if (get(size - i - 1)) { + newBits[i >> 5] |= 1 << (i & 0x1F); + } + } + bits = newBits; + } + + private static int[] makeArray(int size) { + return new int[(size + 31) >> 5]; + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(size); + for (int i = 0; i < size; i++) { + if ((i & 0x07) == 0) { + result.append(' '); + } + result.append(get(i) ? 'X' : '.'); + } + return result.toString(); + } + } \ No newline at end of file diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitMatrix.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitMatrix.java index 31f46e0..877fba4 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitMatrix.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitMatrix.java @@ -1,311 +1,311 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.common; - -/** - *

Represents a 2D matrix of bits. In function arguments below, and throughout the common - * module, x is the column position, and y is the row position. The ordering is always x, y. - * The origin is at the top-left.

- * - *

Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins - * with a new int. This is done intentionally so that we can copy out a row into a BitArray very - * efficiently.

- * - *

The ordering of bits is row-major. Within each int, the least significant bits are used first, - * meaning they represent lower x values. This is compatible with BitArray's implementation.

- * - * @author Sean Owen - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class BitMatrix { - - private final int width; - private final int height; - private final int rowSize; - private final int[] bits; - - // A helper to construct a square matrix. - public BitMatrix(int dimension) { - this(dimension, dimension); - } - - public BitMatrix(int width, int height) { - if (width < 1 || height < 1) { - throw new IllegalArgumentException("Both dimensions must be greater than 0"); - } - this.width = width; - this.height = height; - this.rowSize = (width + 31) >> 5; - bits = new int[rowSize * height]; - } - - /** - *

Gets the requested bit, where true means black.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - * @return value of given bit in matrix - */ - public boolean get(int x, int y) { - int offset = y * rowSize + (x >> 5); - return ((bits[offset] >>> (x & 0x1f)) & 1) != 0; - } - - /** - *

Sets the given bit to true.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - */ - public void set(int x, int y) { - int offset = y * rowSize + (x >> 5); - bits[offset] |= 1 << (x & 0x1f); - } - - /** - *

Flips the given bit.

- * - * @param x The horizontal component (i.e. which column) - * @param y The vertical component (i.e. which row) - */ - public void flip(int x, int y) { - int offset = y * rowSize + (x >> 5); - bits[offset] ^= 1 << (x & 0x1f); - } - - /** - * Clears all bits (sets to false). - */ - public void clear() { - int max = bits.length; - for (int i = 0; i < max; i++) { - bits[i] = 0; - } - } - - /** - *

Sets a square region of the bit matrix to true.

- * - * @param left The horizontal position to begin at (inclusive) - * @param top The vertical position to begin at (inclusive) - * @param width The width of the region - * @param height The height of the region - */ - public void setRegion(int left, int top, int width, int height) { - if (top < 0 || left < 0) { - throw new IllegalArgumentException("Left and top must be nonnegative"); - } - if (height < 1 || width < 1) { - throw new IllegalArgumentException("Height and width must be at least 1"); - } - int right = left + width; - int bottom = top + height; - if (bottom > this.height || right > this.width) { - throw new IllegalArgumentException("The region must fit inside the matrix"); - } - for (int y = top; y < bottom; y++) { - int offset = y * rowSize; - for (int x = left; x < right; x++) { - bits[offset + (x >> 5)] |= 1 << (x & 0x1f); - } - } - } - - /** - * A fast method to retrieve one row of data from the matrix as a BitArray. - * - * @param y The row to retrieve - * @param row An optional caller-allocated BitArray, will be allocated if null or too small - * @return The resulting BitArray - this reference should always be used even when passing - * your own row - */ - public BitArray getRow(int y, BitArray row) { - if (row == null || row.getSize() < width) { - row = new BitArray(width); - } - int offset = y * rowSize; - for (int x = 0; x < rowSize; x++) { - row.setBulk(x << 5, bits[offset + x]); - } - return row; - } - - /** - * @param y row to set - * @param row {@link BitArray} to copy from - */ - public void setRow(int y, BitArray row) { - System.arraycopy(row.getBitArray(), 0, bits, y * rowSize, rowSize); - } - - /** - * This is useful in detecting the enclosing rectangle of a 'pure' barcode. - * - * @return {left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white - */ - public int[] getEnclosingRectangle() { - int left = width; - int top = height; - int right = -1; - int bottom = -1; - - for (int y = 0; y < height; y++) { - for (int x32 = 0; x32 < rowSize; x32++) { - int theBits = bits[y * rowSize + x32]; - if (theBits != 0) { - if (y < top) { - top = y; - } - if (y > bottom) { - bottom = y; - } - if (x32 * 32 < left) { - int bit = 0; - while ((theBits << (31 - bit)) == 0) { - bit++; - } - if ((x32 * 32 + bit) < left) { - left = x32 * 32 + bit; - } - } - if (x32 * 32 + 31 > right) { - int bit = 31; - while ((theBits >>> bit) == 0) { - bit--; - } - if ((x32 * 32 + bit) > right) { - right = x32 * 32 + bit; - } - } - } - } - } - - int width = right - left; - int height = bottom - top; - - if (width < 0 || height < 0) { - return null; - } - - return new int[] {left, top, width, height}; - } - - /** - * This is useful in detecting a corner of a 'pure' barcode. - * - * @return {x,y} coordinate of top-left-most 1 bit, or null if it is all white - */ - public int[] getTopLeftOnBit() { - int bitsOffset = 0; - while (bitsOffset < bits.length && bits[bitsOffset] == 0) { - bitsOffset++; - } - if (bitsOffset == bits.length) { - return null; - } - int y = bitsOffset / rowSize; - int x = (bitsOffset % rowSize) << 5; - - int theBits = bits[bitsOffset]; - int bit = 0; - while ((theBits << (31-bit)) == 0) { - bit++; - } - x += bit; - return new int[] {x, y}; - } - - public int[] getBottomRightOnBit() { - int bitsOffset = bits.length - 1; - while (bitsOffset >= 0 && bits[bitsOffset] == 0) { - bitsOffset--; - } - if (bitsOffset < 0) { - return null; - } - - int y = bitsOffset / rowSize; - int x = (bitsOffset % rowSize) << 5; - - int theBits = bits[bitsOffset]; - int bit = 31; - while ((theBits >>> bit) == 0) { - bit--; - } - x += bit; - - return new int[] {x, y}; - } - - /** - * @return The width of the matrix - */ - public int getWidth() { - return width; - } - - /** - * @return The height of the matrix - */ - public int getHeight() { - return height; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof BitMatrix)) { - return false; - } - BitMatrix other = (BitMatrix) o; - if (width != other.width || height != other.height || - rowSize != other.rowSize || bits.length != other.bits.length) { - return false; - } - for (int i = 0; i < bits.length; i++) { - if (bits[i] != other.bits[i]) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - int hash = width; - hash = 31 * hash + width; - hash = 31 * hash + height; - hash = 31 * hash + rowSize; - for (int bit : bits) { - hash = 31 * hash + bit; - } - return hash; - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(height * (width + 1)); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - result.append(get(x, y) ? "X " : " "); - } - result.append('\n'); - } - return result.toString(); - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.common; + +/** + *

Represents a 2D matrix of bits. In function arguments below, and throughout the common + * module, x is the column position, and y is the row position. The ordering is always x, y. + * The origin is at the top-left.

+ * + *

Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins + * with a new int. This is done intentionally so that we can copy out a row into a BitArray very + * efficiently.

+ * + *

The ordering of bits is row-major. Within each int, the least significant bits are used first, + * meaning they represent lower x values. This is compatible with BitArray's implementation.

+ * + * @author Sean Owen + * @author dswitkin@google.com (Daniel Switkin) + */ +public final class BitMatrix { + + private final int width; + private final int height; + private final int rowSize; + private final int[] bits; + + // A helper to construct a square matrix. + public BitMatrix(int dimension) { + this(dimension, dimension); + } + + public BitMatrix(int width, int height) { + if (width < 1 || height < 1) { + throw new IllegalArgumentException("Both dimensions must be greater than 0"); + } + this.width = width; + this.height = height; + this.rowSize = (width + 31) >> 5; + bits = new int[rowSize * height]; + } + + /** + *

Gets the requested bit, where true means black.

+ * + * @param x The horizontal component (i.e. which column) + * @param y The vertical component (i.e. which row) + * @return value of given bit in matrix + */ + public boolean get(int x, int y) { + int offset = y * rowSize + (x >> 5); + return ((bits[offset] >>> (x & 0x1f)) & 1) != 0; + } + + /** + *

Sets the given bit to true.

+ * + * @param x The horizontal component (i.e. which column) + * @param y The vertical component (i.e. which row) + */ + public void set(int x, int y) { + int offset = y * rowSize + (x >> 5); + bits[offset] |= 1 << (x & 0x1f); + } + + /** + *

Flips the given bit.

+ * + * @param x The horizontal component (i.e. which column) + * @param y The vertical component (i.e. which row) + */ + public void flip(int x, int y) { + int offset = y * rowSize + (x >> 5); + bits[offset] ^= 1 << (x & 0x1f); + } + + /** + * Clears all bits (sets to false). + */ + public void clear() { + int max = bits.length; + for (int i = 0; i < max; i++) { + bits[i] = 0; + } + } + + /** + *

Sets a square region of the bit matrix to true.

+ * + * @param left The horizontal position to begin at (inclusive) + * @param top The vertical position to begin at (inclusive) + * @param width The width of the region + * @param height The height of the region + */ + public void setRegion(int left, int top, int width, int height) { + if (top < 0 || left < 0) { + throw new IllegalArgumentException("Left and top must be nonnegative"); + } + if (height < 1 || width < 1) { + throw new IllegalArgumentException("Height and width must be at least 1"); + } + int right = left + width; + int bottom = top + height; + if (bottom > this.height || right > this.width) { + throw new IllegalArgumentException("The region must fit inside the matrix"); + } + for (int y = top; y < bottom; y++) { + int offset = y * rowSize; + for (int x = left; x < right; x++) { + bits[offset + (x >> 5)] |= 1 << (x & 0x1f); + } + } + } + + /** + * A fast method to retrieve one row of data from the matrix as a BitArray. + * + * @param y The row to retrieve + * @param row An optional caller-allocated BitArray, will be allocated if null or too small + * @return The resulting BitArray - this reference should always be used even when passing + * your own row + */ + public BitArray getRow(int y, BitArray row) { + if (row == null || row.getSize() < width) { + row = new BitArray(width); + } + int offset = y * rowSize; + for (int x = 0; x < rowSize; x++) { + row.setBulk(x << 5, bits[offset + x]); + } + return row; + } + + /** + * @param y row to set + * @param row {@link BitArray} to copy from + */ + public void setRow(int y, BitArray row) { + System.arraycopy(row.getBitArray(), 0, bits, y * rowSize, rowSize); + } + + /** + * This is useful in detecting the enclosing rectangle of a 'pure' barcode. + * + * @return {left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white + */ + public int[] getEnclosingRectangle() { + int left = width; + int top = height; + int right = -1; + int bottom = -1; + + for (int y = 0; y < height; y++) { + for (int x32 = 0; x32 < rowSize; x32++) { + int theBits = bits[y * rowSize + x32]; + if (theBits != 0) { + if (y < top) { + top = y; + } + if (y > bottom) { + bottom = y; + } + if (x32 * 32 < left) { + int bit = 0; + while ((theBits << (31 - bit)) == 0) { + bit++; + } + if ((x32 * 32 + bit) < left) { + left = x32 * 32 + bit; + } + } + if (x32 * 32 + 31 > right) { + int bit = 31; + while ((theBits >>> bit) == 0) { + bit--; + } + if ((x32 * 32 + bit) > right) { + right = x32 * 32 + bit; + } + } + } + } + } + + int width = right - left; + int height = bottom - top; + + if (width < 0 || height < 0) { + return null; + } + + return new int[] {left, top, width, height}; + } + + /** + * This is useful in detecting a corner of a 'pure' barcode. + * + * @return {x,y} coordinate of top-left-most 1 bit, or null if it is all white + */ + public int[] getTopLeftOnBit() { + int bitsOffset = 0; + while (bitsOffset < bits.length && bits[bitsOffset] == 0) { + bitsOffset++; + } + if (bitsOffset == bits.length) { + return null; + } + int y = bitsOffset / rowSize; + int x = (bitsOffset % rowSize) << 5; + + int theBits = bits[bitsOffset]; + int bit = 0; + while ((theBits << (31-bit)) == 0) { + bit++; + } + x += bit; + return new int[] {x, y}; + } + + public int[] getBottomRightOnBit() { + int bitsOffset = bits.length - 1; + while (bitsOffset >= 0 && bits[bitsOffset] == 0) { + bitsOffset--; + } + if (bitsOffset < 0) { + return null; + } + + int y = bitsOffset / rowSize; + int x = (bitsOffset % rowSize) << 5; + + int theBits = bits[bitsOffset]; + int bit = 31; + while ((theBits >>> bit) == 0) { + bit--; + } + x += bit; + + return new int[] {x, y}; + } + + /** + * @return The width of the matrix + */ + public int getWidth() { + return width; + } + + /** + * @return The height of the matrix + */ + public int getHeight() { + return height; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof BitMatrix)) { + return false; + } + BitMatrix other = (BitMatrix) o; + if (width != other.width || height != other.height || + rowSize != other.rowSize || bits.length != other.bits.length) { + return false; + } + for (int i = 0; i < bits.length; i++) { + if (bits[i] != other.bits[i]) { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + int hash = width; + hash = 31 * hash + width; + hash = 31 * hash + height; + hash = 31 * hash + rowSize; + for (int bit : bits) { + hash = 31 * hash + bit; + } + return hash; + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(height * (width + 1)); + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + result.append(get(x, y) ? "X " : " "); + } + result.append('\n'); + } + return result.toString(); + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitSource.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitSource.java index 45a3858..e3f3246 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitSource.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/BitSource.java @@ -1,111 +1,111 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.common; - -/** - *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the - * number of bits read is not often a multiple of 8.

- * - *

This class is thread-safe but not reentrant -- unless the caller modifies the bytes array - * it passed in, in which case all bets are off.

- * - * @author Sean Owen - */ -public final class BitSource { - - private final byte[] bytes; - private int byteOffset; - private int bitOffset; - - /** - * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. - * Bits are read within a byte from most-significant to least-significant bit. - */ - public BitSource(byte[] bytes) { - this.bytes = bytes; - } - - /** - * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. - */ - public int getBitOffset() { - return bitOffset; - } - - /** - * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. - */ - public int getByteOffset() { - return byteOffset; - } - - /** - * @param numBits number of bits to read - * @return int representing the bits read. The bits will appear as the least-significant - * bits of the int - * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available - */ - public int readBits(int numBits) { - if (numBits < 1 || numBits > 32 || numBits > available()) { - throw new IllegalArgumentException(String.valueOf(numBits)); - } - - int result = 0; - - // First, read remainder from current byte - if (bitOffset > 0) { - int bitsLeft = 8 - bitOffset; - int toRead = numBits < bitsLeft ? numBits : bitsLeft; - int bitsToNotRead = bitsLeft - toRead; - int mask = (0xFF >> (8 - toRead)) << bitsToNotRead; - result = (bytes[byteOffset] & mask) >> bitsToNotRead; - numBits -= toRead; - bitOffset += toRead; - if (bitOffset == 8) { - bitOffset = 0; - byteOffset++; - } - } - - // Next read whole bytes - if (numBits > 0) { - while (numBits >= 8) { - result = (result << 8) | (bytes[byteOffset] & 0xFF); - byteOffset++; - numBits -= 8; - } - - // Finally read a partial byte - if (numBits > 0) { - int bitsToNotRead = 8 - numBits; - int mask = (0xFF >> bitsToNotRead) << bitsToNotRead; - result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead); - bitOffset += numBits; - } - } - - return result; - } - - /** - * @return number of bits that can be read successfully - */ - public int available() { - return 8 * (bytes.length - byteOffset) - bitOffset; - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.common; + +/** + *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the + * number of bits read is not often a multiple of 8.

+ * + *

This class is thread-safe but not reentrant -- unless the caller modifies the bytes array + * it passed in, in which case all bets are off.

+ * + * @author Sean Owen + */ +public final class BitSource { + + private final byte[] bytes; + private int byteOffset; + private int bitOffset; + + /** + * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. + * Bits are read within a byte from most-significant to least-significant bit. + */ + public BitSource(byte[] bytes) { + this.bytes = bytes; + } + + /** + * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. + */ + public int getBitOffset() { + return bitOffset; + } + + /** + * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. + */ + public int getByteOffset() { + return byteOffset; + } + + /** + * @param numBits number of bits to read + * @return int representing the bits read. The bits will appear as the least-significant + * bits of the int + * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available + */ + public int readBits(int numBits) { + if (numBits < 1 || numBits > 32 || numBits > available()) { + throw new IllegalArgumentException(String.valueOf(numBits)); + } + + int result = 0; + + // First, read remainder from current byte + if (bitOffset > 0) { + int bitsLeft = 8 - bitOffset; + int toRead = numBits < bitsLeft ? numBits : bitsLeft; + int bitsToNotRead = bitsLeft - toRead; + int mask = (0xFF >> (8 - toRead)) << bitsToNotRead; + result = (bytes[byteOffset] & mask) >> bitsToNotRead; + numBits -= toRead; + bitOffset += toRead; + if (bitOffset == 8) { + bitOffset = 0; + byteOffset++; + } + } + + // Next read whole bytes + if (numBits > 0) { + while (numBits >= 8) { + result = (result << 8) | (bytes[byteOffset] & 0xFF); + byteOffset++; + numBits -= 8; + } + + // Finally read a partial byte + if (numBits > 0) { + int bitsToNotRead = 8 - numBits; + int mask = (0xFF >> bitsToNotRead) << bitsToNotRead; + result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead); + bitOffset += numBits; + } + } + + return result; + } + + /** + * @return number of bits that can be read successfully + */ + public int available() { + return 8 * (bytes.length - byteOffset) - bitOffset; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/PerspectiveTransform.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/PerspectiveTransform.java index eac9a76..4e0defc 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/PerspectiveTransform.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/common/PerspectiveTransform.java @@ -1,157 +1,157 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.common; - -/** - *

This class implements a perspective transform in two dimensions. Given four source and four - * destination points, it will compute the transformation implied between them. The code is based - * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.

- * - * @author Sean Owen - */ -public final class PerspectiveTransform { - - private final float a11; - private final float a12; - private final float a13; - private final float a21; - private final float a22; - private final float a23; - private final float a31; - private final float a32; - private final float a33; - - private PerspectiveTransform(float a11, float a21, float a31, - float a12, float a22, float a32, - float a13, float a23, float a33) { - this.a11 = a11; - this.a12 = a12; - this.a13 = a13; - this.a21 = a21; - this.a22 = a22; - this.a23 = a23; - this.a31 = a31; - this.a32 = a32; - this.a33 = a33; - } - - public static PerspectiveTransform quadrilateralToQuadrilateral(float x0, float y0, - float x1, float y1, - float x2, float y2, - float x3, float y3, - float x0p, float y0p, - float x1p, float y1p, - float x2p, float y2p, - float x3p, float y3p) { - - PerspectiveTransform qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); - PerspectiveTransform sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); - return sToQ.times(qToS); - } - - public void transformPoints(float[] points) { - int max = points.length; - float a11 = this.a11; - float a12 = this.a12; - float a13 = this.a13; - float a21 = this.a21; - float a22 = this.a22; - float a23 = this.a23; - float a31 = this.a31; - float a32 = this.a32; - float a33 = this.a33; - for (int i = 0; i < max; i += 2) { - float x = points[i]; - float y = points[i + 1]; - float denominator = a13 * x + a23 * y + a33; - points[i] = (a11 * x + a21 * y + a31) / denominator; - points[i + 1] = (a12 * x + a22 * y + a32) / denominator; - } - } - - /** Convenience method, not optimized for performance. */ - public void transformPoints(float[] xValues, float[] yValues) { - int n = xValues.length; - for (int i = 0; i < n; i ++) { - float x = xValues[i]; - float y = yValues[i]; - float denominator = a13 * x + a23 * y + a33; - xValues[i] = (a11 * x + a21 * y + a31) / denominator; - yValues[i] = (a12 * x + a22 * y + a32) / denominator; - } - } - - public static PerspectiveTransform squareToQuadrilateral(float x0, float y0, - float x1, float y1, - float x2, float y2, - float x3, float y3) { - float dx3 = x0 - x1 + x2 - x3; - float dy3 = y0 - y1 + y2 - y3; - if (dx3 == 0.0f && dy3 == 0.0f) { - // Affine - return new PerspectiveTransform(x1 - x0, x2 - x1, x0, - y1 - y0, y2 - y1, y0, - 0.0f, 0.0f, 1.0f); - } else { - float dx1 = x1 - x2; - float dx2 = x3 - x2; - float dy1 = y1 - y2; - float dy2 = y3 - y2; - float denominator = dx1 * dy2 - dx2 * dy1; - float a13 = (dx3 * dy2 - dx2 * dy3) / denominator; - float a23 = (dx1 * dy3 - dx3 * dy1) / denominator; - return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, - y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, - a13, a23, 1.0f); - } - } - - public static PerspectiveTransform quadrilateralToSquare(float x0, float y0, - float x1, float y1, - float x2, float y2, - float x3, float y3) { - // Here, the adjoint serves as the inverse: - return squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint(); - } - - PerspectiveTransform buildAdjoint() { - // Adjoint is the transpose of the cofactor matrix: - return new PerspectiveTransform(a22 * a33 - a23 * a32, - a23 * a31 - a21 * a33, - a21 * a32 - a22 * a31, - a13 * a32 - a12 * a33, - a11 * a33 - a13 * a31, - a12 * a31 - a11 * a32, - a12 * a23 - a13 * a22, - a13 * a21 - a11 * a23, - a11 * a22 - a12 * a21); - } - - PerspectiveTransform times(PerspectiveTransform other) { - return new PerspectiveTransform(a11 * other.a11 + a21 * other.a12 + a31 * other.a13, - a11 * other.a21 + a21 * other.a22 + a31 * other.a23, - a11 * other.a31 + a21 * other.a32 + a31 * other.a33, - a12 * other.a11 + a22 * other.a12 + a32 * other.a13, - a12 * other.a21 + a22 * other.a22 + a32 * other.a23, - a12 * other.a31 + a22 * other.a32 + a32 * other.a33, - a13 * other.a11 + a23 * other.a12 + a33 * other.a13, - a13 * other.a21 + a23 * other.a22 + a33 * other.a23, - a13 * other.a31 + a23 * other.a32 + a33 * other.a33); - - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.common; + +/** + *

This class implements a perspective transform in two dimensions. Given four source and four + * destination points, it will compute the transformation implied between them. The code is based + * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.

+ * + * @author Sean Owen + */ +public final class PerspectiveTransform { + + private final float a11; + private final float a12; + private final float a13; + private final float a21; + private final float a22; + private final float a23; + private final float a31; + private final float a32; + private final float a33; + + private PerspectiveTransform(float a11, float a21, float a31, + float a12, float a22, float a32, + float a13, float a23, float a33) { + this.a11 = a11; + this.a12 = a12; + this.a13 = a13; + this.a21 = a21; + this.a22 = a22; + this.a23 = a23; + this.a31 = a31; + this.a32 = a32; + this.a33 = a33; + } + + public static PerspectiveTransform quadrilateralToQuadrilateral(float x0, float y0, + float x1, float y1, + float x2, float y2, + float x3, float y3, + float x0p, float y0p, + float x1p, float y1p, + float x2p, float y2p, + float x3p, float y3p) { + + PerspectiveTransform qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); + PerspectiveTransform sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); + return sToQ.times(qToS); + } + + public void transformPoints(float[] points) { + int max = points.length; + float a11 = this.a11; + float a12 = this.a12; + float a13 = this.a13; + float a21 = this.a21; + float a22 = this.a22; + float a23 = this.a23; + float a31 = this.a31; + float a32 = this.a32; + float a33 = this.a33; + for (int i = 0; i < max; i += 2) { + float x = points[i]; + float y = points[i + 1]; + float denominator = a13 * x + a23 * y + a33; + points[i] = (a11 * x + a21 * y + a31) / denominator; + points[i + 1] = (a12 * x + a22 * y + a32) / denominator; + } + } + + /** Convenience method, not optimized for performance. */ + public void transformPoints(float[] xValues, float[] yValues) { + int n = xValues.length; + for (int i = 0; i < n; i ++) { + float x = xValues[i]; + float y = yValues[i]; + float denominator = a13 * x + a23 * y + a33; + xValues[i] = (a11 * x + a21 * y + a31) / denominator; + yValues[i] = (a12 * x + a22 * y + a32) / denominator; + } + } + + public static PerspectiveTransform squareToQuadrilateral(float x0, float y0, + float x1, float y1, + float x2, float y2, + float x3, float y3) { + float dx3 = x0 - x1 + x2 - x3; + float dy3 = y0 - y1 + y2 - y3; + if (dx3 == 0.0f && dy3 == 0.0f) { + // Affine + return new PerspectiveTransform(x1 - x0, x2 - x1, x0, + y1 - y0, y2 - y1, y0, + 0.0f, 0.0f, 1.0f); + } else { + float dx1 = x1 - x2; + float dx2 = x3 - x2; + float dy1 = y1 - y2; + float dy2 = y3 - y2; + float denominator = dx1 * dy2 - dx2 * dy1; + float a13 = (dx3 * dy2 - dx2 * dy3) / denominator; + float a23 = (dx1 * dy3 - dx3 * dy1) / denominator; + return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, + y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, + a13, a23, 1.0f); + } + } + + public static PerspectiveTransform quadrilateralToSquare(float x0, float y0, + float x1, float y1, + float x2, float y2, + float x3, float y3) { + // Here, the adjoint serves as the inverse: + return squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint(); + } + + PerspectiveTransform buildAdjoint() { + // Adjoint is the transpose of the cofactor matrix: + return new PerspectiveTransform(a22 * a33 - a23 * a32, + a23 * a31 - a21 * a33, + a21 * a32 - a22 * a31, + a13 * a32 - a12 * a33, + a11 * a33 - a13 * a31, + a12 * a31 - a11 * a32, + a12 * a23 - a13 * a22, + a13 * a21 - a11 * a23, + a11 * a22 - a12 * a21); + } + + PerspectiveTransform times(PerspectiveTransform other) { + return new PerspectiveTransform(a11 * other.a11 + a21 * other.a12 + a31 * other.a13, + a11 * other.a21 + a21 * other.a22 + a31 * other.a23, + a11 * other.a31 + a21 * other.a32 + a31 * other.a33, + a12 * other.a11 + a22 * other.a12 + a32 * other.a13, + a12 * other.a21 + a22 * other.a22 + a32 * other.a23, + a12 * other.a31 + a22 * other.a32 + a32 * other.a33, + a13 * other.a11 + a23 * other.a12 + a33 * other.a13, + a13 * other.a21 + a23 * other.a22 + a33 * other.a23, + a13 * other.a31 + a23 * other.a32 + a33 * other.a33); + + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java index f04f219..45ffd2d 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java @@ -1,440 +1,440 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.datamatrix.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - * @author bbrown@google.com (Brian Brown) - */ -final class BitMatrixParser { - - private final BitMatrix mappingBitMatrix; - private final BitMatrix readMappingMatrix; - private final Version version; - - /** - * @param bitMatrix {@link BitMatrix} to parse - * @throws FormatException if dimension is < 8 or > 144 or not 0 mod 2 - */ - BitMatrixParser(BitMatrix bitMatrix) throws FormatException { - int dimension = bitMatrix.getHeight(); - if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { - throw FormatException.getFormatInstance(); - } - - version = readVersion(bitMatrix); - this.mappingBitMatrix = extractDataRegion(bitMatrix); - this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight()); - } - - Version getVersion() { - return version; - } - - /** - *

Creates the version object based on the dimension of the original bit matrix from - * the datamatrix code.

- * - *

See ISO 16022:2006 Table 7 - ECC 200 symbol attributes

- * - * @param bitMatrix Original {@link BitMatrix} including alignment patterns - * @return {@link Version} encapsulating the Data Matrix Code's "version" - * @throws FormatException if the dimensions of the mapping matrix are not valid - * Data Matrix dimensions. - */ - private static Version readVersion(BitMatrix bitMatrix) throws FormatException { - int numRows = bitMatrix.getHeight(); - int numColumns = bitMatrix.getWidth(); - return Version.getVersionForDimensions(numRows, numColumns); - } - - /** - *

Reads the bits in the {@link BitMatrix} representing the mapping matrix (No alignment patterns) - * in the correct order in order to reconstitute the codewords bytes contained within the - * Data Matrix Code.

- * - * @return bytes encoded within the Data Matrix Code - * @throws FormatException if the exact number of bytes expected is not read - */ - byte[] readCodewords() throws FormatException { - - byte[] result = new byte[version.getTotalCodewords()]; - int resultOffset = 0; - - int row = 4; - int column = 0; - - int numRows = mappingBitMatrix.getHeight(); - int numColumns = mappingBitMatrix.getWidth(); - - boolean corner1Read = false; - boolean corner2Read = false; - boolean corner3Read = false; - boolean corner4Read = false; - - // Read all of the codewords - do { - // Check the four corner cases - if ((row == numRows) && (column == 0) && !corner1Read) { - result[resultOffset++] = (byte) readCorner1(numRows, numColumns); - row -= 2; - column +=2; - corner1Read = true; - } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) { - result[resultOffset++] = (byte) readCorner2(numRows, numColumns); - row -= 2; - column +=2; - corner2Read = true; - } else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) { - result[resultOffset++] = (byte) readCorner3(numRows, numColumns); - row -= 2; - column +=2; - corner3Read = true; - } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) { - result[resultOffset++] = (byte) readCorner4(numRows, numColumns); - row -= 2; - column +=2; - corner4Read = true; - } else { - // Sweep upward diagonally to the right - do { - if ((row < numRows) && (column >= 0) && !readMappingMatrix.get(column, row)) { - result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); - } - row -= 2; - column +=2; - } while ((row >= 0) && (column < numColumns)); - row += 1; - column +=3; - - // Sweep downward diagonally to the left - do { - if ((row >= 0) && (column < numColumns) && !readMappingMatrix.get(column, row)) { - result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); - } - row += 2; - column -=2; - } while ((row < numRows) && (column >= 0)); - row += 3; - column +=1; - } - } while ((row < numRows) || (column < numColumns)); - - if (resultOffset != version.getTotalCodewords()) { - throw FormatException.getFormatInstance(); - } - return result; - } - - /** - *

Reads a bit of the mapping matrix accounting for boundary wrapping.

- * - * @param row Row to read in the mapping matrix - * @param column Column to read in the mapping matrix - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return value of the given bit in the mapping matrix - */ - boolean readModule(int row, int column, int numRows, int numColumns) { - // Adjust the row and column indices based on boundary wrapping - if (row < 0) { - row += numRows; - column += 4 - ((numRows + 4) & 0x07); - } - if (column < 0) { - column += numColumns; - row += 4 - ((numColumns + 4) & 0x07); - } - readMappingMatrix.set(column, row); - return mappingBitMatrix.get(column, row); - } - - /** - *

Reads the 8 bits of the standard Utah-shaped pattern.

- * - *

See ISO 16022:2006, 5.8.1 Figure 6

- * - * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern - * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the utah shape - */ - int readUtah(int row, int column, int numRows, int numColumns) { - int currentByte = 0; - if (readModule(row - 2, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 2, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 1, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 1, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row - 1, column, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(row, column, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 1.

- * - *

See ISO 16022:2006, Figure F.3

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 1 - */ - int readCorner1(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(2, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(3, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 2.

- * - *

See ISO 16022:2006, Figure F.4

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 2 - */ - int readCorner2(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 3, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 2, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 4, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 3.

- * - *

See ISO 16022:2006, Figure F.5

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 3 - */ - int readCorner3(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Reads the 8 bits of the special corner condition 4.

- * - *

See ISO 16022:2006, Figure F.6

- * - * @param numRows Number of rows in the mapping matrix - * @param numColumns Number of columns in the mapping matrix - * @return byte from the Corner condition 4 - */ - int readCorner4(int numRows, int numColumns) { - int currentByte = 0; - if (readModule(numRows - 3, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 2, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(2, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (readModule(3, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; - } - - /** - *

Extracts the data region from a {@link BitMatrix} that contains - * alignment patterns.

- * - * @param bitMatrix Original {@link BitMatrix} with alignment patterns - * @return BitMatrix that has the alignment patterns removed - */ - BitMatrix extractDataRegion(BitMatrix bitMatrix) { - int symbolSizeRows = version.getSymbolSizeRows(); - int symbolSizeColumns = version.getSymbolSizeColumns(); - - if (bitMatrix.getHeight() != symbolSizeRows) { - throw new IllegalArgumentException("Dimension of bitMarix must match the version size"); - } - - int dataRegionSizeRows = version.getDataRegionSizeRows(); - int dataRegionSizeColumns = version.getDataRegionSizeColumns(); - - int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows; - int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns; - - int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; - int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; - - BitMatrix bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow); - for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) { - int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows; - for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) { - int dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns; - for (int i = 0; i < dataRegionSizeRows; ++i) { - int readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i; - int writeRowOffset = dataRegionRowOffset + i; - for (int j = 0; j < dataRegionSizeColumns; ++j) { - int readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j; - if (bitMatrix.get(readColumnOffset, readRowOffset)) { - int writeColumnOffset = dataRegionColumnOffset + j; - bitMatrixWithoutAlignment.set(writeColumnOffset, writeRowOffset); - } - } - } - } - } - return bitMatrixWithoutAlignment; - } - +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.datamatrix.decoder; + +import com.google.zxing.FormatException; +import com.google.zxing.common.BitMatrix; + +/** + * @author bbrown@google.com (Brian Brown) + */ +final class BitMatrixParser { + + private final BitMatrix mappingBitMatrix; + private final BitMatrix readMappingMatrix; + private final Version version; + + /** + * @param bitMatrix {@link BitMatrix} to parse + * @throws FormatException if dimension is < 8 or > 144 or not 0 mod 2 + */ + BitMatrixParser(BitMatrix bitMatrix) throws FormatException { + int dimension = bitMatrix.getHeight(); + if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { + throw FormatException.getFormatInstance(); + } + + version = readVersion(bitMatrix); + this.mappingBitMatrix = extractDataRegion(bitMatrix); + this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight()); + } + + Version getVersion() { + return version; + } + + /** + *

Creates the version object based on the dimension of the original bit matrix from + * the datamatrix code.

+ * + *

See ISO 16022:2006 Table 7 - ECC 200 symbol attributes

+ * + * @param bitMatrix Original {@link BitMatrix} including alignment patterns + * @return {@link Version} encapsulating the Data Matrix Code's "version" + * @throws FormatException if the dimensions of the mapping matrix are not valid + * Data Matrix dimensions. + */ + private static Version readVersion(BitMatrix bitMatrix) throws FormatException { + int numRows = bitMatrix.getHeight(); + int numColumns = bitMatrix.getWidth(); + return Version.getVersionForDimensions(numRows, numColumns); + } + + /** + *

Reads the bits in the {@link BitMatrix} representing the mapping matrix (No alignment patterns) + * in the correct order in order to reconstitute the codewords bytes contained within the + * Data Matrix Code.

+ * + * @return bytes encoded within the Data Matrix Code + * @throws FormatException if the exact number of bytes expected is not read + */ + byte[] readCodewords() throws FormatException { + + byte[] result = new byte[version.getTotalCodewords()]; + int resultOffset = 0; + + int row = 4; + int column = 0; + + int numRows = mappingBitMatrix.getHeight(); + int numColumns = mappingBitMatrix.getWidth(); + + boolean corner1Read = false; + boolean corner2Read = false; + boolean corner3Read = false; + boolean corner4Read = false; + + // Read all of the codewords + do { + // Check the four corner cases + if ((row == numRows) && (column == 0) && !corner1Read) { + result[resultOffset++] = (byte) readCorner1(numRows, numColumns); + row -= 2; + column +=2; + corner1Read = true; + } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) { + result[resultOffset++] = (byte) readCorner2(numRows, numColumns); + row -= 2; + column +=2; + corner2Read = true; + } else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) { + result[resultOffset++] = (byte) readCorner3(numRows, numColumns); + row -= 2; + column +=2; + corner3Read = true; + } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) { + result[resultOffset++] = (byte) readCorner4(numRows, numColumns); + row -= 2; + column +=2; + corner4Read = true; + } else { + // Sweep upward diagonally to the right + do { + if ((row < numRows) && (column >= 0) && !readMappingMatrix.get(column, row)) { + result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); + } + row -= 2; + column +=2; + } while ((row >= 0) && (column < numColumns)); + row += 1; + column +=3; + + // Sweep downward diagonally to the left + do { + if ((row >= 0) && (column < numColumns) && !readMappingMatrix.get(column, row)) { + result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); + } + row += 2; + column -=2; + } while ((row < numRows) && (column >= 0)); + row += 3; + column +=1; + } + } while ((row < numRows) || (column < numColumns)); + + if (resultOffset != version.getTotalCodewords()) { + throw FormatException.getFormatInstance(); + } + return result; + } + + /** + *

Reads a bit of the mapping matrix accounting for boundary wrapping.

+ * + * @param row Row to read in the mapping matrix + * @param column Column to read in the mapping matrix + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return value of the given bit in the mapping matrix + */ + boolean readModule(int row, int column, int numRows, int numColumns) { + // Adjust the row and column indices based on boundary wrapping + if (row < 0) { + row += numRows; + column += 4 - ((numRows + 4) & 0x07); + } + if (column < 0) { + column += numColumns; + row += 4 - ((numColumns + 4) & 0x07); + } + readMappingMatrix.set(column, row); + return mappingBitMatrix.get(column, row); + } + + /** + *

Reads the 8 bits of the standard Utah-shaped pattern.

+ * + *

See ISO 16022:2006, 5.8.1 Figure 6

+ * + * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern + * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the utah shape + */ + int readUtah(int row, int column, int numRows, int numColumns) { + int currentByte = 0; + if (readModule(row - 2, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(row - 2, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(row - 1, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(row - 1, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(row - 1, column, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(row, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(row, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(row, column, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + + /** + *

Reads the 8 bits of the special corner condition 1.

+ * + *

See ISO 16022:2006, Figure F.3

+ * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 1 + */ + int readCorner1(int numRows, int numColumns) { + int currentByte = 0; + if (readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(numRows - 1, 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(numRows - 1, 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(2, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(3, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + + /** + *

Reads the 8 bits of the special corner condition 2.

+ * + *

See ISO 16022:2006, Figure F.4

+ * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 2 + */ + int readCorner2(int numRows, int numColumns) { + int currentByte = 0; + if (readModule(numRows - 3, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(numRows - 2, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 4, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + + /** + *

Reads the 8 bits of the special corner condition 3.

+ * + *

See ISO 16022:2006, Figure F.5

+ * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 3 + */ + int readCorner3(int numRows, int numColumns) { + int currentByte = 0; + if (readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(numRows - 1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(1, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(1, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + + /** + *

Reads the 8 bits of the special corner condition 4.

+ * + *

See ISO 16022:2006, Figure F.6

+ * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 4 + */ + int readCorner4(int numRows, int numColumns) { + int currentByte = 0; + if (readModule(numRows - 3, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(numRows - 2, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(2, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (readModule(3, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + + /** + *

Extracts the data region from a {@link BitMatrix} that contains + * alignment patterns.

+ * + * @param bitMatrix Original {@link BitMatrix} with alignment patterns + * @return BitMatrix that has the alignment patterns removed + */ + BitMatrix extractDataRegion(BitMatrix bitMatrix) { + int symbolSizeRows = version.getSymbolSizeRows(); + int symbolSizeColumns = version.getSymbolSizeColumns(); + + if (bitMatrix.getHeight() != symbolSizeRows) { + throw new IllegalArgumentException("Dimension of bitMarix must match the version size"); + } + + int dataRegionSizeRows = version.getDataRegionSizeRows(); + int dataRegionSizeColumns = version.getDataRegionSizeColumns(); + + int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows; + int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns; + + int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; + int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; + + BitMatrix bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow); + for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) { + int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows; + for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) { + int dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns; + for (int i = 0; i < dataRegionSizeRows; ++i) { + int readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i; + int writeRowOffset = dataRegionRowOffset + i; + for (int j = 0; j < dataRegionSizeColumns; ++j) { + int readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j; + if (bitMatrix.get(readColumnOffset, readRowOffset)) { + int writeColumnOffset = dataRegionColumnOffset + j; + bitMatrixWithoutAlignment.set(writeColumnOffset, writeRowOffset); + } + } + } + } + } + return bitMatrixWithoutAlignment; + } + } \ No newline at end of file diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/DataBlock.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/DataBlock.java index a91b72a..dbbda42 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/DataBlock.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/DataBlock.java @@ -1,117 +1,117 @@ -/* - * Copyright 2008 ZXing authors - * - * 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. - */ - -package com.google.zxing.datamatrix.decoder; - -/** - *

Encapsulates a block of data within a Data Matrix Code. Data Matrix Codes may split their data into - * multiple blocks, each of which is a unit of data and error-correction codewords. Each - * is represented by an instance of this class.

- * - * @author bbrown@google.com (Brian Brown) - */ -final class DataBlock { - - private final int numDataCodewords; - private final byte[] codewords; - - private DataBlock(int numDataCodewords, byte[] codewords) { - this.numDataCodewords = numDataCodewords; - this.codewords = codewords; - } - - /** - *

When Data Matrix Codes use multiple data blocks, they actually interleave the bytes of each of them. - * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This - * method will separate the data into original blocks.

- * - * @param rawCodewords bytes as read directly from the Data Matrix Code - * @param version version of the Data Matrix Code - * @return DataBlocks containing original bytes, "de-interleaved" from representation in the - * Data Matrix Code - */ - static DataBlock[] getDataBlocks(byte[] rawCodewords, - Version version) { - // Figure out the number and size of data blocks used by this version - Version.ECBlocks ecBlocks = version.getECBlocks(); - - // First count the total number of data blocks - int totalBlocks = 0; - Version.ECB[] ecBlockArray = ecBlocks.getECBlocks(); - for (Version.ECB ecBlock : ecBlockArray) { - totalBlocks += ecBlock.getCount(); - } - - // Now establish DataBlocks of the appropriate size and number of data codewords - DataBlock[] result = new DataBlock[totalBlocks]; - int numResultBlocks = 0; - for (Version.ECB ecBlock : ecBlockArray) { - for (int i = 0; i < ecBlock.getCount(); i++) { - int numDataCodewords = ecBlock.getDataCodewords(); - int numBlockCodewords = ecBlocks.getECCodewords() + numDataCodewords; - result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); - } - } - - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 less byte. Figure out where these start. - // TODO(bbrown): There is only one case where there is a difference for Data Matrix for size 144 - int longerBlocksTotalCodewords = result[0].codewords.length; - //int shorterBlocksTotalCodewords = longerBlocksTotalCodewords - 1; - - int longerBlocksNumDataCodewords = longerBlocksTotalCodewords - ecBlocks.getECCodewords(); - int shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; - // The last elements of result may be 1 element shorter for 144 matrix - // first fill out as many elements as all of them have minus 1 - int rawCodewordsOffset = 0; - for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { - for (int j = 0; j < numResultBlocks; j++) { - result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; - } - } - - // Fill out the last data block in the longer ones - boolean specialVersion = version.getVersionNumber() == 24; - int numLongerBlocks = specialVersion ? 8 : numResultBlocks; - for (int j = 0; j < numLongerBlocks; j++) { - result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++]; - } - - // Now add in error correction blocks - int max = result[0].codewords.length; - for (int i = longerBlocksNumDataCodewords; i < max; i++) { - for (int j = 0; j < numResultBlocks; j++) { - int iOffset = specialVersion && j > 7 ? i - 1 : i; - result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; - } - } - - if (rawCodewordsOffset != rawCodewords.length) { - throw new IllegalArgumentException(); - } - - return result; - } - - int getNumDataCodewords() { - return numDataCodewords; - } - - byte[] getCodewords() { - return codewords; - } - -} +/* + * Copyright 2008 ZXing authors + * + * 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. + */ + +package com.google.zxing.datamatrix.decoder; + +/** + *

Encapsulates a block of data within a Data Matrix Code. Data Matrix Codes may split their data into + * multiple blocks, each of which is a unit of data and error-correction codewords. Each + * is represented by an instance of this class.

+ * + * @author bbrown@google.com (Brian Brown) + */ +final class DataBlock { + + private final int numDataCodewords; + private final byte[] codewords; + + private DataBlock(int numDataCodewords, byte[] codewords) { + this.numDataCodewords = numDataCodewords; + this.codewords = codewords; + } + + /** + *

When Data Matrix Codes use multiple data blocks, they actually interleave the bytes of each of them. + * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This + * method will separate the data into original blocks.

+ * + * @param rawCodewords bytes as read directly from the Data Matrix Code + * @param version version of the Data Matrix Code + * @return DataBlocks containing original bytes, "de-interleaved" from representation in the + * Data Matrix Code + */ + static DataBlock[] getDataBlocks(byte[] rawCodewords, + Version version) { + // Figure out the number and size of data blocks used by this version + Version.ECBlocks ecBlocks = version.getECBlocks(); + + // First count the total number of data blocks + int totalBlocks = 0; + Version.ECB[] ecBlockArray = ecBlocks.getECBlocks(); + for (Version.ECB ecBlock : ecBlockArray) { + totalBlocks += ecBlock.getCount(); + } + + // Now establish DataBlocks of the appropriate size and number of data codewords + DataBlock[] result = new DataBlock[totalBlocks]; + int numResultBlocks = 0; + for (Version.ECB ecBlock : ecBlockArray) { + for (int i = 0; i < ecBlock.getCount(); i++) { + int numDataCodewords = ecBlock.getDataCodewords(); + int numBlockCodewords = ecBlocks.getECCodewords() + numDataCodewords; + result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); + } + } + + // All blocks have the same amount of data, except that the last n + // (where n may be 0) have 1 less byte. Figure out where these start. + // TODO(bbrown): There is only one case where there is a difference for Data Matrix for size 144 + int longerBlocksTotalCodewords = result[0].codewords.length; + //int shorterBlocksTotalCodewords = longerBlocksTotalCodewords - 1; + + int longerBlocksNumDataCodewords = longerBlocksTotalCodewords - ecBlocks.getECCodewords(); + int shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; + // The last elements of result may be 1 element shorter for 144 matrix + // first fill out as many elements as all of them have minus 1 + int rawCodewordsOffset = 0; + for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { + for (int j = 0; j < numResultBlocks; j++) { + result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; + } + } + + // Fill out the last data block in the longer ones + boolean specialVersion = version.getVersionNumber() == 24; + int numLongerBlocks = specialVersion ? 8 : numResultBlocks; + for (int j = 0; j < numLongerBlocks; j++) { + result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++]; + } + + // Now add in error correction blocks + int max = result[0].codewords.length; + for (int i = longerBlocksNumDataCodewords; i < max; i++) { + for (int j = 0; j < numResultBlocks; j++) { + int iOffset = specialVersion && j > 7 ? i - 1 : i; + result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; + } + } + + if (rawCodewordsOffset != rawCodewords.length) { + throw new IllegalArgumentException(); + } + + return result; + } + + int getNumDataCodewords() { + return numDataCodewords; + } + + byte[] getCodewords() { + return codewords; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Decoder.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Decoder.java index aa28f8a..7e22c4f 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Decoder.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Decoder.java @@ -1,136 +1,136 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.datamatrix.decoder; - -import com.google.zxing.ChecksumException; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -/** - *

The main class which implements Data Matrix Code decoding -- as opposed to locating and extracting - * the Data Matrix Code from an image.

- * - * @author bbrown@google.com (Brian Brown) - */ -public final class Decoder { - - private final ReedSolomonDecoder rsDecoder; - - public Decoder() { - rsDecoder = new ReedSolomonDecoder(GenericGF.DATA_MATRIX_FIELD_256); - } - - /** - *

Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans. - * "true" is taken to mean a black module.

- * - * @param image booleans representing white/black Data Matrix Code modules - * @return text and bytes encoded within the Data Matrix Code - * @throws FormatException if the Data Matrix Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException { - int dimension = image.length; - BitMatrix bits = new BitMatrix(dimension); - for (int i = 0; i < dimension; i++) { - for (int j = 0; j < dimension; j++) { - if (image[i][j]) { - bits.set(j, i); - } - } - } - return decode(bits); - } - - /** - *

Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken - * to mean a black module.

- * - * @param bits booleans representing white/black Data Matrix Code modules - * @return text and bytes encoded within the Data Matrix Code - * @throws FormatException if the Data Matrix Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException { - - // Construct a parser and read version, error-correction level - BitMatrixParser parser = new BitMatrixParser(bits); - Version version = parser.getVersion(); - - // Read codewords - byte[] codewords = parser.readCodewords(); - // Separate into data blocks - DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version); - - int dataBlocksCount = dataBlocks.length; - - // Count total number of data bytes - int totalBytes = 0; - for (DataBlock db : dataBlocks) { - totalBytes += db.getNumDataCodewords(); - } - byte[] resultBytes = new byte[totalBytes]; - - // Error-correct and copy data blocks together into a stream of bytes - for (int j = 0; j < dataBlocksCount; j++) { - DataBlock dataBlock = dataBlocks[j]; - byte[] codewordBytes = dataBlock.getCodewords(); - int numDataCodewords = dataBlock.getNumDataCodewords(); - correctErrors(codewordBytes, numDataCodewords); - for (int i = 0; i < numDataCodewords; i++) { - // De-interlace data blocks. - resultBytes[i * dataBlocksCount + j] = codewordBytes[i]; - } - } - - // Decode the contents of that stream of bytes - return DecodedBitStreamParser.decode(resultBytes); - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place using Reed-Solomon error correction.

- * - * @param codewordBytes data and error correction codewords - * @param numDataCodewords number of codewords that are data bytes - * @throws ChecksumException if error correction fails - */ - private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException { - int numCodewords = codewordBytes.length; - // First read into an array of ints - int[] codewordsInts = new int[numCodewords]; - for (int i = 0; i < numCodewords; i++) { - codewordsInts[i] = codewordBytes[i] & 0xFF; - } - int numECCodewords = codewordBytes.length - numDataCodewords; - try { - rsDecoder.decode(codewordsInts, numECCodewords); - } catch (ReedSolomonException rse) { - throw ChecksumException.getChecksumInstance(); - } - // Copy back into array of bytes -- only need to worry about the bytes that were data - // We don't care about errors in the error-correction codewords - for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (byte) codewordsInts[i]; - } - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.datamatrix.decoder; + +import com.google.zxing.ChecksumException; +import com.google.zxing.FormatException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.DecoderResult; +import com.google.zxing.common.reedsolomon.GenericGF; +import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; +import com.google.zxing.common.reedsolomon.ReedSolomonException; + +/** + *

The main class which implements Data Matrix Code decoding -- as opposed to locating and extracting + * the Data Matrix Code from an image.

+ * + * @author bbrown@google.com (Brian Brown) + */ +public final class Decoder { + + private final ReedSolomonDecoder rsDecoder; + + public Decoder() { + rsDecoder = new ReedSolomonDecoder(GenericGF.DATA_MATRIX_FIELD_256); + } + + /** + *

Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans. + * "true" is taken to mean a black module.

+ * + * @param image booleans representing white/black Data Matrix Code modules + * @return text and bytes encoded within the Data Matrix Code + * @throws FormatException if the Data Matrix Code cannot be decoded + * @throws ChecksumException if error correction fails + */ + public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException { + int dimension = image.length; + BitMatrix bits = new BitMatrix(dimension); + for (int i = 0; i < dimension; i++) { + for (int j = 0; j < dimension; j++) { + if (image[i][j]) { + bits.set(j, i); + } + } + } + return decode(bits); + } + + /** + *

Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken + * to mean a black module.

+ * + * @param bits booleans representing white/black Data Matrix Code modules + * @return text and bytes encoded within the Data Matrix Code + * @throws FormatException if the Data Matrix Code cannot be decoded + * @throws ChecksumException if error correction fails + */ + public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException { + + // Construct a parser and read version, error-correction level + BitMatrixParser parser = new BitMatrixParser(bits); + Version version = parser.getVersion(); + + // Read codewords + byte[] codewords = parser.readCodewords(); + // Separate into data blocks + DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version); + + int dataBlocksCount = dataBlocks.length; + + // Count total number of data bytes + int totalBytes = 0; + for (DataBlock db : dataBlocks) { + totalBytes += db.getNumDataCodewords(); + } + byte[] resultBytes = new byte[totalBytes]; + + // Error-correct and copy data blocks together into a stream of bytes + for (int j = 0; j < dataBlocksCount; j++) { + DataBlock dataBlock = dataBlocks[j]; + byte[] codewordBytes = dataBlock.getCodewords(); + int numDataCodewords = dataBlock.getNumDataCodewords(); + correctErrors(codewordBytes, numDataCodewords); + for (int i = 0; i < numDataCodewords; i++) { + // De-interlace data blocks. + resultBytes[i * dataBlocksCount + j] = codewordBytes[i]; + } + } + + // Decode the contents of that stream of bytes + return DecodedBitStreamParser.decode(resultBytes); + } + + /** + *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to + * correct the errors in-place using Reed-Solomon error correction.

+ * + * @param codewordBytes data and error correction codewords + * @param numDataCodewords number of codewords that are data bytes + * @throws ChecksumException if error correction fails + */ + private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException { + int numCodewords = codewordBytes.length; + // First read into an array of ints + int[] codewordsInts = new int[numCodewords]; + for (int i = 0; i < numCodewords; i++) { + codewordsInts[i] = codewordBytes[i] & 0xFF; + } + int numECCodewords = codewordBytes.length - numDataCodewords; + try { + rsDecoder.decode(codewordsInts, numECCodewords); + } catch (ReedSolomonException rse) { + throw ChecksumException.getChecksumInstance(); + } + // Copy back into array of bytes -- only need to worry about the bytes that were data + // We don't care about errors in the error-correction codewords + for (int i = 0; i < numDataCodewords; i++) { + codewordBytes[i] = (byte) codewordsInts[i]; + } + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Version.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Version.java index fff9e17..0455802 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Version.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/datamatrix/decoder/Version.java @@ -1,237 +1,237 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.datamatrix.decoder; - -import com.google.zxing.FormatException; - -/** - * The Version object encapsulates attributes about a particular - * size Data Matrix Code. - * - * @author bbrown@google.com (Brian Brown) - */ -public final class Version { - - private static final Version[] VERSIONS = buildVersions(); - - private final int versionNumber; - private final int symbolSizeRows; - private final int symbolSizeColumns; - private final int dataRegionSizeRows; - private final int dataRegionSizeColumns; - private final ECBlocks ecBlocks; - private final int totalCodewords; - - private Version(int versionNumber, - int symbolSizeRows, - int symbolSizeColumns, - int dataRegionSizeRows, - int dataRegionSizeColumns, - ECBlocks ecBlocks) { - this.versionNumber = versionNumber; - this.symbolSizeRows = symbolSizeRows; - this.symbolSizeColumns = symbolSizeColumns; - this.dataRegionSizeRows = dataRegionSizeRows; - this.dataRegionSizeColumns = dataRegionSizeColumns; - this.ecBlocks = ecBlocks; - - // Calculate the total number of codewords - int total = 0; - int ecCodewords = ecBlocks.getECCodewords(); - ECB[] ecbArray = ecBlocks.getECBlocks(); - for (ECB ecBlock : ecbArray) { - total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); - } - this.totalCodewords = total; - } - - public int getVersionNumber() { - return versionNumber; - } - - public int getSymbolSizeRows() { - return symbolSizeRows; - } - - public int getSymbolSizeColumns() { - return symbolSizeColumns; - } - - public int getDataRegionSizeRows() { - return dataRegionSizeRows; - } - - public int getDataRegionSizeColumns() { - return dataRegionSizeColumns; - } - - public int getTotalCodewords() { - return totalCodewords; - } - - ECBlocks getECBlocks() { - return ecBlocks; - } - - /** - *

Deduces version information from Data Matrix dimensions.

- * - * @param numRows Number of rows in modules - * @param numColumns Number of columns in modules - * @return Version for a Data Matrix Code of those dimensions - * @throws FormatException if dimensions do correspond to a valid Data Matrix size - */ - public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException { - if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { - throw FormatException.getFormatInstance(); - } - - for (Version version : VERSIONS) { - if (version.symbolSizeRows == numRows && version.symbolSizeColumns == numColumns) { - return version; - } - } - - throw FormatException.getFormatInstance(); - } - - /** - *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will - * use blocks of differing sizes within one version, so, this encapsulates the parameters for - * each set of blocks. It also holds the number of error-correction codewords per block since it - * will be the same across all blocks within one version.

- */ - static final class ECBlocks { - private final int ecCodewords; - private final ECB[] ecBlocks; - - private ECBlocks(int ecCodewords, ECB ecBlocks) { - this.ecCodewords = ecCodewords; - this.ecBlocks = new ECB[] { ecBlocks }; - } - - private ECBlocks(int ecCodewords, ECB ecBlocks1, ECB ecBlocks2) { - this.ecCodewords = ecCodewords; - this.ecBlocks = new ECB[] { ecBlocks1, ecBlocks2 }; - } - - int getECCodewords() { - return ecCodewords; - } - - ECB[] getECBlocks() { - return ecBlocks; - } - } - - /** - *

Encapsualtes the parameters for one error-correction block in one symbol version. - * This includes the number of data codewords, and the number of times a block with these - * parameters is used consecutively in the Data Matrix code version's format.

- */ - static final class ECB { - private final int count; - private final int dataCodewords; - - private ECB(int count, int dataCodewords) { - this.count = count; - this.dataCodewords = dataCodewords; - } - - int getCount() { - return count; - } - - int getDataCodewords() { - return dataCodewords; - } - } - - @Override - public String toString() { - return String.valueOf(versionNumber); - } - - /** - * See ISO 16022:2006 5.5.1 Table 7 - */ - private static Version[] buildVersions() { - return new Version[]{ - new Version(1, 10, 10, 8, 8, - new ECBlocks(5, new ECB(1, 3))), - new Version(2, 12, 12, 10, 10, - new ECBlocks(7, new ECB(1, 5))), - new Version(3, 14, 14, 12, 12, - new ECBlocks(10, new ECB(1, 8))), - new Version(4, 16, 16, 14, 14, - new ECBlocks(12, new ECB(1, 12))), - new Version(5, 18, 18, 16, 16, - new ECBlocks(14, new ECB(1, 18))), - new Version(6, 20, 20, 18, 18, - new ECBlocks(18, new ECB(1, 22))), - new Version(7, 22, 22, 20, 20, - new ECBlocks(20, new ECB(1, 30))), - new Version(8, 24, 24, 22, 22, - new ECBlocks(24, new ECB(1, 36))), - new Version(9, 26, 26, 24, 24, - new ECBlocks(28, new ECB(1, 44))), - new Version(10, 32, 32, 14, 14, - new ECBlocks(36, new ECB(1, 62))), - new Version(11, 36, 36, 16, 16, - new ECBlocks(42, new ECB(1, 86))), - new Version(12, 40, 40, 18, 18, - new ECBlocks(48, new ECB(1, 114))), - new Version(13, 44, 44, 20, 20, - new ECBlocks(56, new ECB(1, 144))), - new Version(14, 48, 48, 22, 22, - new ECBlocks(68, new ECB(1, 174))), - new Version(15, 52, 52, 24, 24, - new ECBlocks(42, new ECB(2, 102))), - new Version(16, 64, 64, 14, 14, - new ECBlocks(56, new ECB(2, 140))), - new Version(17, 72, 72, 16, 16, - new ECBlocks(36, new ECB(4, 92))), - new Version(18, 80, 80, 18, 18, - new ECBlocks(48, new ECB(4, 114))), - new Version(19, 88, 88, 20, 20, - new ECBlocks(56, new ECB(4, 144))), - new Version(20, 96, 96, 22, 22, - new ECBlocks(68, new ECB(4, 174))), - new Version(21, 104, 104, 24, 24, - new ECBlocks(56, new ECB(6, 136))), - new Version(22, 120, 120, 18, 18, - new ECBlocks(68, new ECB(6, 175))), - new Version(23, 132, 132, 20, 20, - new ECBlocks(62, new ECB(8, 163))), - new Version(24, 144, 144, 22, 22, - new ECBlocks(62, new ECB(8, 156), new ECB(2, 155))), - new Version(25, 8, 18, 6, 16, - new ECBlocks(7, new ECB(1, 5))), - new Version(26, 8, 32, 6, 14, - new ECBlocks(11, new ECB(1, 10))), - new Version(27, 12, 26, 10, 24, - new ECBlocks(14, new ECB(1, 16))), - new Version(28, 12, 36, 10, 16, - new ECBlocks(18, new ECB(1, 22))), - new Version(29, 16, 36, 14, 16, - new ECBlocks(24, new ECB(1, 32))), - new Version(30, 16, 48, 14, 22, - new ECBlocks(28, new ECB(1, 49))) - }; - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.datamatrix.decoder; + +import com.google.zxing.FormatException; + +/** + * The Version object encapsulates attributes about a particular + * size Data Matrix Code. + * + * @author bbrown@google.com (Brian Brown) + */ +public final class Version { + + private static final Version[] VERSIONS = buildVersions(); + + private final int versionNumber; + private final int symbolSizeRows; + private final int symbolSizeColumns; + private final int dataRegionSizeRows; + private final int dataRegionSizeColumns; + private final ECBlocks ecBlocks; + private final int totalCodewords; + + private Version(int versionNumber, + int symbolSizeRows, + int symbolSizeColumns, + int dataRegionSizeRows, + int dataRegionSizeColumns, + ECBlocks ecBlocks) { + this.versionNumber = versionNumber; + this.symbolSizeRows = symbolSizeRows; + this.symbolSizeColumns = symbolSizeColumns; + this.dataRegionSizeRows = dataRegionSizeRows; + this.dataRegionSizeColumns = dataRegionSizeColumns; + this.ecBlocks = ecBlocks; + + // Calculate the total number of codewords + int total = 0; + int ecCodewords = ecBlocks.getECCodewords(); + ECB[] ecbArray = ecBlocks.getECBlocks(); + for (ECB ecBlock : ecbArray) { + total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); + } + this.totalCodewords = total; + } + + public int getVersionNumber() { + return versionNumber; + } + + public int getSymbolSizeRows() { + return symbolSizeRows; + } + + public int getSymbolSizeColumns() { + return symbolSizeColumns; + } + + public int getDataRegionSizeRows() { + return dataRegionSizeRows; + } + + public int getDataRegionSizeColumns() { + return dataRegionSizeColumns; + } + + public int getTotalCodewords() { + return totalCodewords; + } + + ECBlocks getECBlocks() { + return ecBlocks; + } + + /** + *

Deduces version information from Data Matrix dimensions.

+ * + * @param numRows Number of rows in modules + * @param numColumns Number of columns in modules + * @return Version for a Data Matrix Code of those dimensions + * @throws FormatException if dimensions do correspond to a valid Data Matrix size + */ + public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException { + if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { + throw FormatException.getFormatInstance(); + } + + for (Version version : VERSIONS) { + if (version.symbolSizeRows == numRows && version.symbolSizeColumns == numColumns) { + return version; + } + } + + throw FormatException.getFormatInstance(); + } + + /** + *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will + * use blocks of differing sizes within one version, so, this encapsulates the parameters for + * each set of blocks. It also holds the number of error-correction codewords per block since it + * will be the same across all blocks within one version.

+ */ + static final class ECBlocks { + private final int ecCodewords; + private final ECB[] ecBlocks; + + private ECBlocks(int ecCodewords, ECB ecBlocks) { + this.ecCodewords = ecCodewords; + this.ecBlocks = new ECB[] { ecBlocks }; + } + + private ECBlocks(int ecCodewords, ECB ecBlocks1, ECB ecBlocks2) { + this.ecCodewords = ecCodewords; + this.ecBlocks = new ECB[] { ecBlocks1, ecBlocks2 }; + } + + int getECCodewords() { + return ecCodewords; + } + + ECB[] getECBlocks() { + return ecBlocks; + } + } + + /** + *

Encapsualtes the parameters for one error-correction block in one symbol version. + * This includes the number of data codewords, and the number of times a block with these + * parameters is used consecutively in the Data Matrix code version's format.

+ */ + static final class ECB { + private final int count; + private final int dataCodewords; + + private ECB(int count, int dataCodewords) { + this.count = count; + this.dataCodewords = dataCodewords; + } + + int getCount() { + return count; + } + + int getDataCodewords() { + return dataCodewords; + } + } + + @Override + public String toString() { + return String.valueOf(versionNumber); + } + + /** + * See ISO 16022:2006 5.5.1 Table 7 + */ + private static Version[] buildVersions() { + return new Version[]{ + new Version(1, 10, 10, 8, 8, + new ECBlocks(5, new ECB(1, 3))), + new Version(2, 12, 12, 10, 10, + new ECBlocks(7, new ECB(1, 5))), + new Version(3, 14, 14, 12, 12, + new ECBlocks(10, new ECB(1, 8))), + new Version(4, 16, 16, 14, 14, + new ECBlocks(12, new ECB(1, 12))), + new Version(5, 18, 18, 16, 16, + new ECBlocks(14, new ECB(1, 18))), + new Version(6, 20, 20, 18, 18, + new ECBlocks(18, new ECB(1, 22))), + new Version(7, 22, 22, 20, 20, + new ECBlocks(20, new ECB(1, 30))), + new Version(8, 24, 24, 22, 22, + new ECBlocks(24, new ECB(1, 36))), + new Version(9, 26, 26, 24, 24, + new ECBlocks(28, new ECB(1, 44))), + new Version(10, 32, 32, 14, 14, + new ECBlocks(36, new ECB(1, 62))), + new Version(11, 36, 36, 16, 16, + new ECBlocks(42, new ECB(1, 86))), + new Version(12, 40, 40, 18, 18, + new ECBlocks(48, new ECB(1, 114))), + new Version(13, 44, 44, 20, 20, + new ECBlocks(56, new ECB(1, 144))), + new Version(14, 48, 48, 22, 22, + new ECBlocks(68, new ECB(1, 174))), + new Version(15, 52, 52, 24, 24, + new ECBlocks(42, new ECB(2, 102))), + new Version(16, 64, 64, 14, 14, + new ECBlocks(56, new ECB(2, 140))), + new Version(17, 72, 72, 16, 16, + new ECBlocks(36, new ECB(4, 92))), + new Version(18, 80, 80, 18, 18, + new ECBlocks(48, new ECB(4, 114))), + new Version(19, 88, 88, 20, 20, + new ECBlocks(56, new ECB(4, 144))), + new Version(20, 96, 96, 22, 22, + new ECBlocks(68, new ECB(4, 174))), + new Version(21, 104, 104, 24, 24, + new ECBlocks(56, new ECB(6, 136))), + new Version(22, 120, 120, 18, 18, + new ECBlocks(68, new ECB(6, 175))), + new Version(23, 132, 132, 20, 20, + new ECBlocks(62, new ECB(8, 163))), + new Version(24, 144, 144, 22, 22, + new ECBlocks(62, new ECB(8, 156), new ECB(2, 155))), + new Version(25, 8, 18, 6, 16, + new ECBlocks(7, new ECB(1, 5))), + new Version(26, 8, 32, 6, 14, + new ECBlocks(11, new ECB(1, 10))), + new Version(27, 12, 26, 10, 24, + new ECBlocks(14, new ECB(1, 16))), + new Version(28, 12, 36, 10, 16, + new ECBlocks(18, new ECB(1, 22))), + new Version(29, 16, 36, 14, 16, + new ECBlocks(24, new ECB(1, 32))), + new Version(30, 16, 48, 14, 22, + new ECBlocks(28, new ECB(1, 49))) + }; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java index a6ad7de..afa1012 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java @@ -1,317 +1,317 @@ -/* - * Copyright 2009 ZXing authors - * - * 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. - */ - -package com.google.zxing.multi.qrcode.detector; - -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.qrcode.detector.FinderPattern; -import com.google.zxing.qrcode.detector.FinderPatternFinder; -import com.google.zxing.qrcode.detector.FinderPatternInfo; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -/** - *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square - * markers at three corners of a QR Code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object. - * - *

In contrast to {@link FinderPatternFinder}, this class will return an array of all possible - * QR code locations in the image.

- * - *

Use the TRY_HARDER hint to ask for a more thorough detection.

- * - * @author Sean Owen - * @author Hannes Erven - */ -final class MultiFinderPatternFinder extends FinderPatternFinder { - - private static final FinderPatternInfo[] EMPTY_RESULT_ARRAY = new FinderPatternInfo[0]; - - // TODO MIN_MODULE_COUNT and MAX_MODULE_COUNT would be great hints to ask the user for - // since it limits the number of regions to decode - - // max. legal count of modules per QR code edge (177) - private static final float MAX_MODULE_COUNT_PER_EDGE = 180; - // min. legal count per modules per QR code edge (11) - private static final float MIN_MODULE_COUNT_PER_EDGE = 9; - - /** - * More or less arbitrary cutoff point for determining if two finder patterns might belong - * to the same code if they differ less than DIFF_MODSIZE_CUTOFF_PERCENT percent in their - * estimated modules sizes. - */ - private static final float DIFF_MODSIZE_CUTOFF_PERCENT = 0.05f; - - /** - * More or less arbitrary cutoff point for determining if two finder patterns might belong - * to the same code if they differ less than DIFF_MODSIZE_CUTOFF pixels/module in their - * estimated modules sizes. - */ - private static final float DIFF_MODSIZE_CUTOFF = 0.5f; - - - /** - * A comparator that orders FinderPatterns by their estimated module size. - */ - private static final class ModuleSizeComparator implements Comparator, Serializable { - @Override - public int compare(FinderPattern center1, FinderPattern center2) { - float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize(); - return value < 0.0 ? -1 : value > 0.0 ? 1 : 0; - } - } - - /** - *

Creates a finder that will search the image for three finder patterns.

- * - * @param image image to search - */ - MultiFinderPatternFinder(BitMatrix image) { - super(image); - } - - MultiFinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) { - super(image, resultPointCallback); - } - - /** - * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - * those that have been detected at least {@link #CENTER_QUORUM} times, and whose module - * size differs from the average among those patterns the least - * @throws NotFoundException if 3 such finder patterns do not exist - */ - private FinderPattern[][] selectMutipleBestPatterns() throws NotFoundException { - List possibleCenters = getPossibleCenters(); - int size = possibleCenters.size(); - - if (size < 3) { - // Couldn't find enough finder patterns - throw NotFoundException.getNotFoundInstance(); - } - - /* - * Begin HE modifications to safely detect multiple codes of equal size - */ - if (size == 3) { - return new FinderPattern[][]{ - new FinderPattern[]{ - possibleCenters.get(0), - possibleCenters.get(1), - possibleCenters.get(2) - } - }; - } - - // Sort by estimated module size to speed up the upcoming checks - Collections.sort(possibleCenters, new ModuleSizeComparator()); - - /* - * Now lets start: build a list of tuples of three finder locations that - * - feature similar module sizes - * - are placed in a distance so the estimated module count is within the QR specification - * - have similar distance between upper left/right and left top/bottom finder patterns - * - form a triangle with 90° angle (checked by comparing top right/bottom left distance - * with pythagoras) - * - * Note: we allow each point to be used for more than one code region: this might seem - * counterintuitive at first, but the performance penalty is not that big. At this point, - * we cannot make a good quality decision whether the three finders actually represent - * a QR code, or are just by chance layouted so it looks like there might be a QR code there. - * So, if the layout seems right, lets have the decoder try to decode. - */ - - List results = new ArrayList(); // holder for the results - - for (int i1 = 0; i1 < (size - 2); i1++) { - FinderPattern p1 = possibleCenters.get(i1); - if (p1 == null) { - continue; - } - - for (int i2 = i1 + 1; i2 < (size - 1); i2++) { - FinderPattern p2 = possibleCenters.get(i2); - if (p2 == null) { - continue; - } - - // Compare the expected module sizes; if they are really off, skip - float vModSize12 = (p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()) / - Math.min(p1.getEstimatedModuleSize(), p2.getEstimatedModuleSize()); - float vModSize12A = Math.abs(p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()); - if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) { - // break, since elements are ordered by the module size deviation there cannot be - // any more interesting elements for the given p1. - break; - } - - for (int i3 = i2 + 1; i3 < size; i3++) { - FinderPattern p3 = possibleCenters.get(i3); - if (p3 == null) { - continue; - } - - // Compare the expected module sizes; if they are really off, skip - float vModSize23 = (p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()) / - Math.min(p2.getEstimatedModuleSize(), p3.getEstimatedModuleSize()); - float vModSize23A = Math.abs(p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()); - if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) { - // break, since elements are ordered by the module size deviation there cannot be - // any more interesting elements for the given p1. - break; - } - - FinderPattern[] test = {p1, p2, p3}; - ResultPoint.orderBestPatterns(test); - - // Calculate the distances: a = topleft-bottomleft, b=topleft-topright, c = diagonal - FinderPatternInfo info = new FinderPatternInfo(test); - float dA = ResultPoint.distance(info.getTopLeft(), info.getBottomLeft()); - float dC = ResultPoint.distance(info.getTopRight(), info.getBottomLeft()); - float dB = ResultPoint.distance(info.getTopLeft(), info.getTopRight()); - - // Check the sizes - float estimatedModuleCount = (dA + dB) / (p1.getEstimatedModuleSize() * 2.0f); - if (estimatedModuleCount > MAX_MODULE_COUNT_PER_EDGE || - estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) { - continue; - } - - // Calculate the difference of the edge lengths in percent - float vABBC = Math.abs((dA - dB) / Math.min(dA, dB)); - if (vABBC >= 0.1f) { - continue; - } - - // Calculate the diagonal length by assuming a 90° angle at topleft - float dCpy = (float) Math.sqrt(dA * dA + dB * dB); - // Compare to the real distance in % - float vPyC = Math.abs((dC - dCpy) / Math.min(dC, dCpy)); - - if (vPyC >= 0.1f) { - continue; - } - - // All tests passed! - results.add(test); - } // end iterate p3 - } // end iterate p2 - } // end iterate p1 - - if (!results.isEmpty()) { - return results.toArray(new FinderPattern[results.size()][]); - } - - // Nothing found! - throw NotFoundException.getNotFoundInstance(); - } - - public FinderPatternInfo[] findMulti(Map hints) throws NotFoundException { - boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - BitMatrix image = getImage(); - int maxI = image.getHeight(); - int maxJ = image.getWidth(); - // We are looking for black/white/black/white/black modules in - // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far - - // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the - // image, and then account for the center being 3 modules in size. This gives the smallest - // number of pixels the center could be, so skip this often. When trying harder, look for all - // QR versions regardless of how dense they are. - int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); - if (iSkip < MIN_SKIP || tryHarder) { - iSkip = MIN_SKIP; - } - - int[] stateCount = new int[5]; - for (int i = iSkip - 1; i < maxI; i += iSkip) { - // Get a row of black/white values - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - stateCount[3] = 0; - stateCount[4] = 0; - int currentState = 0; - for (int j = 0; j < maxJ; j++) { - if (image.get(j, i)) { - // Black pixel - if ((currentState & 1) == 1) { // Counting white pixels - currentState++; - } - stateCount[currentState]++; - } else { // White pixel - if ((currentState & 1) == 0) { // Counting black pixels - if (currentState == 4) { // A winner? - if (foundPatternCross(stateCount)) { // Yes - boolean confirmed = handlePossibleCenter(stateCount, i, j); - if (!confirmed) { - do { // Advance to next black pixel - j++; - } while (j < maxJ && !image.get(j, i)); - j--; // back up to that last white pixel - } - // Clear state to start looking again - currentState = 0; - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - stateCount[3] = 0; - stateCount[4] = 0; - } else { // No, shift counts back by two - stateCount[0] = stateCount[2]; - stateCount[1] = stateCount[3]; - stateCount[2] = stateCount[4]; - stateCount[3] = 1; - stateCount[4] = 0; - currentState = 3; - } - } else { - stateCount[++currentState]++; - } - } else { // Counting white pixels - stateCount[currentState]++; - } - } - } // for j=... - - if (foundPatternCross(stateCount)) { - handlePossibleCenter(stateCount, i, maxJ); - } // end if foundPatternCross - } // for i=iSkip-1 ... - FinderPattern[][] patternInfo = selectMutipleBestPatterns(); - List result = new ArrayList(); - for (FinderPattern[] pattern : patternInfo) { - ResultPoint.orderBestPatterns(pattern); - result.add(new FinderPatternInfo(pattern)); - } - - if (result.isEmpty()) { - return EMPTY_RESULT_ARRAY; - } else { - return result.toArray(new FinderPatternInfo[result.size()]); - } - } - -} +/* + * Copyright 2009 ZXing authors + * + * 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. + */ + +package com.google.zxing.multi.qrcode.detector; + +import com.google.zxing.DecodeHintType; +import com.google.zxing.NotFoundException; +import com.google.zxing.ResultPoint; +import com.google.zxing.ResultPointCallback; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.detector.FinderPattern; +import com.google.zxing.qrcode.detector.FinderPatternFinder; +import com.google.zxing.qrcode.detector.FinderPatternInfo; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; + +/** + *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square + * markers at three corners of a QR Code.

+ * + *

This class is thread-safe but not reentrant. Each thread must allocate its own object. + * + *

In contrast to {@link FinderPatternFinder}, this class will return an array of all possible + * QR code locations in the image.

+ * + *

Use the TRY_HARDER hint to ask for a more thorough detection.

+ * + * @author Sean Owen + * @author Hannes Erven + */ +final class MultiFinderPatternFinder extends FinderPatternFinder { + + private static final FinderPatternInfo[] EMPTY_RESULT_ARRAY = new FinderPatternInfo[0]; + + // TODO MIN_MODULE_COUNT and MAX_MODULE_COUNT would be great hints to ask the user for + // since it limits the number of regions to decode + + // max. legal count of modules per QR code edge (177) + private static final float MAX_MODULE_COUNT_PER_EDGE = 180; + // min. legal count per modules per QR code edge (11) + private static final float MIN_MODULE_COUNT_PER_EDGE = 9; + + /** + * More or less arbitrary cutoff point for determining if two finder patterns might belong + * to the same code if they differ less than DIFF_MODSIZE_CUTOFF_PERCENT percent in their + * estimated modules sizes. + */ + private static final float DIFF_MODSIZE_CUTOFF_PERCENT = 0.05f; + + /** + * More or less arbitrary cutoff point for determining if two finder patterns might belong + * to the same code if they differ less than DIFF_MODSIZE_CUTOFF pixels/module in their + * estimated modules sizes. + */ + private static final float DIFF_MODSIZE_CUTOFF = 0.5f; + + + /** + * A comparator that orders FinderPatterns by their estimated module size. + */ + private static final class ModuleSizeComparator implements Comparator, Serializable { + @Override + public int compare(FinderPattern center1, FinderPattern center2) { + float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize(); + return value < 0.0 ? -1 : value > 0.0 ? 1 : 0; + } + } + + /** + *

Creates a finder that will search the image for three finder patterns.

+ * + * @param image image to search + */ + MultiFinderPatternFinder(BitMatrix image) { + super(image); + } + + MultiFinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) { + super(image, resultPointCallback); + } + + /** + * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are + * those that have been detected at least {@link #CENTER_QUORUM} times, and whose module + * size differs from the average among those patterns the least + * @throws NotFoundException if 3 such finder patterns do not exist + */ + private FinderPattern[][] selectMutipleBestPatterns() throws NotFoundException { + List possibleCenters = getPossibleCenters(); + int size = possibleCenters.size(); + + if (size < 3) { + // Couldn't find enough finder patterns + throw NotFoundException.getNotFoundInstance(); + } + + /* + * Begin HE modifications to safely detect multiple codes of equal size + */ + if (size == 3) { + return new FinderPattern[][]{ + new FinderPattern[]{ + possibleCenters.get(0), + possibleCenters.get(1), + possibleCenters.get(2) + } + }; + } + + // Sort by estimated module size to speed up the upcoming checks + Collections.sort(possibleCenters, new ModuleSizeComparator()); + + /* + * Now lets start: build a list of tuples of three finder locations that + * - feature similar module sizes + * - are placed in a distance so the estimated module count is within the QR specification + * - have similar distance between upper left/right and left top/bottom finder patterns + * - form a triangle with 90° angle (checked by comparing top right/bottom left distance + * with pythagoras) + * + * Note: we allow each point to be used for more than one code region: this might seem + * counterintuitive at first, but the performance penalty is not that big. At this point, + * we cannot make a good quality decision whether the three finders actually represent + * a QR code, or are just by chance layouted so it looks like there might be a QR code there. + * So, if the layout seems right, lets have the decoder try to decode. + */ + + List results = new ArrayList(); // holder for the results + + for (int i1 = 0; i1 < (size - 2); i1++) { + FinderPattern p1 = possibleCenters.get(i1); + if (p1 == null) { + continue; + } + + for (int i2 = i1 + 1; i2 < (size - 1); i2++) { + FinderPattern p2 = possibleCenters.get(i2); + if (p2 == null) { + continue; + } + + // Compare the expected module sizes; if they are really off, skip + float vModSize12 = (p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()) / + Math.min(p1.getEstimatedModuleSize(), p2.getEstimatedModuleSize()); + float vModSize12A = Math.abs(p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()); + if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) { + // break, since elements are ordered by the module size deviation there cannot be + // any more interesting elements for the given p1. + break; + } + + for (int i3 = i2 + 1; i3 < size; i3++) { + FinderPattern p3 = possibleCenters.get(i3); + if (p3 == null) { + continue; + } + + // Compare the expected module sizes; if they are really off, skip + float vModSize23 = (p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()) / + Math.min(p2.getEstimatedModuleSize(), p3.getEstimatedModuleSize()); + float vModSize23A = Math.abs(p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()); + if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) { + // break, since elements are ordered by the module size deviation there cannot be + // any more interesting elements for the given p1. + break; + } + + FinderPattern[] test = {p1, p2, p3}; + ResultPoint.orderBestPatterns(test); + + // Calculate the distances: a = topleft-bottomleft, b=topleft-topright, c = diagonal + FinderPatternInfo info = new FinderPatternInfo(test); + float dA = ResultPoint.distance(info.getTopLeft(), info.getBottomLeft()); + float dC = ResultPoint.distance(info.getTopRight(), info.getBottomLeft()); + float dB = ResultPoint.distance(info.getTopLeft(), info.getTopRight()); + + // Check the sizes + float estimatedModuleCount = (dA + dB) / (p1.getEstimatedModuleSize() * 2.0f); + if (estimatedModuleCount > MAX_MODULE_COUNT_PER_EDGE || + estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) { + continue; + } + + // Calculate the difference of the edge lengths in percent + float vABBC = Math.abs((dA - dB) / Math.min(dA, dB)); + if (vABBC >= 0.1f) { + continue; + } + + // Calculate the diagonal length by assuming a 90° angle at topleft + float dCpy = (float) Math.sqrt(dA * dA + dB * dB); + // Compare to the real distance in % + float vPyC = Math.abs((dC - dCpy) / Math.min(dC, dCpy)); + + if (vPyC >= 0.1f) { + continue; + } + + // All tests passed! + results.add(test); + } // end iterate p3 + } // end iterate p2 + } // end iterate p1 + + if (!results.isEmpty()) { + return results.toArray(new FinderPattern[results.size()][]); + } + + // Nothing found! + throw NotFoundException.getNotFoundInstance(); + } + + public FinderPatternInfo[] findMulti(Map hints) throws NotFoundException { + boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); + BitMatrix image = getImage(); + int maxI = image.getHeight(); + int maxJ = image.getWidth(); + // We are looking for black/white/black/white/black modules in + // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far + + // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the + // image, and then account for the center being 3 modules in size. This gives the smallest + // number of pixels the center could be, so skip this often. When trying harder, look for all + // QR versions regardless of how dense they are. + int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); + if (iSkip < MIN_SKIP || tryHarder) { + iSkip = MIN_SKIP; + } + + int[] stateCount = new int[5]; + for (int i = iSkip - 1; i < maxI; i += iSkip) { + // Get a row of black/white values + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + int currentState = 0; + for (int j = 0; j < maxJ; j++) { + if (image.get(j, i)) { + // Black pixel + if ((currentState & 1) == 1) { // Counting white pixels + currentState++; + } + stateCount[currentState]++; + } else { // White pixel + if ((currentState & 1) == 0) { // Counting black pixels + if (currentState == 4) { // A winner? + if (foundPatternCross(stateCount)) { // Yes + boolean confirmed = handlePossibleCenter(stateCount, i, j); + if (!confirmed) { + do { // Advance to next black pixel + j++; + } while (j < maxJ && !image.get(j, i)); + j--; // back up to that last white pixel + } + // Clear state to start looking again + currentState = 0; + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + } else { // No, shift counts back by two + stateCount[0] = stateCount[2]; + stateCount[1] = stateCount[3]; + stateCount[2] = stateCount[4]; + stateCount[3] = 1; + stateCount[4] = 0; + currentState = 3; + } + } else { + stateCount[++currentState]++; + } + } else { // Counting white pixels + stateCount[currentState]++; + } + } + } // for j=... + + if (foundPatternCross(stateCount)) { + handlePossibleCenter(stateCount, i, maxJ); + } // end if foundPatternCross + } // for i=iSkip-1 ... + FinderPattern[][] patternInfo = selectMutipleBestPatterns(); + List result = new ArrayList(); + for (FinderPattern[] pattern : patternInfo) { + ResultPoint.orderBestPatterns(pattern); + result.add(new FinderPatternInfo(pattern)); + } + + if (result.isEmpty()) { + return EMPTY_RESULT_ARRAY; + } else { + return result.toArray(new FinderPatternInfo[result.size()]); + } + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/CodaBarReader.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/CodaBarReader.java index 99e9fdd..724ff79 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/CodaBarReader.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/CodaBarReader.java @@ -1,329 +1,329 @@ -/* - * Copyright 2008 ZXing authors - * - * 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. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.Map; - -/** - *

Decodes Codabar barcodes.

- * - * @author Bas Vijfwinkel - * @author David Walker - */ -public final class CodaBarReader extends OneDReader { - - // These values are critical for determining how permissive the decoding - // will be. All stripe sizes must be within the window these define, as - // compared to the average stripe size. - private static final int MAX_ACCEPTABLE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 2.0f); - private static final int PADDING = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 1.5f); - - private static final String ALPHABET_STRING = "0123456789-$:/.+ABCD"; - static final char[] ALPHABET = ALPHABET_STRING.toCharArray(); - - /** - * These represent the encodings of characters, as patterns of wide and narrow bars. The 7 least-significant bits of - * each int correspond to the pattern of wide and narrow, with 1s representing "wide" and 0s representing narrow. - */ - static final int[] CHARACTER_ENCODINGS = { - 0x003, 0x006, 0x009, 0x060, 0x012, 0x042, 0x021, 0x024, 0x030, 0x048, // 0-9 - 0x00c, 0x018, 0x045, 0x051, 0x054, 0x015, 0x01A, 0x029, 0x00B, 0x00E, // -$:/.+ABCD - }; - - // minimal number of characters that should be present (inclusing start and stop characters) - // under normal circumstances this should be set to 3, but can be set higher - // as a last-ditch attempt to reduce false positives. - private static final int MIN_CHARACTER_LENGTH = 3; - - // official start and end patterns - private static final char[] STARTEND_ENCODING = {'A', 'B', 'C', 'D'}; - // some codabar generator allow the codabar string to be closed by every - // character. This will cause lots of false positives! - - // some industries use a checksum standard but this is not part of the original codabar standard - // for more information see : http://www.mecsw.com/specs/codabar.html - - // Keep some instance variables to avoid reallocations - private final StringBuilder decodeRowResult; - private int[] counters; - private int counterLength; - - public CodaBarReader() { - decodeRowResult = new StringBuilder(20); - counters = new int[80]; - counterLength = 0; - } - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) throws NotFoundException { - - setCounters(row); - int startOffset = findStartPattern(); - int nextStart = startOffset; - - decodeRowResult.setLength(0); - do { - int charOffset = toNarrowWidePattern(nextStart); - if (charOffset == -1) { - throw NotFoundException.getNotFoundInstance(); - } - // Hack: We store the position in the alphabet table into a - // StringBuilder, so that we can access the decoded patterns in - // validatePattern. We'll translate to the actual characters later. - decodeRowResult.append((char)charOffset); - nextStart += 8; - // Stop as soon as we see the end character. - if (decodeRowResult.length() > 1 && - arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { - break; - } - } while (nextStart < counterLength); // no fixed end pattern so keep on reading while data is available - - // Look for whitespace after pattern: - int trailingWhitespace = counters[nextStart - 1]; - int lastPatternSize = 0; - for (int i = -8; i < -1; i++) { - lastPatternSize += counters[nextStart + i]; - } - - // We need to see whitespace equal to 50% of the last pattern size, - // otherwise this is probably a false positive. The exception is if we are - // at the end of the row. (I.e. the barcode barely fits.) - if (nextStart < counterLength && trailingWhitespace < lastPatternSize / 2) { - throw NotFoundException.getNotFoundInstance(); - } - - validatePattern(startOffset); - - // Translate character table offsets to actual characters. - for (int i = 0; i < decodeRowResult.length(); i++) { - decodeRowResult.setCharAt(i, ALPHABET[decodeRowResult.charAt(i)]); - } - // Ensure a valid start and end character - char startchar = decodeRowResult.charAt(0); - if (!arrayContains(STARTEND_ENCODING, startchar)) { - throw NotFoundException.getNotFoundInstance(); - } - char endchar = decodeRowResult.charAt(decodeRowResult.length() - 1); - if (!arrayContains(STARTEND_ENCODING, endchar)) { - throw NotFoundException.getNotFoundInstance(); - } - - // remove stop/start characters character and check if a long enough string is contained - if (decodeRowResult.length() <= MIN_CHARACTER_LENGTH) { - // Almost surely a false positive ( start + stop + at least 1 character) - throw NotFoundException.getNotFoundInstance(); - } - - decodeRowResult.deleteCharAt(decodeRowResult.length() - 1); - decodeRowResult.deleteCharAt(0); - - int runningCount = 0; - for (int i = 0; i < startOffset; i++) { - runningCount += counters[i]; - } - float left = (float) runningCount; - for (int i = startOffset; i < nextStart - 1; i++) { - runningCount += counters[i]; - } - float right = (float) runningCount; - return new Result( - decodeRowResult.toString(), - null, - new ResultPoint[]{ - new ResultPoint(left, (float) rowNumber), - new ResultPoint(right, (float) rowNumber)}, - BarcodeFormat.CODABAR); - } - - void validatePattern(int start) throws NotFoundException { - // First, sum up the total size of our four categories of stripe sizes; - int[] sizes = {0, 0, 0, 0}; - int[] counts = {0, 0, 0, 0}; - int end = decodeRowResult.length() - 1; - - // We break out of this loop in the middle, in order to handle - // inter-character spaces properly. - int pos = start; - for (int i = 0; true; i++) { - int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)]; - for (int j = 6; j >= 0; j--) { - // Even j = bars, while odd j = spaces. Categories 2 and 3 are for - // long stripes, while 0 and 1 are for short stripes. - int category = (j & 1) + (pattern & 1) * 2; - sizes[category] += counters[pos + j]; - counts[category]++; - pattern >>= 1; - } - if (i >= end) { - break; - } - // We ignore the inter-character space - it could be of any size. - pos += 8; - } - - // Calculate our allowable size thresholds using fixed-point math. - int[] maxes = new int[4]; - int[] mins = new int[4]; - // Define the threshold of acceptability to be the midpoint between the - // average small stripe and the average large stripe. No stripe lengths - // should be on the "wrong" side of that line. - for (int i = 0; i < 2; i++) { - mins[i] = 0; // Accept arbitrarily small "short" stripes. - mins[i + 2] = ((sizes[i] << INTEGER_MATH_SHIFT) / counts[i] + - (sizes[i + 2] << INTEGER_MATH_SHIFT) / counts[i + 2]) >> 1; - maxes[i] = mins[i + 2]; - maxes[i + 2] = (sizes[i + 2] * MAX_ACCEPTABLE + PADDING) / counts[i + 2]; - } - - // Now verify that all of the stripes are within the thresholds. - pos = start; - for (int i = 0; true; i++) { - int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)]; - for (int j = 6; j >= 0; j--) { - // Even j = bars, while odd j = spaces. Categories 2 and 3 are for - // long stripes, while 0 and 1 are for short stripes. - int category = (j & 1) + (pattern & 1) * 2; - int size = counters[pos + j] << INTEGER_MATH_SHIFT; - if (size < mins[category] || size > maxes[category]) { - throw NotFoundException.getNotFoundInstance(); - } - pattern >>= 1; - } - if (i >= end) { - break; - } - pos += 8; - } - } - - /** - * Records the size of all runs of white and black pixels, starting with white. - * This is just like recordPattern, except it records all the counters, and - * uses our builtin "counters" member for storage. - * @param row row to count from - */ - private void setCounters(BitArray row) throws NotFoundException { - counterLength = 0; - // Start from the first white bit. - int i = row.getNextUnset(0); - int end = row.getSize(); - if (i >= end) { - throw NotFoundException.getNotFoundInstance(); - } - boolean isWhite = true; - int count = 0; - for (; i < end; i++) { - if (row.get(i) ^ isWhite) { // that is, exactly one is true - count++; - } else { - counterAppend(count); - count = 1; - isWhite = !isWhite; - } - } - counterAppend(count); - } - - private void counterAppend(int e) { - counters[counterLength] = e; - counterLength++; - if (counterLength >= counters.length) { - int[] temp = new int[counterLength * 2]; - System.arraycopy(counters, 0, temp, 0, counterLength); - counters = temp; - } - } - - private int findStartPattern() throws NotFoundException { - for (int i = 1; i < counterLength; i += 2) { - int charOffset = toNarrowWidePattern(i); - if (charOffset != -1 && arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { - // Look for whitespace before start pattern, >= 50% of width of start pattern - // We make an exception if the whitespace is the first element. - int patternSize = 0; - for (int j = i; j < i + 7; j++) { - patternSize += counters[j]; - } - if (i == 1 || counters[i-1] >= patternSize / 2) { - return i; - } - } - } - throw NotFoundException.getNotFoundInstance(); - } - - static boolean arrayContains(char[] array, char key) { - if (array != null) { - for (char c : array) { - if (c == key) { - return true; - } - } - } - return false; - } - - // Assumes that counters[position] is a bar. - private int toNarrowWidePattern(int position) { - int end = position + 7; - if (end >= counterLength) { - return -1; - } - // First element is for bars, second is for spaces. - int[] maxes = {0, 0}; - int[] mins = {Integer.MAX_VALUE, Integer.MAX_VALUE}; - int[] thresholds = {0, 0}; - - for (int i = 0; i < 2; i++) { - for (int j = position + i; j < end; j += 2) { - if (counters[j] < mins[i]) { - mins[i] = counters[j]; - } - if (counters[j] > maxes[i]) { - maxes[i] = counters[j]; - } - } - thresholds[i] = (mins[i] + maxes[i]) / 2; - } - - int bitmask = 1 << 7; - int pattern = 0; - for (int i = 0; i < 7; i++) { - int barOrSpace = i & 1; - bitmask >>= 1; - if (counters[position + i] > thresholds[barOrSpace]) { - pattern |= bitmask; - } - } - - for (int i = 0; i < CHARACTER_ENCODINGS.length; i++) { - if (CHARACTER_ENCODINGS[i] == pattern) { - return i; - } - } - return -1; - } - -} +/* + * Copyright 2008 ZXing authors + * + * 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. + */ + +package com.google.zxing.oned; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.DecodeHintType; +import com.google.zxing.NotFoundException; +import com.google.zxing.Result; +import com.google.zxing.ResultPoint; +import com.google.zxing.common.BitArray; + +import java.util.Map; + +/** + *

Decodes Codabar barcodes.

+ * + * @author Bas Vijfwinkel + * @author David Walker + */ +public final class CodaBarReader extends OneDReader { + + // These values are critical for determining how permissive the decoding + // will be. All stripe sizes must be within the window these define, as + // compared to the average stripe size. + private static final int MAX_ACCEPTABLE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 2.0f); + private static final int PADDING = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 1.5f); + + private static final String ALPHABET_STRING = "0123456789-$:/.+ABCD"; + static final char[] ALPHABET = ALPHABET_STRING.toCharArray(); + + /** + * These represent the encodings of characters, as patterns of wide and narrow bars. The 7 least-significant bits of + * each int correspond to the pattern of wide and narrow, with 1s representing "wide" and 0s representing narrow. + */ + static final int[] CHARACTER_ENCODINGS = { + 0x003, 0x006, 0x009, 0x060, 0x012, 0x042, 0x021, 0x024, 0x030, 0x048, // 0-9 + 0x00c, 0x018, 0x045, 0x051, 0x054, 0x015, 0x01A, 0x029, 0x00B, 0x00E, // -$:/.+ABCD + }; + + // minimal number of characters that should be present (inclusing start and stop characters) + // under normal circumstances this should be set to 3, but can be set higher + // as a last-ditch attempt to reduce false positives. + private static final int MIN_CHARACTER_LENGTH = 3; + + // official start and end patterns + private static final char[] STARTEND_ENCODING = {'A', 'B', 'C', 'D'}; + // some codabar generator allow the codabar string to be closed by every + // character. This will cause lots of false positives! + + // some industries use a checksum standard but this is not part of the original codabar standard + // for more information see : http://www.mecsw.com/specs/codabar.html + + // Keep some instance variables to avoid reallocations + private final StringBuilder decodeRowResult; + private int[] counters; + private int counterLength; + + public CodaBarReader() { + decodeRowResult = new StringBuilder(20); + counters = new int[80]; + counterLength = 0; + } + + @Override + public Result decodeRow(int rowNumber, BitArray row, Map hints) throws NotFoundException { + + setCounters(row); + int startOffset = findStartPattern(); + int nextStart = startOffset; + + decodeRowResult.setLength(0); + do { + int charOffset = toNarrowWidePattern(nextStart); + if (charOffset == -1) { + throw NotFoundException.getNotFoundInstance(); + } + // Hack: We store the position in the alphabet table into a + // StringBuilder, so that we can access the decoded patterns in + // validatePattern. We'll translate to the actual characters later. + decodeRowResult.append((char)charOffset); + nextStart += 8; + // Stop as soon as we see the end character. + if (decodeRowResult.length() > 1 && + arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { + break; + } + } while (nextStart < counterLength); // no fixed end pattern so keep on reading while data is available + + // Look for whitespace after pattern: + int trailingWhitespace = counters[nextStart - 1]; + int lastPatternSize = 0; + for (int i = -8; i < -1; i++) { + lastPatternSize += counters[nextStart + i]; + } + + // We need to see whitespace equal to 50% of the last pattern size, + // otherwise this is probably a false positive. The exception is if we are + // at the end of the row. (I.e. the barcode barely fits.) + if (nextStart < counterLength && trailingWhitespace < lastPatternSize / 2) { + throw NotFoundException.getNotFoundInstance(); + } + + validatePattern(startOffset); + + // Translate character table offsets to actual characters. + for (int i = 0; i < decodeRowResult.length(); i++) { + decodeRowResult.setCharAt(i, ALPHABET[decodeRowResult.charAt(i)]); + } + // Ensure a valid start and end character + char startchar = decodeRowResult.charAt(0); + if (!arrayContains(STARTEND_ENCODING, startchar)) { + throw NotFoundException.getNotFoundInstance(); + } + char endchar = decodeRowResult.charAt(decodeRowResult.length() - 1); + if (!arrayContains(STARTEND_ENCODING, endchar)) { + throw NotFoundException.getNotFoundInstance(); + } + + // remove stop/start characters character and check if a long enough string is contained + if (decodeRowResult.length() <= MIN_CHARACTER_LENGTH) { + // Almost surely a false positive ( start + stop + at least 1 character) + throw NotFoundException.getNotFoundInstance(); + } + + decodeRowResult.deleteCharAt(decodeRowResult.length() - 1); + decodeRowResult.deleteCharAt(0); + + int runningCount = 0; + for (int i = 0; i < startOffset; i++) { + runningCount += counters[i]; + } + float left = (float) runningCount; + for (int i = startOffset; i < nextStart - 1; i++) { + runningCount += counters[i]; + } + float right = (float) runningCount; + return new Result( + decodeRowResult.toString(), + null, + new ResultPoint[]{ + new ResultPoint(left, (float) rowNumber), + new ResultPoint(right, (float) rowNumber)}, + BarcodeFormat.CODABAR); + } + + void validatePattern(int start) throws NotFoundException { + // First, sum up the total size of our four categories of stripe sizes; + int[] sizes = {0, 0, 0, 0}; + int[] counts = {0, 0, 0, 0}; + int end = decodeRowResult.length() - 1; + + // We break out of this loop in the middle, in order to handle + // inter-character spaces properly. + int pos = start; + for (int i = 0; true; i++) { + int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)]; + for (int j = 6; j >= 0; j--) { + // Even j = bars, while odd j = spaces. Categories 2 and 3 are for + // long stripes, while 0 and 1 are for short stripes. + int category = (j & 1) + (pattern & 1) * 2; + sizes[category] += counters[pos + j]; + counts[category]++; + pattern >>= 1; + } + if (i >= end) { + break; + } + // We ignore the inter-character space - it could be of any size. + pos += 8; + } + + // Calculate our allowable size thresholds using fixed-point math. + int[] maxes = new int[4]; + int[] mins = new int[4]; + // Define the threshold of acceptability to be the midpoint between the + // average small stripe and the average large stripe. No stripe lengths + // should be on the "wrong" side of that line. + for (int i = 0; i < 2; i++) { + mins[i] = 0; // Accept arbitrarily small "short" stripes. + mins[i + 2] = ((sizes[i] << INTEGER_MATH_SHIFT) / counts[i] + + (sizes[i + 2] << INTEGER_MATH_SHIFT) / counts[i + 2]) >> 1; + maxes[i] = mins[i + 2]; + maxes[i + 2] = (sizes[i + 2] * MAX_ACCEPTABLE + PADDING) / counts[i + 2]; + } + + // Now verify that all of the stripes are within the thresholds. + pos = start; + for (int i = 0; true; i++) { + int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)]; + for (int j = 6; j >= 0; j--) { + // Even j = bars, while odd j = spaces. Categories 2 and 3 are for + // long stripes, while 0 and 1 are for short stripes. + int category = (j & 1) + (pattern & 1) * 2; + int size = counters[pos + j] << INTEGER_MATH_SHIFT; + if (size < mins[category] || size > maxes[category]) { + throw NotFoundException.getNotFoundInstance(); + } + pattern >>= 1; + } + if (i >= end) { + break; + } + pos += 8; + } + } + + /** + * Records the size of all runs of white and black pixels, starting with white. + * This is just like recordPattern, except it records all the counters, and + * uses our builtin "counters" member for storage. + * @param row row to count from + */ + private void setCounters(BitArray row) throws NotFoundException { + counterLength = 0; + // Start from the first white bit. + int i = row.getNextUnset(0); + int end = row.getSize(); + if (i >= end) { + throw NotFoundException.getNotFoundInstance(); + } + boolean isWhite = true; + int count = 0; + for (; i < end; i++) { + if (row.get(i) ^ isWhite) { // that is, exactly one is true + count++; + } else { + counterAppend(count); + count = 1; + isWhite = !isWhite; + } + } + counterAppend(count); + } + + private void counterAppend(int e) { + counters[counterLength] = e; + counterLength++; + if (counterLength >= counters.length) { + int[] temp = new int[counterLength * 2]; + System.arraycopy(counters, 0, temp, 0, counterLength); + counters = temp; + } + } + + private int findStartPattern() throws NotFoundException { + for (int i = 1; i < counterLength; i += 2) { + int charOffset = toNarrowWidePattern(i); + if (charOffset != -1 && arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { + // Look for whitespace before start pattern, >= 50% of width of start pattern + // We make an exception if the whitespace is the first element. + int patternSize = 0; + for (int j = i; j < i + 7; j++) { + patternSize += counters[j]; + } + if (i == 1 || counters[i-1] >= patternSize / 2) { + return i; + } + } + } + throw NotFoundException.getNotFoundInstance(); + } + + static boolean arrayContains(char[] array, char key) { + if (array != null) { + for (char c : array) { + if (c == key) { + return true; + } + } + } + return false; + } + + // Assumes that counters[position] is a bar. + private int toNarrowWidePattern(int position) { + int end = position + 7; + if (end >= counterLength) { + return -1; + } + // First element is for bars, second is for spaces. + int[] maxes = {0, 0}; + int[] mins = {Integer.MAX_VALUE, Integer.MAX_VALUE}; + int[] thresholds = {0, 0}; + + for (int i = 0; i < 2; i++) { + for (int j = position + i; j < end; j += 2) { + if (counters[j] < mins[i]) { + mins[i] = counters[j]; + } + if (counters[j] > maxes[i]) { + maxes[i] = counters[j]; + } + } + thresholds[i] = (mins[i] + maxes[i]) / 2; + } + + int bitmask = 1 << 7; + int pattern = 0; + for (int i = 0; i < 7; i++) { + int barOrSpace = i & 1; + bitmask >>= 1; + if (counters[position + i] > thresholds[barOrSpace]) { + pattern |= bitmask; + } + } + + for (int i = 0; i < CHARACTER_ENCODINGS.length; i++) { + if (CHARACTER_ENCODINGS[i] == pattern) { + return i; + } + } + return -1; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/ITFReader.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/ITFReader.java index 4ecff40..559c93b 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/ITFReader.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/oned/ITFReader.java @@ -1,347 +1,347 @@ -/* - * Copyright 2008 ZXing authors - * - * 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. - */ - -package com.google.zxing.oned; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Result; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitArray; - -import java.util.Map; - -/** - *

Implements decoding of the ITF format, or Interleaved Two of Five.

- * - *

This Reader will scan ITF barcodes of certain lengths only. - * At the moment it reads length 6, 10, 12, 14, 16, 24, and 44 as these have appeared "in the wild". Not all - * lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of - * required checksum function.

- * - *

The checksum is optional and is not applied by this Reader. The consumer of the decoded - * value will have to apply a checksum if required.

- * - *

http://en.wikipedia.org/wiki/Interleaved_2_of_5 - * is a great reference for Interleaved 2 of 5 information.

- * - * @author kevin.osullivan@sita.aero, SITA Lab. - */ -public final class ITFReader extends OneDReader { - - private static final int MAX_AVG_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f); - private static final int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f); - - private static final int W = 3; // Pixel width of a wide line - private static final int N = 1; // Pixed width of a narrow line - - private static final int[] DEFAULT_ALLOWED_LENGTHS = { 44, 24, 20, 18, 16, 14, 12, 10, 8, 6 }; - - // Stores the actual narrow line width of the image being decoded. - private int narrowLineWidth = -1; - - /** - * Start/end guard pattern. - * - * Note: The end pattern is reversed because the row is reversed before - * searching for the END_PATTERN - */ - private static final int[] START_PATTERN = {N, N, N, N}; - private static final int[] END_PATTERN_REVERSED = {N, N, W}; - - /** - * Patterns of Wide / Narrow lines to indicate each digit - */ - static final int[][] PATTERNS = { - {N, N, W, W, N}, // 0 - {W, N, N, N, W}, // 1 - {N, W, N, N, W}, // 2 - {W, W, N, N, N}, // 3 - {N, N, W, N, W}, // 4 - {W, N, W, N, N}, // 5 - {N, W, W, N, N}, // 6 - {N, N, N, W, W}, // 7 - {W, N, N, W, N}, // 8 - {N, W, N, W, N} // 9 - }; - - @Override - public Result decodeRow(int rowNumber, BitArray row, Map hints) - throws FormatException, NotFoundException { - - // Find out where the Middle section (payload) starts & ends - int[] startRange = decodeStart(row); - int[] endRange = decodeEnd(row); - - StringBuilder result = new StringBuilder(20); - decodeMiddle(row, startRange[1], endRange[0], result); - String resultString = result.toString(); - - int[] allowedLengths = null; - if (hints != null) { - allowedLengths = (int[]) hints.get(DecodeHintType.ALLOWED_LENGTHS); - - } - if (allowedLengths == null) { - allowedLengths = DEFAULT_ALLOWED_LENGTHS; - } - - // To avoid false positives with 2D barcodes (and other patterns), make - // an assumption that the decoded string must be 6, 10 or 14 digits. - int length = resultString.length(); - boolean lengthOK = false; - for (int allowedLength : allowedLengths) { - if (length == allowedLength) { - lengthOK = true; - break; - } - } - if (!lengthOK) { - throw FormatException.getFormatInstance(); - } - - return new Result( - resultString, - null, // no natural byte representation for these barcodes - new ResultPoint[] { new ResultPoint(startRange[1], (float) rowNumber), - new ResultPoint(endRange[0], (float) rowNumber)}, - BarcodeFormat.ITF); - } - - /** - * @param row row of black/white values to search - * @param payloadStart offset of start pattern - * @param resultString {@link StringBuilder} to append decoded chars to - * @throws NotFoundException if decoding could not complete successfully - */ - private static void decodeMiddle(BitArray row, - int payloadStart, - int payloadEnd, - StringBuilder resultString) throws NotFoundException { - - // Digits are interleaved in pairs - 5 black lines for one digit, and the - // 5 - // interleaved white lines for the second digit. - // Therefore, need to scan 10 lines and then - // split these into two arrays - int[] counterDigitPair = new int[10]; - int[] counterBlack = new int[5]; - int[] counterWhite = new int[5]; - - while (payloadStart < payloadEnd) { - - // Get 10 runs of black/white. - recordPattern(row, payloadStart, counterDigitPair); - // Split them into each array - for (int k = 0; k < 5; k++) { - int twoK = k << 1; - counterBlack[k] = counterDigitPair[twoK]; - counterWhite[k] = counterDigitPair[twoK + 1]; - } - - int bestMatch = decodeDigit(counterBlack); - resultString.append((char) ('0' + bestMatch)); - bestMatch = decodeDigit(counterWhite); - resultString.append((char) ('0' + bestMatch)); - - for (int counterDigit : counterDigitPair) { - payloadStart += counterDigit; - } - } - } - - /** - * Identify where the start of the middle / payload section starts. - * - * @param row row of black/white values to search - * @return Array, containing index of start of 'start block' and end of - * 'start block' - * @throws NotFoundException - */ - int[] decodeStart(BitArray row) throws NotFoundException { - int endStart = skipWhiteSpace(row); - int[] startPattern = findGuardPattern(row, endStart, START_PATTERN); - - // Determine the width of a narrow line in pixels. We can do this by - // getting the width of the start pattern and dividing by 4 because its - // made up of 4 narrow lines. - this.narrowLineWidth = (startPattern[1] - startPattern[0]) >> 2; - - validateQuietZone(row, startPattern[0]); - - return startPattern; - } - - /** - * The start & end patterns must be pre/post fixed by a quiet zone. This - * zone must be at least 10 times the width of a narrow line. Scan back until - * we either get to the start of the barcode or match the necessary number of - * quiet zone pixels. - * - * Note: Its assumed the row is reversed when using this method to find - * quiet zone after the end pattern. - * - * ref: http://www.barcode-1.net/i25code.html - * - * @param row bit array representing the scanned barcode. - * @param startPattern index into row of the start or end pattern. - * @throws NotFoundException if the quiet zone cannot be found, a ReaderException is thrown. - */ - private void validateQuietZone(BitArray row, int startPattern) throws NotFoundException { - - int quietCount = this.narrowLineWidth * 10; // expect to find this many pixels of quiet zone - - for (int i = startPattern - 1; quietCount > 0 && i >= 0; i--) { - if (row.get(i)) { - break; - } - quietCount--; - } - if (quietCount != 0) { - // Unable to find the necessary number of quiet zone pixels. - throw NotFoundException.getNotFoundInstance(); - } - } - - /** - * Skip all whitespace until we get to the first black line. - * - * @param row row of black/white values to search - * @return index of the first black line. - * @throws NotFoundException Throws exception if no black lines are found in the row - */ - private static int skipWhiteSpace(BitArray row) throws NotFoundException { - int width = row.getSize(); - int endStart = row.getNextSet(0); - if (endStart == width) { - throw NotFoundException.getNotFoundInstance(); - } - - return endStart; - } - - /** - * Identify where the end of the middle / payload section ends. - * - * @param row row of black/white values to search - * @return Array, containing index of start of 'end block' and end of 'end - * block' - * @throws NotFoundException - */ - int[] decodeEnd(BitArray row) throws NotFoundException { - - // For convenience, reverse the row and then - // search from 'the start' for the end block - row.reverse(); - try { - int endStart = skipWhiteSpace(row); - int[] endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED); - - // The start & end patterns must be pre/post fixed by a quiet zone. This - // zone must be at least 10 times the width of a narrow line. - // ref: http://www.barcode-1.net/i25code.html - validateQuietZone(row, endPattern[0]); - - // Now recalculate the indices of where the 'endblock' starts & stops to - // accommodate - // the reversed nature of the search - int temp = endPattern[0]; - endPattern[0] = row.getSize() - endPattern[1]; - endPattern[1] = row.getSize() - temp; - - return endPattern; - } finally { - // Put the row back the right way. - row.reverse(); - } - } - - /** - * @param row row of black/white values to search - * @param rowOffset position to start search - * @param pattern pattern of counts of number of black and white pixels that are - * being searched for as a pattern - * @return start/end horizontal offset of guard pattern, as an array of two - * ints - * @throws NotFoundException if pattern is not found - */ - private static int[] findGuardPattern(BitArray row, - int rowOffset, - int[] pattern) throws NotFoundException { - - // TODO: This is very similar to implementation in UPCEANReader. Consider if they can be - // merged to a single method. - int patternLength = pattern.length; - int[] counters = new int[patternLength]; - int width = row.getSize(); - boolean isWhite = false; - - int counterPosition = 0; - int patternStart = rowOffset; - for (int x = rowOffset; x < width; x++) { - if (row.get(x) ^ isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) { - return new int[]{patternStart, x}; - } - patternStart += counters[0] + counters[1]; - System.arraycopy(counters, 2, counters, 0, patternLength - 2); - counters[patternLength - 2] = 0; - counters[patternLength - 1] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Attempts to decode a sequence of ITF black/white lines into single - * digit. - * - * @param counters the counts of runs of observed black/white/black/... values - * @return The decoded digit - * @throws NotFoundException if digit cannot be decoded - */ - private static int decodeDigit(int[] counters) throws NotFoundException { - - int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept - int bestMatch = -1; - int max = PATTERNS.length; - for (int i = 0; i < max; i++) { - int[] pattern = PATTERNS[i]; - int variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = i; - } - } - if (bestMatch >= 0) { - return bestMatch; - } else { - throw NotFoundException.getNotFoundInstance(); - } - } - -} +/* + * Copyright 2008 ZXing authors + * + * 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. + */ + +package com.google.zxing.oned; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.DecodeHintType; +import com.google.zxing.FormatException; +import com.google.zxing.NotFoundException; +import com.google.zxing.Result; +import com.google.zxing.ResultPoint; +import com.google.zxing.common.BitArray; + +import java.util.Map; + +/** + *

Implements decoding of the ITF format, or Interleaved Two of Five.

+ * + *

This Reader will scan ITF barcodes of certain lengths only. + * At the moment it reads length 6, 10, 12, 14, 16, 24, and 44 as these have appeared "in the wild". Not all + * lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of + * required checksum function.

+ * + *

The checksum is optional and is not applied by this Reader. The consumer of the decoded + * value will have to apply a checksum if required.

+ * + *

http://en.wikipedia.org/wiki/Interleaved_2_of_5 + * is a great reference for Interleaved 2 of 5 information.

+ * + * @author kevin.osullivan@sita.aero, SITA Lab. + */ +public final class ITFReader extends OneDReader { + + private static final int MAX_AVG_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f); + private static final int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f); + + private static final int W = 3; // Pixel width of a wide line + private static final int N = 1; // Pixed width of a narrow line + + private static final int[] DEFAULT_ALLOWED_LENGTHS = { 44, 24, 20, 18, 16, 14, 12, 10, 8, 6 }; + + // Stores the actual narrow line width of the image being decoded. + private int narrowLineWidth = -1; + + /** + * Start/end guard pattern. + * + * Note: The end pattern is reversed because the row is reversed before + * searching for the END_PATTERN + */ + private static final int[] START_PATTERN = {N, N, N, N}; + private static final int[] END_PATTERN_REVERSED = {N, N, W}; + + /** + * Patterns of Wide / Narrow lines to indicate each digit + */ + static final int[][] PATTERNS = { + {N, N, W, W, N}, // 0 + {W, N, N, N, W}, // 1 + {N, W, N, N, W}, // 2 + {W, W, N, N, N}, // 3 + {N, N, W, N, W}, // 4 + {W, N, W, N, N}, // 5 + {N, W, W, N, N}, // 6 + {N, N, N, W, W}, // 7 + {W, N, N, W, N}, // 8 + {N, W, N, W, N} // 9 + }; + + @Override + public Result decodeRow(int rowNumber, BitArray row, Map hints) + throws FormatException, NotFoundException { + + // Find out where the Middle section (payload) starts & ends + int[] startRange = decodeStart(row); + int[] endRange = decodeEnd(row); + + StringBuilder result = new StringBuilder(20); + decodeMiddle(row, startRange[1], endRange[0], result); + String resultString = result.toString(); + + int[] allowedLengths = null; + if (hints != null) { + allowedLengths = (int[]) hints.get(DecodeHintType.ALLOWED_LENGTHS); + + } + if (allowedLengths == null) { + allowedLengths = DEFAULT_ALLOWED_LENGTHS; + } + + // To avoid false positives with 2D barcodes (and other patterns), make + // an assumption that the decoded string must be 6, 10 or 14 digits. + int length = resultString.length(); + boolean lengthOK = false; + for (int allowedLength : allowedLengths) { + if (length == allowedLength) { + lengthOK = true; + break; + } + } + if (!lengthOK) { + throw FormatException.getFormatInstance(); + } + + return new Result( + resultString, + null, // no natural byte representation for these barcodes + new ResultPoint[] { new ResultPoint(startRange[1], (float) rowNumber), + new ResultPoint(endRange[0], (float) rowNumber)}, + BarcodeFormat.ITF); + } + + /** + * @param row row of black/white values to search + * @param payloadStart offset of start pattern + * @param resultString {@link StringBuilder} to append decoded chars to + * @throws NotFoundException if decoding could not complete successfully + */ + private static void decodeMiddle(BitArray row, + int payloadStart, + int payloadEnd, + StringBuilder resultString) throws NotFoundException { + + // Digits are interleaved in pairs - 5 black lines for one digit, and the + // 5 + // interleaved white lines for the second digit. + // Therefore, need to scan 10 lines and then + // split these into two arrays + int[] counterDigitPair = new int[10]; + int[] counterBlack = new int[5]; + int[] counterWhite = new int[5]; + + while (payloadStart < payloadEnd) { + + // Get 10 runs of black/white. + recordPattern(row, payloadStart, counterDigitPair); + // Split them into each array + for (int k = 0; k < 5; k++) { + int twoK = k << 1; + counterBlack[k] = counterDigitPair[twoK]; + counterWhite[k] = counterDigitPair[twoK + 1]; + } + + int bestMatch = decodeDigit(counterBlack); + resultString.append((char) ('0' + bestMatch)); + bestMatch = decodeDigit(counterWhite); + resultString.append((char) ('0' + bestMatch)); + + for (int counterDigit : counterDigitPair) { + payloadStart += counterDigit; + } + } + } + + /** + * Identify where the start of the middle / payload section starts. + * + * @param row row of black/white values to search + * @return Array, containing index of start of 'start block' and end of + * 'start block' + * @throws NotFoundException + */ + int[] decodeStart(BitArray row) throws NotFoundException { + int endStart = skipWhiteSpace(row); + int[] startPattern = findGuardPattern(row, endStart, START_PATTERN); + + // Determine the width of a narrow line in pixels. We can do this by + // getting the width of the start pattern and dividing by 4 because its + // made up of 4 narrow lines. + this.narrowLineWidth = (startPattern[1] - startPattern[0]) >> 2; + + validateQuietZone(row, startPattern[0]); + + return startPattern; + } + + /** + * The start & end patterns must be pre/post fixed by a quiet zone. This + * zone must be at least 10 times the width of a narrow line. Scan back until + * we either get to the start of the barcode or match the necessary number of + * quiet zone pixels. + * + * Note: Its assumed the row is reversed when using this method to find + * quiet zone after the end pattern. + * + * ref: http://www.barcode-1.net/i25code.html + * + * @param row bit array representing the scanned barcode. + * @param startPattern index into row of the start or end pattern. + * @throws NotFoundException if the quiet zone cannot be found, a ReaderException is thrown. + */ + private void validateQuietZone(BitArray row, int startPattern) throws NotFoundException { + + int quietCount = this.narrowLineWidth * 10; // expect to find this many pixels of quiet zone + + for (int i = startPattern - 1; quietCount > 0 && i >= 0; i--) { + if (row.get(i)) { + break; + } + quietCount--; + } + if (quietCount != 0) { + // Unable to find the necessary number of quiet zone pixels. + throw NotFoundException.getNotFoundInstance(); + } + } + + /** + * Skip all whitespace until we get to the first black line. + * + * @param row row of black/white values to search + * @return index of the first black line. + * @throws NotFoundException Throws exception if no black lines are found in the row + */ + private static int skipWhiteSpace(BitArray row) throws NotFoundException { + int width = row.getSize(); + int endStart = row.getNextSet(0); + if (endStart == width) { + throw NotFoundException.getNotFoundInstance(); + } + + return endStart; + } + + /** + * Identify where the end of the middle / payload section ends. + * + * @param row row of black/white values to search + * @return Array, containing index of start of 'end block' and end of 'end + * block' + * @throws NotFoundException + */ + int[] decodeEnd(BitArray row) throws NotFoundException { + + // For convenience, reverse the row and then + // search from 'the start' for the end block + row.reverse(); + try { + int endStart = skipWhiteSpace(row); + int[] endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED); + + // The start & end patterns must be pre/post fixed by a quiet zone. This + // zone must be at least 10 times the width of a narrow line. + // ref: http://www.barcode-1.net/i25code.html + validateQuietZone(row, endPattern[0]); + + // Now recalculate the indices of where the 'endblock' starts & stops to + // accommodate + // the reversed nature of the search + int temp = endPattern[0]; + endPattern[0] = row.getSize() - endPattern[1]; + endPattern[1] = row.getSize() - temp; + + return endPattern; + } finally { + // Put the row back the right way. + row.reverse(); + } + } + + /** + * @param row row of black/white values to search + * @param rowOffset position to start search + * @param pattern pattern of counts of number of black and white pixels that are + * being searched for as a pattern + * @return start/end horizontal offset of guard pattern, as an array of two + * ints + * @throws NotFoundException if pattern is not found + */ + private static int[] findGuardPattern(BitArray row, + int rowOffset, + int[] pattern) throws NotFoundException { + + // TODO: This is very similar to implementation in UPCEANReader. Consider if they can be + // merged to a single method. + int patternLength = pattern.length; + int[] counters = new int[patternLength]; + int width = row.getSize(); + boolean isWhite = false; + + int counterPosition = 0; + int patternStart = rowOffset; + for (int x = rowOffset; x < width; x++) { + if (row.get(x) ^ isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == patternLength - 1) { + if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) { + return new int[]{patternStart, x}; + } + patternStart += counters[0] + counters[1]; + System.arraycopy(counters, 2, counters, 0, patternLength - 2); + counters[patternLength - 2] = 0; + counters[patternLength - 1] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw NotFoundException.getNotFoundInstance(); + } + + /** + * Attempts to decode a sequence of ITF black/white lines into single + * digit. + * + * @param counters the counts of runs of observed black/white/black/... values + * @return The decoded digit + * @throws NotFoundException if digit cannot be decoded + */ + private static int decodeDigit(int[] counters) throws NotFoundException { + + int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept + int bestMatch = -1; + int max = PATTERNS.length; + for (int i = 0; i < max; i++) { + int[] pattern = PATTERNS[i]; + int variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = i; + } + } + if (bestMatch >= 0) { + return bestMatch; + } else { + throw NotFoundException.getNotFoundInstance(); + } + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/PDF417Reader.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/PDF417Reader.java index b1b3bb8..7f1d12f 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/PDF417Reader.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/PDF417Reader.java @@ -1,194 +1,194 @@ -/* - * Copyright 2009 ZXing authors - * - * 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. - */ - -package com.google.zxing.pdf417; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.NotFoundException; -import com.google.zxing.Reader; -import com.google.zxing.Result; -import com.google.zxing.ResultPoint; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.DetectorResult; -import com.google.zxing.pdf417.decoder.Decoder; -import com.google.zxing.pdf417.detector.Detector; - -import java.util.Map; - -/** - * This implementation can detect and decode PDF417 codes in an image. - * - * @author SITA Lab (kevin.osullivan@sita.aero) - */ -public final class PDF417Reader implements Reader { - - private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; - - private final Decoder decoder = new Decoder(); - - /** - * Locates and decodes a PDF417 code in an image. - * - * @return a String representing the content encoded by the PDF417 code - * @throws NotFoundException if a PDF417 code cannot be found, - * @throws FormatException if a PDF417 cannot be decoded - */ - @Override - public Result decode(BinaryBitmap image) throws NotFoundException, FormatException, ChecksumException { - return decode(image, null); - } - - @Override - public Result decode(BinaryBitmap image, Map hints) - throws NotFoundException, FormatException, ChecksumException { - DecoderResult decoderResult; - ResultPoint[] points; - if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { - BitMatrix bits = extractPureBits(image.getBlackMatrix()); - decoderResult = decoder.decode(bits); - points = NO_POINTS; - } else { - DetectorResult detectorResult = new Detector(image).detect(); - decoderResult = decoder.decode(detectorResult.getBits()); - points = detectorResult.getPoints(); - } - return new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, - BarcodeFormat.PDF_417); - } - - @Override - public void reset() { - // do nothing - } - - /** - * This method detects a code in a "pure" image -- that is, pure monochrome image - * which contains only an unrotated, unskewed, image of a code, with some white border - * around it. This is a specialized method that works exceptionally fast in this special - * case. - * - * @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix) - * @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix) - */ - private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException { - - int[] leftTopBlack = image.getTopLeftOnBit(); - int[] rightBottomBlack = image.getBottomRightOnBit(); - if (leftTopBlack == null || rightBottomBlack == null) { - throw NotFoundException.getNotFoundInstance(); - } - - int moduleSize = moduleSize(leftTopBlack, image); - - int top = leftTopBlack[1]; - int bottom = rightBottomBlack[1]; - int left = findPatternStart(leftTopBlack[0], top, image); - int right = findPatternEnd(leftTopBlack[0], top, image); - - int matrixWidth = (right - left + 1) / moduleSize; - int matrixHeight = (bottom - top + 1) / moduleSize; - if (matrixWidth <= 0 || matrixHeight <= 0) { - throw NotFoundException.getNotFoundInstance(); - } - - // Push in the "border" by half the module width so that we start - // sampling in the middle of the module. Just in case the image is a - // little off, this will help recover. - int nudge = moduleSize >> 1; - top += nudge; - left += nudge; - - // Now just read off the bits - BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight); - for (int y = 0; y < matrixHeight; y++) { - int iOffset = top + y * moduleSize; - for (int x = 0; x < matrixWidth; x++) { - if (image.get(left + x * moduleSize, iOffset)) { - bits.set(x, y); - } - } - } - return bits; - } - - private static int moduleSize(int[] leftTopBlack, BitMatrix image) throws NotFoundException { - int x = leftTopBlack[0]; - int y = leftTopBlack[1]; - int width = image.getWidth(); - while (x < width && image.get(x, y)) { - x++; - } - if (x == width) { - throw NotFoundException.getNotFoundInstance(); - } - - int moduleSize = (x - leftTopBlack[0]) >>> 3; // We've crossed left first bar, which is 8x - if (moduleSize == 0) { - throw NotFoundException.getNotFoundInstance(); - } - - return moduleSize; - } - - private static int findPatternStart(int x, int y, BitMatrix image) throws NotFoundException { - int width = image.getWidth(); - int start = x; - // start should be on black - int transitions = 0; - boolean black = true; - while (start < width - 1 && transitions < 8) { - start++; - boolean newBlack = image.get(start, y); - if (black != newBlack) { - transitions++; - } - black = newBlack; - } - if (start == width - 1) { - throw NotFoundException.getNotFoundInstance(); - } - return start; - } - - private static int findPatternEnd(int x, int y, BitMatrix image) throws NotFoundException { - int width = image.getWidth(); - int end = width - 1; - // end should be on black - while (end > x && !image.get(end, y)) { - end--; - } - int transitions = 0; - boolean black = true; - while (end > x && transitions < 9) { - end--; - boolean newBlack = image.get(end, y); - if (black != newBlack) { - transitions++; - } - black = newBlack; - } - if (end == x) { - throw NotFoundException.getNotFoundInstance(); - } - return end; - } - -} +/* + * Copyright 2009 ZXing authors + * + * 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. + */ + +package com.google.zxing.pdf417; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.BinaryBitmap; +import com.google.zxing.ChecksumException; +import com.google.zxing.DecodeHintType; +import com.google.zxing.FormatException; +import com.google.zxing.NotFoundException; +import com.google.zxing.Reader; +import com.google.zxing.Result; +import com.google.zxing.ResultPoint; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.DecoderResult; +import com.google.zxing.common.DetectorResult; +import com.google.zxing.pdf417.decoder.Decoder; +import com.google.zxing.pdf417.detector.Detector; + +import java.util.Map; + +/** + * This implementation can detect and decode PDF417 codes in an image. + * + * @author SITA Lab (kevin.osullivan@sita.aero) + */ +public final class PDF417Reader implements Reader { + + private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; + + private final Decoder decoder = new Decoder(); + + /** + * Locates and decodes a PDF417 code in an image. + * + * @return a String representing the content encoded by the PDF417 code + * @throws NotFoundException if a PDF417 code cannot be found, + * @throws FormatException if a PDF417 cannot be decoded + */ + @Override + public Result decode(BinaryBitmap image) throws NotFoundException, FormatException, ChecksumException { + return decode(image, null); + } + + @Override + public Result decode(BinaryBitmap image, Map hints) + throws NotFoundException, FormatException, ChecksumException { + DecoderResult decoderResult; + ResultPoint[] points; + if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { + BitMatrix bits = extractPureBits(image.getBlackMatrix()); + decoderResult = decoder.decode(bits); + points = NO_POINTS; + } else { + DetectorResult detectorResult = new Detector(image).detect(); + decoderResult = decoder.decode(detectorResult.getBits()); + points = detectorResult.getPoints(); + } + return new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, + BarcodeFormat.PDF_417); + } + + @Override + public void reset() { + // do nothing + } + + /** + * This method detects a code in a "pure" image -- that is, pure monochrome image + * which contains only an unrotated, unskewed, image of a code, with some white border + * around it. This is a specialized method that works exceptionally fast in this special + * case. + * + * @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix) + * @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix) + */ + private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException { + + int[] leftTopBlack = image.getTopLeftOnBit(); + int[] rightBottomBlack = image.getBottomRightOnBit(); + if (leftTopBlack == null || rightBottomBlack == null) { + throw NotFoundException.getNotFoundInstance(); + } + + int moduleSize = moduleSize(leftTopBlack, image); + + int top = leftTopBlack[1]; + int bottom = rightBottomBlack[1]; + int left = findPatternStart(leftTopBlack[0], top, image); + int right = findPatternEnd(leftTopBlack[0], top, image); + + int matrixWidth = (right - left + 1) / moduleSize; + int matrixHeight = (bottom - top + 1) / moduleSize; + if (matrixWidth <= 0 || matrixHeight <= 0) { + throw NotFoundException.getNotFoundInstance(); + } + + // Push in the "border" by half the module width so that we start + // sampling in the middle of the module. Just in case the image is a + // little off, this will help recover. + int nudge = moduleSize >> 1; + top += nudge; + left += nudge; + + // Now just read off the bits + BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight); + for (int y = 0; y < matrixHeight; y++) { + int iOffset = top + y * moduleSize; + for (int x = 0; x < matrixWidth; x++) { + if (image.get(left + x * moduleSize, iOffset)) { + bits.set(x, y); + } + } + } + return bits; + } + + private static int moduleSize(int[] leftTopBlack, BitMatrix image) throws NotFoundException { + int x = leftTopBlack[0]; + int y = leftTopBlack[1]; + int width = image.getWidth(); + while (x < width && image.get(x, y)) { + x++; + } + if (x == width) { + throw NotFoundException.getNotFoundInstance(); + } + + int moduleSize = (x - leftTopBlack[0]) >>> 3; // We've crossed left first bar, which is 8x + if (moduleSize == 0) { + throw NotFoundException.getNotFoundInstance(); + } + + return moduleSize; + } + + private static int findPatternStart(int x, int y, BitMatrix image) throws NotFoundException { + int width = image.getWidth(); + int start = x; + // start should be on black + int transitions = 0; + boolean black = true; + while (start < width - 1 && transitions < 8) { + start++; + boolean newBlack = image.get(start, y); + if (black != newBlack) { + transitions++; + } + black = newBlack; + } + if (start == width - 1) { + throw NotFoundException.getNotFoundInstance(); + } + return start; + } + + private static int findPatternEnd(int x, int y, BitMatrix image) throws NotFoundException { + int width = image.getWidth(); + int end = width - 1; + // end should be on black + while (end > x && !image.get(end, y)) { + end--; + } + int transitions = 0; + boolean black = true; + while (end > x && transitions < 9) { + end--; + boolean newBlack = image.get(end, y); + if (black != newBlack) { + transitions++; + } + black = newBlack; + } + if (end == x) { + throw NotFoundException.getNotFoundInstance(); + } + return end; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/BitMatrixParser.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/BitMatrixParser.java index d556d30..9e5139f 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/BitMatrixParser.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/BitMatrixParser.java @@ -1,932 +1,932 @@ -/* - * Copyright 2009 ZXing authors - * - * 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. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - *

- * This class parses the BitMatrix image into codewords. - *

- * - * @author SITA Lab (kevin.osullivan@sita.aero) - */ -final class BitMatrixParser { - - private static final int[] NO_ERRORS = new int[0]; - - private static final int MAX_ROW_DIFFERENCE = 6; - private static final int MAX_ROWS = 90; - //private static final int MAX_COLUMNS = 30; - // Maximum Codewords (Data + Error) - private static final int MAX_CW_CAPACITY = 929; - private static final int MODULES_IN_SYMBOL = 17; - - private final BitMatrix bitMatrix; - private int rows = 0; - //private int columns = 0; - - private int leftColumnECData = 0; - private int rightColumnECData = 0; - private int eraseCount = 0; - private int[] erasures; - private int ecLevel = -1; - - BitMatrixParser(BitMatrix bitMatrix) { - this.bitMatrix = bitMatrix; - } - - /** - * To ensure separability of rows, codewords of consecutive rows belong to - * different subsets of all possible codewords. This routine scans the - * symbols in the barcode. When it finds a number of consecutive rows which - * are the same, it assumes that this is a row of codewords and processes - * them into a codeword array. - * - * @return an array of codewords. - */ - int[] readCodewords() throws FormatException { - int width = bitMatrix.getWidth(); - int height = bitMatrix.getHeight(); - - erasures = new int[MAX_CW_CAPACITY]; - - // Get the number of pixels in a module across the X dimension - //float moduleWidth = bitMatrix.getModuleWidth(); - float moduleWidth = 1.0f; // Image has been sampled and reduced - - int[] rowCounters = new int[width]; - int[] codewords = new int[MAX_CW_CAPACITY]; - int next = 0; - int matchingConsecutiveScans = 0; - boolean rowInProgress = false; - int rowNumber = 0; - int rowHeight = 0; - for (int i = 1; i < height; i++) { - if (rowNumber >= MAX_ROWS) { - // Something is wrong, since we have exceeded - // the maximum rows in the specification. - throw FormatException.getFormatInstance(); - } - int rowDifference = 0; - // Scan a line of modules and check the - // difference between this and the previous line - for (int j = 0; j < width; j++) { - // Accumulate differences between this line and the - // previous line. - if (bitMatrix.get(j, i) != bitMatrix.get(j, i - 1)) { - rowDifference++; - } - } - if (rowDifference <= moduleWidth * MAX_ROW_DIFFERENCE) { - for (int j = 0; j < width; j++) { - // Accumulate the black pixels on this line - if (bitMatrix.get(j, i)) { - rowCounters[j]++; - } - } - // Increment the number of consecutive rows of pixels - // that are more or less the same - matchingConsecutiveScans++; - // Height of a row is a multiple of the module size in pixels - // It's supposed to be >= 3x module width, but, accept anything >= 2x - if ((matchingConsecutiveScans + 1) >= 2.0f * moduleWidth) { - // We have some previous matches as well as a match here - // Set processing a unique row. - rowInProgress = true; - } - } else { - if (rowInProgress) { - // Process Row - next = processRow(rowCounters, rowNumber, rowHeight, codewords, next); - if (next == -1) { - // Something is wrong, since we have exceeded - // the maximum columns in the specification. - throw FormatException.getFormatInstance(); - } - // Reinitialize the row counters. - for (int j = 0; j < rowCounters.length; j++) { - rowCounters[j] = 0; - } - rowNumber++; - rowHeight = 0; - } - matchingConsecutiveScans = 0; - rowInProgress = false; - } - rowHeight++; - } - // Check for a row that was in progress before we exited above. - if (rowInProgress) { - // Process Row - if (rowNumber >= MAX_ROWS) { - // Something is wrong, since we have exceeded - // the maximum rows in the specification. - throw FormatException.getFormatInstance(); - } - next = processRow(rowCounters, rowNumber, rowHeight, codewords, next); - rowNumber++; - rows = rowNumber; - } - erasures = trimArray(erasures, eraseCount); - return trimArray(codewords, next); - } - - /** - * Trim the array to the required size. - * - * @param array the array - * @param size the size to trim it to - * @return the new trimmed array - */ - private static int[] trimArray(int[] array, int size) { - if (size < 0) { - throw new IllegalArgumentException(); - } - if (size == 0) { - return NO_ERRORS; - } - int[] a = new int[size]; - System.arraycopy(array, 0, a, 0, size); - return a; - } - - /** - * Convert the symbols in the row to codewords. - * Each PDF417 symbol character consists of four bar elements and four space - * elements, each of which can be one to six modules wide. The four bar and - * four space elements shall measure 17 modules in total. - * - * @param rowCounters an array containing the counts of black pixels for each column - * in the row. - * @param rowNumber the current row number of codewords. - * @param rowHeight the height of this row in pixels. - * @param codewords the codeword array to save codewords into. - * @param next the next available index into the codewords array. - * @return the next available index into the codeword array after processing - * this row. - */ - int processRow(int[] rowCounters, int rowNumber, int rowHeight, int[] codewords, int next) - throws FormatException { - int width = bitMatrix.getWidth(); - int columnNumber = 0; - long symbol = 0; - for (int i = 0; i < width; i += MODULES_IN_SYMBOL) { - // This happens in real life and is almost surely a rare misdecode - if (i + MODULES_IN_SYMBOL > rowCounters.length) { - throw FormatException.getFormatInstance(); - } - for (int mask = MODULES_IN_SYMBOL - 1; mask >= 0; mask--) { - if (rowCounters[i + (MODULES_IN_SYMBOL - 1 - mask)] >= rowHeight >>> 1) { - symbol |= 1L << mask; - } - } - if (columnNumber > 0) { - int cw = getCodeword(symbol); - if (cw < 0 && i < width - MODULES_IN_SYMBOL) { - // Skip errors on the Right row indicator column - if (eraseCount >= erasures.length) { - throw FormatException.getFormatInstance(); - } - erasures[eraseCount] = next; - next++; - eraseCount++; - } else { - codewords[next++] = cw; - } - } else { - // Left row indicator column - int cw = getCodeword(symbol); - if (ecLevel < 0) { - if (rowNumber % 3 == 1) { - leftColumnECData = cw; - } - } - } - symbol = 0; - //columns = columnNumber; - columnNumber++; - } - if (columnNumber > 1) { - // Right row indicator column is in codeword[next] - //columns--; - // Overwrite the last codeword i.e. Right Row Indicator - --next; - if (ecLevel < 0) { - if (rowNumber % 3 == 2) { - rightColumnECData = codewords[next]; - if (rightColumnECData == leftColumnECData && leftColumnECData != 0) { - ecLevel = ((rightColumnECData % 30) - rows % 3) / 3; - } - } - } - codewords[next] = 0; - } - return next; - } - - /** - * Translate the symbol into a codeword. - * - * @param symbol - * @return the codeword corresponding to the symbol. - */ - private static int getCodeword(long symbol) { - long sym = symbol & 0x3FFFF; - int i = findCodewordIndex(sym); - if (i == -1) { - return -1; - } else { - long cw = CODEWORD_TABLE[i] - 1; - cw %= 929; - return (int) cw; - } - } - - /** - * Use a binary search to find the index of the codeword corresponding to - * this symbol. - * - * @param symbol the symbol from the barcode. - * @return the index into the codeword table. - */ - private static int findCodewordIndex(long symbol) { - int first = 0; - int upto = SYMBOL_TABLE.length; - while (first < upto) { - int mid = (first + upto) >>> 1; // Compute mid point. - if (symbol < SYMBOL_TABLE[mid]) { - upto = mid; // repeat search in bottom half. - } else if (symbol > SYMBOL_TABLE[mid]) { - first = mid + 1; // Repeat search in top half. - } else { - return mid; // Found it. return position - } - } - return -1; - } - - /** - * Returns an array of locations representing the erasures. - */ - public int[] getErasures() { - return erasures; - } - - public int getECLevel() { - return ecLevel; - } - - /** - * The sorted table of all possible symbols. Extracted from the PDF417 - * specification. The index of a symbol in this table corresponds to the - * index into the codeword table. - */ - private static final int[] SYMBOL_TABLE = {0x1025e, 0x1027a, 0x1029e, - 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396, - 0x103a6, 0x103ac, 0x10422, 0x10428, 0x10436, 0x10442, 0x10444, - 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482, - 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, - 0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e, 0x10520, 0x1053c, - 0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, - 0x105ce, 0x105dc, 0x105e2, 0x105e4, 0x105e8, 0x105f6, 0x1062e, - 0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa, - 0x10716, 0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e, - 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, 0x10822, - 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, - 0x1087a, 0x10882, 0x10884, 0x10890, 0x1089e, 0x108a0, 0x108bc, - 0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, - 0x10908, 0x1091e, 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, - 0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4, - 0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c, - 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, 0x10b18, 0x10b30, - 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2, - 0x10bc4, 0x10bc8, 0x10bd0, 0x10bde, 0x10be6, 0x10bec, 0x10c2e, - 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, - 0x10c9c, 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, - 0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, 0x10d70, - 0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0, - 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, 0x10dee, 0x10df2, 0x10df4, - 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86, - 0x10e8c, 0x10e98, 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a, - 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44, - 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, - 0x11022, 0x11028, 0x11042, 0x11048, 0x11050, 0x1105e, 0x1107a, - 0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, - 0x110cc, 0x110d8, 0x110ee, 0x110f2, 0x110f4, 0x11102, 0x1111e, - 0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0, - 0x111be, 0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6, - 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, 0x11330, - 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, - 0x113c8, 0x113d0, 0x113de, 0x113e6, 0x113ec, 0x11408, 0x11410, - 0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, - 0x1160c, 0x11618, 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, - 0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784, - 0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc, - 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, 0x1185c, 0x11862, - 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2, - 0x118c8, 0x118d0, 0x118de, 0x118e6, 0x118ec, 0x118fa, 0x1190e, - 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, - 0x1199e, 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, - 0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, 0x11a7e, - 0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, - 0x11b40, 0x11b78, 0x11b8c, 0x11b98, 0x11bb0, 0x11bbe, 0x11bce, - 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26, - 0x11c2c, 0x11c46, 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98, - 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8, - 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, - 0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, 0x11dc8, 0x11dd0, - 0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, - 0x11e22, 0x11e24, 0x11e28, 0x11e36, 0x11e42, 0x11e44, 0x11e50, - 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90, - 0x11e9e, 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee, - 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, 0x11f62, - 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, - 0x12090, 0x1209e, 0x120a0, 0x120bc, 0x120d8, 0x120f2, 0x120f4, - 0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, - 0x12198, 0x121b0, 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, - 0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306, - 0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c, - 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, 0x123ec, 0x1241e, - 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660, - 0x1267c, 0x126c0, 0x126f8, 0x12738, 0x12770, 0x1277e, 0x12782, - 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, - 0x127d8, 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, - 0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60, 0x12c7c, - 0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, - 0x12ee0, 0x12efc, 0x12f04, 0x12f08, 0x12f10, 0x12f20, 0x12f3c, - 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe, - 0x12fce, 0x12fdc, 0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068, - 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de, - 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, - 0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc, 0x131c6, 0x131cc, - 0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, - 0x132e0, 0x132fc, 0x13308, 0x1331e, 0x13320, 0x1333c, 0x13340, - 0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc, - 0x133e2, 0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438, - 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, 0x13608, - 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, - 0x1370c, 0x13718, 0x13730, 0x1373e, 0x13760, 0x1377c, 0x1379c, - 0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, - 0x137ec, 0x13816, 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, - 0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce, - 0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930, - 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, 0x139b8, 0x139c8, - 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c, - 0x13a18, 0x13a30, 0x13a3e, 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, - 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, - 0x13b9e, 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, - 0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28, 0x13c36, - 0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, - 0x13c84, 0x13c90, 0x13c9e, 0x13ca0, 0x13cbc, 0x13cc6, 0x13ccc, - 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e, - 0x13d20, 0x13d3c, 0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98, - 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6, - 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, - 0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, 0x13eb8, 0x13ec2, - 0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, - 0x13f2c, 0x13f3a, 0x13f46, 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, - 0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108, - 0x14110, 0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c, - 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, 0x14208, - 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, - 0x14306, 0x1430c, 0x14318, 0x14330, 0x1433e, 0x14360, 0x1437c, - 0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, - 0x14408, 0x14410, 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, - 0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660, - 0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e, - 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, 0x147bc, 0x147c6, - 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840, - 0x14878, 0x148f0, 0x149e0, 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, - 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, - 0x14ee0, 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, - 0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98, 0x14fb0, - 0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0, - 0x153c0, 0x15860, 0x1587c, 0x158c0, 0x158f8, 0x159f0, 0x15be0, - 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08, - 0x15e10, 0x15e20, 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18, - 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e, - 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, - 0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170, 0x1617e, 0x16184, - 0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, - 0x161d8, 0x161f2, 0x161f4, 0x1620e, 0x1621c, 0x16238, 0x16270, - 0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e, - 0x16320, 0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398, - 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, 0x163e8, - 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, - 0x164fc, 0x165c0, 0x165f8, 0x16610, 0x1661e, 0x16620, 0x1663c, - 0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, - 0x1677c, 0x1678e, 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, - 0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870, - 0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e, - 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, 0x16de0, 0x16e18, - 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c, - 0x16f38, 0x16f70, 0x16f7e, 0x16f84, 0x16f88, 0x16f90, 0x16f9e, - 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, - 0x17046, 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, - 0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106, 0x1710c, - 0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c, - 0x171b8, 0x171c2, 0x171c4, 0x171c8, 0x171d0, 0x171de, 0x171e6, - 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e, - 0x17260, 0x1727c, 0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338, - 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc, - 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, - 0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0, 0x174f8, 0x175f0, - 0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, - 0x17708, 0x17710, 0x1771e, 0x17720, 0x1773c, 0x17740, 0x17778, - 0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8, - 0x17822, 0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848, - 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, 0x17888, - 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, - 0x178ee, 0x178f2, 0x178f4, 0x17902, 0x17904, 0x17908, 0x17910, - 0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, - 0x17998, 0x179b0, 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, - 0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20, - 0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18, - 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, 0x17b9c, 0x17bb8, - 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e, - 0x17c32, 0x17c34, 0x17c4e, 0x17c5c, 0x17c62, 0x17c64, 0x17c68, - 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, - 0x17cd0, 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, - 0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e, 0x17da0, - 0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, - 0x17e3a, 0x17e46, 0x17e4c, 0x17e58, 0x17e6e, 0x17e72, 0x17e74, - 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2, - 0x17ee4, 0x17ee8, 0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216, - 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274, - 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, - 0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426, 0x1842c, 0x1843a, - 0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, - 0x184be, 0x184ce, 0x184dc, 0x184e2, 0x184e4, 0x184e8, 0x184f6, - 0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c, - 0x1858e, 0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0, - 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, 0x18622, - 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, - 0x18684, 0x18688, 0x18690, 0x1869e, 0x186a0, 0x186bc, 0x186c6, - 0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, - 0x1875c, 0x18796, 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, - 0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872, - 0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc, - 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, 0x18930, 0x1893e, - 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0, - 0x189de, 0x189e6, 0x189ec, 0x189fa, 0x18a18, 0x18a30, 0x18a3e, - 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, - 0x18b7e, 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, - 0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, 0x18bf4, - 0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50, - 0x18c5e, 0x18c66, 0x18c7a, 0x18c82, 0x18c84, 0x18c90, 0x18c9e, - 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08, - 0x18d10, 0x18d1e, 0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86, - 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32, - 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, - 0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, 0x18ed0, 0x18efa, - 0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, - 0x18f8a, 0x18f92, 0x18f94, 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, - 0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074, - 0x19086, 0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2, - 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, 0x19160, - 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, - 0x191de, 0x191e6, 0x191ec, 0x191fa, 0x19218, 0x1923e, 0x19260, - 0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, - 0x19384, 0x19390, 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, - 0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460, - 0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e, - 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, 0x19710, 0x19720, - 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0, - 0x197be, 0x197ce, 0x197dc, 0x197e2, 0x197e4, 0x197e8, 0x19822, - 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, - 0x19882, 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, - 0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920, 0x1993c, - 0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4, - 0x199e8, 0x19a08, 0x19a10, 0x19a1e, 0x19a20, 0x19a3c, 0x19a40, - 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2, - 0x19bc4, 0x19bc8, 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e, - 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8, - 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, - 0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84, 0x19d88, 0x19d90, - 0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, - 0x19e46, 0x19e4c, 0x19e58, 0x19e74, 0x19e86, 0x19e8c, 0x19e98, - 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a, - 0x19f12, 0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44, - 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, 0x19fb2, - 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, - 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, 0x1a0e4, 0x1a0e8, 0x1a0f6, - 0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, - 0x1a18e, 0x1a19c, 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, - 0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260, - 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e, - 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, 0x1a3a0, 0x1a3bc, - 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418, - 0x1a430, 0x1a43e, 0x1a460, 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, - 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, - 0x1a704, 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, - 0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, 0x1a7ce, - 0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, - 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, 0x1ac70, 0x1ac7e, 0x1ace0, - 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20, - 0x1ae3c, 0x1ae40, 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18, - 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8, - 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, - 0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e, 0x1b0a0, 0x1b0bc, - 0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, - 0x1b11e, 0x1b120, 0x1b13c, 0x1b140, 0x1b178, 0x1b186, 0x1b198, - 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210, - 0x1b21e, 0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c, - 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, 0x1b3d0, - 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, - 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, 0x1b67c, 0x1b6c0, 0x1b738, - 0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, - 0x1b82e, 0x1b84e, 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, - 0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c, - 0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990, - 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, 0x1ba0e, 0x1ba1c, - 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10, - 0x1bb20, 0x1bb3c, 0x1bb40, 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, - 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, - 0x1bc72, 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, - 0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, 0x1bd18, - 0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, - 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, 0x1be12, 0x1be14, 0x1be22, - 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e, - 0x1be66, 0x1be82, 0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0, - 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34, - 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, - 0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162, 0x1c164, 0x1c168, - 0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, - 0x1c262, 0x1c264, 0x1c268, 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, - 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316, - 0x1c326, 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a, - 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, 0x1c464, - 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, - 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, 0x1c4fa, 0x1c51c, 0x1c538, - 0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, - 0x1c5a0, 0x1c5bc, 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, - 0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c, - 0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698, - 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, 0x1c6e4, 0x1c6e8, - 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744, - 0x1c748, 0x1c750, 0x1c75e, 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, - 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, - 0x1c85c, 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, - 0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, 0x1c8ec, - 0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984, - 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, 0x1c9c6, 0x1c9cc, 0x1c9d8, - 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0, - 0x1cafc, 0x1cb02, 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c, - 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe, - 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, - 0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, 0x1cc72, 0x1cc74, - 0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, - 0x1cd06, 0x1cd0c, 0x1cd18, 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, - 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6, - 0x1cdfa, 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66, - 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, 0x1cea0, - 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, - 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, 0x1cf68, 0x1cf96, 0x1cfa6, - 0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, - 0x1d04e, 0x1d05c, 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, - 0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de, - 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e, - 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, 0x1d1a0, 0x1d1bc, - 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c, - 0x1d238, 0x1d270, 0x1d27e, 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, - 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, - 0x1d386, 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, - 0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, 0x1d4e0, - 0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620, - 0x1d640, 0x1d678, 0x1d6f0, 0x1d706, 0x1d70c, 0x1d718, 0x1d730, - 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2, - 0x1d7c4, 0x1d7c8, 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826, - 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874, - 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, - 0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, 0x1d930, 0x1d93e, - 0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, - 0x1d9e6, 0x1d9fa, 0x1da0c, 0x1da18, 0x1da30, 0x1da3e, 0x1da60, - 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88, - 0x1db90, 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22, - 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, 0x1dc7a, - 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, - 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, 0x1dd08, 0x1dd10, 0x1dd1e, - 0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, - 0x1dde2, 0x1dde4, 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, - 0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8, - 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16, - 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, 0x1df72, 0x1df74, - 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a, - 0x1e092, 0x1e094, 0x1e0a2, 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, - 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, - 0x1e142, 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, - 0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, 0x1e222, - 0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e, - 0x1e266, 0x1e26c, 0x1e27a, 0x1e282, 0x1e284, 0x1e288, 0x1e290, - 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2, - 0x1e2f4, 0x1e31a, 0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364, - 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428, - 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, - 0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e, 0x1e4a0, 0x1e4bc, - 0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, - 0x1e504, 0x1e508, 0x1e510, 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, - 0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce, - 0x1e5dc, 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e, - 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, 0x1e68e, - 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, - 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, 0x1e73a, 0x1e746, 0x1e74c, - 0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, - 0x1e7a8, 0x1e7b6, 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, - 0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866, - 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e, - 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, 0x1e8ee, 0x1e8f2, - 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c, - 0x1e940, 0x1e978, 0x1e986, 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, - 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, - 0x1ea08, 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, - 0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, 0x1eb8e, - 0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, - 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, 0x1ec32, 0x1ec34, 0x1ec4e, - 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8, - 0x1ecc2, 0x1ecc4, 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e, - 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88, - 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, - 0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, 0x1ee58, 0x1ee6e, - 0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, - 0x1eece, 0x1eedc, 0x1eee2, 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, - 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50, - 0x1ef5e, 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4, - 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, 0x1f0d2, - 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, - 0x1f158, 0x1f16e, 0x1f172, 0x1f174, 0x1f18a, 0x1f192, 0x1f194, - 0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, - 0x1f23a, 0x1f246, 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, - 0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2, - 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322, - 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, 0x1f35e, 0x1f366, - 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426, - 0x1f42c, 0x1f43a, 0x1f446, 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, - 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, - 0x1f4dc, 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, - 0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, 0x1f59c, - 0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, - 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, 0x1f614, 0x1f622, 0x1f624, - 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e, - 0x1f666, 0x1f67a, 0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e, - 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e, - 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, - 0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, 0x1f7d2, 0x1f7d4, - 0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, - 0x1f92e, 0x1f932, 0x1f934, 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, - 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca, - 0x1f9d2, 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e, - 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, 0x1fa9c, - 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, - 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, 0x1fb3a, 0x1fb46, 0x1fb4c, - 0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, - 0x1fba2, 0x1fba4, 0x1fba8, 0x1fbb6, 0x1fbda}; - - /** - * This table contains to codewords for all symbols. - */ - private static final int[] CODEWORD_TABLE = {2627, 1819, 2622, 2621, 1813, - 1812, 2729, 2724, 2723, 2779, 2774, 2773, 902, 896, 908, 868, 865, - 861, 859, 2511, 873, 871, 1780, 835, 2493, 825, 2491, 842, 837, 844, - 1764, 1762, 811, 810, 809, 2483, 807, 2482, 806, 2480, 815, 814, 813, - 812, 2484, 817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635, 2626, - 2625, 2623, 2628, 1820, 2752, 2739, 2737, 2728, 2727, 2725, 2730, - 2785, 2783, 2778, 2777, 2775, 2780, 787, 781, 747, 739, 736, 2413, - 754, 752, 1719, 692, 689, 681, 2371, 678, 2369, 700, 697, 694, 703, - 1688, 1686, 642, 638, 2343, 631, 2341, 627, 2338, 651, 646, 643, 2345, - 654, 652, 1652, 1650, 1647, 1654, 601, 599, 2322, 596, 2321, 594, - 2319, 2317, 611, 610, 608, 606, 2324, 603, 2323, 615, 614, 612, 1617, - 1616, 1614, 1612, 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, - 909, 2509, 2507, 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, - 2489, 2487, 2485, 1748, 836, 834, 832, 830, 2494, 827, 2492, 843, 841, - 839, 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, - 2631, 2629, 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, - 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591, 588, 576, - 569, 566, 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, - 548, 1572, 1570, 481, 2245, 466, 2242, 462, 2239, 492, 485, 482, 2249, - 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, - 419, 2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, - 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155, 2152, 378, 377, 375, - 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, 1416, - 1414, 385, 1411, 384, 1423, 1422, 1420, 1424, 2461, 802, 2441, 2439, - 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, 756, 753, - 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, 680, 2370, - 702, 699, 696, 704, 1690, 1687, 2337, 2336, 2334, 2332, 1624, 2329, - 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, 645, 2346, 655, - 653, 1653, 1651, 1649, 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576, - 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900, 910, 2503, 2502, - 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, 866, 863, 2513, - 876, 874, 1782, 2720, 2713, 2711, 2697, 2694, 2691, 2702, 2672, 2670, - 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, 2639, 1822, - 2654, 2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, 2751, - 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142, 332, 2140, 345, - 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, 2132, - 1354, 1352, 1349, 1356, 262, 257, 2101, 253, 2096, 2093, 274, 273, - 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, 1318, - 2052, 202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, 224, - 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266, 1264, 1261, 1268, - 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, 2006, - 159, 2003, 2000, 172, 171, 169, 2012, 166, 2010, 1186, 1184, 1182, - 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, 2313, - 2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, 580, - 1591, 2272, 2267, 2264, 1547, 538, 536, 529, 2278, 525, 2275, 547, - 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, 2247, - 470, 2244, 465, 2241, 493, 488, 484, 2250, 498, 495, 1536, 1533, 1530, - 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, 414, 412, - 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, 418, 2201, 431, - 429, 1473, 1471, 1469, 1466, 434, 1477, 1475, 2478, 2472, 2470, 2459, - 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, 2440, 792, 789, - 785, 2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, 2405, 745, 741, - 2415, 758, 755, 1721, 2358, 2357, 2355, 2353, 1661, 2350, 1660, 2347, - 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, 683, 2372, 701, - 698, 705, 1691, 1689, 2619, 2617, 2610, 2608, 2605, 2613, 2593, 2588, - 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573, - 2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, 2514, - 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539, 906, 903, 911, 2721, - 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, - 1824, 2673, 2671, 2669, 2666, 1829, 2679, 2677, 1858, 1857, 2772, - 1854, 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133, - 131, 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, - 1130, 112, 110, 1974, 107, 1973, 104, 1971, 1969, 122, 121, 119, 117, - 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, - 1953, 81, 1952, 78, 1950, 1948, 1945, 94, 93, 91, 1959, 88, 1958, 85, - 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, 100, 1090, 1089, - 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, 1907, 59, 1926, 56, - 1925, 53, 1922, 1919, 66, 64, 1931, 61, 1929, 1042, 1040, 1038, 71, - 1035, 70, 1032, 68, 1048, 1047, 1045, 1043, 1050, 1049, 12, 10, 1869, - 1867, 1864, 1861, 21, 1880, 19, 1877, 1874, 1871, 28, 1888, 25, 1886, - 22, 1883, 982, 980, 977, 974, 32, 30, 991, 989, 987, 984, 34, 995, - 994, 992, 2151, 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, - 2138, 2136, 2134, 1359, 343, 341, 338, 2143, 335, 2141, 348, 347, 346, - 1376, 1374, 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308, 305, - 2131, 302, 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, - 1353, 1351, 1357, 2092, 2091, 2089, 2087, 1276, 2084, 1274, 2081, - 1271, 259, 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, - 2106, 281, 279, 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, - 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207, 2053, 205, 2051, 201, - 2049, 2046, 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, - 2069, 1259, 1257, 1254, 232, 1251, 230, 1267, 1265, 1263, 2316, 2315, - 2312, 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590, - 2288, 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, - 574, 571, 2298, 582, 581, 1592, 2263, 2262, 2260, 2258, 1545, 2255, - 1544, 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, - 2277, 546, 543, 549, 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, - 2214, 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480, 477, - 2248, 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, - 2477, 2476, 2474, 2479, 2469, 2468, 2466, 2464, 1730, 2473, 2471, - 2453, 2452, 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, - 804, 2428, 2427, 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, - 2434, 2431, 1727, 2444, 2442, 793, 791, 788, 795, 2388, 2386, 2384, - 1697, 2381, 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, - 2392, 1701, 2412, 2410, 2407, 751, 748, 744, 2416, 759, 757, 1807, - 2620, 2618, 1806, 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, - 2594, 2592, 2590, 2587, 1804, 2600, 2598, 1794, 1793, 1791, 1789, - 2564, 2562, 2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569, 2578, - 1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714, 1835, 1834, - 1832, 1830, 1839, 1837, 2700, 2698, 2695, 2704, 1817, 1811, 1810, 897, - 862, 1777, 829, 826, 838, 1760, 1758, 808, 2481, 1741, 1740, 1738, - 1743, 2624, 1818, 2726, 2776, 782, 740, 737, 1715, 686, 679, 695, - 1682, 1680, 639, 628, 2339, 647, 644, 1645, 1643, 1640, 1648, 602, - 600, 597, 595, 2320, 593, 2318, 609, 607, 604, 1611, 1610, 1608, 1606, - 613, 1615, 1613, 2328, 926, 924, 892, 886, 899, 857, 850, 2505, 1778, - 824, 823, 821, 819, 2488, 818, 2486, 833, 831, 828, 840, 1761, 1759, - 2649, 2632, 2630, 2746, 2734, 2732, 2782, 2781, 570, 567, 1587, 531, - 527, 523, 540, 1566, 1564, 476, 467, 463, 2240, 486, 483, 1524, 1521, - 1518, 1529, 411, 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, - 428, 1468, 1465, 2210, 366, 363, 2158, 360, 2156, 357, 2153, 376, 373, - 370, 2163, 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412, - 1421, 2175, 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, - 676, 674, 668, 2363, 665, 2360, 685, 1684, 1681, 626, 624, 622, 2335, - 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, 925, - 2530, 2527, 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, 851, 1779, - 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759, 2757, 2744, - 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, 300, 296, - 2126, 315, 312, 1347, 1342, 1350, 261, 258, 250, 2097, 246, 2094, 271, - 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, 203, 2048, 195, - 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, 225, 1234, 222, - 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997, 150, 1995, 147, 1992, - 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 170, - 1164, 167, 1185, 1183, 1180, 1177, 174, 1190, 1188, 2025, 2024, 2022, - 587, 586, 564, 559, 556, 2290, 573, 1588, 520, 518, 512, 2268, 508, - 2265, 530, 1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226, 479, 471, - 489, 1526, 1523, 1520, 397, 395, 2185, 392, 2183, 389, 2180, 2177, - 410, 2194, 402, 422, 1463, 1461, 1459, 1456, 1470, 2455, 799, 2433, - 2430, 779, 776, 773, 2397, 2394, 2390, 734, 728, 724, 746, 1717, 2356, - 2354, 2351, 2348, 1658, 677, 675, 673, 670, 667, 688, 1685, 1683, - 2606, 2589, 2586, 2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784, - 2532, 895, 893, 890, 2718, 2709, 2707, 2689, 2687, 2684, 2663, 2662, - 2660, 2658, 1825, 2667, 2769, 1852, 2760, 2758, 142, 141, 1139, 1138, - 134, 132, 129, 126, 1982, 1129, 1128, 1126, 1131, 113, 111, 108, 105, - 1972, 101, 1970, 120, 118, 115, 1109, 1108, 1106, 1104, 123, 1113, - 1111, 82, 79, 1951, 75, 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, - 1074, 1072, 98, 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, - 1916, 42, 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920, 1031, - 1030, 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, - 1046, 1044, 1944, 1943, 1941, 11, 9, 1868, 7, 1865, 1862, 1859, 20, - 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, 26, 23, 983, - 981, 978, 975, 33, 971, 31, 990, 988, 985, 1906, 1904, 1902, 993, 351, - 2145, 1383, 331, 330, 328, 326, 2137, 323, 2135, 339, 1372, 1370, 294, - 293, 291, 289, 2122, 286, 2120, 283, 2117, 309, 303, 317, 1348, 1346, - 1344, 245, 244, 242, 2090, 239, 2088, 236, 2085, 2082, 260, 2099, 249, - 270, 1307, 1305, 1303, 1300, 1314, 189, 2038, 186, 2036, 183, 2033, - 2030, 2026, 206, 198, 2047, 194, 216, 1247, 1245, 1243, 1240, 227, - 1237, 1255, 2310, 2302, 2300, 2286, 2284, 2281, 565, 563, 561, 558, - 575, 1589, 2261, 2259, 2256, 2253, 1542, 521, 519, 517, 514, 2270, - 511, 533, 1569, 1567, 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, - 456, 453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475, 2467, 2465, - 2451, 2449, 2446, 801, 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, - 778, 775, 2387, 2385, 2382, 2379, 1695, 2375, 1693, 2396, 735, 733, - 730, 727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, - 2579, 1800, 2591, 2550, 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, - 2719, 1841, 2710, 2708, 1833, 1831, 2690, 2688, 2686, 1815, 1809, - 1808, 1774, 1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676, - 1674, 633, 629, 1638, 1636, 1633, 1641, 598, 1605, 1604, 1602, 1600, - 605, 1609, 1607, 2327, 887, 853, 1775, 822, 820, 1757, 1755, 1584, - 524, 1560, 1558, 468, 464, 1514, 1511, 1508, 1519, 408, 404, 400, - 1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361, 358, 2154, 1401, - 1400, 1398, 1396, 374, 1393, 371, 1408, 1406, 1403, 1413, 2173, 2172, - 772, 726, 723, 1712, 672, 669, 666, 682, 1678, 1675, 625, 623, 621, - 618, 2331, 636, 632, 1639, 1637, 1635, 920, 918, 884, 880, 889, 849, - 848, 847, 846, 2497, 855, 852, 1776, 2641, 2742, 2787, 1380, 334, - 1367, 1365, 301, 297, 1340, 1338, 1335, 1343, 255, 251, 247, 1296, - 1291, 1288, 265, 1302, 1299, 2113, 204, 196, 192, 2042, 1232, 1230, - 1224, 214, 1220, 210, 1242, 1239, 1235, 1250, 2077, 2075, 151, 148, - 1993, 144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152, 157, 1173, - 1171, 1168, 1165, 168, 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, - 557, 1585, 516, 509, 1562, 1559, 458, 447, 2227, 472, 1516, 1513, - 1510, 398, 396, 393, 390, 2181, 386, 2178, 407, 1453, 1451, 1449, - 1446, 420, 1460, 2209, 769, 764, 720, 712, 2391, 729, 1713, 664, 663, - 661, 659, 2352, 656, 2349, 671, 1679, 1677, 2553, 922, 919, 2519, - 2516, 885, 883, 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, - 1136, 130, 127, 1125, 1124, 1122, 1127, 109, 106, 102, 1103, 1102, - 1100, 1098, 116, 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, - 1063, 90, 1060, 87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, - 1912, 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008, 51, 1029, - 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, 4, - 1863, 1, 1860, 956, 954, 952, 949, 946, 17, 14, 969, 967, 964, 961, - 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, 1896, 986, 1905, 1903, - 350, 349, 1381, 329, 327, 324, 1368, 1366, 292, 290, 287, 284, 2118, - 304, 1341, 1339, 1337, 1345, 243, 240, 237, 2086, 233, 2083, 254, - 1297, 1295, 1293, 1290, 1304, 2114, 190, 187, 184, 2034, 180, 2031, - 177, 2027, 199, 1233, 1231, 1229, 1226, 217, 1223, 1241, 2078, 2076, - 584, 555, 554, 552, 550, 2282, 562, 1586, 507, 506, 504, 502, 2257, - 499, 2254, 515, 1563, 1561, 445, 443, 441, 2219, 438, 2216, 435, 2212, - 460, 454, 475, 1517, 1515, 1512, 2447, 798, 797, 2422, 2419, 770, 768, - 766, 2383, 2380, 2376, 721, 719, 717, 714, 731, 1714, 2602, 2582, - 2580, 2548, 2546, 2543, 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, - 1771, 1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670, 1668, - 1631, 1629, 1626, 1634, 1599, 1598, 1596, 1594, 1603, 1601, 2326, - 1772, 1753, 1751, 1581, 1554, 1552, 1504, 1501, 1498, 1509, 1442, - 1437, 1434, 401, 1448, 1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, - 1399, 1397, 1394, 1404, 2171, 2170, 1708, 1672, 1669, 619, 1632, 1630, - 1628, 1773, 1378, 1363, 1361, 1333, 1328, 1336, 1286, 1281, 1278, 248, - 1292, 1289, 2111, 1218, 1216, 1210, 197, 1206, 193, 1228, 1225, 1221, - 1236, 2073, 2071, 1151, 1150, 1148, 1146, 152, 1143, 149, 1140, 145, - 1161, 1159, 1156, 1153, 158, 1169, 1166, 2017, 2016, 2014, 2019, 1582, - 510, 1556, 1553, 452, 448, 1506, 1500, 394, 391, 387, 1443, 1441, - 1439, 1436, 1450, 2207, 765, 716, 713, 1709, 662, 660, 657, 1673, - 1671, 916, 914, 879, 878, 877, 882, 1135, 1134, 1121, 1120, 1118, - 1123, 1097, 1096, 1094, 1092, 103, 1101, 1099, 1979, 1059, 1058, 1056, - 1054, 77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963, 1007, 1006, - 1004, 1002, 999, 41, 996, 37, 1017, 1015, 1012, 1009, 52, 1025, 1022, - 1936, 1935, 1933, 1938, 942, 940, 938, 935, 932, 5, 2, 955, 953, 950, - 947, 18, 943, 15, 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, - 1897, 1379, 325, 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, - 234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185, 181, 178, 2028, - 1219, 1217, 1215, 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, - 1583, 505, 503, 500, 513, 1557, 1555, 444, 442, 439, 436, 2213, 455, - 451, 1507, 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706, - 2377, 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, - 1769, 1749, 1747, 1499, 1438, 1435, 2204, 1390, 1388, 1385, 1395, - 2169, 2167, 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, - 1279, 2109, 1214, 1207, 1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, - 1157, 1154, 2013, 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, - 1433, 1431, 1428, 1425, 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, - 1095, 1093, 1978, 1057, 1055, 1052, 1062, 1962, 1960, 1005, 1003, - 1000, 997, 38, 1013, 1010, 1932, 1930, 1927, 1934, 941, 939, 936, 933, - 6, 930, 3, 951, 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, - 1377, 1360, 1358, 1327, 1325, 1322, 1331, 1277, 1275, 1272, 1269, 235, - 1284, 2110, 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, - 1580, 501, 1551, 1548, 440, 437, 1497, 1494, 1490, 1503, 761, 709, - 707, 1706, 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208, - 2058, 2054, 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, - 2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954, 1001, 998, 1924, 1921, - 1918, 1928, 937, 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, - 1323, 1273, 1270, 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, - 1543, 1540, 1484, 1481, 1478, 1491, 1700}; -} +/* + * Copyright 2009 ZXing authors + * + * 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. + */ + +package com.google.zxing.pdf417.decoder; + +import com.google.zxing.FormatException; +import com.google.zxing.common.BitMatrix; + +/** + *

+ * This class parses the BitMatrix image into codewords. + *

+ * + * @author SITA Lab (kevin.osullivan@sita.aero) + */ +final class BitMatrixParser { + + private static final int[] NO_ERRORS = new int[0]; + + private static final int MAX_ROW_DIFFERENCE = 6; + private static final int MAX_ROWS = 90; + //private static final int MAX_COLUMNS = 30; + // Maximum Codewords (Data + Error) + private static final int MAX_CW_CAPACITY = 929; + private static final int MODULES_IN_SYMBOL = 17; + + private final BitMatrix bitMatrix; + private int rows = 0; + //private int columns = 0; + + private int leftColumnECData = 0; + private int rightColumnECData = 0; + private int eraseCount = 0; + private int[] erasures; + private int ecLevel = -1; + + BitMatrixParser(BitMatrix bitMatrix) { + this.bitMatrix = bitMatrix; + } + + /** + * To ensure separability of rows, codewords of consecutive rows belong to + * different subsets of all possible codewords. This routine scans the + * symbols in the barcode. When it finds a number of consecutive rows which + * are the same, it assumes that this is a row of codewords and processes + * them into a codeword array. + * + * @return an array of codewords. + */ + int[] readCodewords() throws FormatException { + int width = bitMatrix.getWidth(); + int height = bitMatrix.getHeight(); + + erasures = new int[MAX_CW_CAPACITY]; + + // Get the number of pixels in a module across the X dimension + //float moduleWidth = bitMatrix.getModuleWidth(); + float moduleWidth = 1.0f; // Image has been sampled and reduced + + int[] rowCounters = new int[width]; + int[] codewords = new int[MAX_CW_CAPACITY]; + int next = 0; + int matchingConsecutiveScans = 0; + boolean rowInProgress = false; + int rowNumber = 0; + int rowHeight = 0; + for (int i = 1; i < height; i++) { + if (rowNumber >= MAX_ROWS) { + // Something is wrong, since we have exceeded + // the maximum rows in the specification. + throw FormatException.getFormatInstance(); + } + int rowDifference = 0; + // Scan a line of modules and check the + // difference between this and the previous line + for (int j = 0; j < width; j++) { + // Accumulate differences between this line and the + // previous line. + if (bitMatrix.get(j, i) != bitMatrix.get(j, i - 1)) { + rowDifference++; + } + } + if (rowDifference <= moduleWidth * MAX_ROW_DIFFERENCE) { + for (int j = 0; j < width; j++) { + // Accumulate the black pixels on this line + if (bitMatrix.get(j, i)) { + rowCounters[j]++; + } + } + // Increment the number of consecutive rows of pixels + // that are more or less the same + matchingConsecutiveScans++; + // Height of a row is a multiple of the module size in pixels + // It's supposed to be >= 3x module width, but, accept anything >= 2x + if ((matchingConsecutiveScans + 1) >= 2.0f * moduleWidth) { + // We have some previous matches as well as a match here + // Set processing a unique row. + rowInProgress = true; + } + } else { + if (rowInProgress) { + // Process Row + next = processRow(rowCounters, rowNumber, rowHeight, codewords, next); + if (next == -1) { + // Something is wrong, since we have exceeded + // the maximum columns in the specification. + throw FormatException.getFormatInstance(); + } + // Reinitialize the row counters. + for (int j = 0; j < rowCounters.length; j++) { + rowCounters[j] = 0; + } + rowNumber++; + rowHeight = 0; + } + matchingConsecutiveScans = 0; + rowInProgress = false; + } + rowHeight++; + } + // Check for a row that was in progress before we exited above. + if (rowInProgress) { + // Process Row + if (rowNumber >= MAX_ROWS) { + // Something is wrong, since we have exceeded + // the maximum rows in the specification. + throw FormatException.getFormatInstance(); + } + next = processRow(rowCounters, rowNumber, rowHeight, codewords, next); + rowNumber++; + rows = rowNumber; + } + erasures = trimArray(erasures, eraseCount); + return trimArray(codewords, next); + } + + /** + * Trim the array to the required size. + * + * @param array the array + * @param size the size to trim it to + * @return the new trimmed array + */ + private static int[] trimArray(int[] array, int size) { + if (size < 0) { + throw new IllegalArgumentException(); + } + if (size == 0) { + return NO_ERRORS; + } + int[] a = new int[size]; + System.arraycopy(array, 0, a, 0, size); + return a; + } + + /** + * Convert the symbols in the row to codewords. + * Each PDF417 symbol character consists of four bar elements and four space + * elements, each of which can be one to six modules wide. The four bar and + * four space elements shall measure 17 modules in total. + * + * @param rowCounters an array containing the counts of black pixels for each column + * in the row. + * @param rowNumber the current row number of codewords. + * @param rowHeight the height of this row in pixels. + * @param codewords the codeword array to save codewords into. + * @param next the next available index into the codewords array. + * @return the next available index into the codeword array after processing + * this row. + */ + int processRow(int[] rowCounters, int rowNumber, int rowHeight, int[] codewords, int next) + throws FormatException { + int width = bitMatrix.getWidth(); + int columnNumber = 0; + long symbol = 0; + for (int i = 0; i < width; i += MODULES_IN_SYMBOL) { + // This happens in real life and is almost surely a rare misdecode + if (i + MODULES_IN_SYMBOL > rowCounters.length) { + throw FormatException.getFormatInstance(); + } + for (int mask = MODULES_IN_SYMBOL - 1; mask >= 0; mask--) { + if (rowCounters[i + (MODULES_IN_SYMBOL - 1 - mask)] >= rowHeight >>> 1) { + symbol |= 1L << mask; + } + } + if (columnNumber > 0) { + int cw = getCodeword(symbol); + if (cw < 0 && i < width - MODULES_IN_SYMBOL) { + // Skip errors on the Right row indicator column + if (eraseCount >= erasures.length) { + throw FormatException.getFormatInstance(); + } + erasures[eraseCount] = next; + next++; + eraseCount++; + } else { + codewords[next++] = cw; + } + } else { + // Left row indicator column + int cw = getCodeword(symbol); + if (ecLevel < 0) { + if (rowNumber % 3 == 1) { + leftColumnECData = cw; + } + } + } + symbol = 0; + //columns = columnNumber; + columnNumber++; + } + if (columnNumber > 1) { + // Right row indicator column is in codeword[next] + //columns--; + // Overwrite the last codeword i.e. Right Row Indicator + --next; + if (ecLevel < 0) { + if (rowNumber % 3 == 2) { + rightColumnECData = codewords[next]; + if (rightColumnECData == leftColumnECData && leftColumnECData != 0) { + ecLevel = ((rightColumnECData % 30) - rows % 3) / 3; + } + } + } + codewords[next] = 0; + } + return next; + } + + /** + * Translate the symbol into a codeword. + * + * @param symbol + * @return the codeword corresponding to the symbol. + */ + private static int getCodeword(long symbol) { + long sym = symbol & 0x3FFFF; + int i = findCodewordIndex(sym); + if (i == -1) { + return -1; + } else { + long cw = CODEWORD_TABLE[i] - 1; + cw %= 929; + return (int) cw; + } + } + + /** + * Use a binary search to find the index of the codeword corresponding to + * this symbol. + * + * @param symbol the symbol from the barcode. + * @return the index into the codeword table. + */ + private static int findCodewordIndex(long symbol) { + int first = 0; + int upto = SYMBOL_TABLE.length; + while (first < upto) { + int mid = (first + upto) >>> 1; // Compute mid point. + if (symbol < SYMBOL_TABLE[mid]) { + upto = mid; // repeat search in bottom half. + } else if (symbol > SYMBOL_TABLE[mid]) { + first = mid + 1; // Repeat search in top half. + } else { + return mid; // Found it. return position + } + } + return -1; + } + + /** + * Returns an array of locations representing the erasures. + */ + public int[] getErasures() { + return erasures; + } + + public int getECLevel() { + return ecLevel; + } + + /** + * The sorted table of all possible symbols. Extracted from the PDF417 + * specification. The index of a symbol in this table corresponds to the + * index into the codeword table. + */ + private static final int[] SYMBOL_TABLE = {0x1025e, 0x1027a, 0x1029e, + 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396, + 0x103a6, 0x103ac, 0x10422, 0x10428, 0x10436, 0x10442, 0x10444, + 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482, + 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, + 0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e, 0x10520, 0x1053c, + 0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, + 0x105ce, 0x105dc, 0x105e2, 0x105e4, 0x105e8, 0x105f6, 0x1062e, + 0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa, + 0x10716, 0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e, + 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, 0x10822, + 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, + 0x1087a, 0x10882, 0x10884, 0x10890, 0x1089e, 0x108a0, 0x108bc, + 0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, + 0x10908, 0x1091e, 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, + 0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4, + 0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c, + 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, 0x10b18, 0x10b30, + 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2, + 0x10bc4, 0x10bc8, 0x10bd0, 0x10bde, 0x10be6, 0x10bec, 0x10c2e, + 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, + 0x10c9c, 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, + 0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, 0x10d70, + 0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0, + 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, 0x10dee, 0x10df2, 0x10df4, + 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86, + 0x10e8c, 0x10e98, 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a, + 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44, + 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, + 0x11022, 0x11028, 0x11042, 0x11048, 0x11050, 0x1105e, 0x1107a, + 0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, + 0x110cc, 0x110d8, 0x110ee, 0x110f2, 0x110f4, 0x11102, 0x1111e, + 0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0, + 0x111be, 0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6, + 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, 0x11330, + 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, + 0x113c8, 0x113d0, 0x113de, 0x113e6, 0x113ec, 0x11408, 0x11410, + 0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, + 0x1160c, 0x11618, 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, + 0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784, + 0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc, + 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, 0x1185c, 0x11862, + 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2, + 0x118c8, 0x118d0, 0x118de, 0x118e6, 0x118ec, 0x118fa, 0x1190e, + 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, + 0x1199e, 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, + 0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, 0x11a7e, + 0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, + 0x11b40, 0x11b78, 0x11b8c, 0x11b98, 0x11bb0, 0x11bbe, 0x11bce, + 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26, + 0x11c2c, 0x11c46, 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98, + 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8, + 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, + 0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, 0x11dc8, 0x11dd0, + 0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, + 0x11e22, 0x11e24, 0x11e28, 0x11e36, 0x11e42, 0x11e44, 0x11e50, + 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90, + 0x11e9e, 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee, + 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, 0x11f62, + 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, + 0x12090, 0x1209e, 0x120a0, 0x120bc, 0x120d8, 0x120f2, 0x120f4, + 0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, + 0x12198, 0x121b0, 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, + 0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306, + 0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c, + 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, 0x123ec, 0x1241e, + 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660, + 0x1267c, 0x126c0, 0x126f8, 0x12738, 0x12770, 0x1277e, 0x12782, + 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, + 0x127d8, 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, + 0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60, 0x12c7c, + 0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, + 0x12ee0, 0x12efc, 0x12f04, 0x12f08, 0x12f10, 0x12f20, 0x12f3c, + 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe, + 0x12fce, 0x12fdc, 0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068, + 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de, + 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, + 0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc, 0x131c6, 0x131cc, + 0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, + 0x132e0, 0x132fc, 0x13308, 0x1331e, 0x13320, 0x1333c, 0x13340, + 0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc, + 0x133e2, 0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438, + 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, 0x13608, + 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, + 0x1370c, 0x13718, 0x13730, 0x1373e, 0x13760, 0x1377c, 0x1379c, + 0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, + 0x137ec, 0x13816, 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, + 0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce, + 0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930, + 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, 0x139b8, 0x139c8, + 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c, + 0x13a18, 0x13a30, 0x13a3e, 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, + 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, + 0x13b9e, 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, + 0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28, 0x13c36, + 0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, + 0x13c84, 0x13c90, 0x13c9e, 0x13ca0, 0x13cbc, 0x13cc6, 0x13ccc, + 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e, + 0x13d20, 0x13d3c, 0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98, + 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6, + 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, + 0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, 0x13eb8, 0x13ec2, + 0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, + 0x13f2c, 0x13f3a, 0x13f46, 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, + 0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108, + 0x14110, 0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c, + 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, 0x14208, + 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, + 0x14306, 0x1430c, 0x14318, 0x14330, 0x1433e, 0x14360, 0x1437c, + 0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, + 0x14408, 0x14410, 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, + 0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660, + 0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e, + 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, 0x147bc, 0x147c6, + 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840, + 0x14878, 0x148f0, 0x149e0, 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, + 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, + 0x14ee0, 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, + 0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98, 0x14fb0, + 0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0, + 0x153c0, 0x15860, 0x1587c, 0x158c0, 0x158f8, 0x159f0, 0x15be0, + 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08, + 0x15e10, 0x15e20, 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18, + 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e, + 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, + 0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170, 0x1617e, 0x16184, + 0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, + 0x161d8, 0x161f2, 0x161f4, 0x1620e, 0x1621c, 0x16238, 0x16270, + 0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e, + 0x16320, 0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398, + 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, 0x163e8, + 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, + 0x164fc, 0x165c0, 0x165f8, 0x16610, 0x1661e, 0x16620, 0x1663c, + 0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, + 0x1677c, 0x1678e, 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, + 0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870, + 0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e, + 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, 0x16de0, 0x16e18, + 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c, + 0x16f38, 0x16f70, 0x16f7e, 0x16f84, 0x16f88, 0x16f90, 0x16f9e, + 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, + 0x17046, 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, + 0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106, 0x1710c, + 0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c, + 0x171b8, 0x171c2, 0x171c4, 0x171c8, 0x171d0, 0x171de, 0x171e6, + 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e, + 0x17260, 0x1727c, 0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338, + 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc, + 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, + 0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0, 0x174f8, 0x175f0, + 0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, + 0x17708, 0x17710, 0x1771e, 0x17720, 0x1773c, 0x17740, 0x17778, + 0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8, + 0x17822, 0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848, + 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, 0x17888, + 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, + 0x178ee, 0x178f2, 0x178f4, 0x17902, 0x17904, 0x17908, 0x17910, + 0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, + 0x17998, 0x179b0, 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, + 0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20, + 0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18, + 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, 0x17b9c, 0x17bb8, + 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e, + 0x17c32, 0x17c34, 0x17c4e, 0x17c5c, 0x17c62, 0x17c64, 0x17c68, + 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, + 0x17cd0, 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, + 0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e, 0x17da0, + 0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, + 0x17e3a, 0x17e46, 0x17e4c, 0x17e58, 0x17e6e, 0x17e72, 0x17e74, + 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2, + 0x17ee4, 0x17ee8, 0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216, + 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274, + 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, + 0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426, 0x1842c, 0x1843a, + 0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, + 0x184be, 0x184ce, 0x184dc, 0x184e2, 0x184e4, 0x184e8, 0x184f6, + 0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c, + 0x1858e, 0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0, + 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, 0x18622, + 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, + 0x18684, 0x18688, 0x18690, 0x1869e, 0x186a0, 0x186bc, 0x186c6, + 0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, + 0x1875c, 0x18796, 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, + 0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872, + 0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc, + 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, 0x18930, 0x1893e, + 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0, + 0x189de, 0x189e6, 0x189ec, 0x189fa, 0x18a18, 0x18a30, 0x18a3e, + 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, + 0x18b7e, 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, + 0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, 0x18bf4, + 0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50, + 0x18c5e, 0x18c66, 0x18c7a, 0x18c82, 0x18c84, 0x18c90, 0x18c9e, + 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08, + 0x18d10, 0x18d1e, 0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86, + 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32, + 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, + 0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, 0x18ed0, 0x18efa, + 0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, + 0x18f8a, 0x18f92, 0x18f94, 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, + 0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074, + 0x19086, 0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2, + 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, 0x19160, + 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, + 0x191de, 0x191e6, 0x191ec, 0x191fa, 0x19218, 0x1923e, 0x19260, + 0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, + 0x19384, 0x19390, 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, + 0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460, + 0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e, + 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, 0x19710, 0x19720, + 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0, + 0x197be, 0x197ce, 0x197dc, 0x197e2, 0x197e4, 0x197e8, 0x19822, + 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, + 0x19882, 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, + 0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920, 0x1993c, + 0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4, + 0x199e8, 0x19a08, 0x19a10, 0x19a1e, 0x19a20, 0x19a3c, 0x19a40, + 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2, + 0x19bc4, 0x19bc8, 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e, + 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8, + 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, + 0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84, 0x19d88, 0x19d90, + 0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, + 0x19e46, 0x19e4c, 0x19e58, 0x19e74, 0x19e86, 0x19e8c, 0x19e98, + 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a, + 0x19f12, 0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44, + 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, 0x19fb2, + 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, + 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, 0x1a0e4, 0x1a0e8, 0x1a0f6, + 0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, + 0x1a18e, 0x1a19c, 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, + 0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260, + 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e, + 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, 0x1a3a0, 0x1a3bc, + 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418, + 0x1a430, 0x1a43e, 0x1a460, 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, + 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, + 0x1a704, 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, + 0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, 0x1a7ce, + 0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, + 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, 0x1ac70, 0x1ac7e, 0x1ace0, + 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20, + 0x1ae3c, 0x1ae40, 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18, + 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8, + 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, + 0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e, 0x1b0a0, 0x1b0bc, + 0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, + 0x1b11e, 0x1b120, 0x1b13c, 0x1b140, 0x1b178, 0x1b186, 0x1b198, + 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210, + 0x1b21e, 0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c, + 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, 0x1b3d0, + 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, + 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, 0x1b67c, 0x1b6c0, 0x1b738, + 0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, + 0x1b82e, 0x1b84e, 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, + 0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c, + 0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990, + 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, 0x1ba0e, 0x1ba1c, + 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10, + 0x1bb20, 0x1bb3c, 0x1bb40, 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, + 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, + 0x1bc72, 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, + 0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, 0x1bd18, + 0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, + 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, 0x1be12, 0x1be14, 0x1be22, + 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e, + 0x1be66, 0x1be82, 0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0, + 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34, + 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, + 0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162, 0x1c164, 0x1c168, + 0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, + 0x1c262, 0x1c264, 0x1c268, 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, + 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316, + 0x1c326, 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a, + 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, 0x1c464, + 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, + 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, 0x1c4fa, 0x1c51c, 0x1c538, + 0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, + 0x1c5a0, 0x1c5bc, 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, + 0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c, + 0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698, + 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, 0x1c6e4, 0x1c6e8, + 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744, + 0x1c748, 0x1c750, 0x1c75e, 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, + 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, + 0x1c85c, 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, + 0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, 0x1c8ec, + 0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984, + 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, 0x1c9c6, 0x1c9cc, 0x1c9d8, + 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0, + 0x1cafc, 0x1cb02, 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c, + 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe, + 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, + 0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, 0x1cc72, 0x1cc74, + 0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, + 0x1cd06, 0x1cd0c, 0x1cd18, 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, + 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6, + 0x1cdfa, 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66, + 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, 0x1cea0, + 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, + 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, 0x1cf68, 0x1cf96, 0x1cfa6, + 0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, + 0x1d04e, 0x1d05c, 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, + 0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de, + 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e, + 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, 0x1d1a0, 0x1d1bc, + 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c, + 0x1d238, 0x1d270, 0x1d27e, 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, + 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, + 0x1d386, 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, + 0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, 0x1d4e0, + 0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620, + 0x1d640, 0x1d678, 0x1d6f0, 0x1d706, 0x1d70c, 0x1d718, 0x1d730, + 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2, + 0x1d7c4, 0x1d7c8, 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826, + 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874, + 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, + 0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, 0x1d930, 0x1d93e, + 0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, + 0x1d9e6, 0x1d9fa, 0x1da0c, 0x1da18, 0x1da30, 0x1da3e, 0x1da60, + 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88, + 0x1db90, 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22, + 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, 0x1dc7a, + 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, + 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, 0x1dd08, 0x1dd10, 0x1dd1e, + 0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, + 0x1dde2, 0x1dde4, 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, + 0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8, + 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16, + 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, 0x1df72, 0x1df74, + 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a, + 0x1e092, 0x1e094, 0x1e0a2, 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, + 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, + 0x1e142, 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, + 0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, 0x1e222, + 0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e, + 0x1e266, 0x1e26c, 0x1e27a, 0x1e282, 0x1e284, 0x1e288, 0x1e290, + 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2, + 0x1e2f4, 0x1e31a, 0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364, + 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428, + 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, + 0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e, 0x1e4a0, 0x1e4bc, + 0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, + 0x1e504, 0x1e508, 0x1e510, 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, + 0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce, + 0x1e5dc, 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e, + 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, 0x1e68e, + 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, + 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, 0x1e73a, 0x1e746, 0x1e74c, + 0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, + 0x1e7a8, 0x1e7b6, 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, + 0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866, + 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e, + 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, 0x1e8ee, 0x1e8f2, + 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c, + 0x1e940, 0x1e978, 0x1e986, 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, + 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, + 0x1ea08, 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, + 0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, 0x1eb8e, + 0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, + 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, 0x1ec32, 0x1ec34, 0x1ec4e, + 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8, + 0x1ecc2, 0x1ecc4, 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e, + 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88, + 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, + 0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, 0x1ee58, 0x1ee6e, + 0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, + 0x1eece, 0x1eedc, 0x1eee2, 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, + 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50, + 0x1ef5e, 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4, + 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, 0x1f0d2, + 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, + 0x1f158, 0x1f16e, 0x1f172, 0x1f174, 0x1f18a, 0x1f192, 0x1f194, + 0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, + 0x1f23a, 0x1f246, 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, + 0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2, + 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322, + 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, 0x1f35e, 0x1f366, + 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426, + 0x1f42c, 0x1f43a, 0x1f446, 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, + 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, + 0x1f4dc, 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, + 0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, 0x1f59c, + 0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, + 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, 0x1f614, 0x1f622, 0x1f624, + 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e, + 0x1f666, 0x1f67a, 0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e, + 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e, + 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, + 0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, 0x1f7d2, 0x1f7d4, + 0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, + 0x1f92e, 0x1f932, 0x1f934, 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, + 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca, + 0x1f9d2, 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e, + 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, 0x1fa9c, + 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, + 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, 0x1fb3a, 0x1fb46, 0x1fb4c, + 0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, + 0x1fba2, 0x1fba4, 0x1fba8, 0x1fbb6, 0x1fbda}; + + /** + * This table contains to codewords for all symbols. + */ + private static final int[] CODEWORD_TABLE = {2627, 1819, 2622, 2621, 1813, + 1812, 2729, 2724, 2723, 2779, 2774, 2773, 902, 896, 908, 868, 865, + 861, 859, 2511, 873, 871, 1780, 835, 2493, 825, 2491, 842, 837, 844, + 1764, 1762, 811, 810, 809, 2483, 807, 2482, 806, 2480, 815, 814, 813, + 812, 2484, 817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635, 2626, + 2625, 2623, 2628, 1820, 2752, 2739, 2737, 2728, 2727, 2725, 2730, + 2785, 2783, 2778, 2777, 2775, 2780, 787, 781, 747, 739, 736, 2413, + 754, 752, 1719, 692, 689, 681, 2371, 678, 2369, 700, 697, 694, 703, + 1688, 1686, 642, 638, 2343, 631, 2341, 627, 2338, 651, 646, 643, 2345, + 654, 652, 1652, 1650, 1647, 1654, 601, 599, 2322, 596, 2321, 594, + 2319, 2317, 611, 610, 608, 606, 2324, 603, 2323, 615, 614, 612, 1617, + 1616, 1614, 1612, 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, + 909, 2509, 2507, 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, + 2489, 2487, 2485, 1748, 836, 834, 832, 830, 2494, 827, 2492, 843, 841, + 839, 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, + 2631, 2629, 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, + 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591, 588, 576, + 569, 566, 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, + 548, 1572, 1570, 481, 2245, 466, 2242, 462, 2239, 492, 485, 482, 2249, + 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, + 419, 2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, + 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155, 2152, 378, 377, 375, + 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, 1416, + 1414, 385, 1411, 384, 1423, 1422, 1420, 1424, 2461, 802, 2441, 2439, + 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, 756, 753, + 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, 680, 2370, + 702, 699, 696, 704, 1690, 1687, 2337, 2336, 2334, 2332, 1624, 2329, + 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, 645, 2346, 655, + 653, 1653, 1651, 1649, 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576, + 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900, 910, 2503, 2502, + 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, 866, 863, 2513, + 876, 874, 1782, 2720, 2713, 2711, 2697, 2694, 2691, 2702, 2672, 2670, + 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, 2639, 1822, + 2654, 2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, 2751, + 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142, 332, 2140, 345, + 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, 2132, + 1354, 1352, 1349, 1356, 262, 257, 2101, 253, 2096, 2093, 274, 273, + 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, 1318, + 2052, 202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, 224, + 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266, 1264, 1261, 1268, + 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, 2006, + 159, 2003, 2000, 172, 171, 169, 2012, 166, 2010, 1186, 1184, 1182, + 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, 2313, + 2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, 580, + 1591, 2272, 2267, 2264, 1547, 538, 536, 529, 2278, 525, 2275, 547, + 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, 2247, + 470, 2244, 465, 2241, 493, 488, 484, 2250, 498, 495, 1536, 1533, 1530, + 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, 414, 412, + 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, 418, 2201, 431, + 429, 1473, 1471, 1469, 1466, 434, 1477, 1475, 2478, 2472, 2470, 2459, + 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, 2440, 792, 789, + 785, 2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, 2405, 745, 741, + 2415, 758, 755, 1721, 2358, 2357, 2355, 2353, 1661, 2350, 1660, 2347, + 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, 683, 2372, 701, + 698, 705, 1691, 1689, 2619, 2617, 2610, 2608, 2605, 2613, 2593, 2588, + 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573, + 2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, 2514, + 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539, 906, 903, 911, 2721, + 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, + 1824, 2673, 2671, 2669, 2666, 1829, 2679, 2677, 1858, 1857, 2772, + 1854, 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133, + 131, 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, + 1130, 112, 110, 1974, 107, 1973, 104, 1971, 1969, 122, 121, 119, 117, + 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, + 1953, 81, 1952, 78, 1950, 1948, 1945, 94, 93, 91, 1959, 88, 1958, 85, + 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, 100, 1090, 1089, + 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, 1907, 59, 1926, 56, + 1925, 53, 1922, 1919, 66, 64, 1931, 61, 1929, 1042, 1040, 1038, 71, + 1035, 70, 1032, 68, 1048, 1047, 1045, 1043, 1050, 1049, 12, 10, 1869, + 1867, 1864, 1861, 21, 1880, 19, 1877, 1874, 1871, 28, 1888, 25, 1886, + 22, 1883, 982, 980, 977, 974, 32, 30, 991, 989, 987, 984, 34, 995, + 994, 992, 2151, 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, + 2138, 2136, 2134, 1359, 343, 341, 338, 2143, 335, 2141, 348, 347, 346, + 1376, 1374, 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308, 305, + 2131, 302, 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, + 1353, 1351, 1357, 2092, 2091, 2089, 2087, 1276, 2084, 1274, 2081, + 1271, 259, 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, + 2106, 281, 279, 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, + 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207, 2053, 205, 2051, 201, + 2049, 2046, 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, + 2069, 1259, 1257, 1254, 232, 1251, 230, 1267, 1265, 1263, 2316, 2315, + 2312, 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590, + 2288, 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, + 574, 571, 2298, 582, 581, 1592, 2263, 2262, 2260, 2258, 1545, 2255, + 1544, 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, + 2277, 546, 543, 549, 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, + 2214, 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480, 477, + 2248, 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, + 2477, 2476, 2474, 2479, 2469, 2468, 2466, 2464, 1730, 2473, 2471, + 2453, 2452, 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, + 804, 2428, 2427, 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, + 2434, 2431, 1727, 2444, 2442, 793, 791, 788, 795, 2388, 2386, 2384, + 1697, 2381, 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, + 2392, 1701, 2412, 2410, 2407, 751, 748, 744, 2416, 759, 757, 1807, + 2620, 2618, 1806, 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, + 2594, 2592, 2590, 2587, 1804, 2600, 2598, 1794, 1793, 1791, 1789, + 2564, 2562, 2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569, 2578, + 1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714, 1835, 1834, + 1832, 1830, 1839, 1837, 2700, 2698, 2695, 2704, 1817, 1811, 1810, 897, + 862, 1777, 829, 826, 838, 1760, 1758, 808, 2481, 1741, 1740, 1738, + 1743, 2624, 1818, 2726, 2776, 782, 740, 737, 1715, 686, 679, 695, + 1682, 1680, 639, 628, 2339, 647, 644, 1645, 1643, 1640, 1648, 602, + 600, 597, 595, 2320, 593, 2318, 609, 607, 604, 1611, 1610, 1608, 1606, + 613, 1615, 1613, 2328, 926, 924, 892, 886, 899, 857, 850, 2505, 1778, + 824, 823, 821, 819, 2488, 818, 2486, 833, 831, 828, 840, 1761, 1759, + 2649, 2632, 2630, 2746, 2734, 2732, 2782, 2781, 570, 567, 1587, 531, + 527, 523, 540, 1566, 1564, 476, 467, 463, 2240, 486, 483, 1524, 1521, + 1518, 1529, 411, 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, + 428, 1468, 1465, 2210, 366, 363, 2158, 360, 2156, 357, 2153, 376, 373, + 370, 2163, 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412, + 1421, 2175, 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, + 676, 674, 668, 2363, 665, 2360, 685, 1684, 1681, 626, 624, 622, 2335, + 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, 925, + 2530, 2527, 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, 851, 1779, + 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759, 2757, 2744, + 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, 300, 296, + 2126, 315, 312, 1347, 1342, 1350, 261, 258, 250, 2097, 246, 2094, 271, + 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, 203, 2048, 195, + 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, 225, 1234, 222, + 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997, 150, 1995, 147, 1992, + 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 170, + 1164, 167, 1185, 1183, 1180, 1177, 174, 1190, 1188, 2025, 2024, 2022, + 587, 586, 564, 559, 556, 2290, 573, 1588, 520, 518, 512, 2268, 508, + 2265, 530, 1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226, 479, 471, + 489, 1526, 1523, 1520, 397, 395, 2185, 392, 2183, 389, 2180, 2177, + 410, 2194, 402, 422, 1463, 1461, 1459, 1456, 1470, 2455, 799, 2433, + 2430, 779, 776, 773, 2397, 2394, 2390, 734, 728, 724, 746, 1717, 2356, + 2354, 2351, 2348, 1658, 677, 675, 673, 670, 667, 688, 1685, 1683, + 2606, 2589, 2586, 2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784, + 2532, 895, 893, 890, 2718, 2709, 2707, 2689, 2687, 2684, 2663, 2662, + 2660, 2658, 1825, 2667, 2769, 1852, 2760, 2758, 142, 141, 1139, 1138, + 134, 132, 129, 126, 1982, 1129, 1128, 1126, 1131, 113, 111, 108, 105, + 1972, 101, 1970, 120, 118, 115, 1109, 1108, 1106, 1104, 123, 1113, + 1111, 82, 79, 1951, 75, 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, + 1074, 1072, 98, 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, + 1916, 42, 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920, 1031, + 1030, 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, + 1046, 1044, 1944, 1943, 1941, 11, 9, 1868, 7, 1865, 1862, 1859, 20, + 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, 26, 23, 983, + 981, 978, 975, 33, 971, 31, 990, 988, 985, 1906, 1904, 1902, 993, 351, + 2145, 1383, 331, 330, 328, 326, 2137, 323, 2135, 339, 1372, 1370, 294, + 293, 291, 289, 2122, 286, 2120, 283, 2117, 309, 303, 317, 1348, 1346, + 1344, 245, 244, 242, 2090, 239, 2088, 236, 2085, 2082, 260, 2099, 249, + 270, 1307, 1305, 1303, 1300, 1314, 189, 2038, 186, 2036, 183, 2033, + 2030, 2026, 206, 198, 2047, 194, 216, 1247, 1245, 1243, 1240, 227, + 1237, 1255, 2310, 2302, 2300, 2286, 2284, 2281, 565, 563, 561, 558, + 575, 1589, 2261, 2259, 2256, 2253, 1542, 521, 519, 517, 514, 2270, + 511, 533, 1569, 1567, 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, + 456, 453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475, 2467, 2465, + 2451, 2449, 2446, 801, 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, + 778, 775, 2387, 2385, 2382, 2379, 1695, 2375, 1693, 2396, 735, 733, + 730, 727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, + 2579, 1800, 2591, 2550, 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, + 2719, 1841, 2710, 2708, 1833, 1831, 2690, 2688, 2686, 1815, 1809, + 1808, 1774, 1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676, + 1674, 633, 629, 1638, 1636, 1633, 1641, 598, 1605, 1604, 1602, 1600, + 605, 1609, 1607, 2327, 887, 853, 1775, 822, 820, 1757, 1755, 1584, + 524, 1560, 1558, 468, 464, 1514, 1511, 1508, 1519, 408, 404, 400, + 1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361, 358, 2154, 1401, + 1400, 1398, 1396, 374, 1393, 371, 1408, 1406, 1403, 1413, 2173, 2172, + 772, 726, 723, 1712, 672, 669, 666, 682, 1678, 1675, 625, 623, 621, + 618, 2331, 636, 632, 1639, 1637, 1635, 920, 918, 884, 880, 889, 849, + 848, 847, 846, 2497, 855, 852, 1776, 2641, 2742, 2787, 1380, 334, + 1367, 1365, 301, 297, 1340, 1338, 1335, 1343, 255, 251, 247, 1296, + 1291, 1288, 265, 1302, 1299, 2113, 204, 196, 192, 2042, 1232, 1230, + 1224, 214, 1220, 210, 1242, 1239, 1235, 1250, 2077, 2075, 151, 148, + 1993, 144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152, 157, 1173, + 1171, 1168, 1165, 168, 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, + 557, 1585, 516, 509, 1562, 1559, 458, 447, 2227, 472, 1516, 1513, + 1510, 398, 396, 393, 390, 2181, 386, 2178, 407, 1453, 1451, 1449, + 1446, 420, 1460, 2209, 769, 764, 720, 712, 2391, 729, 1713, 664, 663, + 661, 659, 2352, 656, 2349, 671, 1679, 1677, 2553, 922, 919, 2519, + 2516, 885, 883, 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, + 1136, 130, 127, 1125, 1124, 1122, 1127, 109, 106, 102, 1103, 1102, + 1100, 1098, 116, 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, + 1063, 90, 1060, 87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, + 1912, 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008, 51, 1029, + 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, 4, + 1863, 1, 1860, 956, 954, 952, 949, 946, 17, 14, 969, 967, 964, 961, + 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, 1896, 986, 1905, 1903, + 350, 349, 1381, 329, 327, 324, 1368, 1366, 292, 290, 287, 284, 2118, + 304, 1341, 1339, 1337, 1345, 243, 240, 237, 2086, 233, 2083, 254, + 1297, 1295, 1293, 1290, 1304, 2114, 190, 187, 184, 2034, 180, 2031, + 177, 2027, 199, 1233, 1231, 1229, 1226, 217, 1223, 1241, 2078, 2076, + 584, 555, 554, 552, 550, 2282, 562, 1586, 507, 506, 504, 502, 2257, + 499, 2254, 515, 1563, 1561, 445, 443, 441, 2219, 438, 2216, 435, 2212, + 460, 454, 475, 1517, 1515, 1512, 2447, 798, 797, 2422, 2419, 770, 768, + 766, 2383, 2380, 2376, 721, 719, 717, 714, 731, 1714, 2602, 2582, + 2580, 2548, 2546, 2543, 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, + 1771, 1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670, 1668, + 1631, 1629, 1626, 1634, 1599, 1598, 1596, 1594, 1603, 1601, 2326, + 1772, 1753, 1751, 1581, 1554, 1552, 1504, 1501, 1498, 1509, 1442, + 1437, 1434, 401, 1448, 1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, + 1399, 1397, 1394, 1404, 2171, 2170, 1708, 1672, 1669, 619, 1632, 1630, + 1628, 1773, 1378, 1363, 1361, 1333, 1328, 1336, 1286, 1281, 1278, 248, + 1292, 1289, 2111, 1218, 1216, 1210, 197, 1206, 193, 1228, 1225, 1221, + 1236, 2073, 2071, 1151, 1150, 1148, 1146, 152, 1143, 149, 1140, 145, + 1161, 1159, 1156, 1153, 158, 1169, 1166, 2017, 2016, 2014, 2019, 1582, + 510, 1556, 1553, 452, 448, 1506, 1500, 394, 391, 387, 1443, 1441, + 1439, 1436, 1450, 2207, 765, 716, 713, 1709, 662, 660, 657, 1673, + 1671, 916, 914, 879, 878, 877, 882, 1135, 1134, 1121, 1120, 1118, + 1123, 1097, 1096, 1094, 1092, 103, 1101, 1099, 1979, 1059, 1058, 1056, + 1054, 77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963, 1007, 1006, + 1004, 1002, 999, 41, 996, 37, 1017, 1015, 1012, 1009, 52, 1025, 1022, + 1936, 1935, 1933, 1938, 942, 940, 938, 935, 932, 5, 2, 955, 953, 950, + 947, 18, 943, 15, 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, + 1897, 1379, 325, 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, + 234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185, 181, 178, 2028, + 1219, 1217, 1215, 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, + 1583, 505, 503, 500, 513, 1557, 1555, 444, 442, 439, 436, 2213, 455, + 451, 1507, 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706, + 2377, 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, + 1769, 1749, 1747, 1499, 1438, 1435, 2204, 1390, 1388, 1385, 1395, + 2169, 2167, 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, + 1279, 2109, 1214, 1207, 1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, + 1157, 1154, 2013, 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, + 1433, 1431, 1428, 1425, 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, + 1095, 1093, 1978, 1057, 1055, 1052, 1062, 1962, 1960, 1005, 1003, + 1000, 997, 38, 1013, 1010, 1932, 1930, 1927, 1934, 941, 939, 936, 933, + 6, 930, 3, 951, 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, + 1377, 1360, 1358, 1327, 1325, 1322, 1331, 1277, 1275, 1272, 1269, 235, + 1284, 2110, 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, + 1580, 501, 1551, 1548, 440, 437, 1497, 1494, 1490, 1503, 761, 709, + 707, 1706, 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208, + 2058, 2054, 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, + 2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954, 1001, 998, 1924, 1921, + 1918, 1928, 937, 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, + 1323, 1273, 1270, 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, + 1543, 1540, 1484, 1481, 1478, 1491, 1700}; +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java index a1acd07..eac6868 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java @@ -1,554 +1,554 @@ -/* - * Copyright 2009 ZXing authors - * - * 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. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.DecoderResult; - -import java.math.BigInteger; - -/** - *

This class contains the methods for decoding the PDF417 codewords.

- * - * @author SITA Lab (kevin.osullivan@sita.aero) - */ -final class DecodedBitStreamParser { - - private enum Mode { - ALPHA, - LOWER, - MIXED, - PUNCT, - ALPHA_SHIFT, - PUNCT_SHIFT - } - - private static final int TEXT_COMPACTION_MODE_LATCH = 900; - private static final int BYTE_COMPACTION_MODE_LATCH = 901; - private static final int NUMERIC_COMPACTION_MODE_LATCH = 902; - private static final int BYTE_COMPACTION_MODE_LATCH_6 = 924; - private static final int BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928; - private static final int BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923; - private static final int MACRO_PDF417_TERMINATOR = 922; - private static final int MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913; - private static final int MAX_NUMERIC_CODEWORDS = 15; - - private static final int PL = 25; - private static final int LL = 27; - private static final int AS = 27; - private static final int ML = 28; - private static final int AL = 28; - private static final int PS = 29; - private static final int PAL = 29; - - private static final char[] PUNCT_CHARS = { - ';', '<', '>', '@', '[', '\\', '}', '_', '`', '~', '!', - '\r', '\t', ',', ':', '\n', '-', '.', '$', '/', '"', '|', '*', - '(', ')', '?', '{', '}', '\''}; - - private static final char[] MIXED_CHARS = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '&', - '\r', '\t', ',', ':', '#', '-', '.', '$', '/', '+', '%', '*', - '=', '^'}; - - /** - * Table containing values for the exponent of 900. - * This is used in the numeric compaction decode algorithm. - */ - private static final BigInteger[] EXP900; - static { - EXP900 = new BigInteger[16]; - EXP900[0] = BigInteger.ONE; - BigInteger nineHundred = BigInteger.valueOf(900); - EXP900[1] = nineHundred; - for (int i = 2; i < EXP900.length; i++) { - EXP900[i] = EXP900[i - 1].multiply(nineHundred); - } - } - - private DecodedBitStreamParser() { - } - - static DecoderResult decode(int[] codewords) throws FormatException { - StringBuilder result = new StringBuilder(100); - // Get compaction mode - int codeIndex = 1; - int code = codewords[codeIndex++]; - while (codeIndex < codewords[0]) { - switch (code) { - case TEXT_COMPACTION_MODE_LATCH: - codeIndex = textCompaction(codewords, codeIndex, result); - break; - case BYTE_COMPACTION_MODE_LATCH: - codeIndex = byteCompaction(code, codewords, codeIndex, result); - break; - case NUMERIC_COMPACTION_MODE_LATCH: - codeIndex = numericCompaction(codewords, codeIndex, result); - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - codeIndex = byteCompaction(code, codewords, codeIndex, result); - break; - case BYTE_COMPACTION_MODE_LATCH_6: - codeIndex = byteCompaction(code, codewords, codeIndex, result); - break; - default: - // Default to text compaction. During testing numerous barcodes - // appeared to be missing the starting mode. In these cases defaulting - // to text compaction seems to work. - codeIndex--; - codeIndex = textCompaction(codewords, codeIndex, result); - break; - } - if (codeIndex < codewords.length) { - code = codewords[codeIndex++]; - } else { - throw FormatException.getFormatInstance(); - } - } - if (result.length() == 0) { - throw FormatException.getFormatInstance(); - } - return new DecoderResult(null, result.toString(), null, null); - } - - /** - * Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be - * encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as - * well as selected control characters. - * - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - private static int textCompaction(int[] codewords, int codeIndex, StringBuilder result) { - // 2 character per codeword - int[] textCompactionData = new int[codewords[0] << 1]; - // Used to hold the byte compaction value if there is a mode shift - int[] byteCompactionData = new int[codewords[0] << 1]; - - int index = 0; - boolean end = false; - while ((codeIndex < codewords[0]) && !end) { - int code = codewords[codeIndex++]; - if (code < TEXT_COMPACTION_MODE_LATCH) { - textCompactionData[index] = code / 30; - textCompactionData[index + 1] = code % 30; - index += 2; - } else { - switch (code) { - case TEXT_COMPACTION_MODE_LATCH: - // reinitialize text compaction mode to alpha sub mode - textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH; - break; - case BYTE_COMPACTION_MODE_LATCH: - codeIndex--; - end = true; - break; - case NUMERIC_COMPACTION_MODE_LATCH: - codeIndex--; - end = true; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - // The Mode Shift codeword 913 shall cause a temporary - // switch from Text Compaction mode to Byte Compaction mode. - // This switch shall be in effect for only the next codeword, - // after which the mode shall revert to the prevailing sub-mode - // of the Text Compaction mode. Codeword 913 is only available - // in Text Compaction mode; its use is described in 5.4.2.4. - textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; - code = codewords[codeIndex++]; - byteCompactionData[index] = code; //Integer.toHexString(code); - index++; - break; - case BYTE_COMPACTION_MODE_LATCH_6: - codeIndex--; - end = true; - break; - } - } - } - decodeTextCompaction(textCompactionData, byteCompactionData, index, result); - return codeIndex; - } - - /** - * The Text Compaction mode includes all the printable ASCII characters - * (i.e. values from 32 to 126) and three ASCII control characters: HT or tab - * (ASCII value 9), LF or line feed (ASCII value 10), and CR or carriage - * return (ASCII value 13). The Text Compaction mode also includes various latch - * and shift characters which are used exclusively within the mode. The Text - * Compaction mode encodes up to 2 characters per codeword. The compaction rules - * for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode - * switches are defined in 5.4.2.3. - * - * @param textCompactionData The text compaction data. - * @param byteCompactionData The byte compaction data if there - * was a mode shift. - * @param length The size of the text compaction and byte compaction data. - * @param result The decoded data is appended to the result. - */ - private static void decodeTextCompaction(int[] textCompactionData, - int[] byteCompactionData, - int length, - StringBuilder result) { - // Beginning from an initial state of the Alpha sub-mode - // The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text - // Compaction mode Alpha sub-mode (uppercase alphabetic). A latch codeword from another mode to the Text - // Compaction mode shall always switch to the Text Compaction Alpha sub-mode. - Mode subMode = Mode.ALPHA; - Mode priorToShiftMode = Mode.ALPHA; - int i = 0; - while (i < length) { - int subModeCh = textCompactionData[i]; - char ch = 0; - switch (subMode) { - case ALPHA: - // Alpha (uppercase alphabetic) - if (subModeCh < 26) { - // Upper case Alpha Character - ch = (char) ('A' + subModeCh); - } else { - if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == LL) { - subMode = Mode.LOWER; - } else if (subModeCh == ML) { - subMode = Mode.MIXED; - } else if (subModeCh == PS) { - // Shift to punctuation - priorToShiftMode = subMode; - subMode = Mode.PUNCT_SHIFT; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result.append((char) byteCompactionData[i]); - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = Mode.ALPHA; - } - } - break; - - case LOWER: - // Lower (lowercase alphabetic) - if (subModeCh < 26) { - ch = (char) ('a' + subModeCh); - } else { - if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == AS) { - // Shift to alpha - priorToShiftMode = subMode; - subMode = Mode.ALPHA_SHIFT; - } else if (subModeCh == ML) { - subMode = Mode.MIXED; - } else if (subModeCh == PS) { - // Shift to punctuation - priorToShiftMode = subMode; - subMode = Mode.PUNCT_SHIFT; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result.append((char) byteCompactionData[i]); - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = Mode.ALPHA; - } - } - break; - - case MIXED: - // Mixed (numeric and some punctuation) - if (subModeCh < PL) { - ch = MIXED_CHARS[subModeCh]; - } else { - if (subModeCh == PL) { - subMode = Mode.PUNCT; - } else if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == LL) { - subMode = Mode.LOWER; - } else if (subModeCh == AL) { - subMode = Mode.ALPHA; - } else if (subModeCh == PS) { - // Shift to punctuation - priorToShiftMode = subMode; - subMode = Mode.PUNCT_SHIFT; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result.append((char) byteCompactionData[i]); - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = Mode.ALPHA; - } - } - break; - - case PUNCT: - // Punctuation - if (subModeCh < PAL) { - ch = PUNCT_CHARS[subModeCh]; - } else { - if (subModeCh == PAL) { - subMode = Mode.ALPHA; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result.append((char) byteCompactionData[i]); - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = Mode.ALPHA; - } - } - break; - - case ALPHA_SHIFT: - // Restore sub-mode - subMode = priorToShiftMode; - if (subModeCh < 26) { - ch = (char) ('A' + subModeCh); - } else { - if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = Mode.ALPHA; - } - } - break; - - case PUNCT_SHIFT: - // Restore sub-mode - subMode = priorToShiftMode; - if (subModeCh < PAL) { - ch = PUNCT_CHARS[subModeCh]; - } else { - if (subModeCh == PAL) { - subMode = Mode.ALPHA; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - // PS before Shift-to-Byte is used as a padding character, - // see 5.4.2.4 of the specification - result.append((char) byteCompactionData[i]); - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = Mode.ALPHA; - } - } - break; - } - if (ch != 0) { - // Append decoded character to result - result.append(ch); - } - i++; - } - } - - /** - * Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded. - * This includes all ASCII characters value 0 to 127 inclusive and provides for international - * character set support. - * - * @param mode The byte compaction mode i.e. 901 or 924 - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - private static int byteCompaction(int mode, int[] codewords, int codeIndex, StringBuilder result) { - if (mode == BYTE_COMPACTION_MODE_LATCH) { - // Total number of Byte Compaction characters to be encoded - // is not a multiple of 6 - int count = 0; - long value = 0; - char[] decodedData = new char[6]; - int[] byteCompactedCodewords = new int[6]; - boolean end = false; - int nextCode = codewords[codeIndex++]; - while ((codeIndex < codewords[0]) && !end) { - byteCompactedCodewords[count++] = nextCode; - // Base 900 - value = 900 * value + nextCode; - nextCode = codewords[codeIndex++]; - // perhaps it should be ok to check only nextCode >= TEXT_COMPACTION_MODE_LATCH - if (nextCode == TEXT_COMPACTION_MODE_LATCH || - nextCode == BYTE_COMPACTION_MODE_LATCH || - nextCode == NUMERIC_COMPACTION_MODE_LATCH || - nextCode == BYTE_COMPACTION_MODE_LATCH_6 || - nextCode == BEGIN_MACRO_PDF417_CONTROL_BLOCK || - nextCode == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || - nextCode == MACRO_PDF417_TERMINATOR) { - codeIndex--; - end = true; - } else { - if ((count % 5 == 0) && (count > 0)) { - // Decode every 5 codewords - // Convert to Base 256 - for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (char) (value % 256); - value >>= 8; - } - result.append(decodedData); - count = 0; - } - } - } - - // if the end of all codewords is reached the last codeword needs to be added - if (codeIndex == codewords[0] && nextCode < TEXT_COMPACTION_MODE_LATCH) { - byteCompactedCodewords[count++] = nextCode; - } - - // If Byte Compaction mode is invoked with codeword 901, - // the last group of codewords is interpreted directly - // as one byte per codeword, without compaction. - for (int i = 0; i < count; i++) { - result.append((char)byteCompactedCodewords[i]); - } - - } else if (mode == BYTE_COMPACTION_MODE_LATCH_6) { - // Total number of Byte Compaction characters to be encoded - // is an integer multiple of 6 - int count = 0; - long value = 0; - boolean end = false; - while (codeIndex < codewords[0] && !end) { - int code = codewords[codeIndex++]; - if (code < TEXT_COMPACTION_MODE_LATCH) { - count++; - // Base 900 - value = 900 * value + code; - } else { - if (code == TEXT_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH || - code == NUMERIC_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH_6 || - code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || - code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || - code == MACRO_PDF417_TERMINATOR) { - codeIndex--; - end = true; - } - } - if ((count % 5 == 0) && (count > 0)) { - // Decode every 5 codewords - // Convert to Base 256 - char[] decodedData = new char[6]; - for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (char) (value & 0xFF); - value >>= 8; - } - result.append(decodedData); - count = 0; - } - } - } - return codeIndex; - } - - /** - * Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings. - * - * @param codewords The array of codewords (data + error) - * @param codeIndex The current index into the codeword array. - * @param result The decoded data is appended to the result. - * @return The next index into the codeword array. - */ - private static int numericCompaction(int[] codewords, int codeIndex, StringBuilder result) throws FormatException { - int count = 0; - boolean end = false; - - int[] numericCodewords = new int[MAX_NUMERIC_CODEWORDS]; - - while (codeIndex < codewords[0] && !end) { - int code = codewords[codeIndex++]; - if (codeIndex == codewords[0]) { - end = true; - } - if (code < TEXT_COMPACTION_MODE_LATCH) { - numericCodewords[count] = code; - count++; - } else { - if (code == TEXT_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH_6 || - code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || - code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || - code == MACRO_PDF417_TERMINATOR) { - codeIndex--; - end = true; - } - } - if (count % MAX_NUMERIC_CODEWORDS == 0 || - code == NUMERIC_COMPACTION_MODE_LATCH || - end) { - // Re-invoking Numeric Compaction mode (by using codeword 902 - // while in Numeric Compaction mode) serves to terminate the - // current Numeric Compaction mode grouping as described in 5.4.4.2, - // and then to start a new one grouping. - String s = decodeBase900toBase10(numericCodewords, count); - result.append(s); - count = 0; - } - } - return codeIndex; - } - - /** - * Convert a list of Numeric Compacted codewords from Base 900 to Base 10. - * - * @param codewords The array of codewords - * @param count The number of codewords - * @return The decoded string representing the Numeric data. - */ - /* - EXAMPLE - Encode the fifteen digit numeric string 000213298174000 - Prefix the numeric string with a 1 and set the initial value of - t = 1 000 213 298 174 000 - Calculate codeword 0 - d0 = 1 000 213 298 174 000 mod 900 = 200 - - t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082 - Calculate codeword 1 - d1 = 1 111 348 109 082 mod 900 = 282 - - t = 1 111 348 109 082 div 900 = 1 234 831 232 - Calculate codeword 2 - d2 = 1 234 831 232 mod 900 = 632 - - t = 1 234 831 232 div 900 = 1 372 034 - Calculate codeword 3 - d3 = 1 372 034 mod 900 = 434 - - t = 1 372 034 div 900 = 1 524 - Calculate codeword 4 - d4 = 1 524 mod 900 = 624 - - t = 1 524 div 900 = 1 - Calculate codeword 5 - d5 = 1 mod 900 = 1 - t = 1 div 900 = 0 - Codeword sequence is: 1, 624, 434, 632, 282, 200 - - Decode the above codewords involves - 1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 + - 632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000 - - Remove leading 1 => Result is 000213298174000 - */ - private static String decodeBase900toBase10(int[] codewords, int count) throws FormatException { - BigInteger result = BigInteger.ZERO; - for (int i = 0; i < count; i++) { - result = result.add(EXP900[count - i - 1].multiply(BigInteger.valueOf(codewords[i]))); - } - String resultString = result.toString(); - if (resultString.charAt(0) != '1') { - throw FormatException.getFormatInstance(); - } - return resultString.substring(1); - } - -} +/* + * Copyright 2009 ZXing authors + * + * 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. + */ + +package com.google.zxing.pdf417.decoder; + +import com.google.zxing.FormatException; +import com.google.zxing.common.DecoderResult; + +import java.math.BigInteger; + +/** + *

This class contains the methods for decoding the PDF417 codewords.

+ * + * @author SITA Lab (kevin.osullivan@sita.aero) + */ +final class DecodedBitStreamParser { + + private enum Mode { + ALPHA, + LOWER, + MIXED, + PUNCT, + ALPHA_SHIFT, + PUNCT_SHIFT + } + + private static final int TEXT_COMPACTION_MODE_LATCH = 900; + private static final int BYTE_COMPACTION_MODE_LATCH = 901; + private static final int NUMERIC_COMPACTION_MODE_LATCH = 902; + private static final int BYTE_COMPACTION_MODE_LATCH_6 = 924; + private static final int BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928; + private static final int BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923; + private static final int MACRO_PDF417_TERMINATOR = 922; + private static final int MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913; + private static final int MAX_NUMERIC_CODEWORDS = 15; + + private static final int PL = 25; + private static final int LL = 27; + private static final int AS = 27; + private static final int ML = 28; + private static final int AL = 28; + private static final int PS = 29; + private static final int PAL = 29; + + private static final char[] PUNCT_CHARS = { + ';', '<', '>', '@', '[', '\\', '}', '_', '`', '~', '!', + '\r', '\t', ',', ':', '\n', '-', '.', '$', '/', '"', '|', '*', + '(', ')', '?', '{', '}', '\''}; + + private static final char[] MIXED_CHARS = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '&', + '\r', '\t', ',', ':', '#', '-', '.', '$', '/', '+', '%', '*', + '=', '^'}; + + /** + * Table containing values for the exponent of 900. + * This is used in the numeric compaction decode algorithm. + */ + private static final BigInteger[] EXP900; + static { + EXP900 = new BigInteger[16]; + EXP900[0] = BigInteger.ONE; + BigInteger nineHundred = BigInteger.valueOf(900); + EXP900[1] = nineHundred; + for (int i = 2; i < EXP900.length; i++) { + EXP900[i] = EXP900[i - 1].multiply(nineHundred); + } + } + + private DecodedBitStreamParser() { + } + + static DecoderResult decode(int[] codewords) throws FormatException { + StringBuilder result = new StringBuilder(100); + // Get compaction mode + int codeIndex = 1; + int code = codewords[codeIndex++]; + while (codeIndex < codewords[0]) { + switch (code) { + case TEXT_COMPACTION_MODE_LATCH: + codeIndex = textCompaction(codewords, codeIndex, result); + break; + case BYTE_COMPACTION_MODE_LATCH: + codeIndex = byteCompaction(code, codewords, codeIndex, result); + break; + case NUMERIC_COMPACTION_MODE_LATCH: + codeIndex = numericCompaction(codewords, codeIndex, result); + break; + case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + codeIndex = byteCompaction(code, codewords, codeIndex, result); + break; + case BYTE_COMPACTION_MODE_LATCH_6: + codeIndex = byteCompaction(code, codewords, codeIndex, result); + break; + default: + // Default to text compaction. During testing numerous barcodes + // appeared to be missing the starting mode. In these cases defaulting + // to text compaction seems to work. + codeIndex--; + codeIndex = textCompaction(codewords, codeIndex, result); + break; + } + if (codeIndex < codewords.length) { + code = codewords[codeIndex++]; + } else { + throw FormatException.getFormatInstance(); + } + } + if (result.length() == 0) { + throw FormatException.getFormatInstance(); + } + return new DecoderResult(null, result.toString(), null, null); + } + + /** + * Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be + * encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as + * well as selected control characters. + * + * @param codewords The array of codewords (data + error) + * @param codeIndex The current index into the codeword array. + * @param result The decoded data is appended to the result. + * @return The next index into the codeword array. + */ + private static int textCompaction(int[] codewords, int codeIndex, StringBuilder result) { + // 2 character per codeword + int[] textCompactionData = new int[codewords[0] << 1]; + // Used to hold the byte compaction value if there is a mode shift + int[] byteCompactionData = new int[codewords[0] << 1]; + + int index = 0; + boolean end = false; + while ((codeIndex < codewords[0]) && !end) { + int code = codewords[codeIndex++]; + if (code < TEXT_COMPACTION_MODE_LATCH) { + textCompactionData[index] = code / 30; + textCompactionData[index + 1] = code % 30; + index += 2; + } else { + switch (code) { + case TEXT_COMPACTION_MODE_LATCH: + // reinitialize text compaction mode to alpha sub mode + textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH; + break; + case BYTE_COMPACTION_MODE_LATCH: + codeIndex--; + end = true; + break; + case NUMERIC_COMPACTION_MODE_LATCH: + codeIndex--; + end = true; + break; + case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + // The Mode Shift codeword 913 shall cause a temporary + // switch from Text Compaction mode to Byte Compaction mode. + // This switch shall be in effect for only the next codeword, + // after which the mode shall revert to the prevailing sub-mode + // of the Text Compaction mode. Codeword 913 is only available + // in Text Compaction mode; its use is described in 5.4.2.4. + textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; + code = codewords[codeIndex++]; + byteCompactionData[index] = code; //Integer.toHexString(code); + index++; + break; + case BYTE_COMPACTION_MODE_LATCH_6: + codeIndex--; + end = true; + break; + } + } + } + decodeTextCompaction(textCompactionData, byteCompactionData, index, result); + return codeIndex; + } + + /** + * The Text Compaction mode includes all the printable ASCII characters + * (i.e. values from 32 to 126) and three ASCII control characters: HT or tab + * (ASCII value 9), LF or line feed (ASCII value 10), and CR or carriage + * return (ASCII value 13). The Text Compaction mode also includes various latch + * and shift characters which are used exclusively within the mode. The Text + * Compaction mode encodes up to 2 characters per codeword. The compaction rules + * for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode + * switches are defined in 5.4.2.3. + * + * @param textCompactionData The text compaction data. + * @param byteCompactionData The byte compaction data if there + * was a mode shift. + * @param length The size of the text compaction and byte compaction data. + * @param result The decoded data is appended to the result. + */ + private static void decodeTextCompaction(int[] textCompactionData, + int[] byteCompactionData, + int length, + StringBuilder result) { + // Beginning from an initial state of the Alpha sub-mode + // The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text + // Compaction mode Alpha sub-mode (uppercase alphabetic). A latch codeword from another mode to the Text + // Compaction mode shall always switch to the Text Compaction Alpha sub-mode. + Mode subMode = Mode.ALPHA; + Mode priorToShiftMode = Mode.ALPHA; + int i = 0; + while (i < length) { + int subModeCh = textCompactionData[i]; + char ch = 0; + switch (subMode) { + case ALPHA: + // Alpha (uppercase alphabetic) + if (subModeCh < 26) { + // Upper case Alpha Character + ch = (char) ('A' + subModeCh); + } else { + if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == LL) { + subMode = Mode.LOWER; + } else if (subModeCh == ML) { + subMode = Mode.MIXED; + } else if (subModeCh == PS) { + // Shift to punctuation + priorToShiftMode = subMode; + subMode = Mode.PUNCT_SHIFT; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result.append((char) byteCompactionData[i]); + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = Mode.ALPHA; + } + } + break; + + case LOWER: + // Lower (lowercase alphabetic) + if (subModeCh < 26) { + ch = (char) ('a' + subModeCh); + } else { + if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == AS) { + // Shift to alpha + priorToShiftMode = subMode; + subMode = Mode.ALPHA_SHIFT; + } else if (subModeCh == ML) { + subMode = Mode.MIXED; + } else if (subModeCh == PS) { + // Shift to punctuation + priorToShiftMode = subMode; + subMode = Mode.PUNCT_SHIFT; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result.append((char) byteCompactionData[i]); + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = Mode.ALPHA; + } + } + break; + + case MIXED: + // Mixed (numeric and some punctuation) + if (subModeCh < PL) { + ch = MIXED_CHARS[subModeCh]; + } else { + if (subModeCh == PL) { + subMode = Mode.PUNCT; + } else if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == LL) { + subMode = Mode.LOWER; + } else if (subModeCh == AL) { + subMode = Mode.ALPHA; + } else if (subModeCh == PS) { + // Shift to punctuation + priorToShiftMode = subMode; + subMode = Mode.PUNCT_SHIFT; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result.append((char) byteCompactionData[i]); + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = Mode.ALPHA; + } + } + break; + + case PUNCT: + // Punctuation + if (subModeCh < PAL) { + ch = PUNCT_CHARS[subModeCh]; + } else { + if (subModeCh == PAL) { + subMode = Mode.ALPHA; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result.append((char) byteCompactionData[i]); + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = Mode.ALPHA; + } + } + break; + + case ALPHA_SHIFT: + // Restore sub-mode + subMode = priorToShiftMode; + if (subModeCh < 26) { + ch = (char) ('A' + subModeCh); + } else { + if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = Mode.ALPHA; + } + } + break; + + case PUNCT_SHIFT: + // Restore sub-mode + subMode = priorToShiftMode; + if (subModeCh < PAL) { + ch = PUNCT_CHARS[subModeCh]; + } else { + if (subModeCh == PAL) { + subMode = Mode.ALPHA; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + // PS before Shift-to-Byte is used as a padding character, + // see 5.4.2.4 of the specification + result.append((char) byteCompactionData[i]); + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = Mode.ALPHA; + } + } + break; + } + if (ch != 0) { + // Append decoded character to result + result.append(ch); + } + i++; + } + } + + /** + * Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded. + * This includes all ASCII characters value 0 to 127 inclusive and provides for international + * character set support. + * + * @param mode The byte compaction mode i.e. 901 or 924 + * @param codewords The array of codewords (data + error) + * @param codeIndex The current index into the codeword array. + * @param result The decoded data is appended to the result. + * @return The next index into the codeword array. + */ + private static int byteCompaction(int mode, int[] codewords, int codeIndex, StringBuilder result) { + if (mode == BYTE_COMPACTION_MODE_LATCH) { + // Total number of Byte Compaction characters to be encoded + // is not a multiple of 6 + int count = 0; + long value = 0; + char[] decodedData = new char[6]; + int[] byteCompactedCodewords = new int[6]; + boolean end = false; + int nextCode = codewords[codeIndex++]; + while ((codeIndex < codewords[0]) && !end) { + byteCompactedCodewords[count++] = nextCode; + // Base 900 + value = 900 * value + nextCode; + nextCode = codewords[codeIndex++]; + // perhaps it should be ok to check only nextCode >= TEXT_COMPACTION_MODE_LATCH + if (nextCode == TEXT_COMPACTION_MODE_LATCH || + nextCode == BYTE_COMPACTION_MODE_LATCH || + nextCode == NUMERIC_COMPACTION_MODE_LATCH || + nextCode == BYTE_COMPACTION_MODE_LATCH_6 || + nextCode == BEGIN_MACRO_PDF417_CONTROL_BLOCK || + nextCode == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || + nextCode == MACRO_PDF417_TERMINATOR) { + codeIndex--; + end = true; + } else { + if ((count % 5 == 0) && (count > 0)) { + // Decode every 5 codewords + // Convert to Base 256 + for (int j = 0; j < 6; ++j) { + decodedData[5 - j] = (char) (value % 256); + value >>= 8; + } + result.append(decodedData); + count = 0; + } + } + } + + // if the end of all codewords is reached the last codeword needs to be added + if (codeIndex == codewords[0] && nextCode < TEXT_COMPACTION_MODE_LATCH) { + byteCompactedCodewords[count++] = nextCode; + } + + // If Byte Compaction mode is invoked with codeword 901, + // the last group of codewords is interpreted directly + // as one byte per codeword, without compaction. + for (int i = 0; i < count; i++) { + result.append((char)byteCompactedCodewords[i]); + } + + } else if (mode == BYTE_COMPACTION_MODE_LATCH_6) { + // Total number of Byte Compaction characters to be encoded + // is an integer multiple of 6 + int count = 0; + long value = 0; + boolean end = false; + while (codeIndex < codewords[0] && !end) { + int code = codewords[codeIndex++]; + if (code < TEXT_COMPACTION_MODE_LATCH) { + count++; + // Base 900 + value = 900 * value + code; + } else { + if (code == TEXT_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH || + code == NUMERIC_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH_6 || + code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || + code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || + code == MACRO_PDF417_TERMINATOR) { + codeIndex--; + end = true; + } + } + if ((count % 5 == 0) && (count > 0)) { + // Decode every 5 codewords + // Convert to Base 256 + char[] decodedData = new char[6]; + for (int j = 0; j < 6; ++j) { + decodedData[5 - j] = (char) (value & 0xFF); + value >>= 8; + } + result.append(decodedData); + count = 0; + } + } + } + return codeIndex; + } + + /** + * Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings. + * + * @param codewords The array of codewords (data + error) + * @param codeIndex The current index into the codeword array. + * @param result The decoded data is appended to the result. + * @return The next index into the codeword array. + */ + private static int numericCompaction(int[] codewords, int codeIndex, StringBuilder result) throws FormatException { + int count = 0; + boolean end = false; + + int[] numericCodewords = new int[MAX_NUMERIC_CODEWORDS]; + + while (codeIndex < codewords[0] && !end) { + int code = codewords[codeIndex++]; + if (codeIndex == codewords[0]) { + end = true; + } + if (code < TEXT_COMPACTION_MODE_LATCH) { + numericCodewords[count] = code; + count++; + } else { + if (code == TEXT_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH_6 || + code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || + code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || + code == MACRO_PDF417_TERMINATOR) { + codeIndex--; + end = true; + } + } + if (count % MAX_NUMERIC_CODEWORDS == 0 || + code == NUMERIC_COMPACTION_MODE_LATCH || + end) { + // Re-invoking Numeric Compaction mode (by using codeword 902 + // while in Numeric Compaction mode) serves to terminate the + // current Numeric Compaction mode grouping as described in 5.4.4.2, + // and then to start a new one grouping. + String s = decodeBase900toBase10(numericCodewords, count); + result.append(s); + count = 0; + } + } + return codeIndex; + } + + /** + * Convert a list of Numeric Compacted codewords from Base 900 to Base 10. + * + * @param codewords The array of codewords + * @param count The number of codewords + * @return The decoded string representing the Numeric data. + */ + /* + EXAMPLE + Encode the fifteen digit numeric string 000213298174000 + Prefix the numeric string with a 1 and set the initial value of + t = 1 000 213 298 174 000 + Calculate codeword 0 + d0 = 1 000 213 298 174 000 mod 900 = 200 + + t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082 + Calculate codeword 1 + d1 = 1 111 348 109 082 mod 900 = 282 + + t = 1 111 348 109 082 div 900 = 1 234 831 232 + Calculate codeword 2 + d2 = 1 234 831 232 mod 900 = 632 + + t = 1 234 831 232 div 900 = 1 372 034 + Calculate codeword 3 + d3 = 1 372 034 mod 900 = 434 + + t = 1 372 034 div 900 = 1 524 + Calculate codeword 4 + d4 = 1 524 mod 900 = 624 + + t = 1 524 div 900 = 1 + Calculate codeword 5 + d5 = 1 mod 900 = 1 + t = 1 div 900 = 0 + Codeword sequence is: 1, 624, 434, 632, 282, 200 + + Decode the above codewords involves + 1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 + + 632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000 + + Remove leading 1 => Result is 000213298174000 + */ + private static String decodeBase900toBase10(int[] codewords, int count) throws FormatException { + BigInteger result = BigInteger.ZERO; + for (int i = 0; i < count; i++) { + result = result.add(EXP900[count - i - 1].multiply(BigInteger.valueOf(codewords[i]))); + } + String resultString = result.toString(); + if (resultString.charAt(0) != '1') { + throw FormatException.getFormatInstance(); + } + return resultString.substring(1); + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/Decoder.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/Decoder.java index b63f194..45af481 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/Decoder.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/pdf417/decoder/Decoder.java @@ -1,137 +1,137 @@ -/* - * Copyright 2009 ZXing authors - * - * 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. - */ - -package com.google.zxing.pdf417.decoder; - -import com.google.zxing.ChecksumException; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.pdf417.decoder.ec.ErrorCorrection; - -/** - *

The main class which implements PDF417 Code decoding -- as - * opposed to locating and extracting the PDF417 Code from an image.

- * - * @author SITA Lab (kevin.osullivan@sita.aero) - */ -public final class Decoder { - - private static final int MAX_ERRORS = 3; - private static final int MAX_EC_CODEWORDS = 512; - private final ErrorCorrection errorCorrection; - - public Decoder() { - errorCorrection = new ErrorCorrection(); - } - - /** - *

Convenience method that can decode a PDF417 Code represented as a 2D array of booleans. - * "true" is taken to mean a black module.

- * - * @param image booleans representing white/black PDF417 modules - * @return text and bytes encoded within the PDF417 Code - */ - public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException { - int dimension = image.length; - BitMatrix bits = new BitMatrix(dimension); - for (int i = 0; i < dimension; i++) { - for (int j = 0; j < dimension; j++) { - if (image[j][i]) { - bits.set(j, i); - } - } - } - return decode(bits); - } - - /** - *

Decodes a PDF417 Code represented as a {@link BitMatrix}. - * A 1 or "true" is taken to mean a black module.

- * - * @param bits booleans representing white/black PDF417 Code modules - * @return text and bytes encoded within the PDF417 Code - * @throws FormatException if the PDF417 Code cannot be decoded - */ - public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException { - // Construct a parser to read the data codewords and error-correction level - BitMatrixParser parser = new BitMatrixParser(bits); - int[] codewords = parser.readCodewords(); - if (codewords.length == 0) { - throw FormatException.getFormatInstance(); - } - - int ecLevel = parser.getECLevel(); - int numECCodewords = 1 << (ecLevel + 1); - int[] erasures = parser.getErasures(); - - correctErrors(codewords, erasures, numECCodewords); - verifyCodewordCount(codewords, numECCodewords); - - // Decode the codewords - return DecodedBitStreamParser.decode(codewords); - } - - /** - * Verify that all is OK with the codeword array. - * - * @param codewords - * @return an index to the first data codeword. - */ - private static void verifyCodewordCount(int[] codewords, int numECCodewords) throws FormatException { - if (codewords.length < 4) { - // Codeword array size should be at least 4 allowing for - // Count CW, At least one Data CW, Error Correction CW, Error Correction CW - throw FormatException.getFormatInstance(); - } - // The first codeword, the Symbol Length Descriptor, shall always encode the total number of data - // codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad - // codewords, but excluding the number of error correction codewords. - int numberOfCodewords = codewords[0]; - if (numberOfCodewords > codewords.length) { - throw FormatException.getFormatInstance(); - } - if (numberOfCodewords == 0) { - // Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords) - if (numECCodewords < codewords.length) { - codewords[0] = codewords.length - numECCodewords; - } else { - throw FormatException.getFormatInstance(); - } - } - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place.

- * - * @param codewords data and error correction codewords - * @param erasures positions of any known erasures - * @param numECCodewords number of error correction codewards that were available in codewords - * @throws ChecksumException if error correction fails - */ - private void correctErrors(int[] codewords, - int[] erasures, - int numECCodewords) throws ChecksumException { - if (erasures.length > numECCodewords / 2 + MAX_ERRORS || - numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS) { - // Too many errors or EC Codewords is corrupted - throw ChecksumException.getChecksumInstance(); - } - errorCorrection.decode(codewords, numECCodewords, erasures); - } - -} +/* + * Copyright 2009 ZXing authors + * + * 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. + */ + +package com.google.zxing.pdf417.decoder; + +import com.google.zxing.ChecksumException; +import com.google.zxing.FormatException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.DecoderResult; +import com.google.zxing.pdf417.decoder.ec.ErrorCorrection; + +/** + *

The main class which implements PDF417 Code decoding -- as + * opposed to locating and extracting the PDF417 Code from an image.

+ * + * @author SITA Lab (kevin.osullivan@sita.aero) + */ +public final class Decoder { + + private static final int MAX_ERRORS = 3; + private static final int MAX_EC_CODEWORDS = 512; + private final ErrorCorrection errorCorrection; + + public Decoder() { + errorCorrection = new ErrorCorrection(); + } + + /** + *

Convenience method that can decode a PDF417 Code represented as a 2D array of booleans. + * "true" is taken to mean a black module.

+ * + * @param image booleans representing white/black PDF417 modules + * @return text and bytes encoded within the PDF417 Code + */ + public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException { + int dimension = image.length; + BitMatrix bits = new BitMatrix(dimension); + for (int i = 0; i < dimension; i++) { + for (int j = 0; j < dimension; j++) { + if (image[j][i]) { + bits.set(j, i); + } + } + } + return decode(bits); + } + + /** + *

Decodes a PDF417 Code represented as a {@link BitMatrix}. + * A 1 or "true" is taken to mean a black module.

+ * + * @param bits booleans representing white/black PDF417 Code modules + * @return text and bytes encoded within the PDF417 Code + * @throws FormatException if the PDF417 Code cannot be decoded + */ + public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException { + // Construct a parser to read the data codewords and error-correction level + BitMatrixParser parser = new BitMatrixParser(bits); + int[] codewords = parser.readCodewords(); + if (codewords.length == 0) { + throw FormatException.getFormatInstance(); + } + + int ecLevel = parser.getECLevel(); + int numECCodewords = 1 << (ecLevel + 1); + int[] erasures = parser.getErasures(); + + correctErrors(codewords, erasures, numECCodewords); + verifyCodewordCount(codewords, numECCodewords); + + // Decode the codewords + return DecodedBitStreamParser.decode(codewords); + } + + /** + * Verify that all is OK with the codeword array. + * + * @param codewords + * @return an index to the first data codeword. + */ + private static void verifyCodewordCount(int[] codewords, int numECCodewords) throws FormatException { + if (codewords.length < 4) { + // Codeword array size should be at least 4 allowing for + // Count CW, At least one Data CW, Error Correction CW, Error Correction CW + throw FormatException.getFormatInstance(); + } + // The first codeword, the Symbol Length Descriptor, shall always encode the total number of data + // codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad + // codewords, but excluding the number of error correction codewords. + int numberOfCodewords = codewords[0]; + if (numberOfCodewords > codewords.length) { + throw FormatException.getFormatInstance(); + } + if (numberOfCodewords == 0) { + // Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords) + if (numECCodewords < codewords.length) { + codewords[0] = codewords.length - numECCodewords; + } else { + throw FormatException.getFormatInstance(); + } + } + } + + /** + *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to + * correct the errors in-place.

+ * + * @param codewords data and error correction codewords + * @param erasures positions of any known erasures + * @param numECCodewords number of error correction codewards that were available in codewords + * @throws ChecksumException if error correction fails + */ + private void correctErrors(int[] codewords, + int[] erasures, + int numECCodewords) throws ChecksumException { + if (erasures.length > numECCodewords / 2 + MAX_ERRORS || + numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS) { + // Too many errors or EC Codewords is corrupted + throw ChecksumException.getChecksumInstance(); + } + errorCorrection.decode(codewords, numECCodewords, erasures); + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/BitMatrixParser.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/BitMatrixParser.java index b645295..1136148 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/BitMatrixParser.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/BitMatrixParser.java @@ -1,205 +1,205 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - * @author Sean Owen - */ -final class BitMatrixParser { - - private final BitMatrix bitMatrix; - private Version parsedVersion; - private FormatInformation parsedFormatInfo; - - /** - * @param bitMatrix {@link BitMatrix} to parse - * @throws FormatException if dimension is not >= 21 and 1 mod 4 - */ - BitMatrixParser(BitMatrix bitMatrix) throws FormatException { - int dimension = bitMatrix.getHeight(); - if (dimension < 21 || (dimension & 0x03) != 1) { - throw FormatException.getFormatInstance(); - } - this.bitMatrix = bitMatrix; - } - - /** - *

Reads format information from one of its two locations within the QR Code.

- * - * @return {@link FormatInformation} encapsulating the QR Code's format info - * @throws FormatException if both format information locations cannot be parsed as - * the valid encoding of format information - */ - FormatInformation readFormatInformation() throws FormatException { - - if (parsedFormatInfo != null) { - return parsedFormatInfo; - } - - // Read top-left format info bits - int formatInfoBits1 = 0; - for (int i = 0; i < 6; i++) { - formatInfoBits1 = copyBit(i, 8, formatInfoBits1); - } - // .. and skip a bit in the timing pattern ... - formatInfoBits1 = copyBit(7, 8, formatInfoBits1); - formatInfoBits1 = copyBit(8, 8, formatInfoBits1); - formatInfoBits1 = copyBit(8, 7, formatInfoBits1); - // .. and skip a bit in the timing pattern ... - for (int j = 5; j >= 0; j--) { - formatInfoBits1 = copyBit(8, j, formatInfoBits1); - } - - // Read the top-right/bottom-left pattern too - int dimension = bitMatrix.getHeight(); - int formatInfoBits2 = 0; - int jMin = dimension - 7; - for (int j = dimension - 1; j >= jMin; j--) { - formatInfoBits2 = copyBit(8, j, formatInfoBits2); - } - for (int i = dimension - 8; i < dimension; i++) { - formatInfoBits2 = copyBit(i, 8, formatInfoBits2); - } - - parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2); - if (parsedFormatInfo != null) { - return parsedFormatInfo; - } - throw FormatException.getFormatInstance(); - } - - /** - *

Reads version information from one of its two locations within the QR Code.

- * - * @return {@link Version} encapsulating the QR Code's version - * @throws FormatException if both version information locations cannot be parsed as - * the valid encoding of version information - */ - Version readVersion() throws FormatException { - - if (parsedVersion != null) { - return parsedVersion; - } - - int dimension = bitMatrix.getHeight(); - - int provisionalVersion = (dimension - 17) >> 2; - if (provisionalVersion <= 6) { - return Version.getVersionForNumber(provisionalVersion); - } - - // Read top-right version info: 3 wide by 6 tall - int versionBits = 0; - int ijMin = dimension - 11; - for (int j = 5; j >= 0; j--) { - for (int i = dimension - 9; i >= ijMin; i--) { - versionBits = copyBit(i, j, versionBits); - } - } - - Version theParsedVersion = Version.decodeVersionInformation(versionBits); - if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) { - parsedVersion = theParsedVersion; - return theParsedVersion; - } - - // Hmm, failed. Try bottom left: 6 wide by 3 tall - versionBits = 0; - for (int i = 5; i >= 0; i--) { - for (int j = dimension - 9; j >= ijMin; j--) { - versionBits = copyBit(i, j, versionBits); - } - } - - theParsedVersion = Version.decodeVersionInformation(versionBits); - if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) { - parsedVersion = theParsedVersion; - return theParsedVersion; - } - throw FormatException.getFormatInstance(); - } - - private int copyBit(int i, int j, int versionBits) { - return bitMatrix.get(i, j) ? (versionBits << 1) | 0x1 : versionBits << 1; - } - - /** - *

Reads the bits in the {@link BitMatrix} representing the finder pattern in the - * correct order in order to reconstitute the codewords bytes contained within the - * QR Code.

- * - * @return bytes encoded within the QR Code - * @throws FormatException if the exact number of bytes expected is not read - */ - byte[] readCodewords() throws FormatException { - - FormatInformation formatInfo = readFormatInformation(); - Version version = readVersion(); - - // Get the data mask for the format used in this QR Code. This will exclude - // some bits from reading as we wind through the bit matrix. - DataMask dataMask = DataMask.forReference((int) formatInfo.getDataMask()); - int dimension = bitMatrix.getHeight(); - dataMask.unmaskBitMatrix(bitMatrix, dimension); - - BitMatrix functionPattern = version.buildFunctionPattern(); - - boolean readingUp = true; - byte[] result = new byte[version.getTotalCodewords()]; - int resultOffset = 0; - int currentByte = 0; - int bitsRead = 0; - // Read columns in pairs, from right to left - for (int j = dimension - 1; j > 0; j -= 2) { - if (j == 6) { - // Skip whole column with vertical alignment pattern; - // saves time and makes the other code proceed more cleanly - j--; - } - // Read alternatingly from bottom to top then top to bottom - for (int count = 0; count < dimension; count++) { - int i = readingUp ? dimension - 1 - count : count; - for (int col = 0; col < 2; col++) { - // Ignore bits covered by the function pattern - if (!functionPattern.get(j - col, i)) { - // Read a bit - bitsRead++; - currentByte <<= 1; - if (bitMatrix.get(j - col, i)) { - currentByte |= 1; - } - // If we've made a whole byte, save it off - if (bitsRead == 8) { - result[resultOffset++] = (byte) currentByte; - bitsRead = 0; - currentByte = 0; - } - } - } - } - readingUp ^= true; // readingUp = !readingUp; // switch directions - } - if (resultOffset != version.getTotalCodewords()) { - throw FormatException.getFormatInstance(); - } - return result; - } - +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.qrcode.decoder; + +import com.google.zxing.FormatException; +import com.google.zxing.common.BitMatrix; + +/** + * @author Sean Owen + */ +final class BitMatrixParser { + + private final BitMatrix bitMatrix; + private Version parsedVersion; + private FormatInformation parsedFormatInfo; + + /** + * @param bitMatrix {@link BitMatrix} to parse + * @throws FormatException if dimension is not >= 21 and 1 mod 4 + */ + BitMatrixParser(BitMatrix bitMatrix) throws FormatException { + int dimension = bitMatrix.getHeight(); + if (dimension < 21 || (dimension & 0x03) != 1) { + throw FormatException.getFormatInstance(); + } + this.bitMatrix = bitMatrix; + } + + /** + *

Reads format information from one of its two locations within the QR Code.

+ * + * @return {@link FormatInformation} encapsulating the QR Code's format info + * @throws FormatException if both format information locations cannot be parsed as + * the valid encoding of format information + */ + FormatInformation readFormatInformation() throws FormatException { + + if (parsedFormatInfo != null) { + return parsedFormatInfo; + } + + // Read top-left format info bits + int formatInfoBits1 = 0; + for (int i = 0; i < 6; i++) { + formatInfoBits1 = copyBit(i, 8, formatInfoBits1); + } + // .. and skip a bit in the timing pattern ... + formatInfoBits1 = copyBit(7, 8, formatInfoBits1); + formatInfoBits1 = copyBit(8, 8, formatInfoBits1); + formatInfoBits1 = copyBit(8, 7, formatInfoBits1); + // .. and skip a bit in the timing pattern ... + for (int j = 5; j >= 0; j--) { + formatInfoBits1 = copyBit(8, j, formatInfoBits1); + } + + // Read the top-right/bottom-left pattern too + int dimension = bitMatrix.getHeight(); + int formatInfoBits2 = 0; + int jMin = dimension - 7; + for (int j = dimension - 1; j >= jMin; j--) { + formatInfoBits2 = copyBit(8, j, formatInfoBits2); + } + for (int i = dimension - 8; i < dimension; i++) { + formatInfoBits2 = copyBit(i, 8, formatInfoBits2); + } + + parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2); + if (parsedFormatInfo != null) { + return parsedFormatInfo; + } + throw FormatException.getFormatInstance(); + } + + /** + *

Reads version information from one of its two locations within the QR Code.

+ * + * @return {@link Version} encapsulating the QR Code's version + * @throws FormatException if both version information locations cannot be parsed as + * the valid encoding of version information + */ + Version readVersion() throws FormatException { + + if (parsedVersion != null) { + return parsedVersion; + } + + int dimension = bitMatrix.getHeight(); + + int provisionalVersion = (dimension - 17) >> 2; + if (provisionalVersion <= 6) { + return Version.getVersionForNumber(provisionalVersion); + } + + // Read top-right version info: 3 wide by 6 tall + int versionBits = 0; + int ijMin = dimension - 11; + for (int j = 5; j >= 0; j--) { + for (int i = dimension - 9; i >= ijMin; i--) { + versionBits = copyBit(i, j, versionBits); + } + } + + Version theParsedVersion = Version.decodeVersionInformation(versionBits); + if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) { + parsedVersion = theParsedVersion; + return theParsedVersion; + } + + // Hmm, failed. Try bottom left: 6 wide by 3 tall + versionBits = 0; + for (int i = 5; i >= 0; i--) { + for (int j = dimension - 9; j >= ijMin; j--) { + versionBits = copyBit(i, j, versionBits); + } + } + + theParsedVersion = Version.decodeVersionInformation(versionBits); + if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) { + parsedVersion = theParsedVersion; + return theParsedVersion; + } + throw FormatException.getFormatInstance(); + } + + private int copyBit(int i, int j, int versionBits) { + return bitMatrix.get(i, j) ? (versionBits << 1) | 0x1 : versionBits << 1; + } + + /** + *

Reads the bits in the {@link BitMatrix} representing the finder pattern in the + * correct order in order to reconstitute the codewords bytes contained within the + * QR Code.

+ * + * @return bytes encoded within the QR Code + * @throws FormatException if the exact number of bytes expected is not read + */ + byte[] readCodewords() throws FormatException { + + FormatInformation formatInfo = readFormatInformation(); + Version version = readVersion(); + + // Get the data mask for the format used in this QR Code. This will exclude + // some bits from reading as we wind through the bit matrix. + DataMask dataMask = DataMask.forReference((int) formatInfo.getDataMask()); + int dimension = bitMatrix.getHeight(); + dataMask.unmaskBitMatrix(bitMatrix, dimension); + + BitMatrix functionPattern = version.buildFunctionPattern(); + + boolean readingUp = true; + byte[] result = new byte[version.getTotalCodewords()]; + int resultOffset = 0; + int currentByte = 0; + int bitsRead = 0; + // Read columns in pairs, from right to left + for (int j = dimension - 1; j > 0; j -= 2) { + if (j == 6) { + // Skip whole column with vertical alignment pattern; + // saves time and makes the other code proceed more cleanly + j--; + } + // Read alternatingly from bottom to top then top to bottom + for (int count = 0; count < dimension; count++) { + int i = readingUp ? dimension - 1 - count : count; + for (int col = 0; col < 2; col++) { + // Ignore bits covered by the function pattern + if (!functionPattern.get(j - col, i)) { + // Read a bit + bitsRead++; + currentByte <<= 1; + if (bitMatrix.get(j - col, i)) { + currentByte |= 1; + } + // If we've made a whole byte, save it off + if (bitsRead == 8) { + result[resultOffset++] = (byte) currentByte; + bitsRead = 0; + currentByte = 0; + } + } + } + } + readingUp ^= true; // readingUp = !readingUp; // switch directions + } + if (resultOffset != version.getTotalCodewords()) { + throw FormatException.getFormatInstance(); + } + return result; + } + } \ No newline at end of file diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataBlock.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataBlock.java index 8f5cdcb..14141b6 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataBlock.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataBlock.java @@ -1,122 +1,122 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.qrcode.decoder; - -/** - *

Encapsulates a block of data within a QR Code. QR Codes may split their data into - * multiple blocks, each of which is a unit of data and error-correction codewords. Each - * is represented by an instance of this class.

- * - * @author Sean Owen - */ -final class DataBlock { - - private final int numDataCodewords; - private final byte[] codewords; - - private DataBlock(int numDataCodewords, byte[] codewords) { - this.numDataCodewords = numDataCodewords; - this.codewords = codewords; - } - - /** - *

When QR Codes use multiple data blocks, they are actually interleaved. - * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This - * method will separate the data into original blocks.

- * - * @param rawCodewords bytes as read directly from the QR Code - * @param version version of the QR Code - * @param ecLevel error-correction level of the QR Code - * @return DataBlocks containing original bytes, "de-interleaved" from representation in the - * QR Code - */ - static DataBlock[] getDataBlocks(byte[] rawCodewords, - Version version, - ErrorCorrectionLevel ecLevel) { - - if (rawCodewords.length != version.getTotalCodewords()) { - throw new IllegalArgumentException(); - } - - // Figure out the number and size of data blocks used by this version and - // error correction level - Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); - - // First count the total number of data blocks - int totalBlocks = 0; - Version.ECB[] ecBlockArray = ecBlocks.getECBlocks(); - for (Version.ECB ecBlock : ecBlockArray) { - totalBlocks += ecBlock.getCount(); - } - - // Now establish DataBlocks of the appropriate size and number of data codewords - DataBlock[] result = new DataBlock[totalBlocks]; - int numResultBlocks = 0; - for (Version.ECB ecBlock : ecBlockArray) { - for (int i = 0; i < ecBlock.getCount(); i++) { - int numDataCodewords = ecBlock.getDataCodewords(); - int numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords; - result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); - } - } - - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 more byte. Figure out where these start. - int shorterBlocksTotalCodewords = result[0].codewords.length; - int longerBlocksStartAt = result.length - 1; - while (longerBlocksStartAt >= 0) { - int numCodewords = result[longerBlocksStartAt].codewords.length; - if (numCodewords == shorterBlocksTotalCodewords) { - break; - } - longerBlocksStartAt--; - } - longerBlocksStartAt++; - - int shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock(); - // The last elements of result may be 1 element longer; - // first fill out as many elements as all of them have - int rawCodewordsOffset = 0; - for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { - for (int j = 0; j < numResultBlocks; j++) { - result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; - } - } - // Fill out the last data block in the longer ones - for (int j = longerBlocksStartAt; j < numResultBlocks; j++) { - result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; - } - // Now add in error correction blocks - int max = result[0].codewords.length; - for (int i = shorterBlocksNumDataCodewords; i < max; i++) { - for (int j = 0; j < numResultBlocks; j++) { - int iOffset = j < longerBlocksStartAt ? i : i + 1; - result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; - } - } - return result; - } - - int getNumDataCodewords() { - return numDataCodewords; - } - - byte[] getCodewords() { - return codewords; - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.qrcode.decoder; + +/** + *

Encapsulates a block of data within a QR Code. QR Codes may split their data into + * multiple blocks, each of which is a unit of data and error-correction codewords. Each + * is represented by an instance of this class.

+ * + * @author Sean Owen + */ +final class DataBlock { + + private final int numDataCodewords; + private final byte[] codewords; + + private DataBlock(int numDataCodewords, byte[] codewords) { + this.numDataCodewords = numDataCodewords; + this.codewords = codewords; + } + + /** + *

When QR Codes use multiple data blocks, they are actually interleaved. + * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This + * method will separate the data into original blocks.

+ * + * @param rawCodewords bytes as read directly from the QR Code + * @param version version of the QR Code + * @param ecLevel error-correction level of the QR Code + * @return DataBlocks containing original bytes, "de-interleaved" from representation in the + * QR Code + */ + static DataBlock[] getDataBlocks(byte[] rawCodewords, + Version version, + ErrorCorrectionLevel ecLevel) { + + if (rawCodewords.length != version.getTotalCodewords()) { + throw new IllegalArgumentException(); + } + + // Figure out the number and size of data blocks used by this version and + // error correction level + Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); + + // First count the total number of data blocks + int totalBlocks = 0; + Version.ECB[] ecBlockArray = ecBlocks.getECBlocks(); + for (Version.ECB ecBlock : ecBlockArray) { + totalBlocks += ecBlock.getCount(); + } + + // Now establish DataBlocks of the appropriate size and number of data codewords + DataBlock[] result = new DataBlock[totalBlocks]; + int numResultBlocks = 0; + for (Version.ECB ecBlock : ecBlockArray) { + for (int i = 0; i < ecBlock.getCount(); i++) { + int numDataCodewords = ecBlock.getDataCodewords(); + int numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords; + result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); + } + } + + // All blocks have the same amount of data, except that the last n + // (where n may be 0) have 1 more byte. Figure out where these start. + int shorterBlocksTotalCodewords = result[0].codewords.length; + int longerBlocksStartAt = result.length - 1; + while (longerBlocksStartAt >= 0) { + int numCodewords = result[longerBlocksStartAt].codewords.length; + if (numCodewords == shorterBlocksTotalCodewords) { + break; + } + longerBlocksStartAt--; + } + longerBlocksStartAt++; + + int shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock(); + // The last elements of result may be 1 element longer; + // first fill out as many elements as all of them have + int rawCodewordsOffset = 0; + for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { + for (int j = 0; j < numResultBlocks; j++) { + result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; + } + } + // Fill out the last data block in the longer ones + for (int j = longerBlocksStartAt; j < numResultBlocks; j++) { + result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; + } + // Now add in error correction blocks + int max = result[0].codewords.length; + for (int i = shorterBlocksNumDataCodewords; i < max; i++) { + for (int j = 0; j < numResultBlocks; j++) { + int iOffset = j < longerBlocksStartAt ? i : i + 1; + result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; + } + } + return result; + } + + int getNumDataCodewords() { + return numDataCodewords; + } + + byte[] getCodewords() { + return codewords; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataMask.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataMask.java index 353c1a8..bb2430c 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataMask.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/DataMask.java @@ -1,163 +1,163 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.common.BitMatrix; - -/** - *

Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations - * of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix, - * including areas used for finder patterns, timing patterns, etc. These areas should be unused - * after the point they are unmasked anyway.

- * - *

Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position - * and j is row position. In fact, as the text says, i is row position and j is column position.

- * - * @author Sean Owen - */ -abstract class DataMask { - - /** - * See ISO 18004:2006 6.8.1 - */ - private static final DataMask[] DATA_MASKS = { - new DataMask000(), - new DataMask001(), - new DataMask010(), - new DataMask011(), - new DataMask100(), - new DataMask101(), - new DataMask110(), - new DataMask111(), - }; - - private DataMask() { - } - - /** - *

Implementations of this method reverse the data masking process applied to a QR Code and - * make its bits ready to read.

- * - * @param bits representation of QR Code bits - * @param dimension dimension of QR Code, represented by bits, being unmasked - */ - final void unmaskBitMatrix(BitMatrix bits, int dimension) { - for (int i = 0; i < dimension; i++) { - for (int j = 0; j < dimension; j++) { - if (isMasked(i, j)) { - bits.flip(j, i); - } - } - } - } - - abstract boolean isMasked(int i, int j); - - /** - * @param reference a value between 0 and 7 indicating one of the eight possible - * data mask patterns a QR Code may use - * @return DataMask encapsulating the data mask pattern - */ - static DataMask forReference(int reference) { - if (reference < 0 || reference > 7) { - throw new IllegalArgumentException(); - } - return DATA_MASKS[reference]; - } - - /** - * 000: mask bits for which (x + y) mod 2 == 0 - */ - private static final class DataMask000 extends DataMask { - @Override - boolean isMasked(int i, int j) { - return ((i + j) & 0x01) == 0; - } - } - - /** - * 001: mask bits for which x mod 2 == 0 - */ - private static final class DataMask001 extends DataMask { - @Override - boolean isMasked(int i, int j) { - return (i & 0x01) == 0; - } - } - - /** - * 010: mask bits for which y mod 3 == 0 - */ - private static final class DataMask010 extends DataMask { - @Override - boolean isMasked(int i, int j) { - return j % 3 == 0; - } - } - - /** - * 011: mask bits for which (x + y) mod 3 == 0 - */ - private static final class DataMask011 extends DataMask { - @Override - boolean isMasked(int i, int j) { - return (i + j) % 3 == 0; - } - } - - /** - * 100: mask bits for which (x/2 + y/3) mod 2 == 0 - */ - private static final class DataMask100 extends DataMask { - @Override - boolean isMasked(int i, int j) { - return (((i >>> 1) + (j /3)) & 0x01) == 0; - } - } - - /** - * 101: mask bits for which xy mod 2 + xy mod 3 == 0 - */ - private static final class DataMask101 extends DataMask { - @Override - boolean isMasked(int i, int j) { - int temp = i * j; - return (temp & 0x01) + (temp % 3) == 0; - } - } - - /** - * 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0 - */ - private static final class DataMask110 extends DataMask { - @Override - boolean isMasked(int i, int j) { - int temp = i * j; - return (((temp & 0x01) + (temp % 3)) & 0x01) == 0; - } - } - - /** - * 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0 - */ - private static final class DataMask111 extends DataMask { - @Override - boolean isMasked(int i, int j) { - return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0; - } - } -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.qrcode.decoder; + +import com.google.zxing.common.BitMatrix; + +/** + *

Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations + * of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix, + * including areas used for finder patterns, timing patterns, etc. These areas should be unused + * after the point they are unmasked anyway.

+ * + *

Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position + * and j is row position. In fact, as the text says, i is row position and j is column position.

+ * + * @author Sean Owen + */ +abstract class DataMask { + + /** + * See ISO 18004:2006 6.8.1 + */ + private static final DataMask[] DATA_MASKS = { + new DataMask000(), + new DataMask001(), + new DataMask010(), + new DataMask011(), + new DataMask100(), + new DataMask101(), + new DataMask110(), + new DataMask111(), + }; + + private DataMask() { + } + + /** + *

Implementations of this method reverse the data masking process applied to a QR Code and + * make its bits ready to read.

+ * + * @param bits representation of QR Code bits + * @param dimension dimension of QR Code, represented by bits, being unmasked + */ + final void unmaskBitMatrix(BitMatrix bits, int dimension) { + for (int i = 0; i < dimension; i++) { + for (int j = 0; j < dimension; j++) { + if (isMasked(i, j)) { + bits.flip(j, i); + } + } + } + } + + abstract boolean isMasked(int i, int j); + + /** + * @param reference a value between 0 and 7 indicating one of the eight possible + * data mask patterns a QR Code may use + * @return DataMask encapsulating the data mask pattern + */ + static DataMask forReference(int reference) { + if (reference < 0 || reference > 7) { + throw new IllegalArgumentException(); + } + return DATA_MASKS[reference]; + } + + /** + * 000: mask bits for which (x + y) mod 2 == 0 + */ + private static final class DataMask000 extends DataMask { + @Override + boolean isMasked(int i, int j) { + return ((i + j) & 0x01) == 0; + } + } + + /** + * 001: mask bits for which x mod 2 == 0 + */ + private static final class DataMask001 extends DataMask { + @Override + boolean isMasked(int i, int j) { + return (i & 0x01) == 0; + } + } + + /** + * 010: mask bits for which y mod 3 == 0 + */ + private static final class DataMask010 extends DataMask { + @Override + boolean isMasked(int i, int j) { + return j % 3 == 0; + } + } + + /** + * 011: mask bits for which (x + y) mod 3 == 0 + */ + private static final class DataMask011 extends DataMask { + @Override + boolean isMasked(int i, int j) { + return (i + j) % 3 == 0; + } + } + + /** + * 100: mask bits for which (x/2 + y/3) mod 2 == 0 + */ + private static final class DataMask100 extends DataMask { + @Override + boolean isMasked(int i, int j) { + return (((i >>> 1) + (j /3)) & 0x01) == 0; + } + } + + /** + * 101: mask bits for which xy mod 2 + xy mod 3 == 0 + */ + private static final class DataMask101 extends DataMask { + @Override + boolean isMasked(int i, int j) { + int temp = i * j; + return (temp & 0x01) + (temp % 3) == 0; + } + } + + /** + * 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0 + */ + private static final class DataMask110 extends DataMask { + @Override + boolean isMasked(int i, int j) { + int temp = i * j; + return (((temp & 0x01) + (temp % 3)) & 0x01) == 0; + } + } + + /** + * 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0 + */ + private static final class DataMask111 extends DataMask { + @Override + boolean isMasked(int i, int j) { + return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0; + } + } +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Decoder.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Decoder.java index dc4b8f0..1c8e8e2 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Decoder.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Decoder.java @@ -1,146 +1,146 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.ChecksumException; -import com.google.zxing.DecodeHintType; -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.common.DecoderResult; -import com.google.zxing.common.reedsolomon.GenericGF; -import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; -import com.google.zxing.common.reedsolomon.ReedSolomonException; - -import java.util.Map; - -/** - *

The main class which implements QR Code decoding -- as opposed to locating and extracting - * the QR Code from an image.

- * - * @author Sean Owen - */ -public final class Decoder { - - private final ReedSolomonDecoder rsDecoder; - - public Decoder() { - rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256); - } - - public DecoderResult decode(boolean[][] image) throws ChecksumException, FormatException { - return decode(image, null); - } - - /** - *

Convenience method that can decode a QR Code represented as a 2D array of booleans. - * "true" is taken to mean a black module.

- * - * @param image booleans representing white/black QR Code modules - * @return text and bytes encoded within the QR Code - * @throws FormatException if the QR Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(boolean[][] image, Map hints) - throws ChecksumException, FormatException { - int dimension = image.length; - BitMatrix bits = new BitMatrix(dimension); - for (int i = 0; i < dimension; i++) { - for (int j = 0; j < dimension; j++) { - if (image[i][j]) { - bits.set(j, i); - } - } - } - return decode(bits, hints); - } - - public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException { - return decode(bits, null); - } - - /** - *

Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.

- * - * @param bits booleans representing white/black QR Code modules - * @return text and bytes encoded within the QR Code - * @throws FormatException if the QR Code cannot be decoded - * @throws ChecksumException if error correction fails - */ - public DecoderResult decode(BitMatrix bits, Map hints) - throws FormatException, ChecksumException { - - // Construct a parser and read version, error-correction level - BitMatrixParser parser = new BitMatrixParser(bits); - Version version = parser.readVersion(); - ErrorCorrectionLevel ecLevel = parser.readFormatInformation().getErrorCorrectionLevel(); - - // Read codewords - byte[] codewords = parser.readCodewords(); - // Separate into data blocks - DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel); - - // Count total number of data bytes - int totalBytes = 0; - for (DataBlock dataBlock : dataBlocks) { - totalBytes += dataBlock.getNumDataCodewords(); - } - byte[] resultBytes = new byte[totalBytes]; - int resultOffset = 0; - - // Error-correct and copy data blocks together into a stream of bytes - for (DataBlock dataBlock : dataBlocks) { - byte[] codewordBytes = dataBlock.getCodewords(); - int numDataCodewords = dataBlock.getNumDataCodewords(); - correctErrors(codewordBytes, numDataCodewords); - for (int i = 0; i < numDataCodewords; i++) { - resultBytes[resultOffset++] = codewordBytes[i]; - } - } - - // Decode the contents of that stream of bytes - return DecodedBitStreamParser.decode(resultBytes, version, ecLevel, hints); - } - - /** - *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - * correct the errors in-place using Reed-Solomon error correction.

- * - * @param codewordBytes data and error correction codewords - * @param numDataCodewords number of codewords that are data bytes - * @throws ChecksumException if error correction fails - */ - private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException { - int numCodewords = codewordBytes.length; - // First read into an array of ints - int[] codewordsInts = new int[numCodewords]; - for (int i = 0; i < numCodewords; i++) { - codewordsInts[i] = codewordBytes[i] & 0xFF; - } - int numECCodewords = codewordBytes.length - numDataCodewords; - try { - rsDecoder.decode(codewordsInts, numECCodewords); - } catch (ReedSolomonException rse) { - throw ChecksumException.getChecksumInstance(); - } - // Copy back into array of bytes -- only need to worry about the bytes that were data - // We don't care about errors in the error-correction codewords - for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (byte) codewordsInts[i]; - } - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.qrcode.decoder; + +import com.google.zxing.ChecksumException; +import com.google.zxing.DecodeHintType; +import com.google.zxing.FormatException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.DecoderResult; +import com.google.zxing.common.reedsolomon.GenericGF; +import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; +import com.google.zxing.common.reedsolomon.ReedSolomonException; + +import java.util.Map; + +/** + *

The main class which implements QR Code decoding -- as opposed to locating and extracting + * the QR Code from an image.

+ * + * @author Sean Owen + */ +public final class Decoder { + + private final ReedSolomonDecoder rsDecoder; + + public Decoder() { + rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256); + } + + public DecoderResult decode(boolean[][] image) throws ChecksumException, FormatException { + return decode(image, null); + } + + /** + *

Convenience method that can decode a QR Code represented as a 2D array of booleans. + * "true" is taken to mean a black module.

+ * + * @param image booleans representing white/black QR Code modules + * @return text and bytes encoded within the QR Code + * @throws FormatException if the QR Code cannot be decoded + * @throws ChecksumException if error correction fails + */ + public DecoderResult decode(boolean[][] image, Map hints) + throws ChecksumException, FormatException { + int dimension = image.length; + BitMatrix bits = new BitMatrix(dimension); + for (int i = 0; i < dimension; i++) { + for (int j = 0; j < dimension; j++) { + if (image[i][j]) { + bits.set(j, i); + } + } + } + return decode(bits, hints); + } + + public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException { + return decode(bits, null); + } + + /** + *

Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.

+ * + * @param bits booleans representing white/black QR Code modules + * @return text and bytes encoded within the QR Code + * @throws FormatException if the QR Code cannot be decoded + * @throws ChecksumException if error correction fails + */ + public DecoderResult decode(BitMatrix bits, Map hints) + throws FormatException, ChecksumException { + + // Construct a parser and read version, error-correction level + BitMatrixParser parser = new BitMatrixParser(bits); + Version version = parser.readVersion(); + ErrorCorrectionLevel ecLevel = parser.readFormatInformation().getErrorCorrectionLevel(); + + // Read codewords + byte[] codewords = parser.readCodewords(); + // Separate into data blocks + DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel); + + // Count total number of data bytes + int totalBytes = 0; + for (DataBlock dataBlock : dataBlocks) { + totalBytes += dataBlock.getNumDataCodewords(); + } + byte[] resultBytes = new byte[totalBytes]; + int resultOffset = 0; + + // Error-correct and copy data blocks together into a stream of bytes + for (DataBlock dataBlock : dataBlocks) { + byte[] codewordBytes = dataBlock.getCodewords(); + int numDataCodewords = dataBlock.getNumDataCodewords(); + correctErrors(codewordBytes, numDataCodewords); + for (int i = 0; i < numDataCodewords; i++) { + resultBytes[resultOffset++] = codewordBytes[i]; + } + } + + // Decode the contents of that stream of bytes + return DecodedBitStreamParser.decode(resultBytes, version, ecLevel, hints); + } + + /** + *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to + * correct the errors in-place using Reed-Solomon error correction.

+ * + * @param codewordBytes data and error correction codewords + * @param numDataCodewords number of codewords that are data bytes + * @throws ChecksumException if error correction fails + */ + private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException { + int numCodewords = codewordBytes.length; + // First read into an array of ints + int[] codewordsInts = new int[numCodewords]; + for (int i = 0; i < numCodewords; i++) { + codewordsInts[i] = codewordBytes[i] & 0xFF; + } + int numECCodewords = codewordBytes.length - numDataCodewords; + try { + rsDecoder.decode(codewordsInts, numECCodewords); + } catch (ReedSolomonException rse) { + throw ChecksumException.getChecksumInstance(); + } + // Copy back into array of bytes -- only need to worry about the bytes that were data + // We don't care about errors in the error-correction codewords + for (int i = 0; i < numDataCodewords; i++) { + codewordBytes[i] = (byte) codewordsInts[i]; + } + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Version.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Version.java index 97170d0..ef92e2a 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Version.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/decoder/Version.java @@ -1,578 +1,578 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.qrcode.decoder; - -import com.google.zxing.FormatException; -import com.google.zxing.common.BitMatrix; - -/** - * See ISO 18004:2006 Annex D - * - * @author Sean Owen - */ -public final class Version { - - /** - * See ISO 18004:2006 Annex D. - * Element i represents the raw version bits that specify version i + 7 - */ - private static final int[] VERSION_DECODE_INFO = { - 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, - 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, - 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, - 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, - 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, - 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, - 0x2542E, 0x26A64, 0x27541, 0x28C69 - }; - - private static final Version[] VERSIONS = buildVersions(); - - private final int versionNumber; - private final int[] alignmentPatternCenters; - private final ECBlocks[] ecBlocks; - private final int totalCodewords; - - private Version(int versionNumber, - int[] alignmentPatternCenters, - ECBlocks... ecBlocks) { - this.versionNumber = versionNumber; - this.alignmentPatternCenters = alignmentPatternCenters; - this.ecBlocks = ecBlocks; - int total = 0; - int ecCodewords = ecBlocks[0].getECCodewordsPerBlock(); - ECB[] ecbArray = ecBlocks[0].getECBlocks(); - for (ECB ecBlock : ecbArray) { - total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); - } - this.totalCodewords = total; - } - - public int getVersionNumber() { - return versionNumber; - } - - public int[] getAlignmentPatternCenters() { - return alignmentPatternCenters; - } - - public int getTotalCodewords() { - return totalCodewords; - } - - public int getDimensionForVersion() { - return 17 + 4 * versionNumber; - } - - public ECBlocks getECBlocksForLevel(ErrorCorrectionLevel ecLevel) { - return ecBlocks[ecLevel.ordinal()]; - } - - /** - *

Deduces version information purely from QR Code dimensions.

- * - * @param dimension dimension in modules - * @return Version for a QR Code of that dimension - * @throws FormatException if dimension is not 1 mod 4 - */ - public static Version getProvisionalVersionForDimension(int dimension) throws FormatException { - if (dimension % 4 != 1) { - throw FormatException.getFormatInstance(); - } - try { - return getVersionForNumber((dimension - 17) >> 2); - } catch (IllegalArgumentException iae) { - throw FormatException.getFormatInstance(); - } - } - - public static Version getVersionForNumber(int versionNumber) { - if (versionNumber < 1 || versionNumber > 40) { - throw new IllegalArgumentException(); - } - return VERSIONS[versionNumber - 1]; - } - - static Version decodeVersionInformation(int versionBits) { - int bestDifference = Integer.MAX_VALUE; - int bestVersion = 0; - for (int i = 0; i < VERSION_DECODE_INFO.length; i++) { - int targetVersion = VERSION_DECODE_INFO[i]; - // Do the version info bits match exactly? done. - if (targetVersion == versionBits) { - return getVersionForNumber(i + 7); - } - // Otherwise see if this is the closest to a real version info bit string - // we have seen so far - int bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion); - if (bitsDifference < bestDifference) { - bestVersion = i + 7; - bestDifference = bitsDifference; - } - } - // We can tolerate up to 3 bits of error since no two version info codewords will - // differ in less than 8 bits. - if (bestDifference <= 3) { - return getVersionForNumber(bestVersion); - } - // If we didn't find a close enough match, fail - return null; - } - - /** - * See ISO 18004:2006 Annex E - */ - BitMatrix buildFunctionPattern() { - int dimension = getDimensionForVersion(); - BitMatrix bitMatrix = new BitMatrix(dimension); - - // Top left finder pattern + separator + format - bitMatrix.setRegion(0, 0, 9, 9); - // Top right finder pattern + separator + format - bitMatrix.setRegion(dimension - 8, 0, 8, 9); - // Bottom left finder pattern + separator + format - bitMatrix.setRegion(0, dimension - 8, 9, 8); - - // Alignment patterns - int max = alignmentPatternCenters.length; - for (int x = 0; x < max; x++) { - int i = alignmentPatternCenters[x] - 2; - for (int y = 0; y < max; y++) { - if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) { - // No alignment patterns near the three finder paterns - continue; - } - bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5); - } - } - - // Vertical timing pattern - bitMatrix.setRegion(6, 9, 1, dimension - 17); - // Horizontal timing pattern - bitMatrix.setRegion(9, 6, dimension - 17, 1); - - if (versionNumber > 6) { - // Version info, top right - bitMatrix.setRegion(dimension - 11, 0, 3, 6); - // Version info, bottom left - bitMatrix.setRegion(0, dimension - 11, 6, 3); - } - - return bitMatrix; - } - - /** - *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will - * use blocks of differing sizes within one version, so, this encapsulates the parameters for - * each set of blocks. It also holds the number of error-correction codewords per block since it - * will be the same across all blocks within one version.

- */ - public static final class ECBlocks { - private final int ecCodewordsPerBlock; - private final ECB[] ecBlocks; - - ECBlocks(int ecCodewordsPerBlock, ECB... ecBlocks) { - this.ecCodewordsPerBlock = ecCodewordsPerBlock; - this.ecBlocks = ecBlocks; - } - - public int getECCodewordsPerBlock() { - return ecCodewordsPerBlock; - } - - public int getNumBlocks() { - int total = 0; - for (ECB ecBlock : ecBlocks) { - total += ecBlock.getCount(); - } - return total; - } - - public int getTotalECCodewords() { - return ecCodewordsPerBlock * getNumBlocks(); - } - - public ECB[] getECBlocks() { - return ecBlocks; - } - } - - /** - *

Encapsualtes the parameters for one error-correction block in one symbol version. - * This includes the number of data codewords, and the number of times a block with these - * parameters is used consecutively in the QR code version's format.

- */ - public static final class ECB { - private final int count; - private final int dataCodewords; - - ECB(int count, int dataCodewords) { - this.count = count; - this.dataCodewords = dataCodewords; - } - - public int getCount() { - return count; - } - - public int getDataCodewords() { - return dataCodewords; - } - } - - @Override - public String toString() { - return String.valueOf(versionNumber); - } - - /** - * See ISO 18004:2006 6.5.1 Table 9 - */ - private static Version[] buildVersions() { - return new Version[]{ - new Version(1, new int[]{}, - new ECBlocks(7, new ECB(1, 19)), - new ECBlocks(10, new ECB(1, 16)), - new ECBlocks(13, new ECB(1, 13)), - new ECBlocks(17, new ECB(1, 9))), - new Version(2, new int[]{6, 18}, - new ECBlocks(10, new ECB(1, 34)), - new ECBlocks(16, new ECB(1, 28)), - new ECBlocks(22, new ECB(1, 22)), - new ECBlocks(28, new ECB(1, 16))), - new Version(3, new int[]{6, 22}, - new ECBlocks(15, new ECB(1, 55)), - new ECBlocks(26, new ECB(1, 44)), - new ECBlocks(18, new ECB(2, 17)), - new ECBlocks(22, new ECB(2, 13))), - new Version(4, new int[]{6, 26}, - new ECBlocks(20, new ECB(1, 80)), - new ECBlocks(18, new ECB(2, 32)), - new ECBlocks(26, new ECB(2, 24)), - new ECBlocks(16, new ECB(4, 9))), - new Version(5, new int[]{6, 30}, - new ECBlocks(26, new ECB(1, 108)), - new ECBlocks(24, new ECB(2, 43)), - new ECBlocks(18, new ECB(2, 15), - new ECB(2, 16)), - new ECBlocks(22, new ECB(2, 11), - new ECB(2, 12))), - new Version(6, new int[]{6, 34}, - new ECBlocks(18, new ECB(2, 68)), - new ECBlocks(16, new ECB(4, 27)), - new ECBlocks(24, new ECB(4, 19)), - new ECBlocks(28, new ECB(4, 15))), - new Version(7, new int[]{6, 22, 38}, - new ECBlocks(20, new ECB(2, 78)), - new ECBlocks(18, new ECB(4, 31)), - new ECBlocks(18, new ECB(2, 14), - new ECB(4, 15)), - new ECBlocks(26, new ECB(4, 13), - new ECB(1, 14))), - new Version(8, new int[]{6, 24, 42}, - new ECBlocks(24, new ECB(2, 97)), - new ECBlocks(22, new ECB(2, 38), - new ECB(2, 39)), - new ECBlocks(22, new ECB(4, 18), - new ECB(2, 19)), - new ECBlocks(26, new ECB(4, 14), - new ECB(2, 15))), - new Version(9, new int[]{6, 26, 46}, - new ECBlocks(30, new ECB(2, 116)), - new ECBlocks(22, new ECB(3, 36), - new ECB(2, 37)), - new ECBlocks(20, new ECB(4, 16), - new ECB(4, 17)), - new ECBlocks(24, new ECB(4, 12), - new ECB(4, 13))), - new Version(10, new int[]{6, 28, 50}, - new ECBlocks(18, new ECB(2, 68), - new ECB(2, 69)), - new ECBlocks(26, new ECB(4, 43), - new ECB(1, 44)), - new ECBlocks(24, new ECB(6, 19), - new ECB(2, 20)), - new ECBlocks(28, new ECB(6, 15), - new ECB(2, 16))), - new Version(11, new int[]{6, 30, 54}, - new ECBlocks(20, new ECB(4, 81)), - new ECBlocks(30, new ECB(1, 50), - new ECB(4, 51)), - new ECBlocks(28, new ECB(4, 22), - new ECB(4, 23)), - new ECBlocks(24, new ECB(3, 12), - new ECB(8, 13))), - new Version(12, new int[]{6, 32, 58}, - new ECBlocks(24, new ECB(2, 92), - new ECB(2, 93)), - new ECBlocks(22, new ECB(6, 36), - new ECB(2, 37)), - new ECBlocks(26, new ECB(4, 20), - new ECB(6, 21)), - new ECBlocks(28, new ECB(7, 14), - new ECB(4, 15))), - new Version(13, new int[]{6, 34, 62}, - new ECBlocks(26, new ECB(4, 107)), - new ECBlocks(22, new ECB(8, 37), - new ECB(1, 38)), - new ECBlocks(24, new ECB(8, 20), - new ECB(4, 21)), - new ECBlocks(22, new ECB(12, 11), - new ECB(4, 12))), - new Version(14, new int[]{6, 26, 46, 66}, - new ECBlocks(30, new ECB(3, 115), - new ECB(1, 116)), - new ECBlocks(24, new ECB(4, 40), - new ECB(5, 41)), - new ECBlocks(20, new ECB(11, 16), - new ECB(5, 17)), - new ECBlocks(24, new ECB(11, 12), - new ECB(5, 13))), - new Version(15, new int[]{6, 26, 48, 70}, - new ECBlocks(22, new ECB(5, 87), - new ECB(1, 88)), - new ECBlocks(24, new ECB(5, 41), - new ECB(5, 42)), - new ECBlocks(30, new ECB(5, 24), - new ECB(7, 25)), - new ECBlocks(24, new ECB(11, 12), - new ECB(7, 13))), - new Version(16, new int[]{6, 26, 50, 74}, - new ECBlocks(24, new ECB(5, 98), - new ECB(1, 99)), - new ECBlocks(28, new ECB(7, 45), - new ECB(3, 46)), - new ECBlocks(24, new ECB(15, 19), - new ECB(2, 20)), - new ECBlocks(30, new ECB(3, 15), - new ECB(13, 16))), - new Version(17, new int[]{6, 30, 54, 78}, - new ECBlocks(28, new ECB(1, 107), - new ECB(5, 108)), - new ECBlocks(28, new ECB(10, 46), - new ECB(1, 47)), - new ECBlocks(28, new ECB(1, 22), - new ECB(15, 23)), - new ECBlocks(28, new ECB(2, 14), - new ECB(17, 15))), - new Version(18, new int[]{6, 30, 56, 82}, - new ECBlocks(30, new ECB(5, 120), - new ECB(1, 121)), - new ECBlocks(26, new ECB(9, 43), - new ECB(4, 44)), - new ECBlocks(28, new ECB(17, 22), - new ECB(1, 23)), - new ECBlocks(28, new ECB(2, 14), - new ECB(19, 15))), - new Version(19, new int[]{6, 30, 58, 86}, - new ECBlocks(28, new ECB(3, 113), - new ECB(4, 114)), - new ECBlocks(26, new ECB(3, 44), - new ECB(11, 45)), - new ECBlocks(26, new ECB(17, 21), - new ECB(4, 22)), - new ECBlocks(26, new ECB(9, 13), - new ECB(16, 14))), - new Version(20, new int[]{6, 34, 62, 90}, - new ECBlocks(28, new ECB(3, 107), - new ECB(5, 108)), - new ECBlocks(26, new ECB(3, 41), - new ECB(13, 42)), - new ECBlocks(30, new ECB(15, 24), - new ECB(5, 25)), - new ECBlocks(28, new ECB(15, 15), - new ECB(10, 16))), - new Version(21, new int[]{6, 28, 50, 72, 94}, - new ECBlocks(28, new ECB(4, 116), - new ECB(4, 117)), - new ECBlocks(26, new ECB(17, 42)), - new ECBlocks(28, new ECB(17, 22), - new ECB(6, 23)), - new ECBlocks(30, new ECB(19, 16), - new ECB(6, 17))), - new Version(22, new int[]{6, 26, 50, 74, 98}, - new ECBlocks(28, new ECB(2, 111), - new ECB(7, 112)), - new ECBlocks(28, new ECB(17, 46)), - new ECBlocks(30, new ECB(7, 24), - new ECB(16, 25)), - new ECBlocks(24, new ECB(34, 13))), - new Version(23, new int[]{6, 30, 54, 78, 102}, - new ECBlocks(30, new ECB(4, 121), - new ECB(5, 122)), - new ECBlocks(28, new ECB(4, 47), - new ECB(14, 48)), - new ECBlocks(30, new ECB(11, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(16, 15), - new ECB(14, 16))), - new Version(24, new int[]{6, 28, 54, 80, 106}, - new ECBlocks(30, new ECB(6, 117), - new ECB(4, 118)), - new ECBlocks(28, new ECB(6, 45), - new ECB(14, 46)), - new ECBlocks(30, new ECB(11, 24), - new ECB(16, 25)), - new ECBlocks(30, new ECB(30, 16), - new ECB(2, 17))), - new Version(25, new int[]{6, 32, 58, 84, 110}, - new ECBlocks(26, new ECB(8, 106), - new ECB(4, 107)), - new ECBlocks(28, new ECB(8, 47), - new ECB(13, 48)), - new ECBlocks(30, new ECB(7, 24), - new ECB(22, 25)), - new ECBlocks(30, new ECB(22, 15), - new ECB(13, 16))), - new Version(26, new int[]{6, 30, 58, 86, 114}, - new ECBlocks(28, new ECB(10, 114), - new ECB(2, 115)), - new ECBlocks(28, new ECB(19, 46), - new ECB(4, 47)), - new ECBlocks(28, new ECB(28, 22), - new ECB(6, 23)), - new ECBlocks(30, new ECB(33, 16), - new ECB(4, 17))), - new Version(27, new int[]{6, 34, 62, 90, 118}, - new ECBlocks(30, new ECB(8, 122), - new ECB(4, 123)), - new ECBlocks(28, new ECB(22, 45), - new ECB(3, 46)), - new ECBlocks(30, new ECB(8, 23), - new ECB(26, 24)), - new ECBlocks(30, new ECB(12, 15), - new ECB(28, 16))), - new Version(28, new int[]{6, 26, 50, 74, 98, 122}, - new ECBlocks(30, new ECB(3, 117), - new ECB(10, 118)), - new ECBlocks(28, new ECB(3, 45), - new ECB(23, 46)), - new ECBlocks(30, new ECB(4, 24), - new ECB(31, 25)), - new ECBlocks(30, new ECB(11, 15), - new ECB(31, 16))), - new Version(29, new int[]{6, 30, 54, 78, 102, 126}, - new ECBlocks(30, new ECB(7, 116), - new ECB(7, 117)), - new ECBlocks(28, new ECB(21, 45), - new ECB(7, 46)), - new ECBlocks(30, new ECB(1, 23), - new ECB(37, 24)), - new ECBlocks(30, new ECB(19, 15), - new ECB(26, 16))), - new Version(30, new int[]{6, 26, 52, 78, 104, 130}, - new ECBlocks(30, new ECB(5, 115), - new ECB(10, 116)), - new ECBlocks(28, new ECB(19, 47), - new ECB(10, 48)), - new ECBlocks(30, new ECB(15, 24), - new ECB(25, 25)), - new ECBlocks(30, new ECB(23, 15), - new ECB(25, 16))), - new Version(31, new int[]{6, 30, 56, 82, 108, 134}, - new ECBlocks(30, new ECB(13, 115), - new ECB(3, 116)), - new ECBlocks(28, new ECB(2, 46), - new ECB(29, 47)), - new ECBlocks(30, new ECB(42, 24), - new ECB(1, 25)), - new ECBlocks(30, new ECB(23, 15), - new ECB(28, 16))), - new Version(32, new int[]{6, 34, 60, 86, 112, 138}, - new ECBlocks(30, new ECB(17, 115)), - new ECBlocks(28, new ECB(10, 46), - new ECB(23, 47)), - new ECBlocks(30, new ECB(10, 24), - new ECB(35, 25)), - new ECBlocks(30, new ECB(19, 15), - new ECB(35, 16))), - new Version(33, new int[]{6, 30, 58, 86, 114, 142}, - new ECBlocks(30, new ECB(17, 115), - new ECB(1, 116)), - new ECBlocks(28, new ECB(14, 46), - new ECB(21, 47)), - new ECBlocks(30, new ECB(29, 24), - new ECB(19, 25)), - new ECBlocks(30, new ECB(11, 15), - new ECB(46, 16))), - new Version(34, new int[]{6, 34, 62, 90, 118, 146}, - new ECBlocks(30, new ECB(13, 115), - new ECB(6, 116)), - new ECBlocks(28, new ECB(14, 46), - new ECB(23, 47)), - new ECBlocks(30, new ECB(44, 24), - new ECB(7, 25)), - new ECBlocks(30, new ECB(59, 16), - new ECB(1, 17))), - new Version(35, new int[]{6, 30, 54, 78, 102, 126, 150}, - new ECBlocks(30, new ECB(12, 121), - new ECB(7, 122)), - new ECBlocks(28, new ECB(12, 47), - new ECB(26, 48)), - new ECBlocks(30, new ECB(39, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(22, 15), - new ECB(41, 16))), - new Version(36, new int[]{6, 24, 50, 76, 102, 128, 154}, - new ECBlocks(30, new ECB(6, 121), - new ECB(14, 122)), - new ECBlocks(28, new ECB(6, 47), - new ECB(34, 48)), - new ECBlocks(30, new ECB(46, 24), - new ECB(10, 25)), - new ECBlocks(30, new ECB(2, 15), - new ECB(64, 16))), - new Version(37, new int[]{6, 28, 54, 80, 106, 132, 158}, - new ECBlocks(30, new ECB(17, 122), - new ECB(4, 123)), - new ECBlocks(28, new ECB(29, 46), - new ECB(14, 47)), - new ECBlocks(30, new ECB(49, 24), - new ECB(10, 25)), - new ECBlocks(30, new ECB(24, 15), - new ECB(46, 16))), - new Version(38, new int[]{6, 32, 58, 84, 110, 136, 162}, - new ECBlocks(30, new ECB(4, 122), - new ECB(18, 123)), - new ECBlocks(28, new ECB(13, 46), - new ECB(32, 47)), - new ECBlocks(30, new ECB(48, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(42, 15), - new ECB(32, 16))), - new Version(39, new int[]{6, 26, 54, 82, 110, 138, 166}, - new ECBlocks(30, new ECB(20, 117), - new ECB(4, 118)), - new ECBlocks(28, new ECB(40, 47), - new ECB(7, 48)), - new ECBlocks(30, new ECB(43, 24), - new ECB(22, 25)), - new ECBlocks(30, new ECB(10, 15), - new ECB(67, 16))), - new Version(40, new int[]{6, 30, 58, 86, 114, 142, 170}, - new ECBlocks(30, new ECB(19, 118), - new ECB(6, 119)), - new ECBlocks(28, new ECB(18, 47), - new ECB(31, 48)), - new ECBlocks(30, new ECB(34, 24), - new ECB(34, 25)), - new ECBlocks(30, new ECB(20, 15), - new ECB(61, 16))) - }; - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.qrcode.decoder; + +import com.google.zxing.FormatException; +import com.google.zxing.common.BitMatrix; + +/** + * See ISO 18004:2006 Annex D + * + * @author Sean Owen + */ +public final class Version { + + /** + * See ISO 18004:2006 Annex D. + * Element i represents the raw version bits that specify version i + 7 + */ + private static final int[] VERSION_DECODE_INFO = { + 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, + 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, + 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, + 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, + 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, + 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, + 0x2542E, 0x26A64, 0x27541, 0x28C69 + }; + + private static final Version[] VERSIONS = buildVersions(); + + private final int versionNumber; + private final int[] alignmentPatternCenters; + private final ECBlocks[] ecBlocks; + private final int totalCodewords; + + private Version(int versionNumber, + int[] alignmentPatternCenters, + ECBlocks... ecBlocks) { + this.versionNumber = versionNumber; + this.alignmentPatternCenters = alignmentPatternCenters; + this.ecBlocks = ecBlocks; + int total = 0; + int ecCodewords = ecBlocks[0].getECCodewordsPerBlock(); + ECB[] ecbArray = ecBlocks[0].getECBlocks(); + for (ECB ecBlock : ecbArray) { + total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); + } + this.totalCodewords = total; + } + + public int getVersionNumber() { + return versionNumber; + } + + public int[] getAlignmentPatternCenters() { + return alignmentPatternCenters; + } + + public int getTotalCodewords() { + return totalCodewords; + } + + public int getDimensionForVersion() { + return 17 + 4 * versionNumber; + } + + public ECBlocks getECBlocksForLevel(ErrorCorrectionLevel ecLevel) { + return ecBlocks[ecLevel.ordinal()]; + } + + /** + *

Deduces version information purely from QR Code dimensions.

+ * + * @param dimension dimension in modules + * @return Version for a QR Code of that dimension + * @throws FormatException if dimension is not 1 mod 4 + */ + public static Version getProvisionalVersionForDimension(int dimension) throws FormatException { + if (dimension % 4 != 1) { + throw FormatException.getFormatInstance(); + } + try { + return getVersionForNumber((dimension - 17) >> 2); + } catch (IllegalArgumentException iae) { + throw FormatException.getFormatInstance(); + } + } + + public static Version getVersionForNumber(int versionNumber) { + if (versionNumber < 1 || versionNumber > 40) { + throw new IllegalArgumentException(); + } + return VERSIONS[versionNumber - 1]; + } + + static Version decodeVersionInformation(int versionBits) { + int bestDifference = Integer.MAX_VALUE; + int bestVersion = 0; + for (int i = 0; i < VERSION_DECODE_INFO.length; i++) { + int targetVersion = VERSION_DECODE_INFO[i]; + // Do the version info bits match exactly? done. + if (targetVersion == versionBits) { + return getVersionForNumber(i + 7); + } + // Otherwise see if this is the closest to a real version info bit string + // we have seen so far + int bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion); + if (bitsDifference < bestDifference) { + bestVersion = i + 7; + bestDifference = bitsDifference; + } + } + // We can tolerate up to 3 bits of error since no two version info codewords will + // differ in less than 8 bits. + if (bestDifference <= 3) { + return getVersionForNumber(bestVersion); + } + // If we didn't find a close enough match, fail + return null; + } + + /** + * See ISO 18004:2006 Annex E + */ + BitMatrix buildFunctionPattern() { + int dimension = getDimensionForVersion(); + BitMatrix bitMatrix = new BitMatrix(dimension); + + // Top left finder pattern + separator + format + bitMatrix.setRegion(0, 0, 9, 9); + // Top right finder pattern + separator + format + bitMatrix.setRegion(dimension - 8, 0, 8, 9); + // Bottom left finder pattern + separator + format + bitMatrix.setRegion(0, dimension - 8, 9, 8); + + // Alignment patterns + int max = alignmentPatternCenters.length; + for (int x = 0; x < max; x++) { + int i = alignmentPatternCenters[x] - 2; + for (int y = 0; y < max; y++) { + if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) { + // No alignment patterns near the three finder paterns + continue; + } + bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5); + } + } + + // Vertical timing pattern + bitMatrix.setRegion(6, 9, 1, dimension - 17); + // Horizontal timing pattern + bitMatrix.setRegion(9, 6, dimension - 17, 1); + + if (versionNumber > 6) { + // Version info, top right + bitMatrix.setRegion(dimension - 11, 0, 3, 6); + // Version info, bottom left + bitMatrix.setRegion(0, dimension - 11, 6, 3); + } + + return bitMatrix; + } + + /** + *

Encapsulates a set of error-correction blocks in one symbol version. Most versions will + * use blocks of differing sizes within one version, so, this encapsulates the parameters for + * each set of blocks. It also holds the number of error-correction codewords per block since it + * will be the same across all blocks within one version.

+ */ + public static final class ECBlocks { + private final int ecCodewordsPerBlock; + private final ECB[] ecBlocks; + + ECBlocks(int ecCodewordsPerBlock, ECB... ecBlocks) { + this.ecCodewordsPerBlock = ecCodewordsPerBlock; + this.ecBlocks = ecBlocks; + } + + public int getECCodewordsPerBlock() { + return ecCodewordsPerBlock; + } + + public int getNumBlocks() { + int total = 0; + for (ECB ecBlock : ecBlocks) { + total += ecBlock.getCount(); + } + return total; + } + + public int getTotalECCodewords() { + return ecCodewordsPerBlock * getNumBlocks(); + } + + public ECB[] getECBlocks() { + return ecBlocks; + } + } + + /** + *

Encapsualtes the parameters for one error-correction block in one symbol version. + * This includes the number of data codewords, and the number of times a block with these + * parameters is used consecutively in the QR code version's format.

+ */ + public static final class ECB { + private final int count; + private final int dataCodewords; + + ECB(int count, int dataCodewords) { + this.count = count; + this.dataCodewords = dataCodewords; + } + + public int getCount() { + return count; + } + + public int getDataCodewords() { + return dataCodewords; + } + } + + @Override + public String toString() { + return String.valueOf(versionNumber); + } + + /** + * See ISO 18004:2006 6.5.1 Table 9 + */ + private static Version[] buildVersions() { + return new Version[]{ + new Version(1, new int[]{}, + new ECBlocks(7, new ECB(1, 19)), + new ECBlocks(10, new ECB(1, 16)), + new ECBlocks(13, new ECB(1, 13)), + new ECBlocks(17, new ECB(1, 9))), + new Version(2, new int[]{6, 18}, + new ECBlocks(10, new ECB(1, 34)), + new ECBlocks(16, new ECB(1, 28)), + new ECBlocks(22, new ECB(1, 22)), + new ECBlocks(28, new ECB(1, 16))), + new Version(3, new int[]{6, 22}, + new ECBlocks(15, new ECB(1, 55)), + new ECBlocks(26, new ECB(1, 44)), + new ECBlocks(18, new ECB(2, 17)), + new ECBlocks(22, new ECB(2, 13))), + new Version(4, new int[]{6, 26}, + new ECBlocks(20, new ECB(1, 80)), + new ECBlocks(18, new ECB(2, 32)), + new ECBlocks(26, new ECB(2, 24)), + new ECBlocks(16, new ECB(4, 9))), + new Version(5, new int[]{6, 30}, + new ECBlocks(26, new ECB(1, 108)), + new ECBlocks(24, new ECB(2, 43)), + new ECBlocks(18, new ECB(2, 15), + new ECB(2, 16)), + new ECBlocks(22, new ECB(2, 11), + new ECB(2, 12))), + new Version(6, new int[]{6, 34}, + new ECBlocks(18, new ECB(2, 68)), + new ECBlocks(16, new ECB(4, 27)), + new ECBlocks(24, new ECB(4, 19)), + new ECBlocks(28, new ECB(4, 15))), + new Version(7, new int[]{6, 22, 38}, + new ECBlocks(20, new ECB(2, 78)), + new ECBlocks(18, new ECB(4, 31)), + new ECBlocks(18, new ECB(2, 14), + new ECB(4, 15)), + new ECBlocks(26, new ECB(4, 13), + new ECB(1, 14))), + new Version(8, new int[]{6, 24, 42}, + new ECBlocks(24, new ECB(2, 97)), + new ECBlocks(22, new ECB(2, 38), + new ECB(2, 39)), + new ECBlocks(22, new ECB(4, 18), + new ECB(2, 19)), + new ECBlocks(26, new ECB(4, 14), + new ECB(2, 15))), + new Version(9, new int[]{6, 26, 46}, + new ECBlocks(30, new ECB(2, 116)), + new ECBlocks(22, new ECB(3, 36), + new ECB(2, 37)), + new ECBlocks(20, new ECB(4, 16), + new ECB(4, 17)), + new ECBlocks(24, new ECB(4, 12), + new ECB(4, 13))), + new Version(10, new int[]{6, 28, 50}, + new ECBlocks(18, new ECB(2, 68), + new ECB(2, 69)), + new ECBlocks(26, new ECB(4, 43), + new ECB(1, 44)), + new ECBlocks(24, new ECB(6, 19), + new ECB(2, 20)), + new ECBlocks(28, new ECB(6, 15), + new ECB(2, 16))), + new Version(11, new int[]{6, 30, 54}, + new ECBlocks(20, new ECB(4, 81)), + new ECBlocks(30, new ECB(1, 50), + new ECB(4, 51)), + new ECBlocks(28, new ECB(4, 22), + new ECB(4, 23)), + new ECBlocks(24, new ECB(3, 12), + new ECB(8, 13))), + new Version(12, new int[]{6, 32, 58}, + new ECBlocks(24, new ECB(2, 92), + new ECB(2, 93)), + new ECBlocks(22, new ECB(6, 36), + new ECB(2, 37)), + new ECBlocks(26, new ECB(4, 20), + new ECB(6, 21)), + new ECBlocks(28, new ECB(7, 14), + new ECB(4, 15))), + new Version(13, new int[]{6, 34, 62}, + new ECBlocks(26, new ECB(4, 107)), + new ECBlocks(22, new ECB(8, 37), + new ECB(1, 38)), + new ECBlocks(24, new ECB(8, 20), + new ECB(4, 21)), + new ECBlocks(22, new ECB(12, 11), + new ECB(4, 12))), + new Version(14, new int[]{6, 26, 46, 66}, + new ECBlocks(30, new ECB(3, 115), + new ECB(1, 116)), + new ECBlocks(24, new ECB(4, 40), + new ECB(5, 41)), + new ECBlocks(20, new ECB(11, 16), + new ECB(5, 17)), + new ECBlocks(24, new ECB(11, 12), + new ECB(5, 13))), + new Version(15, new int[]{6, 26, 48, 70}, + new ECBlocks(22, new ECB(5, 87), + new ECB(1, 88)), + new ECBlocks(24, new ECB(5, 41), + new ECB(5, 42)), + new ECBlocks(30, new ECB(5, 24), + new ECB(7, 25)), + new ECBlocks(24, new ECB(11, 12), + new ECB(7, 13))), + new Version(16, new int[]{6, 26, 50, 74}, + new ECBlocks(24, new ECB(5, 98), + new ECB(1, 99)), + new ECBlocks(28, new ECB(7, 45), + new ECB(3, 46)), + new ECBlocks(24, new ECB(15, 19), + new ECB(2, 20)), + new ECBlocks(30, new ECB(3, 15), + new ECB(13, 16))), + new Version(17, new int[]{6, 30, 54, 78}, + new ECBlocks(28, new ECB(1, 107), + new ECB(5, 108)), + new ECBlocks(28, new ECB(10, 46), + new ECB(1, 47)), + new ECBlocks(28, new ECB(1, 22), + new ECB(15, 23)), + new ECBlocks(28, new ECB(2, 14), + new ECB(17, 15))), + new Version(18, new int[]{6, 30, 56, 82}, + new ECBlocks(30, new ECB(5, 120), + new ECB(1, 121)), + new ECBlocks(26, new ECB(9, 43), + new ECB(4, 44)), + new ECBlocks(28, new ECB(17, 22), + new ECB(1, 23)), + new ECBlocks(28, new ECB(2, 14), + new ECB(19, 15))), + new Version(19, new int[]{6, 30, 58, 86}, + new ECBlocks(28, new ECB(3, 113), + new ECB(4, 114)), + new ECBlocks(26, new ECB(3, 44), + new ECB(11, 45)), + new ECBlocks(26, new ECB(17, 21), + new ECB(4, 22)), + new ECBlocks(26, new ECB(9, 13), + new ECB(16, 14))), + new Version(20, new int[]{6, 34, 62, 90}, + new ECBlocks(28, new ECB(3, 107), + new ECB(5, 108)), + new ECBlocks(26, new ECB(3, 41), + new ECB(13, 42)), + new ECBlocks(30, new ECB(15, 24), + new ECB(5, 25)), + new ECBlocks(28, new ECB(15, 15), + new ECB(10, 16))), + new Version(21, new int[]{6, 28, 50, 72, 94}, + new ECBlocks(28, new ECB(4, 116), + new ECB(4, 117)), + new ECBlocks(26, new ECB(17, 42)), + new ECBlocks(28, new ECB(17, 22), + new ECB(6, 23)), + new ECBlocks(30, new ECB(19, 16), + new ECB(6, 17))), + new Version(22, new int[]{6, 26, 50, 74, 98}, + new ECBlocks(28, new ECB(2, 111), + new ECB(7, 112)), + new ECBlocks(28, new ECB(17, 46)), + new ECBlocks(30, new ECB(7, 24), + new ECB(16, 25)), + new ECBlocks(24, new ECB(34, 13))), + new Version(23, new int[]{6, 30, 54, 78, 102}, + new ECBlocks(30, new ECB(4, 121), + new ECB(5, 122)), + new ECBlocks(28, new ECB(4, 47), + new ECB(14, 48)), + new ECBlocks(30, new ECB(11, 24), + new ECB(14, 25)), + new ECBlocks(30, new ECB(16, 15), + new ECB(14, 16))), + new Version(24, new int[]{6, 28, 54, 80, 106}, + new ECBlocks(30, new ECB(6, 117), + new ECB(4, 118)), + new ECBlocks(28, new ECB(6, 45), + new ECB(14, 46)), + new ECBlocks(30, new ECB(11, 24), + new ECB(16, 25)), + new ECBlocks(30, new ECB(30, 16), + new ECB(2, 17))), + new Version(25, new int[]{6, 32, 58, 84, 110}, + new ECBlocks(26, new ECB(8, 106), + new ECB(4, 107)), + new ECBlocks(28, new ECB(8, 47), + new ECB(13, 48)), + new ECBlocks(30, new ECB(7, 24), + new ECB(22, 25)), + new ECBlocks(30, new ECB(22, 15), + new ECB(13, 16))), + new Version(26, new int[]{6, 30, 58, 86, 114}, + new ECBlocks(28, new ECB(10, 114), + new ECB(2, 115)), + new ECBlocks(28, new ECB(19, 46), + new ECB(4, 47)), + new ECBlocks(28, new ECB(28, 22), + new ECB(6, 23)), + new ECBlocks(30, new ECB(33, 16), + new ECB(4, 17))), + new Version(27, new int[]{6, 34, 62, 90, 118}, + new ECBlocks(30, new ECB(8, 122), + new ECB(4, 123)), + new ECBlocks(28, new ECB(22, 45), + new ECB(3, 46)), + new ECBlocks(30, new ECB(8, 23), + new ECB(26, 24)), + new ECBlocks(30, new ECB(12, 15), + new ECB(28, 16))), + new Version(28, new int[]{6, 26, 50, 74, 98, 122}, + new ECBlocks(30, new ECB(3, 117), + new ECB(10, 118)), + new ECBlocks(28, new ECB(3, 45), + new ECB(23, 46)), + new ECBlocks(30, new ECB(4, 24), + new ECB(31, 25)), + new ECBlocks(30, new ECB(11, 15), + new ECB(31, 16))), + new Version(29, new int[]{6, 30, 54, 78, 102, 126}, + new ECBlocks(30, new ECB(7, 116), + new ECB(7, 117)), + new ECBlocks(28, new ECB(21, 45), + new ECB(7, 46)), + new ECBlocks(30, new ECB(1, 23), + new ECB(37, 24)), + new ECBlocks(30, new ECB(19, 15), + new ECB(26, 16))), + new Version(30, new int[]{6, 26, 52, 78, 104, 130}, + new ECBlocks(30, new ECB(5, 115), + new ECB(10, 116)), + new ECBlocks(28, new ECB(19, 47), + new ECB(10, 48)), + new ECBlocks(30, new ECB(15, 24), + new ECB(25, 25)), + new ECBlocks(30, new ECB(23, 15), + new ECB(25, 16))), + new Version(31, new int[]{6, 30, 56, 82, 108, 134}, + new ECBlocks(30, new ECB(13, 115), + new ECB(3, 116)), + new ECBlocks(28, new ECB(2, 46), + new ECB(29, 47)), + new ECBlocks(30, new ECB(42, 24), + new ECB(1, 25)), + new ECBlocks(30, new ECB(23, 15), + new ECB(28, 16))), + new Version(32, new int[]{6, 34, 60, 86, 112, 138}, + new ECBlocks(30, new ECB(17, 115)), + new ECBlocks(28, new ECB(10, 46), + new ECB(23, 47)), + new ECBlocks(30, new ECB(10, 24), + new ECB(35, 25)), + new ECBlocks(30, new ECB(19, 15), + new ECB(35, 16))), + new Version(33, new int[]{6, 30, 58, 86, 114, 142}, + new ECBlocks(30, new ECB(17, 115), + new ECB(1, 116)), + new ECBlocks(28, new ECB(14, 46), + new ECB(21, 47)), + new ECBlocks(30, new ECB(29, 24), + new ECB(19, 25)), + new ECBlocks(30, new ECB(11, 15), + new ECB(46, 16))), + new Version(34, new int[]{6, 34, 62, 90, 118, 146}, + new ECBlocks(30, new ECB(13, 115), + new ECB(6, 116)), + new ECBlocks(28, new ECB(14, 46), + new ECB(23, 47)), + new ECBlocks(30, new ECB(44, 24), + new ECB(7, 25)), + new ECBlocks(30, new ECB(59, 16), + new ECB(1, 17))), + new Version(35, new int[]{6, 30, 54, 78, 102, 126, 150}, + new ECBlocks(30, new ECB(12, 121), + new ECB(7, 122)), + new ECBlocks(28, new ECB(12, 47), + new ECB(26, 48)), + new ECBlocks(30, new ECB(39, 24), + new ECB(14, 25)), + new ECBlocks(30, new ECB(22, 15), + new ECB(41, 16))), + new Version(36, new int[]{6, 24, 50, 76, 102, 128, 154}, + new ECBlocks(30, new ECB(6, 121), + new ECB(14, 122)), + new ECBlocks(28, new ECB(6, 47), + new ECB(34, 48)), + new ECBlocks(30, new ECB(46, 24), + new ECB(10, 25)), + new ECBlocks(30, new ECB(2, 15), + new ECB(64, 16))), + new Version(37, new int[]{6, 28, 54, 80, 106, 132, 158}, + new ECBlocks(30, new ECB(17, 122), + new ECB(4, 123)), + new ECBlocks(28, new ECB(29, 46), + new ECB(14, 47)), + new ECBlocks(30, new ECB(49, 24), + new ECB(10, 25)), + new ECBlocks(30, new ECB(24, 15), + new ECB(46, 16))), + new Version(38, new int[]{6, 32, 58, 84, 110, 136, 162}, + new ECBlocks(30, new ECB(4, 122), + new ECB(18, 123)), + new ECBlocks(28, new ECB(13, 46), + new ECB(32, 47)), + new ECBlocks(30, new ECB(48, 24), + new ECB(14, 25)), + new ECBlocks(30, new ECB(42, 15), + new ECB(32, 16))), + new Version(39, new int[]{6, 26, 54, 82, 110, 138, 166}, + new ECBlocks(30, new ECB(20, 117), + new ECB(4, 118)), + new ECBlocks(28, new ECB(40, 47), + new ECB(7, 48)), + new ECBlocks(30, new ECB(43, 24), + new ECB(22, 25)), + new ECBlocks(30, new ECB(10, 15), + new ECB(67, 16))), + new Version(40, new int[]{6, 30, 58, 86, 114, 142, 170}, + new ECBlocks(30, new ECB(19, 118), + new ECB(6, 119)), + new ECBlocks(28, new ECB(18, 47), + new ECB(31, 48)), + new ECBlocks(30, new ECB(34, 24), + new ECB(34, 25)), + new ECBlocks(30, new ECB(20, 15), + new ECB(61, 16))) + }; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java index 179bcc1..169bd11 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java @@ -1,277 +1,277 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.qrcode.detector; - -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; - -import java.util.ArrayList; -import java.util.List; - -/** - *

This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder - * patterns but are smaller and appear at regular intervals throughout the image.

- * - *

At the moment this only looks for the bottom-right alignment pattern.

- * - *

This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, - * pasted and stripped down here for maximum performance but does unfortunately duplicate - * some code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object.

- * - * @author Sean Owen - */ -final class AlignmentPatternFinder { - - private final BitMatrix image; - private final List possibleCenters; - private final int startX; - private final int startY; - private final int width; - private final int height; - private final float moduleSize; - private final int[] crossCheckStateCount; - private final ResultPointCallback resultPointCallback; - - /** - *

Creates a finder that will look in a portion of the whole image.

- * - * @param image image to search - * @param startX left column from which to start searching - * @param startY top row from which to start searching - * @param width width of region to search - * @param height height of region to search - * @param moduleSize estimated module size so far - */ - AlignmentPatternFinder(BitMatrix image, - int startX, - int startY, - int width, - int height, - float moduleSize, - ResultPointCallback resultPointCallback) { - this.image = image; - this.possibleCenters = new ArrayList(5); - this.startX = startX; - this.startY = startY; - this.width = width; - this.height = height; - this.moduleSize = moduleSize; - this.crossCheckStateCount = new int[3]; - this.resultPointCallback = resultPointCallback; - } - - /** - *

This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since - * it's pretty performance-critical and so is written to be fast foremost.

- * - * @return {@link AlignmentPattern} if found - * @throws NotFoundException if not found - */ - AlignmentPattern find() throws NotFoundException { - int startX = this.startX; - int height = this.height; - int maxJ = startX + width; - int middleI = startY + (height >> 1); - // We are looking for black/white/black modules in 1:1:1 ratio; - // this tracks the number of black/white/black modules seen so far - int[] stateCount = new int[3]; - for (int iGen = 0; iGen < height; iGen++) { - // Search from middle outwards - int i = middleI + ((iGen & 0x01) == 0 ? (iGen + 1) >> 1 : -((iGen + 1) >> 1)); - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - int j = startX; - // Burn off leading white pixels before anything else; if we start in the middle of - // a white run, it doesn't make sense to count its length, since we don't know if the - // white run continued to the left of the start point - while (j < maxJ && !image.get(j, i)) { - j++; - } - int currentState = 0; - while (j < maxJ) { - if (image.get(j, i)) { - // Black pixel - if (currentState == 1) { // Counting black pixels - stateCount[currentState]++; - } else { // Counting white pixels - if (currentState == 2) { // A winner? - if (foundPatternCross(stateCount)) { // Yes - AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, j); - if (confirmed != null) { - return confirmed; - } - } - stateCount[0] = stateCount[2]; - stateCount[1] = 1; - stateCount[2] = 0; - currentState = 1; - } else { - stateCount[++currentState]++; - } - } - } else { // White pixel - if (currentState == 1) { // Counting black pixels - currentState++; - } - stateCount[currentState]++; - } - j++; - } - if (foundPatternCross(stateCount)) { - AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, maxJ); - if (confirmed != null) { - return confirmed; - } - } - - } - - // Hmm, nothing we saw was observed and confirmed twice. If we had - // any guess at all, return it. - if (!possibleCenters.isEmpty()) { - return possibleCenters.get(0); - } - - throw NotFoundException.getNotFoundInstance(); - } - - /** - * Given a count of black/white/black pixels just seen and an end position, - * figures the location of the center of this black/white/black run. - */ - private static float centerFromEnd(int[] stateCount, int end) { - return (float) (end - stateCount[2]) - stateCount[1] / 2.0f; - } - - /** - * @param stateCount count of black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/1 ratios - * used by alignment patterns to be considered a match - */ - private boolean foundPatternCross(int[] stateCount) { - float moduleSize = this.moduleSize; - float maxVariance = moduleSize / 2.0f; - for (int i = 0; i < 3; i++) { - if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) { - return false; - } - } - return true; - } - - /** - *

After a horizontal scan finds a potential alignment pattern, this method - * "cross-checks" by scanning down vertically through the center of the possible - * alignment pattern to see if the same proportion is detected.

- * - * @param startI row where an alignment pattern was detected - * @param centerJ center of the section that appears to cross an alignment pattern - * @param maxCount maximum reasonable number of modules that should be - * observed in any reading state, based on the results of the horizontal scan - * @return vertical center of alignment pattern, or {@link Float#NaN} if not found - */ - private float crossCheckVertical(int startI, int centerJ, int maxCount, - int originalStateCountTotal) { - BitMatrix image = this.image; - - int maxI = image.getHeight(); - int[] stateCount = crossCheckStateCount; - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - - // Start counting up from center - int i = startI; - while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) { - return Float.NaN; - } - while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return Float.NaN; - } - - // Now also count down from center - i = startI + 1; - while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i++; - } - if (i == maxI || stateCount[1] > maxCount) { - return Float.NaN; - } - while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) { - stateCount[2]++; - i++; - } - if (stateCount[2] > maxCount) { - return Float.NaN; - } - - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { - return Float.NaN; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : Float.NaN; - } - - /** - *

This is called when a horizontal scan finds a possible alignment pattern. It will - * cross check with a vertical scan, and if successful, will see if this pattern had been - * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have - * found the alignment pattern.

- * - * @param stateCount reading state module counts from horizontal scan - * @param i row where alignment pattern may be found - * @param j end of possible alignment pattern in row - * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not - */ - private AlignmentPattern handlePossibleCenter(int[] stateCount, int i, int j) { - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - float centerJ = centerFromEnd(stateCount, j); - float centerI = crossCheckVertical(i, (int) centerJ, 2 * stateCount[1], stateCountTotal); - if (!Float.isNaN(centerI)) { - float estimatedModuleSize = (float) (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f; - for (AlignmentPattern center : possibleCenters) { - // Look for about the same center and module size: - if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { - return center.combineEstimate(centerI, centerJ, estimatedModuleSize); - } - } - // Hadn't found this before; save it - AlignmentPattern point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize); - possibleCenters.add(point); - if (resultPointCallback != null) { - resultPointCallback.foundPossibleResultPoint(point); - } - } - return null; - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.qrcode.detector; + +import com.google.zxing.NotFoundException; +import com.google.zxing.ResultPointCallback; +import com.google.zxing.common.BitMatrix; + +import java.util.ArrayList; +import java.util.List; + +/** + *

This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder + * patterns but are smaller and appear at regular intervals throughout the image.

+ * + *

At the moment this only looks for the bottom-right alignment pattern.

+ * + *

This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, + * pasted and stripped down here for maximum performance but does unfortunately duplicate + * some code.

+ * + *

This class is thread-safe but not reentrant. Each thread must allocate its own object.

+ * + * @author Sean Owen + */ +final class AlignmentPatternFinder { + + private final BitMatrix image; + private final List possibleCenters; + private final int startX; + private final int startY; + private final int width; + private final int height; + private final float moduleSize; + private final int[] crossCheckStateCount; + private final ResultPointCallback resultPointCallback; + + /** + *

Creates a finder that will look in a portion of the whole image.

+ * + * @param image image to search + * @param startX left column from which to start searching + * @param startY top row from which to start searching + * @param width width of region to search + * @param height height of region to search + * @param moduleSize estimated module size so far + */ + AlignmentPatternFinder(BitMatrix image, + int startX, + int startY, + int width, + int height, + float moduleSize, + ResultPointCallback resultPointCallback) { + this.image = image; + this.possibleCenters = new ArrayList(5); + this.startX = startX; + this.startY = startY; + this.width = width; + this.height = height; + this.moduleSize = moduleSize; + this.crossCheckStateCount = new int[3]; + this.resultPointCallback = resultPointCallback; + } + + /** + *

This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since + * it's pretty performance-critical and so is written to be fast foremost.

+ * + * @return {@link AlignmentPattern} if found + * @throws NotFoundException if not found + */ + AlignmentPattern find() throws NotFoundException { + int startX = this.startX; + int height = this.height; + int maxJ = startX + width; + int middleI = startY + (height >> 1); + // We are looking for black/white/black modules in 1:1:1 ratio; + // this tracks the number of black/white/black modules seen so far + int[] stateCount = new int[3]; + for (int iGen = 0; iGen < height; iGen++) { + // Search from middle outwards + int i = middleI + ((iGen & 0x01) == 0 ? (iGen + 1) >> 1 : -((iGen + 1) >> 1)); + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + int j = startX; + // Burn off leading white pixels before anything else; if we start in the middle of + // a white run, it doesn't make sense to count its length, since we don't know if the + // white run continued to the left of the start point + while (j < maxJ && !image.get(j, i)) { + j++; + } + int currentState = 0; + while (j < maxJ) { + if (image.get(j, i)) { + // Black pixel + if (currentState == 1) { // Counting black pixels + stateCount[currentState]++; + } else { // Counting white pixels + if (currentState == 2) { // A winner? + if (foundPatternCross(stateCount)) { // Yes + AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, j); + if (confirmed != null) { + return confirmed; + } + } + stateCount[0] = stateCount[2]; + stateCount[1] = 1; + stateCount[2] = 0; + currentState = 1; + } else { + stateCount[++currentState]++; + } + } + } else { // White pixel + if (currentState == 1) { // Counting black pixels + currentState++; + } + stateCount[currentState]++; + } + j++; + } + if (foundPatternCross(stateCount)) { + AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, maxJ); + if (confirmed != null) { + return confirmed; + } + } + + } + + // Hmm, nothing we saw was observed and confirmed twice. If we had + // any guess at all, return it. + if (!possibleCenters.isEmpty()) { + return possibleCenters.get(0); + } + + throw NotFoundException.getNotFoundInstance(); + } + + /** + * Given a count of black/white/black pixels just seen and an end position, + * figures the location of the center of this black/white/black run. + */ + private static float centerFromEnd(int[] stateCount, int end) { + return (float) (end - stateCount[2]) - stateCount[1] / 2.0f; + } + + /** + * @param stateCount count of black/white/black pixels just read + * @return true iff the proportions of the counts is close enough to the 1/1/1 ratios + * used by alignment patterns to be considered a match + */ + private boolean foundPatternCross(int[] stateCount) { + float moduleSize = this.moduleSize; + float maxVariance = moduleSize / 2.0f; + for (int i = 0; i < 3; i++) { + if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) { + return false; + } + } + return true; + } + + /** + *

After a horizontal scan finds a potential alignment pattern, this method + * "cross-checks" by scanning down vertically through the center of the possible + * alignment pattern to see if the same proportion is detected.

+ * + * @param startI row where an alignment pattern was detected + * @param centerJ center of the section that appears to cross an alignment pattern + * @param maxCount maximum reasonable number of modules that should be + * observed in any reading state, based on the results of the horizontal scan + * @return vertical center of alignment pattern, or {@link Float#NaN} if not found + */ + private float crossCheckVertical(int startI, int centerJ, int maxCount, + int originalStateCountTotal) { + BitMatrix image = this.image; + + int maxI = image.getHeight(); + int[] stateCount = crossCheckStateCount; + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + + // Start counting up from center + int i = startI; + while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + // If already too many modules in this state or ran off the edge: + if (i < 0 || stateCount[1] > maxCount) { + return Float.NaN; + } + while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return Float.NaN; + } + + // Now also count down from center + i = startI + 1; + while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i++; + } + if (i == maxI || stateCount[1] > maxCount) { + return Float.NaN; + } + while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) { + stateCount[2]++; + i++; + } + if (stateCount[2] > maxCount) { + return Float.NaN; + } + + int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { + return Float.NaN; + } + + return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : Float.NaN; + } + + /** + *

This is called when a horizontal scan finds a possible alignment pattern. It will + * cross check with a vertical scan, and if successful, will see if this pattern had been + * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have + * found the alignment pattern.

+ * + * @param stateCount reading state module counts from horizontal scan + * @param i row where alignment pattern may be found + * @param j end of possible alignment pattern in row + * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not + */ + private AlignmentPattern handlePossibleCenter(int[] stateCount, int i, int j) { + int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + float centerJ = centerFromEnd(stateCount, j); + float centerI = crossCheckVertical(i, (int) centerJ, 2 * stateCount[1], stateCountTotal); + if (!Float.isNaN(centerI)) { + float estimatedModuleSize = (float) (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f; + for (AlignmentPattern center : possibleCenters) { + // Look for about the same center and module size: + if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { + return center.combineEstimate(centerI, centerJ, estimatedModuleSize); + } + } + // Hadn't found this before; save it + AlignmentPattern point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize); + possibleCenters.add(point); + if (resultPointCallback != null) { + resultPointCallback.foundPossibleResultPoint(point); + } + } + return null; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java index 2fdfe0d..4331f45 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java +++ b/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java @@ -1,585 +1,585 @@ -/* - * Copyright 2007 ZXing authors - * - * 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. - */ - -package com.google.zxing.qrcode.detector; - -import com.google.zxing.DecodeHintType; -import com.google.zxing.NotFoundException; -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.BitMatrix; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -/** - *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square - * markers at three corners of a QR Code.

- * - *

This class is thread-safe but not reentrant. Each thread must allocate its own object. - * - * @author Sean Owen - */ -public class FinderPatternFinder { - - private static final int CENTER_QUORUM = 2; - protected static final int MIN_SKIP = 3; // 1 pixel/module times 3 modules/center - protected static final int MAX_MODULES = 57; // support up to version 10 for mobile clients - private static final int INTEGER_MATH_SHIFT = 8; - - private final BitMatrix image; - private final List possibleCenters; - private boolean hasSkipped; - private final int[] crossCheckStateCount; - private final ResultPointCallback resultPointCallback; - - /** - *

Creates a finder that will search the image for three finder patterns.

- * - * @param image image to search - */ - public FinderPatternFinder(BitMatrix image) { - this(image, null); - } - - public FinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) { - this.image = image; - this.possibleCenters = new ArrayList(); - this.crossCheckStateCount = new int[5]; - this.resultPointCallback = resultPointCallback; - } - - protected final BitMatrix getImage() { - return image; - } - - protected final List getPossibleCenters() { - return possibleCenters; - } - - final FinderPatternInfo find(Map hints) throws NotFoundException { - boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - int maxI = image.getHeight(); - int maxJ = image.getWidth(); - // We are looking for black/white/black/white/black modules in - // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far - - // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the - // image, and then account for the center being 3 modules in size. This gives the smallest - // number of pixels the center could be, so skip this often. When trying harder, look for all - // QR versions regardless of how dense they are. - int iSkip = (3 * maxI) / (4 * MAX_MODULES); - if (iSkip < MIN_SKIP || tryHarder) { - iSkip = MIN_SKIP; - } - - boolean done = false; - int[] stateCount = new int[5]; - for (int i = iSkip - 1; i < maxI && !done; i += iSkip) { - // Get a row of black/white values - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - stateCount[3] = 0; - stateCount[4] = 0; - int currentState = 0; - for (int j = 0; j < maxJ; j++) { - if (image.get(j, i)) { - // Black pixel - if ((currentState & 1) == 1) { // Counting white pixels - currentState++; - } - stateCount[currentState]++; - } else { // White pixel - if ((currentState & 1) == 0) { // Counting black pixels - if (currentState == 4) { // A winner? - if (foundPatternCross(stateCount)) { // Yes - boolean confirmed = handlePossibleCenter(stateCount, i, j); - if (confirmed) { - // Start examining every other line. Checking each line turned out to be too - // expensive and didn't improve performance. - iSkip = 2; - if (hasSkipped) { - done = haveMultiplyConfirmedCenters(); - } else { - int rowSkip = findRowSkip(); - if (rowSkip > stateCount[2]) { - // Skip rows between row of lower confirmed center - // and top of presumed third confirmed center - // but back up a bit to get a full chance of detecting - // it, entire width of center of finder pattern - - // Skip by rowSkip, but back off by stateCount[2] (size of last center - // of pattern we saw) to be conservative, and also back off by iSkip which - // is about to be re-added - i += rowSkip - stateCount[2] - iSkip; - j = maxJ - 1; - } - } - } else { - stateCount[0] = stateCount[2]; - stateCount[1] = stateCount[3]; - stateCount[2] = stateCount[4]; - stateCount[3] = 1; - stateCount[4] = 0; - currentState = 3; - continue; - } - // Clear state to start looking again - currentState = 0; - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - stateCount[3] = 0; - stateCount[4] = 0; - } else { // No, shift counts back by two - stateCount[0] = stateCount[2]; - stateCount[1] = stateCount[3]; - stateCount[2] = stateCount[4]; - stateCount[3] = 1; - stateCount[4] = 0; - currentState = 3; - } - } else { - stateCount[++currentState]++; - } - } else { // Counting white pixels - stateCount[currentState]++; - } - } - } - if (foundPatternCross(stateCount)) { - boolean confirmed = handlePossibleCenter(stateCount, i, maxJ); - if (confirmed) { - iSkip = stateCount[0]; - if (hasSkipped) { - // Found a third one - done = haveMultiplyConfirmedCenters(); - } - } - } - } - - FinderPattern[] patternInfo = selectBestPatterns(); - ResultPoint.orderBestPatterns(patternInfo); - - return new FinderPatternInfo(patternInfo); - } - - /** - * Given a count of black/white/black/white/black pixels just seen and an end position, - * figures the location of the center of this run. - */ - private static float centerFromEnd(int[] stateCount, int end) { - return (float) (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0f; - } - - /** - * @param stateCount count of black/white/black/white/black pixels just read - * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios - * used by finder patterns to be considered a match - */ - protected static boolean foundPatternCross(int[] stateCount) { - int totalModuleSize = 0; - for (int i = 0; i < 5; i++) { - int count = stateCount[i]; - if (count == 0) { - return false; - } - totalModuleSize += count; - } - if (totalModuleSize < 7) { - return false; - } - int moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7; - int maxVariance = moduleSize / 2; - // Allow less than 50% variance from 1-1-3-1-1 proportions - return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && - Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance; - } - - private int[] getCrossCheckStateCount() { - crossCheckStateCount[0] = 0; - crossCheckStateCount[1] = 0; - crossCheckStateCount[2] = 0; - crossCheckStateCount[3] = 0; - crossCheckStateCount[4] = 0; - return crossCheckStateCount; - } - - /** - *

After a horizontal scan finds a potential finder pattern, this method - * "cross-checks" by scanning down vertically through the center of the possible - * finder pattern to see if the same proportion is detected.

- * - * @param startI row where a finder pattern was detected - * @param centerJ center of the section that appears to cross a finder pattern - * @param maxCount maximum reasonable number of modules that should be - * observed in any reading state, based on the results of the horizontal scan - * @return vertical center of finder pattern, or {@link Float#NaN} if not found - */ - private float crossCheckVertical(int startI, int centerJ, int maxCount, - int originalStateCountTotal) { - BitMatrix image = this.image; - - int maxI = image.getHeight(); - int[] stateCount = getCrossCheckStateCount(); - - // Start counting up from center - int i = startI; - while (i >= 0 && image.get(centerJ, i)) { - stateCount[2]++; - i--; - } - if (i < 0) { - return Float.NaN; - } - while (i >= 0 && !image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) { - return Float.NaN; - } - while (i >= 0 && image.get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return Float.NaN; - } - - // Now also count down from center - i = startI + 1; - while (i < maxI && image.get(centerJ, i)) { - stateCount[2]++; - i++; - } - if (i == maxI) { - return Float.NaN; - } - while (i < maxI && !image.get(centerJ, i) && stateCount[3] < maxCount) { - stateCount[3]++; - i++; - } - if (i == maxI || stateCount[3] >= maxCount) { - return Float.NaN; - } - while (i < maxI && image.get(centerJ, i) && stateCount[4] < maxCount) { - stateCount[4]++; - i++; - } - if (stateCount[4] >= maxCount) { - return Float.NaN; - } - - // If we found a finder-pattern-like section, but its size is more than 40% different than - // the original, assume it's a false positive - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + - stateCount[4]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { - return Float.NaN; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : Float.NaN; - } - - /** - *

Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, - * except it reads horizontally instead of vertically. This is used to cross-cross - * check a vertical cross check and locate the real center of the alignment pattern.

- */ - private float crossCheckHorizontal(int startJ, int centerI, int maxCount, - int originalStateCountTotal) { - BitMatrix image = this.image; - - int maxJ = image.getWidth(); - int[] stateCount = getCrossCheckStateCount(); - - int j = startJ; - while (j >= 0 && image.get(j, centerI)) { - stateCount[2]++; - j--; - } - if (j < 0) { - return Float.NaN; - } - while (j >= 0 && !image.get(j, centerI) && stateCount[1] <= maxCount) { - stateCount[1]++; - j--; - } - if (j < 0 || stateCount[1] > maxCount) { - return Float.NaN; - } - while (j >= 0 && image.get(j, centerI) && stateCount[0] <= maxCount) { - stateCount[0]++; - j--; - } - if (stateCount[0] > maxCount) { - return Float.NaN; - } - - j = startJ + 1; - while (j < maxJ && image.get(j, centerI)) { - stateCount[2]++; - j++; - } - if (j == maxJ) { - return Float.NaN; - } - while (j < maxJ && !image.get(j, centerI) && stateCount[3] < maxCount) { - stateCount[3]++; - j++; - } - if (j == maxJ || stateCount[3] >= maxCount) { - return Float.NaN; - } - while (j < maxJ && image.get(j, centerI) && stateCount[4] < maxCount) { - stateCount[4]++; - j++; - } - if (stateCount[4] >= maxCount) { - return Float.NaN; - } - - // If we found a finder-pattern-like section, but its size is significantly different than - // the original, assume it's a false positive - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + - stateCount[4]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) { - return Float.NaN; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, j) : Float.NaN; - } - - /** - *

This is called when a horizontal scan finds a possible alignment pattern. It will - * cross check with a vertical scan, and if successful, will, ah, cross-cross-check - * with another horizontal scan. This is needed primarily to locate the real horizontal - * center of the pattern in cases of extreme skew.

- * - *

If that succeeds the finder pattern location is added to a list that tracks - * the number of times each location has been nearly-matched as a finder pattern. - * Each additional find is more evidence that the location is in fact a finder - * pattern center - * - * @param stateCount reading state module counts from horizontal scan - * @param i row where finder pattern may be found - * @param j end of possible finder pattern in row - * @return true if a finder pattern candidate was found this time - */ - protected final boolean handlePossibleCenter(int[] stateCount, int i, int j) { - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + - stateCount[4]; - float centerJ = centerFromEnd(stateCount, j); - float centerI = crossCheckVertical(i, (int) centerJ, stateCount[2], stateCountTotal); - if (!Float.isNaN(centerI)) { - // Re-cross check - centerJ = crossCheckHorizontal((int) centerJ, (int) centerI, stateCount[2], stateCountTotal); - if (!Float.isNaN(centerJ)) { - float estimatedModuleSize = (float) stateCountTotal / 7.0f; - boolean found = false; - for (int index = 0; index < possibleCenters.size(); index++) { - FinderPattern center = possibleCenters.get(index); - // Look for about the same center and module size: - if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { - possibleCenters.set(index, center.combineEstimate(centerI, centerJ, estimatedModuleSize)); - found = true; - break; - } - } - if (!found) { - FinderPattern point = new FinderPattern(centerJ, centerI, estimatedModuleSize); - possibleCenters.add(point); - if (resultPointCallback != null) { - resultPointCallback.foundPossibleResultPoint(point); - } - } - return true; - } - } - return false; - } - - /** - * @return number of rows we could safely skip during scanning, based on the first - * two finder patterns that have been located. In some cases their position will - * allow us to infer that the third pattern must lie below a certain point farther - * down in the image. - */ - private int findRowSkip() { - int max = possibleCenters.size(); - if (max <= 1) { - return 0; - } - FinderPattern firstConfirmedCenter = null; - for (FinderPattern center : possibleCenters) { - if (center.getCount() >= CENTER_QUORUM) { - if (firstConfirmedCenter == null) { - firstConfirmedCenter = center; - } else { - // We have two confirmed centers - // How far down can we skip before resuming looking for the next - // pattern? In the worst case, only the difference between the - // difference in the x / y coordinates of the two centers. - // This is the case where you find top left last. - hasSkipped = true; - return (int) (Math.abs(firstConfirmedCenter.getX() - center.getX()) - - Math.abs(firstConfirmedCenter.getY() - center.getY())) / 2; - } - } - } - return 0; - } - - /** - * @return true iff we have found at least 3 finder patterns that have been detected - * at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the - * candidates is "pretty similar" - */ - private boolean haveMultiplyConfirmedCenters() { - int confirmedCount = 0; - float totalModuleSize = 0.0f; - int max = possibleCenters.size(); - for (FinderPattern pattern : possibleCenters) { - if (pattern.getCount() >= CENTER_QUORUM) { - confirmedCount++; - totalModuleSize += pattern.getEstimatedModuleSize(); - } - } - if (confirmedCount < 3) { - return false; - } - // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" - // and that we need to keep looking. We detect this by asking if the estimated module sizes - // vary too much. We arbitrarily say that when the total deviation from average exceeds - // 5% of the total module size estimates, it's too much. - float average = totalModuleSize / (float) max; - float totalDeviation = 0.0f; - for (FinderPattern pattern : possibleCenters) { - totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average); - } - return totalDeviation <= 0.05f * totalModuleSize; - } - - /** - * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - * those that have been detected at least {@link #CENTER_QUORUM} times, and whose module - * size differs from the average among those patterns the least - * @throws NotFoundException if 3 such finder patterns do not exist - */ - private FinderPattern[] selectBestPatterns() throws NotFoundException { - - int startSize = possibleCenters.size(); - if (startSize < 3) { - // Couldn't find enough finder patterns - throw NotFoundException.getNotFoundInstance(); - } - - // Filter outlier possibilities whose module size is too different - if (startSize > 3) { - // But we can only afford to do so if we have at least 4 possibilities to choose from - float totalModuleSize = 0.0f; - float square = 0.0f; - for (FinderPattern center : possibleCenters) { - float size = center.getEstimatedModuleSize(); - totalModuleSize += size; - square += size * size; - } - float average = totalModuleSize / (float) startSize; - float stdDev = (float) Math.sqrt(square / startSize - average * average); - - Collections.sort(possibleCenters, new FurthestFromAverageComparator(average)); - - float limit = Math.max(0.2f * average, stdDev); - - for (int i = 0; i < possibleCenters.size() && possibleCenters.size() > 3; i++) { - FinderPattern pattern = possibleCenters.get(i); - if (Math.abs(pattern.getEstimatedModuleSize() - average) > limit) { - possibleCenters.remove(i); - i--; - } - } - } - - if (possibleCenters.size() > 3) { - // Throw away all but those first size candidate points we found. - - float totalModuleSize = 0.0f; - for (FinderPattern possibleCenter : possibleCenters) { - totalModuleSize += possibleCenter.getEstimatedModuleSize(); - } - - float average = totalModuleSize / (float) possibleCenters.size(); - - Collections.sort(possibleCenters, new CenterComparator(average)); - - possibleCenters.subList(3, possibleCenters.size()).clear(); - } - - return new FinderPattern[]{ - possibleCenters.get(0), - possibleCenters.get(1), - possibleCenters.get(2) - }; - } - - /** - *

Orders by furthest from average

- */ - private static final class FurthestFromAverageComparator implements Comparator, Serializable { - private final float average; - private FurthestFromAverageComparator(float f) { - average = f; - } - @Override - public int compare(FinderPattern center1, FinderPattern center2) { - float dA = Math.abs(center2.getEstimatedModuleSize() - average); - float dB = Math.abs(center1.getEstimatedModuleSize() - average); - return dA < dB ? -1 : dA == dB ? 0 : 1; - } - } - - /** - *

Orders by {@link FinderPattern#getCount()}, descending.

- */ - private static final class CenterComparator implements Comparator, Serializable { - private final float average; - private CenterComparator(float f) { - average = f; - } - @Override - public int compare(FinderPattern center1, FinderPattern center2) { - if (center2.getCount() == center1.getCount()) { - float dA = Math.abs(center2.getEstimatedModuleSize() - average); - float dB = Math.abs(center1.getEstimatedModuleSize() - average); - return dA < dB ? 1 : dA == dB ? 0 : -1; - } else { - return center2.getCount() - center1.getCount(); - } - } - } - -} +/* + * Copyright 2007 ZXing authors + * + * 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. + */ + +package com.google.zxing.qrcode.detector; + +import com.google.zxing.DecodeHintType; +import com.google.zxing.NotFoundException; +import com.google.zxing.ResultPoint; +import com.google.zxing.ResultPointCallback; +import com.google.zxing.common.BitMatrix; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; + +/** + *

This class attempts to find finder patterns in a QR Code. Finder patterns are the square + * markers at three corners of a QR Code.

+ * + *

This class is thread-safe but not reentrant. Each thread must allocate its own object. + * + * @author Sean Owen + */ +public class FinderPatternFinder { + + private static final int CENTER_QUORUM = 2; + protected static final int MIN_SKIP = 3; // 1 pixel/module times 3 modules/center + protected static final int MAX_MODULES = 57; // support up to version 10 for mobile clients + private static final int INTEGER_MATH_SHIFT = 8; + + private final BitMatrix image; + private final List possibleCenters; + private boolean hasSkipped; + private final int[] crossCheckStateCount; + private final ResultPointCallback resultPointCallback; + + /** + *

Creates a finder that will search the image for three finder patterns.

+ * + * @param image image to search + */ + public FinderPatternFinder(BitMatrix image) { + this(image, null); + } + + public FinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) { + this.image = image; + this.possibleCenters = new ArrayList(); + this.crossCheckStateCount = new int[5]; + this.resultPointCallback = resultPointCallback; + } + + protected final BitMatrix getImage() { + return image; + } + + protected final List getPossibleCenters() { + return possibleCenters; + } + + final FinderPatternInfo find(Map hints) throws NotFoundException { + boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); + int maxI = image.getHeight(); + int maxJ = image.getWidth(); + // We are looking for black/white/black/white/black modules in + // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far + + // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the + // image, and then account for the center being 3 modules in size. This gives the smallest + // number of pixels the center could be, so skip this often. When trying harder, look for all + // QR versions regardless of how dense they are. + int iSkip = (3 * maxI) / (4 * MAX_MODULES); + if (iSkip < MIN_SKIP || tryHarder) { + iSkip = MIN_SKIP; + } + + boolean done = false; + int[] stateCount = new int[5]; + for (int i = iSkip - 1; i < maxI && !done; i += iSkip) { + // Get a row of black/white values + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + int currentState = 0; + for (int j = 0; j < maxJ; j++) { + if (image.get(j, i)) { + // Black pixel + if ((currentState & 1) == 1) { // Counting white pixels + currentState++; + } + stateCount[currentState]++; + } else { // White pixel + if ((currentState & 1) == 0) { // Counting black pixels + if (currentState == 4) { // A winner? + if (foundPatternCross(stateCount)) { // Yes + boolean confirmed = handlePossibleCenter(stateCount, i, j); + if (confirmed) { + // Start examining every other line. Checking each line turned out to be too + // expensive and didn't improve performance. + iSkip = 2; + if (hasSkipped) { + done = haveMultiplyConfirmedCenters(); + } else { + int rowSkip = findRowSkip(); + if (rowSkip > stateCount[2]) { + // Skip rows between row of lower confirmed center + // and top of presumed third confirmed center + // but back up a bit to get a full chance of detecting + // it, entire width of center of finder pattern + + // Skip by rowSkip, but back off by stateCount[2] (size of last center + // of pattern we saw) to be conservative, and also back off by iSkip which + // is about to be re-added + i += rowSkip - stateCount[2] - iSkip; + j = maxJ - 1; + } + } + } else { + stateCount[0] = stateCount[2]; + stateCount[1] = stateCount[3]; + stateCount[2] = stateCount[4]; + stateCount[3] = 1; + stateCount[4] = 0; + currentState = 3; + continue; + } + // Clear state to start looking again + currentState = 0; + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + } else { // No, shift counts back by two + stateCount[0] = stateCount[2]; + stateCount[1] = stateCount[3]; + stateCount[2] = stateCount[4]; + stateCount[3] = 1; + stateCount[4] = 0; + currentState = 3; + } + } else { + stateCount[++currentState]++; + } + } else { // Counting white pixels + stateCount[currentState]++; + } + } + } + if (foundPatternCross(stateCount)) { + boolean confirmed = handlePossibleCenter(stateCount, i, maxJ); + if (confirmed) { + iSkip = stateCount[0]; + if (hasSkipped) { + // Found a third one + done = haveMultiplyConfirmedCenters(); + } + } + } + } + + FinderPattern[] patternInfo = selectBestPatterns(); + ResultPoint.orderBestPatterns(patternInfo); + + return new FinderPatternInfo(patternInfo); + } + + /** + * Given a count of black/white/black/white/black pixels just seen and an end position, + * figures the location of the center of this run. + */ + private static float centerFromEnd(int[] stateCount, int end) { + return (float) (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0f; + } + + /** + * @param stateCount count of black/white/black/white/black pixels just read + * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios + * used by finder patterns to be considered a match + */ + protected static boolean foundPatternCross(int[] stateCount) { + int totalModuleSize = 0; + for (int i = 0; i < 5; i++) { + int count = stateCount[i]; + if (count == 0) { + return false; + } + totalModuleSize += count; + } + if (totalModuleSize < 7) { + return false; + } + int moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7; + int maxVariance = moduleSize / 2; + // Allow less than 50% variance from 1-1-3-1-1 proportions + return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && + Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && + Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && + Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && + Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance; + } + + private int[] getCrossCheckStateCount() { + crossCheckStateCount[0] = 0; + crossCheckStateCount[1] = 0; + crossCheckStateCount[2] = 0; + crossCheckStateCount[3] = 0; + crossCheckStateCount[4] = 0; + return crossCheckStateCount; + } + + /** + *

After a horizontal scan finds a potential finder pattern, this method + * "cross-checks" by scanning down vertically through the center of the possible + * finder pattern to see if the same proportion is detected.

+ * + * @param startI row where a finder pattern was detected + * @param centerJ center of the section that appears to cross a finder pattern + * @param maxCount maximum reasonable number of modules that should be + * observed in any reading state, based on the results of the horizontal scan + * @return vertical center of finder pattern, or {@link Float#NaN} if not found + */ + private float crossCheckVertical(int startI, int centerJ, int maxCount, + int originalStateCountTotal) { + BitMatrix image = this.image; + + int maxI = image.getHeight(); + int[] stateCount = getCrossCheckStateCount(); + + // Start counting up from center + int i = startI; + while (i >= 0 && image.get(centerJ, i)) { + stateCount[2]++; + i--; + } + if (i < 0) { + return Float.NaN; + } + while (i >= 0 && !image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + // If already too many modules in this state or ran off the edge: + if (i < 0 || stateCount[1] > maxCount) { + return Float.NaN; + } + while (i >= 0 && image.get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return Float.NaN; + } + + // Now also count down from center + i = startI + 1; + while (i < maxI && image.get(centerJ, i)) { + stateCount[2]++; + i++; + } + if (i == maxI) { + return Float.NaN; + } + while (i < maxI && !image.get(centerJ, i) && stateCount[3] < maxCount) { + stateCount[3]++; + i++; + } + if (i == maxI || stateCount[3] >= maxCount) { + return Float.NaN; + } + while (i < maxI && image.get(centerJ, i) && stateCount[4] < maxCount) { + stateCount[4]++; + i++; + } + if (stateCount[4] >= maxCount) { + return Float.NaN; + } + + // If we found a finder-pattern-like section, but its size is more than 40% different than + // the original, assume it's a false positive + int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + + stateCount[4]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { + return Float.NaN; + } + + return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : Float.NaN; + } + + /** + *

Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, + * except it reads horizontally instead of vertically. This is used to cross-cross + * check a vertical cross check and locate the real center of the alignment pattern.

+ */ + private float crossCheckHorizontal(int startJ, int centerI, int maxCount, + int originalStateCountTotal) { + BitMatrix image = this.image; + + int maxJ = image.getWidth(); + int[] stateCount = getCrossCheckStateCount(); + + int j = startJ; + while (j >= 0 && image.get(j, centerI)) { + stateCount[2]++; + j--; + } + if (j < 0) { + return Float.NaN; + } + while (j >= 0 && !image.get(j, centerI) && stateCount[1] <= maxCount) { + stateCount[1]++; + j--; + } + if (j < 0 || stateCount[1] > maxCount) { + return Float.NaN; + } + while (j >= 0 && image.get(j, centerI) && stateCount[0] <= maxCount) { + stateCount[0]++; + j--; + } + if (stateCount[0] > maxCount) { + return Float.NaN; + } + + j = startJ + 1; + while (j < maxJ && image.get(j, centerI)) { + stateCount[2]++; + j++; + } + if (j == maxJ) { + return Float.NaN; + } + while (j < maxJ && !image.get(j, centerI) && stateCount[3] < maxCount) { + stateCount[3]++; + j++; + } + if (j == maxJ || stateCount[3] >= maxCount) { + return Float.NaN; + } + while (j < maxJ && image.get(j, centerI) && stateCount[4] < maxCount) { + stateCount[4]++; + j++; + } + if (stateCount[4] >= maxCount) { + return Float.NaN; + } + + // If we found a finder-pattern-like section, but its size is significantly different than + // the original, assume it's a false positive + int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + + stateCount[4]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) { + return Float.NaN; + } + + return foundPatternCross(stateCount) ? centerFromEnd(stateCount, j) : Float.NaN; + } + + /** + *

This is called when a horizontal scan finds a possible alignment pattern. It will + * cross check with a vertical scan, and if successful, will, ah, cross-cross-check + * with another horizontal scan. This is needed primarily to locate the real horizontal + * center of the pattern in cases of extreme skew.

+ * + *

If that succeeds the finder pattern location is added to a list that tracks + * the number of times each location has been nearly-matched as a finder pattern. + * Each additional find is more evidence that the location is in fact a finder + * pattern center + * + * @param stateCount reading state module counts from horizontal scan + * @param i row where finder pattern may be found + * @param j end of possible finder pattern in row + * @return true if a finder pattern candidate was found this time + */ + protected final boolean handlePossibleCenter(int[] stateCount, int i, int j) { + int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + + stateCount[4]; + float centerJ = centerFromEnd(stateCount, j); + float centerI = crossCheckVertical(i, (int) centerJ, stateCount[2], stateCountTotal); + if (!Float.isNaN(centerI)) { + // Re-cross check + centerJ = crossCheckHorizontal((int) centerJ, (int) centerI, stateCount[2], stateCountTotal); + if (!Float.isNaN(centerJ)) { + float estimatedModuleSize = (float) stateCountTotal / 7.0f; + boolean found = false; + for (int index = 0; index < possibleCenters.size(); index++) { + FinderPattern center = possibleCenters.get(index); + // Look for about the same center and module size: + if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { + possibleCenters.set(index, center.combineEstimate(centerI, centerJ, estimatedModuleSize)); + found = true; + break; + } + } + if (!found) { + FinderPattern point = new FinderPattern(centerJ, centerI, estimatedModuleSize); + possibleCenters.add(point); + if (resultPointCallback != null) { + resultPointCallback.foundPossibleResultPoint(point); + } + } + return true; + } + } + return false; + } + + /** + * @return number of rows we could safely skip during scanning, based on the first + * two finder patterns that have been located. In some cases their position will + * allow us to infer that the third pattern must lie below a certain point farther + * down in the image. + */ + private int findRowSkip() { + int max = possibleCenters.size(); + if (max <= 1) { + return 0; + } + FinderPattern firstConfirmedCenter = null; + for (FinderPattern center : possibleCenters) { + if (center.getCount() >= CENTER_QUORUM) { + if (firstConfirmedCenter == null) { + firstConfirmedCenter = center; + } else { + // We have two confirmed centers + // How far down can we skip before resuming looking for the next + // pattern? In the worst case, only the difference between the + // difference in the x / y coordinates of the two centers. + // This is the case where you find top left last. + hasSkipped = true; + return (int) (Math.abs(firstConfirmedCenter.getX() - center.getX()) - + Math.abs(firstConfirmedCenter.getY() - center.getY())) / 2; + } + } + } + return 0; + } + + /** + * @return true iff we have found at least 3 finder patterns that have been detected + * at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the + * candidates is "pretty similar" + */ + private boolean haveMultiplyConfirmedCenters() { + int confirmedCount = 0; + float totalModuleSize = 0.0f; + int max = possibleCenters.size(); + for (FinderPattern pattern : possibleCenters) { + if (pattern.getCount() >= CENTER_QUORUM) { + confirmedCount++; + totalModuleSize += pattern.getEstimatedModuleSize(); + } + } + if (confirmedCount < 3) { + return false; + } + // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" + // and that we need to keep looking. We detect this by asking if the estimated module sizes + // vary too much. We arbitrarily say that when the total deviation from average exceeds + // 5% of the total module size estimates, it's too much. + float average = totalModuleSize / (float) max; + float totalDeviation = 0.0f; + for (FinderPattern pattern : possibleCenters) { + totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average); + } + return totalDeviation <= 0.05f * totalModuleSize; + } + + /** + * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are + * those that have been detected at least {@link #CENTER_QUORUM} times, and whose module + * size differs from the average among those patterns the least + * @throws NotFoundException if 3 such finder patterns do not exist + */ + private FinderPattern[] selectBestPatterns() throws NotFoundException { + + int startSize = possibleCenters.size(); + if (startSize < 3) { + // Couldn't find enough finder patterns + throw NotFoundException.getNotFoundInstance(); + } + + // Filter outlier possibilities whose module size is too different + if (startSize > 3) { + // But we can only afford to do so if we have at least 4 possibilities to choose from + float totalModuleSize = 0.0f; + float square = 0.0f; + for (FinderPattern center : possibleCenters) { + float size = center.getEstimatedModuleSize(); + totalModuleSize += size; + square += size * size; + } + float average = totalModuleSize / (float) startSize; + float stdDev = (float) Math.sqrt(square / startSize - average * average); + + Collections.sort(possibleCenters, new FurthestFromAverageComparator(average)); + + float limit = Math.max(0.2f * average, stdDev); + + for (int i = 0; i < possibleCenters.size() && possibleCenters.size() > 3; i++) { + FinderPattern pattern = possibleCenters.get(i); + if (Math.abs(pattern.getEstimatedModuleSize() - average) > limit) { + possibleCenters.remove(i); + i--; + } + } + } + + if (possibleCenters.size() > 3) { + // Throw away all but those first size candidate points we found. + + float totalModuleSize = 0.0f; + for (FinderPattern possibleCenter : possibleCenters) { + totalModuleSize += possibleCenter.getEstimatedModuleSize(); + } + + float average = totalModuleSize / (float) possibleCenters.size(); + + Collections.sort(possibleCenters, new CenterComparator(average)); + + possibleCenters.subList(3, possibleCenters.size()).clear(); + } + + return new FinderPattern[]{ + possibleCenters.get(0), + possibleCenters.get(1), + possibleCenters.get(2) + }; + } + + /** + *

Orders by furthest from average

+ */ + private static final class FurthestFromAverageComparator implements Comparator, Serializable { + private final float average; + private FurthestFromAverageComparator(float f) { + average = f; + } + @Override + public int compare(FinderPattern center1, FinderPattern center2) { + float dA = Math.abs(center2.getEstimatedModuleSize() - average); + float dB = Math.abs(center1.getEstimatedModuleSize() - average); + return dA < dB ? -1 : dA == dB ? 0 : 1; + } + } + + /** + *

Orders by {@link FinderPattern#getCount()}, descending.

+ */ + private static final class CenterComparator implements Comparator, Serializable { + private final float average; + private CenterComparator(float f) { + average = f; + } + @Override + public int compare(FinderPattern center1, FinderPattern center2) { + if (center2.getCount() == center1.getCount()) { + float dA = Math.abs(center2.getEstimatedModuleSize() - average); + float dB = Math.abs(center1.getEstimatedModuleSize() - average); + return dA < dB ? 1 : dA == dB ? 0 : -1; + } else { + return center2.getCount() - center1.getCount(); + } + } + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/android/README.md b/plugins/phonegap-plugin-barcodescanner/src/android/README.md index 6c266e2..a8d6f8e 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/android/README.md +++ b/plugins/phonegap-plugin-barcodescanner/src/android/README.md @@ -1,91 +1,91 @@ -Building Android -================ - -## Building localy ## - -Steps if you have Netbeans setup for Android or want to do that. - -1. Setup Netbeans for Android development. - 1. Download and install JDK (be sure to set JAVA_HOME - it will be important for the SDK). - 2. Download and install Netebeans. - 3. Download and install Android SDK (do NOT use ADT boundle). - 4. Download and install NBAndroid: http://www.nbandroid.org/p/installation.html - 5. Set path of Android SDK in Netbeans (for installation for all users this is: ```c:\Program Files (x86)\Android\android-sdk\```). - -2. Install Phonegap: - - 1. Add to Windows PATH Android SDK tools: ```;C:\...[android-sdk]\platform-tools;C:\...[android-sdk]\tools``` - 2. Copy ANT home from Netbeans and add it your PATH too. - 3. Add Java bin to PATH: ```;%JAVA_HOME%\bin;%ANT_HOME%\bin``` - -3. Install cordova command line - 1. Install node.js. - 2. Install cordova command line: - ``` - npm install -g cordova - ``` - -4. Create and build test project to check command line tools: - ``` - cordova create hello com.example.hello "Hello World" - cd hello - cordova platform add android - cordova build - ``` - -5. To open project in Netbeans just use Open Project and in the folder you created the project navigate to platforms\android. - -6. Add the plugin following instructions from this page: https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner - -## Preparing for PhoneGap Build ## - -The process may vary depending on version of Zxing project, but base steps should be the same. - -1. Get latest zxing-android project and create a LibraryProject from that: - 1. Checked out zxing-android from SVN (http://zxing.googlecode.com/svn/trunk/). - 2. Overlayed the source from zxing-core. - 3. Set to library project. - 4. Change intent names to avoid conflict with ZXing app. - 5. Remove two lines from AndroidManifest.xml to avoid shortcuts being created. -2. Update plugin.xml with any needed resources (you can use ```plugin.xml.generate.php``` to generate some stuff for Android). -3. Refactor LibraryProject for usage with PGB: - 1. Commented out call to showHelpOnFirstLaunch (it will probably not work anyway). - 2. Replace R class with FakeR class calls (this is needed beacuse R class will be in a different namespace). - 3. Add FakeR initialization in each class it was added (note that if some classes extened other then you might want to add a protected fakeR variable to their parent - see e.g. ResultHandler class and it's children). - 4. Comment out ```([^<>]+)``` from strings.xml (to avoid replacing original application name). -4. Build LibraryProject, rename and copy it. - -## Building with plugman ## - -[Plugman](https://github.com/apache/cordova-plugman) is a Node.js tool used by PG Build. - -Workflow for creating and building example project with the plugin: - -1. Create and build example project: - ``` - cordova create hello com.example.hello "HelloWorld" - cd hello - cordova platform add android - cordova build - ``` - - Warning! White space characters are not allowed in app name (and any other that cannot be used in an activity or class name). See: https://issues.apache.org/jira/browse/CB-4148 - - Note. If you wish to remove Android platform (to e.g. generate it with your www assests) you will need to remove "platforms\android" and "merges\android\". - -2. Copy plugin files to "hello\plugins\com.phonegap.plugins.barcodescanner\". You can simply download from github: - ``` - git clone https://github.com/wildabeast/BarcodeScanner.git plugins\com.phonegap.plugins.barcodescanner - ``` - -3. Install the plugin (current dir. being "hello"): - ``` - plugman --plugins_dir plugins --plugin com.phonegap.plugins.barcodescanner --platform android --project platforms\android - plugman install --plugins_dir plugins --plugin com.phonegap.plugins.barcodescanner --platform android --project platforms\android - ``` - - Note. To manually remove plugin you need to re-create plugins\android.json (and remove changes done by the plugin - you can simply remove whole platform as described in first step and re-create). - -4. Build & deploy Android project with whatever Android IDE (or ANT + ADK tools). - -Note. Plugin sub-dir (here "com.phonegap.plugins.barcodescanner") need to be the same as the plugin ID only since PhoneGap 3.0. +Building Android +================ + +## Building localy ## + +Steps if you have Netbeans setup for Android or want to do that. + +1. Setup Netbeans for Android development. + 1. Download and install JDK (be sure to set JAVA_HOME - it will be important for the SDK). + 2. Download and install Netebeans. + 3. Download and install Android SDK (do NOT use ADT boundle). + 4. Download and install NBAndroid: http://www.nbandroid.org/p/installation.html + 5. Set path of Android SDK in Netbeans (for installation for all users this is: ```c:\Program Files (x86)\Android\android-sdk\```). + +2. Install Phonegap: + + 1. Add to Windows PATH Android SDK tools: ```;C:\...[android-sdk]\platform-tools;C:\...[android-sdk]\tools``` + 2. Copy ANT home from Netbeans and add it your PATH too. + 3. Add Java bin to PATH: ```;%JAVA_HOME%\bin;%ANT_HOME%\bin``` + +3. Install cordova command line + 1. Install node.js. + 2. Install cordova command line: + ``` + npm install -g cordova + ``` + +4. Create and build test project to check command line tools: + ``` + cordova create hello com.example.hello "Hello World" + cd hello + cordova platform add android + cordova build + ``` + +5. To open project in Netbeans just use Open Project and in the folder you created the project navigate to platforms\android. + +6. Add the plugin following instructions from this page: https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner + +## Preparing for PhoneGap Build ## + +The process may vary depending on version of Zxing project, but base steps should be the same. + +1. Get latest zxing-android project and create a LibraryProject from that: + 1. Checked out zxing-android from SVN (http://zxing.googlecode.com/svn/trunk/). + 2. Overlayed the source from zxing-core. + 3. Set to library project. + 4. Change intent names to avoid conflict with ZXing app. + 5. Remove two lines from AndroidManifest.xml to avoid shortcuts being created. +2. Update plugin.xml with any needed resources (you can use ```plugin.xml.generate.php``` to generate some stuff for Android). +3. Refactor LibraryProject for usage with PGB: + 1. Commented out call to showHelpOnFirstLaunch (it will probably not work anyway). + 2. Replace R class with FakeR class calls (this is needed beacuse R class will be in a different namespace). + 3. Add FakeR initialization in each class it was added (note that if some classes extened other then you might want to add a protected fakeR variable to their parent - see e.g. ResultHandler class and it's children). + 4. Comment out ```([^<>]+)``` from strings.xml (to avoid replacing original application name). +4. Build LibraryProject, rename and copy it. + +## Building with plugman ## + +[Plugman](https://github.com/apache/cordova-plugman) is a Node.js tool used by PG Build. + +Workflow for creating and building example project with the plugin: + +1. Create and build example project: + ``` + cordova create hello com.example.hello "HelloWorld" + cd hello + cordova platform add android + cordova build + ``` + + Warning! White space characters are not allowed in app name (and any other that cannot be used in an activity or class name). See: https://issues.apache.org/jira/browse/CB-4148 + + Note. If you wish to remove Android platform (to e.g. generate it with your www assests) you will need to remove "platforms\android" and "merges\android\". + +2. Copy plugin files to "hello\plugins\com.phonegap.plugins.barcodescanner\". You can simply download from github: + ``` + git clone https://github.com/wildabeast/BarcodeScanner.git plugins\com.phonegap.plugins.barcodescanner + ``` + +3. Install the plugin (current dir. being "hello"): + ``` + plugman --plugins_dir plugins --plugin com.phonegap.plugins.barcodescanner --platform android --project platforms\android + plugman install --plugins_dir plugins --plugin com.phonegap.plugins.barcodescanner --platform android --project platforms\android + ``` + + Note. To manually remove plugin you need to re-create plugins\android.json (and remove changes done by the plugin - you can simply remove whole platform as described in first step and re-create). + +4. Build & deploy Android project with whatever Android IDE (or ANT + ADK tools). + +Note. Plugin sub-dir (here "com.phonegap.plugins.barcodescanner") need to be the same as the plugin ID only since PhoneGap 3.0. diff --git a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/.cproject b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/.cproject new file mode 100644 index 0000000..5a94b8d --- /dev/null +++ b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/.cproject @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.cpp b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.cpp index fd1db92..1410185 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.cpp +++ b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.cpp @@ -1,105 +1,105 @@ -/* - * Copyright 2013-2014 BlackBerry Limited. - * - * 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. - */ - -#include "../public/tokenizer.h" -#include "barcodescanner_js.hpp" -#include "barcodescanner_ndk.hpp" - -using namespace std; - -/** - * Default constructor. - */ -BarcodeScannerJS::BarcodeScannerJS(const std::string& id) : - m_id(id) { - m_pLogger = new webworks::Logger("BarcodeScannerJS", this); - m_pBarcodeScannerController = new webworks::BarcodeScannerNDK(this); -} - -/** - * BarcodeScannerJS destructor. - */ -BarcodeScannerJS::~BarcodeScannerJS() { - if (m_pBarcodeScannerController) - delete m_pBarcodeScannerController; - if (m_pLogger) - delete m_pLogger; -} - -webworks::Logger* BarcodeScannerJS::getLog() { - return m_pLogger; -} - -/** - * This method returns the list of objects implemented by this native - * extension. - */ -char* onGetObjList() { - static char name[] = "BarcodeScannerJS"; - return name; -} - -/** - * This method is used by JNext to instantiate the BarcodeScannerJS object when - * an object is created on the JavaScript server side. - */ -JSExt* onCreateObject(const string& className, const string& id) { - if (className == "BarcodeScannerJS") { - return new BarcodeScannerJS(id); - } - - return NULL; -} - -/** - * Method used by JNext to determine if the object can be deleted. - */ -bool BarcodeScannerJS::CanDelete() { - return true; -} - -/** - * It will be called from JNext JavaScript side with passed string. - * This method implements the interface for the JavaScript to native binding - * for invoking native code. This method is triggered when JNext.invoke is - * called on the JavaScript side with this native objects id. - */ -string BarcodeScannerJS::InvokeMethod(const std::string& command) { - // command appears with parameters following after a space - size_t commandIndex = command.find_first_of(" "); - std::string strCommand = command.substr(0, commandIndex); - size_t callbackIndex = command.find_first_of(" ", commandIndex + 1); - std::string callbackId = command.substr(commandIndex + 1, callbackIndex - commandIndex - 1); - std::string arg = command.substr(callbackIndex + 1, command.length()); - - if (strCommand == "startRead") { - m_pBarcodeScannerController->startRead(callbackId, arg); - } - else if (strCommand == "stopRead") { - m_pBarcodeScannerController->stopRead(callbackId); - } - - strCommand.append(";"); - strCommand.append(command); - return strCommand; -} - -// Notifies JavaScript of an event -void BarcodeScannerJS::NotifyEvent(const std::string& event) { - std::string eventString = m_id + " "; - eventString.append(event); - SendPluginEvent(eventString.c_str(), m_pContext); -} +/* + * Copyright 2013-2014 BlackBerry Limited. + * + * 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. + */ + +#include "../public/tokenizer.h" +#include "barcodescanner_js.hpp" +#include "barcodescanner_ndk.hpp" + +using namespace std; + +/** + * Default constructor. + */ +BarcodeScannerJS::BarcodeScannerJS(const std::string& id) : + m_id(id) { + m_pLogger = new webworks::Logger("BarcodeScannerJS", this); + m_pBarcodeScannerController = new webworks::BarcodeScannerNDK(this); +} + +/** + * BarcodeScannerJS destructor. + */ +BarcodeScannerJS::~BarcodeScannerJS() { + if (m_pBarcodeScannerController) + delete m_pBarcodeScannerController; + if (m_pLogger) + delete m_pLogger; +} + +webworks::Logger* BarcodeScannerJS::getLog() { + return m_pLogger; +} + +/** + * This method returns the list of objects implemented by this native + * extension. + */ +char* onGetObjList() { + static char name[] = "BarcodeScannerJS"; + return name; +} + +/** + * This method is used by JNext to instantiate the BarcodeScannerJS object when + * an object is created on the JavaScript server side. + */ +JSExt* onCreateObject(const string& className, const string& id) { + if (className == "BarcodeScannerJS") { + return new BarcodeScannerJS(id); + } + + return NULL; +} + +/** + * Method used by JNext to determine if the object can be deleted. + */ +bool BarcodeScannerJS::CanDelete() { + return true; +} + +/** + * It will be called from JNext JavaScript side with passed string. + * This method implements the interface for the JavaScript to native binding + * for invoking native code. This method is triggered when JNext.invoke is + * called on the JavaScript side with this native objects id. + */ +string BarcodeScannerJS::InvokeMethod(const std::string& command) { + // command appears with parameters following after a space + size_t commandIndex = command.find_first_of(" "); + std::string strCommand = command.substr(0, commandIndex); + size_t callbackIndex = command.find_first_of(" ", commandIndex + 1); + std::string callbackId = command.substr(commandIndex + 1, callbackIndex - commandIndex - 1); + std::string arg = command.substr(callbackIndex + 1, command.length()); + + if (strCommand == "startRead") { + m_pBarcodeScannerController->startRead(callbackId, arg); + } + else if (strCommand == "stopRead") { + m_pBarcodeScannerController->stopRead(callbackId); + } + + strCommand.append(";"); + strCommand.append(command); + return strCommand; +} + +// Notifies JavaScript of an event +void BarcodeScannerJS::NotifyEvent(const std::string& event) { + std::string eventString = m_id + " "; + eventString.append(event); + SendPluginEvent(eventString.c_str(), m_pContext); +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.hpp b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.hpp index 4b04a78..8a8e960 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.hpp +++ b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_js.hpp @@ -1,41 +1,41 @@ -/* -* Copyright 2013-2014 BlackBerry Limited. -* -* 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. -*/ - -#ifndef BARCODESCANNERJS_HPP_ -#define BARCODESCANNERJS_HPP_ - -#include "../public/plugin.h" -#include "barcodescanner_ndk.hpp" -#include "Logger.hpp" -#include - -class BarcodeScannerJS: public JSExt { - -public: - explicit BarcodeScannerJS(const std::string& id); - virtual ~BarcodeScannerJS(); - virtual bool CanDelete(); - virtual std::string InvokeMethod(const std::string& command); - void NotifyEvent(const std::string& event); - webworks::Logger* getLog(); - webworks::BarcodeScannerNDK *m_pBarcodeScannerController; -private: - std::string m_id; - // Definition of a pointer to the actual native extension code - webworks::Logger *m_pLogger; -}; - -#endif /* BarcodeScannerJS_HPP_ */ +/* +* Copyright 2013-2014 BlackBerry Limited. +* +* 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. +*/ + +#ifndef BARCODESCANNERJS_HPP_ +#define BARCODESCANNERJS_HPP_ + +#include "../public/plugin.h" +#include "barcodescanner_ndk.hpp" +#include "Logger.hpp" +#include + +class BarcodeScannerJS: public JSExt { + +public: + explicit BarcodeScannerJS(const std::string& id); + virtual ~BarcodeScannerJS(); + virtual bool CanDelete(); + virtual std::string InvokeMethod(const std::string& command); + void NotifyEvent(const std::string& event); + webworks::Logger* getLog(); + webworks::BarcodeScannerNDK *m_pBarcodeScannerController; +private: + std::string m_id; + // Definition of a pointer to the actual native extension code + webworks::Logger *m_pLogger; +}; + +#endif /* BarcodeScannerJS_HPP_ */ diff --git a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.cpp b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.cpp index 830f17b..8c73efd 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.cpp +++ b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.cpp @@ -1,709 +1,709 @@ -/* - * Copyright 2013-2015 BlackBerry Limited. - * - * 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. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "barcodescanner_ndk.hpp" -#include "barcodescanner_js.hpp" - -#include -#include - -using namespace zxing; - -namespace webworks { - -BarcodeScannerJS* eventDispatcher = NULL; -// Variables for native viewfinder screen -static screen_window_t vf_win = NULL; -static uint32_t vfRotation = 0; -static bool touch = false; - - -#define MUTEX_LOCK() pthread_mutex_trylock(&m_lock) -#define MUTEX_UNLOCK() pthread_mutex_unlock(&m_lock) - -static pthread_mutex_t m_lock; -static pthread_t m_thread = 0; - - /* - * getCameraErrorDesc - * - * Returns a descriptive error message for a given camera error code - */ - const char* getCameraErrorDesc(camera_error_t err) { - switch (err) { - case CAMERA_EOK: - return "The function call to the camera completed successfully."; - case CAMERA_EAGAIN: - return "The specified camera was not available. Try again."; - case CAMERA_EINVAL: - return "The camera call failed because of an invalid parameter."; - case CAMERA_ENODEV: - return "No such camera was found."; - case CAMERA_EMFILE: - return "The camera called failed because of a file table overflow."; - case CAMERA_EBADF: - return "Indicates that an invalid handle to a @c camera_handle_t value was used."; - case CAMERA_EACCESS: - return "Indicates that the necessary permissions to access the camera are not available."; - case CAMERA_EBADR: - return "Indicates that an invalid file descriptor was used."; - case CAMERA_ENOENT: - return "Indicates that the access a file or directory that does not exist."; - case CAMERA_ENOMEM: - return "Indicates that memory allocation failed."; - case CAMERA_EOPNOTSUPP: - return "Indicates that the requested operation is not supported."; - case CAMERA_ETIMEDOUT: - return "The function call failed due to communication problem or time-out with the camera."; - case CAMERA_EALREADY: - return "Indicates an operation on the camera is already in progress. In addition, this error can indicate that an error could not be completed because it was already completed. For example, if you called the @c camera_stop_video() function but the camera had already stopped recording video, this error code would be returned."; - case CAMERA_EUNINIT: - return "Indicates that the Camera Library is not initialized."; - case CAMERA_EREGFAULT: - return "Indicates that registration of a callback failed."; - case CAMERA_EMICINUSE: - return "Indicates that it failed to open because microphone is already in use."; - } - return NULL; - } - - - /* - * viewfinder_callback - * - * This callback is invoked when an image frame from the camera viewfinder becomes available. - * The frame is analyzed to determine if a barcode can be matched. - * Frames come in NV12 format which makes code analysis very fast. - */ - void viewfinder_callback(camera_handle_t handle,camera_buffer_t* buf,void* arg) { - camera_frame_nv12_t* data = (camera_frame_nv12_t*)(&(buf->framedesc)); - uint8_t* buff = buf->framebuf; - int stride = data->stride; - int width = data->width; - int height = data->height; - if ( eventDispatcher != NULL ){ -// eventDispatcher->getLog()->debug("Frame received"); - } - - try { - Ref source(new GreyscaleLuminanceSource((unsigned char *)buff, stride, height, 0,0,width,height)); - - Ref binarizer(new HybridBinarizer(source)); - Ref bitmap(new BinaryBitmap(binarizer)); - Ref result; - - // setup the code reader - MultiFormatReader *reader = new MultiFormatReader(); - DecodeHints *hints = new DecodeHints(); - - hints->addFormat(BarcodeFormat_QR_CODE); - hints->addFormat(BarcodeFormat_EAN_8); - hints->addFormat(BarcodeFormat_EAN_13); - hints->addFormat(BarcodeFormat_UPC_A); - hints->addFormat(BarcodeFormat_UPC_E); - hints->addFormat(BarcodeFormat_DATA_MATRIX); - hints->addFormat(BarcodeFormat_CODE_128); - hints->addFormat(BarcodeFormat_CODE_39); - hints->addFormat(BarcodeFormat_ITF); - hints->addFormat(BarcodeFormat_AZTEC); - - // attempt to decode and retrieve a valid QR code from the image bitmap - result = reader->decode(bitmap, *hints); - - std::string newBarcodeData = result->getText()->getText().data(); - - Json::FastWriter writer; - Json::Value root; - root["text"] = newBarcodeData; - root["format"] = barcodeFormatNames[result->getBarcodeFormat()]; - root["cancelled"] = false; - - // notify caller that a valid QR code has been decoded - if ( eventDispatcher != NULL){ - std::string event = "community.barcodescanner.codefound.native"; - event.insert(0, " "); - event.insert(0, (char *) arg); - eventDispatcher->NotifyEvent(event + " " + writer.write(root)); - eventDispatcher->getLog()->debug("This is the detected Barcode"); - eventDispatcher->getLog()->debug(newBarcodeData.c_str()); - } - - } - catch (const std::exception& ex) - { - // Uncomment this if you need to verify scanning - if ( eventDispatcher != NULL ){ -// eventDispatcher->getLog()->warn("Scan error"); -// eventDispatcher->getLog()->warn(ex.what()); - } - } - } - - std::string convertIntToString(int i) { - stringstream ss; - ss << i; - return ss.str(); - } - - - /* - * Constructor for Barcode Scanner NDK class - */ - BarcodeScannerNDK::BarcodeScannerNDK(BarcodeScannerJS *parent): threadHalt(false) { - cbId = new char[1000]; - m_pParent = parent; - eventDispatcher = parent; - mCameraHandle = CAMERA_HANDLE_INVALID; - } - - BarcodeScannerNDK::~BarcodeScannerNDK() { - delete[] cbId; - } - - webworks::Logger* BarcodeScannerNDK::getLog() { - return m_pParent->getLog(); - } - - void interrogateWindowCV(screen_window_t window, Logger* log, string description, int property) { - char* value = new char[256]; - int ok = screen_get_window_property_cv(window, property, 256, value); - if (ok == 0) { - log->info(description.c_str()); - log->info(value); - } else { - log->warn("Unable to interpret value for"); - log->warn(description.c_str()); - } - } - - void interrogateWindowIV(screen_window_t window, Logger* log, string description, int property) { - int value = -1; - int ok = screen_get_window_property_iv(window, property, &value); - if (ok == 0) { - log->info(description.c_str()); - log->info(convertIntToString(value).c_str()); - } else { - log->warn("Unable to interpret value for"); - log->warn(description.c_str()); - } - } - - void interrogateWindow(screen_window_t window, Logger* log) { - log->info("Window Details--->"); - interrogateWindowCV(window, log, "Window ID", SCREEN_PROPERTY_ID_STRING); - interrogateWindowIV(window, log, "Window Type", SCREEN_PROPERTY_TYPE); - interrogateWindowIV(window, log, "Window Owner PID", SCREEN_PROPERTY_OWNER_PID); - interrogateWindowCV(window, log, "Window Group", SCREEN_PROPERTY_GROUP); - interrogateWindowIV(window, log, "Window Z Order", SCREEN_PROPERTY_ZORDER); - interrogateWindowIV(window, log, "Window Visible", SCREEN_PROPERTY_VISIBLE); - log->info("Window Interrogation complete"); - } - - void *HandleEvents(void *args) { - BarcodeScannerNDK *parent = static_cast(args); - parent->getLog()->debug("BarcodeScannerNDK EventHandler"); - - /** - * Creating a native viewfinder screen - */ - const int usage = SCREEN_USAGE_NATIVE; - screen_window_t screen_win; - screen_buffer_t screen_buf = NULL; - int rect[4] = { 0, 0, 0, 0 }; - - if(screen_create_window_type(&screen_win, parent->windowContext, SCREEN_CHILD_WINDOW) == -1) { - parent->getLog()->error("screen_create_window() failed");; - } - screen_join_window_group(screen_win, parent->windowGroup); - char * groupCheck = new char[256]; - screen_get_window_property_cv(screen_win, SCREEN_PROPERTY_GROUP, 256, groupCheck); - parent->getLog()->info("Window Group Check"); - parent->getLog()->info(groupCheck); - screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); - int r = 0; - screen_display_t display = NULL; - screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void**)&display); - if (display != NULL) { - screen_get_display_property_iv(display, SCREEN_PROPERTY_ROTATION, &r); - parent->getLog()->debug("Current Display Rotation"); - parent->getLog()->debug(convertIntToString(r).c_str()); - } - screen_create_window_buffers(screen_win, 1); - screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); - screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); - // The screen (and backing buffer) don't take into account the rotation, so we need to swap the size. - if (r == 90 || r == 270) { - int swap = rect[2]; - rect[2] = rect[3]; - rect[3] = swap; - } - // Set the window size and the buffer follows along - screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, rect+2); - screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); - - parent->getLog()->debug("Screen Buffer Size:"); - parent->getLog()->debug(convertIntToString(rect[0]).c_str()); - parent->getLog()->debug(convertIntToString(rect[1]).c_str()); - parent->getLog()->debug(convertIntToString(rect[2]).c_str()); - parent->getLog()->debug(convertIntToString(rect[3]).c_str()); - - int type = -1; - screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_TYPE, &type); - parent->getLog()->debug("Window Type"); - parent->getLog()->debug(convertIntToString(type).c_str()); - - // fill the window with a flat colour - int attribs[] = { SCREEN_BLIT_COLOR, 0x00333333, SCREEN_BLIT_END }; - screen_fill(parent->windowContext, screen_buf, attribs); - screen_post_window(screen_win, screen_buf, 1, rect, 0); - // position the window at an arbitrary z-order - int i = 1; - screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &i); - screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &i); - parent->getLog()->debug("Current Zorder"); - parent->getLog()->debug(convertIntToString(i).c_str()); - int visible = 1; - screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &visible); - screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &visible); - parent->getLog()->debug("Visible?"); - parent->getLog()->debug(convertIntToString(visible).c_str()); - screen_flush_context(parent->windowContext, 0); - - parent->getLog()->debug("Created Background window"); - - if (parent->windowContext) { - if (BPS_SUCCESS == screen_request_events(parent->windowContext)) { - parent->getLog()->debug("Requested Events"); - } else { - parent->getLog()->error("Unable to request events"); - return NULL; - } - } - - screen_group_t group; - screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_GROUP, (void **)&group); - char* groupName = new char[256]; - screen_get_group_property_cv(group, SCREEN_PROPERTY_NAME, 256, groupName); - parent->getLog()->debug("Group Found"); - parent->getLog()->debug(groupName); - - // reset Touch value before starting up listening for touch events - touch = false; - - while(!parent->isThreadHalt()) { - MUTEX_LOCK(); - - int domain; - // Get the first event in the queue. - bps_event_t *event = NULL; - if (BPS_SUCCESS != bps_get_event(&event, 0)) { - parent->getLog()->warn("bps_get_event() failed"); - } - - // Handle all events in the queue. - while (event) { - if (touch) { - // HandleScreenEvent got a tap on the screen - // Shutdown the scanning - parent->cancelScan(); - break; - } - if (event) { - domain = bps_event_get_domain(event); - parent->getLog()->debug("BPS Event"); - if (domain == screen_get_domain()) { - parent->getLog()->debug("BPS Screen Event"); - parent->handleScreenEvent(event, parent->getLog(), parent->windowGroup); - } - } - if (BPS_SUCCESS != bps_get_event(&event, 0)) { - parent->getLog()->error("bps_get_event() failed"); -// return; - } - } - - MUTEX_UNLOCK(); - - // Poll at 10hz - usleep(100000); - } - // stop screen events on this thread - if(screen_stop_events(parent->windowContext) == -1) { - parent->getLog()->error("screen_stop_events failed"); - } - screen_destroy_window(screen_win); - return NULL; - } - - void BarcodeScannerNDK::handleScreenEvent(bps_event_t *event, Logger* log, const char* windowGroup) { - int eventType, objectType, eventProperty; - - screen_event_t screen_event = screen_event_get_event(event); - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType); - - switch (eventType) { - case SCREEN_EVENT_MTOUCH_RELEASE: - case SCREEN_EVENT_MTOUCH_TOUCH: - case SCREEN_EVENT_MTOUCH_MOVE: - log->info("Touch Event"); - touch = true; - break; - case SCREEN_EVENT_CREATE: - log->info("Screen Create Event"); - if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void **)&vf_win) == -1) { - log->error("screen_get_event_property_pv(SCREEN_PROPERTY_WINDOW)"); - } else { - log->info("viewfinder window found!"); - } - break; - case SCREEN_EVENT_IDLE: - log->debug("Screen Idle"); - break; - case SCREEN_EVENT_POST: - log->debug("Screen posted first frame"); - if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void **)&vf_win) == -1) { - log->error("screen_get_event_property_pv(SCREEN_PROPERTY_WINDOW)"); - } else { - interrogateWindow(vf_win, log); - int i = 100; - screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_ZORDER, &i); - screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_ZORDER, &i); - log->debug("Current Zorder"); - log->debug(convertIntToString(i).c_str()); - // make viewfinder window visible - i = 1; - screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_VISIBLE, &i); - screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_VISIBLE, &i); - log->debug("Visible?"); - log->debug(convertIntToString(i).c_str()); - // Rotate the window as needed - screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_ROTATION, &i); - log->debug("Current Rotation"); - log->debug(convertIntToString(i).c_str()); - i = 360 - vfRotation; - screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_ROTATION, &i); - screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_ROTATION, &i); - log->debug("Rotation"); - log->debug(convertIntToString(i).c_str()); - // Make full screen - screen_display_t display = NULL; - screen_get_window_property_pv(vf_win, SCREEN_PROPERTY_DISPLAY, (void **)&display); - if (display != NULL) { - log->debug("Found a Display"); - int size[2] = { 0, 0 }; - screen_get_display_property_iv(display, SCREEN_PROPERTY_SIZE, size); - log->debug("Display Size"); - log->debug(convertIntToString(size[0]).c_str()); - log->debug(convertIntToString(size[1]).c_str()); - int r = 0; - screen_get_display_property_iv(display, SCREEN_PROPERTY_ROTATION, &r); - log->debug("Current Display Rotation"); - log->debug(convertIntToString(r).c_str()); - if (r == 90 || r == 270) { - int swap = size[0]; - size[0] = size[1]; - size[1] = swap; - } - screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_SIZE, size); - screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_SIZE, size); - log->debug("Window Size"); - log->debug(convertIntToString(size[0]).c_str()); - log->debug(convertIntToString(size[1]).c_str()); - } - - } - break; - case SCREEN_EVENT_CLOSE: - log->debug("Screen closed"); - break; - case SCREEN_EVENT_INPUT: - log->debug("Screen input event"); - break; - case SCREEN_EVENT_PROPERTY: - log->debug("Screen property event"); - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType); - log->debug("Object Type"); - log->debug(convertIntToString(objectType).c_str()); - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_NAME, &eventProperty); - log->debug("Property Name"); - log->debug(convertIntToString(eventProperty).c_str()); - break; - default: - log->warn("Unhandled Screen Event Type"); - log->warn(convertIntToString(eventType).c_str()); - break; - } - } - - bool BarcodeScannerNDK::StartEvents() { - if (!m_thread) { - threadHalt = false; - pthread_attr_t thread_attr; - pthread_attr_init(&thread_attr); - pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); - int error = pthread_create(&m_thread, &thread_attr, HandleEvents, static_cast(this)); - pthread_attr_destroy(&thread_attr); - if (error) { - m_pParent->getLog()->error("Thread Failed to start"); - m_thread = 0; - return false; - } else { - m_pParent->getLog()->info("Thread Started"); - MUTEX_LOCK(); - return true; - } - } - - return false; - } - - void BarcodeScannerNDK::StopEvents() { - if (m_thread) { - MUTEX_LOCK(); - threadHalt = true; - MUTEX_UNLOCK(); - m_pParent->getLog()->debug("BarcodeScannerNDK joining event thread"); - pthread_join(m_thread, NULL); - m_thread = 0; - m_pParent->getLog()->debug("BarcodeScannerNDK event thread stopped"); - } - } - - - // getter for the stop value - bool BarcodeScannerNDK::isThreadHalt() { - bool isThreadHalt; - MUTEX_LOCK(); - isThreadHalt = threadHalt; - MUTEX_UNLOCK(); - return isThreadHalt; - } - - void BarcodeScannerNDK::cancelScan() { - m_pParent->getLog()->warn("Cancel Scan"); - std::string event = "community.barcodescanner.codefound.native"; - std::string callbackId = cbId; - Json::FastWriter writer; - Json::Value root; - - // Scan cancelled by user - root["text"] = ""; - root["format"] = ""; - root["cancelled"] = true; - - m_pParent->NotifyEvent(callbackId + " " + event + " " + writer.write(root)); - } - - /* - * BarcodeScannerNDK::startRead - * - * This method is called to start a QR code read. A connection is opened to the device camera - * and the photo viewfinder is started. - */ - int BarcodeScannerNDK::startRead(const string &callbackId, const string &arg) { - std::string errorEvent = "community.barcodescanner.errorfound.native"; - Json::FastWriter writer; - Json::Value root; - - // Important for maintaining proper event queue support on 10.2.1 - bps_initialize(); - - std::string handle; - std::string group; - Json::Reader reader; - Json::Value input; - bool parse = reader.parse(arg, input); - - if (!parse) { - m_pParent->getLog()->error("Parse Error"); - Json::Value error; - root["state"] = "Parsing JSON object"; - root["error"] = "Cannot parse JSON object"; - root["description"] = ""; - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(error)); - return EIO; - } else { - handle = input["handle"].asString(); - group = input["group"].asString(); - } - - std::copy(callbackId.begin(), callbackId.end(), this->cbId); - this->cbId[callbackId.size()] = '\0'; - - this->windowHandle = handle; - m_pParent->getLog()->info("Window Handle"); - m_pParent->getLog()->info(handle.c_str()); - // the jsScreenWindowHandle of the UIWebView that we passed in - int windowPointer = (int) strtol(handle.c_str(), NULL, 10); - // As an integer is the actual window handle - screen_window_t window = (screen_window_t) windowPointer; - interrogateWindow(window, m_pParent->getLog()); - // Create a group for the main window - windowGroup = new char[group.length()+1]; - std::strcpy (windowGroup, group.c_str()); - m_pParent->getLog()->debug("Window Group using:"); - m_pParent->getLog()->debug(windowGroup); - - int getContext = screen_get_window_property_pv(window, SCREEN_PROPERTY_CONTEXT, (void **)&windowContext); - if (getContext == -1) { - m_pParent->getLog()->critical("Unable to get Context"); - root["state"] = "Get App Window Context"; - root["error"] = getContext; - root["description"] = "Unable to get application context"; - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); - return EIO; - } - - StartEvents(); - - camera_error_t err; - // Open the camera first before running any operations on it - err = camera_open(CAMERA_UNIT_REAR,CAMERA_MODE_RW | CAMERA_MODE_ROLL,&mCameraHandle); - - if ( err != CAMERA_EOK){ - m_pParent->getLog()->error("Ran into an issue when initializing the camera"); - m_pParent->getLog()->error(getCameraErrorDesc( err )); - root["state"] = "Open Camera"; - root["error"] = err; - root["description"] = getCameraErrorDesc( err ); - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); - return EIO; - } - - // We want maximum framerate from the viewfinder which will scan for codes - int numRates = 0; - err = camera_get_photo_vf_framerates(mCameraHandle, true, 0, &numRates, NULL, NULL); - double* camFramerates = new double[numRates]; - bool maxmin = false; - err = camera_get_photo_vf_framerates(mCameraHandle, true, numRates, &numRates, camFramerates, &maxmin); - - // do we need to rotate the viewfinder? - - err = camera_get_photovf_property(mCameraHandle, CAMERA_IMGPROP_ROTATION, &vfRotation); - m_pParent->getLog()->debug("Viewfinder Rotation"); - m_pParent->getLog()->debug(convertIntToString(vfRotation).c_str()); - - m_pParent->getLog()->debug("Camera Window Group"); - m_pParent->getLog()->debug(windowGroup); - // We're going to have the viewfinder window join our app's window group, and start an embedded window - err = camera_set_photovf_property(mCameraHandle, - CAMERA_IMGPROP_WIN_GROUPID, windowGroup, - CAMERA_IMGPROP_WIN_ID, "my_viewfinder"); - if ( err != CAMERA_EOK){ - m_pParent->getLog()->error("Ran into an issue when configuring the camera viewfinder"); - m_pParent->getLog()->error(getCameraErrorDesc( err )); - root["state"] = "Set VF Props"; - root["error"] = err; - root["description"] = getCameraErrorDesc( err ); - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); - return EIO; - } - - // Starting viewfinder up which will call the viewfinder callback - this gets the NV12 images for scanning - err = camera_start_photo_viewfinder( mCameraHandle, &viewfinder_callback, NULL, this->cbId); - if ( err != CAMERA_EOK) { - m_pParent->getLog()->error("Ran into a strange issue when starting up the camera viewfinder"); - m_pParent->getLog()->error(getCameraErrorDesc( err )); - root["state"] = "ViewFinder Start"; - root["error"] = err; - root["description"] = getCameraErrorDesc( err ); - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); - return EIO; - } - - // Focus mode can't be set until the viewfinder is started. We need Continuous Macro for barcodes - err = camera_set_focus_mode(mCameraHandle, CAMERA_FOCUSMODE_CONTINUOUS_MACRO); - if ( err != CAMERA_EOK){ - m_pParent->getLog()->error("Ran into an issue when setting focus mode"); - m_pParent->getLog()->error(getCameraErrorDesc( err )); - root["state"] = "Set Focus Mode"; - root["error"] = err; - root["description"] = getCameraErrorDesc( err ); - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); - return EIO; - } - - std::string successEvent = "community.barcodescanner.started.native"; - root["successful"] = true; - m_pParent->NotifyEvent(callbackId + " " + successEvent + " " + writer.write(root)); - return EOK; - } - - - /* - * BarcodeScannerNDK::stopRead - * - * This method is called to clean up following successful detection of a barcode. - * Calling this method will stop the viewfinder and close an open connection to the device camera. - */ - int BarcodeScannerNDK::stopRead(const string &callbackId) { - std::string errorEvent = "community.barcodescanner.errorfound.native"; - Json::FastWriter writer; - Json::Value root; - camera_error_t err; - - // Stop events first so that you don't get better response from the screen - StopEvents(); - - err = camera_stop_photo_viewfinder(mCameraHandle); - if ( err != CAMERA_EOK) - { - m_pParent->getLog()->error("Error with turning off the photo viewfinder"); - m_pParent->getLog()->error(getCameraErrorDesc( err )); - root["error"] = err; - root["description"] = getCameraErrorDesc( err ); - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); - return EIO; - } - - //check to see if the camera is open, if it is open, then close it - err = camera_close(mCameraHandle); - if ( err != CAMERA_EOK){ - m_pParent->getLog()->error("Error with closing the camera"); - m_pParent->getLog()->error(getCameraErrorDesc( err )); - root["error"] = err; - root["description"] = getCameraErrorDesc( err ); - m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); - return EIO; - } - - std::string successEvent = "community.barcodescanner.ended.native"; - root["successful"] = true; - mCameraHandle = CAMERA_HANDLE_INVALID; - m_pParent->NotifyEvent(callbackId + " " + successEvent + " " + writer.write(root)); - - // Important for maintaining proper event queue support on 10.2.1 - bps_shutdown(); - - return EOK; - } - -} +/* + * Copyright 2013-2015 BlackBerry Limited. + * + * 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. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "barcodescanner_ndk.hpp" +#include "barcodescanner_js.hpp" + +#include +#include + +using namespace zxing; + +namespace webworks { + +BarcodeScannerJS* eventDispatcher = NULL; +// Variables for native viewfinder screen +static screen_window_t vf_win = NULL; +static uint32_t vfRotation = 0; +static bool touch = false; + + +#define MUTEX_LOCK() pthread_mutex_trylock(&m_lock) +#define MUTEX_UNLOCK() pthread_mutex_unlock(&m_lock) + +static pthread_mutex_t m_lock; +static pthread_t m_thread = 0; + + /* + * getCameraErrorDesc + * + * Returns a descriptive error message for a given camera error code + */ + const char* getCameraErrorDesc(camera_error_t err) { + switch (err) { + case CAMERA_EOK: + return "The function call to the camera completed successfully."; + case CAMERA_EAGAIN: + return "The specified camera was not available. Try again."; + case CAMERA_EINVAL: + return "The camera call failed because of an invalid parameter."; + case CAMERA_ENODEV: + return "No such camera was found."; + case CAMERA_EMFILE: + return "The camera called failed because of a file table overflow."; + case CAMERA_EBADF: + return "Indicates that an invalid handle to a @c camera_handle_t value was used."; + case CAMERA_EACCESS: + return "Indicates that the necessary permissions to access the camera are not available."; + case CAMERA_EBADR: + return "Indicates that an invalid file descriptor was used."; + case CAMERA_ENOENT: + return "Indicates that the access a file or directory that does not exist."; + case CAMERA_ENOMEM: + return "Indicates that memory allocation failed."; + case CAMERA_EOPNOTSUPP: + return "Indicates that the requested operation is not supported."; + case CAMERA_ETIMEDOUT: + return "The function call failed due to communication problem or time-out with the camera."; + case CAMERA_EALREADY: + return "Indicates an operation on the camera is already in progress. In addition, this error can indicate that an error could not be completed because it was already completed. For example, if you called the @c camera_stop_video() function but the camera had already stopped recording video, this error code would be returned."; + case CAMERA_EUNINIT: + return "Indicates that the Camera Library is not initialized."; + case CAMERA_EREGFAULT: + return "Indicates that registration of a callback failed."; + case CAMERA_EMICINUSE: + return "Indicates that it failed to open because microphone is already in use."; + } + return NULL; + } + + + /* + * viewfinder_callback + * + * This callback is invoked when an image frame from the camera viewfinder becomes available. + * The frame is analyzed to determine if a barcode can be matched. + * Frames come in NV12 format which makes code analysis very fast. + */ + void viewfinder_callback(camera_handle_t handle,camera_buffer_t* buf,void* arg) { + camera_frame_nv12_t* data = (camera_frame_nv12_t*)(&(buf->framedesc)); + uint8_t* buff = buf->framebuf; + int stride = data->stride; + int width = data->width; + int height = data->height; + if ( eventDispatcher != NULL ){ +// eventDispatcher->getLog()->debug("Frame received"); + } + + try { + Ref source(new GreyscaleLuminanceSource((unsigned char *)buff, stride, height, 0,0,width,height)); + + Ref binarizer(new HybridBinarizer(source)); + Ref bitmap(new BinaryBitmap(binarizer)); + Ref result; + + // setup the code reader + MultiFormatReader *reader = new MultiFormatReader(); + DecodeHints *hints = new DecodeHints(); + + hints->addFormat(BarcodeFormat_QR_CODE); + hints->addFormat(BarcodeFormat_EAN_8); + hints->addFormat(BarcodeFormat_EAN_13); + hints->addFormat(BarcodeFormat_UPC_A); + hints->addFormat(BarcodeFormat_UPC_E); + hints->addFormat(BarcodeFormat_DATA_MATRIX); + hints->addFormat(BarcodeFormat_CODE_128); + hints->addFormat(BarcodeFormat_CODE_39); + hints->addFormat(BarcodeFormat_ITF); + hints->addFormat(BarcodeFormat_AZTEC); + + // attempt to decode and retrieve a valid QR code from the image bitmap + result = reader->decode(bitmap, *hints); + + std::string newBarcodeData = result->getText()->getText().data(); + + Json::FastWriter writer; + Json::Value root; + root["text"] = newBarcodeData; + root["format"] = barcodeFormatNames[result->getBarcodeFormat()]; + root["cancelled"] = false; + + // notify caller that a valid QR code has been decoded + if ( eventDispatcher != NULL){ + std::string event = "community.barcodescanner.codefound.native"; + event.insert(0, " "); + event.insert(0, (char *) arg); + eventDispatcher->NotifyEvent(event + " " + writer.write(root)); + eventDispatcher->getLog()->debug("This is the detected Barcode"); + eventDispatcher->getLog()->debug(newBarcodeData.c_str()); + } + + } + catch (const std::exception& ex) + { + // Uncomment this if you need to verify scanning + if ( eventDispatcher != NULL ){ +// eventDispatcher->getLog()->warn("Scan error"); +// eventDispatcher->getLog()->warn(ex.what()); + } + } + } + + std::string convertIntToString(int i) { + stringstream ss; + ss << i; + return ss.str(); + } + + + /* + * Constructor for Barcode Scanner NDK class + */ + BarcodeScannerNDK::BarcodeScannerNDK(BarcodeScannerJS *parent): threadHalt(false) { + cbId = new char[1000]; + m_pParent = parent; + eventDispatcher = parent; + mCameraHandle = CAMERA_HANDLE_INVALID; + } + + BarcodeScannerNDK::~BarcodeScannerNDK() { + delete[] cbId; + } + + webworks::Logger* BarcodeScannerNDK::getLog() { + return m_pParent->getLog(); + } + + void interrogateWindowCV(screen_window_t window, Logger* log, string description, int property) { + char* value = new char[256]; + int ok = screen_get_window_property_cv(window, property, 256, value); + if (ok == 0) { + log->info(description.c_str()); + log->info(value); + } else { + log->warn("Unable to interpret value for"); + log->warn(description.c_str()); + } + } + + void interrogateWindowIV(screen_window_t window, Logger* log, string description, int property) { + int value = -1; + int ok = screen_get_window_property_iv(window, property, &value); + if (ok == 0) { + log->info(description.c_str()); + log->info(convertIntToString(value).c_str()); + } else { + log->warn("Unable to interpret value for"); + log->warn(description.c_str()); + } + } + + void interrogateWindow(screen_window_t window, Logger* log) { + log->info("Window Details--->"); + interrogateWindowCV(window, log, "Window ID", SCREEN_PROPERTY_ID_STRING); + interrogateWindowIV(window, log, "Window Type", SCREEN_PROPERTY_TYPE); + interrogateWindowIV(window, log, "Window Owner PID", SCREEN_PROPERTY_OWNER_PID); + interrogateWindowCV(window, log, "Window Group", SCREEN_PROPERTY_GROUP); + interrogateWindowIV(window, log, "Window Z Order", SCREEN_PROPERTY_ZORDER); + interrogateWindowIV(window, log, "Window Visible", SCREEN_PROPERTY_VISIBLE); + log->info("Window Interrogation complete"); + } + + void *HandleEvents(void *args) { + BarcodeScannerNDK *parent = static_cast(args); + parent->getLog()->debug("BarcodeScannerNDK EventHandler"); + + /** + * Creating a native viewfinder screen + */ + const int usage = SCREEN_USAGE_NATIVE; + screen_window_t screen_win; + screen_buffer_t screen_buf = NULL; + int rect[4] = { 0, 0, 0, 0 }; + + if(screen_create_window_type(&screen_win, parent->windowContext, SCREEN_CHILD_WINDOW) == -1) { + parent->getLog()->error("screen_create_window() failed");; + } + screen_join_window_group(screen_win, parent->windowGroup); + char * groupCheck = new char[256]; + screen_get_window_property_cv(screen_win, SCREEN_PROPERTY_GROUP, 256, groupCheck); + parent->getLog()->info("Window Group Check"); + parent->getLog()->info(groupCheck); + screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); + int r = 0; + screen_display_t display = NULL; + screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void**)&display); + if (display != NULL) { + screen_get_display_property_iv(display, SCREEN_PROPERTY_ROTATION, &r); + parent->getLog()->debug("Current Display Rotation"); + parent->getLog()->debug(convertIntToString(r).c_str()); + } + screen_create_window_buffers(screen_win, 1); + screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); + screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); + // The screen (and backing buffer) don't take into account the rotation, so we need to swap the size. + if (r == 90 || r == 270) { + int swap = rect[2]; + rect[2] = rect[3]; + rect[3] = swap; + } + // Set the window size and the buffer follows along + screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, rect+2); + screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); + + parent->getLog()->debug("Screen Buffer Size:"); + parent->getLog()->debug(convertIntToString(rect[0]).c_str()); + parent->getLog()->debug(convertIntToString(rect[1]).c_str()); + parent->getLog()->debug(convertIntToString(rect[2]).c_str()); + parent->getLog()->debug(convertIntToString(rect[3]).c_str()); + + int type = -1; + screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_TYPE, &type); + parent->getLog()->debug("Window Type"); + parent->getLog()->debug(convertIntToString(type).c_str()); + + // fill the window with a flat colour + int attribs[] = { SCREEN_BLIT_COLOR, 0x00333333, SCREEN_BLIT_END }; + screen_fill(parent->windowContext, screen_buf, attribs); + screen_post_window(screen_win, screen_buf, 1, rect, 0); + // position the window at an arbitrary z-order + int i = 1; + screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &i); + screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &i); + parent->getLog()->debug("Current Zorder"); + parent->getLog()->debug(convertIntToString(i).c_str()); + int visible = 1; + screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &visible); + screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &visible); + parent->getLog()->debug("Visible?"); + parent->getLog()->debug(convertIntToString(visible).c_str()); + screen_flush_context(parent->windowContext, 0); + + parent->getLog()->debug("Created Background window"); + + if (parent->windowContext) { + if (BPS_SUCCESS == screen_request_events(parent->windowContext)) { + parent->getLog()->debug("Requested Events"); + } else { + parent->getLog()->error("Unable to request events"); + return NULL; + } + } + + screen_group_t group; + screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_GROUP, (void **)&group); + char* groupName = new char[256]; + screen_get_group_property_cv(group, SCREEN_PROPERTY_NAME, 256, groupName); + parent->getLog()->debug("Group Found"); + parent->getLog()->debug(groupName); + + // reset Touch value before starting up listening for touch events + touch = false; + + while(!parent->isThreadHalt()) { + MUTEX_LOCK(); + + int domain; + // Get the first event in the queue. + bps_event_t *event = NULL; + if (BPS_SUCCESS != bps_get_event(&event, 0)) { + parent->getLog()->warn("bps_get_event() failed"); + } + + // Handle all events in the queue. + while (event) { + if (touch) { + // HandleScreenEvent got a tap on the screen + // Shutdown the scanning + parent->cancelScan(); + break; + } + if (event) { + domain = bps_event_get_domain(event); + parent->getLog()->debug("BPS Event"); + if (domain == screen_get_domain()) { + parent->getLog()->debug("BPS Screen Event"); + parent->handleScreenEvent(event, parent->getLog(), parent->windowGroup); + } + } + if (BPS_SUCCESS != bps_get_event(&event, 0)) { + parent->getLog()->error("bps_get_event() failed"); +// return; + } + } + + MUTEX_UNLOCK(); + + // Poll at 10hz + usleep(100000); + } + // stop screen events on this thread + if(screen_stop_events(parent->windowContext) == -1) { + parent->getLog()->error("screen_stop_events failed"); + } + screen_destroy_window(screen_win); + return NULL; + } + + void BarcodeScannerNDK::handleScreenEvent(bps_event_t *event, Logger* log, const char* windowGroup) { + int eventType, objectType, eventProperty; + + screen_event_t screen_event = screen_event_get_event(event); + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType); + + switch (eventType) { + case SCREEN_EVENT_MTOUCH_RELEASE: + case SCREEN_EVENT_MTOUCH_TOUCH: + case SCREEN_EVENT_MTOUCH_MOVE: + log->info("Touch Event"); + touch = true; + break; + case SCREEN_EVENT_CREATE: + log->info("Screen Create Event"); + if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void **)&vf_win) == -1) { + log->error("screen_get_event_property_pv(SCREEN_PROPERTY_WINDOW)"); + } else { + log->info("viewfinder window found!"); + } + break; + case SCREEN_EVENT_IDLE: + log->debug("Screen Idle"); + break; + case SCREEN_EVENT_POST: + log->debug("Screen posted first frame"); + if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void **)&vf_win) == -1) { + log->error("screen_get_event_property_pv(SCREEN_PROPERTY_WINDOW)"); + } else { + interrogateWindow(vf_win, log); + int i = 100; + screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_ZORDER, &i); + screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_ZORDER, &i); + log->debug("Current Zorder"); + log->debug(convertIntToString(i).c_str()); + // make viewfinder window visible + i = 1; + screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_VISIBLE, &i); + screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_VISIBLE, &i); + log->debug("Visible?"); + log->debug(convertIntToString(i).c_str()); + // Rotate the window as needed + screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_ROTATION, &i); + log->debug("Current Rotation"); + log->debug(convertIntToString(i).c_str()); + i = 360 - vfRotation; + screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_ROTATION, &i); + screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_ROTATION, &i); + log->debug("Rotation"); + log->debug(convertIntToString(i).c_str()); + // Make full screen + screen_display_t display = NULL; + screen_get_window_property_pv(vf_win, SCREEN_PROPERTY_DISPLAY, (void **)&display); + if (display != NULL) { + log->debug("Found a Display"); + int size[2] = { 0, 0 }; + screen_get_display_property_iv(display, SCREEN_PROPERTY_SIZE, size); + log->debug("Display Size"); + log->debug(convertIntToString(size[0]).c_str()); + log->debug(convertIntToString(size[1]).c_str()); + int r = 0; + screen_get_display_property_iv(display, SCREEN_PROPERTY_ROTATION, &r); + log->debug("Current Display Rotation"); + log->debug(convertIntToString(r).c_str()); + if (r == 90 || r == 270) { + int swap = size[0]; + size[0] = size[1]; + size[1] = swap; + } + screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_SIZE, size); + screen_get_window_property_iv(vf_win, SCREEN_PROPERTY_SIZE, size); + log->debug("Window Size"); + log->debug(convertIntToString(size[0]).c_str()); + log->debug(convertIntToString(size[1]).c_str()); + } + + } + break; + case SCREEN_EVENT_CLOSE: + log->debug("Screen closed"); + break; + case SCREEN_EVENT_INPUT: + log->debug("Screen input event"); + break; + case SCREEN_EVENT_PROPERTY: + log->debug("Screen property event"); + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType); + log->debug("Object Type"); + log->debug(convertIntToString(objectType).c_str()); + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_NAME, &eventProperty); + log->debug("Property Name"); + log->debug(convertIntToString(eventProperty).c_str()); + break; + default: + log->warn("Unhandled Screen Event Type"); + log->warn(convertIntToString(eventType).c_str()); + break; + } + } + + bool BarcodeScannerNDK::StartEvents() { + if (!m_thread) { + threadHalt = false; + pthread_attr_t thread_attr; + pthread_attr_init(&thread_attr); + pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); + int error = pthread_create(&m_thread, &thread_attr, HandleEvents, static_cast(this)); + pthread_attr_destroy(&thread_attr); + if (error) { + m_pParent->getLog()->error("Thread Failed to start"); + m_thread = 0; + return false; + } else { + m_pParent->getLog()->info("Thread Started"); + MUTEX_LOCK(); + return true; + } + } + + return false; + } + + void BarcodeScannerNDK::StopEvents() { + if (m_thread) { + MUTEX_LOCK(); + threadHalt = true; + MUTEX_UNLOCK(); + m_pParent->getLog()->debug("BarcodeScannerNDK joining event thread"); + pthread_join(m_thread, NULL); + m_thread = 0; + m_pParent->getLog()->debug("BarcodeScannerNDK event thread stopped"); + } + } + + + // getter for the stop value + bool BarcodeScannerNDK::isThreadHalt() { + bool isThreadHalt; + MUTEX_LOCK(); + isThreadHalt = threadHalt; + MUTEX_UNLOCK(); + return isThreadHalt; + } + + void BarcodeScannerNDK::cancelScan() { + m_pParent->getLog()->warn("Cancel Scan"); + std::string event = "community.barcodescanner.codefound.native"; + std::string callbackId = cbId; + Json::FastWriter writer; + Json::Value root; + + // Scan cancelled by user + root["text"] = ""; + root["format"] = ""; + root["cancelled"] = true; + + m_pParent->NotifyEvent(callbackId + " " + event + " " + writer.write(root)); + } + + /* + * BarcodeScannerNDK::startRead + * + * This method is called to start a QR code read. A connection is opened to the device camera + * and the photo viewfinder is started. + */ + int BarcodeScannerNDK::startRead(const string &callbackId, const string &arg) { + std::string errorEvent = "community.barcodescanner.errorfound.native"; + Json::FastWriter writer; + Json::Value root; + + // Important for maintaining proper event queue support on 10.2.1 + bps_initialize(); + + std::string handle; + std::string group; + Json::Reader reader; + Json::Value input; + bool parse = reader.parse(arg, input); + + if (!parse) { + m_pParent->getLog()->error("Parse Error"); + Json::Value error; + root["state"] = "Parsing JSON object"; + root["error"] = "Cannot parse JSON object"; + root["description"] = ""; + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(error)); + return EIO; + } else { + handle = input["handle"].asString(); + group = input["group"].asString(); + } + + std::copy(callbackId.begin(), callbackId.end(), this->cbId); + this->cbId[callbackId.size()] = '\0'; + + this->windowHandle = handle; + m_pParent->getLog()->info("Window Handle"); + m_pParent->getLog()->info(handle.c_str()); + // the jsScreenWindowHandle of the UIWebView that we passed in + int windowPointer = (int) strtol(handle.c_str(), NULL, 10); + // As an integer is the actual window handle + screen_window_t window = (screen_window_t) windowPointer; + interrogateWindow(window, m_pParent->getLog()); + // Create a group for the main window + windowGroup = new char[group.length()+1]; + std::strcpy (windowGroup, group.c_str()); + m_pParent->getLog()->debug("Window Group using:"); + m_pParent->getLog()->debug(windowGroup); + + int getContext = screen_get_window_property_pv(window, SCREEN_PROPERTY_CONTEXT, (void **)&windowContext); + if (getContext == -1) { + m_pParent->getLog()->critical("Unable to get Context"); + root["state"] = "Get App Window Context"; + root["error"] = getContext; + root["description"] = "Unable to get application context"; + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); + return EIO; + } + + StartEvents(); + + camera_error_t err; + // Open the camera first before running any operations on it + err = camera_open(CAMERA_UNIT_REAR,CAMERA_MODE_RW | CAMERA_MODE_ROLL,&mCameraHandle); + + if ( err != CAMERA_EOK){ + m_pParent->getLog()->error("Ran into an issue when initializing the camera"); + m_pParent->getLog()->error(getCameraErrorDesc( err )); + root["state"] = "Open Camera"; + root["error"] = err; + root["description"] = getCameraErrorDesc( err ); + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); + return EIO; + } + + // We want maximum framerate from the viewfinder which will scan for codes + int numRates = 0; + err = camera_get_photo_vf_framerates(mCameraHandle, true, 0, &numRates, NULL, NULL); + double* camFramerates = new double[numRates]; + bool maxmin = false; + err = camera_get_photo_vf_framerates(mCameraHandle, true, numRates, &numRates, camFramerates, &maxmin); + + // do we need to rotate the viewfinder? + + err = camera_get_photovf_property(mCameraHandle, CAMERA_IMGPROP_ROTATION, &vfRotation); + m_pParent->getLog()->debug("Viewfinder Rotation"); + m_pParent->getLog()->debug(convertIntToString(vfRotation).c_str()); + + m_pParent->getLog()->debug("Camera Window Group"); + m_pParent->getLog()->debug(windowGroup); + // We're going to have the viewfinder window join our app's window group, and start an embedded window + err = camera_set_photovf_property(mCameraHandle, + CAMERA_IMGPROP_WIN_GROUPID, windowGroup, + CAMERA_IMGPROP_WIN_ID, "my_viewfinder"); + if ( err != CAMERA_EOK){ + m_pParent->getLog()->error("Ran into an issue when configuring the camera viewfinder"); + m_pParent->getLog()->error(getCameraErrorDesc( err )); + root["state"] = "Set VF Props"; + root["error"] = err; + root["description"] = getCameraErrorDesc( err ); + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); + return EIO; + } + + // Starting viewfinder up which will call the viewfinder callback - this gets the NV12 images for scanning + err = camera_start_photo_viewfinder( mCameraHandle, &viewfinder_callback, NULL, this->cbId); + if ( err != CAMERA_EOK) { + m_pParent->getLog()->error("Ran into a strange issue when starting up the camera viewfinder"); + m_pParent->getLog()->error(getCameraErrorDesc( err )); + root["state"] = "ViewFinder Start"; + root["error"] = err; + root["description"] = getCameraErrorDesc( err ); + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); + return EIO; + } + + // Focus mode can't be set until the viewfinder is started. We need Continuous Macro for barcodes + err = camera_set_focus_mode(mCameraHandle, CAMERA_FOCUSMODE_CONTINUOUS_MACRO); + if ( err != CAMERA_EOK){ + m_pParent->getLog()->error("Ran into an issue when setting focus mode"); + m_pParent->getLog()->error(getCameraErrorDesc( err )); + root["state"] = "Set Focus Mode"; + root["error"] = err; + root["description"] = getCameraErrorDesc( err ); + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); + return EIO; + } + + std::string successEvent = "community.barcodescanner.started.native"; + root["successful"] = true; + m_pParent->NotifyEvent(callbackId + " " + successEvent + " " + writer.write(root)); + return EOK; + } + + + /* + * BarcodeScannerNDK::stopRead + * + * This method is called to clean up following successful detection of a barcode. + * Calling this method will stop the viewfinder and close an open connection to the device camera. + */ + int BarcodeScannerNDK::stopRead(const string &callbackId) { + std::string errorEvent = "community.barcodescanner.errorfound.native"; + Json::FastWriter writer; + Json::Value root; + camera_error_t err; + + // Stop events first so that you don't get better response from the screen + StopEvents(); + + err = camera_stop_photo_viewfinder(mCameraHandle); + if ( err != CAMERA_EOK) + { + m_pParent->getLog()->error("Error with turning off the photo viewfinder"); + m_pParent->getLog()->error(getCameraErrorDesc( err )); + root["error"] = err; + root["description"] = getCameraErrorDesc( err ); + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); + return EIO; + } + + //check to see if the camera is open, if it is open, then close it + err = camera_close(mCameraHandle); + if ( err != CAMERA_EOK){ + m_pParent->getLog()->error("Error with closing the camera"); + m_pParent->getLog()->error(getCameraErrorDesc( err )); + root["error"] = err; + root["description"] = getCameraErrorDesc( err ); + m_pParent->NotifyEvent(callbackId + " " + errorEvent + " " + writer.write(root)); + return EIO; + } + + std::string successEvent = "community.barcodescanner.ended.native"; + root["successful"] = true; + mCameraHandle = CAMERA_HANDLE_INVALID; + m_pParent->NotifyEvent(callbackId + " " + successEvent + " " + writer.write(root)); + + // Important for maintaining proper event queue support on 10.2.1 + bps_shutdown(); + + return EOK; + } + +} diff --git a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.hpp b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.hpp index 9289f6a..0727fc1 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.hpp +++ b/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/src/barcodescanner_ndk.hpp @@ -1,55 +1,55 @@ -/* -* Copyright 2013-2015 BlackBerry Limited. -* -* 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. -*/ - -#ifndef BARCODESCANNERNDK_HPP_ -#define BARCODESCANNERNDK_HPP_ - -#include -#include "Logger.hpp" -#include -#include - -class BarcodeScannerJS; - -namespace webworks { - -class BarcodeScannerNDK { -public: - explicit BarcodeScannerNDK(BarcodeScannerJS *parent = NULL); - virtual ~BarcodeScannerNDK(); - - int startRead(const std::string& callbackId, const std::string& handle); - int stopRead(const std::string& callbackId); - bool isThreadHalt(); - void StopEvents(); - bool StartEvents(); - Logger* getLog(); - void handleScreenEvent(bps_event_t *event, Logger* log, const char* windowGroup); - void cancelScan(); - char* windowGroup; - screen_context_t windowContext; - char* cbId; - -private: - BarcodeScannerJS *m_pParent; - camera_handle_t mCameraHandle; - bool threadHalt; - std::string windowHandle; -}; - -} // namespace webworks - -#endif /* BARCODESCANNERNDK_H_ */ +/* +* Copyright 2013-2015 BlackBerry Limited. +* +* 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. +*/ + +#ifndef BARCODESCANNERNDK_HPP_ +#define BARCODESCANNERNDK_HPP_ + +#include +#include "Logger.hpp" +#include +#include + +class BarcodeScannerJS; + +namespace webworks { + +class BarcodeScannerNDK { +public: + explicit BarcodeScannerNDK(BarcodeScannerJS *parent = NULL); + virtual ~BarcodeScannerNDK(); + + int startRead(const std::string& callbackId, const std::string& handle); + int stopRead(const std::string& callbackId); + bool isThreadHalt(); + void StopEvents(); + bool StartEvents(); + Logger* getLog(); + void handleScreenEvent(bps_event_t *event, Logger* log, const char* windowGroup); + void cancelScan(); + char* windowGroup; + screen_context_t windowContext; + char* cbId; + +private: + BarcodeScannerJS *m_pParent; + camera_handle_t mCameraHandle; + bool threadHalt; + std::string windowHandle; +}; + +} // namespace webworks + +#endif /* BARCODESCANNERNDK_H_ */ diff --git a/plugins/phonegap-plugin-barcodescanner/src/windows/BarcodeScannerProxy.js b/plugins/phonegap-plugin-barcodescanner/src/windows/BarcodeScannerProxy.js index ac070f0..efd3bba 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/windows/BarcodeScannerProxy.js +++ b/plugins/phonegap-plugin-barcodescanner/src/windows/BarcodeScannerProxy.js @@ -57,7 +57,7 @@ function findCamera() { } var backCameras = cameras.filter(function (camera) { - return camera.enclosureLocation.panel === Devices.Panel.back; + return camera.enclosureLocation && camera.enclosureLocation.panel === Devices.Panel.back; }); // If there is back cameras, return the id of the first, @@ -230,20 +230,20 @@ module.exports = { return; } - var rotGUID = "{0xC380465D, 0x2271, 0x428C, {0x9B, 0x83, 0xEC, 0xEA, 0x3B, 0x4A, 0x85, 0xC1}}"; + var ROTATION_KEY = "C380465D-2271-428C-9B83-ECEA3B4A85C1"; var displayInformation = (evt && evt.target) || Windows.Graphics.Display.DisplayInformation.getForCurrentView(); var currentOrientation = displayInformation.currentOrientation; previewMirroring = capture.getPreviewMirroring(); - // Lookup up the rotation degrees. + // Lookup up the rotation degrees. var rotDegree = videoPreviewRotationLookup(currentOrientation, previewMirroring); // rotate the preview video - var videoEncodingProperties = capture.videoDeviceController.getMediaStreamProperties(Windows.Media.Capture.MediaStreamType.VideoPreview); - videoEncodingProperties.properties.insert(rotGUID, rotDegree); - capture.setEncodingPropertiesAsync(Windows.Media.Capture.MediaStreamType.VideoPreview, videoEncodingProperties, null); + var videoEncodingProperties = capture.videoDeviceController.getMediaStreamProperties(Windows.Media.Capture.MediaStreamType.videoPreview); + videoEncodingProperties.properties.insert(ROTATION_KEY, rotDegree); + return capture.videoDeviceController.setMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.videoPreview, videoEncodingProperties); } /** diff --git a/plugins/phonegap-plugin-barcodescanner/src/windows/assets/plugin-barcodeScanner.css b/plugins/phonegap-plugin-barcodescanner/src/windows/assets/plugin-barcodeScanner.css index f58b731..3d25884 100644 --- a/plugins/phonegap-plugin-barcodescanner/src/windows/assets/plugin-barcodeScanner.css +++ b/plugins/phonegap-plugin-barcodescanner/src/windows/assets/plugin-barcodeScanner.css @@ -1,74 +1,74 @@ -.barcode-scanner-wrap { - margin: 0; - padding: 0; - outline: 0; - font-size: 100%; - vertical-align: baseline; - background: 0 0 black; - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 9999999; -} - -.barcode-scanner-preview { - width: 100%; - height: calc(100% - 70px); -} - -.barcode-scanner-mark { - position: absolute; - left: 0; - top: 50%; - width: 100%; - height: 3px; - background: red; - z-index: 9999999; -} - -.barcode-scanner-app-bar { - height: 70px; - width: 100%; - padding-top: 10px; - z-index: 9999999; - text-align: center; - user-select: none; -} - -.app-bar-action { - width: 40px; - height: 40px; - margin: 0 auto; - font-family: "Segoe UI Symbol"; - color: white; - font-size: 12px; - text-transform: lowercase; - text-align: center; - cursor: default; -} - -@media all and (orientation: landscape) { - .app-bar-action { - float: right; - margin-right: 20px; - } -} - -.app-bar-action::before { - font-size: 28px; - display: block; - height: 36px; -} - -.action-close::before { - content: "\E0C7"; - /* close icon is larger so we re-size it to fit other icons */ - font-size: 20px; - line-height: 40px; -} - -.action-close:hover::before { - content: "\E0CA"; -} +.barcode-scanner-wrap { + margin: 0; + padding: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: 0 0 black; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 9999999; +} + +.barcode-scanner-preview { + width: 100%; + height: calc(100% - 70px); +} + +.barcode-scanner-mark { + position: absolute; + left: 0; + top: 50%; + width: 100%; + height: 3px; + background: red; + z-index: 9999999; +} + +.barcode-scanner-app-bar { + height: 70px; + width: 100%; + padding-top: 10px; + z-index: 9999999; + text-align: center; + user-select: none; +} + +.app-bar-action { + width: 40px; + height: 40px; + margin: 0 auto; + font-family: "Segoe UI Symbol"; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; +} + +@media all and (orientation: landscape) { + .app-bar-action { + float: right; + margin-right: 20px; + } +} + +.app-bar-action::before { + font-size: 28px; + display: block; + height: 36px; +} + +.action-close::before { + content: "\E0C7"; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; +} + +.action-close:hover::before { + content: "\E0CA"; +} diff --git a/www/css/main.css b/www/css/main.css index 468f96c..91dbb61 100644 --- a/www/css/main.css +++ b/www/css/main.css @@ -69,7 +69,7 @@ body { top: 0; left: 0; width: 100%; - height: 20%; + height: auto; z-index: 9500; } @@ -167,9 +167,10 @@ body { position: absolute; bottom: 0px; left: 0px; - height: 50%; + height: auto !important; max-height: 50%; width: 100%; + z-index: 9501; } #chatmsgs { diff --git a/www/index.html b/www/index.html index 5846f9c..13899f6 100644 --- a/www/index.html +++ b/www/index.html @@ -9,7 +9,10 @@ - + TerranQuest @@ -28,6 +31,15 @@ + + + + + + + + + @@ -39,12 +51,6 @@
- - - - - - diff --git a/www/js/auth.js b/www/js/auth.js index 1690630..344b93e 100644 --- a/www/js/auth.js +++ b/www/js/auth.js @@ -4,6 +4,19 @@ var authOpInProgress = false; +function askLogout() { + navigator.notification.confirm( + 'Do you really want to logout?', // message + function (btn) { + if (btn === 1) { + logout(); + } + }, + 'Logout?', + ['Logout', 'Cancel'] + ); +} + function logout() { localStorage.setItem("username", ''); localStorage.setItem("password", ''); @@ -97,6 +110,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: " + out.message); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; } }).fail(function (err) { @@ -104,6 +118,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: Login OK, but cannot connect to game server. Try again later."); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; }); } else { @@ -111,6 +126,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text(data); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); } authOpInProgress = false; }).fail(function () { @@ -118,6 +134,7 @@ function dologin() { $('#loginBtn').attr('disabled', false); $('#errormsg').text("Error: Network failure."); $('#errorbase').css('display', 'block'); + $('#loading').css('display', 'none'); authOpInProgress = false; }); } diff --git a/www/js/home.js b/www/js/home.js index 15faf2f..8f5f6c2 100644 --- a/www/js/home.js +++ b/www/js/home.js @@ -64,23 +64,23 @@ var lc = L.control.locate({ }, locateOptions: {} // define location options e.g enableHighAccuracy: true or maxZoom: 10 }).addTo(map); -map.addLayer(new L.tileLayer(tileurl, {minZoom: 17, maxZoom: 17})); +map.addLayer(new L.tileLayer(tileurl, {minZoom: 17, maxZoom: 18})); // GeoJSON layer var placeLayer = L.geoJson( {"name": "Places", "type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [0, 0]}, "properties": {"osm_id": -1, "name": null}}]}, -{ - onEachFeature: onPlaceTap, - pointToLayer: function (feature, latlng) { - return L.circleMarker(latlng, { - radius: 8, - fillColor: "#ff7800", - color: "#000", - weight: 1, - opacity: 1, - fillOpacity: 0.8 - }); - } -}).addTo(map); + { + onEachFeature: onPlaceTap, + pointToLayer: function (feature, latlng) { + return L.circleMarker(latlng, { + radius: 14, + fillColor: "#ff7800", + color: "#000", + weight: 1, + opacity: 1, + fillOpacity: 0.6 + }); + } + }).addTo(map); lc.start(); function mapPos(lat, lon) { lockGot = true; @@ -291,9 +291,11 @@ function toggleChat() { function closeChat() { $('#chatmsgs').css('display', 'none'); + $('.chatbox').css('height', 'auto'); } function openChat() { + $('.chatbox').css('height', '50%'); $('#chatmsgs').css('display', 'block'); $("#chatmsgs").animate({scrollTop: $('#chatmsgs').prop("scrollHeight")}, 1000); } diff --git a/www/screens/home.html b/www/screens/home.html index ad6f529..0213329 100644 --- a/www/screens/home.html +++ b/www/screens/home.html @@ -1,57 +1,57 @@ -
-
- -

- Acquiring Location... -
-
-

-
-
-
- -
-

GPS location inaccurate. -
-
- Waiting for better accuracy...

-
- - - -
-

-
-
-
-
-

Energy

- -
- -
-
- Menu -
-
- -
-
-
-
-
-
-
- -
-
-
-
- +
+
+ +

+ Acquiring Location... +
+
+

+
+
+
+ +
+

GPS location inaccurate. +
+
+ Waiting for better accuracy...

+
+ + + +
+

+
+
+
+
+

Energy

+ +
+ +
+
+ Menu +
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/www/screens/login.html b/www/screens/login.html index 3d75bd1..13a7a25 100644 --- a/www/screens/login.html +++ b/www/screens/login.html @@ -1,68 +1,69 @@ -
-
- -

- Logging in... -
-
-

-
-
-
-
-
-
-
- Login to TerranQuest -
-
- -
- - -
-
-
- - -
-
- -
-
-
- - \ No newline at end of file +
+
+ +

+ Logging in... +
+
+

+
+
+
+
+
+
+
+ Login to TerranQuest +
+
+ +
+ + +
+
+
+ + +
+
+ +
+
+
+ \ No newline at end of file diff --git a/www/screens/place.html b/www/screens/place.html index 1bd2dd2..5c993a1 100644 --- a/www/screens/place.html +++ b/www/screens/place.html @@ -1,9 +1,9 @@ -
-
-
- - \ No newline at end of file diff --git a/www/screens/settings.html b/www/screens/settings.html index b370c7d..c8d4efa 100644 --- a/www/screens/settings.html +++ b/www/screens/settings.html @@ -1,26 +1,26 @@ -
-
-
- Logout from app -
-
-

- Third-Party Licenses -
- Map tiles by Stamen Design (stamen.com), under CC BY 3.0 (creativecommons.org/licenses/by/3.0). -
- Map tile data by OpenStreetMap (openstreetmap.org), under CC BY-SA (creativecommons.org/licenses/by-sa/3.0). -
- Places from OpenStreetMap and contributers, licensed under the ODbL (opendatacommons.org/licenses/odbl). Email apis@netsyms.com for free access to our API. -
- Map display is powered by Leaflet (leafletjs.com), copyright (c) 2010-2016, Vladimir Agafonkin and copyright (c) 2010-2011, CloudMade. BSD 2-clause license. -
- Terrain information for the United States from the MRLC National Land Cover Database 2011 (mrlc.gov). -
- Weather data Powered by Forecast (forecast.io). -
- Geocache data from the OpenCaching.US OKAPI. Data licensed under the CC BY-NC-SA 2.5 (creativecommons.org/licenses/by-nc-sa/2.5). -

-
-
+
+
+
+ Logout from app +
+
+

+ Third-Party Licenses +
+ Map tiles by Stamen Design (stamen.com), under CC BY 3.0 (creativecommons.org/licenses/by/3.0). +
+ Map tile data by OpenStreetMap (openstreetmap.org), under CC BY-SA (creativecommons.org/licenses/by-sa/3.0). +
+ Places from OpenStreetMap and contributers, licensed under the ODbL (opendatacommons.org/licenses/odbl). Email apis@netsyms.com for free access to our API. +
+ Map display is powered by Leaflet (leafletjs.com), copyright (c) 2010-2016, Vladimir Agafonkin and copyright (c) 2010-2011, CloudMade. BSD 2-clause license. +
+ Terrain information for the United States from the MRLC National Land Cover Database 2011 (mrlc.gov). +
+ Weather data Powered by Forecast (forecast.io). +
+ Geocache data from the OpenCaching.US OKAPI. Data licensed under the CC BY-NC-SA 2.5 (creativecommons.org/licenses/by-nc-sa/2.5). +

+
+
\ No newline at end of file