You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2017/01/09 17:47:31 UTC

[1/8] cordova-plugin-inappbrowser git commit: CB-9148 (android) Add Support for input[type=file] File Chooser

Repository: cordova-plugin-inappbrowser
Updated Branches:
  refs/heads/master f32917df3 -> fe686b3c1


CB-9148 (android) Add Support for input[type=file] File Chooser


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/c53be403
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/c53be403
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/c53be403

Branch: refs/heads/master
Commit: c53be403e223aae6d591d1105a02cf31bb4d3ae4
Parents: 26f7ef3
Author: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Tue Jan 3 14:40:16 2017 +0900
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jan 9 09:27:53 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/c53be403/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 22b1f12..3e4b126 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -729,7 +729,7 @@ public class InAppBrowser extends CordovaPlugin {
                 inAppWebView = new WebView(cordova.getActivity());
                 inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
                 inAppWebView.setId(Integer.valueOf(6));
-// File Chooser Implemented ChromeClient
+                // File Chooser Implemented ChromeClient
                 inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
                     // For Android 5.0+
                     public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)


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


[7/8] cordova-plugin-inappbrowser git commit: CB-9148 (android) Add Support for input[type=file] File Chooser

Posted by bo...@apache.org.
CB-9148 (android) Add Support for input[type=file] File Chooser


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/1c490922
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/1c490922
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/1c490922

