Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9397D200BC1 for ; Wed, 16 Nov 2016 09:13:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 926DF160B03; Wed, 16 Nov 2016 08:13:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C2088160B13 for ; Wed, 16 Nov 2016 09:12:59 +0100 (CET) Received: (qmail 82446 invoked by uid 500); 16 Nov 2016 08:12:58 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 82141 invoked by uid 99); 16 Nov 2016 08:12:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2016 08:12:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 993892C0088 for ; Wed, 16 Nov 2016 08:12:58 +0000 (UTC) Date: Wed, 16 Nov 2016 08:12:58 +0000 (UTC) From: "Darron Park (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CB-9148) Add support for file picker in InAppBrowser MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 16 Nov 2016 08:13:00 -0000 [ https://issues.apache.org/jira/browse/CB-9148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15669717#comment-15669717 ] Darron Park edited comment on CB-9148 at 11/16/16 8:12 AM: ----------------------------------------------------------- The Code below fixed this problem for me. Maybe someone who can contribute this code to inappbrowser source. > Source: InAppBrowser.java > First, I imported some Classes ---------------------------------------------------- import android.util.Log; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; ---------------------------------------------------- > Second, I added some variables in InAppBrowser class. ---------------------------------------------------- private ValueCallback mUploadMessage; private ValueCallback mUploadMessageLollipop; private final static int FILECHOOSER_RESULTCODE = 1; private final static int FILECHOOSER_LOLLIPOP_RESULTCODE = 2; ---------------------------------------------------- > Then, I changed the code from... ---------------------------------------------------- inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); ---------------------------------------------------- > to... ---------------------------------------------------- inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) { public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); Log.i("mytag", "openFileChooser Executed"); cordova.getActivity().startActivityForResult( Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } public void showFileChooser(ValueCallback filePathCallback, String acceptType, boolean paramBoolean) { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); Log.i("mytag", "showFileChooser Executed"); cordova.getActivity().startActivityForResult( Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 5.0+ public boolean onShowFileChooser( WebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { mUploadMessageLollipop = filePathCallback; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); Log.d("MainActivity", "5.0+"); cordova.getActivity().startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_LOLLIPOP_RESULTCODE); return true; } }); ---------------------------------------------------- > Also added method below to InAppBrowser class ---------------------------------------------------- public void onActivityResult(int requestCode, int resultCode, Intent intent) { Log.i("mytag", "onActivityResult"); if (requestCode == FILECHOOSER_RESULTCODE) { Log.i("mytag", "onActivityResult (File Chooser)"); if (null == mUploadMessage) return; Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData(); mUploadMessage.onReceiveValue(result); mUploadMessage = null; } else if(requestCode == FILECHOOSER_LOLLIPOP_RESULTCODE) { Log.i("mytag", "onActivityResult (File Chooser Lollipop)"); if (mUploadMessageLollipop == null) return ; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mUploadMessageLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent)); } mUploadMessageLollipop = null; } } ---------------------------------------------------- I can't understand why this basic function is not yet implemented to InAppBrowser :( was (Author: jay8585): The Code below fixed this problem for me. Maybe someone who can contribute this code to inappbrowser source. > Source: InAppBrowser.java > First, I added some variables in InAppBrowser class. ---------------------------------------------------- private ValueCallback mUploadMessage; private ValueCallback mUploadMessageLollipop; private final static int FILECHOOSER_RESULTCODE = 1; private final static int FILECHOOSER_LOLLIPOP_RESULTCODE = 2; ---------------------------------------------------- > Then, I changed the code from... ---------------------------------------------------- inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); ---------------------------------------------------- > to... ---------------------------------------------------- inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) { public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); Log.i("mytag", "openFileChooser Executed"); cordova.getActivity().startActivityForResult( Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } public void showFileChooser(ValueCallback filePathCallback, String acceptType, boolean paramBoolean) { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); Log.i("mytag", "showFileChooser Executed"); cordova.getActivity().startActivityForResult( Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 5.0+ public boolean onShowFileChooser( WebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { mUploadMessageLollipop = filePathCallback; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); Log.d("MainActivity", "5.0+"); cordova.getActivity().startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_LOLLIPOP_RESULTCODE); return true; } }); ---------------------------------------------------- > Also added method below to InAppBrowser class ---------------------------------------------------- public void onActivityResult(int requestCode, int resultCode, Intent intent) { Log.i("mytag", "onActivityResult"); if (requestCode == FILECHOOSER_RESULTCODE) { Log.i("mytag", "onActivityResult (File Chooser)"); if (null == mUploadMessage) return; Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData(); mUploadMessage.onReceiveValue(result); mUploadMessage = null; } else if(requestCode == FILECHOOSER_LOLLIPOP_RESULTCODE) { Log.i("mytag", "onActivityResult (File Chooser Lollipop)"); if (mUploadMessageLollipop == null) return ; mUploadMessageLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent)); mUploadMessageLollipop = null; } } ---------------------------------------------------- I can't understand why this basic function is not yet implemented to InAppBrowser :( > Add support for file picker in InAppBrowser > ------------------------------------------- > > Key: CB-9148 > URL: https://issues.apache.org/jira/browse/CB-9148 > Project: Apache Cordova > Issue Type: Improvement > Components: Plugin InAppBrowser > Affects Versions: 3.5.0, 3.6.0 > Environment: problem in Android, the camera roll never opens (iOS working OK) > Reporter: Tomas Rawski > Labels: Android, camera, file, input, roll, triaged > > reproduce : > open the inAppBrowser: http://www.plupload.com/examples > click in Add files. > This works ok when I call it from the _system or _self. But not for _blank. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org For additional commands, e-mail: issues-help@cordova.apache.org