diff --git a/README.md b/README.md index aa815bd..77371fe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -cordova-open -==== +# cordova-open -[![Build Status](https://travis-ci.org/disusered/cordova-open.svg)](https://travis-ci.org/disusered/cordova-open) [![Code Climate](https://codeclimate.com/github/disusered/cordova-open/badges/gpa.svg)](https://codeclimate.com/github/disusered/cordova-open) +[![Build Status](https://travis-ci.org/disusered/cordova-open.svg)](https://travis-ci.org/disusered/cordova-open) [![Code Climate](https://codeclimate.com/github/disusered/cordova-open/badges/gpa.svg)](https://codeclimate.com/github/disusered/cordova-open) > Open audio, video, images and more with applications installed on the user's device. @@ -9,30 +8,36 @@ cordova-open ## Install +This version or the Cordova Open Plugin must be installed from the Github Repo listed below. + ```bash -$ cordova plugin add cordova-open +$ cordova plugin add https://github.com/remoorejr/cordova-open.git ``` +## Features + +- This version uses the newer AndroidX libraries for compatibility with the latest versions of Android. + ## Usage ```javascript var open = cordova.plugins.disusered.open; function success() { - console.log('Success'); + console.log("Success"); } function error(code) { if (code === 1) { - console.log('No file handler found'); + console.log("No file handler found"); } else { - console.log('Undefined error'); + console.log("Undefined error"); } } function progress(progressEvent) { if (progressEvent.lengthComputable) { - var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100); + var perc = Math.floor((progressEvent.loaded / progressEvent.total) * 100); // update UI with status, for example: // statusDom.innerHTML = perc + "% loaded..."; } else { @@ -45,30 +50,44 @@ function progress(progressEvent) { } */ } -}; +} -open('file:/storage/sdcard/DCIM/Camera/1404177327783.jpg', success, error, progress); +open( + "file:/storage/sdcard/DCIM/Camera/1404177327783.jpg", + success, + error, + progress +); ``` ## API + The plugin exposes the following methods: ```javascript -cordova.plugins.disusered.open(file, success, error, progress, trustAllCertificates) +cordova.plugins.disusered.open( + file, + success, + error, + progress, + trustAllCertificates +); ``` #### Parameters: -* __file:__ A string representing a URI -* __success:__ Optional success callback -* __error:__ Optional error callback -* __progress:__ Optional progress callback -* __trustAllCertificates:__ Optional, trusts any certificate when the connection is done over HTTPS. + +- **file:** A string representing a URI +- **success:** Optional success callback +- **error:** Optional error callback +- **progress:** Optional progress callback +- **trustAllCertificates:** Optional, trusts any certificate when the connection is done over HTTPS. #### Events: -* __pause:__ Opening files emits Cordova's pause event (Android only) -* __resume:__ Closing the file emits Cordova's resume event -* __open.success:__ File is found and can be opened -* __open.error:__ File not found, or no file handler is installed + +- **pause:** Opening files emits Cordova's pause event (Android only) +- **resume:** Closing the file emits Cordova's resume event +- **open.success:** File is found and can be opened +- **open.error:** File not found, or no file handler is installed ## License diff --git a/package.json b/package.json index ae14a16..e15e6c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-open", - "version": "1.1.0", + "version": "1.2.0", "description": "Open audio, video, images and more with applications installed on the user's device", "cordova": { "id": "com.disusered.open", diff --git a/plugin.xml b/plugin.xml index 7518434..da98583 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + Open Open audio, video, images and more with applications installed on the user's device MIT @@ -10,18 +10,29 @@ + + + + - - + + - + + @@ -34,6 +45,6 @@ - - + + diff --git a/src/android/FileProvider.java b/src/android/FileProvider.java new file mode 100644 index 0000000..951dc28 --- /dev/null +++ b/src/android/FileProvider.java @@ -0,0 +1,4 @@ +package com.disusered.cordova.open; + +public class FileProvider extends androidx.core.content.FileProvider {} + diff --git a/src/android/Open.java b/src/android/Open.java index 8a30c19..3e24843 100644 --- a/src/android/Open.java +++ b/src/android/Open.java @@ -9,7 +9,7 @@ import android.content.Context; import android.net.Uri; import android.content.Intent; -import android.support.v4.content.FileProvider; +import androidx.core.content.FileProvider; import android.webkit.MimeTypeMap; import android.content.ActivityNotFoundException; import android.os.Build; diff --git a/src/android/provider_paths.xml b/src/android/open_provider_paths.xml similarity index 100% rename from src/android/provider_paths.xml rename to src/android/open_provider_paths.xml