Branch: refs/heads/master
Commit: 1c490922053b9b62c5b20b7f6e0e2866379040a7
Parents: 6809713
Author: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Tue Jan 3 14:28:05 2017 +0900
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jan 9 09:27:53 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/1c490922/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 94c5a68..9357ec4 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -894,7 +894,7 @@ public class InAppBrowser extends CordovaPlugin {
 
     /**
      * Receive File Data from File Chooser
-     *
+     * 
      * @param requestCode the requested code from chromeclient
      * @param resultCode the result code returned from android system
      * @param intent the data from android file chooser


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


[5/8] cordova-plugin-inappbrowser git commit: CB-9148 (android) Add Support for input[type=file] File Chooser

Posted by bo...@apache.org.
CB-9148 (android) Add Support for input[type=file] File Chooser


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/2a383a66
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/2a383a66
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/2a383a66

Branch: refs/heads/master
Commit: 2a383a66c59018560ea39777f3b3b7dc17bd6913
Parents: 1c49092
Author: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Tue Jan 3 14:29:44 2017 +0900
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jan 9 09:27:53 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/2a383a66/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 9357ec4..94c5a68 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -894,7 +894,7 @@ public class InAppBrowser extends CordovaPlugin {
 
     /**
      * Receive File Data from File Chooser
-     * 
+     *
      * @param requestCode the requested code from chromeclient
      * @param resultCode the result code returned from android system
      * @param intent the data from android file chooser


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


[6/8] cordova-plugin-inappbrowser git commit: Add Support for input[type=file] File Chooser

Posted by bo...@apache.org.
Add Support for input[type=file] File Chooser


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/fa70a64a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/fa70a64a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/fa70a64a

Branch: refs/heads/master
Commit: fa70a64af9494cd6d2ae840f5cca285ca26fecf0
Parents: f32917d
Author: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Tue Jan 3 14:09:17 2017 +0900
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jan 9 09:27:53 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 93 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 92 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/fa70a64a/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 24a8efa..b7a463c 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -68,6 +68,10 @@ import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.StringTokenizer;
 
+import android.util.Log;
+import android.webkit.ValueCallback;
+import android.webkit.WebChromeClient;
+
 @SuppressLint("SetJavaScriptEnabled")
 public class InAppBrowser extends CordovaPlugin {
 
@@ -104,6 +108,11 @@ public class InAppBrowser extends CordovaPlugin {
     private boolean shouldPauseInAppBrowser = false;
     private boolean useWideViewPort = true;
 
+    private ValueCallback<Uri> mUploadCallback;
+    private ValueCallback<Uri[]> mUploadCallbackLollipop;
+    private final static int FILECHOOSER_REQUESTCODE = 1;
+    private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
+
     /**
      * Executes the request and returns PluginResult.
      *
@@ -722,7 +731,59 @@ public class InAppBrowser extends CordovaPlugin {
                 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, "");
+                    }
+
+                });
+
                 WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
                 inAppWebView.setWebViewClient(client);
                 WebSettings settings = inAppWebView.getSettings();
@@ -1026,5 +1087,35 @@ public class InAppBrowser extends CordovaPlugin {
             // By default handle 401 like we'd normally do!
             super.onReceivedHttpAuthRequest(view, handler, host, realm);
         }
+
+        @Override
+        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)");
+                // If RequestCode or Callback is Invalid
+                if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
+                    super.onActivityResult(requestCode, resultCode, intent);
+                    return;
+                }
+                mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
+                mUploadCallbackLollipop = null;
+            }
+            // For Android < 5.0
+            else {
+                Log.i("mytag", "onActivityResult (For Android < 5.0)");
+                // If RequestCode or Callback is Invalid
+                if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
+                    super.onActivityResult(requestCode, resultCode, intent);
+                    return;
+                }
+
+                if (null == mUploadCallback) return;
+                Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
+
+                mUploadCallback.onReceiveValue(result);
+                mUploadCallback = null;
+            }
+        }
     }
 }


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


[4/8] cordova-plugin-inappbrowser git commit: CB-9148 (android) Add Support for input[type=file] File Chooser

Posted by bo...@apache.org.
CB-9148 (android) Add Support for input[type=file] File Chooser


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/68097131
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/68097131
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/68097131

Branch: refs/heads/master
Commit: 680971316d727a3ab57a831a4bf34e43a90d43b9
Parents: ad28a0e
Author: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Tue Jan 3 14:22:59 2017 +0900
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jan 9 09:27:53 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/68097131/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index a02743d..94c5a68 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -1048,7 +1048,6 @@ public class InAppBrowser extends CordovaPlugin {
         }
 
 
-
         public void onPageFinished(WebView view, String url) {
             super.onPageFinished(view, url);
 


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


[3/8] cordova-plugin-inappbrowser git commit: Add Support for input[type=file] File Chooser

Posted by bo...@apache.org.
Add Support for input[type=file] File Chooser


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/ad28a0ec
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/ad28a0ec
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/ad28a0ec

Branch: refs/heads/master
Commit: ad28a0ec68b49078821a61bb54e81f261bb6460e
Parents: fa70a64
Author: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Tue Jan 3 14:20:50 2017 +0900
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jan 9 09:27:53 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 82 ++++++++++++++++++++------------------
 1 file changed, 44 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/ad28a0ec/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index b7a463c..a02743d 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -409,7 +409,7 @@ public class InAppBrowser extends CordovaPlugin {
             intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
             this.cordova.getActivity().startActivity(intent);
             return "";
-        // not catching FileUriExposedException explicitly because buildtools<24 doesn't know about it
+            // not catching FileUriExposedException explicitly because buildtools<24 doesn't know about it
         } catch (java.lang.RuntimeException e) {
             LOG.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString());
             return e.toString();
@@ -571,7 +571,7 @@ public class InAppBrowser extends CordovaPlugin {
             }
             Boolean wideViewPort = features.get(USER_WIDE_VIEW_PORT);
             if (wideViewPort != null ) {
-		            useWideViewPort = wideViewPort.booleanValue();
+                useWideViewPort = wideViewPort.booleanValue();
             }
         }
 
@@ -586,8 +586,8 @@ public class InAppBrowser extends CordovaPlugin {
              */
             private int dpToPixels(int dipValue) {
                 int value = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP,
-                                                            (float) dipValue,
-                                                            cordova.getActivity().getResources().getDisplayMetrics()
+                        (float) dipValue,
+                        cordova.getActivity().getResources().getDisplayMetrics()
                 );
 
                 return value;
@@ -695,8 +695,8 @@ public class InAppBrowser extends CordovaPlugin {
                     public boolean onKey(View v, int keyCode, KeyEvent event) {
                         // If the event is a key-down event on the "enter" button
                         if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
-                          navigate(edittext.getText().toString());
-                          return true;
+                            navigate(edittext.getText().toString());
+                            return true;
                         }
                         return false;
                     }
@@ -893,6 +893,42 @@ public class InAppBrowser extends CordovaPlugin {
     }
 
     /**
+     * Receive File Data from File Chooser
+     *
+     * @param requestCode the requested code from chromeclient
+     * @param resultCode the result code returned from android system
+     * @param intent the data from android file chooser
+     */
+    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)");
+            // If RequestCode or Callback is Invalid
+            if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
+                super.onActivityResult(requestCode, resultCode, intent);
+                return;
+            }
+            mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
+            mUploadCallbackLollipop = null;
+        }
+        // For Android < 5.0
+        else {
+            Log.i("mytag", "onActivityResult (For Android < 5.0)");
+            // If RequestCode or Callback is Invalid
+            if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
+                super.onActivityResult(requestCode, resultCode, intent);
+                return;
+            }
+
+            if (null == mUploadCallback) return;
+            Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
+
+            mUploadCallback.onReceiveValue(result);
+            mUploadCallback = null;
+        }
+    }
+
+    /**
      * The webview client receives notifications about appView
      */
     public class InAppBrowserClient extends WebViewClient {
@@ -999,7 +1035,7 @@ public class InAppBrowser extends CordovaPlugin {
             // Update the UI if we haven't already
             if (!newloc.equals(edittext.getText().toString())) {
                 edittext.setText(newloc);
-             }
+            }
 
             try {
                 JSONObject obj = new JSONObject();
@@ -1087,35 +1123,5 @@ public class InAppBrowser extends CordovaPlugin {
             // By default handle 401 like we'd normally do!
             super.onReceivedHttpAuthRequest(view, handler, host, realm);
         }
-
-        @Override
-        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)");
-                // If RequestCode or Callback is Invalid
-                if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
-                    super.onActivityResult(requestCode, resultCode, intent);
-                    return;
-                }
-                mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
-                mUploadCallbackLollipop = null;
-            }
-            // For Android < 5.0
-            else {
-                Log.i("mytag", "onActivityResult (For Android < 5.0)");
-                // If RequestCode or Callback is Invalid
-                if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
-                    super.onActivityResult(requestCode, resultCode, intent);
-                    return;
-                }
-
-                if (null == mUploadCallback) return;
-                Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
-
-                mUploadCallback.onReceiveValue(result);
-                mUploadCallback = null;
-            }
-        }
     }
