From 1e38a6c005305b145b877ab1606d43f530ed767b Mon Sep 17 00:00:00 2001 From: Guillaume Date: Sat, 21 Jan 2017 05:11:19 +0800 Subject: [PATCH 1/5] feat(broadcaster): add Broadcaster plugin (#877) * feat(broadcaster): add Broadcaster plugin * fix(broadcaster): return Obserable for addEventListener - also remove the listener when clearing observable --- src/index.ts | 3 +++ src/plugins/broadcaster.ts | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/plugins/broadcaster.ts diff --git a/src/index.ts b/src/index.ts index 5e41d57e2..42144bd26 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,7 @@ import { BatteryStatus } from './plugins/batterystatus'; import { Brightness } from './plugins/brightness'; import { BLE } from './plugins/ble'; import { BluetoothSerial } from './plugins/bluetoothserial'; +import { Broadcaster } from './plugins/broadcaster'; import { Calendar } from './plugins/calendar'; import { CallNumber } from './plugins/call-number'; import { Camera } from './plugins/camera'; @@ -135,6 +136,7 @@ export * from './plugins/batterystatus'; export * from './plugins/ble'; export * from './plugins/bluetoothserial'; export * from './plugins/brightness'; +export * from './plugins/broadcaster'; export * from './plugins/calendar'; export * from './plugins/call-number'; export * from './plugins/camera'; @@ -253,6 +255,7 @@ window['IonicNative'] = { Brightness, BLE, BluetoothSerial, + Broadcaster, Calendar, CallNumber, Camera, diff --git a/src/plugins/broadcaster.ts b/src/plugins/broadcaster.ts new file mode 100644 index 000000000..8262637ca --- /dev/null +++ b/src/plugins/broadcaster.ts @@ -0,0 +1,51 @@ +import { Plugin, Cordova } from './plugin'; +import { Observable } from 'rxjs/Observable'; + +/** + * @name Broadcaster + * @description + * This plugin adds exchanging events between native code and your app. + * + * @usage + * ``` + * import { Broadcaster } from 'ionic-native'; + * + * // Listen to events from Native + * Broadcaster.addEventListener('eventName').then((event) => console.log(event)); + * + * // Send event to Native + * Broadcaster.fireNativeEvent('eventName', {}).then(() => console.log('success')); + * + * ``` + */ +@Plugin({ + pluginName: 'Broadcaster', + plugin: 'cordova-plugin-broadcaster', + pluginRef: 'broadcaster', + repo: 'https://github.com/bsorrentino/cordova-broadcaster', + platforms: ['Android', 'iOS'] +}) +export class Broadcaster { + + /** + * This function listen to an event sent from the native code + * @param eventName {string} + * @return {Observable} Returns an observable to watch when an event is received + */ + @Cordova({ + observable: true, + clearFunction: 'removeEventListener', + clearWithArgs: true + }) + static addEventListener(eventName: string): Observable { return; } + + /** + * This function sends data to the native code + * @param eventName {string} + * @param eventData {any} + * @return {Promise} Returns a promise that resolves when an event is successfully fired + */ + @Cordova() + static fireNativeEvent(eventName: string, eventData: any): Promise { return; } + +} From 9c75a0613168fcb4309acf2d0eae66a30e49b42e Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Fri, 20 Jan 2017 22:11:57 +0100 Subject: [PATCH 2/5] feat(launch-review): add LaunchReview plugin (#949) * Add LaunchReview * Fix pluginRef --- src/index.ts | 3 +++ src/plugins/launch-review.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/plugins/launch-review.ts diff --git a/src/index.ts b/src/index.ts index 42144bd26..abb0b4b95 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,6 +70,7 @@ import { Instagram } from './plugins/instagram'; import { IsDebug } from './plugins/is-debug'; import { Keyboard } from './plugins/keyboard'; import { LaunchNavigator } from './plugins/launchnavigator'; +import { LaunchReview } from './plugins/launch-review'; import { LocalNotifications } from './plugins/localnotifications'; import { LocationAccuracy } from './plugins/location-accuracy'; import { MediaCapture } from './plugins/media-capture'; @@ -187,6 +188,7 @@ export * from './plugins/instagram'; export * from './plugins/is-debug'; export * from './plugins/keyboard'; export * from './plugins/launchnavigator'; +export * from './plugins/launch-review'; export * from './plugins/localnotifications'; export * from './plugins/location-accuracy'; export * from './plugins/market'; @@ -305,6 +307,7 @@ window['IonicNative'] = { IsDebug, Keyboard, LaunchNavigator, + LaunchReview, LocalNotifications, LocationAccuracy, Market, diff --git a/src/plugins/launch-review.ts b/src/plugins/launch-review.ts new file mode 100644 index 000000000..dbd8ae69b --- /dev/null +++ b/src/plugins/launch-review.ts @@ -0,0 +1,36 @@ +import { Plugin, Cordova } from './plugin'; + +/** + * @name LaunchReview + * @description + * + * This launches the native store app in order for the user to leave a review. + * On Android, the plugin opens the the app's storepage in the Play Store where the user can leave a review by pressing the stars to give a rating. + * On iOS, the plugin opens the app's storepage in the App Store and focuses the Review tab, where the user can leave a review by pressing "Write a review". + * + * @usage + * ``` + * import { LaunchReview } from 'ionic-native'; + * + * const appId: string = 'yourAppId'; + * LaunchReview.launch(appId) + * .then(() => console.log('Successfully launched store app'); + * ``` + */ +@Plugin({ + pluginName: 'LaunchReview', + plugin: 'cordova-launch-review', + pluginRef: 'LaunchReview', + repo: 'https://github.com/dpa99c/cordova-launch-review', + platforms: ['Android', 'iOS'] +}) +export class LaunchReview { + + /** + * Launch store app using given app ID + * @returns {Promise} + */ + @Cordova() + static launch(appId: string): Promise { return; } + +} From 7c30718369348968ef641ad7bde3b1823c7df479 Mon Sep 17 00:00:00 2001 From: Peter Bakondy Date: Fri, 20 Jan 2017 22:13:58 +0100 Subject: [PATCH 3/5] feat(speech-recognition): add SpeechRecognition plugin (#897) --- src/index.ts | 3 + src/plugins/speech-recognition.ts | 156 ++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 src/plugins/speech-recognition.ts diff --git a/src/index.ts b/src/index.ts index abb0b4b95..acc5c881d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -101,6 +101,7 @@ import { Shake } from './plugins/shake'; import { Sim } from './plugins/sim'; import { SMS } from './plugins/sms'; import { SocialSharing } from './plugins/socialsharing'; +import { SpeechRecognition } from './plugins/speech-recognition'; import { SpinnerDialog } from './plugins/spinnerdialog'; import { Splashscreen } from './plugins/splashscreen'; import { SQLite } from './plugins/sqlite'; @@ -220,6 +221,7 @@ export * from './plugins/shake'; export * from './plugins/sim'; export * from './plugins/sms'; export * from './plugins/socialsharing'; +export * from './plugins/speech-recognition'; export * from './plugins/spinnerdialog'; export * from './plugins/splashscreen'; export * from './plugins/sqlite'; @@ -342,6 +344,7 @@ window['IonicNative'] = { Splashscreen, SQLite, StatusBar, + SpeechRecognition, Stepcounter, StreamingMedia, Stripe, diff --git a/src/plugins/speech-recognition.ts b/src/plugins/speech-recognition.ts new file mode 100644 index 000000000..5a3ef528c --- /dev/null +++ b/src/plugins/speech-recognition.ts @@ -0,0 +1,156 @@ +import { Plugin, Cordova } from './plugin'; +import { Observable } from 'rxjs/Observable'; + +export type SpeechRecognitionListeningOptions = SpeechRecognitionListeningOptionsIOS | SpeechRecognitionListeningOptionsAndroid; + +export interface SpeechRecognitionListeningOptionsIOS { + /** + * used language for recognition (default `"en-US"`) + */ + language?: string; + + /** + * umber of return matches (default `5`) + */ + matches?: number; + + /** + * Allow partial results to be returned (default `false`) + */ + showPartial?: boolean; +} + +export interface SpeechRecognitionListeningOptionsAndroid { + /** + * used language for recognition (default `"en-US"`) + */ + language?: string; + + /** + * number of return matches (maximum number of matches) + */ + matches?: number; + + /** + * displayed prompt of listener popup window + */ + prompt?: string; + + /** + * display listener popup window with prompt (default `true`) + */ + showPopup?: boolean; +} + +/** + * @name SpeechRecognition + * @description + * This plugin does speech recognition using cloud services + * + * @usage + * ``` + * import { SpeechRecognition } from 'ionic-native'; + * + * // Check feature available + * SpeechRecognition.isRecognitionAvailable() + * .then((available: boolean) => console.log(available)) + * + * // Start the recognition process + * SpeechRecognition.startListening(options) + * .subscribe( + * (matches: Array) => console.log(matches), + * (onerror) => console.log('error:', onerror) + * ) + * + * // Stop the recognition process (iOS only) + * SpeechRecognition.stopListening() + * + * // Get the list of supported languages + * SpeechRecognition.getSupportedLanguages() + * .then( + * (languages: Array) => console.log(languages), + * (error) => console.log(error) + * ) + * + * // Check permission + * SpeechRecognition.hasPermission() + * .then((hasPermission: boolean) => console.log(hasPermission)) + * + * // Request permissions + * SpeechRecognition.requestPermission() + * .then( + * () => console.log('Granted'), + * () => console.log('Denied') + * ) + * + * ``` + */ +@Plugin({ + pluginName: 'SpeechRecognition', + plugin: 'cordova-plugin-speechrecognition', + pluginRef: 'plugins.speechRecognition', + repo: 'https://github.com/pbakondy/cordova-plugin-speechrecognition', + platforms: ['Android', 'iOS'] +}) +export class SpeechRecognition { + + /** + * Check feature available + * @return {Promise} + */ + @Cordova() + static isRecognitionAvailable(): Promise { + return; + } + + /** + * Start the recognition process + * @return {Promise< Array >} list of recognized terms + */ + @Cordova({ + callbackOrder: 'reverse', + observable: true, + + }) + static startListening(options?: SpeechRecognitionListeningOptions): Observable> { + return; + } + + /** + * Stop the recognition process + */ + @Cordova({ + platforms: ['iOS'] + }) + static stopListening(): Promise { + return; + } + + /** + * Get the list of supported languages + * @return {Promise< Array >} list of languages + */ + @Cordova() + static getSupportedLanguages(): Promise> { + return; + } + + /** + * Check permission + * @return {Promise} has permission + */ + @Cordova() + static hasPermission(): Promise { + return; + } + + /** + * Request permissions + * @return {Promise} + */ + @Cordova() + static requestPermission(): Promise { + return; + } + +} From 1279114b73fbc35e7fd741cc952a649a71a75739 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Sat, 21 Jan 2017 05:14:29 +0800 Subject: [PATCH 4/5] feat(backlight): add Backlight plugin (#973) * feat(backlight): add Backlight plugin * fix(backlight): set as beta --- src/index.ts | 3 +++ src/plugins/backlight.ts | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/plugins/backlight.ts diff --git a/src/index.ts b/src/index.ts index acc5c881d..c0fdeff2a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,7 @@ import { AppVersion } from './plugins/appversion'; import { Badge } from './plugins/badge'; import { BackgroundGeolocation } from './plugins/background-geolocation'; import { BackgroundMode } from './plugins/backgroundmode'; +import { Backlight } from './plugins/backlight'; import { BarcodeScanner } from './plugins/barcodescanner'; import { Base64ToGallery } from './plugins/base64togallery'; import { BatteryStatus } from './plugins/batterystatus'; @@ -131,6 +132,7 @@ export * from './plugins/apprate'; export * from './plugins/appversion'; export * from './plugins/background-geolocation'; export * from './plugins/backgroundmode'; +export * from './plugins/backlight'; export * from './plugins/badge'; export * from './plugins/barcodescanner'; export * from './plugins/base64togallery'; @@ -253,6 +255,7 @@ window['IonicNative'] = { Badge, BackgroundGeolocation, BackgroundMode, + Backlight, BarcodeScanner, Base64ToGallery, BatteryStatus, diff --git a/src/plugins/backlight.ts b/src/plugins/backlight.ts new file mode 100644 index 000000000..ec1c55746 --- /dev/null +++ b/src/plugins/backlight.ts @@ -0,0 +1,44 @@ +import { Plugin, Cordova } from './plugin'; + +/** + * @beta + * @name Backlight + * @description + * This plugin adds turning on/off the device backlight. + * + * @usage + * ``` + * import { Backlight } from 'ionic-native'; + * + * // Turn backlight on + * Backlight.on().then(() => console.log('backlight on')); + * + * // Turn backlight off + * Backlight.off().then(() => console.log('backlight off')); + * + * ``` + */ +@Plugin({ + pluginName: 'Backlight', + plugin: 'cordova-plugin-backlight', + pluginRef: 'cordova.plugins.Backlight', + repo: 'https://github.com/mebibou/cordova-plugin-backlight', + platforms: ['Android'] +}) +export class Backlight { + + /** + * This function turns backlight on + * @return {Promise} Returns a promise that resolves when the backlight is on + */ + @Cordova() + static on(): Promise { return; } + + /** + * This function turns backlight off + * @return {Promise} Returns a promise that resolves when the backlight is off + */ + @Cordova() + static off(): Promise { return; } + +} From ac748abf789d2732a9a335f8fb2ba7c64f661fc3 Mon Sep 17 00:00:00 2001 From: Megan Kearl Date: Fri, 20 Jan 2017 15:16:12 -0600 Subject: [PATCH 5/5] feat(serial): add Serial plugin (#952) * style: fix whitespace lint issue * feat(serial): add serial plugin * docs(serial): remove unnecessary comments --- src/index.ts | 3 ++ src/plugins/serial.ts | 111 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 src/plugins/serial.ts diff --git a/src/index.ts b/src/index.ts index c0fdeff2a..f22e8c711 100644 --- a/src/index.ts +++ b/src/index.ts @@ -98,6 +98,7 @@ import { Rollbar } from './plugins/rollbar'; import { SafariViewController } from './plugins/safari-view-controller'; import { Screenshot } from './plugins/screenshot'; import { SecureStorage } from './plugins/securestorage'; +import { Serial } from './plugins/serial'; import { Shake } from './plugins/shake'; import { Sim } from './plugins/sim'; import { SMS } from './plugins/sms'; @@ -219,6 +220,7 @@ export * from './plugins/safari-view-controller'; export * from './plugins/screen-orientation'; export * from './plugins/screenshot'; export * from './plugins/securestorage'; +export * from './plugins/serial'; export * from './plugins/shake'; export * from './plugins/sim'; export * from './plugins/sms'; @@ -339,6 +341,7 @@ window['IonicNative'] = { SafariViewController, Screenshot, SecureStorage, + Serial, Shake, Sim, SMS, diff --git a/src/plugins/serial.ts b/src/plugins/serial.ts new file mode 100644 index 000000000..4d548faf7 --- /dev/null +++ b/src/plugins/serial.ts @@ -0,0 +1,111 @@ +import { Plugin, Cordova } from './plugin'; +import { Observable } from 'rxjs/Observable'; + +declare var serial: any; + +export interface SerialPermissionOptions { + vid: string; + pid: string; + driver: string; +} + +export interface SerialOpenOptions { + baudRate: number; +} + +/** + * @name Serial + * @description + * This plugin provides functions for working with Serial connections + * + * @usage + * + * ``` + * import { Serial } from 'ionic-native'; + * + * Serial.requestPermission({ + * vid: '0403', + * pid: '6001', + * driver: 'FtdiSerialDriver' + * }).then(() => { + * Serial.open({ + * baudRate: 38400 + * }).then(() => { + * console.log('Serial connection opened'); + * }); + * }).catch((error: any) => console.log(error)); + * + * ``` + */ +@Plugin({ + pluginName: 'Serial', + plugin: 'cordovarduino', + pluginRef: 'serial', + repo: 'https://github.com/xseignard/cordovarduino', + platforms: ['Android'] +}) +export class Serial { + + /** + * Request permission to connect to a serial device + * + * @param options {SerialPermissionOptions} Options used to request serial permissions + * @return {Promise} Returns a promise that resolves when permissions are granted + */ + @Cordova() + static requestPermission(options: SerialPermissionOptions): Promise { return; } + + /** + * Open connection to a serial device + * + * @param options {SerialOpenOptions} Options used to open serial connection + * @return {Promise} Returns a promise that resolves when the serial connection is opened + */ + @Cordova() + static open(options: SerialOpenOptions): Promise { return; } + + /** + * Write to a serial connection + * + * @param data {any} data to write to the serial connection + * @return {Promise} Returns a promise that resolves when the write is complete + */ + @Cordova() + static write(data: any): Promise { return; } + + /** + * Write hex to a serial connection + * + * @param data {any} data to write to the serial connection + * @return {Promise} Returns a promise that resolves when the write is complete + */ + @Cordova() + static writeHex(data: any): Promise { return; } + + /** + * Read from a serial connection + * + * @return {Promise} Returns a promise that resolves with data read from the serial connection + */ + @Cordova() + static read(): Promise { return; } + + /** + * Watch the incoming data from the serial connection. Clear the watch by unsubscribing from the observable + * + * @returns {Observable} Observable returns an observable that you can subscribe to + */ + @Cordova({ + observable: true + }) + static registerReadCallback(): Observable { return; } + + /** + * Close the serial connection + * + * @return {Promise} Returns a promise that resolves when the serial connection is closed + */ + @Cordova() + static close(): Promise { return; } + +}