Added support for Windows

Added support for Windows.  Updated wp8 so that file can be on device,
rather than only in local storage folder
This commit is contained in:
Gillardo 2015-05-05 09:59:27 +01:00
parent 3e48517abd
commit 5935a4e8ac
3 changed files with 43 additions and 12 deletions

View File

@ -39,11 +39,19 @@
<!-- WP8 -->
<platform name="wp8">
<config-file target="config.xml" parent="/*">
<feature name="FileOpener2">
<param name="wp-package" value="FileOpener2" />
</feature>
</config-file>
<source-file src="src/wp8/FileOpener2.cs" />
<config-file target="config.xml" parent="/*">
<feature name="FileOpener2">
<param name="wp-package" value="FileOpener2" />
</feature>
</config-file>
<source-file src="src/wp8/FileOpener2.cs" />
</platform>
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/fileOpener2Proxy.js" name="fileOpener2Proxy">
<merges target="" />
</js-module>
</platform>
</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)
{
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
var fileName = System.IO.Path.GetFileName(args[0]);
string aliasCurrentCommandCallbackId = args[2];
try
{
// Access isolated storage.
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
// Access the file.
StorageFile file = await local.GetFileAsync(fileName);
// Get the file.
StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(args[0]);
// Launch the bug query file.
await Windows.System.Launcher.LaunchFileAsync(file);