mirror of https://github.com/logseq/logseq
android: add folder picker
parent
a4db23cb78
commit
7e5a364d18
|
@ -0,0 +1,33 @@
|
|||
package com.logseq.app;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.activity.result.ActivityResult;
|
||||
|
||||
import com.getcapacitor.JSObject;
|
||||
import com.getcapacitor.Plugin;
|
||||
import com.getcapacitor.annotation.ActivityCallback;
|
||||
import com.getcapacitor.annotation.CapacitorPlugin;
|
||||
import com.getcapacitor.PluginCall;
|
||||
import com.getcapacitor.PluginMethod;
|
||||
|
||||
|
||||
@CapacitorPlugin(name = "FolderPicker")
|
||||
public class FolderPicker extends Plugin {
|
||||
@PluginMethod()
|
||||
public void pickFolder(PluginCall call) {
|
||||
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
i.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
startActivityForResult(call, i, "folderPickerResult");
|
||||
}
|
||||
|
||||
@ActivityCallback
|
||||
private void folderPickerResult(PluginCall call, ActivityResult result) {
|
||||
if (call == null) {
|
||||
return;
|
||||
}
|
||||
JSObject ret = new JSObject();
|
||||
ret.put("result", result.getData().getData());
|
||||
call.resolve(ret);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,13 @@
|
|||
package com.logseq.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {}
|
||||
public class MainActivity extends BridgeActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
registerPlugin(FolderPicker.class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue