From ef4f212fc1482136dba1e690ec589b315b4a377f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 8 Nov 2016 12:37:03 -0500 Subject: build 0.7.0 --- StoneIsland/plugins/android.json | 34 +- StoneIsland/plugins/com.ionic.keyboard/LICENSE | 202 --- StoneIsland/plugins/com.ionic.keyboard/README.md | 123 -- .../plugins/com.ionic.keyboard/package.json | 19 - StoneIsland/plugins/com.ionic.keyboard/plugin.xml | 55 - .../src/android/IonicKeyboard.java | 96 -- .../com.ionic.keyboard/src/blackberry10/index.js | 135 -- .../src/blackberry10/native/.cproject | 222 --- .../src/blackberry10/native/.project | 76 - .../src/blackberry10/native/public/json/autolink.h | 19 - .../src/blackberry10/native/public/json/config.h | 43 - .../src/blackberry10/native/public/json/features.h | 42 - .../src/blackberry10/native/public/json/forwards.h | 39 - .../src/blackberry10/native/public/json/json.h | 10 - .../src/blackberry10/native/public/json/reader.h | 196 --- .../src/blackberry10/native/public/json/value.h | 1069 ------------ .../src/blackberry10/native/public/json/writer.h | 174 -- .../native/public/json_batchallocator.h | 125 -- .../native/public/json_internalarray.inl | 448 ----- .../native/public/json_internalmap.inl | 607 ------- .../src/blackberry10/native/public/json_reader.cpp | 892 ---------- .../src/blackberry10/native/public/json_value.cpp | 1726 -------------------- .../native/public/json_valueiterator.inl | 292 ---- .../src/blackberry10/native/public/json_writer.cpp | 829 ---------- .../src/blackberry10/native/public/plugin.cpp | 320 ---- .../src/blackberry10/native/public/plugin.h | 70 - .../src/blackberry10/native/public/tokenizer.cpp | 222 --- .../src/blackberry10/native/public/tokenizer.h | 55 - .../src/blackberry10/native/src/Logger.cpp | 104 -- .../src/blackberry10/native/src/Logger.hpp | 49 - .../src/blackberry10/native/src/keyboard_js.cpp | 117 -- .../src/blackberry10/native/src/keyboard_js.hpp | 42 - .../src/blackberry10/native/src/keyboard_ndk.cpp | 155 -- .../src/blackberry10/native/src/keyboard_ndk.hpp | 71 - .../com.ionic.keyboard/src/ios/IonicKeyboard.h | 13 - .../com.ionic.keyboard/src/ios/IonicKeyboard.m | 160 -- .../src/ios/UIWebViewExtension.h | 4 - .../src/ios/UIWebViewExtension.m | 109 -- .../plugins/com.ionic.keyboard/www/keyboard.js | 37 - .../plugins/cordova-plugin-compat/README.md | 31 + .../plugins/cordova-plugin-compat/RELEASENOTES.md | 29 + .../plugins/cordova-plugin-compat/package.json | 32 + .../plugins/cordova-plugin-compat/plugin.xml | 37 + .../src/android/BuildHelper.java | 70 + .../src/android/PermissionHelper.java | 138 ++ .../plugins/cordova-plugin-console/CONTRIBUTING.md | 2 +- StoneIsland/plugins/cordova-plugin-console/LICENSE | 0 StoneIsland/plugins/cordova-plugin-console/NOTICE | 0 .../plugins/cordova-plugin-console/README.md | 65 +- .../plugins/cordova-plugin-console/RELEASENOTES.md | 116 +- .../cordova-plugin-console/doc/de/README.md | 0 .../plugins/cordova-plugin-console/doc/de/index.md | 0 .../cordova-plugin-console/doc/es/README.md | 0 .../plugins/cordova-plugin-console/doc/es/index.md | 0 .../cordova-plugin-console/doc/fr/README.md | 0 .../plugins/cordova-plugin-console/doc/fr/index.md | 0 .../cordova-plugin-console/doc/it/README.md | 0 .../plugins/cordova-plugin-console/doc/it/index.md | 0 .../cordova-plugin-console/doc/ja/README.md | 0 .../plugins/cordova-plugin-console/doc/ja/index.md | 0 .../cordova-plugin-console/doc/ko/README.md | 0 .../plugins/cordova-plugin-console/doc/ko/index.md | 0 .../cordova-plugin-console/doc/pl/README.md | 0 .../plugins/cordova-plugin-console/doc/pl/index.md | 0 .../plugins/cordova-plugin-console/doc/ru/index.md | 0 .../cordova-plugin-console/doc/zh/README.md | 0 .../plugins/cordova-plugin-console/doc/zh/index.md | 0 .../plugins/cordova-plugin-console/package.json | 18 +- .../plugins/cordova-plugin-console/plugin.xml | 53 +- .../cordova-plugin-console/src/ios/CDVLogger.h | 0 .../cordova-plugin-console/src/ios/CDVLogger.m | 0 .../cordova-plugin-console/src/ubuntu/console.cpp | 0 .../cordova-plugin-console/src/ubuntu/console.h | 0 .../cordova-plugin-console/src/wp/DebugConsole.cs | 0 .../cordova-plugin-console/tests/plugin.xml | 2 +- .../plugins/cordova-plugin-console/tests/tests.js | 12 +- .../www/console-via-logger.js | 1 - .../plugins/cordova-plugin-console/www/logger.js | 1 - .../LaunchMyApp-PhoneGap-Plugin.iws | 1242 -------------- .../cordova-plugin-customurlscheme/README.md | 41 +- .../atlassian-ide-plugin.xml | 5 - .../cordova-plugin-customurlscheme/package.json | 4 +- .../cordova-plugin-customurlscheme/plugin.xml | 52 +- .../android/nl/xservices/plugins/LaunchMyApp.java | 49 +- .../src/windows/hooks/prepare-manifest.js | 30 + .../src/wp8/CompositeUriMapper.cs | 46 + .../src/wp8/CustomUriMapperCommand.cs | 9 + .../src/wp8/ICustomUriMapper.cs | 7 + .../src/wp8/hooks/add-uri-mapper.js | 80 + .../www/android/LaunchMyApp.js | 26 +- .../www/wp8/LaunchMyApp.js | 12 + .../plugins/cordova-plugin-device/CONTRIBUTING.md | 2 +- StoneIsland/plugins/cordova-plugin-device/LICENSE | 0 StoneIsland/plugins/cordova-plugin-device/NOTICE | 0 .../plugins/cordova-plugin-device/README.md | 221 ++- .../plugins/cordova-plugin-device/RELEASENOTES.md | 182 ++- .../plugins/cordova-plugin-device/doc/de/README.md | 0 .../plugins/cordova-plugin-device/doc/de/index.md | 0 .../plugins/cordova-plugin-device/doc/es/README.md | 0 .../plugins/cordova-plugin-device/doc/es/index.md | 0 .../plugins/cordova-plugin-device/doc/fr/README.md | 0 .../plugins/cordova-plugin-device/doc/fr/index.md | 0 .../plugins/cordova-plugin-device/doc/it/README.md | 0 .../plugins/cordova-plugin-device/doc/it/index.md | 0 .../plugins/cordova-plugin-device/doc/ja/README.md | 0 .../plugins/cordova-plugin-device/doc/ja/index.md | 0 .../plugins/cordova-plugin-device/doc/ko/README.md | 0 .../plugins/cordova-plugin-device/doc/ko/index.md | 0 .../plugins/cordova-plugin-device/doc/pl/README.md | 0 .../plugins/cordova-plugin-device/doc/pl/index.md | 0 .../plugins/cordova-plugin-device/doc/ru/index.md | 0 .../plugins/cordova-plugin-device/doc/zh/README.md | 0 .../plugins/cordova-plugin-device/doc/zh/index.md | 0 .../plugins/cordova-plugin-device/package.json | 24 +- .../plugins/cordova-plugin-device/plugin.xml | 15 +- .../cordova-plugin-device/src/android/Device.java | 19 +- .../src/blackberry10/index.js | 2 + .../src/browser/DeviceProxy.js | 2 +- .../src/firefoxos/DeviceProxy.js | 2 - .../cordova-plugin-device/src/ios/CDVDevice.h | 0 .../cordova-plugin-device/src/ios/CDVDevice.m | 51 +- .../cordova-plugin-device/src/osx/CDVDevice.h | 28 + .../cordova-plugin-device/src/osx/CDVDevice.m | 113 ++ .../cordova-plugin-device/src/tizen/DeviceProxy.js | 1 - .../cordova-plugin-device/src/ubuntu/device.cpp | 0 .../cordova-plugin-device/src/ubuntu/device.h | 0 .../cordova-plugin-device/src/ubuntu/device.js | 3 +- .../src/windows/DeviceProxy.js | 68 +- .../plugins/cordova-plugin-device/src/wp/Device.cs | 100 +- .../plugins/cordova-plugin-device/tests/plugin.xml | 2 +- .../plugins/cordova-plugin-device/tests/tests.js | 34 +- .../plugins/cordova-plugin-device/www/device.js | 4 + .../plugins/cordova-plugin-dialogs/CONTRIBUTING.md | 2 +- StoneIsland/plugins/cordova-plugin-dialogs/LICENSE | 0 StoneIsland/plugins/cordova-plugin-dialogs/NOTICE | 0 .../plugins/cordova-plugin-dialogs/README.md | 17 +- .../plugins/cordova-plugin-dialogs/RELEASENOTES.md | 221 +-- .../cordova-plugin-dialogs/doc/de/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/de/index.md | 0 .../cordova-plugin-dialogs/doc/es/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/es/index.md | 0 .../cordova-plugin-dialogs/doc/fr/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/fr/index.md | 0 .../cordova-plugin-dialogs/doc/it/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/it/index.md | 0 .../cordova-plugin-dialogs/doc/ja/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/ja/index.md | 0 .../cordova-plugin-dialogs/doc/ko/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/ko/index.md | 0 .../cordova-plugin-dialogs/doc/pl/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/pl/index.md | 0 .../plugins/cordova-plugin-dialogs/doc/ru/index.md | 0 .../cordova-plugin-dialogs/doc/zh/README.md | 0 .../plugins/cordova-plugin-dialogs/doc/zh/index.md | 0 .../plugins/cordova-plugin-dialogs/package.json | 18 +- .../plugins/cordova-plugin-dialogs/plugin.xml | 24 +- .../src/android/Notification.java | 50 +- .../src/blackberry10/index.js | 2 + .../src/firefoxos/notification.js | 9 +- .../src/ios/CDVNotification.bundle/beep.wav | Bin .../src/ios/CDVNotification.h | 0 .../src/ios/CDVNotification.m | 95 +- .../src/ubuntu/notification.cpp | 0 .../src/ubuntu/notification.h | 0 .../src/ubuntu/notification.qml | 0 .../src/windows/NotificationProxy.js | 94 +- .../cordova-plugin-dialogs/src/wp/Notification.cs | 0 .../src/wp/NotificationBox.xaml | 0 .../src/wp/NotificationBox.xaml.cs | 0 .../src/wp/notification-beep.wav | Bin .../cordova-plugin-dialogs/tests/plugin.xml | 2 +- .../plugins/cordova-plugin-dialogs/tests/tests.js | 61 +- .../www/android/notification.js | 0 .../www/blackberry10/beep.js | 32 +- .../www/blackberry10/notification-beep.wav | Bin .../www/browser/notification.js | 30 +- .../www/firefoxos/danger-press.png | Bin .../www/firefoxos/danger.png | Bin .../www/firefoxos/default.png | Bin .../www/firefoxos/gradient.png | Bin .../www/firefoxos/notification.css | 0 .../www/firefoxos/pattern.png | Bin .../www/firefoxos/recommend.png | Bin .../cordova-plugin-dialogs/www/notification.js | 62 +- .../www/windows/notification.css | 84 + .../cordova-plugin-geolocation/CONTRIBUTING.md | 2 +- .../plugins/cordova-plugin-geolocation/LICENSE | 0 .../plugins/cordova-plugin-geolocation/NOTICE | 0 .../plugins/cordova-plugin-geolocation/README.md | 479 +++++- .../cordova-plugin-geolocation/RELEASENOTES.md | 214 ++- .../cordova-plugin-geolocation/doc/de/README.md | 2 +- .../cordova-plugin-geolocation/doc/de/index.md | 2 +- .../cordova-plugin-geolocation/doc/es/README.md | 2 +- .../cordova-plugin-geolocation/doc/es/index.md | 2 +- .../cordova-plugin-geolocation/doc/fr/README.md | 2 +- .../cordova-plugin-geolocation/doc/fr/index.md | 2 +- .../cordova-plugin-geolocation/doc/it/README.md | 2 +- .../cordova-plugin-geolocation/doc/it/index.md | 2 +- .../cordova-plugin-geolocation/doc/ja/README.md | 2 +- .../cordova-plugin-geolocation/doc/ja/index.md | 0 .../cordova-plugin-geolocation/doc/ko/README.md | 2 +- .../cordova-plugin-geolocation/doc/ko/index.md | 2 +- .../cordova-plugin-geolocation/doc/pl/README.md | 2 +- .../cordova-plugin-geolocation/doc/pl/index.md | 0 .../cordova-plugin-geolocation/doc/ru/index.md | 0 .../cordova-plugin-geolocation/doc/zh/README.md | 2 +- .../cordova-plugin-geolocation/doc/zh/index.md | 2 +- .../cordova-plugin-geolocation/package.json | 18 +- .../plugins/cordova-plugin-geolocation/plugin.xml | 38 +- .../src/android/Geolocation.java | 107 ++ .../src/firefoxos/GeolocationProxy.js | 0 .../src/ios/CDVLocation.h | 0 .../src/ios/CDVLocation.m | 67 +- .../src/ubuntu/geolocation.cpp | 34 +- .../src/ubuntu/geolocation.h | 0 .../src/windows/GeolocationProxy.js | 180 +- .../src/wp/GeoLocation.cs | 0 .../cordova-plugin-geolocation/tests/plugin.xml | 3 +- .../cordova-plugin-geolocation/tests/tests.js | 289 ++-- .../cordova-plugin-geolocation/www/Coordinates.js | 0 .../cordova-plugin-geolocation/www/Position.js | 2 +- .../www/PositionError.js | 6 +- .../www/android/geolocation.js | 71 + .../www/blackberry10/GeolocationProxy.js | 0 .../cordova-plugin-geolocation/www/geolocation.js | 6 +- .../cordova-plugin-inappbrowser/CONTRIBUTING.md | 29 +- .../plugins/cordova-plugin-inappbrowser/LICENSE | 0 .../plugins/cordova-plugin-inappbrowser/NOTICE | 0 .../plugins/cordova-plugin-inappbrowser/README.md | 312 +++- .../cordova-plugin-inappbrowser/RELEASENOTES.md | 66 + .../cordova-plugin-inappbrowser/doc/de/README.md | 0 .../cordova-plugin-inappbrowser/doc/de/index.md | 0 .../cordova-plugin-inappbrowser/doc/es/README.md | 0 .../cordova-plugin-inappbrowser/doc/es/index.md | 0 .../cordova-plugin-inappbrowser/doc/fr/README.md | 0 .../cordova-plugin-inappbrowser/doc/fr/index.md | 0 .../cordova-plugin-inappbrowser/doc/it/README.md | 0 .../cordova-plugin-inappbrowser/doc/it/index.md | 0 .../cordova-plugin-inappbrowser/doc/ja/README.md | 0 .../cordova-plugin-inappbrowser/doc/ja/index.md | 0 .../cordova-plugin-inappbrowser/doc/ko/README.md | 0 .../cordova-plugin-inappbrowser/doc/ko/index.md | 0 .../cordova-plugin-inappbrowser/doc/pl/README.md | 0 .../cordova-plugin-inappbrowser/doc/pl/index.md | 0 .../cordova-plugin-inappbrowser/doc/ru/index.md | 0 .../cordova-plugin-inappbrowser/doc/zh/README.md | 0 .../cordova-plugin-inappbrowser/doc/zh/index.md | 0 .../cordova-plugin-inappbrowser/package.json | 25 +- .../plugins/cordova-plugin-inappbrowser/plugin.xml | 2 +- .../src/amazon/InAppBrowser.java | 0 .../src/amazon/InAppChromeClient.java | 0 .../src/android/InAppBrowser.java | 294 +++- .../src/android/InAppBrowserDialog.java | 1 - .../src/android/InAppChromeClient.java | 0 .../res/drawable-hdpi/ic_action_next_item.png | Bin .../res/drawable-hdpi/ic_action_previous_item.png | Bin .../android/res/drawable-hdpi/ic_action_remove.png | Bin .../res/drawable-mdpi/ic_action_next_item.png | Bin .../res/drawable-mdpi/ic_action_previous_item.png | Bin .../android/res/drawable-mdpi/ic_action_remove.png | Bin .../res/drawable-xhdpi/ic_action_next_item.png | Bin .../res/drawable-xhdpi/ic_action_previous_item.png | Bin .../res/drawable-xhdpi/ic_action_remove.png | Bin .../res/drawable-xxhdpi/ic_action_next_item.png | Bin .../drawable-xxhdpi/ic_action_previous_item.png | Bin .../res/drawable-xxhdpi/ic_action_remove.png | Bin .../src/blackberry10/README.md | 0 .../src/blackberry10/doc/de/README.md | 0 .../src/blackberry10/doc/es/README.md | 0 .../src/blackberry10/doc/fr/README.md | 0 .../src/blackberry10/doc/it/README.md | 0 .../src/blackberry10/doc/ja/README.md | 0 .../src/blackberry10/doc/ko/README.md | 0 .../src/blackberry10/doc/pl/README.md | 0 .../src/blackberry10/doc/zh/README.md | 0 .../src/browser/InAppBrowserProxy.js | 35 +- .../src/firefoxos/InAppBrowserProxy.js | 24 +- .../src/ios/CDVInAppBrowser.h | 1 - .../src/ios/CDVInAppBrowser.m | 86 +- .../src/ubuntu/InAppBrowser.qml | 0 .../src/ubuntu/InAppBrowser_escapeScript.js | 3 + .../src/ubuntu/close.png | Bin .../src/ubuntu/inappbrowser.cpp | 0 .../src/ubuntu/inappbrowser.h | 0 .../src/windows/InAppBrowserProxy.js | 442 ++--- .../src/wp/InAppBrowser.cs | 0 .../cordova-plugin-inappbrowser/tests/plugin.xml | 4 +- .../tests/resources/inject.css | 0 .../tests/resources/inject.html | 0 .../tests/resources/inject.js | 2 +- .../tests/resources/local.html | 0 .../tests/resources/local.pdf | Bin .../tests/resources/video.html | 3 + .../cordova-plugin-inappbrowser/tests/tests.js | 155 +- .../www/inappbrowser.css | 74 + .../www/inappbrowser.js | 155 +- .../www/windows8/InAppBrowserProxy.js | 5 - .../CONTRIBUTING.md | 2 +- .../cordova-plugin-network-information/LICENSE | 0 .../cordova-plugin-network-information/NOTICE | 0 .../cordova-plugin-network-information/README.md | 187 ++- .../RELEASENOTES.md | 181 +- .../doc/de/README.md | 0 .../doc/de/index.md | 0 .../doc/es/README.md | 0 .../doc/es/index.md | 0 .../doc/fr/README.md | 0 .../doc/fr/index.md | 0 .../doc/it/README.md | 0 .../doc/it/index.md | 0 .../doc/ja/README.md | 0 .../doc/ja/index.md | 0 .../doc/ko/README.md | 0 .../doc/ko/index.md | 0 .../doc/pl/README.md | 0 .../doc/pl/index.md | 0 .../doc/ru/index.md | 0 .../doc/zh/README.md | 0 .../doc/zh/index.md | 0 .../package.json | 18 +- .../cordova-plugin-network-information/plugin.xml | 12 +- .../src/android/NetworkManager.java | 72 +- .../src/blackberry10/index.js | 2 + .../src/browser/network.js | 48 + .../src/firefoxos/NetworkProxy.js | 7 +- .../src/ios/CDVConnection.h | 0 .../src/ios/CDVConnection.m | 31 +- .../src/ios/CDVReachability.h | 0 .../src/ios/CDVReachability.m | 6 + .../src/tizen/NetworkProxy.js | 3 +- .../src/ubuntu/network_information.cpp | 0 .../src/ubuntu/network_information.h | 0 .../src/windows/NetworkInfoProxy.js | 7 +- .../src/wp/NetworkStatus.cs | 0 .../tests/plugin.xml | 2 +- .../tests/tests.js | 3 + .../www/Connection.js | 0 .../www/browser/network.js | 92 -- .../www/network.js | 0 .../plugins/cordova-plugin-splashscreen/README.md | 223 ++- .../cordova-plugin-splashscreen/RELEASENOTES.md | 45 + .../cordova-plugin-splashscreen/package.json | 29 +- .../plugins/cordova-plugin-splashscreen/plugin.xml | 3 +- .../src/android/SplashScreen.java | 187 ++- .../src/blackberry10/index.js | 2 + .../src/browser/SplashScreenProxy.js | 6 +- .../src/ios/CDVSplashScreen.h | 2 + .../src/ios/CDVSplashScreen.m | 181 +- .../src/ios/CDVViewController+SplashScreen.m | 7 + .../src/tizen/SplashScreenProxy.js | 2 +- .../tests/ios/package.json | 8 +- .../cordova-plugin-splashscreen/tests/plugin.xml | 2 +- .../cordova-plugin-splashscreen/tests/tests.js | 8 +- .../www/windows/SplashScreenProxy.js | 48 +- .../cordova-plugin-whitelist/CONTRIBUTING.md | 2 +- .../plugins/cordova-plugin-whitelist/LICENSE | 0 .../plugins/cordova-plugin-whitelist/NOTICE | 0 .../plugins/cordova-plugin-whitelist/README.md | 69 +- .../cordova-plugin-whitelist/RELEASENOTES.md | 39 +- .../cordova-plugin-whitelist/doc/de/README.md | 148 ++ .../cordova-plugin-whitelist/doc/es/README.md | 148 ++ .../cordova-plugin-whitelist/doc/fr/README.md | 148 ++ .../cordova-plugin-whitelist/doc/it/README.md | 148 ++ .../cordova-plugin-whitelist/doc/ja/README.md | 148 ++ .../cordova-plugin-whitelist/doc/ko/README.md | 148 ++ .../cordova-plugin-whitelist/doc/pl/README.md | 148 ++ .../cordova-plugin-whitelist/doc/zh/README.md | 148 ++ .../plugins/cordova-plugin-whitelist/package.json | 28 +- .../plugins/cordova-plugin-whitelist/plugin.xml | 13 +- .../src/android/WhitelistPlugin.java | 4 +- .../src/ios/CDVNavigationWhitelistPlugin.h | 31 - .../src/ios/CDVNavigationWhitelistPlugin.m | 89 - .../plugins/cordova-plugin-whitelist/whitelist.js | 27 - .../plugins/cordova-plugin-x-socialsharing/MIT | 21 + .../cordova-plugin-x-socialsharing/README.md | 104 +- .../cordova-plugin-x-socialsharing/package.json | 4 +- .../cordova-plugin-x-socialsharing/plugin.xml | 7 +- .../screenshots/screenshot-android-share.png | Bin .../screenshots/screenshot-ios6-share.png | Bin .../screenshots/screenshot-ios7-ipad-share.png | Bin .../screenshots/screenshot-ios7-share.png | Bin .../screenshots/screenshot-wp8-share.jpg | Bin .../screenshots/screenshots-ios7-shareconfig.png | Bin .../nl/xservices/plugins/SocialSharing.java | 280 +++- .../src/ios/NSString+URLEncoding.h | 5 + .../src/ios/NSString+URLEncoding.m | 30 + .../src/ios/SocialSharing.h | 3 +- .../src/ios/SocialSharing.m | 157 +- .../src/windows/SocialSharingProxy.js | 86 +- .../src/wp8/SocialSharing.cs | 4 +- .../tests/plugin.xml | 0 .../cordova-plugin-x-socialsharing/tests/test.js | 2 +- .../www/SocialSharing.js | 17 +- StoneIsland/plugins/fetch.json | 78 +- StoneIsland/plugins/ionic-plugin-keyboard/LICENSE | 202 +++ .../plugins/ionic-plugin-keyboard/README.md | 128 ++ .../plugins/ionic-plugin-keyboard/package.json | 30 + .../plugins/ionic-plugin-keyboard/plugin.xml | 71 + .../src/android/IonicKeyboard.java | 130 ++ .../src/blackberry10/index.js | 125 ++ .../src/blackberry10/native/.cproject | 222 +++ .../src/blackberry10/native/.project | 76 + .../src/blackberry10/native/public/json/autolink.h | 19 + .../src/blackberry10/native/public/json/config.h | 43 + .../src/blackberry10/native/public/json/features.h | 42 + .../src/blackberry10/native/public/json/forwards.h | 39 + .../src/blackberry10/native/public/json/json.h | 10 + .../src/blackberry10/native/public/json/reader.h | 196 +++ .../src/blackberry10/native/public/json/value.h | 1069 ++++++++++++ .../src/blackberry10/native/public/json/writer.h | 174 ++ .../native/public/json_batchallocator.h | 125 ++ .../native/public/json_internalarray.inl | 448 +++++ .../native/public/json_internalmap.inl | 607 +++++++ .../src/blackberry10/native/public/json_reader.cpp | 892 ++++++++++ .../src/blackberry10/native/public/json_value.cpp | 1726 ++++++++++++++++++++ .../native/public/json_valueiterator.inl | 292 ++++ .../src/blackberry10/native/public/json_writer.cpp | 829 ++++++++++ .../src/blackberry10/native/public/plugin.cpp | 320 ++++ .../src/blackberry10/native/public/plugin.h | 70 + .../src/blackberry10/native/public/tokenizer.cpp | 222 +++ .../src/blackberry10/native/public/tokenizer.h | 55 + .../src/blackberry10/native/src/Logger.cpp | 104 ++ .../src/blackberry10/native/src/Logger.hpp | 49 + .../src/blackberry10/native/src/keyboard_js.cpp | 117 ++ .../src/blackberry10/native/src/keyboard_js.hpp | 42 + .../src/blackberry10/native/src/keyboard_ndk.cpp | 155 ++ .../src/blackberry10/native/src/keyboard_ndk.hpp | 71 + .../ionic-plugin-keyboard/src/ios/IonicKeyboard.h | 16 + .../ionic-plugin-keyboard/src/ios/IonicKeyboard.m | 176 ++ .../src/windows/KeyboardProxy.js | 37 + .../ionic-plugin-keyboard/www/android/keyboard.js | 60 + .../ionic-plugin-keyboard/www/browser/keyboard.js | 34 + .../ionic-plugin-keyboard/www/ios/keyboard.js | 40 + StoneIsland/plugins/ios.json | 29 +- .../plugins/phonegap-plugin-push/CHANGELOG.md | 215 --- .../plugins/phonegap-plugin-push/MIT-LICENSE | 20 - StoneIsland/plugins/phonegap-plugin-push/README.md | 694 -------- .../phonegap-plugin-push/example/www/beep.wav | Bin 11400 -> 0 bytes .../phonegap-plugin-push/example/www/css/index.css | 115 -- .../example/www/css/materialize.min.css | 16 - .../www/font/material-design-icons/LICENSE.txt | 428 ----- .../Material-Design-Icons.eot | Bin 141748 -> 0 bytes .../Material-Design-Icons.svg | 751 --------- .../Material-Design-Icons.ttf | Bin 141528 -> 0 bytes .../Material-Design-Icons.woff | Bin 141604 -> 0 bytes .../Material-Design-Icons.woff2 | Bin 37396 -> 0 bytes .../example/www/font/roboto/Roboto-Bold.ttf | Bin 127744 -> 0 bytes .../example/www/font/roboto/Roboto-Bold.woff | Bin 62876 -> 0 bytes .../example/www/font/roboto/Roboto-Bold.woff2 | Bin 49976 -> 0 bytes .../example/www/font/roboto/Roboto-Light.ttf | Bin 126792 -> 0 bytes .../example/www/font/roboto/Roboto-Light.woff | Bin 62316 -> 0 bytes .../example/www/font/roboto/Roboto-Light.woff2 | Bin 49380 -> 0 bytes .../example/www/font/roboto/Roboto-Medium.ttf | Bin 127488 -> 0 bytes .../example/www/font/roboto/Roboto-Medium.woff | Bin 62980 -> 0 bytes .../example/www/font/roboto/Roboto-Medium.woff2 | Bin 50224 -> 0 bytes .../example/www/font/roboto/Roboto-Regular.ttf | Bin 126072 -> 0 bytes .../example/www/font/roboto/Roboto-Regular.woff | Bin 61736 -> 0 bytes .../example/www/font/roboto/Roboto-Regular.woff2 | Bin 49236 -> 0 bytes .../example/www/font/roboto/Roboto-Thin.ttf | Bin 127584 -> 0 bytes .../example/www/font/roboto/Roboto-Thin.woff | Bin 61628 -> 0 bytes .../example/www/font/roboto/Roboto-Thin.woff2 | Bin 48524 -> 0 bytes .../phonegap-plugin-push/example/www/index.html | 56 - .../phonegap-plugin-push/example/www/js/index.js | 77 - .../example/www/js/jquery-2.1.1.min.js | 4 - .../example/www/js/materialize.min.js | 10 - .../plugins/phonegap-plugin-push/package.json | 48 - .../plugins/phonegap-plugin-push/plugin.xml | 127 -- .../plugins/phonegap-plugin-push/push.gradle | 21 - .../phonegap-plugin-push/spec/helper/cordova.js | 83 - .../phonegap-plugin-push/spec/index.spec.js | 210 --- .../com/adobe/phonegap/push/GCMIntentService.java | 603 ------- .../com/adobe/phonegap/push/PushConstants.java | 53 - .../adobe/phonegap/push/PushHandlerActivity.java | 70 - .../push/PushInstanceIDListenerService.java | 27 - .../com/adobe/phonegap/push/PushPlugin.java | 294 ---- .../phonegap/push/RegistrationIntentService.java | 42 - .../src/ios/AppDelegate+notification.h | 21 - .../src/ios/AppDelegate+notification.m | 167 -- .../phonegap-plugin-push/src/ios/PushPlugin.h | 62 - .../phonegap-plugin-push/src/ios/PushPlugin.m | 347 ---- .../src/windows/PushPluginProxy.js | 86 - .../plugins/phonegap-plugin-push/www/push.js | 230 --- 482 files changed, 16434 insertions(+), 17394 deletions(-) delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/LICENSE delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/README.md delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/package.json delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/plugin.xml delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/android/IonicKeyboard.java delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/index.js delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.cproject delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.project delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/autolink.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/config.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/features.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/forwards.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/json.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/reader.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/value.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/writer.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_batchallocator.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalarray.inl delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalmap.inl delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_reader.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_value.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_valueiterator.inl delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_writer.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.hpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.hpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.cpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.hpp delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.m delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.h delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.m delete mode 100755 StoneIsland/plugins/com.ionic.keyboard/www/keyboard.js create mode 100644 StoneIsland/plugins/cordova-plugin-compat/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-compat/RELEASENOTES.md create mode 100644 StoneIsland/plugins/cordova-plugin-compat/package.json create mode 100644 StoneIsland/plugins/cordova-plugin-compat/plugin.xml create mode 100644 StoneIsland/plugins/cordova-plugin-compat/src/android/BuildHelper.java create mode 100644 StoneIsland/plugins/cordova-plugin-compat/src/android/PermissionHelper.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/RELEASENOTES.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/de/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/es/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/fr/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/it/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/ja/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/ko/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/pl/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/ru/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/doc/zh/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/src/ios/CDVLogger.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/src/ios/CDVLogger.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/src/ubuntu/console.cpp mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/src/ubuntu/console.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/src/wp/DebugConsole.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/tests/tests.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/www/console-via-logger.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-console/www/logger.js delete mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws delete mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/src/windows/hooks/prepare-manifest.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CustomUriMapperCommand.cs create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/ICustomUriMapper.cs create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/hooks/add-uri-mapper.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/www/wp8/LaunchMyApp.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/de/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/es/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/fr/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/it/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/ja/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/ko/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/pl/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/ru/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/doc/zh/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/android/Device.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m create mode 100644 StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h create mode 100644 StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/tests/tests.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-device/www/device.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/RELEASENOTES.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/de/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/es/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/fr/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/it/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/ja/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/ko/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/pl/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/ru/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/doc/zh/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/android/Notification.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/blackberry10/index.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.bundle/beep.wav mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.cpp mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.qml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/wp/Notification.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/wp/NotificationBox.xaml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/wp/NotificationBox.xaml.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/src/wp/notification-beep.wav mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/tests/tests.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/android/notification.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/notification-beep.wav mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/browser/notification.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/danger-press.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/danger.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/default.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/gradient.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/notification.css mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/pattern.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/recommend.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/notification.js create mode 100644 StoneIsland/plugins/cordova-plugin-dialogs/www/windows/notification.css mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/ru/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml create mode 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/android/Geolocation.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/firefoxos/GeolocationProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/src/wp/GeoLocation.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/www/Coordinates.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js create mode 100644 StoneIsland/plugins/cordova-plugin-geolocation/www/android/geolocation.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/www/blackberry10/GeolocationProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ru/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.css mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.html mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.html mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js create mode 100644 StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js delete mode 100755 StoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-network-information/www/network.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/RELEASENOTES.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/de/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/es/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/fr/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/it/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/ja/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/ko/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/pl/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-whitelist/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java delete mode 100755 StoneIsland/plugins/cordova-plugin-whitelist/src/ios/CDVNavigationWhitelistPlugin.h delete mode 100755 StoneIsland/plugins/cordova-plugin-whitelist/src/ios/CDVNavigationWhitelistPlugin.m delete mode 100755 StoneIsland/plugins/cordova-plugin-whitelist/whitelist.js create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.h create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/SocialSharing.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/SocialSharing.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/SocialSharing.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/LICENSE create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/README.md create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/package.json create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/plugin.xml create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/android/IonicKeyboard.java create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/index.js create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/.cproject create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/.project create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/autolink.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/config.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/features.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/forwards.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/json.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/reader.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/value.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json/writer.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json_batchallocator.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json_internalarray.inl create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json_internalmap.inl create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json_reader.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json_value.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json_valueiterator.inl create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/json_writer.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/plugin.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/plugin.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/tokenizer.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/tokenizer.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/src/Logger.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/src/Logger.hpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/src/keyboard_js.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/src/keyboard_js.hpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/src/keyboard_ndk.cpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/blackberry10/native/src/keyboard_ndk.hpp create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/ios/IonicKeyboard.h create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/ios/IonicKeyboard.m create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/src/windows/KeyboardProxy.js create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/www/android/keyboard.js create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/www/browser/keyboard.js create mode 100644 StoneIsland/plugins/ionic-plugin-keyboard/www/ios/keyboard.js delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/CHANGELOG.md delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/MIT-LICENSE delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/README.md delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/beep.wav delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/css/index.css delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/css/materialize.min.css delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/material-design-icons/LICENSE.txt delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/material-design-icons/Material-Design-Icons.eot delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/material-design-icons/Material-Design-Icons.svg delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/material-design-icons/Material-Design-Icons.ttf delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/material-design-icons/Material-Design-Icons.woff delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/material-design-icons/Material-Design-Icons.woff2 delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Bold.ttf delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Bold.woff delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Bold.woff2 delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Light.ttf delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Light.woff delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Light.woff2 delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Medium.ttf delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Medium.woff delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Medium.woff2 delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Regular.ttf delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Regular.woff delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Regular.woff2 delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Thin.ttf delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Thin.woff delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/font/roboto/Roboto-Thin.woff2 delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/index.html delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/js/index.js delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/js/jquery-2.1.1.min.js delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/example/www/js/materialize.min.js delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/package.json delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/plugin.xml delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/push.gradle delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/spec/helper/cordova.js delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/spec/index.spec.js delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/GCMIntentService.java delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushConstants.java delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushHandlerActivity.java delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.java delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/PushPlugin.java delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.h delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/ios/AppDelegate+notification.m delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.h delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/ios/PushPlugin.m delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/src/windows/PushPluginProxy.js delete mode 100755 StoneIsland/plugins/phonegap-plugin-push/www/push.js (limited to 'StoneIsland/plugins') diff --git a/StoneIsland/plugins/android.json b/StoneIsland/plugins/android.json index 8747af08..3e0b601f 100755 --- a/StoneIsland/plugins/android.json +++ b/StoneIsland/plugins/android.json @@ -7,48 +7,52 @@ "files": {} }, "installed_plugins": { - "com.ionic.keyboard": { - "PACKAGE_NAME": "us.okfoc.stoneisland" - }, "com.parse.cordova.core.pushplugin": { "APP_ID": "GS82ZxpN8Mecpc53rsyu6aLLGK0W4CKi42J25DLB", "CLIENT_KEY": "hQRtQfsgimYnX5PMivtcdXCG9eZhESeyTr0Rd8Sv", "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-console": { + "cordova-plugin-inappbrowser": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-customurlscheme": { - "URL_SCHEME": "stoneisland", + "cordova-plugin-x-socialsharing": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-device": { + "cordova-plugin-customurlscheme": { + "URL_SCHEME": "stoneisland", + "ANDROID_SCHEME": " ", + "ANDROID_HOST": " ", + "ANDROID_PATHPREFIX": "/", "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-dialogs": { + "cordova-plugin-whitelist": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-geolocation": { + "cordova-plugin-console": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-inappbrowser": { + "cordova-plugin-device": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, "cordova-plugin-network-information": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-splashscreen": { + "cordova-plugin-dialogs": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-whitelist": { + "cordova-plugin-splashscreen": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "cordova-plugin-x-socialsharing": { + "cordova-plugin-geolocation": { "PACKAGE_NAME": "us.okfoc.stoneisland" }, - "phonegap-plugin-push": { + "ionic-plugin-keyboard": { "PACKAGE_NAME": "us.okfoc.stoneisland" } }, - "dependent_plugins": {} + "dependent_plugins": { + "cordova-plugin-compat": { + "PACKAGE_NAME": "us.okfoc.stoneisland" + } + } } \ No newline at end of file diff --git a/StoneIsland/plugins/com.ionic.keyboard/LICENSE b/StoneIsland/plugins/com.ionic.keyboard/LICENSE deleted file mode 100755 index d6f545b8..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2014 Drifty Co. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/StoneIsland/plugins/com.ionic.keyboard/README.md b/StoneIsland/plugins/com.ionic.keyboard/README.md deleted file mode 100755 index 63f70012..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/README.md +++ /dev/null @@ -1,123 +0,0 @@ -Keyboard -====== - -The `cordova.plugins.Keyboard` object provides functions to make interacting with the keyboard easier, and fires events to indicate that the keyboard will hide/show. - - cordova plugin add com.ionic.keyboard - -Methods -------- - -- cordova.plugins.Keyboard.hideKeyboardAccessoryBar -- cordova.plugins.Keyboard.close -- cordova.plugins.Keyboard.disableScroll -- cordova.plugins.Keyboard.show - -Properties --------- - -- cordova.plugins.Keyboard.isVisible - -Events --------- - -These events are fired on the window. - -- native.keyboardshow - * A number `keyboardHeight` is given on the event object, which is the pixel height of the keyboard. -- native.keyboardhide - -Keyboard.hideKeyboardAccessoryBar -================= - -Hide the keyboard accessory bar with the next, previous and done buttons. - - cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); - cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); - -Supported Platforms -------------------- - -- iOS - - -Keyboard.close -================= - -Close the keyboard if it is open. - - cordova.plugins.Keyboard.close(); - -Supported Platforms -------------------- - -- iOS, Android, Blackberry 10 - - -Keyboard.disableScroll -================= - -Disable native scrolling, useful if you are using JavaScript to scroll - - cordova.plugins.Keyboard.disableScroll(true); - cordova.plugins.Keyboard.disableScroll(false); - -Supported Platforms -------------------- - -- iOS - -Keyboard.show -================= - -Force keyboard to be shown on Android. This typically helps if autofocus on a text element does not pop up the keyboard automatically - - cordova.plugins.Keyboard.show(); - -Supported Platforms - -- Android, Blackberry 10 - -native.keyboardshow -================= - -This event fires when the keyboard will be shown - - window.addEventListener('native.keyboardshow', keyboardShowHandler); - - function keyboardShowHandler(e){ - alert('Keyboard height is: ' + e.keyboardHeight); - } - -Properties ------------ - -keyboardHeight: the height of the keyboard in pixels - - -Supported Platforms -------------------- - -- iOS, Android, Blackberry 10 - - -native.keyboardhide -================= - -This event fires when the keyboard will hide - - window.addEventListener('native.keyboardhide', keyboardHideHandler); - - function keyboardHideHandler(e){ - alert('Goodnight, sweet prince'); - } - -Properties ------------ - -None - -Supported Platforms -------------------- - -- iOS, Android, Blackberry 10 diff --git a/StoneIsland/plugins/com.ionic.keyboard/package.json b/StoneIsland/plugins/com.ionic.keyboard/package.json deleted file mode 100755 index 4dd54150..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "1.0.4", - "name": "com.ionic.keyboard", - "cordova_name": "Keyboard", - "description": "Ionic Keyboard Plugin", - "license": "Apache 2.0", - "repo": "https://github.com/driftyco/ionic-plugins-keyboard.git", - "issue": "https://github.com/driftyco/ionic-plugins-keyboard/issues", - "keywords": [ - "Ionic", - "keyboard" - ], - "platforms": [ - "android", - "ios", - "blackberry10" - ], - "engines": [] -} \ No newline at end of file diff --git a/StoneIsland/plugins/com.ionic.keyboard/plugin.xml b/StoneIsland/plugins/com.ionic.keyboard/plugin.xml deleted file mode 100755 index 06688915..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/plugin.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - Keyboard - Ionic Keyboard Plugin - Apache 2.0 - Ionic,keyboard - https://github.com/driftyco/ionic-plugins-keyboard.git - https://github.com/driftyco/ionic-plugins-keyboard/issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/android/IonicKeyboard.java b/StoneIsland/plugins/com.ionic.keyboard/src/android/IonicKeyboard.java deleted file mode 100755 index deb914ab..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/android/IonicKeyboard.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.ionic.keyboard; - -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaInterface; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CordovaWebView; -import org.apache.cordova.PluginResult.Status; -import org.json.JSONArray; -import org.json.JSONException; - -import android.content.Context; -import android.graphics.Rect; -import android.util.DisplayMetrics; -import android.view.View; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; -import android.view.inputmethod.InputMethodManager; - -public class IonicKeyboard extends CordovaPlugin{ - - public void initialize(CordovaInterface cordova, CordovaWebView webView) { - super.initialize(cordova, webView); - - //calculate density-independent pixels (dp) - //http://developer.android.com/guide/practices/screens_support.html - DisplayMetrics dm = new DisplayMetrics(); - cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); - final float density = dm.density; - - final CordovaWebView appView = webView; - - //http://stackoverflow.com/a/4737265/1091751 detect if keyboard is showing - final View rootView = cordova.getActivity().getWindow().getDecorView().findViewById(android.R.id.content).getRootView(); - OnGlobalLayoutListener list = new OnGlobalLayoutListener() { - int previousHeightDiff = 0; - @Override - public void onGlobalLayout() { - Rect r = new Rect(); - //r will be populated with the coordinates of your view that area still visible. - rootView.getWindowVisibleDisplayFrame(r); - - int heightDiff = rootView.getRootView().getHeight() - (r.bottom - r.top); - int pixelHeightDiff = (int)(heightDiff / density); - if (pixelHeightDiff > 100 && pixelHeightDiff != previousHeightDiff) { // if more than 100 pixels, its probably a keyboard... - appView.sendJavascript("cordova.plugins.Keyboard.isVisible = true"); - appView.sendJavascript("cordova.fireWindowEvent('native.keyboardshow', { 'keyboardHeight':" + Integer.toString(pixelHeightDiff)+"});"); - - //deprecated - appView.sendJavascript("cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight':" + Integer.toString(pixelHeightDiff)+"});"); - } - else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelHeightDiff ) > 100 ){ - appView.sendJavascript("cordova.plugins.Keyboard.isVisible = false"); - appView.sendJavascript("cordova.fireWindowEvent('native.keyboardhide')"); - - //deprecated - appView.sendJavascript("cordova.fireWindowEvent('native.hidekeyboard')"); - } - previousHeightDiff = pixelHeightDiff; - } - }; - - rootView.getViewTreeObserver().addOnGlobalLayoutListener(list); - } - - public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - if ("close".equals(action)) { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - //http://stackoverflow.com/a/7696791/1091751 - InputMethodManager inputManager = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); - View v = cordova.getActivity().getCurrentFocus(); - - if (v == null) { - callbackContext.error("No current focus"); - } else { - inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); - callbackContext.success(); // Thread-safe. - } - } - }); - return true; - } - if ("show".equals(action)) { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - ((InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); - callbackContext.success(); // Thread-safe. - } - }); - return true; - } - return false; // Returning false results in a "MethodNotFound" error. - } - - -} - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/index.js b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/index.js deleted file mode 100755 index 40294158..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/index.js +++ /dev/null @@ -1,135 +0,0 @@ - - -var keyboard, - resultObjs = {}, - threadCallback = null, - _utils = require("../../lib/utils"); - _event = require("../../lib/event"); - _webview = require("../../lib/webview"); - - - - -module.exports = { - - // Code can be declared and used outside the module.exports object, - // but any functions to be called by client.js need to be declared - // here in this object. - - // These methods call into JNEXT.Keyboard which handles the - // communication through the JNEXT plugin to keyboard_js.cpp - startService: function (success, fail, args, env) { - var result = new PluginResult(args, env); - - result.ok(keyboard.getInstance().startService(), false); - }, - show: function (success, fail, args, env) { - var result = new PluginResult(args, env); - - result.ok(keyboard.getInstance().showKeyboard(), false); - }, - close: function (success, fail, args, env) { - var result = new PluginResult(args, env); - - result.ok(keyboard.getInstance().closeKeyboard(), false); - } -}; - -keyboardShow = function(a){ - _webview.executeJavascript("cordova.plugins.Keyboard.isVisible = true"); - _webview.executeJavascript("cordova.fireDocumentEvent('native.keyboardshow',"+a+")"); - -} -keyboardHide = function(){ - _webview.executeJavascript("cordova.plugins.Keyboard.isVisible = false"); - _webview.executeJavascript("cordova.fireDocumentEvent('native.keyboardhide','')"); - -} -onStart = function() { - _webview.executeJavascript("cordova.exec("+null+", "+null+", 'Keyboard', 'startService', '')"); - } - -setTimeout(onStart,2000); - -/////////////////////////////////////////////////////////////////// -// JavaScript wrapper for JNEXT plugin for connection -/////////////////////////////////////////////////////////////////// - -JNEXT.Keyboard = function () { - var self = this, - hasInstance = false; - - self.getId = function () { - return self.m_id; - }; - - self.init = function () { - if (!JNEXT.require("libKeyboard")) { - return false; - } - - self.m_id = JNEXT.createObject("libKeyboard.Keyboard_JS"); - - if (self.m_id === "") { - return false; - } - - JNEXT.registerEvents(self); - }; - - // ************************ - // Enter your methods here - // ************************ - - // calls into InvokeMethod(string command) in keyboard_js.cpp - self.startService = function () { - return JNEXT.invoke(self.m_id, "startService"); - }; - self.showKeyboard = function () { - return JNEXT.invoke(self.m_id, "showKeyboard"); - }; - self.closeKeyboard = function () { - return JNEXT.invoke(self.m_id, "closeKeyboard"); - }; - - self.onEvent = function (strData) { // Fired by the Event framework (used by asynchronous callbacks) - var arData = strData.split(" "), - strEventDesc = arData[0], - jsonData; - - if (strEventDesc === "native.keyboardshow") { - jsonData = arData.slice(1, arData.length).join(" "); - keyboardShow(jsonData); - - } - else if (strEventDesc === "native.keyboardhide") { - keyboardHide(); - } - - }; - - // Thread methods - self.keyboardStartThread = function (callbackId) { - return JNEXT.invoke(self.m_id, "keyboardStartThread " + callbackId); - }; - self.keyboardStopThread = function () { - return JNEXT.invoke(self.m_id, "keyboardStopThread"); - }; - - // ************************ - // End of methods to edit - // ************************ - self.m_id = ""; - - self.getInstance = function () { - if (!hasInstance) { - hasInstance = true; - self.init(); - } - return self; - }; - -}; - -keyboard = new JNEXT.Keyboard(); - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.cproject b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.cproject deleted file mode 100755 index 7b118eec..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.cproject +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.project b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.project deleted file mode 100755 index 8a39f221..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/.project +++ /dev/null @@ -1,76 +0,0 @@ - - - Keyboard - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/Keyboard/Device-Release} - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - com.qnx.tools.bbt.xml.core.bbtXMLValidationBuilder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - com.qnx.tools.ide.bbt.core.bbtnature - - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/autolink.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/autolink.h deleted file mode 100755 index 37c9258e..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/autolink.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef JSON_AUTOLINK_H_INCLUDED -# define JSON_AUTOLINK_H_INCLUDED - -# include "config.h" - -# ifdef JSON_IN_CPPTL -# include -# endif - -# if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL) -# define CPPTL_AUTOLINK_NAME "json" -# undef CPPTL_AUTOLINK_DLL -# ifdef JSON_DLL -# define CPPTL_AUTOLINK_DLL -# endif -# include "autolink.h" -# endif - -#endif // JSON_AUTOLINK_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/config.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/config.h deleted file mode 100755 index 5d334cbc..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/config.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef JSON_CONFIG_H_INCLUDED -# define JSON_CONFIG_H_INCLUDED - -/// If defined, indicates that json library is embedded in CppTL library. -//# define JSON_IN_CPPTL 1 - -/// If defined, indicates that json may leverage CppTL library -//# define JSON_USE_CPPTL 1 -/// If defined, indicates that cpptl vector based map should be used instead of std::map -/// as Value container. -//# define JSON_USE_CPPTL_SMALLMAP 1 -/// If defined, indicates that Json specific container should be used -/// (hash table & simple deque container with customizable allocator). -/// THIS FEATURE IS STILL EXPERIMENTAL! -//# define JSON_VALUE_USE_INTERNAL_MAP 1 -/// Force usage of standard new/malloc based allocator instead of memory pool based allocator. -/// The memory pools allocator used optimization (initializing Value and ValueInternalLink -/// as if it was a POD) that may cause some validation tool to report errors. -/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined. -//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1 - -/// If defined, indicates that Json use exception to report invalid type manipulation -/// instead of C assert macro. -# define JSON_USE_EXCEPTION 1 - -# ifdef JSON_IN_CPPTL -# include -# ifndef JSON_USE_CPPTL -# define JSON_USE_CPPTL 1 -# endif -# endif - -# ifdef JSON_IN_CPPTL -# define JSON_API CPPTL_API -# elif defined(JSON_DLL_BUILD) -# define JSON_API __declspec(dllexport) -# elif defined(JSON_DLL) -# define JSON_API __declspec(dllimport) -# else -# define JSON_API -# endif - -#endif // JSON_CONFIG_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/features.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/features.h deleted file mode 100755 index 5a9adec1..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/features.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef CPPTL_JSON_FEATURES_H_INCLUDED -# define CPPTL_JSON_FEATURES_H_INCLUDED - -# include "forwards.h" - -namespace Json { - - /** \brief Configuration passed to reader and writer. - * This configuration object can be used to force the Reader or Writer - * to behave in a standard conforming way. - */ - class JSON_API Features - { - public: - /** \brief A configuration that allows all features and assumes all strings are UTF-8. - * - C & C++ comments are allowed - * - Root object can be any JSON value - * - Assumes Value strings are encoded in UTF-8 - */ - static Features all(); - - /** \brief A configuration that is strictly compatible with the JSON specification. - * - Comments are forbidden. - * - Root object must be either an array or an object value. - * - Assumes Value strings are encoded in UTF-8 - */ - static Features strictMode(); - - /** \brief Initialize the configuration like JsonConfig::allFeatures; - */ - Features(); - - /// \c true if comments are allowed. Default: \c true. - bool allowComments_; - - /// \c true if root must be either an array or an object value. Default: \c false. - bool strictRoot_; - }; - -} // namespace Json - -#endif // CPPTL_JSON_FEATURES_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/forwards.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/forwards.h deleted file mode 100755 index d0ce8300..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/forwards.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef JSON_FORWARDS_H_INCLUDED -# define JSON_FORWARDS_H_INCLUDED - -# include "config.h" - -namespace Json { - - // writer.h - class FastWriter; - class StyledWriter; - - // reader.h - class Reader; - - // features.h - class Features; - - // value.h - typedef int Int; - typedef unsigned int UInt; - class StaticString; - class Path; - class PathArgument; - class Value; - class ValueIteratorBase; - class ValueIterator; - class ValueConstIterator; -#ifdef JSON_VALUE_USE_INTERNAL_MAP - class ValueAllocator; - class ValueMapAllocator; - class ValueInternalLink; - class ValueInternalArray; - class ValueInternalMap; -#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP - -} // namespace Json - - -#endif // JSON_FORWARDS_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/json.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/json.h deleted file mode 100755 index c71ed65a..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/json.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef JSON_JSON_H_INCLUDED -# define JSON_JSON_H_INCLUDED - -# include "autolink.h" -# include "value.h" -# include "reader.h" -# include "writer.h" -# include "features.h" - -#endif // JSON_JSON_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/reader.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/reader.h deleted file mode 100755 index ee1d6a24..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/reader.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef CPPTL_JSON_READER_H_INCLUDED -# define CPPTL_JSON_READER_H_INCLUDED - -# include "features.h" -# include "value.h" -# include -# include -# include -# include - -namespace Json { - - /** \brief Unserialize a JSON document into a Value. - * - */ - class JSON_API Reader - { - public: - typedef char Char; - typedef const Char *Location; - - /** \brief Constructs a Reader allowing all features - * for parsing. - */ - Reader(); - - /** \brief Constructs a Reader allowing the specified feature set - * for parsing. - */ - Reader( const Features &features ); - - /** \brief Read a Value from a JSON document. - * \param document UTF-8 encoded string containing the document to read. - * \param root [out] Contains the root value of the document if it was - * successfully parsed. - * \param collectComments \c true to collect comment and allow writing them back during - * serialization, \c false to discard comments. - * This parameter is ignored if Features::allowComments_ - * is \c false. - * \return \c true if the document was successfully parsed, \c false if an error occurred. - */ - bool parse( const std::string &document, - Value &root, - bool collectComments = true ); - - /** \brief Read a Value from a JSON document. - * \param document UTF-8 encoded string containing the document to read. - * \param root [out] Contains the root value of the document if it was - * successfully parsed. - * \param collectComments \c true to collect comment and allow writing them back during - * serialization, \c false to discard comments. - * This parameter is ignored if Features::allowComments_ - * is \c false. - * \return \c true if the document was successfully parsed, \c false if an error occurred. - */ - bool parse( const char *beginDoc, const char *endDoc, - Value &root, - bool collectComments = true ); - - /// \brief Parse from input stream. - /// \see Json::operator>>(std::istream&, Json::Value&). - bool parse( std::istream &is, - Value &root, - bool collectComments = true ); - - /** \brief Returns a user friendly string that list errors in the parsed document. - * \return Formatted error message with the list of errors with their location in - * the parsed document. An empty string is returned if no error occurred - * during parsing. - */ - std::string getFormatedErrorMessages() const; - - private: - enum TokenType - { - tokenEndOfStream = 0, - tokenObjectBegin, - tokenObjectEnd, - tokenArrayBegin, - tokenArrayEnd, - tokenString, - tokenNumber, - tokenTrue, - tokenFalse, - tokenNull, - tokenArraySeparator, - tokenMemberSeparator, - tokenComment, - tokenError - }; - - class Token - { - public: - TokenType type_; - Location start_; - Location end_; - }; - - class ErrorInfo - { - public: - Token token_; - std::string message_; - Location extra_; - }; - - typedef std::deque Errors; - - bool expectToken( TokenType type, Token &token, const char *message ); - bool readToken( Token &token ); - void skipSpaces(); - bool match( Location pattern, - int patternLength ); - bool readComment(); - bool readCStyleComment(); - bool readCppStyleComment(); - bool readString(); - void readNumber(); - bool readValue(); - bool readObject( Token &token ); - bool readArray( Token &token ); - bool decodeNumber( Token &token ); - bool decodeString( Token &token ); - bool decodeString( Token &token, std::string &decoded ); - bool decodeDouble( Token &token ); - bool decodeUnicodeCodePoint( Token &token, - Location ¤t, - Location end, - unsigned int &unicode ); - bool decodeUnicodeEscapeSequence( Token &token, - Location ¤t, - Location end, - unsigned int &unicode ); - bool addError( const std::string &message, - Token &token, - Location extra = 0 ); - bool recoverFromError( TokenType skipUntilToken ); - bool addErrorAndRecover( const std::string &message, - Token &token, - TokenType skipUntilToken ); - void skipUntilSpace(); - Value ¤tValue(); - Char getNextChar(); - void getLocationLineAndColumn( Location location, - int &line, - int &column ) const; - std::string getLocationLineAndColumn( Location location ) const; - void addComment( Location begin, - Location end, - CommentPlacement placement ); - void skipCommentTokens( Token &token ); - - typedef std::stack Nodes; - Nodes nodes_; - Errors errors_; - std::string document_; - Location begin_; - Location end_; - Location current_; - Location lastValueEnd_; - Value *lastValue_; - std::string commentsBefore_; - Features features_; - bool collectComments_; - }; - - /** \brief Read from 'sin' into 'root'. - - Always keep comments from the input JSON. - - This can be used to read a file into a particular sub-object. - For example: - \code - Json::Value root; - cin >> root["dir"]["file"]; - cout << root; - \endcode - Result: - \verbatim - { - "dir": { - "file": { - // The input stream JSON would be nested here. - } - } - } - \endverbatim - \throw std::exception on parse error. - \see Json::operator<<() - */ - std::istream& operator>>( std::istream&, Value& ); - -} // namespace Json - -#endif // CPPTL_JSON_READER_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/value.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/value.h deleted file mode 100755 index 58bfd88e..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/value.h +++ /dev/null @@ -1,1069 +0,0 @@ -#ifndef CPPTL_JSON_H_INCLUDED -# define CPPTL_JSON_H_INCLUDED - -# include "forwards.h" -# include -# include - -# ifndef JSON_USE_CPPTL_SMALLMAP -# include -# else -# include -# endif -# ifdef JSON_USE_CPPTL -# include -# endif - -/** \brief JSON (JavaScript Object Notation). - */ -namespace Json { - - /** \brief Type of the value held by a Value object. - */ - enum ValueType - { - nullValue = 0, ///< 'null' value - intValue, ///< signed integer value - uintValue, ///< unsigned integer value - realValue, ///< double value - stringValue, ///< UTF-8 string value - booleanValue, ///< bool value - arrayValue, ///< array value (ordered list) - objectValue ///< object value (collection of name/value pairs). - }; - - enum CommentPlacement - { - commentBefore = 0, ///< a comment placed on the line before a value - commentAfterOnSameLine, ///< a comment just after a value on the same line - commentAfter, ///< a comment on the line after a value (only make sense for root value) - numberOfCommentPlacement - }; - -//# ifdef JSON_USE_CPPTL -// typedef CppTL::AnyEnumerator EnumMemberNames; -// typedef CppTL::AnyEnumerator EnumValues; -//# endif - - /** \brief Lightweight wrapper to tag static string. - * - * Value constructor and objectValue member assignement takes advantage of the - * StaticString and avoid the cost of string duplication when storing the - * string or the member name. - * - * Example of usage: - * \code - * Json::Value aValue( StaticString("some text") ); - * Json::Value object; - * static const StaticString code("code"); - * object[code] = 1234; - * \endcode - */ - class JSON_API StaticString - { - public: - explicit StaticString( const char *czstring ) - : str_( czstring ) - { - } - - operator const char *() const - { - return str_; - } - - const char *c_str() const - { - return str_; - } - - private: - const char *str_; - }; - - /** \brief Represents a JSON value. - * - * This class is a discriminated union wrapper that can represents a: - * - signed integer [range: Value::minInt - Value::maxInt] - * - unsigned integer (range: 0 - Value::maxUInt) - * - double - * - UTF-8 string - * - boolean - * - 'null' - * - an ordered list of Value - * - collection of name/value pairs (javascript object) - * - * The type of the held value is represented by a #ValueType and - * can be obtained using type(). - * - * values of an #objectValue or #arrayValue can be accessed using operator[]() methods. - * Non const methods will automatically create the a #nullValue element - * if it does not exist. - * The sequence of an #arrayValue will be automatically resize and initialized - * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue. - * - * The get() methods can be used to obtanis default value in the case the required element - * does not exist. - * - * It is possible to iterate over the list of a #objectValue values using - * the getMemberNames() method. - */ - class JSON_API Value - { - friend class ValueIteratorBase; -# ifdef JSON_VALUE_USE_INTERNAL_MAP - friend class ValueInternalLink; - friend class ValueInternalMap; -# endif - public: - typedef std::vector Members; - typedef ValueIterator iterator; - typedef ValueConstIterator const_iterator; - typedef Json::UInt UInt; - typedef Json::Int Int; - typedef UInt ArrayIndex; - - static const Value null; - static const Int minInt; - static const Int maxInt; - static const UInt maxUInt; - - private: -#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION -# ifndef JSON_VALUE_USE_INTERNAL_MAP - class CZString - { - public: - enum DuplicationPolicy - { - noDuplication = 0, - duplicate, - duplicateOnCopy - }; - CZString( int index ); - CZString( const char *cstr, DuplicationPolicy allocate ); - CZString( const CZString &other ); - ~CZString(); - CZString &operator =( const CZString &other ); - bool operator<( const CZString &other ) const; - bool operator==( const CZString &other ) const; - int index() const; - const char *c_str() const; - bool isStaticString() const; - private: - void swap( CZString &other ); - const char *cstr_; - int index_; - }; - - public: -# ifndef JSON_USE_CPPTL_SMALLMAP - typedef std::map ObjectValues; -# else - typedef CppTL::SmallMap ObjectValues; -# endif // ifndef JSON_USE_CPPTL_SMALLMAP -# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP -#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION - - public: - /** \brief Create a default Value of the given type. - - This is a very useful constructor. - To create an empty array, pass arrayValue. - To create an empty object, pass objectValue. - Another Value can then be set to this one by assignment. - This is useful since clear() and resize() will not alter types. - - Examples: - \code - Json::Value null_value; // null - Json::Value arr_value(Json::arrayValue); // [] - Json::Value obj_value(Json::objectValue); // {} - \endcode - */ - Value( ValueType type = nullValue ); - Value( Int value ); - Value( UInt value ); - Value( double value ); - Value( const char *value ); - Value( const char *beginValue, const char *endValue ); - /** \brief Constructs a value from a static string. - - * Like other value string constructor but do not duplicate the string for - * internal storage. The given string must remain alive after the call to this - * constructor. - * Example of usage: - * \code - * Json::Value aValue( StaticString("some text") ); - * \endcode - */ - Value( const StaticString &value ); - Value( const std::string &value ); -# ifdef JSON_USE_CPPTL - Value( const CppTL::ConstString &value ); -# endif - Value( bool value ); - Value( const Value &other ); - ~Value(); - - Value &operator=( const Value &other ); - /// Swap values. - /// \note Currently, comments are intentionally not swapped, for - /// both logic and efficiency. - void swap( Value &other ); - - ValueType type() const; - - bool operator <( const Value &other ) const; - bool operator <=( const Value &other ) const; - bool operator >=( const Value &other ) const; - bool operator >( const Value &other ) const; - - bool operator ==( const Value &other ) const; - bool operator !=( const Value &other ) const; - - int compare( const Value &other ); - - const char *asCString() const; - std::string asString() const; -# ifdef JSON_USE_CPPTL - CppTL::ConstString asConstString() const; -# endif - Int asInt() const; - UInt asUInt() const; - double asDouble() const; - bool asBool() const; - - bool isNull() const; - bool isBool() const; - bool isInt() const; - bool isUInt() const; - bool isIntegral() const; - bool isDouble() const; - bool isNumeric() const; - bool isString() const; - bool isArray() const; - bool isObject() const; - - bool isConvertibleTo( ValueType other ) const; - - /// Number of values in array or object - UInt size() const; - - /// \brief Return true if empty array, empty object, or null; - /// otherwise, false. - bool empty() const; - - /// Return isNull() - bool operator!() const; - - /// Remove all object members and array elements. - /// \pre type() is arrayValue, objectValue, or nullValue - /// \post type() is unchanged - void clear(); - - /// Resize the array to size elements. - /// New elements are initialized to null. - /// May only be called on nullValue or arrayValue. - /// \pre type() is arrayValue or nullValue - /// \post type() is arrayValue - void resize( UInt size ); - - /// Access an array element (zero based index ). - /// If the array contains less than index element, then null value are inserted - /// in the array so that its size is index+1. - /// (You may need to say 'value[0u]' to get your compiler to distinguish - /// this from the operator[] which takes a string.) - Value &operator[]( UInt index ); - /// Access an array element (zero based index ) - /// (You may need to say 'value[0u]' to get your compiler to distinguish - /// this from the operator[] which takes a string.) - const Value &operator[]( UInt index ) const; - /// If the array contains at least index+1 elements, returns the element value, - /// otherwise returns defaultValue. - Value get( UInt index, - const Value &defaultValue ) const; - /// Return true if index < size(). - bool isValidIndex( UInt index ) const; - /// \brief Append value to array at the end. - /// - /// Equivalent to jsonvalue[jsonvalue.size()] = value; - Value &append( const Value &value ); - - /// Access an object value by name, create a null member if it does not exist. - Value &operator[]( const char *key ); - /// Access an object value by name, returns null if there is no member with that name. - const Value &operator[]( const char *key ) const; - /// Access an object value by name, create a null member if it does not exist. - Value &operator[]( const std::string &key ); - /// Access an object value by name, returns null if there is no member with that name. - const Value &operator[]( const std::string &key ) const; - /** \brief Access an object value by name, create a null member if it does not exist. - - * If the object as no entry for that name, then the member name used to store - * the new entry is not duplicated. - * Example of use: - * \code - * Json::Value object; - * static const StaticString code("code"); - * object[code] = 1234; - * \endcode - */ - Value &operator[]( const StaticString &key ); -# ifdef JSON_USE_CPPTL - /// Access an object value by name, create a null member if it does not exist. - Value &operator[]( const CppTL::ConstString &key ); - /// Access an object value by name, returns null if there is no member with that name. - const Value &operator[]( const CppTL::ConstString &key ) const; -# endif - /// Return the member named key if it exist, defaultValue otherwise. - Value get( const char *key, - const Value &defaultValue ) const; - /// Return the member named key if it exist, defaultValue otherwise. - Value get( const std::string &key, - const Value &defaultValue ) const; -# ifdef JSON_USE_CPPTL - /// Return the member named key if it exist, defaultValue otherwise. - Value get( const CppTL::ConstString &key, - const Value &defaultValue ) const; -# endif - /// \brief Remove and return the named member. - /// - /// Do nothing if it did not exist. - /// \return the removed Value, or null. - /// \pre type() is objectValue or nullValue - /// \post type() is unchanged - Value removeMember( const char* key ); - /// Same as removeMember(const char*) - Value removeMember( const std::string &key ); - - /// Return true if the object has a member named key. - bool isMember( const char *key ) const; - /// Return true if the object has a member named key. - bool isMember( const std::string &key ) const; -# ifdef JSON_USE_CPPTL - /// Return true if the object has a member named key. - bool isMember( const CppTL::ConstString &key ) const; -# endif - - /// \brief Return a list of the member names. - /// - /// If null, return an empty list. - /// \pre type() is objectValue or nullValue - /// \post if type() was nullValue, it remains nullValue - Members getMemberNames() const; - -//# ifdef JSON_USE_CPPTL -// EnumMemberNames enumMemberNames() const; -// EnumValues enumValues() const; -//# endif - - /// Comments must be //... or /* ... */ - void setComment( const char *comment, - CommentPlacement placement ); - /// Comments must be //... or /* ... */ - void setComment( const std::string &comment, - CommentPlacement placement ); - bool hasComment( CommentPlacement placement ) const; - /// Include delimiters and embedded newlines. - std::string getComment( CommentPlacement placement ) const; - - std::string toStyledString() const; - - const_iterator begin() const; - const_iterator end() const; - - iterator begin(); - iterator end(); - - private: - Value &resolveReference( const char *key, - bool isStatic ); - -# ifdef JSON_VALUE_USE_INTERNAL_MAP - inline bool isItemAvailable() const - { - return itemIsUsed_ == 0; - } - - inline void setItemUsed( bool isUsed = true ) - { - itemIsUsed_ = isUsed ? 1 : 0; - } - - inline bool isMemberNameStatic() const - { - return memberNameIsStatic_ == 0; - } - - inline void setMemberNameIsStatic( bool isStatic ) - { - memberNameIsStatic_ = isStatic ? 1 : 0; - } -# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP - - private: - struct CommentInfo - { - CommentInfo(); - ~CommentInfo(); - - void setComment( const char *text ); - - char *comment_; - }; - - //struct MemberNamesTransform - //{ - // typedef const char *result_type; - // const char *operator()( const CZString &name ) const - // { - // return name.c_str(); - // } - //}; - - union ValueHolder - { - Int int_; - UInt uint_; - double real_; - bool bool_; - char *string_; -# ifdef JSON_VALUE_USE_INTERNAL_MAP - ValueInternalArray *array_; - ValueInternalMap *map_; -#else - ObjectValues *map_; -# endif - } value_; - ValueType type_ : 8; - int allocated_ : 1; // Notes: if declared as bool, bitfield is useless. -# ifdef JSON_VALUE_USE_INTERNAL_MAP - unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container. - int memberNameIsStatic_ : 1; // used by the ValueInternalMap container. -# endif - CommentInfo *comments_; - }; - - - /** \brief Experimental and untested: represents an element of the "path" to access a node. - */ - class PathArgument - { - public: - friend class Path; - - PathArgument(); - PathArgument( UInt index ); - PathArgument( const char *key ); - PathArgument( const std::string &key ); - - private: - enum Kind - { - kindNone = 0, - kindIndex, - kindKey - }; - std::string key_; - UInt index_; - Kind kind_; - }; - - /** \brief Experimental and untested: represents a "path" to access a node. - * - * Syntax: - * - "." => root node - * - ".[n]" => elements at index 'n' of root node (an array value) - * - ".name" => member named 'name' of root node (an object value) - * - ".name1.name2.name3" - * - ".[0][1][2].name1[3]" - * - ".%" => member name is provided as parameter - * - ".[%]" => index is provied as parameter - */ - class Path - { - public: - Path( const std::string &path, - const PathArgument &a1 = PathArgument(), - const PathArgument &a2 = PathArgument(), - const PathArgument &a3 = PathArgument(), - const PathArgument &a4 = PathArgument(), - const PathArgument &a5 = PathArgument() ); - - const Value &resolve( const Value &root ) const; - Value resolve( const Value &root, - const Value &defaultValue ) const; - /// Creates the "path" to access the specified node and returns a reference on the node. - Value &make( Value &root ) const; - - private: - typedef std::vector InArgs; - typedef std::vector Args; - - void makePath( const std::string &path, - const InArgs &in ); - void addPathInArg( const std::string &path, - const InArgs &in, - InArgs::const_iterator &itInArg, - PathArgument::Kind kind ); - void invalidPath( const std::string &path, - int location ); - - Args args_; - }; - - /** \brief Experimental do not use: Allocator to customize member name and string value memory management done by Value. - * - * - makeMemberName() and releaseMemberName() are called to respectively duplicate and - * free an Json::objectValue member name. - * - duplicateStringValue() and releaseStringValue() are called similarly to - * duplicate and free a Json::stringValue value. - */ - class ValueAllocator - { - public: - enum { unknown = (unsigned)-1 }; - - virtual ~ValueAllocator(); - - virtual char *makeMemberName( const char *memberName ) = 0; - virtual void releaseMemberName( char *memberName ) = 0; - virtual char *duplicateStringValue( const char *value, - unsigned int length = unknown ) = 0; - virtual void releaseStringValue( char *value ) = 0; - }; - -#ifdef JSON_VALUE_USE_INTERNAL_MAP - /** \brief Allocator to customize Value internal map. - * Below is an example of a simple implementation (default implementation actually - * use memory pool for speed). - * \code - class DefaultValueMapAllocator : public ValueMapAllocator - { - public: // overridden from ValueMapAllocator - virtual ValueInternalMap *newMap() - { - return new ValueInternalMap(); - } - - virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) - { - return new ValueInternalMap( other ); - } - - virtual void destructMap( ValueInternalMap *map ) - { - delete map; - } - - virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) - { - return new ValueInternalLink[size]; - } - - virtual void releaseMapBuckets( ValueInternalLink *links ) - { - delete [] links; - } - - virtual ValueInternalLink *allocateMapLink() - { - return new ValueInternalLink(); - } - - virtual void releaseMapLink( ValueInternalLink *link ) - { - delete link; - } - }; - * \endcode - */ - class JSON_API ValueMapAllocator - { - public: - virtual ~ValueMapAllocator(); - virtual ValueInternalMap *newMap() = 0; - virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0; - virtual void destructMap( ValueInternalMap *map ) = 0; - virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0; - virtual void releaseMapBuckets( ValueInternalLink *links ) = 0; - virtual ValueInternalLink *allocateMapLink() = 0; - virtual void releaseMapLink( ValueInternalLink *link ) = 0; - }; - - /** \brief ValueInternalMap hash-map bucket chain link (for internal use only). - * \internal previous_ & next_ allows for bidirectional traversal. - */ - class JSON_API ValueInternalLink - { - public: - enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture. - enum InternalFlags { - flagAvailable = 0, - flagUsed = 1 - }; - - ValueInternalLink(); - - ~ValueInternalLink(); - - Value items_[itemPerLink]; - char *keys_[itemPerLink]; - ValueInternalLink *previous_; - ValueInternalLink *next_; - }; - - - /** \brief A linked page based hash-table implementation used internally by Value. - * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked - * list in each bucket to handle collision. There is an addional twist in that - * each node of the collision linked list is a page containing a fixed amount of - * value. This provides a better compromise between memory usage and speed. - * - * Each bucket is made up of a chained list of ValueInternalLink. The last - * link of a given bucket can be found in the 'previous_' field of the following bucket. - * The last link of the last bucket is stored in tailLink_ as it has no following bucket. - * Only the last link of a bucket may contains 'available' item. The last link always - * contains at least one element unless is it the bucket one very first link. - */ - class JSON_API ValueInternalMap - { - friend class ValueIteratorBase; - friend class Value; - public: - typedef unsigned int HashKey; - typedef unsigned int BucketIndex; - -# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION - struct IteratorState - { - IteratorState() - : map_(0) - , link_(0) - , itemIndex_(0) - , bucketIndex_(0) - { - } - ValueInternalMap *map_; - ValueInternalLink *link_; - BucketIndex itemIndex_; - BucketIndex bucketIndex_; - }; -# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION - - ValueInternalMap(); - ValueInternalMap( const ValueInternalMap &other ); - ValueInternalMap &operator =( const ValueInternalMap &other ); - ~ValueInternalMap(); - - void swap( ValueInternalMap &other ); - - BucketIndex size() const; - - void clear(); - - bool reserveDelta( BucketIndex growth ); - - bool reserve( BucketIndex newItemCount ); - - const Value *find( const char *key ) const; - - Value *find( const char *key ); - - Value &resolveReference( const char *key, - bool isStatic ); - - void remove( const char *key ); - - void doActualRemove( ValueInternalLink *link, - BucketIndex index, - BucketIndex bucketIndex ); - - ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex ); - - Value &setNewItem( const char *key, - bool isStatic, - ValueInternalLink *link, - BucketIndex index ); - - Value &unsafeAdd( const char *key, - bool isStatic, - HashKey hashedKey ); - - HashKey hash( const char *key ) const; - - int compare( const ValueInternalMap &other ) const; - - private: - void makeBeginIterator( IteratorState &it ) const; - void makeEndIterator( IteratorState &it ) const; - static bool equals( const IteratorState &x, const IteratorState &other ); - static void increment( IteratorState &iterator ); - static void incrementBucket( IteratorState &iterator ); - static void decrement( IteratorState &iterator ); - static const char *key( const IteratorState &iterator ); - static const char *key( const IteratorState &iterator, bool &isStatic ); - static Value &value( const IteratorState &iterator ); - static int distance( const IteratorState &x, const IteratorState &y ); - - private: - ValueInternalLink *buckets_; - ValueInternalLink *tailLink_; - BucketIndex bucketsSize_; - BucketIndex itemCount_; - }; - - /** \brief A simplified deque implementation used internally by Value. - * \internal - * It is based on a list of fixed "page", each page contains a fixed number of items. - * Instead of using a linked-list, a array of pointer is used for fast item look-up. - * Look-up for an element is as follow: - * - compute page index: pageIndex = itemIndex / itemsPerPage - * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage] - * - * Insertion is amortized constant time (only the array containing the index of pointers - * need to be reallocated when items are appended). - */ - class JSON_API ValueInternalArray - { - friend class Value; - friend class ValueIteratorBase; - public: - enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo. - typedef Value::ArrayIndex ArrayIndex; - typedef unsigned int PageIndex; - -# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION - struct IteratorState // Must be a POD - { - IteratorState() - : array_(0) - , currentPageIndex_(0) - , currentItemIndex_(0) - { - } - ValueInternalArray *array_; - Value **currentPageIndex_; - unsigned int currentItemIndex_; - }; -# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION - - ValueInternalArray(); - ValueInternalArray( const ValueInternalArray &other ); - ValueInternalArray &operator =( const ValueInternalArray &other ); - ~ValueInternalArray(); - void swap( ValueInternalArray &other ); - - void clear(); - void resize( ArrayIndex newSize ); - - Value &resolveReference( ArrayIndex index ); - - Value *find( ArrayIndex index ) const; - - ArrayIndex size() const; - - int compare( const ValueInternalArray &other ) const; - - private: - static bool equals( const IteratorState &x, const IteratorState &other ); - static void increment( IteratorState &iterator ); - static void decrement( IteratorState &iterator ); - static Value &dereference( const IteratorState &iterator ); - static Value &unsafeDereference( const IteratorState &iterator ); - static int distance( const IteratorState &x, const IteratorState &y ); - static ArrayIndex indexOf( const IteratorState &iterator ); - void makeBeginIterator( IteratorState &it ) const; - void makeEndIterator( IteratorState &it ) const; - void makeIterator( IteratorState &it, ArrayIndex index ) const; - - void makeIndexValid( ArrayIndex index ); - - Value **pages_; - ArrayIndex size_; - PageIndex pageCount_; - }; - - /** \brief Experimental: do not use. Allocator to customize Value internal array. - * Below is an example of a simple implementation (actual implementation use - * memory pool). - \code -class DefaultValueArrayAllocator : public ValueArrayAllocator -{ -public: // overridden from ValueArrayAllocator - virtual ~DefaultValueArrayAllocator() - { - } - - virtual ValueInternalArray *newArray() - { - return new ValueInternalArray(); - } - - virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) - { - return new ValueInternalArray( other ); - } - - virtual void destruct( ValueInternalArray *array ) - { - delete array; - } - - virtual void reallocateArrayPageIndex( Value **&indexes, - ValueInternalArray::PageIndex &indexCount, - ValueInternalArray::PageIndex minNewIndexCount ) - { - ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1; - if ( minNewIndexCount > newIndexCount ) - newIndexCount = minNewIndexCount; - void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount ); - if ( !newIndexes ) - throw std::bad_alloc(); - indexCount = newIndexCount; - indexes = static_cast( newIndexes ); - } - virtual void releaseArrayPageIndex( Value **indexes, - ValueInternalArray::PageIndex indexCount ) - { - if ( indexes ) - free( indexes ); - } - - virtual Value *allocateArrayPage() - { - return static_cast( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) ); - } - - virtual void releaseArrayPage( Value *value ) - { - if ( value ) - free( value ); - } -}; - \endcode - */ - class JSON_API ValueArrayAllocator - { - public: - virtual ~ValueArrayAllocator(); - virtual ValueInternalArray *newArray() = 0; - virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0; - virtual void destructArray( ValueInternalArray *array ) = 0; - /** \brief Reallocate array page index. - * Reallocates an array of pointer on each page. - * \param indexes [input] pointer on the current index. May be \c NULL. - * [output] pointer on the new index of at least - * \a minNewIndexCount pages. - * \param indexCount [input] current number of pages in the index. - * [output] number of page the reallocated index can handle. - * \b MUST be >= \a minNewIndexCount. - * \param minNewIndexCount Minimum number of page the new index must be able to - * handle. - */ - virtual void reallocateArrayPageIndex( Value **&indexes, - ValueInternalArray::PageIndex &indexCount, - ValueInternalArray::PageIndex minNewIndexCount ) = 0; - virtual void releaseArrayPageIndex( Value **indexes, - ValueInternalArray::PageIndex indexCount ) = 0; - virtual Value *allocateArrayPage() = 0; - virtual void releaseArrayPage( Value *value ) = 0; - }; -#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP - - - /** \brief base class for Value iterators. - * - */ - class ValueIteratorBase - { - public: - typedef unsigned int size_t; - typedef int difference_type; - typedef ValueIteratorBase SelfType; - - ValueIteratorBase(); -#ifndef JSON_VALUE_USE_INTERNAL_MAP - explicit ValueIteratorBase( const Value::ObjectValues::iterator ¤t ); -#else - ValueIteratorBase( const ValueInternalArray::IteratorState &state ); - ValueIteratorBase( const ValueInternalMap::IteratorState &state ); -#endif - - bool operator ==( const SelfType &other ) const - { - return isEqual( other ); - } - - bool operator !=( const SelfType &other ) const - { - return !isEqual( other ); - } - - difference_type operator -( const SelfType &other ) const - { - return computeDistance( other ); - } - - /// Return either the index or the member name of the referenced value as a Value. - Value key() const; - - /// Return the index of the referenced Value. -1 if it is not an arrayValue. - UInt index() const; - - /// Return the member name of the referenced Value. "" if it is not an objectValue. - const char *memberName() const; - - protected: - Value &deref() const; - - void increment(); - - void decrement(); - - difference_type computeDistance( const SelfType &other ) const; - - bool isEqual( const SelfType &other ) const; - - void copy( const SelfType &other ); - - private: -#ifndef JSON_VALUE_USE_INTERNAL_MAP - Value::ObjectValues::iterator current_; - // Indicates that iterator is for a null value. - bool isNull_; -#else - union - { - ValueInternalArray::IteratorState array_; - ValueInternalMap::IteratorState map_; - } iterator_; - bool isArray_; -#endif - }; - - /** \brief const iterator for object and array value. - * - */ - class ValueConstIterator : public ValueIteratorBase - { - friend class Value; - public: - typedef unsigned int size_t; - typedef int difference_type; - typedef const Value &reference; - typedef const Value *pointer; - typedef ValueConstIterator SelfType; - - ValueConstIterator(); - private: - /*! \internal Use by Value to create an iterator. - */ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - explicit ValueConstIterator( const Value::ObjectValues::iterator ¤t ); -#else - ValueConstIterator( const ValueInternalArray::IteratorState &state ); - ValueConstIterator( const ValueInternalMap::IteratorState &state ); -#endif - public: - SelfType &operator =( const ValueIteratorBase &other ); - - SelfType operator++( int ) - { - SelfType temp( *this ); - ++*this; - return temp; - } - - SelfType operator--( int ) - { - SelfType temp( *this ); - --*this; - return temp; - } - - SelfType &operator--() - { - decrement(); - return *this; - } - - SelfType &operator++() - { - increment(); - return *this; - } - - reference operator *() const - { - return deref(); - } - }; - - - /** \brief Iterator for object and array value. - */ - class ValueIterator : public ValueIteratorBase - { - friend class Value; - public: - typedef unsigned int size_t; - typedef int difference_type; - typedef Value &reference; - typedef Value *pointer; - typedef ValueIterator SelfType; - - ValueIterator(); - ValueIterator( const ValueConstIterator &other ); - ValueIterator( const ValueIterator &other ); - private: - /*! \internal Use by Value to create an iterator. - */ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - explicit ValueIterator( const Value::ObjectValues::iterator ¤t ); -#else - ValueIterator( const ValueInternalArray::IteratorState &state ); - ValueIterator( const ValueInternalMap::IteratorState &state ); -#endif - public: - - SelfType &operator =( const SelfType &other ); - - SelfType operator++( int ) - { - SelfType temp( *this ); - ++*this; - return temp; - } - - SelfType operator--( int ) - { - SelfType temp( *this ); - --*this; - return temp; - } - - SelfType &operator--() - { - decrement(); - return *this; - } - - SelfType &operator++() - { - increment(); - return *this; - } - - reference operator *() const - { - return deref(); - } - }; - - -} // namespace Json - - -#endif // CPPTL_JSON_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/writer.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/writer.h deleted file mode 100755 index 5f4b83be..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json/writer.h +++ /dev/null @@ -1,174 +0,0 @@ -#ifndef JSON_WRITER_H_INCLUDED -# define JSON_WRITER_H_INCLUDED - -# include "value.h" -# include -# include -# include - -namespace Json { - - class Value; - - /** \brief Abstract class for writers. - */ - class JSON_API Writer - { - public: - virtual ~Writer(); - - virtual std::string write( const Value &root ) = 0; - }; - - /** \brief Outputs a Value in JSON format without formatting (not human friendly). - * - * The JSON document is written in a single line. It is not intended for 'human' consumption, - * but may be usefull to support feature such as RPC where bandwith is limited. - * \sa Reader, Value - */ - class JSON_API FastWriter : public Writer - { - public: - FastWriter(); - virtual ~FastWriter(){} - - void enableYAMLCompatibility(); - - public: // overridden from Writer - virtual std::string write( const Value &root ); - - private: - void writeValue( const Value &value ); - - std::string document_; - bool yamlCompatiblityEnabled_; - }; - - /** \brief Writes a Value in JSON format in a human friendly way. - * - * The rules for line break and indent are as follow: - * - Object value: - * - if empty then print {} without indent and line break - * - if not empty the print '{', line break & indent, print one value per line - * and then unindent and line break and print '}'. - * - Array value: - * - if empty then print [] without indent and line break - * - if the array contains no object value, empty array or some other value types, - * and all the values fit on one lines, then print the array on a single line. - * - otherwise, it the values do not fit on one line, or the array contains - * object or non empty array, then print one value per line. - * - * If the Value have comments then they are outputed according to their #CommentPlacement. - * - * \sa Reader, Value, Value::setComment() - */ - class JSON_API StyledWriter: public Writer - { - public: - StyledWriter(); - virtual ~StyledWriter(){} - - public: // overridden from Writer - /** \brief Serialize a Value in JSON format. - * \param root Value to serialize. - * \return String containing the JSON document that represents the root value. - */ - virtual std::string write( const Value &root ); - - private: - void writeValue( const Value &value ); - void writeArrayValue( const Value &value ); - bool isMultineArray( const Value &value ); - void pushValue( const std::string &value ); - void writeIndent(); - void writeWithIndent( const std::string &value ); - void indent(); - void unindent(); - void writeCommentBeforeValue( const Value &root ); - void writeCommentAfterValueOnSameLine( const Value &root ); - bool hasCommentForValue( const Value &value ); - static std::string normalizeEOL( const std::string &text ); - - typedef std::vector ChildValues; - - ChildValues childValues_; - std::string document_; - std::string indentString_; - int rightMargin_; - int indentSize_; - bool addChildValues_; - }; - - /** \brief Writes a Value in JSON format in a human friendly way, - to a stream rather than to a string. - * - * The rules for line break and indent are as follow: - * - Object value: - * - if empty then print {} without indent and line break - * - if not empty the print '{', line break & indent, print one value per line - * and then unindent and line break and print '}'. - * - Array value: - * - if empty then print [] without indent and line break - * - if the array contains no object value, empty array or some other value types, - * and all the values fit on one lines, then print the array on a single line. - * - otherwise, it the values do not fit on one line, or the array contains - * object or non empty array, then print one value per line. - * - * If the Value have comments then they are outputed according to their #CommentPlacement. - * - * \param indentation Each level will be indented by this amount extra. - * \sa Reader, Value, Value::setComment() - */ - class JSON_API StyledStreamWriter - { - public: - StyledStreamWriter( std::string indentation="\t" ); - ~StyledStreamWriter(){} - - public: - /** \brief Serialize a Value in JSON format. - * \param out Stream to write to. (Can be ostringstream, e.g.) - * \param root Value to serialize. - * \note There is no point in deriving from Writer, since write() should not return a value. - */ - void write( std::ostream &out, const Value &root ); - - private: - void writeValue( const Value &value ); - void writeArrayValue( const Value &value ); - bool isMultineArray( const Value &value ); - void pushValue( const std::string &value ); - void writeIndent(); - void writeWithIndent( const std::string &value ); - void indent(); - void unindent(); - void writeCommentBeforeValue( const Value &root ); - void writeCommentAfterValueOnSameLine( const Value &root ); - bool hasCommentForValue( const Value &value ); - static std::string normalizeEOL( const std::string &text ); - - typedef std::vector ChildValues; - - ChildValues childValues_; - std::ostream* document_; - std::string indentString_; - int rightMargin_; - std::string indentation_; - bool addChildValues_; - }; - - std::string JSON_API valueToString( Int value ); - std::string JSON_API valueToString( UInt value ); - std::string JSON_API valueToString( double value ); - std::string JSON_API valueToString( bool value ); - std::string JSON_API valueToQuotedString( const char *value ); - - /// \brief Output using the StyledStreamWriter. - /// \see Json::operator>>() - std::ostream& operator<<( std::ostream&, const Value &root ); - -} // namespace Json - - - -#endif // JSON_WRITER_H_INCLUDED diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_batchallocator.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_batchallocator.h deleted file mode 100755 index 87ea5ed8..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_batchallocator.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED -# define JSONCPP_BATCHALLOCATOR_H_INCLUDED - -# include -# include - -# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION - -namespace Json { - -/* Fast memory allocator. - * - * This memory allocator allocates memory for a batch of object (specified by - * the page size, the number of object in each page). - * - * It does not allow the destruction of a single object. All the allocated objects - * can be destroyed at once. The memory can be either released or reused for future - * allocation. - * - * The in-place new operator must be used to construct the object using the pointer - * returned by allocate. - */ -template -class BatchAllocator -{ -public: - typedef AllocatedType Type; - - BatchAllocator( unsigned int objectsPerPage = 255 ) - : freeHead_( 0 ) - , objectsPerPage_( objectsPerPage ) - { -// printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() ); - assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space. - assert( objectsPerPage >= 16 ); - batches_ = allocateBatch( 0 ); // allocated a dummy page - currentBatch_ = batches_; - } - - ~BatchAllocator() - { - for ( BatchInfo *batch = batches_; batch; ) - { - BatchInfo *nextBatch = batch->next_; - free( batch ); - batch = nextBatch; - } - } - - /// allocate space for an array of objectPerAllocation object. - /// @warning it is the responsability of the caller to call objects constructors. - AllocatedType *allocate() - { - if ( freeHead_ ) // returns node from free list. - { - AllocatedType *object = freeHead_; - freeHead_ = *(AllocatedType **)object; - return object; - } - if ( currentBatch_->used_ == currentBatch_->end_ ) - { - currentBatch_ = currentBatch_->next_; - while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ ) - currentBatch_ = currentBatch_->next_; - - if ( !currentBatch_ ) // no free batch found, allocate a new one - { - currentBatch_ = allocateBatch( objectsPerPage_ ); - currentBatch_->next_ = batches_; // insert at the head of the list - batches_ = currentBatch_; - } - } - AllocatedType *allocated = currentBatch_->used_; - currentBatch_->used_ += objectPerAllocation; - return allocated; - } - - /// Release the object. - /// @warning it is the responsability of the caller to actually destruct the object. - void release( AllocatedType *object ) - { - assert( object != 0 ); - *(AllocatedType **)object = freeHead_; - freeHead_ = object; - } - -private: - struct BatchInfo - { - BatchInfo *next_; - AllocatedType *used_; - AllocatedType *end_; - AllocatedType buffer_[objectPerAllocation]; - }; - - // disabled copy constructor and assignement operator. - BatchAllocator( const BatchAllocator & ); - void operator =( const BatchAllocator &); - - static BatchInfo *allocateBatch( unsigned int objectsPerPage ) - { - const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation - + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage; - BatchInfo *batch = static_cast( malloc( mallocSize ) ); - batch->next_ = 0; - batch->used_ = batch->buffer_; - batch->end_ = batch->buffer_ + objectsPerPage; - return batch; - } - - BatchInfo *batches_; - BatchInfo *currentBatch_; - /// Head of a single linked list within the allocated space of freeed object - AllocatedType *freeHead_; - unsigned int objectsPerPage_; -}; - - -} // namespace Json - -# endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION - -#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalarray.inl b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalarray.inl deleted file mode 100755 index 9b985d25..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalarray.inl +++ /dev/null @@ -1,448 +0,0 @@ -// included by json_value.cpp -// everything is within Json namespace - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class ValueInternalArray -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// - -ValueArrayAllocator::~ValueArrayAllocator() -{ -} - -// ////////////////////////////////////////////////////////////////// -// class DefaultValueArrayAllocator -// ////////////////////////////////////////////////////////////////// -#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR -class DefaultValueArrayAllocator : public ValueArrayAllocator -{ -public: // overridden from ValueArrayAllocator - virtual ~DefaultValueArrayAllocator() - { - } - - virtual ValueInternalArray *newArray() - { - return new ValueInternalArray(); - } - - virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) - { - return new ValueInternalArray( other ); - } - - virtual void destructArray( ValueInternalArray *array ) - { - delete array; - } - - virtual void reallocateArrayPageIndex( Value **&indexes, - ValueInternalArray::PageIndex &indexCount, - ValueInternalArray::PageIndex minNewIndexCount ) - { - ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1; - if ( minNewIndexCount > newIndexCount ) - newIndexCount = minNewIndexCount; - void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount ); - if ( !newIndexes ) - throw std::bad_alloc(); - indexCount = newIndexCount; - indexes = static_cast( newIndexes ); - } - virtual void releaseArrayPageIndex( Value **indexes, - ValueInternalArray::PageIndex indexCount ) - { - if ( indexes ) - free( indexes ); - } - - virtual Value *allocateArrayPage() - { - return static_cast( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) ); - } - - virtual void releaseArrayPage( Value *value ) - { - if ( value ) - free( value ); - } -}; - -#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR -/// @todo make this thread-safe (lock when accessign batch allocator) -class DefaultValueArrayAllocator : public ValueArrayAllocator -{ -public: // overridden from ValueArrayAllocator - virtual ~DefaultValueArrayAllocator() - { - } - - virtual ValueInternalArray *newArray() - { - ValueInternalArray *array = arraysAllocator_.allocate(); - new (array) ValueInternalArray(); // placement new - return array; - } - - virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) - { - ValueInternalArray *array = arraysAllocator_.allocate(); - new (array) ValueInternalArray( other ); // placement new - return array; - } - - virtual void destructArray( ValueInternalArray *array ) - { - if ( array ) - { - array->~ValueInternalArray(); - arraysAllocator_.release( array ); - } - } - - virtual void reallocateArrayPageIndex( Value **&indexes, - ValueInternalArray::PageIndex &indexCount, - ValueInternalArray::PageIndex minNewIndexCount ) - { - ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1; - if ( minNewIndexCount > newIndexCount ) - newIndexCount = minNewIndexCount; - void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount ); - if ( !newIndexes ) - throw std::bad_alloc(); - indexCount = newIndexCount; - indexes = static_cast( newIndexes ); - } - virtual void releaseArrayPageIndex( Value **indexes, - ValueInternalArray::PageIndex indexCount ) - { - if ( indexes ) - free( indexes ); - } - - virtual Value *allocateArrayPage() - { - return static_cast( pagesAllocator_.allocate() ); - } - - virtual void releaseArrayPage( Value *value ) - { - if ( value ) - pagesAllocator_.release( value ); - } -private: - BatchAllocator arraysAllocator_; - BatchAllocator pagesAllocator_; -}; -#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR - -static ValueArrayAllocator *&arrayAllocator() -{ - static DefaultValueArrayAllocator defaultAllocator; - static ValueArrayAllocator *arrayAllocator = &defaultAllocator; - return arrayAllocator; -} - -static struct DummyArrayAllocatorInitializer { - DummyArrayAllocatorInitializer() - { - arrayAllocator(); // ensure arrayAllocator() statics are initialized before main(). - } -} dummyArrayAllocatorInitializer; - -// ////////////////////////////////////////////////////////////////// -// class ValueInternalArray -// ////////////////////////////////////////////////////////////////// -bool -ValueInternalArray::equals( const IteratorState &x, - const IteratorState &other ) -{ - return x.array_ == other.array_ - && x.currentItemIndex_ == other.currentItemIndex_ - && x.currentPageIndex_ == other.currentPageIndex_; -} - - -void -ValueInternalArray::increment( IteratorState &it ) -{ - JSON_ASSERT_MESSAGE( it.array_ && - (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_ - != it.array_->size_, - "ValueInternalArray::increment(): moving iterator beyond end" ); - ++(it.currentItemIndex_); - if ( it.currentItemIndex_ == itemsPerPage ) - { - it.currentItemIndex_ = 0; - ++(it.currentPageIndex_); - } -} - - -void -ValueInternalArray::decrement( IteratorState &it ) -{ - JSON_ASSERT_MESSAGE( it.array_ && it.currentPageIndex_ == it.array_->pages_ - && it.currentItemIndex_ == 0, - "ValueInternalArray::decrement(): moving iterator beyond end" ); - if ( it.currentItemIndex_ == 0 ) - { - it.currentItemIndex_ = itemsPerPage-1; - --(it.currentPageIndex_); - } - else - { - --(it.currentItemIndex_); - } -} - - -Value & -ValueInternalArray::unsafeDereference( const IteratorState &it ) -{ - return (*(it.currentPageIndex_))[it.currentItemIndex_]; -} - - -Value & -ValueInternalArray::dereference( const IteratorState &it ) -{ - JSON_ASSERT_MESSAGE( it.array_ && - (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_ - < it.array_->size_, - "ValueInternalArray::dereference(): dereferencing invalid iterator" ); - return unsafeDereference( it ); -} - -void -ValueInternalArray::makeBeginIterator( IteratorState &it ) const -{ - it.array_ = const_cast( this ); - it.currentItemIndex_ = 0; - it.currentPageIndex_ = pages_; -} - - -void -ValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const -{ - it.array_ = const_cast( this ); - it.currentItemIndex_ = index % itemsPerPage; - it.currentPageIndex_ = pages_ + index / itemsPerPage; -} - - -void -ValueInternalArray::makeEndIterator( IteratorState &it ) const -{ - makeIterator( it, size_ ); -} - - -ValueInternalArray::ValueInternalArray() - : pages_( 0 ) - , size_( 0 ) - , pageCount_( 0 ) -{ -} - - -ValueInternalArray::ValueInternalArray( const ValueInternalArray &other ) - : pages_( 0 ) - , pageCount_( 0 ) - , size_( other.size_ ) -{ - PageIndex minNewPages = other.size_ / itemsPerPage; - arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages ); - JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, - "ValueInternalArray::reserve(): bad reallocation" ); - IteratorState itOther; - other.makeBeginIterator( itOther ); - Value *value; - for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) ) - { - if ( index % itemsPerPage == 0 ) - { - PageIndex pageIndex = index / itemsPerPage; - value = arrayAllocator()->allocateArrayPage(); - pages_[pageIndex] = value; - } - new (value) Value( dereference( itOther ) ); - } -} - - -ValueInternalArray & -ValueInternalArray::operator =( const ValueInternalArray &other ) -{ - ValueInternalArray temp( other ); - swap( temp ); - return *this; -} - - -ValueInternalArray::~ValueInternalArray() -{ - // destroy all constructed items - IteratorState it; - IteratorState itEnd; - makeBeginIterator( it); - makeEndIterator( itEnd ); - for ( ; !equals(it,itEnd); increment(it) ) - { - Value *value = &dereference(it); - value->~Value(); - } - // release all pages - PageIndex lastPageIndex = size_ / itemsPerPage; - for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex ) - arrayAllocator()->releaseArrayPage( pages_[pageIndex] ); - // release pages index - arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ ); -} - - -void -ValueInternalArray::swap( ValueInternalArray &other ) -{ - Value **tempPages = pages_; - pages_ = other.pages_; - other.pages_ = tempPages; - ArrayIndex tempSize = size_; - size_ = other.size_; - other.size_ = tempSize; - PageIndex tempPageCount = pageCount_; - pageCount_ = other.pageCount_; - other.pageCount_ = tempPageCount; -} - -void -ValueInternalArray::clear() -{ - ValueInternalArray dummy; - swap( dummy ); -} - - -void -ValueInternalArray::resize( ArrayIndex newSize ) -{ - if ( newSize == 0 ) - clear(); - else if ( newSize < size_ ) - { - IteratorState it; - IteratorState itEnd; - makeIterator( it, newSize ); - makeIterator( itEnd, size_ ); - for ( ; !equals(it,itEnd); increment(it) ) - { - Value *value = &dereference(it); - value->~Value(); - } - PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage; - PageIndex lastPageIndex = size_ / itemsPerPage; - for ( ; pageIndex < lastPageIndex; ++pageIndex ) - arrayAllocator()->releaseArrayPage( pages_[pageIndex] ); - size_ = newSize; - } - else if ( newSize > size_ ) - resolveReference( newSize ); -} - - -void -ValueInternalArray::makeIndexValid( ArrayIndex index ) -{ - // Need to enlarge page index ? - if ( index >= pageCount_ * itemsPerPage ) - { - PageIndex minNewPages = (index + 1) / itemsPerPage; - arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages ); - JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, "ValueInternalArray::reserve(): bad reallocation" ); - } - - // Need to allocate new pages ? - ArrayIndex nextPageIndex = - (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage - : size_; - if ( nextPageIndex <= index ) - { - PageIndex pageIndex = nextPageIndex / itemsPerPage; - PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1; - for ( ; pageToAllocate-- > 0; ++pageIndex ) - pages_[pageIndex] = arrayAllocator()->allocateArrayPage(); - } - - // Initialize all new entries - IteratorState it; - IteratorState itEnd; - makeIterator( it, size_ ); - size_ = index + 1; - makeIterator( itEnd, size_ ); - for ( ; !equals(it,itEnd); increment(it) ) - { - Value *value = &dereference(it); - new (value) Value(); // Construct a default value using placement new - } -} - -Value & -ValueInternalArray::resolveReference( ArrayIndex index ) -{ - if ( index >= size_ ) - makeIndexValid( index ); - return pages_[index/itemsPerPage][index%itemsPerPage]; -} - -Value * -ValueInternalArray::find( ArrayIndex index ) const -{ - if ( index >= size_ ) - return 0; - return &(pages_[index/itemsPerPage][index%itemsPerPage]); -} - -ValueInternalArray::ArrayIndex -ValueInternalArray::size() const -{ - return size_; -} - -int -ValueInternalArray::distance( const IteratorState &x, const IteratorState &y ) -{ - return indexOf(y) - indexOf(x); -} - - -ValueInternalArray::ArrayIndex -ValueInternalArray::indexOf( const IteratorState &iterator ) -{ - if ( !iterator.array_ ) - return ArrayIndex(-1); - return ArrayIndex( - (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage - + iterator.currentItemIndex_ ); -} - - -int -ValueInternalArray::compare( const ValueInternalArray &other ) const -{ - int sizeDiff( size_ - other.size_ ); - if ( sizeDiff != 0 ) - return sizeDiff; - - for ( ArrayIndex index =0; index < size_; ++index ) - { - int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( - other.pages_[index/itemsPerPage][index%itemsPerPage] ); - if ( diff != 0 ) - return diff; - } - return 0; -} diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalmap.inl b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalmap.inl deleted file mode 100755 index 19771488..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_internalmap.inl +++ /dev/null @@ -1,607 +0,0 @@ -// included by json_value.cpp -// everything is within Json namespace - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class ValueInternalMap -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// - -/** \internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) ); - * This optimization is used by the fast allocator. - */ -ValueInternalLink::ValueInternalLink() - : previous_( 0 ) - , next_( 0 ) -{ -} - -ValueInternalLink::~ValueInternalLink() -{ - for ( int index =0; index < itemPerLink; ++index ) - { - if ( !items_[index].isItemAvailable() ) - { - if ( !items_[index].isMemberNameStatic() ) - free( keys_[index] ); - } - else - break; - } -} - - - -ValueMapAllocator::~ValueMapAllocator() -{ -} - -#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR -class DefaultValueMapAllocator : public ValueMapAllocator -{ -public: // overridden from ValueMapAllocator - virtual ValueInternalMap *newMap() - { - return new ValueInternalMap(); - } - - virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) - { - return new ValueInternalMap( other ); - } - - virtual void destructMap( ValueInternalMap *map ) - { - delete map; - } - - virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) - { - return new ValueInternalLink[size]; - } - - virtual void releaseMapBuckets( ValueInternalLink *links ) - { - delete [] links; - } - - virtual ValueInternalLink *allocateMapLink() - { - return new ValueInternalLink(); - } - - virtual void releaseMapLink( ValueInternalLink *link ) - { - delete link; - } -}; -#else -/// @todo make this thread-safe (lock when accessign batch allocator) -class DefaultValueMapAllocator : public ValueMapAllocator -{ -public: // overridden from ValueMapAllocator - virtual ValueInternalMap *newMap() - { - ValueInternalMap *map = mapsAllocator_.allocate(); - new (map) ValueInternalMap(); // placement new - return map; - } - - virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) - { - ValueInternalMap *map = mapsAllocator_.allocate(); - new (map) ValueInternalMap( other ); // placement new - return map; - } - - virtual void destructMap( ValueInternalMap *map ) - { - if ( map ) - { - map->~ValueInternalMap(); - mapsAllocator_.release( map ); - } - } - - virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) - { - return new ValueInternalLink[size]; - } - - virtual void releaseMapBuckets( ValueInternalLink *links ) - { - delete [] links; - } - - virtual ValueInternalLink *allocateMapLink() - { - ValueInternalLink *link = linksAllocator_.allocate(); - memset( link, 0, sizeof(ValueInternalLink) ); - return link; - } - - virtual void releaseMapLink( ValueInternalLink *link ) - { - link->~ValueInternalLink(); - linksAllocator_.release( link ); - } -private: - BatchAllocator mapsAllocator_; - BatchAllocator linksAllocator_; -}; -#endif - -static ValueMapAllocator *&mapAllocator() -{ - static DefaultValueMapAllocator defaultAllocator; - static ValueMapAllocator *mapAllocator = &defaultAllocator; - return mapAllocator; -} - -static struct DummyMapAllocatorInitializer { - DummyMapAllocatorInitializer() - { - mapAllocator(); // ensure mapAllocator() statics are initialized before main(). - } -} dummyMapAllocatorInitializer; - - - -// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32. - -/* -use linked list hash map. -buckets array is a container. -linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124) -value have extra state: valid, available, deleted -*/ - - -ValueInternalMap::ValueInternalMap() - : buckets_( 0 ) - , tailLink_( 0 ) - , bucketsSize_( 0 ) - , itemCount_( 0 ) -{ -} - - -ValueInternalMap::ValueInternalMap( const ValueInternalMap &other ) - : buckets_( 0 ) - , tailLink_( 0 ) - , bucketsSize_( 0 ) - , itemCount_( 0 ) -{ - reserve( other.itemCount_ ); - IteratorState it; - IteratorState itEnd; - other.makeBeginIterator( it ); - other.makeEndIterator( itEnd ); - for ( ; !equals(it,itEnd); increment(it) ) - { - bool isStatic; - const char *memberName = key( it, isStatic ); - const Value &aValue = value( it ); - resolveReference(memberName, isStatic) = aValue; - } -} - - -ValueInternalMap & -ValueInternalMap::operator =( const ValueInternalMap &other ) -{ - ValueInternalMap dummy( other ); - swap( dummy ); - return *this; -} - - -ValueInternalMap::~ValueInternalMap() -{ - if ( buckets_ ) - { - for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex ) - { - ValueInternalLink *link = buckets_[bucketIndex].next_; - while ( link ) - { - ValueInternalLink *linkToRelease = link; - link = link->next_; - mapAllocator()->releaseMapLink( linkToRelease ); - } - } - mapAllocator()->releaseMapBuckets( buckets_ ); - } -} - - -void -ValueInternalMap::swap( ValueInternalMap &other ) -{ - ValueInternalLink *tempBuckets = buckets_; - buckets_ = other.buckets_; - other.buckets_ = tempBuckets; - ValueInternalLink *tempTailLink = tailLink_; - tailLink_ = other.tailLink_; - other.tailLink_ = tempTailLink; - BucketIndex tempBucketsSize = bucketsSize_; - bucketsSize_ = other.bucketsSize_; - other.bucketsSize_ = tempBucketsSize; - BucketIndex tempItemCount = itemCount_; - itemCount_ = other.itemCount_; - other.itemCount_ = tempItemCount; -} - - -void -ValueInternalMap::clear() -{ - ValueInternalMap dummy; - swap( dummy ); -} - - -ValueInternalMap::BucketIndex -ValueInternalMap::size() const -{ - return itemCount_; -} - -bool -ValueInternalMap::reserveDelta( BucketIndex growth ) -{ - return reserve( itemCount_ + growth ); -} - -bool -ValueInternalMap::reserve( BucketIndex newItemCount ) -{ - if ( !buckets_ && newItemCount > 0 ) - { - buckets_ = mapAllocator()->allocateMapBuckets( 1 ); - bucketsSize_ = 1; - tailLink_ = &buckets_[0]; - } -// BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink; - return true; -} - - -const Value * -ValueInternalMap::find( const char *key ) const -{ - if ( !bucketsSize_ ) - return 0; - HashKey hashedKey = hash( key ); - BucketIndex bucketIndex = hashedKey % bucketsSize_; - for ( const ValueInternalLink *current = &buckets_[bucketIndex]; - current != 0; - current = current->next_ ) - { - for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index ) - { - if ( current->items_[index].isItemAvailable() ) - return 0; - if ( strcmp( key, current->keys_[index] ) == 0 ) - return ¤t->items_[index]; - } - } - return 0; -} - - -Value * -ValueInternalMap::find( const char *key ) -{ - const ValueInternalMap *constThis = this; - return const_cast( constThis->find( key ) ); -} - - -Value & -ValueInternalMap::resolveReference( const char *key, - bool isStatic ) -{ - HashKey hashedKey = hash( key ); - if ( bucketsSize_ ) - { - BucketIndex bucketIndex = hashedKey % bucketsSize_; - ValueInternalLink **previous = 0; - BucketIndex index; - for ( ValueInternalLink *current = &buckets_[bucketIndex]; - current != 0; - previous = ¤t->next_, current = current->next_ ) - { - for ( index=0; index < ValueInternalLink::itemPerLink; ++index ) - { - if ( current->items_[index].isItemAvailable() ) - return setNewItem( key, isStatic, current, index ); - if ( strcmp( key, current->keys_[index] ) == 0 ) - return current->items_[index]; - } - } - } - - reserveDelta( 1 ); - return unsafeAdd( key, isStatic, hashedKey ); -} - - -void -ValueInternalMap::remove( const char *key ) -{ - HashKey hashedKey = hash( key ); - if ( !bucketsSize_ ) - return; - BucketIndex bucketIndex = hashedKey % bucketsSize_; - for ( ValueInternalLink *link = &buckets_[bucketIndex]; - link != 0; - link = link->next_ ) - { - BucketIndex index; - for ( index =0; index < ValueInternalLink::itemPerLink; ++index ) - { - if ( link->items_[index].isItemAvailable() ) - return; - if ( strcmp( key, link->keys_[index] ) == 0 ) - { - doActualRemove( link, index, bucketIndex ); - return; - } - } - } -} - -void -ValueInternalMap::doActualRemove( ValueInternalLink *link, - BucketIndex index, - BucketIndex bucketIndex ) -{ - // find last item of the bucket and swap it with the 'removed' one. - // set removed items flags to 'available'. - // if last page only contains 'available' items, then desallocate it (it's empty) - ValueInternalLink *&lastLink = getLastLinkInBucket( index ); - BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1 - for ( ; - lastItemIndex < ValueInternalLink::itemPerLink; - ++lastItemIndex ) // may be optimized with dicotomic search - { - if ( lastLink->items_[lastItemIndex].isItemAvailable() ) - break; - } - - BucketIndex lastUsedIndex = lastItemIndex - 1; - Value *valueToDelete = &link->items_[index]; - Value *valueToPreserve = &lastLink->items_[lastUsedIndex]; - if ( valueToDelete != valueToPreserve ) - valueToDelete->swap( *valueToPreserve ); - if ( lastUsedIndex == 0 ) // page is now empty - { // remove it from bucket linked list and delete it. - ValueInternalLink *linkPreviousToLast = lastLink->previous_; - if ( linkPreviousToLast != 0 ) // can not deleted bucket link. - { - mapAllocator()->releaseMapLink( lastLink ); - linkPreviousToLast->next_ = 0; - lastLink = linkPreviousToLast; - } - } - else - { - Value dummy; - valueToPreserve->swap( dummy ); // restore deleted to default Value. - valueToPreserve->setItemUsed( false ); - } - --itemCount_; -} - - -ValueInternalLink *& -ValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex ) -{ - if ( bucketIndex == bucketsSize_ - 1 ) - return tailLink_; - ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_; - if ( !previous ) - previous = &buckets_[bucketIndex]; - return previous; -} - - -Value & -ValueInternalMap::setNewItem( const char *key, - bool isStatic, - ValueInternalLink *link, - BucketIndex index ) -{ - char *duplicatedKey = valueAllocator()->makeMemberName( key ); - ++itemCount_; - link->keys_[index] = duplicatedKey; - link->items_[index].setItemUsed(); - link->items_[index].setMemberNameIsStatic( isStatic ); - return link->items_[index]; // items already default constructed. -} - - -Value & -ValueInternalMap::unsafeAdd( const char *key, - bool isStatic, - HashKey hashedKey ) -{ - JSON_ASSERT_MESSAGE( bucketsSize_ > 0, "ValueInternalMap::unsafeAdd(): internal logic error." ); - BucketIndex bucketIndex = hashedKey % bucketsSize_; - ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex ); - ValueInternalLink *link = previousLink; - BucketIndex index; - for ( index =0; index < ValueInternalLink::itemPerLink; ++index ) - { - if ( link->items_[index].isItemAvailable() ) - break; - } - if ( index == ValueInternalLink::itemPerLink ) // need to add a new page - { - ValueInternalLink *newLink = mapAllocator()->allocateMapLink(); - index = 0; - link->next_ = newLink; - previousLink = newLink; - link = newLink; - } - return setNewItem( key, isStatic, link, index ); -} - - -ValueInternalMap::HashKey -ValueInternalMap::hash( const char *key ) const -{ - HashKey hash = 0; - while ( *key ) - hash += *key++ * 37; - return hash; -} - - -int -ValueInternalMap::compare( const ValueInternalMap &other ) const -{ - int sizeDiff( itemCount_ - other.itemCount_ ); - if ( sizeDiff != 0 ) - return sizeDiff; - // Strict order guaranty is required. Compare all keys FIRST, then compare values. - IteratorState it; - IteratorState itEnd; - makeBeginIterator( it ); - makeEndIterator( itEnd ); - for ( ; !equals(it,itEnd); increment(it) ) - { - if ( !other.find( key( it ) ) ) - return 1; - } - - // All keys are equals, let's compare values - makeBeginIterator( it ); - for ( ; !equals(it,itEnd); increment(it) ) - { - const Value *otherValue = other.find( key( it ) ); - int valueDiff = value(it).compare( *otherValue ); - if ( valueDiff != 0 ) - return valueDiff; - } - return 0; -} - - -void -ValueInternalMap::makeBeginIterator( IteratorState &it ) const -{ - it.map_ = const_cast( this ); - it.bucketIndex_ = 0; - it.itemIndex_ = 0; - it.link_ = buckets_; -} - - -void -ValueInternalMap::makeEndIterator( IteratorState &it ) const -{ - it.map_ = const_cast( this ); - it.bucketIndex_ = bucketsSize_; - it.itemIndex_ = 0; - it.link_ = 0; -} - - -bool -ValueInternalMap::equals( const IteratorState &x, const IteratorState &other ) -{ - return x.map_ == other.map_ - && x.bucketIndex_ == other.bucketIndex_ - && x.link_ == other.link_ - && x.itemIndex_ == other.itemIndex_; -} - - -void -ValueInternalMap::incrementBucket( IteratorState &iterator ) -{ - ++iterator.bucketIndex_; - JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_, - "ValueInternalMap::increment(): attempting to iterate beyond end." ); - if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ ) - iterator.link_ = 0; - else - iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]); - iterator.itemIndex_ = 0; -} - - -void -ValueInternalMap::increment( IteratorState &iterator ) -{ - JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterator using invalid iterator." ); - ++iterator.itemIndex_; - if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink ) - { - JSON_ASSERT_MESSAGE( iterator.link_ != 0, - "ValueInternalMap::increment(): attempting to iterate beyond end." ); - iterator.link_ = iterator.link_->next_; - if ( iterator.link_ == 0 ) - incrementBucket( iterator ); - } - else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() ) - { - incrementBucket( iterator ); - } -} - - -void -ValueInternalMap::decrement( IteratorState &iterator ) -{ - if ( iterator.itemIndex_ == 0 ) - { - JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterate using invalid iterator." ); - if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] ) - { - JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, "Attempting to iterate beyond beginning." ); - --(iterator.bucketIndex_); - } - iterator.link_ = iterator.link_->previous_; - iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1; - } -} - - -const char * -ValueInternalMap::key( const IteratorState &iterator ) -{ - JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." ); - return iterator.link_->keys_[iterator.itemIndex_]; -} - -const char * -ValueInternalMap::key( const IteratorState &iterator, bool &isStatic ) -{ - JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." ); - isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic(); - return iterator.link_->keys_[iterator.itemIndex_]; -} - - -Value & -ValueInternalMap::value( const IteratorState &iterator ) -{ - JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." ); - return iterator.link_->items_[iterator.itemIndex_]; -} - - -int -ValueInternalMap::distance( const IteratorState &x, const IteratorState &y ) -{ - int offset = 0; - IteratorState it = x; - while ( !equals( it, y ) ) - increment( it ); - return offset; -} diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_reader.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_reader.cpp deleted file mode 100755 index 5af16c8d..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_reader.cpp +++ /dev/null @@ -1,892 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#if _MSC_VER >= 1400 // VC++ 8.0 -#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated. -#endif - -namespace Json { - -// QNX is strict about declaring C symbols in the std namespace. -#ifdef __QNXNTO__ -using std::memcpy; -using std::sprintf; -using std::sscanf; -#endif - -// Implementation of class Features -// //////////////////////////////// - -Features::Features() - : allowComments_( true ) - , strictRoot_( false ) -{ -} - - -Features -Features::all() -{ - return Features(); -} - - -Features -Features::strictMode() -{ - Features features; - features.allowComments_ = false; - features.strictRoot_ = true; - return features; -} - -// Implementation of class Reader -// //////////////////////////////// - - -static inline bool -in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4 ) -{ - return c == c1 || c == c2 || c == c3 || c == c4; -} - -static inline bool -in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4, Reader::Char c5 ) -{ - return c == c1 || c == c2 || c == c3 || c == c4 || c == c5; -} - - -static bool -containsNewLine( Reader::Location begin, - Reader::Location end ) -{ - for ( ;begin < end; ++begin ) - if ( *begin == '\n' || *begin == '\r' ) - return true; - return false; -} - -static std::string codePointToUTF8(unsigned int cp) -{ - std::string result; - - // based on description from http://en.wikipedia.org/wiki/UTF-8 - - if (cp <= 0x7f) - { - result.resize(1); - result[0] = static_cast(cp); - } - else if (cp <= 0x7FF) - { - result.resize(2); - result[1] = static_cast(0x80 | (0x3f & cp)); - result[0] = static_cast(0xC0 | (0x1f & (cp >> 6))); - } - else if (cp <= 0xFFFF) - { - result.resize(3); - result[2] = static_cast(0x80 | (0x3f & cp)); - result[1] = 0x80 | static_cast((0x3f & (cp >> 6))); - result[0] = 0xE0 | static_cast((0xf & (cp >> 12))); - } - else if (cp <= 0x10FFFF) - { - result.resize(4); - result[3] = static_cast(0x80 | (0x3f & cp)); - result[2] = static_cast(0x80 | (0x3f & (cp >> 6))); - result[1] = static_cast(0x80 | (0x3f & (cp >> 12))); - result[0] = static_cast(0xF0 | (0x7 & (cp >> 18))); - } - - return result; -} - - -// Class Reader -// ////////////////////////////////////////////////////////////////// - -Reader::Reader() - : features_( Features::all() ) -{ -} - - -Reader::Reader( const Features &features ) - : features_( features ) -{ -} - - -bool -Reader::parse( const std::string &document, - Value &root, - bool collectComments ) -{ - document_ = document; - const char *begin = document_.c_str(); - const char *end = begin + document_.length(); - return parse( begin, end, root, collectComments ); -} - - -bool -Reader::parse( std::istream& sin, - Value &root, - bool collectComments ) -{ - //std::istream_iterator begin(sin); - //std::istream_iterator end; - // Those would allow streamed input from a file, if parse() were a - // template function. - - // Since std::string is reference-counted, this at least does not - // create an extra copy. - std::string doc; - std::getline(sin, doc, (char)EOF); - return parse( doc, root, collectComments ); -} - -bool -Reader::parse( const char *beginDoc, const char *endDoc, - Value &root, - bool collectComments ) -{ - if ( !features_.allowComments_ ) - { - collectComments = false; - } - - begin_ = beginDoc; - end_ = endDoc; - collectComments_ = collectComments; - current_ = begin_; - lastValueEnd_ = 0; - lastValue_ = 0; - commentsBefore_ = ""; - errors_.clear(); - while ( !nodes_.empty() ) - nodes_.pop(); - nodes_.push( &root ); - - bool successful = readValue(); - Token token; - skipCommentTokens( token ); - if ( collectComments_ && !commentsBefore_.empty() ) - root.setComment( commentsBefore_, commentAfter ); - if ( features_.strictRoot_ ) - { - if ( !root.isArray() && !root.isObject() ) - { - // Set error location to start of doc, ideally should be first token found in doc - token.type_ = tokenError; - token.start_ = beginDoc; - token.end_ = endDoc; - addError( "A valid JSON document must be either an array or an object value.", - token ); - return false; - } - } - return successful; -} - - -bool -Reader::readValue() -{ - Token token; - skipCommentTokens( token ); - bool successful = true; - - if ( collectComments_ && !commentsBefore_.empty() ) - { - currentValue().setComment( commentsBefore_, commentBefore ); - commentsBefore_ = ""; - } - - - switch ( token.type_ ) - { - case tokenObjectBegin: - successful = readObject( token ); - break; - case tokenArrayBegin: - successful = readArray( token ); - break; - case tokenNumber: - successful = decodeNumber( token ); - break; - case tokenString: - successful = decodeString( token ); - break; - case tokenTrue: - currentValue() = true; - break; - case tokenFalse: - currentValue() = false; - break; - case tokenNull: - currentValue() = Value(); - break; - default: - return addError( "Syntax error: value, object or array expected.", token ); - } - - if ( collectComments_ ) - { - lastValueEnd_ = current_; - lastValue_ = ¤tValue(); - } - - return successful; -} - - -void -Reader::skipCommentTokens( Token &token ) -{ - if ( features_.allowComments_ ) - { - do - { - readToken( token ); - } - while ( token.type_ == tokenComment ); - } - else - { - readToken( token ); - } -} - - -bool -Reader::expectToken( TokenType type, Token &token, const char *message ) -{ - readToken( token ); - if ( token.type_ != type ) - return addError( message, token ); - return true; -} - - -bool -Reader::readToken( Token &token ) -{ - skipSpaces(); - token.start_ = current_; - Char c = getNextChar(); - bool ok = true; - switch ( c ) - { - case '{': - token.type_ = tokenObjectBegin; - break; - case '}': - token.type_ = tokenObjectEnd; - break; - case '[': - token.type_ = tokenArrayBegin; - break; - case ']': - token.type_ = tokenArrayEnd; - break; - case '"': - token.type_ = tokenString; - ok = readString(); - break; - case '/': - token.type_ = tokenComment; - ok = readComment(); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - token.type_ = tokenNumber; - readNumber(); - break; - case 't': - token.type_ = tokenTrue; - ok = match( "rue", 3 ); - break; - case 'f': - token.type_ = tokenFalse; - ok = match( "alse", 4 ); - break; - case 'n': - token.type_ = tokenNull; - ok = match( "ull", 3 ); - break; - case ',': - token.type_ = tokenArraySeparator; - break; - case ':': - token.type_ = tokenMemberSeparator; - break; - case 0: - token.type_ = tokenEndOfStream; - break; - default: - ok = false; - break; - } - if ( !ok ) - token.type_ = tokenError; - token.end_ = current_; - return true; -} - - -void -Reader::skipSpaces() -{ - while ( current_ != end_ ) - { - Char c = *current_; - if ( c == ' ' || c == '\t' || c == '\r' || c == '\n' ) - ++current_; - else - break; - } -} - - -bool -Reader::match( Location pattern, - int patternLength ) -{ - if ( end_ - current_ < patternLength ) - return false; - int index = patternLength; - while ( index-- ) - if ( current_[index] != pattern[index] ) - return false; - current_ += patternLength; - return true; -} - - -bool -Reader::readComment() -{ - Location commentBegin = current_ - 1; - Char c = getNextChar(); - bool successful = false; - if ( c == '*' ) - successful = readCStyleComment(); - else if ( c == '/' ) - successful = readCppStyleComment(); - if ( !successful ) - return false; - - if ( collectComments_ ) - { - CommentPlacement placement = commentBefore; - if ( lastValueEnd_ && !containsNewLine( lastValueEnd_, commentBegin ) ) - { - if ( c != '*' || !containsNewLine( commentBegin, current_ ) ) - placement = commentAfterOnSameLine; - } - - addComment( commentBegin, current_, placement ); - } - return true; -} - - -void -Reader::addComment( Location begin, - Location end, - CommentPlacement placement ) -{ - assert( collectComments_ ); - if ( placement == commentAfterOnSameLine ) - { - assert( lastValue_ != 0 ); - lastValue_->setComment( std::string( begin, end ), placement ); - } - else - { - if ( !commentsBefore_.empty() ) - commentsBefore_ += "\n"; - commentsBefore_ += std::string( begin, end ); - } -} - - -bool -Reader::readCStyleComment() -{ - while ( current_ != end_ ) - { - Char c = getNextChar(); - if ( c == '*' && *current_ == '/' ) - break; - } - return getNextChar() == '/'; -} - - -bool -Reader::readCppStyleComment() -{ - while ( current_ != end_ ) - { - Char c = getNextChar(); - if ( c == '\r' || c == '\n' ) - break; - } - return true; -} - - -void -Reader::readNumber() -{ - while ( current_ != end_ ) - { - if ( !(*current_ >= '0' && *current_ <= '9') && - !in( *current_, '.', 'e', 'E', '+', '-' ) ) - break; - ++current_; - } -} - -bool -Reader::readString() -{ - Char c = 0; - while ( current_ != end_ ) - { - c = getNextChar(); - if ( c == '\\' ) - getNextChar(); - else if ( c == '"' ) - break; - } - return c == '"'; -} - - -bool -Reader::readObject( Token &tokenStart ) -{ - Token tokenName; - std::string name; - currentValue() = Value( objectValue ); - while ( readToken( tokenName ) ) - { - bool initialTokenOk = true; - while ( tokenName.type_ == tokenComment && initialTokenOk ) - initialTokenOk = readToken( tokenName ); - if ( !initialTokenOk ) - break; - if ( tokenName.type_ == tokenObjectEnd && name.empty() ) // empty object - return true; - if ( tokenName.type_ != tokenString ) - break; - - name = ""; - if ( !decodeString( tokenName, name ) ) - return recoverFromError( tokenObjectEnd ); - - Token colon; - if ( !readToken( colon ) || colon.type_ != tokenMemberSeparator ) - { - return addErrorAndRecover( "Missing ':' after object member name", - colon, - tokenObjectEnd ); - } - Value &value = currentValue()[ name ]; - nodes_.push( &value ); - bool ok = readValue(); - nodes_.pop(); - if ( !ok ) // error already set - return recoverFromError( tokenObjectEnd ); - - Token comma; - if ( !readToken( comma ) - || ( comma.type_ != tokenObjectEnd && - comma.type_ != tokenArraySeparator && - comma.type_ != tokenComment ) ) - { - return addErrorAndRecover( "Missing ',' or '}' in object declaration", - comma, - tokenObjectEnd ); - } - bool finalizeTokenOk = true; - while ( comma.type_ == tokenComment && - finalizeTokenOk ) - finalizeTokenOk = readToken( comma ); - if ( comma.type_ == tokenObjectEnd ) - return true; - } - return addErrorAndRecover( "Missing '}' or object member name", - tokenName, - tokenObjectEnd ); -} - - -bool -Reader::readArray( Token &tokenStart ) -{ - currentValue() = Value( arrayValue ); - skipSpaces(); - if ( *current_ == ']' ) // empty array - { - Token endArray; - readToken( endArray ); - return true; - } - int index = 0; - while ( true ) - { - Value &value = currentValue()[ index++ ]; - nodes_.push( &value ); - bool ok = readValue(); - nodes_.pop(); - if ( !ok ) // error already set - return recoverFromError( tokenArrayEnd ); - - Token token; - // Accept Comment after last item in the array. - ok = readToken( token ); - while ( token.type_ == tokenComment && ok ) - { - ok = readToken( token ); - } - bool badTokenType = ( token.type_ == tokenArraySeparator && - token.type_ == tokenArrayEnd ); - if ( !ok || badTokenType ) - { - return addErrorAndRecover( "Missing ',' or ']' in array declaration", - token, - tokenArrayEnd ); - } - if ( token.type_ == tokenArrayEnd ) - break; - } - return true; -} - - -bool -Reader::decodeNumber( Token &token ) -{ - bool isDouble = false; - for ( Location inspect = token.start_; inspect != token.end_; ++inspect ) - { - isDouble = isDouble - || in( *inspect, '.', 'e', 'E', '+' ) - || ( *inspect == '-' && inspect != token.start_ ); - } - if ( isDouble ) - return decodeDouble( token ); - Location current = token.start_; - bool isNegative = *current == '-'; - if ( isNegative ) - ++current; - Value::UInt threshold = (isNegative ? Value::UInt(-Value::minInt) - : Value::maxUInt) / 10; - Value::UInt value = 0; - while ( current < token.end_ ) - { - Char c = *current++; - if ( c < '0' || c > '9' ) - return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token ); - if ( value >= threshold ) - return decodeDouble( token ); - value = value * 10 + Value::UInt(c - '0'); - } - if ( isNegative ) - currentValue() = -Value::Int( value ); - else if ( value <= Value::UInt(Value::maxInt) ) - currentValue() = Value::Int( value ); - else - currentValue() = value; - return true; -} - - -bool -Reader::decodeDouble( Token &token ) -{ - double value = 0; - const int bufferSize = 32; - int count; - int length = int(token.end_ - token.start_); - if ( length <= bufferSize ) - { - Char buffer[bufferSize]; - memcpy( buffer, token.start_, length ); - buffer[length] = 0; - count = sscanf( buffer, "%lf", &value ); - } - else - { - std::string buffer( token.start_, token.end_ ); - count = sscanf( buffer.c_str(), "%lf", &value ); - } - - if ( count != 1 ) - return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token ); - currentValue() = value; - return true; -} - - -bool -Reader::decodeString( Token &token ) -{ - std::string decoded; - if ( !decodeString( token, decoded ) ) - return false; - currentValue() = decoded; - return true; -} - - -bool -Reader::decodeString( Token &token, std::string &decoded ) -{ - decoded.reserve( token.end_ - token.start_ - 2 ); - Location current = token.start_ + 1; // skip '"' - Location end = token.end_ - 1; // do not include '"' - while ( current != end ) - { - Char c = *current++; - if ( c == '"' ) - break; - else if ( c == '\\' ) - { - if ( current == end ) - return addError( "Empty escape sequence in string", token, current ); - Char escape = *current++; - switch ( escape ) - { - case '"': decoded += '"'; break; - case '/': decoded += '/'; break; - case '\\': decoded += '\\'; break; - case 'b': decoded += '\b'; break; - case 'f': decoded += '\f'; break; - case 'n': decoded += '\n'; break; - case 'r': decoded += '\r'; break; - case 't': decoded += '\t'; break; - case 'u': - { - unsigned int unicode; - if ( !decodeUnicodeCodePoint( token, current, end, unicode ) ) - return false; - decoded += codePointToUTF8(unicode); - } - break; - default: - return addError( "Bad escape sequence in string", token, current ); - } - } - else - { - decoded += c; - } - } - return true; -} - -bool -Reader::decodeUnicodeCodePoint( Token &token, - Location ¤t, - Location end, - unsigned int &unicode ) -{ - - if ( !decodeUnicodeEscapeSequence( token, current, end, unicode ) ) - return false; - if (unicode >= 0xD800 && unicode <= 0xDBFF) - { - // surrogate pairs - if (end - current < 6) - return addError( "additional six characters expected to parse unicode surrogate pair.", token, current ); - unsigned int surrogatePair; - if (*(current++) == '\\' && *(current++)== 'u') - { - if (decodeUnicodeEscapeSequence( token, current, end, surrogatePair )) - { - unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF); - } - else - return false; - } - else - return addError( "expecting another \\u token to begin the second half of a unicode surrogate pair", token, current ); - } - return true; -} - -bool -Reader::decodeUnicodeEscapeSequence( Token &token, - Location ¤t, - Location end, - unsigned int &unicode ) -{ - if ( end - current < 4 ) - return addError( "Bad unicode escape sequence in string: four digits expected.", token, current ); - unicode = 0; - for ( int index =0; index < 4; ++index ) - { - Char c = *current++; - unicode *= 16; - if ( c >= '0' && c <= '9' ) - unicode += c - '0'; - else if ( c >= 'a' && c <= 'f' ) - unicode += c - 'a' + 10; - else if ( c >= 'A' && c <= 'F' ) - unicode += c - 'A' + 10; - else - return addError( "Bad unicode escape sequence in string: hexadecimal digit expected.", token, current ); - } - return true; -} - - -bool -Reader::addError( const std::string &message, - Token &token, - Location extra ) -{ - ErrorInfo info; - info.token_ = token; - info.message_ = message; - info.extra_ = extra; - errors_.push_back( info ); - return false; -} - - -bool -Reader::recoverFromError( TokenType skipUntilToken ) -{ - int errorCount = int(errors_.size()); - Token skip; - while ( true ) - { - if ( !readToken(skip) ) - errors_.resize( errorCount ); // discard errors caused by recovery - if ( skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream ) - break; - } - errors_.resize( errorCount ); - return false; -} - - -bool -Reader::addErrorAndRecover( const std::string &message, - Token &token, - TokenType skipUntilToken ) -{ - addError( message, token ); - return recoverFromError( skipUntilToken ); -} - - -Value & -Reader::currentValue() -{ - return *(nodes_.top()); -} - - -Reader::Char -Reader::getNextChar() -{ - if ( current_ == end_ ) - return 0; - return *current_++; -} - - -void -Reader::getLocationLineAndColumn( Location location, - int &line, - int &column ) const -{ - Location current = begin_; - Location lastLineStart = current; - line = 0; - while ( current < location && current != end_ ) - { - Char c = *current++; - if ( c == '\r' ) - { - if ( *current == '\n' ) - ++current; - lastLineStart = current; - ++line; - } - else if ( c == '\n' ) - { - lastLineStart = current; - ++line; - } - } - // column & line start at 1 - column = int(location - lastLineStart) + 1; - ++line; -} - - -std::string -Reader::getLocationLineAndColumn( Location location ) const -{ - int line, column; - getLocationLineAndColumn( location, line, column ); - char buffer[18+16+16+1]; - sprintf( buffer, "Line %d, Column %d", line, column ); - return buffer; -} - - -std::string -Reader::getFormatedErrorMessages() const -{ - std::string formattedMessage; - for ( Errors::const_iterator itError = errors_.begin(); - itError != errors_.end(); - ++itError ) - { - const ErrorInfo &error = *itError; - formattedMessage += "* " + getLocationLineAndColumn( error.token_.start_ ) + "\n"; - formattedMessage += " " + error.message_ + "\n"; - if ( error.extra_ ) - formattedMessage += "See " + getLocationLineAndColumn( error.extra_ ) + " for detail.\n"; - } - return formattedMessage; -} - - -std::istream& operator>>( std::istream &sin, Value &root ) -{ - Json::Reader reader; - bool ok = reader.parse(sin, root, true); - //JSON_ASSERT( ok ); - if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages()); - return sin; -} - - -} // namespace Json diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_value.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_value.cpp deleted file mode 100755 index 6e5dcd3e..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_value.cpp +++ /dev/null @@ -1,1726 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#ifdef JSON_USE_CPPTL -# include -#endif -#include // size_t -#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR -# include "json_batchallocator.h" -#endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR - -#define JSON_ASSERT_UNREACHABLE assert( false ) -#define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw -#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message ); - -namespace Json { - -// QNX is strict about declaring C symbols in the std namespace. -#ifdef __QNXNTO__ -using std::memcpy; -using std::strchr; -using std::strcmp; -using std::strlen; -#endif - -const Value Value::null; -const Int Value::minInt = Int( ~(UInt(-1)/2) ); -const Int Value::maxInt = Int( UInt(-1)/2 ); -const UInt Value::maxUInt = UInt(-1); - -// A "safe" implementation of strdup. Allow null pointer to be passed. -// Also avoid warning on msvc80. -// -//inline char *safeStringDup( const char *czstring ) -//{ -// if ( czstring ) -// { -// const size_t length = (unsigned int)( strlen(czstring) + 1 ); -// char *newString = static_cast( malloc( length ) ); -// memcpy( newString, czstring, length ); -// return newString; -// } -// return 0; -//} -// -//inline char *safeStringDup( const std::string &str ) -//{ -// if ( !str.empty() ) -// { -// const size_t length = str.length(); -// char *newString = static_cast( malloc( length + 1 ) ); -// memcpy( newString, str.c_str(), length ); -// newString[length] = 0; -// return newString; -// } -// return 0; -//} - -ValueAllocator::~ValueAllocator() -{ -} - -class DefaultValueAllocator : public ValueAllocator -{ -public: - virtual ~DefaultValueAllocator() - { - } - - virtual char *makeMemberName( const char *memberName ) - { - return duplicateStringValue( memberName ); - } - - virtual void releaseMemberName( char *memberName ) - { - releaseStringValue( memberName ); - } - - virtual char *duplicateStringValue( const char *value, - unsigned int length = unknown ) - { - //@todo invesgate this old optimization - //if ( !value || value[0] == 0 ) - // return 0; - - if ( length == unknown ) - length = (unsigned int)strlen(value); - char *newString = static_cast( malloc( length + 1 ) ); - memcpy( newString, value, length ); - newString[length] = 0; - return newString; - } - - virtual void releaseStringValue( char *value ) - { - if ( value ) - free( value ); - } -}; - -static ValueAllocator *&valueAllocator() -{ - static DefaultValueAllocator defaultAllocator; - static ValueAllocator *valueAllocator = &defaultAllocator; - return valueAllocator; -} - -static struct DummyValueAllocatorInitializer { - DummyValueAllocatorInitializer() - { - valueAllocator(); // ensure valueAllocator() statics are initialized before main(). - } -} dummyValueAllocatorInitializer; - - - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ValueInternals... -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -#ifdef JSON_VALUE_USE_INTERNAL_MAP -# include "json_internalarray.inl" -# include "json_internalmap.inl" -#endif // JSON_VALUE_USE_INTERNAL_MAP - -# include "json_valueiterator.inl" - - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class Value::CommentInfo -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// - - -Value::CommentInfo::CommentInfo() - : comment_( 0 ) -{ -} - -Value::CommentInfo::~CommentInfo() -{ - if ( comment_ ) - valueAllocator()->releaseStringValue( comment_ ); -} - - -void -Value::CommentInfo::setComment( const char *text ) -{ - if ( comment_ ) - valueAllocator()->releaseStringValue( comment_ ); - JSON_ASSERT( text ); - JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /"); - // It seems that /**/ style comments are acceptable as well. - comment_ = valueAllocator()->duplicateStringValue( text ); -} - - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class Value::CZString -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -# ifndef JSON_VALUE_USE_INTERNAL_MAP - -// Notes: index_ indicates if the string was allocated when -// a string is stored. - -Value::CZString::CZString( int index ) - : cstr_( 0 ) - , index_( index ) -{ -} - -Value::CZString::CZString( const char *cstr, DuplicationPolicy allocate ) - : cstr_( allocate == duplicate ? valueAllocator()->makeMemberName(cstr) - : cstr ) - , index_( allocate ) -{ -} - -Value::CZString::CZString( const CZString &other ) -: cstr_( other.index_ != noDuplication && other.cstr_ != 0 - ? valueAllocator()->makeMemberName( other.cstr_ ) - : other.cstr_ ) - , index_( other.cstr_ ? (other.index_ == noDuplication ? noDuplication : duplicate) - : other.index_ ) -{ -} - -Value::CZString::~CZString() -{ - if ( cstr_ && index_ == duplicate ) - valueAllocator()->releaseMemberName( const_cast( cstr_ ) ); -} - -void -Value::CZString::swap( CZString &other ) -{ - std::swap( cstr_, other.cstr_ ); - std::swap( index_, other.index_ ); -} - -Value::CZString & -Value::CZString::operator =( const CZString &other ) -{ - CZString temp( other ); - swap( temp ); - return *this; -} - -bool -Value::CZString::operator<( const CZString &other ) const -{ - if ( cstr_ ) - return strcmp( cstr_, other.cstr_ ) < 0; - return index_ < other.index_; -} - -bool -Value::CZString::operator==( const CZString &other ) const -{ - if ( cstr_ ) - return strcmp( cstr_, other.cstr_ ) == 0; - return index_ == other.index_; -} - - -int -Value::CZString::index() const -{ - return index_; -} - - -const char * -Value::CZString::c_str() const -{ - return cstr_; -} - -bool -Value::CZString::isStaticString() const -{ - return index_ == noDuplication; -} - -#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP - - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class Value::Value -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// - -/*! \internal Default constructor initialization must be equivalent to: - * memset( this, 0, sizeof(Value) ) - * This optimization is used in ValueInternalMap fast allocator. - */ -Value::Value( ValueType type ) - : type_( type ) - , allocated_( 0 ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - switch ( type ) - { - case nullValue: - break; - case intValue: - case uintValue: - value_.int_ = 0; - break; - case realValue: - value_.real_ = 0.0; - break; - case stringValue: - value_.string_ = 0; - break; -#ifndef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - case objectValue: - value_.map_ = new ObjectValues(); - break; -#else - case arrayValue: - value_.array_ = arrayAllocator()->newArray(); - break; - case objectValue: - value_.map_ = mapAllocator()->newMap(); - break; -#endif - case booleanValue: - value_.bool_ = false; - break; - default: - JSON_ASSERT_UNREACHABLE; - } -} - - -Value::Value( Int value ) - : type_( intValue ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.int_ = value; -} - - -Value::Value( UInt value ) - : type_( uintValue ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.uint_ = value; -} - -Value::Value( double value ) - : type_( realValue ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.real_ = value; -} - -Value::Value( const char *value ) - : type_( stringValue ) - , allocated_( true ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.string_ = valueAllocator()->duplicateStringValue( value ); -} - - -Value::Value( const char *beginValue, - const char *endValue ) - : type_( stringValue ) - , allocated_( true ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.string_ = valueAllocator()->duplicateStringValue( beginValue, - UInt(endValue - beginValue) ); -} - - -Value::Value( const std::string &value ) - : type_( stringValue ) - , allocated_( true ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.string_ = valueAllocator()->duplicateStringValue( value.c_str(), - (unsigned int)value.length() ); - -} - -Value::Value( const StaticString &value ) - : type_( stringValue ) - , allocated_( false ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.string_ = const_cast( value.c_str() ); -} - - -# ifdef JSON_USE_CPPTL -Value::Value( const CppTL::ConstString &value ) - : type_( stringValue ) - , allocated_( true ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.string_ = valueAllocator()->duplicateStringValue( value, value.length() ); -} -# endif - -Value::Value( bool value ) - : type_( booleanValue ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - value_.bool_ = value; -} - - -Value::Value( const Value &other ) - : type_( other.type_ ) - , comments_( 0 ) -# ifdef JSON_VALUE_USE_INTERNAL_MAP - , itemIsUsed_( 0 ) -#endif -{ - switch ( type_ ) - { - case nullValue: - case intValue: - case uintValue: - case realValue: - case booleanValue: - value_ = other.value_; - break; - case stringValue: - if ( other.value_.string_ ) - { - value_.string_ = valueAllocator()->duplicateStringValue( other.value_.string_ ); - allocated_ = true; - } - else - value_.string_ = 0; - break; -#ifndef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - case objectValue: - value_.map_ = new ObjectValues( *other.value_.map_ ); - break; -#else - case arrayValue: - value_.array_ = arrayAllocator()->newArrayCopy( *other.value_.array_ ); - break; - case objectValue: - value_.map_ = mapAllocator()->newMapCopy( *other.value_.map_ ); - break; -#endif - default: - JSON_ASSERT_UNREACHABLE; - } - if ( other.comments_ ) - { - comments_ = new CommentInfo[numberOfCommentPlacement]; - for ( int comment =0; comment < numberOfCommentPlacement; ++comment ) - { - const CommentInfo &otherComment = other.comments_[comment]; - if ( otherComment.comment_ ) - comments_[comment].setComment( otherComment.comment_ ); - } - } -} - - -Value::~Value() -{ - switch ( type_ ) - { - case nullValue: - case intValue: - case uintValue: - case realValue: - case booleanValue: - break; - case stringValue: - if ( allocated_ ) - valueAllocator()->releaseStringValue( value_.string_ ); - break; -#ifndef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - case objectValue: - delete value_.map_; - break; -#else - case arrayValue: - arrayAllocator()->destructArray( value_.array_ ); - break; - case objectValue: - mapAllocator()->destructMap( value_.map_ ); - break; -#endif - default: - JSON_ASSERT_UNREACHABLE; - } - - if ( comments_ ) - delete[] comments_; -} - -Value & -Value::operator=( const Value &other ) -{ - Value temp( other ); - swap( temp ); - return *this; -} - -void -Value::swap( Value &other ) -{ - ValueType temp = type_; - type_ = other.type_; - other.type_ = temp; - std::swap( value_, other.value_ ); - int temp2 = allocated_; - allocated_ = other.allocated_; - other.allocated_ = temp2; -} - -ValueType -Value::type() const -{ - return type_; -} - - -int -Value::compare( const Value &other ) -{ - /* - int typeDelta = other.type_ - type_; - switch ( type_ ) - { - case nullValue: - - return other.type_ == type_; - case intValue: - if ( other.type_.isNumeric() - case uintValue: - case realValue: - case booleanValue: - break; - case stringValue, - break; - case arrayValue: - delete value_.array_; - break; - case objectValue: - delete value_.map_; - default: - JSON_ASSERT_UNREACHABLE; - } - */ - return 0; // unreachable -} - -bool -Value::operator <( const Value &other ) const -{ - int typeDelta = type_ - other.type_; - if ( typeDelta ) - return typeDelta < 0 ? true : false; - switch ( type_ ) - { - case nullValue: - return false; - case intValue: - return value_.int_ < other.value_.int_; - case uintValue: - return value_.uint_ < other.value_.uint_; - case realValue: - return value_.real_ < other.value_.real_; - case booleanValue: - return value_.bool_ < other.value_.bool_; - case stringValue: - return ( value_.string_ == 0 && other.value_.string_ ) - || ( other.value_.string_ - && value_.string_ - && strcmp( value_.string_, other.value_.string_ ) < 0 ); -#ifndef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - case objectValue: - { - int delta = int( value_.map_->size() - other.value_.map_->size() ); - if ( delta ) - return delta < 0; - return (*value_.map_) < (*other.value_.map_); - } -#else - case arrayValue: - return value_.array_->compare( *(other.value_.array_) ) < 0; - case objectValue: - return value_.map_->compare( *(other.value_.map_) ) < 0; -#endif - default: - JSON_ASSERT_UNREACHABLE; - } - return 0; // unreachable -} - -bool -Value::operator <=( const Value &other ) const -{ - return !(other > *this); -} - -bool -Value::operator >=( const Value &other ) const -{ - return !(*this < other); -} - -bool -Value::operator >( const Value &other ) const -{ - return other < *this; -} - -bool -Value::operator ==( const Value &other ) const -{ - //if ( type_ != other.type_ ) - // GCC 2.95.3 says: - // attempt to take address of bit-field structure member `Json::Value::type_' - // Beats me, but a temp solves the problem. - int temp = other.type_; - if ( type_ != temp ) - return false; - switch ( type_ ) - { - case nullValue: - return true; - case intValue: - return value_.int_ == other.value_.int_; - case uintValue: - return value_.uint_ == other.value_.uint_; - case realValue: - return value_.real_ == other.value_.real_; - case booleanValue: - return value_.bool_ == other.value_.bool_; - case stringValue: - return ( value_.string_ == other.value_.string_ ) - || ( other.value_.string_ - && value_.string_ - && strcmp( value_.string_, other.value_.string_ ) == 0 ); -#ifndef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - case objectValue: - return value_.map_->size() == other.value_.map_->size() - && (*value_.map_) == (*other.value_.map_); -#else - case arrayValue: - return value_.array_->compare( *(other.value_.array_) ) == 0; - case objectValue: - return value_.map_->compare( *(other.value_.map_) ) == 0; -#endif - default: - JSON_ASSERT_UNREACHABLE; - } - return 0; // unreachable -} - -bool -Value::operator !=( const Value &other ) const -{ - return !( *this == other ); -} - -const char * -Value::asCString() const -{ - JSON_ASSERT( type_ == stringValue ); - return value_.string_; -} - - -std::string -Value::asString() const -{ - switch ( type_ ) - { - case nullValue: - return ""; - case stringValue: - return value_.string_ ? value_.string_ : ""; - case booleanValue: - return value_.bool_ ? "true" : "false"; - case intValue: - case uintValue: - case realValue: - case arrayValue: - case objectValue: - JSON_ASSERT_MESSAGE( false, "Type is not convertible to string" ); - default: - JSON_ASSERT_UNREACHABLE; - } - return ""; // unreachable -} - -# ifdef JSON_USE_CPPTL -CppTL::ConstString -Value::asConstString() const -{ - return CppTL::ConstString( asString().c_str() ); -} -# endif - -Value::Int -Value::asInt() const -{ - switch ( type_ ) - { - case nullValue: - return 0; - case intValue: - return value_.int_; - case uintValue: - JSON_ASSERT_MESSAGE( value_.uint_ < (unsigned)maxInt, "integer out of signed integer range" ); - return value_.uint_; - case realValue: - JSON_ASSERT_MESSAGE( value_.real_ >= minInt && value_.real_ <= maxInt, "Real out of signed integer range" ); - return Int( value_.real_ ); - case booleanValue: - return value_.bool_ ? 1 : 0; - case stringValue: - case arrayValue: - case objectValue: - JSON_ASSERT_MESSAGE( false, "Type is not convertible to int" ); - default: - JSON_ASSERT_UNREACHABLE; - } - return 0; // unreachable; -} - -Value::UInt -Value::asUInt() const -{ - switch ( type_ ) - { - case nullValue: - return 0; - case intValue: - JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" ); - return value_.int_; - case uintValue: - return value_.uint_; - case realValue: - JSON_ASSERT_MESSAGE( value_.real_ >= 0 && value_.real_ <= maxUInt, "Real out of unsigned integer range" ); - return UInt( value_.real_ ); - case booleanValue: - return value_.bool_ ? 1 : 0; - case stringValue: - case arrayValue: - case objectValue: - JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" ); - default: - JSON_ASSERT_UNREACHABLE; - } - return 0; // unreachable; -} - -double -Value::asDouble() const -{ - switch ( type_ ) - { - case nullValue: - return 0.0; - case intValue: - return value_.int_; - case uintValue: - return value_.uint_; - case realValue: - return value_.real_; - case booleanValue: - return value_.bool_ ? 1.0 : 0.0; - case stringValue: - case arrayValue: - case objectValue: - JSON_ASSERT_MESSAGE( false, "Type is not convertible to double" ); - default: - JSON_ASSERT_UNREACHABLE; - } - return 0; // unreachable; -} - -bool -Value::asBool() const -{ - switch ( type_ ) - { - case nullValue: - return false; - case intValue: - case uintValue: - return value_.int_ != 0; - case realValue: - return value_.real_ != 0.0; - case booleanValue: - return value_.bool_; - case stringValue: - return value_.string_ && value_.string_[0] != 0; - case arrayValue: - case objectValue: - return value_.map_->size() != 0; - default: - JSON_ASSERT_UNREACHABLE; - } - return false; // unreachable; -} - - -bool -Value::isConvertibleTo( ValueType other ) const -{ - switch ( type_ ) - { - case nullValue: - return true; - case intValue: - return ( other == nullValue && value_.int_ == 0 ) - || other == intValue - || ( other == uintValue && value_.int_ >= 0 ) - || other == realValue - || other == stringValue - || other == booleanValue; - case uintValue: - return ( other == nullValue && value_.uint_ == 0 ) - || ( other == intValue && value_.uint_ <= (unsigned)maxInt ) - || other == uintValue - || other == realValue - || other == stringValue - || other == booleanValue; - case realValue: - return ( other == nullValue && value_.real_ == 0.0 ) - || ( other == intValue && value_.real_ >= minInt && value_.real_ <= maxInt ) - || ( other == uintValue && value_.real_ >= 0 && value_.real_ <= maxUInt ) - || other == realValue - || other == stringValue - || other == booleanValue; - case booleanValue: - return ( other == nullValue && value_.bool_ == false ) - || other == intValue - || other == uintValue - || other == realValue - || other == stringValue - || other == booleanValue; - case stringValue: - return other == stringValue - || ( other == nullValue && (!value_.string_ || value_.string_[0] == 0) ); - case arrayValue: - return other == arrayValue - || ( other == nullValue && value_.map_->size() == 0 ); - case objectValue: - return other == objectValue - || ( other == nullValue && value_.map_->size() == 0 ); - default: - JSON_ASSERT_UNREACHABLE; - } - return false; // unreachable; -} - - -/// Number of values in array or object -Value::UInt -Value::size() const -{ - switch ( type_ ) - { - case nullValue: - case intValue: - case uintValue: - case realValue: - case booleanValue: - case stringValue: - return 0; -#ifndef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: // size of the array is highest index + 1 - if ( !value_.map_->empty() ) - { - ObjectValues::const_iterator itLast = value_.map_->end(); - --itLast; - return (*itLast).first.index()+1; - } - return 0; - case objectValue: - return Int( value_.map_->size() ); -#else - case arrayValue: - return Int( value_.array_->size() ); - case objectValue: - return Int( value_.map_->size() ); -#endif - default: - JSON_ASSERT_UNREACHABLE; - } - return 0; // unreachable; -} - - -bool -Value::empty() const -{ - if ( isNull() || isArray() || isObject() ) - return size() == 0u; - else - return false; -} - - -bool -Value::operator!() const -{ - return isNull(); -} - - -void -Value::clear() -{ - JSON_ASSERT( type_ == nullValue || type_ == arrayValue || type_ == objectValue ); - - switch ( type_ ) - { -#ifndef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - case objectValue: - value_.map_->clear(); - break; -#else - case arrayValue: - value_.array_->clear(); - break; - case objectValue: - value_.map_->clear(); - break; -#endif - default: - break; - } -} - -void -Value::resize( UInt newSize ) -{ - JSON_ASSERT( type_ == nullValue || type_ == arrayValue ); - if ( type_ == nullValue ) - *this = Value( arrayValue ); -#ifndef JSON_VALUE_USE_INTERNAL_MAP - UInt oldSize = size(); - if ( newSize == 0 ) - clear(); - else if ( newSize > oldSize ) - (*this)[ newSize - 1 ]; - else - { - for ( UInt index = newSize; index < oldSize; ++index ) - value_.map_->erase( index ); - assert( size() == newSize ); - } -#else - value_.array_->resize( newSize ); -#endif -} - - -Value & -Value::operator[]( UInt index ) -{ - JSON_ASSERT( type_ == nullValue || type_ == arrayValue ); - if ( type_ == nullValue ) - *this = Value( arrayValue ); -#ifndef JSON_VALUE_USE_INTERNAL_MAP - CZString key( index ); - ObjectValues::iterator it = value_.map_->lower_bound( key ); - if ( it != value_.map_->end() && (*it).first == key ) - return (*it).second; - - ObjectValues::value_type defaultValue( key, null ); - it = value_.map_->insert( it, defaultValue ); - return (*it).second; -#else - return value_.array_->resolveReference( index ); -#endif -} - - -const Value & -Value::operator[]( UInt index ) const -{ - JSON_ASSERT( type_ == nullValue || type_ == arrayValue ); - if ( type_ == nullValue ) - return null; -#ifndef JSON_VALUE_USE_INTERNAL_MAP - CZString key( index ); - ObjectValues::const_iterator it = value_.map_->find( key ); - if ( it == value_.map_->end() ) - return null; - return (*it).second; -#else - Value *value = value_.array_->find( index ); - return value ? *value : null; -#endif -} - - -Value & -Value::operator[]( const char *key ) -{ - return resolveReference( key, false ); -} - - -Value & -Value::resolveReference( const char *key, - bool isStatic ) -{ - JSON_ASSERT( type_ == nullValue || type_ == objectValue ); - if ( type_ == nullValue ) - *this = Value( objectValue ); -#ifndef JSON_VALUE_USE_INTERNAL_MAP - CZString actualKey( key, isStatic ? CZString::noDuplication - : CZString::duplicateOnCopy ); - ObjectValues::iterator it = value_.map_->lower_bound( actualKey ); - if ( it != value_.map_->end() && (*it).first == actualKey ) - return (*it).second; - - ObjectValues::value_type defaultValue( actualKey, null ); - it = value_.map_->insert( it, defaultValue ); - Value &value = (*it).second; - return value; -#else - return value_.map_->resolveReference( key, isStatic ); -#endif -} - - -Value -Value::get( UInt index, - const Value &defaultValue ) const -{ - const Value *value = &((*this)[index]); - return value == &null ? defaultValue : *value; -} - - -bool -Value::isValidIndex( UInt index ) const -{ - return index < size(); -} - - - -const Value & -Value::operator[]( const char *key ) const -{ - JSON_ASSERT( type_ == nullValue || type_ == objectValue ); - if ( type_ == nullValue ) - return null; -#ifndef JSON_VALUE_USE_INTERNAL_MAP - CZString actualKey( key, CZString::noDuplication ); - ObjectValues::const_iterator it = value_.map_->find( actualKey ); - if ( it == value_.map_->end() ) - return null; - return (*it).second; -#else - const Value *value = value_.map_->find( key ); - return value ? *value : null; -#endif -} - - -Value & -Value::operator[]( const std::string &key ) -{ - return (*this)[ key.c_str() ]; -} - - -const Value & -Value::operator[]( const std::string &key ) const -{ - return (*this)[ key.c_str() ]; -} - -Value & -Value::operator[]( const StaticString &key ) -{ - return resolveReference( key, true ); -} - - -# ifdef JSON_USE_CPPTL -Value & -Value::operator[]( const CppTL::ConstString &key ) -{ - return (*this)[ key.c_str() ]; -} - - -const Value & -Value::operator[]( const CppTL::ConstString &key ) const -{ - return (*this)[ key.c_str() ]; -} -# endif - - -Value & -Value::append( const Value &value ) -{ - return (*this)[size()] = value; -} - - -Value -Value::get( const char *key, - const Value &defaultValue ) const -{ - const Value *value = &((*this)[key]); - return value == &null ? defaultValue : *value; -} - - -Value -Value::get( const std::string &key, - const Value &defaultValue ) const -{ - return get( key.c_str(), defaultValue ); -} - -Value -Value::removeMember( const char* key ) -{ - JSON_ASSERT( type_ == nullValue || type_ == objectValue ); - if ( type_ == nullValue ) - return null; -#ifndef JSON_VALUE_USE_INTERNAL_MAP - CZString actualKey( key, CZString::noDuplication ); - ObjectValues::iterator it = value_.map_->find( actualKey ); - if ( it == value_.map_->end() ) - return null; - Value old(it->second); - value_.map_->erase(it); - return old; -#else - Value *value = value_.map_->find( key ); - if (value){ - Value old(*value); - value_.map_.remove( key ); - return old; - } else { - return null; - } -#endif -} - -Value -Value::removeMember( const std::string &key ) -{ - return removeMember( key.c_str() ); -} - -# ifdef JSON_USE_CPPTL -Value -Value::get( const CppTL::ConstString &key, - const Value &defaultValue ) const -{ - return get( key.c_str(), defaultValue ); -} -# endif - -bool -Value::isMember( const char *key ) const -{ - const Value *value = &((*this)[key]); - return value != &null; -} - - -bool -Value::isMember( const std::string &key ) const -{ - return isMember( key.c_str() ); -} - - -# ifdef JSON_USE_CPPTL -bool -Value::isMember( const CppTL::ConstString &key ) const -{ - return isMember( key.c_str() ); -} -#endif - -Value::Members -Value::getMemberNames() const -{ - JSON_ASSERT( type_ == nullValue || type_ == objectValue ); - if ( type_ == nullValue ) - return Value::Members(); - Members members; - members.reserve( value_.map_->size() ); -#ifndef JSON_VALUE_USE_INTERNAL_MAP - ObjectValues::const_iterator it = value_.map_->begin(); - ObjectValues::const_iterator itEnd = value_.map_->end(); - for ( ; it != itEnd; ++it ) - members.push_back( std::string( (*it).first.c_str() ) ); -#else - ValueInternalMap::IteratorState it; - ValueInternalMap::IteratorState itEnd; - value_.map_->makeBeginIterator( it ); - value_.map_->makeEndIterator( itEnd ); - for ( ; !ValueInternalMap::equals( it, itEnd ); ValueInternalMap::increment(it) ) - members.push_back( std::string( ValueInternalMap::key( it ) ) ); -#endif - return members; -} -// -//# ifdef JSON_USE_CPPTL -//EnumMemberNames -//Value::enumMemberNames() const -//{ -// if ( type_ == objectValue ) -// { -// return CppTL::Enum::any( CppTL::Enum::transform( -// CppTL::Enum::keys( *(value_.map_), CppTL::Type() ), -// MemberNamesTransform() ) ); -// } -// return EnumMemberNames(); -//} -// -// -//EnumValues -//Value::enumValues() const -//{ -// if ( type_ == objectValue || type_ == arrayValue ) -// return CppTL::Enum::anyValues( *(value_.map_), -// CppTL::Type() ); -// return EnumValues(); -//} -// -//# endif - - -bool -Value::isNull() const -{ - return type_ == nullValue; -} - - -bool -Value::isBool() const -{ - return type_ == booleanValue; -} - - -bool -Value::isInt() const -{ - return type_ == intValue; -} - - -bool -Value::isUInt() const -{ - return type_ == uintValue; -} - - -bool -Value::isIntegral() const -{ - return type_ == intValue - || type_ == uintValue - || type_ == booleanValue; -} - - -bool -Value::isDouble() const -{ - return type_ == realValue; -} - - -bool -Value::isNumeric() const -{ - return isIntegral() || isDouble(); -} - - -bool -Value::isString() const -{ - return type_ == stringValue; -} - - -bool -Value::isArray() const -{ - return type_ == nullValue || type_ == arrayValue; -} - - -bool -Value::isObject() const -{ - return type_ == nullValue || type_ == objectValue; -} - - -void -Value::setComment( const char *comment, - CommentPlacement placement ) -{ - if ( !comments_ ) - comments_ = new CommentInfo[numberOfCommentPlacement]; - comments_[placement].setComment( comment ); -} - - -void -Value::setComment( const std::string &comment, - CommentPlacement placement ) -{ - setComment( comment.c_str(), placement ); -} - - -bool -Value::hasComment( CommentPlacement placement ) const -{ - return comments_ != 0 && comments_[placement].comment_ != 0; -} - -std::string -Value::getComment( CommentPlacement placement ) const -{ - if ( hasComment(placement) ) - return comments_[placement].comment_; - return ""; -} - - -std::string -Value::toStyledString() const -{ - StyledWriter writer; - return writer.write( *this ); -} - - -Value::const_iterator -Value::begin() const -{ - switch ( type_ ) - { -#ifdef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - if ( value_.array_ ) - { - ValueInternalArray::IteratorState it; - value_.array_->makeBeginIterator( it ); - return const_iterator( it ); - } - break; - case objectValue: - if ( value_.map_ ) - { - ValueInternalMap::IteratorState it; - value_.map_->makeBeginIterator( it ); - return const_iterator( it ); - } - break; -#else - case arrayValue: - case objectValue: - if ( value_.map_ ) - return const_iterator( value_.map_->begin() ); - break; -#endif - default: - break; - } - return const_iterator(); -} - -Value::const_iterator -Value::end() const -{ - switch ( type_ ) - { -#ifdef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - if ( value_.array_ ) - { - ValueInternalArray::IteratorState it; - value_.array_->makeEndIterator( it ); - return const_iterator( it ); - } - break; - case objectValue: - if ( value_.map_ ) - { - ValueInternalMap::IteratorState it; - value_.map_->makeEndIterator( it ); - return const_iterator( it ); - } - break; -#else - case arrayValue: - case objectValue: - if ( value_.map_ ) - return const_iterator( value_.map_->end() ); - break; -#endif - default: - break; - } - return const_iterator(); -} - - -Value::iterator -Value::begin() -{ - switch ( type_ ) - { -#ifdef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - if ( value_.array_ ) - { - ValueInternalArray::IteratorState it; - value_.array_->makeBeginIterator( it ); - return iterator( it ); - } - break; - case objectValue: - if ( value_.map_ ) - { - ValueInternalMap::IteratorState it; - value_.map_->makeBeginIterator( it ); - return iterator( it ); - } - break; -#else - case arrayValue: - case objectValue: - if ( value_.map_ ) - return iterator( value_.map_->begin() ); - break; -#endif - default: - break; - } - return iterator(); -} - -Value::iterator -Value::end() -{ - switch ( type_ ) - { -#ifdef JSON_VALUE_USE_INTERNAL_MAP - case arrayValue: - if ( value_.array_ ) - { - ValueInternalArray::IteratorState it; - value_.array_->makeEndIterator( it ); - return iterator( it ); - } - break; - case objectValue: - if ( value_.map_ ) - { - ValueInternalMap::IteratorState it; - value_.map_->makeEndIterator( it ); - return iterator( it ); - } - break; -#else - case arrayValue: - case objectValue: - if ( value_.map_ ) - return iterator( value_.map_->end() ); - break; -#endif - default: - break; - } - return iterator(); -} - - -// class PathArgument -// ////////////////////////////////////////////////////////////////// - -PathArgument::PathArgument() - : kind_( kindNone ) -{ -} - - -PathArgument::PathArgument( Value::UInt index ) - : index_( index ) - , kind_( kindIndex ) -{ -} - - -PathArgument::PathArgument( const char *key ) - : key_( key ) - , kind_( kindKey ) -{ -} - - -PathArgument::PathArgument( const std::string &key ) - : key_( key.c_str() ) - , kind_( kindKey ) -{ -} - -// class Path -// ////////////////////////////////////////////////////////////////// - -Path::Path( const std::string &path, - const PathArgument &a1, - const PathArgument &a2, - const PathArgument &a3, - const PathArgument &a4, - const PathArgument &a5 ) -{ - InArgs in; - in.push_back( &a1 ); - in.push_back( &a2 ); - in.push_back( &a3 ); - in.push_back( &a4 ); - in.push_back( &a5 ); - makePath( path, in ); -} - - -void -Path::makePath( const std::string &path, - const InArgs &in ) -{ - const char *current = path.c_str(); - const char *end = current + path.length(); - InArgs::const_iterator itInArg = in.begin(); - while ( current != end ) - { - if ( *current == '[' ) - { - ++current; - if ( *current == '%' ) - addPathInArg( path, in, itInArg, PathArgument::kindIndex ); - else - { - Value::UInt index = 0; - for ( ; current != end && *current >= '0' && *current <= '9'; ++current ) - index = index * 10 + Value::UInt(*current - '0'); - args_.push_back( index ); - } - if ( current == end || *current++ != ']' ) - invalidPath( path, int(current - path.c_str()) ); - } - else if ( *current == '%' ) - { - addPathInArg( path, in, itInArg, PathArgument::kindKey ); - ++current; - } - else if ( *current == '.' ) - { - ++current; - } - else - { - const char *beginName = current; - while ( current != end && !strchr( "[.", *current ) ) - ++current; - args_.push_back( std::string( beginName, current ) ); - } - } -} - - -void -Path::addPathInArg( const std::string &path, - const InArgs &in, - InArgs::const_iterator &itInArg, - PathArgument::Kind kind ) -{ - if ( itInArg == in.end() ) - { - // Error: missing argument %d - } - else if ( (*itInArg)->kind_ != kind ) - { - // Error: bad argument type - } - else - { - args_.push_back( **itInArg ); - } -} - - -void -Path::invalidPath( const std::string &path, - int location ) -{ - // Error: invalid path. -} - - -const Value & -Path::resolve( const Value &root ) const -{ - const Value *node = &root; - for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) - { - const PathArgument &arg = *it; - if ( arg.kind_ == PathArgument::kindIndex ) - { - if ( !node->isArray() || node->isValidIndex( arg.index_ ) ) - { - // Error: unable to resolve path (array value expected at position... - } - node = &((*node)[arg.index_]); - } - else if ( arg.kind_ == PathArgument::kindKey ) - { - if ( !node->isObject() ) - { - // Error: unable to resolve path (object value expected at position...) - } - node = &((*node)[arg.key_]); - if ( node == &Value::null ) - { - // Error: unable to resolve path (object has no member named '' at position...) - } - } - } - return *node; -} - - -Value -Path::resolve( const Value &root, - const Value &defaultValue ) const -{ - const Value *node = &root; - for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) - { - const PathArgument &arg = *it; - if ( arg.kind_ == PathArgument::kindIndex ) - { - if ( !node->isArray() || node->isValidIndex( arg.index_ ) ) - return defaultValue; - node = &((*node)[arg.index_]); - } - else if ( arg.kind_ == PathArgument::kindKey ) - { - if ( !node->isObject() ) - return defaultValue; - node = &((*node)[arg.key_]); - if ( node == &Value::null ) - return defaultValue; - } - } - return *node; -} - - -Value & -Path::make( Value &root ) const -{ - Value *node = &root; - for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) - { - const PathArgument &arg = *it; - if ( arg.kind_ == PathArgument::kindIndex ) - { - if ( !node->isArray() ) - { - // Error: node is not an array at position ... - } - node = &((*node)[arg.index_]); - } - else if ( arg.kind_ == PathArgument::kindKey ) - { - if ( !node->isObject() ) - { - // Error: node is not an object at position... - } - node = &((*node)[arg.key_]); - } - } - return *node; -} - - -} // namespace Json diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_valueiterator.inl b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_valueiterator.inl deleted file mode 100755 index 736e260e..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_valueiterator.inl +++ /dev/null @@ -1,292 +0,0 @@ -// included by json_value.cpp -// everything is within Json namespace - - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class ValueIteratorBase -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// - -ValueIteratorBase::ValueIteratorBase() -#ifndef JSON_VALUE_USE_INTERNAL_MAP - : current_() - , isNull_( true ) -{ -} -#else - : isArray_( true ) - , isNull_( true ) -{ - iterator_.array_ = ValueInternalArray::IteratorState(); -} -#endif - - -#ifndef JSON_VALUE_USE_INTERNAL_MAP -ValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator ¤t ) - : current_( current ) - , isNull_( false ) -{ -} -#else -ValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state ) - : isArray_( true ) -{ - iterator_.array_ = state; -} - - -ValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state ) - : isArray_( false ) -{ - iterator_.map_ = state; -} -#endif - -Value & -ValueIteratorBase::deref() const -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - return current_->second; -#else - if ( isArray_ ) - return ValueInternalArray::dereference( iterator_.array_ ); - return ValueInternalMap::value( iterator_.map_ ); -#endif -} - - -void -ValueIteratorBase::increment() -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - ++current_; -#else - if ( isArray_ ) - ValueInternalArray::increment( iterator_.array_ ); - ValueInternalMap::increment( iterator_.map_ ); -#endif -} - - -void -ValueIteratorBase::decrement() -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - --current_; -#else - if ( isArray_ ) - ValueInternalArray::decrement( iterator_.array_ ); - ValueInternalMap::decrement( iterator_.map_ ); -#endif -} - - -ValueIteratorBase::difference_type -ValueIteratorBase::computeDistance( const SelfType &other ) const -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP -# ifdef JSON_USE_CPPTL_SMALLMAP - return current_ - other.current_; -# else - // Iterator for null value are initialized using the default - // constructor, which initialize current_ to the default - // std::map::iterator. As begin() and end() are two instance - // of the default std::map::iterator, they can not be compared. - // To allow this, we handle this comparison specifically. - if ( isNull_ && other.isNull_ ) - { - return 0; - } - - - // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL, - // which is the one used by default). - // Using a portable hand-made version for non random iterator instead: - // return difference_type( std::distance( current_, other.current_ ) ); - difference_type myDistance = 0; - for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it ) - { - ++myDistance; - } - return myDistance; -# endif -#else - if ( isArray_ ) - return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ ); - return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ ); -#endif -} - - -bool -ValueIteratorBase::isEqual( const SelfType &other ) const -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - if ( isNull_ ) - { - return other.isNull_; - } - return current_ == other.current_; -#else - if ( isArray_ ) - return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ ); - return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ ); -#endif -} - - -void -ValueIteratorBase::copy( const SelfType &other ) -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - current_ = other.current_; -#else - if ( isArray_ ) - iterator_.array_ = other.iterator_.array_; - iterator_.map_ = other.iterator_.map_; -#endif -} - - -Value -ValueIteratorBase::key() const -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - const Value::CZString czstring = (*current_).first; - if ( czstring.c_str() ) - { - if ( czstring.isStaticString() ) - return Value( StaticString( czstring.c_str() ) ); - return Value( czstring.c_str() ); - } - return Value( czstring.index() ); -#else - if ( isArray_ ) - return Value( ValueInternalArray::indexOf( iterator_.array_ ) ); - bool isStatic; - const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic ); - if ( isStatic ) - return Value( StaticString( memberName ) ); - return Value( memberName ); -#endif -} - - -UInt -ValueIteratorBase::index() const -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - const Value::CZString czstring = (*current_).first; - if ( !czstring.c_str() ) - return czstring.index(); - return Value::UInt( -1 ); -#else - if ( isArray_ ) - return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) ); - return Value::UInt( -1 ); -#endif -} - - -const char * -ValueIteratorBase::memberName() const -{ -#ifndef JSON_VALUE_USE_INTERNAL_MAP - const char *name = (*current_).first.c_str(); - return name ? name : ""; -#else - if ( !isArray_ ) - return ValueInternalMap::key( iterator_.map_ ); - return ""; -#endif -} - - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class ValueConstIterator -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// - -ValueConstIterator::ValueConstIterator() -{ -} - - -#ifndef JSON_VALUE_USE_INTERNAL_MAP -ValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator ¤t ) - : ValueIteratorBase( current ) -{ -} -#else -ValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state ) - : ValueIteratorBase( state ) -{ -} - -ValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state ) - : ValueIteratorBase( state ) -{ -} -#endif - -ValueConstIterator & -ValueConstIterator::operator =( const ValueIteratorBase &other ) -{ - copy( other ); - return *this; -} - - -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// class ValueIterator -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////// - -ValueIterator::ValueIterator() -{ -} - - -#ifndef JSON_VALUE_USE_INTERNAL_MAP -ValueIterator::ValueIterator( const Value::ObjectValues::iterator ¤t ) - : ValueIteratorBase( current ) -{ -} -#else -ValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state ) - : ValueIteratorBase( state ) -{ -} - -ValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state ) - : ValueIteratorBase( state ) -{ -} -#endif - -ValueIterator::ValueIterator( const ValueConstIterator &other ) - : ValueIteratorBase( other ) -{ -} - -ValueIterator::ValueIterator( const ValueIterator &other ) - : ValueIteratorBase( other ) -{ -} - -ValueIterator & -ValueIterator::operator =( const SelfType &other ) -{ - copy( other ); - return *this; -} diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_writer.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_writer.cpp deleted file mode 100755 index cdf4188f..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/json_writer.cpp +++ /dev/null @@ -1,829 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#if _MSC_VER >= 1400 // VC++ 8.0 -#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated. -#endif - -namespace Json { - -static bool isControlCharacter(char ch) -{ - return ch > 0 && ch <= 0x1F; -} - -static bool containsControlCharacter( const char* str ) -{ - while ( *str ) - { - if ( isControlCharacter( *(str++) ) ) - return true; - } - return false; -} -static void uintToString( unsigned int value, - char *¤t ) -{ - *--current = 0; - do - { - *--current = (value % 10) + '0'; - value /= 10; - } - while ( value != 0 ); -} - -std::string valueToString( Int value ) -{ - char buffer[32]; - char *current = buffer + sizeof(buffer); - bool isNegative = value < 0; - if ( isNegative ) - value = -value; - uintToString( UInt(value), current ); - if ( isNegative ) - *--current = '-'; - assert( current >= buffer ); - return current; -} - - -std::string valueToString( UInt value ) -{ - char buffer[32]; - char *current = buffer + sizeof(buffer); - uintToString( value, current ); - assert( current >= buffer ); - return current; -} - -std::string valueToString( double value ) -{ - char buffer[32]; -#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with visual studio 2005 to avoid warning. - sprintf_s(buffer, sizeof(buffer), "%#.16g", value); -#else - sprintf(buffer, "%#.16g", value); -#endif - char* ch = buffer + strlen(buffer) - 1; - if (*ch != '0') return buffer; // nothing to truncate, so save time - while(ch > buffer && *ch == '0'){ - --ch; - } - char* last_nonzero = ch; - while(ch >= buffer){ - switch(*ch){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - --ch; - continue; - case '.': - // Truncate zeroes to save bytes in output, but keep one. - *(last_nonzero+2) = '\0'; - return buffer; - default: - return buffer; - } - } - return buffer; -} - - -std::string valueToString( bool value ) -{ - return value ? "true" : "false"; -} - -std::string valueToQuotedString( const char *value ) -{ - // Not sure how to handle unicode... - if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value )) - return std::string("\"") + value + "\""; - // We have to walk value and escape any special characters. - // Appending to std::string is not efficient, but this should be rare. - // (Note: forward slashes are *not* rare, but I am not escaping them.) - unsigned maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL - std::string result; - result.reserve(maxsize); // to avoid lots of mallocs - result += "\""; - for (const char* c=value; *c != 0; ++c) - { - switch(*c) - { - case '\"': - result += "\\\""; - break; - case '\\': - result += "\\\\"; - break; - case '\b': - result += "\\b"; - break; - case '\f': - result += "\\f"; - break; - case '\n': - result += "\\n"; - break; - case '\r': - result += "\\r"; - break; - case '\t': - result += "\\t"; - break; - //case '/': - // Even though \/ is considered a legal escape in JSON, a bare - // slash is also legal, so I see no reason to escape it. - // (I hope I am not misunderstanding something. - // blep notes: actually escaping \/ may be useful in javascript to avoid (*c); - result += oss.str(); - } - else - { - result += *c; - } - break; - } - } - result += "\""; - return result; -} - -// Class Writer -// ////////////////////////////////////////////////////////////////// -Writer::~Writer() -{ -} - - -// Class FastWriter -// ////////////////////////////////////////////////////////////////// - -FastWriter::FastWriter() - : yamlCompatiblityEnabled_( false ) -{ -} - - -void -FastWriter::enableYAMLCompatibility() -{ - yamlCompatiblityEnabled_ = true; -} - - -std::string -FastWriter::write( const Value &root ) -{ - document_ = ""; - writeValue( root ); - document_ += "\n"; - return document_; -} - - -void -FastWriter::writeValue( const Value &value ) -{ - switch ( value.type() ) - { - case nullValue: - document_ += "null"; - break; - case intValue: - document_ += valueToString( value.asInt() ); - break; - case uintValue: - document_ += valueToString( value.asUInt() ); - break; - case realValue: - document_ += valueToString( value.asDouble() ); - break; - case stringValue: - document_ += valueToQuotedString( value.asCString() ); - break; - case booleanValue: - document_ += valueToString( value.asBool() ); - break; - case arrayValue: - { - document_ += "["; - int size = value.size(); - for ( int index =0; index < size; ++index ) - { - if ( index > 0 ) - document_ += ","; - writeValue( value[index] ); - } - document_ += "]"; - } - break; - case objectValue: - { - Value::Members members( value.getMemberNames() ); - document_ += "{"; - for ( Value::Members::iterator it = members.begin(); - it != members.end(); - ++it ) - { - const std::string &name = *it; - if ( it != members.begin() ) - document_ += ","; - document_ += valueToQuotedString( name.c_str() ); - document_ += yamlCompatiblityEnabled_ ? ": " - : ":"; - writeValue( value[name] ); - } - document_ += "}"; - } - break; - } -} - - -// Class StyledWriter -// ////////////////////////////////////////////////////////////////// - -StyledWriter::StyledWriter() - : rightMargin_( 74 ) - , indentSize_( 3 ) -{ -} - - -std::string -StyledWriter::write( const Value &root ) -{ - document_ = ""; - addChildValues_ = false; - indentString_ = ""; - writeCommentBeforeValue( root ); - writeValue( root ); - writeCommentAfterValueOnSameLine( root ); - document_ += "\n"; - return document_; -} - - -void -StyledWriter::writeValue( const Value &value ) -{ - switch ( value.type() ) - { - case nullValue: - pushValue( "null" ); - break; - case intValue: - pushValue( valueToString( value.asInt() ) ); - break; - case uintValue: - pushValue( valueToString( value.asUInt() ) ); - break; - case realValue: - pushValue( valueToString( value.asDouble() ) ); - break; - case stringValue: - pushValue( valueToQuotedString( value.asCString() ) ); - break; - case booleanValue: - pushValue( valueToString( value.asBool() ) ); - break; - case arrayValue: - writeArrayValue( value); - break; - case objectValue: - { - Value::Members members( value.getMemberNames() ); - if ( members.empty() ) - pushValue( "{}" ); - else - { - writeWithIndent( "{" ); - indent(); - Value::Members::iterator it = members.begin(); - while ( true ) - { - const std::string &name = *it; - const Value &childValue = value[name]; - writeCommentBeforeValue( childValue ); - writeWithIndent( valueToQuotedString( name.c_str() ) ); - document_ += " : "; - writeValue( childValue ); - if ( ++it == members.end() ) - { - writeCommentAfterValueOnSameLine( childValue ); - break; - } - document_ += ","; - writeCommentAfterValueOnSameLine( childValue ); - } - unindent(); - writeWithIndent( "}" ); - } - } - break; - } -} - - -void -StyledWriter::writeArrayValue( const Value &value ) -{ - unsigned size = value.size(); - if ( size == 0 ) - pushValue( "[]" ); - else - { - bool isArrayMultiLine = isMultineArray( value ); - if ( isArrayMultiLine ) - { - writeWithIndent( "[" ); - indent(); - bool hasChildValue = !childValues_.empty(); - unsigned index =0; - while ( true ) - { - const Value &childValue = value[index]; - writeCommentBeforeValue( childValue ); - if ( hasChildValue ) - writeWithIndent( childValues_[index] ); - else - { - writeIndent(); - writeValue( childValue ); - } - if ( ++index == size ) - { - writeCommentAfterValueOnSameLine( childValue ); - break; - } - document_ += ","; - writeCommentAfterValueOnSameLine( childValue ); - } - unindent(); - writeWithIndent( "]" ); - } - else // output on a single line - { - assert( childValues_.size() == size ); - document_ += "[ "; - for ( unsigned index =0; index < size; ++index ) - { - if ( index > 0 ) - document_ += ", "; - document_ += childValues_[index]; - } - document_ += " ]"; - } - } -} - - -bool -StyledWriter::isMultineArray( const Value &value ) -{ - int size = value.size(); - bool isMultiLine = size*3 >= rightMargin_ ; - childValues_.clear(); - for ( int index =0; index < size && !isMultiLine; ++index ) - { - const Value &childValue = value[index]; - isMultiLine = isMultiLine || - ( (childValue.isArray() || childValue.isObject()) && - childValue.size() > 0 ); - } - if ( !isMultiLine ) // check if line length > max line length - { - childValues_.reserve( size ); - addChildValues_ = true; - int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]' - for ( int index =0; index < size && !isMultiLine; ++index ) - { - writeValue( value[index] ); - lineLength += int( childValues_[index].length() ); - isMultiLine = isMultiLine && hasCommentForValue( value[index] ); - } - addChildValues_ = false; - isMultiLine = isMultiLine || lineLength >= rightMargin_; - } - return isMultiLine; -} - - -void -StyledWriter::pushValue( const std::string &value ) -{ - if ( addChildValues_ ) - childValues_.push_back( value ); - else - document_ += value; -} - - -void -StyledWriter::writeIndent() -{ - if ( !document_.empty() ) - { - char last = document_[document_.length()-1]; - if ( last == ' ' ) // already indented - return; - if ( last != '\n' ) // Comments may add new-line - document_ += '\n'; - } - document_ += indentString_; -} - - -void -StyledWriter::writeWithIndent( const std::string &value ) -{ - writeIndent(); - document_ += value; -} - - -void -StyledWriter::indent() -{ - indentString_ += std::string( indentSize_, ' ' ); -} - - -void -StyledWriter::unindent() -{ - assert( int(indentString_.size()) >= indentSize_ ); - indentString_.resize( indentString_.size() - indentSize_ ); -} - - -void -StyledWriter::writeCommentBeforeValue( const Value &root ) -{ - if ( !root.hasComment( commentBefore ) ) - return; - document_ += normalizeEOL( root.getComment( commentBefore ) ); - document_ += "\n"; -} - - -void -StyledWriter::writeCommentAfterValueOnSameLine( const Value &root ) -{ - if ( root.hasComment( commentAfterOnSameLine ) ) - document_ += " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) ); - - if ( root.hasComment( commentAfter ) ) - { - document_ += "\n"; - document_ += normalizeEOL( root.getComment( commentAfter ) ); - document_ += "\n"; - } -} - - -bool -StyledWriter::hasCommentForValue( const Value &value ) -{ - return value.hasComment( commentBefore ) - || value.hasComment( commentAfterOnSameLine ) - || value.hasComment( commentAfter ); -} - - -std::string -StyledWriter::normalizeEOL( const std::string &text ) -{ - std::string normalized; - normalized.reserve( text.length() ); - const char *begin = text.c_str(); - const char *end = begin + text.length(); - const char *current = begin; - while ( current != end ) - { - char c = *current++; - if ( c == '\r' ) // mac or dos EOL - { - if ( *current == '\n' ) // convert dos EOL - ++current; - normalized += '\n'; - } - else // handle unix EOL & other char - normalized += c; - } - return normalized; -} - - -// Class StyledStreamWriter -// ////////////////////////////////////////////////////////////////// - -StyledStreamWriter::StyledStreamWriter( std::string indentation ) - : document_(NULL) - , rightMargin_( 74 ) - , indentation_( indentation ) -{ -} - - -void -StyledStreamWriter::write( std::ostream &out, const Value &root ) -{ - document_ = &out; - addChildValues_ = false; - indentString_ = ""; - writeCommentBeforeValue( root ); - writeValue( root ); - writeCommentAfterValueOnSameLine( root ); - *document_ << "\n"; - document_ = NULL; // Forget the stream, for safety. -} - - -void -StyledStreamWriter::writeValue( const Value &value ) -{ - switch ( value.type() ) - { - case nullValue: - pushValue( "null" ); - break; - case intValue: - pushValue( valueToString( value.asInt() ) ); - break; - case uintValue: - pushValue( valueToString( value.asUInt() ) ); - break; - case realValue: - pushValue( valueToString( value.asDouble() ) ); - break; - case stringValue: - pushValue( valueToQuotedString( value.asCString() ) ); - break; - case booleanValue: - pushValue( valueToString( value.asBool() ) ); - break; - case arrayValue: - writeArrayValue( value); - break; - case objectValue: - { - Value::Members members( value.getMemberNames() ); - if ( members.empty() ) - pushValue( "{}" ); - else - { - writeWithIndent( "{" ); - indent(); - Value::Members::iterator it = members.begin(); - while ( true ) - { - const std::string &name = *it; - const Value &childValue = value[name]; - writeCommentBeforeValue( childValue ); - writeWithIndent( valueToQuotedString( name.c_str() ) ); - *document_ << " : "; - writeValue( childValue ); - if ( ++it == members.end() ) - { - writeCommentAfterValueOnSameLine( childValue ); - break; - } - *document_ << ","; - writeCommentAfterValueOnSameLine( childValue ); - } - unindent(); - writeWithIndent( "}" ); - } - } - break; - } -} - - -void -StyledStreamWriter::writeArrayValue( const Value &value ) -{ - unsigned size = value.size(); - if ( size == 0 ) - pushValue( "[]" ); - else - { - bool isArrayMultiLine = isMultineArray( value ); - if ( isArrayMultiLine ) - { - writeWithIndent( "[" ); - indent(); - bool hasChildValue = !childValues_.empty(); - unsigned index =0; - while ( true ) - { - const Value &childValue = value[index]; - writeCommentBeforeValue( childValue ); - if ( hasChildValue ) - writeWithIndent( childValues_[index] ); - else - { - writeIndent(); - writeValue( childValue ); - } - if ( ++index == size ) - { - writeCommentAfterValueOnSameLine( childValue ); - break; - } - *document_ << ","; - writeCommentAfterValueOnSameLine( childValue ); - } - unindent(); - writeWithIndent( "]" ); - } - else // output on a single line - { - assert( childValues_.size() == size ); - *document_ << "[ "; - for ( unsigned index =0; index < size; ++index ) - { - if ( index > 0 ) - *document_ << ", "; - *document_ << childValues_[index]; - } - *document_ << " ]"; - } - } -} - - -bool -StyledStreamWriter::isMultineArray( const Value &value ) -{ - int size = value.size(); - bool isMultiLine = size*3 >= rightMargin_ ; - childValues_.clear(); - for ( int index =0; index < size && !isMultiLine; ++index ) - { - const Value &childValue = value[index]; - isMultiLine = isMultiLine || - ( (childValue.isArray() || childValue.isObject()) && - childValue.size() > 0 ); - } - if ( !isMultiLine ) // check if line length > max line length - { - childValues_.reserve( size ); - addChildValues_ = true; - int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]' - for ( int index =0; index < size && !isMultiLine; ++index ) - { - writeValue( value[index] ); - lineLength += int( childValues_[index].length() ); - isMultiLine = isMultiLine && hasCommentForValue( value[index] ); - } - addChildValues_ = false; - isMultiLine = isMultiLine || lineLength >= rightMargin_; - } - return isMultiLine; -} - - -void -StyledStreamWriter::pushValue( const std::string &value ) -{ - if ( addChildValues_ ) - childValues_.push_back( value ); - else - *document_ << value; -} - - -void -StyledStreamWriter::writeIndent() -{ - /* - Some comments in this method would have been nice. ;-) - - if ( !document_.empty() ) - { - char last = document_[document_.length()-1]; - if ( last == ' ' ) // already indented - return; - if ( last != '\n' ) // Comments may add new-line - *document_ << '\n'; - } - */ - *document_ << '\n' << indentString_; -} - - -void -StyledStreamWriter::writeWithIndent( const std::string &value ) -{ - writeIndent(); - *document_ << value; -} - - -void -StyledStreamWriter::indent() -{ - indentString_ += indentation_; -} - - -void -StyledStreamWriter::unindent() -{ - assert( indentString_.size() >= indentation_.size() ); - indentString_.resize( indentString_.size() - indentation_.size() ); -} - - -void -StyledStreamWriter::writeCommentBeforeValue( const Value &root ) -{ - if ( !root.hasComment( commentBefore ) ) - return; - *document_ << normalizeEOL( root.getComment( commentBefore ) ); - *document_ << "\n"; -} - - -void -StyledStreamWriter::writeCommentAfterValueOnSameLine( const Value &root ) -{ - if ( root.hasComment( commentAfterOnSameLine ) ) - *document_ << " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) ); - - if ( root.hasComment( commentAfter ) ) - { - *document_ << "\n"; - *document_ << normalizeEOL( root.getComment( commentAfter ) ); - *document_ << "\n"; - } -} - - -bool -StyledStreamWriter::hasCommentForValue( const Value &value ) -{ - return value.hasComment( commentBefore ) - || value.hasComment( commentAfterOnSameLine ) - || value.hasComment( commentAfter ); -} - - -std::string -StyledStreamWriter::normalizeEOL( const std::string &text ) -{ - std::string normalized; - normalized.reserve( text.length() ); - const char *begin = text.c_str(); - const char *end = begin + text.length(); - const char *current = begin; - while ( current != end ) - { - char c = *current++; - if ( c == '\r' ) // mac or dos EOL - { - if ( *current == '\n' ) // convert dos EOL - ++current; - normalized += '\n'; - } - else // handle unix EOL & other char - normalized += c; - } - return normalized; -} - - -std::ostream& operator<<( std::ostream &sout, const Value &root ) -{ - Json::StyledStreamWriter writer; - writer.write(sout, root); - return sout; -} - - -} // namespace Json diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.cpp deleted file mode 100755 index 6906275e..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.cpp +++ /dev/null @@ -1,320 +0,0 @@ -#include "plugin.h" -#include "tokenizer.h" - -#ifdef _WINDOWS -#include -BOOL APIENTRY DllMain( HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved ) -{ - return TRUE; -} -#else -#include -#include - -extern int errno; -#endif - -SendPluginEv SendPluginEvent; - -string g_GetSysErrMsg( void ) -{ - string strError = "Unknown"; - // Problem loading -#ifdef _WINDOWS - int nErrorCode = GetLastError(); - LPTSTR s; - if ( ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, nErrorCode, 0, ( LPTSTR ) &s, 0, NULL ) ) - { - strError = s; - } - else - { - char szBuf[ 20 ]; - _snprintf_s( szBuf, _countof(szBuf), 19, "%d", nErrorCode ); - strError = szBuf; - } -#else - char szError[80]; - if ( strerror_r( errno, szError, sizeof(szError) ) ) - { - strError = "no description found"; - } - else - { - strError = szError; - } -#endif - return strError; -} - -void g_sleep( unsigned int mseconds ) -{ -#ifdef _WINDOWS - Sleep( mseconds ); -#else - usleep( mseconds * 1000 ); -#endif -} - -string& g_trim( string& str ) -{ - // Whitespace characters - char whspc[] = " \t\r\n\v\f"; - - // Whack off first part - size_t pos = str.find_first_not_of( whspc ); - - if ( pos != string::npos ) - str.replace( 0, pos, "" ); - - // Whack off trailing stuff - pos = str.find_last_not_of( whspc ); - - if ( pos != string::npos ) - str.replace( pos + 1, str.length() - pos, "" ); - - return str; -} - -void g_tokenize( const string& str, const string& delimiters, vector& tokens ) -{ - tokenize( str, tokens, delimiters ); -} - -char* SetEventFunc( SendPluginEv funcPtr ) -{ - static char * szObjList = onGetObjList(); - SendPluginEvent = funcPtr; - return szObjList; -} - - -const int nMAXSIZE = 512; -char* g_pszRetVal = NULL; - -//----------------------------------------------------------- -// Map from an object Id to an object instance -//----------------------------------------------------------- -typedef std::map StringToJExt_T; - -//----------------------------------------------------------- -// Map from a browser context to an id mapping -//----------------------------------------------------------- -typedef std::map VoidToMap_T; - -VoidToMap_T g_context2Map; - -class GlobalSharedModule -{ - -public: - GlobalSharedModule( void ) - { - g_pszRetVal = new char[ nMAXSIZE ]; - } - - ~GlobalSharedModule() - { - delete [] g_pszRetVal; - - VoidToMap_T::iterator posMaps; - - for ( posMaps = g_context2Map.begin(); posMaps != g_context2Map.end(); ++posMaps ) - { - StringToJExt_T& id2Obj = *posMaps->second; - StringToJExt_T::iterator posMap; - - for ( posMap = id2Obj.begin(); posMap != id2Obj.end(); ++posMap ) - { - JSExt* pJSExt = posMap->second; - - if ( pJSExt->CanDelete() ) - { - delete pJSExt; - } - } - - id2Obj.erase( id2Obj.begin(), id2Obj.end() ); - } - - g_context2Map.erase( g_context2Map.begin(), g_context2Map.end() ); - } -}; - -GlobalSharedModule g_sharedModule; - -char* g_str2global( const string& strRetVal ) -{ - int nLen = strRetVal.size(); - - if ( nLen >= nMAXSIZE ) - { - delete [] g_pszRetVal; - g_pszRetVal = new char[ nLen + 1 ]; - } - - else - { - // To minimaize the number of memory reallocations, the assumption - // is that in most times this will be the case - delete [] g_pszRetVal; - g_pszRetVal = new char[ nMAXSIZE ]; - } - - strcpy( g_pszRetVal, strRetVal.c_str() ); - return g_pszRetVal; -} - -bool g_unregisterObject( const string& strObjId, void* pContext ) -{ - // Called by the plugin extension implementation - // if the extension handles the deletion of its object - - StringToJExt_T * pID2Obj = NULL; - - VoidToMap_T::iterator iter = g_context2Map.find( pContext ); - - if ( iter != g_context2Map.end() ) - { - pID2Obj = iter->second; - } - else - { - return false; - } - - StringToJExt_T& mapID2Obj = *pID2Obj; - - StringToJExt_T::iterator r = mapID2Obj.find( strObjId ); - - if ( r == mapID2Obj.end() ) - { - return false; - } - - mapID2Obj.erase( strObjId ); - return true; -} - -char* InvokeFunction( const char* szCommand, void* pContext ) -{ - StringToJExt_T * pID2Obj = NULL; - - VoidToMap_T::iterator iter = g_context2Map.find( pContext ); - - if ( iter != g_context2Map.end() ) - { - pID2Obj = iter->second; - } - else - { - pID2Obj = new StringToJExt_T; - g_context2Map[ pContext ] = pID2Obj; - } - - StringToJExt_T& mapID2Obj = *pID2Obj; - - string strFullCommand = szCommand; - vector arParams; - g_tokenize( strFullCommand, " ", arParams ); - string strCommand = arParams[ 0 ]; - string strRetVal = szERROR; - - if ( strCommand == szCREATE ) - { - string strClassName = arParams[ 1 ]; - string strObjId = arParams[ 2 ]; - - StringToJExt_T::iterator r = mapID2Obj.find( strObjId ); - - if ( r != mapID2Obj.end() ) - { - strRetVal += strObjId; - strRetVal += " :Object already exists."; - return g_str2global( strRetVal ); - } - - JSExt* pJSExt = onCreateObject( strClassName, strObjId ); - - if ( pJSExt == NULL ) - { - strRetVal += strObjId; - strRetVal += " :Unknown object type "; - strRetVal += strClassName; - return g_str2global( strRetVal ); - } - - pJSExt->m_pContext = pContext; - mapID2Obj[ strObjId ] = pJSExt; - - strRetVal = szOK; - strRetVal += strObjId; - return g_str2global( strRetVal ); - } - else - if ( strCommand == szINVOKE ) - { - string strObjId = arParams[ 1 ]; - string strMethod = arParams[ 2 ]; - - StringToJExt_T::iterator r = mapID2Obj.find( strObjId ); - - if ( r == mapID2Obj.end() ) - { - strRetVal += strObjId; - strRetVal += " :No object found for id."; - return g_str2global( strRetVal ); - } - - JSExt* pJSExt = r->second; - - size_t nLoc = strFullCommand.find( strObjId ); - - if ( nLoc == string::npos ) - { - strRetVal += strObjId; - strRetVal += " :Internal InvokeMethod error."; - return g_str2global( strRetVal ); - } - - if ( strMethod == szDISPOSE ) - { - StringToJExt_T::iterator r = mapID2Obj.find( strObjId ); - - if ( r == mapID2Obj.end() ) - { - strRetVal = szERROR; - strRetVal += strObjId; - return g_str2global( strRetVal ); - } - - JSExt * pJSExt = mapID2Obj[ strObjId ]; - - if ( pJSExt->CanDelete() ) - { - delete pJSExt; - } - - mapID2Obj.erase( strObjId ); - strRetVal = szOK; - strRetVal += strObjId; - return g_str2global( strRetVal ); - } - - size_t nSuffixLoc = nLoc + strObjId.size(); - string strInvoke = strFullCommand.substr( nSuffixLoc ); - strInvoke = g_trim( strInvoke ); - strRetVal = pJSExt->InvokeMethod( strInvoke ); - return g_str2global( strRetVal ); - } - - strRetVal += " :Unknown command "; - strRetVal += strCommand; - return g_str2global( strRetVal ); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.h deleted file mode 100755 index 4ef71169..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/plugin.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _PLUGIN_H -#define _PLUGIN_H - -#include -#include -#include -#include -//#include "tokenizer.h" - -using namespace std; - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%% Functions exported by this DLL -//%% Should always be only SetEventFunc and InvokeFunction -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// g++ requires extern "C" otherwise the names of SetEventFunc and InvokeFunction -// are mangled C++ style. MS Visual Studio doesn't seem to care though. -extern "C" -{ - typedef void (*SendPluginEv)( const char* szEvent, void* pContext ); - char* SetEventFunc(SendPluginEv funcPtr); - char* InvokeFunction( const char* szCommand, void* pContext ); -} - -// JNEXT Framework function of the form: -// typedef void (*SendPluginEv)( const char* szEvent ); -// used to notify JavaScript of an asynchronous event -extern SendPluginEv SendPluginEvent; - -///////////////////////////////////////////////////////////////////////// -// Constants and methods common to all JNEXT extensions types -///////////////////////////////////////////////////////////////////////// -#define szERROR "Error " -#define szOK "Ok " - -#define szDISPOSE "Dispose" -#define szINVOKE "InvokeMethod" -#define szCREATE "CreateObj" - -///////////////////////////////////////////////////////////////////////// -// Utility functions -///////////////////////////////////////////////////////////////////////// -string& g_trim( string& str ); -void g_tokenize(const string& str,const string& delimiters, vector& tokens); -char* g_str2static( const string& strRetVal ); -void g_sleep( unsigned int mseconds ); -bool g_unregisterObject( const string& strObjId, void* pContext ); - - -///////////////////////////////////////////////////////////////////////// -// Abstract extension object -///////////////////////////////////////////////////////////////////////// -class JSExt -{ -public: - virtual ~JSExt() {}; - virtual string InvokeMethod( const string& strCommand ) = 0; - virtual bool CanDelete( void ) = 0; - virtual void TryDelete( void ) {} -public: - void* m_pContext; -}; - -///////////////////////////////////////////////////////////////////////// -// Callback functions to be implemented by the plugin implementation -///////////////////////////////////////////////////////////////////////// -extern char* onGetObjList( void ); -extern JSExt* onCreateObject( const string& strClassName, const string& strObjId ); - -#endif diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.cpp deleted file mode 100755 index 4a39573b..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/************************************************************************ -The zlib/libpng License - -Copyright (c) 2006 Joerg Wiedenmann - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from -the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; -you must not claim that you wrote the original software. -If you use this software in a product, an acknowledgment -in the product documentation would be appreciated but is -not required. - -2. Altered source versions must be plainly marked as such, -and must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source distribution. - -***********************************************************************/ - -/******************************************************************** - created: 2006-01-28 - filename: tokenizer.cpp - author: Jörg Wiedenmann - - purpose: A tokenizer function which provides a very - customizable way of breaking up strings. - - history: 2006-01-28, Original version - 2006-03-04, Fixed a small parsing bug, thanks Elias. -*********************************************************************/ - -#include "tokenizer.h" - -using namespace std; - -void tokenize ( const string& str, vector& result, - const string& delimiters, const string& delimiters_preserve, - const string& quote, const string& esc ) -{ - // clear the vector - if ( false == result.empty() ) - { - result.clear(); - } - - string::size_type pos = 0; // the current position (char) in the string - char ch = 0; // buffer for the current character - char delimiter = 0; // the buffer for the delimiter char which - // will be added to the tokens if the delimiter - // is preserved - char current_quote = 0; // the char of the current open quote - bool quoted = false; // indicator if there is an open quote - string token; // string buffer for the token - bool token_complete = false; // indicates if the current token is - // read to be added to the result vector - string::size_type len = str.length(); // length of the input-string - - // for every char in the input-string - while ( len > pos ) - { - // get the character of the string and reset the delimiter buffer - ch = str.at(pos); - delimiter = 0; - - // assume ch isn't a delimiter - bool add_char = true; - - // check ... - - // ... if the delimiter is an escaped character - bool escaped = false; // indicates if the next char is protected - if ( false == esc.empty() ) // check if esc-chars are provided - { - if ( string::npos != esc.find_first_of(ch) ) - { - // get the escaped char - ++pos; - if ( pos < len ) // if there are more chars left - { - // get the next one - ch = str.at(pos); - - // add the escaped character to the token - add_char = true; - } - else // cannot get any more characters - { - // don't add the esc-char - add_char = false; - } - - // ignore the remaining delimiter checks - escaped = true; - } - } - - // ... if the delimiter is a quote - if ( false == quote.empty() && false == escaped ) - { - // if quote chars are provided and the char isn't protected - if ( string::npos != quote.find_first_of(ch) ) - { - // if not quoted, set state to open quote and set - // the quote character - if ( false == quoted ) - { - quoted = true; - current_quote = ch; - - // don't add the quote-char to the token - add_char = false; - } - else // if quote is open already - { - // check if it is the matching character to close it - if ( current_quote == ch ) - { - // close quote and reset the quote character - quoted = false; - current_quote = 0; - - // don't add the quote-char to the token - add_char = false; - } - } // else - } - } - - // ... if the delimiter isn't preserved - if ( false == delimiters.empty() && false == escaped && - false == quoted ) - { - // if a delimiter is provided and the char isn't protected by - // quote or escape char - if ( string::npos != delimiters.find_first_of(ch) ) - { - // if ch is a delimiter and the token string isn't empty - // the token is complete - if ( false == token.empty() ) // BUGFIX: 2006-03-04 - { - token_complete = true; - } - - // don't add the delimiter to the token - add_char = false; - } - } - - // ... if the delimiter is preserved - add it as a token - bool add_delimiter = false; - if ( false == delimiters_preserve.empty() && false == escaped && - false == quoted ) - { - // if a delimiter which will be preserved is provided and the - // char isn't protected by quote or escape char - if ( string::npos != delimiters_preserve.find_first_of(ch) ) - { - // if ch is a delimiter and the token string isn't empty - // the token is complete - if ( false == token.empty() ) // BUGFIX: 2006-03-04 - { - token_complete = true; - } - - // don't add the delimiter to the token - add_char = false; - - // add the delimiter - delimiter = ch; - add_delimiter = true; - } - } - - - // add the character to the token - if ( true == add_char ) - { - // add the current char - token.push_back( ch ); - } - - // add the token if it is complete - if ( true == token_complete && false == token.empty() ) - { - // add the token string - result.push_back( token ); - - // clear the contents - token.clear(); - - // build the next token - token_complete = false; - } - - // add the delimiter - if ( true == add_delimiter ) - { - // the next token is the delimiter - string delim_token; - delim_token.push_back( delimiter ); - result.push_back( delim_token ); - - // REMOVED: 2006-03-04, Bugfix - } - - // repeat for the next character - ++pos; - } // while - - // add the final token - if ( false == token.empty() ) - { - result.push_back( token ); - } -} diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.h b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.h deleted file mode 100755 index 75f567ce..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/public/tokenizer.h +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************ -The zlib/libpng License - -Copyright (c) 2006 Joerg Wiedenmann - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from -the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is - not required. - -2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source distribution. - -***********************************************************************/ - -/******************************************************************** - created: 2006-01-28 - filename: tokenizer.cpp - author: Jörg Wiedenmann - - purpose: A tokenizer function which provides a very - customizable way of breaking up strings. -*********************************************************************/ - -#include -#include -using namespace std; - -// Function to break up a string into tokens -// -// Parameters: -//----------- -// str = the input string that will be tokenized -// result = the tokens for str -// delimiters = the delimiter characters -// delimiters preserve = same as above, but the delimiter characters -// will be put into the result as a token -// quote = characters to protect the enclosed characters -// esc = characters to protect a single character -// - -void tokenize ( const string& str, vector& result, - const string& delimiters, const string& delimiters_preserve = "", - const string& quote = "\"", const string& esc = "\\" ); diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.cpp deleted file mode 100755 index 57b7075e..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2013 BlackBerry Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Logger.hpp" -#include "keyboard_js.hpp" -#include - -namespace webworks { - -Logger::Logger(const char* name, Keyboard_JS *parent): m_pParent(parent) { - buffer_config.buffer_set_name = name; - buffer_config.num_buffers = 2; - buffer_config.verbosity_level = SLOG2_DEBUG1; - - /* Configure the first buffer, using 7 x 4KB pages. This larger buffer will be used for - very chatty logging. Our goal is to have 30-60 seconds of history at any given time, - so we will want to log at a rate of around one log line with a string of 16 bytes - long every 150 milliseconds. - */ - - buffer_config.buffer_config[0].buffer_name = "low_priority"; - buffer_config.buffer_config[0].num_pages = 7; - - /* Configure the second buffer, which we will use for high level info logging that is very - infrequent, but we want a longer history (hours or maybe even over a day or two). This - buffer uses 1 x 4KB. - */ - - buffer_config.buffer_config[1].buffer_name = "high_priority"; - buffer_config.buffer_config[1].num_pages = 1; - - /* Register the buffer set. */ - - if( -1 == slog2_register( &buffer_config, buffer_handle, 0 ) ) { - fprintf( stderr, "Error registering slogger2 buffer!\n" ); - } else { - info("Created slogger2 buffers"); - } - -} - -Logger::~Logger() { - critical("slogger2 buffers reset"); - slog2_reset(); -} - -int Logger::log(slog2_buffer_t buffer, _Uint8t severity, const char* message) { - return slog2c(buffer, 0, severity, message); -} - -int Logger::debug(const char* message) { - return log(lowPriorityBuffer(), SLOG2_DEBUG1, message); -} - -int Logger::info(const char* message) { - return log(lowPriorityBuffer(), SLOG2_INFO, message); -} - -int Logger::notice(const char* message) { - return log(lowPriorityBuffer(), SLOG2_NOTICE, message); -} - -int Logger::warn(const char* message) { - return log(lowPriorityBuffer(), SLOG2_WARNING, message); -} - -int Logger::error(const char* message) { - return log(hiPriorityBuffer(), SLOG2_ERROR, message); -} - -int Logger::critical(const char* message) { - return log(hiPriorityBuffer(), SLOG2_CRITICAL, message); -} - -int Logger::setVerbosity(_Uint8t verbosity) { - return slog2_set_verbosity(buffer_handle[0], verbosity); -} - -_Uint8t Logger::getVerbosity() { - return slog2_get_verbosity(buffer_handle[0]); -} - -slog2_buffer_t Logger::hiPriorityBuffer() { - return buffer_handle[1]; -} - -slog2_buffer_t Logger::lowPriorityBuffer() { - return buffer_handle[0]; -} - -} /* namespace webworks */ diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.hpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.hpp deleted file mode 100755 index ca379ca7..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/Logger.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2013 BlackBerry Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef LOGGER_HPP_ -#define LOGGER_HPP_ - -#include -#include - -class Keyboard_JS; - -namespace webworks { - -class Logger { -public: - explicit Logger(const char* name, Keyboard_JS *parent = NULL); - virtual ~Logger(); - int debug(const char* message); - int info(const char* message); - int notice(const char* message); - int warn(const char* message); - int error(const char* message); - int critical(const char* message); - int setVerbosity(_Uint8t verbosity); - _Uint8t getVerbosity(); - slog2_buffer_t hiPriorityBuffer(); - slog2_buffer_t lowPriorityBuffer(); -private: - Keyboard_JS *m_pParent; - slog2_buffer_set_config_t buffer_config; - slog2_buffer_t buffer_handle[2]; - int log(slog2_buffer_t buffer, _Uint8t severity, const char* message); -}; - -} /* namespace webworks */ -#endif /* LOGGER_HPP_ */ diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.cpp deleted file mode 100755 index 64250a14..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2013 BlackBerry Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "../public/tokenizer.h" -#include "keyboard_js.hpp" -#include "keyboard_ndk.hpp" -#include - -using namespace std; - -/** - * Default constructor. - */ -Keyboard_JS::Keyboard_JS(const std::string& id) : - m_id(id) { - m_pLogger = new webworks::Logger("Keyboard_JS", this); - m_pKeyboardController = new webworks::Keyboard_NDK(this); - - -} - -/** - * Keyboard_JS destructor. - */ -Keyboard_JS::~Keyboard_JS() { - if (m_pKeyboardController) - delete m_pKeyboardController; - if (m_pLogger) - delete m_pLogger; -} - -webworks::Logger* Keyboard_JS::getLog() { - return m_pLogger; -} - -/** - * This method returns the list of objects implemented by this native - * extension. - */ -char* onGetObjList() { - static char name[] = "Keyboard_JS"; - return name; -} - -/** - * This method is used by JNext to instantiate the Keyboard_JS object when - * an object is created on the JavaScript server side. - */ -JSExt* onCreateObject(const string& className, const string& id) { - if (className == "Keyboard_JS") { - return new Keyboard_JS(id); - } - - return NULL; -} - -/** - * Method used by JNext to determine if the object can be deleted. - */ -bool Keyboard_JS::CanDelete() { - return true; -} - -/** - * It will be called from JNext JavaScript side with passed string. - * This method implements the interface for the JavaScript to native binding - * for invoking native code. This method is triggered when JNext.invoke is - * called on the JavaScript side with this native objects id. - */ -string Keyboard_JS::InvokeMethod(const string& command) { - // format must be: "command callbackId params" - size_t commandIndex = command.find_first_of(" "); - std::string strCommand = command.substr(0, commandIndex); - size_t callbackIndex = command.find_first_of(" ", commandIndex + 1); - std::string callbackId = command.substr(commandIndex + 1, callbackIndex - commandIndex - 1); - std::string arg = command.substr(callbackIndex + 1, command.length()); - - // based on the command given, run the appropriate method in keyboard_ndk.cpp - if (strCommand == "showKeyboard") { - m_pKeyboardController->callKeyboardEmail(); - return "Show Keyboard"; - } else if (strCommand == "closeKeyboard") { - m_pKeyboardController->cancelKeyboard(); - return "Cancel Keyboard"; - } - else if(strCommand == "startService"){ - m_pKeyboardController->keyboardStartThread(); - return "Starting Service"; - } - - strCommand.append(";"); - strCommand.append(command); - return strCommand; -} - -// Notifies JavaScript of an event -void Keyboard_JS::NotifyEvent(const std::string& event) { - std::string eventString = m_id + " "; - eventString.append(event); - SendPluginEvent(eventString.c_str(), m_pContext); - -} - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.hpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.hpp deleted file mode 100755 index 1ed3bb78..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_js.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Copyright (c) 2013 BlackBerry Limited -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef Keyboard_JS_HPP_ -#define Keyboard_JS_HPP_ - -#include -#include "../public/plugin.h" -#include "keyboard_ndk.hpp" -#include "Logger.hpp" - - -class Keyboard_JS: public JSExt { - -public: - explicit Keyboard_JS(const std::string& id); - virtual ~Keyboard_JS(); - virtual bool CanDelete(); - virtual std::string InvokeMethod(const std::string& command); - void NotifyEvent(const std::string& event); - webworks::Logger* getLog(); -private: - std::string m_id; - webworks::Keyboard_NDK *m_pKeyboardController; - webworks::Logger *m_pLogger; - -}; - -#endif /* Keyboard_JS_HPP_ */ diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.cpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.cpp deleted file mode 100755 index 26b2e39a..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2013 BlackBerry Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include "keyboard_ndk.hpp" -#include "keyboard_js.hpp" -#include -namespace webworks { - -Keyboard_NDK::Keyboard_NDK(Keyboard_JS *parent): - m_pParent(parent), - keyboardProperty(50), - keyboardThreadCount(1), - threadHalt(true), - m_thread(0) { - pthread_cond_t cond = PTHREAD_COND_INITIALIZER; - pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - bps_initialize(); - - virtualkeyboard_request_events(0); - - virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_EMAIL,VIRTUALKEYBOARD_ENTER_DEFAULT); - - m_pParent->getLog()->info("Keyboard Created"); - - -} - - -Keyboard_NDK::~Keyboard_NDK() { - //bps_shutdown(); -} - - -// Loops and runs the callback method -void* KeyboardThread(void* parent) { - Keyboard_NDK *pParent = static_cast(parent); - - sleep(1); - - // 1. Start the library - bps_initialize(); - - // 2. Request events to flow into the event queue - virtualkeyboard_request_events(0); - - sleep(3); - // 3. Use any service at any time - //virtualkeyboard_show(); // Show the virtual keyboard - - // 4. Listen for events - for (;;) { - // get an event - bps_event_t *event; - bps_get_event(&event, -1); // blocking - - // handle the event - pParent->event(event); - } - return NULL; -} - -// Starts the thread and returns a message on status -std::string Keyboard_NDK::keyboardStartThread() { - m_pParent->NotifyEvent("Teste"); - if (!m_thread) { - m_pParent->NotifyEvent("Teste"); - int rc; - rc = pthread_mutex_lock(&mutex); - threadHalt = false; - rc = pthread_cond_signal(&cond); - rc = pthread_mutex_unlock(&mutex); - - pthread_attr_t thread_attr; - pthread_attr_init(&thread_attr); - pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); - - pthread_create(&m_thread, &thread_attr, KeyboardThread, - static_cast(this)); - pthread_attr_destroy(&thread_attr); - //threadCallbackId = callbackId; - m_pParent->getLog()->info("Thread Started"); - return "Thread Started"; - } else { - m_pParent->getLog()->warn("Thread Started but already running"); - return "Thread Running"; - } -} - - -void Keyboard_NDK::event(bps_event_t *event) { - Json::FastWriter writer; - Json::Value root; - root["threadCount"] = "10"; - int domain = bps_event_get_domain(event); - if (domain == virtualkeyboard_get_domain()) { - int code = bps_event_get_code(event); - int a; - std::string str; - std::string eventString; - std::ostringstream strs; - switch(code) { - case VIRTUALKEYBOARD_EVENT_VISIBLE: - eventString = "native.keyboardshow"; - eventString.append(" "); - virtualkeyboard_get_height(&a) ; - strs << a; - str = strs.str(); - eventString.append("{\"keyboardHeight\":\""+str+"\"}"); - m_pParent->NotifyEvent(eventString); - - break; - case VIRTUALKEYBOARD_EVENT_HIDDEN: - - m_pParent->NotifyEvent("native.keyboardhide"); - break; - } - } - -} -void Keyboard_NDK::callKeyboardEmail(){ - virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_EMAIL,VIRTUALKEYBOARD_ENTER_SEND); - virtualkeyboard_show(); -} - -void Keyboard_NDK::callKeyboardNumber(){ - - virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_NUMBER,VIRTUALKEYBOARD_ENTER_SEND); - virtualkeyboard_show(); -} -void Keyboard_NDK::cancelKeyboard(){ - virtualkeyboard_hide(); -} - - - - -} diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.hpp b/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.hpp deleted file mode 100755 index 01062274..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/blackberry10/native/src/keyboard_ndk.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright (c) 2013 BlackBerry Limited -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef Keyboard_NDK_HPP_ -#define Keyboard_NDK_HPP_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Keyboard_JS; - -namespace webworks { - -class Keyboard_NDK { -public: - explicit Keyboard_NDK(Keyboard_JS *parent = NULL); - virtual ~Keyboard_NDK(); - virtual void event(bps_event_t *event); - - void callKeyboardEmail(); // Method Calls the Keyboard style Email (default) - - void callKeyboardNumber(); // Method Calls the Keyboard style number - - void cancelKeyboard(); // Method cancel the keyboard - - std::string keyboardStartThread(); - - - - - - - -private: - - Keyboard_JS *m_pParent; - int keyboardProperty; - int keyboardThreadCount; - bool threadHalt; - std::string threadCallbackId; - pthread_t m_thread; - pthread_cond_t cond; - pthread_mutex_t mutex; - -}; - -} // namespace webworks - -#endif /* Keyboard_NDK_HPP_ */ diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.h b/StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.h deleted file mode 100755 index b54f430d..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.h +++ /dev/null @@ -1,13 +0,0 @@ -#import - -@interface IonicKeyboard : CDVPlugin { - @protected - id _keyboardShowObserver, _keyboardHideObserver; -} - -@property (readwrite, assign) BOOL hideKeyboardAccessoryBar; -@property (readwrite, assign) BOOL disableScroll; -//@property (readwrite, assign) BOOL styleDark; - -@end - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.m b/StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.m deleted file mode 100755 index 045cc65f..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/ios/IonicKeyboard.m +++ /dev/null @@ -1,160 +0,0 @@ -#import "IonicKeyboard.h" -#import "UIWebViewExtension.h" -#import - -@implementation IonicKeyboard - -@synthesize hideKeyboardAccessoryBar = _hideKeyboardAccessoryBar; -@synthesize disableScroll = _disableScroll; -//@synthesize styleDark = _styleDark; - -- (void)pluginInitialize { - - NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; - __weak IonicKeyboard* weakSelf = self; - - //set defaults - self.hideKeyboardAccessoryBar = NO; - self.disableScroll = NO; - //self.styleDark = NO; - - _keyboardShowObserver = [nc addObserverForName:UIKeyboardWillShowNotification - object:nil - queue:[NSOperationQueue mainQueue] - usingBlock:^(NSNotification* notification) { - - CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; - keyboardFrame = [self.viewController.view convertRect:keyboardFrame fromView:nil]; - - [weakSelf.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.plugins.Keyboard.isVisible = true; cordova.fireWindowEvent('native.keyboardshow', { 'keyboardHeight': %@ }); ", [@(keyboardFrame.size.height) stringValue]]]; - - //deprecated - [weakSelf.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight': %@ }); ", [@(keyboardFrame.size.height) stringValue]]]; - }]; - - _keyboardHideObserver = [nc addObserverForName:UIKeyboardWillHideNotification - object:nil - queue:[NSOperationQueue mainQueue] - usingBlock:^(NSNotification* notification) { - [weakSelf.commandDelegate evalJs:@"cordova.plugins.Keyboard.isVisible = false; cordova.fireWindowEvent('native.keyboardhide'); "]; - - //deprecated - [weakSelf.commandDelegate evalJs:@"cordova.fireWindowEvent('native.hidekeyboard'); "]; - }]; -} -- (BOOL)disableScroll { - return _disableScroll; -} - -- (void)setDisableScroll:(BOOL)disableScroll { - if (disableScroll == _disableScroll) { - return; - } - if (disableScroll) { - self.webView.scrollView.scrollEnabled = NO; - self.webView.scrollView.delegate = self; - } - else { - self.webView.scrollView.scrollEnabled = YES; - self.webView.scrollView.delegate = nil; - } - - _disableScroll = disableScroll; -} - - -- (BOOL)hideKeyboardAccessoryBar { - return _hideKeyboardAccessoryBar; -} - -- (void)setHideKeyboardAccessoryBar:(BOOL)hideKeyboardAccessoryBar { - if (hideKeyboardAccessoryBar == _hideKeyboardAccessoryBar) { - return; - } - if (hideKeyboardAccessoryBar) { - self.webView.hackishlyHidesInputAccessoryView = YES; - } - else { - self.webView.hackishlyHidesInputAccessoryView = NO; - } - - _hideKeyboardAccessoryBar = hideKeyboardAccessoryBar; -} - -/* -- (BOOL)styleDark { - return _styleDark; -} - -- (void)setStyleDark:(BOOL)styleDark { - if (styleDark == _styleDark) { - return; - } - if (styleDark) { - self.webView.styleDark = YES; - } - else { - self.webView.styleDark = NO; - } - - _styleDark = styleDark; -} -*/ - - -/* ------------------------------------------------------------- */ - -- (void)scrollViewDidScroll:(UIScrollView *)scrollView { - [scrollView setContentOffset: CGPointZero]; -} - -/* ------------------------------------------------------------- */ - -- (void)dealloc { - NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; - - [nc removeObserver:self name:UIKeyboardWillShowNotification object:nil]; - [nc removeObserver:self name:UIKeyboardWillHideNotification object:nil]; -} - -/* ------------------------------------------------------------- */ - -- (void) disableScroll:(CDVInvokedUrlCommand*)command { - if (!command.arguments || ![command.arguments count]){ - return; - } - id value = [command.arguments objectAtIndex:0]; - - self.disableScroll = [value boolValue]; -} - -- (void) hideKeyboardAccessoryBar:(CDVInvokedUrlCommand*)command { - if (!command.arguments || ![command.arguments count]){ - return; - } - id value = [command.arguments objectAtIndex:0]; - - self.hideKeyboardAccessoryBar = [value boolValue]; -} - -- (void) close:(CDVInvokedUrlCommand*)command { - [self.webView endEditing:YES]; -} - -- (void) show:(CDVInvokedUrlCommand*)command { - NSLog(@"Showing keyboard not supported in iOS due to platform limitations."); -} - -/* -- (void) styleDark:(CDVInvokedUrlCommand*)command { - if (!command.arguments || ![command.arguments count]){ - return; - } - id value = [command.arguments objectAtIndex:0]; - - self.styleDark = [value boolValue]; -} -*/ - -@end - diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.h b/StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.h deleted file mode 100755 index 1d6c293d..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.h +++ /dev/null @@ -1,4 +0,0 @@ -@interface UIWebView (HackishAccessoryHiding) -@property (nonatomic, assign) BOOL hackishlyHidesInputAccessoryView; -//@property (nonatomic, assign) BOOL styleDark; -@end diff --git a/StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.m b/StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.m deleted file mode 100755 index 25403e6f..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/src/ios/UIWebViewExtension.m +++ /dev/null @@ -1,109 +0,0 @@ -#import -#import -#import "UIWebViewExtension.h" - -//Credit: https://gist.github.com/bjhomer/2048571 -//Also: http://stackoverflow.com/a/23398487/1091751 -@implementation UIWebView (HackishAccessoryHiding) - -static const char * const hackishFixClassName = "UIWebBrowserViewMinusAccessoryView"; -static Class hackishFixClass = Nil; - -- (UIView *)hackishlyFoundBrowserView { - UIScrollView *scrollView = self.scrollView; - - UIView *browserView = nil; - for (UIView *subview in scrollView.subviews) { - if ([NSStringFromClass([subview class]) hasPrefix:@"UIWebBrowserView"]) { - browserView = subview; - break; - } - } - return browserView; -} - -- (id)methodReturningNil { - return nil; -} - -- (void)ensureHackishSubclassExistsOfBrowserViewClass:(Class)browserViewClass { - if (!hackishFixClass) { - Class newClass = objc_allocateClassPair(browserViewClass, hackishFixClassName, 0); - IMP nilImp = [self methodForSelector:@selector(methodReturningNil)]; - class_addMethod(newClass, @selector(inputAccessoryView), nilImp, "@@:"); - objc_registerClassPair(newClass); - - hackishFixClass = newClass; - } -} - -- (BOOL) hackishlyHidesInputAccessoryView { - UIView *browserView = [self hackishlyFoundBrowserView]; - return [browserView class] == hackishFixClass; -} - -- (void) setHackishlyHidesInputAccessoryView:(BOOL)value { - UIView *browserView = [self hackishlyFoundBrowserView]; - if (browserView == nil) { - return; - } - [self ensureHackishSubclassExistsOfBrowserViewClass:[browserView class]]; - - if (value) { - object_setClass(browserView, hackishFixClass); - } - else { - Class normalClass = objc_getClass("UIWebBrowserView"); - object_setClass(browserView, normalClass); - } - [browserView reloadInputViews]; -} -/* ---------------------------------------------------------------- */ - -/* -- (UIKeyboardAppearance) darkKeyboardAppearanceTemplateMethod { - return UIKeyboardAppearanceDark; -} - -- (UIKeyboardAppearance) lightKeyboardAppearanceTemplateMethod { - return UIKeyboardAppearanceLight; -} - -- (BOOL) styleDark { - UIView *browserView = [self hackishlyFoundBrowserView]; - if (browserView == nil) { - return false; - } - - Method m = class_getInstanceMethod( [self class], @selector( darkKeyboardAppearanceTemplateMethod ) ); - IMP imp = method_getImplementation( m ); - - Method m2 = class_getInstanceMethod( [browserView class], @selector(keyboardAppearance) ); - IMP imp2 = method_getImplementation( m2 ); - - return imp == imp2; -} - -- (void) setStyleDark:(BOOL)styleDark { - UIView *browserView = [self hackishlyFoundBrowserView]; - if (browserView == nil) { - return; - } - - if ( styleDark ) { - Method m = class_getInstanceMethod( [self class], @selector( darkKeyboardAppearanceTemplateMethod ) ); - IMP imp = method_getImplementation( m ); - const char* typeEncoding = method_getTypeEncoding( m ); - class_replaceMethod( [browserView class], @selector(keyboardAppearance), imp, typeEncoding ); - } - else { - Method m = class_getInstanceMethod( [self class], @selector( lightKeyboardAppearanceTemplateMethod ) ); - IMP imp = method_getImplementation( m ); - const char* typeEncoding = method_getTypeEncoding( m ); - class_replaceMethod( [browserView class], @selector(keyboardAppearance), imp, typeEncoding ); - } -} -*/ - -@end - diff --git a/StoneIsland/plugins/com.ionic.keyboard/www/keyboard.js b/StoneIsland/plugins/com.ionic.keyboard/www/keyboard.js deleted file mode 100755 index 21b3bf63..00000000 --- a/StoneIsland/plugins/com.ionic.keyboard/www/keyboard.js +++ /dev/null @@ -1,37 +0,0 @@ - -var argscheck = require('cordova/argscheck'), - utils = require('cordova/utils'), - exec = require('cordova/exec'); - - -var Keyboard = function() { -}; - -Keyboard.hideKeyboardAccessoryBar = function(hide) { - exec(null, null, "Keyboard", "hideKeyboardAccessoryBar", [hide]); -}; - -Keyboard.close = function() { - exec(null, null, "Keyboard", "close", []); -}; - -Keyboard.show = function() { - exec(null, null, "Keyboard", "show", []); -}; - -Keyboard.disableScroll = function(disable) { - exec(null, null, "Keyboard", "disableScroll", [disable]); -}; - -/* -Keyboard.styleDark = function(dark) { - exec(null, null, "Keyboard", "styleDark", [dark]); -}; -*/ - -Keyboard.isVisible = false; - -module.exports = Keyboard; - - - diff --git a/StoneIsland/plugins/cordova-plugin-compat/README.md b/StoneIsland/plugins/cordova-plugin-compat/README.md new file mode 100644 index 00000000..095c384b --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-compat/README.md @@ -0,0 +1,31 @@ + + +cordova-plugin-compat +------------------------ + +This repo is for remaining backwards compatible with previous versions of Cordova. + +## USAGE + +Your plugin can depend on this plugin and use it to handle the new run time permissions Android 6.0.0 (cordova-android 5.0.0) introduced. + +View [this commit](https://github.com/apache/cordova-plugin-camera/commit/a9c18710f23e86f5b7f8918dfab7c87a85064870) to see how to depend on `cordova-plugin-compat`. View [this file](https://github.com/apache/cordova-plugin-camera/blob/master/src/android/CameraLauncher.java) to see how `PermissionHelper` is being used to request and store permissions. Read more about Android permissions at http://cordova.apache.org/docs/en/latest/guide/platforms/android/plugin.html#android-permissions. diff --git a/StoneIsland/plugins/cordova-plugin-compat/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-compat/RELEASENOTES.md new file mode 100644 index 00000000..b7aa1293 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-compat/RELEASENOTES.md @@ -0,0 +1,29 @@ + +# Release Notes + +### 1.1.0 (Nov 02, 2016) +* [CB-11625](https://issues.apache.org/jira/browse/CB-11625) Adding the `BuildConfig` fetching code as a backup to using a new preference +* Add github pull request template + +### 1.0.0 (Apr 15, 2016) +* Initial release +* Moved `PermissionHelper.java` into `src` diff --git a/StoneIsland/plugins/cordova-plugin-compat/package.json b/StoneIsland/plugins/cordova-plugin-compat/package.json new file mode 100644 index 00000000..f31174d1 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-compat/package.json @@ -0,0 +1,32 @@ +{ + "name": "cordova-plugin-compat", + "description": "This repo is for remaining backwards compatible with previous versions of Cordova.", + "version": "1.1.0", + "homepage": "http://github.com/apache/cordova-plugin-compat#readme", + "repository": { + "type": "git", + "url": "git://github.com/apache/cordova-plugin-compat.git" + }, + "bugs": { + "url": "https://github.com/apache/cordova-plugin-compat/issues" + }, + "cordova": { + "id": "cordova-plugin-compat", + "platforms": [ + "android" + ] + }, + "keywords": [ + "ecosystem:cordova", + "ecosystem:phonegap", + "cordova-android" + ], + "engines": [ + { + "name": "cordova", + "version": ">=5.0.0" + } + ], + "author": "Apache Software Foundation", + "license": "Apache-2.0" +} diff --git a/StoneIsland/plugins/cordova-plugin-compat/plugin.xml b/StoneIsland/plugins/cordova-plugin-compat/plugin.xml new file mode 100644 index 00000000..40b45ccd --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-compat/plugin.xml @@ -0,0 +1,37 @@ + + + + + + Compat + Cordova Compatibility Plugin + Apache 2.0 + cordova,compat + https://git-wip-us.apache.org/repos/asf/cordova-plugin-compat.git + + + + + + + + diff --git a/StoneIsland/plugins/cordova-plugin-compat/src/android/BuildHelper.java b/StoneIsland/plugins/cordova-plugin-compat/src/android/BuildHelper.java new file mode 100644 index 00000000..d9b18aa2 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-compat/src/android/BuildHelper.java @@ -0,0 +1,70 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +package org.apache.cordova; + +/* + * This is a utility class that allows us to get the BuildConfig variable, which is required + * for the use of different providers. This is not guaranteed to work, and it's better for this + * to be set in the build step in config.xml + * + */ + +import android.app.Activity; +import android.content.Context; + +import java.lang.reflect.Field; + + +public class BuildHelper { + + + private static String TAG="BuildHelper"; + + /* + * This needs to be implemented if you wish to use the Camera Plugin or other plugins + * that read the Build Configuration. + * + * Thanks to Phil@Medtronic and Graham Borland for finding the answer and posting it to + * StackOverflow. This is annoying as hell! However, this method does not work with + * ProGuard, and you should use the config.xml to define the application_id + * + */ + + public static Object getBuildConfigValue(Context ctx, String key) + { + try + { + Class clazz = Class.forName(ctx.getPackageName() + ".BuildConfig"); + Field field = clazz.getField(key); + return field.get(null); + } catch (ClassNotFoundException e) { + LOG.d(TAG, "Unable to get the BuildConfig, is this built with ANT?"); + e.printStackTrace(); + } catch (NoSuchFieldException e) { + LOG.d(TAG, key + " is not a valid field. Check your build.gradle"); + } catch (IllegalAccessException e) { + LOG.d(TAG, "Illegal Access Exception: Let's print a stack trace."); + e.printStackTrace(); + } + + return null; + } + +} diff --git a/StoneIsland/plugins/cordova-plugin-compat/src/android/PermissionHelper.java b/StoneIsland/plugins/cordova-plugin-compat/src/android/PermissionHelper.java new file mode 100644 index 00000000..bbd79112 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-compat/src/android/PermissionHelper.java @@ -0,0 +1,138 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +package org.apache.cordova; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; + +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.LOG; + +import android.content.pm.PackageManager; + +/** + * This class provides reflective methods for permission requesting and checking so that plugins + * written for cordova-android 5.0.0+ can still compile with earlier cordova-android versions. + */ +public class PermissionHelper { + private static final String LOG_TAG = "CordovaPermissionHelper"; + + /** + * Requests a "dangerous" permission for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermission() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permission request + * @param permission The permission to be requested + */ + public static void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { + PermissionHelper.requestPermissions(plugin, requestCode, new String[] {permission}); + } + + /** + * Requests "dangerous" permissions for the application at runtime. This is a helper method + * alternative to cordovaInterface.requestPermissions() that does not require the project to be + * built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permissions are being requested for + * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() + * along with the result of the permissions request + * @param permissions The permissions to be requested + */ + public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) { + try { + Method requestPermission = CordovaInterface.class.getDeclaredMethod( + "requestPermissions", CordovaPlugin.class, int.class, String[].class); + + // If there is no exception, then this is cordova-android 5.0.0+ + requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); + + // Notify the plugin that all were granted by using more reflection + deliverPermissionResult(plugin, requestCode, permissions); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); + } + } + + /** + * Checks at runtime to see if the application has been granted a permission. This is a helper + * method alternative to cordovaInterface.hasPermission() that does not require the project to + * be built with cordova-android 5.0.0+ + * + * @param plugin The plugin the permission is being checked against + * @param permission The permission to be checked + * + * @return True if the permission has already been granted and false otherwise + */ + public static boolean hasPermission(CordovaPlugin plugin, String permission) { + try { + Method hasPermission = CordovaInterface.class.getDeclaredMethod("hasPermission", String.class); + + // If there is no exception, then this is cordova-android 5.0.0+ + return (Boolean) hasPermission.invoke(plugin.cordova, permission); + } catch (NoSuchMethodException noSuchMethodException) { + // cordova-android version is less than 5.0.0, so permission is implicitly granted + LOG.d(LOG_TAG, "No need to check for permission " + permission); + return true; + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when checking permission " + permission, illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method does not throw any exceptions, so this should never be caught + LOG.e(LOG_TAG, "invocationTargetException when checking permission " + permission, invocationTargetException); + } + return false; + } + + private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) { + // Generate the request results + int[] requestResults = new int[permissions.length]; + Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED); + + try { + Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod( + "onRequestPermissionResult", int.class, String[].class, int[].class); + + onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults); + } catch (NoSuchMethodException noSuchMethodException) { + // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it + // made it to this point + LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException); + } catch (IllegalAccessException illegalAccessException) { + // Should never be caught; this is a public method + LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException); + } catch(InvocationTargetException invocationTargetException) { + // This method may throw a JSONException. We are just duplicating cordova-android's + // exception handling behavior here; all it does is log the exception in CordovaActivity, + // print the stacktrace, and ignore it + LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException); + } + } +} diff --git a/StoneIsland/plugins/cordova-plugin-console/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-console/CONTRIBUTING.md old mode 100755 new mode 100644 index f7dbcaba..4c8e6a5e --- a/StoneIsland/plugins/cordova-plugin-console/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-console/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-console/LICENSE b/StoneIsland/plugins/cordova-plugin-console/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/NOTICE b/StoneIsland/plugins/cordova-plugin-console/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/README.md b/StoneIsland/plugins/cordova-plugin-console/README.md old mode 100755 new mode 100644 index 73e89084..ebd09398 --- a/StoneIsland/plugins/cordova-plugin-console/README.md +++ b/StoneIsland/plugins/cordova-plugin-console/README.md @@ -1,3 +1,7 @@ +--- +title: Console +description: Get JavaScript logs in your native logs. +--- -# cordova-plugin-console +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-console/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-console) -[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console) +# cordova-plugin-console This plugin is meant to ensure that console.log() is as useful as it can be. It adds additional function for iOS, Ubuntu, Windows Phone 8, and Windows. If @@ -36,6 +42,9 @@ are not available until after the `deviceready` event. console.log("console.log works well"); } +:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Console%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) + + ## Installation cordova plugin add cordova-plugin-console @@ -46,3 +55,55 @@ On some platforms other than Android, console.log() will act on multiple arguments, such as console.log("1", "2", "3"). However, Android will act only on the first argument. Subsequent arguments to console.log() will be ignored. This plugin is not the cause of that, it is a limitation of Android itself. + +## Supported Methods + +The plugin support following methods of the `console` object: + +- `console.log` +- `console.error` +- `console.exception` +- `console.warn` +- `console.info` +- `console.debug` +- `console.assert` +- `console.dir` +- `console.dirxml` +- `console.time` +- `console.timeEnd` +- `console.table` + +## Partially supported Methods + +Methods of the `console` object which implemented, but behave different from browser implementation: + +- `console.group` +- `console.groupCollapsed` + +The grouping methods are just log name of the group and don't actually indicate grouping for later +calls to `console` object methods. + +## Not supported Methods + +Methods of the `console` object which are implemented, but do nothing: + +- `console.clear` +- `console.trace` +- `console.groupEnd` +- `console.timeStamp` +- `console.profile` +- `console.profileEnd` +- `console.count` + +## Supported formatting + +The following formatting options available: + +Format chars: + +* `%j` - format arg as JSON +* `%o` - format arg as JSON +* `%c` - format arg as `''`. No color formatting could be done. +* `%%` - replace with `'%'` + +Any other char following `%` will format its arg via `toString()`. diff --git a/StoneIsland/plugins/cordova-plugin-console/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-console/RELEASENOTES.md old mode 100755 new mode 100644 index 5b1fdd1d..76cc093b --- a/StoneIsland/plugins/cordova-plugin-console/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-console/RELEASENOTES.md @@ -20,65 +20,85 @@ --> # Release Notes -### 0.2.3 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* CB-4889 renaming org.apache.cordova.core.console to org.apache.cordova.console -* Rename CHANGELOG.md -> RELEASENOTES.md -* [CB-4752] Incremented plugin version on dev branch. +### 1.0.4 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to `cordovaDependencies` +* add `JIRA` issue tracker link +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md - ### 0.2.4 (Oct 28, 2013) -* CB-5154 log formatting incorrectly to native -* CB-5128: added repo + issue tag to plugin.xml for console plugin -* [CB-4915] Incremented plugin version on dev branch. +### 1.0.3 (Apr 15, 2016) +* [CB-10720](https://issues.apache.org/jira/browse/CB-10720) Minor spelling/formatting changes. +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins -### 0.2.5 (Dec 4, 2013) -* add ubuntu platform +### 1.0.2 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* Fixing contribute link. +* Document formatting options for the console object +* [CB-5089](https://issues.apache.org/jira/browse/CB-5089) Document supported methods for console object +* reverted `d58f218b9149d362ebb0b8ce697cf403569d14cd` because `logger` is not needed on **Android** -### 0.2.6 (Jan 02, 2014) -* CB-5658 Add doc/index.md for Console plugin +### 1.0.1 (Jun 17, 2015) +* move logger.js and console-via-logger.js to common modules, instead of the numerous repeats that were there. +* clean up tests, info is below log level so it does not exist by default. +* add a couple tests +* [CB-9191](https://issues.apache.org/jira/browse/CB-9191) Add basic test +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-console documentation translation: cordova-plugin-console +* attempt to fix npm markdown issue -### 0.2.7 (Feb 05, 2014) -* Native console needs to be called DebugConsole to avoid ambiguous reference. This commit requires the 3.4.0 version of the native class factory -* CB-4718 fixed Console plugin not working on wp +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* docs: renamed Windows8 to Windows +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8560](https://issues.apache.org/jira/browse/CB-8560) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-console documentation translation: cordova-plugin-console +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file +* [CB-8362](https://issues.apache.org/jira/browse/CB-8362) Add Windows platform section to Console plugin + +### 0.2.13 (Feb 04, 2015) +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension + +### 0.2.12 (Dec 02, 2014) +* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-console documentation translation: cordova-plugin-console + +### 0.2.11 (Sep 17, 2014) +* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-console documentation translation + +### 0.2.10 (Aug 06, 2014) +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs + +### 0.2.9 (Jun 05, 2014) +* [CB-6848](https://issues.apache.org/jira/browse/CB-6848) Add Android quirk, list applicable platforms +* [CB-6796](https://issues.apache.org/jira/browse/CB-6796) Add license +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md ### 0.2.8 (Apr 17, 2014) -* CB-6460: Update license headers +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers * Add NOTICE file -### 0.2.9 (Jun 05, 2014) -* CB-6848 Add Android quirk, list applicable platforms -* CB-6796 Add license -* CB-6491 add CONTRIBUTING.md +### 0.2.7 (Feb 05, 2014) +* Native console needs to be called DebugConsole to avoid ambiguous reference. This commit requires the 3.4.0 version of the native class factory +* [CB-4718](https://issues.apache.org/jira/browse/CB-4718) fixed Console plugin not working on wp -### 0.2.10 (Aug 06, 2014) -* CB-6127 Updated translations for docs +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Console plugin -### 0.2.11 (Sep 17, 2014) -* CB-7249 cordova-plugin-console documentation translation +### 0.2.5 (Dec 4, 2013) +* add ubuntu platform -### 0.2.12 (Dec 02, 2014) -* CB-7977 Mention `deviceready` in plugin docs -* CB-7700 cordova-plugin-console documentation translation: cordova-plugin-console +### 0.2.4 (Oct 28, 2013) +* [CB-5154](https://issues.apache.org/jira/browse/CB-5154) log formatting incorrectly to native +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for console plugin +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. -### 0.2.13 (Feb 04, 2015) -* CB-8351 ios: Use argumentForIndex rather than NSArray extension +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.console to org.apache.cordova.console +* Rename CHANGELOG.md -> RELEASENOTES.md +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. -### 1.0.0 (Apr 15, 2015) -* CB-8746 gave plugin major version bump -* CB-8683 changed plugin-id to pacakge-name -* CB-8653 updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* docs: renamed Windows8 to Windows -* CB-8653 Updated Readme -* CB-8560 Integrate TravisCI -* CB-8438 cordova-plugin-console documentation translation: cordova-plugin-console -* CB-8538 Added package.json file -* CB-8362 Add Windows platform section to Console plugin -### 1.0.1 (Jun 17, 2015) -* move logger.js and console-via-logger.js to common modules, instead of the numerous repeats that were there. -* clean up tests, info is below log level so it does not exist by default. -* add a couple tests -* CB-9191 Add basic test -* CB-9128 cordova-plugin-console documentation translation: cordova-plugin-console -* attempt to fix npm markdown issue diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/de/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/es/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/fr/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/it/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/ja/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/ko/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/pl/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/ru/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-console/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-console/doc/zh/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/package.json b/StoneIsland/plugins/cordova-plugin-console/package.json old mode 100755 new mode 100644 index 9f667f00..39dc7614 --- a/StoneIsland/plugins/cordova-plugin-console/package.json +++ b/StoneIsland/plugins/cordova-plugin-console/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-console", - "version": "1.0.1", + "version": "1.0.4", "description": "Cordova Console Plugin", "cordova": { "id": "cordova-plugin-console", @@ -28,6 +28,20 @@ "cordova-windows8", "cordova-windows" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "engines": { + "cordovaDependencies": { + "2.0.0": { + "cordova": ">100" + } + } + }, + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-console/plugin.xml b/StoneIsland/plugins/cordova-plugin-console/plugin.xml old mode 100755 new mode 100644 index f902cc74..b2fb3f06 --- a/StoneIsland/plugins/cordova-plugin-console/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-console/plugin.xml @@ -20,7 +20,7 @@ + version="1.0.4"> Console Cordova Console Plugin @@ -29,14 +29,6 @@ https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git https://issues.apache.org/jira/browse/CB/component/12320644 - - - - - - - - @@ -46,6 +38,14 @@ + + + + + + + + @@ -53,6 +53,13 @@ + + + + + + + @@ -67,6 +74,14 @@ + + + + + + + + @@ -78,15 +93,35 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/StoneIsland/plugins/cordova-plugin-console/src/ios/CDVLogger.h b/StoneIsland/plugins/cordova-plugin-console/src/ios/CDVLogger.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/src/ios/CDVLogger.m b/StoneIsland/plugins/cordova-plugin-console/src/ios/CDVLogger.m old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/src/ubuntu/console.cpp b/StoneIsland/plugins/cordova-plugin-console/src/ubuntu/console.cpp old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/src/ubuntu/console.h b/StoneIsland/plugins/cordova-plugin-console/src/ubuntu/console.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/src/wp/DebugConsole.cs b/StoneIsland/plugins/cordova-plugin-console/src/wp/DebugConsole.cs old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-console/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-console/tests/plugin.xml old mode 100755 new mode 100644 index a44db3bc..cce2c53f --- a/StoneIsland/plugins/cordova-plugin-console/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-console/tests/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-console-tests" - version="1.0.1"> + version="1.0.4"> Cordova Console Plugin Tests Apache 2.0 diff --git a/StoneIsland/plugins/cordova-plugin-console/tests/tests.js b/StoneIsland/plugins/cordova-plugin-console/tests/tests.js old mode 100755 new mode 100644 index 6479e41d..74765d98 --- a/StoneIsland/plugins/cordova-plugin-console/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-console/tests/tests.js @@ -19,24 +19,24 @@ * */ +/* jshint jasmine: true */ + exports.defineAutoTests = function () { describe("Console", function () { it("console.spec.1 should exist", function() { expect(window.console).toBeDefined(); }); - + it("console.spec.2 has required methods log|warn|error", function(){ expect(window.console.log).toBeDefined(); expect(typeof window.console.log).toBe('function'); - + expect(window.console.warn).toBeDefined(); expect(typeof window.console.warn).toBe('function'); - + expect(window.console.error).toBeDefined(); - expect(typeof window.console.error).toBe('function'); - + expect(typeof window.console.error).toBe('function'); }); - }); }; diff --git a/StoneIsland/plugins/cordova-plugin-console/www/console-via-logger.js b/StoneIsland/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 index 4095eb3e..ffee3263 --- a/StoneIsland/plugins/cordova-plugin-console/www/console-via-logger.js +++ b/StoneIsland/plugins/cordova-plugin-console/www/console-via-logger.js @@ -22,7 +22,6 @@ //------------------------------------------------------------------------------ var logger = require("./logger"); -var utils = require("cordova/utils"); //------------------------------------------------------------------------------ // object that we're exporting diff --git a/StoneIsland/plugins/cordova-plugin-console/www/logger.js b/StoneIsland/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 index cbf81b9c..430d887d --- a/StoneIsland/plugins/cordova-plugin-console/www/logger.js +++ b/StoneIsland/plugins/cordova-plugin-console/www/logger.js @@ -43,7 +43,6 @@ var logger = exports; var exec = require('cordova/exec'); -var utils = require('cordova/utils'); var UseConsole = false; var UseLogger = true; diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws b/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws deleted file mode 100644 index 9879f7f4..00000000 --- a/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws +++ /dev/null @@ -1,1242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - - - - - - - - 1380298653954 - - - 1380299229689 - - - 1380302935690 - - - 1380305538088 - - - 1380305862564 - - - 1380306489891 - - - 1380307532008 - - - 1380307669209 - - - 1380311306948 - - - 1380311921427 - - - 1380317008739 - - - 1380317829887 - - - 1380353871771 - - - 1380358237732 - - - 1380358605885 - - - 1380376149014 - - - 1380378153190 - - - 1380383948466 - - - 1380393159906 - - - 1380393508799 - - - 1380393757355 - - - 1380393772924 - - - 1380402190419 - - - 1380402398063 - - - 1380402815702 - - - 1380488689110 - - - 1380488797067 - - - 1380488875151 - - - 1380489049263 - - - 1380489820453 - - - 1380567506465 - - - 1380567576964 - - - 1380567665822 - - - 1383169425770 - - - 1383172326587 - - - 1383174045796 - - - 1390857761557 - - - 1390857936690 - - - 1391028041914 - - - 1402048017666 - - - 1417632494865 - - - 1417703047123 - - - 1417706007258 - - - 1434477311221 - - - 1434530307503 - - - 1434577022103 - - - 1435161053225 - - - 1440664137793 - - - 1440664585797 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md b/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md index 2de829c2..d7222e90 100644 --- a/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md @@ -1,6 +1,6 @@ # Custom URL scheme PhoneGap Plugin #### launch your app by a link like this: `mycoolapp://` -for iOS and Android, by [Eddy Verbruggen](http://www.x-services.nl) +for iOS, Android and WP, by [Eddy Verbruggen](http://www.x-services.nl) - This repo is for PhoneGap 3.0.0 and up - For PhoneGap 2.9.0 and lower, [switch to the phonegap-2.9.0-and-lower branch](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin/tree/phonegap-2.9.0-and-lower) @@ -10,11 +10,15 @@ for iOS and Android, by [Eddy Verbruggen](http://www.x-services.nl) 2. [Manually](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#manually) 2. [PhoneGap Build](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#phonegap-build) 3. [Usage](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#3-usage) + 2. [iOS](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#ios-usage) + 2. [Meteor](https://github.com/EddyVerbruggen/Custom-URL-scheme#meteor--getlastintent-android-only) 4. [URL Scheme hints](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#4-url-scheme-hints) 5. [License](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#5-license) -### BEWARE: [This Apache Cordova issue](https://issues.apache.org/jira/browse/CB-7606) causes problems with Cordova-iOS 3.7.0: the `handleOpenURL` function is not invoked upon cold start. Use a higher or lower version than 3.7.0. +### BEWARE: +### - [This Apache Cordova issue](https://issues.apache.org/jira/browse/CB-7606) causes problems with Cordova-iOS 3.7.0: the `handleOpenURL` function is not invoked upon cold start. Use a higher or lower version than 3.7.0. +### - As of iOS 9.2, the dialog `Open in "mycoolapp"?` no longer blocks JS, so if you have a short timeout that opens the app store, the user will be taken to the store before they have a chance to see and answer the dialog. [See below](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#ios-usage) for available solutions. ## 1. Description @@ -32,6 +36,8 @@ This plugin allows you to start your app by calling it with a URL like `mycoolap ### Android specifics * Unlike iOS, there is no way to use config.xml to define a scheme for your app. Now there is. * Tested on Android 4.3, will most likely work with 2.2 and up. +* If you're trying to launch your app from an In-App Browser it opened previously, then [use this In-App Browser plugin fork](https://github.com/Innovation-District/cordova-plugin-inappbrowser) which allows that. +* In case you have a multi-page app (multiple HTML files, and all implementing handleOpenURL), set the preference `CustomURLSchemePluginClearsAndroidIntent` to `true` in `config.xml` so the function won't be triggered multiple times. Note that this may interfere with other plugins requiring the intent data. ## 2. Installation @@ -168,6 +174,37 @@ function handleOpenURL(url) { A more useful implementation would mean parsing the URL, saving any params to sessionStorage and redirecting the app to the correct page inside your app. All this happens before the first page is loaded. +### iOS Usage +A common method of deeplinking is to give the user the URL of a webpage (for instance http://linker.myapp.com/pathfoo) that opens the app if installed or the app store if not. This can be done in the following ways, depending on the desired UX: + +1. The page content has a button that says "Install app" and when clicked opens the app store by doing `location.href = 'itms-apps://itunes.apple.com/us/app/mycoolapp/idfoo'`. On page load, do `location.href = 'mycoolapp://pathfoo'`. If the user has the app, they will see a dialog that says `Open in "mycoolapp"? [Cancel] [Open]`. If the user does not have the app, they will see an alert that says `Cannot Open Page: Safari cannot open the page because the address is invalid`. Once they dismiss the alert, they see the button that opens the app store, and they tap it. +2. The page has two buttons: one that opens the app, and one that opens the app store. +3. On page load, open a Universal Link using [cordova-universal-links-plugin](https://github.com/nordnet/cordova-universal-links-plugin). (A Universal Link either opens the app or the app store.) Then fall back to one of the above methods if Univeral Links is not supported. + +You can also use a service that provides pages that do #3 for you, such as [Branch](https://branch.io/). + +### CSP - or: `handleOpenURL` doesn't work +The Whitelist plugin will prevent inline JS from executing, unless you whitelist the url scheme. Please see [this SO issue](http://stackoverflow.com/questions/34257097/using-handleopenurl-with-custom-url-scheme-in-cordova/34281420#34281420) for details. + +### Meteor / getLastIntent (Android only) +When running a [meteor](meteor.com) app in the cordova environment, `handleOpenURL` doesn't get called after a cold start, because cordova resets the javascript world during startup and our timer waiting for `handleOpenURL` gets vanished (see [#98](https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/98)). To get the intent by which the app was started in a meteor cordova app you need to ask for it from the meteor side with `getLastIntent` like this. +```javascript +Meteor.startup(function() { + if (Meteor.isCordova) { + window.plugins.launchmyapp.getLastIntent(function(url) { + if (intent.indexOf('mycoolapp://' > -1)) { + console.log("received url: " + url); + } else { + return console.log("ignore intent: " + url); + } + }, function(error) { + return console.log("no intent received"); + }); + return; + } +}); +``` + ## 4. URL Scheme hints Please choose a URL_SCHEME which which complies to these restrictions: - Don't use an already registered scheme (like `fb`, `twitter`, `comgooglemaps`, etc). diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml b/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml deleted file mode 100644 index 858eed55..00000000 --- a/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json b/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json index de90c8e2..3d0a4eaf 100644 --- a/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-customurlscheme", - "version": "4.0.0", + "version": "4.2.0", "description": "Launch your app by using this URL: mycoolapp://, you can add a path and even pass params like this: mycoolerapp://somepath?foo=bar", "cordova": { "id": "cordova-plugin-customurlscheme", @@ -40,4 +40,4 @@ "url": "https://github.com/EddyVerbruggen/Custom-URL-scheme/issues" }, "homepage": "https://github.com/EddyVerbruggen/Custom-URL-scheme#readme" -} \ No newline at end of file +} diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml b/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml index 1e43e724..0fde67b0 100755 --- a/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml @@ -2,7 +2,7 @@ + version="4.2.0"> Custom URL scheme @@ -47,6 +47,10 @@ + + + + @@ -59,16 +63,24 @@ - + + + + + + + - + @@ -76,14 +88,20 @@ - + - + + + + + + + @@ -104,4 +122,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java index 9d3f3d63..3a52d287 100644 --- a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java @@ -4,6 +4,8 @@ import android.content.Intent; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaActivity; import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaWebView; import org.apache.cordova.PluginResult; import org.json.JSONArray; import org.json.JSONException; @@ -16,19 +18,52 @@ import java.util.Locale; public class LaunchMyApp extends CordovaPlugin { private static final String ACTION_CHECKINTENT = "checkIntent"; + private static final String ACTION_CLEARINTENT = "clearIntent"; + private static final String ACTION_GETLASTINTENT = "getLastIntent"; + + private String lastIntentString = null; + + /** + * We don't want to interfere with other plugins requiring the intent data, + * but in case of a multi-page app your app may receive the same intent data + * multiple times, that's why you'll get an option to reset it (null it). + * + * Add this to config.xml to enable that behaviour (default false): + * + */ + private boolean resetIntent; + + @Override + public void initialize(final CordovaInterface cordova, CordovaWebView webView){ + this.resetIntent = preferences.getBoolean("resetIntent", false) || + preferences.getBoolean("CustomURLSchemePluginClearsAndroidIntent", false); + } @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (ACTION_CHECKINTENT.equalsIgnoreCase(action)) { + if (ACTION_CLEARINTENT.equalsIgnoreCase(action)) { + final Intent intent = ((CordovaActivity) this.webView.getContext()).getIntent(); + if (resetIntent){ + intent.setData(null); + } + return true; + } else if (ACTION_CHECKINTENT.equalsIgnoreCase(action)) { final Intent intent = ((CordovaActivity) this.webView.getContext()).getIntent(); final String intentString = intent.getDataString(); - if (intentString != null && intentString.contains("://") && intent.getScheme() != null) { + if (intentString != null && intent.getScheme() != null) { + lastIntentString = intentString; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, intent.getDataString())); - intent.setData(null); } else { callbackContext.error("App was not started via the launchmyapp URL scheme. Ignoring this errorcallback is the best approach."); } return true; + } else if (ACTION_GETLASTINTENT.equalsIgnoreCase(action)) { + if(lastIntentString != null) { + callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, lastIntentString)); + } else { + callbackContext.error("No intent received so far."); + } + return true; } else { callbackContext.error("This plugin only responds to the " + ACTION_CHECKINTENT + " action."); return false; @@ -38,8 +73,10 @@ public class LaunchMyApp extends CordovaPlugin { @Override public void onNewIntent(Intent intent) { final String intentString = intent.getDataString(); - if (intentString != null && intentString.contains("://") && intent.getScheme() != null) { - intent.setData(null); + if (intentString != null && intent.getScheme() != null) { + if (resetIntent){ + intent.setData(null); + } try { StringWriter writer = new StringWriter(intentString.length() * 2); escapeJavaStyleString(writer, intentString, true, false); @@ -133,4 +170,4 @@ public class LaunchMyApp extends CordovaPlugin { private static String hex(char ch) { return Integer.toHexString(ch).toUpperCase(Locale.ENGLISH); } -} \ No newline at end of file +} diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/windows/hooks/prepare-manifest.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/windows/hooks/prepare-manifest.js new file mode 100644 index 00000000..06e237f7 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/windows/hooks/prepare-manifest.js @@ -0,0 +1,30 @@ +module.exports = function(context) { + var fs = context.requireCordovaModule('fs'), + et = context.requireCordovaModule('elementtree'), + path = context.requireCordovaModule('path'), + xml= context.requireCordovaModule('cordova-common').xmlHelpers, + projectRoot = path.join(context.opts.projectRoot, "platforms", "windows"); + + var MANIFEST_WINDOWS = 'package.windows.appxmanifest', + MANIFEST_PHONE = 'package.phone.appxmanifest', + MANIFEST_WINDOWS10 = 'package.windows10.appxmanifest', + MANIFEST_WINDOWS80 = 'package.windows80.appxmanifest'; + + function updateManifestFile(manifestPath) { + var doc = xml.parseElementtreeSync(manifestPath); + var root = doc.getroot(); + var app = root.find('./Applications/Application'); + if (!app) { + throw new Error(manifestPath + ' has incorrect XML structure.'); + } + if (!app.find('./Extensions')) { + app.append(new et.Element('Extensions')); + } + fs.writeFileSync(manifestPath, doc.write({indent: 4}), 'utf-8'); + } + + [MANIFEST_PHONE, MANIFEST_WINDOWS80, MANIFEST_WINDOWS, MANIFEST_WINDOWS10] + .forEach(function(manifestFile) { + updateManifestFile(path.join(projectRoot, manifestFile)); + }); +} diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs new file mode 100644 index 00000000..8db593b8 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs @@ -0,0 +1,46 @@ +using System; +using System.Linq; +using System.Windows.Navigation; + +internal class CompositeUriMapper : UriMapperBase +{ + public static string launchUrl; + + public override Uri MapUri(Uri uri) + { + string launchUri = uri.ToString(); + if (launchUri.StartsWith("/Protocol?encodedLaunchUri=")) + { + int launchUrlIndex = launchUri.IndexOf("encodedLaunchUri="); + launchUrl = System.Net.HttpUtility.UrlDecode(launchUri.Substring(launchUrlIndex+17)); + return new Uri("/MainPage.xaml", UriKind.Relative); + } + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + var types = assemblies.SelectMany(a => + { + try + { + return a.ExportedTypes.Where(et => typeof(ICustomUriMapper).IsAssignableFrom(et)); + } + catch + { + return Enumerable.Empty(); + } + }); + + foreach (var type in types) + { + if (type != typeof(ICustomUriMapper)) + { + var worker = (ICustomUriMapper)Activator.CreateInstance(type); + var mappedUri = worker.CustomMapUri(uri); + if (mappedUri != null) + { + return mappedUri; + } + } + } + + return uri; + } +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CustomUriMapperCommand.cs b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CustomUriMapperCommand.cs new file mode 100644 index 00000000..2004f2ec --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CustomUriMapperCommand.cs @@ -0,0 +1,9 @@ +using System; +using WPCordovaClassLib.Cordova.Commands; + +namespace Cordova.Extension.Commands +{ + public class CustomUriMapperCommand : BaseCommand + { + } +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/ICustomUriMapper.cs b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/ICustomUriMapper.cs new file mode 100644 index 00000000..2cc31e5c --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/ICustomUriMapper.cs @@ -0,0 +1,7 @@ +using System; +using System.Linq; + +public interface ICustomUriMapper +{ + Uri CustomMapUri(Uri uri); +} diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/hooks/add-uri-mapper.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/hooks/add-uri-mapper.js new file mode 100644 index 00000000..1c1db69c --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/hooks/add-uri-mapper.js @@ -0,0 +1,80 @@ +module.exports = function (context) { + var deferred = context.requireCordovaModule('q').defer(), + fs = context.requireCordovaModule('fs'), + path = context.requireCordovaModule('path'), + projectRoot = context.opts.projectRoot; + + // While on AppBuilder this may work, the Cordova CLI doesn't like it + // (or at least not all versions of it). + var appXaml = path.join(projectRoot, "App.xaml.cs"); + var mainPageXaml = path.join(projectRoot, "MainPage.xaml.cs"); + try { + fs.statSync(appXaml); + fs.statSync(mainPageXaml); + } catch (err) { + appXaml = path.join(projectRoot, "platforms", "wp8", "App.xaml.cs"); + mainPageXaml = path.join(projectRoot, "platforms", "wp8", "MainPage.xaml.cs"); + try { + fs.statSync(appXaml); + fs.statSync(mainPageXaml); + } catch (err2) { + console.error("Custom URL Scheme plugin couldn't find your App's xaml file! Try to adjust the file manually according to the 'add-uri-mapper.js' hook."); + return; + } + } + + fs.readFile(appXaml, 'utf8', function (err,data) { + if (err) { + console.error("Error while configuring the Custom URL Scheme: " + err); + deferred.reject(err); + return; + } + + var result = data.replace(/^(\s*?)(RootFrame.NavigationFailed\s*?\+=\s*?RootFrame_NavigationFailed;)/gm, + "$1$2\n\n$1// Assign the URI-mapper class to the application frame\n$1RootFrame.UriMapper = new CompositeUriMapper();"); + + fs.writeFile(appXaml, result, 'utf8', function (err) { + if (err){ + deferred.reject(err); + } else{ + deferred.resolve(); + } + }); + }); + + fs.readFile(mainPageXaml, 'utf8', function (err,data) { + if (err) { + console.error("Error while configuring the Custom URL Scheme: " + err); + deferred.reject(err); + return; + } + + // first add a line to refer to a new method + var result = data.replace(/^(\s*?)(this.CordovaView.Loaded\s*?\+=\s*?CordovaView_Loaded;)/gm, + "$1$2\n\n$1// Wire a handler so we can check for our custom scheme\n$1this.CordovaView.Browser.LoadCompleted += CordovaBrowser_LoadCompleted;"); + + // now add that new method + result = result.replace(/^(\s*?)(\/\/ Constructor)/gm, + "$1void CordovaBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) {\n"+ + "$1\tif (CompositeUriMapper.launchUrl != null) {\n" + + "$1\t\tstring handleOpenURL = string.Format(\"(function() {{ document.addEventListener('deviceready', function() {{ if (typeof handleOpenURL === 'function') {{ handleOpenURL(\\\"{0}\\\"); }} }}); }})()\", CompositeUriMapper.launchUrl);\n" + + "$1\t\ttry {\n" + + "$1\t\t\tthis.CordovaView.CordovaBrowser.InvokeScript(\"eval\", new string[] { handleOpenURL });\n" + + "$1\t\t} catch (Exception) {}\n" + + "$1\t\tCompositeUriMapper.launchUrl = null;\n" + + "$1\t}\n" + + "$1\tthis.CordovaView.Browser.LoadCompleted -= CordovaBrowser_LoadCompleted;\n" + + "$1}\n\n" + + "$1$2"); + + fs.writeFile(mainPageXaml, result, 'utf8', function (err) { + if (err){ + deferred.reject(err); + } else{ + deferred.resolve(); + } + }); + }); + + return deferred.promise; +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js index 19dbdc0b..18fe0112 100644 --- a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js @@ -4,10 +4,18 @@ var remainingAttempts = 10; function waitForAndCallHandlerFunction(url) { - if (typeof window.handleOpenURL == "function") { + if (typeof window.handleOpenURL === "function") { + // Clear the intent when we have a handler (note that this is only done when the preference 'CustomURLSchemePluginClearsAndroidIntent' is 'true' in config.xml + cordova.exec( + null, + null, + "LaunchMyApp", + "clearIntent", + []); + window.handleOpenURL(url); } else if (remainingAttempts-- > 0) { - setTimeout(function(){waitForAndCallHandlerFunction(url)}, 500); + setTimeout(function(){waitForAndCallHandlerFunction(url);}, 500); } } @@ -21,4 +29,18 @@ } document.addEventListener("deviceready", triggerOpenURL, false); + + var launchmyapp = { + getLastIntent: function(success, failure) { + cordova.exec( + success, + failure, + "LaunchMyApp", + "getLastIntent", + []); + } + } + + module.exports = launchmyapp; + }()); diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/wp8/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/wp8/LaunchMyApp.js new file mode 100644 index 00000000..a8172f0f --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/wp8/LaunchMyApp.js @@ -0,0 +1,12 @@ +(function () { + function activatedHandlerWinUI(e) { + if (typeof handleOpenURL == 'function' && e.uri) { + handleOpenURL(e.uri.rawUri); + } + }; + + if (typeof Windows != 'undefined') { + var wui = Windows.UI.WebUI.WebUIApplication; + wui.addEventListener("activated", activatedHandlerWinUI, false); + } +}()); \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md old mode 100755 new mode 100644 index f7dbcaba..4c8e6a5e --- a/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-device/LICENSE b/StoneIsland/plugins/cordova-plugin-device/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/NOTICE b/StoneIsland/plugins/cordova-plugin-device/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/README.md b/StoneIsland/plugins/cordova-plugin-device/README.md old mode 100755 new mode 100644 index d3d7673d..10b80160 --- a/StoneIsland/plugins/cordova-plugin-device/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/README.md @@ -1,3 +1,7 @@ +--- +title: Device +description: Get device information. +--- -# cordova-plugin-device +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device)| -[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device) +# cordova-plugin-device This plugin defines a global `device` object, which describes the device's hardware and software. Although the object is in the global scope, it is not available until after the `deviceready` event. - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(device.cordova); - } +```js +document.addEventListener("deviceready", onDeviceReady, false); +function onDeviceReady() { + console.log(device.cordova); +} +``` + +Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) + ## Installation @@ -40,6 +51,9 @@ Although the object is in the global scope, it is not available until after the - device.platform - device.uuid - device.version +- device.manufacturer +- device.isVirtual +- device.serial ## device.cordova @@ -55,7 +69,8 @@ Get the version of Cordova running on the device. - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ## device.model @@ -71,18 +86,22 @@ different across versions of the same product. - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ### Quick Example - // Android: Nexus One returns "Passion" (Nexus One code name) - // Motorola Droid returns "voles" - // BlackBerry: Torch 9800 returns "9800" - // Browser: Google Chrome returns "Chrome" - // Safari returns "Safari" - // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models - // - var model = device.model; +```js +// Android: Nexus One returns "Passion" (Nexus One code name) +// Motorola Droid returns "voles" +// BlackBerry: Torch 9800 returns "9800" +// Browser: Google Chrome returns "Chrome" +// Safari returns "Safari" +// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models +// OSX: returns "x86_64" +// +var model = device.model; +``` ### Android Quirks @@ -100,30 +119,34 @@ different across versions of the same product. Get the device's operating system name. - var string = device.platform; - +```js +var string = device.platform; +``` ### Supported Platforms - Android - BlackBerry 10 -- Browser4 +- Browser - Firefox OS - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ### Quick Example - // Depending on the device, a few examples are: - // - "Android" - // - "BlackBerry 10" - // - Browser: returns "MacIntel" on Mac - // returns "Win32" on Windows - // - "iOS" - // - "WinCE" - // - "Tizen" - var devicePlatform = device.platform; +```js +// Depending on the device, a few examples are: +// - "Android" +// - "BlackBerry 10" +// - "browser" +// - "iOS" +// - "WinCE" +// - "Tizen" +// - "Mac OS X" +var devicePlatform = device.platform; +``` ### Windows Phone 7 Quirks @@ -137,7 +160,9 @@ Windows Phone 8 devices report the platform as `Win32NT`. Get the device's Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). - var string = device.uuid; +```js +var string = device.uuid; +``` ### Description @@ -150,33 +175,36 @@ The details of how a UUID is generated are determined by the device manufacturer - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ### Quick Example - // Android: Returns a random 64-bit integer (as a string, again!) - // The integer is generated on the device's first boot - // - // BlackBerry: Returns the PIN number of the device - // This is a nine-digit unique integer (as a string, though!) - // - // iPhone: (Paraphrased from the UIDevice Class documentation) - // Returns a string of hash values created from multiple hardware identifies. - // It is guaranteed to be unique for every device and can't be tied - // to the user account. - // Windows Phone 7 : Returns a hash of device+current user, - // if the user is not defined, a guid is generated and will persist until the app is uninstalled - // Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number - // unique to every GSM and UMTS mobile phone. - var deviceID = device.uuid; +```js +// Android: Returns a random 64-bit integer (as a string, again!) +// The integer is generated on the device's first boot +// +// BlackBerry: Returns the PIN number of the device +// This is a nine-digit unique integer (as a string, though!) +// +// iPhone: (Paraphrased from the UIDevice Class documentation) +// Returns the [UIDevice identifierForVendor] UUID which is unique and the same for all apps installed by the same vendor. However the UUID can be different if the user deletes all apps from the vendor and then reinstalls it. +// Windows Phone 7 : Returns a hash of device+current user, +// if the user is not defined, a guid is generated and will persist until the app is uninstalled +// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number +// unique to every GSM and UMTS mobile phone. +var deviceID = device.uuid; +``` ### iOS Quirk -The `uuid` on iOS is not unique to a device, but varies for each -application, for each installation. It changes if you delete and -re-install the app, and possibly also when you upgrade iOS, or even -upgrade the app per version (apparent in iOS 5.1). The `uuid` is not -a reliable value. +The `uuid` on iOS uses the identifierForVendor property. It is unique to the device across the same vendor, but will be different for different vendors and will change if all apps from the vendor are deleted and then reinstalled. +Refer [here](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor) for details. +The UUID will be the same if app is restored from a backup or iCloud as it is saved in preferences. Users using older versions of this plugin will still receive the same previous UUID generated by another means as it will be retrieved from preferences. + +### OSX Quirk + +The `uuid` on OSX is generated automatically if it does not exist yet and is stored in the `standardUserDefaults` in the `CDVUUID` property. ### Windows Phone 7 and 8 Quirks @@ -200,21 +228,84 @@ Get the operating system version. - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX + +### Quick Example + +```js +// Android: Froyo OS would return "2.2" +// Eclair OS would return "2.1", "2.0.1", or "2.0" +// Version can also return update level "2.1-update1" +// +// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" +// +// Browser: Returns version number for the browser +// +// iPhone: iOS 3.2 returns "3.2" +// +// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 +// Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384 +// Tizen: returns "TIZEN_20120425_2" +// OSX: El Capitan would return "10.11.2" +// +var deviceVersion = device.version; +``` + +## device.manufacturer + +Get the device's manufacturer. + + var string = device.manufacturer; + +### Supported Platforms + +- Android +- BlackBerry 10 +- iOS +- Windows Phone 7 and 8 +- Windows ### Quick Example - // Android: Froyo OS would return "2.2" - // Eclair OS would return "2.1", "2.0.1", or "2.0" - // Version can also return update level "2.1-update1" - // - // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" - // - // Browser: Returns version number for the browser - // - // iPhone: iOS 3.2 returns "3.2" - // - // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 - // Tizen: returns "TIZEN_20120425_2" - var deviceVersion = device.version; +```js +// Android: Motorola XT1032 would return "motorola" +// BlackBerry: returns "BlackBerry" +// iPhone: returns "Apple" +// +var deviceManufacturer = device.manufacturer; +``` + +## device.isVirtual + +whether the device is running on a simulator. + +```js +var isSim = device.isVirtual; +``` + +### Supported Platforms + +- Android 2.1+ +- iOS +- Windows Phone 8 +- Windows +- OSX + +### OSX Quirk + +The `isVirtual` property on OS X always returns false. + +## device.serial + +Get the device hardware serial number ([SERIAL](http://developer.android.com/reference/android/os/Build.html#SERIAL)). + +```js +var string = device.serial; +``` + +### Supported Platforms + +- Android +- OSX diff --git a/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md old mode 100755 new mode 100644 index f06fc6b5..4167735b --- a/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md @@ -20,95 +20,129 @@ --> # Release Notes -### 0.2.1 (Sept 5, 2013) -* removed extraneous print statement -* [CB-4432] copyright notice change - -### 0.2.3 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* [windows8] commandProxy has moved -* [BlackBerry10] removed uneeded permission tags in plugin.xml -* CB-4889 renaming org.apache.cordova.core.device to org.apache.cordova.device -* Rename CHANGELOG.md -> RELEASENOTES.md -* updated to use commandProxy for ffos -* add firefoxos support -* [CB-4752] Incremented plugin version on dev branch. - -### 0.2.4 (Oct 28, 2013) -* CB-5128: added repo + issue tag in plugin.xml for device plugin -* CB-5085 device.cordova returning wrong value -* [CB-4915] Incremented plugin version on dev branch. +### 1.1.3 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* Readme: Add fenced code blocks with langauage hints +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to `README.md` -### 0.2.5 (Dec 4, 2013) -* CB-5316 Spell Cordova as a brand unless it's a command or script -* [ubuntu] use cordova/exec/proxy -* add ubuntu platform -* Modify Device.platform logic to use amazon-fireos as the platform for Amazon Devices -* 1. Added amazon-fireos platform. 2. Change to use cordova-amazon-fireos as the platform if user agent contains 'cordova-amazon-fireos' +### 1.1.2 (Apr 15, 2016) +* Use passed device, follow create policy forf `CFUUIDCreate` +* [CB-10631](https://issues.apache.org/jira/browse/CB-10631) Fix for `device.uuid` in **iOS 5.1.1** +* Updating the comment to exclude URL +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins +* Refactored `deviceInfo` on **iOS** for better readability. -### 0.2.6 (Jan 02, 2014) -* CB-5658 Add doc/index.md for Device plugin -* CB-5504 Moving Telephony Logic out of Device +### 1.1.1 (Jan 15, 2016) +* [CB-10238](https://issues.apache.org/jira/browse/CB-10238) **OSX** Move `device-plugin` out from `cordovalib` to the plugin repository +* [CB-9923](https://issues.apache.org/jira/browse/CB-9923) Update `device.platform` documentation for **Browser** platform -### 0.2.7 (Jan 07, 2014) -* CB-5737 Fix exception on close caused by left over telephony code from CB-5504 +### 1.1.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* Add `isVirtual` for **Windows Phone 8.x** +* Added basic **Android** support for hardware serial number +* [CB-9865](https://issues.apache.org/jira/browse/CB-9865) Better simulator detection for **iOS** +* Fixing contribute link. +* Added **WP8** implementation +* update to use `TARGET_OS_SIMULATOR` as `TARGET_IPHONE_SIMULATOR` is deprecated. +* update code to use 'isVirtual' +* create test to verify existence and type of new property 'isVirtual' +* add `isSimulator` for **iOS** & **Android** device +* Updated documentation to mention backwards compatibility +* Updated **README** to reflect new behaviour and quirks on **iOS** +* Check user defaults first to maintain backwards compatibility +* Changed `UUID` to use `[UIDevice identifierForVendor]` -### 0.2.8 (Feb 05, 2014) -* Tizen support added +### 1.0.1 (Jun 17, 2015) +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-device documentation translation: cordova-plugin-device +* Attempts to corrent npm markdown issue -### 0.2.9 (Apr 17, 2014) -* CB-5105: [Android, windows8, WP, BlackBerry10] Removed dead code for device.version -* CB-6422: [windows8] use cordova/exec/proxy -* CB-6460: Update license headers -* Add NOTICE file +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* remove defunct windows8 version +* add travis badge +* Add cross-plugin ios paramedic test running for TravisCI +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file -### 0.2.10 (Jun 05, 2014) -* CB-6127 Spanish and French Translations added. Github close #12 -* Changing 1.5 to 2.0 -* added firefoxos version - conversion -* added firefoxos version -* CB-6800 Add license -* CB-6491 add CONTRIBUTING.md +### 0.3.0 (Feb 04, 2015) +* Added device.manufacturer property for Android, iOS, Blackberry, WP8 +* Support for Windows Phone 8 ANID2 ANID is only supported up to Windows Phone 7.5 +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) Use a local copy of uniqueAppInstanceIdentifier rather than CordovaLib's version +* browser: Fixed a bug that caused an "cannot call method of undefined" error if the browser's user agent wasn't recognized -### 0.2.11 (Aug 06, 2014) -* [FFOS] update DeviceProxy.js -* CB-6127 Updated translations for docs -* Use Windows system calls to get better info +### 0.2.13 (Dec 02, 2014) +* Changing `device.platform` to always report the platform as "browser". +* [CB-5892](https://issues.apache.org/jira/browse/CB-5892) - Remove deprecated `window.Settings` +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-device documentation translation: cordova-plugin-device +* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin ### 0.2.12 (Sep 17, 2014) -* CB-7471 cordova-plugin-device documentation translation -* CB-7552 device.name docs have not been removed +* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-device documentation translation +* [CB-7552](https://issues.apache.org/jira/browse/CB-7552) device.name docs have not been removed * [fxos] Fix cordova version * added status box and documentation to manual tests * [fxos] Fix cordova version * added status box and documentation to manual tests * Added plugin support for the browser -* CB-7262 Adds support for universal windows apps. +* [CB-7262](https://issues.apache.org/jira/browse/CB-7262) Adds support for universal windows apps. -### 0.2.13 (Dec 02, 2014) -* Changing `device.platform` to always report the platform as "browser". -* CB-5892 - Remove deprecated `window.Settings` -* CB-7700 cordova-plugin-device documentation translation: cordova-plugin-device -* CB-7571 Bump version of nested plugin to match parent plugin +### 0.2.11 (Aug 06, 2014) +* [FFOS] update DeviceProxy.js +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs +* Use Windows system calls to get better info -### 0.3.0 (Feb 04, 2015) -* Added device.manufacturer property for Android, iOS, Blackberry, WP8 -* Support for Windows Phone 8 ANID2 ANID is only supported up to Windows Phone 7.5 -* CB-8351 Use a local copy of uniqueAppInstanceIdentifier rather than CordovaLib's version -* browser: Fixed a bug that caused an "cannot call method of undefined" error if the browser's user agent wasn't recognized +### 0.2.10 (Jun 05, 2014) +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #12 +* Changing 1.5 to 2.0 +* added firefoxos version - conversion +* added firefoxos version +* [CB-6800](https://issues.apache.org/jira/browse/CB-6800) Add license +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md -### 1.0.0 (Apr 15, 2015) -* CB-8746 gave plugin major version bump -* CB-8683 changed plugin-id to pacakge-name -* CB-8653 properly updated translated docs to use new id -* CB-8653 updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* CB-8653 Updated Readme -* remove defunct windows8 version -* add travis badge -* Add cross-plugin ios paramedic test running for TravisCI -* CB-8538 Added package.json file +### 0.2.9 (Apr 17, 2014) +* [CB-5105](https://issues.apache.org/jira/browse/CB-5105): [Android, windows8, WP, BlackBerry10] Removed dead code for device.version +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* Add NOTICE file -### 1.0.1 (Jun 17, 2015) -* CB-9128 cordova-plugin-device documentation translation: cordova-plugin-device -* Attempts to corrent npm markdown issue +### 0.2.8 (Feb 05, 2014) +* Tizen support added + +### 0.2.7 (Jan 07, 2014) +* [CB-5737](https://issues.apache.org/jira/browse/CB-5737) Fix exception on close caused by left over telephony code from [CB-5504](https://issues.apache.org/jira/browse/CB-5504) + +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Device plugin +* [CB-5504](https://issues.apache.org/jira/browse/CB-5504) Moving Telephony Logic out of Device + +### 0.2.5 (Dec 4, 2013) +* [CB-5316](https://issues.apache.org/jira/browse/CB-5316) Spell Cordova as a brand unless it's a command or script +* [ubuntu] use cordova/exec/proxy +* add ubuntu platform +* Modify Device.platform logic to use amazon-fireos as the platform for Amazon Devices +* 1. Added amazon-fireos platform. 2. Change to use cordova-amazon-fireos as the platform if user agent contains 'cordova-amazon-fireos' + +### 0.2.4 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag in plugin.xml for device plugin +* [CB-5085](https://issues.apache.org/jira/browse/CB-5085) device.cordova returning wrong value +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [windows8] commandProxy has moved +* [BlackBerry10] removed uneeded permission tags in plugin.xml +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.device to org.apache.cordova.device +* Rename CHANGELOG.md -> RELEASENOTES.md +* updated to use commandProxy for ffos +* add firefoxos support +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. + +### 0.2.1 (Sept 5, 2013) +* removed extraneous print statement +* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/de/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/es/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/fr/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/it/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/ja/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/ko/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/pl/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/ru/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/zh/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/package.json b/StoneIsland/plugins/cordova-plugin-device/package.json old mode 100755 new mode 100644 index 388b81d5..1357f229 --- a/StoneIsland/plugins/cordova-plugin-device/package.json +++ b/StoneIsland/plugins/cordova-plugin-device/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-device", - "version": "1.0.1", + "version": "1.1.3", "description": "Cordova Device Plugin", "cordova": { "id": "cordova-plugin-device", @@ -16,7 +16,8 @@ "wp8", "windows8", "windows", - "browser" + "browser", + "osx" ] }, "repository": { @@ -38,8 +39,23 @@ "cordova-wp8", "cordova-windows8", "cordova-windows", - "cordova-browser" + "cordova-browser", + "cordova-osx" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "engines": { + "cordovaDependencies": { + "2.0.0": { + "cordova": ">100" + } + } + }, + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-device/plugin.xml b/StoneIsland/plugins/cordova-plugin-device/plugin.xml old mode 100755 new mode 100644 index 172cff23..7d041252 --- a/StoneIsland/plugins/cordova-plugin-device/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-device/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-device" - version="1.0.1"> + version="1.1.3"> Device Cordova Device Plugin Apache 2.0 @@ -158,4 +158,17 @@ + + + + + + + + + + + + + diff --git a/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java b/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java old mode 100755 new mode 100644 index 5eded907..e9efcb49 --- a/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java +++ b/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java @@ -67,13 +67,15 @@ public class Device extends CordovaPlugin { * @return True if the action was valid, false if not. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("getDeviceInfo")) { + if ("getDeviceInfo".equals(action)) { JSONObject r = new JSONObject(); r.put("uuid", Device.uuid); r.put("version", this.getOSVersion()); r.put("platform", this.getPlatform()); r.put("model", this.getModel()); r.put("manufacturer", this.getManufacturer()); + r.put("isVirtual", this.isVirtual()); + r.put("serial", this.getSerialNumber()); callbackContext.success(r); } else { @@ -88,7 +90,7 @@ public class Device extends CordovaPlugin { /** * Get the OS name. - * + * * @return */ public String getPlatform() { @@ -125,6 +127,12 @@ public class Device extends CordovaPlugin { String manufacturer = android.os.Build.MANUFACTURER; return manufacturer; } + + public String getSerialNumber() { + String serial = android.os.Build.SERIAL; + return serial; + } + /** * Get the OS version. * @@ -148,7 +156,7 @@ public class Device extends CordovaPlugin { /** * Function to check if the device is manufactured by Amazon - * + * * @return */ public boolean isAmazonDevice() { @@ -158,4 +166,9 @@ public class Device extends CordovaPlugin { return false; } + public boolean isVirtual() { + return android.os.Build.FINGERPRINT.contains("generic") || + android.os.Build.PRODUCT.contains("sdk"); + } + } diff --git a/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js b/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js old mode 100755 new mode 100644 index 77f25a9e..ef0543bc --- a/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js @@ -19,6 +19,8 @@ * */ +/* global PluginResult */ + function getModelName () { var modelName = window.qnx.webplatform.device.modelName; //Pre 10.2 (meaning Z10 or Q10) diff --git a/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js old mode 100755 new mode 100644 index fcaed20c..a8632016 --- a/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js @@ -19,7 +19,6 @@ * */ var browser = require('cordova/platform'); -var cordova = require('cordova'); function getPlatform() { return "browser"; @@ -36,6 +35,7 @@ function getVersion() { function getBrowserInfo(getModel) { var userAgent = navigator.userAgent; var returnVal = ''; + var offset; if ((offset = userAgent.indexOf('Chrome')) !== -1) { returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); diff --git a/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js old mode 100755 new mode 100644 index 79f3a2b0..a05d7ca0 --- a/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js @@ -20,8 +20,6 @@ */ //example UA String for Firefox OS //Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 -var firefoxos = require('cordova/platform'); -var cordova = require('cordova'); //UA parsing not recommended but currently this is the only way to get the Firefox OS version //https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h b/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m b/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m old mode 100755 new mode 100644 index 5a3f4708..4d75a574 --- a/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m +++ b/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m @@ -19,6 +19,7 @@ #include #include +#include "TargetConditionals.h" #import #import "CDVDevice.h" @@ -49,21 +50,23 @@ { NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; static NSString* UUID_KEY = @"CDVUUID"; - + + // Check user defaults first to maintain backwards compaitibility with previous versions + // which didn't user identifierForVendor NSString* app_uuid = [userDefaults stringForKey:UUID_KEY]; - if (app_uuid == nil) { - CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); - CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); + if ([device respondsToSelector:@selector(identifierForVendor)]) { + app_uuid = [[device identifierForVendor] UUIDString]; + } else { + CFUUIDRef uuid = CFUUIDCreate(NULL); + app_uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid); + CFRelease(uuid); + } - app_uuid = [NSString stringWithString:(__bridge NSString*)uuidString]; [userDefaults setObject:app_uuid forKey:UUID_KEY]; [userDefaults synchronize]; - - CFRelease(uuidString); - CFRelease(uuidRef); } - + return app_uuid; } @@ -78,17 +81,16 @@ - (NSDictionary*)deviceProperties { UIDevice* device = [UIDevice currentDevice]; - NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4]; - [devProps setObject:@"Apple" forKey:@"manufacturer"]; - [devProps setObject:[device modelVersion] forKey:@"model"]; - [devProps setObject:@"iOS" forKey:@"platform"]; - [devProps setObject:[device systemVersion] forKey:@"version"]; - [devProps setObject:[self uniqueAppInstanceIdentifier:device] forKey:@"uuid"]; - [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"]; - - NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps]; - return devReturn; + return @{ + @"manufacturer": @"Apple", + @"model": [device modelVersion], + @"platform": @"iOS", + @"version": [device systemVersion], + @"uuid": [self uniqueAppInstanceIdentifier:device], + @"cordova": [[self class] cordovaVersion], + @"isVirtual": @([self isVirtual]) + }; } + (NSString*)cordovaVersion @@ -96,4 +98,15 @@ return CDV_VERSION; } +- (BOOL)isVirtual +{ + #if TARGET_OS_SIMULATOR + return true; + #elif TARGET_IPHONE_SIMULATOR + return true; + #else + return false; + #endif +} + @end diff --git a/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h new file mode 100644 index 00000000..9def2548 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h @@ -0,0 +1,28 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + +#import + +@interface CDVDevice : CDVPlugin + ++ (NSString*) cordovaVersion; + +- (void) getDeviceInfo:(CDVInvokedUrlCommand*)command; + +@end diff --git a/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m new file mode 100644 index 00000000..3a63588f --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m @@ -0,0 +1,113 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + +#include + +#import "CDVDevice.h" + +#define SYSTEM_VERSION_PLIST @"/System/Library/CoreServices/SystemVersion.plist" + +@implementation CDVDevice + +- (NSString*) modelVersion { + size_t size; + + sysctlbyname("hw.machine", NULL, &size, NULL, 0); + char* machine = malloc(size); + sysctlbyname("hw.machine", machine, &size, NULL, 0); + NSString* modelVersion = [NSString stringWithUTF8String:machine]; + free(machine); + + return modelVersion; +} + + +- (NSString*) getSerialNr { + NSString* serialNr; + io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + if (platformExpert) { + CFTypeRef serialNumberAsCFString = + IORegistryEntryCreateCFProperty(platformExpert, + CFSTR(kIOPlatformSerialNumberKey), + kCFAllocatorDefault, 0); + if (serialNumberAsCFString) { + serialNr = (__bridge NSString*) serialNumberAsCFString; + } + IOObjectRelease(platformExpert); + } + return serialNr; +} + +- (NSString*) uniqueAppInstanceIdentifier { + NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; + static NSString* UUID_KEY = @"CDVUUID"; + + NSString* app_uuid = [userDefaults stringForKey:UUID_KEY]; + + if (app_uuid == nil) { + CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); + CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); + + app_uuid = [NSString stringWithString:(__bridge NSString*) uuidString]; + [userDefaults setObject:app_uuid forKey:UUID_KEY]; + [userDefaults synchronize]; + + CFRelease(uuidString); + CFRelease(uuidRef); + } + + return app_uuid; +} + +- (NSString*) platform { + return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductName"]; +} + +- (NSString*) systemVersion { + return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductVersion"]; +} + +- (void) getDeviceInfo:(CDVInvokedUrlCommand*) command { + NSDictionary* deviceProperties = [self deviceProperties]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties]; + + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (NSDictionary*) deviceProperties { + NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4]; + + devProps[@"manufacturer"] = @"Apple"; + devProps[@"model"] = [self modelVersion]; + devProps[@"platform"] = [self platform]; + devProps[@"version"] = [self systemVersion]; + devProps[@"uuid"] = [self uniqueAppInstanceIdentifier]; + devProps[@"cordova"] = [[self class] cordovaVersion]; + devProps[@"serial"] = [self getSerialNr]; + devProps[@"isVirtual"] = @NO; + + NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps]; + return devReturn; +} + ++ (NSString*) cordovaVersion { + return CDV_VERSION; +} + +@end diff --git a/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js old mode 100755 new mode 100644 index 2afc3243..973b7162 --- a/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js @@ -20,7 +20,6 @@ */ var tizen = require('cordova/platform'); -var cordova = require('cordova'); module.exports = { getDeviceInfo: function(success, error) { diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js old mode 100755 new mode 100644 index 3adb110b..838586c3 --- a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js @@ -19,8 +19,7 @@ * */ -var cordova = require('cordova'); -var exec = require('cordova/exec'); +/* global Cordova */ module.exports = { getInfo:function(win,fail,args) { diff --git a/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js old mode 100755 new mode 100644 index 69ed4446..f338ad3a --- a/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js @@ -19,13 +19,14 @@ * */ +/* global Windows, createUUID */ + var ROOT_CONTAINER = "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}"; var DEVICE_CLASS_KEY = "{A45C254E-DF1C-4EFD-8020-67D146A850E0},10"; -var DEVICE_CLASS_KEY_NO_SEMICOLON = '{A45C254E-DF1C-4EFD-8020-67D146A850E0}10'; +var DEVICE_CLASS_KEY_NO_SEMICOLON = "{A45C254E-DF1C-4EFD-8020-67D146A850E0}10"; var ROOT_CONTAINER_QUERY = "System.Devices.ContainerId:=\"" + ROOT_CONTAINER + "\""; var HAL_DEVICE_CLASS = "4d36e966-e325-11ce-bfc1-08002be10318"; var DEVICE_DRIVER_VERSION_KEY = "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3"; -var MANU_KEY = "System.Devices.Manufacturer"; module.exports = { @@ -33,8 +34,6 @@ module.exports = { // deviceId aka uuid, stored in Windows.Storage.ApplicationData.current.localSettings.values.deviceId var deviceId; - var manufacturer = "unknown"; - // get deviceId, or create and store one var localSettings = Windows.Storage.ApplicationData.current.localSettings; if (localSettings.values.deviceId) { @@ -55,51 +54,42 @@ module.exports = { var userAgent = window.clientInformation.userAgent; - // this will report "windows" in windows8.1 and windows phone 8.1 apps - // and "windows8" in windows 8.0 apps similar to cordova.js - // See https://github.com/apache/cordova-js/blob/master/src/windows/platform.js#L25 + // this will report "windows" in windows8.1 and windows phone 8.1 apps + // and "windows8" in windows 8.0 apps similar to cordova.js + // See https://github.com/apache/cordova-js/blob/master/src/windows/platform.js#L25 var devicePlatform = userAgent.indexOf("MSAppHost/1.0") == -1 ? "windows" : "windows8"; var versionString = userAgent.match(/Windows (?:Phone |NT )?([0-9.]+)/)[1]; - + var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation(); + // Running in the Windows Simulator is a remote session. + // Running in the Windows Phone Emulator has the systemProductName set to "Virtual" + var isVirtual = Windows.System.RemoteDesktop.InteractiveSession.isRemote || deviceInfo.systemProductName == "Virtual"; + var manufacturer = deviceInfo.systemManufacturer; + var model = deviceInfo.systemProductName; var Pnp = Windows.Devices.Enumeration.Pnp; - Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.deviceContainer,[MANU_KEY]) - .then(function (infoList) { - var numDevices = infoList.length; - if (numDevices) { - for (var i = 0; i < numDevices; i++) { - var devContainer = infoList[i]; - if (devContainer.id == ROOT_CONTAINER) { - manufacturer = devContainer.properties[MANU_KEY]; + Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.device, + [DEVICE_DRIVER_VERSION_KEY, DEVICE_CLASS_KEY], + ROOT_CONTAINER_QUERY) + .then(function (rootDevices) { + for (var i = 0; i < rootDevices.length; i++) { + var rootDevice = rootDevices[i]; + if (!rootDevice.properties) continue; + if (rootDevice.properties[DEVICE_CLASS_KEY_NO_SEMICOLON] == HAL_DEVICE_CLASS) { + versionString = rootDevice.properties[DEVICE_DRIVER_VERSION_KEY]; break; } } - } - }) - .then(function () { - Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.device, - [DEVICE_DRIVER_VERSION_KEY, DEVICE_CLASS_KEY], - ROOT_CONTAINER_QUERY) - .then(function (rootDevices) { - for (var i = 0; i < rootDevices.length; i++) { - var rootDevice = rootDevices[i]; - if (!rootDevice.properties) continue; - if (rootDevice.properties[DEVICE_CLASS_KEY_NO_SEMICOLON] == HAL_DEVICE_CLASS) { - versionString = rootDevice.properties[DEVICE_DRIVER_VERSION_KEY]; - break; - } - } - setTimeout(function () { - win({ platform: devicePlatform, - version: versionString, - uuid: deviceId, - model: window.clientInformation.platform, - manufacturer:manufacturer}); - }, 0); - }); + setTimeout(function () { + win({ platform: devicePlatform, + version: versionString, + uuid: deviceId, + isVirtual: isVirtual, + model: model, + manufacturer:manufacturer}); + }, 0); }); } diff --git a/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs b/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs old mode 100755 new mode 100644 index 897a35af..76fe8cf2 --- a/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs +++ b/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs @@ -1,32 +1,21 @@ /* - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ -using System; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Ink; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; using Microsoft.Phone.Info; -using System.IO.IsolatedStorage; -using System.Windows.Resources; +using System; using System.IO; -using System.Diagnostics; +using System.IO.IsolatedStorage; namespace WPCordovaClassLib.Cordova.Commands { @@ -34,55 +23,27 @@ namespace WPCordovaClassLib.Cordova.Commands { public void getDeviceInfo(string notused) { - - string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\",\"manufacturer\":\"{5}\"", - this.name, - this.platform, - this.uuid, - this.version, - this.model, - this.manufacturer); - - res = "{" + res + "}"; - //Debug.WriteLine("Result::" + res); - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res)); + string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\",\"manufacturer\":\"{5}\",\"isVirtual\":{6}", + DeviceStatus.DeviceName, + Environment.OSVersion.Platform.ToString(), + UUID, + Environment.OSVersion.Version.ToString(), + DeviceStatus.DeviceName, + DeviceStatus.DeviceManufacturer, + IsVirtual ? "true" : "false"); + DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "{" + res + "}")); } - public string model - { - get - { - return DeviceStatus.DeviceName; - //return String.Format("{0},{1},{2}", DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceHardwareVersion, DeviceStatus.DeviceFirmwareVersion); - } - } - public string manufacturer + public bool IsVirtual { - get + get { - return DeviceStatus.DeviceManufacturer; + return (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator); } } - public string name - { - get - { - return DeviceStatus.DeviceName; - - } - } - - public string platform - { - get - { - return Environment.OSVersion.Platform.ToString(); - } - } - - public string uuid + public string UUID { get { @@ -122,14 +83,5 @@ namespace WPCordovaClassLib.Cordova.Commands return returnVal; } } - - public string version - { - get - { - return Environment.OSVersion.Version.ToString(); - } - } - } } diff --git a/StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml old mode 100755 new mode 100644 index bcca190e..ad4433c9 --- a/StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-device-tests" - version="1.0.1"> + version="1.1.3"> Cordova Device Plugin Tests Apache 2.0 diff --git a/StoneIsland/plugins/cordova-plugin-device/tests/tests.js b/StoneIsland/plugins/cordova-plugin-device/tests/tests.js old mode 100755 new mode 100644 index 1f49d7e1..ac9a2810 --- a/StoneIsland/plugins/cordova-plugin-device/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-device/tests/tests.js @@ -19,6 +19,8 @@ * */ +/* jshint jasmine: true */ + exports.defineAutoTests = function() { describe('Device Information (window.device)', function () { it("should exist", function() { @@ -27,18 +29,18 @@ exports.defineAutoTests = function() { it("should contain a platform specification that is a string", function() { expect(window.device.platform).toBeDefined(); - expect((new String(window.device.platform)).length > 0).toBe(true); + expect((String(window.device.platform)).length > 0).toBe(true); }); it("should contain a version specification that is a string", function() { expect(window.device.version).toBeDefined(); - expect((new String(window.device.version)).length > 0).toBe(true); + expect((String(window.device.version)).length > 0).toBe(true); }); it("should contain a UUID specification that is a string or a number", function() { expect(window.device.uuid).toBeDefined(); if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') { - expect((new String(window.device.uuid)).length > 0).toBe(true); + expect((String(window.device.uuid)).length > 0).toBe(true); } else { expect(window.device.uuid > 0).toBe(true); } @@ -46,12 +48,12 @@ exports.defineAutoTests = function() { it("should contain a cordova specification that is a string", function() { expect(window.device.cordova).toBeDefined(); - expect((new String(window.device.cordova)).length > 0).toBe(true); + expect((String(window.device.cordova)).length > 0).toBe(true); }); it("should depend on the presence of cordova.version string", function() { expect(window.cordova.version).toBeDefined(); - expect((new String(window.cordova.version)).length > 0).toBe(true); + expect((String(window.cordova.version)).length > 0).toBe(true); }); it("should contain device.cordova equal to cordova.version", function() { @@ -60,18 +62,30 @@ exports.defineAutoTests = function() { it("should contain a model specification that is a string", function() { expect(window.device.model).toBeDefined(); - expect((new String(window.device.model)).length > 0).toBe(true); + expect((String(window.device.model)).length > 0).toBe(true); }); it("should contain a manufacturer property that is a string", function() { expect(window.device.manufacturer).toBeDefined(); - expect((new String(window.device.manufacturer)).length > 0).toBe(true); + expect((String(window.device.manufacturer)).length > 0).toBe(true); + }); + + it("should contain an isVirtual property that is a boolean", function() { + expect(window.device.isVirtual).toBeDefined(); + expect(typeof window.device.isVirtual).toBe("boolean"); }); + + it("should contain a serial number specification that is a string", function() { + expect(window.device.serial).toBeDefined(); + expect((String(window.device.serial)).length > 0).toBe(true); + + }); + }); }; exports.defineManualTests = function(contentEl, createActionButton) { - var logMessage = function (message, color) { + var logMessage = function (message, color) { var log = document.getElementById('info'); var logLine = document.createElement('div'); if (color) { @@ -79,12 +93,12 @@ exports.defineManualTests = function(contentEl, createActionButton) { } logLine.innerHTML = message; log.appendChild(logLine); - } + }; var clearLog = function () { var log = document.getElementById('info'); log.innerHTML = ''; - } + }; var device_tests = '

Press Dump Device button to get device information

' + '
' + diff --git a/StoneIsland/plugins/cordova-plugin-device/www/device.js b/StoneIsland/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 index b1d0d25d..f7ed19f9 --- a/StoneIsland/plugins/cordova-plugin-device/www/device.js +++ b/StoneIsland/plugins/cordova-plugin-device/www/device.js @@ -42,6 +42,8 @@ function Device() { this.cordova = null; this.model = null; this.manufacturer = null; + this.isVirtual = null; + this.serial = null; var me = this; @@ -56,7 +58,9 @@ function Device() { me.uuid = info.uuid; me.cordova = buildLabel; me.model = info.model; + me.isVirtual = info.isVirtual; me.manufacturer = info.manufacturer || 'unknown'; + me.serial = info.serial || 'unknown'; channel.onCordovaInfoReady.fire(); },function(e) { me.available = false; diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-dialogs/CONTRIBUTING.md old mode 100755 new mode 100644 index f7dbcaba..4c8e6a5e --- a/StoneIsland/plugins/cordova-plugin-dialogs/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-dialogs/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/LICENSE b/StoneIsland/plugins/cordova-plugin-dialogs/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/NOTICE b/StoneIsland/plugins/cordova-plugin-dialogs/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/README.md old mode 100755 new mode 100644 index b16b9f9a..ea2b9311 --- a/StoneIsland/plugins/cordova-plugin-dialogs/README.md +++ b/StoneIsland/plugins/cordova-plugin-dialogs/README.md @@ -1,3 +1,7 @@ +--- +title: Dialogs +description: Use native dialog UI elements +--- -# cordova-plugin-dialogs +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-dialogs)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-dialogs/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-dialogs)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-dialogs/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-dialogs)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-dialogs/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-dialogs)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-dialogs/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-dialogs)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-dialogs/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-dialogs.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-dialogs)| -[![Build Status](https://travis-ci.org/apache/cordova-plugin-dialogs.svg)](https://travis-ci.org/apache/cordova-plugin-dialogs) +# cordova-plugin-dialogs This plugin provides access to some native dialog UI elements via a global `navigator.notification` object. @@ -31,6 +37,8 @@ Although the object is attached to the global scoped `navigator`, it is not avai console.log(navigator.notification); } +Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Dialogs%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) + ## Installation cordova plugin add cordova-plugin-dialogs @@ -77,6 +85,7 @@ function, which is typically less customizable. - Amazon Fire OS - Android - BlackBerry 10 +- Browser - Firefox OS - iOS - Tizen @@ -141,6 +150,7 @@ indexing, so the value is `1`, `2`, `3`, etc. - Amazon Fire OS - Android - BlackBerry 10 +- Browser - Firefox OS - iOS - Tizen @@ -212,6 +222,7 @@ contains the following properties: - Amazon Fire OS - Android +- Browser - Firefox OS - iOS - Windows Phone 7 and 8 @@ -250,6 +261,7 @@ The device plays a beep sound. - Amazon Fire OS - Android - BlackBerry 10 +- Browser - iOS - Tizen - Windows Phone 7 and 8 @@ -272,4 +284,3 @@ The device plays a beep sound. - Tizen implements beeps by playing an audio file via the media API. - The beep file must be short, must be located in a `sounds` subdirectory of the application's root directory, and must be named `beep.wav`. - diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-dialogs/RELEASENOTES.md old mode 100755 new mode 100644 index 79571543..2b34048b --- a/StoneIsland/plugins/cordova-plugin-dialogs/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-dialogs/RELEASENOTES.md @@ -20,120 +20,147 @@ --> # Release Notes -### 0.2.2 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* [windows8] commandProxy was moved -* CB-4889 renaming reference in Notification.cs -* CB-4889 renaming org.apache.cordova.core.dialogs to org.apache.cordova.dialogs -* Rename CHANGELOG.md -> RELEASENOTES.md -* [CB-4592] [Blackberry10] Added beep support -* [CB-4752] Incremented plugin version on dev branch. +### 1.3.0 (Sep 08, 2016) +* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) updated missing header file +* Select the text and put default value in the input directly. +* [CB-11281](https://issues.apache.org/jira/browse/CB-11281) **windows**: `defaultText` is not taken as input if no input by user fixed +* Separated `CSS` from `JS` code. Fixed the prompt dialog CSS to look close to native. Fixed the positioning of the prompt dialog for Windows. Fixed minor JSHint issues. +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* [CB-8773](https://issues.apache.org/jira/browse/CB-8773) Fix for **iOS 8** keyboard not appearing on prompt +* [CB-11677](https://issues.apache.org/jira/browse/CB-11677) **Android**: made text, entered to prompt dialog visible +* CB-8947:(**ios**) Fix crash. Convert non-string messages to strings. Added tests. +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* [CB-11218](https://issues.apache.org/jira/browse/CB-11218) Convert button list to appropriate type +* Simply add **Browser** to supported platforms +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md - ### 0.2.3 (Oct 28, 2013) -* CB-5128: added repo + issue tag to plugin.xml for dialogs plugin -* new plugin execute arguments supported -* new plugin style -* smaller fonts styling input -* img files copied inside plugin -* style added -* prompt added -* styling from James -* fixed "exec" calls addedd css, but not working yet -* first (blind) try -* [CB-4915] Incremented plugin version on dev branch. +### 1.2.1 (Apr 15, 2016) +* [CB-10097](https://issues.apache.org/jira/browse/CB-10097) dialog doesn't show on **iOS** when called from a select list `onChange` event +* Remove `warning` emoji, as it doesn't correctly display in the docs website: http://cordova.apache.org/docs/en/dev/cordova-plugin-dialogs/index.html +* [CB-10727](https://issues.apache.org/jira/browse/CB-10727) Dialogs plugin has warnings on **iOS** +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins - -### 0.2.4 (Dec 4, 2013) -* add ubuntu platform -* 1. Added amazon-fireos platform. 2. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'. -* added beep funtionality using ms-winsoundevent:Notfication.Default +### 1.2.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* [CB-8549](https://issues.apache.org/jira/browse/CB-8549) Updated source to pass `Fortify` scan. +* Fixing contribute link. +* add `CSS class` to prompt `div` for **Windows** platform +* [CB-9347](https://issues.apache.org/jira/browse/CB-9347) - fix to allow to stack multiple `UIAlertControllers` -### 0.2.5 (Jan 02, 2014) -* CB-4696 Fix compile error for Xcode 4.5. -* CB-5658 Add doc/index.md for Dialogs plugin -* CB-3762 Change prompt default to empty string -* Move images from css to img +### 1.1.1 (Jun 17, 2015) +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs +* fix npm md -### 0.2.6 (Feb 05, 2014) -* no need to recreate the manifest.webapp file after each `cordova prepare` for FFOS -* FFOS description added +### 1.1.0 (May 06, 2015) +* [CB-8928](https://issues.apache.org/jira/browse/CB-8928): Removed direct call to `toStaticHTML`, only call it if we are sure it's present. This closes #52 +* [CB-7734](https://issues.apache.org/jira/browse/CB-7734) - `navigator.notification.alert` or `navigator.notification.confirm` seem have a "many words" issue. (closes #39) + +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) updated wp and bb specific references of old id to new id +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of deprecated headers +* [CB-8565](https://issues.apache.org/jira/browse/CB-8565) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file +* [CB-8367](https://issues.apache.org/jira/browse/CB-8367) [org.apache.cordova.dialogs] Add Prompt support on Windows -### 0.2.7 (Apr 17, 2014) -* CB-6212: [iOS] fix warnings compiled under arm64 64-bit -* CB-6411: [BlackBerry10] Work around Audio playback issue -* CB-6411: [BlackBerry10] Updates to beep -* CB-6422: [windows8] use cordova/exec/proxy -* CB-6460: Update license headers -* Add NOTICE file +### 0.3.0 (Feb 04, 2015) +* Correct way to specify Windows platform in config.xml +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension +* [CB-7955](https://issues.apache.org/jira/browse/CB-7955) Add support "browser" platform -### 0.2.8 (Jun 05, 2014) -* CB-6801 Add license -* running original windows.open, inAppBrowser is overriding it no need to place CSS in every page anymore -* CB-5945 [Windows8] do not call success callbacks until dialog is dismissed -* CB-4616 Returned index 0 was not documented for notification.prompt -* update docs to state that prompt is supported on windowsphone -* CB-6528 allow scroll on alert message content -* [CB-6628][amazon-fireos]dialogs plugin's confirm and prompt methods dont work confirm() method was missing amazon-fireos platform check. added that. prompt() method had bug. It is executed in a worker thread that does not have a message queue(or Looper object) associated with it and hence "can't create a handler" exception is thrown. To fix this issue, we need to create the EditText widget from within the UI thread. This was fixed sometime ago when we added fireos platform but commit got lost somewhere. So fixing it again now. -* CB-6491 add CONTRIBUTING.md -* Added check for isFinishing() on the parent activity to prevent crashes when trying to display dialogs when activity is in this phase of it's lifecycle -* CB-4966 Dialogs are in window now No need to add anything to manifest or index.html -* Removing FirefoxOS Quirks * no need to add special permission (it's different API with the same name) * notification.css is added automatically +### 0.2.11 (Dec 02, 2014) +* [CB-7737](https://issues.apache.org/jira/browse/CB-7737) lower min height for alert +* [CB-8038](https://issues.apache.org/jira/browse/CB-8038) backslash getting escaped twice in **BB10** +* [CB-8029](https://issues.apache.org/jira/browse/CB-8029) test 1-based indexing for confirm +* [CB-7639](https://issues.apache.org/jira/browse/CB-7639) Update docs + manual tests +* [CB-7639](https://issues.apache.org/jira/browse/CB-7639) Revert back `isAlertShowing` flag in case of exception to prevent queuing of future dialogs. +* [CB-7639](https://issues.apache.org/jira/browse/CB-7639) Handle button labels as array on windows +* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs +* Check for `setTextDirection` API level +* **Android** Make spinner dialog to use `THEME_DEVICE_DEFAULT_LIGHT` (same as the other dialogs) +* **Android** Unbreak `API` level < `14` +* [CB-7414](https://issues.apache.org/jira/browse/CB-7414) **BB10** Document callback parameter for `navigator.notification.alert` +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs +* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin + +### 0.2.10 (Sep 17, 2014) +* [CB-7538](https://issues.apache.org/jira/browse/CB-7538) Android beep thread fix Beep now executes in it's own thread. It was previously executing in the main UI thread which was causing the application to lock up will the beep was occurring. Closing pull request +* Set dialog text dir to locale +* Renamed test dir, added nested plugin.xml +* added documentation for manual tests +* [CB-6965](https://issues.apache.org/jira/browse/CB-6965) Added manual tests +* [CB-6965](https://issues.apache.org/jira/browse/CB-6965) Port notification tests to test-framework ### 0.2.9 (Aug 06, 2014) * ubuntu: pass proper arguments to prompt callback * ubuntu: use TextField instead of TextInput * ubuntu: proper message escaping before passing to qml * **FFOS** update notification.js -* CB-6127 Updated translations for docs +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs * android: Explicitly apply default theme to dialogs * Fix Beep exception on Android when no argument passed -### 0.2.10 (Sep 17, 2014) -* CB-7538 Android beep thread fix Beep now executes in it's own thread. It was previously executing in the main UI thread which was causing the application to lock up will the beep was occurring. Closing pull request -* Set dialog text dir to locale -* Renamed test dir, added nested plugin.xml -* added documentation for manual tests -* CB-6965 Added manual tests -* CB-6965 Port notification tests to test-framework +### 0.2.8 (Jun 05, 2014) +* [CB-6801](https://issues.apache.org/jira/browse/CB-6801) Add license +* running original windows.open, inAppBrowser is overriding it no need to place CSS in every page anymore +* [CB-5945](https://issues.apache.org/jira/browse/CB-5945) [Windows8] do not call success callbacks until dialog is dismissed +* [CB-4616](https://issues.apache.org/jira/browse/CB-4616) Returned index 0 was not documented for notification.prompt +* update docs to state that prompt is supported on windowsphone +* [CB-6528](https://issues.apache.org/jira/browse/CB-6528) allow scroll on alert message content +* [CB-6628][amazon-fireos]dialogs plugin's confirm and prompt methods dont work confirm() method was missing amazon-fireos platform check. added that. prompt() method had bug. It is executed in a worker thread that does not have a message queue(or Looper object) associated with it and hence "can't create a handler" exception is thrown. To fix this issue, we need to create the EditText widget from within the UI thread. This was fixed sometime ago when we added fireos platform but commit got lost somewhere. So fixing it again now. +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md +* Added check for isFinishing() on the parent activity to prevent crashes when trying to display dialogs when activity is in this phase of it's lifecycle +* [CB-4966](https://issues.apache.org/jira/browse/CB-4966) Dialogs are in window now No need to add anything to manifest or index.html +* Removing FirefoxOS Quirks * no need to add special permission (it's different API with the same name) * notification.css is added automatically -### 0.2.11 (Dec 02, 2014) -* [CB-7737] lower min height for alert -* CB-8038 backslash getting escaped twice in **BB10** -* CB-8029 test 1-based indexing for confirm -* CB-7639 Update docs + manual tests -* CB-7639 Revert back `isAlertShowing` flag in case of exception to prevent queuing of future dialogs. -* CB-7639 Handle button labels as array on windows -* CB-7977 Mention `deviceready` in plugin docs -* Check for `setTextDirection` API level -* **Android** Make spinner dialog to use `THEME_DEVICE_DEFAULT_LIGHT` (same as the other dialogs) -* **Android** Unbreak `API` level < `14` -* CB-7414 **BB10** Document callback parameter for `navigator.notification.alert` -* CB-7700 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs -* CB-7571 Bump version of nested plugin to match parent plugin +### 0.2.7 (Apr 17, 2014) +* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit +* [CB-6411](https://issues.apache.org/jira/browse/CB-6411): [BlackBerry10] Work around Audio playback issue +* [CB-6411](https://issues.apache.org/jira/browse/CB-6411): [BlackBerry10] Updates to beep +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* Add NOTICE file -### 0.3.0 (Feb 04, 2015) -* Correct way to specify Windows platform in config.xml -* CB-8351 ios: Use argumentForIndex rather than NSArray extension -* CB-7955 Add support "browser" platform +### 0.2.6 (Feb 05, 2014) +* no need to recreate the manifest.webapp file after each `cordova prepare` for FFOS +* FFOS description added -### 1.0.0 (Apr 15, 2015) -* CB-8746 gave plugin major version bump -* CB-8683 updated wp and bb specific references of old id to new id -* CB-8683 changed plugin-id to pacakge-name -* CB-8653 properly updated translated docs to use new id -* CB-8653 updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* CB-8653 Updated Readme -* CB-8659: ios: 4.0.x Compatibility: Remove use of deprecated headers -* CB-8565 Integrate TravisCI -* CB-8438 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs -* CB-8538 Added package.json file -* CB-8367 [org.apache.cordova.dialogs] Add Prompt support on Windows +### 0.2.5 (Jan 02, 2014) +* [CB-4696](https://issues.apache.org/jira/browse/CB-4696) Fix compile error for Xcode 4.5. +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Dialogs plugin +* [CB-3762](https://issues.apache.org/jira/browse/CB-3762) Change prompt default to empty string +* Move images from css to img -### 1.1.0 (May 06, 2015) -* CB-8928: Removed direct call to `toStaticHTML`, only call it if we are sure it's present. This closes #52 -* CB-7734 - `navigator.notification.alert` or `navigator.notification.confirm` seem have a "many words" issue. (closes #39) +### 0.2.4 (Dec 4, 2013) +* add ubuntu platform +* 1. Added amazon-fireos platform. 2. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'. +* added beep funtionality using ms-winsoundevent:Notfication.Default -### 1.1.1 (Jun 17, 2015) -* CB-9128 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs -* fix npm md +### 0.2.3 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for dialogs plugin +* new plugin execute arguments supported +* new plugin style +* smaller fonts styling input +* img files copied inside plugin +* style added +* prompt added +* styling from James +* fixed "exec" calls addedd css, but not working yet +* first (blind) try +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.2.2 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [windows8] commandProxy was moved +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming reference in Notification.cs +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.dialogs to org.apache.cordova.dialogs +* Rename CHANGELOG.md -> RELEASENOTES.md +* [CB-4592](https://issues.apache.org/jira/browse/CB-4592) [Blackberry10] Added beep support +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/de/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/es/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/fr/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/it/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/ja/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/ko/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/pl/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/ru/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-dialogs/doc/zh/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/package.json b/StoneIsland/plugins/cordova-plugin-dialogs/package.json old mode 100755 new mode 100644 index 3fd10da8..f85f14ce --- a/StoneIsland/plugins/cordova-plugin-dialogs/package.json +++ b/StoneIsland/plugins/cordova-plugin-dialogs/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-dialogs", - "version": "1.1.1", + "version": "1.3.0", "description": "Cordova Notification Plugin", "cordova": { "id": "cordova-plugin-dialogs", @@ -38,6 +38,20 @@ "cordova-windows8", "cordova-windows" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "engines": { + "cordovaDependencies": { + "2.0.0": { + "cordova": ">100" + } + } + }, + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/plugin.xml b/StoneIsland/plugins/cordova-plugin-dialogs/plugin.xml old mode 100755 new mode 100644 index 6d6235fa..1069cce1 --- a/StoneIsland/plugins/cordova-plugin-dialogs/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-dialogs/plugin.xml @@ -20,7 +20,7 @@ + version="1.3.0"> Notification Cordova Notification Plugin @@ -41,13 +41,13 @@ - - - - - - - + + + + + + + @@ -110,9 +110,9 @@ - - - + + + @@ -167,5 +167,7 @@ + + diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/android/Notification.java b/StoneIsland/plugins/cordova-plugin-dialogs/src/android/Notification.java old mode 100755 new mode 100644 index 3bc3cee6..f19bc888 --- a/StoneIsland/plugins/cordova-plugin-dialogs/src/android/Notification.java +++ b/StoneIsland/plugins/cordova-plugin-dialogs/src/android/Notification.java @@ -21,6 +21,7 @@ package org.apache.cordova.dialogs; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaInterface; import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.LOG; import org.apache.cordova.PluginResult; import org.json.JSONArray; import org.json.JSONException; @@ -31,6 +32,7 @@ import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.ProgressDialog; import android.content.DialogInterface; +import android.content.res.Resources; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; @@ -48,6 +50,8 @@ import android.widget.TextView; */ public class Notification extends CordovaPlugin { + private static final String LOG_TAG = "Notification"; + public int confirmResult = -1; public ProgressDialog spinnerDialog = null; public ProgressDialog progressDialog = null; @@ -139,6 +143,7 @@ public class Notification extends CordovaPlugin { try { Thread.sleep(100); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } } } @@ -215,7 +220,9 @@ public class Notification extends CordovaPlugin { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1)); } }); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on first button."); + } } // Second button @@ -228,7 +235,9 @@ public class Notification extends CordovaPlugin { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2)); } }); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on second button."); + } } // Third button @@ -241,7 +250,9 @@ public class Notification extends CordovaPlugin { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3)); } }); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on third button."); + } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) @@ -276,7 +287,14 @@ public class Notification extends CordovaPlugin { Runnable runnable = new Runnable() { public void run() { final EditText promptInput = new EditText(cordova.getActivity()); - promptInput.setHint(defaultText); + + /* CB-11677 - By default, prompt input text color is set according current theme. + But for some android versions is not visible (for example 5.1.1). + android.R.color.primary_text_light will make text visible on all versions. */ + Resources resources = cordova.getActivity().getResources(); + int promptInputTextColor = resources.getColor(android.R.color.primary_text_light); + promptInput.setTextColor(promptInputTextColor); + promptInput.setText(defaultText); AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); @@ -296,11 +314,15 @@ public class Notification extends CordovaPlugin { try { result.put("buttonIndex",1); result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText()); - } catch (JSONException e) { e.printStackTrace(); } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on first button.", e); + } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on first button."); + } } // Second button @@ -313,11 +335,15 @@ public class Notification extends CordovaPlugin { try { result.put("buttonIndex",2); result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText()); - } catch (JSONException e) { e.printStackTrace(); } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on second button.", e); + } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on second button."); + } } // Third button @@ -330,11 +356,15 @@ public class Notification extends CordovaPlugin { try { result.put("buttonIndex",3); result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText()); - } catch (JSONException e) { e.printStackTrace(); } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on third button.", e); + } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG,"JSONException on third button."); + } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog){ diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/blackberry10/index.js b/StoneIsland/plugins/cordova-plugin-dialogs/src/blackberry10/index.js old mode 100755 new mode 100644 index 3660f667..4969a770 --- a/StoneIsland/plugins/cordova-plugin-dialogs/src/blackberry10/index.js +++ b/StoneIsland/plugins/cordova-plugin-dialogs/src/blackberry10/index.js @@ -14,6 +14,8 @@ * limitations under the License. */ +/* global qnx, PluginResult */ + function showDialog(args, dialogType, result) { //Unpack and map the args var msg = JSON.parse(decodeURIComponent(args[0])), diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js b/StoneIsland/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js old mode 100755 new mode 100644 index b6986fd0..aea562d0 --- a/StoneIsland/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js +++ b/StoneIsland/plugins/cordova-plugin-dialogs/src/firefoxos/notification.js @@ -60,7 +60,8 @@ function modal(message, callback, title, buttonLabels, domObjects) { var menu = modalDocument.createElement('menu'); box.appendChild(menu); for (var index = 0; index < buttonLabels.length; index++) { - addButton(buttonLabels[index], index, (index === 0)); + // TODO: last button listens to the cancel key + addButton(buttonLabels[index], (index+1), (index === 0)); } modalDocument.body.appendChild(box); @@ -83,12 +84,12 @@ function modal(message, callback, title, buttonLabels, domObjects) { result = { input1: '', buttonIndex: 0 - } + }; } mainWindow.setTimeout(function() { callback(result); }, 10); - }; + } modalWindow.addEventListener('unload', onUnload, false); // call callback and destroy modal @@ -109,7 +110,7 @@ function modal(message, callback, title, buttonLabels, domObjects) { } response = response || labelIndex; callback(response); - } + }; } } diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.bundle/beep.wav b/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.bundle/beep.wav old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.h b/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m b/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m old mode 100755 new mode 100644 index 1581ad3c..0dd3d2cb --- a/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m +++ b/StoneIsland/plugins/cordova-plugin-dialogs/src/ios/CDVNotification.m @@ -23,6 +23,7 @@ #define DIALOG_TYPE_PROMPT @"prompt" static void soundCompletionCallback(SystemSoundID ssid, void* data); +static NSMutableArray *alertList = nil; @implementation CDVNotification @@ -39,7 +40,7 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data); - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType { - NSUInteger count = [buttons count]; + int count = (int)[buttons count]; #ifdef __IPHONE_8_0 if (NSClassFromString(@"UIAlertController")) { @@ -58,33 +59,32 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data); alertController.view.frame = alertFrame; } - + + __weak CDVNotification* weakNotif = self; + for (int n = 0; n < count; n++) { - - UIAlertAction* action = [UIAlertAction actionWithTitle:[buttons objectAtIndex:n] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) - { - CDVPluginResult* result; - - if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) { - - NSString* value0 = [[alertController.textFields objectAtIndex:0] text]; - NSDictionary* info = @{ - @"buttonIndex":@(n + 1), - @"input1":(value0 ? value0 : [NSNull null]) - }; - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info]; - - } else { - - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n + 1)]; - - } - - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - - }]; - [alertController addAction:action]; - + [alertController addAction:[UIAlertAction actionWithTitle:[buttons objectAtIndex:n] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) + { + CDVPluginResult* result; + + if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) + { + NSString* value0 = [[alertController.textFields objectAtIndex:0] text]; + NSDictionary* info = @{ + @"buttonIndex":@(n + 1), + @"input1":(value0 ? value0 : [NSNull null]) + }; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info]; + } + else + { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n + 1)]; + } + + [weakNotif.commandDelegate sendPluginResult:result callbackId:callbackId]; + }]]; } if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) { @@ -94,12 +94,19 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data); }]; } + if(!alertList) + alertList = [[NSMutableArray alloc] init]; + [alertList addObject:alertController]; + if ([alertList count]==1) { + [self presentAlertcontroller]; + } - [self.viewController presentViewController:alertController animated:YES completion:nil]; - - } else { + } + else + { #endif + CDVAlertView* alertView = [[CDVAlertView alloc] initWithTitle:title message:message @@ -183,6 +190,14 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data); [self.commandDelegate sendPluginResult:result callbackId:cdvAlertView.callbackId]; } +- (void)didPresentAlertView:(UIAlertView*)alertView +{ + //show keyboard on iOS 8 + if (alertView.alertViewStyle == UIAlertViewStylePlainTextInput){ + [[alertView textFieldAtIndex:0] selectAll:nil]; + } +} + static void playBeep(int count) { SystemSoundID completeSound; NSInteger cbDataCount = count; @@ -211,6 +226,26 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data) { playBeep([count intValue]); } +-(UIViewController *)getTopPresentedViewController { + UIViewController *presentingViewController = self.viewController; + while(presentingViewController.presentedViewController != nil && ![presentingViewController.presentedViewController isBeingDismissed]) + { + presentingViewController = presentingViewController.presentedViewController; + } + return presentingViewController; +} + +-(void)presentAlertcontroller { + + __weak CDVNotification* weakNotif = self; + [self.getTopPresentedViewController presentViewController:[alertList firstObject] animated:YES completion:^{ + [alertList removeObject:[alertList firstObject]]; + if ([alertList count]>0) { + [weakNotif presentAlertcontroller]; + } + }]; + +} @end diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.cpp b/StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.cpp old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.h b/StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.qml b/StoneIsland/plugins/cordova-plugin-dialogs/src/ubuntu/notification.qml old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js b/StoneIsland/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js old mode 100755 new mode 100644 index d1eb3448..2d32f836 --- a/StoneIsland/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js +++ b/StoneIsland/plugins/cordova-plugin-dialogs/src/windows/NotificationProxy.js @@ -17,17 +17,36 @@ * specific language governing permissions and limitations * under the License. * -*/ + */ -/*global Windows:true */ +/*global Windows:true, WinJS, toStaticHTML */ var cordova = require('cordova'); +var urlutil = require('cordova/urlutil'); var isAlertShowing = false; var alertStack = []; +function createCSSElem(fileName) { + var elemId = fileName.substr(0, fileName.lastIndexOf(".")) + "-plugin-style"; + // If the CSS element exists, don't recreate it. + if (document.getElementById(elemId)) { + return false; + } + + // Create CSS and append it to DOM. + var $elem = document.createElement('link'); + $elem.id = elemId; + $elem.rel = "stylesheet"; + $elem.type = "text/css"; + $elem.href = urlutil.makeAbsolute("/www/css/" + fileName); + + document.head.appendChild($elem); + return true; +} + // CB-8928: When toStaticHTML is undefined, prompt fails to run -function _cleanHtml(html) { return html; } +var _cleanHtml = function(html) { return html; }; if (typeof toStaticHTML !== 'undefined') { _cleanHtml = toStaticHTML; } @@ -36,66 +55,53 @@ if (typeof toStaticHTML !== 'undefined') { // simple html-based implementation until it is available function createPromptDialog(title, message, buttons, defaultText, callback) { - var isPhone = cordova.platformId == "windows" && WinJS.Utilities.isPhone;; + var isPhone = cordova.platformId === "windows" && WinJS.Utilities.isPhone; + var isWindows = !!cordova.platformId.match(/windows/); + + createCSSElem("notification.css"); var dlgWrap = document.createElement("div"); - dlgWrap.style.position = "absolute"; - dlgWrap.style.width = "100%"; - dlgWrap.style.height = "100%"; - dlgWrap.style.backgroundColor = "rgba(0,0,0,0.25)"; - dlgWrap.style.zIndex = "100000"; + dlgWrap.className = "dlgWrap"; var dlg = document.createElement("div"); - dlg.style.width = "100%"; - dlg.style.minHeight = "180px"; - dlg.style.height = "auto"; - dlg.style.overflow = "auto"; - dlg.style.backgroundColor = "white"; - dlg.style.position = "relative"; - dlg.style.lineHeight = "2"; - - if (isPhone) { - dlg.style.padding = "0px 5%"; - } else { - dlg.style.top = "50%"; // center vertically - dlg.style.transform = "translateY(-50%)"; - dlg.style.padding = "0px 30%"; + dlg.className = "dlgContainer"; + + if (isWindows) { + dlg.className += " dlgContainer-windows"; + } else if (isPhone) { + dlg.className += " dlgContainer-phone"; } + // dialog layout template - dlg.innerHTML = _cleanHtml("
" // title - + "
" // message - + "
"); // input fields + dlg.innerHTML = _cleanHtml("
" + // title + "
" + // message + "
"); // input fields dlg.querySelector('#lbl-title').appendChild(document.createTextNode(title)); dlg.querySelector('#lbl-message').appendChild(document.createTextNode(message)); dlg.querySelector('#prompt-input').setAttribute('placeholder', defaultText); + dlg.querySelector('#prompt-input').setAttribute('value', defaultText); function makeButtonCallback(idx) { return function () { - var value = promptInput = dlg.querySelector('#prompt-input').value; + var value = dlg.querySelector('#prompt-input').value || defaultText; dlgWrap.parentNode.removeChild(dlgWrap); if (callback) { callback({ input1: value, buttonIndex: idx }); } - } + }; } function addButton(idx, label) { var button = document.createElement('button'); - button.style.margin = "8px 0 8px 16px"; - button.style.float = "right"; - button.style.fontSize = "12pt"; + button.className = "dlgButton"; button.tabIndex = idx; button.onclick = makeButtonCallback(idx + 1); - if (idx == 0) { - button.style.color = "white"; - button.style.backgroundColor = "#464646"; - } else { - button.style.backgroundColor = "#cccccc"; + if (idx === 0) { + button.className += " dlgButtonFirst"; } - button.style.border = "none"; button.appendChild(document.createTextNode(label)); dlg.appendChild(button); } @@ -109,7 +115,7 @@ function createPromptDialog(title, message, buttons, defaultText, callback) { document.body.appendChild(dlgWrap); // make sure input field is under focus - dlg.querySelector('#prompt-input').focus(); + dlg.querySelector('#prompt-input').select(); return dlgWrap; } @@ -134,7 +140,9 @@ module.exports = { md.commands.append(new Windows.UI.Popups.UICommand(_buttonLabel)); md.showAsync().then(function() { isAlertShowing = false; - win && win(); + if (win) { + win(); + } if (alertStack.length) { setTimeout(alertStack.shift(), 0); @@ -204,7 +212,9 @@ module.exports = { md.showAsync().then(function(res) { isAlertShowing = false; var result = res ? buttons.indexOf(res.label) + 1 : 0; - win && win(result); + if (win) { + win(result); + } if (alertStack.length) { setTimeout(alertStack.shift(), 0); } @@ -236,7 +246,9 @@ module.exports = { } else { snd.removeEventListener("ended", onEvent); snd = null; - winX && winX(); // notification.js just sends null, but this is future friendly + if (winX) { + winX(); // notification.js just sends null, but this is future friendly + } } count--; }; diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/Notification.cs b/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/Notification.cs old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/NotificationBox.xaml b/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/NotificationBox.xaml old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/NotificationBox.xaml.cs b/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/NotificationBox.xaml.cs old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/notification-beep.wav b/StoneIsland/plugins/cordova-plugin-dialogs/src/wp/notification-beep.wav old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-dialogs/tests/plugin.xml old mode 100755 new mode 100644 index f021ddd5..55675b20 --- a/StoneIsland/plugins/cordova-plugin-dialogs/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-dialogs/tests/plugin.xml @@ -20,7 +20,7 @@ + version="1.3.0"> Cordova Notification Plugin Tests Apache 2.0 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/tests/tests.js b/StoneIsland/plugins/cordova-plugin-dialogs/tests/tests.js old mode 100755 new mode 100644 index 16e9cd99..7056c0db --- a/StoneIsland/plugins/cordova-plugin-dialogs/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-dialogs/tests/tests.js @@ -19,6 +19,9 @@ * */ +/* jshint jasmine: true */ +/* global cordova */ + exports.defineAutoTests = function () { describe('Notification (navigator.notification)', function () { it("should exist", function () { @@ -57,12 +60,12 @@ exports.defineManualTests = function (contentEl, createActionButton) { var logLine = document.createElement('div'); logLine.innerHTML = message; log.appendChild(logLine); - } + }; var clearLog = function () { var log = document.getElementById('info'); log.innerHTML = ''; - } + }; var beep = function () { console.log("beep()"); @@ -111,14 +114,14 @@ exports.defineManualTests = function (contentEl, createActionButton) { buttons); }; - var promptDialog = function (message, title, buttons) { + var promptDialog = function (message, title, buttons,defaultText) { clearLog(); navigator.notification.prompt(message, function (r) { if (r && r.buttonIndex === 0) { var msg = "Dismissed dialog"; if (r.input1) { - msg += " with input: " + r.input1 + msg += " with input: " + r.input1; } logMessage(msg); console.log(msg); @@ -128,7 +131,7 @@ exports.defineManualTests = function (contentEl, createActionButton) { } }, title, - buttons); + buttons,defaultText); }; /******************************************************************************/ @@ -144,13 +147,15 @@ exports.defineManualTests = function (contentEl, createActionButton) { '

' + 'Expected result: Dialog will say "You pressed confirm". Press Yes, No, or Maybe, Not Sure to close dialog. Status box will tell you what option you selected, and should use 1-based indexing.' + '

' + - 'Expected result: Dialog will say "You pressed prompt". Enter any message and press Yes, No, or Maybe, Not Sure to close dialog. Status box will tell you what option you selected and message you entered, and should use 1-based indexing.' + + 'Expected result: Dialog will say "You pressed prompt". Enter any message and press Yes, No, or Maybe, Not Sure to close dialog. Status box will tell you what option you selected and message you entered or if empty, it will display "Default Text", and should use 1-based indexing.' + '

' + 'Expected result: Dialog will have title "index.html" and say "You pressed alert" Press OK to close dialog. Nothing will get updated in status box.' + '

' + 'Expected result: Dialog will have title "index.html" and say "You selected confirm". Press Cancel or OK to close dialog. Nothing will get updated in status box.' + '

' + - 'Expected result: Dialog will have title "index.html" and say "This is a prompt". "Default value" will be in text box. Press Cancel or OK to close dialog. Nothing will get updated in status box.'; + 'Expected result: Dialog will have title "index.html" and say "This is a prompt". "Default value" will be in text box. Press Cancel or OK to close dialog. Nothing will get updated in status box.' + + '

CB-8947 Tests

' + + 'Expected results: Dialogs will not crash iOS'; contentEl.innerHTML = '
' + dialogs_tests; @@ -177,18 +182,52 @@ exports.defineManualTests = function (contentEl, createActionButton) { }, 'confirm'); createActionButton('Prompt Dialog', function () { - promptDialog('You pressed prompt.', 'Prompt Dialog', ['Yes', 'No', 'Maybe, Not Sure']); + promptDialog('You pressed prompt.', 'Prompt Dialog', ['Yes', 'No', 'Maybe, Not Sure'],'Default Text'); }, 'prompt'); createActionButton('Built-in Alert Dialog', function () { - typeof alert === 'function' && alert('You pressed alert'); + if (typeof alert === 'function') { + alert('You pressed alert'); + } }, 'built_in_alert'); createActionButton('Built-in Confirm Dialog', function () { - typeof confirm === 'function' && confirm('You selected confirm'); + if (typeof confirm === 'function') { + confirm('You selected confirm'); + } }, 'built_in_confirm'); createActionButton('Built-in Prompt Dialog', function () { - typeof prompt === 'function' && prompt('This is a prompt', 'Default value'); + if (typeof prompt === 'function') { + prompt('This is a prompt', 'Default value'); + } }, 'built_in_prompt'); + + // CB-8947 - ensure number messages don't crash iOS + createActionButton('Alert Dialog with Number', function () { + var callback = function() { clearLog(); console.log("Test passed"); }; + navigator.notification.alert(17, callback); + }, 'cb8947'); + + // CB-8947 - ensure object messages don't crash iOS + createActionButton('Alert Dialog with Object', function () { + var object = { number: 42, message: "Make sure an object doesn't crash iOS", issue: 'CB-8947'}; + var callback = function() { clearLog(); console.log("Test passed"); }; + navigator.notification.alert(object, callback); + }, 'cb8947'); + + // CB-8947 - ensure object messages don't crash iOS + createActionButton('Confirm Dialog with Object', function () { + var object = { number: 42, message: "Make sure an object doesn't crash iOS", issue: 'CB-8947'}; + var callback = function() { clearLog(); console.log("Test passed"); }; + navigator.notification.confirm(object, callback); + }, 'cb8947'); + + // CB-8947 - ensure object messages don't crash iOS + createActionButton('Prompt Dialog with Object', function () { + var object = { number: 42, message: "Make sure an object doesn't crash iOS", issue: 'CB-8947'}; + var callback = function() { clearLog(); console.log("Test passed"); }; + navigator.notification.prompt(object, callback); + }, 'cb8947'); + }; diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/android/notification.js b/StoneIsland/plugins/cordova-plugin-dialogs/www/android/notification.js old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js b/StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js old mode 100755 new mode 100644 index 401049e8..da2e75d1 --- a/StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js +++ b/StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/beep.js @@ -21,20 +21,24 @@ module.exports = function (quantity) { var count = 0, - beepObj, - play = function () { - //create new object every time due to strage playback behaviour - beepObj = new Audio('local:///chrome/plugin/cordova-plugin-dialogs/notification-beep.wav'); - beepObj.addEventListener("ended", callback); - beepObj.play(); - }, - callback = function () { - if (--count > 0) { - play(); - } else { - delete beepObj; - } - }; + beepObj; + + function callback() { + if (--count > 0) { + play(); + } else { + beepObj.removeEventListener("ended", callback); + beepObj = null; + } + } + + function play() { + //create new object every time due to strage playback behaviour + beepObj = new Audio('local:///chrome/plugin/cordova-plugin-dialogs/notification-beep.wav'); + beepObj.addEventListener("ended", callback); + beepObj.play(); + } + count += quantity || 1; if (count > 0) { play(); diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/notification-beep.wav b/StoneIsland/plugins/cordova-plugin-dialogs/www/blackberry10/notification-beep.wav old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/browser/notification.js b/StoneIsland/plugins/cordova-plugin-dialogs/www/browser/notification.js old mode 100755 new mode 100644 index e8753093..1fdfafd7 --- a/StoneIsland/plugins/cordova-plugin-dialogs/www/browser/notification.js +++ b/StoneIsland/plugins/cordova-plugin-dialogs/www/browser/notification.js @@ -65,6 +65,21 @@ module.exports.prompt = window.navigator.notification.prompt = function(message, }; +var audioContext = (function() { + // Determine if the Audio API is supported by this browser + var AudioApi = window.AudioContext; + if (!AudioApi) { + AudioApi = window.webkitAudioContext; + } + + if (AudioApi) { + // The Audio API is supported, so create a singleton instance of the AudioContext + return new AudioApi(); + } + + return undefined; +}()); + module.exports.beep = window.navigator.notification.beep = function(times) { if (times > 0) { var BEEP_DURATION = 700; @@ -98,18 +113,3 @@ module.exports.beep = window.navigator.notification.beep = function(times) { } } }; - -var audioContext = (function() { - // Determine if the Audio API is supported by this browser - var AudioApi = window.AudioContext; - if (!AudioApi) { - AudioApi = window.webkitAudioContext; - } - - if (AudioApi) { - // The Audio API is supported, so create a singleton instance of the AudioContext - return new AudioApi(); - } - - return undefined; -}()); diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/danger-press.png b/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/danger-press.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/danger.png b/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/danger.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/default.png b/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/default.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/gradient.png b/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/gradient.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/notification.css b/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/notification.css old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/pattern.png b/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/pattern.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/recommend.png b/StoneIsland/plugins/cordova-plugin-dialogs/www/firefoxos/recommend.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/notification.js b/StoneIsland/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index c3f70d07..4db8f0f2 --- a/StoneIsland/plugins/cordova-plugin-dialogs/www/notification.js +++ b/StoneIsland/plugins/cordova-plugin-dialogs/www/notification.js @@ -37,9 +37,10 @@ module.exports = { * @param {String} buttonLabel Label of the close button (default: OK) */ alert: function(message, completeCallback, title, buttonLabel) { - var _title = (title || "Alert"); + var _message = (typeof message === "string" ? message : JSON.stringify(message)); + var _title = (typeof title === "string" ? title : "Alert"); var _buttonLabel = (buttonLabel || "OK"); - exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]); + exec(completeCallback, null, "Notification", "alert", [_message, _title, _buttonLabel]); }, /** @@ -52,7 +53,8 @@ module.exports = { * @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel']) */ confirm: function(message, resultCallback, title, buttonLabels) { - var _title = (title || "Confirm"); + var _message = (typeof message === "string" ? message : JSON.stringify(message)); + var _title = (typeof title === "string" ? title : "Confirm"); var _buttonLabels = (buttonLabels || ["OK", "Cancel"]); // Strings are deprecated! @@ -60,23 +62,9 @@ module.exports = { console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array)."); } - // Some platforms take an array of button label names. - // Other platforms take a comma separated list. - // For compatibility, we convert to the desired type based on the platform. - if (platform.id == "amazon-fireos" || platform.id == "android" || platform.id == "ios" || - platform.id == "windowsphone" || platform.id == "firefoxos" || platform.id == "ubuntu" || - platform.id == "windows8" || platform.id == "windows") { - - if (typeof _buttonLabels === 'string') { - _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here - } - } else { - if (Array.isArray(_buttonLabels)) { - var buttonLabelArray = _buttonLabels; - _buttonLabels = buttonLabelArray.toString(); - } - } - exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]); + _buttonLabels = convertButtonLabels(_buttonLabels); + + exec(resultCallback, null, "Notification", "confirm", [_message, _title, _buttonLabels]); }, /** @@ -92,9 +80,17 @@ module.exports = { * @param {String} defaultText Textbox input value (default: empty string) */ prompt: function(message, resultCallback, title, buttonLabels, defaultText) { - var _message = (message || "Prompt message"); - var _title = (title || "Prompt"); + var _message = (typeof message === "string" ? message : JSON.stringify(message)); + var _title = (typeof title === "string" ? title : "Prompt"); var _buttonLabels = (buttonLabels || ["OK","Cancel"]); + + // Strings are deprecated! + if (typeof _buttonLabels === 'string') { + console.log("Notification.prompt(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array)."); + } + + _buttonLabels = convertButtonLabels(_buttonLabels); + var _defaultText = (defaultText || ""); exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]); }, @@ -110,3 +106,25 @@ module.exports = { exec(null, null, "Notification", "beep", [ defaultedCount ]); } }; + +function convertButtonLabels(buttonLabels) { + + // Some platforms take an array of button label names. + // Other platforms take a comma separated list. + // For compatibility, we convert to the desired type based on the platform. + if (platform.id == "amazon-fireos" || platform.id == "android" || platform.id == "ios" || + platform.id == "windowsphone" || platform.id == "firefoxos" || platform.id == "ubuntu" || + platform.id == "windows8" || platform.id == "windows") { + + if (typeof buttonLabels === 'string') { + buttonLabels = buttonLabels.split(","); // not crazy about changing the var type here + } + } else { + if (Array.isArray(buttonLabels)) { + var buttonLabelArray = buttonLabels; + buttonLabels = buttonLabelArray.toString(); + } + } + + return buttonLabels; +} diff --git a/StoneIsland/plugins/cordova-plugin-dialogs/www/windows/notification.css b/StoneIsland/plugins/cordova-plugin-dialogs/www/windows/notification.css new file mode 100644 index 00000000..785039ba --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-dialogs/www/windows/notification.css @@ -0,0 +1,84 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +.dlgWrap { + position: absolute; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.25); + z-index: 100000; + top: 0; +} + +.dlgContainer { + width: 100%; + min-height: 180px; + height: auto; + overflow: auto; + background-color: white; + position: relative; + line-height: 2; + top: 50%; + transform: translateY(-50%); + padding: 0 30%; +} + +.dlgContainer #lbl-title { + font-size: 24pt; +} + +.dlgContainer #prompt-input { + width: 100%; +} + +.dlgButton { + margin: 8px 0 0 16px; + float: right; + font-size: 11pt; + background-color: #cccccc; + border: none; + font-weight: 600; + font-family: "Segoe UI", Arial, sans-serif; + padding: 0 22px; +} + +.dlgButton.dlgButtonFirst { + color: white; + background-color: #464646; +} + +.dlgContainer.dlgContainer-windows { + width: 50%; + max-width: 680px; + padding: 0 5%; + top: 50%; + left: 50%; + position: fixed; + transform: translate(-50%, -50%); + border: 1px solid rgb(24, 160, 191); + border-image: none; + box-shadow: 0 0 14px 6px rgba(0,0,0,0.16); + text-transform: none; +} + +.dlgContainer.dlgContainer-phone { + padding: 0 5%; +} diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md old mode 100755 new mode 100644 index f7dbcaba..4c8e6a5e --- a/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/LICENSE b/StoneIsland/plugins/cordova-plugin-geolocation/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/NOTICE b/StoneIsland/plugins/cordova-plugin-geolocation/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/README.md old mode 100755 new mode 100644 index eb10b9f8..77a3c9a7 --- a/StoneIsland/plugins/cordova-plugin-geolocation/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/README.md @@ -1,3 +1,7 @@ +--- +title: Geolocation +description: Access GPS data. +--- -# cordova-plugin-geolocation +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation)| -[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg)](https://travis-ci.org/apache/cordova-plugin-geolocation) +# cordova-plugin-geolocation This plugin provides information about the device's location, such as -latitude and longitude. Common sources of location information include +latitude and longitude. + +Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs. There is no guarantee that the API returns the device's actual location. +> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content. + This API is based on the [W3C Geolocation API Specification](http://dev.w3.org/geo/api/spec-source.html), and only executes on devices that don't already provide an implementation. @@ -45,7 +55,7 @@ accesses geolocation data (if the device operating system doesn't do so already). That notice should provide the same information noted above, as well as obtaining the user's permission (e.g., by presenting choices for __OK__ and __No Thanks__). For more information, please -see the Privacy Guide. +see the [Privacy Guide](http://cordova.apache.org/docs/en/latest/guide/appdev/privacy/index.html). This plugin defines a global `navigator.geolocation` object (for platforms where it is otherwise missing). @@ -53,11 +63,15 @@ where it is otherwise missing). Although the object is in the global scope, features provided by this plugin are not available until after the `deviceready` event. +```javascript + document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { console.log("navigator.geolocation works well"); } +``` +## Reference ## Installation This requires cordova 5.0+ ( current stable 1.0.0 ) @@ -81,7 +95,6 @@ It is also possible to install via repo url directly ( unstable ) - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 - Windows ## Methods @@ -118,6 +131,8 @@ error, the `geolocationError` callback is passed a ### Example +```javascript + // onSuccess Callback // This method accepts a Position object, which contains the // current GPS coordinates @@ -142,6 +157,13 @@ error, the `geolocationError` callback is passed a navigator.geolocation.getCurrentPosition(onSuccess, onError); +``` + +### Android Quirks + +If Geolocation service is turned off the `onError` callback is invoked after `timeout` interval (if specified). +If `timeout` parameter is not specified then no callback is called. + ## navigator.geolocation.watchPosition Returns the device's current position when a change in position is detected. @@ -168,6 +190,8 @@ there is an error, the `geolocationError` callback executes with a ### Example +```javascript + // onSuccess Callback // This method accepts a `Position` object, which contains // the current GPS coordinates @@ -190,6 +214,7 @@ there is an error, the `geolocationError` callback executes with a // var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 30000 }); +``` ## geolocationOptions @@ -208,7 +233,8 @@ Optional parameters to customize the retrieval of the geolocation ### Android Quirks -Android 2.x emulators do not return a geolocation result unless the `enableHighAccuracy` option is set to `true`. +If Geolocation service is turned off the `onError` callback is invoked after `timeout` interval (if specified). +If `timeout` parameter is not specified then no callback is called. ## navigator.geolocation.clearWatch @@ -223,6 +249,8 @@ Stop watching for changes to the device's location referenced by the ### Example +```javascript + // Options: watch for changes in position, and use the most // accurate position acquisition method available. // @@ -232,6 +260,8 @@ Stop watching for changes to the device's location referenced by the navigator.geolocation.clearWatch(watchID); +``` + ## Position Contains `Position` coordinates and timestamp, created by the geolocation API. @@ -240,7 +270,7 @@ Contains `Position` coordinates and timestamp, created by the geolocation API. - __coords__: A set of geographic coordinates. _(Coordinates)_ -- __timestamp__: Creation timestamp for `coords`. _(Date)_ +- __timestamp__: Creation timestamp for `coords`. _(DOMTimeStamp)_ ## Coordinates @@ -291,3 +321,438 @@ callback function when an error occurs with navigator.geolocation. - Returned when the device is unable to retrieve a position. In general, this means the device is not connected to a network or can't get a satellite fix. - `PositionError.TIMEOUT` - Returned when the device is unable to retrieve a position within the time specified by the `timeout` included in `geolocationOptions`. When used with `navigator.geolocation.watchPosition`, this error could be repeatedly passed to the `geolocationError` callback every `timeout` milliseconds. + + +## Sample: Get the weather, find stores, and see photos of things nearby with Geolocation ## + +Use this plugin to help users find things near them such as Groupon deals, houses for sale, movies playing, sports and entertainment events and more. + +Here's a "cookbook" of ideas to get you started. In the snippets below, we'll show you some basic ways to add these features to your app. + +* [Get your coordinates](#coords). +* [Get the weather forecast](#weather). +* [Receive updated weather forecasts as you drive around](#receive). +* [See where you are on a map](#see). +* [Find stores near you](#find). +* [See pictures of things around you](#see). + +## Get your geolocation coordinates + +```javascript + +function getWeatherLocation() { + + navigator.geolocation.getCurrentPosition + (onWeatherSuccess, onWeatherError, { enableHighAccuracy: true }); +} + +``` +## Get the weather forecast + +```javascript + +// Success callback for get geo coordinates + +var onWeatherSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getWeather(Latitude, Longitude); +} + +// Get weather by using coordinates + +function getWeather(latitude, longitude) { + + // Get a free key at http://openweathermap.org/. Replace the "Your_Key_Here" string with that key. + var OpenWeatherAppKey = "Your_Key_Here"; + + var queryString = + 'http://api.openweathermap.org/data/2.5/weather?lat=' + + latitude + '&lon=' + longitude + '&appid=' + OpenWeatherAppKey + '&units=imperial'; + + $.getJSON(queryString, function (results) { + + if (results.weather.length) { + + $.getJSON(queryString, function (results) { + + if (results.weather.length) { + + $('#description').text(results.name); + $('#temp').text(results.main.temp); + $('#wind').text(results.wind.speed); + $('#humidity').text(results.main.humidity); + $('#visibility').text(results.weather[0].main); + + var sunriseDate = new Date(results.sys.sunrise); + $('#sunrise').text(sunriseDate.toLocaleTimeString()); + + var sunsetDate = new Date(results.sys.sunrise); + $('#sunset').text(sunsetDate.toLocaleTimeString()); + } + + }); + } + }).fail(function () { + console.log("error getting location"); + }); +} + +// Error callback + +function onWeatherError(error) { + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +``` + +## Receive updated weather forecasts as you drive around + +```javascript + +// Watch your changing position + +function watchWeatherPosition() { + + return navigator.geolocation.watchPosition + (onWeatherWatchSuccess, onWeatherError, { enableHighAccuracy: true }); +} + +// Success callback for watching your changing position + +var onWeatherWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + // Calls function we defined earlier. + getWeather(updatedLatitude, updatedLongitude); + } +} + +``` + +## See where you are on a map + +Both Bing and Google have map services. We'll use Google's. You'll need a key but it's free if you're just trying things out. + +Add a reference to the **maps** service. + +```HTML + + + +``` +Then, add code to use it. + +```javascript + +var Latitude = undefined; +var Longitude = undefined; + +// Get geo coordinates + +function getMapLocation() { + + navigator.geolocation.getCurrentPosition + (onMapSuccess, onMapError, { enableHighAccuracy: true }); +} + +// Success callback for get geo coordinates + +var onMapSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getMap(Latitude, Longitude); + +} + +// Get map by using coordinates + +function getMap(latitude, longitude) { + + var mapOptions = { + center: new google.maps.LatLng(0, 0), + zoom: 1, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + + map = new google.maps.Map + (document.getElementById("map"), mapOptions); + + + var latLong = new google.maps.LatLng(latitude, longitude); + + var marker = new google.maps.Marker({ + position: latLong + }); + + marker.setMap(map); + map.setZoom(15); + map.setCenter(marker.getPosition()); +} + +// Success callback for watching your changing position + +var onMapWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + getMap(updatedLatitude, updatedLongitude); + } +} + +// Error callback + +function onMapError(error) { + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +// Watch your changing position + +function watchMapPosition() { + + return navigator.geolocation.watchPosition + (onMapWatchSuccess, onMapError, { enableHighAccuracy: true }); +} + +``` + +## Find stores near you + +You can use the same Google key for this. + +Add a reference to the **places** service. + +```HTML + + + +``` + +Then, add code to use it. + +```javascript + +var Map; +var Infowindow; +var Latitude = undefined; +var Longitude = undefined; + +// Get geo coordinates + +function getPlacesLocation() { + navigator.geolocation.getCurrentPosition + (onPlacesSuccess, onPlacesError, { enableHighAccuracy: true }); +} + +// Success callback for get geo coordinates + +var onPlacesSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getPlaces(Latitude, Longitude); + +} + +// Get places by using coordinates + +function getPlaces(latitude, longitude) { + + var latLong = new google.maps.LatLng(latitude, longitude); + + var mapOptions = { + + center: new google.maps.LatLng(latitude, longitude), + zoom: 15, + mapTypeId: google.maps.MapTypeId.ROADMAP + + }; + + Map = new google.maps.Map(document.getElementById("places"), mapOptions); + + Infowindow = new google.maps.InfoWindow(); + + var service = new google.maps.places.PlacesService(Map); + service.nearbySearch({ + + location: latLong, + radius: 500, + type: ['store'] + }, foundStoresCallback); + +} + +// Success callback for watching your changing position + +var onPlacesWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + getPlaces(updatedLatitude, updatedLongitude); + } +} + +// Success callback for locating stores in the area + +function foundStoresCallback(results, status) { + + if (status === google.maps.places.PlacesServiceStatus.OK) { + + for (var i = 0; i < results.length; i++) { + + createMarker(results[i]); + + } + } +} + +// Place a pin for each store on the map + +function createMarker(place) { + + var placeLoc = place.geometry.location; + + var marker = new google.maps.Marker({ + map: Map, + position: place.geometry.location + }); + + google.maps.event.addListener(marker, 'click', function () { + + Infowindow.setContent(place.name); + Infowindow.open(Map, this); + + }); +} + +// Error callback + +function onPlacesError(error) { + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +// Watch your changing position + +function watchPlacesPosition() { + + return navigator.geolocation.watchPosition + (onPlacesWatchSuccess, onPlacesError, { enableHighAccuracy: true }); +} + +``` + +## See pictures of things around you + +Digital photos can contain geo coordinates that identify where the picture was taken. + +Use Flickr API's to find pictures that folks have taken near you. Like Google services, you'll need a key, but it's free if you just want to try things out. + +```javascript + +var Latitude = undefined; +var Longitude = undefined; + +// Get geo coordinates + +function getPicturesLocation() { + + navigator.geolocation.getCurrentPosition + (onPicturesSuccess, onPicturesError, { enableHighAccuracy: true }); + +} + +// Success callback for get geo coordinates + +var onPicturesSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getPictures(Latitude, Longitude); +} + +// Get pictures by using coordinates + +function getPictures(latitude, longitude) { + + $('#pictures').empty(); + + var queryString = + "https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=Your_API_Key&lat=" + + latitude + "&lon=" + longitude + "&format=json&jsoncallback=?"; + + $.getJSON(queryString, function (results) { + $.each(results.photos.photo, function (index, item) { + + var photoURL = "http://farm" + item.farm + ".static.flickr.com/" + + item.server + "/" + item.id + "_" + item.secret + "_m.jpg"; + + $('#pictures').append($("").attr("src", photoURL)); + + }); + } + ); +} + +// Success callback for watching your changing position + +var onPicturesWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + getPictures(updatedLatitude, updatedLongitude); + } +} + +// Error callback + +function onPicturesError(error) { + + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +// Watch your changing position + +function watchPicturePosition() { + + return navigator.geolocation.watchPosition + (onPicturesWatchSuccess, onPicturesError, { enableHighAccuracy: true }); +} + +``` diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md old mode 100755 new mode 100644 index 197b28e5..f622086b --- a/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md @@ -20,110 +20,152 @@ --> # Release Notes -### 0.3.0 (Sept 5, 2013) -* Added support for windows 8 (Adds required permission) +### 2.4.0 (Sep 26, 2016) +* **Ubuntu** Fix altitude & accuracies retrieval +* [CB-11875](https://issues.apache.org/jira/browse/CB-11875) added `android.hardware.location.gps` `uses-feature`. -### 0.3.2 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* [BlackBerry10] removed uneeded permission tags in plugin.xml -* CB-4889 renaming org.apache.cordova.core.geolocation to org.apache.cordova.geolocation +### 2.3.0 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* Plugin uses `Android Log class` and not `Cordova LOG class` +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* Adding links to reference content and sample content to the top of the readme file +* Update **iOS** geolocation plugin to avoid `THREAD WARNING: ['Geolocation']`, operation occurs in new Thread +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md -### 0.3.3 (Oct 28, 2013) -* CB-5128: add repo + issue tag to plugin.xml for geolocation plugin -* [CB-4915] Incremented plugin version on dev branch. +### 2.2.0 (Apr 15, 2016) +* Replace `PermissionHelper.java` with `cordova-plugin-compat` +* [CB-10691](https://issues.apache.org/jira/browse/CB-10691) Check the context to avoid null errors +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins +* Using a fallback epsilon in case `Number.EPSILON` is not defined. +* [CB-10574](https://issues.apache.org/jira/browse/CB-10574) MobileSpec can't get results for **WP8.1** Builds -### 0.3.4 (Dec 4, 2013) -* Append proxy to platform definition in plugin.xml -* Append windows 8 Geolocation proxy -* Code clean-up for android src. -* Updated amazon-fireos platform + reverting some of the fixes in android code. -* Added amazon-fireos platform + some of the fixes in android code. -* CB-5334 [BlackBerry10] Use command proxy -* call FxOS's getCurrentProxy added -* pass by only coords -* proper implementation for firefoxos - -### 0.3.5 (Jan 02, 2014) -* CB-5658 Add doc/index.md for Geolocation plugin -* windows8: adds missing reference to PositionError (w/o it the app crashes) -* Removing incorrectly added closing comments for wp7 platform in plugin.xml +### 2.1.0 (Jan 15, 2016) +* [CB-10319](https://issues.apache.org/jira/browse/CB-10319) **Android** Adding reflective helper methods for permission requests +* [CB-8523](https://issues.apache.org/jira/browse/CB-8523) Fixed accuracy when `enableHighAccuracy: false` on **iOS**. +* [CB-10286](https://issues.apache.org/jira/browse/CB-10286) Don't skip automatic tests on **Android** devices +* [CB-10277](https://issues.apache.org/jira/browse/CB-10277) Error callback should be called w/ `PositionError` when location access is denied +* [CB-10285](https://issues.apache.org/jira/browse/CB-10285) Added tests for `PositionError` constants +* [CB-10278](https://issues.apache.org/jira/browse/CB-10278) geolocation `watchPosition` doesn't return `watchID` string +* [CB-8443](https://issues.apache.org/jira/browse/CB-8443) **Android** nothing happens if `GPS` is turned off +* [CB-10204](https://issues.apache.org/jira/browse/CB-10204) Fix `getCurrentPosition` options on **Android** +* [CB-7146](https://issues.apache.org/jira/browse/CB-7146) Remove built-in `WebView navigator.geolocation` manual tests +* [CB-2845](https://issues.apache.org/jira/browse/CB-2845) `PositionError` constants not attached to prototype as specified in W3C document -### 0.3.6 (Feb 05, 2014) -* add ubuntu platform support -* CB-5326 adding FFOS permission and updating supported platforms -* CB-5729 [BlackBerry10] Update GeolocationProxy to return collapsed object +### 2.0.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* [CB-9907](https://issues.apache.org/jira/browse/CB-9907) Handle **iOS** tests that fail when ios simulator does not have a location +* [CB-8826](https://issues.apache.org/jira/browse/CB-8826) Check for `NSLocationWhenInUseUsageDescription` first +* [CB-9105](https://issues.apache.org/jira/browse/CB-9105): Fixing `JS` errors in the shim +* Added support for new permissions model for **Android 6.0** aka **Marshmallow** +* Expect `lastPosition` to have a `timestamp` that is already in `msecs` +* [CB-4596](https://issues.apache.org/jira/browse/CB-4596) Date objects are supposed to be `DOMTimeStamp` +* Fixing contribute link. +* [CB-9355](https://issues.apache.org/jira/browse/CB-9355) Fix Geolocation plugin start watch fail related to unset `MovementThreshold` on **Windows 10** -### 0.3.7 (Apr 17, 2014) -* CB-6422: [windows8] use cordova/exec/proxy -* CB-6212: [iOS] fix warnings compiled under arm64 64-bit -* CB-5977: [android] Removing the Android Geolocation Code. Mission Accomplished. -* CB-6460: Update license headers -* Add NOTICE file +### 1.0.1 (Jun 17, 2015) +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation +* fix npm md issue +* [CB-8845](https://issues.apache.org/jira/browse/CB-8845) Updated comment why Android tests are currently pended +* [CB-8845](https://issues.apache.org/jira/browse/CB-8845) Pended tests for Android +* Add more install text for legacy versions of cordova tools. This closes #36 -### 0.3.8 (Jun 05, 2014) -* CB-6127 Spanish and French Translations added. Github close #14 -* CB-6804 Add license -* CB-5416 - Adding support for auto-managing permissions -* CB-6491 add CONTRIBUTING.md -* pass by only coords -* proper implementation for firefoxos -* call FxOS's getCurrentProxy added +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8681](https://issues.apache.org/jira/browse/CB-8681) Fixed occasional test failures +* docs: added Windows to supported platforms +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of initWebView method +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of deprecated headers +* Wrong parameter in Firefox OS plugin +* [CB-8568](https://issues.apache.org/jira/browse/CB-8568) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file +* [CB-8443](https://issues.apache.org/jira/browse/CB-8443) Geolocation tests fail on Windows due to done is called multiple times -### 0.3.9 (Aug 06, 2014) -* **FFOS** update GeolocationProxy.js -* CB-7187 ios: Add explicit dependency on CoreLocation.framework -* CB-7187 Delete unused #import of CDVShared.h -* CB-6127 Updated translations for docs -* ios: Changed distanceFilter from none to 5 meters, prevents it from spamming the callback even though nothing changed. +### 0.3.12 (Feb 04, 2015) +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension +### 0.3.11 (Dec 02, 2014) +* Do not stop updating location when the error is `kCLErrorLocationUnknown` +* [CB-8094](https://issues.apache.org/jira/browse/CB-8094) Pended auto tests for **Windows** Store since they require user interaction +* [CB-8085](https://issues.apache.org/jira/browse/CB-8085) Fix geolocation plugin on **Windows** +* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation ### 0.3.10 (Sep 17, 2014) -* CB-7556 iOS: Clearing all Watches does not stop Location Services -* CB-7158 Fix geolocation for ios 8 -* Revert CB-6911 partially (keeping Info.plist key installation for iOS 8) -* CB-6911 Geolocation fails in iOS 8 -* CB-5114 Windows 8.1 - Use a new proxy as old geolocation methods is deprecated -* CB-5114 Append Windows 8.1 into plugin.xml + Optimize Windows 8 Geolocation proxy +* [CB-7556](https://issues.apache.org/jira/browse/CB-7556) iOS: Clearing all Watches does not stop Location Services +* [CB-7158](https://issues.apache.org/jira/browse/CB-7158) Fix geolocation for ios 8 +* Revert [CB-6911](https://issues.apache.org/jira/browse/CB-6911) partially (keeping Info.plist key installation for iOS 8) +* [CB-6911](https://issues.apache.org/jira/browse/CB-6911) Geolocation fails in iOS 8 +* [CB-5114](https://issues.apache.org/jira/browse/CB-5114) Windows 8.1 - Use a new proxy as old geolocation methods is deprecated +* [CB-5114](https://issues.apache.org/jira/browse/CB-5114) Append Windows 8.1 into plugin.xml + Optimize Windows 8 Geolocation proxy * Renamed test dir, added nested plugin.xml * added documentation for manual tests -* CB-7146 Added manual tests +* [CB-7146](https://issues.apache.org/jira/browse/CB-7146) Added manual tests * Removed js-module for tests from plugin.xml * Changing cdvtest format to use module exports * register tests using new style * Convert tests to new style * Removed amazon-fireos code for geolocation. -* CB-7571 Bump version of nested plugin to match parent plugin +* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin -### 0.3.11 (Dec 02, 2014) -* Do not stop updating location when the error is `kCLErrorLocationUnknown` -* CB-8094 Pended auto tests for **Windows** Store since they require user interaction -* CB-8085 Fix geolocation plugin on **Windows** -* CB-7977 Mention `deviceready` in plugin docs -* CB-7700 cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation +### 0.3.9 (Aug 06, 2014) +* **FFOS** update GeolocationProxy.js +* [CB-7187](https://issues.apache.org/jira/browse/CB-7187) ios: Add explicit dependency on CoreLocation.framework +* [CB-7187](https://issues.apache.org/jira/browse/CB-7187) Delete unused #import of CDVShared.h +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs +* ios: Changed distanceFilter from none to 5 meters, prevents it from spamming the callback even though nothing changed. -### 0.3.12 (Feb 04, 2015) -* CB-8351 ios: Use argumentForIndex rather than NSArray extension +### 0.3.8 (Jun 05, 2014) +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #14 +* [CB-6804](https://issues.apache.org/jira/browse/CB-6804) Add license +* [CB-5416](https://issues.apache.org/jira/browse/CB-5416) - Adding support for auto-managing permissions +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md +* pass by only coords +* proper implementation for firefoxos +* call FxOS's getCurrentProxy added -### 1.0.0 (Apr 15, 2015) -* CB-8746 gave plugin major version bump -* CB-8683 changed plugin-id to pacakge-name -* CB-8653 properly updated translated docs to use new id -* CB-8653 updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* CB-8681 Fixed occasional test failures -* docs: added Windows to supported platforms -* CB-8653 Updated Readme -* CB-8659: ios: 4.0.x Compatibility: Remove use of initWebView method -* CB-8659: ios: 4.0.x Compatibility: Remove use of deprecated headers -* Wrong parameter in Firefox OS plugin -* CB-8568 Integrate TravisCI -* CB-8438 cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation -* CB-8538 Added package.json file -* CB-8443 Geolocation tests fail on Windows due to done is called multiple times +### 0.3.7 (Apr 17, 2014) +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit +* [CB-5977](https://issues.apache.org/jira/browse/CB-5977): [android] Removing the Android Geolocation Code. Mission Accomplished. +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* Add NOTICE file -### 1.0.1 (Jun 17, 2015) -* CB-9128 cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation -* fix npm md issue -* CB-8845 Updated comment why Android tests are currently pended -* CB-8845 Pended tests for Android -* Add more install text for legacy versions of cordova tools. This closes #36 +### 0.3.6 (Feb 05, 2014) +* add ubuntu platform support +* [CB-5326](https://issues.apache.org/jira/browse/CB-5326) adding FFOS permission and updating supported platforms +* [CB-5729](https://issues.apache.org/jira/browse/CB-5729) [BlackBerry10] Update GeolocationProxy to return collapsed object + +### 0.3.5 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Geolocation plugin +* windows8: adds missing reference to PositionError (w/o it the app crashes) +* Removing incorrectly added closing comments for wp7 platform in plugin.xml + +### 0.3.4 (Dec 4, 2013) +* Append proxy to platform definition in plugin.xml +* Append windows 8 Geolocation proxy +* Code clean-up for android src. +* Updated amazon-fireos platform + reverting some of the fixes in android code. +* Added amazon-fireos platform + some of the fixes in android code. +* [CB-5334](https://issues.apache.org/jira/browse/CB-5334) [BlackBerry10] Use command proxy +* call FxOS's getCurrentProxy added +* pass by only coords +* proper implementation for firefoxos + +### 0.3.3 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to plugin.xml for geolocation plugin +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.3.2 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [BlackBerry10] removed uneeded permission tags in plugin.xml +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.geolocation to org.apache.cordova.geolocation + +### 0.3.0 (Sept 5, 2013) +* Added support for windows 8 (Adds required permission) diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md old mode 100755 new mode 100644 index 9cf693e5..17e14a53 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md @@ -218,7 +218,7 @@ Enthält `Position` koordinaten und Timestamp, erstellt von der Geolocation API. * **coords**: eine Reihe von geographischen Koordinaten. *(Coordinates)* - * **timestamp**: Zeitstempel der Erstellung für `coords` . *(Date)* + * **timestamp**: Zeitstempel der Erstellung für `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md old mode 100755 new mode 100644 index 3fe4e4a8..92b2079b --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md @@ -205,7 +205,7 @@ Enthält `Position` koordinaten und Timestamp, erstellt von der Geolocation API. * **coords**: eine Reihe von geographischen Koordinaten. *(Coordinates)* -* **timestamp**: Zeitstempel der Erstellung für `coords` . *(Date)* +* **timestamp**: Zeitstempel der Erstellung für `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md old mode 100755 new mode 100644 index 1a4bf006..7808a0e3 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md @@ -216,7 +216,7 @@ Contiene `Position` coordenadas y timestamp, creado por la API de geolocalizaci * **coordenadas**: un conjunto de coordenadas geográficas. *(Coordenadas)* - * **timestamp**: fecha y hora de creación `coords` . *(Fecha)* + * **timestamp**: fecha y hora de creación `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md old mode 100755 new mode 100644 index 043e9294..041f3f82 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md @@ -164,7 +164,7 @@ Contiene `Position` coordenadas y timestamp, creado por la API de geolocalizaci * **coordenadas**: un conjunto de coordenadas geográficas. *(Coordenadas)* -* **timestamp**: fecha y hora de creación `coords` . *(Fecha)* +* **timestamp**: fecha y hora de creación `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md old mode 100755 new mode 100644 index f9865dc6..775a487f --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md @@ -177,7 +177,7 @@ Contient `Position` coordonnées et timestamp, créé par l'API de géolocalisat * **coords** : un ensemble de coordonnées géographiques. *(Coordinates)* - * **timestamp** : horodatage de la création de `coords`. *(Date)* + * **timestamp** : horodatage de la création de `coords`. *(DOMTimeStamp)* ## Coordonnées diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md old mode 100755 new mode 100644 index bea18ddc..4d486375 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md @@ -164,7 +164,7 @@ Contient `Position` coordonnées et timestamp, créé par l'API de géolocalisat * **coords** : un ensemble de coordonnées géographiques. *(Coordinates)* -* **timestamp** : horodatage de la création de `coords`. *(Date)* +* **timestamp** : horodatage de la création de `coords`. *(DOMTimeStamp)* ## Coordonnées diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md old mode 100755 new mode 100644 index 8eb44be9..ffa472b3 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md @@ -218,7 +218,7 @@ Contiene le coordinate della `Position` e timestamp, creato da geolocation API. * **CoOrds**: un insieme di coordinate geografiche. *(Coordinate)* - * **timestamp**: timestamp di creazione per `coords` . *(Data)* + * **timestamp**: timestamp di creazione per `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md old mode 100755 new mode 100644 index 41412a07..7ba7c5c6 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md @@ -205,7 +205,7 @@ Contiene le coordinate della `Position` e timestamp, creato da geolocation API. * **CoOrds**: un insieme di coordinate geografiche. *(Coordinate)* -* **timestamp**: timestamp di creazione per `coords` . *(Data)* +* **timestamp**: timestamp di creazione per `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md old mode 100755 new mode 100644 index a519d2c2..59c5ed6c --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md @@ -218,7 +218,7 @@ * **coords**: 地ç†çš„座標ã®ã‚»ãƒƒãƒˆã€‚*(座標)* - * **timestamp**: 作æˆã®ã‚¿ã‚¤ãƒ ã‚¹ã‚¿ãƒ³ãƒ—ã‚’ `coords` 。*(日)* + * **timestamp**: 作æˆã®ã‚¿ã‚¤ãƒ ã‚¹ã‚¿ãƒ³ãƒ—ã‚’ `coords` 。*(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md old mode 100755 new mode 100644 index 1c032293..dab50057 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md @@ -218,7 +218,7 @@ * **coords**: ì§€ë¦¬ì  ì¢Œí‘œ ì§‘í•©. *(좌표)* - * **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(ë‚ ì§œ)* + * **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md old mode 100755 new mode 100644 index 2a3e7349..19f47c72 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md @@ -205,7 +205,7 @@ * **coords**: ì§€ë¦¬ì  ì¢Œí‘œ ì§‘í•©. *(좌표)* -* **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(ë‚ ì§œ)* +* **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md old mode 100755 new mode 100644 index 8d6717fd..0ef35c4e --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md @@ -218,7 +218,7 @@ Zawiera współrzÄ™dne `Position` i sygnatury czasowej, stworzony przez geolocat * **coords**: zestaw współrzÄ™dnych geograficznych. *(WspółrzÄ™dne)* - * **timestamp**: Sygnatura czasowa utworzenia dla `coords` . *(Data)* + * **timestamp**: Sygnatura czasowa utworzenia dla `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ru/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md old mode 100755 new mode 100644 index 1ad9931e..b2afea51 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md @@ -218,7 +218,7 @@ Android 2.x 模擬器ä¸é™¤éž `enableHighAccuracy` é¸é …設置為 `true`ï¼Œå¦ * **coords**: 一組的地ç†åº§æ¨™ã€‚*(座標)* - * **timestamp**: 創建時間戳記為 `coords` 。*(日期)* + * **timestamp**: 創建時間戳記為 `coords` 。*(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md old mode 100755 new mode 100644 index d6d831e7..c78a9f79 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md @@ -205,7 +205,7 @@ Android 2.x 模擬器ä¸é™¤éž `enableHighAccuracy` é¸é …設置為 `true`ï¼Œå¦ * **coords**: 一組的地ç†åº§æ¨™ã€‚*(座標)* -* **timestamp**: 創建時間戳記為 `coords` 。*(日期)* +* **timestamp**: 創建時間戳記為 `coords` 。*(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/package.json b/StoneIsland/plugins/cordova-plugin-geolocation/package.json old mode 100755 new mode 100644 index dee3543b..a043d278 --- a/StoneIsland/plugins/cordova-plugin-geolocation/package.json +++ b/StoneIsland/plugins/cordova-plugin-geolocation/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-geolocation", - "version": "1.0.1", + "version": "2.4.0", "description": "Cordova Geolocation Plugin", "cordova": { "id": "cordova-plugin-geolocation", @@ -36,6 +36,20 @@ "cordova-windows", "cordova-firefoxos" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "engines": { + "cordovaDependencies": { + "3.0.0": { + "cordova": ">100" + } + } + }, + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml b/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml old mode 100755 new mode 100644 index 4c0a41d1..48abcafc --- a/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geolocation" - version="1.0.1"> + version="2.4.0"> Geolocation Cordova Geolocation Plugin @@ -31,14 +31,34 @@ xmlns:android="http://schemas.android.com/apk/res/android" https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git https://issues.apache.org/jira/browse/CB/component/12320638 + + + + + + + + + + + + + + + + + + + + @@ -48,9 +68,9 @@ xmlns:android="http://schemas.android.com/apk/res/android" - + - + @@ -71,18 +91,18 @@ xmlns:android="http://schemas.android.com/apk/res/android" - - - + + + - + - + @@ -218,7 +238,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" - + diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/android/Geolocation.java b/StoneIsland/plugins/cordova-plugin-geolocation/src/android/Geolocation.java new file mode 100644 index 00000000..6452170a --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/android/Geolocation.java @@ -0,0 +1,107 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + + +package org.apache.cordova.geolocation; + +import android.content.pm.PackageManager; +import android.Manifest; +import android.os.Build; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaArgs; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PermissionHelper; +import org.apache.cordova.PluginResult; +import org.apache.cordova.LOG; +import org.json.JSONArray; +import org.json.JSONException; + +import javax.security.auth.callback.Callback; + +public class Geolocation extends CordovaPlugin { + + String TAG = "GeolocationPlugin"; + CallbackContext context; + + String [] permissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }; + + + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + LOG.d(TAG, "We are entering execute"); + context = callbackContext; + if(action.equals("getPermission")) + { + if(hasPermisssion()) + { + PluginResult r = new PluginResult(PluginResult.Status.OK); + context.sendPluginResult(r); + return true; + } + else { + PermissionHelper.requestPermissions(this, 0, permissions); + } + return true; + } + return false; + } + + + public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException + { + PluginResult result; + //This is important if we're using Cordova without using Cordova, but we have the geolocation plugin installed + if(context != null) { + for (int r : grantResults) { + if (r == PackageManager.PERMISSION_DENIED) { + LOG.d(TAG, "Permission Denied!"); + result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION); + context.sendPluginResult(result); + return; + } + + } + result = new PluginResult(PluginResult.Status.OK); + context.sendPluginResult(result); + } + } + + public boolean hasPermisssion() { + for(String p : permissions) + { + if(!PermissionHelper.hasPermission(this, p)) + { + return false; + } + } + return true; + } + + /* + * We override this so that we can access the permissions variable, which no longer exists in + * the parent class, since we can't initialize it reliably in the constructor! + */ + + public void requestPermissions(int requestCode) + { + PermissionHelper.requestPermissions(this, requestCode, permissions); + } + + + +} diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/firefoxos/GeolocationProxy.js b/StoneIsland/plugins/cordova-plugin-geolocation/src/firefoxos/GeolocationProxy.js old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.h b/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m b/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m old mode 100755 new mode 100644 index 8b543c8e..e4b34a11 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m @@ -122,17 +122,17 @@ NSUInteger code = [CLLocationManager authorizationStatus]; if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)] || [self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) { //iOS8+ __highAccuracyEnabled = enableHighAccuracy; - if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]){ - [self.locationManager requestAlwaysAuthorization]; - } else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) { - [self.locationManager requestWhenInUseAuthorization]; + if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]){ + [self.locationManager requestWhenInUseAuthorization]; + } else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]) { + [self.locationManager requestAlwaysAuthorization]; } else { NSLog(@"[Warning] No NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key is defined in the Info.plist file."); } return; } #endif - + // Tell the location manager to start notifying us of location updates. We // first stop, and then start the updating to ensure we get at least one // update, even if our location did not change. @@ -148,9 +148,8 @@ self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; } else { __highAccuracyEnabled = NO; - // TODO: Set distance filter to 10 meters? and desired accuracy to nearest ten meters? arbitrary. self.locationManager.distanceFilter = 10; - self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; + self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers; } } @@ -193,35 +192,37 @@ - (void)getLocation:(CDVInvokedUrlCommand*)command { - NSString* callbackId = command.callbackId; - BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue]; - - if ([self isLocationServicesEnabled] == NO) { - NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2]; - [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"]; - [posError setObject:@"Location services are disabled." forKey:@"message"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } else { - if (!self.locationData) { - self.locationData = [[CDVLocationData alloc] init]; - } - CDVLocationData* lData = self.locationData; - if (!lData.locationCallbacks) { - lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1]; - } + [self.commandDelegate runInBackground:^{ + NSString* callbackId = command.callbackId; + BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue]; + + if ([self isLocationServicesEnabled] == NO) { + NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2]; + [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"]; + [posError setObject:@"Location services are disabled." forKey:@"message"]; + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + } else { + if (!self.locationData) { + self.locationData = [[CDVLocationData alloc] init]; + } + CDVLocationData* lData = self.locationData; + if (!lData.locationCallbacks) { + lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1]; + } - if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) { - // add the callbackId into the array so we can call back when get data - if (callbackId != nil) { - [lData.locationCallbacks addObject:callbackId]; + if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) { + // add the callbackId into the array so we can call back when get data + if (callbackId != nil) { + [lData.locationCallbacks addObject:callbackId]; + } + // Tell the location manager to start notifying us of heading updates + [self startLocation:enableHighAccuracy]; + } else { + [self returnLocationInfo:callbackId andKeepCallback:NO]; } - // Tell the location manager to start notifying us of heading updates - [self startLocation:enableHighAccuracy]; - } else { - [self returnLocationInfo:callbackId andKeepCallback:NO]; } - } + }]; } - (void)addWatch:(CDVInvokedUrlCommand*)command diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp b/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp old mode 100755 new mode 100644 index c820cfef..3d40ab4c --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp @@ -1,6 +1,6 @@ /* * - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2016 Canonical Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,19 @@ #include "geolocation.h" -Geolocation::Geolocation(Cordova *cordova): CPlugin(cordova), - _geoPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)) { +Geolocation::Geolocation(Cordova *cordova) + : CPlugin(cordova), + _geoPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)) { if (_geoPositionInfoSource.data() != 0) { - QObject::connect(_geoPositionInfoSource.data(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); - QObject::connect(_geoPositionInfoSource.data(), SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); + QObject::connect(_geoPositionInfoSource.data(), + SIGNAL(positionUpdated(QGeoPositionInfo)), + this, + SLOT(positionUpdated(QGeoPositionInfo))); + + QObject::connect(_geoPositionInfoSource.data(), + SIGNAL(updateTimeout()), + this, + SLOT(updateTimeout())); } } @@ -81,16 +89,22 @@ void Geolocation::positionUpdated(const QGeoPositionInfo &update) { p.insert("latitude", coordinate.latitude()); p.insert("longitude", coordinate.longitude()); - p.insert("altitude", coordinate.altitude()); - if (update.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) - p.insert("accuracy", update.attribute(QGeoPositionInfo::VerticalAccuracy)); + if (coordinate.type() == QGeoCoordinate::Coordinate3D) + p.insert("altitude", coordinate.altitude()); + + if (update.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) + p.insert("accuracy", update.attribute(QGeoPositionInfo::HorizontalAccuracy)); + if (update.hasAttribute(QGeoPositionInfo::Direction)) p.insert("heading", update.attribute(QGeoPositionInfo::Direction)); + if (update.hasAttribute(QGeoPositionInfo::GroundSpeed)) p.insert("velocity", update.attribute(QGeoPositionInfo::GroundSpeed)); - if (update.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) - p.insert("altitudeAccuracy", update.attribute(QGeoPositionInfo::HorizontalAccuracy)); + + if (update.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) + p.insert("altitudeAccuracy", update.attribute(QGeoPositionInfo::VerticalAccuracy)); + p.insert("timestamp", update.timestamp().toMSecsSinceEpoch()); for (const QString &id: _id2sc.keys()) { diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.h b/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js b/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js old mode 100755 new mode 100644 index 9cab6a4d..03ed4950 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js @@ -14,27 +14,48 @@ * limitations under the License. */ -var PositionError = require('./PositionError'), - ids = {}, - loc; +/* global Windows, WinJS */ -function ensureLocator() { - if (loc == null) - loc = new Windows.Devices.Geolocation.Geolocator(); +var PositionError = require('./PositionError'); +var callbacks = {}; +var locs = {}; - return loc; +// constants +var FALLBACK_EPSILON = 0.001; + +function ensureAndCreateLocator() { + var deferral; + + var loc = new Windows.Devices.Geolocation.Geolocator(); + + if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') { + deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) { + if (result === Windows.Devices.Geolocation.GeolocationAccessStatus.allowed) { + return loc; + } + + return WinJS.Promise.wrapError({ + code: PositionError.PERMISSION_DENIED, + message: 'Geolocation access has not been allowed by user.' + }); + }); + } else { + deferral = WinJS.Promise.wrap(loc); + } + + return deferral; } -function createErrorCode() { +function createErrorCode(loc) { switch (loc.locationStatus) { case Windows.Devices.Geolocation.PositionStatus.initializing: // This status indicates that a location device is still initializing case Windows.Devices.Geolocation.PositionStatus.noData: - // No location data is currently available + // No location data is currently available case Windows.Devices.Geolocation.PositionStatus.notInitialized: // This status indicates that the app has not yet requested - // location data by calling GetGeolocationAsync() or - // registering an event handler for the positionChanged event. + // location data by calling GetGeolocationAsync() or + // registering an event handler for the positionChanged event. case Windows.Devices.Geolocation.PositionStatus.notAvailable: // Location is not available on this version of Windows return PositionError.POSITION_UNAVAILABLE; @@ -55,8 +76,8 @@ function createResult(pos) { velocity: pos.coordinate.speed, altitudeAccuracy: pos.coordinate.altitudeAccuracy, timestamp: pos.coordinate.timestamp - } - + }; + if (pos.coordinate.point) { res.latitude = pos.coordinate.point.position.latitude; res.longitude = pos.coordinate.point.position.longitude; @@ -66,55 +87,54 @@ function createResult(pos) { res.longitude = pos.coordinate.longitude; res.altitude = pos.coordinate.altitude; } - + return res; } module.exports = { getLocation: function (success, fail, args, env) { - ensureLocator(); - if (loc != null) - { - var highAccuracy = args[0], - maxAge = args[1]; - - loc.desiredAccuracy = highAccuracy ? - Windows.Devices.Geolocation.PositionAccuracy.high : - Windows.Devices.Geolocation.PositionAccuracy.default; - - loc.reportInterval = maxAge ? maxAge : 0; - - loc.getGeopositionAsync().then( - function (pos) { - success(createResult(pos)); - }, - function (err) { - fail({ - code: createErrorCode(), - message: err.message - }); - } - ); - } - else - { - fail({ - code: PositionError.POSITION_UNAVAILABLE, - message: "You do not have the required location services present on your system." - }); - } + ensureAndCreateLocator().done(function (loc) { + if (loc) { + var highAccuracy = args[0], + maxAge = args[1]; + + loc.desiredAccuracy = highAccuracy ? + Windows.Devices.Geolocation.PositionAccuracy.high : + Windows.Devices.Geolocation.PositionAccuracy.default; + + loc.reportInterval = maxAge ? maxAge : 0; + + loc.getGeopositionAsync().then( + function (pos) { + success(createResult(pos)); + }, + function (err) { + fail({ + code: createErrorCode(loc), + message: err.message + }); + } + ); + } + else { + fail({ + code: PositionError.POSITION_UNAVAILABLE, + message: "You do not have the required location services present on your system." + }); + } + }, fail); }, addWatch: function (success, fail, args, env) { - ensureLocator(); - var clientId = args[0], - highAccuracy = args[1], + ensureAndCreateLocator().done(function (loc) { + var clientId = args[0]; + var highAccuracy = args[1]; - onPositionChanged = function (e) { - success(createResult(e.position), {keepCallback: true}); - }, + var onPositionChanged = function (e) { + success(createResult(e.position), { keepCallback: true }); + }; - onStatusChanged = function (e) { + var onStatusChanged = function (e) { switch (e.status) { case Windows.Devices.Geolocation.PositionStatus.noData: case Windows.Devices.Geolocation.PositionStatus.notAvailable: @@ -131,44 +151,52 @@ module.exports = { }); break; - case Windows.Devices.Geolocation.PositionStatus.initializing: - case Windows.Devices.Geolocation.PositionStatus.ready: + // case Windows.Devices.Geolocation.PositionStatus.initializing: + // case Windows.Devices.Geolocation.PositionStatus.ready: default: break; } }; - loc.desiredAccuracy = highAccuracy ? - Windows.Devices.Geolocation.PositionAccuracy.high : - Windows.Devices.Geolocation.PositionAccuracy.default; - - if (cordova.platformId == 'windows' && WinJS.Utilities.isPhone) { - // on Windows Phone 8.1 'positionchanged' event fails with error below if movementThreshold is not set - // JavaScript runtime error: Operation aborted - // You must set the MovementThreshold property or the ReportInterval property before adding event handlers. - // WinRT information: You must set the MovementThreshold property or the ReportInterval property before adding event handlers - loc.movementThreshold = loc.movementThreshold || 1; // 1 meter - } + loc.desiredAccuracy = highAccuracy ? + Windows.Devices.Geolocation.PositionAccuracy.high : + Windows.Devices.Geolocation.PositionAccuracy.default; + + if (cordova.platformId == 'windows') { + // 'positionchanged' event fails with error below if movementThreshold is not set + // JavaScript runtime error: Operation aborted + // You must set the MovementThreshold property or the ReportInterval property before adding event handlers. + // WinRT information: You must set the MovementThreshold property or the ReportInterval property before adding event handlers + if (Number.EPSILON) { + loc.movementThreshold = Number.EPSILON; + } else { + loc.movementThreshold = FALLBACK_EPSILON; + } + } - loc.addEventListener("positionchanged", onPositionChanged); - loc.addEventListener("statuschanged", onStatusChanged); + loc.addEventListener("positionchanged", onPositionChanged); + loc.addEventListener("statuschanged", onStatusChanged); - ids[clientId] = { pos: onPositionChanged, status: onStatusChanged }; + callbacks[clientId] = { pos: onPositionChanged, status: onStatusChanged }; + locs[clientId] = loc; + }, fail); }, clearWatch: function (success, fail, args, env) { - var clientId = args[0], - callbacks = ids[clientId]; + var clientId = args[0]; + var callback = callbacks[clientId]; + var loc = locs[clientId]; - if (callbacks) { - loc.removeEventListener("positionchanged", callbacks.pos); - loc.removeEventListener("statuschanged", callbacks.status); + if (callback && loc) { + loc.removeEventListener("positionchanged", callback.pos); + loc.removeEventListener("statuschanged", callback.status); - delete ids[clientId]; + delete callbacks[clientId]; + delete locs[clientId]; } - success && success(); + success(); } }; -require("cordova/exec/proxy").add("Geolocation", module.exports); \ No newline at end of file +require("cordova/exec/proxy").add("Geolocation", module.exports); diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/wp/GeoLocation.cs b/StoneIsland/plugins/cordova-plugin-geolocation/src/wp/GeoLocation.cs old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml old mode 100755 new mode 100644 index edeb62e1..cf0f2f6d --- a/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml @@ -22,10 +22,11 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geolocation-tests" - version="1.0.1"> + version="2.4.0"> Cordova Geolocation Plugin Tests Apache 2.0 +
diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js b/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js old mode 100755 new mode 100644 index e07caf88..50c5bfb2 --- a/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js @@ -18,43 +18,59 @@ * under the License. * */ + +/* jshint jasmine: true */ +/* global WinJS, device */ + exports.defineAutoTests = function () { var fail = function (done, context, message) { - // prevents done() to be called several times - if (context) { - if (context.done) return; - context.done = true; - } - - if (message) { - expect(false).toBe(true, message); - } else { - expect(false).toBe(true); - } - - // watchPosition could call its callback sync (before returning the value) - // so we invoke done async to make sure we know watcher id to .clear in afterEach - setTimeout(function () { - done(); - }); - }, - succeed = function (done, context) { - // prevents done() to be called several times - if (context) { - if (context.done) return; - context.done = true; - } - - expect(true).toBe(true); - - // watchPosition could call its callback sync (before returning the value) - // so we invoke done async to make sure we know watcher id to .clear in afterEach - setTimeout(function () { - done(); - }); - }, - isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone), - isAndroid = cordova.platformId == "android"; + // prevents done() to be called several times + if (context) { + if (context.done) return; + context.done = true; + } + + if (message) { + expect(false).toBe(true, message); + } else { + expect(false).toBe(true); + } + + // watchPosition could call its callback sync (before returning the value) + // so we invoke done async to make sure we know watcher id to .clear in afterEach + setTimeout(function () { + done(); + }); + }; + + var succeed = function (done, context) { + // prevents done() to be called several times + if (context) { + if (context.done) return; + context.done = true; + } + + expect(true).toBe(true); + + // watchPosition could call its callback sync (before returning the value) + // so we invoke done async to make sure we know watcher id to .clear in afterEach + setTimeout(function () { + done(); + }); + }; + + // On Windows, some tests prompt user for permission to use geolocation and interrupt autotests run + var isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone); + var majorDeviceVersion = null; + var versionRegex = /(\d)\..+/.exec(device.version); + if (versionRegex !== null) { + majorDeviceVersion = Number(versionRegex[1]); + } + // Starting from Android 6.0 there are confirmation dialog which prevents us from running auto tests in silent mode (user interaction needed) + // Also, Android emulator doesn't provide geo fix without manual interactions or mocks + var skipAndroid = cordova.platformId == "android" && (device.isVirtual || majorDeviceVersion >= 6); + var isIOSSim = false; // if iOS simulator does not have a location set, it will fail. + describe('Geolocation (navigator.geolocation)', function () { @@ -84,10 +100,7 @@ exports.defineAutoTests = function () { describe('error callback', function () { it("geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid) { pending(); } @@ -100,15 +113,32 @@ exports.defineAutoTests = function () { }); }); + it("geolocation.spec.9 on failure should return PositionError object with error code constants", function (done) { + if (isWindowsStore || skipAndroid) { + pending(); + } + + navigator.geolocation.getCurrentPosition( + fail.bind(this, done), + function(gpsError) { + // W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface + expect(gpsError.PERMISSION_DENIED).toBe(1); + expect(gpsError.POSITION_UNAVAILABLE).toBe(2); + expect(gpsError.TIMEOUT).toBe(3); + done(); + }, + { + maximumAge: 0, + timeout: 0 + }); + }); + }); describe('success callback', function () { it("geolocation.spec.6 should be called with a Position object", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid) { pending(); } @@ -116,8 +146,17 @@ exports.defineAutoTests = function () { expect(p.coords).toBeDefined(); expect(p.timestamp).toBeDefined(); done(); + }, function(err){ + if(err.message && err.message.indexOf('kCLErrorDomain') > -1){ + console.log("Error: Location not set in simulator, tests will fail."); + expect(true).toBe(true); + isIOSSim = true; + done(); + } + else { + fail(done); + } }, - fail.bind(null, done), { maximumAge: (5 * 60 * 1000) // 5 minutes maximum age of cached position }); @@ -144,10 +183,7 @@ exports.defineAutoTests = function () { }); it("geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid) { pending(); } @@ -161,6 +197,31 @@ exports.defineAutoTests = function () { }); }); + it("geolocation.spec.10 on failure should return PositionError object with error code constants", function (done) { + if (isWindowsStore || skipAndroid) { + pending(); + } + + var context = this; + errorWatch = navigator.geolocation.watchPosition( + fail.bind(this, done, context, 'Unexpected win'), + function(gpsError) { + if (context.done) return; + context.done = true; + + // W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface + expect(gpsError.PERMISSION_DENIED).toBe(1); + expect(gpsError.POSITION_UNAVAILABLE).toBe(2); + expect(gpsError.TIMEOUT).toBe(3); + + done(); + }, + { + maximumAge: 0, + timeout: 0 + }); + }); + }); describe('success callback', function () { @@ -171,10 +232,7 @@ exports.defineAutoTests = function () { }); it("geolocation.spec.8 should be called with a Position object", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid || isIOSSim) { pending(); } @@ -196,6 +254,7 @@ exports.defineAutoTests = function () { { maximumAge: (5 * 60 * 1000) // 5 minutes maximum age of cached position }); + expect(successWatch).toBeDefined(); }); }); @@ -209,23 +268,49 @@ exports.defineAutoTests = function () { /******************************************************************************/ exports.defineManualTests = function (contentEl, createActionButton) { - var newGeolocation = navigator.geolocation; - var origGeolocation = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); - if (!origGeolocation) { - origGeolocation = newGeolocation; - newGeolocation = null; + var watchLocationId = null; + + /** + * Set location status + */ + function setLocationStatus(status) { + document.getElementById('location_status').innerHTML = status; + } + function setLocationDetails(p) { + var date = (new Date(p.timestamp)); + document.getElementById('latitude').innerHTML = p.coords.latitude; + document.getElementById('longitude').innerHTML = p.coords.longitude; + document.getElementById('altitude').innerHTML = p.coords.altitude; + document.getElementById('accuracy').innerHTML = p.coords.accuracy; + document.getElementById('heading').innerHTML = p.coords.heading; + document.getElementById('speed').innerHTML = p.coords.speed; + document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy; + document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString(); } - var watchLocationId = null; + /** + * Stop watching the location + */ + function stopLocation() { + var geo = navigator.geolocation; + if (!geo) { + alert('navigator.geolocation object is missing.'); + return; + } + setLocationStatus("Stopped"); + if (watchLocationId) { + geo.clearWatch(watchLocationId); + watchLocationId = null; + } + } /** * Start watching location */ - var watchLocation = function (usePlugin) { - console.log("watchLocation()"); - var geo = usePlugin ? newGeolocation : origGeolocation; + var watchLocation = function () { + var geo = navigator.geolocation; if (!geo) { - alert('geolocation object is missing. usePlugin = ' + usePlugin); + alert('navigator.geolocation object is missing.'); return; } @@ -245,31 +330,13 @@ exports.defineManualTests = function (contentEl, createActionButton) { setLocationStatus("Running"); }; - /** - * Stop watching the location - */ - var stopLocation = function (usePlugin) { - console.log("stopLocation()"); - var geo = usePlugin ? newGeolocation : origGeolocation; - if (!geo) { - alert('geolocation object is missing. usePlugin = ' + usePlugin); - return; - } - setLocationStatus("Stopped"); - if (watchLocationId) { - geo.clearWatch(watchLocationId); - watchLocationId = null; - } - }; - /** * Get current location */ - var getLocation = function (usePlugin, opts) { - console.log("getLocation()"); - var geo = usePlugin ? newGeolocation : origGeolocation; + var getLocation = function (opts) { + var geo = navigator.geolocation; if (!geo) { - alert('geolocation object is missing. usePlugin = ' + usePlugin); + alert('navigator.geolocation object is missing.'); return; } @@ -295,24 +362,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { }; - /** - * Set location status - */ - var setLocationStatus = function (status) { - document.getElementById('location_status').innerHTML = status; - }; - var setLocationDetails = function (p) { - var date = (new Date(p.timestamp)); - document.getElementById('latitude').innerHTML = p.coords.latitude; - document.getElementById('longitude').innerHTML = p.coords.longitude; - document.getElementById('altitude').innerHTML = p.coords.altitude; - document.getElementById('accuracy').innerHTML = p.coords.accuracy; - document.getElementById('heading').innerHTML = p.coords.heading; - document.getElementById('speed').innerHTML = p.coords.speed; - document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy; - document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString(); - } - /******************************************************************************/ var location_div = '
' + @@ -365,16 +414,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { '' + '
', actions = - '

Use Built-in WebView navigator.geolocation

' + - '
' + - 'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' + - '

' + - 'Expected result: Will update all applicable values in status box for current location and update as location changes. Status will read Running.' + - '

' + - 'Expected result: Will stop watching the location so values will not be updated. Status will read Stopped.' + - '

' + - 'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.' + - '

Use Cordova Geolocation Plugin

' + '
' + 'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' + '

' + @@ -388,38 +427,22 @@ exports.defineManualTests = function (contentEl, createActionButton) { note = '

Allow use of current location, if prompted

'; - contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed - + altitude_accuracy + time + note + actions; - - createActionButton('Get Location', function () { - getLocation(false); - }, 'built-in-getLocation'); - - createActionButton('Start Watching Location', function () { - watchLocation(false); - }, 'built-in-watchLocation'); - - createActionButton('Stop Watching Location', function () { - stopLocation(false); - }, 'built-in-stopLocation'); - - createActionButton('Get Location Up to 30 Sec Old', function () { - getLocation(false, { maximumAge: 30000 }); - }, 'built-in-getOld'); + contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed + + altitude_accuracy + time + note + actions; createActionButton('Get Location', function () { - getLocation(true); + getLocation(); }, 'cordova-getLocation'); createActionButton('Start Watching Location', function () { - watchLocation(true); + watchLocation(); }, 'cordova-watchLocation'); createActionButton('Stop Watching Location', function () { - stopLocation(true); + stopLocation(); }, 'cordova-stopLocation'); createActionButton('Get Location Up to 30 Sec Old', function () { - getLocation(true, { maximumAge: 30000 }); + getLocation({ maximumAge: 30000 }); }, 'cordova-getOld'); }; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/Coordinates.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/Coordinates.js old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js old mode 100755 new mode 100644 index f0470dea..d6b2c0cc --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js @@ -27,7 +27,7 @@ var Position = function(coords, timestamp) { } else { this.coords = new Coordinates(); } - this.timestamp = (timestamp !== undefined) ? timestamp : new Date(); + this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime(); }; module.exports = Position; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js old mode 100755 new mode 100644 index 9403f11f..94562407 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js @@ -31,8 +31,8 @@ var PositionError = function(code, message) { this.message = message || ''; }; -PositionError.PERMISSION_DENIED = 1; -PositionError.POSITION_UNAVAILABLE = 2; -PositionError.TIMEOUT = 3; +PositionError.prototype.PERMISSION_DENIED = PositionError.PERMISSION_DENIED = 1; +PositionError.prototype.POSITION_UNAVAILABLE = PositionError.POSITION_UNAVAILABLE = 2; +PositionError.prototype.TIMEOUT = PositionError.TIMEOUT = 3; module.exports = PositionError; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/android/geolocation.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/android/geolocation.js new file mode 100644 index 00000000..7265bec0 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/android/geolocation.js @@ -0,0 +1,71 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var exec = cordova.require('cordova/exec'); +var utils = require('cordova/utils'); +var PositionError = require('./PositionError'); + +// Native watchPosition method is called async after permissions prompt. +// So we use additional map and own ids to return watch id synchronously. +var pluginToNativeWatchMap = {}; + +module.exports = { + getCurrentPosition: function(success, error, args) { + var win = function() { + var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); + geo.getCurrentPosition(success, error, args); + }; + var fail = function() { + if (error) { + error(new PositionError (PositionError.PERMISSION_DENIED, 'Illegal Access')); + } + }; + exec(win, fail, "Geolocation", "getPermission", []); + }, + + watchPosition: function(success, error, args) { + var pluginWatchId = utils.createUUID(); + + var win = function() { + var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); + pluginToNativeWatchMap[pluginWatchId] = geo.watchPosition(success, error, args); + }; + + var fail = function() { + if (error) { + error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access')); + } + }; + exec(win, fail, "Geolocation", "getPermission", []); + + return pluginWatchId; + }, + + clearWatch: function(pluginWatchId) { + var win = function() { + var nativeWatchId = pluginToNativeWatchMap[pluginWatchId]; + var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); + geo.clearWatch(nativeWatchId); + }; + + exec(win, null, "Geolocation", "getPermission", []); + } +}; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/blackberry10/GeolocationProxy.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/blackberry10/GeolocationProxy.js old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js old mode 100755 new mode 100644 index 3814919a..f1f64456 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js @@ -102,7 +102,7 @@ var geolocation = { velocity:p.velocity, altitudeAccuracy:p.altitudeAccuracy }, - (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp))) + p.timestamp ); geolocation.lastPosition = pos; successCallback(pos); @@ -118,7 +118,7 @@ var geolocation = { // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just // fire the success callback with the cached position. - if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) { + if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp) <= options.maximumAge)) { successCallback(geolocation.lastPosition); // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object. } else if (options.timeout === 0) { @@ -184,7 +184,7 @@ var geolocation = { velocity:p.velocity, altitudeAccuracy:p.altitudeAccuracy }, - (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp))) + p.timestamp ); geolocation.lastPosition = pos; successCallback(pos); diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md old mode 100755 new mode 100644 index 4c8e6a5e..39378f26 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md @@ -26,7 +26,7 @@ Anyone can contribute to Cordova. And we need your contributions. There are multiple ways to contribute: report bugs, improve the docs, and contribute code. -For instructions on this, start with the +For instructions on this, start with the [contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: @@ -35,3 +35,30 @@ The details are explained there, but the important items are: - Run the tests so your patch doesn't break existing functionality. We look forward to your contributions! + +The notes on [Commit Workflow](https://github.com/apache/cordova-coho/blob/master/docs/committer-workflow.md#commit-workflow) can be helpful even if you are not a committer. + +## Running plugin tests + +* clone and install [cordova-plugin-test-framework](https://github.com/apache/cordova-plugin-test-framework) +``` +git clone git@github.com:apache/cordova-plugin-test-framework.git +``` +* edit ```cordova-plugin-test-framework/www/assets/index.html``` and add the following line +``` + +``` +* create test project +``` +cordova create plugintest +cd plugintest +cordova platform add android +cordova plugin add ../cordova-plugin-inappbrowser +cordova plugin add ../cordova-plugin-inappbrowser/tests +cordova plugin add ../cordova-plugin-test-framework +``` +* edit ```config.xml``` and replace `````` with `````` +* run application +``` +cordova run +``` diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/LICENSE b/StoneIsland/plugins/cordova-plugin-inappbrowser/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/NOTICE b/StoneIsland/plugins/cordova-plugin-inappbrowser/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md old mode 100755 new mode 100644 index f5c847d1..e7e96972 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md @@ -1,3 +1,7 @@ +--- +title: Inappbrowser +description: Open an in-app browser window. +--- +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-inappbrowser.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-inappbrowser)| + # cordova-plugin-inappbrowser +You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app. + +> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content. + This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`. var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); @@ -54,10 +66,10 @@ Although `window.open` is in the global scope, InAppBrowser is not available unt console.log("window.open works well"); } -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) - +Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) +## Reference ## Installation cordova plugin add cordova-plugin-inappbrowser @@ -77,7 +89,7 @@ instance, or the system browser. var ref = cordova.InAppBrowser.open(url, target, options); -- __ref__: Reference to the `InAppBrowser` window. _(InAppBrowser)_ +- __ref__: Reference to the `InAppBrowser` window when the target is set to `'_blank'`. _(InAppBrowser)_ - __url__: The URL to load _(String)_. Call `encodeURI()` on this if the URL contains Unicode characters. @@ -100,6 +112,8 @@ instance, or the system browser. - __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened - __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. - __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser. + - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). + - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). iOS only: @@ -110,7 +124,7 @@ instance, or the system browser. - __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened - __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) - __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). - - __mediaPlaybackRequiresUserAction__: Set to `yes` or `no` to prevent HTML5 audio or video from autoplaying (defaults to `no`). + - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). - __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`) - __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`). - __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`). @@ -122,6 +136,7 @@ instance, or the system browser. - __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. - __fullscreen__: set to `yes` to create the browser control without a border around it. Please note that if __location=no__ is also specified, there will be no control presented to user to close IAB window. + - __hardwareback__: works the same way as on Android platform. ### Supported Platforms @@ -172,6 +187,10 @@ opened with `target='_blank'`. The rules might look like these ### Windows Quirks +Windows 8.0, 8.1 and Windows Phone 8.1 don't support remote urls to be opened in the Cordova WebView so remote urls are always showed in the system's web browser if opened with `target='_self'`. + +On Windows 10 if the URL is NOT in the white list and is opened with `target='_self'` it will be showed in the system's web browser instead of InAppBrowser popup. + Similar to Firefox OS IAB window visual behaviour can be overridden via `inAppBrowserWrap`/`inAppBrowserWrapFullscreen` CSS classes ### Browser Quirks @@ -182,7 +201,7 @@ Similar to Firefox OS IAB window visual behaviour can be overridden via `inAppBr ## InAppBrowser -The object returned from a call to `cordova.InAppBrowser.open`. +The object returned from a call to `cordova.InAppBrowser.open` when the target is set to `'_blank'`. ### Methods @@ -193,7 +212,7 @@ The object returned from a call to `cordova.InAppBrowser.open`. - executeScript - insertCSS -## addEventListener +## InAppBrowser.addEventListener > Adds a listener for an event from the `InAppBrowser`. @@ -210,6 +229,76 @@ The object returned from a call to `cordova.InAppBrowser.open`. - __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter. +## Example + +```javascript + +var inAppBrowserRef; + +function showHelp(url) { + + var target = "_blank"; + + var options = "location=yes,hidden=yes"; + + inAppBrowserRef = cordova.InAppBrowser.open(url, target, options); + + inAppBrowserRef.addEventListener('loadstart', loadStartCallBack); + + inAppBrowserRef.addEventListener('loadstop', loadStopCallBack); + + inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack); + +} + +function loadStartCallBack() { + + $('#status-message').text("loading please wait ..."); + +} + +function loadStopCallBack() { + + if (inAppBrowserRef != undefined) { + + inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" }); + + $('#status-message').text(""); + + inAppBrowserRef.show(); + } + +} + +function loadErrorCallBack(params) { + + $('#status-message').text(""); + + var scriptErrorMesssage = + "alert('Sorry we cannot open that page. Message from the server is : " + + params.message + "');" + + inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack); + + inAppBrowserRef.close(); + + inAppBrowserRef = undefined; + +} + +function executeScriptCallBack(params) { + + if (params[0] == null) { + + $('#status-message').text( + "Sorry we couldn't open that page. Message from the server is : '" + + params.message + "'"); + } + +} + +``` + ### InAppBrowserEvent Properties - __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, or `exit`. _(String)_ @@ -239,7 +328,7 @@ The object returned from a call to `cordova.InAppBrowser.open`. var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); ref.addEventListener('loadstart', function(event) { alert(event.url); }); -## removeEventListener +## InAppBrowser.removeEventListener > Removes a listener for an event from the `InAppBrowser`. @@ -273,7 +362,7 @@ The function is passed an `InAppBrowserEvent` object. ref.addEventListener('loadstart', myCallback); ref.removeEventListener('loadstart', myCallback); -## close +## InAppBrowser.close > Closes the `InAppBrowser` window. @@ -296,7 +385,7 @@ The function is passed an `InAppBrowserEvent` object. var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); ref.close(); -## show +## InAppBrowser.show > Displays an InAppBrowser window that was opened hidden. Calling this has no effect if the InAppBrowser was already visible. @@ -318,7 +407,7 @@ The function is passed an `InAppBrowserEvent` object. // some time later... ref.show(); -## executeScript +## InAppBrowser.executeScript > Injects JavaScript code into the `InAppBrowser` window @@ -360,7 +449,7 @@ The function is passed an `InAppBrowserEvent` object. Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.webview.invokescriptasync.aspx) the invoked script can return only string values, otherwise the parameter, passed to __callback__ will be `[null]`. -## insertCSS +## InAppBrowser.insertCSS > Injects CSS into the `InAppBrowser` window. @@ -387,3 +476,204 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont ref.addEventListener('loadstop', function() { ref.insertCSS({file: "mystyles.css"}); }); +__ + +## Sample: Show help pages with an InAppBrowser + +You can use this plugin to show helpful documentation pages within your app. Users can view online help documents and then close them without leaving the app. + +Here's a few snippets that show how you do this. + +* [Give users a way to ask for help](#give). +* [Load a help page](#load). +* [Let users know that you're getting their page ready](#let). +* [Show the help page](#show). +* [Handle page errors](#handle). + +### Give users a way to ask for help + +There's lots of ways to do this in your app. A drop down list is a simple way to do that. + +```html + + + +``` + +Gather the users choice in the ``onDeviceReady`` function of the page and then send an appropriate URL to a helper function in some shared library file. Our helper function is named ``showHelp()`` and we'll write that function next. + +```javascript + +$('#help-select').on('change', function (e) { + + var url; + + switch (this.value) { + + case "article": + url = "https://cordova.apache.org/docs/en/latest/" + + "reference/cordova-plugin-inappbrowser/index.html"; + break; + + case "video": + url = "https://youtu.be/F-GlVrTaeH0"; + break; + + case "search": + url = "https://www.google.com/#q=inAppBrowser+plugin"; + break; + } + + showHelp(url); + +}); + +``` + +### Load a help page + +We'll use the ``open`` function to load the help page. We're setting the ``hidden`` property to ``yes`` so that we can show the browser only after the page content has loaded. That way, users don't see a blank browser while they wait for content to appear. When the ``loadstop`` event is raised, we'll know when the content has loaded. We'll handle that event shortly. + +```javascript + +function showHelp(url) { + + var target = "_blank"; + + var options = "location=yes,hidden=yes"; + + inAppBrowserRef = cordova.InAppBrowser.open(url, target, options); + + inAppBrowserRef.addEventListener('loadstart', loadStartCallBack); + + inAppBrowserRef.addEventListener('loadstop', loadStopCallBack); + + inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack); + +} + +``` + +### Let users know that you're getting their page ready + +Because the browser doesn't immediately appear, we can use the ``loadstart`` event to show a status message, progress bar, or other indicator. This assures users that content is on the way. + +```javascript + +function loadStartCallBack() { + + $('#status-message').text("loading please wait ..."); + +} + +``` + +### Show the help page + +When the ``loadstopcallback`` event is raised, we know that the content has loaded and we can make the browser visible. This sort of trick can create the impression of better performance. The truth is that whether you show the browser before content loads or not, the load times are exactly the same. + +```javascript + +function loadStopCallBack() { + + if (inAppBrowserRef != undefined) { + + inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" }); + + $('#status-message').text(""); + + inAppBrowserRef.show(); + } + +} + +``` +You might have noticed the call to the ``insertCSS`` function. This serves no particular purpose in our scenario. But it gives you an idea of why you might use it. In this case, we're just making sure that the font size of your pages have a certain size. You can use this function to insert any CSS style elements. You can even point to a CSS file in your project. + +### Handle page errors + +Sometimes a page no longer exists, a script error occurs, or a user lacks permission to view the resource. How or if you handle that situation is completely up to you and your design. You can let the browser show that message or you can present it in another way. + +We'll try to show that error in a message box. We can do that by injecting a script that calls the ``alert`` function. That said, this won't work in browsers on Windows devices so we'll have to look at the parameter of the ``executeScript`` callback function to see if our attempt worked. If it didn't work out for us, we'll just show the error message in a ``
`` on the page. + +```javascript + +function loadErrorCallBack(params) { + + $('#status-message').text(""); + + var scriptErrorMesssage = + "alert('Sorry we cannot open that page. Message from the server is : " + + params.message + "');" + + inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack); + + inAppBrowserRef.close(); + + inAppBrowserRef = undefined; + +} + +function executeScriptCallBack(params) { + + if (params[0] == null) { + + $('#status-message').text( + "Sorry we couldn't open that page. Message from the server is : '" + + params.message + "'"); + } + +} + +``` + +## More Usage Info + +### Local Urls ( source is in the app package ) +``` +var iab = cordova.InAppBrowser; + +iab.open('local-url.html'); // loads in the Cordova WebView +iab.open('local-url.html', '_self'); // loads in the Cordova WebView +iab.open('local-url.html', '_system'); // Security error: system browser, but url will not load (iOS) +iab.open('local-url.html', '_blank'); // loads in the InAppBrowser +iab.open('local-url.html', 'random_string'); // loads in the InAppBrowser +iab.open('local-url.html', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar + +``` + + + +### Whitelisted Content + +``` +var iab = cordova.InAppBrowser; + +iab.open('http://whitelisted-url.com'); // loads in the Cordova WebView +iab.open('http://whitelisted-url.com', '_self'); // loads in the Cordova WebView +iab.open('http://whitelisted-url.com', '_system'); // loads in the system browser +iab.open('http://whitelisted-url.com', '_blank'); // loads in the InAppBrowser +iab.open('http://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser + +iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar + +``` + +### Urls that are not white-listed + +``` +var iab = cordova.InAppBrowser; + +iab.open('http://url-that-fails-whitelist.com'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', '_system'); // loads in the system browser +iab.open('http://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar + +``` \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md old mode 100755 new mode 100644 index 1e2005d8..5d8f3e71 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md @@ -20,6 +20,72 @@ --> # Release Notes +### 1.5.0 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* Add intent scheme to be handled by OS +* Plugin uses `Android Log class` and not `Cordova LOG class` +* Adding links to guide content and reference content at the top of the readme file Github: close #163 +* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) **Browser**: wrong height of webview with `location=yes` +* Size and position in browser platform +* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) **Windows**: wrong height of webview with `location=yes` +* [CB-11013](https://issues.apache.org/jira/browse/CB-11013) IAB enabling background play of YouTube videos? +* [CB-10467](https://issues.apache.org/jira/browse/CB-10467) Hardware back button, while `InAppBrowser` is opened, closes the app too in addition to closing `InAppBrowser` +* [CB-11178](https://issues.apache.org/jira/browse/CB-11178) allow to open other apps on **iOS 9** +* fix some calls which used api level 16 +* [CB-5402](https://issues.apache.org/jira/browse/CB-5402) added extra content from wiki page +* [CB-2063](https://issues.apache.org/jira/browse/CB-2063) (**ios**) Fixed presentation style +* [CB-11012](https://issues.apache.org/jira/browse/CB-11012) added some clarifications about `InAppBrowser` object +* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom `inappbrowser` user agent for **ios** +* Add badges for paramedic builds on Jenkins +* [CB-11381](https://issues.apache.org/jira/browse/CB-11381) android: Does not pass sonarqube scan +* Add pull request template. +* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine requirements to `package.json` +* [CB-110003](https://issues.apache.org/jira/browse/CB-110003) Adding samples to Readme. +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md + +### 1.4.0 (Apr 15, 2016) +* [CB-7679](https://issues.apache.org/jira/browse/CB-7679) add fix for **iOS** upload. +* [CB-10944](https://issues.apache.org/jira/browse/CB-10944) `NoSuchMethodError` in `InAppBrowser` plugin +* [CB-10937](https://issues.apache.org/jira/browse/CB-10937) fix stretched icons +* [CB-10760](https://issues.apache.org/jira/browse/CB-10760) Fixing README for display on Cordova website +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins + +### 1.3.0 (Feb 09, 2016) +* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom inappbrowser user agent for android +* [CB-10538](https://issues.apache.org/jira/browse/CB-10538) cordova-plugin-inappbrowser timeout issue +* [CB-10395](https://issues.apache.org/jira/browse/CB-10395) InAppBrowser's WebView not storing cookies reliable on Android +* Edit package.json license to match SPDX id +* [CB-10305](https://issues.apache.org/jira/browse/CB-10305) Gray bar appears in the wrong place on iOS +* [CB-7786](https://issues.apache.org/jira/browse/CB-7786) Support mediaPlaybackRequiresUserAction on Android +* [CB-7500](https://issues.apache.org/jira/browse/CB-7500) executeScript with callback kills/blurs inAppBrowser window on Android + +### 1.2.1 (Feb 02, 2016) +* [CB-10407](https://issues.apache.org/jira/browse/CB-10407) InAppBrowser not firing loadstart event on android +* [CB-10428](https://issues.apache.org/jira/browse/CB-10428) Fix syntax error when browserifying inAppBrowser plugin +* handle app store urls in system browser +* [CB-6702](https://issues.apache.org/jira/browse/CB-6702) InAppBrowser hangs when opening more than one instance +* [CB-10456](https://issues.apache.org/jira/browse/CB-10456) InAppBrowser is not closed if I close it programmatically on Android +* [CB-10451](https://issues.apache.org/jira/browse/CB-10451) InAppBrowser: loadstart event is not triggered on Windows +* [CB-10452](https://issues.apache.org/jira/browse/CB-10452) InAppBrowser: 'exit' event is not triggered on Windows +* [CB-10454](https://issues.apache.org/jira/browse/CB-10454) InAppBrowser: 'loaderror' event does not have code and message on Windows +* [CB-10450](https://issues.apache.org/jira/browse/CB-10450) InAppBrowser: Unable to get property 'canGoBack' of undefined on Windows +* [CB-10441](https://issues.apache.org/jira/browse/CB-10441) Add auto tests for InAppBrowser plugin + +### 1.2.0 (Jan 15, 2016) +* [CB-8180](https://issues.apache.org/jira/browse/CB-8180) Changing methods of interception in `WebViewClient` class +* [CB-10009](https://issues.apache.org/jira/browse/CB-10009) Improve `InAppBrowser` toolbar look and feel on **Windows** +* Open a new window on the **Browser** platform + +### 1.1.1 (Dec 10, 2015) + +* [CB-9445](https://issues.apache.org/jira/browse/CB-9445) Improves executeScript callbacks on iOS +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Incremented plugin version. +* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - re-fix: backwards compatible with cordova-ios < 4.0 +* [CB-8534](https://issues.apache.org/jira/browse/CB-8534) Allow plugins to respond to onReceivedHttpAuthRequest. This closes #82 +* [CB-3750](https://issues.apache.org/jira/browse/CB-3750) Fixes spinner on iOS. This closes #89 +* [CB-7696](https://issues.apache.org/jira/browse/CB-7696) Document target=_self behavior for Windows +* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - Compile Error in InAppBrowser Plugin for iOS - No known instance method for selector 'URLIsWhitelisted:' + ### 1.1.0 (Nov 18, 2015) * [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest * Invoke webview if using local file diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ru/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json b/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json old mode 100755 new mode 100644 index cba3e5f2..8da20900 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-inappbrowser", - "version": "1.1.0", + "version": "1.5.0", "description": "Cordova InAppBrowser Plugin", "cordova": { "id": "cordova-plugin-inappbrowser", @@ -37,12 +37,23 @@ "cordova-windows", "cordova-firefoxos" ], - "engines": [ - { - "name": "cordova", - "version": ">=3.1.0" + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, + "engines": { + "cordovaDependencies": { + "0.2.3": { + "cordova": ">=3.1.0" + }, + "2.0.0": { + "cordova": ">100" + } } - ], + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml b/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml old mode 100755 new mode 100644 index a05fddc7..a27be5cf --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml @@ -20,7 +20,7 @@ + version="1.5.0"> InAppBrowser Cordova InAppBrowser Plugin diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java old mode 100755 new mode 100644 index 60437451..8f4f3d97 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java @@ -19,7 +19,6 @@ package org.apache.cordova.inappbrowser; import android.annotation.SuppressLint; -import org.apache.cordova.inappbrowser.InAppBrowserDialog; import android.content.Context; import android.content.Intent; import android.provider.Browser; @@ -30,7 +29,6 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.text.InputType; -import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; @@ -41,17 +39,21 @@ import android.view.WindowManager.LayoutParams; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.webkit.CookieManager; +import android.webkit.CookieSyncManager; +import android.webkit.HttpAuthHandler; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; -import android.widget.Button; import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import org.apache.cordova.CallbackContext; import org.apache.cordova.Config; import org.apache.cordova.CordovaArgs; +import org.apache.cordova.CordovaHttpAuthHandler; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaWebView; import org.apache.cordova.LOG; @@ -61,6 +63,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashMap; import java.util.StringTokenizer; @@ -82,6 +85,8 @@ public class InAppBrowser extends CordovaPlugin { private static final String CLEAR_ALL_CACHE = "clearcache"; private static final String CLEAR_SESSION_CACHE = "clearsessioncache"; private static final String HARDWARE_BACK_BUTTON = "hardwareback"; + private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction"; + private static final String SHOULD_PAUSE = "shouldPauseOnSuspend"; private InAppBrowserDialog dialog; private WebView inAppWebView; @@ -93,6 +98,8 @@ public class InAppBrowser extends CordovaPlugin { private boolean clearAllCache = false; private boolean clearSessionCache = false; private boolean hadwareBackButton = true; + private boolean mediaPlaybackRequiresUserGesture = false; + private boolean shouldPauseInAppBrowser = false; /** * Executes the request and returns PluginResult. @@ -113,7 +120,7 @@ public class InAppBrowser extends CordovaPlugin { final String target = t; final HashMap features = parseFeature(args.optString(2)); - Log.d(LOG_TAG, "target = " + target); + LOG.d(LOG_TAG, "target = " + target); this.cordova.getActivity().runOnUiThread(new Runnable() { @Override @@ -121,7 +128,7 @@ public class InAppBrowser extends CordovaPlugin { String result = ""; // SELF if (SELF.equals(target)) { - Log.d(LOG_TAG, "in self"); + LOG.d(LOG_TAG, "in self"); /* This code exists for compatibility between 3.x and 4.x versions of Cordova. * Previously the Config class had a static method, isUrlWhitelisted(). That * responsibility has been moved to the plugins, with an aggregating method in @@ -136,8 +143,11 @@ public class InAppBrowser extends CordovaPlugin { Method iuw = Config.class.getMethod("isUrlWhiteListed", String.class); shouldAllowNavigation = (Boolean)iuw.invoke(null, url); } catch (NoSuchMethodException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (InvocationTargetException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } } if (shouldAllowNavigation == null) { @@ -147,20 +157,23 @@ public class InAppBrowser extends CordovaPlugin { Method san = pm.getClass().getMethod("shouldAllowNavigation", String.class); shouldAllowNavigation = (Boolean)san.invoke(pm, url); } catch (NoSuchMethodException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (InvocationTargetException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } } // load in webview if (Boolean.TRUE.equals(shouldAllowNavigation)) { - Log.d(LOG_TAG, "loading in webview"); + LOG.d(LOG_TAG, "loading in webview"); webView.loadUrl(url); } //Load the dialer else if (url.startsWith(WebView.SCHEME_TEL)) { try { - Log.d(LOG_TAG, "loading in dialer"); + LOG.d(LOG_TAG, "loading in dialer"); Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse(url)); cordova.getActivity().startActivity(intent); @@ -170,18 +183,18 @@ public class InAppBrowser extends CordovaPlugin { } // load in InAppBrowser else { - Log.d(LOG_TAG, "loading in InAppBrowser"); + LOG.d(LOG_TAG, "loading in InAppBrowser"); result = showWebPage(url, features); } } // SYSTEM else if (SYSTEM.equals(target)) { - Log.d(LOG_TAG, "in system"); + LOG.d(LOG_TAG, "in system"); result = openExternal(url); } // BLANK - or anything else else { - Log.d(LOG_TAG, "in blank"); + LOG.d(LOG_TAG, "in blank"); result = showWebPage(url, features); } @@ -197,7 +210,7 @@ public class InAppBrowser extends CordovaPlugin { else if (action.equals("injectScriptCode")) { String jsWrapper = null; if (args.getBoolean(1)) { - jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId()); + jsWrapper = String.format("(function(){prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')})()", callbackContext.getCallbackId()); } injectDeferredObject(args.getString(0), jsWrapper); } @@ -253,6 +266,26 @@ public class InAppBrowser extends CordovaPlugin { closeDialog(); } + /** + * Called when the system is about to start resuming a previous activity. + */ + @Override + public void onPause(boolean multitasking) { + if (shouldPauseInAppBrowser) { + inAppWebView.onPause(); + } + } + + /** + * Called when the activity will start interacting with the user. + */ + @Override + public void onResume(boolean multitasking) { + if (shouldPauseInAppBrowser) { + inAppWebView.onResume(); + } + } + /** * Called by AccelBroker when listener is to be shut down. * Stop listener. @@ -350,7 +383,7 @@ public class InAppBrowser extends CordovaPlugin { this.cordova.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { - Log.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString()); + LOG.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString()); return e.toString(); } } @@ -359,20 +392,22 @@ public class InAppBrowser extends CordovaPlugin { * Closes the dialog */ public void closeDialog() { - final WebView childView = this.inAppWebView; - // The JS protects against multiple calls, so this should happen only when - // closeDialog() is called by other native code. - if (childView == null) { - return; - } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { + final WebView childView = inAppWebView; + // The JS protects against multiple calls, so this should happen only when + // closeDialog() is called by other native code. + if (childView == null) { + return; + } + childView.setWebViewClient(new WebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(WebView view, String url) { if (dialog != null) { dialog.dismiss(); + dialog = null; } } }); @@ -380,16 +415,16 @@ public class InAppBrowser extends CordovaPlugin { // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); + + try { + JSONObject obj = new JSONObject(); + obj.put("type", EXIT_EVENT); + sendUpdate(obj, false); + } catch (JSONException ex) { + LOG.d(LOG_TAG, "Should never happen"); + } } }); - - try { - JSONObject obj = new JSONObject(); - obj.put("type", EXIT_EVENT); - sendUpdate(obj, false); - } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); - } } /** @@ -468,6 +503,8 @@ public class InAppBrowser extends CordovaPlugin { showLocationBar = true; showZoomControls = true; openWindowHidden = false; + mediaPlaybackRequiresUserGesture = false; + if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { @@ -485,6 +522,10 @@ public class InAppBrowser extends CordovaPlugin { if (hardwareBack != null) { hadwareBackButton = hardwareBack.booleanValue(); } + Boolean mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION); + if (mediaPlayback != null) { + mediaPlaybackRequiresUserGesture = mediaPlayback.booleanValue(); + } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); @@ -494,6 +535,10 @@ public class InAppBrowser extends CordovaPlugin { clearSessionCache = cache.booleanValue(); } } + Boolean shouldPause = features.get(SHOULD_PAUSE); + if (shouldPause != null) { + shouldPauseInAppBrowser = shouldPause.booleanValue(); + } } final CordovaWebView thatWebView = this.webView; @@ -516,6 +561,12 @@ public class InAppBrowser extends CordovaPlugin { @SuppressLint("NewApi") public void run() { + + // CB-6702 InAppBrowser hangs when opening more than one instance + if (dialog != null) { + dialog.dismiss(); + }; + // Let's create the main dialog dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; @@ -541,26 +592,28 @@ public class InAppBrowser extends CordovaPlugin { actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); - actionButtonContainer.setId(1); + actionButtonContainer.setId(Integer.valueOf(1)); // Back button - Button back = new Button(cordova.getActivity()); + ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); - back.setId(2); + back.setId(Integer.valueOf(2)); Resources activityRes = cordova.getActivity().getResources(); int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName()); Drawable backIcon = activityRes.getDrawable(backResId); - if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) - { - back.setBackgroundDrawable(backIcon); - } + if (Build.VERSION.SDK_INT >= 16) + back.setBackground(null); else - { - back.setBackground(backIcon); - } + back.setBackgroundDrawable(null); + back.setImageDrawable(backIcon); + back.setScaleType(ImageView.ScaleType.FIT_CENTER); + back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + if (Build.VERSION.SDK_INT >= 16) + back.getAdjustViewBounds(); + back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); @@ -568,22 +621,24 @@ public class InAppBrowser extends CordovaPlugin { }); // Forward button - Button forward = new Button(cordova.getActivity()); + ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); - forward.setId(3); + forward.setId(Integer.valueOf(3)); int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName()); Drawable fwdIcon = activityRes.getDrawable(fwdResId); - if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) - { - forward.setBackgroundDrawable(fwdIcon); - } + if (Build.VERSION.SDK_INT >= 16) + forward.setBackground(null); else - { - forward.setBackground(fwdIcon); - } + forward.setBackgroundDrawable(null); + forward.setImageDrawable(fwdIcon); + forward.setScaleType(ImageView.ScaleType.FIT_CENTER); + forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + if (Build.VERSION.SDK_INT >= 16) + forward.getAdjustViewBounds(); + forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); @@ -596,7 +651,7 @@ public class InAppBrowser extends CordovaPlugin { textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); - edittext.setId(4); + edittext.setId(Integer.valueOf(4)); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); @@ -614,22 +669,24 @@ public class InAppBrowser extends CordovaPlugin { }); // Close/Done button - Button close = new Button(cordova.getActivity()); + ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); - close.setId(5); + close.setId(Integer.valueOf(5)); int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); Drawable closeIcon = activityRes.getDrawable(closeResId); - if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) - { - close.setBackgroundDrawable(closeIcon); - } + if (Build.VERSION.SDK_INT >= 16) + close.setBackground(null); else - { - close.setBackground(closeIcon); - } + close.setBackgroundDrawable(null); + close.setImageDrawable(closeIcon); + close.setScaleType(ImageView.ScaleType.FIT_CENTER); + back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + if (Build.VERSION.SDK_INT >= 16) + close.getAdjustViewBounds(); + close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); @@ -639,6 +696,7 @@ public class InAppBrowser extends CordovaPlugin { // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); + inAppWebView.setId(Integer.valueOf(6)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); @@ -648,6 +706,20 @@ public class InAppBrowser extends CordovaPlugin { settings.setBuiltInZoomControls(showZoomControls); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); + if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture); + } + + String overrideUserAgent = preferences.getString("OverrideUserAgent", null); + String appendUserAgent = preferences.getString("AppendUserAgent", null); + + if (overrideUserAgent != null) { + settings.setUserAgentString(overrideUserAgent); + } + if (appendUserAgent != null) { + settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent); + } + //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); @@ -665,7 +737,7 @@ public class InAppBrowser extends CordovaPlugin { } inAppWebView.loadUrl(url); - inAppWebView.setId(6); + inAppWebView.setId(Integer.valueOf(6)); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); @@ -753,34 +825,30 @@ public class InAppBrowser extends CordovaPlugin { } /** - * Notify the host application that a page has started loading. + * Override the URL that should be loaded + * + * This handles a small subset of all the URIs that would be encountered. * - * @param view The webview initiating the callback. - * @param url The url of the page. + * @param webView + * @param url */ @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - super.onPageStarted(view, url, favicon); - String newloc = ""; - if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) { - newloc = url; - } - // If dialing phone (tel:5551212) - else if (url.startsWith(WebView.SCHEME_TEL)) { + public boolean shouldOverrideUrlLoading(WebView webView, String url) { + if (url.startsWith(WebView.SCHEME_TEL)) { try { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse(url)); cordova.getActivity().startActivity(intent); + return true; } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString()); } - } - - else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:")) { + } else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:") || url.startsWith("intent:")) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); cordova.getActivity().startActivity(intent); + return true; } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString()); } @@ -795,8 +863,7 @@ public class InAppBrowser extends CordovaPlugin { int parmIndex = url.indexOf('?'); if (parmIndex == -1) { address = url.substring(4); - } - else { + } else { address = url.substring(4, parmIndex); // If body, then set sms body @@ -812,32 +879,64 @@ public class InAppBrowser extends CordovaPlugin { intent.putExtra("address", address); intent.setType("vnd.android-dir/mms-sms"); cordova.getActivity().startActivity(intent); + return true; } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error sending sms " + url + ":" + e.toString()); } } - else { + return false; + } + + + /* + * onPageStarted fires the LOAD_START_EVENT + * + * @param view + * @param url + * @param favicon + */ + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + super.onPageStarted(view, url, favicon); + String newloc = ""; + if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) { + newloc = url; + } + else + { + // Assume that everything is HTTP at this point, because if we don't specify, + // it really should be. Complain loudly about this!!! + LOG.e(LOG_TAG, "Possible Uncaught/Unknown URI"); newloc = "http://" + url; } + // Update the UI if we haven't already if (!newloc.equals(edittext.getText().toString())) { edittext.setText(newloc); - } + } try { JSONObject obj = new JSONObject(); obj.put("type", LOAD_START_EVENT); obj.put("url", newloc); - sendUpdate(obj, true); } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); + LOG.e(LOG_TAG, "URI passed in has caused a JSON error."); } } + + public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); + // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { + CookieManager.getInstance().flush(); + } else { + CookieSyncManager.getInstance().sync(); + } + try { JSONObject obj = new JSONObject(); obj.put("type", LOAD_STOP_EVENT); @@ -845,7 +944,7 @@ public class InAppBrowser extends CordovaPlugin { sendUpdate(obj, true); } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); + LOG.d(LOG_TAG, "Should never happen"); } } @@ -861,9 +960,46 @@ public class InAppBrowser extends CordovaPlugin { sendUpdate(obj, true, PluginResult.Status.ERROR); } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); + LOG.d(LOG_TAG, "Should never happen"); } } + + /** + * On received http auth request. + */ + @Override + public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) { + + // Check if there is some plugin which can resolve this auth challenge + PluginManager pluginManager = null; + try { + Method gpm = webView.getClass().getMethod("getPluginManager"); + pluginManager = (PluginManager)gpm.invoke(webView); + } catch (NoSuchMethodException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } catch (InvocationTargetException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } + + if (pluginManager == null) { + try { + Field pmf = webView.getClass().getField("pluginManager"); + pluginManager = (PluginManager)pmf.get(webView); + } catch (NoSuchFieldException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } + } + + if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(webView, new CordovaHttpAuthHandler(handler), host, realm)) { + return; + } + + // By default handle 401 like we'd normally do! + super.onReceivedHttpAuthRequest(view, handler, host, realm); + } } } - diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java old mode 100755 new mode 100644 index d7017202..e7b212f2 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java @@ -21,7 +21,6 @@ package org.apache.cordova.inappbrowser; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; -import android.util.Log; import org.json.JSONException; import org.json.JSONObject; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js old mode 100755 new mode 100644 index 33fbe476..da7dacd3 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js @@ -19,9 +19,7 @@ * */ -var cordova = require('cordova'), - channel = require('cordova/channel'), - urlutil = require('cordova/urlutil'); +var modulemapper = require('cordova/modulemapper'); var browserWrap, popup, @@ -68,19 +66,23 @@ var IAB = { open: function (win, lose, args) { var strUrl = args[0], target = args[1], - features = args[2], - url; + features = args[2]; - if (target === "_system" || target === "_self" || !target) { + if (target === "_self" || !target) { window.location = strUrl; + } else if (target === "_system") { + modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, "_blank"); } else { // "_blank" or anything else if (!browserWrap) { browserWrap = document.createElement("div"); browserWrap.style.position = "absolute"; + browserWrap.style.top = "0"; + browserWrap.style.left = "0"; + browserWrap.style.boxSizing = "border-box"; browserWrap.style.borderWidth = "40px"; - browserWrap.style.width = "calc(100% - 80px)"; - browserWrap.style.height = "calc(100% - 80px)"; + browserWrap.style.width = "100vw"; + browserWrap.style.height = "100vh"; browserWrap.style.borderStyle = "solid"; browserWrap.style.borderColor = "rgba(0,0,0,0.25)"; @@ -105,6 +107,7 @@ var IAB = { if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { popup.style.height = "calc(100% - 60px)"; + popup.style.marginBottom = "-4px"; navigationButtonsDiv = document.createElement("div"); navigationButtonsDiv.style.height = "60px"; @@ -190,7 +193,9 @@ var IAB = { if (browserWrap && popup) { try { popup.contentWindow.eval(code); - hasCallback && win([]); + if (hasCallback) { + win([]); + } } catch(e) { console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e)); } @@ -200,19 +205,25 @@ var IAB = { injectScriptFile: function (win, fail, args) { var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented'; console.warn(msg); - fail && fail(msg); + if (fail) { + fail(msg); + } }, injectStyleCode: function (win, fail, args) { var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented'; console.warn(msg); - fail && fail(msg); + if (fail) { + fail(msg); + } }, injectStyleFile: function (win, fail, args) { var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented'; console.warn(msg); - fail && fail(msg); + if (fail) { + fail(msg); + } } }; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js old mode 100755 new mode 100644 index f0d44c12..c09e3583 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js @@ -21,9 +21,7 @@ // https://developer.mozilla.org/en-US/docs/WebAPI/Browser -var cordova = require('cordova'), - channel = require('cordova/channel'), - modulemapper = require('cordova/modulemapper'); +var modulemapper = require('cordova/modulemapper'); var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open'); var browserWrap; @@ -49,9 +47,7 @@ var IABExecs = { var strUrl = args[0], target = args[1], features_string = args[2] || "location=yes", //location=yes is default - features = {}, - url, - elem; + features = {}; var features_list = features_string.split(','); features_list.forEach(function(feature) { @@ -61,7 +57,7 @@ var IABExecs = { } else if (tup[1] == 'no') { tup[1] = false; } else { - var number = parseInt(tup[1]); + var number = parseInt(tup[1]); if (!isNaN(number)) { tup[1] = number; } @@ -115,7 +111,7 @@ var IABExecs = { back.classList.add('inAppBrowserBack'); forward.classList.add('inAppBrowserForward'); - function checkForwardBackward() { + var checkForwardBackward = function () { var backReq = browserElem.getCanGoBack(); backReq.onsuccess = function() { if (this.result) { @@ -123,7 +119,7 @@ var IABExecs = { } else { back.classList.add('disabled'); } - } + }; var forwardReq = browserElem.getCanGoForward(); forwardReq.onsuccess = function() { if (this.result) { @@ -131,7 +127,7 @@ var IABExecs = { } else { forward.classList.add('disabled'); } - } + }; }; browserElem.addEventListener('mozbrowserloadend', checkForwardBackward); @@ -163,16 +159,16 @@ var IABExecs = { win({ type:'loadstart', url : e.detail - }) + }); }, false); browserElem.addEventListener('mozbrowserloadend', function(e){ - win({type:'loadstop'}) + win({type:'loadstop'}); }, false); browserElem.addEventListener('mozbrowsererror', function(e){ - win({type:'loaderror'}) + win({type:'loaderror'}); }, false); browserElem.addEventListener('mozbrowserclose', function(e){ - win({type:'exit'}) + win({type:'exit'}); }, false); } else { window.location = strUrl; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h old mode 100755 new mode 100644 index 1ccc7b14..6bb0ec16 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h @@ -30,7 +30,6 @@ @class CDVInAppBrowserViewController; @interface CDVInAppBrowser : CDVPlugin { - BOOL _injectedIframeBridge; } @property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m old mode 100755 new mode 100644 index 47a8ab3a..b342ca73 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m @@ -47,6 +47,11 @@ _callbackIdPattern = nil; } +- (id)settingForKey:(NSString*)key +{ + return [self.commandDelegate.settings objectForKey:[key lowercaseString]]; +} + - (void)onReset { [self close:nil]; @@ -137,8 +142,16 @@ } if (self.inAppBrowserViewController == nil) { - NSString* originalUA = [CDVUserAgentUtil originalUserAgent]; - self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions]; + NSString* userAgent = [CDVUserAgentUtil originalUserAgent]; + NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"]; + NSString* appendUserAgent = [self settingForKey:@"AppendUserAgent"]; + if(overrideUserAgent){ + userAgent = overrideUserAgent; + } + if(appendUserAgent){ + userAgent = [userAgent stringByAppendingString: appendUserAgent]; + } + self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions]; self.inAppBrowserViewController.navigationDelegate = self; if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) { @@ -218,6 +231,7 @@ initWithRootViewController:self.inAppBrowserViewController]; nav.orientationDelegate = self.inAppBrowserViewController; nav.navigationBarHidden = YES; + nav.modalPresentationStyle = self.inAppBrowserViewController.modalPresentationStyle; __weak CDVInAppBrowser* weakSelf = self; @@ -231,25 +245,25 @@ - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options { - if ([self.commandDelegate URLIsWhitelisted:url]) { - NSURLRequest* request = [NSURLRequest requestWithURL:url]; + NSURLRequest* request = [NSURLRequest requestWithURL:url]; + #ifdef __CORDOVA_4_0_0 - [self.webViewEngine loadRequest:request]; + // the webview engine itself will filter for this according to policy + // in config.xml for cordova-ios-4.0 + [self.webViewEngine loadRequest:request]; #else + if ([self.commandDelegate URLIsWhitelisted:url]) { [self.webView loadRequest:request]; -#endif } else { // this assumes the InAppBrowser can be excepted from the white-list [self openInInAppBrowser:url withOptions:options]; } +#endif } - (void)openInSystem:(NSURL*)url { - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url]; - } else { // handle any custom schemes to plugins - [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; - } + [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; + [[UIApplication sharedApplication] openURL:url]; } // This is a helper method for the inject{Script|Style}{Code|File} API calls, which @@ -263,11 +277,8 @@ - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper { - if (!_injectedIframeBridge) { - _injectedIframeBridge = YES; - // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController - [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"]; - } + // Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController + [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){_cdvIframeBridge=d.getElementById('_cdvIframeBridge');if(!_cdvIframeBridge) {var e = _cdvIframeBridge = d.createElement('iframe');e.id='_cdvIframeBridge'; e.style.display='none';d.body.appendChild(e);}})(document)"]; if (jsWrapper != nil) { NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil]; @@ -390,7 +401,14 @@ [self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId]; return NO; } - } else if ((self.callbackId != nil) && isTopLevelNavigation) { + } + //if is an app store link, let the system handle it, otherwise it fails to load it + else if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) { + [theWebView stopLoading]; + [self openInSystem:url]; + return NO; + } + else if ((self.callbackId != nil) && isTopLevelNavigation) { // Send a loadstart event for each top-level navigation (includes redirects). CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}]; @@ -404,7 +422,6 @@ - (void)webViewDidStartLoad:(UIWebView*)theWebView { - _injectedIframeBridge = NO; } - (void)webViewDidFinishLoad:(UIWebView*)theWebView @@ -512,15 +529,15 @@ self.webView.scalesPageToFit = NO; self.webView.userInteractionEnabled = YES; - self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; + self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; self.spinner.alpha = 1.000; self.spinner.autoresizesSubviews = YES; - self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin; + self.spinner.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin); self.spinner.clearsContextBeforeDrawing = NO; self.spinner.clipsToBounds = NO; self.spinner.contentMode = UIViewContentModeScaleToFill; - self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0); - self.spinner.hidden = YES; + self.spinner.frame = CGRectMake(CGRectGetMidX(self.webView.frame), CGRectGetMidY(self.webView.frame), 20.0, 20.0); + self.spinner.hidden = NO; self.spinner.hidesWhenStopped = YES; self.spinner.multipleTouchEnabled = NO; self.spinner.opaque = NO; @@ -749,6 +766,10 @@ return UIStatusBarStyleDefault; } +- (BOOL)prefersStatusBarHidden { + return NO; +} + - (void)close { [CDVUserAgentUtil releaseLock:&_userAgentLockToken]; @@ -988,19 +1009,38 @@ @implementation CDVInAppBrowserNavigationController : UINavigationController +- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { + if ( self.presentedViewController) { + [super dismissViewControllerAnimated:flag completion:completion]; + } +} + - (void) viewDidLoad { CGRect frame = [UIApplication sharedApplication].statusBarFrame; // simplified from: http://stackoverflow.com/a/25669695/219684 - UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:frame]; + UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]]; bgToolbar.barStyle = UIBarStyleDefault; + [bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; [self.view addSubview:bgToolbar]; [super viewDidLoad]; } +- (CGRect) invertFrameIfNeeded:(CGRect)rect { + // We need to invert since on iOS 7 frames are always in Portrait context + if (!IsAtLeastiOSVersion(@"8.0")) { + if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { + CGFloat temp = rect.size.width; + rect.size.width = rect.size.height; + rect.size.height = temp; + } + rect.origin = CGPointZero; + } + return rect; +} #pragma mark CDVScreenOrientationDelegate diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js old mode 100755 new mode 100644 index 07661bb6..b01daeb5 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js @@ -19,6 +19,9 @@ * */ +/* jshint -W061 */ +/* global oxide */ + oxide.addMessageHandler("EXECUTE", function(msg) { var code = msg.args.code; try { diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js old mode 100755 new mode 100644 index fc037bdb..23f6e547 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js @@ -19,13 +19,10 @@ * */ -/*jslint sloppy:true */ -/*global Windows:true, require, document, setTimeout, window, module */ - - +/* jslint sloppy:true */ +/* global Windows:true, setImmediate */ var cordova = require('cordova'), - channel = require('cordova/channel'), urlutil = require('cordova/urlutil'); var browserWrap, @@ -35,11 +32,13 @@ var browserWrap, backButton, forwardButton, closeButton, - bodyOverflowStyle; + bodyOverflowStyle, + navigationEventsCallback, + hardwareBackCallback; // x-ms-webview is available starting from Windows 8.1 (platformId is 'windows') // http://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx -var isWebViewAvailable = cordova.platformId == 'windows'; +var isWebViewAvailable = cordova.platformId === 'windows'; function attachNavigationEvents(element, callback) { if (isWebViewAvailable) { @@ -48,19 +47,32 @@ function attachNavigationEvents(element, callback) { }); element.addEventListener("MSWebViewNavigationCompleted", function (e) { - callback({ type: e.isSuccess ? "loadstop" : "loaderror", url: e.uri}, {keepCallback: true}); + if (e.isSuccess) { + callback({ type: "loadstop", url: e.uri }, { keepCallback: true }); + } else { + callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true }); + } }); element.addEventListener("MSWebViewUnviewableContentIdentified", function (e) { // WebView found the content to be not HTML. // http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx - callback({ type: "loaderror", url: e.uri}, {keepCallback: true}); + callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true }); }); element.addEventListener("MSWebViewContentLoading", function (e) { - if (navigationButtonsDiv) { - backButton.disabled = !popup.canGoBack; - forwardButton.disabled = !popup.canGoForward; + if (navigationButtonsDiv && popup) { + if (popup.canGoBack) { + backButton.removeAttribute("disabled"); + } else { + backButton.setAttribute("disabled", "true"); + } + + if (popup.canGoForward) { + forwardButton.removeAttribute("disabled"); + } else { + forwardButton.setAttribute("disabled", "true"); + } } }); } else { @@ -83,228 +95,266 @@ function attachNavigationEvents(element, callback) { var IAB = { close: function (win, lose) { - if (browserWrap) { - if (win) win({ type: "exit" }); - - browserWrap.parentNode.removeChild(browserWrap); - // Reset body overflow style to initial value - document.body.style.msOverflowStyle = bodyOverflowStyle; - browserWrap = null; - popup = null; - } - }, - show: function (win, lose) { - if (browserWrap) { - browserWrap.style.display = "block"; - } - }, - open: function (win, lose, args) { - var strUrl = args[0], - target = args[1], - features = args[2], - url; - - if (target === "_system") { - url = new Windows.Foundation.Uri(strUrl); - Windows.System.Launcher.launchUriAsync(url); - } else if (target === "_self" || !target) { - window.location = strUrl; - } else { - // "_blank" or anything else - if (!browserWrap) { - var browserWrapStyle = document.createElement('link'); - browserWrapStyle.rel = "stylesheet"; - browserWrapStyle.type = "text/css"; - browserWrapStyle.href = urlutil.makeAbsolute("/www/css/inappbrowser.css"); - - document.head.appendChild(browserWrapStyle); - - browserWrap = document.createElement("div"); - browserWrap.className = "inAppBrowserWrap"; - - if (features.indexOf("fullscreen=yes") > -1) { - browserWrap.classList.add("inAppBrowserWrapFullscreen"); + setImmediate(function () { + if (browserWrap) { + if (navigationEventsCallback) { + navigationEventsCallback({ type: "exit" }); } - // Save body overflow style to be able to reset it back later - bodyOverflowStyle = document.body.style.msOverflowStyle; - - browserWrap.onclick = function () { - setTimeout(function () { - IAB.close(win); - }, 0); - }; - - document.body.appendChild(browserWrap); - // Hide scrollbars for the whole body while inappbrowser's window is open - document.body.style.msOverflowStyle = "none"; - } + browserWrap.parentNode.removeChild(browserWrap); + // Reset body overflow style to initial value + document.body.style.msOverflowStyle = bodyOverflowStyle; + browserWrap = null; + popup = null; - if (features.indexOf("hidden=yes") !== -1) { - browserWrap.style.display = "none"; + document.removeEventListener("backbutton", hardwareBackCallback, false); } - - popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe"); - if (popup instanceof HTMLIFrameElement) { - // For iframe we need to override bacground color of parent element here - // otherwise pages without background color set will have transparent background - popup.style.backgroundColor = "white"; + }); + }, + show: function (win, lose) { + setImmediate(function () { + if (browserWrap) { + browserWrap.style.display = "block"; } - popup.style.borderWidth = "0px"; - popup.style.width = "100%"; - - browserWrap.appendChild(popup); + }); + }, + open: function (win, lose, args) { + // make function async so that we can add navigation events handlers before view is loaded and navigation occured + setImmediate(function () { + var strUrl = args[0], + target = args[1], + features = args[2], + url; + + navigationEventsCallback = win; + + if (target === "_system") { + url = new Windows.Foundation.Uri(strUrl); + Windows.System.Launcher.launchUriAsync(url); + } else if (target === "_self" || !target) { + window.location = strUrl; + } else { + // "_blank" or anything else + if (!browserWrap) { + var browserWrapStyle = document.createElement('link'); + browserWrapStyle.rel = "stylesheet"; + browserWrapStyle.type = "text/css"; + browserWrapStyle.href = urlutil.makeAbsolute("/www/css/inappbrowser.css"); - if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { - popup.style.height = "calc(100% - 60px)"; + document.head.appendChild(browserWrapStyle); - navigationButtonsDiv = document.createElement("div"); - navigationButtonsDiv.style.height = "60px"; - navigationButtonsDiv.style.backgroundColor = "#404040"; - navigationButtonsDiv.style.zIndex = "999"; - navigationButtonsDiv.onclick = function (e) { - e.cancelBubble = true; - }; + browserWrap = document.createElement("div"); + browserWrap.className = "inAppBrowserWrap"; - navigationButtonsDivInner = document.createElement("div"); - navigationButtonsDivInner.style.paddingTop = "10px"; - navigationButtonsDivInner.style.height = "50px"; - navigationButtonsDivInner.style.width = "160px"; - navigationButtonsDivInner.style.margin = "0 auto"; - navigationButtonsDivInner.style.backgroundColor = "#404040"; - navigationButtonsDivInner.style.zIndex = "999"; - navigationButtonsDivInner.onclick = function (e) { - e.cancelBubble = true; - }; + if (features.indexOf("fullscreen=yes") > -1) { + browserWrap.classList.add("inAppBrowserWrapFullscreen"); + } + // Save body overflow style to be able to reset it back later + bodyOverflowStyle = document.body.style.msOverflowStyle; - backButton = document.createElement("button"); - backButton.style.width = "40px"; - backButton.style.height = "40px"; - backButton.style.borderRadius = "40px"; + browserWrap.onclick = function () { + setTimeout(function () { + IAB.close(navigationEventsCallback); + }, 0); + }; - backButton.innerText = "<-"; - backButton.addEventListener("click", function (e) { - if (popup.canGoBack) - popup.goBack(); - }); + document.body.appendChild(browserWrap); + // Hide scrollbars for the whole body while inappbrowser's window is open + document.body.style.msOverflowStyle = "none"; + } - forwardButton = document.createElement("button"); - forwardButton.style.marginLeft = "20px"; - forwardButton.style.width = "40px"; - forwardButton.style.height = "40px"; - forwardButton.style.borderRadius = "40px"; + if (features.indexOf("hidden=yes") !== -1) { + browserWrap.style.display = "none"; + } - forwardButton.innerText = "->"; - forwardButton.addEventListener("click", function (e) { - if (popup.canGoForward) - popup.goForward(); - }); + popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe"); + if (popup instanceof HTMLIFrameElement) { + // For iframe we need to override bacground color of parent element here + // otherwise pages without background color set will have transparent background + popup.style.backgroundColor = "white"; + } + popup.style.borderWidth = "0px"; + popup.style.width = "100%"; + popup.style.marginBottom = "-3px"; - closeButton = document.createElement("button"); - closeButton.style.marginLeft = "20px"; - closeButton.style.width = "40px"; - closeButton.style.height = "40px"; - closeButton.style.borderRadius = "40px"; + browserWrap.appendChild(popup); - closeButton.innerText = "x"; - closeButton.addEventListener("click", function (e) { + var closeHandler = function (e) { setTimeout(function () { - IAB.close(win); + IAB.close(navigationEventsCallback); }, 0); - }); + }; - if (!isWebViewAvailable) { - // iframe navigation is not yet supported - backButton.disabled = true; - forwardButton.disabled = true; + if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) { + hardwareBackCallback = function () { + if (browserWrap.style.display === 'none') { + // NOTE: backbutton handlers have to throw an exception in order to prevent + // returning 'true' inside cordova-js, which would mean that the event is handled by user. + // Throwing an exception means that the default/system navigation behavior will take place, + // which is to exit the app if the navigation stack is empty. + throw 'Exit the app'; + } + + if (popup.canGoBack) { + popup.goBack(); + } else { + closeHandler(); + } + }; + } else if (features.indexOf("hardwareback=no") > -1) { + hardwareBackCallback = function () { + if (browserWrap.style.display === 'none') { + // See comment above + throw 'Exit the app'; + } + + closeHandler(); + }; } - navigationButtonsDivInner.appendChild(backButton); - navigationButtonsDivInner.appendChild(forwardButton); - navigationButtonsDivInner.appendChild(closeButton); - navigationButtonsDiv.appendChild(navigationButtonsDivInner); + document.addEventListener("backbutton", hardwareBackCallback, false); - browserWrap.appendChild(navigationButtonsDiv); - } else { - popup.style.height = "100%"; - } + if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { + popup.style.height = "calc(100% - 70px)"; + + navigationButtonsDiv = document.createElement("div"); + navigationButtonsDiv.className = "inappbrowser-app-bar"; + navigationButtonsDiv.onclick = function (e) { + e.cancelBubble = true; + }; + + navigationButtonsDivInner = document.createElement("div"); + navigationButtonsDivInner.className = "inappbrowser-app-bar-inner"; + navigationButtonsDivInner.onclick = function (e) { + e.cancelBubble = true; + }; - // start listening for navigation events - attachNavigationEvents(popup, win); + backButton = document.createElement("div"); + backButton.innerText = "back"; + backButton.className = "app-bar-action action-back"; + backButton.addEventListener("click", function (e) { + if (popup.canGoBack) + popup.goBack(); + }); + + forwardButton = document.createElement("div"); + forwardButton.innerText = "forward"; + forwardButton.className = "app-bar-action action-forward"; + forwardButton.addEventListener("click", function (e) { + if (popup.canGoForward) + popup.goForward(); + }); + + closeButton = document.createElement("div"); + closeButton.innerText = "close"; + closeButton.className = "app-bar-action action-close"; + closeButton.addEventListener("click", closeHandler); + + if (!isWebViewAvailable) { + // iframe navigation is not yet supported + backButton.setAttribute("disabled", "true"); + forwardButton.setAttribute("disabled", "true"); + } + + navigationButtonsDivInner.appendChild(backButton); + navigationButtonsDivInner.appendChild(forwardButton); + navigationButtonsDivInner.appendChild(closeButton); + navigationButtonsDiv.appendChild(navigationButtonsDivInner); + + browserWrap.appendChild(navigationButtonsDiv); + } else { + popup.style.height = "100%"; + } + + // start listening for navigation events + attachNavigationEvents(popup, navigationEventsCallback); - if (isWebViewAvailable) { - strUrl = strUrl.replace("ms-appx://", "ms-appx-web://"); + if (isWebViewAvailable) { + strUrl = strUrl.replace("ms-appx://", "ms-appx-web://"); + } + popup.src = strUrl; } - popup.src = strUrl; - } + }); }, injectScriptCode: function (win, fail, args) { - var code = args[0], - hasCallback = args[1]; - - if (isWebViewAvailable && browserWrap && popup) { - var op = popup.invokeScriptAsync("eval", code); - op.oncomplete = function (e) { - // return null if event target is unavailable by some reason - var result = (e && e.target) ? [e.target.result] : [null]; - hasCallback && win(result); - }; - op.onerror = function () { }; - op.start(); - } + setImmediate(function () { + var code = args[0], + hasCallback = args[1]; + + if (isWebViewAvailable && browserWrap && popup) { + var op = popup.invokeScriptAsync("eval", code); + op.oncomplete = function (e) { + if (hasCallback) { + // return null if event target is unavailable by some reason + var result = (e && e.target) ? [e.target.result] : [null]; + win(result); + } + }; + op.onerror = function () { }; + op.start(); + } + }); }, injectScriptFile: function (win, fail, args) { - var filePath = args[0], - hasCallback = args[1]; + setImmediate(function () { + var filePath = args[0], + hasCallback = args[1]; - if (!!filePath) { - filePath = urlutil.makeAbsolute(filePath); - } + if (!!filePath) { + filePath = urlutil.makeAbsolute(filePath); + } - if (isWebViewAvailable && browserWrap && popup) { - var uri = new Windows.Foundation.Uri(filePath); - Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) { - Windows.Storage.FileIO.readTextAsync(file).done(function (code) { - var op = popup.invokeScriptAsync("eval", code); - op.oncomplete = function(e) { - var result = [e.target.result]; - hasCallback && win(result); - }; - op.onerror = function () { }; - op.start(); + if (isWebViewAvailable && browserWrap && popup) { + var uri = new Windows.Foundation.Uri(filePath); + Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) { + Windows.Storage.FileIO.readTextAsync(file).done(function (code) { + var op = popup.invokeScriptAsync("eval", code); + op.oncomplete = function(e) { + if (hasCallback) { + var result = [e.target.result]; + win(result); + } + }; + op.onerror = function () { }; + op.start(); + }); }); - }); - } + } + }); }, injectStyleCode: function (win, fail, args) { - var code = args[0], - hasCallback = args[1]; + setImmediate(function () { + var code = args[0], + hasCallback = args[1]; - if (isWebViewAvailable && browserWrap && popup) { - injectCSS(popup, code, hasCallback && win); - } + if (isWebViewAvailable && browserWrap && popup) { + injectCSS(popup, code, hasCallback && win); + } + }); }, injectStyleFile: function (win, fail, args) { - var filePath = args[0], - hasCallback = args[1]; - - filePath = filePath && urlutil.makeAbsolute(filePath); - - if (isWebViewAvailable && browserWrap && popup) { - var uri = new Windows.Foundation.Uri(filePath); - Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) { - return Windows.Storage.FileIO.readTextAsync(file); - }).done(function (code) { - injectCSS(popup, code, hasCallback && win); - }, function () { - // no-op, just catch an error - }); - } + setImmediate(function () { + var filePath = args[0], + hasCallback = args[1]; + + filePath = filePath && urlutil.makeAbsolute(filePath); + + if (isWebViewAvailable && browserWrap && popup) { + var uri = new Windows.Foundation.Uri(filePath); + Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) { + return Windows.Storage.FileIO.readTextAsync(file); + }).done(function (code) { + injectCSS(popup, code, hasCallback && win); + }, function () { + // no-op, just catch an error + }); + } + }); } }; @@ -316,7 +366,9 @@ function injectCSS (webView, cssCode, callback) { var op = webView.invokeScriptAsync("eval", evalWrapper); op.oncomplete = function() { - callback && callback([]); + if (callback) { + callback([]); + } }; op.onerror = function () { }; op.start(); diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml old mode 100755 new mode 100644 index f4f3be36..2cccd40a --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml @@ -20,10 +20,12 @@ + version="1.5.0"> Cordova InAppBrowser Plugin Tests Apache 2.0 + + diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.css b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.css old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.html b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.html old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js old mode 100755 new mode 100644 index 6f254939..a89a4215 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js @@ -16,5 +16,5 @@ * specific language governing permissions and limitations * under the License. */ -var d = document.getElementById("header") +var d = document.getElementById("header"); d.innerHTML = "Script file successfully injected"; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.html b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.html old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html old mode 100755 new mode 100644 index 64ea3d11..4f167f8c --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html @@ -38,5 +38,8 @@
+ diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js old mode 100755 new mode 100644 index a8279868..1a96029d --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js @@ -19,11 +19,118 @@ * */ +/* jshint jasmine: true */ +/* global MSApp */ + var cordova = require('cordova'); var isWindows = cordova.platformId == 'windows'; window.alert = window.alert || navigator.notification.alert; +exports.defineAutoTests = function () { + + describe('cordova.InAppBrowser', function () { + + it("inappbrowser.spec.1 should exist", function () { + expect(cordova.InAppBrowser).toBeDefined(); + }); + + it("inappbrowser.spec.2 should contain open function", function () { + expect(cordova.InAppBrowser.open).toBeDefined(); + expect(cordova.InAppBrowser.open).toEqual(jasmine.any(Function)); + }); + }); + + describe('open method', function () { + + var iabInstance; + var originalTimeout; + var url = 'https://dist.apache.org/repos/dist/dev/cordova/'; + var badUrl = 'http://bad-uri/'; + + beforeEach(function () { + // increase timeout to ensure test url could be loaded within test time + originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; + + iabInstance = null; + }); + + afterEach(function (done) { + // restore original timeout + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + + if (iabInstance !== null && iabInstance.close) { + iabInstance.close(); + } + iabInstance = null; + // add some extra time so that iab dialog is closed + setTimeout(done, 2000); + }); + + function verifyEvent(evt, type) { + expect(evt).toBeDefined(); + expect(evt.type).toEqual(type); + if (type !== 'exit') { // `exit` event does not have url field + expect(evt.url).toEqual(url); + } + } + + function verifyLoadErrorEvent(evt) { + expect(evt).toBeDefined(); + expect(evt.type).toEqual('loaderror'); + expect(evt.url).toEqual(badUrl); + expect(evt.code).toEqual(jasmine.any(Number)); + expect(evt.message).toEqual(jasmine.any(String)); + } + + it("inappbrowser.spec.3 should retun InAppBrowser instance with required methods", function () { + iabInstance = cordova.InAppBrowser.open(url, '_blank'); + + expect(iabInstance).toBeDefined(); + + expect(iabInstance.addEventListener).toEqual(jasmine.any(Function)); + expect(iabInstance.removeEventListener).toEqual(jasmine.any(Function)); + expect(iabInstance.close).toEqual(jasmine.any(Function)); + expect(iabInstance.show).toEqual(jasmine.any(Function)); + expect(iabInstance.executeScript).toEqual(jasmine.any(Function)); + expect(iabInstance.insertCSS).toEqual(jasmine.any(Function)); + }); + + it("inappbrowser.spec.4 should support loadstart and loadstop events", function (done) { + var onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) { + verifyEvent(evt, 'loadstart'); + }); + + iabInstance = cordova.InAppBrowser.open(url, '_blank'); + iabInstance.addEventListener('loadstart', onLoadStart); + iabInstance.addEventListener('loadstop', function (evt) { + verifyEvent(evt, 'loadstop'); + expect(onLoadStart).toHaveBeenCalled(); + done(); + }); + }); + + it("inappbrowser.spec.5 should support exit event", function (done) { + iabInstance = cordova.InAppBrowser.open(url, '_blank'); + iabInstance.addEventListener('exit', function (evt) { + verifyEvent(evt, 'exit'); + done(); + }); + iabInstance.close(); + iabInstance = null; + }); + + it("inappbrowser.spec.6 should support loaderror event", function (done) { + iabInstance = cordova.InAppBrowser.open(badUrl, '_blank'); + iabInstance.addEventListener('loaderror', function (evt) { + verifyLoadErrorEvent(evt); + done(); + }); + }); + }); +}; + exports.defineManualTests = function (contentEl, createActionButton) { function doOpen(url, target, params, numExpectedRedirects, useWindowOpen) { @@ -79,13 +186,13 @@ exports.defineManualTests = function (contentEl, createActionButton) { if (e.url != lastLoadStartURL) { alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url'); } - if (numExpectedRedirects === 0 && counts['loadstart'] !== 1) { + if (numExpectedRedirects === 0 && counts.loadstart !== 1) { // Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL). - if (!(e.type == 'loaderror' && counts['loadstart'] === 0)) { - alert('Unexpected: got multiple loadstart events. (' + counts['loadstart'] + ')'); + if (!(e.type == 'loaderror' && counts.loadstart === 0)) { + alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')'); } - } else if (numExpectedRedirects > 0 && counts['loadstart'] < (numExpectedRedirects + 1)) { - alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts['loadstart']); + } else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) { + alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart); } wasReset = true; numExpectedRedirects = 0; @@ -93,7 +200,7 @@ exports.defineManualTests = function (contentEl, createActionButton) { } // Verify that loadend / loaderror was called. if (e.type == 'exit') { - var numStopEvents = counts['loadstop'] + counts['loaderror']; + var numStopEvents = counts.loadstop + counts.loaderror; if (numStopEvents === 0 && !wasReset) { alert('Unexpected: browser closed without a loadstop or loaderror.'); } else if (numStopEvents > 1) { @@ -319,7 +426,11 @@ exports.defineManualTests = function (contentEl, createActionButton) { var video_tag_tests = '

Video tag

' + '
' + - 'Expected result: open successfully in InAppBrowser with an embedded video that works after clicking the "play" button.'; + 'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' + + '
' + + 'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' + + '
' + + 'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.'; var local_with_anchor_tag_tests = '

Local with anchor tag

' + '
' + @@ -327,16 +438,24 @@ exports.defineManualTests = function (contentEl, createActionButton) { '

' + 'Expected result: open successfully in InAppBrowser to the local page, scrolled to the beginning of the tall div with border.'; + var hardwareback_tests = '

HardwareBack

' + + '

' + + 'Expected result: By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' + + '

' + + 'Expected result: hardwareback=yes pressing back button should navigate backwards in history then close InAppBrowser' + + '

' + + 'Expected result: hardwareback=no pressing back button should close InAppBrowser regardless history'; + // CB-7490 We need to wrap this code due to Windows security restrictions // see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details if (window.MSApp && window.MSApp.execUnsafeLocalFunction) { MSApp.execUnsafeLocalFunction(function() { contentEl.innerHTML = info_div + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests + - css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests; + css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests; }); } else { contentEl.innerHTML = info_div + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests + - css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests; + css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests; } document.getElementById("user-agent").textContent = navigator.userAgent; @@ -507,6 +626,12 @@ exports.defineManualTests = function (contentEl, createActionButton) { createActionButton('Remote Video', function () { doOpen(videohtml, '_blank'); }, 'openRemoteVideo'); + createActionButton('Remote Need User No Video', function () { + doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=no'); + }, 'openRemoteNeedUserNoVideo'); + createActionButton('Remote Need User Yes Video', function () { + doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes'); + }, 'openRemoteNeedUserYesVideo'); //Local With Anchor Tag createActionButton('Anchor1', function () { @@ -515,5 +640,15 @@ exports.defineManualTests = function (contentEl, createActionButton) { createActionButton('Anchor2', function () { doOpen(localhtml + '#anchor2', '_blank'); }, 'openAnchor2'); -}; + // Hardwareback + createActionButton('no hardwareback (defaults to yes)', function () { + doOpen('http://cordova.apache.org', '_blank'); + }, 'openHardwareBackDefault'); + createActionButton('hardwareback=yes', function () { + doOpen('http://cordova.apache.org', '_blank', 'hardwareback=yes'); + }, 'openHardwareBackYes'); + createActionButton('hardwareback=no', function () { + doOpen('http://cordova.apache.org', '_blank', 'hardwareback=no'); + }, 'openHardwareBackNo'); +}; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css old mode 100755 new mode 100644 index bd1526d3..5762c746 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css @@ -38,3 +38,77 @@ .inAppBrowserWrapFullscreen { border: 0; } + +.inappbrowser-app-bar { + height: 70px; + background-color: #404040; + z-index: 9999999; +} + +.inappbrowser-app-bar-inner { + padding-top: 10px; + height: 60px; + width: 155px; + margin: 0 auto; + background-color: #404040; + z-index: 9999999; +} + +.app-bar-action { + width: auto; + height: 40px; + margin-left: 20px; + font-family: "Segoe UI Symbol"; + float: left; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; +} + +.app-bar-action[disabled] { + color: gray; + /*disable click*/ + pointer-events: none; +} + +.app-bar-action::before { + font-size: 28px; + display: block; + height: 36px; +} + +/* Back */ +.action-back { + margin-left: 0px; +} + +.action-back::before { + content: "\E0BA"; +} + +.action-back:not([disabled]):hover::before { + content: "\E0B3"; +} + +/* Forward */ +.action-forward::before { + content: "\E0AC"; +} + +.action-forward:not([disabled]):hover::before { + content: "\E0AF"; +} + +/* Close */ +.action-close::before { + content: "\E0C7"; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; +} + +.action-close:not([disabled]):hover::before { + content: "\E0CA"; +} diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js old mode 100755 new mode 100644 index 93eb4207..25f62711 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js @@ -19,92 +19,93 @@ * */ -// special patch to correctly work on Ripple emulator (CB-9760) -if (window.parent && !!window.parent.ripple) { // https://gist.github.com/triceam/4658021 - module.exports = window.open.bind(window); // fallback to default window.open behaviour - return; -} +(function() { + // special patch to correctly work on Ripple emulator (CB-9760) + if (window.parent && !!window.parent.ripple) { // https://gist.github.com/triceam/4658021 + module.exports = window.open.bind(window); // fallback to default window.open behaviour + return; + } -var exec = require('cordova/exec'); -var channel = require('cordova/channel'); -var modulemapper = require('cordova/modulemapper'); -var urlutil = require('cordova/urlutil'); + var exec = require('cordova/exec'); + var channel = require('cordova/channel'); + var modulemapper = require('cordova/modulemapper'); + var urlutil = require('cordova/urlutil'); -function InAppBrowser() { - this.channels = { - 'loadstart': channel.create('loadstart'), - 'loadstop' : channel.create('loadstop'), - 'loaderror' : channel.create('loaderror'), - 'exit' : channel.create('exit') - }; -} + function InAppBrowser() { + this.channels = { + 'loadstart': channel.create('loadstart'), + 'loadstop' : channel.create('loadstop'), + 'loaderror' : channel.create('loaderror'), + 'exit' : channel.create('exit') + }; + } -InAppBrowser.prototype = { - _eventHandler: function (event) { - if (event && (event.type in this.channels)) { - this.channels[event.type].fire(event); - } - }, - close: function (eventname) { - exec(null, null, "InAppBrowser", "close", []); - }, - show: function (eventname) { - exec(null, null, "InAppBrowser", "show", []); - }, - addEventListener: function (eventname,f) { - if (eventname in this.channels) { - this.channels[eventname].subscribe(f); - } - }, - removeEventListener: function(eventname, f) { - if (eventname in this.channels) { - this.channels[eventname].unsubscribe(f); - } - }, + InAppBrowser.prototype = { + _eventHandler: function (event) { + if (event && (event.type in this.channels)) { + this.channels[event.type].fire(event); + } + }, + close: function (eventname) { + exec(null, null, "InAppBrowser", "close", []); + }, + show: function (eventname) { + exec(null, null, "InAppBrowser", "show", []); + }, + addEventListener: function (eventname,f) { + if (eventname in this.channels) { + this.channels[eventname].subscribe(f); + } + }, + removeEventListener: function(eventname, f) { + if (eventname in this.channels) { + this.channels[eventname].unsubscribe(f); + } + }, - executeScript: function(injectDetails, cb) { - if (injectDetails.code) { - exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]); - } else if (injectDetails.file) { - exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]); - } else { - throw new Error('executeScript requires exactly one of code or file to be specified'); - } - }, + executeScript: function(injectDetails, cb) { + if (injectDetails.code) { + exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]); + } else if (injectDetails.file) { + exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]); + } else { + throw new Error('executeScript requires exactly one of code or file to be specified'); + } + }, - insertCSS: function(injectDetails, cb) { - if (injectDetails.code) { - exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]); - } else if (injectDetails.file) { - exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]); - } else { - throw new Error('insertCSS requires exactly one of code or file to be specified'); + insertCSS: function(injectDetails, cb) { + if (injectDetails.code) { + exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]); + } else if (injectDetails.file) { + exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]); + } else { + throw new Error('insertCSS requires exactly one of code or file to be specified'); + } } - } -}; - -module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) { - // Don't catch calls that write to existing frames (e.g. named iframes). - if (window.frames && window.frames[strWindowName]) { - var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); - return origOpenFunc.apply(window, arguments); - } + }; - strUrl = urlutil.makeAbsolute(strUrl); - var iab = new InAppBrowser(); + module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) { + // Don't catch calls that write to existing frames (e.g. named iframes). + if (window.frames && window.frames[strWindowName]) { + var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); + return origOpenFunc.apply(window, arguments); + } - callbacks = callbacks || {}; - for (var callbackName in callbacks) { - iab.addEventListener(callbackName, callbacks[callbackName]); - } + strUrl = urlutil.makeAbsolute(strUrl); + var iab = new InAppBrowser(); - var cb = function(eventname) { - iab._eventHandler(eventname); - }; + callbacks = callbacks || {}; + for (var callbackName in callbacks) { + iab.addEventListener(callbackName, callbacks[callbackName]); + } - strWindowFeatures = strWindowFeatures || ""; + var cb = function(eventname) { + iab._eventHandler(eventname); + }; - exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); - return iab; -}; + strWindowFeatures = strWindowFeatures || ""; + exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); + return iab; + }; +})(); diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js old mode 100755 new mode 100644 index 42d15d2c..ed954770 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js @@ -22,10 +22,6 @@ /*jslint sloppy:true */ /*global Windows:true, require, document, setTimeout, window, module */ - -var cordova = require('cordova'), - channel = require('cordova/channel'); - var browserWrap; var IAB = { @@ -45,7 +41,6 @@ var IAB = { open: function (win, lose, args) { var strUrl = args[0], target = args[1], - features = args[2], url, elem; diff --git a/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md old mode 100755 new mode 100644 index f7dbcaba..4c8e6a5e --- a/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-network-information/LICENSE b/StoneIsland/plugins/cordova-plugin-network-information/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/NOTICE b/StoneIsland/plugins/cordova-plugin-network-information/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/README.md b/StoneIsland/plugins/cordova-plugin-network-information/README.md old mode 100755 new mode 100644 index c78f3b02..394058c4 --- a/StoneIsland/plugins/cordova-plugin-network-information/README.md +++ b/StoneIsland/plugins/cordova-plugin-network-information/README.md @@ -1,3 +1,7 @@ +--- +title: Network Information +description: Get information about wireless connectivity. +--- +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-network-information/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-network-information)| + # cordova-plugin-network-information -[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information) This plugin provides an implementation of an old version of the [Network Information API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). It provides information about the device's cellular and wifi connection, and whether the device has an internet connection. +> To get a few ideas how to use the plugin, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content. + +Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cordova issue tracker]. + +##Reference + ## Installation cordova plugin add cordova-plugin-network-information @@ -68,24 +81,25 @@ connection state, and type of connection. ### Quick Example - function checkConnection() { - var networkState = navigator.connection.type; +```js +function checkConnection() { + var networkState = navigator.connection.type; - var states = {}; - states[Connection.UNKNOWN] = 'Unknown connection'; - states[Connection.ETHERNET] = 'Ethernet connection'; - states[Connection.WIFI] = 'WiFi connection'; - states[Connection.CELL_2G] = 'Cell 2G connection'; - states[Connection.CELL_3G] = 'Cell 3G connection'; - states[Connection.CELL_4G] = 'Cell 4G connection'; - states[Connection.CELL] = 'Cell generic connection'; - states[Connection.NONE] = 'No network connection'; + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL] = 'Cell generic connection'; + states[Connection.NONE] = 'No network connection'; - alert('Connection type: ' + states[networkState]); - } - - checkConnection(); + alert('Connection type: ' + states[networkState]); +} +checkConnection(); +``` ### API Change @@ -97,7 +111,7 @@ eventually be removed. ### iOS Quirks -- iOS can't detect the type of cellular network connection. +- + +The code examples in this section show examples of changing app behavior using the online and offline events and your network connection status. + +To start with, create a new FileEntry object (data.txt) to use for sample data. Call this function from the `deviceready` handler. + +>*Note* This code example requires the File plugin. + +```js +var dataFileEntry; + +function createSomeData() { + + window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs) { + + console.log('file system open: ' + fs.name); + // Creates a new file or returns an existing file. + fs.root.getFile("data.txt", { create: true, exclusive: false }, function (fileEntry) { + + dataFileEntry = fileEntry; + + }, onErrorCreateFile); + + }, onErrorLoadFs); +} +``` + +Next, add listeners for the online and offline events in the `deviceready` handler. + +```js +document.addEventListener("offline", onOffline, false); +document.addEventListener("online", onOnline, false); +``` + +The app's `onOnline` function handles the online event. In the event handler, check the current network state. In this app, treat any connection type as good except Connection.NONE. If you have a connection, you try to upload a file. + +```js +function onOnline() { + // Handle the online event + var networkState = navigator.connection.type; + + if (networkState !== Connection.NONE) { + if (dataFileEntry) { + tryToUploadFile(); + } + } + display('Connection type: ' + networkState); +} +``` + +When the online event fires in the preceding code, call the app's `tryToUploadFile` function. + +If the FileTransfer object's upload function fails, call the app's `offlineWrite` function to save the current data somewhere. + +>*Note* This example requires the FileTransfer plugin. + +```js +function tryToUploadFile() { + // !! Assumes variable fileURL contains a valid URL to a text file on the device, + var fileURL = getDataFileEntry().toURL(); + + var success = function (r) { + console.log("Response = " + r.response); + display("Uploaded. Response: " + r.response); + } + + var fail = function (error) { + console.log("An error has occurred: Code = " + error.code); + offlineWrite("Failed to upload: some offline data"); + } + + var options = new FileUploadOptions(); + options.fileKey = "file"; + options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1); + options.mimeType = "text/plain"; + + var ft = new FileTransfer(); + // Make sure you add the domain of your server URL to the + // Content-Security-Policy element in index.html. + ft.upload(fileURL, encodeURI(SERVER), success, fail, options); +}; +``` + +Here is the code for the `offlineWrite` function. + +>*Note* This code examples requires the File plugin. + +```js +function offlineWrite(offlineData) { + // Create a FileWriter object for our FileEntry. + dataFileEntry.createWriter(function (fileWriter) { + + fileWriter.onwriteend = function () { + console.log("Successful file write..."); + display(offlineData); + }; + + fileWriter.onerror = function (e) { + console.log("Failed file write: " + e.toString()); + }; + + fileWriter.write(offlineData); + }); +} +``` + +If the offline event occurs, just do something like notify the user (for this example, just log it). + +```js +function onOffline() { + // Handle the offline event + console.log("lost connection"); +} +``` + +[Apache Cordova issue tracker]: https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Network%20Information%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC diff --git a/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md old mode 100755 new mode 100644 index 06bc5090..7ff57bd6 --- a/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md @@ -20,97 +20,128 @@ --> # Release Notes -### 0.2.1 (Sept 5, 2013) -* CB-4432 copyright notice change +### 1.3.0 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* [CB-11734](https://issues.apache.org/jira/browse/CB-11734) Network Plugin uses `Android Log class` and not `Cordova LOG class` +* [CB-11300](https://issues.apache.org/jira/browse/CB-11300) (**android**) Recognize `2G`, `3G` and `4G` network connection subtype names +* Update `NetworkManager.java` +* Detection of Ethernet Network Type on **Android** +* fixed two potential memory leaks when doing Analyze on **iOS 9** +* [CB-11384](https://issues.apache.org/jira/browse/CB-11384) **android**: Does not pass sonarqube scan +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* Readme: Add fenced code blocks with langauage hints +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md + +### 1.2.1 (Apr 15, 2016) +* [CB-10763](https://issues.apache.org/jira/browse/CB-10763) Remove emoji in `cordova-plugin-network-information` +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins + +### 1.2.0 (Jan 15, 2016) +* Adding `CoreTelephony` to `plugin.xml` +* Adding notification for `CT radio` information +* Adding `CT radio` information +* [CB-10160](https://issues.apache.org/jira/browse/CB-10160) Fixed the case mismatch issue + +### 1.1.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* Fixing contribute link. +* These notifications are objects so their address always evaluates to true. +* Update `NetworkManager.java` +* [CB-9542](https://issues.apache.org/jira/browse/CB-9542) `Browser Proxy` not defined correctly +* Solved `toLowerCase` issue with `Locale.US` -### 0.2.3 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* [windows8] commandProxy was moved -* CB-4889 renaming org.apache.cordova.core.network-information to org.apache.cordova.network-information -* removed duplicate comment line from plugin.xml -* added Network APIs for FirefoxOS -* Rename CHANGELOG.md -> RELEASENOTES.md -* [CB-4752] Incremented plugin version on dev branch. +### 1.0.1 (Jun 17, 2015) +* Adding .ratignore file. +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-network-information documentation translation: cordova-plugin-network-information +* fix npm md issue -### 0.2.4 (Oct 28, 2013) -* CB-5128: add repo + issue tag to plugin.xml for network information plugin -* [CB-4915] Incremented plugin version on dev branch. +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Fixes typo in `cordova.platformId` +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Use `navigator.onLine` as connection information source on browser platform +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of initWebView method +* [CB-8573](https://issues.apache.org/jira/browse/CB-8573) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-network-information documentation translation: cordova-plugin-network-information +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file -### 0.2.5 (Dec 4, 2013) -* [ubuntu] specify policy_group -* add ubuntu platform -* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos' +### 0.2.15 (Feb 04, 2015) +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Network status change support on Windows +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Fixes the way we detect online status on Windows +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows platform quirks +* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows section to Network Information plugin -### 0.2.6 (Jan 02, 2014) -* CB-5658 Add doc/index.md for netinfo plugin +### 0.2.14 (Dec 02, 2014) +* [CB-7976](https://issues.apache.org/jira/browse/CB-7976) **Android**: Use webView's context rather than Activity's context for intent receiver +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-network-information documentation translation: cordova-plugin-network-information -### 0.2.7 (Feb 05, 2014) -* Initial implementation of Tizen plugin. +### 0.2.13 (Oct 03, 2014) +* [CB-7595](https://issues.apache.org/jira/browse/CB-7595): Android L changes the type from Mobile to Cellular, I'm pretty sure this isn't documented -### 0.2.8 (Apr 17, 2014) -* CB-6342: [iOS] iOS reports a cellular connection even when in Airplane mode -* CB-6422: [windows8] use cordova/exec/proxy -* CB-6460: Update license headers -* CB-6465: Add license headers to Tizen code -* Add NOTICE file +### 0.2.12 (Sep 17, 2014) +* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-network-information documentation translation +* Fix network information type exception on fxos 2 +* Added support for the browser +* [CB-6724](https://issues.apache.org/jira/browse/CB-6724) added documentation for manual tests +* remove reference to test assets, they are optional +* Renamed test dir and added nested plugin.xml +* [CB-6964](https://issues.apache.org/jira/browse/CB-6964) ported manual tests +* Port network tests to plugin-test-framework +* Fix naviagtor typo + +### 0.2.11 (Aug 06, 2014) +* **FFOS** update NetworkProxy.js +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs +* [CB-7019](https://issues.apache.org/jira/browse/CB-7019) Updated version and RELEASENOTES.md for release 0.2.10 +* Fixed docs for online/offline event being backwards + +### 0.2.10 (Jun 24, 2014) +* [CB-6907](https://issues.apache.org/jira/browse/CB-6907): [android] Don't crash on startup if no networks available ### 0.2.9 (Jun 05, 2014) * updated notice file to include missing license * Cached extra info to better detect changes. -* CB-6809 Add license to CONTRIBUTING.md -* CB-6491 add CONTRIBUTING.md -* CB-6350 - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8) +* [CB-6809](https://issues.apache.org/jira/browse/CB-6809) Add license to CONTRIBUTING.md +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md +* [CB-6350](https://issues.apache.org/jira/browse/CB-6350) - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8) * Initial version of firefox os network information plugin * there was an error in the object definition -### 0.2.10 (Jun 24, 2014) -* CB-6907: [android] Don't crash on startup if no networks available - -### 0.2.11 (Aug 06, 2014) -* **FFOS** update NetworkProxy.js -* CB-6127 Updated translations for docs -* CB-7019 Updated version and RELEASENOTES.md for release 0.2.10 -* Fixed docs for online/offline event being backwards +### 0.2.8 (Apr 17, 2014) +* [CB-6342](https://issues.apache.org/jira/browse/CB-6342): [iOS] iOS reports a cellular connection even when in Airplane mode +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code +* Add NOTICE file -### 0.2.12 (Sep 17, 2014) -* CB-7471 cordova-plugin-network-information documentation translation -* Fix network information type exception on fxos 2 -* Added support for the browser -* CB-6724 added documentation for manual tests -* remove reference to test assets, they are optional -* Renamed test dir and added nested plugin.xml -* CB-6964 ported manual tests -* Port network tests to plugin-test-framework -* Fix naviagtor typo +### 0.2.7 (Feb 05, 2014) +* Initial implementation of Tizen plugin. -### 0.2.13 (Oct 03, 2014) -* CB-7595: Android L changes the type from Mobile to Cellular, I'm pretty sure this isn't documented +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for netinfo plugin -### 0.2.14 (Dec 02, 2014) -* CB-7976 **Android**: Use webView's context rather than Activity's context for intent receiver -* CB-7700 cordova-plugin-network-information documentation translation: cordova-plugin-network-information +### 0.2.5 (Dec 4, 2013) +* [ubuntu] specify policy_group +* add ubuntu platform +* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos' -### 0.2.15 (Feb 04, 2015) -* CB-8384 Network status change support on Windows -* CB-8384 Fixes the way we detect online status on Windows -* CB-8384 Add Windows platform quirks -* CB-8384 Add Windows section to Network Information plugin +### 0.2.4 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to plugin.xml for network information plugin +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. -### 1.0.0 (Apr 15, 2015) -* CB-8746 gave plugin major version bump -* CB-8683 changed plugin-id to pacakge-name -* CB-8653 properly updated translated docs to use new id -* CB-8653 updated translated docs to use new id -* CB-8185 Fixes typo in `cordova.platformId` -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* CB-8185 Use `navigator.onLine` as connection information source on browser platform -* CB-8653 Updated Readme -* CB-8659: ios: 4.0.x Compatibility: Remove use of initWebView method -* CB-8573 Integrate TravisCI -* CB-8438 cordova-plugin-network-information documentation translation: cordova-plugin-network-information -* CB-8538 Added package.json file +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [windows8] commandProxy was moved +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.network-information to org.apache.cordova.network-information +* removed duplicate comment line from plugin.xml +* added Network APIs for FirefoxOS +* Rename CHANGELOG.md -> RELEASENOTES.md +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. -### 1.0.1 (Jun 17, 2015) -* Adding .ratignore file. -* CB-9128 cordova-plugin-network-information documentation translation: cordova-plugin-network-information -* fix npm md issue +### 0.2.1 (Sept 5, 2013) +* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/package.json b/StoneIsland/plugins/cordova-plugin-network-information/package.json old mode 100755 new mode 100644 index 452db88b..fd804b86 --- a/StoneIsland/plugins/cordova-plugin-network-information/package.json +++ b/StoneIsland/plugins/cordova-plugin-network-information/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-network-information", - "version": "1.0.1", + "version": "1.3.0", "description": "Cordova Network Information Plugin", "cordova": { "id": "cordova-plugin-network-information", @@ -41,6 +41,20 @@ "cordova-tizen", "cordova-browser" ], + "scripts": { + "test": "npm run jshint", + "jshint": "jshint www && jshint src && jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "engines": { + "cordovaDependencies": { + "2.0.0": { + "cordova": ">100" + } + } + }, + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-network-information/plugin.xml b/StoneIsland/plugins/cordova-plugin-network-information/plugin.xml old mode 100755 new mode 100644 index e0ed97fc..29922293 --- a/StoneIsland/plugins/cordova-plugin-network-information/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-network-information/plugin.xml @@ -21,7 +21,7 @@ + version="1.3.0"> Network Information Cordova Network Information Plugin @@ -103,6 +103,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" + @@ -146,14 +147,14 @@ xmlns:android="http://schemas.android.com/apk/res/android" - + - + @@ -166,9 +167,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" - - - + + diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java b/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java index 4c85ddab..614b6e7b 100755 --- a/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java @@ -21,6 +21,7 @@ package org.apache.cordova.networkinformation; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaInterface; import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.LOG; import org.apache.cordova.PluginResult; import org.apache.cordova.CordovaWebView; import org.json.JSONArray; @@ -33,7 +34,8 @@ import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.util.Log; + +import java.util.Locale; public class NetworkManager extends CordovaPlugin { @@ -45,14 +47,16 @@ public class NetworkManager extends CordovaPlugin { public static final String WIMAX = "wimax"; // mobile public static final String MOBILE = "mobile"; - - // Android L calls this Cellular, because I have no idea! + + // Android L calls this Cellular, because I have no idea! public static final String CELLULAR = "cellular"; // 2G network types + public static final String TWO_G = "2g"; public static final String GSM = "gsm"; public static final String GPRS = "gprs"; public static final String EDGE = "edge"; // 3G network types + public static final String THREE_G = "3g"; public static final String CDMA = "cdma"; public static final String UMTS = "umts"; public static final String HSPA = "hspa"; @@ -61,12 +65,14 @@ public class NetworkManager extends CordovaPlugin { public static final String ONEXRTT = "1xrtt"; public static final String EHRPD = "ehrpd"; // 4G network types + public static final String FOUR_G = "4g"; public static final String LTE = "lte"; public static final String UMB = "umb"; public static final String HSPA_PLUS = "hspa+"; // return type public static final String TYPE_UNKNOWN = "unknown"; public static final String TYPE_ETHERNET = "ethernet"; + public static final String TYPE_ETHERNET_SHORT = "eth"; public static final String TYPE_WIFI = "wifi"; public static final String TYPE_2G = "2g"; public static final String TYPE_3G = "3g"; @@ -125,7 +131,9 @@ public class NetworkManager extends CordovaPlugin { String connectionType = ""; try { connectionType = this.getConnectionInfo(info).get("type").toString(); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, connectionType); pluginResult.setKeepCallback(true); @@ -143,7 +151,7 @@ public class NetworkManager extends CordovaPlugin { try { webView.getContext().unregisterReceiver(this.receiver); } catch (Exception e) { - Log.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e); + LOG.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e); } finally { receiver = null; } @@ -169,7 +177,9 @@ public class NetworkManager extends CordovaPlugin { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } sendUpdate(connectionType); lastInfo = thisInfo; @@ -196,15 +206,17 @@ public class NetworkManager extends CordovaPlugin { extraInfo = info.getExtraInfo(); } - Log.d("CordovaNetworkManager", "Connection Type: " + type); - Log.d("CordovaNetworkManager", "Connection Extra Info: " + extraInfo); + LOG.d(LOG_TAG, "Connection Type: " + type); + LOG.d(LOG_TAG, "Connection Extra Info: " + extraInfo); JSONObject connectionInfo = new JSONObject(); try { connectionInfo.put("type", type); connectionInfo.put("extraInfo", extraInfo); - } catch (JSONException e) { } + } catch (JSONException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } return connectionInfo; } @@ -231,30 +243,38 @@ public class NetworkManager extends CordovaPlugin { */ private String getType(NetworkInfo info) { if (info != null) { - String type = info.getTypeName(); + String type = info.getTypeName().toLowerCase(Locale.US); - if (type.toLowerCase().equals(WIFI)) { + LOG.d(LOG_TAG, "toLower : " + type.toLowerCase()); + LOG.d(LOG_TAG, "wifi : " + WIFI); + if (type.equals(WIFI)) { return TYPE_WIFI; } - else if (type.toLowerCase().equals(MOBILE) || type.toLowerCase().equals(CELLULAR)) { - type = info.getSubtypeName(); - if (type.toLowerCase().equals(GSM) || - type.toLowerCase().equals(GPRS) || - type.toLowerCase().equals(EDGE)) { + else if (type.toLowerCase().equals(TYPE_ETHERNET) || type.toLowerCase().startsWith(TYPE_ETHERNET_SHORT)) { + return TYPE_ETHERNET; + } + else if (type.equals(MOBILE) || type.equals(CELLULAR)) { + type = info.getSubtypeName().toLowerCase(Locale.US); + if (type.equals(GSM) || + type.equals(GPRS) || + type.equals(EDGE) || + type.equals(TWO_G)) { return TYPE_2G; } - else if (type.toLowerCase().startsWith(CDMA) || - type.toLowerCase().equals(UMTS) || - type.toLowerCase().equals(ONEXRTT) || - type.toLowerCase().equals(EHRPD) || - type.toLowerCase().equals(HSUPA) || - type.toLowerCase().equals(HSDPA) || - type.toLowerCase().equals(HSPA)) { + else if (type.startsWith(CDMA) || + type.equals(UMTS) || + type.equals(ONEXRTT) || + type.equals(EHRPD) || + type.equals(HSUPA) || + type.equals(HSDPA) || + type.equals(HSPA) || + type.equals(THREE_G)) { return TYPE_3G; } - else if (type.toLowerCase().equals(LTE) || - type.toLowerCase().equals(UMB) || - type.toLowerCase().equals(HSPA_PLUS)) { + else if (type.equals(LTE) || + type.equals(UMB) || + type.equals(HSPA_PLUS) || + type.equals(FOUR_G)) { return TYPE_4G; } } diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js b/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js old mode 100755 new mode 100644 index d47d840e..c6cd00a9 --- a/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js @@ -19,6 +19,8 @@ * */ +/* global PluginResult */ + //map from BB10 to cordova connection types: //https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js function mapConnectionType(con) { diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js b/StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js new file mode 100644 index 00000000..8a6ddb0e --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var cordova = require('cordova'), + proxy = require("cordova/exec/proxy"), + Connection = require('./Connection'); + +var type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + +// Subscribe to 'native' online/offline events +function onStatusChange(evt) { + type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; + // force async + setTimeout(function(){ + cordova.fireDocumentEvent(evt.type); + },0); +} + +window.addEventListener('online', onStatusChange); +window.addEventListener('offline', onStatusChange); + +proxy.add("NetworkStatus", { + getConnectionInfo:function(cbSuccess) { + // force async + setTimeout(function(){ + cbSuccess(type); + },0); + } +}); + + diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js b/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js old mode 100755 new mode 100644 index 40d61637..8c82557d --- a/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js @@ -24,8 +24,7 @@ and http://w3c.github.io/netinfo/ */ -var cordova = require('cordova'), - Connection = require('./Connection'), +var Connection = require('./Connection'), modulemapper = require('cordova/modulemapper'); var origConnection = modulemapper.getOriginalSymbol(window, 'navigator.connection'); @@ -47,7 +46,7 @@ module.exports = { metered = connection.metered, type = connection.type; - if (type != undefined) { + if (type !== undefined) { // For more information see: // https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API @@ -65,7 +64,7 @@ module.exports = { connectionType = Connection.NONE; break; } - } else if (bandwidth != undefined && metered != undefined) { + } else if (bandwidth !== undefined && metered !== undefined) { /* bandwidth of type double, readonly The user agent must set the value of the bandwidth attribute to: diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m old mode 100755 new mode 100644 index 37497675..6715322a --- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m @@ -16,6 +16,7 @@ specific language governing permissions and limitations under the License. */ +#import #import "CDVConnection.h" #import "CDVReachability.h" @@ -57,6 +58,32 @@ if (isConnectionRequired) { return @"none"; } else { + if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) { + CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new]; + if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) { + return @"2g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) { + return @"2g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) { + return @"4g"; + } + } return @"cellular"; } } @@ -118,7 +145,9 @@ [self.internetReach startNotifier]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:) name:kReachabilityChangedNotification object:nil]; - if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:) + name:CTRadioAccessTechnologyDidChangeNotification object:nil]; + if (UIApplicationDidEnterBackgroundNotification && UIApplicationWillEnterForegroundNotification) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil]; } diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m old mode 100755 new mode 100644 index c60261ae..1399867e --- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m @@ -142,6 +142,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe retVal->reachabilityRef = reachability; retVal->localWiFiRef = NO; } + else { + CFRelease(reachability); + } } return retVal; } @@ -156,6 +159,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe retVal->reachabilityRef = reachability; retVal->localWiFiRef = NO; } + else { + CFRelease(reachability); + } } return retVal; } diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js b/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js old mode 100755 new mode 100644 index cd9506e1..d2de2ccc --- a/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js @@ -19,7 +19,8 @@ * */ -var cordova = require('cordova'); +/* global tizen */ + var Connection = require('./Connection'); module.exports = { diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp b/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js b/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js old mode 100755 new mode 100644 index 27ad2f06..92153c7b --- a/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js @@ -21,15 +21,10 @@ /*global Windows:true */ -var cordova = require('cordova'); var Connection = require('./Connection'); var winNetConn = Windows.Networking.Connectivity; var networkInfo = winNetConn.NetworkInformation; -var networkCostInfo = winNetConn.NetworkCostType; -var networkConnectivityInfo = winNetConn.NetworkConnectivityLevel; -var networkAuthenticationInfo = winNetConn.NetworkAuthenticationType; -var networkEncryptionInfo = winNetConn.NetworkEncryptionType; function getCurrrentConnectionType() { @@ -76,7 +71,7 @@ module.exports = { { var reportConnectionInfoOnce = function () { win(getCurrrentConnectionType(), { keepCallback: true }); - } + }; // report current connection type setTimeout(reportConnectionInfoOnce, 0); diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs b/StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml old mode 100755 new mode 100644 index 8df4769c..c4b03c26 --- a/StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml @@ -21,7 +21,7 @@ + version="1.3.0"> Cordova Network Information Plugin Tests Apache 2.0 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js b/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js old mode 100755 new mode 100644 index 23be97ac..07f4b27f --- a/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js @@ -19,6 +19,9 @@ * */ +/* jshint jasmine: true */ +/* global Connection */ + exports.defineAutoTests = function () { describe('Network (navigator.connection)', function () { it("network.spec.1 should exist", function () { diff --git a/StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js b/StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js b/StoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js deleted file mode 100755 index 72ec5139..00000000 --- a/StoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/*global module, require*/ - -var cordova = require('cordova'), - Connection = require('./Connection'); - -var DOCUMENT_EVENTS_CHECK_INTERVAL = 500; // ms -// Flag that indicates that ew need to re-fire online/offline events at document level -// (Workaround for Chrome, since it fires such events only for window object) -var NEED_FIRE_DOCUMENT_EVENT_MANUALLY = false; - -function NetworkConnection() { - this.type = Connection.UNKNOWN; -} - -/** - * Get connection info - * - * @param {Function} successCallback The function to call when the Connection data is available - */ -NetworkConnection.prototype.getInfo = function(successCallback) { - successCallback(this.type); -}; - -Object.defineProperty(NetworkConnection.prototype, 'type', { - get: function () { - // It is not possible to determine real connection type in browser - // so we always report Connection.UNKNOWN when online - return (window.navigator.onLine === false ? Connection.NONE : Connection.UNKNOWN); - }, - configurable: true, - enumerable: true -}); - -// This function tries to detect if document online/offline events is being fired -// after corresponding window events, and if not, then fires them manually -// This is workaround for Chrome, which fires only window online/offline events -// and regarding to plugin spec we need these events at document object -var eventRedirectHandler = function (e) { - // NEED_FIRE_DOCUMENT_EVENT_MANUALLY flag is already set, - // just fire corresponding document event and return - if (NEED_FIRE_DOCUMENT_EVENT_MANUALLY) { - cordova.fireDocumentEvent(e.type); - return; - } - - // Flag that indicates whether corresponding document even is fired - var documentStateEventFired = false; - var setDocumentStateEventFired = function() { - documentStateEventFired = true; - }; - document.addEventListener(e.type, setDocumentStateEventFired); - setTimeout(function () { - // Remove unnecessary listener - document.removeEventListener(e.type, setDocumentStateEventFired); - // if document event hasn't been fired in specified interval (500 ms by default), - // then we're in chrome and need to fire it manually - if (!documentStateEventFired) { - NEED_FIRE_DOCUMENT_EVENT_MANUALLY = true; - cordova.fireDocumentEvent(e.type); - } - }, DOCUMENT_EVENTS_CHECK_INTERVAL); -}; - -// Subscribe to native online/offline events -window.addEventListener('online', eventRedirectHandler); -window.addEventListener('offline', eventRedirectHandler); - -var me = new NetworkConnection(); - -require("cordova/exec/proxy").add("NetworkStatus", { getConnectionInfo: me.getConnectionInfo }); - -module.exports = me; diff --git a/StoneIsland/plugins/cordova-plugin-network-information/www/network.js b/StoneIsland/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/README.md b/StoneIsland/plugins/cordova-plugin-splashscreen/README.md index ff790b16..6a6faaf9 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/README.md +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/README.md @@ -1,3 +1,7 @@ +--- +title: Splashscreen +description: Control the splash screen for your app. +--- +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-splashscreen)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-splashscreen/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-splashscreen)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-splashscreen/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-splashscreen)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-splashscreen/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-splashscreen)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-splashscreen/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-splashscreen)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-splashscreen/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-splashscreen.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-splashscreen)| + # cordova-plugin-splashscreen -This plugin displays and hides a splash screen during application launch. +This plugin is required to work with splash screens. This plugin displays and hides a splash screen during application launch. -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Splashscreen%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) +Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cordova issue tracker]. ## Installation @@ -38,76 +46,192 @@ This plugin displays and hides a splash screen during application launch. - BlackBerry 10 - iOS - Windows Phone 7 and 8 -- Windows 8 -- Windows +- Windows (`cordova-windows` version >= 4.4.0 is required) - Browser +__Note__: Extended splashscreen does not require the plugin on Windows (as opposed to Android and iOS) in case you don't use the plugin API, i.e. programmatic hide/show. + +## Example Configuration +In the top-level `config.xml` file (not the one in `platforms`), add configuration elements like those specified here. + +Please notice that the value of the "src" attribute is relative to the project root directory and not to the www directory (see `Directory structure` below). You can name the source image whatever you like. The internal name in the app is determined by Cordova. + +Directory structure: + +``` +projectRoot + hooks + platforms + plugins + www + css + img + js + res + screen + android + ios + windows +``` + +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + ## Preferences #### config.xml -- __SplashScreen__ (string). The resource name which is used for the displaying splash screen. Different platforms use values for this. +- `AutoHideSplashScreen` (boolean, default to `true`). Indicates whether to hide splash screen automatically or not. Splash screen hidden after amount of time specified in the `SplashScreenDelay` preference. - +```xml + +``` -- __AutoHideSplashScreen__ (boolean, default to `true`). Indicates wherether hide splash screen automatically or not. Splash screen hidden after amount of time specified in the `SplashScreenDelay` preference. +- `SplashScreenDelay` (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen. - +```xml + +``` -- __SplashScreenDelay__ (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen. +Note also that this value used to be seconds, and not milliseconds, so values less than 30 will still be treated as seconds. ( Consider this a deprecated patch that will disapear in some future version. ) - +To disable the splashscreen add the following preference to `config.xml`: +```xml + +``` +**iOS Quirk**: to disable the splashscreen on `ios` platform you should also add `` to `config.xml`. -### Android Quirks +- `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to + prevent the splash screen from fading in and out when its display + state changes. -In your `config.xml`, you need to add the following preferences: +```xml + +``` - - - +- `FadeSplashScreenDuration` (float, defaults to `500`): Specifies the + number of milliseconds for the splash screen fade effect to execute. + +```xml + +``` + +_Note_: `FadeSplashScreenDuration` is included into `SplashScreenDelay`, for example if you have `` and `` defined in `config.xml`: + +- 00:00 - splashscreen is shown +- 00:02 - fading has started +- 00:03 - splashscreen is hidden + +Turning the fading off via `` technically means fading duration to be `0` so that in this example the overall splash delay will still be 3 seconds. + +_Note_: This only applies to the app startup - you need to take the fading timeout into account when manually showing/hiding the splashscreen in the code: + +```javascript +navigator.splashscreen.show(); +window.setTimeout(function () { + navigator.splashscreen.hide(); +}, splashDuration - fadeDuration); +``` + +- `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false` + to hide the splash-screen spinner. + +```xml + +``` + +### Android Quirks + +In your `config.xml`, you can add the following preferences: -Where foo is the name of the splashscreen file, preferably a 9 patch file. Make sure to add your splashcreen files to your res/xml directory under the appropriate folders. The second parameter represents how long the splashscreen will appear in milliseconds. It defaults to 3000 ms. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) -for more information. +```xml + + +``` "SplashMaintainAspectRatio" preference is optional. If set to true, splash screen drawable is not stretched to fit screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios. The plugin reloads splash drawable whenever orientation changes, so you can specify different drawables for portrait and landscape orientations. +"SplashShowOnlyFirstTime" preference is also optional and defaults to `true`. When set to `true` splash screen will only appear on application launch. However, if you plan to use `navigator.app.exitApp()` to close application and force splash screen appear on next launch, you should set this property to `false` (this also applies to closing the App with Back button). + ### Browser Quirks You can use the following preferences in your `config.xml`: - - - - - - - - +```xml + + + + + + + + +``` +__Note__: `SplashScreen` value should be absolute in order to work in a sub-page. The `SplashScreen` value is used only for the browser platform. The value will be ignored for other platforms. ### iOS Quirks -- `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to - prevent the splash screen from fading in and out when its display - state changes. +- In iOS, the splashscreen images are called launch images. These images are mandatory on iOS. - +### Windows Quirks -- `FadeSplashScreenDuration` (float, defaults to `3000`): Specifies the - number of milliseconds for the splash screen fade effect to execute. +- `SplashScreenSpinnerColor` (string, defaults to system accent color): hash, rgb notation or CSS color name. - +```xml + + + +``` -Note also that this value used to be seconds, and not milliseconds, so values less than 30 will still be treated as seconds. ( Consider this a deprecated patch that will disapear in some future version. ) - - -- `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false` - to hide the splash-screen spinner. +- `SplashScreenBackgroundColor` (string, defaults to #464646): hex notation. - +```xml + +``` ## Methods @@ -118,7 +242,9 @@ Note also that this value used to be seconds, and not milliseconds, so values le Dismiss the splash screen. - navigator.splashscreen.hide(); +```js +navigator.splashscreen.hide(); +``` ### BlackBerry 10, WP8, iOS Quirk @@ -127,16 +253,19 @@ The `config.xml` file's `AutoHideSplashScreen` setting must be `false`. To delay hiding the splash screen for two seconds, add a timer such as the following in the `deviceready` event handler: - setTimeout(function() { - navigator.splashscreen.hide(); - }, 2000); +```js +setTimeout(function() { + navigator.splashscreen.hide(); +}, 2000); +``` ## splashscreen.show Displays the splash screen. - navigator.splashscreen.show(); - +```js +navigator.splashscreen.show(); +``` Your application cannot call `navigator.splashscreen.show()` until the app has started and the `deviceready` event has fired. But since typically the splash @@ -144,7 +273,7 @@ screen is meant to be visible before your app has started, that would seem to defeat the purpose of the splash screen. Providing some configuration in `config.xml` will automatically `show` the splash screen immediately after your app launch and before it has fully started and received the `deviceready` -event. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) -for more information on doing this configuration. For this reason, it is -unlikely you need to call `navigator.splashscreen.show()` to make the splash +event. For this reason, it is unlikely you need to call `navigator.splashscreen.show()` to make the splash screen visible for app startup. + +[Apache Cordova issue tracker]: https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Splashscreen%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-splashscreen/RELEASENOTES.md index 4f6ad612..f264fe6d 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/RELEASENOTES.md @@ -20,6 +20,51 @@ --> # Release Notes +### 4.0.0 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* [CB-11326](https://issues.apache.org/jira/browse/CB-11326) Prevent crash when initializing plugin after navigating to another URL +* Fix crash on **iOS** when reloading page from remote **Safari** +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* [CB-11179](https://issues.apache.org/jira/browse/CB-11179) Extend the windows-splashscreen docs +* [CB-11159](https://issues.apache.org/jira/browse/CB-11159) Fix flaky splashscreen native tests +* [CB-11156](https://issues.apache.org/jira/browse/CB-11156) Change default `FadeSplashScreenDuration` value +* [CB-8056](https://issues.apache.org/jira/browse/CB-8056) Updated the dependency version, added it to the docs +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md +* [CB-8056](https://issues.apache.org/jira/browse/CB-8056) Implement splashscreen for **Windows** platform +* [CB-6498](https://issues.apache.org/jira/browse/CB-6498) Misleading documentation in **Android** Quirks + +### 3.2.2 (Apr 15, 2016) +* [CB-10979](https://issues.apache.org/jira/browse/CB-10979) Fix splashscreen **iOS** native tests. Added `jshintignore` for tests/ios +* [CB-10895](https://issues.apache.org/jira/browse/CB-10895) Transparent Splashscreen view sometimes remains +* [CB-10562](https://issues.apache.org/jira/browse/CB-10562) `hide()` not working in latest splashscreen plug in 3.1.0 in **iOS** +* [CB-10688](https://issues.apache.org/jira/browse/CB-10688) Plugin Splashscreen Readme must have examples. +* [CB-10864](https://issues.apache.org/jira/browse/CB-10864) Run **iOS** native tests on Travis + +### 3.2.1 (Mar 09, 2016) +* [CB-10764](https://issues.apache.org/jira/browse/CB-10764) Remove emoji in cordova-plugin-splashscreen +* [CB-10650](https://issues.apache.org/jira/browse/CB-10650) Non-index content.src causes Splashscreen to be not displayed on **Browser** +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins +* [CB-10606](https://issues.apache.org/jira/browse/CB-10606) fix deprecation warning for interfaceOrientation on **iOS** +* chore: edit package.json license to match SPDX id + +### 3.2.0 (Feb 09, 2016) +* [CB-10422](https://issues.apache.org/jira/browse/CB-10422) Splashscreen displays black screen with no image on Android +* [CB-10412](https://issues.apache.org/jira/browse/CB-10412) AutoHideSplashScreen "false" isn't taken in account on iOS +* [CB-9516](https://issues.apache.org/jira/browse/CB-9516) Android SplashScreen - Spinner Does Not Display +* [CB-9094](https://issues.apache.org/jira/browse/CB-9094) Smarter autohide logic on Android +* [CB-8396](https://issues.apache.org/jira/browse/CB-8396) Add AutoHideSplashScreen logic to Android's Splashscreen + +### 3.1.0 (Jan 15, 2016) +* [CB-9538](https://issues.apache.org/jira/browse/CB-9538) Implementing `FadeSplashScreen` feature for **Android** +* [CB-9240](https://issues.apache.org/jira/browse/CB-9240) Cordova splash screen plugin **iPad** landscape mode issue +* [CB-10263](https://issues.apache.org/jira/browse/CB-10263) Fix splashscreen plugin filenames for Asset Catalog +* [CB-9374](https://issues.apache.org/jira/browse/CB-9374) **Android** add `SplashShowOnlyFirstTime` as preference +* [CB-10244](https://issues.apache.org/jira/browse/CB-10244) Don't rotate the **iPhone 6 Plus** splash +* [CB-9043](https://issues.apache.org/jira/browse/CB-9043) Fix the **ios** splashscreen being deformed on orientation change +* [CB-10079](https://issues.apache.org/jira/browse/CB-10079) Splashscreen plugin does not honor `SplashScreenDelay` on **iOS** +* [CB-10231](https://issues.apache.org/jira/browse/CB-10231) Fix `FadeSplashScreen` to default to true on **iOS** + ### 3.0.0 (Nov 18, 2015) * [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest * Fixing contribute link. diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/package.json b/StoneIsland/plugins/cordova-plugin-splashscreen/package.json index 1c0a8403..08836dc9 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/package.json +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-splashscreen", - "version": "3.0.0", + "version": "4.0.0", "description": "Cordova Splashscreen Plugin", "cordova": { "id": "cordova-plugin-splashscreen", @@ -34,12 +34,27 @@ "cordova-windows", "cordova-tizen" ], - "engines": [ - { - "name": "cordova-android", - "version": ">=3.6.0" + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, + "engines": { + "cordovaDependencies": { + "2.0.0": { + "cordova-android": ">=3.6.0" + }, + "4.0.0": { + "cordova-android": ">=3.6.0", + "cordova-windows": ">=4.4.0" + }, + "5.0.0": { + "cordova": ">100" + } } - ], + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/plugin.xml b/StoneIsland/plugins/cordova-plugin-splashscreen/plugin.xml index 6477ad65..5c1e5707 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/plugin.xml @@ -20,7 +20,7 @@ + version="4.0.0"> Splashscreen Cordova Splashscreen Plugin Apache 2.0 @@ -30,6 +30,7 @@ + diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java b/StoneIsland/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java index 75ad724c..14b63790 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java @@ -25,13 +25,20 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.Configuration; import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.os.Handler; import android.view.Display; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.AlphaAnimation; +import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; @@ -44,9 +51,12 @@ public class SplashScreen extends CordovaPlugin { // Cordova 3.x.x has a copy of this plugin bundled with it (SplashScreenInternal.java). // Enable functionality only if running on 4.x.x. private static final boolean HAS_BUILT_IN_SPLASH_SCREEN = Integer.valueOf(CordovaWebView.CORDOVA_VERSION.split("\\.")[0]) < 4; + private static final int DEFAULT_SPLASHSCREEN_DURATION = 3000; + private static final int DEFAULT_FADE_DURATION = 500; private static Dialog splashDialog; private static ProgressDialog spinnerDialog; private static boolean firstShow = true; + private static boolean lastHideAfterDelay; // https://issues.apache.org/jira/browse/CB-9094 /** * Displays the splash drawable. @@ -69,11 +79,17 @@ public class SplashScreen extends CordovaPlugin { @Override protected void pluginInitialize() { - if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) { + if (HAS_BUILT_IN_SPLASH_SCREEN) { return; } // Make WebView invisible while loading URL - getView().setVisibility(View.INVISIBLE); + // CB-11326 Ensure we're calling this on UI thread + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + getView().setVisibility(View.INVISIBLE); + } + }); int drawableId = preferences.getInteger("SplashDrawableId", 0); if (drawableId == 0) { String splashResource = preferences.getString("SplashScreen", "screen"); @@ -89,9 +105,14 @@ public class SplashScreen extends CordovaPlugin { // Save initial orientation. orientation = cordova.getActivity().getResources().getConfiguration().orientation; - firstShow = false; - loadSpinner(); - showSplashScreen(true); + if (firstShow) { + boolean autoHide = preferences.getBoolean("AutoHideSplashScreen", true); + showSplashScreen(autoHide); + } + + if (preferences.getBoolean("SplashShowOnlyFirstTime", true)) { + firstShow = false; + } } /** @@ -101,13 +122,26 @@ public class SplashScreen extends CordovaPlugin { return preferences.getBoolean("SplashMaintainAspectRatio", false); } + private int getFadeDuration () { + int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ? + preferences.getInteger("FadeSplashScreenDuration", DEFAULT_FADE_DURATION) : 0; + + if (fadeSplashScreenDuration < 30) { + // [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10 + // they mean 10 seconds, and not the meaningless 10ms + fadeSplashScreenDuration *= 1000; + } + + return fadeSplashScreenDuration; + } + @Override public void onPause(boolean multitasking) { if (HAS_BUILT_IN_SPLASH_SCREEN) { return; } // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); + this.removeSplashScreen(true); } @Override @@ -116,7 +150,7 @@ public class SplashScreen extends CordovaPlugin { return; } // hide the splash screen to avoid leaking a window - this.removeSplashScreen(); + this.removeSplashScreen(true); // If we set this to true onDestroy, we lose track when we go from page to page! //firstShow = true; } @@ -135,16 +169,6 @@ public class SplashScreen extends CordovaPlugin { webView.postMessage("splashscreen", "show"); } }); - } else if (action.equals("spinnerStart")) { - if (!HAS_BUILT_IN_SPLASH_SCREEN) { - final String title = args.getString(0); - final String message = args.getString(1); - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - spinnerStart(title, message); - } - }); - } } else { return false; } @@ -160,17 +184,16 @@ public class SplashScreen extends CordovaPlugin { } if ("splashscreen".equals(id)) { if ("hide".equals(data.toString())) { - this.removeSplashScreen(); + this.removeSplashScreen(false); } else { this.showSplashScreen(false); } } else if ("spinner".equals(id)) { if ("stop".equals(data.toString())) { - this.spinnerStop(); getView().setVisibility(View.VISIBLE); } } else if ("onReceivedError".equals(id)) { - spinnerStop(); + this.spinnerStop(); } return null; } @@ -190,13 +213,45 @@ public class SplashScreen extends CordovaPlugin { } } - private void removeSplashScreen() { + private void removeSplashScreen(final boolean forceHideImmediately) { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { if (splashDialog != null && splashDialog.isShowing()) { - splashDialog.dismiss(); - splashDialog = null; - splashImageView = null; + final int fadeSplashScreenDuration = getFadeDuration(); + // CB-10692 If the plugin is being paused/destroyed, skip the fading and hide it immediately + if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) { + AlphaAnimation fadeOut = new AlphaAnimation(1, 0); + fadeOut.setInterpolator(new DecelerateInterpolator()); + fadeOut.setDuration(fadeSplashScreenDuration); + + splashImageView.setAnimation(fadeOut); + splashImageView.startAnimation(fadeOut); + + fadeOut.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + spinnerStop(); + } + + @Override + public void onAnimationEnd(Animation animation) { + if (splashDialog != null && splashDialog.isShowing()) { + splashDialog.dismiss(); + splashDialog = null; + splashImageView = null; + } + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + }); + } else { + spinnerStop(); + splashDialog.dismiss(); + splashDialog = null; + splashImageView = null; + } } } }); @@ -207,9 +262,14 @@ public class SplashScreen extends CordovaPlugin { */ @SuppressWarnings("deprecation") private void showSplashScreen(final boolean hideAfterDelay) { - final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000); + final int splashscreenTime = preferences.getInteger("SplashScreenDelay", DEFAULT_SPLASHSCREEN_DURATION); final int drawableId = preferences.getInteger("SplashDrawableId", 0); + final int fadeSplashScreenDuration = getFadeDuration(); + final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration); + + lastHideAfterDelay = hideAfterDelay; + // If the splash dialog is showing don't try to show it again if (splashDialog != null && splashDialog.isShowing()) { return; @@ -257,60 +317,57 @@ public class SplashScreen extends CordovaPlugin { splashDialog.setCancelable(false); splashDialog.show(); + if (preferences.getBoolean("ShowSplashScreenSpinner", true)) { + spinnerStart(); + } + // Set Runnable to remove splash screen just in case if (hideAfterDelay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { - removeSplashScreen(); + if (lastHideAfterDelay) { + removeSplashScreen(false); + } } - }, splashscreenTime); + }, effectiveSplashDuration); } } }); } - /* - * Load the spinner - */ - private void loadSpinner() { - // If loadingDialog property, then show the App loading dialog for first page of app - String loading = null; - if (webView.canGoBack()) { - loading = preferences.getString("LoadingDialog", null); - } - else { - loading = preferences.getString("LoadingPageDialog", null); - } - if (loading != null) { - String title = ""; - String message = "Loading Application..."; - - if (loading.length() > 0) { - int comma = loading.indexOf(','); - if (comma > 0) { - title = loading.substring(0, comma); - message = loading.substring(comma + 1); - } - else { - title = ""; - message = loading; - } - } - spinnerStart(title, message); - } - } - - private void spinnerStart(final String title, final String message) { + // Show only spinner in the center of the screen + private void spinnerStart() { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { spinnerStop(); - spinnerDialog = ProgressDialog.show(webView.getContext(), title, message, true, true, - new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { - spinnerDialog = null; - } - }); + + spinnerDialog = new ProgressDialog(webView.getContext()); + spinnerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { + public void onCancel(DialogInterface dialog) { + spinnerDialog = null; + } + }); + + spinnerDialog.setCancelable(false); + spinnerDialog.setIndeterminate(true); + + RelativeLayout centeredLayout = new RelativeLayout(cordova.getActivity()); + centeredLayout.setGravity(Gravity.CENTER); + centeredLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + + ProgressBar progressBar = new ProgressBar(webView.getContext()); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + progressBar.setLayoutParams(layoutParams); + + centeredLayout.addView(progressBar); + + spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + spinnerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + + spinnerDialog.show(); + spinnerDialog.setContentView(centeredLayout); } }); } diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js b/StoneIsland/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js index bd7e48c8..c6825064 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/src/blackberry10/index.js @@ -14,6 +14,8 @@ * limitations under the License. */ +/* global PluginResult */ + module.exports = { show: function (success, fail, args, env) { var result = new PluginResult(args, env); diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js b/StoneIsland/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js index d19f8c87..6cf9309f 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js @@ -18,17 +18,18 @@ * under the License. * */ + // Default parameter values including image size can be changed in `config.xml` var splashImageWidth = 170; var splashImageHeight = 200; var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight }; -var splash = null; // var localSplash; // the image to display var localSplashImage; var bgColor = "#464646"; -var imageSrc = 'img/logo.png'; +var imageSrc = '/img/logo.png'; var splashScreenDelay = 3000; // in milliseconds var showSplashScreen = true; // show splashcreen by default +var cordova = require('cordova'); var configHelper = cordova.require('cordova/confighelper'); function updateImageLocation() { @@ -103,7 +104,6 @@ function readPreferencesFromCfg(cfg) { } catch(e) { var msg = '[Browser][SplashScreen] Error occured on loading preferences from config.xml: ' + JSON.stringify(e); console.error(msg); - error(msg); } } diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h b/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h index 0d6ae397..ec5d6022 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.h @@ -23,6 +23,7 @@ typedef struct { BOOL iPhone; BOOL iPad; + BOOL iPhone4; BOOL iPhone5; BOOL iPhone6; BOOL iPhone6Plus; @@ -35,6 +36,7 @@ typedef struct { UIImageView* _imageView; NSString* _curImageName; BOOL _visible; + BOOL _destroyed; } - (void)show:(CDVInvokedUrlCommand*)command; diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m b/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m index a1add304..8ad8116b 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVSplashScreen.m @@ -23,6 +23,7 @@ #import "CDVViewController+SplashScreen.h" #define kSplashScreenDurationDefault 3000.0f +#define kFadeDurationDefault 500.0f @implementation CDVSplashScreen @@ -41,7 +42,7 @@ - (void)hide:(CDVInvokedUrlCommand*)command { - [self setVisible:NO]; + [self setVisible:NO andForce:YES]; } - (void)pageDidLoad @@ -76,7 +77,7 @@ BOOL autorotateValue = (device.iPad || device.iPhone6Plus) ? [(CDVViewController *)self.viewController shouldAutorotateDefaultValue] : NO; - + [(CDVViewController *)self.viewController setEnabledAutorotation:autorotateValue]; NSString* topActivityIndicator = [self.commandDelegate.settings objectForKey:[@"TopActivityIndicator" lowercaseString]]; @@ -120,6 +121,7 @@ [parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil]; [self updateImage]; + _destroyed = NO; } - (void)hideViews @@ -130,6 +132,7 @@ - (void)destroyViews { + _destroyed = YES; [(CDVViewController *)self.viewController setEnabledAutorotation:[(CDVViewController *)self.viewController shouldAutorotateDefaultValue]]; [_imageView removeFromSuperview]; @@ -139,30 +142,39 @@ _curImageName = nil; self.viewController.view.userInteractionEnabled = YES; // re-enable user interaction upon completion - [self.viewController.view removeObserver:self forKeyPath:@"frame"]; - [self.viewController.view removeObserver:self forKeyPath:@"bounds"]; + @try { + [self.viewController.view removeObserver:self forKeyPath:@"frame"]; + [self.viewController.view removeObserver:self forKeyPath:@"bounds"]; + } + @catch (NSException *exception) { + // When reloading the page from a remotely connected Safari, there + // are no observers, so the removeObserver method throws an exception, + // that we can safely ignore. + // Alternatively we can check whether there are observers before calling removeObserver + } } - (CDV_iOSDevice) getCurrentDevice { CDV_iOSDevice device; - + UIScreen* mainScreen = [UIScreen mainScreen]; CGFloat mainScreenHeight = mainScreen.bounds.size.height; CGFloat mainScreenWidth = mainScreen.bounds.size.width; - + int limit = MAX(mainScreenHeight,mainScreenWidth); - + device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone); device.retina = ([mainScreen scale] == 2.0); + device.iPhone4 = (device.iPhone && limit == 480.0); device.iPhone5 = (device.iPhone && limit == 568.0); // note these below is not a true device detect, for example if you are on an // iPhone 6/6+ but the app is scaled it will prob set iPhone5 as true, but // this is appropriate for detecting the runtime screen environment device.iPhone6 = (device.iPhone && limit == 667.0); device.iPhone6Plus = (device.iPhone && limit == 736.0); - + return device; } @@ -170,15 +182,15 @@ { // Use UILaunchImageFile if specified in plist. Otherwise, use Default. NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"]; - + NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations]; - + // Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape); BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown); // this means there are no mixed orientations in there BOOL isOrientationLocked = !(supportsPortrait && supportsLandscape); - + if (imageName) { imageName = [imageName stringByDeletingPathExtension]; @@ -187,7 +199,23 @@ { imageName = @"Default"; } - + + // Add Asset Catalog specific prefixes + if ([imageName isEqualToString:@"LaunchImage"]) + { + if (device.iPhone4 || device.iPhone5 || device.iPad) { + imageName = [imageName stringByAppendingString:@"-700"]; + } else if(device.iPhone6) { + imageName = [imageName stringByAppendingString:@"-800"]; + } else if(device.iPhone6Plus) { + imageName = [imageName stringByAppendingString:@"-800"]; + if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown) + { + imageName = [imageName stringByAppendingString:@"-Portrait"]; + } + } + } + if (device.iPhone5) { // does not support landscape imageName = [imageName stringByAppendingString:@"-568h"]; @@ -231,7 +259,7 @@ case UIInterfaceOrientationLandscapeRight: imageName = [imageName stringByAppendingString:@"-Landscape"]; break; - + case UIInterfaceOrientationPortrait: case UIInterfaceOrientationPortraitUpsideDown: default: @@ -240,14 +268,51 @@ } } } - + return imageName; } +- (UIInterfaceOrientation)getCurrentOrientation +{ + UIInterfaceOrientation iOrientation = [UIApplication sharedApplication].statusBarOrientation; + UIDeviceOrientation dOrientation = [UIDevice currentDevice].orientation; + + bool landscape; + + if (dOrientation == UIDeviceOrientationUnknown || dOrientation == UIDeviceOrientationFaceUp || dOrientation == UIDeviceOrientationFaceDown) { + // If the device is laying down, use the UIInterfaceOrientation based on the status bar. + landscape = UIInterfaceOrientationIsLandscape(iOrientation); + } else { + // If the device is not laying down, use UIDeviceOrientation. + landscape = UIDeviceOrientationIsLandscape(dOrientation); + + // There's a bug in iOS!!!! http://openradar.appspot.com/7216046 + // So values needs to be reversed for landscape! + if (dOrientation == UIDeviceOrientationLandscapeLeft) + { + iOrientation = UIInterfaceOrientationLandscapeRight; + } + else if (dOrientation == UIDeviceOrientationLandscapeRight) + { + iOrientation = UIInterfaceOrientationLandscapeLeft; + } + else if (dOrientation == UIDeviceOrientationPortrait) + { + iOrientation = UIInterfaceOrientationPortrait; + } + else if (dOrientation == UIDeviceOrientationPortraitUpsideDown) + { + iOrientation = UIInterfaceOrientationPortraitUpsideDown; + } + } + + return iOrientation; +} + // Sets the view's frame and image. - (void)updateImage { - NSString* imageName = [self getImageName:[[UIApplication sharedApplication] statusBarOrientation] delegate:(id)self.viewController device:[self getCurrentDevice]]; + NSString* imageName = [self getImageName:[self getCurrentOrientation] delegate:(id)self.viewController device:[self getCurrentDevice]]; if (![imageName isEqualToString:_curImageName]) { @@ -273,7 +338,7 @@ CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero; CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size; - UIInterfaceOrientation orientation = self.viewController.interfaceOrientation; + UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; CGAffineTransform imgTransform = CGAffineTransformIdentity; /* If and only if an iPhone application is landscape-only as per @@ -281,8 +346,8 @@ * landscape. In this case the image must be rotated in order to appear * correctly. */ - BOOL isIPad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad; - if (UIInterfaceOrientationIsLandscape(orientation) && !isIPad) + CDV_iOSDevice device = [self getCurrentDevice]; + if (UIInterfaceOrientationIsLandscape(orientation) && !device.iPhone6Plus && !device.iPad) { imgTransform = CGAffineTransformMakeRotation(M_PI / 2); imgBounds.size = CGSizeMake(imgBounds.size.height, imgBounds.size.width); @@ -322,26 +387,52 @@ - (void)setVisible:(BOOL)visible { - if (visible != _visible) + [self setVisible:visible andForce:NO]; +} + +- (void)setVisible:(BOOL)visible andForce:(BOOL)force +{ + if (visible != _visible || force) { _visible = visible; id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreen" lowercaseString]]; id fadeSplashScreenDuration = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreenDuration" lowercaseString]]; - float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue]; + float fadeDuration = fadeSplashScreenDuration == nil ? kFadeDurationDefault : [fadeSplashScreenDuration floatValue]; + + id splashDurationString = [self.commandDelegate.settings objectForKey: [@"SplashScreenDelay" lowercaseString]]; + float splashDuration = splashDurationString == nil ? kSplashScreenDurationDefault : [splashDurationString floatValue]; - if ((fadeSplashScreenValue == nil) || ![fadeSplashScreenValue boolValue]) + id autoHideSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"AutoHideSplashScreen" lowercaseString]]; + BOOL autoHideSplashScreen = true; + + if (autoHideSplashScreenValue != nil) { + autoHideSplashScreen = [autoHideSplashScreenValue boolValue]; + } + + if (!autoHideSplashScreen) { + // CB-10412 SplashScreenDelay does not make sense if the splashscreen is hidden manually + splashDuration = 0; + } + + + if (fadeSplashScreenValue == nil) + { + fadeSplashScreenValue = @"true"; + } + + if (![fadeSplashScreenValue boolValue]) { fadeDuration = 0; } - else if(fadeDuration < 30) + else if (fadeDuration < 30) { // [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10 // they mean 10 seconds, and not the meaningless 10ms fadeDuration *= 1000; } - + if (_visible) { if (_imageView == nil) @@ -349,26 +440,42 @@ [self createViews]; } } - else if (fadeDuration == 0) + else if (fadeDuration == 0 && splashDuration == 0) { [self destroyViews]; } else { __weak __typeof(self) weakSelf = self; - [UIView transitionWithView:self.viewController.view - duration:(fadeDuration / 1000) - options:UIViewAnimationOptionTransitionNone - animations:^(void) { - [weakSelf hideViews]; - } - completion:^(BOOL finished) { - if (finished) { - [weakSelf destroyViews]; - // TODO: It might also be nice to have a js event happen here -jm - } - } - ]; + float effectiveSplashDuration; + + // [CB-10562] AutoHideSplashScreen may be "true" but we should still be able to hide the splashscreen manually. + if (!autoHideSplashScreen || force) { + effectiveSplashDuration = (fadeDuration) / 1000; + } else { + effectiveSplashDuration = (splashDuration - fadeDuration) / 1000; + } + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t) effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(), CFBridgingRelease(CFBridgingRetain(^(void) { + if (!_destroyed) { + [UIView transitionWithView:self.viewController.view + duration:(fadeDuration / 1000) + options:UIViewAnimationOptionTransitionNone + animations:^(void) { + [weakSelf hideViews]; + } + completion:^(BOOL finished) { + // Always destroy views, otherwise you could have an + // invisible splashscreen that is overlayed over your active views + // which causes that no touch events are passed + if (!_destroyed) { + [weakSelf destroyViews]; + // TODO: It might also be nice to have a js event happen here -jm + } + } + ]; + } + }))); } } } diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVViewController+SplashScreen.m b/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVViewController+SplashScreen.m index 5736b6f2..e483def6 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVViewController+SplashScreen.m +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/src/ios/CDVViewController+SplashScreen.m @@ -35,6 +35,13 @@ - (BOOL)enabledAutorotation { NSNumber *number = (NSNumber *)objc_getAssociatedObject(self, @selector(enabledAutorotation)); + + // Defaulting to YES to correspond parent CDVViewController behavior + if (number == nil) + { + return YES; + } + return [number boolValue]; } diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js b/StoneIsland/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js index fbd9f35f..06c06972 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/src/tizen/SplashScreenProxy.js @@ -21,7 +21,7 @@ ( function() { -win = null; +var win = null; module.exports = { show: function() { diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/tests/ios/package.json b/StoneIsland/plugins/cordova-plugin-splashscreen/tests/ios/package.json index d8b23857..67f0edce 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/tests/ios/package.json +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/tests/ios/package.json @@ -5,9 +5,9 @@ "author": "Apache Software Foundation", "license": "Apache Version 2.0", "dependencies": { - "cordova-ios": "^3.6.0" + "cordova-ios": "*" }, "scripts": { - "test": "xcodebuild test -workspace CDVSplashScreenTest.xcworkspace -scheme CDVSplashScreenLibTests -destination 'platform=iOS Simulator,name=iPhone 5' CONFIGURATION_BUILD_DIR='/tmp'" - } -} \ No newline at end of file + "test": "xcodebuild test -workspace CDVSplashScreenTest.xcworkspace -scheme CDVSplashScreenLibTests -destination 'platform=iOS Simulator,name=iPhone 5' CONFIGURATION_BUILD_DIR='/tmp' HEADER_SEARCH_PATHS='$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include'" + } +} diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-splashscreen/tests/plugin.xml index 36652d98..8accd865 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/tests/plugin.xml @@ -20,7 +20,7 @@ + version="4.0.0"> Cordova Splashscreen Plugin Tests Apache 2.0 diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/tests/tests.js b/StoneIsland/plugins/cordova-plugin-splashscreen/tests/tests.js index 8c4d22b4..7b55a81c 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/tests/tests.js @@ -19,18 +19,20 @@ * */ -exports.defineAutoTest = function () { +/* jshint jasmine: true */ + +exports.defineAutoTests = function () { describe('Splashscreen (cordova)', function () { it("splashscreen.spec.1 should exist", function () { expect(navigator.splashscreen).toBeDefined(); }); - it("splashscreen.spec.2 exec method should exist", function () { + it("splashscreen.spec.2 show method should exist", function () { expect(navigator.splashscreen.show).toBeDefined(); expect(typeof navigator.splashscreen.show).toBe('function'); }); - it("splashscreen.spec.3 exec method should exist", function () { + it("splashscreen.spec.3 hide method should exist", function () { expect(navigator.splashscreen.hide).toBeDefined(); expect(typeof navigator.splashscreen.hide).toBe('function'); }); diff --git a/StoneIsland/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js b/StoneIsland/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js index 271a14ca..1003f061 100644 --- a/StoneIsland/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js +++ b/StoneIsland/plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js @@ -20,57 +20,15 @@ */ /*jslint sloppy:true */ -/*global Windows:true, require, module, window, document, WinJS */ -var cordova = require('cordova'), - channel = require('cordova/channel'); - -var isPhone = (cordova.platformId == "windows") && WinJS.Utilities.isPhone; -var isHosted = window.location.protocol.indexOf('http') === 0; -var localSplash = null; -var bgColor = "#464646"; // default backgrond color; TDOO - read it from .appxmanifest -var splashImageSrc = (isHosted ? "ms-appx-web" : "ms-appx") + ":///images/" - + (isPhone ? "splashscreenphone.png" : "splashscreen.png"); +var splash = require('cordova/splashscreen'); var SplashScreen = { - setBGColor: function (cssBGColor) { - bgColor = cssBGColor; - if (localSplash) { - localSplash.style.backgroundColor = bgColor; - } - }, show: function () { - if (localSplash) { - return; // already showed - } - - localSplash = document.createElement("div"); - localSplash.style.backgroundColor = bgColor; - localSplash.style.position = "fixed"; - localSplash.style.top = "0"; - localSplash.style.width = "100%"; - localSplash.style.height = "100%"; - - localSplashImage = document.createElement("img"); - localSplashImage.src = splashImageSrc; - localSplashImage.style.maxWidth = "100%"; - localSplashImage.style.maxHeight = "100%"; - // center horizontally - localSplashImage.style.margin = "0 auto"; - localSplashImage.style.display = "block"; - // center vertically - localSplashImage.style.position = "relative"; - localSplashImage.style.top = "50%"; - localSplashImage.style.transform = "translateY(-50%)"; - - localSplash.appendChild(localSplashImage); - document.body.appendChild(localSplash); + splash.show(); }, hide: function () { - if (localSplash) { - document.body.removeChild(localSplash); - localSplash = null; - } + splash.hide(); } }; diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-whitelist/CONTRIBUTING.md old mode 100755 new mode 100644 index e4a178f5..7de4c641 --- a/StoneIsland/plugins/cordova-plugin-whitelist/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-whitelist/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/LICENSE b/StoneIsland/plugins/cordova-plugin-whitelist/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/NOTICE b/StoneIsland/plugins/cordova-plugin-whitelist/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/README.md old mode 100755 new mode 100644 index def10044..e19d2304 --- a/StoneIsland/plugins/cordova-plugin-whitelist/README.md +++ b/StoneIsland/plugins/cordova-plugin-whitelist/README.md @@ -1,30 +1,44 @@ - # cordova-plugin-whitelist This plugin implements a whitelist policy for navigating the application webview on Cordova 4.0 +:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Whitelist%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) + +## Installation + +You can install whitelist plugin with Cordova CLI, from npm: + +``` +$ cordova plugin add cordova-plugin-whitelist +$ cordova prepare +``` + ## Supported Cordova Platforms * Android 4.0.0 or above -* iOS 4.0.0 or above ## Navigation Whitelist Controls which URLs the WebView itself can be navigated to. Applies to @@ -32,15 +46,14 @@ top-level navigations only. Quirks: on Android it also applies to iframes for non-http(s) schemes. -By default, navigations only to `file://` URLs, are allowed. To allow other -other URLs, you must add `` tags to your `config.xml`: +By default, navigations only to `file://` URLs, are allowed. To allow others URLs, you must add `` tags to your `config.xml`: - + - + - - + + - + diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-whitelist/RELEASENOTES.md old mode 100755 new mode 100644 index 703552ca..9e271c09 --- a/StoneIsland/plugins/cordova-plugin-whitelist/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-whitelist/RELEASENOTES.md @@ -20,9 +20,44 @@ --> # Release Notes +### 1.3.0 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* Updated installation section +* Plugin uses `Android Log class` and not `Cordova LOG class` +* Add pull request template. +* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine info to `package.json` +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md + +### 1.2.2 (Apr 15, 2016) +* add note about redirects +* [CB-10624](https://issues.apache.org/jira/browse/CB-10624) remove error message from `whitelist.js`, which leaves it empty + +### 1.2.1 (Jan 15, 2016) +* [CB-10194](https://issues.apache.org/jira/browse/CB-10194) info tag prints for ios when not applicable + +### 1.2.0 (Nov 18, 2015) +* removed **iOS** engine check from `plugin.xml` +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* [CB-9972](https://issues.apache.org/jira/browse/CB-9972) - Remove **iOS** whitelist +* Updated the text, it should read 4.0.x and greater, since this plugin will be required for `cordova-android 5.0` +* Fixing contribute link. +* Updated `plugin.xml ` tag to remove warning about not needing this plugin if you are using the **iOS 9 SDK** +* [CB-9738](https://issues.apache.org/jira/browse/CB-9738) - Disable whitelist use when runtime environment is **iOS 9** +* [CB-9740](https://issues.apache.org/jira/browse/CB-9740) - Add `` tag describing whitelist plugin not needed on `cordova-ios` and cordova-android 3.x` +* [CB-9568](https://issues.apache.org/jira/browse/CB-9568) - Update whitelist plugin to allow all network access by default +* [CB-9337](https://issues.apache.org/jira/browse/CB-9337) - enable use of `` tags for native code network requests + +### 1.1.0 (Jun 17, 2015) +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-whitelist documentation translation: cordova-plugin-whitelist +* fix npm md issue +* Usage of CDVURLRequestFilter protocol. +* [CB-9089](https://issues.apache.org/jira/browse/CB-9089) - iOS whitelist plugin does not compile +* [CB-9090](https://issues.apache.org/jira/browse/CB-9090) - Enable whitelist plugin for cordova-ios 4.0.0 +* Fixed error in Content-Security-Policy example + ### 1.0.0 (Mar 25, 2015) -* CB-8739 added missing license headers +* [CB-8739](https://issues.apache.org/jira/browse/CB-8739) added missing license headers * Add @Override to CustomConfigXmlParser methods * Change ID to cordova-plugin-whitelist rather than reverse-DNS-style * Tweak CSP examples in README -* CB-8660 remove extra commas from package.json +* [CB-8660](https://issues.apache.org/jira/browse/CB-8660) remove extra commas from package.json diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/de/README.md new file mode 100644 index 00000000..e97eaa63 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/de/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +Dieses Plugin implementiert eine Whitelist-Politik für die Navigation in der Anwendung Webview Cordova 4.0 + +## Cordova unterstützte Plattformen + + * Android 4.0.0 oder höher + * iOS 4.0.0 oder höher + +## Navigation-Whitelist + +Steuert, welche URLs die WebView selbst zu navigiert werden kann. Bezieht sich auf der obersten Ebene Navigationen nur. + +Macken: auf Android es gilt auch für Iframes für nicht-http(s) Systeme. + +In der Standardeinstellung Navigationen nur auf `file://` URLs, sind zulässig. Wenn andere andere URLs zulassen möchten, müssen Sie Ihre `"config.xml"` `` Markierungen hinzufügen: + + + + + + + + + + + + + + + + +## Vorsatz-Whitelist + +Steuert, welche URLs die app zulässig ist, um das System zu öffnen Fragen. Standardmäßig dürfen keine externe URLs. + +Das entspricht auf Android eine Absicht des Typs BROWSEABLE senden. + +Diese Whitelist gilt nicht für Plugins, nur Hyperlinks und Aufrufe von `window.open()`. + +Fügen Sie in `"config.xml"` `` Tags hinzu, wie folgt: + + + + + + + + + + + + + + + + + + + + + + + + +## Netzwerk-Anforderung-Whitelist + +Steuert, welche-Anforderungen Netzwerk (Bilder, XHRs, etc.) dürfen (über Cordova native Haken) erfolgen. + +Hinweis: Wir empfehlen Ihnen eine Content Security Policy (siehe unten), das ist sicherer. Diese Whitelist ist vor allem historisch für Webansichten für die CSP nicht unterstützen. + +Fügen Sie in `"config.xml"` `` Tags hinzu, wie folgt: + + + + + + + + + + + + + + + + + + +Ohne `` -Tags dürfen nur Anforderungen an `file://` URLs. Enthält jedoch die Standardanwendung Cordova `` standardmäßig. + +Eigenart: Android kann auch Anforderungen an https://ssl.gstatic.com/accessibility/javascript/android/ standardmäßig, da dies für TalkBack ordnungsgemäß erforderlich ist. + +### Content-Security-Policy + +Steuert, welche-Anforderungen Netzwerk (Bilder, XHRs, etc.) dürfen (über Webview direkt) erfolgen. + +Auf Android und iOS ist die Netzwerk Anfrage Whitelist (s.o.) nicht in der Lage, alle Arten von Anfragen (z.B. `< video >` & WebSockets nicht blockiert) filtern. Also, sollten Sie neben der Whitelist, [Content Security Policy](http://content-security-policy.com/) `< Meta >` -Tags auf allen Ihren Seiten verwenden. + +Auf Android Unterstützung für CSP innerhalb der System-Webview beginnt mit KitKat (aber ist in allen Versionen mit Crosswalk WebView verfügbar). + +Hier sind einige Beispiel-CSP-Deklarationen für Ihre `HTML` -Seiten: + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/es/README.md new file mode 100644 index 00000000..b3e46849 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/es/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +Este plugin implementa una política de lista blanca para navegar la aplicación webview en Cordova 4.0 + +## Plataformas soportadas Cordova + + * Android 4.0 o superior + * iOS 4.0.0 o superior + +## Lista blanca de navegación + +Controla que las URLs del WebView se puede navegar a. Se aplica a nivel superior navegaciones solo. + +Peculiaridades: en Android también se aplica a iframes para esquemas que son de http (s). + +Por defecto, navegaciones solo a direcciones URL `file://` , son permitidas. Para permitir que otros otras URL, debe agregar `< allow-navegación >` etiquetas en el `archivo config.xml`: + + + + + + + + + + + + + + + + +## Intención de lista blanca + +Controla qué URLs de la aplicación se permite hacer el sistema para abrir. De forma predeterminada, se permiten ninguÃŒ n external URLs. + +En Android, esto equivale a enviar una intención de tipo BROWSEABLE. + +Esta lista blanca no se aplica a plugins, sólo los hipervínculos y las llamadas a `window.Open)`. + +En `config.xml`, agregar etiquetas `< allow-intent >` , como este: + + + + + + + + + + + + + + + + + + + + + + + + +## Solicitud de red blanca + +Controles que las peticiones de la red (imágenes, XHRs, etc.) se les permite hacer (a través de ganchos nativa de Córdoba). + +Nota: Le sugerimos que utilice una política de seguridad de contenido (véase abajo), que es más seguro. Esta lista blanca es sobre todo histórico para webviews que no admiten la CSP. + +En `config.xml`, agregue etiquetas de `< access >` , como este: + + + + + + + + + + + + + + + + + + +Sin las etiquetas `< access >` , se admiten sólo las solicitudes a direcciones URL `file://` . Sin embargo, la aplicación por defecto de Cordova incluye `< access origin = "*" >` por defecto. + +Quirk: Android también permite las solicitudes de https://ssl.gstatic.com/accessibility/javascript/android/ por defecto, puesto que es necesario para TalkBack funcionar correctamente. + +### Política de seguridad de contenido + +Controles que las peticiones de la red (imágenes, XHRs, etc.) se les permite hacer (vía webview directamente). + +En iOS y Android, la red solicitud lista blanca (véase arriba) no es capaz de filtrar todos los tipos de solicitudes (por ejemplo, `< video >` y WebSockets no estén bloqueadas). Así, además de la lista blanca, usted debe utilizar una etiqueta `< meta >` de [Contenido la política de seguridad](http://content-security-policy.com/) en todas las páginas. + +En Android, soporte para CSP en el sistema webview comienza con KitKat (pero está disponible en todas las versiones con WebView de paso de peatones). + +Aquí están algunas declaraciones de CSP de ejemplo para las páginas `.html` : + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/fr/README.md new file mode 100644 index 00000000..2a8c4b73 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/fr/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +Ce plugin met en Å“uvre une politique de liste blanche pour naviguer le webview application sur Cordova 4.0 + +## Plates-formes prises en charge Cordova + + * 4.0.0 Android ou supérieur + * iOS 4.0.0 ou supérieur + +## Navigation liste blanche + +Contrôle quels URL le WebView lui-même peut être parcourus à. S'applique à des navigations niveau supérieur seulement. + +Particularités : sur Android il s'applique également aux iframes pour non-schémas http (s). + +Par défaut, navigations qu'aux URL `file://` , sont autorisés. Pour permettre aux autres d'autres URL, vous devez ajouter des balises `` à votre `fichier config.xml`: + + + + + + + + + + + + + + + + +## Intent Whitelist + +Contrôle quels URL l'app n'est autorisé à poser le système d'ouverture. Par défaut, aucun external URL est autorisés. + +Sur Android, cela équivaut à envoyer une intention de type BROWSEABLE. + +Cette autorisation ne s'applique pas aux plugins, uniquement les liens hypertexte et les appels à `window.open()`. + +Dans le `fichier config.xml`, ajouter des balises `` , comme ceci : + + + + + + + + + + + + + + + + + + + + + + + + +## Réseau demande liste blanche + +Les contrôles dont les demandes de réseau (images, XHRs, etc.) sont autorisés à effectuer (via cordova natif crochets). + +Remarque : Nous vous suggérons de qu'utiliser un contenu politique de sécurité (voir ci-dessous), qui est plus sûr. Cette liste blanche est surtout historique pour webviews qui ne prennent pas en charge les CSP. + +Dans le `fichier config.xml`, ajouter des balises `` , comme ceci : + + + + + + + + + + + + + + + + + + +Sans les balises `` , seules les demandes d'URL `file://` sont autorisés. Toutefois, l'application de Cordoue par défaut inclut `` par défaut. + +Bizarrerie : Android permet également aux requêtes à https://ssl.gstatic.com/accessibility/javascript/android/ par défaut, puisque c'est nécessaire pour TalkBack fonctionner correctement. + +### Politique de sécurité du contenu + +Les contrôles dont les demandes de réseau (images, XHRs, etc.) sont autorisés à effectuer (via webview directement). + +Sur Android et iOS, la réseau demande liste blanche (voir ci-dessus) n'est pas en mesure de filtrer tous les types de demandes (p. ex. `< video >` & WebSockets ne sont pas bloquées). Ainsi, en plus de la liste blanche, vous devez utiliser une balise `< meta >` de [Contenu politique de sécurité](http://content-security-policy.com/) sur toutes vos pages. + +Sur Android, support pour le CSP dans le système webview commence par KitKat (mais n'est disponible sur toutes les versions à l'aide du tableau de concordance WebView). + +Voici quelques exemples de déclarations de CSP pour vos pages `.html` : + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/it/README.md new file mode 100644 index 00000000..157dc036 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/it/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +Questo plugin attua una politica di whitelist per spostarsi all'interno dell'applicazione webview in Cordova 4.0 + +## Piattaforme supportate Cordova + + * Android 4.0.0 o superiore + * iOS 4.0.0 o superiore + +## Navigazione Whitelist + +Controlla quali URL WebView stessa può essere esplorato. Si applica al solo primo livello navigazioni. + +Stranezze: su Android vale anche per gli iframe per non-schemi di http (s). + +Per impostazione predefinita, navigazioni solo agli URL `file://` , sono ammessi. Per consentire altri altri URL, è necessario aggiungere `` tag per il tuo `config. XML`: + + + + + + + + + + + + + + + + +## Whitelist intento + +Controlla quali URL app è consentito richiedere il sistema di apertura. Per impostazione predefinita, nessun esterno URL sono ammessi. + +Su Android, ciò equivale all'invio di un intento di tipo BROWSEABLE. + +Questa whitelist non si applica ai plugin, solo i collegamenti ipertestuali e chiamate a `Window`. + +In `config. XML`, aggiungere tag `` , simile al seguente: + + + + + + + + + + + + + + + + + + + + + + + + +## Rete richiesta Whitelist + +Controlli che le richieste di rete (immagini, XHRs, ecc.) sono consentiti (tramite ganci nativo di cordova). + +Nota: Si consiglia di che utilizzare un criterio di protezione contenuti (Vedi sotto), che è più sicuro. La whitelist è principalmente storico per visualizzazioni Web che non supportano la CSP. + +In `config. XML`, aggiungere tag `< access >` , simile al seguente: + + + + + + + + + + + + + + + + + + +Senza qualsiasi tag `< access >` , sono consentite solo le richieste di URL `file://` . Tuttavia, l'applicazione di Cordova predefinito include `< access origin = "*" >` per impostazione predefinita. + +Stranezza: Android consente anche alle richieste di https://ssl.gstatic.com/accessibility/javascript/android/ per impostazione predefinita, poiché questa operazione è necessaria per TalkBack funzionare correttamente. + +### Politica di sicurezza del contenuto + +Controlli che le richieste di rete (immagini, XHRs, ecc.) possono essere effettuate (via webview direttamente). + +Su Android e iOS, la rete richiesta whitelist (Vedi sopra) non è in grado di filtrare tutti i tipi di richieste (ad esempio non sono bloccate `< video >` & WebSockets). Così, oltre alla whitelist, è necessario utilizzare un tag `< meta >` [Content Security Policy](http://content-security-policy.com/) su tutte le pagine. + +Su Android, supporto per CSP all'interno webview sistema inizia con KitKat (ma è disponibile su tutte le versioni usando Crosswalk WebView). + +Ecco alcuni esempi di dichiarazioni di CSP per le pagine `HTML` : + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/ja/README.md new file mode 100644 index 00000000..6db17f1e --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/ja/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +ã“ã®ãƒ—ラグイン実装コルドム4.0 アプリケーション webview をナビゲートã™ã‚‹ãŸã‚ã®ãƒ›ãƒ¯ã‚¤ãƒˆ リスト ãƒãƒªã‚·ãƒ¼ + +## サãƒãƒ¼ãƒˆã•れã¦ã„るコルドãƒã®ãƒ—ラットフォーム + + * アンドロイド 4.0.0 以上 + * iOS 4.0.0 以上 + +## ナビゲーションã®ãƒ›ãƒ¯ã‚¤ãƒˆ リスト + +WebView 自体ã«ç§»å‹•ã« Url を制御ã—ã¾ã™ã€‚最上ä½ãƒŠãƒ“ゲーションã®ã¿ã«é©ç”¨ã•れã¾ã™ã€‚ + +ç™–: Android ã«ã‚‚ã«é©ç”¨ã•れã¾ã™ã® iframe éž-[http スキーム。 + +既定ã§ã¯ã€ãƒŠãƒ“ゲーション〠`file://`ã® Url ã«ã®ã¿è¨±å¯ã•れã¾ã™ã€‚ãã®ä»–ã®ä»–ã® Url を許å¯ã™ã‚‹ã‚ˆã†ã«ã€ `config.xml`ã«``タグを追加ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ + + + + + + + + + + + + + + + + +## インテントã®ãƒ›ãƒ¯ã‚¤ãƒˆ リスト + +ã©ã® Url ã‚’é–‹ãよã†ã«ã‚·ã‚¹ãƒ†ãƒ ã‚’èžã„ã¦ã€ã‚¢ãƒ—リã«è¨±å¯ã‚’制御ã—ã¾ã™ã€‚ 既定ã§ã¯ã€å¤–部 Url 許å¯ã•れã¾ã›ã‚“。 + +人造人間ã€ã“れã¯åž‹ BROWSEABLE ã®æ„図をé€ä¿¡ã™ã‚‹ã“ã¨ã«ç›¸å½“ã—ã¾ã™ã€‚ + +ã“ã®ãƒ›ãƒ¯ã‚¤ãƒˆ リストã¯ãƒ—ラグインã®ã¿ãƒã‚¤ãƒ‘ーリンクãŠã‚ˆã³`window.open()`ã¸ã®å‘¼ã³å‡ºã—ã«ã¯é©ç”¨ã•れã¾ã›ã‚“。. + +`Config.xml`内ã®``ã‚¿ã‚°ã¯ã€ã“ã®ã‚ˆã†ãªã‚’追加ã—ã¾ã™ã€‚ + + + + + + + + + + + + + + + + + + + + + + + + +## ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯è¦æ±‚ã®ãƒ›ãƒ¯ã‚¤ãƒˆ リスト + +ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯è¦æ±‚コントロール (ç”»åƒã€XHRs ç­‰) (コルドムãƒã‚¤ãƒ†ã‚£ãƒ– フック) を介ã—ã¦è¡Œã‚れるã“ã¨ãŒã€‚ + +注: より安全ãªã‚³ãƒ³ãƒ†ãƒ³ãƒ„ セキュリティ ãƒãƒªã‚·ãƒ¼ (下記å‚ç…§) を使用ã—ã¦ãŠå‹§ã‚ã—ã¾ã™ã€‚ ã“ã®ãƒ›ãƒ¯ã‚¤ãƒˆ リストã»ã¨ã‚“ã©ã® CSP をサãƒãƒ¼ãƒˆã—ã¦ã„ãªã„ web 表示ã®ãŸã‚ã«æ­´å²çš„ã§ã™ã€‚ + +`Config.xml`内ã®ã“ã®ã‚ˆã†ãª``タグを追加ã—ã¾ã™ã€‚ + + + + + + + + + + + + + + + + + + +``ã‚¿ã‚°ã€ãªã—`file://` Url ã«è¦æ±‚ã®ã¿ã‚’許å¯ã—ã¾ã™ã€‚ ãŸã ã—ã€æ—¢å®šã®ã‚³ãƒ«ãƒ‰ãƒ アプリケーションãŒå«ã¾ã‚Œã¦ã„ã¾ã™``デフォルトã§ã€‚ + +æ°—ã¾ãれ: ã‚¢ãƒ³ãƒ‰ãƒ­ã‚¤ãƒ‰ã‚‚è¦æ±‚ã§ãã¾ã™ https://ssl.gstatic.com/accessibility/javascript/android/デフォルトã§ã¯ã€ãƒˆãƒ¼ã‚¯ãŒæ­£å¸¸ã«æ©Ÿèƒ½ã™ã‚‹ãŸã‚ã«å¿…è¦ã§ã™ã®ã§ã€‚ + +### コンテンツã®ã‚»ã‚­ãƒ¥ãƒªãƒ†ã‚£ ãƒãƒªã‚·ãƒ¼ + +ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯è¦æ±‚コントロール (ç”»åƒã€XHRs ç­‰) (直接 webview) を介ã—ã¦è¡Œã‚れるã“ã¨ãŒã€‚ + +Android 㨠iOS ã¯ã€ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯è¦æ±‚ホワイト リスト (上記å‚ç…§) ã¯ã™ã¹ã¦ã®ç¨®é¡žã®è¦æ±‚ (例: `< ビデオ >` & Websocket ãŒãµã•ãŒã‚Œã¦ã„ãªã„) をフィルター処ç†ã§ãã¾ã›ã‚“。 ã ã‹ã‚‰ã€ãƒ›ãƒ¯ã‚¤ãƒˆ リストã«åŠ ãˆã¦ã™ã¹ã¦ã®ãƒšãƒ¼ã‚¸ã«[コンテンツ セキュリティ ãƒãƒªã‚·ãƒ¼](http://content-security-policy.com/) `< meta >`タグを使用ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ + +Android 上システム webview 内 CSP サãƒãƒ¼ãƒˆ キットカットã‹ã‚‰å§‹ã¾ã‚Šã¾ã™ (ã—ã‹ã—æ¨ªæ–­æ­©é“ WebView を使用ã—ã¦ã™ã¹ã¦ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§åˆ©ç”¨å¯èƒ½ã§ã™)。 + +`.Html`ページã®ã„ãã¤ã‹ã®ä¾‹ CSP ã®å®£è¨€ã¯æ¬¡ã®ã¨ãŠã‚Šã§ã™ã€‚ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/ko/README.md new file mode 100644 index 00000000..4cbae914 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/ko/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +ì´ í”ŒëŸ¬ê·¸ì¸ êµ¬í˜„ 코르ë„ë°” 4.0 ì‘ìš© 프로그램 webview를 íƒìƒ‰ì— 대 한 허용 ì •ì±… + +## ì§€ì›ëœ 코르ë„ë°” í”Œëž«í¼ + + * 안 드 로ì´ë“œ 4.0.0 ì´ìƒ + * iOS 4.0.0 ì´ìƒ + +## íƒìƒ‰ 허용 + +WebView ìžì²´ê°€ íƒìƒ‰í•  수 있는 Urlì„ ì œì–´ 합니다. 최ìƒìœ„ íƒìƒ‰ì—ë§Œ ì ìš© ë©ë‹ˆë‹¤. + +단ì : 안 드 로ì´ë“œì—ë„ ì ìš© ë©ë‹ˆë‹¤ iframeì— ëŒ€ 한 비-í”„ë¡œí† ì½œì¸ ê³„íš. + +기본ì ìœ¼ë¡œ íƒìƒ‰ `file://` Urlì—ë§Œ 사용할 수 있습니다. 다른 다른 Urlì„ í—ˆìš© 하려면 `config.xml`ì— `< allow-navigation >` 태그를 추가 해야 합니다. + + + + + + + + + + + + + + + + +## ì˜ë„ 허용 + +App 시스템 ì—´ì„ ê²Œ 허용 ë˜ëŠ” Urlì„ ì œì–´ 합니다. 기본ì ìœ¼ë¡œ 외부 Urlì€ ì‚¬ìš©í•  수 있습니다. + +안 드 로ì´ë“œì—ì´ í˜•ì‹ì˜ BROWSEABLE ì˜ë„ 보내는 것 같습니다. + +ì´ í—ˆìš© ëœ í”ŒëŸ¬ê·¸ì¸, 하ì´í¼ë§í¬ ë° `window.open ()` í˜¸ì¶œì— ì ìš© ë˜ì§€ 않습니다.. + +`Config.xml`ì—ì´ ê°™ì€ `< allow-intent >` 태그를 추가 합니다. + + + + + + + + + + + + + + + + + + + + + + + + +## ë„¤íŠ¸ì›Œí¬ ìš”ì²­ 허용 + +ìš”ì²­ì„ ë„¤íŠ¸ì›Œí¬ ì»¨íŠ¸ë¡¤ (ì´ë¯¸ì§€, XHRs, 등) (코르ë„ë°” 네ì´í‹°ë¸Œ 후í¬)를 통해 í•  수 있습니다. + +참고: ë‹¹ì‹ ì´ ì‚¬ìš© 콘í…츠 보안 ì •ì±… (아래 참조), ë” ì•ˆì „í•œ ê²ƒì´ ì¢‹ìŠµë‹ˆë‹¤. ì´ í—ˆìš©ì€ CSP를 ì§€ì› í•˜ì§€ 않는 webviewsì— ëŒ€ 한 역사ì . + +`Config.xml`ì—ì´ ê°™ì€ `< access >` 태그를 추가 합니다. + + + + + + + + + + + + + + + + + + +ì–´ë–¤ `< access >` 태그 ì—†ì´ ìš”ì²­ `file://` Url 사용할 수 있습니다. 그러나 기본 코르ë„ë°” ì‘ìš© í”„ë¡œê·¸ëž¨ì„ í¬í•¨ 하는, `< access origin="*" >` 기본ì ìœ¼ë¡œ. + +특질: 안 드 로ì´ë“œ ë˜í•œ 수 있습니다 ìš”ì²­ì„ https://ssl.gstatic.com/accessibility/javascript/android/ 기본ì ìœ¼ë¡œ í•„ìš” 제대로 ìž‘ë™ í•˜ë ¤ë©´ ì˜ê²¬ ì´ë¯€ë¡œ. + +### 콘í…츠 보안 ì •ì±… + +ìš”ì²­ì„ ë„¤íŠ¸ì›Œí¬ ì»¨íŠ¸ë¡¤ (ì´ë¯¸ì§€, XHRs, 등) (webview ì§ì ‘)를 통해 í•  수 있습니다. + +안 드 로ì´ë“œì™€ iOSì— ë„¤íŠ¸ì›Œí¬ ìš”ì²­ 허용 (위 참조)는 모든 ì¢…ë¥˜ì˜ ìš”ì²­ (예: `< 비디오 >` & WebSockets 차단 ë˜ì§€ 않습니다)를 í•„í„°ë§ í•  수 없습니다. 그래서, 허용, ë¿ë§Œ ì•„ë‹ˆë¼ ê·€í•˜ì˜ ëª¨ë“  페ì´ì§€ì— [콘í…츠 보안 ì •ì±…](http://content-security-policy.com/) `< meta >` 태그를 사용 해야 합니다. + +안 드 로ì´ë“œ, 시스템 webview ë‚´ì—서 CSPì— ëŒ€ 한 ì§€ì›ì„ KitKat 시작 (하지만 횡단 ë³´ë„ WebView를 사용 하 ì—¬ 모든 버전ì—서 사용할 수). + +다ìŒì€ `.html` 페ì´ì§€ì— 대 한 몇 가지 예제 CSP 선언입니다. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/pl/README.md new file mode 100644 index 00000000..ecdc3d5c --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/pl/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +Ten plugin wdraża polityki biaÅ‚ej nawigacja widoku sieci Web aplikacji na Cordova 4.0 + +## Cordova obsÅ‚ugiwanych platform + + * Android 4.0.0 lub powyżej + * iOS 4.0.0 lub powyżej + +## BiaÅ‚a lista nawigacji + +Kontroluje, których adresy URL widoku sieci Web, samej można nawigować do. Dotyczy tylko najwyższego poziomu nawigacje. + +Dziwactwa: na Android to dotyczy także IFRAME do nie-http (s) systemów. + +DomyÅ›lnie, nawigacje tylko do URLi `file://` , sÄ… dozwolone. Aby zezwolić na inne adresy URL, należy dodać Tagi `< allow-navigation >` do pliku `config.xml`: + + + + + + + + + + + + + + + + +## Zamiarem biaÅ‚a + +Kontroluje, których adresy URL aplikacji jest możliwość zapytać systemem otwierania. DomyÅ›lnie nie ma zewnÄ™trznych adresów URL sÄ… dozwolone. + +Na Android to przyrównuje do wysyÅ‚ania zamiarem typu BROWSEABLE. + +Ta biaÅ‚a nie ma zastosowania do pluginów, tylko hiperłącza i wywoÅ‚ania `window.open()`. + +W `pliku config.xml`dodawanie tagów `< allow-intent >` , jak to: + + + + + + + + + + + + + + + + + + + + + + + + +## Sieci wniosek biaÅ‚a + +Formanty, które sieci żądaÅ„ (obrazy, XHRs, itp.) mogÄ… być wykonane (za poÅ›rednictwem cordova rodzimych haki). + +Uwaga: Zalecamy, że używasz treÅ›ci polityki bezpieczeÅ„stwa (patrz poniżej), który jest bardziej bezpieczne. Ta BiaÅ‚a jest głównie historyczne dla webviews, które nie obsÅ‚ugujÄ… CSP. + +W `pliku config.xml`dodawanie tagów `< access >` , jak to: + + + + + + + + + + + + + + + + + + +Bez żadnych tagów `< access >` dozwolone sÄ… tylko żądania do URLi `file://` . Jednak domyÅ›lnie Cordova aplikacja zawiera `< access origin = "*" >` domyÅ›lnie. + +Cokół: Android pozwala również żądania do https://ssl.gstatic.com/accessibility/javascript/android/ domyÅ›lnie, ponieważ jest to wymagane dla TalkBack wobec funkcja poprawnie. + +### Zasady zabezpieczeÅ„ zawartoÅ›ci + +Formanty, które sieci żądaÅ„ (obrazy, XHRs, itp.) mogÄ… być wykonane (za pomocÄ… widoku sieci Web bezpoÅ›rednio). + +Na Androida i iOS biaÅ‚a żądanie sieci (patrz wyżej) nie jest w stanie filtrować wszystkie rodzaje wniosków (np. `< video >` & WebSockets nie sÄ… zablokowane). Tak oprócz biaÅ‚ej listy, należy użyć tagu `< meta >` [TreÅ›ci polityki bezpieczeÅ„stwa](http://content-security-policy.com/) na wszystkich stronach. + +Na Android wsparcie dla CSP w ramach systemu widoku sieci Web zaczyna KitKat (ale jest dostÄ™pne we wszystkich wersjach przy użyciu widoku sieci Web przejÅ›cie dla pieszych). + +Oto niektóre przykÅ‚ad CSP deklaracje dla strony `HTML` : + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-whitelist/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-whitelist/doc/zh/README.md new file mode 100644 index 00000000..c2c7e112 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-whitelist/doc/zh/README.md @@ -0,0 +1,148 @@ + + +# cordova-plugin-whitelist + +這個外掛程å¼å¯¦ç¾ä¸€å€‹ç”¨æ–¼å°Žèˆªåœ¨ç§‘爾多瓦 4.0 æ‡‰ç”¨ç¨‹å¼ web 視圖的白å單策略 + +## 支æ´çš„科爾多瓦平臺 + + * Android 4.0.0 或以上 + * iOS 4.0.0 或以上 + +## 導航白åå–® + +控制 web 視圖本身å¯ä»¥å°Žèˆªåˆ°çš„ Url。é©ç”¨äºŽé ‚級導航åªã€‚ + +怪癖: 在 Android 上它也é©ç”¨äºŽ iframe çš„éž-çµè¨ˆç•«ã€‚ + +é è¨­æƒ…æ³ä¸‹ï¼Œåªæœ‰åˆ°`file://` Url 導航å…許。若è¦å…許其他其他 Url,必須將``標籤添加到您的`config.xml`: + + + + + + + + + + + + + + + + +## 科爾多瓦-外掛程å¼-白åå–® + +控制應用程å¼å…許讓系統打開的 Url。 é è¨­æƒ…æ³ä¸‹ï¼Œæ²’有外部 Url å…許。 + +在 android 系統,這相當於發é€é¡žåž‹ BROWSEABLE çš„æ„圖。 + +此白å單並ä¸é©ç”¨äºŽåªè¶…連çµå’Œå°`window.open ()`調用的外掛程å¼. + +在`config.xml`中添加``標籤,åƒé€™æ¨£: + + + + + + + + + + + + + + + + + + + + + + + + +## 網路請求白åå–® + +網路請求的控制項 (圖åƒï¼ŒXHRs ç­‰) å…許 (通éŽç§‘爾多瓦本機掛鉤)。 + +注æ„: 我們建議你使用內容的安全性原則 (見下文),這是更安全。 此白å單大多是為 webviews 䏿”¯æ´ CSP 的歷å²ã€‚ + +在`config.xml`中添加``標記,åƒé€™æ¨£: + + + + + + + + + + + + + + + + + + +沒有任何``標籤,åªåˆ°`file://` Url å…許請求。 但是,é è¨­çš„科爾多瓦應用程å¼åŒ…括`` ,é è¨­æƒ…æ³ã€‚ + +怪癖: Android é‚„å…è¨±å° HTTPs://ssl.gstatic.com/accessibility/javascript/android/ 請求é è¨­æƒ…æ³ä¸‹ï¼Œå› ç‚ºé€™æ˜¯å°è¬›æ­£å¸¸æ‰€éœ€ã€‚ + +### 內容安全政策 + +網路請求的控制項 (圖åƒï¼ŒXHRs ç­‰) å…許 (é€šéŽ web 視圖直接)。 + +å° Android å’Œ iOS,網路請求白åå–® (見上文) 是ä¸èƒ½å¤ éŽæ¿¾æ‰€æœ‰é¡žåž‹çš„請求 (例如`