You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by MeirBon <gi...@git.apache.org> on 2017/05/19 09:51:51 UTC

[GitHub] cordova-plugin-inappbrowser pull request #221: CB-12834: (android) Fix bug w...

GitHub user MeirBon opened a pull request:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221

    CB-12834: (android) Fix bug when opening a download link

    ### Platforms affected
    Android
    
    ### What does this PR do?
    It adds a dialog to request permissions when a file is downloaded in the inappbrowser. I have committed the changes using the given format, original changes are from [this pull request](https://github.com/apache/cordova-plugin-inappbrowser/pull/201)
    
    ### What testing has been done on this change?
    Multiple Android devices have been tested. Different download links, cancelling the download then re-downloading.
    
    ### Checklist
    - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
    - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
    - [ ] Added automated test coverage as appropriate for this change.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/MeirBon/cordova-plugin-inappbrowser download-permissions

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221.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 #221
    
----
commit d246092d1a066160aa4f3a4e5424b255d1550076
Author: Mèir Noordermeer <m....@genkgo.nl>
Date:   2017-05-19T09:26:29Z

    CB-12834: (android) Fix bug when opening a download link

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by infil00p <gi...@git.apache.org>.
Github user infil00p commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    @MeirBon Sadly, only asfgit has actual rights to this repo, since it's a mirror of the official repo.  I have to send empty-commits to close issues on this repo since it's only a mirror of the ASF repo and not official yet.  That is how the typo and this mistake happened.
    
    I'll create a new branch, pull this in, and create a new PR to fix this screw-up. 


---

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


[GitHub] cordova-plugin-inappbrowser pull request #221: CB-12834: (android) Fix bug w...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221


---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by cordova-qa <gi...@git.apache.org>.
Github user cordova-qa commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    Cordova CI Build has completed successfully.
    
    **Commit**     - [Link](https://github.com/apache/cordova-plugin-inappbrowser/pull/221/commits/d246092d1a066160aa4f3a4e5424b255d1550076)
    **Dashboard** - [Link](http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/145/)
    
     36 tests run, 0 skipped, 0 failed.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by adirel <gi...@git.apache.org>.
Github user adirel commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    I join this request. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by adirel <gi...@git.apache.org>.
Github user adirel commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    Thank you. great work


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by RafaelKr <gi...@git.apache.org>.
Github user RafaelKr commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    This is awesome!
    But can you please change the function `processDownload` like this?
    
    ```Java
    import android.webkit.CookieManager;
    
    [...]
    
    protected void processDownload() {
        final String url = InAppBrowserDownloads.this.url;
        final String cookie = CookieManager.getInstance().getCookie(url);
        final String filename = URLUtil.guessFileName(url, InAppBrowserDownloads.this.contentDisposition, InAppBrowserDownloads.this.mimetype);
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    
        request.addRequestHeader("Cookie", cookie);
        request.addRequestHeader("User-Agent", InAppBrowserDownloads.this.userAgent);
        request.addRequestHeader("Referer", url);
        request.allowScanningByMediaScanner();
        // Notify client once download is completed!
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
    
        try {
            DownloadManager dm = (DownloadManager) plugin.cordova.getActivity().getSystemService(DOWNLOAD_SERVICE);
            dm.enqueue(request);
    
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); // This is important!
            intent.addCategory(Intent.CATEGORY_OPENABLE); // CATEGORY.OPENABLE
            intent.setType("*/*"); // any application, any extension
            Toast.makeText(plugin.cordova.getActivity().getApplicationContext(), "Downloading File '" + filename + "'", Toast.LENGTH_LONG).show();
        } catch (Exception exception) {
            Toast.makeText(plugin.cordova.getActivity().getApplicationContext(), "Error downloading file, missing storage permissions", Toast.LENGTH_LONG).show();
            exception.printStackTrace();
        }
    }
    ```
    
    This passes the cookies from the WebView to the DownloadManager, so you're able to download files from locations where you need to be signed in.
    I also cleaned up the code a little bit. The important code I added is this part:
    ```Java
    import android.webkit.CookieManager;
    [...]
    final String cookie = CookieManager.getInstance().getCookie(url); // Note that I defined the variable url before
    [...]
    request.addRequestHeader("Cookie", cookie);
    request.addRequestHeader("User-Agent", InAppBrowserDownloads.this.userAgent);
    request.addRequestHeader("Referer", url);
    [...]
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by infil00p <gi...@git.apache.org>.
Github user infil00p commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    Continuing discussion on #244, I want to add this, but I think people are going to balk on adding the download permission for InAppBrowser.  However, since this is a compile-time option, and not a runtime option, it's not something you can easily create an option for in config.xml.


---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by RafaelKr <gi...@git.apache.org>.
Github user RafaelKr commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    Hi @adirel, of course this `let` must be changed to `var`. Thank you!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by adirel <gi...@git.apache.org>.
Github user adirel commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    @RafaelKr, Just wanted to let you know that we've tested your branch. Great work!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by infil00p <gi...@git.apache.org>.
Github user infil00p commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    CRAP, this was a typo.  @RafaelKr can you re-open this one? I meant to close #201 


---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by MeirBon <gi...@git.apache.org>.
Github user MeirBon commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    @RafaelKr Don't have the time right now to work on this. Feel free to make a pull request to my fork and I will take a look when I have time.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by RafaelKr <gi...@git.apache.org>.
Github user RafaelKr commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    @infil00p I'm not the thread owner. @MeirBon could you please reopen this?


---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by adirel <gi...@git.apache.org>.
Github user adirel commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    Hi @RafaelKr, Few points about old devices. 
    the app crash whith error on line 109 at In: cordova-plugin-inappbrowser\www\inappbrowser.js 
    
    **the code:** 
    
    +      let windowFeatures = {
    +        width: isNumeric(size.width) ? size.width : null,
    +        height: isNumeric(size.height) ? size.height : null
    +      };
    
    **error recived:**
    D/SystemWebChromeClient( 8784): file:///android_asset/www/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js: Line 109 : Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    
    I/chromium( 8784): [INFO:CONSOLE(109)] "Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode", source: file:///android_asset/www/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js (109)



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by alanhg <gi...@git.apache.org>.
Github user alanhg commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    Please publish the official version v1.7.2 as soon as possible.
    I need to implement download file like pdf or doc .


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-inappbrowser issue #221: CB-12834: (android) Fix bug when ope...

Posted by MeirBon <gi...@git.apache.org>.
Github user MeirBon commented on the issue:

    https://github.com/apache/cordova-plugin-inappbrowser/pull/221
  
    @RafaelKr I can't, the person that closed this issue or someone with push rights to this repo should be able to reopen it.


---

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