|
|
@@ -69,12 +69,14 @@ public class MainActivity extends AppCompatActivity {
|
|
|
private static final int REQUEST_CAMERA_CODE = 101;
|
|
|
private static final int REQUEST_PHOTO_LIBRARY_CODE = 102;
|
|
|
private static final int REQUEST_SIGNATURE_CODE = 103;
|
|
|
+ private static final int REQUEST_FILE_CHOOSE_CODE = 104;
|
|
|
|
|
|
private static final String CurrentActionStringKey = "CurrentActionStringKey";
|
|
|
private static final String ExcuteJSArrayKey = "ExcuteJSArrayKey";
|
|
|
private String mCurrentActionString = null;
|
|
|
private JSONArray mExcuteJSArray;
|
|
|
private RAJSInterface mJSInterface;
|
|
|
+ private ValueCallback<Uri[]> mFileCallback;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -88,6 +90,17 @@ public class MainActivity extends AppCompatActivity {
|
|
|
mJSInterface = new RAJSInterface(mActionHandler);
|
|
|
mWebView.addJSInterface(mJSInterface, "RAJSInterface");
|
|
|
|
|
|
+ mWebView.setFileChooserCallback(new RAWebView.WebViewFileChooserCallback() {
|
|
|
+ @Override
|
|
|
+ public void webViewDecideToShowFileChooser(RAWebView webView, Intent intent, ValueCallback<Uri[]> filePathCallback) {
|
|
|
+
|
|
|
+ if (intent != null) {
|
|
|
+ mFileCallback = filePathCallback;
|
|
|
+ self.startActivityForResult(intent, REQUEST_FILE_CHOOSE_CODE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
if (savedInstanceState != null) {
|
|
|
mCurrentActionString = savedInstanceState.getString(CurrentActionStringKey);
|
|
|
|
|
|
@@ -198,7 +211,11 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
onPhotoLibraryResult(resultCode, data);
|
|
|
} else if (requestCode == REQUEST_SIGNATURE_CODE) {
|
|
|
+
|
|
|
onSignatureResult(resultCode, data);
|
|
|
+ } else if (requestCode == REQUEST_FILE_CHOOSE_CODE) {
|
|
|
+
|
|
|
+ onFileChooseResult(resultCode, data);
|
|
|
}
|
|
|
|
|
|
mCurrentActionString = null;
|
|
|
@@ -414,6 +431,20 @@ public class MainActivity extends AppCompatActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void onFileChooseResult(int resultCode, Intent data) {
|
|
|
+
|
|
|
+ if (mFileCallback != null) {
|
|
|
+
|
|
|
+ if (resultCode == RESULT_OK) {
|
|
|
+
|
|
|
+ Uri uri = data.getData();
|
|
|
+ mFileCallback.onReceiveValue(new Uri[] {uri});
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mFileCallback = null;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Private Action
|