/**
 */
package de.solvis;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.PluginResult;
import org.apache.cordova.PluginResult.Status;
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;

import android.util.Log;

import java.util.Date;

public class FileExtra extends CordovaPlugin {
  private static final String TAG = "FileExtra";

  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    Log.d(TAG, "Initializing FileExtra");
  }

  public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
    if(action.equals("dirChooser")) {
      final PluginResult result = new PluginResult(PluginResult.Status.OK, "folderPathDummy");
      callbackContext.sendPluginResult(result);
    }
    return true;
  }

}

@@ -21,16 +21,151 @@
 olvis;%0A%0A
+import android.app.Activity;%0Aimport android.content.Intent;%0Aimport android.support.v4.provider.DocumentFile;%0Aimport android.util.Log;%0A%0A
 import o
@@ -370,83 +370,8 @@
 lt;%0A
-import org.apache.cordova.PluginResult.Status;%0Aimport org.json.JSONObject;%0A
 impo
@@ -429,58 +429,8 @@
 n;%0A%0A
-import android.util.Log;%0A%0Aimport java.util.Date;%0A%0A
 publ
@@ -520,16 +520,102 @@
 eExtra%22;
+%0A  private static final int ACTION_GET_FILES = 56;%0A  private CallbackContext callback;
 %0A%0A  publ
@@ -899,207 +899,1215 @@
     
-if(action.equals(%22dirChooser%22)) %7B%0A      final PluginResult result = new PluginResult(PluginResult.Status.OK, %22folderPathDummy%22);%0A      callbackContext.sendPluginResult(result);%0A    %7D%0A    return true;
+boolean result = false;%0A%0A    PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);%0A    pluginResult.setKeepCallback(true);%0A    callbackContext.sendPluginResult(pluginResult);%0A    callback = callbackContext;%0A%0A    if(action.equals(%22dirChooser%22)) %7B%0A      cordova.getThreadPool().execute(new Runnable() %7B%0A        @Override%0A        public void run() %7B%0A          openDirChooser();%0A        %7D%0A      %7D);%0A%0A      result = true;%0A    %7D%0A%0A    return result;%0A  %7D%0A%0A  private void openDirChooser() %7B%0A    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);%0A    cordova.startActivityForResult(this, intent, ACTION_GET_FILES);%0A  %7D%0A%0A  @Override%0A  public void onActivityResult(int requestCode, int resultCode, Intent intent) %7B%0A    if(requestCode == ACTION_GET_FILES%0A            && resultCode == Activity.RESULT_OK%0A            && callback != null%0A            && intent != null)%7B%0A      Activity activity = cordova.getActivity();%0A      DocumentFile externalFile = DocumentFile.fromTreeUri(%0A              activity.getApplicationContext(), intent.getData());%0A      Log.i(TAG, %22external directory to get files: %22 + externalFile.getUri());%0A%0A      callback.success(externalFile.getUri().toString());%0A    %7D
 %0A  %7D

add dir chooser and return path