Initial-Release
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
cordova.define("com.smartmobilesoftware.androidinappbilling.InAppBillingPlugin", function(require, exports, module) { /*
|
||||
* Copyright (C) 2012-2013 by Guillaume Charhon
|
||||
* Modifications 10/16/2013 by Brian Thurlow
|
||||
*/
|
||||
var log = function (msg) {
|
||||
console.log("InAppBilling[js]: " + msg);
|
||||
};
|
||||
|
||||
var InAppBilling = function () {
|
||||
this.options = {};
|
||||
};
|
||||
|
||||
InAppBilling.prototype.init = function (success, fail, options, skus) {
|
||||
options || (options = {});
|
||||
|
||||
this.options = {
|
||||
showLog: options.showLog !== false
|
||||
};
|
||||
|
||||
if (this.options.showLog) {
|
||||
log('setup ok');
|
||||
}
|
||||
|
||||
var hasSKUs = false;
|
||||
//Optional Load SKUs to Inventory.
|
||||
if(typeof skus !== "undefined"){
|
||||
if (typeof skus === "string") {
|
||||
skus = [skus];
|
||||
}
|
||||
if (skus.length > 0) {
|
||||
if (typeof skus[0] !== 'string') {
|
||||
var msg = 'invalid productIds: ' + JSON.stringify(skus);
|
||||
if (this.options.showLog) {
|
||||
log(msg);
|
||||
}
|
||||
fail(msg);
|
||||
return;
|
||||
}
|
||||
if (this.options.showLog) {
|
||||
log('load ' + JSON.stringify(skus));
|
||||
}
|
||||
hasSKUs = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hasSKUs){
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "init", [skus]);
|
||||
}else {
|
||||
//No SKUs
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "init", []);
|
||||
}
|
||||
};
|
||||
InAppBilling.prototype.getPurchases = function (success, fail) {
|
||||
if (this.options.showLog) {
|
||||
log('getPurchases called!');
|
||||
}
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "getPurchases", ["null"]);
|
||||
};
|
||||
InAppBilling.prototype.refreshPurchases = function (success, fail) {
|
||||
if (this.options.showLog) {
|
||||
log('refreshPurchases called!');
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var onSuccess = function() {
|
||||
self.getPurchases(function(purchases) {
|
||||
success(purchases);
|
||||
}, fail);
|
||||
};
|
||||
|
||||
return cordova.exec(onSuccess, fail, "InAppBillingPlugin", "refreshPurchases", ["null"]);
|
||||
};
|
||||
InAppBilling.prototype.buy = function (success, fail, productId) {
|
||||
if (this.options.showLog) {
|
||||
log('buy called!');
|
||||
}
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "buy", [productId]);
|
||||
};
|
||||
InAppBilling.prototype.subscribe = function (success, fail, productId) {
|
||||
if (this.options.showLog) {
|
||||
log('subscribe called!');
|
||||
}
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "subscribe", [productId]);
|
||||
};
|
||||
InAppBilling.prototype.consumePurchase = function (success, fail, productId) {
|
||||
if (this.options.showLog) {
|
||||
log('consumePurchase called!');
|
||||
}
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "consumePurchase", [productId]);
|
||||
};
|
||||
InAppBilling.prototype.getAvailableProducts = function (success, fail) {
|
||||
if (this.options.showLog) {
|
||||
log('getAvailableProducts called!');
|
||||
}
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "getAvailableProducts", ["null"]);
|
||||
};
|
||||
InAppBilling.prototype.getProductDetails = function (success, fail, skus) {
|
||||
if (this.options.showLog) {
|
||||
log('getProductDetails called!');
|
||||
}
|
||||
|
||||
if (typeof skus === "string") {
|
||||
skus = [skus];
|
||||
}
|
||||
if (!skus.length) {
|
||||
// Empty array, nothing to do.
|
||||
return;
|
||||
}else {
|
||||
if (typeof skus[0] !== 'string') {
|
||||
var msg = 'invalid productIds: ' + JSON.stringify(skus);
|
||||
log(msg);
|
||||
fail(msg);
|
||||
return;
|
||||
}
|
||||
if (this.options.showLog) {
|
||||
log('load ' + JSON.stringify(skus));
|
||||
}
|
||||
return cordova.exec(success, fail, "InAppBillingPlugin", "getProductDetails", [skus]);
|
||||
}
|
||||
};
|
||||
InAppBilling.prototype.isPurchaseOpen = function (success, fail) {
|
||||
|
||||
var onSuccess = function(state) {
|
||||
var bool = (state == "true") ? true : false;
|
||||
success(bool);
|
||||
};
|
||||
|
||||
return cordova.exec(onSuccess, fail, "InAppBillingPlugin", "isPurchaseOpen", []);
|
||||
}
|
||||
|
||||
module.exports = new InAppBilling();
|
||||
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
cordova.define("cordova-plugin-device.device", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
channel = require('cordova/channel'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec'),
|
||||
cordova = require('cordova');
|
||||
|
||||
channel.createSticky('onCordovaInfoReady');
|
||||
// Tell cordova channel to wait on the CordovaInfoReady event
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device() {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
this.model = null;
|
||||
this.manufacturer = null;
|
||||
this.isVirtual = null;
|
||||
this.serial = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
me.getInfo(function(info) {
|
||||
//ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
|
||||
//TODO: CB-5105 native implementations should not return info.cordova
|
||||
var buildLabel = cordova.version;
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = buildLabel;
|
||||
me.model = info.model;
|
||||
me.isVirtual = info.isVirtual;
|
||||
me.manufacturer = info.manufacturer || 'unknown';
|
||||
me.serial = info.serial || 'unknown';
|
||||
channel.onCordovaInfoReady.fire();
|
||||
},function(e) {
|
||||
me.available = false;
|
||||
utils.alert("[ERROR] Error initializing Cordova: " + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
|
||||
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
||||
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
cordova.define("cordova-plugin-splashscreen.SplashScreen", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var splashscreen = {
|
||||
show:function() {
|
||||
exec(null, null, "SplashScreen", "show", []);
|
||||
},
|
||||
hide:function() {
|
||||
exec(null, null, "SplashScreen", "hide", []);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = splashscreen;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,111 @@
|
||||
cordova.define("cordova-plugin-statusbar.statusbar", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var namedColors = {
|
||||
"black": "#000000",
|
||||
"darkGray": "#A9A9A9",
|
||||
"lightGray": "#D3D3D3",
|
||||
"white": "#FFFFFF",
|
||||
"gray": "#808080",
|
||||
"red": "#FF0000",
|
||||
"green": "#00FF00",
|
||||
"blue": "#0000FF",
|
||||
"cyan": "#00FFFF",
|
||||
"yellow": "#FFFF00",
|
||||
"magenta": "#FF00FF",
|
||||
"orange": "#FFA500",
|
||||
"purple": "#800080",
|
||||
"brown": "#A52A2A"
|
||||
};
|
||||
|
||||
var StatusBar = {
|
||||
|
||||
isVisible: true,
|
||||
|
||||
overlaysWebView: function (doOverlay) {
|
||||
exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
|
||||
},
|
||||
|
||||
styleDefault: function () {
|
||||
// dark text ( to be used on a light background )
|
||||
exec(null, null, "StatusBar", "styleDefault", []);
|
||||
},
|
||||
|
||||
styleLightContent: function () {
|
||||
// light text ( to be used on a dark background )
|
||||
exec(null, null, "StatusBar", "styleLightContent", []);
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
// #88000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackTranslucent", []);
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
// #FF000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackOpaque", []);
|
||||
},
|
||||
|
||||
backgroundColorByName: function (colorname) {
|
||||
return StatusBar.backgroundColorByHexString(namedColors[colorname]);
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (hexString) {
|
||||
if (hexString.charAt(0) !== "#") {
|
||||
hexString = "#" + hexString;
|
||||
}
|
||||
|
||||
if (hexString.length === 4) {
|
||||
var split = hexString.split("");
|
||||
hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
|
||||
}
|
||||
|
||||
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
exec(null, null, "StatusBar", "hide", []);
|
||||
StatusBar.isVisible = false;
|
||||
},
|
||||
|
||||
show: function () {
|
||||
exec(null, null, "StatusBar", "show", []);
|
||||
StatusBar.isVisible = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// prime it
|
||||
exec(function (res) {
|
||||
if (typeof res == 'object') {
|
||||
if (res.type == 'tap') {
|
||||
cordova.fireWindowEvent('statusTap');
|
||||
}
|
||||
} else {
|
||||
StatusBar.isVisible = res;
|
||||
}
|
||||
}, null, "StatusBar", "_ready", []);
|
||||
|
||||
module.exports = StatusBar;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
cordova.define("cordova-plugin-whitelist.whitelist", function(require, exports, module) { /*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
if (!document.querySelector('meta[http-equiv=Content-Security-Policy]')) {
|
||||
var msg = 'No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.';
|
||||
console.error(msg);
|
||||
setInterval(function() {
|
||||
console.warn(msg);
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
cordova.define("ionic-plugin-keyboard.keyboard", function(require, exports, module) {
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
|
||||
var Keyboard = function() {
|
||||
};
|
||||
|
||||
Keyboard.hideKeyboardAccessoryBar = function(hide) {
|
||||
exec(null, null, "Keyboard", "hideKeyboardAccessoryBar", [hide]);
|
||||
};
|
||||
|
||||
Keyboard.close = function() {
|
||||
exec(null, null, "Keyboard", "close", []);
|
||||
};
|
||||
|
||||
Keyboard.show = function() {
|
||||
exec(null, null, "Keyboard", "show", []);
|
||||
};
|
||||
|
||||
Keyboard.disableScroll = function(disable) {
|
||||
exec(null, null, "Keyboard", "disableScroll", [disable]);
|
||||
};
|
||||
|
||||
/*
|
||||
Keyboard.styleDark = function(dark) {
|
||||
exec(null, null, "Keyboard", "styleDark", [dark]);
|
||||
};
|
||||
*/
|
||||
|
||||
Keyboard.isVisible = false;
|
||||
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
exec(success, null, 'Keyboard', 'init', []);
|
||||
|
||||
function success(msg) {
|
||||
var action = msg.charAt(0);
|
||||
if ( action === 'S' ) {
|
||||
var keyboardHeight = msg.substr(1);
|
||||
cordova.plugins.Keyboard.isVisible = true;
|
||||
cordova.fireWindowEvent('native.keyboardshow', { 'keyboardHeight': + keyboardHeight });
|
||||
|
||||
//deprecated
|
||||
cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight': + keyboardHeight });
|
||||
} else if ( action === 'H' ) {
|
||||
cordova.plugins.Keyboard.isVisible = false;
|
||||
cordova.fireWindowEvent('native.keyboardhide');
|
||||
|
||||
//deprecated
|
||||
cordova.fireWindowEvent('native.hidekeyboard');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Keyboard;
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user