Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4DED51919F for ; Sat, 19 Mar 2016 09:36:18 +0000 (UTC) Received: (qmail 83839 invoked by uid 500); 19 Mar 2016 09:36:18 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 83720 invoked by uid 500); 19 Mar 2016 09:36:18 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 83469 invoked by uid 99); 19 Mar 2016 09:36:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Mar 2016 09:36:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9D80CE02D3; Sat, 19 Mar 2016 09:36:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: dblotsky@apache.org To: commits@cordova.apache.org Date: Sat, 19 Mar 2016 09:36:24 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [08/15] docs commit: Snapshotting dev to 6.x. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/android/plugin.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/android/plugin.md b/www/docs/en/6.x/guide/platforms/android/plugin.md index a30d2f8..719c102 100644 --- a/www/docs/en/6.x/guide/platforms/android/plugin.md +++ b/www/docs/en/6.x/guide/platforms/android/plugin.md @@ -39,9 +39,9 @@ overrides one of its `execute` methods. The plugin's JavaScript interface uses the `cordova.exec` method as follows: - - exec(, , , , []); - +```js +exec(, , , , []); +``` This marshals a request from the WebView to the Android native side, effectively calling the `action` method on the `service` class, with additional arguments passed in the `args` array. @@ -52,9 +52,11 @@ application's `res/xml/config.xml` file. See Application Plugins for more information on how to use the `plugin.xml` file to inject this `feature` element: - - - +```xml + + + +``` The service name matches the one used in the JavaScript `exec` call. The value is the Java class's fully qualified namespace identifier. @@ -67,18 +69,22 @@ One instance of a plugin object is created for the life of each referenced by a call from JavaScript, unless `` with an `onload` `name` attribute is set to `"true"` in `config.xml`. For example, - - - - +```xml + + + + +``` Plugins should use the `initialize` method for their start-up logic. - @Override - public void initialize(CordovaInterface cordova, CordovaWebView webView) { - super.initialize(cordova, webView); - // your init code here - } +```java +@Override +public void initialize(CordovaInterface cordova, CordovaWebView webView) { + super.initialize(cordova, webView); + // your init code here +} +``` Plugins also have access to Android lifecycle events and can handle them by extending one of the provided methods (`onResume`, `onDestroy`, etc). @@ -96,15 +102,17 @@ Whatever is dispatched to the plugin with JavaScript's `exec` function is passed into the plugin class's `execute` method. Most `execute` implementations look like this: - @Override - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if ("beep".equals(action)) { - this.beep(args.getLong(0)); - callbackContext.success(); - return true; - } - return false; // Returning false results in a "MethodNotFound" error. - } +```java +@Override +public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + if ("beep".equals(action)) { + this.beep(args.getLong(0)); + callbackContext.success(); + return true; + } + return false; // Returning false results in a "MethodNotFound" error. +} +``` The JavaScript `exec` function's `action` parameter corresponds to a private class method to dispatch with optional parameters. @@ -121,40 +129,44 @@ does the `execute` method. If you need to interact with the user interface, you should use the [Activity's `runOnUiThread`][ref-runonuithread] method like so: - @Override - public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - if ("beep".equals(action)) { - final long duration = args.getLong(0); - cordova.getActivity().runOnUiThread(new Runnable() { - public void run() { - ... - callbackContext.success(); // Thread-safe. - } - }); - return true; +```java +@Override +public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { + if ("beep".equals(action)) { + final long duration = args.getLong(0); + cordova.getActivity().runOnUiThread(new Runnable() { + public void run() { + ... + callbackContext.success(); // Thread-safe. } - return false; - } + }); + return true; + } + return false; +} +``` If you do not need to run on the UI thread, but do not wish to block the `WebCore` thread either, you should execute your code using the Cordova [`ExecutorService`][ref-executor] obtained with `cordova.getThreadPool()` like so: - @Override - public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - if ("beep".equals(action)) { - final long duration = args.getLong(0); - cordova.getThreadPool().execute(new Runnable() { - public void run() { - ... - callbackContext.success(); // Thread-safe. - } - }); - return true; +```java +@Override +public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { + if ("beep".equals(action)) { + final long duration = args.getLong(0); + cordova.getThreadPool().execute(new Runnable() { + public void run() { + ... + callbackContext.success(); // Thread-safe. } - return false; - } + }); + return true; + } + return false; +} +``` ## Adding Dependency Libraries @@ -183,50 +195,54 @@ To match the JavaScript interface's _echo_ feature described in Application Plugins, use the `plugin.xml` to inject a `feature` specification to the local platform's `config.xml` file: - - - - - - +```xml + + + + + + - - + + +``` Then add the following to the `src/android/Echo.java` file: - package org.apache.cordova.plugin; - - import org.apache.cordova.CordovaPlugin; - import org.apache.cordova.CallbackContext; +```java +package org.apache.cordova.plugin; - import org.json.JSONArray; - import org.json.JSONException; - import org.json.JSONObject; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CallbackContext; - /** - * This class echoes a string called from JavaScript. - */ - public class Echo extends CordovaPlugin { +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; - @Override - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("echo")) { - String message = args.getString(0); - this.echo(message, callbackContext); - return true; - } - return false; - } +/** +* This class echoes a string called from JavaScript. +*/ +public class Echo extends CordovaPlugin { + +@Override +public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + if (action.equals("echo")) { + String message = args.getString(0); + this.echo(message, callbackContext); + return true; + } + return false; +} - private void echo(String message, CallbackContext callbackContext) { - if (message != null && message.length() > 0) { - callbackContext.success(message); - } else { - callbackContext.error("Expected one non-empty string argument."); - } - } - } +private void echo(String message, CallbackContext callbackContext) { + if (message != null && message.length() > 0) { + callbackContext.success(message); + } else { + callbackContext.error("Expected one non-empty string argument."); + } +} +} +``` The necessary imports at the top of the file extends the class from `CordovaPlugin`, whose `execute()` method it overrides to receive @@ -268,9 +284,11 @@ the permissions, and these permissions need to be added to the Android Manifest. accomplished by using the `config.xml` to inject these permissions in the `AndroidManifest.xml` file. The example below uses the Contacts permission. - - - +```xml + + + +``` ### Runtime Permissions (Cordova-Android 5.0.0+) @@ -284,72 +302,87 @@ documentation [here][permissions-guide]. As far as a plugin is concerned, the permission can be requested by calling the permission method, which signature is as follows: - cordova.requestPermission(CordovaPlugin plugin, int requestCode, String permission); +```java +cordova.requestPermission(CordovaPlugin plugin, int requestCode, String permission); +``` To cut down on verbosity, it's standard practice to assign this to a local static variable: - public static final String READ = Manifest.permission.READ_CONTACTS; +```java +public static final String READ = Manifest.permission.READ_CONTACTS; +``` It is also standard practice to define the requestCode as follows: - public static final int SEARCH_REQ_CODE = 0; +```java +public static final int SEARCH_REQ_CODE = 0; +``` Then, in the exec method, the permission should be checked: - if(cordova.hasPermission(READ)) - { - search(executeArgs); - } - else - { - getReadPermission(SEARCH_REQ_CODE); - } +```java +if(cordova.hasPermission(READ)) +{ + search(executeArgs); +} +else +{ + getReadPermission(SEARCH_REQ_CODE); +} +``` In this case, we just call requestPermission: - protected void getReadPermission(int requestCode) - { - cordova.requestPermission(this, requestCode, READ); - } +```java +protected void getReadPermission(int requestCode) +{ + cordova.requestPermission(this, requestCode, READ); +} +``` This will call the activity and cause a prompt to appear asking for the permission. Once the user has the permission, the result must be handled with the `onRequestPermissionResult` method, which every plugin should override. An example of this can be found below: - public void onRequestPermissionResult(int requestCode, String[] permissions, - int[] grantResults) throws JSONException +```java +public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException +{ + for(int r:grantResults) { - for(int r:grantResults) + if(r == PackageManager.PERMISSION_DENIED) { - if(r == PackageManager.PERMISSION_DENIED) - { - this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR)); - return; - } - } - switch(requestCode) - { - case SEARCH_REQ_CODE: - search(executeArgs); - break; - case SAVE_REQ_CODE: - save(executeArgs); - break; - case REMOVE_REQ_CODE: - remove(executeArgs); - break; + this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR)); + return; } } - + switch(requestCode) + { + case SEARCH_REQ_CODE: + search(executeArgs); + break; + case SAVE_REQ_CODE: + save(executeArgs); + break; + case REMOVE_REQ_CODE: + remove(executeArgs); + break; + } +} +``` The switch statement above would return from the prompt and depending on the requestCode that was passed in, it would call the method. It should be noted that permission prompts may stack if the execution is not handled correctly, and that this should be avoided. In addition to asking for permission for a single permission, it is also possible to request permissions for an entire group by defining the permissions array, as what is done with the Geolocation plugin: - String [] permissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }; +```java +String [] permissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }; +``` Then when requesting the permission, all that needs to be done is the following: - cordova.requestPermissions(this, 0, permissions); +```java +cordova.requestPermissions(this, 0, permissions); +``` This requests the permissions specified in the array. It's a good idea to provide a publicly accessible permissions array since this can be used by plugins that use your plugin as a dependency, although this is not required. @@ -413,7 +446,7 @@ Instead, this replacement `CallbackContext` will return the result as part of th [`resume`][event-resume] event that is fired when the application resumes. The payload of the [`resume`][event-resume] event follows this structure: -``` +```text { action: "resume", pendingResult: { http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/android/upgrade.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/android/upgrade.md b/www/docs/en/6.x/guide/platforms/android/upgrade.md index d6dd685..c5c2865 100644 --- a/www/docs/en/6.x/guide/platforms/android/upgrade.md +++ b/www/docs/en/6.x/guide/platforms/android/upgrade.md @@ -32,7 +32,7 @@ version of the CLI. The best way to upgrade to 5.X.X is to simply remove the Android platform from your project and re-add it with the new version. For example, -``` +```bash cordova platform remove android cordova platform add android@5.X.X ``` @@ -44,7 +44,9 @@ discouraged). Alternatively, you may attempt to use the platform update script. For non-CLI projects, run: - bin/update path/to/project +`` +bin/update path/to/project +`` For CLI projects: @@ -78,7 +80,7 @@ For non-core plugins, you can verify if a plugin requests a `plugin.xml` file. If the plugin uses Android permissions, you will see entries in `plugin.xml` that declare them. For example: -``` +```xml ``` @@ -86,7 +88,7 @@ Where `PERMISSION_NAME` is replaced with the name of an Android permission. The `plugin.xml` file can be found in the plugin's folder in your Cordova project (e.g. `plugins/example-plugin/plugin.xml`). Consult the documentation of any plugins using dangerous permissions to determine what steps need to be taken -to ensure **cordova-android 5.0.0+** compatibility. +to ensure **cordova-android 5.0.0+** compatibility. ## Upgrading to 4.0.0 @@ -95,7 +97,9 @@ changes in 4.0.0. First, the common upgrade steps are needed as below. For non-CLI projects, run: - bin/update path/to/project +``` +bin/update path/to/project +``` For CLI projects: @@ -127,7 +131,9 @@ By default, your app will continue to use the system WebView provided by the device. If you wish to use the Crosswalk WebView instead, simply add the Crosswalk plugin: - cordova plugin add cordova-plugin-crosswalk-webview +```bash +cordova plugin add cordova-plugin-crosswalk-webview +``` Upon adding the plugin, your app will get the Crosswalk WebView installed and configured correctly. @@ -137,13 +143,17 @@ If your app makes use of a splash screen, that functionality has been moved to a plugin. The configuration options for splash screens are unchanged. The only upgrade step required is to add the plugin: - cordova plugin add cordova-plugin-splashscreen +```bash +cordova plugin add cordova-plugin-splashscreen +``` ## Upgrading to 3.7.1 from 3.6.0 For non-CLI projects, run: - bin/update path/to/project +``` +bin/update path/to/project +``` For CLI projects: http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/android/webview.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/android/webview.md b/www/docs/en/6.x/guide/platforms/android/webview.md index 24bcf12..b07ac6a 100644 --- a/www/docs/en/6.x/guide/platforms/android/webview.md +++ b/www/docs/en/6.x/guide/platforms/android/webview.md @@ -91,16 +91,16 @@ legacy `CordovaActivity` component that pre-dates the 1.9 release. public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) { this.activityResultCallback = command; this.activityResultKeepRunning = this.keepRunning; - + // If multitasking turned on, then disable it for activities that return results if (command != null) { this.keepRunning = false; } - + // Start activity super.startActivityForResult(intent, requestCode); - } - + } + @Override /** * Called when an activity you launched exits, giving you the requestCode you started it with, http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/blackberry/upgrade.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/blackberry/upgrade.md b/www/docs/en/6.x/guide/platforms/blackberry/upgrade.md index c608bb8..9d0bab2 100644 --- a/www/docs/en/6.x/guide/platforms/blackberry/upgrade.md +++ b/www/docs/en/6.x/guide/platforms/blackberry/upgrade.md @@ -338,14 +338,16 @@ Updating just the `www` directory: 6. Update the `www/plugins.xml` file. Two plugins changed their namespace/service label. Change the old entries for the Capture and Contact plugins from: - - - + ```xml + + + ``` To: - - - + ```xml + + + ``` Updating the sample directory (ie, updating using the ant tools): @@ -366,14 +368,16 @@ Updating the sample directory (ie, updating using the ant tools): 8. Open the `www` directory and update the `plugins.xml` file. Two plugins changed their namespace/service label. Change the old entries for the Capture and Contact plugins from: - - - + ```xml + + + ``` To: - - - + ```xml + + + ``` - To upgrade to 1.8.0, please go from 1.7.0 @@ -395,14 +399,16 @@ Updating just the `www` directory: 6. Update the `www/plugins.xml` file. Two plugins changed their namespace/service label. Change the old entries for the Capture and Contact plugins from: - - - + ```xml + + + ``` To: - - - + ```xml + + + ``` Updating the sample directory (ie, updating using the ant tools): @@ -423,12 +429,13 @@ Updating the sample directory (ie, updating using the ant tools): 8. Open the `www` directory and update the `plugins.xml` file. Two plugins changed their namespace/service label. Change the old entries for the Capture and Contact plugins from: - - - + ```xml + + + ``` To: - - - - + ```xml + + + ``` http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/blackberry10/config.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/blackberry10/config.md b/www/docs/en/6.x/guide/platforms/blackberry10/config.md index 9ffa87f..ce2d5c3 100644 --- a/www/docs/en/6.x/guide/platforms/blackberry10/config.md +++ b/www/docs/en/6.x/guide/platforms/blackberry10/config.md @@ -32,15 +32,17 @@ File](config_ref_index.md.html#The%20config.xml%20File) for information on globa to display resources accessed via `window.open()` or by specifying a `_blank` anchor target. Specify `disable` to override this default behavior. - - + ```xml + + ``` - `PopupBlocker` (`enable` or the default `disable`): Enables the popup blocker, which prevents calls to `window.open()`. By default, popups display in a child browser window. Setting the preference to `enable` prevents it from displaying at all. - - + ```xml + + ``` - `WebSecurity` (`disable` or the default `enable`): Set to `disable` to override web security settings, allowing access to remote content @@ -49,6 +51,6 @@ File](config_ref_index.md.html#The%20config.xml%20File) for information on globa distribution. For the released app, all URIs should be known and whitelisted using the `` element, described in the Domain [Whitelist Guide](../../appdev/whitelist/index.html). - - - + ```xml + + ``` http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/blackberry10/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/blackberry10/index.md b/www/docs/en/6.x/guide/platforms/blackberry10/index.md index a6063d3..0ce8760 100644 --- a/www/docs/en/6.x/guide/platforms/blackberry10/index.md +++ b/www/docs/en/6.x/guide/platforms/blackberry10/index.md @@ -30,7 +30,7 @@ For BlackBerry 10, you need to install the SDK regardless of whether you want to use the cross-platform Cordova CLI for development, or a narrower set of platform-centered command-line tools. For a comparison of the two development paths, see the [Overview](../../overview/index.html). For -details on each, see [Cordova CLI Reference] and the BlackBerry 10 +details on each, see [Cordova CLI Reference][cli] and the BlackBerry 10 Shell Tool Guide. ## Requirements @@ -75,46 +75,52 @@ On Windows: * Go to __My Computer → Properties → Advanced → Environment Variables__. * Append the Native SDK's install directory to the PATH, for example: - - ;C:\bbndk\host_10_1_0_132\win32\x86\usr\bin\ + ``` + ;C:\bbndk\host_10_1_0_132\win32\x86\usr\bin\ + ``` On Mac and Linux: * Edit the `~/.bash_profile` file, adding a line such as the following, depending on where the Native SDK was installed: + ```bash + export PATH=${PATH}:/Applications/bbndk/host_10_1_0_132/darwin/x86/usr/bin/ - $ export PATH=${PATH}:/Applications/bbndk/host_10_1_0_132/darwin/x86/usr/bin/ - - or for the 10.2 Native SDK: - - $ export PATH=${PATH}:/Applications/Momentics.app/host_10_2_0_15/darwin/x86/usr/bin/ + # or for the 10.2 Native SDK: + export PATH=${PATH}:/Applications/Momentics.app/host_10_2_0_15/darwin/x86/usr/bin/ + ``` * Run the following to apply the change in the current session: - - $ source ~/.bash_profile + ```bash + $ source ~/.bash_profile + ``` If you got any environmental problem, using the Native SDK from the command line, execute the appropriate file for your platform, located within the installation path: * On Windows → MS-DOS shell: - - C:\> \bbndk\bbndk-env_xx_xx_xx_xxxx.bat + ``` + C:\> \bbndk\bbndk-env_xx_xx_xx_xxxx.bat + ``` * On Windows → git bash shell: - - $ `\bbndk\bbndk-env_xx_xx_xx_xxxx.bat` + ``` + $ `\bbndk\bbndk-env_xx_xx_xx_xxxx.bat` + ``` * On Linux → Installed as root user: - - $ `./opt/bbndk/bbndk-env_xx_xx_xx_xxxx.sh` + ```bash + $ `./opt/bbndk/bbndk-env_xx_xx_xx_xxxx.sh` + ``` * On Linux → Installed as non-root user: - - $ `./home/username/bbndk/bbndk-env_xx_xx_xx_xxxx.sh` + ```bash + $ `./home/username/bbndk/bbndk-env_xx_xx_xx_xxxx.sh` + ``` * On Mac: - - $ `/Developer/SDKs/bbndk/bbndk-env_xx_xx_xx_xxxx.sh` - + ```bash + $ `/Developer/SDKs/bbndk/bbndk-env_xx_xx_xx_xxxx.sh` + ``` ## Set up for Signing @@ -132,17 +138,21 @@ download page. The final step is to generate a signing certificate: - $ blackberry-keytool -genkeypair -storepass -author 'Your Name’ +```bash +$ blackberry-keytool -genkeypair -storepass -author 'Your Name’ +``` ## Create a Project Use the `cordova` utility to set up a new project, as described in -[Cordova CLI Reference]. For example, in a source-code directory: +[Cordova CLI Reference][cli]. For example, in a source-code directory: - $ cordova create hello com.example.hello - $ cd hello - $ cordova platform add blackberry10 - $ cordova build +```bash +$ cordova create hello com.example.hello +$ cd hello +$ cordova platform add blackberry10 +$ cordova build +``` ## Deploy to Emulator @@ -170,16 +180,19 @@ command, in this case invoked from the project top-level directory, associates a target named _emu_ with the IP address displayed above. * On Windows: - - $ platforms\blackberry10\cordova\target.bat add emu 169.254.0.1 -t simulator + ``` + $ platforms\blackberry10\cordova\target.bat add emu 169.254.0.1 -t simulator + ``` * On Mac/Linux: - - $ platforms/blackberry10/cordova/target add emu 169.254.0.1 -t simulator + ```bash + platforms/blackberry10/cordova/target add emu 169.254.0.1 -t simulator + ``` Then, run the `emulate` command to view the app: - - $ cordova emulate blackberry10 +```bash +$ cordova emulate blackberry10 +``` ## Deploy to Device @@ -194,12 +207,14 @@ Run the target command-line utility to associate a name with an IP address, device password and PIN. * On Windows: - - $ platforms\blackberry10\cordova\target.bat add mydevice 169.254.0.1 -t device --password 123456 --pin FFFF972E + ``` + $ platforms\blackberry10\cordova\target.bat add mydevice 169.254.0.1 -t device --password 123456 --pin FFFF972E + ``` * On Mac/Linux: - - $ platforms/blackberry10/cordova/target add mydevice 169.254.0.1 -t device --password 123456 --pin FFFF972E + ```bash + $ platforms/blackberry10/cordova/target add mydevice 169.254.0.1 -t device --password 123456 --pin FFFF972E + ``` where: @@ -209,19 +224,23 @@ where: Then, run the `run` command to view the app: - $ cordova run blackberry10 +```bash +$ cordova run blackberry10 +``` If a debug token is not yet set up for the device, an error message prompts you to use the platform run script with the password you provided when registering for signing keys. * On Windows: - - $ platforms\blackberry10\cordova\run.bat --device --keystorepass mysecret + ``` + $ platforms\blackberry10\cordova\run.bat --device --keystorepass mysecret + ``` * On Mac/Linux: - - $ platforms/blackberry10/cordova/run --device --keystorepass mysecret + ```bash + $ platforms/blackberry10/cordova/run --device --keystorepass mysecret + ``` ## Debugging with WebInspector @@ -239,7 +258,9 @@ _.bar_ package file suitable for testing on a device or simulator. Use `--release` to create a release version suitable for distribution through BlackBerry World. - $ cordova build --release --keystorepass +```bash +$ cordova build --release --keystorepass +``` The `--keystorepass` option specifies the password you defined when configuring your computer to sign applications. @@ -257,16 +278,20 @@ command, in this case invoked from the project top-level directory, associates a target named _emu_ with an IP address. * On Windows: - - $ platforms\blackberry10\cordova\build.bat --release --keystorepass mysecret + ``` + $ platforms\blackberry10\cordova\build.bat --release --keystorepass mysecret + ``` * On Mac/Linux: - - $ platforms/blackberry10/cordova/build --release --keystorepass mysecret + ```bash + $ platforms/blackberry10/cordova/build --release --keystorepass mysecret + ``` Once the target is defined, you can provide it to the run command using `--target`: - $ cordova run blackberry10 --target=emu +```bash +$ cordova run blackberry10 --target=emu +``` -[Cordova CLI Reference]: ../../../cordova-cli/index.html +[cli]: ../../../reference/cordova-cli/index.html http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/blackberry10/plugin.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/blackberry10/plugin.md b/www/docs/en/6.x/guide/platforms/blackberry10/plugin.md index c6d02d5..a20b5b8 100644 --- a/www/docs/en/6.x/guide/platforms/blackberry10/plugin.md +++ b/www/docs/en/6.x/guide/platforms/blackberry10/plugin.md @@ -32,11 +32,13 @@ platform and back. The Echo plugin basically returns whatever string the `window.echo` function sends from JavaScript: - window.echo = function(str, callback) { - cordova.exec(callback, function(err) { - callback('Nothing to echo.'); - }, "Echo", "echo", [str]); - }; +```javascript +window.echo = function(str, callback) { + cordova.exec(callback, function(err) { + callback('Nothing to echo.'); + }, "Echo", "echo", [str]); +}; +``` A Cordova plugin for BlackBerry 10 contains both JavaScript and native code, which communicate with each other through a framework provided @@ -63,37 +65,41 @@ features constants and utility functions available from within native code. The plugin must be derived from `JSExt`, which is defined in `plugin.h`. That is, you must implement the following class: - class JSExt - { - public: - virtual ~JSExt() {}; - virtual string InvokeMethod( const string& strCommand ) = 0; - virtual bool CanDelete( void ) = 0; - private: - std::string m_id; - }; +```cpp +class JSExt +{ +public: + virtual ~JSExt() {}; + virtual string InvokeMethod( const string& strCommand ) = 0; + virtual bool CanDelete( void ) = 0; +private: + std::string m_id; +}; +``` The extension should include the `plugin.h` header file. In the `Echo` example, you use `JSExt` as follows in the `echo_js.hpp` file: - #include "../public/plugin.h" - #include +```cpp +#include "../public/plugin.h" +#include - #ifndef ECHO_JS_H_ - #define ECHO_JS_H_ +#ifndef ECHO_JS_H_ +#define ECHO_JS_H_ - class Echo : public JSExt - { - public: - explicit Echo(const std::string& id); - virtual ~Echo(); - virtual std::string InvokeMethod(const std::string& command); - virtual bool CanDelete(); - private: - std::string m_id; - }; +class Echo : public JSExt +{ +public: + explicit Echo(const std::string& id); + virtual ~Echo(); + virtual std::string InvokeMethod(const std::string& command); + virtual bool CanDelete(); +private: + std::string m_id; +}; - #endif // ECHO_JS_H_ +#endif // ECHO_JS_H_ +``` The `m_id` attribute contains the `JNEXT` id for the object, which is passed to the class as an argument to the constructor. It is needed @@ -107,20 +113,22 @@ object's methods should execute. These methods are implemented in `echo_js.cpp`. Here is the `InvokeMethod` function for the `Echo` example: - string Echo::InvokeMethod(const string& command) { +```cpp +string Echo::InvokeMethod(const string& command) { - //parse command and args from string - int index = command.find_first_of(" "); - string strCommand = command.substr(0, index); - string strValue = command.substr(index + 1, command.length()); + //parse command and args from string + int index = command.find_first_of(" "); + string strCommand = command.substr(0, index); + string strValue = command.substr(index + 1, command.length()); - // Determine which function should be executed - if (strCommand == "echo") { - return strValue; - } else { - return "Unsupported Method"; - } - } + // Determine which function should be executed + if (strCommand == "echo") { + return strValue; + } else { + return "Unsupported Method"; + } +} +``` The native plugin must also implement the following callback functions: @@ -134,10 +142,12 @@ supported by JNEXT. JNEXT uses this function to determine the set of classes that JNEXT can instantiate. The `Echo` plugin implements the following in `echo_js.cpp`: - char* onGetObjList() { - static char name[] = "Echo"; - return name; - } +```cpp +char* onGetObjList() { + static char name[] = "Echo"; + return name; +} +``` The `onCreateObject ` function takes two parameters. The first is the name of the requested class to be created from the JavaScript side, @@ -146,12 +156,14 @@ parameter is the class's unique object id. This method returns a pointer to the created plugin object. The `Echo` plugin implements the following in `echo_js.cpp`: - JSExt* onCreateObject(const string& className, const string& id) { - if (className == "Echo") { - return new Echo(id); - } - return NULL; - } +```cpp +JSExt* onCreateObject(const string& className, const string& id) { + if (className == "Echo") { + return new Echo(id); + } + return NULL; +} +``` ## Creating the Plugin's JavaScript @@ -172,14 +184,16 @@ through the `Cordova.exec` function. The `client.js` needs to invoke the `exec` function and provide the necessary arguments. The `Echo` plugin implements the following in the `client.js` file: - var service = "org.apache.cordova.blackberry.echo", - exec = cordova.require("cordova/exec"); +```javascript +var service = "org.apache.cordova.blackberry.echo", + exec = cordova.require("cordova/exec"); - module.exports = { - echo: function (data, success, fail) { - exec(success, fail, service, "echo", { data: data }); - } - }; +module.exports = { + echo: function (data, success, fail) { + exec(success, fail, service, "echo", { data: data }); + } +}; +``` The `index.js` component uses JNEXT to interact with the native side. Attaching a constructor function named `Echo` to JNEXT allows @@ -189,12 +203,16 @@ you to perform the following key operations using the `init` function: the required module must match the name of a shared library file (`.so` file): - JNEXT.require("libecho") + ```javascript + JNEXT.require("libecho") + ``` - Create an object by using an acquired module and save the ID that's returned by the call: - self.m_id = JNEXT.createObject("libecho.Echo"); + ```javascript + self.m_id = JNEXT.createObject("libecho.Echo"); + ``` When the application calls the `echo` function in `client.js`, that call in turn calls the `echo` function in `index.js`, where the @@ -203,18 +221,22 @@ you to perform the following key operations using the `init` function: `JSON.stringfy()` and encoded as a `URIcomponent`, you must call the following: - data = JSON.parse(decodeURIComponent(args.data)); +```javascript +data = JSON.parse(decodeURIComponent(args.data)); +``` You can now send the data back, as in the following: - module.exports = { - echo: function (success, fail, args, env) { - var result = new PluginResult(args, env), - data = JSON.parse(decodeURIComponent(args.data)), - response = echo.getInstance().echo(data); - result.ok(response, false); - } - }; +```javascript +module.exports = { + echo: function (success, fail, args, env) { + var result = new PluginResult(args, env), + data = JSON.parse(decodeURIComponent(args.data)), + response = echo.getInstance().echo(data); + result.ok(response, false); + } +}; +``` ## Plugin Architecture @@ -241,18 +263,20 @@ sign. The `plugin.xml` file contains the extension's namespace and other metadata. Set up the `Echo` plugin as follows: - - - - - - - - - - - - - +```xml + + + + + + + + + + + + + +``` http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/blackberry10/tools.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/blackberry10/tools.md b/www/docs/en/6.x/guide/platforms/blackberry10/tools.md index 197d1dd..b209e10 100644 --- a/www/docs/en/6.x/guide/platforms/blackberry10/tools.md +++ b/www/docs/en/6.x/guide/platforms/blackberry10/tools.md @@ -46,7 +46,9 @@ arguments. The `create` command creates a new project: - bin/create +``` +bin/create +``` where @@ -71,7 +73,9 @@ or set a target as the default target. ### Add a Target - /cordova/target add [-t | --type ] [-p | --password ] [--pin ] +``` +/cordova/target add [-t | --type ] [-p | --password ] [--pin ] +``` where @@ -91,11 +95,15 @@ where ### Remove a Target - /cordova/target remove +``` +/cordova/target remove +``` ### Set a Target as the Default - /cordova/target default +``` +/cordova/target default +``` ## Build the App @@ -105,7 +113,9 @@ in debug mode (which produces an unsigned .bar file). ### Build the App in Release Mode - /cordova/build release [-k | --keystorepass ] [-b | --buildId ] [-p | --params ] +``` +/cordova/build release [-k | --keystorepass ] [-b | --buildId ] [-p | --params ] +``` where @@ -117,7 +127,9 @@ where ### Build the Project in Debug Mode - /cordova/build debug [] [-k | --keystorepass ] [-p | --params ] [-ll | --loglevel ] +``` +/cordova/build debug [] [-k | --keystorepass ] [-p | --params ] [-ll | --loglevel ] +``` where @@ -147,7 +159,9 @@ installed a debug token, if that target is a BlackBerry device), you can run the script with no arguments, and the script packages your app and deploys it to the default target. For example: - /cordova/build debug +``` +/cordova/build debug +``` ## Run the App @@ -155,7 +169,9 @@ The `run` command deploys the app's most recent build on the specified BlackBerry device or an emulator. To deploy your app, you need to specify a target for the device or emulator: - /cordova/run +``` +/cordova/run +``` ...where ` `specifies the name of a previously added target. If `` is a device, then it must be connected to your computer @@ -166,16 +182,24 @@ via USB cable, or else over the same Wi-Fi network as your computer. The `target` command allows you to add and remove plugins. To fetch a locally hosted plugin: - /cordova/plugin fetch +``` +/cordova/plugin fetch +``` View a list of installed plugins: - /cordova/plugin ls +``` +/cordova/plugin ls +``` Add a plugin: - /cordova/plugin add +``` +/cordova/plugin add +``` Remove a plugin: - /cordova/plugin rm +``` +/cordova/plugin rm +``` http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/blackberry10/upgrade.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/blackberry10/upgrade.md b/www/docs/en/6.x/guide/platforms/blackberry10/upgrade.md index c821e4f..fe9f282 100644 --- a/www/docs/en/6.x/guide/platforms/blackberry10/upgrade.md +++ b/www/docs/en/6.x/guide/platforms/blackberry10/upgrade.md @@ -32,7 +32,7 @@ version of the CLI. For non-CLI projects, run: bin/update path/to/project - + For CLI projects: 1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). @@ -41,12 +41,12 @@ For CLI projects: ## Upgrading to 3.2.0 from 3.1.0 -For projects that were created with the cordova CLI: +For projects that were created with the cordova CLI: 1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). 2. Run `cordova platform update blackberry` - + For projects not created with the cordova CLI, run: bin/update @@ -438,13 +438,17 @@ Updating the sample directory (i.e., updating using the ant tools): changed their namespace/service label. Change the old entries for the Capture and Contact plugins from: - - + ```xml + + + ``` - To: + To: - - + ```xml + + + ``` - To upgrade to 1.8.0, please go from 1.7.0 @@ -467,13 +471,17 @@ Updating just the `www` directory: namespace/service label. Change the old entries for the Capture and Contact plugins from: - - + ```xml + + + ``` - To: + To: - - + ```xml + + + ``` Updating the sample directory (i.e., updating using the ant tools): @@ -495,11 +503,14 @@ Updating the sample directory (i.e., updating using the ant tools): changed their namespace/service label. Change the old entries for the Capture and Contact plugins from: - - - - To: + ```xml + + + ``` - - + To: + ```xml + + + ``` http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/ios/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/ios/index.md b/www/docs/en/6.x/guide/platforms/ios/index.md index 5a9c45d..997b9be 100644 --- a/www/docs/en/6.x/guide/platforms/ios/index.md +++ b/www/docs/en/6.x/guide/platforms/ios/index.md @@ -29,7 +29,7 @@ development workflow. You need to install the SDK tools regardless of whether you want to use these platform-centered shell tools or cross-platform Cordova CLI for development. For a comparison of the two development paths, see the [Overview](../../overview/index.html#development-paths). -For details on the CLI, see [Cordova CLI Reference]. +For details on the CLI, see [Cordova CLI Reference][cli]. ## Requirements and Support @@ -61,7 +61,9 @@ There are two ways to download Xcode: Once Xcode is installed, several command-line tools need to be enabled for Cordova to run. From the command line, run: -``` xcode-select --install``` +```bash +$ xcode-select --install +``` ### Deployment Tools @@ -71,8 +73,10 @@ to launch iOS apps into the iOS Simulator and iOS Device from the command-line. To install them, run the following from command-line terminal: - $ npm install -g ios-sim - $ npm install -g ios-deploy +```bash +$ npm install -g ios-sim +$ npm install -g ios-deploy +``` ## Project Configuration @@ -160,25 +164,27 @@ Alternatively, you could specify them in a build configuration file (`build.json using the `--buildConfig` argument to the same commands. Here's a sample of a build configuration file: - { - "ios": { - "debug": { - "codeSignIdentity": "iPhone Development", - "provisioningProfile": "926c2bd6-8de9-4c2f-8407-1016d2d12954" - }, - "release": { - "codeSignIdentity": "iPhone Distribution", - "provisioningProfile": "70f699ad-faf1-4adE-8fea-9d84738fb306" - } - } +```json +{ + "ios": { + "debug": { + "codeSignIdentity": "iPhone Development", + "provisioningProfile": "926c2bd6-8de9-4c2f-8407-1016d2d12954" + }, + "release": { + "codeSignIdentity": "iPhone Distribution", + "provisioningProfile": "70f699ad-faf1-4adE-8fea-9d84738fb306" + } } +} +``` ### Using xcrun You can also sign from the command line using the following command: -``` - xcrun -sdk iphoneos PackageApplication -v /home/user/app/build/device/MyApp.app -o /home/user/app/build/device/MyApp.ipa --sign "iPhone Development" --embed "7151ab45-6085-4ea1-9bcd-022b5cebe44b" +```bash +xcrun -sdk iphoneos PackageApplication -v /home/user/app/build/device/MyApp.app -o /home/user/app/build/device/MyApp.ipa --sign "iPhone Development" --embed "7151ab45-6085-4ea1-9bcd-022b5cebe44b" ``` ## Debugging @@ -217,7 +223,7 @@ as described in [Requirements and Support](#link-requirements-and-support) above. For each of the scripts discussed below, refer to - [Cordova CLI Reference] for more information on their + [Cordova CLI Reference][cli] for more information on their arguments and usage. Each script has a name that matches the corresponding CLI command. For example, `cordova-ios/bin/create` is equivalent to `cordova create`. @@ -229,11 +235,15 @@ To get started, either download the cordova-ios package from To create a project using this package, run the `create` script in the `bin` folder: - $ cordova-ios/bin/create ... +```bash +$ cordova-ios/bin/create ... +``` To run the app, use the `run` script in the `bin` folder: - $ cordova-ios/bin/run +```bash +$ cordova-ios/bin/run +``` The created project will have a folder named `cordova` inside that contains scripts for the project-specific Cordova commands (e.g. `run`, `build`, etc.). @@ -249,4 +259,4 @@ Refer to [this](./upgrade.html) article for instructions to upgrade your ```cord (Mac®, OS X®, Apple®, Xcode®, App Store℠, iPad®, iPhone®, iPod® and Finder® are Trademarks of Apple Inc.) -[Cordova CLI Reference]: ../../../cordova-cli/index.html +[cli]: ../../../reference/cordova-cli/index.html http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/ios/plugin.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/ios/plugin.md b/www/docs/en/6.x/guide/platforms/ios/plugin.md index 9dcc255..abf945b 100644 --- a/www/docs/en/6.x/guide/platforms/ios/plugin.md +++ b/www/docs/en/6.x/guide/platforms/ios/plugin.md @@ -40,7 +40,9 @@ registered as a `` tag in the named application directory's The JavaScript portion of a plugin uses the `cordova.exec` method as follows: - exec(, , , , []); +```javascript +exec(, , , , []); +``` This marshals a request from the `UIWebView` to the iOS native side, effectively calling the `action` method on the `service` class, with @@ -50,9 +52,11 @@ Specify the plugin as a `` tag in your Cordova-iOS application's project's `config.xml` file, using the `plugin.xml` file to inject this markup automatically, as described in [Plugin Development Guide][plugin-dev]: - - - +```xml + + + +``` The feature's `name` attribute should match what you specify as the JavaScript `exec` call's `service` parameter. The `value` attribute @@ -68,16 +72,18 @@ One instance of a plugin object is created for the life of each referenced by a call from JavaScript, unless `` with an `onload` `name` attribute is set to `"true"` in `config.xml`. For example, - - - - +```xml + + + + +``` Plugins should use the `pluginInitialize` method for their startup logic. Plugins with long-running requests or background activities such as media -playback, listeners, or that maintain internal state should implement -the `onReset` method to cancel those long-running requests or to clean up +playback, listeners, or that maintain internal state should implement +the `onReset` method to cancel those long-running requests or to clean up after those activities. The method runs when the `UIWebView` navigates to a new page or refreshes, which reloads the JavaScript. @@ -91,18 +97,20 @@ class look like? Whatever is dispatched to the plugin with JavaScript's `exec` function is passed into the corresponding plugin class's `action` method. A plugin method has this signature: - - (void)myMethod:(CDVInvokedUrlCommand*)command - { - CDVPluginResult* pluginResult = nil; - NSString* myarg = [command.arguments objectAtIndex:0]; - - if (myarg != nil) { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - } else { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Arg was null"]; - } - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - } +```objective_c +- (void)myMethod:(CDVInvokedUrlCommand*)command +{ + CDVPluginResult* pluginResult = nil; + NSString* myarg = [command.arguments objectAtIndex:0]; + + if (myarg != nil) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Arg was null"]; + } + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} +``` For more details, see [CDVInvokedUrlCommand.h][CDVInvokedUrlCommand.h], [CDVPluginResult.h][CDVPluginResult.h], @@ -113,7 +121,9 @@ and [CDVCommandDelegate.h][CDVCommandDelegate.h]. You can use `CDVPluginResult` to return a variety of result types back to the JavaScript callbacks, using class methods that follow this pattern: - + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAs... +```objective_c ++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAs... +``` You can create `String`, `Int`, `Double`, `Bool`, `Array`, `Dictionary`, `ArrayBuffer`, and `Multipart` types. You can also leave @@ -139,50 +149,55 @@ To match the JavaScript interface's _echo_ feature described in Application Plugins, use the `plugin.xml` to inject a `feature` specification to the local platform's `config.xml` file: - - - - - - - +```xml + + + + + + + +``` Then we would add the following `Echo.h` and `Echo.m` files to the `Plugins` folder within the Cordova-iOS application directory: - /********* Echo.h Cordova Plugin Header *******/ - #import +```objective_c +/********* Echo.h Cordova Plugin Header *******/ + +#import - @interface Echo : CDVPlugin +@interface Echo : CDVPlugin - - (void)echo:(CDVInvokedUrlCommand*)command; +- (void)echo:(CDVInvokedUrlCommand*)command; - @end +@end - /********* Echo.m Cordova Plugin Implementation *******/ +/********* Echo.m Cordova Plugin Implementation *******/ - #import "Echo.h" - #import +#import "Echo.h" +#import - @implementation Echo +@implementation Echo - - (void)echo:(CDVInvokedUrlCommand*)command - { - CDVPluginResult* pluginResult = nil; - NSString* echo = [command.arguments objectAtIndex:0]; +- (void)echo:(CDVInvokedUrlCommand*)command +{ + CDVPluginResult* pluginResult = nil; + NSString* echo = [command.arguments objectAtIndex:0]; - if (echo != nil && [echo length] > 0) { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:echo]; - } else { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; - } + if (echo != nil && [echo length] > 0) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:echo]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; + } - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - } + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} - @end +@end +``` The necessary imports at the top of the file extends the class from `CDVPlugin`. In this case, the plugin only supports a single `echo` @@ -214,17 +229,19 @@ interface. If your plugin requires a great deal of processing or requires a blocking call, you should use a background thread. For example: - - (void)myPluginMethod:(CDVInvokedUrlCommand*)command - { - // Check command.arguments here. - [self.commandDelegate runInBackground:^{ - NSString* payload = nil; - // Some blocking logic... - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload]; - // The sendPluginResult method is thread-safe. - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - }]; - } +```objective_c +- (void)myPluginMethod:(CDVInvokedUrlCommand*)command +{ + // Check command.arguments here. + [self.commandDelegate runInBackground:^{ + NSString* payload = nil; + // Some blocking logic... + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload]; + // The sendPluginResult method is thread-safe. + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }]; +} +``` ## Debugging iOS Plugins http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/ios/upgrade.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/ios/upgrade.md b/www/docs/en/6.x/guide/platforms/ios/upgrade.md index c12150c..83219e3 100644 --- a/www/docs/en/6.x/guide/platforms/ios/upgrade.md +++ b/www/docs/en/6.x/guide/platforms/ios/upgrade.md @@ -35,8 +35,10 @@ Apple App Store, you should use the latest shipped version of the iOS SDK, which For non-CLI projects, run: - bin/update path/to/project - +``` +bin/update path/to/project +``` + For CLI projects: 1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). @@ -48,8 +50,10 @@ For CLI projects: For non-CLI projects, run: - bin/update path/to/project - +``` +bin/update path/to/project +``` + For CLI projects: 1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). @@ -60,8 +64,10 @@ For CLI projects: For non-CLI projects, run: - bin/update path/to/project - +``` +bin/update path/to/project +``` + For CLI projects: 1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). @@ -72,27 +78,31 @@ For CLI projects: For non-CLI projects, run: - bin/update path/to/project - +``` +bin/update path/to/project +``` + For CLI projects: 1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). 2. Run `cordova platform update ios` - + ## Upgrading 3.0.0 Projects to 3.1.0 For non-CLI projects, run: - bin/update path/to/project - +``` +bin/update path/to/project +``` + For CLI projects: 1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). 2. Run `cordova platform update ios` - + iOS 7 Issues: 1. Remove `width=device-width, height=device-height` from the @@ -190,23 +200,27 @@ yourself. See [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html deprecated. You can copy this information in the `config.xml` file for a new project. For example: - - - - - - - - - - - + ```xml + + + + + + + + + + + ``` + 8. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. 9. Add these two frameworks to your project: - - OpenAL - ImageIO + + ``` + OpenAL + ImageIO + ``` 10. Update your project's target __Build Settings__. Under __Linking → Other Linker Flags__, edit __"-Obj-C"__ to be __"-ObjC"__. @@ -334,7 +348,9 @@ yourself. See [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html 11. Add the InAppBrowser plugin to the `config.xml`, by adding this tag under ``: - + ```xml + + ``` 12. Note that Objective-C plugins are _not_ whitelisted anymore. To whitelist your connections with the app whitelist, you need to set the `User-Agent` header of the connection to the same user-agent as the main Cordova WebView. You can get this by accessing the `userAgent` property off the main view-controller. The main view-controller (`CDVViewController`) also has a `URLisAllowed` method for you to check whether a URL passes the whitelist. @@ -368,7 +384,9 @@ You can get this by accessing the `userAgent` property off the main view-control 2. Go to the location where you installed Cordova (see Step 1), in the `bin` subdirectory 3. Run the script below where the first parameter is the path to your project's `.xcodeproj` file: - `update_cordova_subproject path/to/your/project/xcodeproj` + ``` + update_cordova_subproject path/to/your/project/xcodeproj + ``` __NOTE__: In 2.2.0, the `bin/create` script copy in the `CordovaLib` sub-project into your project. To have the same kind of setup, just copy in the right `CordovaLib` into your project directory, and update the `CordovaLib` sub-project location (relative to the project) in the Xcode File Inspector. @@ -404,7 +422,9 @@ With Cordova 2.1.0, `CordovaLib` has been upgraded to use __Automatic Reference 2. Go to the location where you installed Cordova (see Step 1), in the `bin` subdirectory 3. Run the script below where the first parameter is the path to your project's `.xcodeproj` file: - `update_cordova_subproject path/to/your/project/xcodeproj` + ``` + update_cordova_subproject path/to/your/project/xcodeproj + ``` ## Upgrading 1.9.0 Projects to 2.0.0 @@ -438,11 +458,15 @@ With Cordova 2.1.0, `CordovaLib` has been upgraded to use __Automatic Reference 14. For the `#import` errors, change any quote-based imports in this style: - #import "CDV.h" + ```objective_c + #import "CDV.h" + ``` to this brackets-based style: - #import + ```objective_c + #import + ``` and remove any `#ifdef` wrappers around any Cordova imports, they are not needed anymore (the imports are now unified) @@ -482,15 +506,19 @@ With Cordova 2.1.0, `CordovaLib` has been upgraded to use __Automatic Reference 32. Search for __Header Search Paths__. For that setting, append these three values, including quotes: - "$(TARGET_BUILD_DIR)/usr/local/lib/include" + ```bash + "$(TARGET_BUILD_DIR)/usr/local/lib/include" - "$(OBJROOT)/UninstalledProducts/include" + "$(OBJROOT)/UninstalledProducts/include" - "$(BUILT_PRODUCTS_DIR)" + "$(BUILT_PRODUCTS_DIR)" + ``` 33. Search for __Other Linker Flags__. For that setting, append this value: - -weak_framework CoreFoundation + ```bash + -weak_framework CoreFoundation + ``` 34. Build your project, it should compile and link with __no issues__. @@ -551,11 +579,13 @@ If you intend on using the Capture API, you will need the new __iPad retina-disp 4. Copy these files from the new project into your 1.5.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - Cordova.plist + ``` + AppDelegate.h + AppDelegate.m + MainViewController.h + MainViewController.m + Cordova.plist + ``` 5. Add all the new `MainViewController` and `AppDelegate` files into your Xcode project. @@ -618,7 +648,9 @@ If you intend on using the Capture API, you will need the new __iPad retina-disp 18. In the `AppDelegate.h`, `AppDelegate.m`, and `MainViewController.h` files, replace the whole `#ifdef PHONEGAP_FRAMEWORK` block with: - #import "CDVDeprecated.h" + ```objective_c + #import "CDVDeprecated.h" + ``` 19. Click on the __project icon__ in the Project Navigator, select your __Target__, then select the __Build Settings__ tab. @@ -680,11 +712,13 @@ If you intend on using the Capture API, you will need the new __iPad retina-disp 4. Copy these files from the new project into your 1.3.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib + ``` + AppDelegate.h + AppDelegate.m + MainViewController.h + MainViewController.m + MainViewController.xib + ``` 5. Add all the `MainViewController` files into your Xcode project. @@ -707,11 +741,13 @@ If you intend on using the Capture API, you will need the new __iPad retina-disp 4. Copy these files from the new project into your 1.2.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib + ``` + AppDelegate.h + AppDelegate.m + MainViewController.h + MainViewController.m + MainViewController.xib + ``` 5. Add all the `MainViewController` files into your Xcode project. @@ -734,11 +770,13 @@ If you intend on using the Capture API, you will need the new __iPad retina-disp 4. Copy these files from the new project into your 1.1.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib + ``` + AppDelegate.h + AppDelegate.m + MainViewController.h + MainViewController.m + MainViewController.xib + ``` 5. Add all the `MainViewController` files into your Xcode project. @@ -761,11 +799,13 @@ If you intend on using the Capture API, you will need the new __iPad retina-disp 4. Copy these files from the new project into your 1.0.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib + ``` + AppDelegate.h + AppDelegate.m + MainViewController.h + MainViewController.m + MainViewController.xib + ``` 5. Add all the `MainViewController` files into your Xcode project. @@ -788,11 +828,13 @@ If you intend on using the Capture API, you will need the new __iPad retina-disp 4. Copy these files from the new project into your 0.9.6-based project directory on disk, replacing any old files (backup your files first from step 2 above): - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib + ``` + AppDelegate.h + AppDelegate.m + MainViewController.h + MainViewController.m + MainViewController.xib + ``` 5. Add all the `MainViewController` files into your Xcode project. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/ios/webview.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/ios/webview.md b/www/docs/en/6.x/guide/platforms/ios/webview.md index 9e78208..829dd15 100644 --- a/www/docs/en/6.x/guide/platforms/ios/webview.md +++ b/www/docs/en/6.x/guide/platforms/ios/webview.md @@ -83,10 +83,12 @@ package. Optionally within the __Project Navigator__, move them under the __Frameworks__ group: - AssetsLibrary.framework - CoreLocation.framework - CoreGraphics.framework - MobileCoreServices.framework + ``` + AssetsLibrary.framework + CoreLocation.framework + CoreGraphics.framework + MobileCoreServices.framework + ``` 1. Expand __Target Dependencies__, the top box with that label if there's more than one box. @@ -107,10 +109,12 @@ package. 1. Search for __Header Search Paths__. For that setting, add these three values below, including the quotes: - "$(TARGET_BUILD_DIR)/usr/local/lib/include" - "$(OBJROOT)/UninstalledProducts/include" - "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" - "$(BUILT_PRODUCTS_DIR)" + ``` + "$(TARGET_BUILD_DIR)/usr/local/lib/include" + "$(OBJROOT)/UninstalledProducts/include" + "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" + "$(BUILT_PRODUCTS_DIR)" + ``` As of Cordova 2.1.0, `CordovaLib` has been upgraded to use __Automatic Reference Counting (ARC)__. You don't need to upgrade @@ -124,38 +128,54 @@ package. 1. Add the following header: - #import + ```objective_c + #import + ``` 1. Instantiate a new `CDVViewController` and retain it somewhere, e.g., to a class property: - CDVViewController* viewController = [CDVViewController new]; + ```objective_c + CDVViewController* viewController = [CDVViewController new]; + ``` 1. Optionally, set the `wwwFolderName` property, which defaults to `www`: - viewController.wwwFolderName = @"myfolder"; + ```objective_c + viewController.wwwFolderName = @"myfolder"; + ``` 1. Optionally, set the start page in the `config.xml` file's `` tag, either a local file: - + ```xml + + ``` ...or a remote site: - + ```xml + + ``` 1. Optionally, set the `useSplashScreen` property, which defaults to `NO`: - viewController.useSplashScreen = YES; + ```objective_c + viewController.useSplashScreen = YES; + ``` 1. Set the __view frame__. Always set this as the last property: - viewController.view.frame = CGRectMake(0, 0, 320, 480); + ```objective_c + viewController.view.frame = CGRectMake(0, 0, 320, 480); + ``` 1. Add Cleaver to the view: - [myView addSubview:viewController.view]; + ```objective_c + [myView addSubview:viewController.view]; + ``` ## Adding HTML, CSS and JavaScript Assets @@ -173,11 +193,13 @@ package. in the previous section) when instantiating the `CDVViewController`. - /* - if you created a folder called 'myfolder' and - you want the file 'mypage.html' in it to be - the startPage - */ - viewController.wwwFolderName = @"myfolder"; - viewController.startPage = @"mypage.html" + ```objective_c + /* + if you created a folder called 'myfolder' and + you want the file 'mypage.html' in it to be + the startPage + */ + viewController.wwwFolderName = @"myfolder"; + viewController.startPage = @"mypage.html" + ``` http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/osx/config.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/osx/config.md b/www/docs/en/6.x/guide/platforms/osx/config.md index 9ff467c..8a496ed 100644 --- a/www/docs/en/6.x/guide/platforms/osx/config.md +++ b/www/docs/en/6.x/guide/platforms/osx/config.md @@ -40,41 +40,48 @@ File](config_ref_index.md.html#The%20config.xml%20File) for information on globa ## Details ### HideMousePointer -(integer, defaults to _disabled_) +(integer, defaults to _disabled_) Idle duration in seconds after which the mouse pointer should be hidden. Set it to `0` for immediate. Example: hide mouse pointer after 5 seconds: - +```xml + +``` ### OSXLocalStoragePath -(string, defaults to `~/Library/Application Support/{bundle.id}`) +(string, defaults to `~/Library/Application Support/{bundle.id}`) Sets the directory for the local storage path. Example: use custom path: - +```xml + +``` ### WindowSize -(string, defaults to `auto`) +(string, defaults to `auto`) Defines the size of the application window in the format `WxH` or the special values `auto` and `fullscreen`. The latter will open a borderless window spanning the entire desktop area. Please note, that this is different from the _normal_ OS X fullscreen mode, which would never span multiple displays. Example: set the window size to 800 x 400: - +```xml + +``` > **Note**: The global cordova `fullscreen` preference is not supported. ### EnableWebGL -(boolean, defaults to `false`) -If set to `true` it enables WebGL on the webview. +(boolean, defaults to `false`) +If set to `true` it enables WebGL on the webview. Example: enable WebGL - - - +```xml + +``` + http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/osx/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/osx/index.md b/www/docs/en/6.x/guide/platforms/osx/index.md index 3732c4e..35143c9 100644 --- a/www/docs/en/6.x/guide/platforms/osx/index.md +++ b/www/docs/en/6.x/guide/platforms/osx/index.md @@ -42,7 +42,7 @@ includes the OS X SDK (Software Development Kit). To submit apps to the Apple App Store℠ requires the latest versions of the Apple tools. You can test all of the Cordova features using the XCode or any other -IDE such as [JetBrain's AppCode](https://www.jetbrains.com/objc/), but +IDE such as [JetBrain's AppCode](https://www.jetbrains.com/objc/), but you need to use XCode to sign before submitting to the App Store. To sign the apps, you must also be a member of Apple's [OS X Developer Program](https://developer.apple.com/osx/). @@ -67,16 +67,20 @@ __Install__ button next to the __Command Line Tools__ listing. Use the `cordova` utility to set up a new project, as described in The Cordova [The Command-Line Interface](../../cli/index.html). For example, in a source-code directory: - $ cordova create hello com.example.hello "HelloWorld" - $ cd hello - $ cordova platform add osx - $ cordova prepare # or "cordova build" +```bash +$ cordova create hello com.example.hello "HelloWorld" +$ cd hello +$ cordova platform add osx +$ cordova prepare # or "cordova build" +``` ## Run the app To run the app on your desktop: - $ cordova run +```bash +$ cordova run +``` And you should see a bordered window with the example app: @@ -87,13 +91,13 @@ options. ## Open a Project in the SDK -Once osx platform is added to your project, you can open it from +Once osx platform is added to your project, you can open it from within Xcode. Double-click to open the `hello/platforms/osx/HelloWorld.xcodeproj` file. The screen should look like this: ![]({{ site.baseurl }}/static/img/guide/platforms/osx/helloworld_project.png) -> **TIP** +> **TIP** > You can also use the `open` command to open the XCode project directly > from the command line: > ``` @@ -110,7 +114,7 @@ Cordova, and Xcode issues warnings about them when you build and deploy an application. __Missing Headers__: Compilation errors relating to missing headers -result from problems with the build location, and can be fixed +result from problems with the build location, and can be fixed via Xcode preferences: 1. Select __Xcode → Preferences → Locations__. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e3751865/www/docs/en/6.x/guide/platforms/ubuntu/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/ubuntu/index.md b/www/docs/en/6.x/guide/platforms/ubuntu/index.md index daa2a79..9efaf7d 100644 --- a/www/docs/en/6.x/guide/platforms/ubuntu/index.md +++ b/www/docs/en/6.x/guide/platforms/ubuntu/index.md @@ -66,12 +66,16 @@ Add the Ubuntu Cordova [Personal Package Archive](https://launchpad.net/~cordova-ubuntu/+archive/ppa) to your Ubuntu system: - $ sudo add-apt-repository ppa:cordova-ubuntu/ppa - $ sudo apt-get update +```bash +$ sudo add-apt-repository ppa:cordova-ubuntu/ppa +$ sudo apt-get update +``` Install cordova-cli package (and its dependencies): - $ sudo apt-get install cordova-cli +```bash +$ sudo apt-get install cordova-cli +``` ## Project Workflow @@ -80,25 +84,36 @@ Install cordova-cli package (and its dependencies): Creates an app in a `hello` directory whose display name is `HelloWorld`: - $ cordova create hello com.example.hello HelloWorld +```bash +$ cordova create hello com.example.hello HelloWorld +``` ### Move into the Project Directory - $ cd hello +```bash +$ cd hello +``` ### Add the Ubuntu Platform - $ cordova platform add ubuntu +```bash +$ cordova platform add ubuntu +``` ### Build for Ubuntu - $ cordova build ubuntu +```bash +$ cordova build ubuntu +``` ### Run the App - $ cordova run ubuntu +```bash +$ cordova run ubuntu +``` ### Add the Camera Plugin - $ cordova plugin add cordova-plugin-camera - +```bash +$ cordova plugin add cordova-plugin-camera +`` --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org