From 96c47df151a2bc799e8f52b6e5c204033694f394 Mon Sep 17 00:00:00 2001 From: Ignat Ignatov Date: Wed, 6 Apr 2016 16:36:26 +0200 Subject: [PATCH 001/115] Added implementation for readAsText() method. --- src/plugins/file.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/plugins/file.ts b/src/plugins/file.ts index 54874bcbe..fb0fa9358 100644 --- a/src/plugins/file.ts +++ b/src/plugins/file.ts @@ -462,7 +462,57 @@ export class File { // static writeExistingFile(path: string, fileName: string, text: string): Promise { return } - // static readAsText(path: string, file: string): Promise { return } + /** + * Read a file as string. + * + * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above + * @param {string} fileName Name of file to move + * @return Returns a Promise that resolves or rejects with an error. + */ + static readAsText(path: string, fileName: string): Promise { + let resolveFn, rejectFn; + let promise = new Promise((resolve, reject) => {resolveFn = resolve; rejectFn = reject; }); + + if ((/^\//.test(fileName))) { + rejectFn('file-name cannot start with \/'); + } + + try { + window.resolveLocalFileSystemURL(path, function (fileSystem) { + fileSystem.getFile(fileName, {create: false}, function (fileEntry) { + fileEntry.file(function (file) { + var reader = new FileReader(); + + reader.onloadend = function(e) { + if (this.result !== undefined && this.result !== null) { + resolveFn(this.result); + } else if (this.error !== undefined && this.error !== null) { + rejectFn(this.error); + } else { + rejectFn({code: null, message: 'READER_ONLOADEND_ERR'}); + } + } + + reader.readAsText(file); + }, function (error) { + error.message = File.cordovaFileError[error.code]; + rejectFn(error); + }); + }, function (err) { + err.message = File.cordovaFileError[err.code]; + rejectFn(err); + }); + }, function (er) { + er.message = File.cordovaFileError[er.code]; + rejectFn(er); + }); + } catch (e) { + e.message = File.cordovaFileError[e.code]; + rejectFn(e); + } + + return promise; + } // static readAsDataURL(path: string, file: string): Promise { return } From ce2772b994058b22978d0f842b2c95672a47e708 Mon Sep 17 00:00:00 2001 From: Barry Rowe Date: Thu, 14 Apr 2016 12:48:04 -0400 Subject: [PATCH 002/115] Append trailingSlash if not present on path param In some cases the incoming ```path``` variable may not necessarily contain a trailing slash, but in cases where the directory path is manually built within the plugin this was not protected against. This shouldn't be a big issue if consumers are using ```cordova.file.*``` for the path params, but not all consumers may be using this. --- src/plugins/file.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/file.ts b/src/plugins/file.ts index 54874bcbe..893458f1d 100644 --- a/src/plugins/file.ts +++ b/src/plugins/file.ts @@ -50,7 +50,11 @@ export class File { if ((/^\//.test(dir))) { rejectFn('directory cannot start with \/'); } - + + if (!(/\/$/.test(noSlash))) { + path += "/"; + } + try { var directory = path + dir; @@ -351,6 +355,10 @@ export class File { rejectFn('file cannot start with \/'); } + if (!(/\/$/.test(noSlash))) { + path += "/"; + } + try { var directory = path + file; From 9d359a50e2568c7385247ab0e9ed0a16dc6ba7dd Mon Sep 17 00:00:00 2001 From: "Keith D. Moore" Date: Sat, 30 Apr 2016 14:58:46 -0500 Subject: [PATCH 003/115] fix usage comments add delay in setTimeout to ensure connection attribute has been set. --- src/plugins/network.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/network.ts b/src/plugins/network.ts index 1bca41273..3986963ab 100644 --- a/src/plugins/network.ts +++ b/src/plugins/network.ts @@ -32,7 +32,7 @@ declare var navigator: any; * if (Network.connection === Connection.WIFI) { * console.log('we got a wifi connection, woohoo!'); * } - * }); + * }, 3000); * }); * * // stop connect watch From da1cf7c3a1d78a9eae38caaa3aacf2efeab72413 Mon Sep 17 00:00:00 2001 From: Ionitron Date: Wed, 4 May 2016 17:03:53 -0500 Subject: [PATCH 004/115] trying new CI approach --- circle.yml | 20 ++++++++++---------- scripts/docs/prepare.sh | 5 ++++- scripts/docs/update_docs.sh | 2 -- scripts/git/clone.sh | 6 +++++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/circle.yml b/circle.yml index d007caa6a..166686e1f 100644 --- a/circle.yml +++ b/circle.yml @@ -9,19 +9,19 @@ general: only: - master # ignore PRs and branches -#dependencies: -# pre: -# - ./scripts/docs/prepare.sh -# cache_directories: -# - "~/ionic-site" # cache ionic-site +dependencies: + pre: + - ./scripts/docs/prepare.sh + cache_directories: + - "~/ionic-site" # cache ionic-site test: override: - echo "No tests are written at the moment. But we will attempt to build the library with the latest changes." - npm run build_bundle -#deployment: -# staging: -# branch: master -# commands: -# - ./scripts/docs/update_docs.sh +deployment: + staging: + branch: master + commands: + - ./scripts/docs/update_docs.sh diff --git a/scripts/docs/prepare.sh b/scripts/docs/prepare.sh index 5300127af..084f36796 100755 --- a/scripts/docs/prepare.sh +++ b/scripts/docs/prepare.sh @@ -14,7 +14,10 @@ function init { } function run { - + # no need to run on PRs + if [ -z $CI_PULL_REQUEST ] then + exit 0 + fi if [ ! -d "$SITE_DIR" ]; then echo "checking out" cd ./scripts diff --git a/scripts/docs/update_docs.sh b/scripts/docs/update_docs.sh index d765238b4..413b3a0f3 100755 --- a/scripts/docs/update_docs.sh +++ b/scripts/docs/update_docs.sh @@ -30,8 +30,6 @@ function run { echo "-- No changes detected for the following commit, docs not updated." echo "https://github.com/driftyco/$CIRCLE_PROJECT_REPONAME/commit/$CIRCLE_SHA1" else - git config --global user.email "hi@ionicframework.com" - git config --global user.name "Ionitron" git add -A git commit -am "Automated build of native docs driftyco/$CIRCLE_PROJECT_REPONAME@$CIRCLE_SHA1" git push origin master diff --git a/scripts/git/clone.sh b/scripts/git/clone.sh index dd29fe56a..d4e2d7b97 100755 --- a/scripts/git/clone.sh +++ b/scripts/git/clone.sh @@ -17,7 +17,11 @@ function run { if [[ "$DEPTH" != "" ]]; then ARGS="$ARGS --depth=$DEPTH" fi - git clone https://driftyco:$GH_TOKEN@github.com/$REPOSITORY $DIRECTORY $ARGS + + git config --global user.email "hi@ionicframework.com" + git config --global user.name "Ionitron" + + git clone git@github.com:driftyco/$REPOSITORY.git $DIRECTORY $ARGS cd $DIRECTORY git fetch origin --tags cd ../ From a35580e0dd867cfaa239ccea417a6b84b6b42c4a Mon Sep 17 00:00:00 2001 From: Ionitron Date: Wed, 4 May 2016 17:05:19 -0500 Subject: [PATCH 005/115] typo --- scripts/docs/prepare.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/docs/prepare.sh b/scripts/docs/prepare.sh index 084f36796..7cae3adae 100755 --- a/scripts/docs/prepare.sh +++ b/scripts/docs/prepare.sh @@ -15,9 +15,10 @@ function init { function run { # no need to run on PRs - if [ -z $CI_PULL_REQUEST ] then + if [ -z $CI_PULL_REQUEST ]; then exit 0 fi + if [ ! -d "$SITE_DIR" ]; then echo "checking out" cd ./scripts From 73095b121189bb12b00426c605faf4fc01ecee62 Mon Sep 17 00:00:00 2001 From: Ionitron Date: Wed, 4 May 2016 17:08:28 -0500 Subject: [PATCH 006/115] pulling for now --- scripts/docs/prepare.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/docs/prepare.sh b/scripts/docs/prepare.sh index 7cae3adae..5300127af 100755 --- a/scripts/docs/prepare.sh +++ b/scripts/docs/prepare.sh @@ -14,10 +14,6 @@ function init { } function run { - # no need to run on PRs - if [ -z $CI_PULL_REQUEST ]; then - exit 0 - fi if [ ! -d "$SITE_DIR" ]; then echo "checking out" From 487aaafb153c77f6f8f1fbaeaae01cb6ca7664be Mon Sep 17 00:00:00 2001 From: Ionitron Date: Wed, 4 May 2016 17:10:41 -0500 Subject: [PATCH 007/115] CI tweak --- scripts/docs/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docs/prepare.sh b/scripts/docs/prepare.sh index 5300127af..03a25083f 100755 --- a/scripts/docs/prepare.sh +++ b/scripts/docs/prepare.sh @@ -18,7 +18,7 @@ function run { if [ ! -d "$SITE_DIR" ]; then echo "checking out" cd ./scripts - ./git/clone.sh --repository="driftyco/ionic-site" \ + ./git/clone.sh --repository="ionic-site" \ --directory="$SITE_DIR" \ --branch="master" ls -al $SITE_DIR From 3a80434a1cf6803ae78d80f196bc49d6247f8c10 Mon Sep 17 00:00:00 2001 From: perry Date: Thu, 5 May 2016 14:50:40 -0500 Subject: [PATCH 008/115] attempting to prevent errors in the even a commit to ionic-site is made during docgen --- scripts/docs/update_docs.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/docs/update_docs.sh b/scripts/docs/update_docs.sh index 413b3a0f3..c1c58dfce 100755 --- a/scripts/docs/update_docs.sh +++ b/scripts/docs/update_docs.sh @@ -32,6 +32,11 @@ function run { else git add -A git commit -am "Automated build of native docs driftyco/$CIRCLE_PROJECT_REPONAME@$CIRCLE_SHA1" + # in case a different commit was pushed to ionic-site during doc/demo gen, + # try to rebase around it before pushing + git fetch + git rebase + git push origin master echo "-- Updated docs for $VERSION_NAME succesfully!" From 6fab67ca9ff4e4320007bbe40d4974836f9d59e0 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Thu, 5 May 2016 15:50:28 -0700 Subject: [PATCH 009/115] Adding some types to `plugins/hotspot.ts` --- src/plugins/hotspot.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/hotspot.ts b/src/plugins/hotspot.ts index 95d6d6f7c..9903f3a14 100644 --- a/src/plugins/hotspot.ts +++ b/src/plugins/hotspot.ts @@ -44,16 +44,16 @@ export class Hotspot { static getAllHotspotDevices(): Promise {return; } @Cordova() - static connectToHotspot(ssid, password): Promise {return; } + static connectToHotspot(ssid: string, password: string): Promise {return; } @Cordova() - static connectToWifiAuthEncrypt(ssid, password, authentication, encryption): Promise {return; } + static connectToWifiAuthEncrypt(ssid: string, password: string, authentication, encryption): Promise {return; } @Cordova() - static addWifiNetwork(ssid, mode, password): Promise {return; } + static addWifiNetwork(ssid: string, mode, password): Promise {return; } @Cordova() - static removeWifiNetwork(ssid): Promise {return; } + static removeWifiNetwork(ssid: string): Promise {return; } @Cordova() static isConnectedToInternet(): Promise {return; } @@ -77,7 +77,7 @@ export class Hotspot { static scanWifiByLevel(): Promise {return; } @Cordova() - static startPeriodicallyScan(interval, duration): Promise {return; } + static startPeriodicallyScan(interval: number, duration: number): Promise {return; } @Cordova() static stopPeriodicallyScan(): Promise {return; } @@ -89,16 +89,16 @@ export class Hotspot { static getConnectionInfo(): Promise {return; } @Cordova() - static pingHost(ip): Promise {return; } + static pingHost(ip: string): Promise {return; } @Cordova() - static getMacAddressOfHost(ip): Promise {return; } + static getMacAddressOfHost(ip: string): Promise {return; } @Cordova() - static isDnsLive(ip): Promise {return; } + static isDnsLive(ip: string): Promise {return; } @Cordova() - static isPortLife(ip): Promise {return; } + static isPortLife(ip: string): Promise {return; } @Cordova() static isRooted(): Promise {return; } From b4b131c82af080979c40d9a858a5aaaad22207b7 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Thu, 5 May 2016 17:57:49 -0700 Subject: [PATCH 010/115] Adding more typings for hotspot.ts --- src/plugins/connection-info.model.ts | 27 ++++ src/plugins/hotspot-device.model.ts | 12 ++ src/plugins/hotspot.ts | 198 +++++++++++++++++++++------ src/plugins/network-config.model.ts | 18 +++ src/plugins/network.model.ts | 32 +++++ 5 files changed, 244 insertions(+), 43 deletions(-) create mode 100644 src/plugins/connection-info.model.ts create mode 100644 src/plugins/hotspot-device.model.ts create mode 100644 src/plugins/network-config.model.ts create mode 100644 src/plugins/network.model.ts diff --git a/src/plugins/connection-info.model.ts b/src/plugins/connection-info.model.ts new file mode 100644 index 000000000..572b7a99f --- /dev/null +++ b/src/plugins/connection-info.model.ts @@ -0,0 +1,27 @@ +export class ConnectionInfo { + /** + * @property {string} SSID + * The service set identifier (SSID) of the current 802.11 network. + */ + SSID: string; + /** + * @property {string} BSSID + * The basic service set identifier (BSSID) of the current access point. + */ + BSSID: string; + /** + * @property {string} linkSpeed + * The current link speed in Mbps + */ + linkSpeed: string; + /** + * @property {string} IPAddress + * The IP Address + */ + IPAddress: string; + /** + * @property {string} networkID + * Each configured network has a unique small integer ID, used to identify the network when performing operations on the supplicant. + */ + networkID: string; +} diff --git a/src/plugins/hotspot-device.model.ts b/src/plugins/hotspot-device.model.ts new file mode 100644 index 000000000..ffb727eb8 --- /dev/null +++ b/src/plugins/hotspot-device.model.ts @@ -0,0 +1,12 @@ +export class HotspotDevice { + /** + * @property {string} ip + * Hotspot IP Address + */ + ip: string; + /** + * @property {string} mac + * Hotspot MAC Address + */ + mac: string; +} diff --git a/src/plugins/hotspot.ts b/src/plugins/hotspot.ts index 9903f3a14..d294e208e 100644 --- a/src/plugins/hotspot.ts +++ b/src/plugins/hotspot.ts @@ -1,5 +1,10 @@ import {Plugin, Cordova} from './plugin'; +import {Network} from './network.model'; +import {NetworkConfig} from './network-config.model'; +import {ConnectionInfo} from './connection-info.model'; +import {HotspotDevice} from './hotspot-device.model'; + /** * @name Hotspot * @description @@ -23,58 +28,139 @@ export class Hotspot { static isAvailable(): Promise {return; } @Cordova() - static toggleWifi(): Promise {return; } + static toggleWifi(): Promise {return; } + + /** + * Configures and starts hotspot with SSID and Password + * + * @param {string} SSID - SSID of your new Access Point + * @param {string} mode - encryption mode (Open, WEP, WPA, WPA_PSK) + * @param {string} password - password for your new Access Point + * + * @return {Promise} - Promise to call once hotspot is started, or reject upon failure + */ + @Cordova() + static createHotspot(ssid: string, mode: string, password: string): Promise {return; } + + /** + * Turns on Access Point + * + * @return {Promise} - true if AP is started + */ + @Cordova() + static startHotspot(): Promise {return; } + + /** + * Configures hotspot with SSID and Password + * + * @param {string} SSID - SSID of your new Access Point + * @param {string} mode - encryption mode (Open, WEP, WPA, WPA_PSK) + * @param {string} password - password for your new Access Point + * + * @return {Promise} - Promise to call when hotspot is configured, or reject upon failure + */ + @Cordova() + static configureHotspot(ssid: string, mode: string, password: string): Promise {return; } + + /** + * Turns off Access Point + * + * @return {Promise} - Promise to turn off the hotspot, true on success, false on failure + */ + @Cordova() + static stopHotspot(): Promise {return; } + + /** + * Checks if hotspot is enabled + * + * @return {Promise} - Promise that hotspot is enabled, rejected if it is not enabled + */ + @Cordova() + static isHotspotEnabled(): Promise {return; } @Cordova() - static createHotspot(ssid: string, mode: string, password: string): Promise {return; } + static getAllHotspotDevices(): Promise> {return; } + + /** + * Connect to a WiFi network + * + * @param {string} ssid + * SSID to connect + * @param {string} password + * password to use + * + * @return {Promise} + * Promise that connection to the WiFi network was successfull, rejected if unsuccessful + */ + @Cordova() + static connectToHotspot(ssid: string, password: string): Promise {return; } + + /** + * Connect to a WiFi network + * + * @param {string} ssid + * SSID to connect + * @param {string} password + * Password to use + * @param {string} authentication + * Authentication modes to use (LEAP, SHARED, OPEN) + * @param {string[]} encryption + * Encryption modes to use (CCMP, TKIP, WEP104, WEP40) + * + * @return {Promise} + * Promise that connection to the WiFi network was successfull, rejected if unsuccessful + */ + @Cordova() + static connectToWifiAuthEncrypt(ssid: string, password: string, authentication: string, encryption: Array): Promise {return; } + + /** + * Add a WiFi network + * + * @param {string} ssid + * SSID of network + * @param {string} mode + * Authentication mode of (Open, WEP, WPA, WPA_PSK) + * @param {string} password + * Password for network + * + * @return {Promise} + * Promise that adding the WiFi network was successfull, rejected if unsuccessful + */ + @Cordova() + static addWifiNetwork(ssid: string, mode: string, password: string): Promise {return; } + + /** + * Remove a WiFi network + * + * @param {string} ssid + * SSID of network + * + * @return {Promise} + * Promise that removing the WiFi network was successfull, rejected if unsuccessful + */ + @Cordova() + static removeWifiNetwork(ssid: string): Promise {return; } @Cordova() - static startHotspot(): Promise {return; } + static isConnectedToInternet(): Promise {return; } @Cordova() - static configureHotspot(ssid: string, mode: string, password: string): Promise {return; } + static isConnectedToInternetViaWifi(): Promise {return; } @Cordova() - static stopHotspot(): Promise {return; } + static isWifiOn(): Promise {return; } @Cordova() - static isHotspotEnabled(): Promise {return; } + static isWifiSupported(): Promise {return; } @Cordova() - static getAllHotspotDevices(): Promise {return; } + static isWifiDirectSupported(): Promise {return; } @Cordova() - static connectToHotspot(ssid: string, password: string): Promise {return; } + static scanWifi(): Promise> {return; } @Cordova() - static connectToWifiAuthEncrypt(ssid: string, password: string, authentication, encryption): Promise {return; } - - @Cordova() - static addWifiNetwork(ssid: string, mode, password): Promise {return; } - - @Cordova() - static removeWifiNetwork(ssid: string): Promise {return; } - - @Cordova() - static isConnectedToInternet(): Promise {return; } - - @Cordova() - static isConnectedToInternetViaWifi(): Promise {return; } - - @Cordova() - static isWifiOn(): Promise {return; } - - @Cordova() - static isWifiSupported(): Promise {return; } - - @Cordova() - static isWifiDirectSupported(): Promise {return; } - - @Cordova() - static scanWifi(): Promise {return; } - - @Cordova() - static scanWifiByLevel(): Promise {return; } + static scanWifiByLevel(): Promise> {return; } @Cordova() static startPeriodicallyScan(interval: number, duration: number): Promise {return; } @@ -83,24 +169,50 @@ export class Hotspot { static stopPeriodicallyScan(): Promise {return; } @Cordova() - static getNetConfig(): Promise {return; } + static getNetConfig(): Promise {return; } @Cordova() - static getConnectionInfo(): Promise {return; } + static getConnectionInfo(): Promise {return; } @Cordova() - static pingHost(ip: string): Promise {return; } + static pingHost(ip: string): Promise {return; } + /** + * Gets MAC Address associated with IP Address from ARP File + * + * @param {string} ip - IP Address that you want the MAC Address of + * + * @return {Promise} - A Promise for the MAC Address + */ @Cordova() - static getMacAddressOfHost(ip: string): Promise {return; } + static getMacAddressOfHost(ip: string): Promise {return; } + /** + * Checks if IP is live using DNS + * + * @param {string} ip - IP Address you want to test + * + * @return {Promise} - A Promise for whether the IP Address is reachable + */ @Cordova() - static isDnsLive(ip: string): Promise {return; } + static isDnsLive(ip: string): Promise {return; } + /** + * Checks if IP is live using socket And PORT + * + * @param {string} ip - IP Address you want to test + * + * @return {Promise} - A Promise for whether the IP Address is reachable + */ @Cordova() - static isPortLife(ip: string): Promise {return; } + static isPortLife(ip: string): Promise {return; } + /** + * Checks if device is rooted + * + * @return {Promise} - A Promise for whether the device is rooted + */ @Cordova() - static isRooted(): Promise {return; } + static isRooted(): Promise {return; } } diff --git a/src/plugins/network-config.model.ts b/src/plugins/network-config.model.ts new file mode 100644 index 000000000..c2fafa934 --- /dev/null +++ b/src/plugins/network-config.model.ts @@ -0,0 +1,18 @@ +export class NetworkConfig { + /** + * @property {string} deviceIPAddress - Device IP Address + */ + deviceIPAddress: string; + /** + * @property {string} deviceMacAddress - Device MAC Address + */ + deviceMacAddress: string; + /** + * @property {string} gatewayIPAddress - Gateway IP Address + */ + gatewayIPAddress: string; + /** + * @property {string} gatewayMacAddress - Gateway MAC Address + */ + gatewayMacAddress: string; +} diff --git a/src/plugins/network.model.ts b/src/plugins/network.model.ts new file mode 100644 index 000000000..8260791d8 --- /dev/null +++ b/src/plugins/network.model.ts @@ -0,0 +1,32 @@ +export class Network { + /** + * @property {string} SSID + * Human readable network name + */ + SSID: string; + /** + * @property {string} BSSID + * MAC Address of the access point + */ + BSSID: string; + /** + * @property {number (int)} frequency + * The primary 20 MHz frequency (in MHz) of the channel over which the client is communicating with the access point. + */ + frequency: number; + /** + * @property {number} level + * The detected signal level in dBm, also known as the RSSI. + */ + level: number; + /** + * @property {number} timestamp + * Timestamp in microseconds (since boot) when this result was last seen. + */ + timestamp: number; + /** + * @property {string} capabilities + * Describes the authentication, key management, and encryption schemes supported by the access point. + */ + capabilities: string; +} From 9682ac8f1136baa8abb8ac849daed117177a1510 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Thu, 5 May 2016 18:06:33 -0700 Subject: [PATCH 011/115] Adding some JSDoc definitions --- src/plugins/connection-info.model.ts | 3 +++ src/plugins/hotspot-device.model.ts | 3 +++ src/plugins/hotspot.ts | 8 ++++++-- src/plugins/network-config.model.ts | 3 +++ src/plugins/network.model.ts | 5 +++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/plugins/connection-info.model.ts b/src/plugins/connection-info.model.ts index 572b7a99f..21c785da9 100644 --- a/src/plugins/connection-info.model.ts +++ b/src/plugins/connection-info.model.ts @@ -1,3 +1,6 @@ +/** + * @name ConnectionInfo + */ export class ConnectionInfo { /** * @property {string} SSID diff --git a/src/plugins/hotspot-device.model.ts b/src/plugins/hotspot-device.model.ts index ffb727eb8..fd9a7f736 100644 --- a/src/plugins/hotspot-device.model.ts +++ b/src/plugins/hotspot-device.model.ts @@ -1,3 +1,6 @@ +/** + * @name HotspotDevice + */ export class HotspotDevice { /** * @property {string} ip diff --git a/src/plugins/hotspot.ts b/src/plugins/hotspot.ts index d294e208e..dfdefe312 100644 --- a/src/plugins/hotspot.ts +++ b/src/plugins/hotspot.ts @@ -10,9 +10,13 @@ import {HotspotDevice} from './hotspot-device.model'; * @description * @usage * ```js - * import {Hotspot} from 'ionic-native'; - * + * import {Hotspot, Network} from 'ionic-native'; * + * ... + * Hotspot.scanWifi().then((networks: Array) => { + * console.log(networks); + * }); + * ... * * ``` */ diff --git a/src/plugins/network-config.model.ts b/src/plugins/network-config.model.ts index c2fafa934..32164cddc 100644 --- a/src/plugins/network-config.model.ts +++ b/src/plugins/network-config.model.ts @@ -1,3 +1,6 @@ +/** + * @name ConnectionInfo + */ export class NetworkConfig { /** * @property {string} deviceIPAddress - Device IP Address diff --git a/src/plugins/network.model.ts b/src/plugins/network.model.ts index 8260791d8..45f930953 100644 --- a/src/plugins/network.model.ts +++ b/src/plugins/network.model.ts @@ -1,3 +1,8 @@ +/** + * @name Network + * @description + * Based on [ScanResult](http://developer.android.com/reference/android/net/wifi/ScanResult.html) + */ export class Network { /** * @property {string} SSID From 116dc1a1b36221898dcd12c1ec7e7521d0ebca37 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Thu, 5 May 2016 19:01:07 -0700 Subject: [PATCH 012/115] Fixing typos --- src/plugins/hotspot.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/hotspot.ts b/src/plugins/hotspot.ts index dfdefe312..732a57e9a 100644 --- a/src/plugins/hotspot.ts +++ b/src/plugins/hotspot.ts @@ -97,7 +97,7 @@ export class Hotspot { * Promise that connection to the WiFi network was successfull, rejected if unsuccessful */ @Cordova() - static connectToHotspot(ssid: string, password: string): Promise {return; } + static connectToWifi(ssid: string, password: string): Promise {return; } /** * Connect to a WiFi network @@ -167,10 +167,10 @@ export class Hotspot { static scanWifiByLevel(): Promise> {return; } @Cordova() - static startPeriodicallyScan(interval: number, duration: number): Promise {return; } + static startWifiPeriodicallyScan(interval: number, duration: number): Promise {return; } @Cordova() - static stopPeriodicallyScan(): Promise {return; } + static stopWifiPeriodicallyScan(): Promise {return; } @Cordova() static getNetConfig(): Promise {return; } @@ -209,7 +209,7 @@ export class Hotspot { * @return {Promise} - A Promise for whether the IP Address is reachable */ @Cordova() - static isPortLife(ip: string): Promise {return; } + static isPortLive(ip: string): Promise {return; } /** * Checks if device is rooted From 451cfe5cd859ce58f9ee20de0844100ebdf2690b Mon Sep 17 00:00:00 2001 From: Guillermo Date: Sun, 8 May 2016 22:44:16 +0200 Subject: [PATCH 013/115] Update install command cordova -> ionic --- src/plugins/facebook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/facebook.ts b/src/plugins/facebook.ts index 64507b759..0260d26af 100644 --- a/src/plugins/facebook.ts +++ b/src/plugins/facebook.ts @@ -20,7 +20,7 @@ import {Plugin, Cordova} from './plugin'; * Then type in the following command in your Terminal, where APP_ID and APP_NAME are the values from the Facebook Developer portal. * * ```bash - * cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" + * ionic plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" * ``` * * After, you'll need to add the native platforms you'll be using to your app in the Facebook Developer portal under your app's Settings: From 6f50138d9e22292711e4bb3bbba7f2ab9280f55b Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Sun, 8 May 2016 18:56:18 -0700 Subject: [PATCH 014/115] Moving interface files around for organization --- src/plugins/hotspot.ts | 8 ++++---- .../connection-info.interface.ts} | 0 .../hotspot-device.interface.ts} | 0 .../network-config.interface.ts} | 0 .../{network.model.ts => interfaces/network.interface.ts} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/plugins/{connection-info.model.ts => interfaces/connection-info.interface.ts} (100%) rename src/plugins/{hotspot-device.model.ts => interfaces/hotspot-device.interface.ts} (100%) rename src/plugins/{network-config.model.ts => interfaces/network-config.interface.ts} (100%) rename src/plugins/{network.model.ts => interfaces/network.interface.ts} (100%) diff --git a/src/plugins/hotspot.ts b/src/plugins/hotspot.ts index 732a57e9a..27fdbff3a 100644 --- a/src/plugins/hotspot.ts +++ b/src/plugins/hotspot.ts @@ -1,9 +1,9 @@ import {Plugin, Cordova} from './plugin'; -import {Network} from './network.model'; -import {NetworkConfig} from './network-config.model'; -import {ConnectionInfo} from './connection-info.model'; -import {HotspotDevice} from './hotspot-device.model'; +import {Network} from './interfaces/network.interface'; +import {NetworkConfig} from './interfaces/network-config.interface'; +import {ConnectionInfo} from './interfaces/connection-info.interface'; +import {HotspotDevice} from './interfaces/hotspot-device.interface'; /** * @name Hotspot diff --git a/src/plugins/connection-info.model.ts b/src/plugins/interfaces/connection-info.interface.ts similarity index 100% rename from src/plugins/connection-info.model.ts rename to src/plugins/interfaces/connection-info.interface.ts diff --git a/src/plugins/hotspot-device.model.ts b/src/plugins/interfaces/hotspot-device.interface.ts similarity index 100% rename from src/plugins/hotspot-device.model.ts rename to src/plugins/interfaces/hotspot-device.interface.ts diff --git a/src/plugins/network-config.model.ts b/src/plugins/interfaces/network-config.interface.ts similarity index 100% rename from src/plugins/network-config.model.ts rename to src/plugins/interfaces/network-config.interface.ts diff --git a/src/plugins/network.model.ts b/src/plugins/interfaces/network.interface.ts similarity index 100% rename from src/plugins/network.model.ts rename to src/plugins/interfaces/network.interface.ts From b280c052c7f3f56ea58a6004a0c419b32483ed2b Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Sun, 8 May 2016 18:59:47 -0700 Subject: [PATCH 015/115] Actually exporting an interface instead of a class --- src/plugins/interfaces/connection-info.interface.ts | 2 +- src/plugins/interfaces/hotspot-device.interface.ts | 2 +- src/plugins/interfaces/network-config.interface.ts | 2 +- src/plugins/interfaces/network.interface.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/interfaces/connection-info.interface.ts b/src/plugins/interfaces/connection-info.interface.ts index 21c785da9..37a7c73b6 100644 --- a/src/plugins/interfaces/connection-info.interface.ts +++ b/src/plugins/interfaces/connection-info.interface.ts @@ -1,7 +1,7 @@ /** * @name ConnectionInfo */ -export class ConnectionInfo { +export interface ConnectionInfo { /** * @property {string} SSID * The service set identifier (SSID) of the current 802.11 network. diff --git a/src/plugins/interfaces/hotspot-device.interface.ts b/src/plugins/interfaces/hotspot-device.interface.ts index fd9a7f736..660dbb42c 100644 --- a/src/plugins/interfaces/hotspot-device.interface.ts +++ b/src/plugins/interfaces/hotspot-device.interface.ts @@ -1,7 +1,7 @@ /** * @name HotspotDevice */ -export class HotspotDevice { +export interface HotspotDevice { /** * @property {string} ip * Hotspot IP Address diff --git a/src/plugins/interfaces/network-config.interface.ts b/src/plugins/interfaces/network-config.interface.ts index 32164cddc..ce48444c0 100644 --- a/src/plugins/interfaces/network-config.interface.ts +++ b/src/plugins/interfaces/network-config.interface.ts @@ -1,7 +1,7 @@ /** * @name ConnectionInfo */ -export class NetworkConfig { +export interface NetworkConfig { /** * @property {string} deviceIPAddress - Device IP Address */ diff --git a/src/plugins/interfaces/network.interface.ts b/src/plugins/interfaces/network.interface.ts index 45f930953..16243a1c7 100644 --- a/src/plugins/interfaces/network.interface.ts +++ b/src/plugins/interfaces/network.interface.ts @@ -3,7 +3,7 @@ * @description * Based on [ScanResult](http://developer.android.com/reference/android/net/wifi/ScanResult.html) */ -export class Network { +export interface Network { /** * @property {string} SSID * Human readable network name From fc08e353a43f13d473a804402000d3199255db84 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 9 May 2016 11:01:51 -0500 Subject: [PATCH 016/115] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 61f24d3bc..3fcc8b0ee 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ Ionic Native is a curated set of wrappers for Cordova plugins that make adding any native functionality you need to your [Ionic](http://ionicframework.com/), Cordova, or Web View mobile app easy. +### Documentation + +For the full Ionic Native documentation, please visit [http://ionicframework.com/docs/v2/native/](http://ionicframework.com/docs/v2/native/). + ### Promises and Observables Ionic Native wraps plugin callbacks in a Promise or [Observable](https://gist.github.com/staltz/868e7e9bc2a7b8c1f754), providing a common interface for all plugins and ensuring that native events trigger change detection in Angular 2. From a631cc1d3a5e2956320db8430b6a8847b85974c0 Mon Sep 17 00:00:00 2001 From: perry Date: Mon, 9 May 2016 11:36:38 -0500 Subject: [PATCH 017/115] CI: make sure ident is set before push --- scripts/docs/update_docs.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/docs/update_docs.sh b/scripts/docs/update_docs.sh index c1c58dfce..b63af8472 100755 --- a/scripts/docs/update_docs.sh +++ b/scripts/docs/update_docs.sh @@ -30,6 +30,8 @@ function run { echo "-- No changes detected for the following commit, docs not updated." echo "https://github.com/driftyco/$CIRCLE_PROJECT_REPONAME/commit/$CIRCLE_SHA1" else + git config --global user.email "hi@ionicframework.com" + git config --global user.name "Ionitron" git add -A git commit -am "Automated build of native docs driftyco/$CIRCLE_PROJECT_REPONAME@$CIRCLE_SHA1" # in case a different commit was pushed to ionic-site during doc/demo gen, From 3cdf50bf3be0757954d228c79033ac268011a086 Mon Sep 17 00:00:00 2001 From: perry Date: Mon, 9 May 2016 13:07:42 -0500 Subject: [PATCH 018/115] make doc URLs use dashes and lower case --- scripts/docs/processors/jekyll.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/docs/processors/jekyll.js b/scripts/docs/processors/jekyll.js index 21152dfaa..1e5f68a6d 100644 --- a/scripts/docs/processors/jekyll.js +++ b/scripts/docs/processors/jekyll.js @@ -17,8 +17,9 @@ module.exports = function jekyll(renderDocsProcessor) { return (textA < textB) ? -1 : (textA > textB) ? 1 : 0; }); docs.forEach(function(doc, i) { - docs[i].URL = doc.outputPath.replace('docs/v2//','docs/v2/') - .replace('/index.md',''); + doc.outputPath = doc.outputPath.toLowerCase().replace(' ', '-'); + docs[i].URL = doc.outputPath.replace('docs/v2//', 'docs/v2/') + .replace('/index.md', ''); }); docs.push({ From df1cee1fc68ef2a9ce784d233a9bf8c6dcf094bb Mon Sep 17 00:00:00 2001 From: perry Date: Tue, 10 May 2016 17:49:21 -0500 Subject: [PATCH 019/115] copy edits from @kgindervogel --- src/plugins/apprate.ts | 28 +++++++++++++++------------- src/plugins/diagnostic.ts | 5 +++-- src/plugins/file.ts | 6 +++--- src/plugins/flashlight.ts | 10 +++++----- src/plugins/keyboard.ts | 4 ++-- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/plugins/apprate.ts b/src/plugins/apprate.ts index b1e36c154..96bc4add4 100644 --- a/src/plugins/apprate.ts +++ b/src/plugins/apprate.ts @@ -32,19 +32,21 @@ export class AppRate { /** * Rating dialog preferences * - * useLanguage {String} null - custom BCP 47 language tag - * displayAppName {String} '' - custom application title - * promptAgainForEachNewVersion {Boolean} true - show dialog again when application version will be updated - * usesUntilPrompt {Integer} 3 - count of runs of application before dialog will be displayed - * openStoreInApp {Boolean} false - leave app or no when application page opened in app store (now supported only for iOS) - * useCustomRateDialog {Boolean} false - use custom view for rate dialog - * callbacks.onButtonClicked {Function} null - call back function. called when user clicked on rate-dialog buttons - * callbacks.onRateDialogShow {Function} null - call back function. called when rate-dialog showing - * storeAppURL.ios {String} null - application id in AppStore - * storeAppURL.android {String} null - application URL in GooglePlay - * storeAppURL.blackberry {String} null - application URL in AppWorld - * storeAppURL.windows8 {String} null - application URL in WindowsStore - * customLocale {Object} null - custom locale object + * | Option | Type | Default | Description | + * |------------------------------|------------|---------|----------------------------------------------------------------------------------------| + * | useLanguage | `String` | null | custom BCP 47 language tag | + * | displayAppName | `String` | '' | custom application title | + * | promptAgainForEachNewVersion | `Boolean` | true | show dialog again when application version will be updated | + * | usesUntilPrompt | `Integer` | 3 | count of runs of application before dialog will be displayed | + * | openStoreInApp | `Boolean` | false | leave app or no when application page opened in app store (now supported only for iOS) | + * | useCustomRateDialog | `Boolean` | false | use custom view for rate dialog | + * | callbacks.onButtonClicked | `Function` | null | call back function. called when user clicked on rate-dialog buttons | + * | callbacks.onRateDialogShow | `Function` | null | call back function. called when rate-dialog showing | + * | storeAppURL.ios | `String` | null | application id in AppStore | + * | storeAppURL.android | `String` | null | application URL in GooglePlay | + * | storeAppURL.blackberry | `String` | null | application URL in AppWorld | + * | storeAppURL.windows8 | `String` | null | application URL in WindowsStore | + * | customLocale | `Object` | null | custom locale object | * @type {{}} */ @CordovaProperty diff --git a/src/plugins/diagnostic.ts b/src/plugins/diagnostic.ts index 6db5489f2..01b0be072 100644 --- a/src/plugins/diagnostic.ts +++ b/src/plugins/diagnostic.ts @@ -3,6 +3,7 @@ import {Plugin, Cordova} from './plugin'; @Plugin({ plugin: 'cordova.plugins.diagnostic', pluginRef: 'cordova.plugins.diagnostic' + repo: 'https://github.com/floatinghotpot/cordova-plugin-admob' }) export class Diagnostic { /** @@ -20,7 +21,7 @@ export class Diagnostic { /** * Checks if Wifi is connected/enabled. On iOS this returns true if the device is connected to a network by WiFi. On Android and Windows 10 Mobile this returns true if the WiFi setting is set to enabled. - * On Android this requires permission + * On Android this requires permission. `` */ @Cordova() static isWifiEnabled() { @@ -185,4 +186,4 @@ export class Diagnostic { -} \ No newline at end of file +} diff --git a/src/plugins/file.ts b/src/plugins/file.ts index d59426de8..35ff868fe 100644 --- a/src/plugins/file.ts +++ b/src/plugins/file.ts @@ -118,7 +118,7 @@ export class File { } /** - * Remove a directory at a given path + * Remove a directory at a given path. * * @param {string} path The path to the directory * @param {string} dirName The directory name @@ -158,7 +158,7 @@ export class File { } /** - * Move a directory to a given path + * Move a directory to a given path. * * @param {string} path The source path to the directory * @param {string} dirName The source directory name @@ -252,7 +252,7 @@ export class File { } /** - * List files and directory from a given path + * List files and directory from a given path. * * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} dirName Name of directory diff --git a/src/plugins/flashlight.ts b/src/plugins/flashlight.ts index 1447b0e3b..80aa7ee30 100644 --- a/src/plugins/flashlight.ts +++ b/src/plugins/flashlight.ts @@ -23,8 +23,8 @@ export class Flashlight { /** - * Checks if the flash light is available - * @returns {Promise} Returns a promise that resolves with a boolean stating if the flash light is available. + * Checks if the flashlight is available + * @returns {Promise} Returns a promise that resolves with a boolean stating if the flashlight is available. */ @Cordova() static available(): Promise { return; } @@ -37,7 +37,7 @@ export class Flashlight { static switchOn(): Promise { return; } /** - * Switches the flash light off + * Switches the flashlight off * @returns {Promise} */ @Cordova() @@ -52,7 +52,7 @@ export class Flashlight { /** - * Checks if the flash light is turned on. + * Checks if the flashlight is turned on. * Returns a boolean */ @Cordova({ @@ -60,4 +60,4 @@ export class Flashlight { }) static isSwitchedOn(): boolean { return; } -} \ No newline at end of file +} diff --git a/src/plugins/keyboard.ts b/src/plugins/keyboard.ts index e3bf63165..7c01269cc 100644 --- a/src/plugins/keyboard.ts +++ b/src/plugins/keyboard.ts @@ -37,7 +37,7 @@ export class Keyboard { static show(): void {} /** - * Close the keyboard if open + * Close the keyboard if open. */ @Cordova({ sync: true, @@ -75,4 +75,4 @@ export class Keyboard { }) static onKeyboardHide(): Observable {return; } -} \ No newline at end of file +} From 2e68ba6fb705886d4a93c9de9f3b7228ffa87254 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 11 May 2016 00:42:32 -0400 Subject: [PATCH 020/115] add missing comma --- src/plugins/diagnostic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/diagnostic.ts b/src/plugins/diagnostic.ts index 01b0be072..975c60df8 100644 --- a/src/plugins/diagnostic.ts +++ b/src/plugins/diagnostic.ts @@ -2,7 +2,7 @@ import {Plugin, Cordova} from './plugin'; @Plugin({ plugin: 'cordova.plugins.diagnostic', - pluginRef: 'cordova.plugins.diagnostic' + pluginRef: 'cordova.plugins.diagnostic', repo: 'https://github.com/floatinghotpot/cordova-plugin-admob' }) export class Diagnostic { From 494e55769c12a6f1679898b9b78aadf5608d914b Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 11 May 2016 01:05:12 -0400 Subject: [PATCH 021/115] change interface to type in filename --- src/plugins/hotspot.ts | 8 ++++---- .../connection-info.type.ts} | 0 .../hotspot-device.type.ts} | 0 .../network-config.type.ts} | 0 .../network.interface.ts => types/network.type.ts} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/plugins/{interfaces/connection-info.interface.ts => types/connection-info.type.ts} (100%) rename src/plugins/{interfaces/hotspot-device.interface.ts => types/hotspot-device.type.ts} (100%) rename src/plugins/{interfaces/network-config.interface.ts => types/network-config.type.ts} (100%) rename src/plugins/{interfaces/network.interface.ts => types/network.type.ts} (100%) diff --git a/src/plugins/hotspot.ts b/src/plugins/hotspot.ts index 27fdbff3a..acc29c853 100644 --- a/src/plugins/hotspot.ts +++ b/src/plugins/hotspot.ts @@ -1,9 +1,9 @@ import {Plugin, Cordova} from './plugin'; -import {Network} from './interfaces/network.interface'; -import {NetworkConfig} from './interfaces/network-config.interface'; -import {ConnectionInfo} from './interfaces/connection-info.interface'; -import {HotspotDevice} from './interfaces/hotspot-device.interface'; +import {Network} from './types/network.type'; +import {NetworkConfig} from './types/network-config.type'; +import {ConnectionInfo} from './types/connection-info.type'; +import {HotspotDevice} from './types/hotspot-device.type'; /** * @name Hotspot diff --git a/src/plugins/interfaces/connection-info.interface.ts b/src/plugins/types/connection-info.type.ts similarity index 100% rename from src/plugins/interfaces/connection-info.interface.ts rename to src/plugins/types/connection-info.type.ts diff --git a/src/plugins/interfaces/hotspot-device.interface.ts b/src/plugins/types/hotspot-device.type.ts similarity index 100% rename from src/plugins/interfaces/hotspot-device.interface.ts rename to src/plugins/types/hotspot-device.type.ts diff --git a/src/plugins/interfaces/network-config.interface.ts b/src/plugins/types/network-config.type.ts similarity index 100% rename from src/plugins/interfaces/network-config.interface.ts rename to src/plugins/types/network-config.type.ts diff --git a/src/plugins/interfaces/network.interface.ts b/src/plugins/types/network.type.ts similarity index 100% rename from src/plugins/interfaces/network.interface.ts rename to src/plugins/types/network.type.ts From aa034a208155d173c31b9fb7b2835a7b1f1ea91e Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 11 May 2016 01:51:18 -0400 Subject: [PATCH 022/115] 1.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 778d66b5a..a7c2a75cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-native", - "version": "1.2.0", + "version": "1.2.1", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "main": "dist/index.js", "directories": { From f0d5b88ec47a1ddcb22218f7661259adae5ec4db Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Fri, 13 May 2016 01:26:05 +0200 Subject: [PATCH 023/115] * Add background geolocation plugin from https://github.com/mauron85/cordova-plugin-background-geolocation --- src/plugins/background-geolocation.ts | 259 ++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 src/plugins/background-geolocation.ts diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts new file mode 100644 index 000000000..dd9ebf9f8 --- /dev/null +++ b/src/plugins/background-geolocation.ts @@ -0,0 +1,259 @@ +import {Plugin, Cordova} from './plugin'; +import {Observable} from 'rxjs/Observable'; + +declare var window; + + +export interface Location { + + /** + * ID of location as stored in DB (or null) + */ + locationId: number; + + /** + * Service provider + */ + serviceProvider: string; + + /** + * true if location recorded as part of debug + */ + debug: boolean + + /** + * UTC time of this fix, in milliseconds since January 1, 1970. + */ + time: number; + + /** + * latitude, in degrees. + */ + latitude: number; + + /** + * longitude, in degrees. + */ + longitude: number; + + /** + * estimated accuracy of this location, in meters. + */ + accuracy: number; + + /** + * speed if it is available, in meters/second over ground. + */ + speed: number; + + /** + * altitude if available, in meters above the WGS 84 reference ellipsoid. + */ + altitude: number; + + /** + * bearing, in degrees. + */ + bearing: number; + + /** + * A Coordinates object defining the current location + */ + coords: Coordinates; + + /** + * A timestamp representing the time at which the location was retrieved. + */ + timestamp: number; +} + +export interface BGeoOptions { + + /** + * Desired accuracy in meters. Possible values [0, 10, 100, 1000]. The lower + * the number, the more power devoted to GeoLocation resulting in higher + * accuracy readings. 1000 results in lowest power drain and least accurate + * readings. @see Apple docs (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instp/CLLocationManager/desiredAccuracy) + */ + desiredAccuracy: number; + + /** + * Stationary radius in meters. When stopped, the minimum distance the device + * must move beyond the stationary location for aggressive background-tracking + * to engage. + */ + stationaryRadius: number; + + /** + * When enabled, the plugin will emit sounds for life-cycle events of + * background-geolocation! See debugging sounds table. + */ + debug: boolean; + + /** + * The minimum distance (measured in meters) a device must move horizontally + * before an update event is generated. @see Apple docs. (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/distanceFilter) + */ + distanceFilter: number; + + /** + * IOS, ANDROID ONLY + * Enable this in order to force a stop() when the application terminated + * (e.g. on iOS, double-tap home button, swipe away the app). + */ + stopOnTerminate?: boolean; + + /** + * ANDROID, WP8 ONLY + * The minimum time interval between location updates in seconds. + * @see Android docs (http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(long,%20float,%20android.location.Criteria,%20android.app.PendingIntent)) + * and the MS doc (http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geolocator.reportinterval) + * for more information + */ + locationTimeout?: number; + + /** + * ANDROID ONLY + * Custom notification title in the drawer. + */ + notificationTitle?: string; + + /** + * ANDROID ONLY + * Custom notification text in the drawer. + */ + notificationText?: string; + + /** + * ANDROID ONLY + * The accent color to use for notification. Eg. #4CAF50. + */ + notificationIconColor?: string; + + /** + * ANDROID ONLY + * The filename of a custom notification icon. See android quirks. + * NOTE: Only available for API Level >=21. + */ + notificationIcon?: string; + + /** + * ANDROID ONLY + * Set location service provider @see wiki (https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers) + */ + locationService?: number; + + /** + * IOS ONLY + * [AutomotiveNavigation, OtherNavigation, Fitness, Other] Presumably, + * this affects iOS GPS algorithm. @see Apple docs for more information + * (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/activityType) + */ + activityType?: string; + +} + +/** + * @name BackgroundGeolocation + * @description + * This plugin provides foreground and background geolocation with battery-saving "circular region monitoring" and "stop detection". For + * more detail, please see https://github.com/mauron85/cordova-plugin-background-geolocation + * + * @usage + * + * ```ts + * import {BackgroundGeolocation} from 'ionic-native'; + * + * + * + * // When device is ready : + * platform.ready().then(() => { + * + * // BackgroundGeoLocation is highly configurable. See platform specific configuration options + * BackgroundGeolocation.configure( + * (location) => { + * console.log('[js] BackgroundGeoLocation callback: ' + location.latitude + ',' + location.longitude); + * /* + * IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, + * and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. + * IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. + * */ + * backgroundGeoLocation.finish(); + * }, + * (error) => { + * console.log('BackgroundGeoLocation error'); + * }, + * { + * desiredAccuracy: 10, + * stationaryRadius: 20, + * distanceFilter: 30, + * debug: true, // <-- enable this hear sounds for background-geolocation life-cycle. + * stopOnTerminate: false, // <-- enable this to clear background location settings when the app terminates + * } + * ); + * + * // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app. + * BackgroundGeoLocation.start(); + * } + * + * // If you wish to turn OFF background-tracking, call the #stop method. + * BackgroundGeoLocation.stop(); + * + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-mauron85-background-geolocation', + pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js + repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation' +}) +export class BackgroundGeoLocation { + + /** + * Configure the plugin. + * Success callback will be called with one argument - Location object, which tries to mimic w3c Coordinates interface. + * See http://dev.w3.org/geo/api/spec-source.html#coordinates_interface + * Callback to be executed every time a geolocation is recorded in the background. + * + * Fail callback to be executed every time a geolocation error occurs. + * + * Options a json object of type BGeoOptions + */ + @Cordova({ + callbackOrder: 'reverse' + }) + static configure(options: BGeoOptions): Promise { return; } + +// /** +// * Get the device's current position. +// * +// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). +// * @return Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error. +// */ +// @Cordova({ +// callbackOrder: 'reverse' +// }) +// static getCurrentPosition(options?: GeolocationOptions): Promise { return; } +// +// /** +// * Watch the current device's position. Clear the watch by unsubscribing from +// * Observable changes. +// * +// * ```ts +// * var subscription = Geolocation.watchPosition().subscribe(position => { +// * console.log(position.coords.longitude + ' ' + position.coords.latitude); +// * }); +// * +// * // To stop notifications +// * subscription.unsubscribe(); +// * ``` +// * +// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). +// * @return Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors. +// */ +// @Cordova({ +// callbackOrder: 'reverse', +// observable: true, +// clearFunction: 'clearWatch' +// }) +// static watchPosition(options?: GeolocationOptions): Observable { return; } +} From ddbd64d19a3bb1ae475157c936fb9399e6e7ac19 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 12 May 2016 21:54:52 -0400 Subject: [PATCH 024/115] fix(calendar): add new permissions functions for Android 6 (M) devices closes #156 --- src/plugins/calendar.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/plugins/calendar.ts b/src/plugins/calendar.ts index 705d789a6..ec199d584 100644 --- a/src/plugins/calendar.ts +++ b/src/plugins/calendar.ts @@ -33,6 +33,26 @@ export interface Calendar { platforms: ['Android', 'iOS'] }) export class Calendar { + + /** + * This function checks if we have permission to read/write from/to the calendar. + * The promise will resolve with `true` when: + * - You're running on iOS, or + * - You're targetting API level lower than 23, or + * - You're using Android < 6, or + * - You've already granted permission + * + * If this returns false, you should call `requestReadWritePermissions` function + */ + @Cordova() + static hasReadWritePermissions(): Promise { return; } + + /** + * Requests read/write permissions + */ + @Cordova({sync: true}) + static requestReadWritePermissions(): void {} + /** * Create a calendar. (iOS only) * From 58e3f0bbb9a6f8a0b219dc6ff599633d0692fd1f Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 12 May 2016 22:14:27 -0400 Subject: [PATCH 025/115] fix(Bluetooth): make connect function an observable to maintain full functionality closes #154 --- src/plugins/bluetoothserial.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/plugins/bluetoothserial.ts b/src/plugins/bluetoothserial.ts index 5a784de76..4bec47e62 100644 --- a/src/plugins/bluetoothserial.ts +++ b/src/plugins/bluetoothserial.ts @@ -16,29 +16,27 @@ export class BluetoothSerial { /** * Connect to a Bluetooth device + * Returns an Observable. Subscribe to connect, unsubscribe to disconnect. * @param macAddress_or_uuid Identifier of the remote device */ @Cordova({ - platforms: ['Android', 'iOS', 'Windows Phone'] + platforms: ['Android', 'iOS', 'Windows Phone'], + observable: true, + clearFunction: 'disconnect' }) - static connect (macAddress_or_uuid: string): Promise {return; } + static connect (macAddress_or_uuid: string): Observable {return; } /** * Connect insecurely to a Bluetooth device + * Returns an Observable. Subscribe to connect, unsubscribe to disconnect. * @param macAddress Identifier of the remote device */ @Cordova({ - platforms: ['Android'] + platforms: ['Android'], + observable: true, + clearFunction: 'disconnect' }) - static connectInsecure (macAddress: string): Promise {return; } - - /** - * Disconnect - */ - @Cordova({ - platforms: ['Android', 'iOS', 'Windows Phone'] - }) - static disconnect (): Promise {return; } + static connectInsecure (macAddress: string): Observable {return; } /** * Writes data to the serial port From 0f4fdda8c6eab6631c03fc79ad7bc7249e9666e9 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 12 May 2016 22:55:06 -0400 Subject: [PATCH 026/115] tslint + fix var name --- src/plugins/file.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/file.ts b/src/plugins/file.ts index 37c976d95..cd4e901f0 100644 --- a/src/plugins/file.ts +++ b/src/plugins/file.ts @@ -50,11 +50,11 @@ export class File { if ((/^\//.test(dir))) { rejectFn('directory cannot start with \/'); } - - if (!(/\/$/.test(noSlash))) { - path += "/"; + + if (!(/\/$/.test(dir))) { + path += '/'; } - + try { var directory = path + dir; @@ -355,10 +355,10 @@ export class File { rejectFn('file cannot start with \/'); } - if (!(/\/$/.test(noSlash))) { - path += "/"; + if (!(/\/$/.test(file))) { + path += '/'; } - + try { var directory = path + file; @@ -499,7 +499,7 @@ export class File { } else { rejectFn({code: null, message: 'READER_ONLOADEND_ERR'}); } - } + }; reader.readAsText(file); }, function (error) { From 2daca853dcecf4c4d5e37fab26ff67a0914a3cb3 Mon Sep 17 00:00:00 2001 From: vfdev Date: Fri, 13 May 2016 15:58:43 +0200 Subject: [PATCH 027/115] * [DEV] Add some functions * Add plugin in the index.ts --- src/index.ts | 1 + src/plugins/background-geolocation.ts | 86 ++++++++++++++++++++++----- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1d43e9c14..0fbcbffb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,7 @@ import {AppAvailability} from './plugins/appavailability'; import {AppRate} from './plugins/apprate'; import {AppVersion} from './plugins/appversion'; import {Badge} from './plugins/badge'; +import {BackgroundGeolocation} from './plugins/background-geolocation'; import {BarcodeScanner} from './plugins/barcodescanner'; import {Base64ToGallery} from './plugins/base64togallery'; import {BatteryStatus} from './plugins/batterystatus'; diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index dd9ebf9f8..f91c07172 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -67,7 +67,7 @@ export interface Location { timestamp: number; } -export interface BGeoOptions { +export interface Config { /** * Desired accuracy in meters. Possible values [0, 10, 100, 1000]. The lower @@ -169,44 +169,44 @@ export interface BGeoOptions { * // When device is ready : * platform.ready().then(() => { * - * // BackgroundGeoLocation is highly configurable. See platform specific configuration options + * // BackgroundGeolocation is highly configurable. See platform specific configuration options * BackgroundGeolocation.configure( * (location) => { - * console.log('[js] BackgroundGeoLocation callback: ' + location.latitude + ',' + location.longitude); + * console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude); * /* * IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, * and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. * IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. * */ - * backgroundGeoLocation.finish(); + * BackgroundGeolocation.finish(); * }, * (error) => { - * console.log('BackgroundGeoLocation error'); + * console.log('BackgroundGeolocation error'); * }, * { * desiredAccuracy: 10, * stationaryRadius: 20, * distanceFilter: 30, - * debug: true, // <-- enable this hear sounds for background-geolocation life-cycle. - * stopOnTerminate: false, // <-- enable this to clear background location settings when the app terminates + * debug: true, // enable this hear sounds for background-geolocation life-cycle. + * stopOnTerminate: false, // enable this to clear background location settings when the app terminates * } * ); * * // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app. - * BackgroundGeoLocation.start(); + * BackgroundGeolocation.start(); * } * * // If you wish to turn OFF background-tracking, call the #stop method. - * BackgroundGeoLocation.stop(); + * BackgroundGeolocation.stop(); * * ``` */ @Plugin({ plugin: 'cordova-plugin-mauron85-background-geolocation', - pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js + pluginRef: 'plugins.backgroundGeolocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation' }) -export class BackgroundGeoLocation { +export class BackgroundGeolocation { /** * Configure the plugin. @@ -218,11 +218,69 @@ export class BackgroundGeoLocation { * * Options a json object of type BGeoOptions */ - @Cordova({ - callbackOrder: 'reverse' - }) +// NOT SURE ABOUT THE TYPE OF RETURNED OBJECT +// https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/src/android/BackgroundGeolocationPlugin.java + @Cordova() static configure(options: BGeoOptions): Promise { return; } + + /** + * Turn ON the background-geolocation system. + * The user will be tracked whenever they suspend the app. + */ + @Cordova() + static start(): boolean { return; } + + + /** + * Turn OFF background-tracking + */ + @Cordova() + static stop(): boolean { return; } + + /** + * Inform the native plugin that you're finished, the background-task may be completed + */ + @Cordova() + static finish(): boolean { return; } + + + /** + * Force the plugin to enter "moving" or "stationary" state + */ + @Cordova() + static changePace(isMoving: boolean): boolean { return; } + + + /** + * Setup configuration + */ + @Cordova() + static setConfig(options: Config): boolean { return; } + +// /** +// * Returns current stationaryLocation if available. null if not +// */ +// @Cordova() +// static getStationaryLocation(): boolean { return; } + + /** + * Add a stationary-region listener. Whenever the devices enters "stationary-mode", + * your #success callback will be executed with #location param containing #radius of region + */ + @Cordova() + static setConfig(options: Config): boolean { return; } + + + + + + + + + + + // /** // * Get the device's current position. // * From 293145257c9e56982443d6febdca96ffa3742fce Mon Sep 17 00:00:00 2001 From: glecaros Date: Sun, 1 May 2016 21:56:55 -0700 Subject: [PATCH 028/115] Implemented wrappers for FileTransfer. --- src/index.ts | 3 + src/plugins/filetransfer.ts | 189 ++++++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 src/plugins/filetransfer.ts diff --git a/src/index.ts b/src/index.ts index 1d43e9c14..52e1f8ca8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,6 +31,7 @@ import {Dialogs} from './plugins/dialogs'; import {EmailComposer} from './plugins/emailcomposer'; import {Facebook} from './plugins/facebook'; import {File} from './plugins/file'; +import {Transfer} from './plugins/filetransfer'; import {Flashlight} from './plugins/flashlight'; import {Geolocation} from './plugins/geolocation'; import {Globalization} from './plugins/globalization'; @@ -108,6 +109,7 @@ export { StatusBar, Toast, TouchID, + Transfer, Vibration, WebIntent } @@ -166,6 +168,7 @@ window['IonicNative'] = { StatusBar: StatusBar, Toast: Toast, TouchID: TouchID, + Transfer: Transfer, Vibration: Vibration, WebIntent: WebIntent }; diff --git a/src/plugins/filetransfer.ts b/src/plugins/filetransfer.ts new file mode 100644 index 000000000..49b6e0061 --- /dev/null +++ b/src/plugins/filetransfer.ts @@ -0,0 +1,189 @@ +import {Plugin, Cordova} from './plugin'; +import {Observable} from 'rxjs/Observable'; + +declare var FileTransfer; + +export interface FileUploadOptions { + + /** + * The name of the form element. + * Defaults to 'file'. + */ + fileKey?: string; + + /** + * The file name to use when saving the file on the server. + * Defaults to 'image.jpg'. + */ + fileName?: string; + + /** + * The HTTP method to use - either PUT or POST. + * Defaults to POST. + */ + httpMethod?: string; + + /** + * The mime type of the data to upload. + * Defaults to image/jpeg. + */ + mimeType?: string; + + /** + * A set of optional key/value pairs to pass in the HTTP request. + */ + params?: { [s: string]: any; } + + /** + * Whether to upload the data in chunked streaming mode. + * Defaults to true. + */ + chunkedMode?: boolean; + + /** + * A map of header name/header values. Use an array to specify more + * than one value. On iOS, FireOS, and Android, if a header named + * Content-Type is present, multipart form data will NOT be used. + */ + headers?: { [s: string]: any; } +} + +export interface FileUploadResult { + + /** + * The number of bytes sent to the server as part of the upload. + */ + bytesSent: number; + + /** + * The HTTP response code returned by the server. + */ + responseCode: number; + + /** + * The HTTP response returned by the server. + */ + response: string; + + /** + * The HTTP response headers by the server. + */ + headers: { [s: string]: any; } +} + +export interface FileTransferError { + + /** + * One of the predefined error codes listed below. + */ + code: number; + + /** + * URL to the source. + */ + source: string; + + /** + * URL to the target. + */ + target: string; + + /** + * HTTP status code. This attribute is only available when a response + * code is received from the HTTP connection. + */ + http_status: number; + + /** + * Response body. This attribute is only available when a response is received from the HTTP connection. + */ + body: string; + + /** + * Either e.getMessage or e.toString. + */ + exception: string; +} + +/** + * @name Transfer + * @description This plugin allows you to upload and download files. + * Example: + * Create instance: + * const fileTransfer = new Transfer(); + * + * Upload a file: + * fileTransfer.upload(..).then(..).catch(..); + * + * Download a file: + * fileTransfer.download(..).then(..).catch(..); + * + * Abort active transfer: + * fileTransfer.abort(); + */ +@Plugin({ + plugin: 'cordova-plugin-file-transfer', + pluginRef: 'FileTransfer', + repo: 'https://github.com/apache/cordova-plugin-file-transfer' +}) +export class Transfer { + + public static FILE_NOT_FOUND_ERR: number = 1; + public static INVALID_URL_ERR: number = 2; + public static CONNECTION_ERR: number = 3; + public static ABORT_ERR: number = 4; + public static NOT_MODIFIED_ERR: number = 4; + + ft: any; + + constructor() { + this.ft = new FileTransfer(); + } + + /** + * Sends a file to a server. + * + * @param {string} fileUrl Filesystem URL representing the file on the device or a data URI. For backwards compatibility, this can also be the full path of the file on the device. + * @param {string} url URL of the server to receive the file, as encoded by encodeURI(). + * @param {FileUploadOptions} options Optional parameters. + * @param {boolean} trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. + * @return Returns a Promise that resolves to a FileUploadResult and rejects with FileTransferError. + */ + upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise { + return new Promise((resolve, reject) => { + this.ft.upload(fileUrl, url, (result: FileUploadResult) => { + resolve(result); + }, (err: FileTransferError) => { + reject(err); + }); + }); + } + + /** + * Downloads a file from server. + * + * @param {string} source URL of the server to download the file, as encoded by encodeURI(). + * @param {stirng} target Filesystem url representing the file on the device. For backwards compatibility, this can also be the full path of the file on the device. + * @param {boolean} trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful because Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. + * @param {object} Optional parameters, currently only supports headers (such as Authorization (Basic Authentication), etc). + * @return Returns a Promise that resolves to a FileEntry object. + */ + download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise { + return new Promise((resolve, reject) => { + this.ft.download(source, target, (result: any) => { + resolve(result); + }, (err: FileTransferError) => { + reject(err); + }, trustAllHosts, options); + }) + } + + /** + * Aborts an in-progress transfer. The onerror callback is passed a FileTransferError + * object which has an error code of FileTransferError.ABORT_ERR. + */ + abort() { + return this.ft.abort(); + } + +} From e9739882f42aa8cfac025502f161182272496c1a Mon Sep 17 00:00:00 2001 From: glecaros Date: Mon, 2 May 2016 23:13:53 -0700 Subject: [PATCH 029/115] Exposed onprogress. --- src/plugins/filetransfer.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/filetransfer.ts b/src/plugins/filetransfer.ts index 49b6e0061..77dac2413 100644 --- a/src/plugins/filetransfer.ts +++ b/src/plugins/filetransfer.ts @@ -178,11 +178,19 @@ export class Transfer { }) } + /** + * Registers a listener that gets called whenever a new chunk of data is transferred. + * @param {function} Listener that takes a progress event. + */ + onProgress(listener: (event: ProgressEvent) => any): void { + this.ft.onprocess = listener; + } + /** * Aborts an in-progress transfer. The onerror callback is passed a FileTransferError * object which has an error code of FileTransferError.ABORT_ERR. */ - abort() { + abort(): void { return this.ft.abort(); } From 631d7f2d85177645f7bde295351d959bcfaa91ef Mon Sep 17 00:00:00 2001 From: glecaros Date: Sat, 7 May 2016 21:05:23 -0700 Subject: [PATCH 030/115] Added missing parameters to upload. --- src/plugins/filetransfer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/filetransfer.ts b/src/plugins/filetransfer.ts index 77dac2413..9de541d1f 100644 --- a/src/plugins/filetransfer.ts +++ b/src/plugins/filetransfer.ts @@ -155,7 +155,7 @@ export class Transfer { resolve(result); }, (err: FileTransferError) => { reject(err); - }); + }, options, trustAllHosts); }); } From 9ddde5762d9618b374d5ee594e4c9de0fc21041c Mon Sep 17 00:00:00 2001 From: glecaros Date: Sat, 14 May 2016 00:24:45 -0700 Subject: [PATCH 031/115] Reimplemented using CordovaInstance. Fixed wrapInstance signature to match how it is called. --- src/plugins/filetransfer.ts | 41 +++++++++++++++++-------------------- src/plugins/plugin.ts | 2 +- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/plugins/filetransfer.ts b/src/plugins/filetransfer.ts index 9de541d1f..52e9c8fb5 100644 --- a/src/plugins/filetransfer.ts +++ b/src/plugins/filetransfer.ts @@ -1,5 +1,4 @@ -import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Plugin, CordovaInstance} from './plugin'; declare var FileTransfer; @@ -134,10 +133,10 @@ export class Transfer { public static ABORT_ERR: number = 4; public static NOT_MODIFIED_ERR: number = 4; - ft: any; + private _objectInstance: any; constructor() { - this.ft = new FileTransfer(); + this._objectInstance = new FileTransfer(); } /** @@ -149,14 +148,12 @@ export class Transfer { * @param {boolean} trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. * @return Returns a Promise that resolves to a FileUploadResult and rejects with FileTransferError. */ + @CordovaInstance({ + successIndex: 2, + errorIndex: 3 + }) upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise { - return new Promise((resolve, reject) => { - this.ft.upload(fileUrl, url, (result: FileUploadResult) => { - resolve(result); - }, (err: FileTransferError) => { - reject(err); - }, options, trustAllHosts); - }); + return; } /** @@ -168,30 +165,30 @@ export class Transfer { * @param {object} Optional parameters, currently only supports headers (such as Authorization (Basic Authentication), etc). * @return Returns a Promise that resolves to a FileEntry object. */ + @CordovaInstance({ + successIndex: 2, + errorIndex: 3 + }) download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise { - return new Promise((resolve, reject) => { - this.ft.download(source, target, (result: any) => { - resolve(result); - }, (err: FileTransferError) => { - reject(err); - }, trustAllHosts, options); - }) + return; } /** * Registers a listener that gets called whenever a new chunk of data is transferred. * @param {function} Listener that takes a progress event. */ + onProgress(listener: (event: ProgressEvent) => any): void { - this.ft.onprocess = listener; + this._objectInstance.onprogress = listener; } /** * Aborts an in-progress transfer. The onerror callback is passed a FileTransferError * object which has an error code of FileTransferError.ABORT_ERR. */ - abort(): void { - return this.ft.abort(); - } + @CordovaInstance({ + sync: true + }) + abort(): void {} } diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 71a6a9f17..4b3f38107 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -160,7 +160,7 @@ function callInstance(pluginObj: any, methodName: string, args: any[], opts: any return pluginObj._objectInstance[methodName].apply(pluginObj._objectInstance, args); } -function wrapInstance (pluginObj: any, methodName: string, args: any[], opts: any = {}) { +function wrapInstance (pluginObj: any, methodName: string, opts: any = {}) { return (...args) => { if (opts.sync) { return callInstance(pluginObj, methodName, args, opts); From 5c7b7e350f041bb21084d35ef7b7ae27828067b4 Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Sun, 15 May 2016 03:15:51 +0200 Subject: [PATCH 032/115] * Fix plugin insertion in index.ts * Add main functions --- src/index.ts | 2 + src/plugins/background-geolocation.ts | 110 ++++++++++++++------------ 2 files changed, 61 insertions(+), 51 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0fbcbffb7..b5a403a6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,6 +65,7 @@ export { AppRate, AppVersion, Badge, + BackgroundGeolocation, BarcodeScanner, Base64ToGallery, BatteryStatus, @@ -123,6 +124,7 @@ window['IonicNative'] = { AppRate: AppRate, AppVersion: AppVersion, Badge: Badge, + BackgroundGeolocation: BackgroundGeolocation, BarcodeScanner: BarcodeScanner, Base64ToGallery: Base64ToGallery, BatteryStatus: BatteryStatus, diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index f91c07172..453b17469 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -173,11 +173,10 @@ export interface Config { * BackgroundGeolocation.configure( * (location) => { * console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude); - * /* - * IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, - * and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. - * IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. - * */ + * + * // IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, + * // and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. + * // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. * BackgroundGeolocation.finish(); * }, * (error) => { @@ -203,7 +202,7 @@ export interface Config { */ @Plugin({ plugin: 'cordova-plugin-mauron85-background-geolocation', - pluginRef: 'plugins.backgroundGeolocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js + pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation' }) export class BackgroundGeolocation { @@ -216,102 +215,111 @@ export class BackgroundGeolocation { * * Fail callback to be executed every time a geolocation error occurs. * - * Options a json object of type BGeoOptions + * Options a json object of type Config */ // NOT SURE ABOUT THE TYPE OF RETURNED OBJECT // https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/src/android/BackgroundGeolocationPlugin.java @Cordova() - static configure(options: BGeoOptions): Promise { return; } + static configure(options: Config): Promise { return; } /** - * Turn ON the background-geolocation system. + * Turn ON the background-geolocation system. * The user will be tracked whenever they suspend the app. */ - @Cordova() + @Cordova() static start(): boolean { return; } /** * Turn OFF background-tracking */ - @Cordova() + @Cordova() static stop(): boolean { return; } + /** * Inform the native plugin that you're finished, the background-task may be completed */ - @Cordova() + @Cordova() static finish(): boolean { return; } /** * Force the plugin to enter "moving" or "stationary" state */ - @Cordova() + @Cordova() static changePace(isMoving: boolean): boolean { return; } /** * Setup configuration */ - @Cordova() + @Cordova() static setConfig(options: Config): boolean { return; } // /** // * Returns current stationaryLocation if available. null if not // */ -// @Cordova() +// @Cordova() // static getStationaryLocation(): boolean { return; } +// /** +// * Add a stationary-region listener. Whenever the devices enters "stationary-mode", +// * your #success callback will be executed with #location param containing #radius of region +// */ +// @Cordova() +// static onStationary(options: Config): boolean { return; } + /** - * Add a stationary-region listener. Whenever the devices enters "stationary-mode", - * your #success callback will be executed with #location param containing #radius of region + * Check if location is enabled on the device + * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). */ - @Cordova() - static setConfig(options: Config): boolean { return; } + @Cordova() + static isLocationEnabled(): Promise { return; } + /** + * Display device location settings + */ + @Cordova() + static showLocationSettings(): boolean { return; } +// /** +// * +// */ +// @Cordova() +// static watchLocationMode(): boolean { return; } +// /** +// * +// */ +// @Cordova() +// static stopWatchingLocationMode(): boolean { return; } - - - - - +// /** +// * +// */ +// @Cordova() +// static getLocations(): boolean { return; } // /** -// * Get the device's current position. // * -// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). -// * @return Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error. // */ -// @Cordova({ -// callbackOrder: 'reverse' -// }) -// static getCurrentPosition(options?: GeolocationOptions): Promise { return; } -// +// @Cordova() +// static deleteLocation(): boolean { return; } + // /** -// * Watch the current device's position. Clear the watch by unsubscribing from -// * Observable changes. // * -// * ```ts -// * var subscription = Geolocation.watchPosition().subscribe(position => { -// * console.log(position.coords.longitude + ' ' + position.coords.latitude); -// * }); -// * -// * // To stop notifications -// * subscription.unsubscribe(); -// * ``` -// * -// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). -// * @return Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors. // */ -// @Cordova({ -// callbackOrder: 'reverse', -// observable: true, -// clearFunction: 'clearWatch' -// }) -// static watchPosition(options?: GeolocationOptions): Observable { return; } +// @Cordova() +// static deleteAllLocations(): boolean { return; } + + +// /** +// * +// */ +// @Cordova() +// static apply(): boolean { return; } + } From 58b351ce13e40b39b6e12eb8ba2362a70630af3d Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Sun, 15 May 2016 04:47:35 +0200 Subject: [PATCH 033/115] * Fix signatures and bugs --- src/plugins/background-geolocation.ts | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index 453b17469..5b296c0f1 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -217,9 +217,9 @@ export class BackgroundGeolocation { * * Options a json object of type Config */ -// NOT SURE ABOUT THE TYPE OF RETURNED OBJECT -// https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/src/android/BackgroundGeolocationPlugin.java - @Cordova() + @Cordova({ + callbackOrder: 'reverse' + }) static configure(options: Config): Promise { return; } @@ -228,35 +228,39 @@ export class BackgroundGeolocation { * The user will be tracked whenever they suspend the app. */ @Cordova() - static start(): boolean { return; } + static start() { } /** * Turn OFF background-tracking */ @Cordova() - static stop(): boolean { return; } + static stop(): Promise { return; } /** * Inform the native plugin that you're finished, the background-task may be completed + * Method implemented for IOS */ @Cordova() - static finish(): boolean { return; } + static finish() { } /** * Force the plugin to enter "moving" or "stationary" state + * Used */ @Cordova() - static changePace(isMoving: boolean): boolean { return; } + static changePace(isMoving: boolean) { } /** * Setup configuration */ - @Cordova() - static setConfig(options: Config): boolean { return; } + @Cordova({ + callbackOrder: 'reverse' + }) + static setConfig(options: Config): Promise { return; } // /** // * Returns current stationaryLocation if available. null if not @@ -273,16 +277,16 @@ export class BackgroundGeolocation { /** * Check if location is enabled on the device - * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). + * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). */ @Cordova() - static isLocationEnabled(): Promise { return; } + static isLocationEnabled(): Promise { return; } /** * Display device location settings */ @Cordova() - static showLocationSettings(): boolean { return; } + static showLocationSettings() { } // /** // * @@ -316,10 +320,10 @@ export class BackgroundGeolocation { // static deleteAllLocations(): boolean { return; } -// /** -// * -// */ -// @Cordova() -// static apply(): boolean { return; } + /** + * + */ + @Cordova() + static apply(destination: Config, source: Config): Config { return; } } From f7ace39516f5e8412ac7f7871e997b16d12caa0b Mon Sep 17 00:00:00 2001 From: Matias Tucci Date: Mon, 16 May 2016 08:34:01 +0200 Subject: [PATCH 034/115] implement wrappers for Insomnia --- src/index.ts | 8 ++++--- src/plugins/insomnia.ts | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/plugins/insomnia.ts diff --git a/src/index.ts b/src/index.ts index 1d43e9c14..19e20c8f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,6 +39,7 @@ import {GoogleAnalytics} from './plugins/googleanalytics'; import {Hotspot} from './plugins/hotspot'; import {ImagePicker} from './plugins/imagepicker'; import {InAppBrowser} from './plugins/inappbrowser'; +import {Insomnia} from './plugins/insomnia'; import {Keyboard} from './plugins/keyboard'; import {LaunchNavigator} from './plugins/launchnavigator'; import {LocalNotifications} from './plugins/localnotifications'; @@ -93,6 +94,7 @@ export { Hotspot, ImagePicker, InAppBrowser, + Insomnia, Keyboard, LaunchNavigator, LocalNotifications, @@ -104,7 +106,7 @@ export { SocialSharing, SpinnerDialog, Splashscreen, - SQLite, + SQLite, StatusBar, Toast, TouchID, @@ -146,7 +148,7 @@ window['IonicNative'] = { Flashlight: Flashlight, Geolocation: Geolocation, Globalization: Globalization, - GoogleMaps : GoogleMaps, + GoogleMaps : GoogleMaps, GoogleAnalytics: GoogleAnalytics, Hotspot: Hotspot, ImagePicker: ImagePicker, @@ -162,7 +164,7 @@ window['IonicNative'] = { SocialSharing: SocialSharing, SpinnerDialog: SpinnerDialog, Splashscreen: Splashscreen, - SQLite: SQLite, + SQLite: SQLite, StatusBar: StatusBar, Toast: Toast, TouchID: TouchID, diff --git a/src/plugins/insomnia.ts b/src/plugins/insomnia.ts new file mode 100644 index 000000000..95238a666 --- /dev/null +++ b/src/plugins/insomnia.ts @@ -0,0 +1,47 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name Insomnia + * @description + * Prevent the screen of the mobile device from falling asleep. + * + * @usage + * ```js + * import {Insomnia} from 'ionic-native'; + * + * Insomnia.keepAwake() + * .then( + * () => console.log('success'), + * () => console.log('error') + * ); + * + * Insomnia.allowSleepAgain() + * .then( + * () => console.log('success'), + * () => console.log('error') + * ); + * ``` + * + */ +@Plugin({ + plugin: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git', + pluginRef: 'plugins.insomnia', + repo: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin', + platforms: ['Android', 'iOS', 'Windows Phone 8'] +}) +export class Insomnia { + + /** + * Keeps awake the application + * @returns {Promise} + */ + @Cordova() + static keepAwake(): Promise { return; } + + /** + * Allows the application to sleep again + * @returns {Promise} + */ + @Cordova() + static allowSleepAgain(): Promise { return; } +} From d561694750edb27578f77901d3ec22ac4e89deb6 Mon Sep 17 00:00:00 2001 From: Mati Tucci Date: Mon, 16 May 2016 08:44:51 +0200 Subject: [PATCH 035/115] Update DEVELOPER.md --- DEVELOPER.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DEVELOPER.md b/DEVELOPER.md index c1eb00e09..fcd2cfc30 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -92,6 +92,10 @@ The `@Cordova` decorator has a few more options now. `clearFunction` is used in conjunction with the `observable` option and indicates the function to be called when the Observable is disposed. +### Testing your changes + +You need to run `npm run build_bundle` in the `ionic-native` project, this will create a `dist` directory. Then, you must go to your ionic application folder and replace your current `node_modules/ionic-native/dist/` with the newly generated one. + ### 'Wrapping' Up That's it! The only thing left to do is rigorously document the plugin and it's usage. Take a look at some of the other plugins for good documentation styles. From d12a99c962ab3abffe1b9d8d92ab5c86d0e1f57d Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Tue, 17 May 2016 23:34:14 +0200 Subject: [PATCH 036/115] * Added Background-geolocation plugin : version to test --- src/plugins/background-geolocation.ts | 103 ++++++++++++++------------ 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index 5b296c0f1..86786a7ac 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -228,7 +228,7 @@ export class BackgroundGeolocation { * The user will be tracked whenever they suspend the app. */ @Cordova() - static start() { } + static start(): Promise { return; } /** @@ -240,7 +240,7 @@ export class BackgroundGeolocation { /** * Inform the native plugin that you're finished, the background-task may be completed - * Method implemented for IOS + * NOTE: IOS, WP only */ @Cordova() static finish() { } @@ -248,7 +248,7 @@ export class BackgroundGeolocation { /** * Force the plugin to enter "moving" or "stationary" state - * Used + * NOTE: IOS, WP only */ @Cordova() static changePace(isMoving: boolean) { } @@ -262,22 +262,25 @@ export class BackgroundGeolocation { }) static setConfig(options: Config): Promise { return; } -// /** -// * Returns current stationaryLocation if available. null if not -// */ -// @Cordova() -// static getStationaryLocation(): boolean { return; } + /** + * Returns current stationaryLocation if available. null if not + * NOTE: IOS, WP only + */ + @Cordova() + static getStationaryLocation(): Promise { return; } -// /** -// * Add a stationary-region listener. Whenever the devices enters "stationary-mode", -// * your #success callback will be executed with #location param containing #radius of region -// */ -// @Cordova() -// static onStationary(options: Config): boolean { return; } + /** + * Add a stationary-region listener. Whenever the devices enters "stationary-mode", + * your #success callback will be executed with #location param containing #radius of region + * NOTE: IOS, WP only + */ + @Cordova() + static onStationary(): Promise { return; } /** * Check if location is enabled on the device * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). + * NOTE: ANDROID only */ @Cordova() static isLocationEnabled(): Promise { return; } @@ -288,42 +291,46 @@ export class BackgroundGeolocation { @Cordova() static showLocationSettings() { } -// /** -// * -// */ -// @Cordova() -// static watchLocationMode(): boolean { return; } - -// /** -// * -// */ -// @Cordova() -// static stopWatchingLocationMode(): boolean { return; } - -// /** -// * -// */ -// @Cordova() -// static getLocations(): boolean { return; } - - -// /** -// * -// */ -// @Cordova() -// static deleteLocation(): boolean { return; } - -// /** -// * -// */ -// @Cordova() -// static deleteAllLocations(): boolean { return; } - - /** - * + * Method can be used to detect user changes in location services settings. + * If user enable or disable location services then success callback will be executed. + * In case or error (SettingNotFoundException) fail callback will be executed. + * NOTE: ANDROID only */ @Cordova() - static apply(destination: Config, source: Config): Config { return; } + static watchLocationMode(): Promise { return; } + + /** + * Stop watching for location mode changes. + * NOTE: ANDROID only + */ + @Cordova() + static stopWatchingLocationMode() { } + + /** + * Method will return all stored locations. + * Locations are stored when: + * - config.stopOnTerminate is false and main activity was killed + * by the system + * or + * - option.debug is true + * NOTE: ANDROID only + */ + @Cordova() + static getLocations(): Promise { return; } + + /** + * Delete stored location by given locationId. + * NOTE: ANDROID only + */ + @Cordova() + static deleteLocation(locationId: number): Promise { return; } + + /** + * Delete all stored locations. + * NOTE: ANDROID only + */ + @Cordova() + static deleteAllLocations(): Promise { return; } } From 3c49face4cc59acd6ed89cf3d7a6d0dfbc4e5ce8 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 13:57:00 -0400 Subject: [PATCH 037/115] docs(emailcomposer): fix docs partially fixes #168 --- src/plugins/emailcomposer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/emailcomposer.ts b/src/plugins/emailcomposer.ts index c40c7bfda..35e1f65d7 100644 --- a/src/plugins/emailcomposer.ts +++ b/src/plugins/emailcomposer.ts @@ -49,7 +49,7 @@ export interface Email { * }; * * // Send a text message using default options - * EmailComposer.send(email); + * EmailComposer.open(email); * * ``` */ From 2a568d2398c3c5ec4d4b1f4db305f795024f71e0 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 14:06:13 -0400 Subject: [PATCH 038/115] fix(emailcomposer): fix isAvailable function function now returns a promise that resolves if email composer is available, and rejects if it's not partially fixes #168 --- src/plugins/emailcomposer.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/emailcomposer.ts b/src/plugins/emailcomposer.ts index 35e1f65d7..d2cb4f87e 100644 --- a/src/plugins/emailcomposer.ts +++ b/src/plugins/emailcomposer.ts @@ -64,13 +64,13 @@ export class EmailComposer { /** * Verifies if sending emails is supported on the device. * - * @param app {string?} An optional app id or uri scheme. Defaults to mailto. - * @param scope {any?} An optional scope for the promise - * @returns {Promise} Resolves promise with boolean whether EmailComposer is available + * @param app {string?} An optional app id or uri scheme. + * @returns {Promise} Resolves if available, rejects if not available */ - static isAvailable (app?: string, scope?: any): Promise { + static isAvailable (app?: string): Promise { return new Promise((resolve, reject) => { - cordova.plugins.email.isAvailable(app, resolve, scope); + if (app) cordova.plugins.email.isAvailable(app, (isAvailable) => { if (isAvailable) resolve(); else reject(); }); + else cordova.plugins.email.isAvailable((isAvailable) => { if (isAvailable) resolve(); else reject(); }); }); } From 21ffe99226c06f7dfef177665efa4ca884555392 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 14:08:25 -0400 Subject: [PATCH 039/115] refactor(emailcomposer): create new file for the Email type addresses #168 --- src/plugins/emailcomposer.ts | 16 +--------------- src/plugins/types/email.type.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 src/plugins/types/email.type.ts diff --git a/src/plugins/emailcomposer.ts b/src/plugins/emailcomposer.ts index d2cb4f87e..22219efde 100644 --- a/src/plugins/emailcomposer.ts +++ b/src/plugins/emailcomposer.ts @@ -1,21 +1,7 @@ import {Plugin, Cordova} from './plugin'; - +import {Email} from './types/email.type.ts'; declare var cordova; -/** - * Email object for Opening Email Composer - */ -export interface Email { - app?: string; - to: string | Array; - cc: string | Array; - bcc: string | Array; - attachments: Array; - subject: string; - body: string; - isHtml: boolean; -} - /** * @name Email Composer * @description diff --git a/src/plugins/types/email.type.ts b/src/plugins/types/email.type.ts new file mode 100644 index 000000000..bea6a0ad5 --- /dev/null +++ b/src/plugins/types/email.type.ts @@ -0,0 +1,13 @@ +/** + * Email object for Opening Email Composer + */ +export interface Email { + app?: string; + to: string | Array; + cc: string | Array; + bcc: string | Array; + attachments: Array; + subject: string; + body: string; + isHtml: boolean; +} \ No newline at end of file From 2f6688c9c4d43abc9154c5eed3cd36029c1f023d Mon Sep 17 00:00:00 2001 From: Robert Coie Date: Thu, 19 May 2016 16:02:15 -0700 Subject: [PATCH 040/115] type return value of globalization's stringToNumber --- src/plugins/globalization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/globalization.ts b/src/plugins/globalization.ts index e6793a4bd..eacc75a34 100644 --- a/src/plugins/globalization.ts +++ b/src/plugins/globalization.ts @@ -107,7 +107,7 @@ export class Globalization { successIndex: 1, errorIndex: 2 }) - static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value}> {return; } + static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value:number|string}> {return; } /** * From eed8cb1b1d4d8f7628892c8bd4c7302785d469b3 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 15:04:11 -0400 Subject: [PATCH 041/115] fix email type import --- src/plugins/emailcomposer.ts | 2 +- src/plugins/types/email.type.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/emailcomposer.ts b/src/plugins/emailcomposer.ts index 22219efde..db3ddb0d4 100644 --- a/src/plugins/emailcomposer.ts +++ b/src/plugins/emailcomposer.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Email} from './types/email.type.ts'; +import {Email} from './types/email.type'; declare var cordova; /** diff --git a/src/plugins/types/email.type.ts b/src/plugins/types/email.type.ts index bea6a0ad5..d133d1b3f 100644 --- a/src/plugins/types/email.type.ts +++ b/src/plugins/types/email.type.ts @@ -3,11 +3,11 @@ */ export interface Email { app?: string; - to: string | Array; - cc: string | Array; - bcc: string | Array; - attachments: Array; - subject: string; - body: string; - isHtml: boolean; + to?: string | Array; + cc?: string | Array; + bcc?: string | Array; + attachments?: Array; + subject?: string; + body?: string; + isHtml?: boolean; } \ No newline at end of file From 5105b0a184b01f371519997464271103329b72a0 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 15:34:34 -0400 Subject: [PATCH 042/115] fixes --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a7c2a75cf..ad74e852c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dist" ], "dependencies": { - "rxjs": "5.0.0-beta.2" + "rxjs": "^5.0.0-beta.6" }, "devDependencies": { "browserify": "^13.0.0", @@ -33,7 +33,7 @@ "semver": "^5.0.1", "tslint": "^3.8.1", "tslint-eslint-rules": "^1.3.0", - "typescript": "^1.7.5" + "typescript": "^1.8.10" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", From e391f5fa394005113cbf8a97fceaf427fbe8b899 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 16:35:14 -0400 Subject: [PATCH 043/115] fix screenshot plugin - closes #169 --- src/plugins/screenshot.ts | 58 +++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/src/plugins/screenshot.ts b/src/plugins/screenshot.ts index 551b9fe4e..44085594b 100644 --- a/src/plugins/screenshot.ts +++ b/src/plugins/screenshot.ts @@ -1,4 +1,5 @@ import {Cordova, Plugin} from './plugin'; +declare var navigator: any; @Plugin({ plugin: 'https://github.com/gitawego/cordova-screenshot.git', pluginRef: 'navigator.screenshot', @@ -8,29 +9,52 @@ export class Screenshot { /** * Takes screenshot and saves the image - * + * * @param {string} format. Format can take the value of either 'jpg' or 'png' * On ios, only 'jpg' format is supported - * @param {number} quality. Determines the quality of the screenshot. + * @param {number} quality. Determines the quality of the screenshot. * Default quality is set to 100. - * @param {string} filename. Name of the file as stored on the storage + * @param {string} filename. Name of the file as stored on the storage */ - @Cordova({ - successIndex: 1, - errorIndex: 0 - }) - static save (format?: string, quality?: number, filename?: string): Promise {return; } + static save (format?: string, quality?: number, filename?: string): Promise { + return new Promise( + (resolve, reject) => { + navigator.screenshot.save( + (error, result) => { + if(error){ + reject(error); + }else{ + resolve(result); + } + }, + format, + quality, + filename + ); + } + ); + } /** * Takes screenshot and returns the image as an URI - * - * @param {number} quality. Determines the quality of the screenshot. + * + * @param {number} quality. Determines the quality of the screenshot. * Default quality is set to 100. */ - - @Cordova({ - successIndex: 1, - errorIndex: 0 - }) - static URI (quality?: number): Promise {return; } -} \ No newline at end of file + static URI (quality?: number): Promise { + return new Promise( + (resolve, reject) => { + navigator.screenshot.URI( + (error, result) => { + if(error){ + reject(error); + }else{ + resolve(result); + } + }, + quality + ); + } + ); + } +} From bcdec67c2ea8687738400ca9b06514978f566e5c Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 16:58:57 -0400 Subject: [PATCH 044/115] refractor Observable imports --- src/plugins/webintent.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/webintent.ts b/src/plugins/webintent.ts index 3065cbb7a..6ad99735b 100644 --- a/src/plugins/webintent.ts +++ b/src/plugins/webintent.ts @@ -35,4 +35,4 @@ export class WebIntent { @Cordova() static sendBroadcast(options: {action: string, extras?: {option: boolean}}): Promise {return; } -} \ No newline at end of file +} From 9987fb24dac3bad21f856055012888aee5c6e093 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 16:59:18 -0400 Subject: [PATCH 045/115] refractor Observable imports --- src/plugins/admob.ts | 4 ++-- src/plugins/background-geolocation.ts | 2 +- src/plugins/batterystatus.ts | 2 +- src/plugins/ble.ts | 2 +- src/plugins/bluetoothserial.ts | 4 ++-- src/plugins/dbmeter.ts | 4 ++-- src/plugins/devicemotion.ts | 4 ++-- src/plugins/deviceorientation.ts | 2 +- src/plugins/geolocation.ts | 2 +- src/plugins/googlemaps.ts | 2 +- src/plugins/keyboard.ts | 2 +- src/plugins/network.ts | 4 ++-- src/plugins/plugin.ts | 4 ++-- src/plugins/toast.ts | 2 +- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/plugins/admob.ts b/src/plugins/admob.ts index 8f781a88e..91a9367c1 100644 --- a/src/plugins/admob.ts +++ b/src/plugins/admob.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; /** * @name AdMob @@ -174,4 +174,4 @@ export class AdMob { }) static onInterstitialDismiss (): Observable {return; } -} \ No newline at end of file +} diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index 86786a7ac..3cf540008 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; declare var window; diff --git a/src/plugins/batterystatus.ts b/src/plugins/batterystatus.ts index c52b7aee3..efdb3972e 100644 --- a/src/plugins/batterystatus.ts +++ b/src/plugins/batterystatus.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; /** * @name Battery Status diff --git a/src/plugins/ble.ts b/src/plugins/ble.ts index c4bf4e7c4..f95941c35 100644 --- a/src/plugins/ble.ts +++ b/src/plugins/ble.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; /** * @name BLE diff --git a/src/plugins/bluetoothserial.ts b/src/plugins/bluetoothserial.ts index 4bec47e62..901ae1a57 100644 --- a/src/plugins/bluetoothserial.ts +++ b/src/plugins/bluetoothserial.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; /** * @name Bluetooth Serial @@ -221,4 +221,4 @@ export class BluetoothSerial { -} \ No newline at end of file +} diff --git a/src/plugins/dbmeter.ts b/src/plugins/dbmeter.ts index 9a9a9ff44..aee63c2de 100644 --- a/src/plugins/dbmeter.ts +++ b/src/plugins/dbmeter.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; /** * @name DB Meter * @description This plugin defines a global DBMeter object, which permits to get the decibel values from the microphone. @@ -68,4 +68,4 @@ export class DBMeter { @Cordova() static delete(): Promise {return; } -} \ No newline at end of file +} diff --git a/src/plugins/devicemotion.ts b/src/plugins/devicemotion.ts index 26eee6837..c991c628e 100644 --- a/src/plugins/devicemotion.ts +++ b/src/plugins/devicemotion.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; export interface AccelerationData { @@ -101,4 +101,4 @@ export class DeviceMotion { static watchAcceleration(options?: AccelerometerOptions): Observable { return; } -} \ No newline at end of file +} diff --git a/src/plugins/deviceorientation.ts b/src/plugins/deviceorientation.ts index c0a9be5c2..853c5d7c2 100644 --- a/src/plugins/deviceorientation.ts +++ b/src/plugins/deviceorientation.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; export interface CompassHeading { diff --git a/src/plugins/geolocation.ts b/src/plugins/geolocation.ts index fea2a97dc..781c7ed3e 100644 --- a/src/plugins/geolocation.ts +++ b/src/plugins/geolocation.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; declare var window; diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index a24462f75..fbdd3f7eb 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -1,5 +1,5 @@ import {Cordova, Plugin} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; import {CordovaInstance} from './plugin'; /** * Created by Ibrahim on 3/29/2016. diff --git a/src/plugins/keyboard.ts b/src/plugins/keyboard.ts index 7c01269cc..570af472b 100644 --- a/src/plugins/keyboard.ts +++ b/src/plugins/keyboard.ts @@ -1,5 +1,5 @@ import {Cordova, Plugin} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; /** * @name Keyboard diff --git a/src/plugins/network.ts b/src/plugins/network.ts index 3986963ab..9c6d07af3 100644 --- a/src/plugins/network.ts +++ b/src/plugins/network.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova, CordovaProperty} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; declare var navigator: any; @@ -25,7 +25,7 @@ declare var navigator: any; * let connectSubscription = Network.onConnect().subscribe(() => { * console.log('network connected!');
* * // We just got a connection but we need to wait briefly - * 
// before we determine the connection type. Might need to wait
 + *
// before we determine the connection type. Might need to wait
 * // prior to doing any api requests as well. * setTimeout(() => { * console.log(Network.connection); diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 4b3f38107..014d72a18 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -6,7 +6,7 @@ declare var window; declare var Promise; declare var $q; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; /** * @private @@ -335,4 +335,4 @@ export function InstanceProperty(target: Function, key: string, descriptor: Type }; return descriptor; -} \ No newline at end of file +} diff --git a/src/plugins/toast.ts b/src/plugins/toast.ts index 00e12aa86..ff48e1c7e 100644 --- a/src/plugins/toast.ts +++ b/src/plugins/toast.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs/Rx'; export interface ToastOptions { /** From b11da8da0b8b607ca50ae6e548242ecc3d509c90 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 20 May 2016 17:02:45 -0400 Subject: [PATCH 046/115] 1.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad74e852c..913e97fc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-native", - "version": "1.2.1", + "version": "1.2.2", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "main": "dist/index.js", "directories": { From cc267038e6030eb41b0c0cf0621a33c6041d58df Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 00:28:19 -0400 Subject: [PATCH 047/115] add missing return type closes #172 --- src/plugins/calendar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/calendar.ts b/src/plugins/calendar.ts index ec199d584..ec19234aa 100644 --- a/src/plugins/calendar.ts +++ b/src/plugins/calendar.ts @@ -271,7 +271,7 @@ export class Calendar { * @return A Promise that resolves with the list of calendars, or rejects with an error. */ @Cordova() - static listCalendars() { return; } + static listCalendars(): Promise { return; } /** * Get a list of all future events in the specified calendar. (iOS only) From 6c485ed1f63ee21c375b7a81bf8d1babb3e8c483 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 00:53:35 -0400 Subject: [PATCH 048/115] added docs --- src/plugins/googlemaps.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index fbdd3f7eb..e72859d15 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -7,6 +7,18 @@ import {CordovaInstance} from './plugin'; declare var plugin: any; /** * @name Google Maps + * @description This plugin uses the native Google Maps SDK + * @usage + * ``` + * import {GoogleMaps} from 'ionic-native'; + * + * ... + * + * // somewhere in your component + * let map = new GoogleMaps('elementID'); + * + * map.onInit().subscribe(() => console.log("Map is ready!")); + * ``` */ @Plugin({ pluginRef: 'plugin.google.maps', From 9f67fa79dbbad3b1cd4db1b0886043a12c4179ca Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 03:12:11 -0400 Subject: [PATCH 049/115] add googlemap features --- src/plugins/googlemaps.ts | 181 +++++++++++++++++++++++++++++++++++++- 1 file changed, 179 insertions(+), 2 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index e72859d15..b9367629c 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -21,7 +21,7 @@ declare var plugin: any; * ``` */ @Plugin({ - pluginRef: 'plugin.google.maps', + pluginRef: 'plugin.google.maps.Map', plugin: 'cordova-plugin-googlemaps', repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' }) @@ -29,21 +29,198 @@ export class GoogleMaps { private _objectInstance: any; + /** + * Checks if a map object has been created. + * @return {Promise} returns a promise that resolves with the Map object (if it exists). + */ + @Cordova() + static isAvailable (): Promise {return; } + constructor (elementId: string) { this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId)); } + /** + * Get notified via an Observable when the user clicks on the map. (Event: MAP_CLICK) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.MAP_CLICK' + }) + static onMapClick (): Observable {return; } + + /** + * Get notified via an Observable when the user long-clicks on the map. (Event: MAP_LONG_CLICK) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.MAP_LONG_CLICK' + }) + static onMapLongClick (): Observable {return; } + + /** + * Get notified via an Observable when the user clicks the `My Location` button. (Event: MY_LOCATION_BUTTON_CLICK) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK' + }) + static onMyLocationButtonClick (): Observable {return; } + + /** + * Get notified via an Observable when the user changes the view. (Event: CAMERA_CHANGE) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.CAMERA_CHANGE' + }) + static onCameraChange (): Observable {return; } + + /** + * Get notified via an Observable when the view is on idle. (Event: CAMERA_IDLE) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.CAMERA_IDLE', + platforms: ['iOS'] + }) + static onCameraIdle (): Observable {return; } + + /** + * Get notified via an Observable when the map is ready. (Event: MAP_READY) + */ @Cordova({ eventObservable: true, event: 'plugin.google.maps.event.MAP_READY' }) - static onInit (): Observable {return; } + static onMapReady (): Observable {return; } + + /** + * Get notified via an Observable when the map is loaded. (Event: MAP_LOADED) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.MAP_LOADED', + platforms: ['Android'] + }) + static onMapLoaded (): Observable {return; } + + /** + * Get notified via an Observable when the map will move. (Event: MAP_WILL_MOVE) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.MAP_WILL_MOVE', + platforms: ['iOS'] + }) + static onMapWillMove (): Observable {return; } + + /** + * Get notified via an Observable when the user closes the map. (Event: MAP_CLOSE) + */ + @Cordova({ + eventObservable: true, + event: 'plugin.google.maps.event.MAP_CLOSE' + }) + static onMapClose (): Observable {return; } @CordovaInstance({ sync: true }) setDebuggable (isDebuggable: boolean): void {} + @CordovaInstance({ + sync: true + }) setClickable (isClickable: boolean): void {} + @CordovaInstance({ + sync: true + }) + animateCamera (options: AnimateCameraOptions): void {return; } + + /** + * + */ + @CordovaInstance() + getCameraPosition (): Promise {return; } + + /** + * + */ + @CordovaInstance() + getMyLocation (): Promise {return; } + + /** + * + */ + @CordovaInstance() + getVisibleRegion (): Promise {return; } + + + } + +export interface AnimateCameraOptions { + target: string; + tilt: number; + zoom: number; + bearing: number; + duration: number; +} + +export interface CameraPosition { + target: { + lat: string; + lng: string; + }; + zoom: number; + tilt: number; + bearing: number; +} + +export interface MyLocation { + latLng: { + lat: string; + lng: string; + }; + speed: number; + time: string; + bearing: number; +} + +export interface VisibleRegion { + northeast: any; + southwest: any; +} + + +/** + * @private + Google Maps LatLng + **/ +@Plugin({ + pluginRef: 'plugin.google.maps.Map', + plugin: 'cordova-plugin-googlemaps', + repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' +}) +export class GoogleMapsLatLng { + constructor (public lat: string, public lng: string) { + return plugin.google.maps.LatLng(lat, lng); + } + + @CordovaInstance({ + sync: true + }) + equals (other: GoogleMapsLatLng): boolean {return; } + + @CordovaInstance({ + sync: true + }) + toString (): string {return; } + + @CordovaInstance({ + sync: true + }) + toUrlValue (precision?: number): string {return; } +} \ No newline at end of file From fbb1353827ccd85aee8407d0b87e71833e7f7e89 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 03:12:58 -0400 Subject: [PATCH 050/115] add docs --- src/plugins/googlemaps.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index b9367629c..62ce5a148 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -140,25 +140,23 @@ export class GoogleMaps { animateCamera (options: AnimateCameraOptions): void {return; } /** - * + * Get the position of the camera */ @CordovaInstance() getCameraPosition (): Promise {return; } /** - * + * Get the location of the user */ @CordovaInstance() getMyLocation (): Promise {return; } /** - * + * Get the visible region */ @CordovaInstance() getVisibleRegion (): Promise {return; } - - } export interface AnimateCameraOptions { From 5517e510dc210540040f701edc23925dceb064ba Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 03:31:27 -0400 Subject: [PATCH 051/115] add more functions --- src/plugins/googlemaps.ts | 170 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 162 insertions(+), 8 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 62ce5a148..fccbc9b19 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -47,7 +47,7 @@ export class GoogleMaps { eventObservable: true, event: 'plugin.google.maps.event.MAP_CLICK' }) - static onMapClick (): Observable {return; } + static onMapClick (): Observable {return; } /** * Get notified via an Observable when the user long-clicks on the map. (Event: MAP_LONG_CLICK) @@ -56,7 +56,7 @@ export class GoogleMaps { eventObservable: true, event: 'plugin.google.maps.event.MAP_LONG_CLICK' }) - static onMapLongClick (): Observable {return; } + static onMapLongClick (): Observable {return; } /** * Get notified via an Observable when the user clicks the `My Location` button. (Event: MY_LOCATION_BUTTON_CLICK) @@ -65,7 +65,7 @@ export class GoogleMaps { eventObservable: true, event: 'plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK' }) - static onMyLocationButtonClick (): Observable {return; } + static onMyLocationButtonClick (): Observable {return; } /** * Get notified via an Observable when the user changes the view. (Event: CAMERA_CHANGE) @@ -74,7 +74,7 @@ export class GoogleMaps { eventObservable: true, event: 'plugin.google.maps.event.CAMERA_CHANGE' }) - static onCameraChange (): Observable {return; } + static onCameraChange (): Observable {return; } /** * Get notified via an Observable when the view is on idle. (Event: CAMERA_IDLE) @@ -84,7 +84,7 @@ export class GoogleMaps { event: 'plugin.google.maps.event.CAMERA_IDLE', platforms: ['iOS'] }) - static onCameraIdle (): Observable {return; } + static onCameraIdle (): Observable {return; } /** * Get notified via an Observable when the map is ready. (Event: MAP_READY) @@ -113,7 +113,7 @@ export class GoogleMaps { event: 'plugin.google.maps.event.MAP_WILL_MOVE', platforms: ['iOS'] }) - static onMapWillMove (): Observable {return; } + static onMapWillMove (): Observable {return; } /** * Get notified via an Observable when the user closes the map. (Event: MAP_CLOSE) @@ -122,7 +122,7 @@ export class GoogleMaps { eventObservable: true, event: 'plugin.google.maps.event.MAP_CLOSE' }) - static onMapClose (): Observable {return; } + static onMapClose (): Observable {return; } @CordovaInstance({ sync: true @@ -157,6 +157,158 @@ export class GoogleMaps { @CordovaInstance() getVisibleRegion (): Promise {return; } + @CordovaInstance({ + sync: true + }) + showDialog (): void { } + + @CordovaInstance({ + sync: true + }) + closeDialog (): void { } + + @CordovaInstance() + getLicenseInfo (): Promise {return ;} + + @CordovaInstance({ + sync: true + }) + setCenter (latLng: GoogleMapsLatLng): void { } + + @CordovaInstance({ + sync: true + }) + setZoome (zoomLevel: number): void { } + + @CordovaInstance({ + sync: true + }) + setMapTypeId (typeId: string): void { } + + @CordovaInstance({ + sync: true + }) + setTilt (tiltLevel: number): void { } + + @CordovaInstance({ + sync: true + }) + animateCamera (cameraPosition: CameraPosition): void { } + + @CordovaInstance({ + sync: true + }) + moveCamera (cameraPosition: CameraPosition): void { } + + @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 { } + +@CordovaInstance({ + sync: true +}) + addMarker (options: any): void { } + +@CordovaInstance({ + sync: true +}) + addCircle (options: any): void { } + +@CordovaInstance({ + sync: true +}) + addPolygon (options: any): void { } + +@CordovaInstance({ + sync: true +}) + addPolyline (options: any): void { } + +@CordovaInstance({ + sync: true +}) + addTileOverlay (options: any): void { } + +@CordovaInstance({ + sync: true +}) + addGroundOverlay (options: any): void { } + +@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 { } + +@CordovaInstance() + fromLatLngToPoint (latLng: GoogleMapsLatLng, point: any): Promise {return; } + +@CordovaInstance() + fromPointToLatLng (point: any, latLng: GoogleMapsLatLng): Promise {return; } + +@CordovaInstance() + toDataURL (): Promise {return; } + +@CordovaInstance({ + sync: true +}) + remove (): void { } + +@CordovaInstance({ + sync: true +}) + panBy (): void { } + } export interface AnimateCameraOptions { @@ -221,4 +373,6 @@ export class GoogleMapsLatLng { sync: true }) toUrlValue (precision?: number): string {return; } -} \ No newline at end of file +} + + From c531114f46ce6e5ca5b42c3965afc5d2edcc4a39 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 03:32:05 -0400 Subject: [PATCH 052/115] formatting --- src/plugins/googlemaps.ts | 114 +++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index fccbc9b19..b128a55cc 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -210,103 +210,103 @@ export class GoogleMaps { }) setIndoorEnabled (enabled: boolean): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setTrafficEnabled (enabled: boolean): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setCompassEnabled (enabled: boolean): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setAllGesturesEnabled (enabled: boolean): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) addMarker (options: any): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) addCircle (options: any): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) addPolygon (options: any): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) addPolyline (options: any): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) addTileOverlay (options: any): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) addGroundOverlay (options: any): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setDiv (domNode: HTMLElement): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setVisible (visible: boolean): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setOptions (options: any): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setBackgroundColor (backgroundColor: string): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setPadding (top?: number, right?: number, bottom?: number, left?: number): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) clear (): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) refreshLayout (): void { } -@CordovaInstance() + @CordovaInstance() fromLatLngToPoint (latLng: GoogleMapsLatLng, point: any): Promise {return; } -@CordovaInstance() + @CordovaInstance() fromPointToLatLng (point: any, latLng: GoogleMapsLatLng): Promise {return; } -@CordovaInstance() + @CordovaInstance() toDataURL (): Promise {return; } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) remove (): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) panBy (): void { } } From 3aefd5a46d232c61d059d5f7beb71ce03a7adc36 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 03:33:27 -0400 Subject: [PATCH 053/115] typo --- src/plugins/googlemaps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index b128a55cc..1e0bf0c6d 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -178,7 +178,7 @@ export class GoogleMaps { @CordovaInstance({ sync: true }) - setZoome (zoomLevel: number): void { } + setZoom (zoomLevel: number): void { } @CordovaInstance({ sync: true From 346ca3e403fc65034ff78174972391ebccd11d86 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 03:52:00 -0400 Subject: [PATCH 054/115] add marker object (temporary) --- src/plugins/googlemaps.ts | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 1e0bf0c6d..ff0cb8323 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -344,13 +344,54 @@ export interface VisibleRegion { southwest: any; } +/** + * @private + * Marker object + */ +@Plugin({ + pluginRef: 'plugin.google.maps.Marker', + plugin: 'cordova-plugin-googlemaps', + repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' +}) +export interface GoogleMapsMarker { + icon: any; + title: string; + snippet: string; + position: GoogleMapsLatLng; + infoWindowAnchor: number[]; + draggable: boolean; + flat: boolean; + rotation: number; + visible: boolean; + styles: any; + animation: string; + zIndex: number; + + getPosition() + showInfoWindow(): void; + hideInfoWindow(): void; + get(message: string): void; + setIcon(icon: GoogleMapsMarkerIcon): void; + remove(): void; + setDraggable(draggable: boolean): void; + +} + +export interface GoogleMapsMarkerIcon { + url: string; + size: { + width: number; + height: number; + } +} + /** * @private Google Maps LatLng **/ @Plugin({ - pluginRef: 'plugin.google.maps.Map', + pluginRef: 'plugin.google.maps.LatLng', plugin: 'cordova-plugin-googlemaps', repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' }) From 531e6162784b9eba809a26d24f5932a624a61af7 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 16:43:18 -0400 Subject: [PATCH 055/115] add marker class --- src/plugins/googlemaps.ts | 140 +++++++++++++++++++++++++++++++++++--- 1 file changed, 132 insertions(+), 8 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index ff0cb8323..433da91f2 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -1,3 +1,7 @@ +// Notes: +// - The way I'm listening to events might not work. Might need to switch +// - I'm assuming that the sub objects do need a constructor, so I'm using the constructor for other purposes + import {Cordova, Plugin} from './plugin'; import {Observable} from 'rxjs/Rx'; import {CordovaInstance} from './plugin'; @@ -353,7 +357,7 @@ export interface VisibleRegion { plugin: 'cordova-plugin-googlemaps', repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' }) -export interface GoogleMapsMarker { +export class GoogleMapsMarker { icon: any; title: string; snippet: string; @@ -367,13 +371,133 @@ export interface GoogleMapsMarker { animation: string; zIndex: number; - getPosition() - showInfoWindow(): void; - hideInfoWindow(): void; - get(message: string): void; - setIcon(icon: GoogleMapsMarkerIcon): void; - remove(): void; - setDraggable(draggable: boolean): void; + constructor (private _objectInstance: any) { } + + @CordovaInstance() + getPosition (): Promise {return; } + + @CordovaInstance({ + sync: true + }) + isVisible (): boolean {return;} + + @CordovaInstance() + setVisible (visible: boolean): void { } + + @CordovaInstance({ + sync: true + }) + getHashCode (): string {return; } + + @CordovaInstance({ + sync: true + }) + remove(): void { } + + @CordovaInstance({ + sync: true + }) + setOpacity (alpha: number): void { } + + @CordovaInstance({ + sync: true + }) + getOpacity(): number {return; } + + @CordovaInstance({ + sync: true + }) + setZIndex(): void { } + + @CordovaInstance({ + sync: true + }) + setIconAnchor(x: number, y: number): void { } + + @CordovaInstance({ + sync: true + }) + setInfoWindowAnchor(x: number, y:number): void { } + + @CordovaInstance({ + sync: true + }) + setDraggable(draggable: boolean): void { } + + @CordovaInstance({ + sync: true + }) + isDraggable(): boolean {return; } + + @CordovaInstance({ + sync: true + }) + setFlat(flat: boolean): void {return; } + + @CordovaInstance({ + sync: true + }) + setIcon(icon: GoogleMapsMarkerIcon): void { } + + @CordovaInstance({ + sync: true + }) + setTitle(title: string): void { } + + @CordovaInstance({ + sync: true + }) + getTitle(): string {return; } + + @CordovaInstance({ + sync: true + }) + setSnippet(snippet: string): void { } + + @CordovaInstance({ + sync: true + }) + getSnippet(): string {return; } + + @CordovaInstance({ + sync: true + }) + setRotation(rotation: number): void { } + + @CordovaInstance({ + sync: true + }) + getRotation(): number {return; } + + @CordovaInstance({ + sync: true + }) + showInfoWindow(): number {return; } + + @CordovaInstance({ + sync: true + }) + hideInfoWindow(): number {return; } + + @CordovaInstance({ + sync: true + }) + setPosition(latLng: GoogleMapsLatLng): void { } + + @CordovaInstance() + getPosition(): Promise {return; } + + @CordovaInstance({ + sync: true + }) + getMap(): GoogleMaps {return; } + + @CordovaInstance({ + sync: true + }) + setAnimation(animation: string): void { } + + } From 1ff614edecc98fcacb24e3166e56e92bb3a8ed60 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 16:48:03 -0400 Subject: [PATCH 056/115] fixes --- src/plugins/googlemaps.ts | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 433da91f2..26255c241 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -229,10 +229,15 @@ export class GoogleMaps { }) setAllGesturesEnabled (enabled: boolean): void { } - @CordovaInstance({ - sync: true - }) - addMarker (options: any): void { } + addMarker (options: any): GoogleMapsMarker { + if (!options) { + console.warn('Google Maps Plugin: No options provided.'); + return; + } + + let objectInstance = this._objectInstance.addMarker(options); + return new GoogleMapsMarker(objectInstance); + } @CordovaInstance({ sync: true @@ -348,15 +353,6 @@ export interface VisibleRegion { southwest: any; } -/** - * @private - * Marker object - */ -@Plugin({ - pluginRef: 'plugin.google.maps.Marker', - plugin: 'cordova-plugin-googlemaps', - repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' -}) export class GoogleMapsMarker { icon: any; title: string; @@ -509,16 +505,6 @@ export interface GoogleMapsMarkerIcon { } } - -/** - * @private - Google Maps LatLng - **/ -@Plugin({ - pluginRef: 'plugin.google.maps.LatLng', - plugin: 'cordova-plugin-googlemaps', - repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' -}) export class GoogleMapsLatLng { constructor (public lat: string, public lng: string) { return plugin.google.maps.LatLng(lat, lng); From 5cf9fde50585c02afb070a5aa1f0c927071a4a21 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 16:59:32 -0400 Subject: [PATCH 057/115] add InstanceProperty decorator --- src/plugins/googlemaps.ts | 113 +++++++++++++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 13 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 26255c241..3f9d63bfc 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -5,6 +5,7 @@ import {Cordova, Plugin} from './plugin'; import {Observable} from 'rxjs/Rx'; import {CordovaInstance} from './plugin'; +import {InstanceProperty} from "../../dist/plugins/plugin"; /** * Created by Ibrahim on 3/29/2016. */ @@ -354,23 +355,23 @@ export interface VisibleRegion { } export class GoogleMapsMarker { - icon: any; - title: string; - snippet: string; - position: GoogleMapsLatLng; - infoWindowAnchor: number[]; - draggable: boolean; - flat: boolean; - rotation: number; - visible: boolean; - styles: any; - animation: string; - zIndex: number; + @InstanceProperty icon: any; + @InstanceProperty title: string; + @InstanceProperty snippet: string; + @InstanceProperty position: GoogleMapsLatLng; + @InstanceProperty infoWindowAnchor: number[]; + @InstanceProperty draggable: boolean; + @InstanceProperty flat: boolean; + @InstanceProperty rotation: number; + @InstanceProperty visible: boolean; + @InstanceProperty styles: any; + @InstanceProperty animation: string; + @InstanceProperty zIndex: number; constructor (private _objectInstance: any) { } @CordovaInstance() - getPosition (): Promise {return; } + getPosition (): Promise {return; } @CordovaInstance({ sync: true @@ -505,6 +506,92 @@ export interface GoogleMapsMarkerIcon { } } +export class GoogleMapsCircle { + @InstanceProperty center: GoogleMapsLatLng; + @InstanceProperty visible: boolean; + @InstanceProperty radius: number; + @InstanceProperty strokeColor: string; + @InstanceProperty strokeWidth: number; + @InstanceProperty fillColor: string; + @InstanceProperty visible: boolean; + @InstanceProperty zIndex: number; + + constructor(private _objectInstnace: any) { } + + @CordovaInstance({ + sync: true + }) + getCenter(): GoogleMapsLatLng {return; } + +@CordovaInstance({ + sync: true +}) + getRadius(): number {return; } + +@CordovaInstance({ + sync: true +}) + getStrokeColor(): string {return; } + + @CordovaInstance({ + sync: true + }) + getVisible(): boolean {return; } + +@CordovaInstance({ + sync: true +}) + getZIndex(): number {return; } + +@CordovaInstance({ + sync: true +}) + remove(): void { } + +@CordovaInstance({ + sync: true +}) + setCenter(latLng: GoogleMapsLatLng): 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(): GoogleMaps {return; } + + + +} + export class GoogleMapsLatLng { constructor (public lat: string, public lng: string) { return plugin.google.maps.LatLng(lat, lng); From bec74e6f44da8b1243f56de2d7c3ac98060d6b8f Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 17:03:43 -0400 Subject: [PATCH 058/115] add notes --- src/plugins/googlemaps.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 3f9d63bfc..c85205eb3 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -1,6 +1,12 @@ -// Notes: -// - The way I'm listening to events might not work. Might need to switch -// - I'm assuming that the sub objects do need a constructor, so I'm using the constructor for other purposes +/** + * ----- IMPORTANT NOTES ----- + * + * - The current event listeners might not work. They might need an alternative implementation. + * - Constructors of the "sub-objects" are not meant to be used. They are for ionic-native developer only. + * - The plugin isn't fully tested and documented yet. Use at your own risk, and don't hesitate to ask questions. + * + * --------------------------- + */ import {Cordova, Plugin} from './plugin'; import {Observable} from 'rxjs/Rx'; From 72d9047da8713cd446081d1553cd0056f1ccdea8 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 17:07:53 -0400 Subject: [PATCH 059/115] fixes! --- src/plugins/googlemaps.ts | 62 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index c85205eb3..88fdbdec3 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -11,7 +11,6 @@ import {Cordova, Plugin} from './plugin'; import {Observable} from 'rxjs/Rx'; import {CordovaInstance} from './plugin'; -import {InstanceProperty} from "../../dist/plugins/plugin"; /** * Created by Ibrahim on 3/29/2016. */ @@ -236,20 +235,15 @@ export class GoogleMaps { }) setAllGesturesEnabled (enabled: boolean): void { } - addMarker (options: any): GoogleMapsMarker { - if (!options) { - console.warn('Google Maps Plugin: No options provided.'); - return; - } - - let objectInstance = this._objectInstance.addMarker(options); + addMarker (options: GoogleMapsMarkerOptions): GoogleMapsMarker { + let objectInstance: any = this._objectInstance.addMarker(options); return new GoogleMapsMarker(objectInstance); } - @CordovaInstance({ - sync: true - }) - addCircle (options: any): void { } + addCircle (options: GoogleMapsCircleOptions): GoogleMapsCircle { + let objectInstance: any = this._objectInstance.addCircle(options); + return new GoogleMapsCircle(objectInstance); + } @CordovaInstance({ sync: true @@ -360,19 +354,21 @@ export interface VisibleRegion { southwest: any; } +export interface GoogleMapsMarkerOptions { + icon: any; + title: string; + snippet: string; + position: GoogleMapsLatLng; + infoWindowAnchor: number[]; + draggable: boolean; + flat: boolean; + rotation: number; + visible: boolean; + styles: any; + animation: string; + zIndex: number; +} export class GoogleMapsMarker { - @InstanceProperty icon: any; - @InstanceProperty title: string; - @InstanceProperty snippet: string; - @InstanceProperty position: GoogleMapsLatLng; - @InstanceProperty infoWindowAnchor: number[]; - @InstanceProperty draggable: boolean; - @InstanceProperty flat: boolean; - @InstanceProperty rotation: number; - @InstanceProperty visible: boolean; - @InstanceProperty styles: any; - @InstanceProperty animation: string; - @InstanceProperty zIndex: number; constructor (private _objectInstance: any) { } @@ -512,15 +508,17 @@ export interface GoogleMapsMarkerIcon { } } +export interface GoogleMapsCircleOptions { + center: GoogleMapsLatLng; + visible: boolean; + radius: number; + strokeColor: string; + strokeWidth: number; + fillColor: string; + visible: boolean; + zIndex: number; +} export class GoogleMapsCircle { - @InstanceProperty center: GoogleMapsLatLng; - @InstanceProperty visible: boolean; - @InstanceProperty radius: number; - @InstanceProperty strokeColor: string; - @InstanceProperty strokeWidth: number; - @InstanceProperty fillColor: string; - @InstanceProperty visible: boolean; - @InstanceProperty zIndex: number; constructor(private _objectInstnace: any) { } From e884a9cb89e96eedf241704ef1dfeaa70f60050e Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 17:08:28 -0400 Subject: [PATCH 060/115] enable circleci --- circle.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index 166686e1f..561b592c6 100644 --- a/circle.yml +++ b/circle.yml @@ -4,10 +4,10 @@ machine: ruby: version: 2.1.2 -general: - branches: - only: - - master # ignore PRs and branches +#general: +# branches: +# only: +# - master # ignore PRs and branches dependencies: pre: From 16e3264c8408fac8c78d330f39bd4c7394ba7479 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 17:12:47 -0400 Subject: [PATCH 061/115] Fix ts issues --- src/plugins/googlemaps.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 88fdbdec3..652cbe662 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -144,11 +144,6 @@ export class GoogleMaps { }) setClickable (isClickable: boolean): void {} - @CordovaInstance({ - sync: true - }) - animateCamera (options: AnimateCameraOptions): void {return; } - /** * Get the position of the camera */ @@ -372,9 +367,6 @@ export class GoogleMapsMarker { constructor (private _objectInstance: any) { } - @CordovaInstance() - getPosition (): Promise {return; } - @CordovaInstance({ sync: true }) @@ -510,7 +502,6 @@ export interface GoogleMapsMarkerIcon { export interface GoogleMapsCircleOptions { center: GoogleMapsLatLng; - visible: boolean; radius: number; strokeColor: string; strokeWidth: number; From 2e8b7455760a92e43473ddaf973de9c2b80fe0b8 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 17:40:00 -0400 Subject: [PATCH 062/115] Fixes --- src/index.ts | 6 +- src/plugins/googlemaps.ts | 165 +++++++++++++++++++++++++------------- 2 files changed, 111 insertions(+), 60 deletions(-) diff --git a/src/index.ts b/src/index.ts index d4d678e24..eb9d74be7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,7 +36,7 @@ import {Transfer} from './plugins/filetransfer'; import {Flashlight} from './plugins/flashlight'; import {Geolocation} from './plugins/geolocation'; import {Globalization} from './plugins/globalization'; -import {GoogleMaps} from './plugins/googlemaps'; +import {GoogleMap} from './plugins/googlemaps'; import {GoogleAnalytics} from './plugins/googleanalytics'; import {Hotspot} from './plugins/hotspot'; import {ImagePicker} from './plugins/imagepicker'; @@ -92,7 +92,7 @@ export { Flashlight, Geolocation, Globalization, - GoogleMaps, + GoogleMap, GoogleAnalytics, Hotspot, ImagePicker, @@ -153,7 +153,7 @@ window['IonicNative'] = { Flashlight: Flashlight, Geolocation: Geolocation, Globalization: Globalization, - GoogleMaps : GoogleMaps, + GoogleMap : GoogleMap, GoogleAnalytics: GoogleAnalytics, Hotspot: Hotspot, ImagePicker: ImagePicker, diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 652cbe662..07122f814 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -35,16 +35,16 @@ declare var plugin: any; plugin: 'cordova-plugin-googlemaps', repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' }) -export class GoogleMaps { +export class GoogleMap { private _objectInstance: any; /** * Checks if a map object has been created. - * @return {Promise} returns a promise that resolves with the Map object (if it exists). + * @return {Promise} returns a promise that resolves with the Map object (if it exists). */ @Cordova() - static isAvailable (): Promise {return; } + static isAvailable (): Promise {return; } constructor (elementId: string) { this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId)); @@ -103,7 +103,7 @@ export class GoogleMaps { eventObservable: true, event: 'plugin.google.maps.event.MAP_READY' }) - static onMapReady (): Observable {return; } + static onMapReady (): Observable {return; } /** * Get notified via an Observable when the map is loaded. (Event: MAP_LOADED) @@ -113,7 +113,7 @@ export class GoogleMaps { event: 'plugin.google.maps.event.MAP_LOADED', platforms: ['Android'] }) - static onMapLoaded (): Observable {return; } + static onMapLoaded (): Observable {return; } /** * Get notified via an Observable when the map will move. (Event: MAP_WILL_MOVE) @@ -323,7 +323,6 @@ export interface AnimateCameraOptions { bearing: number; duration: number; } - export interface CameraPosition { target: { lat: string; @@ -333,7 +332,6 @@ export interface CameraPosition { tilt: number; bearing: number; } - export interface MyLocation { latLng: { lat: string; @@ -343,7 +341,6 @@ export interface MyLocation { time: string; bearing: number; } - export interface VisibleRegion { northeast: any; southwest: any; @@ -363,6 +360,13 @@ export interface GoogleMapsMarkerOptions { animation: string; zIndex: number; } +export interface GoogleMapsMarkerIcon { + url: string; + size: { + width: number; + height: number; + } +} export class GoogleMapsMarker { constructor (private _objectInstance: any) { } @@ -481,7 +485,7 @@ export class GoogleMapsMarker { @CordovaInstance({ sync: true }) - getMap(): GoogleMaps {return; } + getMap(): GoogleMap {return; } @CordovaInstance({ sync: true @@ -492,14 +496,6 @@ export class GoogleMapsMarker { } -export interface GoogleMapsMarkerIcon { - url: string; - size: { - width: number; - height: number; - } -} - export interface GoogleMapsCircleOptions { center: GoogleMapsLatLng; radius: number; @@ -518,14 +514,14 @@ export class GoogleMapsCircle { }) getCenter(): GoogleMapsLatLng {return; } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) getRadius(): number {return; } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) getStrokeColor(): string {return; } @CordovaInstance({ @@ -533,63 +529,120 @@ export class GoogleMapsCircle { }) getVisible(): boolean {return; } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) getZIndex(): number {return; } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) remove(): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setCenter(latLng: GoogleMapsLatLng): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setFillColor(fillColor: string): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setStrokeColor(strokeColor: string): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setStrokeWidth(strokeWidth: number): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setVisible(visible: boolean): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setZIndex(zIndex: number): void { } -@CordovaInstance({ - sync: true -}) + @CordovaInstance({ + sync: true + }) setRadius(radius: number): void { } -@CordovaInstance({ - sync: true -}) - getMap(): GoogleMaps {return; } + @CordovaInstance({ + sync: true + }) + getMap(): GoogleMap {return; } +} + +export interface GoogleMapsPolylineOptions { + points: Array; + visible: boolean; + googledesic: boolean; + color: string; + width: number; + visible: boolean; + zIndex: number; +} +export class GoogleMapsPolyline { + constructor (private _objectInstance: any) { } + + // TODO add event listeners + + @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; } + } export class GoogleMapsLatLng { + private _objectInstance: any; + constructor (public lat: string, public lng: string) { - return plugin.google.maps.LatLng(lat, lng); + this._objectInstance = plugin.google.maps.LatLng(lat, lng); } @CordovaInstance({ @@ -607,5 +660,3 @@ export class GoogleMapsLatLng { }) toUrlValue (precision?: number): string {return; } } - - From 6b5f216fa4715622b645af6f70f279812c7161af Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 25 May 2016 17:42:25 -0400 Subject: [PATCH 063/115] remove duplicate identifier --- src/plugins/googlemaps.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 07122f814..f993a07bb 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -589,7 +589,6 @@ export interface GoogleMapsPolylineOptions { googledesic: boolean; color: string; width: number; - visible: boolean; zIndex: number; } export class GoogleMapsPolyline { From 7e61e3bd7c2dc04d60c30db3e11852b15a816895 Mon Sep 17 00:00:00 2001 From: perry Date: Thu, 26 May 2016 12:53:06 -0500 Subject: [PATCH 064/115] fix improve this doc link --- scripts/docs/templates/common.template.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docs/templates/common.template.html b/scripts/docs/templates/common.template.html index d22083a10..4354f8c1d 100644 --- a/scripts/docs/templates/common.template.html +++ b/scripts/docs/templates/common.template.html @@ -104,7 +104,7 @@ docType: "<$ doc.docType $>" - + Improve this doc From f3509689db75d5adf8394ffbcfb9456b141b599e Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:05:15 -0400 Subject: [PATCH 065/115] working! --- src/plugins/googlemaps.ts | 161 ++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 78 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index f993a07bb..63414f417 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -36,8 +36,18 @@ declare var plugin: any; repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' }) export class GoogleMap { - - private _objectInstance: any; + static event: any = { + MAP_READY: plugin.google.maps.event.MAP_READY, + MAP_CLICK: plugin.google.maps.event.MAP_CLICK, + MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK, + MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK, + CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE, + CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE, + MAP_LOADED: plugin.google.maps.event.MAP_LOADED, + MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE, + MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE + }; + _objectInstance: any; /** * Checks if a map object has been created. @@ -50,32 +60,21 @@ export class GoogleMap { this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId)); } - /** - * Get notified via an Observable when the user clicks on the map. (Event: MAP_CLICK) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.MAP_CLICK' - }) - static onMapClick (): Observable {return; } + on(event: any): Observable{ + return new Observable( + (observer) => { + this._objectInstance.on(event, observer.next); + return () => this._objectInstance.off(event); + } + ); + } - /** - * Get notified via an Observable when the user long-clicks on the map. (Event: MAP_LONG_CLICK) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.MAP_LONG_CLICK' - }) - static onMapLongClick (): Observable {return; } + one(event: any): Promise{ + return new Promise( + resolve => this._objectInstance.one(event, resolve) + ); + } - /** - * Get notified via an Observable when the user clicks the `My Location` button. (Event: MY_LOCATION_BUTTON_CLICK) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK' - }) - static onMyLocationButtonClick (): Observable {return; } /** * Get notified via an Observable when the user changes the view. (Event: CAMERA_CHANGE) @@ -230,9 +229,15 @@ export class GoogleMap { }) setAllGesturesEnabled (enabled: boolean): void { } - addMarker (options: GoogleMapsMarkerOptions): GoogleMapsMarker { - let objectInstance: any = this._objectInstance.addMarker(options); - return new GoogleMapsMarker(objectInstance); + addMarker (options: GoogleMapsMarkerOptions): Promise { + return new Promise( + (resolve, reject) => { + this._objectInstance.addMarker(options, (marker: any) => { + if(marker) resolve(new GoogleMapsMarker(marker)); + else reject(); + }); + } + ); } addCircle (options: GoogleMapsCircleOptions): GoogleMapsCircle { @@ -317,54 +322,54 @@ export class GoogleMap { } export interface AnimateCameraOptions { - target: string; - tilt: number; - zoom: number; - bearing: number; - duration: number; + target?: string; + tilt?: number; + zoom?: number; + bearing?: number; + duration?: number; } export interface CameraPosition { - target: { - lat: string; - lng: string; + target?: { + lat?: string; + lng?: string; }; - zoom: number; - tilt: number; - bearing: number; + zoom?: number; + tilt?: number; + bearing?: number; } export interface MyLocation { - latLng: { - lat: string; - lng: string; + latLng?: { + lat?: string; + lng?: string; }; - speed: number; - time: string; - bearing: number; + speed?: number; + time?: string; + bearing?: number; } export interface VisibleRegion { - northeast: any; - southwest: any; + northeast?: any; + southwest?: any; } export interface GoogleMapsMarkerOptions { - icon: any; - title: string; - snippet: string; - position: GoogleMapsLatLng; - infoWindowAnchor: number[]; - draggable: boolean; - flat: boolean; - rotation: number; - visible: boolean; - styles: any; - animation: string; - zIndex: number; + icon?: any; + title?: string; + snippet?: string; + position?: GoogleMapsLatLng; + infoWindowAnchor?: number[]; + draggable?: boolean; + flat?: boolean; + rotation?: number; + visible?: boolean; + styles?: any; + animation?: string; + zIndex?: number; } export interface GoogleMapsMarkerIcon { - url: string; - size: { - width: number; - height: number; + url?: string; + size?: { + width?: number; + height?: number; } } export class GoogleMapsMarker { @@ -497,13 +502,13 @@ export class GoogleMapsMarker { } export interface GoogleMapsCircleOptions { - center: GoogleMapsLatLng; - radius: number; - strokeColor: string; - strokeWidth: number; - fillColor: string; - visible: boolean; - zIndex: number; + center?: GoogleMapsLatLng; + radius?: number; + strokeColor?: string; + strokeWidth?: number; + fillColor?: string; + visible?: boolean; + zIndex?: number; } export class GoogleMapsCircle { @@ -584,12 +589,12 @@ export class GoogleMapsCircle { } export interface GoogleMapsPolylineOptions { - points: Array; - visible: boolean; - googledesic: boolean; - color: string; - width: number; - zIndex: number; + points?: Array; + visible?: boolean; + googledesic?: boolean; + color?: string; + width?: number; + zIndex?: number; } export class GoogleMapsPolyline { constructor (private _objectInstance: any) { } @@ -641,7 +646,7 @@ export class GoogleMapsLatLng { private _objectInstance: any; constructor (public lat: string, public lng: string) { - this._objectInstance = plugin.google.maps.LatLng(lat, lng); + this._objectInstance = new plugin.google.maps.LatLng(lat, lng); } @CordovaInstance({ From 4eeb5b3525ea4dfb642e17421173e2b043706895 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:20:25 -0400 Subject: [PATCH 066/115] fix marker + circle --- src/plugins/googlemaps.ts | 137 ++++++++++++++------------------------ 1 file changed, 51 insertions(+), 86 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 63414f417..e12026def 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -15,19 +15,40 @@ import {CordovaInstance} from './plugin'; * Created by Ibrahim on 3/29/2016. */ declare var plugin: any; + +/** + * You can listen to these events where appropriate + */ +export const GoogleMapsEvent = { + MAP_READY: plugin.google.maps.event.MAP_READY, + MAP_CLICK: plugin.google.maps.event.MAP_CLICK, + MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK, + MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK, + CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE, + CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE, + MAP_LOADED: plugin.google.maps.event.MAP_LOADED, + MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE, + MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE, + MARKER_CLICK: plugin.google.maps.event.MARKER_CLICK, + INFO_CLICK: plugin.google.maps.event.INFO_CLICK, + MARKER_DRAG: plugin.google.maps.event.MARKER_DRAG, + MARKER_DRAG_START: plugin.google.maps.event.MARKER_DRAG_START, + MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END +}; + /** * @name Google Maps * @description This plugin uses the native Google Maps SDK * @usage * ``` - * import {GoogleMaps} from 'ionic-native'; + * import {GoogleMaps, GoogleMapsEvent} from 'ionic-native'; * * ... * * // somewhere in your component * let map = new GoogleMaps('elementID'); * - * map.onInit().subscribe(() => console.log("Map is ready!")); + * map.on(GoogleMapsEvent.MAP_READY).subscribe(() => console.log("Map is ready!")); * ``` */ @Plugin({ @@ -36,17 +57,6 @@ declare var plugin: any; repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps' }) export class GoogleMap { - static event: any = { - MAP_READY: plugin.google.maps.event.MAP_READY, - MAP_CLICK: plugin.google.maps.event.MAP_CLICK, - MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK, - MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK, - CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE, - CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE, - MAP_LOADED: plugin.google.maps.event.MAP_LOADED, - MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE, - MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE - }; _objectInstance: any; /** @@ -76,63 +86,6 @@ export class GoogleMap { } - /** - * Get notified via an Observable when the user changes the view. (Event: CAMERA_CHANGE) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.CAMERA_CHANGE' - }) - static onCameraChange (): Observable {return; } - - /** - * Get notified via an Observable when the view is on idle. (Event: CAMERA_IDLE) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.CAMERA_IDLE', - platforms: ['iOS'] - }) - static onCameraIdle (): Observable {return; } - - /** - * Get notified via an Observable when the map is ready. (Event: MAP_READY) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.MAP_READY' - }) - static onMapReady (): Observable {return; } - - /** - * Get notified via an Observable when the map is loaded. (Event: MAP_LOADED) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.MAP_LOADED', - platforms: ['Android'] - }) - static onMapLoaded (): Observable {return; } - - /** - * Get notified via an Observable when the map will move. (Event: MAP_WILL_MOVE) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.MAP_WILL_MOVE', - platforms: ['iOS'] - }) - static onMapWillMove (): Observable {return; } - - /** - * Get notified via an Observable when the user closes the map. (Event: MAP_CLOSE) - */ - @Cordova({ - eventObservable: true, - event: 'plugin.google.maps.event.MAP_CLOSE' - }) - static onMapClose (): Observable {return; } - @CordovaInstance({ sync: true }) @@ -240,29 +193,23 @@ export class GoogleMap { ); } - addCircle (options: GoogleMapsCircleOptions): GoogleMapsCircle { - let objectInstance: any = this._objectInstance.addCircle(options); - return new GoogleMapsCircle(objectInstance); + addCircle (options: GoogleMapsCircleOptions): Promise { + return new Promise( + (resolve, reject) => { + this._objectInstance.addCircle(options, (circle: any) => { + if(circle) resolve(new GoogleMapsCircle(circle)); + else reject(); + }); + } + ); } - @CordovaInstance({ - sync: true - }) addPolygon (options: any): void { } - @CordovaInstance({ - sync: true - }) addPolyline (options: any): void { } - @CordovaInstance({ - sync: true - }) addTileOverlay (options: any): void { } - @CordovaInstance({ - sync: true - }) addGroundOverlay (options: any): void { } @CordovaInstance({ @@ -376,6 +323,15 @@ export class GoogleMapsMarker { constructor (private _objectInstance: any) { } + addEventListener(event: any): Observable { + return new Observable( + (observer) => { + this._objectInstance.addEventListener(event, observer.next); + return () => this._objectInstance.removeEventListener(event, observer.next) + } + ); + } + @CordovaInstance({ sync: true }) @@ -512,7 +468,16 @@ export interface GoogleMapsCircleOptions { } export class GoogleMapsCircle { - constructor(private _objectInstnace: any) { } + constructor(private _objectInstance: any) { } + + addEventListener(event: any): Observable { + return new Observable( + (observer) => { + this._objectInstance.addEventListener(event, observer.next); + return () => this._objectInstance.removeEventListener(event, observer.next) + } + ); + } @CordovaInstance({ sync: true From 1ba119b45144599a57fd1fac2d9be3d91de9ca81 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:41:59 -0400 Subject: [PATCH 067/115] almost complete --- src/plugins/googlemaps.ts | 244 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 237 insertions(+), 7 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index e12026def..f527cf48d 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -33,7 +33,8 @@ export const GoogleMapsEvent = { INFO_CLICK: plugin.google.maps.event.INFO_CLICK, MARKER_DRAG: plugin.google.maps.event.MARKER_DRAG, MARKER_DRAG_START: plugin.google.maps.event.MARKER_DRAG_START, - MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END + MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END, + OVERLAY_CLICK: plugin.google.maps.event.OVERLAY_CLICK }; /** @@ -197,20 +198,67 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addCircle(options, (circle: any) => { - if(circle) resolve(new GoogleMapsCircle(circle)); + if(circle) resolve(new GoogleMapsCircle(circle)); else reject(); }); } ); } - addPolygon (options: any): void { } + addPolygon (options: GoogleMapsPolygonOptions): Promise { + return new Promise( + (resolve, reject) => { + this._objectInstance.addPolygon(options, (polygon: any) => { + if(polygon) resolve(new GoogleMapsPolygon(polygon)); + else reject(); + }); + } + ); + } - addPolyline (options: any): void { } + addPolyline (options: GoogleMapsPolylineOptions): Promise { + return new Promise( + (resolve, reject) => { + this._objectInstance.addPolyline(options, (polyline: any) => { + if(polyline) resolve(new GoogleMapsPolyline(polyline)); + else reject(); + }); + } + ); + } - addTileOverlay (options: any): void { } + addTileOverlay (options: GoogleMapsTileOverlayOptions): Promise { + return new Promise( + (resolve, reject) => { + this._objectInstance.addTileOverlay(options, (tileOverlay: any) => { + if(tileOverlay) resolve(new GoogleMapsPolyline(tileOverlay)); + else reject(); + }); + } + ) + } - addGroundOverlay (options: any): void { } + addGroundOverlay (options: GoogleMapsGroundOverlayOptions): Promise { + return new Promise( + (resolve, reject) => { + this._objectInstance.addTileOverlay(options, (groundOverlay: any) => { + if(groundOverlay) resolve(new GoogleMapsPolyline(groundOverlay)); + else reject(); + }); + } + ) + } + + addKmlOverlay (options: GoogleMapsKmlOverlayOptions): Promise { + return new Promise( + (resolve, reject) => { + this._objectInstance.addTileOverlay(options, (kmlOverlay: any) => { + if(kmlOverlay) resolve(new GoogleMapsPolyline(kmlOverlay)); + else reject(); + }); + } + ) + } @CordovaInstance({ sync: true @@ -564,7 +612,14 @@ export interface GoogleMapsPolylineOptions { export class GoogleMapsPolyline { constructor (private _objectInstance: any) { } - // TODO add event listeners + addEventListener(event: any): Observable { + return new Observable( + (observer) => { + this._objectInstance.addEventListener(event, observer.next); + return () => this._objectInstance.removeEventListener(event, observer.next) + } + ); + } @CordovaInstance({sync: true}) getPoints(): Array {return; } @@ -607,6 +662,181 @@ export class GoogleMapsPolyline { } +export interface GoogleMapsPolygonOptions { + points?: Array; + geodesic?: boolean; + strokeColor?: string; + strokeWidth?: number; + fillColor?: string; + visible?: boolean; + zIndex?: number; + addHole?: Array +} +export class GoogleMapsPolygon { + + constructor(private _objectInstance: any) { } + + addEventListener(event: any): Observable { + return new Observable( + (observer) => { + this._objectInstance.addEventListener(event, observer.next); + return () => this._objectInstance.removeEventListener(event, observer.next) + } + ); + } + + @CordovaInstance({sync: true}) + getPoints(): Array { return; } + + @CordovaInstance({sync: true}) + getStrokeColor(): string {return; } + + @CordovaInstance({sync: true}) + getFillColor(): string {return; } + + @CordovaInstance({sync: true}) + getStrokeWidth(): number {return; } + + @CordovaInstance({sync: true}) + getGeodesic(): boolean {return; } + + @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 { } +} + +export interface GoogleMapsTileOverlayOptions { + titleUrilFormat?: string; + visible?: boolean; + zIndex?: number; + tileSize?: number; + opacity?: number; +} + +export class GoogleMapsTileOverlay { + + constructor(private _objectInstance: any) { } + + @CordovaInstance({sync: true}) + getVisible(): boolean {return; } + + @CordovaInstance({sync: true}) + setVisible(visible: boolean): void { } + + @CordovaInstance({sync: true}) + getFadeIn(): boolean {return; } + + @CordovaInstance({sync: true}) + setFadeIn(fadeIn: boolean): void { } + + @CordovaInstance({sync: true}) + getZIndex(): number {return; } + + @CordovaInstance({sync: true}) + setZIndex(zIndex: number): void { } + + @CordovaInstance({sync: true}) + getOpacity(): number {return; } + + @CordovaInstance({sync: true}) + setOpacity(opacity: number): void { } + + @CordovaInstance({sync: true}) + clearTileCache(): void { } + + @CordovaInstance({sync: true}) + remove(): void { } + +} + + + +export interface GoogleMapsGroundOverlayOptions { + url?: string; + bounds?: Array; + visible?: boolean; + opacity?: number; + bearing?: number; + zIndex?: number; +} + +export class GoogleMapsGroundOverlay { + + constructor(private _objectInstance: any) { } + + @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; } + + @CordovaInstance({sync: true}) + setVisible(visible: boolean): void { } + + @CordovaInstance({sync: true}) + getVisible(): boolean {return; } + + @CordovaInstance({sync: true}) + setImage(image: string): void { }; + + @CordovaInstance({sync: true}) + remove(): void { } + +} + + + +export interface GoogleMapsKmlOverlayOptions { + url?: string; + preserveViewport?: boolean; + animation?: boolean; +} + +export class GoogleMapsKmlOverlay { + + constructor(private _objectInstance: any) { } + + @CordovaInstance({sync: true}) + remove(): void { } + + @CordovaInstance({sync: true}) + getOverlays(): Array {return; } +} + + + export class GoogleMapsLatLng { private _objectInstance: any; From 1286bdb5be63e48baa673ee24deda5e358326bd5 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:44:56 -0400 Subject: [PATCH 068/115] almost complete --- src/plugins/googlemaps.ts | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index f527cf48d..3ea5212fc 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -1,13 +1,3 @@ -/** - * ----- IMPORTANT NOTES ----- - * - * - The current event listeners might not work. They might need an alternative implementation. - * - Constructors of the "sub-objects" are not meant to be used. They are for ionic-native developer only. - * - The plugin isn't fully tested and documented yet. Use at your own risk, and don't hesitate to ask questions. - * - * --------------------------- - */ - import {Cordova, Plugin} from './plugin'; import {Observable} from 'rxjs/Rx'; import {CordovaInstance} from './plugin'; @@ -15,7 +5,6 @@ import {CordovaInstance} from './plugin'; * Created by Ibrahim on 3/29/2016. */ declare var plugin: any; - /** * You can listen to these events where appropriate */ @@ -36,7 +25,6 @@ export const GoogleMapsEvent = { MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END, OVERLAY_CLICK: plugin.google.maps.event.OVERLAY_CLICK }; - /** * @name Google Maps * @description This plugin uses the native Google Maps SDK @@ -231,7 +219,7 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addTileOverlay(options, (tileOverlay: any) => { - if(tileOverlay) resolve(new GoogleMapsPolyline(tileOverlay)); + if(tileOverlay) resolve(new GoogleMapsTileOverlay(tileOverlay)); else reject(); }); } @@ -242,7 +230,7 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addTileOverlay(options, (groundOverlay: any) => { - if(groundOverlay) resolve(new GoogleMapsPolyline(groundOverlay)); + if(groundOverlay) resolve(new GoogleMapsGroundOverlay(groundOverlay)); else reject(); }); } @@ -253,7 +241,7 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addTileOverlay(options, (kmlOverlay: any) => { - if(kmlOverlay) resolve(new GoogleMapsPolyline(kmlOverlay)); + if(kmlOverlay) resolve(new GoogleMapsKmlOverlay(kmlOverlay)); else reject(); }); } @@ -315,7 +303,6 @@ export class GoogleMap { panBy (): void { } } - export interface AnimateCameraOptions { target?: string; tilt?: number; @@ -345,7 +332,6 @@ export interface VisibleRegion { northeast?: any; southwest?: any; } - export interface GoogleMapsMarkerOptions { icon?: any; title?: string; @@ -504,7 +490,6 @@ export class GoogleMapsMarker { } - export interface GoogleMapsCircleOptions { center?: GoogleMapsLatLng; radius?: number; @@ -600,7 +585,6 @@ export class GoogleMapsCircle { } - export interface GoogleMapsPolylineOptions { points?: Array; visible?: boolean; @@ -661,7 +645,6 @@ export class GoogleMapsPolyline { getMap(): GoogleMap {return; } } - export interface GoogleMapsPolygonOptions { points?: Array; geodesic?: boolean; @@ -730,7 +713,6 @@ export class GoogleMapsPolygon { @CordovaInstance({sync: true}) setGeodesic(geodesic: boolean): void { } } - export interface GoogleMapsTileOverlayOptions { titleUrilFormat?: string; visible?: boolean; @@ -738,7 +720,6 @@ export interface GoogleMapsTileOverlayOptions { tileSize?: number; opacity?: number; } - export class GoogleMapsTileOverlay { constructor(private _objectInstance: any) { } @@ -774,9 +755,6 @@ export class GoogleMapsTileOverlay { remove(): void { } } - - - export interface GoogleMapsGroundOverlayOptions { url?: string; bounds?: Array; @@ -785,7 +763,6 @@ export interface GoogleMapsGroundOverlayOptions { bearing?: number; zIndex?: number; } - export class GoogleMapsGroundOverlay { constructor(private _objectInstance: any) { } @@ -815,15 +792,11 @@ export class GoogleMapsGroundOverlay { remove(): void { } } - - - export interface GoogleMapsKmlOverlayOptions { url?: string; preserveViewport?: boolean; animation?: boolean; } - export class GoogleMapsKmlOverlay { constructor(private _objectInstance: any) { } @@ -834,9 +807,6 @@ export class GoogleMapsKmlOverlay { @CordovaInstance({sync: true}) getOverlays(): Array {return; } } - - - export class GoogleMapsLatLng { private _objectInstance: any; From f659bd24f37659c993afba1d4c863be31a6b6535 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:46:05 -0400 Subject: [PATCH 069/115] export all from googlemaps plugin --- src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index eb9d74be7..dfbdeb241 100644 --- a/src/index.ts +++ b/src/index.ts @@ -59,7 +59,7 @@ import {Toast} from './plugins/toast'; import {TouchID} from './plugins/touchid'; import {Vibration} from './plugins/vibration'; import {WebIntent} from './plugins/webintent'; - +export * from './plugins/googlemaps'; export { ActionSheet, AdMob, @@ -92,7 +92,6 @@ export { Flashlight, Geolocation, Globalization, - GoogleMap, GoogleAnalytics, Hotspot, ImagePicker, From 6282d743a8a2c79c91c45c6b4479800d0957c628 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:47:50 -0400 Subject: [PATCH 070/115] reset circle.yml to previous config --- circle.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index 561b592c6..166686e1f 100644 --- a/circle.yml +++ b/circle.yml @@ -4,10 +4,10 @@ machine: ruby: version: 2.1.2 -#general: -# branches: -# only: -# - master # ignore PRs and branches +general: + branches: + only: + - master # ignore PRs and branches dependencies: pre: From b444e5f3164a61819a6999a689ce790520535769 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:52:56 -0400 Subject: [PATCH 071/115] Tslint --- src/plugins/googlemaps.ts | 493 ++++++++++++++++++++++++++------------ 1 file changed, 335 insertions(+), 158 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 3ea5212fc..fa8c249b8 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -53,13 +53,15 @@ export class GoogleMap { * @return {Promise} returns a promise that resolves with the Map object (if it exists). */ @Cordova() - static isAvailable (): Promise {return; } + static isAvailable(): Promise { + return; + } - constructor (elementId: string) { + constructor(elementId: string) { this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId)); } - on(event: any): Observable{ + on(event: any): Observable { return new Observable( (observer) => { this._objectInstance.on(event, observer.next); @@ -68,7 +70,7 @@ export class GoogleMap { ); } - one(event: any): Promise{ + one(event: any): Promise { return new Promise( resolve => this._objectInstance.one(event, resolve) ); @@ -78,229 +80,267 @@ export class GoogleMap { @CordovaInstance({ sync: true }) - setDebuggable (isDebuggable: boolean): void {} + setDebuggable(isDebuggable: boolean): void { + } @CordovaInstance({ sync: true }) - setClickable (isClickable: boolean): void {} + setClickable(isClickable: boolean): void { + } /** * Get the position of the camera */ @CordovaInstance() - getCameraPosition (): Promise {return; } + getCameraPosition(): Promise { + return; + } /** * Get the location of the user */ @CordovaInstance() - getMyLocation (): Promise {return; } + getMyLocation(): Promise { + return; + } /** * Get the visible region */ @CordovaInstance() - getVisibleRegion (): Promise {return; } + getVisibleRegion(): Promise { + return; + } @CordovaInstance({ sync: true }) - showDialog (): void { } + showDialog(): void { + } @CordovaInstance({ sync: true }) - closeDialog (): void { } + closeDialog(): void { + } @CordovaInstance() - getLicenseInfo (): Promise {return ;} + getLicenseInfo(): Promise { + return; + } @CordovaInstance({ sync: true }) - setCenter (latLng: GoogleMapsLatLng): void { } + setCenter(latLng: GoogleMapsLatLng): void { + } @CordovaInstance({ sync: true }) - setZoom (zoomLevel: number): void { } + setZoom(zoomLevel: number): void { + } @CordovaInstance({ sync: true }) - setMapTypeId (typeId: string): void { } + setMapTypeId(typeId: string): void { + } @CordovaInstance({ sync: true }) - setTilt (tiltLevel: number): void { } + setTilt(tiltLevel: number): void { + } @CordovaInstance({ sync: true }) - animateCamera (cameraPosition: CameraPosition): void { } + animateCamera(cameraPosition: CameraPosition): void { + } @CordovaInstance({ sync: true }) - moveCamera (cameraPosition: CameraPosition): void { } + moveCamera(cameraPosition: CameraPosition): void { + } @CordovaInstance({ sync: true }) - setMyLocationEnabled (enabled: boolean): void { } + setMyLocationEnabled(enabled: boolean): void { + } @CordovaInstance({ sync: true }) - setIndoorEnabled (enabled: boolean): void { } + setIndoorEnabled(enabled: boolean): void { + } @CordovaInstance({ sync: true }) - setTrafficEnabled (enabled: boolean): void { } + setTrafficEnabled(enabled: boolean): void { + } @CordovaInstance({ sync: true }) - setCompassEnabled (enabled: boolean): void { } + setCompassEnabled(enabled: boolean): void { + } @CordovaInstance({ sync: true }) - setAllGesturesEnabled (enabled: boolean): void { } + setAllGesturesEnabled(enabled: boolean): void { + } - addMarker (options: GoogleMapsMarkerOptions): Promise { + addMarker(options: GoogleMapsMarkerOptions): Promise { return new Promise( (resolve, reject) => { this._objectInstance.addMarker(options, (marker: any) => { - if(marker) resolve(new GoogleMapsMarker(marker)); + if (marker) resolve(new GoogleMapsMarker(marker)); else reject(); }); } ); } - addCircle (options: GoogleMapsCircleOptions): Promise { + addCircle(options: GoogleMapsCircleOptions): Promise { return new Promise( (resolve, reject) => { this._objectInstance.addCircle(options, (circle: any) => { - if(circle) resolve(new GoogleMapsCircle(circle)); + if (circle) resolve(new GoogleMapsCircle(circle)); else reject(); }); } ); } - addPolygon (options: GoogleMapsPolygonOptions): Promise { + addPolygon(options: GoogleMapsPolygonOptions): Promise { return new Promise( (resolve, reject) => { this._objectInstance.addPolygon(options, (polygon: any) => { - if(polygon) resolve(new GoogleMapsPolygon(polygon)); + if (polygon) resolve(new GoogleMapsPolygon(polygon)); else reject(); }); } ); } - addPolyline (options: GoogleMapsPolylineOptions): Promise { + addPolyline(options: GoogleMapsPolylineOptions): Promise { return new Promise( (resolve, reject) => { this._objectInstance.addPolyline(options, (polyline: any) => { - if(polyline) resolve(new GoogleMapsPolyline(polyline)); + if (polyline) resolve(new GoogleMapsPolyline(polyline)); else reject(); }); } ); } - addTileOverlay (options: GoogleMapsTileOverlayOptions): Promise { + addTileOverlay(options: GoogleMapsTileOverlayOptions): Promise { return new Promise( (resolve, reject) => { this._objectInstance.addTileOverlay(options, (tileOverlay: any) => { - if(tileOverlay) resolve(new GoogleMapsTileOverlay(tileOverlay)); + if (tileOverlay) resolve(new GoogleMapsTileOverlay(tileOverlay)); else reject(); }); } - ) + ); } - addGroundOverlay (options: GoogleMapsGroundOverlayOptions): Promise { + addGroundOverlay(options: GoogleMapsGroundOverlayOptions): Promise { return new Promise( (resolve, reject) => { this._objectInstance.addTileOverlay(options, (groundOverlay: any) => { - if(groundOverlay) resolve(new GoogleMapsGroundOverlay(groundOverlay)); + if (groundOverlay) resolve(new GoogleMapsGroundOverlay(groundOverlay)); else reject(); }); } - ) + ); } - addKmlOverlay (options: GoogleMapsKmlOverlayOptions): Promise { + addKmlOverlay(options: GoogleMapsKmlOverlayOptions): Promise { return new Promise( (resolve, reject) => { this._objectInstance.addTileOverlay(options, (kmlOverlay: any) => { - if(kmlOverlay) resolve(new GoogleMapsKmlOverlay(kmlOverlay)); + if (kmlOverlay) resolve(new GoogleMapsKmlOverlay(kmlOverlay)); else reject(); }); } - ) + ); } @CordovaInstance({ sync: true }) - setDiv (domNode: HTMLElement): void { } + setDiv(domNode: HTMLElement): void { + } @CordovaInstance({ sync: true }) - setVisible (visible: boolean): void { } + setVisible(visible: boolean): void { + } @CordovaInstance({ sync: true }) - setOptions (options: any): void { } + setOptions(options: any): void { + } @CordovaInstance({ sync: true }) - setBackgroundColor (backgroundColor: string): void { } + setBackgroundColor(backgroundColor: string): void { + } @CordovaInstance({ sync: true }) - setPadding (top?: number, right?: number, bottom?: number, left?: number): void { } + setPadding(top?: number, right?: number, bottom?: number, left?: number): void { + } @CordovaInstance({ sync: true }) - clear (): void { } + clear(): void { + } @CordovaInstance({ sync: true }) - refreshLayout (): void { } + refreshLayout(): void { + } @CordovaInstance() - fromLatLngToPoint (latLng: GoogleMapsLatLng, point: any): Promise {return; } + fromLatLngToPoint(latLng: GoogleMapsLatLng, point: any): Promise { + return; + } @CordovaInstance() - fromPointToLatLng (point: any, latLng: GoogleMapsLatLng): Promise {return; } + fromPointToLatLng(point: any, latLng: GoogleMapsLatLng): Promise { + return; + } @CordovaInstance() - toDataURL (): Promise {return; } + toDataURL(): Promise { + return; + } @CordovaInstance({ sync: true }) - remove (): void { } + remove(): void { + } @CordovaInstance({ sync: true }) - panBy (): void { } + panBy(): void { + } } export interface AnimateCameraOptions { @@ -351,17 +391,18 @@ export interface GoogleMapsMarkerIcon { size?: { width?: number; height?: number; - } + }; } export class GoogleMapsMarker { - constructor (private _objectInstance: any) { } + constructor(private _objectInstance: any) { + } addEventListener(event: any): Observable { return new Observable( (observer) => { this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next) + return () => this._objectInstance.removeEventListener(event, observer.next); } ); } @@ -369,124 +410,160 @@ export class GoogleMapsMarker { @CordovaInstance({ sync: true }) - isVisible (): boolean {return;} + isVisible(): boolean { + return; + } @CordovaInstance() - setVisible (visible: boolean): void { } + setVisible(visible: boolean): void { + } @CordovaInstance({ sync: true }) - getHashCode (): string {return; } + getHashCode(): string { + return; + } @CordovaInstance({ sync: true }) - remove(): void { } + remove(): void { + } @CordovaInstance({ sync: true }) - setOpacity (alpha: number): void { } + setOpacity(alpha: number): void { + } @CordovaInstance({ sync: true }) - getOpacity(): number {return; } + getOpacity(): number { + return; + } @CordovaInstance({ sync: true }) - setZIndex(): void { } + setZIndex(): void { + } @CordovaInstance({ sync: true }) - setIconAnchor(x: number, y: number): void { } + setIconAnchor(x: number, y: number): void { + } @CordovaInstance({ sync: true }) - setInfoWindowAnchor(x: number, y:number): void { } + setInfoWindowAnchor(x: number, y: number): void { + } @CordovaInstance({ sync: true }) - setDraggable(draggable: boolean): void { } + setDraggable(draggable: boolean): void { + } @CordovaInstance({ sync: true }) - isDraggable(): boolean {return; } + isDraggable(): boolean { + return; + } @CordovaInstance({ sync: true }) - setFlat(flat: boolean): void {return; } + setFlat(flat: boolean): void { + return; + } @CordovaInstance({ sync: true }) - setIcon(icon: GoogleMapsMarkerIcon): void { } + setIcon(icon: GoogleMapsMarkerIcon): void { + } @CordovaInstance({ sync: true }) - setTitle(title: string): void { } + setTitle(title: string): void { + } @CordovaInstance({ sync: true }) - getTitle(): string {return; } + getTitle(): string { + return; + } @CordovaInstance({ sync: true }) - setSnippet(snippet: string): void { } + setSnippet(snippet: string): void { + } @CordovaInstance({ sync: true }) - getSnippet(): string {return; } + getSnippet(): string { + return; + } @CordovaInstance({ sync: true }) - setRotation(rotation: number): void { } + setRotation(rotation: number): void { + } @CordovaInstance({ sync: true }) - getRotation(): number {return; } + getRotation(): number { + return; + } @CordovaInstance({ sync: true }) - showInfoWindow(): number {return; } + showInfoWindow(): number { + return; + } @CordovaInstance({ sync: true }) - hideInfoWindow(): number {return; } + hideInfoWindow(): number { + return; + } @CordovaInstance({ sync: true }) - setPosition(latLng: GoogleMapsLatLng): void { } + setPosition(latLng: GoogleMapsLatLng): void { + } @CordovaInstance() - getPosition(): Promise {return; } + getPosition(): Promise { + return; + } @CordovaInstance({ sync: true }) - getMap(): GoogleMap {return; } + getMap(): GoogleMap { + return; + } @CordovaInstance({ sync: true }) - setAnimation(animation: string): void { } - + setAnimation(animation: string): void { + } } @@ -501,13 +578,14 @@ export interface GoogleMapsCircleOptions { } export class GoogleMapsCircle { - constructor(private _objectInstance: any) { } + constructor(private _objectInstance: any) { + } addEventListener(event: any): Observable { return new Observable( (observer) => { this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next) + return () => this._objectInstance.removeEventListener(event, observer.next); } ); } @@ -515,73 +593,92 @@ export class GoogleMapsCircle { @CordovaInstance({ sync: true }) - getCenter(): GoogleMapsLatLng {return; } + getCenter(): GoogleMapsLatLng { + return; + } @CordovaInstance({ sync: true }) - getRadius(): number {return; } + getRadius(): number { + return; + } @CordovaInstance({ sync: true }) - getStrokeColor(): string {return; } + getStrokeColor(): string { + return; + } @CordovaInstance({ sync: true }) - getVisible(): boolean {return; } + getVisible(): boolean { + return; + } @CordovaInstance({ sync: true }) - getZIndex(): number {return; } + getZIndex(): number { + return; + } @CordovaInstance({ sync: true }) - remove(): void { } + remove(): void { + } @CordovaInstance({ sync: true }) - setCenter(latLng: GoogleMapsLatLng): void { } + setCenter(latLng: GoogleMapsLatLng): void { + } @CordovaInstance({ sync: true }) - setFillColor(fillColor: string): void { } + setFillColor(fillColor: string): void { + } @CordovaInstance({ sync: true }) - setStrokeColor(strokeColor: string): void { } + setStrokeColor(strokeColor: string): void { + } @CordovaInstance({ sync: true }) - setStrokeWidth(strokeWidth: number): void { } + setStrokeWidth(strokeWidth: number): void { + } @CordovaInstance({ sync: true }) - setVisible(visible: boolean): void { } + setVisible(visible: boolean): void { + } @CordovaInstance({ sync: true }) - setZIndex(zIndex: number): void { } + setZIndex(zIndex: number): void { + } @CordovaInstance({ sync: true }) - setRadius(radius: number): void { } + setRadius(radius: number): void { + } @CordovaInstance({ sync: true }) - getMap(): GoogleMap {return; } - + getMap(): GoogleMap { + return; + } } @@ -594,55 +691,75 @@ export interface GoogleMapsPolylineOptions { zIndex?: number; } export class GoogleMapsPolyline { - constructor (private _objectInstance: any) { } + constructor(private _objectInstance: any) { + } addEventListener(event: any): Observable { return new Observable( (observer) => { this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next) + return () => this._objectInstance.removeEventListener(event, observer.next); } ); } @CordovaInstance({sync: true}) - getPoints(): Array {return; } + getPoints(): Array { + return; + } @CordovaInstance({sync: true}) - getCOlor(): string {return; } + getCOlor(): string { + return; + } @CordovaInstance({sync: true}) - getWidth(): number {return; } + getWidth(): number { + return; + } @CordovaInstance({sync: true}) - getGeodesic(): boolean {return; } + getGeodesic(): boolean { + return; + } @CordovaInstance({sync: true}) - getZIndex(): number {return; } + getZIndex(): number { + return; + } @CordovaInstance({sync: true}) - remove(): void { } + remove(): void { + } @CordovaInstance({sync: true}) - setPoints(points: Array): void { } + setPoints(points: Array): void { + } @CordovaInstance({sync: true}) - setColor(color: string): void { } + setColor(color: string): void { + } @CordovaInstance({sync: true}) - setWidth(width: number): void { } + setWidth(width: number): void { + } @CordovaInstance({sync: true}) - setVisible(visible: boolean): void { } + setVisible(visible: boolean): void { + } @CordovaInstance({sync: true}) - setZIndex(zIndex: number): void { } + setZIndex(zIndex: number): void { + } @CordovaInstance({sync: true}) - setGeoDesic(geoDesic: boolean): void { } + setGeoDesic(geoDesic: boolean): void { + } @CordovaInstance({sync: true}) - getMap(): GoogleMap {return; } + getMap(): GoogleMap { + return; + } } export interface GoogleMapsPolygonOptions { @@ -653,65 +770,88 @@ export interface GoogleMapsPolygonOptions { fillColor?: string; visible?: boolean; zIndex?: number; - addHole?: Array + addHole?: Array; } export class GoogleMapsPolygon { - constructor(private _objectInstance: any) { } + constructor(private _objectInstance: any) { + } addEventListener(event: any): Observable { return new Observable( (observer) => { this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next) + return () => this._objectInstance.removeEventListener(event, observer.next); } ); } @CordovaInstance({sync: true}) - getPoints(): Array { return; } + getPoints(): Array { + return; + } @CordovaInstance({sync: true}) - getStrokeColor(): string {return; } + getStrokeColor(): string { + return; + } @CordovaInstance({sync: true}) - getFillColor(): string {return; } + getFillColor(): string { + return; + } @CordovaInstance({sync: true}) - getStrokeWidth(): number {return; } + getStrokeWidth(): number { + return; + } @CordovaInstance({sync: true}) - getGeodesic(): boolean {return; } + getGeodesic(): boolean { + return; + } @CordovaInstance({sync: true}) - getVisible(): boolean {return; } + getVisible(): boolean { + return; + } @CordovaInstance({sync: true}) - getZIndex(): boolean {return; } + getZIndex(): boolean { + return; + } @CordovaInstance({sync: true}) - remove(): void { } + remove(): void { + } @CordovaInstance({sync: true}) - setPoints(points: Array): void { } + setPoints(points: Array): void { + } @CordovaInstance({sync: true}) - setStrokeColor(strokeColor: string): void { } + setStrokeColor(strokeColor: string): void { + } @CordovaInstance({sync: true}) - setFillColor(fillColor: string): void { } + setFillColor(fillColor: string): void { + } @CordovaInstance({sync: true}) - setStrokeWidth(strokeWidth: number): void { } + setStrokeWidth(strokeWidth: number): void { + } @CordovaInstance({sync: true}) - setVisible(visible: boolean): void { } + setVisible(visible: boolean): void { + } @CordovaInstance({sync: true}) - setZIndex(zIndex: number): void { } + setZIndex(zIndex: number): void { + } @CordovaInstance({sync: true}) - setGeodesic(geodesic: boolean): void { } + setGeodesic(geodesic: boolean): void { + } } export interface GoogleMapsTileOverlayOptions { titleUrilFormat?: string; @@ -722,37 +862,52 @@ export interface GoogleMapsTileOverlayOptions { } export class GoogleMapsTileOverlay { - constructor(private _objectInstance: any) { } + constructor(private _objectInstance: any) { + } @CordovaInstance({sync: true}) - getVisible(): boolean {return; } + getVisible(): boolean { + return; + } @CordovaInstance({sync: true}) - setVisible(visible: boolean): void { } + setVisible(visible: boolean): void { + } @CordovaInstance({sync: true}) - getFadeIn(): boolean {return; } + getFadeIn(): boolean { + return; + } @CordovaInstance({sync: true}) - setFadeIn(fadeIn: boolean): void { } + setFadeIn(fadeIn: boolean): void { + } @CordovaInstance({sync: true}) - getZIndex(): number {return; } + getZIndex(): number { + return; + } @CordovaInstance({sync: true}) - setZIndex(zIndex: number): void { } + setZIndex(zIndex: number): void { + } @CordovaInstance({sync: true}) - getOpacity(): number {return; } + getOpacity(): number { + return; + } @CordovaInstance({sync: true}) - setOpacity(opacity: number): void { } + setOpacity(opacity: number): void { + } @CordovaInstance({sync: true}) - clearTileCache(): void { } + clearTileCache(): void { + } @CordovaInstance({sync: true}) - remove(): void { } + remove(): void { + } } export interface GoogleMapsGroundOverlayOptions { @@ -765,31 +920,43 @@ export interface GoogleMapsGroundOverlayOptions { } export class GoogleMapsGroundOverlay { - constructor(private _objectInstance: any) { } + constructor(private _objectInstance: any) { + } @CordovaInstance({sync: true}) - setBearing(bearing: number): void { } + setBearing(bearing: number): void { + } @CordovaInstance({sync: true}) - getBearing(): number {return; } + getBearing(): number { + return; + } @CordovaInstance({sync: true}) - setOpacity(opacity: number): void { } + setOpacity(opacity: number): void { + } @CordovaInstance({sync: true}) - getOpacity(): number {return; } + getOpacity(): number { + return; + } @CordovaInstance({sync: true}) - setVisible(visible: boolean): void { } + setVisible(visible: boolean): void { + } @CordovaInstance({sync: true}) - getVisible(): boolean {return; } + getVisible(): boolean { + return; + } @CordovaInstance({sync: true}) - setImage(image: string): void { }; + setImage(image: string): void { + }; @CordovaInstance({sync: true}) - remove(): void { } + remove(): void { + } } export interface GoogleMapsKmlOverlayOptions { @@ -799,33 +966,43 @@ export interface GoogleMapsKmlOverlayOptions { } export class GoogleMapsKmlOverlay { - constructor(private _objectInstance: any) { } + constructor(private _objectInstance: any) { + } @CordovaInstance({sync: true}) - remove(): void { } + remove(): void { + } @CordovaInstance({sync: true}) - getOverlays(): Array {return; } + getOverlays(): Array { + return; + } } export class GoogleMapsLatLng { private _objectInstance: any; - constructor (public lat: string, public lng: string) { + constructor(public lat: string, public lng: string) { this._objectInstance = new plugin.google.maps.LatLng(lat, lng); } @CordovaInstance({ sync: true }) - equals (other: GoogleMapsLatLng): boolean {return; } + equals(other: GoogleMapsLatLng): boolean { + return; + } @CordovaInstance({ sync: true }) - toString (): string {return; } + toString(): string { + return; + } @CordovaInstance({ sync: true }) - toUrlValue (precision?: number): string {return; } + toUrlValue(precision?: number): string { + return; + } } From 5fa6d1d02293d88d7a9a897f845f71520c1b0eea Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:56:04 -0400 Subject: [PATCH 072/115] tslint --- src/plugins/background-geolocation.ts | 2 +- src/plugins/filetransfer.ts | 6 +++--- src/plugins/globalization.ts | 2 +- src/plugins/screenshot.ts | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index 3cf540008..f3e989378 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -19,7 +19,7 @@ export interface Location { /** * true if location recorded as part of debug */ - debug: boolean + debug: boolean; /** * UTC time of this fix, in milliseconds since January 1, 1970. diff --git a/src/plugins/filetransfer.ts b/src/plugins/filetransfer.ts index 52e9c8fb5..65f75c585 100644 --- a/src/plugins/filetransfer.ts +++ b/src/plugins/filetransfer.ts @@ -31,7 +31,7 @@ export interface FileUploadOptions { /** * A set of optional key/value pairs to pass in the HTTP request. */ - params?: { [s: string]: any; } + params?: { [s: string]: any; }; /** * Whether to upload the data in chunked streaming mode. @@ -44,7 +44,7 @@ export interface FileUploadOptions { * than one value. On iOS, FireOS, and Android, if a header named * Content-Type is present, multipart form data will NOT be used. */ - headers?: { [s: string]: any; } + headers?: { [s: string]: any; }; } export interface FileUploadResult { @@ -67,7 +67,7 @@ export interface FileUploadResult { /** * The HTTP response headers by the server. */ - headers: { [s: string]: any; } + headers: { [s: string]: any; }; } export interface FileTransferError { diff --git a/src/plugins/globalization.ts b/src/plugins/globalization.ts index eacc75a34..c616a2ee1 100644 --- a/src/plugins/globalization.ts +++ b/src/plugins/globalization.ts @@ -107,7 +107,7 @@ export class Globalization { successIndex: 1, errorIndex: 2 }) - static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value:number|string}> {return; } + static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value: number|string}> {return; } /** * diff --git a/src/plugins/screenshot.ts b/src/plugins/screenshot.ts index 44085594b..710efc09f 100644 --- a/src/plugins/screenshot.ts +++ b/src/plugins/screenshot.ts @@ -21,9 +21,9 @@ export class Screenshot { (resolve, reject) => { navigator.screenshot.save( (error, result) => { - if(error){ + if (error) { reject(error); - }else{ + }else { resolve(result); } }, @@ -46,9 +46,9 @@ export class Screenshot { (resolve, reject) => { navigator.screenshot.URI( (error, result) => { - if(error){ + if (error) { reject(error); - }else{ + }else { resolve(result); } }, From 09e5734720e176b8b8ab78f0de6b4f4ae09a11c1 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 06:56:53 -0400 Subject: [PATCH 073/115] 1.2.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 913e97fc4..1d952a4fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-native", - "version": "1.2.2", + "version": "1.2.3", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "main": "dist/index.js", "directories": { From a9604c3bb9cc3f324750e64554c47009fd01a1a1 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 16:36:12 -0400 Subject: [PATCH 074/115] fix plugin undefined, closes #185 --- src/plugins/googlemaps.ts | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index fa8c249b8..63e62d79d 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -9,21 +9,29 @@ declare var plugin: any; * You can listen to these events where appropriate */ export const GoogleMapsEvent = { - MAP_READY: plugin.google.maps.event.MAP_READY, - MAP_CLICK: plugin.google.maps.event.MAP_CLICK, - MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK, - MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK, - CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE, - CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE, - MAP_LOADED: plugin.google.maps.event.MAP_LOADED, - MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE, - MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE, - MARKER_CLICK: plugin.google.maps.event.MARKER_CLICK, - INFO_CLICK: plugin.google.maps.event.INFO_CLICK, - MARKER_DRAG: plugin.google.maps.event.MARKER_DRAG, - MARKER_DRAG_START: plugin.google.maps.event.MARKER_DRAG_START, - MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END, - OVERLAY_CLICK: plugin.google.maps.event.OVERLAY_CLICK + MAP_CLICK: 'click', + MAP_LONG_CLICK: 'long_click', + MY_LOCATION_CHANGE: 'my_location_change', + 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', + INFO_CLICK: 'info_click', + MARKER_DRAG: 'drag', + MARKER_DRAG_START: 'drag_start', + MARKER_DRAG_END: 'drag_end' +}; + +export const GoogleMapsAnimation = { + BOUNCE: 'BOUNCE', + DROP: 'DROP' }; /** * @name Google Maps From a250bd3e81a5170eca5f4207ae3cc41629e536b0 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 1 Jun 2016 16:36:52 -0400 Subject: [PATCH 075/115] 1.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d952a4fd..1304532af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-native", - "version": "1.2.3", + "version": "1.2.4", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "main": "dist/index.js", "directories": { From 02a658321a4c061bb47dbf31c477b6e587389273 Mon Sep 17 00:00:00 2001 From: Guille Date: Fri, 3 Jun 2016 11:31:54 +0200 Subject: [PATCH 076/115] lat/lng string->number --- src/plugins/googlemaps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 63e62d79d..ac8a990eb 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -989,7 +989,7 @@ export class GoogleMapsKmlOverlay { export class GoogleMapsLatLng { private _objectInstance: any; - constructor(public lat: string, public lng: string) { + constructor(public lat: number, public lng: number) { this._objectInstance = new plugin.google.maps.LatLng(lat, lng); } From d40f8d868a4be6200385939aee534e3a4bfb5eff Mon Sep 17 00:00:00 2001 From: Guille Date: Fri, 3 Jun 2016 11:32:55 +0200 Subject: [PATCH 077/115] Update interfaces to use GoogleMapsLatLng instead of Lat / Lng --- src/plugins/googlemaps.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index ac8a990eb..5e6c2ac9b 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -352,26 +352,20 @@ export class GoogleMap { } export interface AnimateCameraOptions { - target?: string; + target?: GoogleMapsLatLng; tilt?: number; zoom?: number; bearing?: number; duration?: number; } export interface CameraPosition { - target?: { - lat?: string; - lng?: string; - }; + target?: GoogleMapsLatLng; zoom?: number; tilt?: number; bearing?: number; } export interface MyLocation { - latLng?: { - lat?: string; - lng?: string; - }; + latLng?: GoogleMapsLatLng; speed?: number; time?: string; bearing?: number; From d715d6a118dacb14db8036b6775979bbf96b4613 Mon Sep 17 00:00:00 2001 From: Guille Date: Fri, 3 Jun 2016 11:33:42 +0200 Subject: [PATCH 078/115] Update animateCamera parameter --- src/plugins/googlemaps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 5e6c2ac9b..2900196a2 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -165,7 +165,7 @@ export class GoogleMap { @CordovaInstance({ sync: true }) - animateCamera(cameraPosition: CameraPosition): void { + animateCamera(animateCameraOptions: AnimateCameraOptions): void { } @CordovaInstance({ From 82cfe33d8644eb33b157d162933fc09d1a0212c8 Mon Sep 17 00:00:00 2001 From: Guille Date: Fri, 3 Jun 2016 11:34:15 +0200 Subject: [PATCH 079/115] Update docs GoogleMaps -> GoogleMap --- src/plugins/googlemaps.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 2900196a2..128040a10 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -38,12 +38,12 @@ export const GoogleMapsAnimation = { * @description This plugin uses the native Google Maps SDK * @usage * ``` - * import {GoogleMaps, GoogleMapsEvent} from 'ionic-native'; + * import {GoogleMap, GoogleMapsEvent} from 'ionic-native'; * * ... * * // somewhere in your component - * let map = new GoogleMaps('elementID'); + * let map = new GoogleMap('elementID'); * * map.on(GoogleMapsEvent.MAP_READY).subscribe(() => console.log("Map is ready!")); * ``` From f54cfb8a97d4e2ce5fd9773b8d04e51fa72995dc Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 3 Jun 2016 09:52:44 -0400 Subject: [PATCH 080/115] fix event listener --- src/plugins/googlemaps.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 63e62d79d..af667a594 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -72,7 +72,8 @@ export class GoogleMap { on(event: any): Observable { return new Observable( (observer) => { - this._objectInstance.on(event, observer.next); + let cb = data => observer.next(data); + this._objectInstance.on(event, cb); return () => this._objectInstance.off(event); } ); @@ -409,8 +410,11 @@ export class GoogleMapsMarker { addEventListener(event: any): Observable { return new Observable( (observer) => { - this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next); + let cb = (data: any) => { + observer.next(data); + }; + this._objectInstance.addEventListener(event, cb); + return () => this._objectInstance.removeEventListener(event, cb); } ); } From 22aae7422e986f4b7f39b115bcbf9cbb79ea071c Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 3 Jun 2016 10:02:57 -0400 Subject: [PATCH 081/115] fix event listener --- src/plugins/googlemaps.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 8b4b25edc..2bcec4211 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -590,8 +590,9 @@ export class GoogleMapsCircle { addEventListener(event: any): Observable { return new Observable( (observer) => { - this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next); + let cb = data => observer.next(data); + this._objectInstance.addEventListener(event, cb); + return () => this._objectInstance.removeEventListener(event, cb); } ); } From 55a7f1f3774d834803b5fc09648a01fd78e173c2 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 3 Jun 2016 10:03:22 -0400 Subject: [PATCH 082/115] fix event listener --- src/plugins/googlemaps.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 2bcec4211..cea1f138d 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -704,8 +704,9 @@ export class GoogleMapsPolyline { addEventListener(event: any): Observable { return new Observable( (observer) => { - this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next); + let cb = data => observer.next(data); + this._objectInstance.addEventListener(event, cb); + return () => this._objectInstance.removeEventListener(event, cb); } ); } @@ -787,8 +788,9 @@ export class GoogleMapsPolygon { addEventListener(event: any): Observable { return new Observable( (observer) => { - this._objectInstance.addEventListener(event, observer.next); - return () => this._objectInstance.removeEventListener(event, observer.next); + let cb = data => observer.next(data); + this._objectInstance.addEventListener(event, cb); + return () => this._objectInstance.removeEventListener(event, cb); } ); } From e7086531360ee28958ab26cfd5d32db19576c966 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 3 Jun 2016 10:05:07 -0400 Subject: [PATCH 083/115] change rxjs/Rxjs to rxjs/Observable --- src/plugins/admob.ts | 2 +- src/plugins/background-geolocation.ts | 2 +- src/plugins/batterystatus.ts | 2 +- src/plugins/ble.ts | 2 +- src/plugins/bluetoothserial.ts | 2 +- src/plugins/dbmeter.ts | 2 +- src/plugins/devicemotion.ts | 2 +- src/plugins/deviceorientation.ts | 2 +- src/plugins/geolocation.ts | 2 +- src/plugins/googlemaps.ts | 2 +- src/plugins/keyboard.ts | 2 +- src/plugins/network.ts | 2 +- src/plugins/plugin.ts | 2 +- src/plugins/toast.ts | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/plugins/admob.ts b/src/plugins/admob.ts index 91a9367c1..73882fa52 100644 --- a/src/plugins/admob.ts +++ b/src/plugins/admob.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; /** * @name AdMob diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index f3e989378..8bf5e22e1 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; declare var window; diff --git a/src/plugins/batterystatus.ts b/src/plugins/batterystatus.ts index efdb3972e..c52b7aee3 100644 --- a/src/plugins/batterystatus.ts +++ b/src/plugins/batterystatus.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; /** * @name Battery Status diff --git a/src/plugins/ble.ts b/src/plugins/ble.ts index f95941c35..c4bf4e7c4 100644 --- a/src/plugins/ble.ts +++ b/src/plugins/ble.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; /** * @name BLE diff --git a/src/plugins/bluetoothserial.ts b/src/plugins/bluetoothserial.ts index 901ae1a57..828565ca6 100644 --- a/src/plugins/bluetoothserial.ts +++ b/src/plugins/bluetoothserial.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; /** * @name Bluetooth Serial diff --git a/src/plugins/dbmeter.ts b/src/plugins/dbmeter.ts index aee63c2de..3ef16c487 100644 --- a/src/plugins/dbmeter.ts +++ b/src/plugins/dbmeter.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; /** * @name DB Meter * @description This plugin defines a global DBMeter object, which permits to get the decibel values from the microphone. diff --git a/src/plugins/devicemotion.ts b/src/plugins/devicemotion.ts index c991c628e..96ee680c5 100644 --- a/src/plugins/devicemotion.ts +++ b/src/plugins/devicemotion.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; export interface AccelerationData { diff --git a/src/plugins/deviceorientation.ts b/src/plugins/deviceorientation.ts index 853c5d7c2..c0a9be5c2 100644 --- a/src/plugins/deviceorientation.ts +++ b/src/plugins/deviceorientation.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; export interface CompassHeading { diff --git a/src/plugins/geolocation.ts b/src/plugins/geolocation.ts index 781c7ed3e..fea2a97dc 100644 --- a/src/plugins/geolocation.ts +++ b/src/plugins/geolocation.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; declare var window; diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index cea1f138d..987dcb93e 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -1,5 +1,5 @@ import {Cordova, Plugin} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; import {CordovaInstance} from './plugin'; /** * Created by Ibrahim on 3/29/2016. diff --git a/src/plugins/keyboard.ts b/src/plugins/keyboard.ts index 570af472b..7c01269cc 100644 --- a/src/plugins/keyboard.ts +++ b/src/plugins/keyboard.ts @@ -1,5 +1,5 @@ import {Cordova, Plugin} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; /** * @name Keyboard diff --git a/src/plugins/network.ts b/src/plugins/network.ts index 9c6d07af3..ba79dfef0 100644 --- a/src/plugins/network.ts +++ b/src/plugins/network.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova, CordovaProperty} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; declare var navigator: any; diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 014d72a18..500479c89 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -6,7 +6,7 @@ declare var window; declare var Promise; declare var $q; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; /** * @private diff --git a/src/plugins/toast.ts b/src/plugins/toast.ts index ff48e1c7e..00e12aa86 100644 --- a/src/plugins/toast.ts +++ b/src/plugins/toast.ts @@ -1,5 +1,5 @@ import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Rx'; +import {Observable} from 'rxjs/Observable'; export interface ToastOptions { /** From f83c8965e1f757ce98f931abce8743be6d829c42 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 3 Jun 2016 10:08:09 -0400 Subject: [PATCH 084/115] Update toast.ts closes #182 --- src/plugins/toast.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/toast.ts b/src/plugins/toast.ts index ff48e1c7e..9ec956183 100644 --- a/src/plugins/toast.ts +++ b/src/plugins/toast.ts @@ -9,7 +9,7 @@ export interface ToastOptions { /** * Duration in ms to show */ - duration?: string; + duration?: number; /** * Position */ From 66b7fa63128f92963dfe3fc76120da81b0b8ea76 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Mon, 6 Jun 2016 11:16:41 -0500 Subject: [PATCH 085/115] fix(batterystatus): correct plugin name on npm --- src/plugins/batterystatus.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/batterystatus.ts b/src/plugins/batterystatus.ts index c52b7aee3..4758ad72f 100644 --- a/src/plugins/batterystatus.ts +++ b/src/plugins/batterystatus.ts @@ -25,7 +25,7 @@ import {Observable} from 'rxjs/Observable'; * ``` */ @Plugin({ - plugin: 'cordova-plugin-batterystatus', + plugin: 'cordova-plugin-battery-status', repo: 'https://github.com/apache/cordova-plugin-battery-status', platforms: ['Amazon Fire OS', 'iOS', 'Android', 'BlackBerry 10', 'Windows Phone 7', 'Windows Phone 8', 'Windows', 'Firefox OS', 'Browser'] }) From c5bfe0f83ece2a4ecfdcc7a4d6bf4a1e177e1752 Mon Sep 17 00:00:00 2001 From: pniraula Date: Wed, 8 Jun 2016 10:25:24 -0400 Subject: [PATCH 086/115] Added backgroundMode.ts for plugin cordova.plugin.background-mode --- src/plugins/backgroundMode.ts | 103 ++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/plugins/backgroundMode.ts diff --git a/src/plugins/backgroundMode.ts b/src/plugins/backgroundMode.ts new file mode 100644 index 000000000..fec66b8be --- /dev/null +++ b/src/plugins/backgroundMode.ts @@ -0,0 +1,103 @@ +import {Plugin, Cordova} from './plugin'; + +/** +* @name Background Mode +* @description +* The ActionSheet plugin shows a native list of options the user can choose from. +* +* Requires Cordova plugin: `cordova-plugin-actionsheet`. For more info, please see the [ActionSheet plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-actionsheet). +* +* @usage +* ```ts +* import {ActionSheet} from 'ionic-native'; +* +* let buttonLabels = ['Share via Facebook', 'Share via Twitter']; +* ActionSheet.show({ +* 'title': 'What do you want with this image?', +* 'buttonLabels': buttonLabels, +* 'addCancelButtonWithLabel': 'Cancel', +* 'addDestructiveButtonWithLabel' : 'Delete' +* }).then(buttonIndex => { +* console.log('Button pressed: ' + buttonLabels[buttonIndex - 1]); +* }); +* ``` +* +*/ +@Plugin({ + plugin: 'cordova-plugin-background-mode', + pluginRef: 'cordova.plugin.background-mode', + repo: 'https://github.com/katzer/cordova-plugin-background-mode', + platforms: ['Android', 'iOS', 'Windows Phone 8'] +}) +export class BackgroundMode { + @Cordova({ + sync: true + }) + static enable(): void{} + + @Cordova() + static disable(): void{} + + @Cordova() + static isEnabled(): Promise {return; } + + @Cordova() + static isActive(): Promise {return; } + + @Cordova() + static setDefaults(options?:Defaults):void{} + + @Cordova() + static configure(options?:Configure):void{} + /** + * Sets a callback for a specific event + * @param eventName The name of the event. Available events: activate, deactivate, failure + */ + @Cordova({ + sync: true + }) + static on(eventName: string, callback: any): void {} +} +/** +*Configurations avaialable only on Android +*/ +export interface Defaults{ + /** + *Title of the background task + */ + title?: String; + + /** + *The text that scrolls itself on statusbar + */ + ticker?: String; + + /** + *Description of background task + */ + text?: String; + +} + +export interface Configure{ + /** + *Title of the background task + */ + title?: String; + + /** + *The text that scrolls itself on statusbar + */ + ticker?: String; + + /** + *Description of background task + */ + text?: String; + + /** + *Boolean, if true plugin will not display a notification. Default is false. + */ + silent?:boolean; + +} From 043f77a06c75190057a961eda41b2b4bb32bd3f5 Mon Sep 17 00:00:00 2001 From: pniraula Date: Wed, 8 Jun 2016 10:27:35 -0400 Subject: [PATCH 087/115] Registered backgroundmode --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index dfbdeb241..d73b13376 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,7 @@ import {AppRate} from './plugins/apprate'; import {AppVersion} from './plugins/appversion'; import {Badge} from './plugins/badge'; import {BackgroundGeolocation} from './plugins/background-geolocation'; +import {BackgroundMode} from './plugins/backgroundmode'; import {BarcodeScanner} from './plugins/barcodescanner'; import {Base64ToGallery} from './plugins/base64togallery'; import {BatteryStatus} from './plugins/batterystatus'; From 18692b179700c1cb08676c670aed64021383c984 Mon Sep 17 00:00:00 2001 From: pniraula Date: Wed, 8 Jun 2016 10:30:02 -0400 Subject: [PATCH 088/115] updated file name --- src/plugins/{backgroundMode.ts => background-mode.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/plugins/{backgroundMode.ts => background-mode.ts} (100%) diff --git a/src/plugins/backgroundMode.ts b/src/plugins/background-mode.ts similarity index 100% rename from src/plugins/backgroundMode.ts rename to src/plugins/background-mode.ts From 715a33dceec2101f447c1851402b674a749e2ce0 Mon Sep 17 00:00:00 2001 From: pniraula Date: Wed, 8 Jun 2016 10:30:30 -0400 Subject: [PATCH 089/115] update file name to be backgorundmode.ts --- src/plugins/{background-mode.ts => backgroundmode.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/plugins/{background-mode.ts => backgroundmode.ts} (100%) diff --git a/src/plugins/background-mode.ts b/src/plugins/backgroundmode.ts similarity index 100% rename from src/plugins/background-mode.ts rename to src/plugins/backgroundmode.ts From c07e3f3e665016633db740632b3d7c418844941a Mon Sep 17 00:00:00 2001 From: pniraula Date: Wed, 8 Jun 2016 10:43:11 -0400 Subject: [PATCH 090/115] Cleaned and added comments --- src/plugins/backgroundmode.ts | 53 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/plugins/backgroundmode.ts b/src/plugins/backgroundmode.ts index fec66b8be..78ca8ec0e 100644 --- a/src/plugins/backgroundmode.ts +++ b/src/plugins/backgroundmode.ts @@ -3,25 +3,8 @@ import {Plugin, Cordova} from './plugin'; /** * @name Background Mode * @description -* The ActionSheet plugin shows a native list of options the user can choose from. -* -* Requires Cordova plugin: `cordova-plugin-actionsheet`. For more info, please see the [ActionSheet plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-actionsheet). -* -* @usage -* ```ts -* import {ActionSheet} from 'ionic-native'; -* -* let buttonLabels = ['Share via Facebook', 'Share via Twitter']; -* ActionSheet.show({ -* 'title': 'What do you want with this image?', -* 'buttonLabels': buttonLabels, -* 'addCancelButtonWithLabel': 'Cancel', -* 'addDestructiveButtonWithLabel' : 'Delete' -* }).then(buttonIndex => { -* console.log('Button pressed: ' + buttonLabels[buttonIndex - 1]); -* }); -* ``` -* +* Cordova plugin to prevent the app from going to sleep while in background. +* For more info about plugin, vist: https://github.com/katzer/cordova-plugin-background-mode#android-customization */ @Plugin({ plugin: 'cordova-plugin-background-mode', @@ -30,27 +13,49 @@ import {Plugin, Cordova} from './plugin'; platforms: ['Android', 'iOS', 'Windows Phone 8'] }) export class BackgroundMode { + /** + * Enable the background mode. + * Once called, prevents the app from being puased while in background. + */ @Cordova({ sync: true }) static enable(): void{} + /** + * Disable the background mode. + * Once the background mode has been disabled, the app will be paused when in background. + */ @Cordova() static disable(): void{} + /** + * Checks if background mode is enabled or not. + */ @Cordova() static isEnabled(): Promise {return; } - + /** + * Can be used to get the information if the background mode is active. + */ @Cordova() static isActive(): Promise {return; } + /** + * Override the default title, ticker and text. + * Available only for Android platform. + */ @Cordova() static setDefaults(options?:Defaults):void{} + /** + * Modify the displayed information. + * Available only for Android platform. + */ @Cordova() - static configure(options?:Configure):void{} + static update(options?:Configure):void{} /** * Sets a callback for a specific event + * Can be used to get notified or run function when the background mode has been activated, deactivated or failed. * @param eventName The name of the event. Available events: activate, deactivate, failure */ @Cordova({ @@ -59,7 +64,7 @@ export class BackgroundMode { static on(eventName: string, callback: any): void {} } /** -*Configurations avaialable only on Android +*Default configurations avaialable only on Android */ export interface Defaults{ /** @@ -78,7 +83,9 @@ export interface Defaults{ text?: String; } - +/** +* Configurations items that can be updated. +*/ export interface Configure{ /** *Title of the background task From 49eb13ddeee7743fd59b352208ecd933c153371c Mon Sep 17 00:00:00 2001 From: Guille Date: Wed, 8 Jun 2016 16:55:43 +0200 Subject: [PATCH 091/115] Add options while creating map --- src/plugins/googlemaps.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 987dcb93e..5d0b8ed28 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -65,8 +65,12 @@ export class GoogleMap { return; } - constructor(elementId: string) { - this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId)); + constructor(elementId: string, options?: any) { + if (options) { + this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId), options); + } else { + this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId)); + } } on(event: any): Observable { From ab1d37d0064988c54ecbcad13048f130e9252841 Mon Sep 17 00:00:00 2001 From: P Niraula

Date: Wed, 8 Jun 2016 17:03:30 -0400 Subject: [PATCH 092/115] Added backgroundmode in index.ts --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index d73b13376..2a816d569 100644 --- a/src/index.ts +++ b/src/index.ts @@ -69,6 +69,7 @@ export { AppVersion, Badge, BackgroundGeolocation, + BackgroundMode, BarcodeScanner, Base64ToGallery, BatteryStatus, From 397515274bc8ab02772110a139b56ce7cfb9f2ae Mon Sep 17 00:00:00 2001 From: P Niraula

Date: Wed, 8 Jun 2016 21:30:41 -0400 Subject: [PATCH 093/115] Fixed pluginRef --- src/plugins/backgroundmode.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/backgroundmode.ts b/src/plugins/backgroundmode.ts index 78ca8ec0e..231b6a4de 100644 --- a/src/plugins/backgroundmode.ts +++ b/src/plugins/backgroundmode.ts @@ -7,8 +7,8 @@ import {Plugin, Cordova} from './plugin'; * For more info about plugin, vist: https://github.com/katzer/cordova-plugin-background-mode#android-customization */ @Plugin({ - plugin: 'cordova-plugin-background-mode', - pluginRef: 'cordova.plugin.background-mode', + plugin: 'de.appplant.cordova.plugin.background-mode', + pluginRef: 'cordova.plugins.backgroundMode', repo: 'https://github.com/katzer/cordova-plugin-background-mode', platforms: ['Android', 'iOS', 'Windows Phone 8'] }) From fd06247b067c5d583858a96a3bcbccda4b39af8d Mon Sep 17 00:00:00 2001 From: P Niraula

Date: Wed, 8 Jun 2016 21:40:16 -0400 Subject: [PATCH 094/115] Updated some comments and added resume option for android --- src/plugins/backgroundmode.ts | 41 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/plugins/backgroundmode.ts b/src/plugins/backgroundmode.ts index 231b6a4de..75ba0aa4d 100644 --- a/src/plugins/backgroundmode.ts +++ b/src/plugins/backgroundmode.ts @@ -4,7 +4,12 @@ import {Plugin, Cordova} from './plugin'; * @name Background Mode * @description * Cordova plugin to prevent the app from going to sleep while in background. -* For more info about plugin, vist: https://github.com/katzer/cordova-plugin-background-mode#android-customization +* Requires Cordova plugin: cordova-plugin-background-mode. For more info about plugin, vist: https://github.com/katzer/cordova-plugin-background-mode#android-customization +*@usage +* ```js +* import {BackgroundMode} from 'ionic-native'; +* +* BackgroundMode.enable(); */ @Plugin({ plugin: 'de.appplant.cordova.plugin.background-mode', @@ -44,14 +49,18 @@ export class BackgroundMode { * Override the default title, ticker and text. * Available only for Android platform. */ - @Cordova() - static setDefaults(options?:Defaults):void{} + @Cordova({ + platforms: ['Android'] + }) + static setDefaults(options?:Configure):void{} /** * Modify the displayed information. * Available only for Android platform. */ - @Cordova() + @Cordova({ + platforms: ['Android'] + }) static update(options?:Configure):void{} /** * Sets a callback for a specific event @@ -63,26 +72,7 @@ export class BackgroundMode { }) static on(eventName: string, callback: any): void {} } -/** -*Default configurations avaialable only on Android -*/ -export interface Defaults{ - /** - *Title of the background task - */ - title?: String; - /** - *The text that scrolls itself on statusbar - */ - ticker?: String; - - /** - *Description of background task - */ - text?: String; - -} /** * Configurations items that can be updated. */ @@ -107,4 +97,9 @@ export interface Configure{ */ silent?:boolean; + /** + *Boolean. By default the app will come to foreground when taping on the notification. If false, plugin wont come to foreground when tapped. + */ + resume?:boolean; + } From 3e42bed84e1f77788ca3111c4a1eb198926667f2 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Wed, 8 Jun 2016 21:57:29 -0400 Subject: [PATCH 095/115] refractor(googlemaps): optimize --- src/plugins/googlemaps.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 5d0b8ed28..24a8befa4 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -66,11 +66,7 @@ export class GoogleMap { } constructor(elementId: string, options?: any) { - if (options) { - this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId), options); - } else { - this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId)); - } + this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId), options); } on(event: any): Observable { From 1e6828d0bb43bcf08ef310f1df3aac1f887d7e9b Mon Sep 17 00:00:00 2001 From: vfdev Date: Thu, 9 Jun 2016 08:35:03 +0200 Subject: [PATCH 096/115] Fix documentation problem Indicated in the issue [#101](https://github.com/driftyco/ionic-native/issues/101) --- src/plugins/background-geolocation.ts | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index 86786a7ac..ed3cdaae1 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -170,26 +170,26 @@ export interface Config { * platform.ready().then(() => { * * // BackgroundGeolocation is highly configurable. See platform specific configuration options - * BackgroundGeolocation.configure( - * (location) => { - * console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude); - * - * // IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, - * // and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. - * // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. - * BackgroundGeolocation.finish(); - * }, - * (error) => { - * console.log('BackgroundGeolocation error'); - * }, - * { + * let config = { * desiredAccuracy: 10, * stationaryRadius: 20, * distanceFilter: 30, * debug: true, // enable this hear sounds for background-geolocation life-cycle. * stopOnTerminate: false, // enable this to clear background location settings when the app terminates - * } - * ); + * }; + * + * BackgroundGeolocation.configure(config) + * .then((location) => { + * console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude); + * + * // IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, + * // and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. + * // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. + * BackgroundGeolocation.finish(); // FOR IOS ONLY + * }) + * .catch((error) => { + * console.log('BackgroundGeolocation error'); + * }); * * // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app. * BackgroundGeolocation.start(); From 4c548581d62183eb5238f44e8af998c228b0da84 Mon Sep 17 00:00:00 2001 From: Guille Date: Thu, 9 Jun 2016 11:50:59 +0200 Subject: [PATCH 097/115] Overwrite equals and toUrlValue --- src/plugins/googlemaps.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 5d0b8ed28..ad85609ef 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -998,11 +998,8 @@ export class GoogleMapsLatLng { this._objectInstance = new plugin.google.maps.LatLng(lat, lng); } - @CordovaInstance({ - sync: true - }) equals(other: GoogleMapsLatLng): boolean { - return; + return this.lat === other.lat && this.lng === other.lng; } @CordovaInstance({ @@ -1012,10 +1009,9 @@ export class GoogleMapsLatLng { return; } - @CordovaInstance({ - sync: true - }) toUrlValue(precision?: number): string { - return; + precision = precision || 6; + + return this.lat.toFixed(precision) + ',' + this.lng.toFixed(precision); } } From 4fdcbb57263f282b45b837060b1d04fe2f68d7d4 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 09:38:58 -0400 Subject: [PATCH 098/115] fix(barcodescanner): add missing options param closes #180 --- src/plugins/barcodescanner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/barcodescanner.ts b/src/plugins/barcodescanner.ts index 31398efad..67d0c9885 100644 --- a/src/plugins/barcodescanner.ts +++ b/src/plugins/barcodescanner.ts @@ -32,7 +32,7 @@ export class BarcodeScanner { * @return Returns a Promise that resolves with scanner data, or rejects with an error. */ @Cordova() - static scan(): Promise { return; } + static scan(options?: any): Promise { return; } // Not well supported // @Cordova() From 62286db24946883814cefc6df8c5d2d452027a5a Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 09:47:45 -0400 Subject: [PATCH 099/115] add browserInit(), closes #160 --- src/plugins/facebook.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/facebook.ts b/src/plugins/facebook.ts index 0260d26af..4ceaf43ad 100644 --- a/src/plugins/facebook.ts +++ b/src/plugins/facebook.ts @@ -85,10 +85,15 @@ import {Plugin, Cordova} from './plugin'; }) export class Facebook { - // @Cordova() - // static browserInit(appId: number){ - // return new Promise((res, rej) => {}); - // } + /** + * Browser wrapper + * @param appId + * @param version + */ + @Cordova() + static browserInit(appId: number, version?: string): Promise { + return; + } /** * Login to Facebook to authenticate this app. From d337cbdd690cc2a220ad03349ce16d8ea4041d8c Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 10:05:38 -0400 Subject: [PATCH 100/115] add SafariViewController plugin, closes #195 --- src/plugins/safari-view-controller.ts | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/plugins/safari-view-controller.ts diff --git a/src/plugins/safari-view-controller.ts b/src/plugins/safari-view-controller.ts new file mode 100644 index 000000000..ac7181220 --- /dev/null +++ b/src/plugins/safari-view-controller.ts @@ -0,0 +1,101 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name SafariViewController + * @description + * @usage + * ``` + * import {SafariViewController} from 'ionic-native'; + * + * ... + * + * SafariViewController.isAvailable() + * .then( + * (available) => { + * if(available){ + * + * SafariViewController.show({ + * utl: 'http://ionic.io', + * hidden: false, + * animated: false, + * transition: 'curl', + * enterReaderModeIfAvailable: true, + * tintColor: '#ff0000' + * }) + * .then( + * (result: any) => { + * if(result.event === 'opened') console.log("Opened"); + * else if(result.event === 'loaded') console.log("Loaded"); + * else if(result.event === 'closed') console.log("Closed"); + * }, + * (error: any) => console.error(error) + * ); + * + * } else { + * // use fallback browser, example InAppBrowser + * } + * } + * ); + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-safariviewcontroller', + pluginRef: 'SafariViewController', + platforms: ['iOS'], + repo: 'https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller' +}) +export class SafariViewController { + + /** + * Checks if SafariViewController is available + */ + @Cordova() + static isAvailable(): Promise {return; } + + /** + * Shows Safari View Controller + * @param options + */ + @Cordova({ + callbackOrder: 'reverse' + }) + static show(options?: SafariViewControllerOptions): void {} + + /** + * Hides Safari View Controller + */ + @Cordova({ + sync: true + }) + static hide(): void {} + + /** + * Tries to connect to the Chrome's custom tabs service. you must call this method before calling any of the other methods listed below. + */ + @Cordova() + static connectToService(): Promise {return; } + + /** + * Call this method whenever there's a chance the user will open an external url. + */ + @Cordova() + static warmUp(): Promise {return; } + + /** + * For even better performance optimization, call this methods if there's more than a 50% chance the user will open a certain URL. + * @param url + */ + @Cordova() + static mayLaunchUrl(url: string): Promise {return; } +} + +export interface SafariViewControllerOptions { + url?: string; + hidden?: boolean; + toolbarColor?: string; + animated?: boolean; + showDefaultShareMenuItem?: boolean; + enterReaderModeIfAvailable?: boolean; + tintColor?: string; + transition?: string; +} \ No newline at end of file From 1e29166c416134a07cf4dd2ab796cbcc9f2d4314 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 10:17:08 -0400 Subject: [PATCH 101/115] add cardio plugin, closes #194 --- src/plugins/card-io.ts | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/plugins/card-io.ts diff --git a/src/plugins/card-io.ts b/src/plugins/card-io.ts new file mode 100644 index 000000000..d5045e8c5 --- /dev/null +++ b/src/plugins/card-io.ts @@ -0,0 +1,73 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name CardIO + * @description + * @usage + * ``` + * import {CardIO} from 'ionic-native'; + * + * ... + * + * CardIO.canScan() + * .then( + * (res: boolean) => { + * if(res){ + * let options = { + * requireExpiry: true, + * requireCCV: false, + * requirePostalCode: false + * }; + * CardIO.scan(options); + * } + * } + * ); + * ``` + */ +@Plugin({ + plugin: 'https://github.com/card-io/card.io-Cordova-Plugin', + pluginRef: 'CardIO', + repo: 'https://github.com/card-io/card.io-Cordova-Plugin', + platforms: ['iOS', 'Android'] +}) +export class CardIO { + /** + * Check whether card scanning is currently available. (May vary by + * device, OS version, network connectivity, etc.) + * + */ + @Cordova() + static canScan(): Promise {return; } + + /** + * Scan a credit card with card.io. + * @param options + */ + @Cordova() + static scan(options?: CardIOOptions): Promise {return; } + + /** + * Retrieve the version of the card.io library. Useful when contacting support. + */ + @Cordova() + static version(): Promise {return; } +} + +export interface CardIOOptions { + requireExpiry?: boolean; + requireCCV?: boolean; + requirePostalCode?: boolean; + supressManual?: boolean; + restrictPostalCodeToNumericOnly?: boolean; + keepApplicationTheme?: boolean; + requireCardholderName?: boolean; + scanInstructions?: string; + noCamera?: boolean; + scanExpiry?: boolean; + languageOrLocale?: string; + guideColor?: string; + supressConfirmation?: boolean; + hideCardIOLogo?: boolean; + useCardIOLogo?: boolean; + supressScan?: boolean; +} \ No newline at end of file From fea980f1d9582efdc1d5ce0abde819c3123bff1b Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 10:18:53 -0400 Subject: [PATCH 102/115] chore(index): update indexl --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 2a816d569..37fb72b80 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,6 +20,7 @@ import {BLE} from './plugins/ble'; import {BluetoothSerial} from './plugins/bluetoothserial'; import {Calendar} from './plugins/calendar'; import {Camera} from './plugins/camera'; +import {CardIO} from './plugins/card-io'; import {Clipboard} from './plugins/clipboard'; import {Contacts} from './plugins/contacts'; import {DatePicker} from './plugins/datepicker'; @@ -49,6 +50,7 @@ import {LocalNotifications} from './plugins/localnotifications'; import {MediaPlugin} from './plugins/media'; import {Network, Connection} from './plugins/network'; import {Push} from './plugins/push'; +import {SafariViewController} from './plugins/safari-view-controller'; import {Screenshot} from './plugins/screenshot'; import {SMS} from './plugins/sms'; import {SocialSharing} from './plugins/socialsharing'; @@ -77,6 +79,7 @@ export { BluetoothSerial, Calendar, Camera, + CardIO, Clipboard, Connection, Contacts, @@ -105,6 +108,7 @@ export { MediaPlugin, Network, Push, + SafariViewController, Screenshot, SMS, SocialSharing, @@ -137,6 +141,7 @@ window['IonicNative'] = { BluetoothSerial: BluetoothSerial, Calendar: Calendar, Camera: Camera, + CardIO: CardIO, Clipboard: Clipboard, Connection: Connection, Contacts: Contacts, @@ -165,6 +170,7 @@ window['IonicNative'] = { MediaPlugin: MediaPlugin, Network: Network, Push: Push, + SafariViewController: SafariViewController, Screenshot: Screenshot, SMS: SMS, SocialSharing: SocialSharing, From d57a2dc29bf517e365bdb1138119e843bbcb2328 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 10:27:07 -0400 Subject: [PATCH 103/115] add GooglePlus plugin, closes #183 --- src/index.ts | 3 +++ src/plugins/google-plus.ts | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/plugins/google-plus.ts diff --git a/src/index.ts b/src/index.ts index 37fb72b80..da7efec49 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,6 +38,7 @@ import {Transfer} from './plugins/filetransfer'; import {Flashlight} from './plugins/flashlight'; import {Geolocation} from './plugins/geolocation'; import {Globalization} from './plugins/globalization'; +import {GooglePlus} from './plugins/google-plus'; import {GoogleMap} from './plugins/googlemaps'; import {GoogleAnalytics} from './plugins/googleanalytics'; import {Hotspot} from './plugins/hotspot'; @@ -97,6 +98,7 @@ export { Flashlight, Geolocation, Globalization, + GooglePlus, GoogleAnalytics, Hotspot, ImagePicker, @@ -159,6 +161,7 @@ window['IonicNative'] = { Flashlight: Flashlight, Geolocation: Geolocation, Globalization: Globalization, + GooglePlus: GooglePlus, GoogleMap : GoogleMap, GoogleAnalytics: GoogleAnalytics, Hotspot: Hotspot, diff --git a/src/plugins/google-plus.ts b/src/plugins/google-plus.ts new file mode 100644 index 000000000..924b1a1f7 --- /dev/null +++ b/src/plugins/google-plus.ts @@ -0,0 +1,46 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name Google Plus + * @description + * @usage + * ``` + * + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-googleplus', + pluginRef: 'window.plugins.googleplus', + repo: 'https://github.com/EddyVerbruggen/cordova-plugin-googleplus', + platforms: ['Web','Android','iOS'], + install: 'ionic plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myreversedclientid' +}) +export class GooglePlus { + + /** + * The login function walks the user through the Google Auth process. + * @param options + */ + @Cordova() + static login(options?: any): Promise {return; } + + /** + * You can call trySilentLogin to check if they're already signed in to the app and sign them in silently if they are. + * @param options + */ + @Cordova() + static trySilentLogin(options?: any): Promise {return; } + + /** + * This will clear the OAuth2 token. + */ + @Cordova() + static logout(): Promise {return; } + + /** + * This will clear the OAuth2 token, forget which account was used to login, and disconnect that account from the app. This will require the user to allow the app access again next time they sign in. Be aware that this effect is not always instantaneous. It can take time to completely disconnect. + */ + @Cordova() + static disconnect(): Promise {return; } + +} \ No newline at end of file From dcfe04861e6beac5251c947103507ceeb5aa1b8e Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 10:27:18 -0400 Subject: [PATCH 104/115] tslint --- src/plugins/google-plus.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/google-plus.ts b/src/plugins/google-plus.ts index 924b1a1f7..f766e6e00 100644 --- a/src/plugins/google-plus.ts +++ b/src/plugins/google-plus.ts @@ -12,7 +12,7 @@ import {Plugin, Cordova} from './plugin'; plugin: 'cordova-plugin-googleplus', pluginRef: 'window.plugins.googleplus', repo: 'https://github.com/EddyVerbruggen/cordova-plugin-googleplus', - platforms: ['Web','Android','iOS'], + platforms: ['Web', 'Android', 'iOS'], install: 'ionic plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myreversedclientid' }) export class GooglePlus { From aec95709bc5125c3746ea2594ee29e949556e652 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 10:28:46 -0400 Subject: [PATCH 105/115] tslint & cleanup --- src/plugins/backgroundmode.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/backgroundmode.ts b/src/plugins/backgroundmode.ts index 75ba0aa4d..6cfad0748 100644 --- a/src/plugins/backgroundmode.ts +++ b/src/plugins/backgroundmode.ts @@ -20,19 +20,19 @@ import {Plugin, Cordova} from './plugin'; export class BackgroundMode { /** * Enable the background mode. - * Once called, prevents the app from being puased while in background. + * Once called, prevents the app from being paused while in background. */ @Cordova({ sync: true }) - static enable(): void{} + static enable(): void {} /** * Disable the background mode. * Once the background mode has been disabled, the app will be paused when in background. */ @Cordova() - static disable(): void{} + static disable(): void {} /** * Checks if background mode is enabled or not. @@ -52,7 +52,7 @@ export class BackgroundMode { @Cordova({ platforms: ['Android'] }) - static setDefaults(options?:Configure):void{} + static setDefaults(options?: Configure): void {} /** * Modify the displayed information. @@ -61,7 +61,7 @@ export class BackgroundMode { @Cordova({ platforms: ['Android'] }) - static update(options?:Configure):void{} + static update(options?: Configure): void {} /** * Sets a callback for a specific event * Can be used to get notified or run function when the background mode has been activated, deactivated or failed. @@ -76,7 +76,7 @@ export class BackgroundMode { /** * Configurations items that can be updated. */ -export interface Configure{ +export interface Configure { /** *Title of the background task */ @@ -95,11 +95,11 @@ export interface Configure{ /** *Boolean, if true plugin will not display a notification. Default is false. */ - silent?:boolean; + silent?: boolean; /** *Boolean. By default the app will come to foreground when taping on the notification. If false, plugin wont come to foreground when tapped. */ - resume?:boolean; + resume?: boolean; } From af8fbde892651905fe7538669e3e3b4ac5886442 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 9 Jun 2016 11:24:38 -0500 Subject: [PATCH 106/115] feat(angular1): Support Angular 1 --- src/index.ts | 3 ++- src/ng1.ts | 38 +++++++++++++++++++++----------------- src/plugins/plugin.ts | 2 -- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/index.ts b/src/index.ts index da7efec49..bb3d92aab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import {initAngular1} from './ng1'; -initAngular1(); const DEVICE_READY_TIMEOUT = 2000; @@ -188,6 +187,8 @@ window['IonicNative'] = { WebIntent: WebIntent }; +initAngular1(window['IonicNative']); + // To help developers using cordova, we listen for the device ready event and // log an error if it didn't fire in a reasonable amount of time. Generally, // when this happens, developers should remove and reinstall plugins, since diff --git a/src/ng1.ts b/src/ng1.ts index 1101d257a..cd3bc0ce5 100644 --- a/src/ng1.ts +++ b/src/ng1.ts @@ -1,24 +1,28 @@ declare var window; /** - * Initialize the ngCordova Angular module if we're running in ng1 + * Initialize the ngCordova Angular module if we're running in ng1. + * This iterates through the list of registered plugins and dynamically + * creates Angular 1 services of the form $cordovaSERVICE, ex: $cordovStatusBar. */ -export function initAngular1() { +export function initAngular1(plugins) { if (window.angular) { - window.angular.module('ngCordova', []); + window.angular.module('ionic.native', []); + + for(var name in plugins) { + let serviceName = '$cordova' + name; + let cls = plugins[name]; + + (function(serviceName, cls, name) { + window.angular.module('ionic.native').service(serviceName, [function() { + let funcs = {}; + for (var k in cls) { + funcs[k] = cls[k]; + } + funcs['name'] = name; + return funcs; + }]) + })(serviceName, cls, name); + } } } - -/** - * Publish a new Angular 1 service for this plugin. - */ -export function publishAngular1Service(config: any, cls: any) { - let serviceName = '$cordova' + cls.name; - console.log('Registering Angular1 service', serviceName); - window.angular.module('ngCordova').service(serviceName, [function() { - let funcs = {}; - for (var k in cls) { - } - return funcs; - }]); -} diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 500479c89..533217c50 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -1,7 +1,5 @@ import {get} from '../util'; -import {publishAngular1Service} from '../ng1'; - declare var window; declare var Promise; declare var $q; From 4875f66b7ac1093950e45c3cc3f6cd00035935b2 Mon Sep 17 00:00:00 2001 From: mhartington Date: Thu, 9 Jun 2016 16:48:40 -0400 Subject: [PATCH 107/115] docs(googleMaps): clean up extra docs --- src/plugins/googlemaps.ts | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index a7711c582..c3ad4b55f 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -2,10 +2,12 @@ import {Cordova, Plugin} from './plugin'; import {Observable} from 'rxjs/Observable'; import {CordovaInstance} from './plugin'; /** + * @private * Created by Ibrahim on 3/29/2016. */ declare var plugin: any; /** + * @private * You can listen to these events where appropriate */ export const GoogleMapsEvent = { @@ -29,10 +31,14 @@ export const GoogleMapsEvent = { MARKER_DRAG_END: 'drag_end' }; +/** + * @private + */ export const GoogleMapsAnimation = { BOUNCE: 'BOUNCE', DROP: 'DROP' }; + /** * @name Google Maps * @description This plugin uses the native Google Maps SDK @@ -352,6 +358,10 @@ export class GoogleMap { } } + +/** + * @private + */ export interface AnimateCameraOptions { target?: GoogleMapsLatLng; tilt?: number; @@ -359,22 +369,38 @@ export interface AnimateCameraOptions { bearing?: number; duration?: number; } + +/** + * @private + */ export interface CameraPosition { target?: GoogleMapsLatLng; zoom?: number; tilt?: number; bearing?: number; } + +/** + * @private + */ export interface MyLocation { latLng?: GoogleMapsLatLng; speed?: number; time?: string; bearing?: number; } + +/** + * @private + */ export interface VisibleRegion { northeast?: any; southwest?: any; } + +/** + * @private + */ export interface GoogleMapsMarkerOptions { icon?: any; title?: string; @@ -389,6 +415,10 @@ export interface GoogleMapsMarkerOptions { animation?: string; zIndex?: number; } + +/** + * @private + */ export interface GoogleMapsMarkerIcon { url?: string; size?: { @@ -396,6 +426,10 @@ export interface GoogleMapsMarkerIcon { height?: number; }; } + +/** + * @private + */ export class GoogleMapsMarker { constructor(private _objectInstance: any) { @@ -573,6 +607,10 @@ export class GoogleMapsMarker { } + +/** + * @private + */ export interface GoogleMapsCircleOptions { center?: GoogleMapsLatLng; radius?: number; @@ -582,6 +620,10 @@ export interface GoogleMapsCircleOptions { visible?: boolean; zIndex?: number; } + +/** + * @private + */ export class GoogleMapsCircle { constructor(private _objectInstance: any) { @@ -689,6 +731,10 @@ export class GoogleMapsCircle { } + +/** + * @private + */ export interface GoogleMapsPolylineOptions { points?: Array; visible?: boolean; @@ -697,6 +743,10 @@ export interface GoogleMapsPolylineOptions { width?: number; zIndex?: number; } + +/** + * @private + */ export class GoogleMapsPolyline { constructor(private _objectInstance: any) { } @@ -770,6 +820,10 @@ export class GoogleMapsPolyline { } } + +/** + * @private + */ export interface GoogleMapsPolygonOptions { points?: Array; geodesic?: boolean; @@ -780,6 +834,10 @@ export interface GoogleMapsPolygonOptions { zIndex?: number; addHole?: Array; } + +/** + * @private + */ export class GoogleMapsPolygon { constructor(private _objectInstance: any) { @@ -862,6 +920,10 @@ export class GoogleMapsPolygon { setGeodesic(geodesic: boolean): void { } } + +/** + * @private + */ export interface GoogleMapsTileOverlayOptions { titleUrilFormat?: string; visible?: boolean; @@ -869,6 +931,10 @@ export interface GoogleMapsTileOverlayOptions { tileSize?: number; opacity?: number; } + +/** + * @private + */ export class GoogleMapsTileOverlay { constructor(private _objectInstance: any) { @@ -919,6 +985,10 @@ export class GoogleMapsTileOverlay { } } + +/** + * @private + */ export interface GoogleMapsGroundOverlayOptions { url?: string; bounds?: Array; @@ -927,6 +997,10 @@ export interface GoogleMapsGroundOverlayOptions { bearing?: number; zIndex?: number; } + +/** + * @private + */ export class GoogleMapsGroundOverlay { constructor(private _objectInstance: any) { @@ -968,11 +1042,19 @@ export class GoogleMapsGroundOverlay { } } + +/** + * @private + */ export interface GoogleMapsKmlOverlayOptions { url?: string; preserveViewport?: boolean; animation?: boolean; } + +/** + * @private + */ export class GoogleMapsKmlOverlay { constructor(private _objectInstance: any) { @@ -987,6 +1069,10 @@ export class GoogleMapsKmlOverlay { return; } } + +/** + * @private + */ export class GoogleMapsLatLng { private _objectInstance: any; From c93cbed9d2c60b9c311d01be38f82e2ecc3f1543 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 9 Jun 2016 15:37:40 -0500 Subject: [PATCH 108/115] feat(deeplinks): Add Ionic Deeplinks Plugin --- src/index.ts | 3 ++ src/plugins/deeplinks.ts | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/plugins/deeplinks.ts diff --git a/src/index.ts b/src/index.ts index bb3d92aab..e0fe66e55 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,7 @@ import {Clipboard} from './plugins/clipboard'; import {Contacts} from './plugins/contacts'; import {DatePicker} from './plugins/datepicker'; import {DBMeter} from './plugins/dbmeter'; +import {Deeplinks} from './plugins/deeplinks'; import {Device} from './plugins/device'; import {DeviceAccounts} from './plugins/deviceaccounts'; import {DeviceMotion} from './plugins/devicemotion'; @@ -85,6 +86,7 @@ export { Contacts, DatePicker, DBMeter, + Deeplinks, Device, DeviceAccounts, DeviceMotion, @@ -148,6 +150,7 @@ window['IonicNative'] = { Contacts: Contacts, DatePicker: DatePicker, DBMeter: DBMeter, + Deeplinks: Deeplinks, Device: Device, DeviceAccounts: DeviceAccounts, DeviceMotion: DeviceMotion, diff --git a/src/plugins/deeplinks.ts b/src/plugins/deeplinks.ts new file mode 100644 index 000000000..5bb060f69 --- /dev/null +++ b/src/plugins/deeplinks.ts @@ -0,0 +1,74 @@ +import {Plugin, Cordova} from './plugin'; +import {Observable} from 'rxjs/Observable'; + +export interface DeeplinkMatch { + /** + * The route info for the matched route + */ + routeInfo: any; + + /** + * The arguments passed to the route through GET params along with + * any internal native data available as "extras" at the time + * the route was matched (for example, Facebook sometimes adds extra data) + */ + args: any; +} + +/** + * @name Ionic Deeplinks + * @description This plugin handles deeplinks on iOS and Android for both custom URL scheme links + * and Universal App Links. + * + * @usage + * ```ts + * import {IonicDeeplinks} from 'ionic-native'; + * + * ``` + */ +@Plugin({ + plugin: 'ionic-plugin-deeplinks', + pluginRef: 'IonicDeeplink', + repo: 'https://github.com/driftyo/ionic-plugin-deeplinks', + platforms: ['iOS', 'Android'] +}) +export class Deeplinks { + + /** + * Define a set of paths to match against incoming deeplinks. + * + * @param {paths} Define a set of paths to match against incoming deeplinks. + * paths takes an object of the form { 'path': data }. If a deeplink + * matches the path, the resulting path-data pair will be returned in the + * promise result which you can then use to navigate in the app as you see fit. + * @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and + * is rejected if a deeplink comes through that does not match a given path. + */ + @Cordova({ + observable: true + }) + static route(paths): Observable {return; } + + /** + * + * This is a convenience version of `route` that takes a reference to a NavController + * from Ionic 2, or a custom class that conforms to this protocol: + * + * NavController.push = function(View, Params){} + * + * This handler will automatically navigate when a route matches. If you need finer-grained + * control over the behavior of a matching deeplink, use the plain `route` method. + * + * @param {paths} Define a set of paths to match against incoming deeplinks. + * paths takes an object of the form { 'path': data }. If a deeplink + * matches the path, the resulting path-data pair will be returned in the + * promise result which you can then use to navigate in the app as you see fit. + * + * @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and + * is rejected if a deeplink comes through that does not match a given path. + */ + @Cordova({ + observable: true + }) + static routeWithNavController(navController, paths): Observable {return; } +} From 8dee02e234d3927cad0eef7f1fad1b07466d89bf Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 9 Jun 2016 15:50:54 -0500 Subject: [PATCH 109/115] fix(deviceorientation): cancelFunction renamed to clearFunction --- src/plugins/deviceorientation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/deviceorientation.ts b/src/plugins/deviceorientation.ts index c0a9be5c2..a923d68b9 100644 --- a/src/plugins/deviceorientation.ts +++ b/src/plugins/deviceorientation.ts @@ -89,7 +89,7 @@ export class DeviceOrientation { @Cordova({ callbackOrder: 'reverse', observable: true, - cancelFunction: 'clearWatch' + clearFunction: 'clearWatch' }) static watchHeading(options?: CompassOptions): Observable { return; } From 0d624c4cb643256178ea5250fbe2d712ef3c3811 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 21:18:13 -0400 Subject: [PATCH 110/115] Fix typo --- src/plugins/safari-view-controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/safari-view-controller.ts b/src/plugins/safari-view-controller.ts index ac7181220..5af60f6f7 100644 --- a/src/plugins/safari-view-controller.ts +++ b/src/plugins/safari-view-controller.ts @@ -15,7 +15,7 @@ import {Plugin, Cordova} from './plugin'; * if(available){ * * SafariViewController.show({ - * utl: 'http://ionic.io', + * url: 'http://ionic.io', * hidden: false, * animated: false, * transition: 'curl', From b49efd89a72f5c80fef214984915ab385a1b3a78 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 21:20:55 -0400 Subject: [PATCH 111/115] Missing semicolumn!! --- src/ng1.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng1.ts b/src/ng1.ts index cd3bc0ce5..dc897a212 100644 --- a/src/ng1.ts +++ b/src/ng1.ts @@ -21,7 +21,7 @@ export function initAngular1(plugins) { } funcs['name'] = name; return funcs; - }]) + }]); })(serviceName, cls, name); } } From 81f5d4acd1eca8d5b6cae0ecc86e9eb1411a0305 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 21:22:05 -0400 Subject: [PATCH 112/115] tslint --- src/ng1.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ng1.ts b/src/ng1.ts index dc897a212..9bca81165 100644 --- a/src/ng1.ts +++ b/src/ng1.ts @@ -1,7 +1,7 @@ declare var window; /** - * Initialize the ngCordova Angular module if we're running in ng1. + * Initialize the ionic.native Angular module if we're running in ng1. * This iterates through the list of registered plugins and dynamically * creates Angular 1 services of the form $cordovaSERVICE, ex: $cordovStatusBar. */ @@ -9,7 +9,7 @@ export function initAngular1(plugins) { if (window.angular) { window.angular.module('ionic.native', []); - for(var name in plugins) { + for (var name in plugins) { let serviceName = '$cordova' + name; let cls = plugins[name]; @@ -25,4 +25,4 @@ export function initAngular1(plugins) { })(serviceName, cls, name); } } -} +} \ No newline at end of file From e9efc9a0a35aaaf380ead3e942a3c38d5dbd6acc Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 21:25:53 -0400 Subject: [PATCH 113/115] add 3dtouch plugin --- src/plugins/3dtouch.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/plugins/3dtouch.ts diff --git a/src/plugins/3dtouch.ts b/src/plugins/3dtouch.ts new file mode 100644 index 000000000..a155d39d0 --- /dev/null +++ b/src/plugins/3dtouch.ts @@ -0,0 +1,13 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name + * @description + * @usage + */ +@Plugin({ + plugin: '', + pluginRef: '', + repo: '', + platforms: ['iOS'] +}) \ No newline at end of file From 596948eeb3c68c0ab16b671a11dcc1d762ce7a18 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 21:47:27 -0400 Subject: [PATCH 114/115] add 3D touch plugin --- src/index.ts | 3 ++ src/plugins/3dtouch.ts | 103 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 100 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index e0fe66e55..e75461475 100644 --- a/src/index.ts +++ b/src/index.ts @@ -59,11 +59,13 @@ import {SpinnerDialog} from './plugins/spinnerdialog'; import {Splashscreen} from './plugins/splashscreen'; import {SQLite} from './plugins/sqlite'; import {StatusBar} from './plugins/statusbar'; +import {ThreeDeeTouch} from './plugins/3dtouch'; import {Toast} from './plugins/toast'; import {TouchID} from './plugins/touchid'; import {Vibration} from './plugins/vibration'; import {WebIntent} from './plugins/webintent'; export * from './plugins/googlemaps'; +export * from './plugins/3dtouch'; export { ActionSheet, AdMob, @@ -183,6 +185,7 @@ window['IonicNative'] = { Splashscreen: Splashscreen, SQLite: SQLite, StatusBar: StatusBar, + ThreeDeeTouch: ThreeDeeTouch, Toast: Toast, TouchID: TouchID, Transfer: Transfer, diff --git a/src/plugins/3dtouch.ts b/src/plugins/3dtouch.ts index a155d39d0..6d1583a0f 100644 --- a/src/plugins/3dtouch.ts +++ b/src/plugins/3dtouch.ts @@ -1,13 +1,104 @@ import {Plugin, Cordova} from './plugin'; - +import {Observable} from 'rxjs/Observable'; /** - * @name + * @name 3DTouch * @description * @usage + * ``` + * import {ThreeDeeTouch, ThreeDeeTouchQuickAction, ThreeDeeTouchForceTouch} from 'ionic-native'; + * + * ... + * + * ThreeDeeTouch.isAvailable().then(isAvailable => console.log("3D Touch available? " + isAvailable)): + * + * ThreeDeeTouch.watchForceTouches() + * .subscribe( + * (data: ThreeDeeTouchForceTouch) => { + * console.log("Force touch %" + data.force); + * console.log("Force touch timestamp: " + data.timestamp); + * console.log("Force touch x: " + data.x); + * console.log("Force touch y: " + data.y); + * } + * ); + * + * + * let actions: Array = [ + * { + * type: 'checkin', + * title: 'Check in', + * subtitle: 'Quickly check in', + * iconType: 'Compose' + * }, + * { + * type: 'share', + * title: 'Share', + * subtitle: 'Share like you care', + * iconType: 'Share' + * }, + * { + * type: 'search', + * title: 'Search', + * iconType: 'Search' + * }, + * { + * title: 'Show favorites', + * iconTemplate: 'HeartTemplate' + * } + * ]; + * ThreeDeeTouch.configureQuickActions(actions); + * ``` */ @Plugin({ - plugin: '', - pluginRef: '', - repo: '', + plugin: 'cordova-plugin-3dtouch', + pluginRef: 'ThreeDeeTouch', + repo: 'https://github.com/EddyVerbruggen/cordova-plugin-3dtouch', platforms: ['iOS'] -}) \ No newline at end of file +}) +export class ThreeDeeTouch { + + /** + * You need an iPhone 6S or some future tech to use the features of this plugin, so you can check at runtime if the user's device is supported. + */ + @Cordova() + static isAvailable(): Promise {return; } + + /** + * You can get a notification when the user force touches the webview. The plugin defines a Force Touch when at least 75% of the maximum force is applied to the screen. Your app will receive the x and y coordinates, so you have to figure out which UI element was touched. + */ + @Cordova({ + observable: true + }) + static watchForceTouches(): Observable {return; } + + @Cordova({ + sync: true + }) + static configureQuickActions(quickActions: Array): void {} + + @Cordova({ + observable: true + }) + static onHomeIconPressed(): Observable {return; } + + @Cordova({ + sync: true + }) + static enableLinkPreview(): void {} + + @Cordova({ + sync: true + }) + static disableLinkPreview(): void {} +} +export interface ThreeDeeTouchQuickAction { + type?: string; + title: string; + subtitle?: string; + iconType?: string; +} +export interface ThreeDeeTouchForceTouch { + force: number; + timestamp: number; + x: number; + y: number; +} \ No newline at end of file From 0c8bcf8b21c06573b83f2ebcc965787ca7d60f1e Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 9 Jun 2016 21:51:23 -0400 Subject: [PATCH 115/115] add 3D touch plugin docs --- src/plugins/3dtouch.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/3dtouch.ts b/src/plugins/3dtouch.ts index 6d1583a0f..20e8c7921 100644 --- a/src/plugins/3dtouch.ts +++ b/src/plugins/3dtouch.ts @@ -4,6 +4,7 @@ import {Observable} from 'rxjs/Observable'; * @name 3DTouch * @description * @usage + * Please do refer to the original plugin's repo for detailed usage. The usage example here might not be sufficient. * ``` * import {ThreeDeeTouch, ThreeDeeTouchQuickAction, ThreeDeeTouchForceTouch} from 'ionic-native'; * @@ -58,12 +59,14 @@ export class ThreeDeeTouch { /** * You need an iPhone 6S or some future tech to use the features of this plugin, so you can check at runtime if the user's device is supported. + * @returns {Promise} returns a promise that resolves with a boolean that indicates whether the plugin is available or not */ @Cordova() static isAvailable(): Promise {return; } /** * You can get a notification when the user force touches the webview. The plugin defines a Force Touch when at least 75% of the maximum force is applied to the screen. Your app will receive the x and y coordinates, so you have to figure out which UI element was touched. + * @returns {Observable} Returns an observable that sends a `ThreeDeeTouchForceTouch` object */ @Cordova({ observable: true @@ -75,16 +78,26 @@ export class ThreeDeeTouch { }) static configureQuickActions(quickActions: Array): void {} + /** + * When a home icon is pressed, your app launches and this JS callback is invoked. + * @returns {Observable} returns an observable that notifies you when he user presses on the home screen icon + */ @Cordova({ observable: true }) static onHomeIconPressed(): Observable {return; } + /** + * UIWebView and WKWebView (the webviews powering Cordova apps) don't allow the fancy new link preview feature of iOS9. + */ @Cordova({ sync: true }) static enableLinkPreview(): void {} + /** + * Disabled the link preview feature, if enabled. + */ @Cordova({ sync: true })