From 66ae70c12f4592fdd565119ab8e6ca7af64096be Mon Sep 17 00:00:00 2001 From: Elizabeth Graham Date: Tue, 28 Jan 2020 10:03:21 -0500 Subject: [PATCH] Added plugin and native ionic code (#18) * Added plugin and native ionic code * Removed the cognitive services plugin .DS_Store file from gitignore, and added all .DS_Store files. --- .gitignore | 6 + README.md | 194 ++- cogservPlugin/.idea/codeStyles/Project.xml | 116 ++ cogservPlugin/.idea/gradle.xml | 19 + cogservPlugin/.idea/misc.xml | 5 + cogservPlugin/.idea/vcs.xml | 6 + cogservPlugin/.idea/workspace.xml | 335 +++++ cogservPlugin/README.md | 315 ++++ cogservPlugin/cognitiveservicesPlugin.iml | 8 + cogservPlugin/config.xml | 28 + .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 56177 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + cogservPlugin/gradlew | 172 +++ cogservPlugin/gradlew.bat | 84 ++ cogservPlugin/package-lock.json | 1309 +++++++++++++++++ cogservPlugin/package.json | 31 + cogservPlugin/plugin.xml | 57 + cogservPlugin/plugins/android.json | 15 + cogservPlugin/plugins/browser.json | 15 + .../cordova-plugin-whitelist/CONTRIBUTING.md | 37 + .../plugins/cordova-plugin-whitelist/LICENSE | 202 +++ .../plugins/cordova-plugin-whitelist/NOTICE | 5 + .../cordova-plugin-whitelist/README.md | 167 +++ .../cordova-plugin-whitelist/RELEASENOTES.md | 87 ++ .../cordova-plugin-whitelist/package.json | 67 + .../cordova-plugin-whitelist/plugin.xml | 44 + .../src/android/WhitelistPlugin.java | 161 ++ .../cordova-plugin-whitelist/tests/README.md | 53 + .../tests/package.json | 15 + .../cordova-plugin-whitelist/tests/plugin.xml | 56 + .../tests/scripts/remove-access.js | 19 + .../tests/src/android/WhitelistAPI.java | 90 ++ .../cordova-plugin-whitelist/tests/tests.js | 214 +++ .../tests/www/whitelist.js | 34 + cogservPlugin/plugins/fetch.json | 10 + cogservPlugin/src/.DS_Store | Bin 0 -> 6148 bytes .../src/android/CognitiveServices.gradle | 17 + .../src/android/CognitiveServices.java | 174 +++ cogservPlugin/src/ios/.DS_Store | Bin 0 -> 6148 bytes cogservPlugin/src/ios/CDVCognitiveServices.h | 21 + cogservPlugin/src/ios/CDVCognitiveServices.m | 185 +++ cogservPlugin/www/cognitiveservices.js | 37 + cogservicesNative/index.d.ts | 47 + cogservicesNative/index.js | 39 + cogservicesNative/ngx/index.d.ts | 45 + cogservicesNative/ngx/index.js | 48 + cogservicesNative/ngx/index.metadata.json | 42 + 47 files changed, 4634 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 cogservPlugin/.idea/codeStyles/Project.xml create mode 100644 cogservPlugin/.idea/gradle.xml create mode 100644 cogservPlugin/.idea/misc.xml create mode 100644 cogservPlugin/.idea/vcs.xml create mode 100644 cogservPlugin/.idea/workspace.xml create mode 100644 cogservPlugin/README.md create mode 100644 cogservPlugin/cognitiveservicesPlugin.iml create mode 100644 cogservPlugin/config.xml create mode 100644 cogservPlugin/gradle/wrapper/gradle-wrapper.jar create mode 100644 cogservPlugin/gradle/wrapper/gradle-wrapper.properties create mode 100644 cogservPlugin/gradlew create mode 100644 cogservPlugin/gradlew.bat create mode 100644 cogservPlugin/package-lock.json create mode 100644 cogservPlugin/package.json create mode 100644 cogservPlugin/plugin.xml create mode 100644 cogservPlugin/plugins/android.json create mode 100644 cogservPlugin/plugins/browser.json create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/CONTRIBUTING.md create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/LICENSE create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/NOTICE create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/README.md create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/RELEASENOTES.md create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/package.json create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/plugin.xml create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/tests/README.md create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/tests/package.json create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/tests/plugin.xml create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/tests/scripts/remove-access.js create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/tests/src/android/WhitelistAPI.java create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/tests/tests.js create mode 100644 cogservPlugin/plugins/cordova-plugin-whitelist/tests/www/whitelist.js create mode 100644 cogservPlugin/plugins/fetch.json create mode 100644 cogservPlugin/src/.DS_Store create mode 100644 cogservPlugin/src/android/CognitiveServices.gradle create mode 100644 cogservPlugin/src/android/CognitiveServices.java create mode 100644 cogservPlugin/src/ios/.DS_Store create mode 100644 cogservPlugin/src/ios/CDVCognitiveServices.h create mode 100644 cogservPlugin/src/ios/CDVCognitiveServices.m create mode 100644 cogservPlugin/www/cognitiveservices.js create mode 100644 cogservicesNative/index.d.ts create mode 100644 cogservicesNative/index.js create mode 100644 cogservicesNative/ngx/index.d.ts create mode 100644 cogservicesNative/ngx/index.js create mode 100644 cogservicesNative/ngx/index.metadata.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30f4f71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +cogservPlugin/node_modules/ +cogservPlugin/.gradle/ +cogservPlugin/platforms/ +cogservPlugin/src/ios/MicrosoftCognitiveServicesSpeech.framework/ +cogservPlugin/aar diff --git a/README.md b/README.md index dd3466e..65d1430 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,192 @@ -# cordova-plugin-cogsvcsspeech -Cordova plugin for Microsoft Cognitive Services speech services. +# Ionic Application + +The Ionic application was build with the +[Ionic framework](https://ionicframework.com/), an open-source front-end +development kit for building cross-platform mobile apps with HTML5 and Javascript. + +## Getting started + +First, install [Node.js](https://nodejs.org/en/). The cognitive services plugin supports Node version 10.9 or greater. + +Next, install Ionic using the following command: + +```bash +npm install -g ionic +``` + +Note: Visual Studio Code was used for development and ionic was installed +through VS Code. + +## Dependencies + +### Create a Speech resource in Azure + +To add a Speech Services resource to your Azure account: + +1. Sign in to the [Azure portal](https://portal.azure.com/) using your Microsoft +account. + +1. Select **Create a resource** at the top left of the portal. + + ![Create a resource](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/media/index/try-speech-api-create-speech1.png) + +1. In the **New** window, search for **speech**. + +1. In the search results, select **Speech**. + + ![Select Speech](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/media//index/try-speech-api-create-speech2.png) + +1. Under **Speech**, select the **Create** button. + + ![Select the Create button](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/media//index/try-speech-api-create-speech3.png) + +1. Under **Create**, enter: + + * A name for the new resource. The name helps you distinguish among multiple + subscriptions to the same service. + * Choose the Azure subscription that the new resource is associated with to + determine how the fees are billed. + * Choose the region where the resource will be used. + * Choose either a free or paid pricing tier. + * Create a new resource group for this Speech subscription or assign the + subscription to an existing resource group. Resource groups help you keep your + various Azure subscriptions organized. + * Select **Create.** + + ![Select the Create button](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/media/index/try-speech-api-create-speech4.png) + + It takes a moment to create and deploy your new Speech resource. Select + **Quickstart** to see information about your new resource. + + ![Quickstart panel](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/media//index/try-speech-api-create-speech5.png) + +1. Under **Quickstart**, select the **Keys** link under step 1 to display your +subscription keys. Each subscription has two keys; you can use either key in your +application. Select the button next to each key to copy it to the clipboard for +pasting into the [Environment.ts](\src\environments\environment.ts) file. +1. Copy the name of the Speech Service and the region of the service into the +Environments.ts file. + +## Install packages using NPM + +In the folder of the Ionic Application (ie examples/ionic-angular), run the following steps. + +Run the following command to install all packages within the app. In a terminal +window, browse to the speecthtoText folder +and run the following: + +```bash +npm install +``` + +Install Native-Run so that the application can run the cordova native platforms (android, ios, or browser) + +```bash +npm i -g native-run +``` + +Install Cordova + +```bash +npm i -g cordova +``` + +To include the wrapper for the Cognitive Services plugin as an observable, run the following command: + +```bash +cp -r ../cogservicesNative ../examples/ionic-angular/node_modules/@ionic-native/ +``` + +While this should install all components, there have been a few changes to +cordova recently and errors were being generated while devloping on the Mac. +If you get errors, specifically using toLowerCase, the run the following commands: + +```bash +npm uninstall cordova +npm install cordova@latest +cordova platform remove ios +cordova platform add ios +``` + +## Run it Application + +### Run on Browser + +To run the application, in a terminal window, browse to the speecthtoText folder +and run the following: + +```bash +ionic cordova run browser +``` + +### Run in Android Emulator + +#### Setting up Android environment + +These steps are to set up your SDK environment to build, test, and deploy +Android apps. + +1. Install [Java Development Kit (JDK) 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) + or later. +1. Install [Gradle](https://gradle.org/). Go through each steps on the +[Gradle Installation](https://gradle.org/install/) page. +1. Install [Android Studio](https://developer.android.com/studio/index.html). +1. After installing Android Studio, run the Android Studio Setup Wizard to +download some standard components that are required for development. + +#### Creating an emulator + +1. In Android Studio, click the AVD Manager in the Toolbar. + + ![AVD Manager](img/avdmanager.png) + +1. In the Select Deployment Target window, click Create New Virtual Device. + + ![Create Virtual Device](img/createvirtualdevice.png) + +1. Select a device configuration of your choice and press Next. + + ![Device Configuration](img/deviceconfiguration.png) + +1. Download and select a system image. Press next. + + ![System Image](img/systemimage.png) + +1. Verify configuration and press finish. + + ![Verify](img/verifyinstallation.png) + +1. In the Virtual Device Manager, select the run button to start the emulator. + + ![Run](img/verifyinstallation.png) + +#### Run Android Application + +To run the application, in a terminal window, browse to the speecthtoText folder +and run the following: + +```bash +ionic cordova run android +``` + +### Run in iOS Emulator + +#### Setting up iOS environment + +These steps are to set up your SDK environment to build, test, and deploy +iOS apps. This will only work on a Mac. + +1. Install [XCode](https://developer.apple.com/download/) with Apple Developer +account, or download from the App Store. + +#### Run iOS Application + +To run the application, in a terminal window, browse to the speecthtoText folder +and run the following: + +```bash +ionic cordova run ios +``` + +By participating in this project, you +agree to abide by the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) diff --git a/cogservPlugin/.idea/codeStyles/Project.xml b/cogservPlugin/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/cogservPlugin/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/cogservPlugin/.idea/gradle.xml b/cogservPlugin/.idea/gradle.xml new file mode 100644 index 0000000..f885d59 --- /dev/null +++ b/cogservPlugin/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/cogservPlugin/.idea/misc.xml b/cogservPlugin/.idea/misc.xml new file mode 100644 index 0000000..aecc280 --- /dev/null +++ b/cogservPlugin/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cogservPlugin/.idea/vcs.xml b/cogservPlugin/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/cogservPlugin/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cogservPlugin/.idea/workspace.xml b/cogservPlugin/.idea/workspace.xml new file mode 100644 index 0000000..ab2a7e6 --- /dev/null +++ b/cogservPlugin/.idea/workspace.xml @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +