cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [8/8] cordova-plugin-inappbrowser git commit: CB-9148 (android) Add Support for input[type=file] File Chooser
Date Mon, 09 Jan 2017 17:47:38 GMT
CB-9148 (android) Add Support for input[type=file] File Chooser

This closes #205


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/fe686b3c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/fe686b3c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/fe686b3c

Branch: refs/heads/master
Commit: fe686b3c1f18551b25dfa0ca5dac549b58fa3622
Parents: c53be40
Author: 박관영 <jay8585@naver.com>
Authored: Wed Jan 4 19:42:52 2017 +0900
Committer: Joe Bowser <bowserj@apache.org>
Committed: Mon Jan 9 09:46:54 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/fe686b3c/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 3e4b126..c10617e 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -29,7 +29,6 @@ import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.text.InputType;
-import android.util.Log;
 import android.util.TypedValue;
 import android.view.Gravity;
 import android.view.KeyEvent;
@@ -734,7 +733,7 @@ public class InAppBrowser extends CordovaPlugin {
                     // For Android 5.0+
                     public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]>
filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
                     {
-                        Log.d(LOG_TAG, "File Chooser 5.0+");
+                        LOG.d(LOG_TAG, "File Chooser 5.0+");
                         // If callback exists, finish it.
                         if(mUploadCallbackLollipop != null) {
                             mUploadCallbackLollipop.onReceiveValue(null);
@@ -746,16 +745,15 @@ public class InAppBrowser extends CordovaPlugin {
                         content.addCategory(Intent.CATEGORY_OPENABLE);
                         content.setType("*/*");
 
-                        // [important] Register ActvityResultCallback on Cordova
-                        cordova.setActivityResultCallback(InAppBrowser.this);
-                        cordova.getActivity().startActivityForResult(content, FILECHOOSER_REQUESTCODE_LOLLIPOP);
+                        // Run cordova startActivityForResult
+                        cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content,
"Select File"), 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+");
+                        LOG.d(LOG_TAG, "File Chooser 4.1+");
                         // Call file chooser for Android 3.0+
                         openFileChooser(uploadMsg, acceptType);
                     }
@@ -763,20 +761,13 @@ public class InAppBrowser extends CordovaPlugin {
                     // For Android 3.0+
                     public void openFileChooser(ValueCallback<Uri> uploadMsg, String
acceptType)
                     {
-                        Log.d(LOG_TAG, "File Chooser 3.0+");
+                        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);
-                    }
+                        Intent content = new Intent(Intent.ACTION_GET_CONTENT);
+                        content.addCategory(Intent.CATEGORY_OPENABLE);
 
-                    // 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, "");
+                        // run startActivityForResult
+                        cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content,
"Select File"), FILECHOOSER_REQUESTCODE);
                     }
 
                 });
@@ -898,7 +889,7 @@ public class InAppBrowser extends CordovaPlugin {
     public void onActivityResult(int requestCode, int resultCode, Intent intent) {
         // For Android >= 5.0
         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-            Log.i("mytag", "onActivityResult (For Android >= 5.0)");
+            LOG.d(LOG_TAG, "onActivityResult (For Android >= 5.0)");
             // If RequestCode or Callback is Invalid
             if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop
== null) {
                 super.onActivityResult(requestCode, resultCode, intent);
@@ -909,7 +900,7 @@ public class InAppBrowser extends CordovaPlugin {
         }
         // For Android < 5.0
         else {
-            Log.i("mytag", "onActivityResult (For Android < 5.0)");
+            LOG.d(LOG_TAG, "onActivityResult (For Android < 5.0)");
             // If RequestCode or Callback is Invalid
             if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
                 super.onActivityResult(requestCode, resultCode, intent);


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


Mime
View raw message