mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
update for 2.x
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using WP7GapClassLib.PhoneGap;
|
||||
using WP7GapClassLib.PhoneGap.Commands;
|
||||
using WP7GapClassLib.PhoneGap.JSON;
|
||||
using WP7CordovaClassLib.Cordova;
|
||||
using WP7CordovaClassLib.Cordova.Commands;
|
||||
using WP7CordovaClassLib.Cordova.JSON;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -17,7 +17,7 @@ using System.Linq;
|
||||
using Microsoft.Phone.Controls;
|
||||
using System.Windows;
|
||||
|
||||
namespace PhoneGap.Extension.Commands
|
||||
namespace Cordova.Extension.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementes access to application live tiles
|
||||
@@ -87,7 +87,7 @@ namespace PhoneGap.Extension.Commands
|
||||
LiveTilesOptions liveTileOptions;
|
||||
try
|
||||
{
|
||||
liveTileOptions = WP7GapClassLib.PhoneGap.JSON.JsonHelper.Deserialize<LiveTilesOptions>(options);
|
||||
liveTileOptions = JsonHelper.Deserialize<LiveTilesOptions[]>(options)[0];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ namespace PhoneGap.Extension.Commands
|
||||
LiveTilesOptions liveTileOptions;
|
||||
try
|
||||
{
|
||||
liveTileOptions = WP7GapClassLib.PhoneGap.JSON.JsonHelper.Deserialize<LiveTilesOptions>(options);
|
||||
liveTileOptions = JsonHelper.Deserialize<LiveTilesOptions[]>(options)[0];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -171,7 +171,7 @@ namespace PhoneGap.Extension.Commands
|
||||
LiveTilesOptions liveTileOptions;
|
||||
try
|
||||
{
|
||||
liveTileOptions = WP7GapClassLib.PhoneGap.JSON.JsonHelper.Deserialize<LiveTilesOptions>(options);
|
||||
liveTileOptions = JsonHelper.Deserialize<LiveTilesOptions[]>(options)[0];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ namespace PhoneGap.Extension.Commands
|
||||
LiveTilesOptions liveTileOptions;
|
||||
try
|
||||
{
|
||||
liveTileOptions = WP7GapClassLib.PhoneGap.JSON.JsonHelper.Deserialize<LiveTilesOptions>(options);
|
||||
liveTileOptions = JsonHelper.Deserialize<LiveTilesOptions[]>(options)[0];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -238,8 +238,7 @@ namespace PhoneGap.Extension.Commands
|
||||
else
|
||||
{
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Can't get secondary live tile"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -1,55 +1,45 @@
|
||||
PhoneGap.addConstructor(function () {
|
||||
|
||||
|
||||
navigator.plugins.liveTiles =
|
||||
{
|
||||
updateAppTile: function (successCallback, errorCallback, options) {
|
||||
if (successCallback && (typeof successCallback !== "function")) {
|
||||
console.log("LiveTiles Error: successCallback is not a function");
|
||||
return;
|
||||
}
|
||||
(function () {
|
||||
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("LiveTiles Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
PhoneGap.exec(successCallback, errorCallback, "LiveTiles", "updateAppTile", options);
|
||||
},
|
||||
|
||||
createSecondaryTile: function (successCallback, errorCallback, options) {
|
||||
if (successCallback && (typeof successCallback !== "function")) {
|
||||
console.log("LiveTiles Error: successCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("LiveTiles Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
PhoneGap.exec(successCallback, errorCallback, "LiveTiles", "createSecondaryTile", options);
|
||||
},
|
||||
updateSecondaryTile: function (successCallback, errorCallback, options) {
|
||||
if (successCallback && (typeof successCallback !== "function")) {
|
||||
console.log("LiveTiles Error: successCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("LiveTiles Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
PhoneGap.exec(successCallback, errorCallback, "LiveTiles", "updateSecondaryTile", options);
|
||||
},
|
||||
deleteSecondaryTile: function (successCallback, errorCallback, options) {
|
||||
if (successCallback && (typeof successCallback !== "function")) {
|
||||
console.log("LiveTile Error: successCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("LiveTiles Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
PhoneGap.exec(successCallback, errorCallback, "LiveTiles", "deleteSecondaryTile", options);
|
||||
function checkArgs(win,fail) {
|
||||
if(win && typeof win === "function" && fail && typeof fail === "function") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
console.log("LiveTiles Error: successCallback || errorCallback is not a function");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var cdv = window.cordova || window.Cordova;
|
||||
// if(cdv && cdv.exec) {
|
||||
navigator.plugins.liveTiles = {
|
||||
updateAppTile: function (successCallback, errorCallback, options) {
|
||||
if(checkArgs(successCallback, errorCallback)) {
|
||||
cdv.exec(successCallback, errorCallback, "LiveTiles", "updateAppTile", [options]);
|
||||
}
|
||||
},
|
||||
|
||||
createSecondaryTile: function (successCallback, errorCallback, options) {
|
||||
if(checkArgs(successCallback, errorCallback)) {
|
||||
cdv.exec(successCallback, errorCallback, "LiveTiles", "createSecondaryTile", [options]);
|
||||
}
|
||||
},
|
||||
|
||||
updateSecondaryTile: function (successCallback, errorCallback, options) {
|
||||
if(checkArgs(successCallback, errorCallback)) {
|
||||
cdv.exec(successCallback, errorCallback, "LiveTiles", "updateSecondaryTile", [options]);
|
||||
}
|
||||
},
|
||||
|
||||
deleteSecondaryTile: function (successCallback, errorCallback, options) {
|
||||
if(checkArgs(successCallback, errorCallback)) {
|
||||
cdv.exec(successCallback, errorCallback, "LiveTiles", "deleteSecondaryTile", [options]);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
// }
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,32 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!-- meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=2.0, maximum-scale=4.0, minimum-scale=1.0" / -->
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/> <!-- ISO-8859-1 -->
|
||||
<title>Live Tiles</title>
|
||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
// provide our own console if it does not exist, huge dev aid!
|
||||
if (typeof window.console == "undefined") {
|
||||
window.console = { log: function (str) { window.external.Notify(str); } };
|
||||
}
|
||||
|
||||
// output any errors to console log, created above.
|
||||
window.onerror = function (e) {
|
||||
console.log("window.onerror ::" + JSON.stringify(e));
|
||||
};
|
||||
|
||||
console.log("Installed console ! ");
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="liveTiles.js"></script>
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
var secondaryTile = 'www/liveTiles.html';
|
||||
|
||||
@@ -34,15 +20,7 @@
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function () {
|
||||
deviceReady = true;
|
||||
console.log("Device=" + device.platform + " " + device.version);
|
||||
}, false);
|
||||
window.setTimeout(function () {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
|
||||
function updateAppTile() {
|
||||
|
||||
Reference in New Issue
Block a user