MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / pickFiles

Function pickFiles

apps/toolbox/src/pages/fs-helper.ts:75–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73}
74
75export function pickFiles() {
76 if (!global.isAndroid) {
77 return;
78 }
79 const Intent = android.content.Intent;
80 Application.android.on('activityResult', (args) => {
81 if (args.requestCode === 1000) {
82 const intent: android.content.Intent = args.intent;
83 const clip = intent.getClipData();
84 if (clip) {
85 const count = clip.getItemCount();
86 for (let i = 0; i < count; i++) {
87 const item = clip.getItemAt(i);
88 readFile(item.getUri().toString());
89 }
90 } else {
91 readFile(intent.getData().toString());
92 }
93 }
94 });
95 const picker = new Intent(Intent.ACTION_OPEN_DOCUMENT);
96 picker.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
97 picker.addCategory(Intent.CATEGORY_OPENABLE);
98 picker.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
99 picker.setType('*/*');
100 Application.android.foregroundActivity.startActivityForResult(picker, 1000);
101}
102
103export function pickFile() {
104 if (!global.isAndroid) {

Callers

nothing calls this directly

Calls 5

readFileFunction · 0.85
getItemAtMethod · 0.80
onMethod · 0.65
getItemCountMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected