[GitHub] cordova-plugin-file-transfer pull request: added link to sample
Github user Mikejo5000 closed the pull request at: https://github.com/apache/cordova-plugin-file-transfer/pull/145 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-file pull request: minor edits
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-file/pull/180 minor edits You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-file master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-file/pull/180.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #180 commit 7f44303cf914bcfaf903a9fdab7522289dc0b99a Author: Mikejo5001 Date: 2016-05-03T18:57:20Z minor edits --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-file-transfer pull request: added link to sample
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-file-transfer/pull/145 added link to sample You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-file-transfer master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-file-transfer/pull/145.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #145 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-camera pull request: fixed some bad formatting that...
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-camera/pull/207 fixed some bad formatting that hid HTML tags You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-camera master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-camera/pull/207.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #207 commit 088c03323a75fea45a71b17548a5673dbf67f01d Author: Mikejo5001 Date: 2016-04-26T20:30:38Z fixed some bad formatting that hid HTML tags --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-network-information pull request: added code exampl...
Github user Mikejo5000 commented on a diff in the pull request: https://github.com/apache/cordova-plugin-network-information/pull/40#discussion_r60999738 --- Diff: README.md --- @@ -210,4 +210,120 @@ When running in the Emulator, the `connection.status` is always unknown, so this The Emulator reports the connection type as `Cellular`, which does not change, so events does _not_ fire. +## Sample: Upload a File Depending on your Network State + +The code examples in this section show examples of changing app behavior using the online and offline events and your network connection status. + +To start with, create a new FileEntry object (data.txt) to use for sample data. Call this function from the `deviceready` handler. + +>*Note* This code example requires the File plugin. + +```js + +var dataFileEntry; + +function createSomeData() { + +window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs) { + +console.log('file system open: ' + fs.name); +// Creates a new file or returns an existing file. +fs.root.getFile("data.txt", { create: true, exclusive: false }, function (fileEntry) { + + dataFileEntry = fileEntry; + +}, onErrorCreateFile); + +}, onErrorLoadFs); +} +``` + +Next, add listeners for the online and offline events in the `deviceready` handler. + +```js +document.addEventListener("offline", onOffline, false); +document.addEventListener("online", onOnline, false); +``` + +The app's `onOnline` function handles the online event. In the event handler, check the current network state. In this app, treat any connection type as good except Connection.NONE. If you have a connection, you try to upload a file. + +```js +function onOnline() { +// Handle the online event +var networkState = navigator.connection.type; + +if (networkState !== Connection.NONE) { +if (dataFileEntry) { +tryToUploadFile(); +} +} +display('Connection type: ' + networkState); +} +``` + +When the online event fires in the preceding code, call the app's `tryToUploadFile` function. + +If the FileTransfer object's upload function fails, call the app's `offlineWrite` function to save the current data somewhere. + +>*Note* This example requires the FileTransfer plugin. + +```js +function tryToUploadFile() { +// !! Assumes variable fileURL contains a valid URL to a text file on the device, +var fileURL = getDataFileEntry().toURL(); + +var success = function (r) { +console.log("Response = " + r.response); +display("Uploaded. Response: " + r.response); +} + +var fail = function (error) { +console.log("An error has occurred: Code = " + error.code); +offlineWrite("Failed to upload: some offline data"); +} + +var options = new FileUploadOptions(); +options.fileKey = "file"; +options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); +options.mimeType = "text/plain"; + +var ft = new FileTransfer(); +// Make sure you add the domain of your server URL to the +// Content-Security-Policy element in index.html. +ft.upload(fileURL, encodeURI(SERVER), success, fail, options); +}; +``` + +In addition to calling `offlineWrite` from the error handler for the upload function, you also call the same `offlineWrite` function from the app's offline event handler. + +```js +function onOffline() { --- End diff -- Yes, that is what I had in mind for offlineWrite; some in-memory data of some kind gets written when you go offline. But yes, really you could write to the file anytime so this does seem too contrived... I could add a timestamp to the file when you go offline (following your suggestion), either that or maybe it's best that I remove the offline event handler completely for this scenario. Any preference or other suggestion? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-network-information pull request: added code exampl...
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-network-information/pull/40 added code examples You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-network-information master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-network-information/pull/40.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #40 commit 35e2d3ba8336f66b898ecf1e816282766de2fab2 Author: Mikejo5001 Date: 2016-04-13T22:42:11Z added code examples --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-camera pull request: Added Sample section to the Ca...
Github user Mikejo5000 commented on a diff in the pull request: https://github.com/apache/cordova-plugin-camera/pull/203#discussion_r59604648 --- Diff: jsdoc2md/TEMPLATE.md --- @@ -203,3 +203,194 @@ Tizen only supports a `destinationType` of [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 + +## Sample: Take Pictures, Select Pictures from the Picture Library, and Get Thumbnails + +The Camera plugin allows you to do things like open the device's Camera app and take a picture, or open the file picker and select one. The code snippets in this section demonstrate different tasks including: + +* Open the Camera app and [take a Picture](#takePicture) +* Take a picture and [return thumbnails](#getThumbnails) (resized picture) +* Take a picture and [generate a FileEntry object](#convert) +* [Select a file](#selectFile) from the picture library +* Select a JPEG image and [return thumbnails](#getFileThumbnails) (resized image) +* Select an image and [generate a FileEntry object](#convert) + +## Take a Picture + +Before you can take a picture, you need to set some Camera plugin options to pass into the Camera plugin's `getPicture` function. Here is a common set of recommendations. In this example, you create the object that you will use for the Camera options, and set the `sourceType` dynamically to support both the Camera app and the file picker. + +```js +function setOptions(srcType) { +var options = { +// Some common settings are 20, 50, and 100 +quality: 50, +destinationType: Camera.DestinationType.FILE_URI, +// In this app, dynamically set the picture source, Camera or photo gallery +sourceType: srcType, +encodingType: Camera.EncodingType.JPEG, +mediaType: Camera.MediaType.PICTURE, +allowEdit: true, +correctOrientation: true //Corrects Android orientation quirks +} +return options; +} +``` + +Typically, you want to use a FILE_URI instead of a DATA_URL to avoid most memory issues. JPEG is the recommended encoding type for Android. + +You take a picture by passing in the options object to `getPicture`, which takes a CameraOptions object as the third argument. When you call `setOptions`, pass `Camera.PictureSourceType.CAMERA` as the picture source. + +```js +function openCamera(selection) { + +var srcType = Camera.PictureSourceType.CAMERA; +var options = setOptions(srcType); +var func = copyToFile; + +navigator.camera.getPicture(function cameraSuccess(imageUri) { + +displayImage(imageUri); +// You may choose to copy the picture, save it somewhere, or upload. +func(imageUri); + +}, function cameraError(error) { +console.debug("Unable to obtain picture: " + error, "app"); + +}, options); +} +``` + +Once you take the picture, you can display it or do something else. In this example, call the app's `displayImage` function from the preceding code. + +```js +function displayImage(imgUri) { + +var elem = document.getElementById('imageFile'); +elem.src = imgUri; +} +``` + +## Take a Picture and Return Thumbnails (Resize the Picture) + +To get smaller images, you can return a resized image by passing both `targetHeight` and `targetWidth` values with your CameraOptions object. In this example, you resize the returned image to fit in a 100px by 100px box (the aspect ratio is maintained, so 100px is either the height or width, whichever is greater in the source). + +```js +function openCamera(selection) { + +var srcType = Camera.PictureSourceType.CAMERA; +var options = setOptions(srcType); +var func = copyToFile; + +if (selection == "camera-thmb") { +options.targetHeight = 100; +options.targetWidth = 100; +} + +navigator.camera.getPicture(function cameraSuccess(imageUri) { + +// Do something + +}, function cameraError(error) { +console.debug("Unable to obtain picture: " + error, "app"); + +}, options); +} +``` + +## Select a File from the Picture Library + +When selecting a file using the file picker, you also need to set the CameraOptions object. In this example, set the `sourceType` to `Camera.PictureSourceType.SAVEDPHOTOALBUM`. To open the file picker, call `getPicture` just as you did in the previous example,
[GitHub] cordova-plugin-camera pull request: Added Sample section to the Ca...
Github user Mikejo5000 commented on a diff in the pull request: https://github.com/apache/cordova-plugin-camera/pull/203#discussion_r59600615 --- Diff: jsdoc2md/TEMPLATE.md --- @@ -203,3 +203,194 @@ Tizen only supports a `destinationType` of [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 + +## Sample: Take Pictures, Select Pictures from the Picture Library, and Get Thumbnails + +The Camera plugin allows you to do things like open the device's Camera app and take a picture, or open the file picker and select one. The code snippets in this section demonstrate different tasks including: + +* Open the Camera app and [take a Picture](#takePicture) +* Take a picture and [return thumbnails](#getThumbnails) (resized picture) +* Take a picture and [generate a FileEntry object](#convert) +* [Select a file](#selectFile) from the picture library +* Select a JPEG image and [return thumbnails](#getFileThumbnails) (resized image) +* Select an image and [generate a FileEntry object](#convert) + +## Take a Picture + +Before you can take a picture, you need to set some Camera plugin options to pass into the Camera plugin's `getPicture` function. Here is a common set of recommendations. In this example, you create the object that you will use for the Camera options, and set the `sourceType` dynamically to support both the Camera app and the file picker. + +```js +function setOptions(srcType) { +var options = { +// Some common settings are 20, 50, and 100 +quality: 50, +destinationType: Camera.DestinationType.FILE_URI, +// In this app, dynamically set the picture source, Camera or photo gallery +sourceType: srcType, +encodingType: Camera.EncodingType.JPEG, +mediaType: Camera.MediaType.PICTURE, +allowEdit: true, +correctOrientation: true //Corrects Android orientation quirks +} +return options; +} +``` + +Typically, you want to use a FILE_URI instead of a DATA_URL to avoid most memory issues. JPEG is the recommended encoding type for Android. + +You take a picture by passing in the options object to `getPicture`, which takes a CameraOptions object as the third argument. When you call `setOptions`, pass `Camera.PictureSourceType.CAMERA` as the picture source. + +```js +function openCamera(selection) { + +var srcType = Camera.PictureSourceType.CAMERA; +var options = setOptions(srcType); +var func = copyToFile; + +navigator.camera.getPicture(function cameraSuccess(imageUri) { + +displayImage(imageUri); +// You may choose to copy the picture, save it somewhere, or upload. +func(imageUri); + +}, function cameraError(error) { +console.debug("Unable to obtain picture: " + error, "app"); + +}, options); +} +``` + +Once you take the picture, you can display it or do something else. In this example, call the app's `displayImage` function from the preceding code. + +```js +function displayImage(imgUri) { + +var elem = document.getElementById('imageFile'); +elem.src = imgUri; +} +``` + +## Take a Picture and Return Thumbnails (Resize the Picture) + +To get smaller images, you can return a resized image by passing both `targetHeight` and `targetWidth` values with your CameraOptions object. In this example, you resize the returned image to fit in a 100px by 100px box (the aspect ratio is maintained, so 100px is either the height or width, whichever is greater in the source). + +```js +function openCamera(selection) { + +var srcType = Camera.PictureSourceType.CAMERA; +var options = setOptions(srcType); +var func = copyToFile; + +if (selection == "camera-thmb") { +options.targetHeight = 100; +options.targetWidth = 100; +} + +navigator.camera.getPicture(function cameraSuccess(imageUri) { + +// Do something + +}, function cameraError(error) { +console.debug("Unable to obtain picture: " + error, "app"); + +}, options); +} +``` + +## Select a File from the Picture Library + +When selecting a file using the file picker, you also need to set the CameraOptions object. In this example, set the `sourceType` to `Camera.PictureSourceType.SAVEDPHOTOALBUM`. To open the file picker, call `getPicture` just as you did in the previous example,
[GitHub] cordova-plugin-camera pull request: Added Sample section to the Ca...
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-camera/pull/203 Added Sample section to the Camera plugin README You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-camera master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-camera/pull/203.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #203 commit 0d1ecf74973a3aa3bd4171a9726b4ee53277b6ff Author: Mikejo5001 Date: 2016-04-08T22:38:19Z Added Sample section to the Camera plugin README --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-file pull request: adding sample section to readme
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-file/pull/176 adding sample section to readme removed link to current complete sample, related edits You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-file master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-file/pull/176.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #176 commit 2cf6527ec83286e5c8aaa19a055dedc8e53af354 Author: Mikejo5001 Date: 2016-03-29T00:22:49Z readme updates with samples commit ebe57fe3780812d5ce3e5b38423f0c0ac3269ea5 Author: Mikejo5001 Date: 2016-03-29T00:31:01Z readme edits commit 96af5b056357e827d5ec4307af67a714498d5ee5 Author: Mikejo5001 Date: 2016-04-01T21:17:15Z readme updates --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-file pull request: readme updates with samples
Github user Mikejo5000 closed the pull request at: https://github.com/apache/cordova-plugin-file/pull/175 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-file-transfer pull request: adding sample section t...
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-file-transfer/pull/136 adding sample section to readme You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-file-transfer master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-file-transfer/pull/136.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #136 commit 013a3b60a20e03e69b7403c355033397453df870 Author: Mikejo5001 Date: 2016-04-01T21:04:31Z adding sample section to readme --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org
[GitHub] cordova-plugin-file pull request: readme updates with samples
GitHub user Mikejo5000 opened a pull request: https://github.com/apache/cordova-plugin-file/pull/175 readme updates with samples You can merge this pull request into a Git repository by running: $ git pull https://github.com/Mikejo5000/cordova-plugin-file master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-file/pull/175.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #175 commit 2cf6527ec83286e5c8aaa19a055dedc8e53af354 Author: Mikejo5001 Date: 2016-03-29T00:22:49Z readme updates with samples --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org