not sure how the lib works honestly, and I don’t feel like digging around in it to understand why, as I currently have a working solution. Is it the best probably not, does it allow me to pick a file or a folder yes. Image text etc, no problem. Of course this is just my personal taste.
import select.files.*;
SelectLibrary files;
void setup() {
size(displayWidth, displayHeight);
Permission p = new Permission(this, "WRITE_EXTERNAL_STORAGE");
p = new Permission(this, "READ_EXTERNAL_STORAGE");
files = new SelectLibrary(this);
//files.selectFolder("Select a folder to process:", "fileSelected");
//files.selectOutput("Save the file please:", "fileSelected");
};
void mousePressed() {
files.selectFolder("Select a folder to process:", "fileSelected");
//selectInput("Select a file to process:", "fileSelected");
files.selectOutput("Save the file please:", "fileSelected");
};
void handleRequest(boolean granted) {
if (granted) {
println("1");
files.selectInput("Select a file to process:", "fileSelected");
} else {
println("Does not have permission to read external storage.");
}
};
void fileSelected(File selection) {
if (selection == null) {
println("Nothing was selected.");
} else {
println("User selected " + selection.getAbsolutePath());
}
};
this is the permission class remember you also need to set permission in processing’s ide.
public class Permission{
PApplet parent;
String p;
public Permission(PApplet pParent,String permissionName) {
parent = pParent;
p = permissionName;
parent.requestPermission("android.permission."+permissionName, "onPermissionResult", this);
};
public void onPermissionResult(boolean granted) {
if (!granted) {
PApplet.println("User did not grant", p ,"permission.", p ,"is disabled.");
}
};
};
However the code above doesnt work even with permissions.