-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
13 changed files
with
375 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<paths xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<external-path name="external_files" path="."/> | ||
</paths> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { EventData } from "tns-core-modules/data/observable"; | ||
import { SubMainPageViewModel } from "../sub-main-page-view-model"; | ||
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout"; | ||
import { Page } from "tns-core-modules/ui/page"; | ||
|
||
export function pageLoaded(args: EventData) { | ||
const page = <Page>args.object; | ||
const wrapLayout = <WrapLayout>page.getViewById("wrapLayoutWithExamples"); | ||
page.bindingContext = new SubMainPageViewModel(wrapLayout, loadExamples()); | ||
} | ||
|
||
export function loadExamples() { | ||
const examples = new Map<string, string>(); | ||
examples.set("open-file", "intent/open-file"); | ||
|
||
return examples; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Page loaded="pageLoaded"> | ||
<ScrollView orientation="vertical" row="1"> | ||
<WrapLayout id="wrapLayoutWithExamples"/> | ||
</ScrollView> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { isIOS, isAndroid } from "tns-core-modules/platform"; | ||
import * as fs from "tns-core-modules/file-system/file-system"; | ||
import * as utils from "tns-core-modules/utils/utils"; | ||
|
||
export function openFile() { | ||
let directory; | ||
if (isIOS) { | ||
directory = fs.knownFolders.ios.downloads(); | ||
} else if (isAndroid) { | ||
directory = android.os.Environment.getExternalStorageDirectory().getAbsolutePath().toString(); | ||
} | ||
|
||
const filePath = fs.path.join(directory, "Test_File_Open.txt"); | ||
utils.openFile(filePath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Page navigatingTo="navigatingTo"> | ||
<GridLayout id="root"> | ||
<Button text="Open File" tap="openFile" height="40"></Button> | ||
</GridLayout> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.