@@ -409,7 +409,7 @@ public String openExternal(String url) {
409
409
intent .putExtra (Browser .EXTRA_APPLICATION_ID , cordova .getActivity ().getPackageName ());
410
410
this .cordova .getActivity ().startActivity (intent );
411
411
return "" ;
412
- // not catching FileUriExposedException explicitly because buildtools<24 doesn't know about it
412
+ // not catching FileUriExposedException explicitly because buildtools<24 doesn't know about it
413
413
} catch (java .lang .RuntimeException e ) {
414
414
LOG .d (LOG_TAG , "InAppBrowser: Error loading url " +url +":" + e .toString ());
415
415
return e .toString ();
@@ -571,7 +571,7 @@ public String showWebPage(final String url, HashMap<String, Boolean> features) {
571
571
}
572
572
Boolean wideViewPort = features .get (USER_WIDE_VIEW_PORT );
573
573
if (wideViewPort != null ) {
574
- useWideViewPort = wideViewPort .booleanValue ();
574
+ useWideViewPort = wideViewPort .booleanValue ();
575
575
}
576
576
}
577
577
@@ -586,8 +586,8 @@ public String showWebPage(final String url, HashMap<String, Boolean> features) {
586
586
*/
587
587
private int dpToPixels (int dipValue ) {
588
588
int value = (int ) TypedValue .applyDimension ( TypedValue .COMPLEX_UNIT_DIP ,
589
- (float ) dipValue ,
590
- cordova .getActivity ().getResources ().getDisplayMetrics ()
589
+ (float ) dipValue ,
590
+ cordova .getActivity ().getResources ().getDisplayMetrics ()
591
591
);
592
592
593
593
return value ;
@@ -695,8 +695,8 @@ public void onClick(View v) {
695
695
public boolean onKey (View v , int keyCode , KeyEvent event ) {
696
696
// If the event is a key-down event on the "enter" button
697
697
if ((event .getAction () == KeyEvent .ACTION_DOWN ) && (keyCode == KeyEvent .KEYCODE_ENTER )) {
698
- navigate (edittext .getText ().toString ());
699
- return true ;
698
+ navigate (edittext .getText ().toString ());
699
+ return true ;
700
700
}
701
701
return false ;
702
702
}
@@ -892,6 +892,42 @@ private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Statu
892
892
}
893
893
}
894
894
895
+ /**
896
+ * Receive File Data from File Chooser
897
+ *
898
+ * @param requestCode the requested code from chromeclient
899
+ * @param resultCode the result code returned from android system
900
+ * @param intent the data from android file chooser
901
+ */
902
+ public void onActivityResult (int requestCode , int resultCode , Intent intent ) {
903
+ // For Android >= 5.0
904
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
905
+ Log .i ("mytag" , "onActivityResult (For Android >= 5.0)" );
906
+ // If RequestCode or Callback is Invalid
907
+ if (requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null ) {
908
+ super .onActivityResult (requestCode , resultCode , intent );
909
+ return ;
910
+ }
911
+ mUploadCallbackLollipop .onReceiveValue (WebChromeClient .FileChooserParams .parseResult (resultCode , intent ));
912
+ mUploadCallbackLollipop = null ;
913
+ }
914
+ // For Android < 5.0
915
+ else {
916
+ Log .i ("mytag" , "onActivityResult (For Android < 5.0)" );
917
+ // If RequestCode or Callback is Invalid
918
+ if (requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null ) {
919
+ super .onActivityResult (requestCode , resultCode , intent );
920
+ return ;
921
+ }
922
+
923
+ if (null == mUploadCallback ) return ;
924
+ Uri result = intent == null || resultCode != cordova .getActivity ().RESULT_OK ? null : intent .getData ();
925
+
926
+ mUploadCallback .onReceiveValue (result );
927
+ mUploadCallback = null ;
928
+ }
929
+ }
930
+
895
931
/**
896
932
* The webview client receives notifications about appView
897
933
*/
@@ -999,7 +1035,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
999
1035
// Update the UI if we haven't already
1000
1036
if (!newloc .equals (edittext .getText ().toString ())) {
1001
1037
edittext .setText (newloc );
1002
- }
1038
+ }
1003
1039
1004
1040
try {
1005
1041
JSONObject obj = new JSONObject ();
@@ -1087,35 +1123,5 @@ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, Str
1087
1123
// By default handle 401 like we'd normally do!
1088
1124
super .onReceivedHttpAuthRequest (view , handler , host , realm );
1089
1125
}
1090
-
1091
- @ Override
1092
- public void onActivityResult (int requestCode , int resultCode , Intent intent ) {
1093
- // For Android >= 5.0
1094
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
1095
- Log .i ("mytag" , "onActivityResult (For Android >= 5.0)" );
1096
- // If RequestCode or Callback is Invalid
1097
- if (requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null ) {
1098
- super .onActivityResult (requestCode , resultCode , intent );
1099
- return ;
1100
- }
1101
- mUploadCallbackLollipop .onReceiveValue (WebChromeClient .FileChooserParams .parseResult (resultCode , intent ));
1102
- mUploadCallbackLollipop = null ;
1103
- }
1104
- // For Android < 5.0
1105
- else {
1106
- Log .i ("mytag" , "onActivityResult (For Android < 5.0)" );
1107
- // If RequestCode or Callback is Invalid
1108
- if (requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null ) {
1109
- super .onActivityResult (requestCode , resultCode , intent );
1110
- return ;
1111
- }
1112
-
1113
- if (null == mUploadCallback ) return ;
1114
- Uri result = intent == null || resultCode != cordova .getActivity ().RESULT_OK ? null : intent .getData ();
1115
-
1116
- mUploadCallback .onReceiveValue (result );
1117
- mUploadCallback = null ;
1118
- }
1119
- }
1120
1126
}
1121
- }
1127
+ }
0 commit comments