Github user jcesarmobile commented on a diff in the pull request:

    
https://github.com/apache/cordova-plugin-inappbrowser/pull/205#discussion_r94467650
  
    --- Diff: src/android/InAppBrowser.java ---
    @@ -722,7 +729,57 @@ public void onClick(View v) {
                     inAppWebView = new WebView(cordova.getActivity());
                     inAppWebView.setLayoutParams(new 
LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 
LayoutParams.MATCH_PARENT));
                     inAppWebView.setId(Integer.valueOf(6));
    -                inAppWebView.setWebChromeClient(new 
InAppChromeClient(thatWebView));
    +                // File Chooser Implemented ChromeClient
    +                inAppWebView.setWebChromeClient(new 
InAppChromeClient(thatWebView) {
    +                    // For Android 5.0+
    +                    public boolean onShowFileChooser (WebView webView, 
ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams 
fileChooserParams)
    +                    {
    +                        Log.d(LOG_TAG, "File Chooser 5.0+");
    +                        // If callback exists, finish it.
    +                        if(mUploadCallbackLollipop != null) {
    +                            mUploadCallbackLollipop.onReceiveValue(null);
    +                        }
    +                        mUploadCallbackLollipop = filePathCallback;
    +
    +                        // Create File Chooser Intent
    +                        Intent content = new 
Intent(Intent.ACTION_GET_CONTENT);
    +                        content.addCategory(Intent.CATEGORY_OPENABLE);
    +                        content.setType("*/*");
    +
    +                        // [important] Register ActvityResultCallback on 
Cordova
    +                        
cordova.setActivityResultCallback(InAppBrowser.this);
    +                        
cordova.getActivity().startActivityForResult(content, 
FILECHOOSER_REQUESTCODE_LOLLIPOP);
    +                        return true;
    +                    }
    +
    +                    // For Android 4.1+
    +                    public void openFileChooser(ValueCallback<Uri> 
uploadMsg, String acceptType, String capture)
    +                    {
    +                        Log.d(LOG_TAG, "File Chooser 4.1+");
    +                        // Call file chooser for Android 3.0+
    +                        openFileChooser(uploadMsg, acceptType);
    +                    }
    +
    +                    // For Android 3.0+
    +                    public void openFileChooser(ValueCallback<Uri> 
uploadMsg, String acceptType)
    +                    {
    +                        Log.d(LOG_TAG, "File Chooser 3.0+");
    +                        mUploadCallback = uploadMsg;
    +                        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    +                        i.addCategory(Intent.CATEGORY_OPENABLE);
    +
    +                        
cordova.setActivityResultCallback(InAppBrowser.this);
    +                        cordova.getActivity().startActivityForResult( 
Intent.createChooser(i, "File Chooser"), FILECHOOSER_REQUESTCODE);
    +                    }
    +
    +                    // For Android < 3.0
    +                    public void openFileChooser(ValueCallback<Uri> 
uploadMsg) {
    +                        Log.d(LOG_TAG, "File Chooser 3.0 <");
    +                        // Call file chooser for Android 3.0+
    +                        openFileChooser(uploadMsg, "");
    +                    }
    +
    --- End diff --
    
    Well, latest cordova-android doesn't support Android versions below 4.1, 
but the plugin can be used with older versions of cordova-android as we have 
the engine set to cordova >=3.1.0. We should bump the engine version to the one 
that started setting the SDK version to 16 if we are not going to support older 
Android versions in plugins.


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

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

Reply via email to