CB-9148 (android) Add Support for input[type=file] File Chooser
This commit is contained in:
parent
2a383a66c5
commit
26f7ef3c67
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user