You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/06/29 19:11:03 UTC

[GitHub] [cordova-plugin-inappbrowser] shaikh-amaan-fm opened a new pull request #743: Added download event

shaikh-amaan-fm opened a new pull request #743:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/743


   <!--
   Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
   
   http://cordova.apache.org/contribute/contribute_guidelines.html
   
   Thanks!
   -->
   
   ### Platforms affected
   Android
   
   
   ### Motivation and Context
   <!-- Why is this change required? What problem does it solve? -->
   <!-- If it fixes an open issue, please link to the issue here. -->
   This change enables, generation of a download event.
   
   
   ### Description
   <!-- Describe your changes in detail -->
   
   Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assgined to the "download" event is called. The parameter passed to this callback is an object with the the follwing properties
   
   - **type** _it contains the String value "download" always_
   - **url** _The url that leaded to the downloading of file. Basically, the download link of file_
   - **userAgent** _User Agent of the webview_
   - **contentDisposition** _If the url contains "content-disposition" header, then this property holds the value of that field else this field is empty_
   - **contentLength** _If the link of the file allows to obtain file size then this property holds the file size else it contains int value 0_
   - **mimetype** _The MIME type of the file_
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] shaikh-amaan-fm commented on a change in pull request #743: Added download event

Posted by GitBox <gi...@apache.org>.
shaikh-amaan-fm commented on a change in pull request #743:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/743#discussion_r447211724



##########
File path: README.md
##########
@@ -304,6 +305,29 @@ function messageCallBack(params){
 }
 
 ```
+#### Download event Example
+
+Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assgined to the "download" event is called. The parameter passed to this callback is an object with the the follwing properties
+
+- **type** _it contains the String value "download" always_
+- **url** _The url that leaded to the downloading of file. Basically, the download link of file_

Review comment:
       The url will be an http url to the file.
   The downloading of the file (if required) have to be explicitly done by using the http url received in the callback to the event. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] breautek commented on a change in pull request #743: Added download event

Posted by GitBox <gi...@apache.org>.
breautek commented on a change in pull request #743:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/743#discussion_r447198188



##########
File path: README.md
##########
@@ -304,6 +305,29 @@ function messageCallBack(params){
 }
 
 ```
+#### Download event Example
+
+Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assgined to the "download" event is called. The parameter passed to this callback is an object with the the follwing properties

Review comment:
       Couple of typos.
   
   ```suggestion
   Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assigned to the "download" event is called. The parameter passed to this callback is an object with the the following properties
   ```

##########
File path: src/android/InAppBrowser.java
##########
@@ -938,6 +942,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
 
                 // WebView
                 inAppWebView = new WebView(cordova.getActivity());
+

Review comment:
       Unnecessary white line was added here. Please remove.

##########
File path: src/android/InAppBrowser.java
##########
@@ -1113,6 +1142,7 @@ private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Statu
         if (callbackContext != null) {
             PluginResult result = new PluginResult(status, obj);
             result.setKeepCallback(keepCallback);
+                                

Review comment:
       Unnecessary white line was added here. Please remove.

##########
File path: README.md
##########
@@ -354,6 +378,7 @@ function messageCallBack(params){
   - __loaderror__: event fires when the `InAppBrowser` encounters an error loading a URL.
   - __exit__: event fires when the `InAppBrowser` window is closed.
   - __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview.
+  - __download__: event fires when the `InAppBrowser` loads a URL that leads in downloading of a file.

Review comment:
       Since this PR only provides an android implementation of this feature, we probably should make note of platform support.
   
   Or we should have an implementation for the other platforms as well.

##########
File path: src/android/InAppBrowser.java
##########
@@ -339,6 +342,7 @@ public void run() {
             pluginResult.setKeepCallback(true);
             this.callbackContext.sendPluginResult(pluginResult);
         }
+

Review comment:
       Unnecessary white line was added here. Please remove.

##########
File path: www/inappbrowser.js
##########
@@ -110,7 +115,7 @@
         var cb = function (eventname) {
             iab._eventHandler(eventname);
         };
-
+        

Review comment:
       Please remove the extra whitespace on this line.

##########
File path: README.md
##########
@@ -304,6 +305,29 @@ function messageCallBack(params){
 }
 
 ```
+#### Download event Example
+
+Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assgined to the "download" event is called. The parameter passed to this callback is an object with the the follwing properties
+
+- **type** _it contains the String value "download" always_
+- **url** _The url that leaded to the downloading of file. Basically, the download link of file_

Review comment:
       Is this a `http` url or a local filesystem url?
   
   Or I guess in other words, is this file already downloaded it, or is the developer expected to implement logic of actually downloading the requested resource?
   
   I'm unfamiliar with the `DownloadListener` API, but if it is expected for the developer to download the resource, perhaps a small XHR request example can show this. e.g:
   
   ```
   var xhr = new XMLHttpRequest();
   xhr.open("GET", params.url);
   xhr.onload = function() {
       var content = xhr.responseText;
   };
   xhr.send();
   ```
   
   If the file is already downloaded, perhaps a quick mention and link to the `cordova-plugin-file` for reading files.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org