-}
+}
\ No newline at end of file


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


[2/8] cordova-plugin-inappbrowser git commit: CB-9148 (android) Add Support for input[type=file] File Chooser

Posted by bo...@apache.org.
CB-9148 (android) Add Support for input[type=file] File Chooser


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/26f7ef3c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/26f7ef3c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/26f7ef3c

Branch: refs/heads/master
Commit: 26f7ef3c671a442885ebe16d9e1c576613eaf390
Parents: 2a383a6
Author: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Tue Jan 3 14:39:25 2017 +0900
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jan 9 09:27:53 2017 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/26f7ef3c/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 94c5a68..22b1f12 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -29,6 +29,7 @@ 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;
@@ -41,6 +42,8 @@ import android.view.inputmethod.InputMethodManager;
 import android.webkit.CookieManager;
 import android.webkit.CookieSyncManager;
 import android.webkit.HttpAuthHandler;
+import android.webkit.ValueCallback;
+import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;
@@ -68,10 +71,6 @@ import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.StringTokenizer;
 
-import android.util.Log;
-import android.webkit.ValueCallback;
-import android.webkit.WebChromeClient;
-
 @SuppressLint("SetJavaScriptEnabled")
 public class InAppBrowser extends CordovaPlugin {
 
@@ -107,7 +106,6 @@ public class InAppBrowser extends CordovaPlugin {
     private boolean mediaPlaybackRequiresUserGesture = false;
     private boolean shouldPauseInAppBrowser = false;
     private boolean useWideViewPort = true;
-
     private ValueCallback<Uri> mUploadCallback;
     private ValueCallback<Uri[]> mUploadCallbackLollipop;
     private final static int FILECHOOSER_REQUESTCODE = 1;
@@ -409,7 +407,7 @@ public class InAppBrowser extends CordovaPlugin {
             intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
             this.cordova.getActivity().startActivity(intent);
             return "";
-            // not catching FileUriExposedException explicitly because buildtools<24 doesn't know about it
+        // not catching FileUriExposedException explicitly because buildtools<24 doesn't know about it
         } catch (java.lang.RuntimeException e) {
             LOG.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString());
             return e.toString();
@@ -571,7 +569,7 @@ public class InAppBrowser extends CordovaPlugin {
             }
             Boolean wideViewPort = features.get(USER_WIDE_VIEW_PORT);
             if (wideViewPort != null ) {
-                useWideViewPort = wideViewPort.booleanValue();
+		            useWideViewPort = wideViewPort.booleanValue();
             }
         }
 
@@ -586,8 +584,8 @@ public class InAppBrowser extends CordovaPlugin {
              */
             private int dpToPixels(int dipValue) {
                 int value = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP,
-                        (float) dipValue,
-                        cordova.getActivity().getResources().getDisplayMetrics()
+                                                            (float) dipValue,
+                                                            cordova.getActivity().getResources().getDisplayMetrics()
                 );
 
                 return value;
@@ -695,8 +693,8 @@ public class InAppBrowser extends CordovaPlugin {
                     public boolean onKey(View v, int keyCode, KeyEvent event) {
                         // If the event is a key-down event on the "enter" button
                         if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
-                            navigate(edittext.getText().toString());
-                            return true;
+                          navigate(edittext.getText().toString());
+                          return true;
                         }
                         return false;
                     }
@@ -731,8 +729,7 @@ public class InAppBrowser extends CordovaPlugin {
                 inAppWebView = new WebView(cordova.getActivity());
                 inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
                 inAppWebView.setId(Integer.valueOf(6));
-
-                // File Chooser Implemented ChromeClient
+// File Chooser Implemented ChromeClient
                 inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
                     // For Android 5.0+
                     public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
@@ -783,7 +780,6 @@ public class InAppBrowser extends CordovaPlugin {
                     }
 
                 });
-
                 WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
                 inAppWebView.setWebViewClient(client);
                 WebSettings settings = inAppWebView.getSettings();
@@ -1035,7 +1031,7 @@ public class InAppBrowser extends CordovaPlugin {
             // Update the UI if we haven't already
             if (!newloc.equals(edittext.getText().toString())) {
                 edittext.setText(newloc);
-            }
+             }
 
             try {
                 JSONObject obj = new JSONObject();
@@ -1048,6 +1044,7 @@ public class InAppBrowser extends CordovaPlugin {
         }
 
 
+
         public void onPageFinished(WebView view, String url) {
             super.onPageFinished(view, url);
 
@@ -1123,4 +1120,4 @@ public class InAppBrowser extends CordovaPlugin {
             super.onReceivedHttpAuthRequest(view, handler, host, realm);
         }
     }
-}
\ No newline at end of file
+}


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


[8/8] cordova-plugin-inappbrowser git commit: CB-9148 (android) Add Support for input[type=file] File Chooser

Posted by bo...@apache.org.
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: \ubc15\uad00\uc601 <ja...@naver.com>
Authored: Wed Jan 4 19:42:52 2017 +0900
Committer: Joe Bowser <bo...@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