From a6ae0919e40e4b9c3f189d9e53ec33464ec3aeb5 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Wed, 5 Jul 2017 08:41:35 +0200 Subject: [PATCH 01/30] chore(package): bump dev deps (#1747) --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8c1820e57..bd4d0880f 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "author": "Ionic Team (https://ionic.io)", "license": "MIT", "devDependencies": { - "@angular/compiler": "4.1.3", - "@angular/compiler-cli": "4.1.3", - "@angular/core": "4.1.3", + "@angular/compiler": "4.2.5", + "@angular/compiler-cli": "4.2.5", + "@angular/core": "4.2.5", "@types/cordova": "0.0.34", "@types/jasmine": "^2.5.51", "@types/node": "^7.0.27", @@ -39,12 +39,12 @@ "q": "1.5.0", "queue": "4.2.1", "rimraf": "2.6.1", - "rxjs": "5.1.1", + "rxjs": "5.4.1", "semver": "5.3.0", "tslint": "3.15.1", "tslint-ionic-rules": "0.0.8", "typescript": "2.3.3", - "zone.js": "^0.8.11" + "zone.js": "0.8.12" }, "scripts": { "start": "npm run test:watch", From f5f92e191ae53193525118e5e8353ae7d6bbed12 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Wed, 5 Jul 2017 02:42:37 -0400 Subject: [PATCH 02/30] chore(): use same deps as ionic2-app-base --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index bd4d0880f..bdb336949 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "author": "Ionic Team (https://ionic.io)", "license": "MIT", "devDependencies": { - "@angular/compiler": "4.2.5", - "@angular/compiler-cli": "4.2.5", - "@angular/core": "4.2.5", + "@angular/compiler": "4.1.3", + "@angular/compiler-cli": "4.1.3", + "@angular/core": "4.1.3", "@types/cordova": "0.0.34", "@types/jasmine": "^2.5.51", "@types/node": "^7.0.27", @@ -39,7 +39,7 @@ "q": "1.5.0", "queue": "4.2.1", "rimraf": "2.6.1", - "rxjs": "5.4.1", + "rxjs": "5.4.0", "semver": "5.3.0", "tslint": "3.15.1", "tslint-ionic-rules": "0.0.8", From f41dfee9125a792cbf992c07219e4f3a54cad532 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Wed, 5 Jul 2017 02:43:30 -0400 Subject: [PATCH 03/30] 3.13.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bdb336949..9364e8cdc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-native", - "version": "3.13.0", + "version": "3.13.1", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "homepage": "https://ionicframework.com/", "author": "Ionic Team (https://ionic.io)", From c0d27262e4d326ed88b2e57b3837246393fe459f Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Wed, 5 Jul 2017 02:43:36 -0400 Subject: [PATCH 04/30] chore(): update changelog --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 186c212ae..7e5f0b368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ + +## [3.13.1](https://github.com/ionic-team/ionic-native/compare/v3.13.0...v3.13.1) (2017-07-05) + + +### Bug Fixes + +* **document-viewer:** make config properties optional ([#1767](https://github.com/ionic-team/ionic-native/issues/1767)) ([5b914d7](https://github.com/ionic-team/ionic-native/commit/5b914d7)) + + +### Features + +* **app-rate:** add function handleNegativeFeedback() ([#1748](https://github.com/ionic-team/ionic-native/issues/1748)) ([e64cc0c](https://github.com/ionic-team/ionic-native/commit/e64cc0c)) +* **app-rate:** add function navigateToAppStore() ([#1719](https://github.com/ionic-team/ionic-native/issues/1719)) ([0c79ac1](https://github.com/ionic-team/ionic-native/commit/0c79ac1)) + + + # [3.13.0](https://github.com/ionic-team/ionic-native/compare/v3.12.2...v3.13.0) (2017-07-03) From 398d0eeac534c90787f9e8b56f3c29a0a83dab7f Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 18:46:17 -0400 Subject: [PATCH 05/30] feat(in-app-purchase2): add a second InAppPurchase plugin (#1775) * initial commit for iap2 * fix(iap2): fix events callbacks (#1705) * fix(iap2): add missing decorator to register function (#1709) * (feat): change iap2 for callbacks * (fix): register cordova * (doc): updated docs with usage example (#1713) * (feat): change iap2 for callbacks * (fix): register cordova * (doc): adding setup for store --- .../plugins/in-app-purchase-2/index.ts | 425 ++++++++++++++++++ 1 file changed, 425 insertions(+) create mode 100644 src/@ionic-native/plugins/in-app-purchase-2/index.ts diff --git a/src/@ionic-native/plugins/in-app-purchase-2/index.ts b/src/@ionic-native/plugins/in-app-purchase-2/index.ts new file mode 100644 index 000000000..4fd5d68fe --- /dev/null +++ b/src/@ionic-native/plugins/in-app-purchase-2/index.ts @@ -0,0 +1,425 @@ +import { Plugin, IonicNativePlugin, Cordova, CordovaProperty } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @name In App Purchase 2 + * @description + * In-App Purchase for Cordova on iOS, Android and Windows + * + * @usage + * ```typescript + * import { InAppPurchase2 } from '@ionic-native/in-app-purchase-2'; + * + * constructor(private store: InAppPurchase2) { } + * + * ... + * + * * @advanced + * + * ```typescript + * // After Platform Ready + * this.store.verbosity = this.store.DEBUG; + * this.store.register({ + * id: productId, + * alias: productId, + * type: this.store.NON_RENEWING_SUBSCRIPTION + * }); + * + * // Register Event Handlers for the specific product + * this.store.when(productId).registered( (product: IAPProduct) => { + * console.log('Registered: ' + JSON.stringify(product)); + * }); + * + * // Updated + * this.store.when(productId).updated( (product: IAPProduct) => { + * console.log('Loaded' + JSON.stringify(product)); + * }); + * + * // Issue with buying + * this.store.when(productId).cancelled( (product) => { + * alert('Purchase was Cancelled'); + * }); + * + * // Track All Store Errors + * this.store.error( (err) => { + * alert('Store Error ' + JSON.stringify(err)); + * }); + * + * this.store.ready().then((status) => { + * console.log(JSON.stringify(this.store.get(productId))); + * console.log('Store is Ready: ' + JSON.stringify(status)); + * console.log('Products: ' + JSON.stringify(this.store.products)); + * }); + * + * + * // Errors + * this.store.when(productId).error( (error) => { + * this.loader.dismiss(); + * alert('An Error Occured' + JSON.stringify(error)); + * }); + * // Refresh Starts Handlers + * console.log('Refresh Store'); + * this.store.refresh(); + * + * ... + * + * // To Purchase + * this.store.order(productId); + * + * ``` + * + */ + +export interface IAPProductOptions { + id: string; + alias: string; + type: string; +} + +export type IAPProducts = Array & { + /** + * Get product by ID + */ + byId: { [id: string]: IAPProduct; }; + /** + * Get product by alias + */ + byAlias: { [alias: string]: IAPProduct; }; + /** + * Remove all products (for testing only). + */ + reset: () => {}; +}; + +export type IAPQueryCallback = ((product: IAPProduct) => void) | ((error: IAPError) => void); + +export interface IAPProduct { + + id: string; + + alias: string; + + type: string; + + state: string; + + title: string; + + description: string; + + priceMicros: string; + + price: string; + + currency: string; + + loaded: boolean; + + valid: boolean; + + canPurchase: boolean; + + owned: boolean; + + downloading: boolean; + + downloaded: boolean; + + additionalData: any; + + transaction: any; + + finish(): void; + + verify(): any; + + set(key: string, value: any): void; + + stateChanged(): void; + + on(event: string, callback: Function): void; + + once(event: string, callback: Function): void; + + off(callback: Function): void; + + trigger(action: string, args: any): void; + +} + +export interface IAPProductEvents { + loaded: (callback: IAPQueryCallback) => void; + updated: (callback: IAPQueryCallback) => void; + error: (callback: IAPQueryCallback) => void; + approved: (callback: IAPQueryCallback) => void; + owned: (callback: IAPQueryCallback) => void; + cancelled: (callback: IAPQueryCallback) => void; + refunded: (callback: IAPQueryCallback) => void; + registered: (callback: IAPQueryCallback) => void; + valid: (callback: IAPQueryCallback) => void; + invalid: (callback: IAPQueryCallback) => void; + requested: (callback: IAPQueryCallback) => void; + initiated: (callback: IAPQueryCallback) => void; + finished: (callback: IAPQueryCallback) => void; + verified: (callback: IAPQueryCallback) => void; + unverified: (callback: IAPQueryCallback) => void; + expired: (callback: IAPQueryCallback) => void; + downloading: (product: IAPProduct, progress: any, time_remaining: any) => void; + downloaded: (callback: IAPQueryCallback) => void; +} + +export class IAPError { + code: number; + message: string; +} + +/** + * @name In App Purchase 2 + * @description + * + * @usage + * ``` + * import { InAppPurchase2 } from '@ionic-native/in-app-purchase-2'; + * + * + * constructor(private inAppPurchase2: InAppPurchase2) { } + * + * ... + * + * + * ``` + */ +@Plugin({ + pluginName: 'InAppPurchase2', + plugin: 'cc.fovea.cordova.purchase', + pluginRef: 'store', + repo: 'https://github.com/j3k0/cordova-plugin-purchase', + platforms: ['iOS', 'Android', 'Windows'], + install: 'ionic cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY=""' +}) +@Injectable() +export class InAppPurchase2 extends IonicNativePlugin { + + @CordovaProperty + QUIET: number; + + @CordovaProperty + ERROR: number; + + @CordovaProperty + WARNING: number; + + @CordovaProperty + INFO: number; + + @CordovaProperty + DEBUG: number; + + /** + * Debug level. Use QUIET, ERROR, WARNING, INFO or DEBUG constants + */ + @CordovaProperty + verbosity: number; + + /** + * Set to true to invoke the platform purchase sandbox. (Windows only) + */ + @CordovaProperty + sandbox: boolean; + + @CordovaProperty + FREE_SUBSCRIPTION: string; + + @CordovaProperty + PAID_SUBSCRIPTION: string; + + @CordovaProperty + NON_RENEWING_SUBSCRIPTION: string; + + @CordovaProperty + CONSUMABLE: string; + + @CordovaProperty + NON_CONSUMABLE: string; + + + @CordovaProperty + ERR_SETUP: number; + + @CordovaProperty + ERR_LOAD: number; + + @CordovaProperty + ERR_PURCHASE: number; + + @CordovaProperty + ERR_LOAD_RECEIPTS: number; + + @CordovaProperty + ERR_CLIENT_INVALID: number; + + @CordovaProperty + ERR_PAYMENT_CANCELLED: number; + + @CordovaProperty + ERR_PAYMENT_INVALID: number; + + @CordovaProperty + ERR_PAYMENT_NOT_ALLOWED: number; + + @CordovaProperty + ERR_UNKNOWN: number; + + @CordovaProperty + ERR_REFRESH_RECEIPTS: number; + + @CordovaProperty + ERR_INVALID_PRODUCT_ID: number; + + @CordovaProperty + ERR_FINISH: number; + + @CordovaProperty + ERR_COMMUNICATION: number; + + @CordovaProperty + ERR_SUBSCRIPTIONS_NOT_AVAILABLE: number; + + @CordovaProperty + ERR_MISSING_TOKEN: number; + + @CordovaProperty + ERR_VERIFICATION_FAILED: number; + + @CordovaProperty + ERR_BAD_RESPONSE: number; + + @CordovaProperty + ERR_REFRESH: number; + + @CordovaProperty + ERR_PAYMENT_EXPIRED: number; + + @CordovaProperty + ERR_DOWNLOAD: number; + + @CordovaProperty + ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE: number; + + + @CordovaProperty + REGISTERED: string; + + @CordovaProperty + INVALID: string; + + @CordovaProperty + VALID: string; + + @CordovaProperty + REQUESTED: string; + + @CordovaProperty + INITIATED: string; + + @CordovaProperty + APPROVED: string; + + @CordovaProperty + FINISHED: string; + + @CordovaProperty + OWNED: string; + + @CordovaProperty + DOWNLOADING: string; + + @CordovaProperty + DOWNLOADED: string; + + + @CordovaProperty + INVALID_PAYLOAD: number; + + @CordovaProperty + CONNECTION_FAILED: number; + + @CordovaProperty + PURCHASE_EXPIRED: number; + + @CordovaProperty + products: IAPProducts; + + @CordovaProperty + validator: string | ((product: string | IAPProduct, callback: Function) => void); + + @CordovaProperty + log: { + error: (message: string) => void; + warn: (message: string) => void; + info: (message: string) => void; + debug: (message: string) => void; + }; + + /** + * Get product by id or alias + * @param idOrAlias + */ + @Cordova({ sync: true }) + get(idOrAlias: string): IAPProduct { return; } + + /** + * Register error handler + * @param onError {Function} function to call on error + */ + @Cordova({ sync: true }) + error(onError: Function): void {} + + /** + * Add or register a product + * @param product {IAPProductOptions} + */ + @Cordova({ sync: true}) + register(product: IAPProductOptions): void {} + + /** + * + * @param query + * @param event + * @param callback + * @return {IAPProductEvents} + */ + @Cordova({ sync: true }) + when(query: string | IAPProduct, event?: string, callback?: IAPQueryCallback): IAPProductEvents { return; } + + /** + * Identical to `when`, but the callback will be called only once. After being called, the callback will be unregistered. + * @param query {string | IAPProduct} + * @param [event] {event} + * @param [callback] {IAPQueryCallback} + * @return {IAPProductEvents} + */ + @Cordova({ sync: true }) + once(query: string | IAPProduct, event?: string, callback?: IAPQueryCallback): IAPProductEvents { return; } + + /** + * Unregister a callback. Works for callbacks registered with ready, when, once and error. + * @param callback {Function} + */ + @Cordova({ sync: true }) + off(callback: Function): void {} + + @Cordova({ sync: true }) + order(product: string | IAPProduct, additionalData?: any): { then: Function; error: Function; } { return; } + + /** + * + * @return {Promise} returns a promise that resolves when the store is ready + */ + @Cordova() + ready(): Promise { return; } + + @Cordova({ sync: true }) + refresh(): void {} + +} From 0e970f5038e8d5445c57e007827e27399977706e Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 18:49:28 -0400 Subject: [PATCH 06/30] 3.14.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9364e8cdc..d7ba18d2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-native", - "version": "3.13.1", + "version": "3.14.0", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "homepage": "https://ionicframework.com/", "author": "Ionic Team (https://ionic.io)", From 9a4e36d9d8789ca55808156f3b8e4f0e0485f574 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 18:49:34 -0400 Subject: [PATCH 07/30] chore(): update changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5f0b368..756d90a10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +# [3.14.0](https://github.com/ionic-team/ionic-native/compare/v3.13.1...v3.14.0) (2017-07-07) + + +### Features + +* **in-app-purchase2:** add a second InAppPurchase plugin ([#1775](https://github.com/ionic-team/ionic-native/issues/1775)) ([398d0ee](https://github.com/ionic-team/ionic-native/commit/398d0ee)), closes [#1705](https://github.com/ionic-team/ionic-native/issues/1705) + + + ## [3.13.1](https://github.com/ionic-team/ionic-native/compare/v3.13.0...v3.13.1) (2017-07-05) From 06e666d6a015c4671ad2afef32580cc48bb851b4 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 19:13:04 -0400 Subject: [PATCH 08/30] feat(google-maps): update wrapper to support v2 of the plugin (#1759) * update google maps * more updates * add BaseClass * add BaseArrayClass * add BaseArrayClass constructor * finish up BaseArrayClass * add Environment class * improve docs and add missing functions to GoogleMap class * improve TileOverlayOptions interface * add types to constants * add ILatLng interface * improve types in BaseArrayClass * fix geocoder return type * use Cordova decorator for geocoder * document CameraPosition and add missing duration property * document circle class and add update functions * tslint * remove extra decorator * add setVisible and getVisible to Circle class * complete Environment class * add convenience method to return instance of environment * add more classes to docs * re-organize plugin definition * document GroundOverlayOptions * complete GroundOverlay class * add and complete HtmlInfoWindow class * complete LatLngBounds class * update MyLocation interface * complete GoogleMap class * fix TERRAIN spelling * complete Marker class * complete Polygon class * complete TileOverlay class * remove setDebuggable and isAvailable developer said they're not suited for users --- .../plugins/google-maps/index.ts | 2962 +++++++++-------- 1 file changed, 1609 insertions(+), 1353 deletions(-) diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index 68a4933d5..cd1a9dac1 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -1,39 +1,264 @@ import { Injectable } from '@angular/core'; -import { Cordova, CordovaInstance, CordovaCheck, Plugin, InstanceProperty, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core'; +import { Cordova, CordovaInstance, Plugin, InstanceProperty, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; import 'rxjs/add/observable/fromEvent'; -declare const plugin: any; +export interface AnimateCameraOptions { + target?: LatLng | Array | LatLngBounds; + tilt?: number; + zoom?: number; + bearing?: number; + duration?: number; +} + +export interface CameraPosition { + /** + * The center location of the camera view. + */ + target?: LatLng | LatLngBounds | LatLng[]; + /** + * View angle + */ + tilt?: number; + /** + * Zoom level + */ + zoom?: number; + /** + * Map orientation + */ + bearing?: number; + /** + * The duration of animation in milliseconds + */ + duration?: number; +} + +export interface CircleOptions { + center?: LatLng; + radius?: number; + strokeColor?: string; + strokeWidth?: number; + fillColor?: string; + visible?: boolean; + zIndex?: number; +} + +export interface GeocoderRequest { + address?: string | string[]; + position?: ILatLng | ILatLng[]; +} + +export interface GeocoderResult { + adminArea?: string; + country?: string; + countryCode?: string; + extra?: { + featureName?: string; + lines?: Array; + permises?: string; + phone?: string; + url?: string + }; + locale?: string; + locality?: string; + position?: { lat: number; lng: number }; + postalCode?: string; + subAdminArea?: string; + subLocality?: string; + subThoroughfare?: string; + thoroughfare?: string; +} + +export interface GroundOverlayOptions { + /** + * URL of overlay + */ + url?: string; + /** + * Bounds, array of LatLng + */ + bounds?: Array; + /** + * Set to false to hide + */ + visible?: boolean; + /** + * Opacity. From 0 to 1. + */ + opacity?: number; + /** + * Bearing + */ + bearing?: number; + /** + * Z-index + */ + zIndex?: number; +} + +export interface ILatLng { + lat: number; + lng: number; +} + +export interface MarkerIcon { + url?: string; + size?: { + width?: number; + height?: number; + }; +} + +export interface MarkerOptions { + /** + * The icon image url or properties. Also you can specify HTML Color values. Alternatively you can specify the image as Base64 + */ + icon?: any; + + /** + * The content of the infoWindow. + */ + title?: string; + + /** + * The snippet of the infoWindow. + */ + snippet?: string; + + /** + * The position of the marker. + */ + position?: LatLng; + + /** + * Specify the anchor of the InfoWindow + */ + infoWindowAnchor?: number[]; + + /** + * Set true if you want to enable to drag the marker. (Default: false) Important! Drag starts after long pressed on the marker. + */ + draggable?: boolean; + + /** + * Set true if you want to use a flat marker. (Default: false) + */ + flat?: boolean; + + /** + * Set rotation angle. (Default: 0) + */ + rotation?: number; + + /** + * Set false if you want to hide. (Default: true) + */ + visible?: boolean; + + /** + * Specify the options for title. + */ + styles?: any; + + /** + * Which animation to play when marker is added to a map. + */ + animation?: string; + + /** + * iOS only, Plugin Version >= 1.3.3 Higher zIndex value overlays will be drawn on top of lower zIndex value tile layers and overlays. (You're able to run this on Android, but it will have no effect) + */ + zIndex?: number; + + /** + * Set to true to disable auto panning when the marker is clicked. + */ + disableAutoPan?: boolean; +} + +export interface MyLocation { + latLng?: LatLng; + elapsedRealtimeNanos?: any; + time?: string; + accuracy?: any; + bearing?: number; + altitude?: any; + speed?: number; + provider?: any; + hashCode?: any; +} + +export interface MyLocationOptions { + enableHighAccuracy?: boolean; +} + +export interface PolygonOptions { + points?: Array; + geodesic?: boolean; + strokeColor?: string; + strokeWidth?: number; + fillColor?: string; + visible?: boolean; + zIndex?: number; + addHole?: Array; +} + +export interface PolylineOptions { + points?: Array; + visible?: boolean; + geodesic?: boolean; + color?: string; + width?: number; + zIndex?: number; +} + +export interface TileOverlayOptions { + getTile: (x: number, y: number, zoom: number) => string; + visible?: boolean; + zIndex?: number; + tileSize?: number; + opacity?: number; +} + +export interface VisibleRegion { + northeast?: any; + southwest?: any; +} /** * @hidden * You can listen to these events where appropriate */ -export const GoogleMapsEvent = { - MAP_CLICK: 'click', - MAP_LONG_CLICK: 'long_click', - MY_LOCATION_CHANGE: 'my_location_change', +export const GoogleMapsEvent: { [eventName: string]: string; } = { + MAP_READY: 'map_ready', + MAP_CLICK: 'map_click', + MAP_LONG_CLICK: 'map_long_click', MY_LOCATION_BUTTON_CLICK: 'my_location_button_click', INDOOR_BUILDING_FOCUSED: 'indoor_building_focused', INDOOR_LEVEL_ACTIVATED: 'indoor_level_activated', - CAMERA_CHANGE: 'camera_change', - CAMERA_IDLE: 'camera_idle', - MAP_READY: 'map_ready', - MAP_LOADED: 'map_loaded', - MAP_WILL_MOVE: 'will_move', - MAP_CLOSE: 'map_close', - MARKER_CLICK: 'click', - OVERLAY_CLICK: 'overlay_click', + CAMERA_MOVE_START: 'camera_move_start', + CAMERA_MOVE: 'camera_move', + CAMERA_MOVE_END: 'camera_move_end', + POLYGON_CLICK: 'polygon_click', + POLYLINE_CLICK: 'polyline_click', + CIRCLE_CLICK: 'circle_click', + GROUND_OVERLAY_CLICK: 'ground_overlay_click', INFO_CLICK: 'info_click', - MARKER_DRAG: 'drag', - MARKER_DRAG_START: 'drag_start', - MARKER_DRAG_END: 'drag_end' + INFO_LONG_CLICK: 'info_long_click', + INFO_CLOSE: 'info_close', + INFO_OPEN: 'info_open', + MARKER_CLICK: 'marker_click', + MARKER_DRAG: 'marker_drag', + MARKER_DRAG_START: 'marker_drag_start', + MARKER_DRAG_END: 'marker_drag_end' }; /** * @hidden */ -export const GoogleMapsAnimation = { +export const GoogleMapsAnimation: { [animationName: string]: string; } = { BOUNCE: 'BOUNCE', DROP: 'DROP' }; @@ -41,331 +266,15 @@ export const GoogleMapsAnimation = { /** * @hidden */ -export const GoogleMapsMapTypeId = { - HYBRID: 'MAP_TYPE_HYBRID', - NONE: 'MAP_TYPE_NONE', +export const GoogleMapsMapTypeId: { [mapType: string]: string; } = { NORMAL: 'MAP_TYPE_NORMAL', ROADMAP: 'MAP_TYPE_ROADMAP', SATELLITE: 'MAP_TYPE_SATELLITE', - TERAIN: 'MAP_TYPE_TERRAIN' + HYBRID: 'MAP_TYPE_HYBRID', + TERRAIN: 'MAP_TYPE_TERRAIN', + NONE: 'MAP_TYPE_NONE' }; -/** - * @hidden - */ -@Plugin({ - pluginName: 'GoogleMaps', - plugin: 'cordova-plugin-googlemaps' -}) -export class GoogleMap { - _objectInstance: any; - - constructor(element: string | HTMLElement, options?: any) { - if (checkAvailability('plugin.google.maps.Map', null, 'GoogleMaps') === true) { - if (typeof element === 'string') { - element = document.getElementById(element); - } - this._objectInstance = plugin.google.maps.Map.getMap(element, options); - } - } - - /** - * Adds an event listener. - * - * @returns {Observable} - */ - @InstanceCheck() - addEventListener(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); - } - - /** - * Adds an event listener that works once. - * - * @returns {Promise} - */ - @InstanceCheck() - addListenerOnce(eventName: string): Promise { - return new Promise(resolve => this._objectInstance.addListenerOnce(eventName, resolve)); - } - - /** - * Gets a value - * @param key - */ - @CordovaInstance({ sync: true }) - get(key: string): any { return; } - - /** - * Sets a value - * @param key - * @param value - */ - @CordovaInstance({ sync: true }) - set(key: string, value: any): void { } - - /** - * Listen to a map event. - * - * @returns {Observable} - */ - @InstanceCheck({ observable: true }) - on(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); - } - - /** - * Listen to a map event only once. - * - * @returns {Promise} - */ - @InstanceCheck() - one(eventName: string): Promise { - return new Promise(resolve => this._objectInstance.one(eventName, resolve)); - } - - /** - * Clears all stored values - */ - @CordovaInstance({ sync: true }) - empty(): void { } - - @CordovaInstance({ sync: true }) - setDebuggable(isDebuggable: boolean): void { } - - @CordovaInstance({ sync: true }) - setClickable(isClickable: boolean): void { } - - /** - * Get the position of the camera. - * - * @returns {Promise} - */ - @CordovaInstance() - getCameraPosition(): Promise { return; } - - /** - * Get the location of the user. - * - * @returns {Promise} - */ - @CordovaInstance() - getMyLocation(options?: MyLocationOptions): Promise { return; } - - /** - * Get the visible region. - * - * @returns {Promise} - */ - @CordovaInstance() - getVisibleRegion(): Promise { return; } - - @CordovaInstance({ sync: true }) - showDialog(): void { } - - @CordovaInstance({ sync: true }) - closeDialog(): void { } - - @CordovaInstance() - getLicenseInfo(): Promise { return; } - - @CordovaInstance({ sync: true }) - setCenter(latLng: LatLng): void { } - - @CordovaInstance({ sync: true }) - setZoom(zoomLevel: number): void { } - - @CordovaInstance({ sync: true }) - setMapTypeId(mapTypeId: string): void { } - - @CordovaInstance({ sync: true }) - setTilt(tiltLevel: number): void { } - - /** - * @returns {Promise} - */ - @CordovaInstance() - animateCamera(animateCameraOptions: AnimateCameraOptions): Promise { return; } - - /** - * @returns {Promise} - */ - @CordovaInstance() - moveCamera(cameraPosition: CameraPosition): Promise { return; } - - @CordovaInstance({ sync: true }) - setMyLocationEnabled(enabled: boolean): void { } - - @CordovaInstance({ sync: true }) - setIndoorEnabled(enabled: boolean): void { } - - @CordovaInstance({ sync: true }) - setTrafficEnabled(enabled: boolean): void { } - - @CordovaInstance({ sync: true }) - setCompassEnabled(enabled: boolean): void { } - - @CordovaInstance({ sync: true }) - setAllGesturesEnabled(enabled: boolean): void { } - - /** - * @returns {Promise} - */ - @InstanceCheck() - addMarker(options: MarkerOptions): Promise { - return new Promise((resolve, reject) => { - this._objectInstance.addMarker(options, (marker: any) => { - if (marker) { - resolve(new Marker(marker)); - } else { - reject(); - } - }); - }); - } - - /** - * @returns {Promise} - */ - @InstanceCheck() - addCircle(options: CircleOptions): Promise { - return new Promise((resolve, reject) => { - this._objectInstance.addCircle(options, (circle: any) => { - if (circle) { - resolve(new Circle(circle)); - } else { - reject(); - } - }); - }); - } - - /** - * @returns {Promise} - */ - @InstanceCheck() - addPolygon(options: PolygonOptions): Promise { - return new Promise((resolve, reject) => { - this._objectInstance.addPolygon(options, (polygon: any) => { - if (polygon) { - resolve(new Polygon(polygon)); - } else { - reject(); - } - }); - }); - } - - /** - * @returns {Promise} - */ - @InstanceCheck() - addPolyline(options: PolylineOptions): Promise { - return new Promise((resolve, reject) => { - this._objectInstance.addPolyline(options, (polyline: any) => { - if (polyline) { - resolve(new Polyline(polyline)); - } else { - reject(); - } - }); - }); - } - - /** - * @returns {Promise} - */ - @InstanceCheck() - addTileOverlay(options: TileOverlayOptions): Promise { - return new Promise((resolve, reject) => { - this._objectInstance.addTileOverlay(options, (tileOverlay: any) => { - if (tileOverlay) { - resolve(new TileOverlay(tileOverlay)); - } else { - reject(); - } - }); - }); - } - - /** - * @returns {Promise} - */ - @InstanceCheck() - addGroundOverlay(options: GroundOverlayOptions): Promise { - return new Promise((resolve, reject) => { - this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => { - if (groundOverlay) { - resolve(new GroundOverlay(groundOverlay)); - } else { - reject(); - } - }); - }); - } - - /** - * @returns {Promise} - */ - @InstanceCheck() - addKmlOverlay(options: KmlOverlayOptions): Promise { - return new Promise((resolve, reject) => { - this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => { - if (kmlOverlay) { - resolve(new KmlOverlay(kmlOverlay)); - } else { - reject(); - } - }); - }); - } - - @CordovaInstance({ sync: true }) - setDiv(domNode: HTMLElement): void { } - - @CordovaInstance({ sync: true }) - setVisible(visible: boolean): void { } - - @CordovaInstance({ sync: true }) - setOptions(options: any): void { } - - @CordovaInstance({ sync: true }) - setBackgroundColor(backgroundColor: string): void { } - - @CordovaInstance({ sync: true }) - setPadding(top?: number, right?: number, bottom?: number, left?: number): void { } - - @CordovaInstance({ sync: true }) - clear(): void { } - - @CordovaInstance({ sync: true }) - refreshLayout(): void { } - - /** - * @returns {Promise} - */ - @CordovaInstance() - fromLatLngToPoint(latLng: LatLng, point: any): Promise { return; } - - /** - * @returns {Promise} - */ - @CordovaInstance() - fromPointToLatLng(point: any): Promise { return; } - - /** - * @returns {Promise} - */ - @CordovaInstance() - toDataURL(): Promise { return; } - - @CordovaInstance({ sync: true }) - remove(): void { } - - @CordovaInstance({ sync: true }) - panBy(x: string | number, y: string | number): void { } -} - /** * @name Google Maps * @description This plugin uses the native Google Maps SDK @@ -439,6 +348,8 @@ export class GoogleMap { * ``` * @classes * GoogleMap + * Circle + * Environment * Marker * LatLng * Geocoder @@ -452,16 +363,21 @@ export class GoogleMap { */ @Plugin({ pluginName: 'GoogleMaps', - pluginRef: 'plugin.google.maps.Map', + pluginRef: 'plugin.google.maps', plugin: 'cordova-plugin-googlemaps', - repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps', - install: 'ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"', + repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps', + install: 'ionic cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"', installVariables: ['API_KEY_FOR_ANDROID', 'API_KEY_FOR_IOS'], platforms: ['Android', 'iOS'] }) @Injectable() export class GoogleMaps extends IonicNativePlugin { + /** + * @hidden + */ + _environment: Environment = new Environment(); + /** * Checks if a map object has been created and is available. * @@ -480,157 +396,138 @@ export class GoogleMaps extends IonicNativePlugin { return new GoogleMap(element, options); } + /** + * Convenience method that returns an instance of Environment class + * @return {Object} + */ + environment(): Environment { + return this._environment; + } + } /** * @hidden */ -export interface AnimateCameraOptions { - target?: LatLng | Array | LatLngBounds; - tilt?: number; - zoom?: number; - bearing?: number; - duration?: number; +@Plugin({ + plugin: 'cordova-plugin-googlemaps', + pluginName: 'GoogleMaps', + pluginRef: 'plugin.google.maps.BaseArrayClass', + repo: '' +}) +export class BaseArrayClass extends IonicNativePlugin { + private _objectInstance: any; + + constructor(initialData: T[]) { + super(); + if (checkAvailability(BaseArrayClass.getPluginRef(), null, BaseArrayClass.getPluginName()) === true) { + this._objectInstance = new (BaseArrayClass.getPlugin())(initialData); + } + } + + /** + * Add an event listener + * @param event {string} name of the event. Can be `insert_at`, `remove_at`, `set_at`, or `finish`. + * @returns {Observable} returns an Observable + */ + @InstanceCheck({ observable: true }) + on(event: 'insert_at' | 'remove_at' | 'set_at' | 'finish') { + return new Observable((observer: Observer) => { + this._objectInstance.on(event, observer.next.bind(observer)); + return () => this._objectInstance.off(event, observer.next.bind(observer)); + }); + } + + /** + * Removes all elements from the array. + */ + @CordovaInstance({ sync: true }) + empty(): void {} + + /** + * Iterate over each element, calling the provided callback. + * @param fn {Function} + * @param callback {Function} + */ + @CordovaInstance({ sync: true }) + forEach(fn: ((element: T, index?: number) => void) | ((element: T, callback: () => void) => void), callback?: () => void): void {} + + /** + * Iterate over each element, calling the provided callback. + * Then you can get the results of each callback. + * @param fn {Function} + * @param callback {Function} + * @return {Array} returns a new array with the results + */ + @CordovaInstance({ sync: true }) + map(fn: Function, callback?: ((element: T, index: number) => T) | ((element: T, callback: (newElement: T) => void) => void)): T[] { return; } + + /** + * Returns a reference to the underlying Array. + * @return {Array} + */ + @CordovaInstance({ sync: true }) + getArray(): T[] { return; } + + /** + * Returns the element at the specified index. + * @param index {number} + * @return {Object} + */ + @CordovaInstance({ sync: true }) + getAt(index: number): any {} + + /** + * Inserts an element at the specified index. + * @param index {number} + * @param element {Object} + * @return {Object} + */ + @CordovaInstance({ sync: true }) + insertAt(index: number, element: T) {} + + /** + * Removes the last element of the array and returns that element. + * @return {Object} + */ + @CordovaInstance({ sync: true }) + pop(): T { return; } + + /** + * Adds one element to the end of the array and returns the new length of the array. + * @param element {object} + */ + @CordovaInstance({ sync: true }) + push(element: T): void {} + + /** + * Removes an element from the specified index. + * @param index {number} + */ + @CordovaInstance({ sync: true }) + removeAt(index: number): void {} + + /** + * Sets an element at the specified index. + * @param index {number} + * @param element {object} + */ + @CordovaInstance({ sync: true }) + setAt(index: number, element: T): void {} } /** * @hidden */ -export interface CameraPosition { - target?: LatLng | LatLngBounds | LatLng[]; - zoom?: number; - tilt?: number; - bearing?: number; -} - -/** - * @hidden - */ -export interface MyLocation { - latLng?: LatLng; - speed?: number; - time?: string; - bearing?: number; -} - -/** - * @hidden - */ -export interface MyLocationOptions { - enableHighAccuracy?: boolean; -} - -/** - * @hidden - */ -export interface VisibleRegion { - northeast?: any; - southwest?: any; -} - -/** - * @hidden - */ -export interface MarkerOptions { - /** - * The icon image url or properties. Also you can specify HTML Color values. Alternatively you can specify the image as Base64 - */ - icon?: any; - - /** - * The content of the infoWindow. - */ - title?: string; - - /** - * The snippet of the infoWindow. - */ - snippet?: string; - - /** - * The position of the marker. - */ - position?: LatLng; - - /** - * Specify the anchor of the InfoWindow - */ - infoWindowAnchor?: number[]; - - /** - * Set true if you want to enable to drag the marker. (Default: false) Important! Drag starts after long pressed on the marker. - */ - draggable?: boolean; - - /** - * Set true if you want to use a flat marker. (Default: false) - */ - flat?: boolean; - - /** - * Set rotation angle. (Default: 0) - */ - rotation?: number; - - /** - * Set false if you want to hide. (Default: true) - */ - visible?: boolean; - - /** - * Specify the options for title. - */ - styles?: any; - - /** - * Which animation to play when marker is added to a map. - */ - animation?: string; - - /** - * iOS only, Plugin Version >= 1.3.3 Higher zIndex value overlays will be drawn on top of lower zIndex value tile layers and overlays. (You're able to run this on Android, but it will have no effect) - */ - zIndex?: number; - - /** - * Set to true to disable auto panning when the marker is clicked. - */ - disableAutoPan?: boolean; - - /** - * Function to be invoked when the user clicks on the marker - */ - markerClick?: Function; - - /** - * Function to be invoked when the user clicks on the info box - */ - infoClick?: Function; -} - -/** - * @hidden - */ -export interface MarkerIcon { - url?: string; - size?: { - width?: number; - height?: number; - }; -} - -/** - * @hidden - */ -export class Marker { - - constructor(private _objectInstance: any) { } +export class BaseClass { + protected _objectInstance: any; /** * Adds an event listener. * * @returns {Observable} */ + @InstanceCheck() addEventListener(eventName: string): Observable { return Observable.fromEvent(this._objectInstance, eventName); } @@ -640,13 +537,9 @@ export class Marker { * * @returns {Promise} */ + @InstanceCheck() addListenerOnce(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.addListenerOnce(eventName, resolve) - ); + return new Promise(resolve => this._objectInstance.addListenerOnce(eventName, resolve)); } /** @@ -669,19 +562,9 @@ export class Marker { * * @returns {Observable} */ + @InstanceCheck({ observable: true }) on(eventName: string): Observable { - if (!this._objectInstance) { - return new Observable((observer) => { - observer.error({ error: 'plugin_not_installed' }); - }); - } - - return new Observable( - (observer) => { - this._objectInstance.on(eventName, observer.next.bind(observer)); - return () => this._objectInstance.off(event); - } - ); + return Observable.fromEvent(this._objectInstance, eventName); } /** @@ -689,13 +572,9 @@ export class Marker { * * @returns {Promise} */ + @InstanceCheck() one(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.one(eventName, resolve) - ); + return new Promise(resolve => this._objectInstance.one(eventName, resolve)); } /** @@ -704,6 +583,871 @@ export class Marker { @CordovaInstance({ sync: true }) empty(): void { } + @CordovaInstance({ sync: true }) + trigger(eventName: string, ...parameters: any[]): void {} +} + +/** + * @hidden + */ +export class Circle extends BaseClass { + + constructor(_objectInstance: any) { + super(); + this._objectInstance = _objectInstance; + } + + /** + * Change the center position. + * @param latLng {LatLng} + */ + @CordovaInstance({ sync: true }) + setCenter(latLng: LatLng): void {} + + /** + * Return the current center position + * @return {LatLng} + */ + @CordovaInstance({ sync: true }) + getCenter(): LatLng { return; } + + /** + * Return the current circle radius. + * @return {number} + */ + @CordovaInstance({ sync: true }) + getRadius(): number { return; } + + /** + * Change the circle radius. + * @param radius {number} + */ + @CordovaInstance({ sync: true }) + setRadius(radius: number): void {} + + /** + * Change the filling color (inner color). + * @param color {string} + */ + @CordovaInstance({ sync: true }) + setFillColor(color: string): void {} + + /** + * Return the current circle filling color (inner color). + * @return {string} + */ + @CordovaInstance({ sync: true }) + getFillColor(): string { return; } + + /** + * Change the stroke width. + * @param strokeWidth {number} + */ + @CordovaInstance({ sync: true }) + setStrokeWidth(strokeWidth: number): void {} + + /** + * Return the current circle stroke width (unit: pixel). + * @return {number} + */ + @CordovaInstance({ sync: true }) + getStrokeWidth(): number { return; } + + /** + * Change the stroke color (outter color). + * @param strokeColor {string} + */ + @CordovaInstance({ sync: true }) + setStrokeColor(strokeColor: string): void {} + + /** + * Return the current circle stroke color (outer color). + * @return {string} + */ + @CordovaInstance({ sync: true }) + getStrokeColor(): string { return; } + + /** + * Change clickablity of the circle. + * @param clickable {boolean} + */ + @CordovaInstance({ sync: true }) + setClickable(clickable: boolean): void {} + + /** + * Return true if the circle is clickable. + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + getClickable(): boolean { return; } + + /** + * Change the circle zIndex order. + * @param zIndex {number} + */ + @CordovaInstance({ sync: true }) + setZIndex(zIndex: number): void {} + + /** + * Return the current circle zIndex. + * @return {number} + */ + @CordovaInstance({ sync: true }) + getZIndex(): number { return; } + + /** + * Remove the circle. + */ + @CordovaInstance({ sync: true }) + remove(): void {} + + /** + * Return the latLngBounds (rectangle) that contains the circle. + * @return {LatLngBounds} + */ + @CordovaInstance({ sync: true }) + getBounds(): LatLngBounds { return; } + + /** + * Set circle visibility + * @param visible {boolean} + */ + @CordovaInstance({ sync: true }) + setVisible(visible: boolean): void {} + + /** + * Returns a boolean that indicates whether the circle is visible + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + getVisible(): boolean { return; } +} + +/** + * @hidden + */ +@Plugin({ + plugin: 'cordova-plugin-googlemaps', + pluginName: 'GoogleMaps', + pluginRef: 'plugin.google.maps.environment', + repo: '' +}) +export class Environment extends IonicNativePlugin { + + /** + * Get the open source software license information for Google Maps Android API v2 and Google Maps SDK for iOS. + * @returns {Promise} + */ + @Cordova() + getLicenseInfo(): Promise { return; } + + /** + * Specifies the background color of the app. + * @param color + */ + @Cordova({ sync: true }) + setBackgroundColor(color: string): void {} + +} + +/** + * @hidden + */ +@Plugin({ + pluginName: 'GoogleMaps', + pluginRef: 'plugin.google.maps.Geocoder', + plugin: 'cordova-plugin-googlemaps', + repo: '' +}) +export class Geocoder { + /** + * Converts position to address and vice versa + * @param {GeocoderRequest} request Request object with either an address or a position + * @returns {Promise>} + */ + @Cordova() + geocode(request: GeocoderRequest): Promise> { return; } +} + +/** + * @hidden + */ +@Plugin({ + pluginName: 'GoogleMaps', + plugin: 'cordova-plugin-googlemaps' +}) +export class GoogleMap extends BaseClass { + constructor(element: string | HTMLElement, options?: any) { + super(); + if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) { + if (typeof element === 'string') { + element = document.getElementById(element); + } + this._objectInstance = GoogleMaps.getPlugin().Map.getMap(element, options); + } + } + + /** + * Changes the map div + * @param domNode + */ + @CordovaInstance({ sync: true }) + setDiv(domNode: HTMLElement): void { } + + /** + * Returns the map HTML element + * @return {HTMLElement} + */ + @CordovaInstance({ sync: true }) + getDiv(): HTMLElement { return; } + + /** + * Changes the map type id + * @param mapTypeId {string} + */ + @CordovaInstance({ sync: true }) + setMapTypeId(mapTypeId: string): void { } + + /** + * Moves the camera with animation + * @returns {Promise} + */ + @CordovaInstance() + animateCamera(animateCameraOptions: AnimateCameraOptions): Promise { return; } + + /** + * Zooming in the camera with animation + */ + @CordovaInstance() + animateCameraZoomIn(): void {} + + /** + * Zooming out the camera with animation + */ + @CordovaInstance() + animateCameraZoomOut(): void {} + + /** + * Moves the camera without animation + * @returns {Promise} + */ + @CordovaInstance() + moveCamera(cameraPosition: CameraPosition): Promise { return; } + + /** + * Zooming in the camera without animation + */ + @CordovaInstance() + moveCameraZoomIn(): void {} + + /** + * Zooming out the camera without animation + */ + @CordovaInstance() + moveCameraZoomOut(): void {} + + /** + * Get the position of the camera. + * @returns {Promise} + */ + @CordovaInstance() + getCameraPosition(): Promise { return; } + + /** + * Get the current camera target position + * @return {Promise} + */ + @CordovaInstance() + getCameraTarget(): Promise { return; } + + /** + * Get the current camera zoom level + * @return {number} + */ + @CordovaInstance({ sync: true }) + getCameraZoom(): number { return; } + + /** + * Get the current camera bearing + * @return {number} + */ + @CordovaInstance({ sync: true }) + getCameraBearing(): number { return; } + + /** + * Get the current camera tilt (view angle) + * @return {number} + */ + @CordovaInstance({ sync: true }) + getCameraTilt(): number { return; } + + /** + * Set the center position of the camera view + * @param latLng {LatLng} + */ + @CordovaInstance({ sync: true }) + setCameraTarget(latLng: LatLng): void { } + + /** + * Set zoom level of the camera + * @param zoomLevel {number} Zoom level + */ + @CordovaInstance({ sync: true }) + setCameraZoom(zoomLevel: number): void {} + + /** + * Set the camera view angle + * @param tiltLevel {number} Tilt level + */ + @CordovaInstance({ sync: true }) + setCameraTilt(tiltLevel: number): void {} + + /** + * Set camera bearing + * @param bearing {any} + */ + @CordovaInstance({ sync: true }) + setCameraBearing(bearing: any): void {} + + /** + * Change the center of the map by the given distance in pixels + * @param x {any} + * @param y {any} + */ + @CordovaInstance({ sync: true }) + panBy(x: string | number, y: string | number): void { } + + /** + * Get the current visible region (sw and ne) + * @returns {Promise} + */ + @CordovaInstance() + getVisibleRegion(): Promise { return; } + + /** + * Get the current device location + * @returns {Promise} + */ + @CordovaInstance() + getMyLocation(options?: MyLocationOptions): Promise { return; } + + /** + * Set false to ignore all clicks on the map + * @param isClickable {boolean} + */ + @CordovaInstance({ sync: true }) + setClickable(isClickable: boolean): void {} + + /** + * Destroy a map completely + */ + @CordovaInstance({ sync: true }) + remove(): void {} + + /** + * Remove all overlays, such as marker + */ + @CordovaInstance({ sync: true }) + clear(): void {} + + /** + * Convert the unit from LatLng to the pixels from the left/top of the map div + * @returns {Promise} + */ + @CordovaInstance() + fromLatLngToPoint(latLng: LatLng): Promise { return; } + + /** + * Convert the unit from the pixels from the left/top to the LatLng + * @returns {Promise} + */ + @CordovaInstance() + fromPointToLatLng(point: any): Promise { return; } + + /** + * Set true if you want to show the MyLocation button + * @param enabled {boolean} + */ + @CordovaInstance({ sync: true }) + setMyLocationEnabled(enabled: boolean): void {} + + /** + * Get the currently focused building + * @return {Promise} + */ + @CordovaInstance() + getFocusedBuilding(): Promise { return; } + + /** + * Set true if you want to show the indoor map + * @param enabled {boolean} + */ + @CordovaInstance({ sync: true }) + setIndoorEnabled(enabled: boolean): void {} + + /** + * Set true if you want to show the traffic layer + * @param enabled {boolean} + */ + @CordovaInstance({ sync: true }) + setTrafficEnabled(enabled: boolean): void {} + + /** + * Set true if you want to show the compass button + * @param enabled {boolean} + */ + @CordovaInstance({ sync: true }) + setCompassEnabled(enabled: boolean): void {} + + /** + * Sets the preference for whether all gestures should be enabled or disabled + * @param enabled {boolean} + */ + @CordovaInstance({ sync: true }) + setAllGesturesEnabled(enabled: boolean): void {} + + /** + * Set visiblity of the map + * @param visible {boolean} + */ + @CordovaInstance({ sync: true }) + setVisible(visible: boolean): void {} + + /** + * Adjust the map padding + * @param top {number} + * @param right {number} + * @param left {number} + * @param bottom {number} + */ + @CordovaInstance({ sync: true }) + setPadding(top?: number, right?: number, bottom?: number, left?: number): void { } + + /** + * Set options + * @param options + */ + @CordovaInstance({ sync: true }) + setOptions(options: any): void {} + + /** + * Adds a marker + * @returns {Promise} + */ + @InstanceCheck() + addMarker(options: MarkerOptions): Promise { + return new Promise((resolve, reject) => { + this._objectInstance.addMarker(options, (marker: any) => { + if (marker) { + resolve(new Marker(marker)); + } else { + reject(); + } + }); + }); + } + + /** + * Adds a circle + * @returns {Promise} + */ + @InstanceCheck() + addCircle(options: CircleOptions): Promise { + return new Promise((resolve, reject) => { + this._objectInstance.addCircle(options, (circle: any) => { + if (circle) { + resolve(new Circle(circle)); + } else { + reject(); + } + }); + }); + } + + /** + * Adds a polygon + * @returns {Promise} + */ + @InstanceCheck() + addPolygon(options: PolygonOptions): Promise { + return new Promise((resolve, reject) => { + this._objectInstance.addPolygon(options, (polygon: any) => { + if (polygon) { + resolve(new Polygon(polygon)); + } else { + reject(); + } + }); + }); + } + + /** + * + * @returns {Promise} + */ + @InstanceCheck() + addPolyline(options: PolylineOptions): Promise { + return new Promise((resolve, reject) => { + this._objectInstance.addPolyline(options, (polyline: any) => { + if (polyline) { + resolve(new Polyline(polyline)); + } else { + reject(); + } + }); + }); + } + + /** + * @returns {Promise} + */ + @InstanceCheck() + addTileOverlay(options: TileOverlayOptions): Promise { + return new Promise((resolve, reject) => { + this._objectInstance.addTileOverlay(options, (tileOverlay: any) => { + if (tileOverlay) { + resolve(new TileOverlay(tileOverlay)); + } else { + reject(); + } + }); + }); + } + + /** + * @returns {Promise} + */ + @InstanceCheck() + addGroundOverlay(options: GroundOverlayOptions): Promise { + return new Promise((resolve, reject) => { + this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => { + if (groundOverlay) { + resolve(new GroundOverlay(groundOverlay)); + } else { + reject(); + } + }); + }); + } + + /** + * Refreshes layout. + * You can execute it, but you don't need to do that. The plugin does this automatically. + */ + @CordovaInstance({ sync: true }) + refreshLayout(): void {} + + /** + * @returns {Promise} + */ + @CordovaInstance() + toDataURL(): Promise { return; } + + // /** + // * @returns {Promise} + // */ + // @InstanceCheck() + // addKmlOverlay(options: KmlOverlayOptions): Promise { + // return new Promise((resolve, reject) => { + // this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => { + // if (kmlOverlay) { + // resolve(new KmlOverlay(kmlOverlay)); + // } else { + // reject(); + // } + // }); + // }); + // } +} + +/** + * @hidden + */ +export class GroundOverlay extends BaseClass { + + constructor(_objectInstance: any) { + super(); + this._objectInstance = _objectInstance; + } + + /** + * Change the bounds of the GroundOverlay + * @param bounds {ILatLng[]} + */ + @CordovaInstance({ sync: true }) + setBounds(bounds: ILatLng[]): void {} + + /** + * Return the current center position + * @return {ILatLng[]} + */ + @CordovaInstance({ sync: true }) + getBounds(): ILatLng[] { return; } + + /** + * Change the bearing of the ground overlay + * @param bearing {number} + */ + @CordovaInstance({ sync: true }) + setBearing(bearing: number): void { } + + /** + * Return the current bearing value + */ + @CordovaInstance({ sync: true }) + getBearing(): number { return; } + + /** + * Change the image of the ground overlay + * @param image {string} URL of image + */ + @CordovaInstance({ sync: true }) + setImage(image: string): void {}; + + /** + * Change the opacity of the ground overlay + * @param opacity {number} + */ + @CordovaInstance({ sync: true }) + setOpacity(opacity: number): void { } + + /** + * Return the current opacity + * @return {number} + */ + @CordovaInstance({ sync: true }) + getOpacity(): number { return; } + + /** + * Change clickablity of the ground overlay + * @param clickable {boolean} + */ + @CordovaInstance({ sync: true }) + setClickable(clickable: boolean): void {} + + /** + * Return true if the ground overlay is clickable + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + getClickable(): boolean { return; } + + /** + * Change visibility of the ground overlay + * @param visible {boolean} + */ + @CordovaInstance({ sync: true }) + setVisible(visible: boolean): void { } + + /** + * Return true if the ground overlay is visible + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + getVisible(): boolean { return; } + + /** + * Change the ground overlay zIndex order + * @param index {number} + */ + @CordovaInstance({ sync: true }) + setZIndex(index: number): void {} + + /** + * Return the current ground overlay zIndex + * @return {number} + */ + @CordovaInstance({ sync: true }) + getZIndex(): number { return; } + + /** + * Remove the ground overlay + */ + @CordovaInstance({ sync: true }) + remove(): void {} + +} + +/** + * @hidden + */ +export class HtmlInfoWindow extends BaseClass { + + constructor() { + super(); + if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) { + this._objectInstance = new (GoogleMaps.getPlugin()).HtmlInfoWindow(); + } + } + + /** + * Change the backgroundColor + * @param color {string} + */ + @CordovaInstance() + setBackgroundColor(color: string): void {} + + /** + * Set your HTML contents. + * @param content {any} String containing text or HTML element + */ + @CordovaInstance() + setContent(content: string | Element): void {} + + /** + * Open the htmlInfoWindow + * @param marker {Marker} + */ + @CordovaInstance() + open(marker: any): any {} + + /** + * Close the htmlInfoWindow + */ + @CordovaInstance() + close(): void {} + +} + +/** + * @hidden + */ +export class LatLng implements ILatLng { + + lat: number; + lng: number; + + constructor(lat: number, lng: number) { + this.lat = lat; + this.lng = lng; + } + + equals(other: ILatLng): boolean { + return this.lat === other.lat && this.lng === other.lng; + } + + toString(): string { + return this.lat + ',' + this.lng; + } + + toUrlValue(precision?: number): string { + precision = precision || 6; + + return this.lat.toFixed(precision) + ',' + this.lng.toFixed(precision); + } +} + +/** + * @hidden + */ +export class LatLngBounds { + private _objectInstance: any; + + @InstanceProperty northeast: LatLng; + @InstanceProperty southwest: LatLng; + @InstanceProperty type: string; + + constructor(southwestOrArrayOfLatLng: LatLng | LatLng[], northeast?: LatLng) { + let args = !!northeast ? [southwestOrArrayOfLatLng, northeast] : southwestOrArrayOfLatLng; + this._objectInstance = new (GoogleMaps.getPlugin()).LatLngBounds(args); + } + + /** + * Converts to string + * @return {string} + */ + @CordovaInstance({ sync: true }) + toString(): string { return; } + + /** + * Returns a string of the form "lat_lo,lng_lo,lat_hi,lng_hi" for this bounds, where "lo" corresponds to the southwest corner of the bounding box, while "hi" corresponds to the northeast corner of that box. + * @param precision {number} + * @return {string} + */ + @CordovaInstance({ sync: true }) + toUrlValue(precision?: number): string { return; } + + /** + * Extends this bounds to contain the given point. + * @param LatLng {ILatLng} + */ + @CordovaInstance({ sync: true }) + extend(LatLng: ILatLng): void {} + + /** + * Returns true if the given lat/lng is in this bounds. + * @param LatLng {ILatLng} + */ + @CordovaInstance({ sync: true }) + contains(LatLng: ILatLng): boolean { return; } + + /** + * Computes the center of this LatLngBounds + * @return {ILatLng} + */ + @CordovaInstance({ sync: true }) + getCenter(): LatLng { return; } +} + +/** + * @hidden + */ +export class Marker extends BaseClass { + + constructor(_objectInstance: any) { + super(); + this._objectInstance = _objectInstance; + } + + /** + * Set the marker position. + * @param latLng {LatLng} + */ + @CordovaInstance({ sync: true }) + setPosition(latLng: LatLng): void { return; } + + /** + * Return the marker position. + * @return {Promise} + */ + @CordovaInstance() + getPosition(): Promise { return; } + + /** + * Show the infoWindow of the marker. + * @return {number} + */ + @CordovaInstance({ sync: true }) + showInfoWindow(): number { return; } + + /** + * Hide the infoWindow of the marker. + * @return {number} + */ + @CordovaInstance({ sync: true }) + hideInfoWindow(): number { return; } + + /** + * Specify the animation either `DROP` or `BOUNCE` + * @param animation {string} + */ + @CordovaInstance({ sync: true }) + setAnimation(animation: string): void {} + + /** + * Set true if you **do not want** to move the map when you click on the marker. + * @param disableAutoPan {boolean} + */ + @CordovaInstance({ sync: true }) + setDisableAutoPan(disableAutoPan: boolean): void {} + + /** + * Set false if you want to hide the marker. + * @param visible + */ + @CordovaInstance() + setVisible(visible: boolean): void {} + /** * Return true if the marker is visible */ @@ -711,31 +1455,39 @@ export class Marker { isVisible(): boolean { return; } /** - * Set false if you want to hide the marker. - * @param visible - */ - @CordovaInstance() - setVisible(visible: boolean): void { } - - /** - * Return the marker hash code. - * @return {string} Marker hash code + * Change title of the infoWindow. + * @param title {string} */ @CordovaInstance({ sync: true }) - getHashCode(): string { return; } + setTitle(title: string): void {} /** - * Remove the marker completely. + * Return the title strings. + * @return {string} */ @CordovaInstance({ sync: true }) - remove(): void { } + getTitle(): string { return; } + + /** + * Change snippet of the infoWindow. + * @param snippet {string} + */ + @CordovaInstance({ sync: true }) + setSnippet(snippet: string): void {} + + /** + * Return the snippet strings. + * @return {string} + */ + @CordovaInstance({ sync: true }) + getSnippet(): string { return; } /** * Change the marker opacity. * @param alpha {number} Opacity */ @CordovaInstance({ sync: true }) - setOpacity(alpha: number): void { } + setOpacity(alpha: number): void {} /** * Return the marker opacity. @@ -745,11 +1497,10 @@ export class Marker { getOpacity(): number { return; } /** - * iOS only, Plugin Version >= 1.3.3 Higher zIndex value overlays will be drawn on top of lower zIndex value tile layers and overlays. (You're able to run this on Android, but it will have no effect) - * @return {number} + * Remove the marker completely. */ @CordovaInstance({ sync: true }) - setZIndex(): number { return; } + remove(): void {} /** * Change the info window anchor. This defaults to 50% from the left of the image and at the bottom of the image. @@ -757,7 +1508,7 @@ export class Marker { * @param y {number} */ @CordovaInstance({ sync: true }) - setIconAnchor(x: number, y: number): void { } + setIconAnchor(x: number, y: number): void {} /** * Change the info window anchor. This defaults to 50% from the left of the image and at the top of the image. @@ -765,7 +1516,34 @@ export class Marker { * @param y {number} */ @CordovaInstance({ sync: true }) - setInfoWindowAnchor(x: number, y: number): void { } + setInfoWindowAnchor(x: number, y: number): void {} + + /** + * Retrurn true if the infoWindow is shown on the marker + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + isInfoWindowShown(): boolean { return; } + + /** + * Return the marker hash code. + * @return {string} Marker hash code + */ + @CordovaInstance({ sync: true }) + getHashCode(): string { return; } + + /** + * iOS only, Plugin Version >= 1.3.3 Higher zIndex value overlays will be drawn on top of lower zIndex value tile layers and overlays. (You're able to run this on Android, but it will have no effect) + */ + @CordovaInstance({ sync: true }) + setZIndex(): void {} + + /** + * Get z-index + * @return {number} + */ + @CordovaInstance({ sync: true }) + getZIndex(): number { return; } /** * Set true if you allows all users to drag the marker. @@ -795,34 +1573,6 @@ export class Marker { @CordovaInstance({ sync: true }) setIcon(icon: MarkerIcon): void { return; } - /** - * Change title of the infoWindow. - * @param title {string} - */ - @CordovaInstance({ sync: true }) - setTitle(title: string): void { } - - /** - * Return the title strings. - * @return {string} - */ - @CordovaInstance({ sync: true }) - getTitle(): string { return; } - - /** - * Change snippet of the infoWindow. - * @param snippet {string} - */ - @CordovaInstance({ sync: true }) - setSnippet(snippet: string): void { } - - /** - * Return the snippet strings. - * @return {string} - */ - @CordovaInstance({ sync: true }) - getSnippet(): string { return; } - /** * Set the marker rotation angle. * @param rotation {number} @@ -837,937 +1587,443 @@ export class Marker { @CordovaInstance({ sync: true }) getRotation(): number { return; } - /** - * Show the infoWindow of the marker. - * @return {number} - */ - @CordovaInstance({ sync: true }) - showInfoWindow(): number { return; } - - /** - * Hide the infoWindow of the marker. - * @return {number} - */ - @CordovaInstance({ sync: true }) - hideInfoWindow(): number { return; } - - /** - * Set the marker position. - * @param latLng {LatLng} - */ - @CordovaInstance({ sync: true }) - setPosition(latLng: LatLng): void { return; } - - /** - * Return the marker position. - * @return {Promise} - */ - @CordovaInstance() - getPosition(): Promise { return; } - /** * Return the map instance. - * @return {GoogleMap} + * Note that this method returns the original Google Map object, and not the Ionic Native wrapper. + * @return {Object} */ @CordovaInstance({ sync: true }) - getMap(): GoogleMap { return; } - - /** - * Specify the animation either `DROP` or `BOUNCE` - * @param animation {string} - */ - @CordovaInstance({ sync: true }) - setAnimation(animation: string): void { } + getMap(): any { return; } } /** * @hidden */ -export interface CircleOptions { - center?: LatLng; - radius?: number; - strokeColor?: string; - strokeWidth?: number; - fillColor?: string; - visible?: boolean; - zIndex?: number; -} +export class Polygon extends BaseClass { -/** - * @hidden - */ - -export class Circle { - - constructor(private _objectInstance: any) { } - - /** - * Adds an event listener. - * - * @returns {Observable} - */ - addEventListener(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); + constructor(_objectInstance: any) { + super(); + this._objectInstance = _objectInstance; } /** - * Adds an event listener that works once. - * - * @returns {Promise} - */ - addListenerOnce(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.addListenerOnce(eventName, resolve) - ); - } - - /** - * Gets a value - * @param key + * Change the polygon points. + * @param points {ILatLng[]} */ @CordovaInstance({ sync: true }) - get(key: string): any { return; } + setPoints(points: ILatLng[]): void {} /** - * Sets a value - * @param key - * @param value + * Return an instance of the BaseArrayClass. + * You can modify the points. + * @return {BaseArrayClass} */ @CordovaInstance({ sync: true }) - set(key: string, value: any): void { } + getPoints(): BaseArrayClass { return; } /** - * Listen to a map event. - * - * @returns {Observable} + * Change the polygon holes. + * @param holes {ILatLng[][]} */ - on(eventName: string): Observable { - if (!this._objectInstance) { - return new Observable((observer) => { - observer.error({ error: 'plugin_not_installed' }); - }); - } - - return new Observable( - (observer) => { - this._objectInstance.on(eventName, observer.next.bind(observer)); - return () => this._objectInstance.off(event); - } - ); - } + @CordovaInstance({ sync: true }) + setHoles(holes: ILatLng[][]): void {} /** - * Listen to a map event only once. - * - * @returns {Promise} + * Return an instance of the BaseArrayClass. + * You can modify the holes. + * @return {BaseArrayClass} */ - one(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.one(eventName, resolve) - ); - } + @CordovaInstance({ sync: true }) + getHoles(): BaseArrayClass { return; } /** - * Clears all stored values + * Change the filling color (inner color) + * @param fillColor {string} */ @CordovaInstance({ sync: true }) - empty(): void { } + setFillColor(fillColor: string): void {} + /** + * Return the current polygon filling color (inner color). + * @return {string} + */ @CordovaInstance({ sync: true }) - getCenter(): LatLng { return; } + getFillColor(): string { return; } + /** + * Change the stroke color (outter color) + * @param strokeColor {string} + */ @CordovaInstance({ sync: true }) - getRadius(): number { return; } + setStrokeColor(strokeColor: string): void {} + /** + * Return the current polygon stroke color (outer color) + * @return {string} + */ @CordovaInstance({ sync: true }) getStrokeColor(): string { return; } + /** + * Change clickablity of the polygon + * @param clickable {boolean} + */ + @CordovaInstance({ sync: true }) + setClickable(clickable: boolean): void {} + + /** + * Return true if the polygon is clickable + */ + @CordovaInstance({ sync: true }) + getClickable(): boolean { return; } + + /** + * Change visibility of the polygon + * @param visible {boolean} + */ + @CordovaInstance({ sync: true }) + setVisible(visible: boolean): void {} + + /** + * Return true if the polygon is visible + * @return {boolean} + */ @CordovaInstance({ sync: true }) getVisible(): boolean { return; } + /** + * Change the polygon zIndex order. + * @param zIndex {number} + */ + @CordovaInstance({ sync: true }) + setZIndex(zIndex: number): void {} + + /** + * Return the current polygon zIndex + * @return {number} + */ @CordovaInstance({ sync: true }) getZIndex(): number { return; } @CordovaInstance({ sync: true }) - remove(): void { } + remove(): void {} @CordovaInstance({ sync: true }) - setCenter(latLng: LatLng): void { } - - @CordovaInstance({ sync: true }) - setFillColor(fillColor: string): void { } - - @CordovaInstance({ sync: true }) - setStrokeColor(strokeColor: string): void { } - - @CordovaInstance({ sync: true }) - setStrokeWidth(strokeWidth: number): void { } - - @CordovaInstance({ sync: true }) - setVisible(visible: boolean): void { } - - @CordovaInstance({ sync: true }) - setZIndex(zIndex: number): void { } - - @CordovaInstance({ sync: true }) - setRadius(radius: number): void { } - - @CordovaInstance({ sync: true }) - getMap(): GoogleMap { return; } -} - -/** - * @hidden - */ -export interface PolylineOptions { - points?: Array; - visible?: boolean; - geodesic?: boolean; - color?: string; - width?: number; - zIndex?: number; -} - -/** - * @hidden - */ - -export class Polyline { - constructor(private _objectInstance: any) { } - - /** - * Adds an event listener. - * - * @returns {Observable} - */ - addEventListener(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); - } - - /** - * Adds an event listener that works once. - * - * @returns {Promise} - */ - addListenerOnce(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.addListenerOnce(eventName, resolve) - ); - } - - /** - * Gets a value - * @param key - */ - @CordovaInstance({ sync: true }) - get(key: string): any { return; } - - /** - * Sets a value - * @param key - * @param value - */ - @CordovaInstance({ sync: true }) - set(key: string, value: any): void { } - - /** - * Listen to a map event. - * - * @returns {Observable} - */ - on(eventName: string): Observable { - if (!this._objectInstance) { - return new Observable((observer) => { - observer.error({ error: 'plugin_not_installed' }); - }); - } - - return new Observable( - (observer) => { - this._objectInstance.on(eventName, observer.next.bind(observer)); - return () => this._objectInstance.off(event); - } - ); - } - - /** - * Listen to a map event only once. - * - * @returns {Promise} - */ - one(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.one(eventName, resolve) - ); - } - - /** - * Clears all stored values - */ - @CordovaInstance({ sync: true }) - empty(): void { } - - @CordovaInstance({ sync: true }) - getPoints(): Array { return; } - - @CordovaInstance({ sync: true }) - getCOlor(): string { return; } - - @CordovaInstance({ sync: true }) - getWidth(): number { return; } - - @CordovaInstance({ sync: true }) - getGeodesic(): boolean { return; } - - @CordovaInstance({ sync: true }) - getZIndex(): number { return; } - - @CordovaInstance({ sync: true }) - remove(): void { } - - @CordovaInstance({ sync: true }) - setPoints(points: Array): void { } - - @CordovaInstance({ sync: true }) - setColor(color: string): void { } - - @CordovaInstance({ sync: true }) - setWidth(width: number): void { } - - @CordovaInstance({ sync: true }) - setVisible(visible: boolean): void { } - - @CordovaInstance({ sync: true }) - setZIndex(zIndex: number): void { } - - @CordovaInstance({ sync: true }) - setGeoDesic(geoDesic: boolean): void { } - - @CordovaInstance({ sync: true }) - getMap(): GoogleMap { return; } - -} - -/** - * @hidden - */ -export interface PolygonOptions { - points?: Array; - geodesic?: boolean; - strokeColor?: string; - strokeWidth?: number; - fillColor?: string; - visible?: boolean; - zIndex?: number; - addHole?: Array; -} - -/** - * @hidden - */ - -export class Polygon { - - constructor(private _objectInstance: any) { } - - /** - * Adds an event listener. - * - * @returns {Observable} - */ - addEventListener(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); - } - - /** - * Adds an event listener that works once. - * - * @returns {Promise} - */ - addListenerOnce(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.addListenerOnce(eventName, resolve) - ); - } - - /** - * Gets a value - * @param key - */ - @CordovaInstance({ sync: true }) - get(key: string): any { return; } - - /** - * Sets a value - * @param key - * @param value - */ - @CordovaInstance({ sync: true }) - set(key: string, value: any): void { } - - /** - * Listen to a map event. - * - * @returns {Observable} - */ - on(eventName: string): Observable { - if (!this._objectInstance) { - return new Observable((observer) => { - observer.error({ error: 'plugin_not_installed' }); - }); - } - - return new Observable( - (observer) => { - this._objectInstance.on(eventName, observer.next.bind(observer)); - return () => this._objectInstance.off(event); - } - ); - } - - /** - * Listen to a map event only once. - * - * @returns {Promise} - */ - one(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.one(eventName, resolve) - ); - } - - /** - * Clears all stored values - */ - @CordovaInstance({ sync: true }) - empty(): void { } - - @CordovaInstance({ sync: true }) - getPoints(): Array { return; } - - @CordovaInstance({ sync: true }) - getStrokeColor(): string { return; } - - @CordovaInstance({ sync: true }) - getFillColor(): string { return; } + setStrokeWidth(strokeWidth: number): void {} @CordovaInstance({ sync: true }) getStrokeWidth(): number { return; } + /** + * When true, edges of the polygon are interpreted as geodesic and will follow the curvature of the Earth. + * @param geodesic {boolean} + */ + @CordovaInstance({ sync: true }) + setGeodesic(geodesic: boolean): void {} + + /** + * Return true if the polylgon is geodesic. + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + getGeodesic(): boolean { return; } +} + +/** + * @hidden + */ +export class Polyline extends BaseClass { + + constructor(_objectInstance: any) { + super(); + this._objectInstance = _objectInstance; + } + + /** + * Change the polyline points. + * @param points {ILatLng[]} + */ + @CordovaInstance({ sync: true }) + setPoints(points: ILatLng[]): void {} + + /** + * Return an instance of the BaseArrayClass + * You can modify the points. + */ + @CordovaInstance({ sync: true }) + getPoints(): BaseArrayClass { return; } + + /** + * When true, edges of the polyline are interpreted as geodesic and will follow the curvature of the Earth. + * @param geoDesic {boolean} + */ + @CordovaInstance({ sync: true }) + setGeoDesic(geoDesic: boolean): void {} + + /** + * Return true if the polyline is geodesic + */ @CordovaInstance({ sync: true }) getGeodesic(): boolean { return; } + /** + * Change visibility of the polyline + * @param visible {boolean} + */ + @CordovaInstance({ sync: true }) + setVisible(visible: boolean): void {} + + /** + * Return true if the polyline is visible + * @return {boolean} + */ @CordovaInstance({ sync: true }) getVisible(): boolean { return; } - @CordovaInstance({ sync: true }) - getZIndex(): boolean { return; } - - @CordovaInstance({ sync: true }) - remove(): void { } - - @CordovaInstance({ sync: true }) - setPoints(points: Array): void { } - - @CordovaInstance({ sync: true }) - setStrokeColor(strokeColor: string): void { } - - @CordovaInstance({ sync: true }) - setFillColor(fillColor: string): void { } - - @CordovaInstance({ sync: true }) - setStrokeWidth(strokeWidth: number): void { } - - @CordovaInstance({ sync: true }) - setVisible(visible: boolean): void { } - - @CordovaInstance({ sync: true }) - setZIndex(zIndex: number): void { } - - @CordovaInstance({ sync: true }) - setGeodesic(geodesic: boolean): void { } -} - -/** - * @hidden - */ -export interface TileOverlayOptions { - tileUrlFormat?: string; - visible?: boolean; - zIndex?: number; - tileSize?: number; - opacity?: number; -} - -/** - * @hidden - */ -export class TileOverlay { - - constructor(private _objectInstance: any) { } - /** - * Adds an event listener. - * - * @returns {Observable} - */ - addEventListener(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); - } - - /** - * Adds an event listener that works once. - * - * @returns {Promise} - */ - addListenerOnce(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.addListenerOnce(eventName, resolve) - ); - } - - /** - * Gets a value - * @param key + * Change clickablity of the polyline + * @param clickable {boolean} */ @CordovaInstance({ sync: true }) - get(key: string): any { return; } + setClickable(clickable: boolean): void {} /** - * Sets a value - * @param key - * @param value + * Return true if the polyline is clickable + * @return {boolean} */ @CordovaInstance({ sync: true }) - set(key: string, value: any): void { } + getClickable(): boolean { return; } /** - * Listen to a map event. - * - * @returns {Observable} + * Change the polyline color + * @param strokeColor {string} */ - on(eventName: string): Observable { - if (!this._objectInstance) { - return new Observable((observer) => { - observer.error({ error: 'plugin_not_installed' }); - }); - } - - return new Observable( - (observer) => { - this._objectInstance.on(eventName, observer.next.bind(observer)); - return () => this._objectInstance.off(event); - } - ); - } + @CordovaInstance({ sync: true }) + setStrokeColor(strokeColor: string): void {} /** - * Listen to a map event only once. - * - * @returns {Promise} + * Return the current polyline color + * @return {string} */ - one(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.one(eventName, resolve) - ); - } + @CordovaInstance({ sync: true }) + getStrokeColor(): string { return; } /** - * Clears all stored values + * Change the polyline stroke width + * @param strokeWidth {number} */ @CordovaInstance({ sync: true }) - empty(): void { } + setStrokeWidth(strokeWidth: number): void {} + /** + * Return the current stroke width (unit: pixel). + * @return {number} + */ @CordovaInstance({ sync: true }) - getVisible(): boolean { return; } + getStrokeWidth(): number { return; } + /** + * Change the polyline zIndex order. + * @param index {number} + */ @CordovaInstance({ sync: true }) - setVisible(visible: boolean): void { } - - @CordovaInstance({ sync: true }) - getFadeIn(): boolean { return; } - - @CordovaInstance({ sync: true }) - setFadeIn(fadeIn: boolean): void { } + setZIndex(index: number): void {} + /** + * Return the current polyline zIndex + * @return {number} + */ @CordovaInstance({ sync: true }) getZIndex(): number { return; } + /** + * Remove the polyline + */ @CordovaInstance({ sync: true }) - setZIndex(zIndex: number): void { } + remove(): void {} @CordovaInstance({ sync: true }) - getOpacity(): number { return; } - - @CordovaInstance({ sync: true }) - setOpacity(opacity: number): void { } - - @CordovaInstance({ sync: true }) - clearTileCache(): void { } - - @CordovaInstance({ sync: true }) - remove(): void { } + getMap(): any { return; } } /** * @hidden */ -export interface GroundOverlayOptions { - url?: string; - bounds?: Array; - visible?: boolean; - opacity?: number; - bearing?: number; - zIndex?: number; -} +export class TileOverlay extends BaseClass { -/** - * @hidden - */ -export class GroundOverlay { - - constructor(private _objectInstance: any) { } - - /** - * Adds an event listener. - * - * @returns {Observable} - */ - addEventListener(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); + constructor(_objectInstance: any) { + super(); + this._objectInstance = _objectInstance; } /** - * Adds an event listener that works once. - * - * @returns {Promise} + * Set whether the tiles should fade in. + * @param fadeIn {boolean} */ - addListenerOnce(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - (resolve: Function) => this._objectInstance.addListenerOnce(eventName, resolve) - ); - } + @CordovaInstance({ sync: true }) + setFadeIn(fadeIn: boolean): void {} /** - * Gets a value - * @param key + * Get whether the tiles should fade in + * @return {boolean} */ @CordovaInstance({ sync: true }) - get(key: string): any { return; } + getFadeIn(): boolean { return; } /** - * Sets a value - * @param key - * @param value + * Set the zIndex of the tile overlay + * @param zIndex {number} */ @CordovaInstance({ sync: true }) - set(key: string, value: any): void { } + setZIndex(zIndex: number): void {} /** - * Listen to a map event. - * - * @returns {Observable} + * Return the zIndex of the tile overlay + * @return {number} */ - on(eventName: string): Observable { - if (!this._objectInstance) { - return new Observable((observer) => { - observer.error({ error: 'plugin_not_installed' }); - }); - } - - return new Observable( - (observer) => { - this._objectInstance.on(eventName, observer.next.bind(observer)); - return () => this._objectInstance.off(event); - } - ); - } + @CordovaInstance({ sync: true }) + getZIndex(): number { return; } /** - * Listen to a map event only once. - * - * @returns {Promise} + * Set the opacity of the tile overlay + * @param opacity {number} */ - one(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.one(eventName, resolve) - ); - } + @CordovaInstance({ sync: true }) + setOpacity(opacity: number): void {} /** - * Clears all stored values + * Return the opacity of the tile overlay + * @return {number} */ - @CordovaInstance({ sync: true }) - empty(): void { } - - @CordovaInstance({ sync: true }) - setBearing(bearing: number): void { } - - @CordovaInstance({ sync: true }) - getBearing(): number { return; } - - @CordovaInstance({ sync: true }) - setOpacity(opacity: number): void { } - @CordovaInstance({ sync: true }) getOpacity(): number { return; } + /** + * Set false if you want to hide + * @param visible {boolean} + */ @CordovaInstance({ sync: true }) - setVisible(visible: boolean): void { } + setVisible(visible: boolean): void {} + /** + * Return true if the tile overlay is visible + * @return {boolean} + */ @CordovaInstance({ sync: true }) getVisible(): boolean { return; } + /** + * Get tile size + */ @CordovaInstance({ sync: true }) - setImage(image: string): void { }; + getTileSize(): any { return; } + /** + * Remove the tile overlay + */ @CordovaInstance({ sync: true }) - remove(): void { } + remove(): void {} } -/** - * @hidden - */ -export interface KmlOverlayOptions { - url?: string; - preserveViewport?: boolean; - animation?: boolean; -} - -/** - * @hidden - */ -export class KmlOverlay { - - constructor(private _objectInstance: any) { } - - /** - * Adds an event listener. - * - * @returns {Observable} - */ - addEventListener(eventName: string): Observable { - return Observable.fromEvent(this._objectInstance, eventName); - } - - /** - * Adds an event listener that works once. - * - * @returns {Promise} - */ - addListenerOnce(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.addListenerOnce(eventName, resolve) - ); - } - - /** - * Gets a value - * @param key - */ - @CordovaInstance({ sync: true }) - get(key: string): any { return; } - - /** - * Sets a value - * @param key - * @param value - */ - @CordovaInstance({ sync: true }) - set(key: string, value: any): void { } - - /** - * Listen to a map event. - * - * @returns {Observable} - */ - on(eventName: string): Observable { - if (!this._objectInstance) { - return new Observable((observer) => { - observer.error({ error: 'plugin_not_installed' }); - }); - } - - return new Observable( - (observer) => { - this._objectInstance.on(eventName, observer.next.bind(observer)); - return () => this._objectInstance.off(event); - } - ); - } - - /** - * Listen to a map event only once. - * - * @returns {Promise} - */ - one(eventName: string): Promise { - if (!this._objectInstance) { - return Promise.reject({ error: 'plugin_not_installed' }); - } - return new Promise( - resolve => this._objectInstance.one(eventName, resolve) - ); - } - - /** - * Clears all stored values - */ - @CordovaInstance({ sync: true }) - empty(): void { } - - @CordovaInstance({ sync: true }) - remove(): void { } - - @CordovaInstance({ sync: true }) - getOverlays(): Array { return; } -} - -/** - * @hidden - */ -export class LatLngBounds { - private _objectInstance: any; - - @InstanceProperty northeast: LatLng; - @InstanceProperty southwest: LatLng; - @InstanceProperty type: string; - - constructor(southwestOrArrayOfLatLng: LatLng | LatLng[], northeast?: LatLng) { - let args = !!northeast ? [southwestOrArrayOfLatLng, northeast] : southwestOrArrayOfLatLng; - this._objectInstance = new plugin.google.maps.LatLngBounds(args); - } - - @CordovaInstance({ sync: true }) - toString(): string { return; } - - @CordovaInstance({ sync: true }) - toUrlValue(precision?: number): string { return; } - - @CordovaInstance({ sync: true }) - extend(LatLng: LatLng): void { } - - @CordovaInstance({ sync: true }) - contains(LatLng: LatLng): boolean { return; } - - @CordovaInstance({ sync: true }) - getCenter(): LatLng { return; } -} - -/** - * @hidden - */ - -export class LatLng { - - lat: number; - lng: number; - - constructor(lat: number, lng: number) { - this.lat = lat; - this.lng = lng; - } - - equals(other: LatLng): boolean { - return this.lat === other.lat && this.lng === other.lng; - } - - toString(): string { - return this.lat + ',' + this.lng; - } - - toUrlValue(precision?: number): string { - precision = precision || 6; - - return this.lat.toFixed(precision) + ',' + this.lng.toFixed(precision); - } -} -/** - * @hidden - */ -export interface GeocoderRequest { - address?: string; - bounds?: LatLng[]; - position?: { lat: number; lng: number }; -} -/** - * @hidden - */ -export interface GeocoderResult { - adminArea?: string; - country?: string; - countryCode?: string; - extra?: { - featureName?: string; - lines?: Array; - permises?: string; - phone?: string; - url?: string - }; - locale?: string; - locality?: string; - position?: { lat: number; lng: number }; - postalCode?: string; - subAdminArea?: string; - subLocality?: string; - subThoroughfare?: string; - thoroughfare?: string; -} -/** - * @hidden - */ -@Plugin({ - pluginName: 'Geocoder', - pluginRef: 'plugin.google.maps.Geocoder', - plugin: 'cordova-plugin-googlemaps', - repo: '' -}) -export class Geocoder { - /** - * Converts position to address and vice versa - * @param {GeocoderRequest} request Request object with either an address or a position - * @returns {Promise} - */ - @CordovaCheck() - geocode(request: GeocoderRequest): Promise { - return new Promise((resolve: Function) => { - plugin.google.maps.Geocoder.geocode(request, resolve); - }); - } -} +// /** +// * @hidden +// */ +// export interface KmlOverlayOptions { +// url?: string; +// preserveViewport?: boolean; +// animation?: boolean; +// } +// /** +// * @hidden +// */ +// export class KmlOverlay { +// +// constructor(private _objectInstance: any) { } +// +// /** +// * Adds an event listener. +// * +// * @returns {Observable} +// */ +// addEventListener(eventName: string): Observable { +// return Observable.fromEvent(this._objectInstance, eventName); +// } +// +// /** +// * Adds an event listener that works once. +// * +// * @returns {Promise} +// */ +// addListenerOnce(eventName: string): Promise { +// if (!this._objectInstance) { +// return Promise.reject({ error: 'plugin_not_installed' }); +// } +// return new Promise( +// resolve => this._objectInstance.addListenerOnce(eventName, resolve) +// ); +// } +// +// /** +// * Gets a value +// * @param key +// */ +// @CordovaInstance({ sync: true }) +// get(key: string): any { return; } +// +// /** +// * Sets a value +// * @param key +// * @param value +// */ +// @CordovaInstance({ sync: true }) +// set(key: string, value: any): void { } +// +// /** +// * Listen to a map event. +// * +// * @returns {Observable} +// */ +// on(eventName: string): Observable { +// if (!this._objectInstance) { +// return new Observable((observer) => { +// observer.error({ error: 'plugin_not_installed' }); +// }); +// } +// +// return new Observable( +// (observer) => { +// this._objectInstance.on(eventName, observer.next.bind(observer)); +// return () => this._objectInstance.off(event); +// } +// ); +// } +// +// /** +// * Listen to a map event only once. +// * +// * @returns {Promise} +// */ +// one(eventName: string): Promise { +// if (!this._objectInstance) { +// return Promise.reject({ error: 'plugin_not_installed' }); +// } +// return new Promise( +// resolve => this._objectInstance.one(eventName, resolve) +// ); +// } +// +// /** +// * Clears all stored values +// */ +// @CordovaInstance({ sync: true }) +// empty(): void { } +// +// @CordovaInstance({ sync: true }) +// remove(): void { } +// +// @CordovaInstance({ sync: true }) +// getOverlays(): Array { return; } +// } From 3c54a1c7f5c03f2f5adb2c8a7b0e7aca9ac274bc Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 19:13:14 -0400 Subject: [PATCH 09/30] refactor(rename plugin to FileTransfer to match original plugin): (#1768) BREAKING CHANGE: Package name is now `@ionic-native/file-transfer`. `Transfer` class has been renamed to `FileTransfer`. Also, `TransferObject` class has been renamed to `FileTransferObject`. --- .../{transfer => file-transfer}/index.ts | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) rename src/@ionic-native/plugins/{transfer => file-transfer}/index.ts (89%) diff --git a/src/@ionic-native/plugins/transfer/index.ts b/src/@ionic-native/plugins/file-transfer/index.ts similarity index 89% rename from src/@ionic-native/plugins/transfer/index.ts rename to src/@ionic-native/plugins/file-transfer/index.ts index 8a66f39a7..1dd4355ca 100644 --- a/src/@ionic-native/plugins/transfer/index.ts +++ b/src/@ionic-native/plugins/file-transfer/index.ts @@ -1,8 +1,6 @@ import { Injectable } from '@angular/core'; import { CordovaInstance, Plugin, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core'; -declare const FileTransfer: any; - export interface FileUploadOptions { /** @@ -109,21 +107,21 @@ export interface FileTransferError { } /** - * @name Transfer + * @name File Transfer * * @description * This plugin allows you to upload and download files. * * @usage * ```typescript - * import { Transfer, FileUploadOptions, TransferObject } from '@ionic-native/transfer'; + * import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/transfer'; * import { File } from '@ionic-native/file'; * - * constructor(private transfer: Transfer, private file: File) { } + * constructor(private transfer: FileTransfer, private file: File) { } * * ... * - * const fileTransfer: TransferObject = this.transfer.create(); + * const fileTransfer: FileTransferObject = this.transfer.create(); * * // Upload a file: * fileTransfer.upload(..).then(..).catch(..); @@ -170,7 +168,7 @@ export interface FileTransferError { * FileUploadResult * FileTransferError * @classes - * TransferObject + * FileTransferObject */ @Plugin({ pluginName: 'FileTransfer', @@ -180,7 +178,7 @@ export interface FileTransferError { platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Ubuntu', 'Windows', 'Windows Phone'] }) @Injectable() -export class Transfer extends IonicNativePlugin { +export class FileTransfer extends IonicNativePlugin { /** * Error code rejected from upload with FileTransferError @@ -202,10 +200,10 @@ export class Transfer extends IonicNativePlugin { /** * Creates a new FileTransfer object - * @return {TransferObject} + * @return {FileTransferObject} */ - create(): TransferObject { - return new TransferObject(); + create(): FileTransferObject { + return new FileTransferObject(); } } @@ -217,12 +215,12 @@ export class Transfer extends IonicNativePlugin { plugin: 'cordova-plugin-file-transfer', pluginName: 'FileTransfer' }) -export class TransferObject { +export class FileTransferObject { private _objectInstance: any; constructor() { - if (checkAvailability('FileTransfer', null, 'FileTransfer') === true) { - this._objectInstance = new FileTransfer(); + if (checkAvailability(FileTransfer.getPluginRef(), null, FileTransfer.getPluginName()) === true) { + this._objectInstance = new (FileTransfer.getPlugin())(); } } @@ -239,9 +237,7 @@ export class TransferObject { successIndex: 2, errorIndex: 3 }) - upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise { - return; - } + upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise { return; } /** * Downloads a file from server. @@ -256,9 +252,7 @@ export class TransferObject { successIndex: 2, errorIndex: 3 }) - download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise { - return; - } + download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise { return; } /** * Registers a listener that gets called whenever a new chunk of data is transferred. @@ -276,5 +270,5 @@ export class TransferObject { @CordovaInstance({ sync: true }) - abort(): void { } + abort(): void {} } From 9f1a0f95857542330fac0b2b12ec158f6d805e67 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 19:13:25 -0400 Subject: [PATCH 10/30] refactor(media): rename main class to Media (#1769) BREAKING CHANGE: `MediaObject` class is now `Media` --- src/@ionic-native/plugins/media/index.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/@ionic-native/plugins/media/index.ts b/src/@ionic-native/plugins/media/index.ts index 5ba4da05c..465f8e0a7 100644 --- a/src/@ionic-native/plugins/media/index.ts +++ b/src/@ionic-native/plugins/media/index.ts @@ -1,9 +1,6 @@ import { Injectable } from '@angular/core'; import { CordovaInstance, Plugin, checkAvailability, IonicNativePlugin } from '@ionic-native/core'; -declare const Media: any; -// TODO for ionic native 4.x ... rename plugin class to Media and use Media.getPlugin() to retrieve the original media object - /** * @hidden */ @@ -129,12 +126,12 @@ export type MediaErrorCallback = (error: MediaError) => void; * 2.) If that's not working, too, create the file before using. * Example: * ```typescript - * import { MediaPlugin, MediaObject } from '@ionic-native/media'; + * import { Media, MediaObject } from '@ionic-native/media'; * import { File } from '@ionic-native/file'; * * ... * - * constructor(private media: MediaPlugin, private file: File) { } + * constructor(private media: Media, private file: File) { } * * ... * @@ -149,16 +146,16 @@ export type MediaErrorCallback = (error: MediaError) => void; * * @usage * ```typescript - * import { MediaPlugin, MediaObject } from '@ionic-native/media'; + * import { Media, MediaObject } from '@ionic-native/media'; * * - * constructor(private media: MediaPlugin) { } + * constructor(private media: Media) { } * * * ... * * - * // Create a MediaPlugin instance. Expects path to file or url as argument + * // Create a Media instance. Expects path to file or url as argument * // We can optionally pass a second argument to track the status of the media * * const onStatusUpdate = (status) => console.log(status); @@ -211,14 +208,14 @@ export type MediaErrorCallback = (error: MediaError) => void; * MediaError */ @Plugin({ - pluginName: 'MediaPlugin', + pluginName: 'Media', repo: 'https://github.com/apache/cordova-plugin-media', plugin: 'cordova-plugin-media', pluginRef: 'Media', platforms: ['Android', 'BlackBerry 10', 'Browser', 'iOS', 'Tizen', 'Ubuntu', 'Windows', 'Windows Phone'] }) @Injectable() -export class MediaPlugin extends IonicNativePlugin { +export class Media extends IonicNativePlugin { // Constants /** @@ -275,9 +272,9 @@ export class MediaPlugin extends IonicNativePlugin { let instance: any; - if (checkAvailability(MediaPlugin.getPluginRef(), null, MediaPlugin.getPluginName()) === true) { + if (checkAvailability(Media.getPluginRef(), null, Media.getPluginName()) === true) { // Creates a new media object - instance = new Media(src, onSuccess, onError, onStatusUpdate); + instance = new (Media.getPlugin())(src, onSuccess, onError, onStatusUpdate); } return new MediaObject(instance); From bc6bf6671e0cbf390fdddd1a099b61cd3f85396d Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 19:13:35 -0400 Subject: [PATCH 11/30] refactor(admob-pro): rename plugin from AdMob to AdMobPro (#1770) BREAKING CHANGE: `@ionic-native/admob` is now `@ionic-native/admob-pro`. Also, class name is changed from `AdMob` to `AdMobPro`. --- .../plugins/{admob => admob-pro}/index.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename src/@ionic-native/plugins/{admob => admob-pro}/index.ts (93%) diff --git a/src/@ionic-native/plugins/admob/index.ts b/src/@ionic-native/plugins/admob-pro/index.ts similarity index 93% rename from src/@ionic-native/plugins/admob/index.ts rename to src/@ionic-native/plugins/admob-pro/index.ts index 527f733dd..fbdd446e2 100644 --- a/src/@ionic-native/plugins/admob/index.ts +++ b/src/@ionic-native/plugins/admob-pro/index.ts @@ -32,7 +32,7 @@ export interface AdMobOptions { overlap?: boolean; /** - * Position of banner ad. Defaults to `TOP_CENTER`. You can use the `AdMob.AD_POSITION` property to select other values. + * Position of banner ad. Defaults to `TOP_CENTER`. You can use the `AdMobPro.AD_POSITION` property to select other values. */ position?: number; @@ -90,17 +90,17 @@ export interface AdExtras { } /** - * @name AdMob + * @name AdMobPro Pro * @description - * Plugin for Google Ads, including AdMob / DFP (doubleclick for publisher) and mediations to other Ad networks. + * Plugin for Google Ads, including AdMob / DFP (DoubleClick for publisher) and mediations to other Ad networks. * - * IMPORTANT NOTICE: this plugin takes a percentage out of your earnings if you profit more than $1,000. Read more about this on the plugin's repo. For a completely free alternative, see [AdMob Free](../admob-free). + * IMPORTANT NOTICE: this plugin takes a percentage out of your earnings if you profit more than $1,000. Read more about this on the plugin's repo. For a completely free alternative, see [AdMobPro Free](../admob-free). * @usage * ```typescript - * import { AdMob } from '@ionic-native/admob'; + * import { AdMobPro } from '@ionic-native/admob-pro'; * import { Platform } from 'ionic-angular'; * - * constructor(private admob: AdMob, private platform: Platform ) { } + * constructor(private admob: AdMobPro, private platform: Platform ) { } * * ionViewDidLoad() { * this.admob.onAdDismiss() @@ -125,14 +125,14 @@ export interface AdExtras { * AdExtras */ @Plugin({ - pluginName: 'AdMob', + pluginName: 'AdMob Pro', plugin: 'cordova-plugin-admobpro', pluginRef: 'AdMob', repo: 'https://github.com/floatinghotpot/cordova-admob-pro', platforms: ['Android', 'iOS', 'Windows Phone 8'] }) @Injectable() -export class AdMob extends IonicNativePlugin { +export class AdMobPro extends IonicNativePlugin { AD_POSITION: { NO_CHANGE: number; @@ -178,7 +178,7 @@ export class AdMob extends IonicNativePlugin { /** * Show banner at position - * @param position {number} Position. Use `AdMob.AD_POSITION` to set values. + * @param position {number} Position. Use `AdMobPro.AD_POSITION` to set values. */ @Cordova({ sync: true From d395b4278829994b4a02892d3e54203d0de9e5dd Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 19:13:45 -0400 Subject: [PATCH 12/30] feat(email-composer): update plugin to latest version and use original plugin (#1771) * change source and document interface * document addAlias example * feat(email-composer): add requestPermission and hasPermission methods * refactor(): use getPlugin() instead of referencing cordova --- .../plugins/email-composer/index.ts | 71 ++++++++++++++++--- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/src/@ionic-native/plugins/email-composer/index.ts b/src/@ionic-native/plugins/email-composer/index.ts index 1deac3f72..ad148fd14 100644 --- a/src/@ionic-native/plugins/email-composer/index.ts +++ b/src/@ionic-native/plugins/email-composer/index.ts @@ -1,28 +1,46 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; -interface Cordova { - plugins: CordovaPlugins & { email: any }; -} - -declare const cordova: Cordova; - export interface EmailComposerOptions { + /** + * App to send the email with + */ app?: string; + /** + * Email address(es) for To field + */ to?: string | Array; + /** + * Email address(es) for CC field + */ cc?: string | Array; + /** + * Email address(es) for BCC field + */ bcc?: string | Array; - attachments?: Array; + /** + * File paths or base64 data streams + */ + attachments?: string[]; + /** + * Subject of the email + */ subject?: string; + /** + * Email body (for HTML, set isHtml to true) + */ body?: string; + /** + * Indicates if the body is HTML or plain text + */ isHtml?: boolean; } @@ -67,16 +85,27 @@ export interface EmailComposerOptions { * * // Send a text message using default options * this.emailComposer.open(email); + * ``` * + * You can also assign aliases to email apps + * ```ts + * // add alias + * this.email.addAlias('gmail', 'com.google.android.gm'); + * + * // then use alias when sending email + * this.email.open({ + * app: 'gmail', + * ... + * }); * ``` * @interfaces * EmailComposerOptions */ @Plugin({ pluginName: 'EmailComposer', - plugin: 'cordova-plugin-email', + plugin: 'cordova-plugin-email-composer', pluginRef: 'cordova.plugins.email', - repo: 'https://github.com/hypery2k/cordova-email-plugin', + repo: 'https://github.com/katzer/cordova-plugin-email-composer', platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Windows'] }) @Injectable() @@ -92,7 +121,7 @@ export class EmailComposer extends IonicNativePlugin { isAvailable(app?: string): Promise { return new Promise((resolve, reject) => { if (app) { - cordova.plugins.email.isAvailable(app, (isAvailable: boolean) => { + EmailComposer.getPlugin().isAvailable(app, (isAvailable: boolean) => { if (isAvailable) { resolve(); } else { @@ -100,7 +129,7 @@ export class EmailComposer extends IonicNativePlugin { } }); } else { - cordova.plugins.email.isAvailable((isAvailable: boolean) => { + EmailComposer.getPlugin().isAvailable((isAvailable: boolean) => { if (isAvailable) { resolve(); } else { @@ -111,6 +140,26 @@ export class EmailComposer extends IonicNativePlugin { }); } + /** + * Request permission to access email accounts information + * @return {Promise} returns a promise that resolves with a boolean that indicates if the permission was granted + */ + @Cordova({ + successIndex: 0, + errorIndex: 2 + }) + requestPermission(): Promise { return; } + + /** + * Checks if the app has a permission to access email accounts information + * @return {Promise} returns a promise that resolves with a boolean that indicates if the permission was granted + */ + @Cordova({ + successIndex: 0, + errorIndex: 2 + }) + hasPermission(): Promise { return; } + /** * Adds a new mail app alias. * From 0867cfff3f6c80ca9186c43bdd9953e577139627 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 7 Jul 2017 19:29:03 -0400 Subject: [PATCH 13/30] fix(media): wrap plugin callbacks with Observables BREAKING CHANGE: the plugin's `create` method no longer takes callback functions. You must use the observables provided by the `MediaObject` instance. Refer to the updated documentation for more information. closes #1591 --- src/@ionic-native/plugins/media/index.ts | 92 ++++++++++++++---------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/src/@ionic-native/plugins/media/index.ts b/src/@ionic-native/plugins/media/index.ts index 465f8e0a7..4b93b67c7 100644 --- a/src/@ionic-native/plugins/media/index.ts +++ b/src/@ionic-native/plugins/media/index.ts @@ -1,12 +1,14 @@ import { Injectable } from '@angular/core'; import { CordovaInstance, Plugin, checkAvailability, IonicNativePlugin } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; /** * @hidden */ export class MediaObject { - constructor(private _objectInstance: any) {} + constructor(private _objectInstance: any, public onSuccess: Observable, public onError: Observable, public onStatusUpdate: Observable) {} /** * Get the current amplitude of the current recording. @@ -119,31 +121,6 @@ export type MediaErrorCallback = (error: MediaError) => void; * @description * This plugin provides the ability to record and play back audio files on a device. * - * Some hints if you are using iOS and recording doesn't work: - * 1.) Try to use a absolute file path but remove beginning "file://". - * Then it looks like: `/var/mobile/Containers/Data/Application/AF438B8B-7724-4FBB-8E69-083463224FC4/tmp/my_file.m4a` - * Example: `this.media.create(this.file.tempDirectory.replace(/^file:\/\//, '') + 'my_file.m4a')` - * 2.) If that's not working, too, create the file before using. - * Example: - * ```typescript - * import { Media, MediaObject } from '@ionic-native/media'; - * import { File } from '@ionic-native/file'; - * - * ... - * - * constructor(private media: Media, private file: File) { } - * - * ... - * - * this.file.createFile(this.file.tempDirectory, 'my_file.m4a', true).then(() => { - * let file = this.media.create(this.file.tempDirectory.replace(/^file:\/\//, '') + 'my_file.m4a'); - * file.startRecord(); - * window.setTimeout(() => file.stopRecord(), 10000); - * }); - * ``` - * - * You can find the reasons here: https://github.com/ionic-team/ionic-native/issues/1452#issuecomment-299605906 - * * @usage * ```typescript * import { Media, MediaObject } from '@ionic-native/media'; @@ -158,11 +135,15 @@ export type MediaErrorCallback = (error: MediaError) => void; * // Create a Media instance. Expects path to file or url as argument * // We can optionally pass a second argument to track the status of the media * - * const onStatusUpdate = (status) => console.log(status); - * const onSuccess = () => console.log('Action is successful.'); - * const onError = (error) => console.error(error.message); + * const file: MediaObject = this.media.create('file.mp3'); * - * const file: MediaObject = this.media.create('path/to/file.mp3', onStatusUpdate, onSuccess, onError); + * // to listen to plugin events: + * + * file.onStatusUpdate.subscribe(status => console.log(status)); // fires when file status changes + * + * file.onSuccess.subscribe(() => console.log('Action is successful')); + * + * file.onError.subscribe(error => console.log('Error!', error)); * * // play the file * file.play(); @@ -202,6 +183,31 @@ export type MediaErrorCallback = (error: MediaError) => void; * * * ``` + * + * Some hints if you are using iOS and recording doesn't work: + * 1.) Try to use a absolute file path but remove beginning "file://". + * Then it looks like: `/var/mobile/Containers/Data/Application/AF438B8B-7724-4FBB-8E69-083463224FC4/tmp/my_file.m4a` + * Example: `this.media.create(this.file.tempDirectory.replace(/^file:\/\//, '') + 'my_file.m4a')` + * 2.) If that's not working, too, create the file before using. + * Example: + * ```typescript + * import { Media, MediaObject } from '@ionic-native/media'; + * import { File } from '@ionic-native/file'; + * + * ... + * + * constructor(private media: Media, private file: File) { } + * + * ... + * + * this.file.createFile(this.file.tempDirectory, 'my_file.m4a', true).then(() => { + * let file = this.media.create(this.file.tempDirectory.replace(/^file:\/\//, '') + 'my_file.m4a'); + * file.startRecord(); + * window.setTimeout(() => file.stopRecord(), 10000); + * }); + * ``` + * + * You can find the reasons here: https://github.com/ionic-team/ionic-native/issues/1452#issuecomment-299605906 * @classes * MediaObject * @interfaces @@ -265,19 +271,33 @@ export class Media extends IonicNativePlugin { * @param [onError] {MediaErrorCallback} A callback function is be invoked if an error occurs. * @return {MediaObject} */ - create(src: string, - onStatusUpdate?: MediaStatusUpdateCallback, - onSuccess?: Function, - onError?: MediaErrorCallback): MediaObject { + create(src: string): MediaObject { - let instance: any; + let instance: any, + onSuccess: Function, + onError: Function, + onStatusUpdate: Function; + + + const onSuccessObservable: Observable = new Observable((observer: Observer) => { + onSuccess = observer.next.bind(observer); + return () => {}; + }), + onErrorObservable: Observable = new Observable((observer: Observer) => { + onError = observer.next.bind(observer); + return () => {}; + }), + onStatusUpdateObservable: Observable = new Observable((observer: Observer) => { + onStatusUpdate = observer.next.bind(observer); + return () => {}; + }); if (checkAvailability(Media.getPluginRef(), null, Media.getPluginName()) === true) { // Creates a new media object instance = new (Media.getPlugin())(src, onSuccess, onError, onStatusUpdate); } - return new MediaObject(instance); + return new MediaObject(instance, onSuccessObservable, onErrorObservable, onStatusUpdateObservable); } From aff653de2e4e12bb533a370ebce866173b2b2ab6 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Sat, 8 Jul 2017 08:43:11 -0400 Subject: [PATCH 14/30] feat(google-maps): add GoogleMapOptions interface --- .../plugins/google-maps/index.ts | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index cd1a9dac1..f83c3a696 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -4,6 +4,34 @@ import { Observable } from 'rxjs/Observable'; import { Observer } from 'rxjs/Observer'; import 'rxjs/add/observable/fromEvent'; + +export type MapType = 'MAP_TYPE_NORMAL' | 'MAP_TYPE_ROADMAP' | 'MAP_TYPE_SATELLITE' | 'MAP_TYPE_HYBRID' | 'MAP_TYPE_TERRAIN' | 'MAP_TYPE_NONE'; + +export interface GoogleMapOptions { + mapType: MapType; + controls: { + compass: boolean; + myLocationButton: boolean; + indoorPicker: boolean; + zoom: boolean; + }; + gestures: { + scroll: boolean; + tilt: boolean; + zoom: boolean; + rotate: boolean; + }; + styles: any[]; + camera: CameraPosition; + preferences: { + zoom: { + minZoom: number; + maxZoom: number; + }, + building: boolean; + }; +} + export interface AnimateCameraOptions { target?: LatLng | Array | LatLngBounds; tilt?: number; @@ -392,7 +420,7 @@ export class GoogleMaps extends IonicNativePlugin { * @param options {any} Options * @returns {GoogleMap} */ - create(element: string | HTMLElement, options?: any): GoogleMap { + create(element: string | HTMLElement, options?: GoogleMapOptions): GoogleMap { return new GoogleMap(element, options); } @@ -777,7 +805,7 @@ export class Geocoder { plugin: 'cordova-plugin-googlemaps' }) export class GoogleMap extends BaseClass { - constructor(element: string | HTMLElement, options?: any) { + constructor(element: string | HTMLElement, options?: GoogleMapOptions) { super(); if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) { if (typeof element === 'string') { @@ -1028,7 +1056,7 @@ export class GoogleMap extends BaseClass { * @param options */ @CordovaInstance({ sync: true }) - setOptions(options: any): void {} + setOptions(options: GoogleMapOptions): void {} /** * Adds a marker From 01ae8e11fc9803a0dd63bf0ff6b03cbf987e3d6b Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Sat, 8 Jul 2017 08:45:09 -0400 Subject: [PATCH 15/30] refactor(google-maps): use MapType interface instead of string --- src/@ionic-native/plugins/google-maps/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index f83c3a696..ec3616b8c 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -294,7 +294,7 @@ export const GoogleMapsAnimation: { [animationName: string]: string; } = { /** * @hidden */ -export const GoogleMapsMapTypeId: { [mapType: string]: string; } = { +export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = { NORMAL: 'MAP_TYPE_NORMAL', ROADMAP: 'MAP_TYPE_ROADMAP', SATELLITE: 'MAP_TYPE_SATELLITE', @@ -834,7 +834,7 @@ export class GoogleMap extends BaseClass { * @param mapTypeId {string} */ @CordovaInstance({ sync: true }) - setMapTypeId(mapTypeId: string): void { } + setMapTypeId(mapTypeId: MapType): void { } /** * Moves the camera with animation From 7bbd25c1a2a62a41bbf1747c827b550348f1b317 Mon Sep 17 00:00:00 2001 From: victor sosa Date: Mon, 10 Jul 2017 05:10:03 -0400 Subject: [PATCH 16/30] fix(google-analytics): fix parameter types in the trackMetric method (#1780) * Fix parameter in the trackMetric method In the trackMetric the first parameter is a number type; * Update index.ts --- src/@ionic-native/plugins/google-analytics/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@ionic-native/plugins/google-analytics/index.ts b/src/@ionic-native/plugins/google-analytics/index.ts index 06b4ddacc..9af3c62e5 100644 --- a/src/@ionic-native/plugins/google-analytics/index.ts +++ b/src/@ionic-native/plugins/google-analytics/index.ts @@ -102,7 +102,7 @@ export class GoogleAnalytics extends IonicNativePlugin { /** * Track custom metric - * @param key {string} + * @param key {number} * @param value {any} * @returns {Promise} */ @@ -110,7 +110,7 @@ export class GoogleAnalytics extends IonicNativePlugin { successIndex: 2, errorIndex: 3 }) - trackMetric(key: string, value?: any): Promise { return; } + trackMetric(key: number, value?: number): Promise { return; } /** * Track a screen From f1a036d8b094ccac5b821b8df557ddd1165388d7 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Mon, 10 Jul 2017 11:10:40 +0200 Subject: [PATCH 17/30] docs(printer): fix `isAvailable` description (#1782) --- src/@ionic-native/plugins/printer/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/@ionic-native/plugins/printer/index.ts b/src/@ionic-native/plugins/printer/index.ts index 51337b564..4598ce909 100644 --- a/src/@ionic-native/plugins/printer/index.ts +++ b/src/@ionic-native/plugins/printer/index.ts @@ -76,7 +76,7 @@ export interface PrintOptions { export class Printer extends IonicNativePlugin { /** - * Checks whether to device is capable of printing. + * Checks whether the device is capable of printing (uses `check()` internally) * @returns {Promise} */ isAvailable(): Promise { From 71349655c0e0f1d0c62137fb9ecc2308ae904bbb Mon Sep 17 00:00:00 2001 From: Jason Kim Date: Mon, 10 Jul 2017 02:15:56 -0700 Subject: [PATCH 18/30] docs(image-resizer): update plugin source (#1781) * Update image-resizer index.ts Running original command "ionic cordova plugin add https://github.com/protonet/cordova-plugin-image-resizer.git" will throw a Cordova error shown below. Installing the plugin via the plugin cordova id (per the original repo's package.json) will allow this plugin to install correctly and work with the ionic native "image-resizer" An error occurred while running ionic cordova plugin add https://github.com/protonet/cordova-plugin-image-resizer.git ... (exit code 1): Error: Failed to fetch plugin https://github.com/protonet/cordova-plugin-image-resizer.git via registry ... * Update index.ts --- src/@ionic-native/plugins/image-resizer/index.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/@ionic-native/plugins/image-resizer/index.ts b/src/@ionic-native/plugins/image-resizer/index.ts index 09f96171a..2928e119c 100644 --- a/src/@ionic-native/plugins/image-resizer/index.ts +++ b/src/@ionic-native/plugins/image-resizer/index.ts @@ -42,11 +42,6 @@ export interface ImageResizerOptions { * @description * Cordova Plugin For Image Resize * - * Requires plugin `info.protonet.imageresizer` - use the Ionic CLI and type in the following command: - * `ionic cordova plugin add https://github.com/protonet/cordova-plugin-image-resizer.git` - * - * For more info, please see the https://github.com/protonet/cordova-plugin-image-resizer - * * @usage * ```typescript * import { ImageResizer, ImageResizerOptions } from '@ionic-native/image-resizer'; @@ -74,9 +69,9 @@ export interface ImageResizerOptions { */ @Plugin({ pluginName: 'ImageResizer', - plugin: 'https://github.com/protonet/cordova-plugin-image-resizer.git', + plugin: 'info.protonet.imageresizer', pluginRef: 'ImageResizer', - repo: 'https://github.com/protonet/cordova-plugin-image-resizer', + repo: 'https://github.com/JoschkaSchulz/cordova-plugin-image-resizer', platforms: ['Android', 'iOS', 'Windows'] }) @Injectable() From a6f9714422a960ee8464d678b7d727a0994550fb Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 09:13:24 -0400 Subject: [PATCH 19/30] fix(safari-view-controller): show should return an Observable BREAKING CHANGE: `show` method now returns an Observable closes #1619 --- src/@ionic-native/plugins/safari-view-controller/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/@ionic-native/plugins/safari-view-controller/index.ts b/src/@ionic-native/plugins/safari-view-controller/index.ts index 2112b959b..1733fed76 100644 --- a/src/@ionic-native/plugins/safari-view-controller/index.ts +++ b/src/@ionic-native/plugins/safari-view-controller/index.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; export interface SafariViewControllerOptions { animated?: boolean; @@ -74,13 +75,14 @@ export class SafariViewController extends IonicNativePlugin { /** * Shows Safari View Controller * @param options {SafariViewControllerOptions} optional - * @returns {Promise} + * @returns {Observable} */ @Cordova({ successIndex: 1, - errorIndex: 2 + errorIndex: 2, + observable: true }) - show(options?: SafariViewControllerOptions): Promise { return; } + show(options?: SafariViewControllerOptions): Observable { return; } /** * Hides Safari View Controller From e8faf22357ad6c59302809d4a7abed6fa62c2f1a Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 09:13:58 -0400 Subject: [PATCH 20/30] fix(sqlite): fix param type for `sqlBatch` method closes #1596 --- src/@ionic-native/plugins/sqlite/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@ionic-native/plugins/sqlite/index.ts b/src/@ionic-native/plugins/sqlite/index.ts index 69737fa14..29b4d2a8c 100644 --- a/src/@ionic-native/plugins/sqlite/index.ts +++ b/src/@ionic-native/plugins/sqlite/index.ts @@ -95,11 +95,11 @@ export class SQLiteObject { executeSql(statement: string, params: any): Promise { return; } /** - * @param sqlStatements {Array} + * @param sqlStatements {Array} * @returns {Promise} */ @CordovaInstance() - sqlBatch(sqlStatements: Array): Promise { return; } + sqlBatch(sqlStatements: Array): Promise { return; } @CordovaInstance({ sync: true From ff793d649b5639bc066d21b38ddace6559d5edde Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 09:14:35 -0400 Subject: [PATCH 21/30] docs(onesignal): add iOS platform to iOSSettings method --- src/@ionic-native/plugins/onesignal/index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/@ionic-native/plugins/onesignal/index.ts b/src/@ionic-native/plugins/onesignal/index.ts index 8ddeaf1b3..e2d6d61fc 100644 --- a/src/@ionic-native/plugins/onesignal/index.ts +++ b/src/@ionic-native/plugins/onesignal/index.ts @@ -305,14 +305,14 @@ export enum OSActionType { * * #### Icons * If you want to use generated icons with command `ionic cordova resources`: - * + * * 1. Add a file to your `hooks` directory inside the `after_prepare` folder called `030_copy_android_notification_icons.js` * * 2. Put the following code in it: * * ``` * #!/usr/bin/env node - * + * * var filestocopy = [{ * "resources/android/icon/drawable-hdpi-icon.png": * "platforms/android/res/drawable-hdpi/ic_stat_onesignal_default.png" @@ -329,13 +329,13 @@ export enum OSActionType { * "resources/android/icon/drawable-xxxhdpi-icon.png": * "platforms/android/res/drawable-xxxhdpi/ic_stat_onesignal_default.png" * } ]; - * + * * var fs = require('fs'); * var path = require('path'); - * + * * // no need to configure below * var rootdir = process.argv[2]; - * + * * filestocopy.forEach(function(obj) { * Object.keys(obj).forEach(function(key) { * var val = obj[key]; @@ -449,7 +449,10 @@ export class OneSignal extends IonicNativePlugin { * Launch notifications with a launch URL as an in app webview. * @returns {any} */ - @Cordova({ sync: true }) + @Cordova({ + sync: true, + platforms: ['iOS'] + }) iOSSettings(settings: { kOSSettingsKeyAutoPrompt: boolean; kOSSettingsKeyInAppLaunchURL: boolean; @@ -574,7 +577,7 @@ export class OneSignal extends IonicNativePlugin { /** * Get the current notification and permission state. Returns a OSPermissionSubscriptionState type described below. - * + * * @returns {Promise} */ @Cordova() From b35dab26346ddfb09d7f9e7c0b89c8280b44d89b Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 09:14:56 -0400 Subject: [PATCH 22/30] feat(onesignal): add new methods closes #1677 --- src/@ionic-native/plugins/onesignal/index.ts | 161 ++++++++++++------- 1 file changed, 102 insertions(+), 59 deletions(-) diff --git a/src/@ionic-native/plugins/onesignal/index.ts b/src/@ionic-native/plugins/onesignal/index.ts index e2d6d61fc..046a87b0c 100644 --- a/src/@ionic-native/plugins/onesignal/index.ts +++ b/src/@ionic-native/plugins/onesignal/index.ts @@ -97,13 +97,13 @@ export enum OSLockScreenVisibility { * Fully visible (default) */ Public = 1, - /** - * Contents are hidden - */ + /** + * Contents are hidden + */ Private = 0, - /** - * Not shown - */ + /** + * Not shown + */ Secret = -1 } @@ -115,13 +115,13 @@ export enum OSDisplayType { * notification is silent, or inFocusDisplaying is disabled. */ None = 0, - /** - * (**DEFAULT**) - native alert dialog display. - */ + /** + * (**DEFAULT**) - native alert dialog display. + */ InAppAlert = 1, - /** - * native notification display. - */ + /** + * native notification display. + */ Notification = 2 } @@ -236,10 +236,10 @@ export interface OSPermissionState { * OSSubscriptionState */ export interface OSSubscriptionState { - subscribed: boolean; - userSubscriptionSetting: any; - userId: any; - pushToken: any; + subscribed: boolean; + userSubscriptionSetting: any; + userId: any; + pushToken: any; } /** * Subscription and permissions status @@ -466,6 +466,15 @@ export class OneSignal extends IonicNativePlugin { @Cordova({ sync: true }) endInit(): any { return; } + /** + * Prompt the user for notification permissions. Callback fires as soon as the user accepts or declines notifications. + * @returns {Promise} + */ + @Cordova({ + platforms: ['iOS'] + }) + promptForPushNotificationsWithUserResponse(): Promise { return; } + /** * Retrieve a list of tags that have been set on the user from the OneSignal server. * @@ -533,67 +542,74 @@ export class OneSignal extends IonicNativePlugin { registerForPushNotifications(): void { } /** - * Warning: - * Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications. - * - * By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode. - * Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode. - * - * @param {boolean} false to disable vibrate, true to re-enable it. - */ + * Warning: + * Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications. + * + * By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode. + * Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode. + * + * @param {boolean} false to disable vibrate, true to re-enable it. + */ @Cordova({ sync: true }) enableVibrate(enable: boolean): void { } /** - * Warning: - * Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications. - * - * By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on. - * Passing false means that the device will only vibrate unless the device is set to a total silent mode. - * - * @param {boolean} false to disable sound, true to re-enable it. - */ + * Warning: + * Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications. + * + * By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on. + * Passing false means that the device will only vibrate unless the device is set to a total silent mode. + * + * @param {boolean} false to disable sound, true to re-enable it. + */ @Cordova({ sync: true }) enableSound(enable: boolean): void { } /** - * - * Setting to control how OneSignal notifications will be shown when one is received while your app is in focus. By default this is set to inAppAlert, which can be helpful during development. - * - * @param {DisplayType} displayOption - * @returns {any} - */ + * + * Setting to control how OneSignal notifications will be shown when one is received while your app is in focus. By default this is set to inAppAlert, which can be helpful during development. + * + * @param {DisplayType} displayOption + * @returns {any} + */ @Cordova({ sync: true }) inFocusDisplaying(displayOption: OSDisplayType): any { return; } /** - * You can call this method with false to opt users out of receiving all notifications through OneSignal. - * You can pass true later to opt users back into notifications. - * - * @param {boolean} enable - */ + * You can call this method with false to opt users out of receiving all notifications through OneSignal. + * You can pass true later to opt users back into notifications. + * + * @param {boolean} enable + */ @Cordova({ sync: true }) setSubscription(enable: boolean): void { } /** - * Get the current notification and permission state. Returns a OSPermissionSubscriptionState type described below. - * - * @returns {Promise} - */ + * Get the current notification and permission state. Returns a OSPermissionSubscriptionState type described below. + * + * @returns {Promise} + */ @Cordova() getPermissionSubscriptionState(): Promise { return; } /** - * - * @param {notificationObj} Parameters see POST [documentation](https://documentation.onesignal.com/v2.0/docs/notifications-create-notification) - * @returns {Promise} Returns a Promise that resolves if the notification was send successfully. - */ + * + * @param {notificationObj} Parameters see POST [documentation](https://documentation.onesignal.com/v2.0/docs/notifications-create-notification) + * @returns {Promise} Returns a Promise that resolves if the notification was send successfully. + */ @Cordova() postNotification(notificationObj: OSNotification): Promise { return; } /** - * Prompts the user for location permission to allow geotagging based on the "Location radius" filter on the OneSignal dashboard. - */ + * Cancels a single OneSignal notification based on its Android notification integer id. Use instead of NotificationManager.cancel(id); otherwise the notification will be restored when your app is restarted. + * @param notificationId {string} + */ + @Cordova({ sync: true }) + cancelNotification(notificationId: string): void {} + + /** + * Prompts the user for location permission to allow geotagging based on the "Location radius" filter on the OneSignal dashboard. + */ @Cordova({ sync: true }) promptLocation(): void { } @@ -605,17 +621,44 @@ export class OneSignal extends IonicNativePlugin { syncHashedEmail(email: string): void { } /** - * Enable logging to help debug if you run into an issue setting up OneSignal. - * The logging levels are as follows: 0 = None, 1= Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose + * Enable logging to help debug if you run into an issue setting up OneSignal. + * The logging levels are as follows: 0 = None, 1= Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose - * The higher the value the more information is shown. - * - * @param {loglevel} contains two properties: logLevel (for console logging) and visualLevel (for dialog messages) - */ + * The higher the value the more information is shown. + * + * @param {loglevel} contains two properties: logLevel (for console logging) and visualLevel (for dialog messages) + */ @Cordova({ sync: true }) setLogLevel(logLevel: { logLevel: number, visualLevel: number }): void { } + /** + * The passed in function will be fired when a notification permission setting changes. + * This includes the following events: + * - Notification permission prompt shown + * - The user accepting or declining the permission prompt + * - Enabling/disabling notifications for your app in the device Settings after returning to your app. + * @return {Observable} + */ + @Cordova({ + observable: true + }) + addPermissionObserver(): Observable { return; } + + /** + * The passed in function will be fired when a notification subscription property changes. + * This includes the following events: + * - Getting a push token from Apple / Google. + * - Getting a player / user id from OneSignal + * - OneSignal.setSubscription is called + * - User disables or enables notifications + * @return {Observable} + */ + @Cordova({ + observable: true + }) + addSubscriptionObserver(): Observable { return; } + } From bde2b386687656a19d112680e085dc1c5428d504 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 09:15:50 -0400 Subject: [PATCH 23/30] feat(qr-scanner): add QRScanner plugin closes #715 --- src/@ionic-native/plugins/qr-scanner/index.ts | 228 ++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 src/@ionic-native/plugins/qr-scanner/index.ts diff --git a/src/@ionic-native/plugins/qr-scanner/index.ts b/src/@ionic-native/plugins/qr-scanner/index.ts new file mode 100644 index 000000000..135df901f --- /dev/null +++ b/src/@ionic-native/plugins/qr-scanner/index.ts @@ -0,0 +1,228 @@ +import { Plugin, IonicNativePlugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; + +export interface QRScannerStatus { + /** + * On iOS and Android 6.0+, camera access is granted at runtime by the user (by clicking "Allow" at the dialog). + * The authorized property is a boolean value which is true only when the user has allowed camera access to your app (AVAuthorizationStatus.Authorized). + * On platforms with permissions granted at install (Android pre-6.0, Windows Phone) this property is always true. + */ + authorized: boolean; + /** + * A boolean value which is true if the user permanently denied camera access to the app (AVAuthorizationStatus.Denied). + * Once denied, camera access can only be gained by requesting the user change their decision (consider offering a link to the setting via openSettings()). + */ + denied: boolean; + /** + * A boolean value which is true if the user is unable to grant permissions due to parental controls, organization security configuration profiles, or similar reasons. + */ + restricted: boolean; + /** + * A boolean value which is true if QRScanner is prepared to capture video and render it to the view. + */ + prepared: boolean; + /** + * A boolean value which is true when the preview layer is visible (and on all platforms but browser, the native webview background is transparent). + */ + showing: boolean; + /** + * A boolean value which is true if QRScanner is actively scanning for a QR code. + */ + scanning: boolean; + /** + * A boolean value which is true if QRScanner is displaying a live preview from the device's camera. Set to false when the preview is paused. + */ + previewing: boolean; + /** + * A boolean value which is true if the light is enabled. + */ + lightEnabled: boolean; + /** + * A boolean value which is true only if the users' operating system is able to QRScanner.openSettings(). + */ + canOpenSettings: boolean; + /** + * A boolean value which is true only if the users' device can enable a light in the direction of the currentCamera. + */ + canEnableLight: boolean; + /** + * A boolean value which is true only if the current device "should" have a front camera. + * The camera may still not be capturable, which would emit error code 3, 4, or 5 when the switch is attempted. + * (On the browser platform, this value is false until the prepare method is called.) + */ + canChangeCamera: boolean; + /** + * A number representing the index of the currentCamera. 0 is the back camera, 1 is the front. + */ + currentCamera: number; +} + +/** + * @name QR Scanner + * @description + * + * @usage + * ```typescript + * import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner'; + * + * + * constructor(private qrScanner: QRScanner) { } + * + * ... + * + * // Optionally request the permission early + * this.qrScanner.prepare() + * .then((status: QRScannerStatus) => { + * if (status.authorized) { + * // camera permission was granted + * + * + * // start scanning + * let scanSub = this.qrScanner.scan().subscribe((text: string) => { + * console.log('Scanned something', text); + * + * this.qrScanner.hide(); // hide camera preview + * scanSub.unsubscribe(); // stop scanning + * }); + * + * // show camera preview + * this.qrScanner.show(); + * + * // wait for user to scan something, then the observable callback will be called + * + * } else if (status.denied) { + * // camera permission was permanently denied + * // you must use QRScanner.openSettings() method to guide the user to the settings page + * // then they can grant the permission from there + * } else { + * // permission was denied, but not permanently. You can ask for permission again at a later time. + * } + * }) + * .catch((e: any) => console.log('Error is', e)); + * + * + * ``` + * @interfaces + * QRScannerStatus + */ +@Plugin({ + pluginName: 'QRScanner', + plugin: 'cordova-plugin-qrscanner', + pluginRef: 'QRScanner', + repo: 'https://github.com/bitpay/cordova-plugin-qrscanner', + platforms: ['Android', 'Browser', 'iOS', 'Windows'] +}) +@Injectable() +export class QRScanner extends IonicNativePlugin { + + /** + * Request permission to use QR scanner. + * @return {Promise} + */ + @Cordova({ + callbackStyle: 'node' + }) + prepare(): Promise { return; } + + /** + * Call this method to enable scanning. You must then call the `show` method to make the camera preview visible. + * @return {Observable} returns an Observable that emits the scanned text. Unsubscribe from the observable to stop scanning. + */ + @Cordova({ + callbackStyle: 'node', + observable: true, + clearFunction: 'cancelScan' + }) + scan(): Observable { return; } + + /** + * Configures the native webview to have a transparent background, then sets the background of the and DOM elements to transparent, allowing the webview to re-render with the transparent background. + * @returns {Promise} + */ + @Cordova() + show(): Promise { return; } + + /** + * Configures the native webview to be opaque with a white background, covering the video preview. + * @returns {Promise} + */ + @Cordova() + hide(): Promise { return; } + + /** + * Enable the device's light (for scanning in low-light environments). + * @returns {Promise} + */ + @Cordova({ + callbackStyle: 'node' + }) + enableLight(): Promise { return; } + + /** + * Disable the device's light. + * @return {Promise} + */ + @Cordova({ + callbackStyle: 'node' + }) + disableLight(): Promise { return; } + + /** + * Use front camera + * @return {Promise} + */ + @Cordova({ + callbackStyle: 'node' + }) + useFrontCamera(): Promise { return; } + + /** + * Use back camera + * @return {Promise} + */ + @Cordova({ + callbackStyle: 'node' + }) + useBackCamera(): Promise { return; } + + /** + * Set camera to be used. + * @param camera {number} Provide `0` for back camera, and `1` for front camera. + * @return {Promise} + */ + @Cordova({ + callbackStyle: 'node' + }) + useCamera(camera: number): Promise { return; } + + /** + * Pauses the video preview on the current frame and pauses scanning. + * @return {Promise} + */ + @Cordova() + pausePreview(): Promise { return; } + + /** + * Resumse the video preview and resumes scanning. + * @return {Promise} + */ + @Cordova() + resumePreview(): Promise { return; } + + /** + * Returns permission status + * @return {Promise} + */ + @Cordova() + getStatus(): Promise { return; } + + /** + * Opens settings to edit app permissions. + */ + @Cordova({ + sync: true + }) + openSettings(): void {} + +} From cf0c7402692d7c9e754d2021ccd6d17e45d343a7 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 09:40:53 -0400 Subject: [PATCH 24/30] feat(ms-adal): add Azure Active Directory Authentication plugin closes #372 --- src/@ionic-native/plugins/ms-adal/index.ts | 154 +++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 src/@ionic-native/plugins/ms-adal/index.ts diff --git a/src/@ionic-native/plugins/ms-adal/index.ts b/src/@ionic-native/plugins/ms-adal/index.ts new file mode 100644 index 000000000..bdd993760 --- /dev/null +++ b/src/@ionic-native/plugins/ms-adal/index.ts @@ -0,0 +1,154 @@ +import { Plugin, IonicNativePlugin, checkAvailability, InstanceProperty, CordovaInstance } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +export interface AuthenticationResult { + + accessToken: string; + accesSTokenType: string; + expiresOn: Date; + idToken: string; + isMultipleResourceRefreshToken: boolean; + status: string; + statusCode: number; + tenantId: string; + + /** + * Creates authorization header for web requests. + * @returns {String} The authorization header. + */ + createAuthorizationHeader(): string; + +} + +export interface TokenCache { + clear(): void; + readItems(): Promise; + deleteItem(item: TokenCacheItem): void; +} + +export interface TokenCacheItem { + accessToken: string; + authority: string; + clientId: string; + displayableId: string; + expiresOn: Date; + isMultipleResourceRefreshToken: boolean; + resource: string; + tenantId: string; + userInfo: UserInfo; +} + +export interface UserInfo { + displayableId: string; + userId: string; + familyName: string; + givenName: string; + identityProvider: string; + passwordChangeUrl: string; + passwordExpiresOn: Date; + uniqueId: string; +} + + +/** + * @name MS ADAL + * @description + * Active Directory Authentication Library (ADAL) plugin. + * Active Directory Authentication Library ([ADAL](https://docs.microsoft.com/en-us/dotnet/api/microsoft.identitymodel.clients.activedirectory?view=azure-dotnet)) + * plugin provides easy to use authentication functionality for your Apache Cordova apps by taking advantage of + * Windows Server Active Directory and Windows Azure Active Directory. Here you can find the source code for the library. + * @usage + * ```typescript + * import { MSAdal, AuthenticationContext, AuthenticationResult } from '@ionic-native/ms-adal'; + * + * + * constructor(private msAdal: MSAdal) {} + * + * ... + * + * let authContext: AuthenticationContext = this.msAdal.createAuthenticationContext('https://login.windows.net/common'); + * + * authContext.acquireTokenAsync('https://graph.windows.net', 'a5d92493-ae5a-4a9f-bcbf-9f1d354067d3', 'http://MyDirectorySearcherApp') + * .then((authResponse: AuthenticationResult) => { + * console.log('Token is' , authResponse.accessToken); + * console.log('Token will expire on', authResponse.expiresOn); + * }) + * .catch((e: any) => console.log('Authentication failed', e)); + * + * + * ``` + * + * @classes + * AuthenticationContext + * @interfaces + * AuthenticationResult + * TokenCache + * TokenCacheItem + * UserInfo + */ +@Plugin({ + pluginName: 'MSADAL', + plugin: 'cordova-plugin-ms-adal', + pluginRef: 'Microsoft.ADAL', + repo: 'https://github.com/AzureAD/azure-activedirectory-library-for-cordova', + platforms: ['Android', 'iOS', 'Windows'] +}) +@Injectable() +export class MSAdal extends IonicNativePlugin { + + createAuthenticationContext(authority: string, validateAuthority: boolean = true) { + let authContext: any; + if (checkAvailability(MSAdal.getPluginRef(), null, MSAdal.getPluginName()) === true) { + authContext = new (MSAdal.getPlugin()).AuthenticationContext(authority); + } + return new AuthenticationContext(authContext); + } + +} + +export class AuthenticationContext { + + @InstanceProperty + authority: string; + + @InstanceProperty + validateAuthority: boolean; + + @InstanceProperty + tokenCache: any; + + constructor(private _objectInstance: any) {} + + /** + * Acquires token using interactive flow. It always shows UI and skips token from cache. + * + * @param {String} resourceUrl Resource identifier + * @param {String} clientId Client (application) identifier + * @param {String} redirectUrl Redirect url for this application + * @param {String} userId User identifier (optional) + * @param {String} extraQueryParameters + * Extra query parameters (optional) + * Parameters should be escaped before passing to this method (e.g. using 'encodeURI()') + * @returns {Promise} Promise either fulfilled with AuthenticationResult object or rejected with error + */ + @CordovaInstance({ + otherPromise: true + }) + acquireTokenAsync(resourceUrl: string, clientId: string, redirectUrl: string, userId: string, extraQueryParameters?: any): Promise { return; } + + /** + * Acquires token WITHOUT using interactive flow. It checks the cache to return existing result + * if not expired. It tries to use refresh token if available. If it fails to get token without + * displaying UI it will fail. This method guarantees that no UI will be shown to user. + * + * @param {String} resourceUrl Resource identifier + * @param {String} clientId Client (application) identifier + * @param {String} userId User identifier (optional) + * @returns {Promise} Promise either fulfilled with AuthenticationResult object or rejected with error + */ + @CordovaInstance({ + otherPromise: true + }) + acquireTokenSilentAsync(resourceUrl: string, clientId: string, userId: string): Promise { return; } + +} From dd12be6722c474c14cb044ab9bf22bbc06b4aa88 Mon Sep 17 00:00:00 2001 From: Brad Grzesiak Date: Mon, 10 Jul 2017 08:54:53 -0500 Subject: [PATCH 25/30] docs(): provide "see also" for the Secure Storage plugin (#1773) --- src/@ionic-native/plugins/keychain/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/@ionic-native/plugins/keychain/index.ts b/src/@ionic-native/plugins/keychain/index.ts index 831d5b1ce..20381d70e 100644 --- a/src/@ionic-native/plugins/keychain/index.ts +++ b/src/@ionic-native/plugins/keychain/index.ts @@ -9,6 +9,8 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; * * Requires Cordova plugin: `cordova-plugin-ios-keychain`. For more info, please see the [Keychain plugin docs](https://github.com/ionic-team/cordova-plugin-ios-keychain). * + * See also [Secure Storage](https://ionicframework.com/docs/native/secure-storage/) for more supported platforms. + * * @usage * ```typescript * import { Keychain } from '@ionic-native/keychain'; From cdb99a74ccddb191a4d840cc24b9aae717ef4dd3 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Mon, 10 Jul 2017 15:55:16 +0200 Subject: [PATCH 26/30] docs(readme) improve link to 2.x README (#1764) link to branch instead of specific version so possible future updates are reflected after clicking the link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6aa9dde5a..d5232669e 100644 --- a/README.md +++ b/README.md @@ -171,9 +171,9 @@ Spent way too long diagnosing an issue only to realize a plugin wasn't firing or ## Plugin Missing? Let us know or submit a PR! Take a look at [the Developer Guide](https://github.com/ionic-team/ionic-native/blob/master/DEVELOPER.md) for more on how to contribute. :heart: -## Ionic V1/Angular 1 support +## Ionic v1 (AngularJS, Angular 1.x) support -For Ionic V1/Angular 1 support, please use version 2 of Ionic Native. See the [2.x README](https://github.com/ionic-team/ionic-native/blob/8cd648db5cddd7bdbe2bd78839b19c620cc8c04c/README.md) for usage information. +For Ionic v1 (AngularJS, Angular 1.x) support, please use version 2 of Ionic Native. See the [2.x README](https://github.com/ionic-team/ionic-native/blob/v2.x/README.md) for usage information. # Credits From 12a83831c8262952e0b442ec9abfd2be8c2bfa6d Mon Sep 17 00:00:00 2001 From: jasonmamy Date: Mon, 10 Jul 2017 06:55:40 -0700 Subject: [PATCH 27/30] refactor(): added default items interface (#1725) --- .../plugins/wheel-selector/index.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/@ionic-native/plugins/wheel-selector/index.ts b/src/@ionic-native/plugins/wheel-selector/index.ts index 2958f02db..b97a9d326 100644 --- a/src/@ionic-native/plugins/wheel-selector/index.ts +++ b/src/@ionic-native/plugins/wheel-selector/index.ts @@ -5,6 +5,11 @@ export interface WheelSelectorItem { description?: string; } +export interface DefaultItem { + index: number; + value: string; +} + export interface WheelSelectorOptions { /** * The title of the selector's input box @@ -17,9 +22,9 @@ export interface WheelSelectorOptions { items: Array>; /** - * Which items to display by default, example ["2","Apple"] (if items.length is 2 for instance) + * Which items to display by default. */ - defaultItems?: Array; + defaultItems?: Array; /** * The 'ok' button text @@ -127,9 +132,9 @@ export interface WheelSelectorData { * positiveButtonText: "Ok", * negativeButtonText: "Nope", * defaultItems: [ - * this.jsonData.numbers[2], // '3' - * this.jsonData.fruits[3] // 'Banana' - * ] + * {index:0, value: this.jsonData.numbers[2].description}, + * {index: 1, value: this.jsonData.fruits[3].description} + * ] * }).then( * result => { * console.log(result[0].description + ' ' + result[1].description); @@ -150,8 +155,8 @@ export interface WheelSelectorData { * ], * displayKey: 'name', * defaultItems: [ - * this.jsonData.firstNames[2], - * this.jsonData.lastNames[3] + * {index:0, value: this.jsonData.firstNames[2].name}, + * {index: 0, value: this.jsonData.lastNames[3].name} * ] * }).then( * result => { From d8bac2f0ab5df8adcc1b1d319922105e3f3cbf8c Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 09:59:35 -0400 Subject: [PATCH 28/30] docs(google-maps): show all classes and interfaces --- .../plugins/google-maps/index.ts | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index ec3616b8c..aae3a6739 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -378,16 +378,35 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = { * GoogleMap * Circle * Environment - * Marker - * LatLng * Geocoder + * GroundOverlay + * HtmlInfoWindow + * Geocoder + * LatLng + * LatLngBounds + * Marker + * Polygon + * Polyline + * TileOverlay + * BaseClass + * BaseArrayClass * @interfaces + * GoogleMapOptions * AnimateCameraOptions + * CameraPosition + * CircleOptions + * GeocoderRequest + * GeocoderResult + * GroundOverlayOptions + * ILatLng + * MarkerIcon * MarkerOptions * MyLocation * MyLocationOptions + * PolygonOptions + * PolylineOptions + * TileOverlayOptions * VisibleRegion - * */ @Plugin({ pluginName: 'GoogleMaps', From cbdde57681bae98f53d2dc9963ad151d6cbb19c3 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 13:02:06 -0400 Subject: [PATCH 29/30] chore(): update @ionic-native/core dependency version no changes were made in 4.0, so older versions should work fine --- scripts/build/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/build.js b/scripts/build/build.js index dd8353427..f850f6dc8 100644 --- a/scripts/build/build.js +++ b/scripts/build/build.js @@ -19,7 +19,7 @@ const ROOT = path.resolve(path.join(__dirname, '../../')), // root ionic-native // dependency versions const ANGULAR_VERSION = '*', RXJS_VERSION = '^5.0.1', - MIN_CORE_VERSION = '^3.6.0', + MIN_CORE_VERSION = '^3.6.0 || >= 4.0.0', IONIC_NATIVE_VERSION = require(path.resolve(ROOT, 'package.json')).version; // package dependencies From ad9556ca038fc829e8fcd40a7d626e6f3c3adbc2 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Mon, 10 Jul 2017 13:02:50 -0400 Subject: [PATCH 30/30] amend(): remove space --- scripts/build/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/build.js b/scripts/build/build.js index f850f6dc8..5065e6ae7 100644 --- a/scripts/build/build.js +++ b/scripts/build/build.js @@ -19,7 +19,7 @@ const ROOT = path.resolve(path.join(__dirname, '../../')), // root ionic-native // dependency versions const ANGULAR_VERSION = '*', RXJS_VERSION = '^5.0.1', - MIN_CORE_VERSION = '^3.6.0 || >= 4.0.0', + MIN_CORE_VERSION = '^3.6.0 || >=4.0.0', IONIC_NATIVE_VERSION = require(path.resolve(ROOT, 'package.json')).version; // package dependencies