mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 12:02:49 +08:00
Merge pull request #26 from Gillardo/master
Added support for Windows. WP8 file location change
This commit is contained in:
commit
01c0900696
20
plugin.xml
20
plugin.xml
@ -39,11 +39,19 @@
|
|||||||
|
|
||||||
<!-- WP8 -->
|
<!-- WP8 -->
|
||||||
<platform name="wp8">
|
<platform name="wp8">
|
||||||
<config-file target="config.xml" parent="/*">
|
<config-file target="config.xml" parent="/*">
|
||||||
<feature name="FileOpener2">
|
<feature name="FileOpener2">
|
||||||
<param name="wp-package" value="FileOpener2" />
|
<param name="wp-package" value="FileOpener2" />
|
||||||
</feature>
|
</feature>
|
||||||
</config-file>
|
</config-file>
|
||||||
<source-file src="src/wp8/FileOpener2.cs" />
|
<source-file src="src/wp8/FileOpener2.cs" />
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- windows -->
|
||||||
|
<platform name="windows">
|
||||||
|
<js-module src="src/windows/fileOpener2Proxy.js" name="fileOpener2Proxy">
|
||||||
|
<merges target="" />
|
||||||
|
</js-module>
|
||||||
|
</platform>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
26
src/windows/fileOpener2Proxy.js
Normal file
26
src/windows/fileOpener2Proxy.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
var cordova = require('cordova'),
|
||||||
|
fileOpener2 = require('./FileOpener2');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
open: function (successCallback, errorCallback, args) {
|
||||||
|
Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then(function (file) {
|
||||||
|
var options = new Windows.System.LauncherOptions();
|
||||||
|
options.displayApplicationPicker = true;
|
||||||
|
|
||||||
|
Windows.System.Launcher.launchFileAsync(file, options).then(function (success) {
|
||||||
|
if (success) {
|
||||||
|
successCallback();
|
||||||
|
} else {
|
||||||
|
errorCallback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
require("cordova/exec/proxy").add("FileOpener2", module.exports);
|
||||||
|
|
@ -17,16 +17,13 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
public async void open(string options)
|
public async void open(string options)
|
||||||
{
|
{
|
||||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||||
var fileName = System.IO.Path.GetFileName(args[0]);
|
|
||||||
string aliasCurrentCommandCallbackId = args[2];
|
string aliasCurrentCommandCallbackId = args[2];
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Access isolated storage.
|
// Get the file.
|
||||||
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
|
StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(args[0]);
|
||||||
|
|
||||||
// Access the file.
|
|
||||||
StorageFile file = await local.GetFileAsync(fileName);
|
|
||||||
|
|
||||||
// Launch the bug query file.
|
// Launch the bug query file.
|
||||||
await Windows.System.Launcher.LaunchFileAsync(file);
|
await Windows.System.Launcher.LaunchFileAsync(file);
|
||||||
|
Loading…
Reference in New Issue
Block a user