Skip to content
This repository has been archived by the owner on Mar 27, 2020. It is now read-only.

resolve issue with conflicting provider path & potential build error #68

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 39 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
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.

<img src="https://raw.githubusercontent.com/disusered/cordova-open/docs/open.png" width="300px" />

## 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 {
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 17 additions & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-open" version="1.1.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-open" version="1.2.0">
<name>Open</name>
<description>Open audio, video, images and more with applications installed on the user's device</description>
<license>MIT</license>
Expand All @@ -10,18 +10,29 @@
<merges target="cordova.plugins.disusered"/>
</js-module>
<platform name="android">

<preference name="ANDROIDX_CORE_VERSION" default="1.6.+"/>
<framework src="androidx.core:core:$ANDROIDX_CORE_VERSION" />

<config-file parent="/*" target="res/xml/config.xml">
<feature name="Open">
<param name="android-package" value="com.disusered.Open"/>
</feature>
</config-file>
<config-file parent="/manifest/application" target="AndroidManifest.xml">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
<provider
android:name="com.disusered.cordova.open.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/open_provider_paths"/>
</provider>
</config-file>
<source-file src="src/android/Open.java" target-dir="src/com/disusered"/>
<source-file src="src/android/provider_paths.xml" target-dir="res/xml"/>
<source-file src="src/android/FileProvider.java" target-dir="src/com/disusered"/>
<source-file src="src/android/open_provider_paths.xml" target-dir="res/xml"/>
</platform>
<platform name="ios">
<config-file parent="/*" target="config.xml">
Expand All @@ -34,6 +45,6 @@
<source-file src="src/ios/Open.m"/>
<header-file src="src/ios/Open.h"/>
</platform>
<dependency id="cordova-plugin-file"/>
<dependency id="cordova-plugin-file-transfer"/>
<dependency id="cordova-plugin-file" version="4.3.3"/>
<dependency id="cordova-plugin-file-transfer" url="https://github.com/remoorejr/cordova-plugin-file-transfer" version="1.5.2"/>
</plugin>
4 changes: 4 additions & 0 deletions src/android/FileProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.disusered.cordova.open;

public class FileProvider extends androidx.core.content.FileProvider {}

2 changes: 1 addition & 1 deletion src/android/Open.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down