This commit is contained in:
Ibrahim Hadeed
2016-04-29 20:07:59 -04:00
9 changed files with 525 additions and 14 deletions
+177
View File
@@ -0,0 +1,177 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from "rxjs/Observable";
/**
* @name AdMob
* @description
* @usage
*/
@Plugin({
plugin: 'cordova-plugin-admobpro',
pluginRef: 'AdMob',
repo: 'https://github.com/floatinghotspot/cordova-admob-pro'
})
export class AdMob {
// Static Methods
/**
*
* @param adIdOrOptions
*/
@Cordova()
static createBanner(adIdOrOptions : any) : Promise<any> {return}
/**
*
*/
@Cordova({
sync: true
})
static removeBanner() : void {}
/**
*
* @param position
*/
@Cordova({
sync: true
})
static showBanner(position : any) : void {}
/**
*
* @param x
* @param y
*/
@Cordova({
sync: true
})
static showBannerAtXY(x : number, y : number) : void {}
/**
*
*/
@Cordova({
sync: true
})
static hideBanner() : void {}
/**
*
* @param adIdOrOptions
*/
@Cordova()
static prepareInterstitial(adIdOrOptions : any) : Promise<any> {return}
/**
* Show interstitial
*/
@Cordova({
sync: true
})
static showInterstitial() : void {}
/**
*
*/
@Cordova()
static isInterstitialReady () : Promise<boolean> {return}
/**
* Prepare a reward video ad
* @param adIdOrOptions
*/
@Cordova()
static prepareRewardVideoAd(adIdOrOptions : any) : Promise<any> {return}
/**
* Show a reward video ad
*/
@Cordova({
sync : true
})
static showRewardVideoAd() : void {}
/**
* Sets the values for configuration and targeting
* @param options Returns a promise that resolves if the options are set successfully
*/
@Cordova()
static setOptions(options:any) : Promise<any> {return}
/**
* Get user ad settings
* @returns {Promise<any>} Returns a promise that resolves with the ad settings
*/
@Cordova()
static getAdSettings() : Promise<any> {return}
// Events
@Cordova({
eventObservable: true,
event: 'onBannerFailedToReceive'
})
static onBannerFailedToReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerReceive'
})
static onBannerReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerPresent'
})
static onBannerPresent () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerLeaveApp'
})
static onBannerLeaveApp () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerDismiss'
})
static onBannerDismiss () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialFailedToReceive'
})
static onInterstitialFailedToReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialReceive'
})
static onInterstitialReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialPresent'
})
static onInterstitialPresent () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialLeaveApp'
})
static onInterstitialLeaveApp () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialDismiss'
})
static onInterstitialDismiss () : Observable<any> {return}
}
+226
View File
@@ -0,0 +1,226 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from "rxjs/Observable";
/**
* @name Bluetooth Serial
* @description This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino.
* @usage
*/
@Plugin({
repo: 'https://github.com/don/BluetoothSerial',
plugin: 'cordova-plugin-bluetooth-serial',
pluginRef: 'bluetoothSerial',
platforms: ['Android','iOS','Windows Phone','Browser']
})
export class BluetoothSerial {
/**
* Connect to a Bluetooth device
* @param macAddress_or_uuid Identifier of the remote device
*/
@Cordova({
platforms: ['Android','iOS','Windows Phone']
})
static connect (macAddress_or_uuid : string) : Promise<any> {return}
/**
* Connect insecurely to a Bluetooth device
* @param macAddress Identifier of the remote device
*/
@Cordova({
platforms: ['Android']
})
static connectInsecure (macAddress : string) : Promise<any> {return}
/**
* Disconnect
*/
@Cordova({
platforms: ['Android','iOS','Windows Phone']
})
static disconnect () : Promise<any> {return}
/**
* Writes data to the serial port
* @param data ArrayBuffer of data
* @usage
* ```ts
* // Write a string
* Bluetooth.write("hello world").then(success, failure);
*
* // Array of int or bytes
* Bluetooth.write([186, 220, 222]).then(success, failure);
*
* // Typed Array
* var data = new Uint8Array(4);
* data[0] = 0x41;
* data[1] = 0x42;
* data[2] = 0x43;
* data[3] = 0x44;
* Bluetooth.write(data).then(success, failure);
*
* // Array Buffer
* Bluetooth.write(data.buffer).then(success, failure);
* ```
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static write (data : any) : Promise<any> {return}
/**
* Gets the number of bytes of data available
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
}) static available () : Promise<any> {return}
/**
* Reads data from the buffer
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static read () : Promise<any> {return}
/**
* Reads data from the buffer until it reaches a delimiter
* @param delimiter
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static readUntil (delimiter : string) : Promise<any> {return}
/**
* Subscribe to be notified when data is received
* @param delimiter
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone'],
observable: true,
clearFunction: 'unsubscribe'
})
static subscribe (delimiter : string) : Observable<any> {return}
/**
* Subscribe to be notified when data is received
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone'],
observable: true,
clearFunction: 'unsubscribeRawData'
})
static subscribeRawData () : Observable<any> {return}
/**
* Clears data in buffer
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static clear () : Promise<any> {return}
/**
* Lists bonded devices
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static list () : Promise<any> {return}
/**
* Reports if bluetooth is enabled
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static isEnabled () : Promise<any> {return}
/**
* Reports the connection status
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static isConnected () : Promise<any> {return}
/**
* Reads the RSSI from the connected peripheral
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static readRSSI () : Promise<any> {return}
/**
* Show the Bluetooth settings on the device
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static showBluetoothSettings () : Promise<any> {return}
/**
* Enable Bluetooth on the device
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static enable () : Promise<any> {return}
/**
* Discover unpaired devices
* @usage
* ```ts
* [{
* "class": 276,
* "id": "10:BF:48:CB:00:00",
* "address": "10:BF:48:CB:00:00",
* "name": "Nexus 7"
* }, {
* "class": 7936,
* "id": "00:06:66:4D:00:00",
* "address": "00:06:66:4D:00:00",
* "name": "RN42"
* }]
* ```
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static discoverUnpaired () : Promise<any> {return}
/**
* Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function.
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone'],
observable: true,
clearFunction: 'clearDeviceDiscoveredListener'
})
static setDeviceDiscoveredListener () : Observable<any> {return}
/**
* Sets the human readable device name that is broadcasted to other devices
* @param newName Desired name of device
*/
@Cordova({
platforms: ['Android'],
sync: true
})
static setName (newName : string) : void {}
/**
* Makes the device discoverable by other devices
* @param discoverableDuration Desired number of seconds device should be discoverable for
*/
@Cordova({
platforms: ['Android'],
sync: true
})
static setDiscoverable (discoverableDuration : number) : void {}
}
+33
View File
@@ -0,0 +1,33 @@
import {Cordova, Plugin} from './plugin';
@Plugin({
plugin: 'https://github.com/loicknuchel/cordova-device-accounts.git',
pluginRef: 'plugins.DeviceAccounts',
repo: 'https://github.com/loicknuchel/cordova-device-accounts',
platforms: ['Android']
})
export class DeviceAccounts {
/**
* Gets all accounts registered on the Android Device
*/
@Cordova()
static get() : Promise<any> {return}
/**
* Get all accounts registered on Android device for requested type
*/
@Cordova()
static getByType(type: string) : Promise<any> {return}
/**
* Get all emails registered on Android device (accounts with 'com.google' type)
*/
@Cordova()
static getEmails() : Promise<any> {return}
/**
* Get the first email registered on Android device
*/
@Cordova()
static getEmail() : Promise<any> {return}
}
+16 -3
View File
@@ -126,14 +126,27 @@ function getPromise(cb) {
}
function wrapPromise(pluginObj:any, methodName:string, args:any[], opts:any={}) {
return getPromise((resolve, reject) => {
callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject);
})
let pluginResult, rej;
const p = getPromise((resolve, reject) => {
pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject);
rej = reject;
});
// Angular throws an error on unhandled rejection, but in this case we have already printed
// a warning that Cordova is undefined or the plugin is uninstalled, so there is no reason
// to error
if (pluginResult && pluginResult.error) {
p.catch(() => {});
rej(pluginResult.error);
}
return p;
}
function wrapObservable(pluginObj:any, methodName:string, args:any[], opts:any = {}) {
return new Observable(observer => {
let pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, observer.next.bind(observer), observer.error.bind(observer));
if (pluginResult && pluginResult.error) {
observer.error(pluginResult.error);
}
return () => {
try {
+36
View File
@@ -0,0 +1,36 @@
import {Cordova, Plugin} from './plugin';
@Plugin({
plugin: 'https://github.com/gitawego/cordova-screenshot.git',
pluginRef: 'navigator.screenshot',
repo: 'https://github.com/gitawego/cordova-screenshot.git'
})
export class Screenshot {
/**
* Takes screenshot and saves the image
*
* @param {string} format. Format can take the value of either 'jpg' or 'png'
* On ios, only 'jpg' format is supported
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
* @param {string} filename. Name of the file as stored on the storage
*/
@Cordova({
successIndex: 1,
errorIndex: 0
})
static save (format?: string, quality?: number, filename?: string) : Promise<any> {return}
/**
* Takes screenshot and returns the image as an URI
*
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
*/
@Cordova({
successIndex: 1,
errorIndex: 0
})
static URI (quality?: number) : Promise<any> {return}
}