FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(android): add openFile to utils (#6895) · NativeScript/NativeScript@f8eee40 · GitHub

Commit f8eee40

Browse files
authored andcommitted
feat(android): add openFile to utils (#6895)
* feat(android): add openFile to utils * tests: move test_openFile() test to apps/ui-tests-app Small changes to openFile() method
1 parent 333db62 commit f8eee40

13 files changed

Lines changed: 375 additions & 161 deletions

File tree

‎apps/app/App_Resources/Android/AndroidManifest.xml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
android:theme="@style/AppTheme"
2828
android:usesCleartextTraffic="true" >
2929
<meta-data android:name="debugLayouts" android:value="true" />
30+
31+
<provider
32+
android:name="android.support.v4.content.FileProvider"
33+
android:authorities="org.nativescript.apps.provider"
34+
android:exported="false"
35+
android:grantUriPermissions="true">
36+
<meta-data
37+
android:name="android.support.FILE_PROVIDER_PATHS"
38+
android:resource="@xml/provider_paths"/>
39+
</provider>
40+
3041
<activity
3142
android:name="com.tns.NativeScriptActivity"
3243
android:label="@string/title_activity_kimera"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths xmlns:android="http://schemas.android.com/apk/res/android">
3+
<external-path name="external_files" path="."/>
4+
</paths>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { EventData } from "tns-core-modules/data/observable";
2+
import { SubMainPageViewModel } from "../sub-main-page-view-model";
3+
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
4+
import { Page } from "tns-core-modules/ui/page";
5+
6+
export function pageLoaded(args: EventData) {
7+
const page = <Page>args.object;
8+
const wrapLayout = <WrapLayout>page.getViewById("wrapLayoutWithExamples");
9+
page.bindingContext = new SubMainPageViewModel(wrapLayout, loadExamples());
10+
}
11+
12+
export function loadExamples() {
13+
const examples = new Map<string, string>();
14+
examples.set("open-file", "intent/open-file");
15+
16+
return examples;
17+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Page loaded="pageLoaded">
3+
<ScrollView orientation="vertical" row="1">
4+
<WrapLayout id="wrapLayoutWithExamples"/>
5+
</ScrollView>
6+
</Page>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { isIOS, isAndroid } from "tns-core-modules/platform";
2+
import * as fs from "tns-core-modules/file-system/file-system";
3+
import * as utils from "tns-core-modules/utils/utils";
4+
5+
export function openFile() {
6+
let directory;
7+
if (isIOS) {
8+
directory = fs.knownFolders.ios.downloads();
9+
} else if (isAndroid) {
10+
directory = android.os.Environment.getExternalStorageDirectory().getAbsolutePath().toString();
11+
}
12+
13+
const filePath = fs.path.join(directory, "Test_File_Open.txt");
14+
utils.openFile(filePath);
15+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Page navigatingTo="navigatingTo">
2+
<GridLayout id="root">
3+
<Button text="Open File" tap="openFile" height="40"></Button>
4+
</GridLayout>
5+
</Page>

‎apps/app/ui-tests-app/main-page.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function pageLoaded(args: EventData) {
3636
examples.set("progress-bar", "progress-bar/main-page");
3737
examples.set("date-picker", "date-picker/date-picker");
3838
examples.set("nested-frames", "nested-frames/main-page");
39+
examples.set("intent", "intent/main-page");
3940
page.bindingContext = new MainPageViewModel(wrapLayout, examples);
4041

4142
const parent = page.getViewById("parentLayout");

‎tests/app/App_Resources/Android/AndroidManifest.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
android:label="@string/app_name"
2828
android:largeHeap="true"
2929
android:theme="@style/AppTheme" >
30+
3031
<activity
3132
android:name="com.tns.NativeScriptActivity"
3233
android:label="@string/title_activity_kimera"

‎tests/app/app/mainPage.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let executeTests = true;
77
trace.enable();
88
trace.addCategories(trace.categories.Test + "," + trace.categories.Error);
99

10-
// When debugging
10+
// // When debugging
1111
// trace.setCategories(trace.categories.concat(
1212
// trace.categories.Test,
1313
// trace.categories.Navigation,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL