Skip to content

Commit

Permalink
update to verion 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa-mansour1 committed Jan 18, 2020
1 parent 5acdd8a commit 821d3e0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ the file path in android must be absolute path to the file starting with file:https://
```
$ cordova plugin add cordova-plugin-preview-any-file --save
```
for ionic projects
```
$ ionic cordova plugin add cordova-plugin-preview-any-file --save
```

## Usage

Expand Down Expand Up @@ -81,25 +85,25 @@ you can use external link, the preview will not opened until the file downloaded
});
```

for ionic projects declare the plugin in the top of file

```
declare var PreviewAnyFile: any;
```

## Supported platforms
- Android
- iOS

## Change Log

-- version 0.1.5
* (Android) Temporary fix for the issue that file not opened in SDK > 28

-- version 0.1.4
- (Android) fix issue getting the file extension
* (Android) fix issue getting the file extension

-- version 0.1.3

- (IOS) fix issue when provide a path of the file not the url , now it accept path that start with "/" or url start with "file:https://"
- (IOS) fix issue if open external link more then one time
- (IOS, Android) fix call back
* (IOS) fix issue when provide a path of the file not the url , now it accept path that start with "/" or url start with "file:https://"
* (IOS) fix issue if open external link more then one time
* (IOS, Android) fix call back

-- version 0.1.2
* update readme to add documentation
Expand All @@ -111,5 +115,5 @@ declare var PreviewAnyFile: any;
* cannot open https url in android

## TO DO
* add ionic wrapper
* support to view base64 string directly
* add ionic wrapper [(Done)](https://ionicframework.com/docs/native/preview-any-file)
* support to view base64 string directly (Working on it)
13 changes: 13 additions & 0 deletions src/android/PreviewAnyFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

import java.net.URLEncoder;

import android.os.Build;
import java.lang.reflect.Method;
import android.os.StrictMode;

public class PreviewAnyFile extends CordovaPlugin {

private CallbackContext callbackContext; // The callback context from which we were invoked.
Expand All @@ -37,6 +41,15 @@ private void presentFile(Intent intent, Uri uri, String type) {

private void viewFile(String url, CallbackContext callbackContext) {

if (Build.VERSION.SDK_INT >= 24) {
try {
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}

boolean file_presented = false;
String error = null;

Expand Down

0 comments on commit 821d3e0

Please sign in to comment.