Merge pull request #26 from Gillardo/master

Added support for Windows. WP8 file location change
This commit is contained in:
pwlin 2015-05-05 19:45:11 +02:00
commit 01c0900696
3 changed files with 43 additions and 12 deletions

View File

@ -46,4 +46,12 @@
</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>

View 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);

View File

@ -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);