http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/hybrid/plugins/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/hybrid/plugins/index.md b/www/docs/en/6.x/guide/hybrid/plugins/index.md index 1a21d53..c0d1a7f 100644 --- a/www/docs/en/6.x/guide/hybrid/plugins/index.md +++ b/www/docs/en/6.x/guide/hybrid/plugins/index.md @@ -25,11 +25,11 @@ title: Plugin Development Guide A _plugin_ is a package of injected code that allows the Cordova webview within which the app renders to communicate with the native platform on which it runs. Plugins provide access to device and platform -functionality that is ordinarily unavailable to web-based apps. All +functionality that is ordinarily unavailable to web-based apps. All the main Cordova API features are implemented as plugins, and many others are available that enable features such as bar code scanners, -NFC communication, or to tailor calendar interfaces. There is a -[registry](http://plugins.cordova.io) of available plugins. +NFC communication, or to tailor calendar interfaces. You can search for available plugins +on [Cordova Plugin Search page](/plugins/). Plugins comprise a single JavaScript interface along with corresponding native code libraries for each supported platform. In essence @@ -45,43 +45,45 @@ this section. In addition to these instructions, when preparing to write a plugin it is best to look over -[existing plugins](http://cordova.apache.org/#contribute) +[existing plugins](http://cordova.apache.org/contribute) for guidance. ## Building a Plugin -Application developers use the CLI's `plugin add` command (discussed -in The Command-Line Interface) to apply a plugin to a project. The +Application developers use the CLI's [plugin add command](../../../cordova-cli/index.html#cordova-plugin-add-command) to add a plugin to a project. The argument to that command is the URL for a _git_ repository containing the plugin code. This example implements Cordova's Device API: - $ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git +```bash + $ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git +``` The plugin repository must feature a top-level `plugin.xml` manifest file. There are many ways to configure this file, details for which -are available in the [Plugin Specification](../../../plugin_ref/spec.html). This abbreviated version of -the `Device` plugin provides a simple example to use as a model: - - <?xml version="1.0" encoding="UTF-8"?> - <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" - id="cordova-plugin-device" version="0.2.3"> - <name>Device</name> - <description>Cordova Device Plugin</description> - <license>Apache 2.0</license> - <keywords>cordova,device</keywords> - <js-module src="www/device.js" name="device"> - <clobbers target="device" /> - </js-module> - <platform name="ios"> - <config-file target="config.xml" parent="/*"> - <feature name="Device"> - <param name="ios-package" value="CDVDevice"/> - </feature> - </config-file> - <header-file src="src/ios/CDVDevice.h" /> - <source-file src="src/ios/CDVDevice.m" /> - </platform> - </plugin> +are available in the [Plugin Specification](../../../plugin_ref/spec.html). This abbreviated version of the `Device` plugin provides a simple example to use as a model: + +```xml + <?xml version="1.0" encoding="UTF-8"?> + <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" + id="cordova-plugin-device" version="0.2.3"> + <name>Device</name> + <description>Cordova Device Plugin</description> + <license>Apache 2.0</license> + <keywords>cordova,device</keywords> + <js-module src="www/device.js" name="device"> + <clobbers target="device" /> + </js-module> + <platform name="ios"> + <config-file target="config.xml" parent="/*"> + <feature name="Device"> + <param name="ios-package" value="CDVDevice"/> + </feature> + </config-file> + <header-file src="src/ios/CDVDevice.h" /> + <source-file src="src/ios/CDVDevice.m" /> + </platform> + </plugin> +``` The top-level `plugin` tag's `id` attribute uses the same reverse-domain format to identify the plugin package as the apps to @@ -93,30 +95,28 @@ the platform-specific `config.xml` file to make the platform aware of the additional code library. The `header-file` and `source-file` tags specify the path to the library's component files. -## Validating a Plugin +## Validating a Plugin using Plugman You can use the `plugman` utility to check whether the plugin installs correctly for each platform. Install `plugman` with the following [node](http://nodejs.org/) command: - $ npm install -g plugman +```bash + $ npm install -g plugman +``` You need an valid app source directory, such as the top-level `www` directory included in a default CLI-generated project as described in -[The Command-Line Interface](../../cli/index.html). Make sure the app's `index.html` home -page reference the name of the plugin's JavaScript interface, as if it -were in the same source directory: - - <script src="myplugin.js"></script> +[Create your first app](../../cli/index.html) guide. Then run a command such as the following to test whether iOS dependencies load properly: - $ plugman install --platform ios --project /path/to/my/project/www --plugin /path/to/my/plugin +```bash + $ plugman install --platform ios --project /path/to/my/project/www --plugin /path/to/my/plugin +``` -For details on `plugman` options, see [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html). -For information on how to actually _debug_ plugins, see each -platform's native interface listed at the bottom of this page. +For details on `plugman` options, see [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html). For information on how to actually _debug_ plugins, see each platform's native interface listed at the bottom of this page. ## The JavaScript Interface @@ -126,11 +126,13 @@ plugin's JavaScript however you like, but you need to call `cordova.exec` to communicate with the native platform, using the following syntax: - cordova.exec(function(winParam) {}, - function(error) {}, - "service", - "action", - ["firstArgument", "secondArgument", 42, false]); +```js + cordova.exec(function(winParam) {}, + function(error) {}, + "service", + "action", + ["firstArgument", "secondArgument", 42, false]); +``` Here is how each parameter works: @@ -188,7 +190,6 @@ Once you define JavaScript for your plugin, you need to complement it with at least one native implementation. Details for each platform are listed below, and each builds on the simple Echo Plugin example above: -- [Amazon Fire OS Plugins](../../platforms/amazonfireos/plugin.html) - [Android Plugins](../../platforms/android/plugin.html) - [iOS Plugins](../../platforms/ios/plugin.html) - [BlackBerry 10 Plugins](../../platforms/blackberry10/plugin.html) @@ -210,7 +211,7 @@ use corresponding `npm` commands. Other developers can install your plugin automatically using either `plugman` or the Cordova CLI. (For details on each development path, see - [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html) and [The Command-Line Interface](../../cli/index.html).) + [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html) and [The Command-Line Interface reference](../../../cordova-cli/index.html).) To publish a plugin to NPM registry you need to follow steps below:
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/hybrid/webviews/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/hybrid/webviews/index.md b/www/docs/en/6.x/guide/hybrid/webviews/index.md index 973950d..73ff509 100644 --- a/www/docs/en/6.x/guide/hybrid/webviews/index.md +++ b/www/docs/en/6.x/guide/hybrid/webviews/index.md @@ -33,7 +33,6 @@ To deploy a WebView, you need to be familiar with each native programming environment. The following provides instructions for supported platforms: -- [Amazon Fire OS WebViews](../../platforms/amazonfireos/webview.html) - [Android WebViews](../../platforms/android/webview.html) - [iOS WebViews](../../platforms/ios/webview.html) -- [Windows Phone 8.0 WebViews](../../platforms/wp8/webview.html) \ No newline at end of file +- [Windows Phone 8.0 WebViews](../../platforms/wp8/webview.html) http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/next/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/next/index.md b/www/docs/en/6.x/guide/next/index.md index 2bdf90d..ca66cae 100644 --- a/www/docs/en/6.x/guide/next/index.md +++ b/www/docs/en/6.x/guide/next/index.md @@ -22,7 +22,7 @@ title: Next Steps # Next Steps -For developers who have an understanding of how to use the Cordova CLI and make use of plugins, there are a few things you may want to consider researching next to build better, more performant Cordova applications. The following document offers advice on various topics relating to best practices, testing, upgrades, and other topics, but is not meant to be prescriptive. Consider this your launching point for your growth as a Cordova developer. Also, if you see something that can be improved, please [contribute](http://cordova.apache.org/#contribute)! +For developers who have an understanding of how to use the Cordova CLI and make use of plugins, there are a few things you may want to consider researching next to build better, more performant Cordova applications. The following document offers advice on various topics relating to best practices, testing, upgrades, and other topics, but is not meant to be prescriptive. Consider this your launching point for your growth as a Cordova developer. Also, if you see something that can be improved, please [contribute](http://cordova.apache.org/contribute/)! This guide contains the following topics: @@ -33,17 +33,17 @@ This guide contains the following topics: * User Interface * Special Considerations * Keeping Up -* Getting Help +* Getting Help # Best Practices Cordova app development ## 1) SPA Is Your Friend -First and foremost - your Cordova applications should adopt the SPA (Single Page Application) design. Loosely defined, a SPA is a client-side application that is run from one request of a web page. The user loads an initial set of resources (HTML, CSS, and JavaScript) and further updates (showing a new view, loading data) is done via AJAX. SPAs are commonly used for more complex client-side applications. GMail is a great example of this. After you load GMail, mail views, editing, and organization are all done by updating the DOM instead of actually leaving the current page to load a completely new one. +First and foremost - your Cordova applications should adopt the SPA (Single Page Application) design. Loosely defined, a SPA is a client-side application that is run from one request of a web page. The user loads an initial set of resources (HTML, CSS, and JavaScript) and further updates (showing a new view, loading data) is done via AJAX. SPAs are commonly used for more complex client-side applications. GMail is a great example of this. After you load GMail, mail views, editing, and organization are all done by updating the DOM instead of actually leaving the current page to load a completely new one. -Using a SPA can help you organize your application in a more efficient manner, but it also has specific benefits for Cordova applications. A Cordova application must wait for the [deviceready](../../cordova/events/events.deviceready.html) event to fire before any plugins may be used. If you do not use a SPA, and your user clicks to go from one page to another, you will have to wait for [deviceready](../../cordova/events/events.deviceready.html) to fire again before you make use of a plugin. This is easy to forget as your application gets larger. +Using a SPA can help you organize your application in a more efficient manner, but it also has specific benefits for Cordova applications. A Cordova application must wait for the [deviceready][DeviceReadyEvent] event to fire before any plugins may be used. If you do not use a SPA, and your user clicks to go from one page to another, you will have to wait for [deviceready][DeviceReadyEvent] to fire again before you make use of a plugin. This is easy to forget as your application gets larger. -Even if you choose not to use Cordova, creating a mobile application without using a single page architecture will have serious performance implications. This is because navigating between pages will require scripts, assets, etc., to be reloaded. Even if these assets are cached, there will still be performance issues. +Even if you choose not to use Cordova, creating a mobile application without using a single page architecture will have serious performance implications. This is because navigating between pages will require scripts, assets, etc., to be reloaded. Even if these assets are cached, there will still be performance issues. Examples of SPA libraries you can use in your Cordova applications are: @@ -60,9 +60,9 @@ And many, many, more. ## 2) Performance Considerations -One of the biggest mistakes a new Cordova developer can make is to assume that the performance they get on a desktop machine is the same they will get on a mobile device. While our mobile devices have gotten more powerful every year, they still lack the power and performance of a desktop. Mobile devices typically have much less RAM and a GPU that is a far cry from their desktop (or even laptop) brethren. A full list of tips here would be too much, but here are a few things to keep in mind (with a list of longer resources at the end for further research). +Consider the following issues to improve the performance in your mobile applications: -**Click versus Touch** - The biggest and simplest mistake you can make is to use click events. While these "work" just fine on mobile, most devices impose a 300ms delay on them in order to distinguish between a touch and a touch "hold" event. Using `touchstart`, or `touchend`, will result in a dramatic improvement - 300ms doesn't sound like much, but it can result in jerky UI updates and behavior. You should also consider the fact that âtouchâ events are not supported on non-webkit browsers, see [CanIUse](http://caniuse.com/#search=touch). In order to deal with these limitations, you can checkout various libraries like HandJS and Fastouch. +**Click versus Touch** - The biggest and simplest mistake you can make is to use click events. While these "work" just fine on mobile, most devices impose a 300ms delay on them in order to distinguish between a touch and a touch "hold" event. Using `touchstart`, or `touchend`, will result in a dramatic improvement - 300ms doesn't sound like much, but it can result in jerky UI updates and behavior. You should also consider the fact that âtouchâ events are not supported on non-webkit browsers, see [CanIUse](http://caniuse.com/#search=touch). In order to deal with these limitations, you can checkout various libraries like HandJS and Fastclick. **CSS Transitions versus DOM Manipulation** - Using hardware accelerated CSS transitions will be dramatically better than using JavaScript to create animations. See the list of resources at the end of this section for examples. @@ -80,9 +80,9 @@ One of the biggest mistakes a new Cordova developer can make is to assume that t See the previous tip about networks. Not only can you be on a slow network, it is entirely possible for your application to be completely offline. Your application should handle this in an intelligent manner. If your application does not, people will think your application is broken. Given how easy it is to handle (Cordova supports listening for both an offline and online event), there is absolutely no reason for your application to not respond well when run offline. Be sure to test (see the Testing section below) your application and be sure to test how your application handles when you start in one state and then switch to another. -Note that the online and offline events, as well as the Network Connection API is not perfect. You may need to rely on using an XHR request to see if the device is truly offline or online. At the end of the day, be sure add some form of support for network issues - in fact, the Apple store (and probably other stores) will reject apps that donât properly handle offline/online states. For more discussion on this topic, see +Note that the online and offline events, as well as the Network Connection API is not perfect. You may need to rely on using an XHR request to see if the device is truly offline or online. At the end of the day, be sure add some form of support for network issues - in fact, the Apple store (and probably other stores) will reject apps that donât properly handle offline/online states. For more discussion on this topic, see ["Is This Thing On?"](http://blogs.telerik.com/appbuilder/posts/13-04-23/is-this-thing-on-%28part-1%29) - + # Handling Upgrades ## Upgrading Cordova Projects @@ -105,26 +105,29 @@ Regardless of the project's prior version, it is absolutely critical that you re Note: some plugins may not be compatible with the new version of Cordova. If a plugin is not compatible, you may be able to find a replacement plugin that does what you need, or you may need to delay upgrading your project. Alternatively, alter the plugin so that it does work under the new version and contribute back to the community. ## Plugin Upgrades -As of Cordova 3.4, there is no mechanism for upgrading changed plugins using a single command. Instead, remove the plugin and add it back to your project, and the new version will be installed: +Currently there is no mechanism for upgrading changed plugins using a single command. Instead, remove the plugin and add it back to your project, and the new version will be installed: - cordova plugin rm com.some.plugin - cordova plugin add com.some.plugin +``` +cordova plugin rm "some-plugin" +cordova plugin add "some-plugin" +``` +Refer to [Manage versions and platforms](../../platform_plugin_versioning_ref/index.html) for more details. Be sure to check the updated plugin's documentation, as you may need to adjust your code to work with the new version. Also, double check that the new version of the plugin works with your projectâs version of Cordova. Always test your apps to ensure that installing the new plugin has not broken something that you did not anticipate. -If your project has a lot of plugins that you need updated, it might save time to create a shell or batch script that removes and adds the plugins with one command. +If your project has a lot of plugins that you need updated, it might save time to create a shell or batch script that removes and adds the plugins with one command. # Testing Cordova apps -Testing your applications is super important. The Cordova team uses Jasmine but any web friendly unit testing solution will do. +Testing your applications is super important. The Cordova team uses Jasmine but any web friendly unit testing solution will do. ## Testing on a simulator vs. on a real device Itâs not uncommon to use desktop browsers and device simulators/emulators when developing a Cordova application. However, it is incredibly important that you test your app on as many physical devices as you possibly can: -* Simulators are just that: simulators. For example, your app may work in the iOS simulator without a problem, but it may fail on a real device (especially in certain circumstances, such as a low memory state). Or, your app may actually fail on the simulator while it works just fine on a real device. +* Simulators are just that: simulators. For example, your app may work in the iOS simulator without a problem, but it may fail on a real device (especially in certain circumstances, such as a low memory state). Or, your app may actually fail on the simulator while it works just fine on a real device. * Emulators are just that: emulators. They do not represent how well your app will run on a physical device. For example, some emulators may render your app with a garbled display, while a real device has no problem. (If you do encounter this problem, disable the host GPU in the emulator.) * Simulators are generally faster than your physical device. Emulators, on the other hand, are generally slower. Do not judge the performance of your app by how it performs in a simulator or an emulator. Do judge the performance of your app by how it runs on a spectrum of real devices. * It's impossible to get a good feel for how your app responds to your touch by using a simulator or an emulator. Instead, running the app on a real device can point out problems with the sizes of user interface elements, responsiveness, etc. @@ -132,7 +135,7 @@ Itâs not uncommon to use desktop browsers and device simulators/emulators when It is, of course, impossible to test on every possible device on the market. For this reason, itâs wise to recruit many testers who have different devices. Although they wonât catch every problem, chances are good that they will discover quirks and issues that you would never find alone. -Tip: It is possible on Android Nexus devices to easily flash different versions of Android onto the device. This simple process will allow you to easily test your application on different levels of Android with a single device, without voiding your warranty or requiring you to âjailbreakâ or ârootâ your device. The Google Android factory images and instructions are located at: https://developers.google.com/android/nexus/images#instructions +Tip: It is possible on Android Nexus devices to easily flash different versions of Android onto the device. This simple process will allow you to easily test your application on different levels of Android with a single device, without voiding your warranty or requiring you to âjailbreakâ or ârootâ your device. Refer to the [Google Android factory images and instructions](https://developers.google.com/android/nexus/images#instructions). # Debugging Cordova apps @@ -141,10 +144,10 @@ Debugging Cordova requires some setup. Unlike a desktop application, you can't s ## iOS Debugging ### Xcode -With Xcode you can debug the iOS native side of your Cordova application. Make sure the Debug Area is showing (View -> Debug Area). Once your app is running on the device (or simulator), you can view log output in the debug area. This is where any errors or warnings will print. You can also set breakpoints within the source files. This will allow you to step through the code one line at a time and view the state of the variables at that time. The state of the variables is shown in the debug area when a breakpoint is hit. Once your app is up and running on the device, you can bring up Safari's web inspector (as described below) to debug the webview and js side of your application. For more details and help, see the Xcode guide: [Xcode Debugging Guide](https://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode_Overview/DebugYourApp/DebugYourApp.html#//apple_ref/doc/uid/TP40010215-CH18-SW1) +With Xcode you can debug the iOS native side of your Cordova application. Make sure the Debug Area is showing (View -> Debug Area). Once your app is running on the device (or simulator), you can view log output in the debug area. This is where any errors or warnings will print. You can also set breakpoints within the source files. This will allow you to step through the code one line at a time and view the state of the variables at that time. The state of the variables is shown in the debug area when a breakpoint is hit. Once your app is up and running on the device, you can bring up Safari's web inspector (as described below) to debug the webview and js side of your application. For more details refer to the [Apple Support](https://developer.apple.com/support/debugging/) docs. ### Safari Remote Debugging with Web Inspector -With Safari's web inspector you can debug the webview and js code in your Cordova application. This works only on OSX and only with iOS 6 (and higher). It uses Safari to connect to your device (or the simulator) and will connect the browser's dev tools to the Cordova application. You get what you expect from dev tools - DOM inspection/manipulation, a JavaScript debugger, network inspection, the console, and more. Like Xcode, with Safari's web inspector you can set breakpoints in the JavaScript code and view the state of the variables at that time. You can view any errors, warnings or messages that are printed to the console. You can also run JavaScript commands directly from the console as your app is running. For more details on how to set it up and what you can do, see this excellent blog post: [http://moduscreate.com/enable-remote-web-inspector-in-ios-6/](http://moduscreate.com/enable-remote-web-inspector-in-ios-6/) and this guide: [Safari Web Inspector Guide](https://developer.a pple.com/library/safari/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/Introduction/Introduction.html) +With Safari's web inspector you can debug the webview and js code in your Cordova application. This works only on OSX and only with iOS 6 (and higher). It uses Safari to connect to your device (or the simulator) and will connect the browser's dev tools to the Cordova application. You get what you expect from dev tools - DOM inspection/manipulation, a JavaScript debugger, network inspection, the console, and more. Like Xcode, with Safari's web inspector you can set breakpoints in the JavaScript code and view the state of the variables at that time. You can view any errors, warnings or messages that are printed to the console. You can also run JavaScript commands directly from the console as your app is running. For more details on how to set it up and what you can do, see the blog post about [Enabling Remote Web Inspector in iOS 6](http://moduscreate.com/enable-remote-web-inspector-in-ios-6/) and [Safari Web Inspector Guide](https://developer.apple.com/library/safari/documentation/Ap pleApplications/Conceptual/Safari_Developer_Guide/Introduction/Introduction.html). ## Chrome Remote Debugging Virtually the same as the Safari version, this works with Android only but can be used from any desktop operating system. It requires a minimum of Android 4.4 (KitKat), minimum API level of 19, and Chrome 30+ (on the desktop). Once connected, you get the same Chrome Dev Tools experience for your mobile applications as you do with your desktop applications. Even better, the Chrome Dev Tools have a mirror option that shows your app running on the mobile device. This is more than just a view - you can scroll and click from dev tools and it updates on the mobile device. More details on Chrome Remote Debugging may be found here: [https://developers.google.com/chrome/mobile/docs/debugging](https://developers.google.com/chrome/mobile/docs/debugging) @@ -160,8 +163,6 @@ Weinre creates a local server that can host a remote debug client for your Cordo ## Other Options * BlackBerry 10 supports debugging as well: [Documentation]( https://developer.blackberry.com/html5/documentation/v2_0/debugging_using_web_inspector.html) -* You can debug using Firefox App Manager as well, see [this blog post](https://hacks.mozilla.org/2014/02/building-cordova-apps-for-firefox-os/) and this -[MDN article](https://developer.mozilla.org/en-US/Apps/Tools_and_frameworks/Cordova_support_for_Firefox_OS#Testing_and_debugging). * For more examples and explanation of the above debugging tips, see: [http://developer.telerik.com/featured/a-concise-guide-to-remote-debugging-on-ios-android-and-windows-phone/](http://developer.telerik.com/featured/a-concise-guide-to-remote-debugging-on-ios-android-and-windows-phone/) # User Interface @@ -169,17 +170,17 @@ Weinre creates a local server that can host a remote debug client for your Cordo Building a Cordova application that looks nice on mobile can be a challenge, especially for developers. Many people chose to use a UI framework to make this easier. Here is a short list of options you may want to consider. * [jQuery Mobile](http://jquerymobile.com) - jQuery Mobile automatically enhances your layout for mobile optimization. It also handles creating a SPA for you automatically. -* [ionic](http://ionicframework.com/) - This powerful UI framework actually has its own CLI to handle project creation. -* [Ratchet](http://goratchet.com/) - Brought to you by the people who created Bootstrap. +* [ionic](http://ionicframework.com/) - This powerful UI framework actually has its own CLI to handle project creation. +* [Ratchet](http://goratchet.com/) - Brought to you by the people who created Bootstrap. * [Kendo UI](http://www.telerik.com/kendo-ui) - Open source UI and application framework from Telerik. * [Topcoat](http://topcoat.io) * [ReactJS](http://facebook.github.io/react/) -When building your user interface, it is important to think about all platforms that you are targeting and the differences between the userâs expectations. For example, an Android application that has an iOS-style UI will probably not go over well with users. This sometimes is even enforced by the various application stores. Because of this, it is important that you respect the conventions of each platform and therefore are familiar with the various Human Interface Guidelines: +When building your user interface, it is important to think about all platforms that you are targeting and the differences between the userâs expectations. For example, an Android application that has an iOS-style UI will probably not go over well with users. This sometimes is even enforced by the various application stores. Because of this, it is important that you respect the conventions of each platform and therefore are familiar with the various Human Interface Guidelines: * [iOS](https://developer.apple.com/library/ios/documentation/userexperience/conceptual/MobileHIG/index.html) -* [Android](https://developer.android.com/designWP8) -* [Windows Phone](http://dev.windowsphone.com/en-us/design/library) +* [Android](http://developer.android.com/design/index.html) +* [Windows Phone](https://dev.windows.com/en-us/design) ## Additional UI Articles and Resources @@ -214,7 +215,8 @@ The following links are the best places to get help for Cordova: By using the Cordova tag, you can view and browse all Cordova questions. Note that StackOverflow automatically converts the "Phonegap" tag to "Cordova", so this way you will be able to access historical questions as well * PhoneGap Google Group: [https://groups.google.com/forum/#!forum/phonegap](https://groups.google.com/forum/#!forum/phonegap) This Google Group was the old support forum when Cordova was still called PhoneGap. While there are still a lot of Cordova users that frequently visit this group, the Cordova community has expressed an interest in focusing less on this group and instead using StackOverflow for support -* Meetup: [http://phonegap.meetup.com](http://phonegap.meetup.com) - +* Meetup: [http://phonegap.meetup.com](http://phonegap.meetup.com) - Consider finding a local Cordova/PhoneGap meetup group +[DeviceReadyEvent]: ../../cordova/events/events.html#deviceready http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/overview/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/overview/index.md b/www/docs/en/6.x/guide/overview/index.md index 146e358..6dc9ede 100644 --- a/www/docs/en/6.x/guide/overview/index.md +++ b/www/docs/en/6.x/guide/overview/index.md @@ -17,19 +17,16 @@ license: > specific language governing permissions and limitations under the License. -title: Overview +title: Architectural overview of Cordova platform --- # Overview Apache Cordova is an open-source mobile development framework. It allows you -to use standard web technologies such as HTML5, CSS3, and JavaScript -for cross-platform development, avoiding each mobile platforms' native -development language. Applications execute within wrappers targeted +to use standard web technologies - HTML5, CSS3, and JavaScript +for cross-platform development. Applications execute within wrappers targeted to each platform, and rely on standards-compliant API bindings to -access each device's sensors, data, and network status. - -Apache Cordova graduated in October 2012 as a top level project within the Apache Software Foundation (ASF). Through the ASF, future Cordova development will ensure open stewardship of the project. It will always remain free and open source under the Apache License, Version 2.0. Visit [cordova.apache.org](http://cordova.apache.org) for more information. +access each device's capabilities such as sensors, data, network status, etc. Use Apache Cordova if you are: @@ -45,99 +42,103 @@ Use Apache Cordova if you are: device-level APIs, or if you want to develop a plugin interface between native and WebView components. -## Basic Components +# Architecture -Apache Cordova applications rely on a common `config.xml` file that provides -information about the app and specifies parameters affecting how it -works, such as whether it responds to orientation shifts. This file -adheres to the W3C's -[Packaged Web App](http://www.w3.org/TR/widgets/), -or _widget_, specification. +There are several components to a cordova application. The following +diagram shows a high-level view of the cordova application architecture. + + -The application itself is implemented as a web page, by default a local -file named _index.html_, that references whatever CSS, JavaScript, -images, media files, or other resources are necessary for it to run. -The app executes as a _WebView_ within the native application wrapper, -which you distribute to app stores. +## WebView The Cordova-enabled WebView may provide the application with its entire user interface. On some platforms, it can also be a component within a larger, hybrid application that mixes the WebView with native -application components. (See [Embedding WebViews](../hybrid/webviews/index.html) for details.) - -A _plugin_ interface is available for Cordova and native components to -communicate with each other. This enables you to invoke native code -from JavaScript. Ideally, the JavaScript APIs to that native code are -consistent across multiple device platforms. As of version 3.0, plugins provide -bindings to standard device APIs. Third-party plugins provide -additional bindings to features not necessarily available on all -platforms. You can find these third-party plugins in the -[plugin registry](http://plugins.cordova.io) and use them in your -application. You can also develop your own plugins, as described in the -[Plugin Development Guide](../hybrid/plugins/index.html). Plugins may be necessary, for example, to -communicate between Cordova and custom native components. - -__NOTE__: As of version 3.0, when you create a Cordova project it does not have +application components. +(See [Embedding WebViews](../hybrid/webviews/index.html) for details.) + +## Web App + +This is the part where your application code resides. The application itself is +implemented as a web page, by default a local file named _index.html_, that +references CSS, JavaScript, images, media files, or other resources +are necessary for it to run. The app executes in a _WebView_ within the native +application wrapper, which you distribute to app stores. + +This container has a very crucial file - [config.xml](../../config_ref/index.html) +file that provides information about the app and specifies parameters affecting how it +works, such as whether it responds to orientation shifts. + +## Plugins + +Plugins are an integral part of the cordova ecosystem. They provide +an interface for Cordova and native components to communicate with each +other and bindings to standard device APIs. This enables you to invoke native +code from JavaScript. + +Apache Cordova project maintains a set of plugins called the +[Core Plugins](../guide/support/index.html#core-plugin-apis). These core +plugins provide your application to access device capabilities such as +battery, camera, contacts, etc. + +In addition to the core plugins, there are several third-party plugins which +provide additional bindings to features not necessarily available on all +platforms. You can search for Cordova plugins using [plugin search](/plugins/) or [npm](https://www.npmjs.com/search?q=ecosystem%3Acordova). You can also +develop your own plugins, as described in the +[Plugin Development Guide](../hybrid/plugins/index.html). Plugins may be +necessary, for example, to communicate between Cordova and custom native +components. + +__NOTE__: When you create a Cordova project it does not have any plugins present. This is the new default behavior. Any plugins you desire, even the core plugins, must be explicitly added. Cordova does not provide any UI widgets or MV* frameworks. Cordova provides only the runtime in which those can execute. If you wish to use UI widgets and/or an MV* framework, you will need to select those and include them in -your application yourself as third-party material. +your application. ## Development Paths -As of version 3.0, you can use two basic workflows to create a mobile +Cordova provides you two basic workflows to create a mobile app. While you can often use either workflow to accomplish the same task, they each offer advantages: - __Cross-platform (CLI) workflow__: Use this workflow if you want your app to run on as many different mobile operating systems as possible, - with little need for platform-specific development. This workflow - centers around the `cordova` utility, otherwise known as the Cordova - _CLI_, that was introduced with Cordova 3.0. The CLI is a high-level - tool that allows you to build projects for many platforms at once, - abstracting away much of the functionality of lower-level shell - scripts. The CLI copies a common set of web assets into + with little need for platform-specific development. This workflow + centers around the `cordova` CLI. The CLI is a high-level tool that allows you to build projects + for many platforms at once, abstracting away much of the functionality of + lower-level shell scripts. The CLI copies a common set of web assets into subdirectories for each mobile platform, makes any necessary configuration changes for each, runs build scripts to generate application binaries. The CLI also provides a common interface to - apply plugins to your app. For more details on the CLI, see The - Command-Line Interface. Unless you have a need for the platform-centered - workflow, the cross-platform workflow is recommended. + apply plugins to your app. To get started follow the steps in the + [Create your first app] guide. Unless you have a need for the platform-centered workflow, the cross-platform workflow is recommended. - __Platform-centered workflow__: Use this workflow if you want to focus on building an app for a single platform and need to be able to modify it at a lower level. You need to use this approach, for example, if you want your app to mix custom native components with - web-based Cordova components, as discussed in [Embedding WebViews](../hybrid/webviews/index.html). - As a rule of thumb, use this workflow if you need to modify the - project within the SDK. This workflow relies on a set of - lower-level shell scripts that are tailored for each supported - platform, and a separate Plugman utility that allows you to apply - plugins. While you can use this workflow to build cross-platform + web-based Cordova components, as discussed in + [Embedding WebViews](../hybrid/webviews/index.html). As a rule of thumb, use + this workflow if you need to modify the project within the SDK. This + workflow relies on a set of lower-level shell scripts that are tailored for + each supported platform, and a separate Plugman utility that allows you to + apply plugins. While you can use this workflow to build cross-platform apps, it is generally more difficult because the lack of a higher-level tool means separate build cycles and plugin - modifications for each platform. Still, this workflow allows you - greater access to development options provided by each SDK, and is - essential for complex hybrid apps. See the various [Platform Guides](../platforms/index.html) - for details on each platform's available shell utilities. + modifications for each platform. When first starting out, it may be easiest to use the cross-platform -workflow to create an app, as described in [The Command-Line Interface](../cli/index.html). +workflow to create an app, as described in [Create your first app] guide. You then have the option to switch to a platform-centered workflow if -you need the greater control the SDK provides. Lower-level shell -utilities are available at -[cordova.apache.org](http://cordova.apache.org) in a separate -distribution than the CLI. For projects initially generated by the -CLI, these shell tools are also available in the project's various -`platforms/*/cordova` directories. - -__NOTE__: Once you switch from the CLI-based workflow to one centered +you need the greater control the SDK provides. + +> __NOTE__: Once you switch from the CLI-based workflow to one centered around the platform-specific SDKs and shell tools, you can't go back. The CLI maintains a common set of cross-platform source code, which on -each build it uses to write over platform-specific source code. To +each build it uses to write over platform-specific source code. To preserve any modifications you make to the platform-specific assets, you need to switch to the platform-centered shell tools, which ignore the cross-platform source code, and instead relies on the @@ -148,13 +149,14 @@ platform-specific source code. The installation of Cordova will differ depending on the workflow above you choose: - * Cross-platform workflow: see [The Command-Line Interface](../cli/index.html). + * Cross-platform workflow: See [Create your first app] guide. + + * Platform-centered workflow. - * Platform-centered workflow: see the [Platform Guides](../platforms/index.html). +After installing Cordova, it is recommended that you review the +```Develop for Platforms``` section for the mobile platforms that you +will be developing for. It is also recommended that you also review the +[Privacy Guide](../appdev/privacy/index.html) and +[Security Guide](../appdev/security/index.html). -After installing Cordova, it is recommended that you review the [Platform Guides](../platforms/index.html) -for the mobile platforms that you will be developing for. It is also -recommended that you also review the [Privacy Guide](../appdev/privacy/index.html), [Security Guide](../appdev/security/index.html), and -[Next Steps](../next/index.html). For configuring Cordova, see [The config.xml File](../../config_ref/index.html). -For accessing native function on a device from JavaScript, refer -to the [Plugin APIs](../../cordova/plugins/pluginapis.html). And refer to the other included guides as necessary. +[Create your first app]:../cli/index.html \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/platforms/amazonfireos/config.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/amazonfireos/config.md b/www/docs/en/6.x/guide/platforms/amazonfireos/config.md deleted file mode 100644 index 8a99227..0000000 --- a/www/docs/en/6.x/guide/platforms/amazonfireos/config.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -license: > - 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. - -title: Amazon Fire OS Configuration ---- - -# Amazon Fire OS Configuration - -The `config.xml` file controls an app's basic settings that apply -across each application and CordovaWebView instance. This section -details preferences that only apply to Amazon Fire OS builds. See [The config.xml -File](config_ref_index.md.html#The%20config.xml%20File) for information on global configuration options. - -- `KeepRunning` (boolean, defaults to `true`): Determines whether the - application stays running in the background even after a `[pause](../../../cordova/events/events.pause.html)` - event fires. Setting this to `false` does not kill the app after a - `[pause](../../../cordova/events/events.pause.html)` event, but simply halts execution of code within the cordova - webview while the app is in the background. - - <preference name="KeepRunning" value="false"/> - -- `ErrorUrl` (URL, defaults to `null`): - If set, will display the referenced page upon an error in the application - instead of a dialog with the title "Application Error". - - <preference name="ErrorUrl" value="error.html"/> - -- `LoadingDialog` (string, defaults to `null`): If set, displays a dialog with - the specified title and message, and a spinner, when loading the first - page of an application. The title and message are separated by a comma - in this value string, and that comma is removed before the dialog is - displayed. - - <preference name="LoadingDialog" value="Please wait, the app is loading"/> - -- `LoadingPageDialog` (string, defaults to `null`): The same as `LoadingDialog`, - but for loading every page after the first page in the application. - - <preference name="LoadingPageDialog" value="Please wait, the data is loading"/> - -- `LoadUrlTimeoutValue` (number, default is `20000`): When loading a - page, the amount of time to wait before throwing a timeout error. - This example specifies 10 seconds rather than 20: - - <preference name="LoadUrlTimeoutValue" value="10000"/> - -- `SplashScreen`: The name of the file minus its extension in the - `res/drawable` directory. Various assets must share this common - name in various subdirectories. - - <preference name="SplashScreen" value="splash"/> - -- `SplashScreenDelay` (number, defaults to `5000`): The amount of - time the splash screen image displays. - - <preference name="SplashScreenDelay" value="10000"/> - -- `ShowTitle` (boolean, defaults to `false`): Show the title at the top - of the screen. - - <preference name="ShowTitle" value="true"/> - -- `LogLevel` (string, defaults to `ERROR`): Sets the minimum log level - through which log messages from your application will be filtered. Valid - values are `ERROR`, `WARN`, `INFO`, `DEBUG`, and `VERBOSE`. - - <preference name="LogLevel" value="VERBOSE"/> - http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/platforms/amazonfireos/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/amazonfireos/index.md b/www/docs/en/6.x/guide/platforms/amazonfireos/index.md deleted file mode 100644 index 055f249..0000000 --- a/www/docs/en/6.x/guide/platforms/amazonfireos/index.md +++ /dev/null @@ -1,195 +0,0 @@ ---- -license: > - 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. - -title: Amazon Fire OS Platform Guide ---- - -# Amazon Fire OS Platform Guide - -This guide shows how to set up your SDK development environment to -deploy Cordova apps for Amazon Fire OS devices, such as the Kindle Fire HDX. - -See the following for more detailed platform-specific information: - -* [Amazon Fire OS Configuration](config.html) -* [Amazon Fire OS WebViews](webview.html) -* [Amazon Fire OS Plugins](plugin.html) - -## Introduction - -By targeting the Amazon Fire OS platform, Cordova developers can create hybrid web apps that take advantage of the advanced web engine integrated into Kindle Fire devices. Amazon WebView API (AWV) is a Chromium-derived web runtime exclusive to Fire OS. A drop-in replacement for the WebView that comes with Android devices, AWV makes it possible to create better performing and more powerful hybrid web apps by providing support for a faster JavaScript engine (V8), remote debugging, and hardware optimizations for Kindle Fire devices including an accelerated 2D Canvas, and access to HTML5 features not supported by Androidâs built in WebView such as: CSS Calc, Form Validation, getUserMedia, IndexedDB, Web Workers, WebSockets and WebGL. - -For more information about the Amazon WebView API, please see the Amazon Developer Portal's [HTML5 Hybrid Apps page](https://developer.amazon.com/public/solutions/platforms/android-fireos/docs/building-and-testing-your-hybrid-app). For questions about getting started and other support issues, please see the Amazon Developer Portal [Forums - HTML5 Hybrid Apps](http://forums.developer.amazon.com/forums/category.jspa?categoryID=41). - - -## Requirements and Support - -Developing Cordova apps for Amazon Fire OS requires installation of a variety of support files, including everything needed for Android development, as well as the Amazon WebView SDK. Check the list below for the required installs: - -* [The Command-Line Interface](../../cli/index.html) -* [Android SDK](http://developer.android.com/sdk/) -* [Apache Ant](http://ant.apache.org) -* [Amazon WebView SDK](https://developer.amazon.com/public/solutions/platforms/android-fireos/docs/building-and-testing-your-hybrid-app) - -## Installation - - -### Android SDK and Apache Ant - -Install the Android SDK from -[developer.android.com/sdk](http://developer.android.com/sdk/). You -may be presented with a choice of where to install the SDK, otherwise -move the downloaded `adt-bundle` tree to wherever you store -development tools. - -You'll need to run the Android SDK Manager (`android` from a command line) at least once before starting your Cordova project. Make sure to install the most recent version of the Android SDK Tools and SDK Platform **specifically API level 19**. Please see [Setting up your Development Environment](https://developer.amazon.com/public/resources/development-tools/ide-tools/tech-docs/01-setting-up-your-development-environment) on the Amazon Developer Portal for more information about setting up your development environment for Kindle Fire OS devices. - -Install the Apache Ant build tool by [downloading an Ant binary distribution](http://ant.apache.org/bindownload.cgi), unzipping into a directory you can refer to later. See the [Ant manual](http://ant.apache.org/manual/index.html) for more info. - -For Cordova command-line tools to work, you need to include the Android SDK's -`tools`, `platform-tools` and `apache-ant/bin` directories in your PATH environment. - -#### Mac/Linux Path - -On Mac, Linux or other Unix-like platforms, you can use a text editor to create or modify the -`~/.bash_profile` file, adding a line such as the following, depending -on where the SDK and Ant are installed: - - export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools:/Development/apache-ant/bin - -This exposes SDK tools in newly opened terminal windows. Otherwise run -this to make them available in the current session: - - $ source ~/.bash_profile - -#### Windows Path - -To modify the PATH environment on Windows: - -* Click on the __Start__ menu in the lower-left corner of the desktop, - right-click on __Computer__, then click __Properties__. - -* Click __Advanced System Settings__ in the column on the left. - -* In the resulting dialog box, press __Environment Variables__. - -* Select the __PATH__ variable and press __Edit__. - -* Append the following to the PATH based on where you installed the - SDK and Ant, for example: - - ;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools;C:\Development\apache-ant\bin - -* Save the value and close both dialog boxes. - -* You will also need to enable Java. Open a command prompt and -type `java`, if it does not run, append the location of the Java binaries to your PATH as well. Make sure %JAVA_HOME% is pointing to installed JDK directory. You might have to add JAVA_HOME environment variable seperately. - - ;%JAVA_HOME%\bin - - -### Amazon WebView SDK - -In order to create Cordova apps using the Amazon Fire OS platform target, you'll need to download, unpack and install the Amazon WebView SDK support files. This step will only need to be done for your first Amazon Fire OS project. - -* Download the Amazon WebView SDK from the [Amazon Developer Portal](https://developer.amazon.com/public/solutions/platforms/android-fireos/docs/building-and-testing-your-hybrid-app). - -* Copy `awv_interface.jar` from the downloaded SDK to Cordova's working directory. Create commonlibs(shown below) folder if it doesn't exist: - - **Mac/Linux:** - `~/.cordova/lib/commonlibs/` - - **Windows:** - `%USERPROFILE%\.cordova\lib\commonlibs` - - -## Create New Project for Amazon Fire OS - -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 amazon-fireos - $ cordova build - -***Note:*** The first time the amazon-fireos platform is installed on your system, it will download the appropriate files to the Cordova working directory, but will then fail as it is missing the AWV SDK support files (see above). Follow the instructions above to install the `awv_interface.jar`, then remove and re-add the amazon-fireos platform to your project. This step will only need to be done for first Amazon Fire OS project. - - -## Deploy to Device - -To push an app directly to the device, make sure USB debugging is enabled on your device as described on the -[Android Developer Site](http://developer.android.com/tools/device.html), -and use a mini USB cable to plug it into your system. - -You can push the app to the device from the command line: - - $ cordova run amazon-fireos - -Alternately within Eclipse, right-click the project and choose __Run -As → Android Application__. - -__Note__: Currently, testing via an emulator is not supported for Amazon WebView based apps, additionally the Amazon WebView API is only available on Fire OS devices. For more information, please see the [Amazon WebView API SDK](https://developer.amazon.com/public/solutions/platforms/android-fireos/docs/building-and-testing-your-hybrid-app) documentation. - -### Run Flags - -The run command accepts optional parameters as specified in the Cordova Command Line Interface document, Fire OS also accepts an additional `--debug` flag which will enable Chromium's Developer Tools for remote web debugging. - -To use Developer Tools, enter: - - $ cordova run --debug amazon-fireos - -This will enable the tools on the running client. You can then connect to the client by port forwarding using the Android Debug Bridge (adb) referring to the app's package name. - -For example: - - adb forward tcp:9222 localabstract:com.example.helloworld.devtools - -You can then use the DevTools via a Chromium-based browser by navigating to: `http://localhost:9222`. - -### Optional Eclipse support - -Once created, you can use the Eclipse that comes along with the Android SDK to modify the project. Beware that modifications made through Eclipse will be overwritten if you continue to use Cordova command line tools. - -* Launch the __Eclipse__ application. - -* Select the __New Project__ menu item. - -* Choose __Android Project from Existing Code__ from the resulting dialog box, and press __Next__: -  - -* Navigate to `hello`, or whichever directory you created for the project, then to the `platforms/amazon-fireos` subdirectory. - -* Eclipse will show you hello and hello-CorddovaLib - 2 projects to be added. Add both. - -* Press __Finish__. - -Once the Eclipse window opens, a red __X__ may appear to indicate -unresolved problems. If so, follow these additional steps: - -* Right-click on the project directory. - -* In the resulting __Properties__ dialog, select __Android__ from the navigation pane. - -* For the project build target, select the highest Android API level (currently API Level 19) you have installed. - -* Click __OK__. - -* Select __Clean__ from the __Project__ menu. This should correct all the errors in the project. - http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/platforms/amazonfireos/plugin.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/amazonfireos/plugin.md b/www/docs/en/6.x/guide/platforms/amazonfireos/plugin.md deleted file mode 100644 index d4fdac4..0000000 --- a/www/docs/en/6.x/guide/platforms/amazonfireos/plugin.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -license: > - 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. - -title: Amazon Fire OS Plugins ---- - -# Amazon Fire OS Plugins - -Follow the instructions provided in the [Android Plugins](../android/plugin.html) Guide for an overview of developing custom plugins. - -## Echo Amazon Fire OS Plugin Example - -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: - - <platform name="amazon-fireos"> - <config-file target="config.xml" parent="/*"> - <feature name="Echo"> - <param name="android-package" value="org.apache.cordova.plugin.Echo"/> - </feature> - </config-file> - </platform> - -Then add the following to the -`src/org/apache/cordova/plugin/Echo.java` file: - - package org.apache.cordova.plugin; - - import org.apache.cordova.CordovaPlugin; - import org.apache.cordova.CallbackContext; - - import org.json.JSONArray; - import org.json.JSONException; - import org.json.JSONObject; - - /** - * 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."); - } - } - } - -If you want to reuse Android Plugin code for the Amazon Fire OS platform then modify the plugin.xml to point to the `android` specific source file. For example, - - <platform name="amazon-fireos"> - <config-file target="config.xml" parent="/*"> - <feature name="Echo"> - <param name="android-package" value="org.apache.cordova.plugin.Echo"/> - </feature> - </config-file> - <source-file src="src/android/Echo.java" target-dir="src/org/apache/cordova/plugin" /> - </platform> - -If you want to write a customized plugin for the Amazon Fire OS platform then create a folder named `amazon` under your plugin src/ folder and modify the plugin.xml to point to the `amazon` specific source file. For example, - - <platform name="amazon-fireos"> - <config-file target="config.xml" parent="/*"> - <feature name="Echo"> - <param name="android-package" value="org.apache.cordova.plugin.Echo"/> - </feature> - </config-file> - <source-file src="src/amazon/Echo.java" target-dir="src/org/apache/cordova/plugin" /> - </platform> - -## Using Amazon WebView in your plugin - -Cordova for Amazon Fire OS makes use of custom Amazon WebView that is built on the open-source Chromium project. It is GPU accelerated and optimized for fluid performance on Kindle Fire. - -To understand how to best use Amazon WebView in your project, check out the [Amazon Developer Portal](https://developer.amazon.com/sdk/fire/IntegratingAWV.html). http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/platforms/amazonfireos/webview.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/amazonfireos/webview.md b/www/docs/en/6.x/guide/platforms/amazonfireos/webview.md deleted file mode 100644 index 4c018e5..0000000 --- a/www/docs/en/6.x/guide/platforms/amazonfireos/webview.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -license: > - 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. - -title: Amazon Fire OS WebViews ---- - -# Amazon Fire OS WebViews - -Beginning with 3.3.0, you can use Cordova as a component in Amazon Fire OS applications. Amazon Fire OS refers to this component as `CordovaWebView`. `CordovaWebView` extends Amazon WebView that is built on the open source Chromium Project. By leveraging this feature, your web apps can utilize the latest HTML5 web standards running in a modern web runtime engine. - -If you're unfamiliar with Amazon Fire OS, you should first familiarize -yourself with the [Amazon Fire OS Platform Guide](index.html) and have the latest SDKs installed before you attempt the more unusual development option of embedding a WebView. - -## Prerequisites - -* Cordova 3.3.0 or greater - -* Android SDK updated to the latest SDK - -* Amazon WebView SDK - -## Guide to using CordovaWebView in a Amazon Fire OS Project - -1. To follow these instructions, make sure you have the latest Cordova - distribution. Download it from - [cordova.apache.org](http://cordova.apache.org) and unzip its - Amazon Fire OS package. - -2. Download and expand the [Amazon WebView SDK](https://developer.amazon.com/sdk/fire/IntegratingAWV.html#installawv) , then copy the awv_interface.jar into `/framework/libs` directory. Create a libs/ folder if it doesn't exist. - -3. Navigate to the package's `/framework` directory and run - `ant jar`. It creates the Cordova `.jar` file, formed as - `/framework/cordova-x.x.x.jar`. - -4. Copy the `.jar` file into the Android project's `/libs` directory. - -5. Add the following to the application's `/res/xml/main.xml` file, - with the `layout_height`, `layout_width` and `id` modified to suit - the application: - - <org.apache.cordova.CordovaWebView - android:id="@+id/tutorialView" - android:layout_width="match_parent" - android:layout_height="match_parent" /> - -6. Modify your activity so that it implements the `CordovaInterface`. You should implement the included methods. You may wish to copy them from `/framework/src/org/apache/cordova/CordovaActivity.java`, or implement them on your own. The code fragment below shows a basic application that uses the interface. Note how the referenced view id matches the `id` attribute specified in the XML fragment shown above: - - public class CordovaViewTestActivity extends Activity implements CordovaInterface { - CordovaWebView cwv; - /* Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - cwv = (CordovaWebView) findViewById(R.id.tutorialView); - Config.init(this); - cwv.loadUrl(Config.getStartUrl()); - } - -If you use the camera, you should also implement this: - - @Override - public void setActivityResultCallback(CordovaPlugin plugin) { - this.activityResultCallback = plugin; - } - /** - * Launch an activity for which you would like a result when it finished. When this activity exits, - * your onActivityResult() method is called. - * - * @param command The command object - * @param intent The intent to start - * @param requestCode The request code that is passed to callback to identify the activity - */ - 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, - * the resultCode it returned, and any additional data from it. - * - * @param requestCode The request code originally supplied to startActivityForResult(), - * allowing you to identify who this result came from. - * @param resultCode The integer result code returned by the child activity through its setResult(). - * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). - */ - protected void onActivityResult(int requestCode, int resultCode, Intent intent) { - super.onActivityResult(requestCode, resultCode, intent); - CordovaPlugin callback = this.activityResultCallback; - if (callback != null) { - callback.onActivityResult(requestCode, resultCode, intent); - } - } - -Finally, remember to add the thread pool, otherwise the plugins have no threads to run on: - - @Override - public ExecutorService getThreadPool() { - return threadPool; - } - -7. Copy your application's HTML and JavaScript files to your Amazon Fire OS project's `/assets/www` directory. - -8. Copy `config.xml` from `/framework/res/xml` to your project's `/res/xml` directory. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/28d8c235/www/docs/en/6.x/guide/platforms/android/config.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/android/config.md b/www/docs/en/6.x/guide/platforms/android/config.md deleted file mode 100644 index 6a120ad..0000000 --- a/www/docs/en/6.x/guide/platforms/android/config.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -license: > - 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. - -title: Android Configuration ---- - -# Android Configuration - -The `config.xml` file controls an app's basic settings that apply -across each application and CordovaWebView instance. This section -details preferences that only apply to Android builds. See [The config.xml -File](config_ref_index.md.html#The%20config.xml%20File) for information on global configuration options. - -- `KeepRunning` (boolean, defaults to `true`): Determines whether the - application stays running in the background even after a `[pause](../../../cordova/events/events.pause.html)` - event fires. Setting this to `false` does not kill the app after a - `[pause](../../../cordova/events/events.pause.html)` event, but simply halts execution of code within the cordova - webview while the app is in the background. - - <preference name="KeepRunning" value="false"/> - -- `LoadUrlTimeoutValue` (number in milliseconds, default to `20000`, - 20 seconds): When loading a page, the amount of time to wait before throwing - a timeout error. This example specifies 10 seconds rather than 20: - - <preference name="LoadUrlTimeoutValue" value="10000"/> - -- `SplashScreen` (string, defaults to `splash`): The name of the file minus - its extension in the `res/drawable` directory. Various assets must share - this common name in various subdirectories. - - <preference name="SplashScreen" value="mySplash"/> - -- `SplashScreenDelay` (number in milliseconds, defaults to `3000`): The amount - of time the splash screen image displays. - - <preference name="SplashScreenDelay" value="10000"/> - -- `InAppBrowserStorageEnabled` (boolean, defaults to `true`): Controls - whether pages opened within an InAppBrowser can access the same - localStorage and WebSQL storage as pages opened with the default - browser. - - <preference name="InAppBrowserStorageEnabled" value="true"/> - -- `LoadingDialog` (string, defaults to `null`): If set, displays a dialog with - the specified title and message, and a spinner, when loading the first - page of an application. The title and message are separated by a comma - in this value string, and that comma is removed before the dialog is - displayed. - - <preference name="LoadingDialog" value="My Title,My Message"/> - -- `LoadingPageDialog` (string, defaults to `null`): The same as `LoadingDialog`, - but for loading every page after the first page in the application. - - <preference name="LoadingPageDialog" value="My Title,My Message"/> - -- `ErrorUrl` (URL, defaults to `null`): - If set, will display the referenced page upon an error in the application - instead of a dialog with the title "Application Error". - - <preference name="ErrorUrl" value="myErrorPage.html"/> - -- `ShowTitle` (boolean, defaults to `false`): Show the title at the top - of the screen. - - <preference name="ShowTitle" value="true"/> - -- `LogLevel` (string, defaults to `ERROR`): Sets the minimum log level - through which log messages from your application will be filtered. Valid - values are `ERROR`, `WARN`, `INFO`, `DEBUG`, and `VERBOSE`. - - <preference name="LogLevel" value="VERBOSE"/> - -- `SetFullscreen` (boolean, defaults to `false`): Same as the `Fullscreen` - parameter in the global configuration of this xml file. This Android-specific - element is deprecated in favor of the global `Fullscreen` element, and will - be removed in a future version. - -- `AndroidLaunchMode` (string, defaults to `singleTop`): Sets the Activity - `android:launchMode` attribute. This changes what happens when the app is - launched from app icon or intent and is already running. - Valid values are `standard`, `singleTop`, `singleTask`, `singleInstance`. - - <preference name="AndroidLaunchMode" value="singleTop"/> - -- `DefaultVolumeStream` (string, defaults to `default`, added in cordova-android 3.7.0): Sets which volume - the hardware volume buttons link to. By default this is "call" for phones - and "media" for tablets. Set this to "media" to have your app's volume - buttons always change the media volume. Note that when using Cordova's - media plugin, the volume buttons will dynamically change to controlling - the media volume when any Media objects are active. - -- `OverrideUserAgent` (string, not set by default): - If set, the value will replace the old UserAgent of webview. - It is helpful to identify the request from app/browser when requesting remote pages. - Use with caution, this may causes compitiable issue with web servers. - For most cases, use AppendUserAgent instead. - - <preference name="OverrideUserAgent" value="Mozilla/5.0 My Browser" /> - -- `AppendUserAgent` (string, not set by default): - If set, the value will append to the end of old UserAgent of webview. - When using with OverrideUserAgent, this value will be ignored. - - <preference name="AppendUserAgent" value="My Browser" /> - - --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
