Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a68fd4394 | |||
| 54996900b5 | |||
| bb08abc0b9 | |||
| 1dfbebf98e | |||
| 2e0f40ff51 | |||
| bdecdea568 | |||
| a88b8de820 | |||
| bb6f75c0a8 | |||
| 57e92e8a56 | |||
| 93b9b53acb | |||
| edb35b5a6d | |||
| bb7bc33a8a | |||
| 64c617d8ab | |||
| bcccb0c620 | |||
| e1de55cc82 | |||
| 4b501a5b63 | |||
| dc494c85f2 | |||
| 624a8d370c | |||
| 5814d666ab | |||
| 53e3a12441 | |||
| dd770ef303 | |||
| 8b3fa5c91e | |||
| 43bf47ea7b | |||
| 4be84fbf12 | |||
| e9b46e5cf6 | |||
| 6a57a3c452 | |||
| cdb49eaa1f | |||
| cb11486f66 | |||
| 0e9b446a81 | |||
| 2cf79a1adb | |||
| 5550ec8f2c | |||
| 70f3785b47 | |||
| 8c4c22c72a | |||
| cd4a316a91 | |||
| 654d489c01 | |||
| f3acf9002e | |||
| e03bd0a40d | |||
| 1167da2027 | |||
| 7cde444ffe | |||
| 67e97a89ce | |||
| c5e83b1079 | |||
| df1536ea77 | |||
| 6aff54be76 | |||
| 24a0e8956c | |||
| e01678da93 | |||
| 2b6a683198 | |||
| 1f58d8ee27 | |||
| fb4527d91b | |||
| a83bbcaf1d |
@@ -1,3 +0,0 @@
|
|||||||
templates/project/assets/www/cordova.js
|
|
||||||
test/android/app
|
|
||||||
test/androidx/app
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
* text eol=lf
|
|
||||||
|
|
||||||
# source code
|
|
||||||
*.php text
|
|
||||||
*.css text
|
|
||||||
*.sass text
|
|
||||||
*.scss text
|
|
||||||
*.less text
|
|
||||||
*.styl text
|
|
||||||
*.js text
|
|
||||||
*.coffee text
|
|
||||||
*.json text
|
|
||||||
*.htm text
|
|
||||||
*.html text
|
|
||||||
*.xml text
|
|
||||||
*.svg text
|
|
||||||
*.txt text
|
|
||||||
*.ini text
|
|
||||||
*.inc text
|
|
||||||
*.pl text
|
|
||||||
*.rb text
|
|
||||||
*.py text
|
|
||||||
*.scm text
|
|
||||||
*.sql text
|
|
||||||
*.sh text
|
|
||||||
*.bat text eol=crlf
|
|
||||||
|
|
||||||
# templates
|
|
||||||
*.ejs text
|
|
||||||
*.hbt text
|
|
||||||
*.jade text
|
|
||||||
*.haml text
|
|
||||||
*.hbs text
|
|
||||||
*.dot text
|
|
||||||
*.tmpl text
|
|
||||||
*.phtml text
|
|
||||||
|
|
||||||
# server config
|
|
||||||
.htaccess text
|
|
||||||
|
|
||||||
# git config
|
|
||||||
.gitattributes text
|
|
||||||
.gitignore text
|
|
||||||
.gitconfig text
|
|
||||||
|
|
||||||
# code analysis config
|
|
||||||
.jshintrc text
|
|
||||||
.jscsrc text
|
|
||||||
.jshintignore text
|
|
||||||
.csslintrc text
|
|
||||||
|
|
||||||
# misc config
|
|
||||||
*.yaml text
|
|
||||||
*.yml text
|
|
||||||
.editorconfig text
|
|
||||||
|
|
||||||
# build config
|
|
||||||
*.npmignore text
|
|
||||||
*.bowerrc text
|
|
||||||
|
|
||||||
# Heroku
|
|
||||||
Procfile text
|
|
||||||
.slugignore text
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
*.md text
|
|
||||||
LICENSE text
|
|
||||||
AUTHORS text
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
## These files are binary and should be left untouched
|
|
||||||
#
|
|
||||||
|
|
||||||
# (binary is a macro for -text -diff)
|
|
||||||
*.png binary
|
|
||||||
*.jpg binary
|
|
||||||
*.jpeg binary
|
|
||||||
*.gif binary
|
|
||||||
*.ico binary
|
|
||||||
*.mov binary
|
|
||||||
*.mp4 binary
|
|
||||||
*.mp3 binary
|
|
||||||
*.flv binary
|
|
||||||
*.fla binary
|
|
||||||
*.swf binary
|
|
||||||
*.gz binary
|
|
||||||
*.zip binary
|
|
||||||
*.7z binary
|
|
||||||
*.ttf binary
|
|
||||||
*.eot binary
|
|
||||||
*.woff binary
|
|
||||||
*.pyc binary
|
|
||||||
*.pdf binary
|
|
||||||
*.jar binary
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<!--
|
|
||||||
Please have a look at the issue templates you get when you click "New issue" in the GitHub UI.
|
|
||||||
We very much prefer issues created by using one of these templates.
|
|
||||||
-->
|
|
||||||
|
|
||||||
### Issue Type
|
|
||||||
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
|
|
||||||
|
|
||||||
- [ ] Bug Report
|
|
||||||
- [ ] Feature Request
|
|
||||||
- [ ] Support Question
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
## Information
|
|
||||||
<!-- Include all relevant information that might help understand and reproduce the problem -->
|
|
||||||
|
|
||||||
### Command or Code
|
|
||||||
<!-- What command or code is needed to reproduce the problem? -->
|
|
||||||
|
|
||||||
### Environment, Platform, Device
|
|
||||||
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Version information
|
|
||||||
<!--
|
|
||||||
What are relevant versions you are using?
|
|
||||||
For example:
|
|
||||||
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
|
|
||||||
Other Frameworks: Ionic Framework and CLI version
|
|
||||||
Operating System, Android Studio, Xcode etc.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Checklist
|
|
||||||
<!-- Please check the boxes by putting an `x` in the `[ ]` like so: `[x]` -->
|
|
||||||
|
|
||||||
- [ ] I searched for already existing GitHub issues about this
|
|
||||||
- [ ] I updated all Cordova tooling to their most recent version
|
|
||||||
- [ ] I included all the necessary information above
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
---
|
|
||||||
name: 🐛 Bug Report
|
|
||||||
about: If something isn't working as expected.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Bug Report
|
|
||||||
|
|
||||||
## Problem
|
|
||||||
|
|
||||||
### What is expected to happen?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### What does actually happen?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Information
|
|
||||||
<!-- Include all relevant information that might help understand and reproduce the problem -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Command or Code
|
|
||||||
<!-- What command or code is needed to reproduce the problem? -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Environment, Platform, Device
|
|
||||||
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Version information
|
|
||||||
<!--
|
|
||||||
What are relevant versions you are using?
|
|
||||||
For example:
|
|
||||||
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
|
|
||||||
Other Frameworks: Ionic Framework and CLI version
|
|
||||||
Operating System, Android Studio, Xcode etc.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Checklist
|
|
||||||
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
|
|
||||||
|
|
||||||
- [ ] I searched for existing GitHub issues
|
|
||||||
- [ ] I updated all Cordova tooling to most recent version
|
|
||||||
- [ ] I included all the necessary information above
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
name: 🚀 Feature Request
|
|
||||||
about: A suggestion for a new functionality
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Feature Request
|
|
||||||
|
|
||||||
## Motivation Behind Feature
|
|
||||||
<!-- Why should this feature be implemented? What problem does it solve? -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Feature Description
|
|
||||||
<!--
|
|
||||||
Describe your feature request in detail
|
|
||||||
Please provide any code examples or screenshots of what this feature would look like
|
|
||||||
Are there any drawbacks? Will this break anything for existing users?
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Alternatives or Workarounds
|
|
||||||
<!--
|
|
||||||
Describe alternatives or workarounds you are currently using
|
|
||||||
Are there ways to do this with existing functionality?
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
name: 💬 Support Question
|
|
||||||
about: If you have a question, please check out our Slack or StackOverflow!
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!------------^ Click "Preview" for a nicer view! -->
|
|
||||||
|
|
||||||
Apache Cordova uses GitHub Issues as a feature request and bug tracker _only_.
|
|
||||||
For usage and support questions, please check out the resources below. Thanks!
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
You can get answers to your usage and support questions about **Apache Cordova** on:
|
|
||||||
|
|
||||||
* Slack Community Chat: https://cordova.slack.com (you can sign-up at http://slack.cordova.io/)
|
|
||||||
* StackOverflow: https://stackoverflow.com/questions/tagged/cordova using the tag `cordova`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels:
|
|
||||||
|
|
||||||
* **Ionic Framework**
|
|
||||||
* [Ionic Community Forum](https://forum.ionicframework.com/)
|
|
||||||
* [Ionic Worldwide Slack](https://ionicworldwide.herokuapp.com/)
|
|
||||||
* **PhoneGap**
|
|
||||||
* [PhoneGap Developer Community](https://forums.adobe.com/community/phonegap)
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<!--
|
|
||||||
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
|
|
||||||
|
|
||||||
http://cordova.apache.org/contribute/contribute_guidelines.html
|
|
||||||
|
|
||||||
Thanks!
|
|
||||||
-->
|
|
||||||
|
|
||||||
### Platforms affected
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Motivation and Context
|
|
||||||
<!-- Why is this change required? What problem does it solve? -->
|
|
||||||
<!-- If it fixes an open issue, please link to the issue here. -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Description
|
|
||||||
<!-- Describe your changes in detail -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
<!-- Please describe in detail how you tested your changes. -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Checklist
|
|
||||||
|
|
||||||
- [ ] I've run the tests to see all new and existing tests pass
|
|
||||||
- [ ] I added automated test coverage as appropriate for this change
|
|
||||||
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
|
|
||||||
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
|
|
||||||
- [ ] I've updated the documentation if necessary
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
|
||||||
# to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance
|
|
||||||
# with the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing,
|
|
||||||
# software distributed under the License is distributed on an
|
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
name: Node CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches-ignore:
|
|
||||||
- 'dependabot/**'
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: NodeJS ${{ matrix.node-version }} on ${{ matrix.os }}
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [20.x, 22.x]
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
|
|
||||||
- uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '17'
|
|
||||||
|
|
||||||
- name: Environment Information
|
|
||||||
run: |
|
|
||||||
node --version
|
|
||||||
npm --version
|
|
||||||
gradle --version
|
|
||||||
|
|
||||||
# "bin/templates/platform_www/cordova.js" is ignored because it is a generated file.
|
|
||||||
# It contains mixed content from the npm package "cordova-js" and "./cordova-js-src".
|
|
||||||
# The report might not be resolvable because of the external package.
|
|
||||||
# If the report is related to this repository, it would be detected when scanning "./cordova-js-src".
|
|
||||||
- uses: github/codeql-action/init@v3
|
|
||||||
with:
|
|
||||||
languages: javascript, java-kotlin
|
|
||||||
queries: security-and-quality
|
|
||||||
config: |
|
|
||||||
paths-ignore:
|
|
||||||
- coverage
|
|
||||||
- node_modules
|
|
||||||
- templates/project/assets/www/cordova.js
|
|
||||||
- test/androidx/app/src/main/assets/www/cordova.js
|
|
||||||
|
|
||||||
- name: npm install and test
|
|
||||||
run: |
|
|
||||||
npm i
|
|
||||||
npm t
|
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- uses: github/codeql-action/analyze@v3
|
|
||||||
|
|
||||||
- uses: codecov/codecov-action@v4
|
|
||||||
if: success()
|
|
||||||
with:
|
|
||||||
name: ${{ runner.os }} node.js ${{ matrix.node-version }}
|
|
||||||
token: ${{ secrets.CORDOVA_CODECOV_TOKEN }}
|
|
||||||
fail_ci_if_error: false
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
|
||||||
# to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance
|
|
||||||
# with the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing,
|
|
||||||
# software distributed under the License is distributed on an
|
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
name: Release Auditing
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches-ignore:
|
|
||||||
- 'dependabot/**'
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: Audit Licenses
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# Checkout project
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
# Check license headers
|
|
||||||
- uses: erisu/apache-rat-action@555ae80334a535eb6c1f8920b121563a5a985a75
|
|
||||||
|
|
||||||
# Setup environment with node
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
|
|
||||||
# Install node packages
|
|
||||||
- name: npm install packages
|
|
||||||
run: npm i
|
|
||||||
|
|
||||||
# Check node package licenses
|
|
||||||
- uses: erisu/license-checker-action@e929758f9416f30234ac454fc9054ca4b803871d
|
|
||||||
with:
|
|
||||||
license-config: 'licence_checker.yml'
|
|
||||||
@@ -1,6 +1,28 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.gradle
|
default.properties
|
||||||
|
gen
|
||||||
|
assets/www/cordova.js
|
||||||
|
framework/assets/www/.tmp*
|
||||||
|
local.properties
|
||||||
|
framework/lib
|
||||||
|
proguard.cfg
|
||||||
|
proguard.cfg
|
||||||
|
proguard-project.txt
|
||||||
|
framework/bin
|
||||||
|
framework/test/org/apache/cordova/*.class
|
||||||
|
framework/assets/www/.DS_Store
|
||||||
|
framework/assets/www/cordova-*.js
|
||||||
|
framework/assets/www/phonegap-*.js
|
||||||
|
framework/libs
|
||||||
|
test/libs
|
||||||
|
example
|
||||||
|
./test
|
||||||
|
test/bin
|
||||||
|
test/assets/www/.tmp*
|
||||||
|
tmp/**
|
||||||
|
bin/node_modules
|
||||||
.metadata
|
.metadata
|
||||||
|
tmp/**/*
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
Desktop.ini
|
Desktop.ini
|
||||||
*.tmp
|
*.tmp
|
||||||
@@ -8,47 +30,6 @@ Desktop.ini
|
|||||||
*.swp
|
*.swp
|
||||||
*.class
|
*.class
|
||||||
*.jar
|
*.jar
|
||||||
default.properties
|
|
||||||
gen
|
|
||||||
assets/www/cordova.js
|
|
||||||
local.properties
|
|
||||||
proguard.cfg
|
|
||||||
proguard-project.txt
|
|
||||||
example
|
|
||||||
/coverage
|
|
||||||
/framework/lib
|
|
||||||
/framework/build
|
|
||||||
/framework/bin
|
|
||||||
/framework/assets/www/.DS_Store
|
|
||||||
/framework/assets/www/cordova-*.js
|
|
||||||
/framework/assets/www/phonegap-*.js
|
|
||||||
/framework/libs
|
|
||||||
/framework/javadoc-public
|
|
||||||
/framework/javadoc-private
|
|
||||||
|
|
||||||
**/assets/www/cordova.js
|
|
||||||
|
|
||||||
/test/.externalNativeBuild
|
|
||||||
/test/androidx/cdv-gradle-config.json
|
|
||||||
/test/androidx/tools
|
|
||||||
/test/androidx/build
|
|
||||||
/test/assets/www/.tmp*
|
|
||||||
/test/assets/www/cordova.js
|
|
||||||
/test/bin
|
|
||||||
/test/build
|
|
||||||
/test/captures
|
|
||||||
/test/libs
|
|
||||||
tmp/**
|
|
||||||
tmp/**/*
|
|
||||||
!/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestLib.jar
|
|
||||||
# IntelliJ IDEA files
|
# IntelliJ IDEA files
|
||||||
**/.idea/**/*
|
|
||||||
*.iml
|
*.iml
|
||||||
npm-debug.log
|
.idea
|
||||||
node_modules/
|
|
||||||
coverage/
|
|
||||||
.nyc_output/
|
|
||||||
# Eclipse Buildship files
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.classpath
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
.*
|
|
||||||
coverage
|
|
||||||
test
|
|
||||||
spec
|
|
||||||
framework/build
|
|
||||||
cordova-js-src
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
\.(.*)
|
|
||||||
(.*).txt
|
|
||||||
coverage
|
|
||||||
fixtures
|
|
||||||
generated
|
|
||||||
gitignore
|
|
||||||
intermediates
|
|
||||||
reports
|
|
||||||
test-results
|
|
||||||
node_modules
|
|
||||||
gradle
|
|
||||||
gradlew
|
|
||||||
gradlew.bat
|
|
||||||
@@ -4,5 +4,5 @@
|
|||||||
GUESS_FIELDS = True
|
GUESS_FIELDS = True
|
||||||
OPEN_BROWSER = True
|
OPEN_BROWSER = True
|
||||||
TARGET_GROUPS = 'cordova'
|
TARGET_GROUPS = 'cordova'
|
||||||
REVIEWBOARD_URL = 'https://reviews.apache.org'
|
REVIEWBOARD_URL = 'http://reviews.apache.org'
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<!--
|
|
||||||
#
|
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
|
||||||
# to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance
|
|
||||||
# with the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing,
|
|
||||||
# software distributed under the License is distributed on an
|
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
#
|
|
||||||
-->
|
|
||||||
|
|
||||||
# Contributing to Apache Cordova
|
|
||||||
|
|
||||||
Anyone can contribute to Cordova. And we need your contributions.
|
|
||||||
|
|
||||||
There are multiple ways to contribute: report bugs, improve the docs, and
|
|
||||||
contribute code.
|
|
||||||
|
|
||||||
For instructions on this, start with the
|
|
||||||
[contribution overview](http://cordova.apache.org/contribute/).
|
|
||||||
|
|
||||||
The details are explained there, but the important items are:
|
|
||||||
- Check for Github issues that corresponds to your contribution and link or create them if necessary.
|
|
||||||
- Run the tests so your patch doesn't break existing functionality.
|
|
||||||
|
|
||||||
We look forward to your contributions!
|
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2015-2024 Apache Cordova
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -199,5 +199,4 @@
|
|||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
@@ -1,5 +1,17 @@
|
|||||||
Apache Cordova
|
Apache Cordova
|
||||||
Copyright 2015-2020 The Apache Software Foundation
|
Copyright 2012 The Apache Software Foundation
|
||||||
|
|
||||||
This product includes software developed at
|
This product includes software developed at
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
The Apache Software Foundation (http://www.apache.org)
|
||||||
|
|
||||||
|
=========================================================================
|
||||||
|
== NOTICE file corresponding to the section 4 d of ==
|
||||||
|
== the Apache License, Version 2.0, ==
|
||||||
|
== in this case for the Android-specific code. ==
|
||||||
|
=========================================================================
|
||||||
|
|
||||||
|
Android Code
|
||||||
|
Copyright 2005-2008 The Android Open Source Project
|
||||||
|
|
||||||
|
This product includes software developed as part of
|
||||||
|
The Android Open Source Project (http://source.android.com).
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
# to you under the Apache License, Version 2.0 (the
|
# to you under the Apache License, Version 2.0 (the
|
||||||
# "License"); you may not use this file except in compliance
|
# "License"); you may not use this file except in compliance
|
||||||
# with the License. You may obtain a copy of the License at
|
# with the License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Unless required by applicable law or agreed to in writing,
|
||||||
# software distributed under the License is distributed on an
|
# software distributed under the License is distributed on an
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
@@ -18,54 +18,102 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
-->
|
-->
|
||||||
|
Cordova Android
|
||||||
|
===
|
||||||
|
|
||||||
# Cordova Android
|
Cordova Android is an Android application library that allows for Cordova-based
|
||||||
|
projects to be built for the Android Platform. Cordova based applications are,
|
||||||
|
at the core, applications written with web technology: HTML, CSS and JavaScript.
|
||||||
|
|
||||||
[](https://nodei.co/npm/cordova-android/)
|
[Apache Cordova](http://cordova.io) is a project at The Apache Software Foundation (ASF).
|
||||||
|
|
||||||
[](https://github.com/apache/cordova-android/actions?query=branch%3Amaster)
|
|
||||||
[](https://codecov.io/github/apache/cordova-android?branch=master)
|
|
||||||
|
|
||||||
Cordova Android is an Android application library that allows for Cordova-based projects to be built for the Android Platform. Cordova based applications are, at the core, applications written with web technology: HTML, CSS and JavaScript.
|
Requires
|
||||||
|
---
|
||||||
|
|
||||||
[Apache Cordova](https://cordova.apache.org/) is a project of [The Apache Software Foundation (ASF)](https://apache.org/).
|
- Java JDK 1.5 or greater
|
||||||
|
- Apache ANT 1.8.0 or greater
|
||||||
|
- Android SDK [http://developer.android.com](http://developer.android.com)
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
Cordova Android Developer Tools
|
||||||
|
---
|
||||||
|
|
||||||
* Java Development Kit (JDK) 17
|
The Cordova developer tooling is split between general tooling and project level tooling.
|
||||||
* [Android SDK](https://developer.android.com/)
|
|
||||||
* [Node.js](https://nodejs.org)
|
|
||||||
|
|
||||||
## Create a Cordova project
|
To enable the command-line tools available in the ./bin directory, make
|
||||||
|
sure you have all of the dependencies installed. You will need
|
||||||
|
[NodeJS](http://nodejs.org) (which should come with `npm`). To install
|
||||||
|
the dependencies:
|
||||||
|
|
||||||
Follow the instructions in the [**Create your first Cordova app**](https://cordova.apache.org/docs/en/latest/guide/cli/index.html) section of [Apache Cordova Docs](https://cordova.apache.org/docs/en/latest/)
|
$ cd bin
|
||||||
|
$ npm install
|
||||||
|
|
||||||
To use a **shared framework**, for example in development, link the appropriate cordova-android platform folder path:
|
General Commands
|
||||||
|
|
||||||
```bash
|
./bin/create [path package activity] ... create the ./example app or a cordova android project
|
||||||
cordova platform add --link /path/to/cordova-android
|
./bin/autotest ......................... test the cli tools
|
||||||
```
|
./bin/test ............................. run mobile-spec
|
||||||
|
|
||||||
## Updating a Cordova project
|
Project Commands
|
||||||
|
|
||||||
When you install a new version of the [`Cordova CLI`](https://www.npmjs.com/package/cordova) that pins a new version of the [`Cordova-Android`](https://www.npmjs.com/package/cordova-android) platform, you can follow these simple upgrade steps within your project:
|
These commands live in a generated Cordova Android project.
|
||||||
|
|
||||||
```bash
|
./cordova/debug [path] ..................... install to first device
|
||||||
cordova platform rm android
|
./cordova/emulate .......................... start avd (emulator) named default
|
||||||
cordova platform add android
|
./cordova/log .............................. starts logcat
|
||||||
```
|
|
||||||
|
|
||||||
## Debugging in Android Studio
|
Running the Example Project
|
||||||
|
---
|
||||||
|
|
||||||
Import project in Android Studio through _File > Open_ and targeting `/path/to/your-cdv-project/platforms/android/`.
|
Start avd (emulator) named `default`:
|
||||||
|
|
||||||
## How to Test Repo Development
|
./bin/emulate
|
||||||
|
|
||||||
```bash
|
Create the example project and build it to the first device:
|
||||||
npm install
|
|
||||||
npm test
|
|
||||||
```
|
|
||||||
|
|
||||||
## Further reading
|
./bin/create
|
||||||
|
cd example
|
||||||
|
./cordova/debug
|
||||||
|
|
||||||
* [Apache Cordova](https://cordova.apache.org/)
|
Start adb logcat (console.log calls output here):
|
||||||
|
|
||||||
|
./cordova/log
|
||||||
|
|
||||||
|
Creating a new Cordova Android Project
|
||||||
|
---
|
||||||
|
|
||||||
|
./bin/create ~/Desktop/myapp com.myapp.special MyApp
|
||||||
|
|
||||||
|
Importing a Cordova Android Project into Eclipse
|
||||||
|
----
|
||||||
|
|
||||||
|
1. File > New > Project...
|
||||||
|
2. Android > Android Project
|
||||||
|
3. Create project from existing source (point to the generated app found in tmp/android)
|
||||||
|
4. Right click on libs/cordova.jar and add to build path
|
||||||
|
5. Right click on the project root: Run as > Run Configurations
|
||||||
|
6. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)
|
||||||
|
|
||||||
|
Building without the Tooling
|
||||||
|
---
|
||||||
|
Note: The Developer Tools handle this. This is only to be done if the tooling fails, or if
|
||||||
|
you are developing directly against the framework.
|
||||||
|
|
||||||
|
|
||||||
|
To create your `cordova.jar` file, run in the framework directory:
|
||||||
|
|
||||||
|
android update project -p . -t android-17
|
||||||
|
ant jar
|
||||||
|
|
||||||
|
|
||||||
|
Running Tests
|
||||||
|
----
|
||||||
|
Please see details under test/README.md.
|
||||||
|
|
||||||
|
Further Reading
|
||||||
|
---
|
||||||
|
|
||||||
|
- [http://developer.android.com](http://developer.android.com)
|
||||||
|
- [http://cordova.apache.org/](http://cordova.apache.org)
|
||||||
|
- [http://wiki.apache.org/cordova/](http://wiki.apache.org/cordova/)
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
ROOT="$( cd "$( dirname "$0" )/.." && pwd )"
|
||||||
|
cmd=`android list target`
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
echo "The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) added to your path."
|
||||||
|
exit 2
|
||||||
|
elif [[ ! $cmd =~ "android-18" ]]; then
|
||||||
|
echo "Please install Android target 18 (the Android 4.3 SDK). Make sure you have the latest Android tools installed as well. Run \"android\" from your command-line to install/update any missing SDKs or tools."
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
cmd="android update project -p $ROOT -t android-18 1> /dev/null 2>&1"
|
||||||
|
eval $cmd
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
echo "Error updating the Cordova library to work with your Android environment."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
:: 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.
|
||||||
|
|
||||||
|
@ECHO OFF
|
||||||
|
SET full_path=%~dp0
|
||||||
|
IF EXIST %full_path%check_reqs.js (
|
||||||
|
cscript "%full_path%check_reqs.js" //nologo
|
||||||
|
) ELSE (
|
||||||
|
ECHO.
|
||||||
|
ECHO ERROR: Could not find 'check_reqs.js' in 'bin' folder, aborting...>&2
|
||||||
|
EXIT /B 1
|
||||||
|
)
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
|
||||||
|
var ROOT = WScript.ScriptFullName.split('\\bin\\check_reqs.js').join(''),
|
||||||
|
shell = WScript.CreateObject("WScript.Shell"),
|
||||||
|
fso = WScript.CreateObject('Scripting.FileSystemObject');
|
||||||
|
|
||||||
|
|
||||||
|
// executes a command in the shell, returns stdout or stderr if error
|
||||||
|
function exec_out(command) {
|
||||||
|
var oExec=shell.Exec(command);
|
||||||
|
var output = new String();
|
||||||
|
while (oExec.Status == 0) {
|
||||||
|
if (!oExec.StdOut.AtEndOfStream) {
|
||||||
|
var line = oExec.StdOut.ReadAll();
|
||||||
|
// XXX: Change to verbose mode
|
||||||
|
// WScript.StdOut.WriteLine(line);
|
||||||
|
output += line;
|
||||||
|
}
|
||||||
|
WScript.sleep(100);
|
||||||
|
}
|
||||||
|
//Check to make sure our scripts did not encounter an error
|
||||||
|
if (!oExec.StdErr.AtEndOfStream) {
|
||||||
|
var line = oExec.StdErr.ReadAll();
|
||||||
|
return {'error' : true, 'output' : line};
|
||||||
|
} else if (!oExec.StdOut.AtEndOfStream) {
|
||||||
|
var line = oExec.StdOut.ReadAll();
|
||||||
|
// XXX: Change to verbose mode
|
||||||
|
// WScript.StdOut.WriteLine(line);
|
||||||
|
output += line;
|
||||||
|
}
|
||||||
|
return {'error' : false, 'output' : output};
|
||||||
|
}
|
||||||
|
|
||||||
|
// log to stdout or stderr
|
||||||
|
function Log(msg, error) {
|
||||||
|
if (error) {
|
||||||
|
WScript.StdErr.WriteLine(msg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WScript.StdOut.WriteLine(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// checks that android requirements are met
|
||||||
|
function check_requirements() {
|
||||||
|
var target = get_target();
|
||||||
|
if(target==null) {
|
||||||
|
Log('Unable to find android target in project.properties');
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
var result = exec_out('%comspec% /c android list target');
|
||||||
|
if(result.error) {
|
||||||
|
Log('The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ' + result.output, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
else if(result.output.indexOf(target) == -1) {
|
||||||
|
Log(result.output.indexOf(target));
|
||||||
|
Log('Please install the latest Android target (' + target + '). Make sure you have the latest Android tools installed as well. Run `android` from your command-line to install/update any missing SDKs or tools.', true);
|
||||||
|
Log(result.output);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var cmd = '%comspec% /c android update project -p ' + ROOT + '\\framework -t ' + target;
|
||||||
|
result = exec_out(cmd);
|
||||||
|
if(result.error) {
|
||||||
|
Log('Error updating the Cordova library to work with your Android environment. Command run: "' + cmd + '", output: ' + result.output, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_target() {
|
||||||
|
var fso=WScript.CreateObject("Scripting.FileSystemObject");
|
||||||
|
var f=fso.OpenTextFile(ROOT + '\\framework\\project.properties', 1);
|
||||||
|
var s=f.ReadAll();
|
||||||
|
var lines = s.split('\n');
|
||||||
|
for (var line in lines) {
|
||||||
|
if(lines[line].match(/target=/))
|
||||||
|
{
|
||||||
|
return lines[line].split('=')[1].replace(' ', '').replace('\r', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
check_requirements();
|
||||||
|
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# create a cordova/android project
|
||||||
|
#
|
||||||
|
# USAGE
|
||||||
|
# ./create [path package activity]
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$1" ] || [ "$1" == "-h" ]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 <path_to_new_project> <package_name> <project_name>"
|
||||||
|
echo "Make sure the Android SDK tools folder is in your PATH!"
|
||||||
|
echo " <path_to_new_project>: Path to your new Cordova iOS project"
|
||||||
|
echo " <package_name>: Package name, following reverse-domain style convention"
|
||||||
|
echo " <project_name>: Project name"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_PATH="$( cd "$( dirname "$0" )/.." && pwd )"
|
||||||
|
VERSION=$(cat "$BUILD_PATH"/VERSION)
|
||||||
|
|
||||||
|
PROJECT_PATH="${1:-'./example'}"
|
||||||
|
PACKAGE=${2:-"org.apache.cordova.example"}
|
||||||
|
ACTIVITY=$(echo ${3:-"cordovaExample"} | tr -d '[:blank:][:punct:]')
|
||||||
|
APP_LABEL=${3:-"Cordova Example"};
|
||||||
|
|
||||||
|
# clobber any existing example
|
||||||
|
if [ -d "$PROJECT_PATH" ]
|
||||||
|
then
|
||||||
|
echo "Project already exists! Delete and recreate"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function createAppInfoJar {
|
||||||
|
pushd "$BUILD_PATH"/bin/templates/cordova/ApplicationInfo > /dev/null
|
||||||
|
javac ApplicationInfo.java
|
||||||
|
jar -cfe ../appinfo.jar ApplicationInfo ApplicationInfo.class
|
||||||
|
popd > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error {
|
||||||
|
echo "An unexpected error occurred: $previous_command exited with $?"
|
||||||
|
echo "Deleting project..."
|
||||||
|
[ -d "$PROJECT_PATH" ] && rm -rf "$PROJECT_PATH"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function replace {
|
||||||
|
local pattern=$1
|
||||||
|
local filename=$2
|
||||||
|
# Mac OS X requires -i argument
|
||||||
|
if [[ "$OSTYPE" =~ "darwin" ]]
|
||||||
|
then
|
||||||
|
/usr/bin/sed -i '' -e "$pattern" "$filename"
|
||||||
|
elif [[ "$OSTYPE" =~ "linux" ]]
|
||||||
|
then
|
||||||
|
/bin/sed -i -e $pattern "$filename"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# we do not want the script to silently fail
|
||||||
|
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
|
||||||
|
trap on_error ERR
|
||||||
|
|
||||||
|
ANDROID_BIN="${ANDROID_BIN:=$( which android )}"
|
||||||
|
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
|
||||||
|
ACTIVITY_PATH="$PROJECT_PATH"/src/$PACKAGE_AS_PATH/$ACTIVITY.java
|
||||||
|
MANIFEST_PATH="$PROJECT_PATH"/AndroidManifest.xml
|
||||||
|
STRINGS_PATH="$PROJECT_PATH"/res/values/strings.xml
|
||||||
|
|
||||||
|
TARGET=$("$ANDROID_BIN" list targets | grep id: | tail -1 | cut -f 2 -d ' ' )
|
||||||
|
API_LEVEL=$("$ANDROID_BIN" list target | grep "API level:" | tail -n 1 | cut -f 2 -d ':' | tr -d ' ')
|
||||||
|
|
||||||
|
# check that build targets exist
|
||||||
|
if [ -z "$TARGET" ] || [ -z "$API_LEVEL" ]
|
||||||
|
then
|
||||||
|
echo "No Android Targets are installed. Please install at least one via the android SDK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if this a distribution release no need to build a jar
|
||||||
|
if [ ! -e "$BUILD_PATH"/cordova-$VERSION.jar ] && [ -d "$BUILD_PATH"/framework ]
|
||||||
|
then
|
||||||
|
# update the cordova-android framework for the desired target
|
||||||
|
"$ANDROID_BIN" update project --target $TARGET --path "$BUILD_PATH"/framework &> /dev/null
|
||||||
|
|
||||||
|
# compile cordova.js and cordova.jar
|
||||||
|
pushd "$BUILD_PATH"/framework > /dev/null
|
||||||
|
ant jar > /dev/null
|
||||||
|
popd > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create new android project
|
||||||
|
"$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY &> /dev/null
|
||||||
|
|
||||||
|
# copy project template
|
||||||
|
cp -r "$BUILD_PATH"/bin/templates/project/assets "$PROJECT_PATH"
|
||||||
|
cp -r "$BUILD_PATH"/bin/templates/project/res "$PROJECT_PATH"
|
||||||
|
|
||||||
|
# copy cordova.js, cordova.jar and res/xml
|
||||||
|
if [ -d "$BUILD_PATH"/framework ]
|
||||||
|
then
|
||||||
|
cp -r "$BUILD_PATH"/framework/res/xml "$PROJECT_PATH"/res
|
||||||
|
cp "$BUILD_PATH"/framework/assets/www/cordova.js "$PROJECT_PATH"/assets/www/cordova.js
|
||||||
|
cp "$BUILD_PATH"/framework/cordova-$VERSION.jar "$PROJECT_PATH"/libs/cordova-$VERSION.jar
|
||||||
|
else
|
||||||
|
cp -r "$BUILD_PATH"/xml "$PROJECT_PATH"/res/xml
|
||||||
|
cp "$BUILD_PATH"/cordova.js "$PROJECT_PATH"/assets/www/cordova.js
|
||||||
|
cp "$BUILD_PATH"/cordova-$VERSION.jar "$PROJECT_PATH"/libs/cordova-$VERSION.jar
|
||||||
|
fi
|
||||||
|
|
||||||
|
# interpolate the activity name and package
|
||||||
|
cp "$BUILD_PATH"/bin/templates/project/Activity.java "$ACTIVITY_PATH"
|
||||||
|
replace "s/__ACTIVITY__/${ACTIVITY}/g" "$ACTIVITY_PATH"
|
||||||
|
replace "s/__ID__/${PACKAGE}/g" "$ACTIVITY_PATH"
|
||||||
|
|
||||||
|
# interpolate the app name into strings.xml
|
||||||
|
replace "s/>${ACTIVITY}</>${APP_LABEL}</g" "$STRINGS_PATH"
|
||||||
|
|
||||||
|
cp "$BUILD_PATH"/bin/templates/project/AndroidManifest.xml "$MANIFEST_PATH"
|
||||||
|
replace "s/__ACTIVITY__/${ACTIVITY}/g" "$MANIFEST_PATH"
|
||||||
|
replace "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH"
|
||||||
|
replace "s/__APILEVEL__/${API_LEVEL}/g" "$MANIFEST_PATH"
|
||||||
|
|
||||||
|
# creating cordova folder and copying run/build/log/launch scripts
|
||||||
|
mkdir "$PROJECT_PATH"/cordova
|
||||||
|
mkdir "$PROJECT_PATH"/cordova/lib
|
||||||
|
createAppInfoJar
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/appinfo.jar "$PROJECT_PATH"/cordova/appinfo.jar
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/build "$PROJECT_PATH"/cordova/build
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/clean "$PROJECT_PATH"/cordova/clean
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/log "$PROJECT_PATH"/cordova/log
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/run "$PROJECT_PATH"/cordova/run
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/version "$PROJECT_PATH"/cordova/version
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/install-device "$PROJECT_PATH"/cordova/lib/install-device
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/install-emulator "$PROJECT_PATH"/cordova/lib/install-emulator
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/list-devices "$PROJECT_PATH"/cordova/lib/list-devices
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/list-emulator-images "$PROJECT_PATH"/cordova/lib/list-emulator-images
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/list-started-emulators "$PROJECT_PATH"/cordova/lib/list-started-emulators
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/start-emulator "$PROJECT_PATH"/cordova/lib/start-emulator
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
GOTO BEGIN
|
||||||
|
:: 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.
|
||||||
|
|
||||||
|
:BEGIN
|
||||||
|
IF NOT DEFINED JAVA_HOME GOTO MISSING_JAVA_HOME
|
||||||
|
|
||||||
|
FOR %%X in (java.exe javac.exe ant.bat android.bat) do (
|
||||||
|
IF [%%~$PATH:X]==[] (
|
||||||
|
ECHO Cannot locate %%X using the PATH environment variable.
|
||||||
|
ECHO Retry after adding directory containing %%X to the PATH variable.
|
||||||
|
ECHO Remember to open a new command window after updating the PATH variable.
|
||||||
|
IF "%%X"=="java.exe" GOTO GET_JAVA
|
||||||
|
IF "%%X"=="javac.exe" GOTO GET_JAVA
|
||||||
|
IF "%%X"=="ant.bat" GOTO GET_ANT
|
||||||
|
IF "%%X"=="android.bat" GOTO GET_ANDROID
|
||||||
|
GOTO ERROR
|
||||||
|
)
|
||||||
|
)
|
||||||
|
cscript "%~dp0\create.js" %* //nologo
|
||||||
|
GOTO END
|
||||||
|
:MISSING_JAVA_HOME
|
||||||
|
ECHO The JAVA_HOME environment variable is not set.
|
||||||
|
ECHO Set JAVA_HOME to an existing JRE directory.
|
||||||
|
ECHO Remember to also add JAVA_HOME to the PATH variable.
|
||||||
|
ECHO After updating system variables, open a new command window and retry.
|
||||||
|
GOTO ERROR
|
||||||
|
:GET_JAVA
|
||||||
|
ECHO Visit http://java.oracle.com if you need to install Java (JDK).
|
||||||
|
GOTO ERROR
|
||||||
|
:GET_ANT
|
||||||
|
ECHO Visit http://ant.apache.org if you need to install Apache Ant.
|
||||||
|
GOTO ERROR
|
||||||
|
:GET_ANDROID
|
||||||
|
ECHO Visit http://developer.android.com if you need to install the Android SDK.
|
||||||
|
GOTO ERROR
|
||||||
|
:ERROR
|
||||||
|
EXIT /B 1
|
||||||
|
:END
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* create a cordova/android project
|
||||||
|
*
|
||||||
|
* USAGE
|
||||||
|
* ./create [path package activity]
|
||||||
|
*/
|
||||||
|
|
||||||
|
var args = WScript.Arguments, PROJECT_PATH="example",
|
||||||
|
PACKAGE="org.apache.cordova.example", ACTIVITY="cordovaExample",
|
||||||
|
shell=WScript.CreateObject("WScript.Shell"),
|
||||||
|
fso = WScript.CreateObject('Scripting.FileSystemObject');
|
||||||
|
|
||||||
|
function Usage() {
|
||||||
|
Log("Usage: create PathTONewProject [ PackageName AppName ]");
|
||||||
|
Log(" PathTONewProject : The path to where you wish to create the project");
|
||||||
|
Log(" PackageName : The package for the project (default is org.apache.cordova.example)")
|
||||||
|
Log(" AppName : The name of the application/activity (default is cordovaExample)");
|
||||||
|
Log("examples:");
|
||||||
|
Log(" create C:\\Users\\anonymous\\Desktop\\MyProject");
|
||||||
|
Log(" create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp");
|
||||||
|
}
|
||||||
|
|
||||||
|
// logs messaged to stdout and stderr
|
||||||
|
function Log(msg, error) {
|
||||||
|
if (error) {
|
||||||
|
WScript.StdErr.WriteLine(msg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WScript.StdOut.WriteLine(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function read(filename) {
|
||||||
|
var fso=WScript.CreateObject("Scripting.FileSystemObject");
|
||||||
|
var f=fso.OpenTextFile(filename, 1);
|
||||||
|
var s=f.ReadAll();
|
||||||
|
f.Close();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkTargets(targets) {
|
||||||
|
if(!targets) {
|
||||||
|
Log("You do not have any android targets setup. Please create at least one target with the `android` command", true);
|
||||||
|
WScript.Quit(69);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTarget() {
|
||||||
|
var targets = shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s\d+/g);
|
||||||
|
checkTargets(targets);
|
||||||
|
return targets[targets.length - 1].replace(/id: /, ""); // TODO: give users the option to set their target
|
||||||
|
}
|
||||||
|
function setApiLevel() {
|
||||||
|
var targets = shell.Exec('android.bat list targets').StdOut.ReadAll().match(/API level:\s\d+/g);
|
||||||
|
checkTargets(targets);
|
||||||
|
return targets[targets.length - 1].replace(/API level: /, "");
|
||||||
|
}
|
||||||
|
function write(filename, contents) {
|
||||||
|
var fso=WScript.CreateObject("Scripting.FileSystemObject");
|
||||||
|
var f=fso.OpenTextFile(filename, 2, true);
|
||||||
|
f.Write(contents);
|
||||||
|
f.Close();
|
||||||
|
}
|
||||||
|
function replaceInFile(filename, regexp, replacement) {
|
||||||
|
write(filename, read(filename).replace(regexp, replacement));
|
||||||
|
}
|
||||||
|
function exec(command) {
|
||||||
|
var oShell=shell.Exec(command);
|
||||||
|
while (oShell.Status == 0) {
|
||||||
|
if(!oShell.StdOut.AtEndOfStream) {
|
||||||
|
var line = oShell.StdOut.ReadLine();
|
||||||
|
// XXX: Change to verbose mode
|
||||||
|
// WScript.StdOut.WriteLine(line);
|
||||||
|
}
|
||||||
|
WScript.sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAppInfoJar() {
|
||||||
|
if(!fso.FileExists(ROOT+"\\bin\\templates\\cordova\\appinfo.jar")) {
|
||||||
|
Log("Creating appinfo.jar...");
|
||||||
|
var cur = shell.CurrentDirectory;
|
||||||
|
shell.CurrentDirectory = ROOT+"\\bin\\templates\\cordova\\ApplicationInfo";
|
||||||
|
exec("javac ApplicationInfo.java");
|
||||||
|
exec("jar -cfe ..\\appinfo.jar ApplicationInfo ApplicationInfo.class");
|
||||||
|
shell.CurrentDirectory = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// working dir
|
||||||
|
var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
|
||||||
|
if (args.Count() > 0) {
|
||||||
|
// support help flags
|
||||||
|
if (args(0) == "--help" || args(0) == "/?" ||
|
||||||
|
args(0) == "help" || args(0) == "-help" || args(0) == "/help" || args(0) == "-h") {
|
||||||
|
Usage();
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
PROJECT_PATH=args(0);
|
||||||
|
if (args.Count() > 1) {
|
||||||
|
PACKAGE = args(1);
|
||||||
|
}
|
||||||
|
if (args.Count() > 2) {
|
||||||
|
ACTIVITY = args(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log("Error : No project path provided.");
|
||||||
|
Usage();
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fso.FolderExists(PROJECT_PATH)) {
|
||||||
|
Log("Project path already exists!", true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
var PACKAGE_AS_PATH=PACKAGE.replace(/\./g, '\\');
|
||||||
|
var ACTIVITY_DIR=PROJECT_PATH + '\\src\\' + PACKAGE_AS_PATH;
|
||||||
|
var SAFE_ACTIVITY = ACTIVITY.replace(/\W/g, '');
|
||||||
|
var ACTIVITY_PATH=ACTIVITY_DIR+'\\'+SAFE_ACTIVITY+'.java';
|
||||||
|
var MANIFEST_PATH=PROJECT_PATH+'\\AndroidManifest.xml';
|
||||||
|
var STRINGS_PATH=PROJECT_PATH+'\\res\\values\\strings.xml';
|
||||||
|
var TARGET=setTarget();
|
||||||
|
var API_LEVEL=setApiLevel();
|
||||||
|
var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
|
||||||
|
// create the project
|
||||||
|
Log("Creating new android project...");
|
||||||
|
exec('android.bat create project --target "'+TARGET+'" --path "'+PROJECT_PATH+'" --package "'+PACKAGE+'" --activity "'+SAFE_ACTIVITY+'"');
|
||||||
|
|
||||||
|
// build from source. distro should have these files
|
||||||
|
if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
|
||||||
|
!fso.FileExists(ROOT+'\\cordova.js')) {
|
||||||
|
Log("Building jar and js files...");
|
||||||
|
// update the cordova framework project to a target that exists on this machine
|
||||||
|
exec('android.bat update project --target "'+TARGET+'" --path "'+ROOT+'\\framework"');
|
||||||
|
exec('ant.bat -f "'+ ROOT +'\\framework\\build.xml" jar');
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy in the project template
|
||||||
|
Log("Copying template files...");
|
||||||
|
exec('%comspec% /c xcopy "'+ ROOT + '\\bin\\templates\\project\\res" "'+PROJECT_PATH+'\\res\\" /E /Y');
|
||||||
|
exec('%comspec% /c xcopy "'+ ROOT + '\\bin\\templates\\project\\assets" "'+PROJECT_PATH+'\\assets\\" /E /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\project\\AndroidManifest.xml" "' + PROJECT_PATH + '\\AndroidManifest.xml" /Y');
|
||||||
|
exec('%comspec% /c mkdir "' + ACTIVITY_DIR + '"');
|
||||||
|
exec('%comspec% /c copy "' + ROOT + '"\\bin\\templates\\project\\Activity.java "' + ACTIVITY_PATH + '" /Y');
|
||||||
|
|
||||||
|
// check if we have the source or the distro files
|
||||||
|
Log("Copying js, jar & config.xml files...");
|
||||||
|
if(fso.FolderExists(ROOT + '\\framework')) {
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\framework\\assets\\www\\cordova.js" "'+PROJECT_PATH+'\\assets\\www\\cordova.js" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\framework\\cordova-'+VERSION+'.jar" "'+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar" /Y');
|
||||||
|
fso.CreateFolder(PROJECT_PATH + '\\res\\xml');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\framework\\res\\xml\\config.xml" "' + PROJECT_PATH + '\\res\\xml\\config.xml" /Y');
|
||||||
|
} else {
|
||||||
|
// copy in cordova.js
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\cordova.js" "'+PROJECT_PATH+'\\assets\\www\\cordova.js" /Y');
|
||||||
|
// copy in cordova.jar
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\cordova-'+VERSION+'.jar" "'+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar" /Y');
|
||||||
|
// copy in xml
|
||||||
|
fso.CreateFolder(PROJECT_PATH + '\\res\\xml');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\xml\\config.xml" "' + PROJECT_PATH + '\\res\\xml\\config.xml" /Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy cordova scripts
|
||||||
|
fso.CreateFolder(PROJECT_PATH + '\\cordova');
|
||||||
|
fso.CreateFolder(PROJECT_PATH + '\\cordova\\lib');
|
||||||
|
createAppInfoJar();
|
||||||
|
Log("Copying cordova command tools...");
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\appinfo.jar" "' + PROJECT_PATH + '\\cordova\\appinfo.jar" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\cordova.js" "' + PROJECT_PATH + '\\cordova\\lib\\cordova.js" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\install-device.bat" "' + PROJECT_PATH + '\\cordova\\lib\\install-device.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\install-emulator.bat" "' + PROJECT_PATH + '\\cordova\\lib\\install-emulator.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\list-emulator-images.bat" "' + PROJECT_PATH + '\\cordova\\lib\\list-emulator-images.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\list-devices.bat" "' + PROJECT_PATH + '\\cordova\\lib\\list-devices.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\list-started-emulators.bat" "' + PROJECT_PATH + '\\cordova\\lib\\list-started-emulators.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\start-emulator.bat" "' + PROJECT_PATH + '\\cordova\\lib\\start-emulator.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\cordova.bat" "' + PROJECT_PATH + '\\cordova\\cordova.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\clean.bat" "' + PROJECT_PATH + '\\cordova\\clean.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\build.bat" "' + PROJECT_PATH + '\\cordova\\build.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\log.bat" "' + PROJECT_PATH + '\\cordova\\log.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\run.bat" "' + PROJECT_PATH + '\\cordova\\run.bat" /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\version.bat" "' + PROJECT_PATH + '\\cordova\\version.bat" /Y');
|
||||||
|
|
||||||
|
// interpolate the activity name and package
|
||||||
|
Log("Updating AndroidManifest.xml and Main Activity...");
|
||||||
|
replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY);
|
||||||
|
replaceInFile(ACTIVITY_PATH, /__ID__/, PACKAGE);
|
||||||
|
|
||||||
|
replaceInFile(MANIFEST_PATH, /__ACTIVITY__/, ACTIVITY);
|
||||||
|
replaceInFile(MANIFEST_PATH, /__PACKAGE__/, PACKAGE);
|
||||||
|
replaceInFile(MANIFEST_PATH, /__APILEVEL__/, API_LEVEL);
|
||||||
|
|
||||||
|
replaceInFile(STRINGS_PATH, new RegExp('>' + SAFE_ACTIVITY + '<'), '>' + ACTIVITY + '<');
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project name="cordova" default="create" basedir="../">
|
||||||
|
|
||||||
|
<property name="project.path" value="${basedir}/example"/>
|
||||||
|
<property name="package" value="org.apache.cordova.example"/>
|
||||||
|
<property name="activity" value="cordovaExample"/>
|
||||||
|
|
||||||
|
<target name="create">
|
||||||
|
|
||||||
|
<!-- this stuff is seriously stupid -->
|
||||||
|
<echo file="tmp/package.tmp">package-as-path=${package}</echo>
|
||||||
|
<replace file="tmp/package.tmp" token="." value="\\" />
|
||||||
|
<property file="tmp/package.tmp" />
|
||||||
|
|
||||||
|
<property name="activity.path" value="${project.path}/src/${package-as-path}/${activity}.java" />
|
||||||
|
<property name="manifest.path" value="${project.path}/AndroidManifest.xml" />
|
||||||
|
|
||||||
|
<!-- get the highest target on this machine -->
|
||||||
|
<!-- this stuff is also seriously stupid -->
|
||||||
|
<exec executable="cmd" osfamily="windows" output="tmp/target.list.tmp">
|
||||||
|
<arg line="/c android.bat list targets"/>
|
||||||
|
</exec>
|
||||||
|
<exec executable="android" osfamily="mac" output="tmp/target.list.tmp">
|
||||||
|
<arg line="list targets"/>
|
||||||
|
</exec>
|
||||||
|
<replaceregexp file="tmp/target.list.tmp" match=".*id:\s([0-9]).*" replace="target=\1" flags="s" />
|
||||||
|
<property file="tmp/target.list.tmp" />
|
||||||
|
|
||||||
|
<!-- var VERSION=read('VERSION').replace(/\r\n/,'').replace(/\n/,''); -->
|
||||||
|
<copy file="VERSION" tofile="tmp/VERSION.tmp" overwrite="true" />
|
||||||
|
<replaceregexp file="tmp/VERSION.tmp" match="^" replace="version=" />
|
||||||
|
<replaceregexp file="tmp/VERSION.tmp" match="\r\n" replace="" />
|
||||||
|
<property file="tmp/VERSION.tmp" />
|
||||||
|
|
||||||
|
<!-- clobber any existing example -->
|
||||||
|
|
||||||
|
<!-- create the project -->
|
||||||
|
<exec executable="cmd" osfamily="windows">
|
||||||
|
<arg line="/c android.bat create project --target ${target} --path ${project.path} --package ${package} --activity ${activity}"/>
|
||||||
|
</exec>
|
||||||
|
<exec executable="android" osfamily="mac">
|
||||||
|
<arg line="create project --target ${target} --path ${project.path} --package ${package} --activity ${activity}"/>
|
||||||
|
</exec>
|
||||||
|
|
||||||
|
<!-- update the framework dir -->
|
||||||
|
<exec executable="cmd" osfamily="windows">
|
||||||
|
<arg line="/c android.bat update project --target ${target} --path ${basedir}/framework"/>
|
||||||
|
</exec>
|
||||||
|
<exec executable="android" osfamily="mac">
|
||||||
|
<arg line="update project --target ${target} --path ${basedir}/framework"/>
|
||||||
|
</exec>
|
||||||
|
|
||||||
|
<!-- compile cordova.js and cordova.jar -->
|
||||||
|
<!-- // if you see an error about "Unable to resolve target" then you may need to
|
||||||
|
// update your android tools or install an additional Android platform version -->
|
||||||
|
<ant antfile="${basedir}/framework/build.xml" useNativeBasedir="true" inheritAll="false" />
|
||||||
|
|
||||||
|
<!-- copy in the project template -->
|
||||||
|
<copy todir="${project.path}" overwrite="true">
|
||||||
|
<fileset dir="${basedir}/bin/templates/project"/>
|
||||||
|
</copy>
|
||||||
|
|
||||||
|
<!-- copy in cordova.js -->
|
||||||
|
<copy file="${basedir}/framework/assets/www/cordova-${version}.js" todir="${project.path}/assets/www/" />
|
||||||
|
|
||||||
|
<!-- copy in cordova.jar -->
|
||||||
|
<copy file="${basedir}/framework/cordova-${version}.jar" todir="${project.path}/libs/" />
|
||||||
|
|
||||||
|
<!-- copy in default activity -->
|
||||||
|
<copy file="${basedir}/bin/templates/Activity.java" tofile="${activity.path}" overwrite="true" />
|
||||||
|
|
||||||
|
<!-- interpolate the activity name and package -->
|
||||||
|
<replaceregexp file="${activity.path}" match="__ACTIVITY__" replace="${activity}" />
|
||||||
|
<replaceregexp file="${activity.path}" match="__ID__" replace="${package}" />
|
||||||
|
|
||||||
|
<replaceregexp file="${manifest.path}" match="__ACTIVITY__" replace="${activity}" />
|
||||||
|
<replaceregexp file="${manifest.path}" match="__PACKAGE__" replace="${package}" />
|
||||||
|
</target>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "cordova-android-cli",
|
||||||
|
"description": "CLI tooling for the cordova-android project",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"licenses": [{
|
||||||
|
"type": "APL 2.0",
|
||||||
|
"url": "http://www.apache.org/licenses/LICENSE-2.0"
|
||||||
|
}],
|
||||||
|
"main" : "./create",
|
||||||
|
"bin": {
|
||||||
|
"create": "./create",
|
||||||
|
"bench": "./bench",
|
||||||
|
"autotest": "./autotest",
|
||||||
|
"BOOM": "./BOOM",
|
||||||
|
"test": "./test"
|
||||||
|
},
|
||||||
|
"homepage": "http://incubator.apache.org/cordova",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "http://git-wip-us.apache.org/repos/asf/incubator-cordova-android.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApplicationInfo {
|
||||||
|
private static void parseAndroidManifest(String path) {
|
||||||
|
// System.out.println(path);
|
||||||
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
|
Document dom;
|
||||||
|
try {
|
||||||
|
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||||
|
dom = db.parse(path);
|
||||||
|
|
||||||
|
// getting package information
|
||||||
|
Element manifest = dom.getDocumentElement();
|
||||||
|
String pakkage = manifest.getAttribute("package");
|
||||||
|
|
||||||
|
// getting activity name
|
||||||
|
String activity = ((Element)dom.getElementsByTagName("activity").item(0)).getAttribute("android:name");
|
||||||
|
System.out.println(String.format("%s/.%s", pakkage, activity.replace(".", "")));
|
||||||
|
} catch(ParserConfigurationException pce) {
|
||||||
|
pce.printStackTrace();
|
||||||
|
} catch(SAXException se) {
|
||||||
|
se.printStackTrace();
|
||||||
|
} catch(IOException ioe) {
|
||||||
|
ioe.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String path;
|
||||||
|
if(args.length > 0) {
|
||||||
|
path = args[0];
|
||||||
|
} else {
|
||||||
|
path = System.getProperty("user.dir") + "/../AndroidManifest.xml";
|
||||||
|
}
|
||||||
|
parseAndroidManifest(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# or more contributor license agreements. See the NOTICE file
|
||||||
# distributed with this work for additional information
|
# distributed with this work for additional information
|
||||||
@@ -5,9 +6,9 @@
|
|||||||
# to you under the Apache License, Version 2.0 (the
|
# to you under the Apache License, Version 2.0 (the
|
||||||
# "License"); you may not use this file except in compliance
|
# "License"); you may not use this file except in compliance
|
||||||
# with the License. You may obtain a copy of the License at
|
# with the License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Unless required by applicable law or agreed to in writing,
|
||||||
# software distributed under the License is distributed on an
|
# software distributed under the License is distributed on an
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
@@ -15,32 +16,24 @@
|
|||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
github:
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
description: Apache Cordova Android
|
PROJECT_PATH=$( cd "$DIR/.." && pwd )
|
||||||
homepage: https://cordova.apache.org/
|
|
||||||
|
|
||||||
labels:
|
if [[ "$#" -eq 1 ]] ; then
|
||||||
- cordova
|
if [[ $1 == "--debug" ]] ; then
|
||||||
- cordova-platform
|
$DIR/clean
|
||||||
- android
|
ant debug -f "$PROJECT_PATH"/build.xml
|
||||||
- java
|
elif [[ $1 == "--release" ]] ; then
|
||||||
- mobile
|
$DIR/clean
|
||||||
- javascript
|
ant release -f "$PROJECT_PATH"/build.xml
|
||||||
- nodejs
|
elif [[ $1 == "--nobuild" ]] ; then
|
||||||
- hacktoberfest
|
echo "Skipping build..."
|
||||||
|
else
|
||||||
features:
|
echo "Error : Build command '$1' not recognized."
|
||||||
wiki: false
|
exit 2
|
||||||
issues: true
|
fi
|
||||||
projects: true
|
else
|
||||||
|
echo "Warning : [ --debug | --release | --nobuild ] not specified, defaulting to --debug"
|
||||||
enabled_merge_buttons:
|
$DIR/clean
|
||||||
squash: true
|
ant debug -f "$PROJECT_PATH"/build.xml
|
||||||
merge: false
|
fi
|
||||||
rebase: false
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
commits: commits@cordova.apache.org
|
|
||||||
issues: issues@cordova.apache.org
|
|
||||||
pullrequests_status: issues@cordova.apache.org
|
|
||||||
pullrequests_comment: issues@cordova.apache.org
|
|
||||||
@@ -5,16 +5,14 @@
|
|||||||
:: to you under the Apache License, Version 2.0 (the
|
:: to you under the Apache License, Version 2.0 (the
|
||||||
:: "License"); you may not use this file except in compliance
|
:: "License"); you may not use this file except in compliance
|
||||||
:: with the License. You may obtain a copy of the License at
|
:: with the License. You may obtain a copy of the License at
|
||||||
::
|
::
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
:: http://www.apache.org/licenses/LICENSE-2.0
|
||||||
::
|
::
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
:: Unless required by applicable law or agreed to in writing,
|
||||||
:: software distributed under the License is distributed on an
|
:: software distributed under the License is distributed on an
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
:: KIND, either express or implied. See the License for the
|
:: KIND, either express or implied. See the License for the
|
||||||
:: specific language governing permissions and limitations
|
:: specific language governing permissions and limitations
|
||||||
:: under the License.
|
:: under the License.
|
||||||
|
|
||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
for /f "tokens=2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Android Studio" /v Path') do set "ASPath=%%~b"
|
%~dp0\cordova.bat build %*
|
||||||
ECHO %ASPath%
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# or more contributor license agreements. See the NOTICE file
|
||||||
# distributed with this work for additional information
|
# distributed with this work for additional information
|
||||||
@@ -5,19 +6,17 @@
|
|||||||
# to you under the Apache License, Version 2.0 (the
|
# to you under the Apache License, Version 2.0 (the
|
||||||
# "License"); you may not use this file except in compliance
|
# "License"); you may not use this file except in compliance
|
||||||
# with the License. You may obtain a copy of the License at
|
# with the License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Unless required by applicable law or agreed to in writing,
|
||||||
# software distributed under the License is distributed on an
|
# software distributed under the License is distributed on an
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
#Mon Dec 28 10:00:20 PST 2015
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
distributionBase=GRADLE_USER_HOME
|
PROJECT_PATH=$( cd "$DIR/.." && pwd )
|
||||||
distributionPath=wrapper/dists
|
echo "Cleaning project..."
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
ant -f "$PROJECT_PATH/build.xml" clean
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
%~dp0\cordova.bat clean %*
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
IF NOT DEFINED JAVA_HOME GOTO MISSING
|
||||||
|
FOR %%X in (java.exe ant.bat android.bat) do (
|
||||||
|
SET FOUND=%%~$PATH:X
|
||||||
|
IF NOT DEFINED FOUND GOTO MISSING
|
||||||
|
)
|
||||||
|
cscript %~dp0\lib\cordova.js %* //nologo
|
||||||
|
GOTO END
|
||||||
|
:MISSING
|
||||||
|
ECHO Missing one of the following:
|
||||||
|
ECHO JDK: http://java.oracle.com
|
||||||
|
ECHO Android SDK: http://developer.android.com
|
||||||
|
ECHO Apache ant: http://ant.apache.org
|
||||||
|
EXIT /B 1
|
||||||
|
:END
|
||||||
@@ -0,0 +1,609 @@
|
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
|
||||||
|
var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\cordova.js').join(''),
|
||||||
|
shell = WScript.CreateObject("WScript.Shell"),
|
||||||
|
fso = WScript.CreateObject('Scripting.FileSystemObject');
|
||||||
|
//device_id for targeting specific device
|
||||||
|
var device_id;
|
||||||
|
//build types
|
||||||
|
var NONE = 0,
|
||||||
|
DEBUG = '--debug',
|
||||||
|
RELEASE = '--release',
|
||||||
|
NO_BUILD = '--nobuild';
|
||||||
|
var build_type = NONE;
|
||||||
|
|
||||||
|
//deploy tpyes
|
||||||
|
var NONE = 0,
|
||||||
|
EMULATOR = 1,
|
||||||
|
DEVICE = 2,
|
||||||
|
TARGET = 3;
|
||||||
|
var deploy_type = NONE;
|
||||||
|
|
||||||
|
|
||||||
|
// log to stdout or stderr
|
||||||
|
function Log(msg, error) {
|
||||||
|
if (error) {
|
||||||
|
WScript.StdErr.WriteLine(msg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WScript.StdOut.WriteLine(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// executes a commmand in the shell, returning stdout
|
||||||
|
function exec(command) {
|
||||||
|
var oExec=shell.Exec(command);
|
||||||
|
var output = new String();
|
||||||
|
while (oExec.Status == 0) {
|
||||||
|
if (!oExec.StdOut.AtEndOfStream) {
|
||||||
|
var line = oExec.StdOut.ReadLine();
|
||||||
|
output += line;
|
||||||
|
}
|
||||||
|
WScript.sleep(100);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
// executes a command in the shell, returns stdout or stderr if error
|
||||||
|
function exec_out(command) {
|
||||||
|
var oExec=shell.Exec(command);
|
||||||
|
var output = new String();
|
||||||
|
while (oExec.Status == 0) {
|
||||||
|
if (!oExec.StdOut.AtEndOfStream) {
|
||||||
|
var line = oExec.StdOut.ReadLine();
|
||||||
|
// XXX: Change to verbose mode
|
||||||
|
// WScript.StdOut.WriteLine(line);
|
||||||
|
output += line;
|
||||||
|
}
|
||||||
|
WScript.sleep(100);
|
||||||
|
}
|
||||||
|
//Check to make sure our scripts did not encounter an error
|
||||||
|
if (!oExec.StdErr.AtEndOfStream) {
|
||||||
|
var line = oExec.StdErr.ReadAll();
|
||||||
|
return {'error' : true, 'output' : line};
|
||||||
|
}
|
||||||
|
return {'error' : false, 'output' : output};
|
||||||
|
}
|
||||||
|
|
||||||
|
// executes a commmand in the shell and outputs stdout and fails on stderr
|
||||||
|
function exec_verbose(command) {
|
||||||
|
//Log("Command: " + command);
|
||||||
|
var oShell=shell.Exec(command);
|
||||||
|
while (oShell.Status == 0) {
|
||||||
|
//Wait a little bit so we're not super looping
|
||||||
|
WScript.sleep(100);
|
||||||
|
//Print any stdout output from the script
|
||||||
|
if (!oShell.StdOut.AtEndOfStream) {
|
||||||
|
var line = oShell.StdOut.ReadLine();
|
||||||
|
Log(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Check to make sure our scripts did not encounter an error
|
||||||
|
if (!oShell.StdErr.AtEndOfStream) {
|
||||||
|
var line = oShell.StdErr.ReadAll();
|
||||||
|
Log(line, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function version(path) {
|
||||||
|
var cordovajs_path = path + "\\assets\\www\\cordova.js";
|
||||||
|
if(fso.FileExists(cordovajs_path)) {
|
||||||
|
var f = fso.OpenTextFile(cordovajs_path, 1,2);
|
||||||
|
var cordovajs = f.ReadAll();
|
||||||
|
f.Close();
|
||||||
|
var version_regex = /^.*CORDOVA_JS_BUILD_LABEL.*$/m;
|
||||||
|
var version_line = cordovajs.match(version_regex) + "";
|
||||||
|
var version = version_line.match(/(\d+)\.(\d+)\.(\d+)(rc\d)?/) + "";
|
||||||
|
// TODO : figure out why this isn't matching properly so we can remove this substring workaround.
|
||||||
|
Log(version.substr(0, ((version.length/2) -1)));
|
||||||
|
} else {
|
||||||
|
Log("Error : Could not find cordova js.", true);
|
||||||
|
Log("Expected Location : " + cordovajs_path, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_devices() {
|
||||||
|
var device_list = []
|
||||||
|
var local_devices = shell.Exec("%comspec% /c adb devices").StdOut.ReadAll();
|
||||||
|
if (local_devices.match(/\w+\tdevice/)) {
|
||||||
|
devices = local_devices.split('\r\n');
|
||||||
|
//format (ID DESCRIPTION)
|
||||||
|
for (i in devices) {
|
||||||
|
if (devices[i].match(/\w+\tdevice/) && !devices[i].match(/emulator/)) {
|
||||||
|
device_list.push(devices[i].replace(/\t/, ' '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return device_list
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_devices() {
|
||||||
|
var devices = get_devices();
|
||||||
|
if (devices.length > 0) {
|
||||||
|
for (i in devices) {
|
||||||
|
Log(devices[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log('No devices found, if your device is connected and not showing,');
|
||||||
|
Log(' then try and install the drivers for your device.');
|
||||||
|
Log(' http://developer.android.com/tools/extras/oem-usb.html');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_emulator_images() {
|
||||||
|
var avd_list = [];
|
||||||
|
var local_emulators = shell.Exec("%comspec% /c android list avds").StdOut.ReadAll();
|
||||||
|
if (local_emulators.match(/Name\:/)) {
|
||||||
|
emulators = local_emulators.split('\n');
|
||||||
|
var count = 0;
|
||||||
|
var output = '';
|
||||||
|
for (i in emulators) {
|
||||||
|
// Find the line with the emulator name.
|
||||||
|
if (emulators[i].match(/Name\:/)) {
|
||||||
|
// strip description
|
||||||
|
var emulator_name = emulators[i].replace(/\s*Name\:\s/, '') + ' ';
|
||||||
|
avd_list.push(emulator_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return avd_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_emulator_images() {
|
||||||
|
var images = get_emulator_images();
|
||||||
|
if (images.length > 0) {
|
||||||
|
for(i in images) {
|
||||||
|
Log(images[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log('No emulators found, if you would like to create an emulator follow the instructions');
|
||||||
|
Log(' provided here : http://developer.android.com/tools/devices/index.html');
|
||||||
|
Log(' Or run \'android create avd --name <name> --target <targetID>\' in on the command line.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_started_emulators() {
|
||||||
|
var started_emulators = [];
|
||||||
|
var local_devices = shell.Exec("%comspec% /c adb devices").StdOut.ReadAll();
|
||||||
|
if (local_devices.match(/emulator/)) {
|
||||||
|
devices = local_devices.split('\r\n');
|
||||||
|
//format (ID DESCRIPTION)
|
||||||
|
for (i in devices) {
|
||||||
|
if (devices[i].match(/\w+\tdevice/) && devices[i].match(/emulator/)) {
|
||||||
|
started_emulators.push(devices[i].replace(/\t/, ' '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return started_emulators
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_started_emulators() {
|
||||||
|
var images = get_started_emulators();
|
||||||
|
if (images.length > 0) {
|
||||||
|
for(i in images) {
|
||||||
|
Log(images[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log('No started emulators found, if you would like to start an emulator call ');
|
||||||
|
Log('\'list-emulator-images\'');
|
||||||
|
Log(' to get the name of an emulator and then start the emulator with');
|
||||||
|
Log('\'start-emulator <Name>\'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_emulator() {
|
||||||
|
//get targets
|
||||||
|
var targets = shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s\d+/g);
|
||||||
|
if(targets) {
|
||||||
|
exec('%comspec% /c android create avd --name cordova_emulator --target ' + targets[targets.length - 1].replace(/id: /, ""));
|
||||||
|
} else {
|
||||||
|
Log("You do not have any android targets setup. Please create at least one target with the `android` command so that an emulator can be created.", true);
|
||||||
|
WScript.Quit(69);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_emulator(name) {
|
||||||
|
var emulators = get_emulator_images();
|
||||||
|
var started_emulators = get_started_emulators();
|
||||||
|
var num_started = started_emulators.length;
|
||||||
|
var emulator_name;
|
||||||
|
var started = false;
|
||||||
|
if (name) {
|
||||||
|
for (i in emulators) {
|
||||||
|
if (emulators[i].substr(0,name.length) == name) {
|
||||||
|
Log("Starting emulator : " + name);
|
||||||
|
shell.Exec("%comspec% /c emulator -avd " + name + " &");
|
||||||
|
//shell.Run("%comspec% /c start cmd /c emulator -cpu-delay 0 -no-boot-anim -cache %Temp%\cache -avd " + name);
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emulators.length > 0 && started_emulators.length == 0) {
|
||||||
|
emulator_name = emulators[0].split(' ', 1)[0];
|
||||||
|
start_emulator(emulator_name);
|
||||||
|
return;
|
||||||
|
} else if (started_emulators.length > 0) {
|
||||||
|
Log("Emulator already started : " + started_emulators[0].split(' ', 1));
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Log("Error : unable to start emulator, ensure you have emulators availible by checking \'list-emulator-images\'", true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!started) {
|
||||||
|
Log("Error : unable to start emulator, ensure you have emulators availible by checking \'list-emulator-images\'", true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// wait for emulator to get the ID
|
||||||
|
Log('Waiting for emulator...');
|
||||||
|
var boot_anim = null;
|
||||||
|
var emulator_ID = null;
|
||||||
|
var new_started = null;
|
||||||
|
var i = 0;
|
||||||
|
while(emulator_ID == null && i < 10) {
|
||||||
|
new_started = get_started_emulators();
|
||||||
|
if(new_started.length > started_emulators.length) {
|
||||||
|
// find new emulator that was just started to get it's ID
|
||||||
|
for(var i = 0; i < new_started.length; i++) {
|
||||||
|
if (new_started[i] != started_emulators[i]) {
|
||||||
|
emulator_ID = new_started[i].split(' ', 1)[0];
|
||||||
|
boot_anim = exec_out('%comspec% /c adb -s ' + emulator_ID + ' shell getprop init.svc.bootanim');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == 10) {
|
||||||
|
Log('\nEmulator start timed out.');
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
WScript.Stdout.Write('Booting up emulator (this may take a while).');
|
||||||
|
// use boot animation property to tell when boot is complete.
|
||||||
|
while (!boot_anim.output.match(/stopped/) && i < 100) {
|
||||||
|
boot_anim = exec_out('%comspec% /c adb -s ' + emulator_ID + ' shell getprop init.svc.bootanim');
|
||||||
|
i++;
|
||||||
|
WScript.Stdout.Write('.');
|
||||||
|
WScript.Sleep(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < 100) {
|
||||||
|
Log('\nBoot Complete!');
|
||||||
|
// Unlock the device
|
||||||
|
shell.Exec("%comspec% /c adb -s " + emulator_ID + " shell input keyevent 82");
|
||||||
|
} else {
|
||||||
|
Log('\nEmulator boot timed out. Failed to load emulator');
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_apk(path) {
|
||||||
|
// check if file .apk has been created
|
||||||
|
if (fso.FolderExists(path + '\\bin')) {
|
||||||
|
var path_to_apk;
|
||||||
|
var out_folder = fso.GetFolder(path + '\\bin');
|
||||||
|
var out_files = new Enumerator(out_folder.Files);
|
||||||
|
for (;!out_files.atEnd(); out_files.moveNext()) {
|
||||||
|
var path = out_files.item() + '';
|
||||||
|
if (fso.GetExtensionName(path) == 'apk' && !path.match(/unaligned/)) {
|
||||||
|
path_to_apk = out_files.item();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (path_to_apk) {
|
||||||
|
return path_to_apk;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log('Failed to find apk, make sure you project is built and there is an ', true);
|
||||||
|
Log(' apk in <project>\\bin\\. To build your project use \'<project>\\cordova\\build\'', true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_device(path) {
|
||||||
|
var devices = get_devices();
|
||||||
|
var use_target = false;
|
||||||
|
if (devices.length < 1) {
|
||||||
|
Log("Error : No devices found to install to, make sure there are devices", true);
|
||||||
|
Log(" availible by checking \'<project_dir>\\cordova\\lib\\list-devices\'", true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
launch(path, devices[0].split(' ', 1)[0], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_emulator(path) {
|
||||||
|
var emulators = get_started_emulators();
|
||||||
|
var use_target = false;
|
||||||
|
if (emulators.length < 1) {
|
||||||
|
Log("Error : No emulators found to install to, make sure there are emulators", true);
|
||||||
|
Log(" availible by checking \'<project_dir>\\cordova\\lib\\list-started-emulators\'", true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
launch(path, emulators[0].split(' ', 1)[0], false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_target(path) {
|
||||||
|
if(device_id) {
|
||||||
|
var device = false;
|
||||||
|
var emulators = get_started_emulators();
|
||||||
|
var devices = get_devices();
|
||||||
|
var exists = false;
|
||||||
|
for (i in emulators) {
|
||||||
|
if (emulators[i].substr(0,device_id.length) == device_id) {
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i in devices) {
|
||||||
|
if (devices[i].substr(0,device_id.length) == device_id) {
|
||||||
|
exists = true;
|
||||||
|
device = true
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!exists) {
|
||||||
|
Log("Error : Unable to find target " + device_id, true);
|
||||||
|
Log("Please ensure the target exists by checking \'<project>\\cordova\\lib\\list-started-emulators'");
|
||||||
|
Log(" Or \'<project>\\cordova\\lib\\list-devices'");
|
||||||
|
}
|
||||||
|
launch(path, device_id, device);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log("You cannot install to a target without providing a valid target ID.", true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch(path, id, device) {
|
||||||
|
if(id) {
|
||||||
|
var path_to_apk = get_apk(path);
|
||||||
|
if (path_to_apk) {
|
||||||
|
var launch_name = exec_out("%comspec% /c java -jar "+path+"\\cordova\\appinfo.jar "+path+"\\AndroidManifest.xml");
|
||||||
|
if (launch_name.error) {
|
||||||
|
Log("Failed to get application name from appinfo.jar + AndroidManifest : ", true);
|
||||||
|
Log("Output : " + launch_name.output, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
if (device) {
|
||||||
|
// install on device (-d)
|
||||||
|
Log("Installing app on device...");
|
||||||
|
} else {
|
||||||
|
// install on emulator (-e)
|
||||||
|
Log("Installing app on emulator...");
|
||||||
|
}
|
||||||
|
var cmd = '%comspec% /c adb -s ' + id + ' install -r ' + path_to_apk;
|
||||||
|
var install = exec_out(cmd);
|
||||||
|
if ( install.error && install.output.match(/Failure/)) {
|
||||||
|
Log("Error : Could not install apk to emulator : ", true);
|
||||||
|
Log(install.output, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log(install.output);
|
||||||
|
}
|
||||||
|
// launch the application
|
||||||
|
Log("Launching application...");
|
||||||
|
cmd = '%comspec% /c adb -s ' + id + ' shell am start -W -a android.intent.action.MAIN -n ' + launch_name.output;
|
||||||
|
exec_verbose(cmd);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log('Failed to find apk, make sure you project is built and there is an ', true);
|
||||||
|
Log(' apk in <project>\\bin\\. To build your project use \'<project>\\cordova\\build\'', true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log("You cannot install to a target without providing a valid target ID.", true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean(path) {
|
||||||
|
Log("Cleaning project...");
|
||||||
|
exec("%comspec% /c ant.bat clean -f "+path+"\\build.xml 2>&1");
|
||||||
|
}
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
// filter out nativeGetEnabledTags spam from latest sdk bug.
|
||||||
|
shell.Run("%comspec% /c adb logcat | grep -v nativeGetEnabledTags");
|
||||||
|
}
|
||||||
|
|
||||||
|
function build(path) {
|
||||||
|
switch (build_type) {
|
||||||
|
case DEBUG :
|
||||||
|
clean(path);
|
||||||
|
Log("Building project...");
|
||||||
|
exec_verbose("%comspec% /c ant.bat debug -f "+path+"\\build.xml 2>&1");
|
||||||
|
break;
|
||||||
|
case RELEASE :
|
||||||
|
clean(path);
|
||||||
|
Log("Building project...");
|
||||||
|
exec_verbose("%comspec% /c ant.bat release -f "+path+"\\build.xml 2>&1");
|
||||||
|
break;
|
||||||
|
case NO_BUILD :
|
||||||
|
Log("Skipping build process.");
|
||||||
|
break;
|
||||||
|
case NONE :
|
||||||
|
clean(path);
|
||||||
|
Log("WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug.");
|
||||||
|
exec_verbose("%comspec% /c ant.bat debug -f "+path+"\\build.xml 2>&1");
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
Log("Build option not recognized: " + build_type, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(path) {
|
||||||
|
switch(deploy_type) {
|
||||||
|
case EMULATOR :
|
||||||
|
build(path);
|
||||||
|
if(get_started_emulators().length == 0) {
|
||||||
|
start_emulator();
|
||||||
|
}
|
||||||
|
//TODO : Start emulator if one isn't started, and create one if none exists.
|
||||||
|
install_emulator(path);
|
||||||
|
break;
|
||||||
|
case DEVICE :
|
||||||
|
build(path);
|
||||||
|
install_device(path);
|
||||||
|
break;
|
||||||
|
case TARGET :
|
||||||
|
build(path);
|
||||||
|
install_target(path);
|
||||||
|
break;
|
||||||
|
case NONE :
|
||||||
|
if (get_devices().length > 0) {
|
||||||
|
Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --device");
|
||||||
|
deploy_type = DEVICE;
|
||||||
|
} else {
|
||||||
|
Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
|
||||||
|
deploy_type = EMULATOR;
|
||||||
|
}
|
||||||
|
run(path);
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
Log("Deploy option not recognized: " + deploy_type, true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var args = WScript.Arguments;
|
||||||
|
if (args.count() == 0) {
|
||||||
|
Log("Error: no args provided.");
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// parse command
|
||||||
|
switch(args(0)) {
|
||||||
|
case "version" :
|
||||||
|
version(ROOT);
|
||||||
|
break;
|
||||||
|
case "build" :
|
||||||
|
if(args.Count() > 1) {
|
||||||
|
if (args(1) == "--release") {
|
||||||
|
build_type = RELEASE;
|
||||||
|
}
|
||||||
|
else if (args(1) == "--debug") {
|
||||||
|
build_type = DEBUG;
|
||||||
|
}
|
||||||
|
else if (args(1) == "--nobuild") {
|
||||||
|
build_type = NO_BUILD;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log('Error: \"' + args(i) + '\" is not recognized as a build option', true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
build(ROOT);
|
||||||
|
break;
|
||||||
|
case "clean" :
|
||||||
|
clean();
|
||||||
|
break;
|
||||||
|
case "list-devices" :
|
||||||
|
list_devices();
|
||||||
|
break;
|
||||||
|
case "list-emulator-images" :
|
||||||
|
list_emulator_images();
|
||||||
|
break;
|
||||||
|
case "list-started-emulators" :
|
||||||
|
list_started_emulators();
|
||||||
|
break;
|
||||||
|
case "start-emulator" :
|
||||||
|
if (args.Count() > 1) {
|
||||||
|
start_emulator(args(1))
|
||||||
|
} else {
|
||||||
|
start_emulator();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "install-emulator" :
|
||||||
|
if (args.Count() == 2) {
|
||||||
|
if (args(1).substr(0,9) == "--target=") {
|
||||||
|
device_id = args(1).split('--target=').join('');
|
||||||
|
install_emulator(ROOT);
|
||||||
|
} else {
|
||||||
|
Log('Error: \"' + args(1) + '\" is not recognized as an install option', true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
install_emulator(ROOT);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "install-device" :
|
||||||
|
if (args.Count() == 2) {
|
||||||
|
if (args(1).substr(0,9) == "--target=") {
|
||||||
|
device_id = args(1).split('--target=').join('');
|
||||||
|
install_target(ROOT);
|
||||||
|
} else {
|
||||||
|
Log('Error: \"' + args(1) + '\" is not recognized as an install option', true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
install_device(ROOT);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "run" :
|
||||||
|
//parse args
|
||||||
|
for(var i = 1; i < args.Count(); i++) {
|
||||||
|
if (args(i) == "--release") {
|
||||||
|
build_type = RELEASE;
|
||||||
|
}
|
||||||
|
else if (args(i) == "--debug") {
|
||||||
|
build_type = DEBUG;
|
||||||
|
}
|
||||||
|
else if (args(i) == "--nobuild") {
|
||||||
|
build_type = NO_BUILD;
|
||||||
|
}
|
||||||
|
else if (args(i) == "--emulator" || args(i) == "-e") {
|
||||||
|
deploy_type = EMULATOR;
|
||||||
|
}
|
||||||
|
else if (args(i) == "--device" || args(i) == "-d") {
|
||||||
|
deploy_type = DEVICE;
|
||||||
|
}
|
||||||
|
else if (args(i).substr(0,9) == "--target=") {
|
||||||
|
device_id = args(i).split("--target=").join("");
|
||||||
|
deploy_type = TARGET;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log('Error: \"' + args(i) + '\" is not recognized as a run option', true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
run(ROOT);
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
Log("Cordova does not regognize the command " + args(0), true);
|
||||||
|
WScript.Quit(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
PROJECT_PATH=$( cd "$DIR/../.." && pwd )
|
||||||
|
device_list=$("$DIR/list-devices")
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "No devices found to deploy to. Please make sure your device is connected"
|
||||||
|
echo " and you can view it using the 'cordova/lib/list-devices' command."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
apks=`find $PROJECT_PATH/bin -type f -maxdepth 1 | egrep '\.apk$'`
|
||||||
|
apk_list=($apks)
|
||||||
|
if [[ ${#apk_list[@]} > 0 ]] ; then
|
||||||
|
# handle target
|
||||||
|
read -ra device_array <<< "$device_list"
|
||||||
|
if [[ "$#" -eq 1 ]] ; then
|
||||||
|
# deploy to given target
|
||||||
|
target=${1/--target=/}
|
||||||
|
else
|
||||||
|
# delete trailing space and 'device' after device ID
|
||||||
|
target=${device_array[0]}
|
||||||
|
fi
|
||||||
|
echo "Installing ${apk_list[0]} onto device $target..."
|
||||||
|
adb -s $target install -r ${apk_list[0]};
|
||||||
|
echo "Launching application..."
|
||||||
|
launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
|
||||||
|
adb -s $target shell am start -W -a android.intent.action.MAIN -n $launch_str
|
||||||
|
else
|
||||||
|
echo "Application package not found, could not install to device"
|
||||||
|
echo " make sure your application is built before deploying."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
SET full_path=%~dp0
|
||||||
|
IF EXIST %full_path%cordova.js (
|
||||||
|
cscript "%full_path%cordova.js" install-device %* //nologo
|
||||||
|
) ELSE (
|
||||||
|
ECHO.
|
||||||
|
ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
|
||||||
|
EXIT /B 1
|
||||||
|
)
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
PROJECT_PATH=$( cd "$DIR/../.." && pwd )
|
||||||
|
emulator_list=$("$DIR/list-started-emulators")
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "No emulators found to deploy to. Please make sure your emulator is started"
|
||||||
|
echo " You can view it using the 'cordova/lib/list-started-emulators' command."
|
||||||
|
echo " You can view created emulator images using the 'cordova/lib/list-emulator-images' command."
|
||||||
|
echo " You can start an emulator image using the 'cordova/lib/start-emulator' command."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
apks=`find $PROJECT_PATH/bin -type f -maxdepth 1 | egrep '\.apk$'`
|
||||||
|
apk_list=($apks)
|
||||||
|
if [[ ${#apk_list[@]} > 0 ]] ; then
|
||||||
|
# handle target emulator
|
||||||
|
if [[ "$#" -eq 1 ]] ; then
|
||||||
|
# deploy to given target
|
||||||
|
target=${1/--target=/}
|
||||||
|
else
|
||||||
|
# delete trailing space and 'device' after emulator ID
|
||||||
|
target=${emulator_list[0]}
|
||||||
|
fi
|
||||||
|
echo "Installing ${apk_list[0]} onto emulator $target..."
|
||||||
|
adb -s $target install -r ${apk_list[0]};
|
||||||
|
echo "Launching application..."
|
||||||
|
launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
|
||||||
|
adb -s $target shell am start -W -a android.intent.action.MAIN -n $launch_str
|
||||||
|
else
|
||||||
|
echo "Application package not found, could not install to device"
|
||||||
|
echo " make sure your application is built before deploying."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
SET full_path=%~dp0
|
||||||
|
IF EXIST %full_path%cordova.js (
|
||||||
|
cscript "%full_path%cordova.js" install-emulator %* //nologo
|
||||||
|
) ELSE (
|
||||||
|
ECHO.
|
||||||
|
ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
|
||||||
|
EXIT /B 1
|
||||||
|
)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# or more contributor license agreements. See the NOTICE file
|
||||||
# distributed with this work for additional information
|
# distributed with this work for additional information
|
||||||
@@ -5,27 +6,25 @@
|
|||||||
# to you under the Apache License, Version 2.0 (the
|
# to you under the Apache License, Version 2.0 (the
|
||||||
# "License"); you may not use this file except in compliance
|
# "License"); you may not use this file except in compliance
|
||||||
# with the License. You may obtain a copy of the License at
|
# with the License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Unless required by applicable law or agreed to in writing,
|
||||||
# software distributed under the License is distributed on an
|
# software distributed under the License is distributed on an
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep 'device' | grep -v 'emulator' | awk '{ print $1; }'`
|
||||||
# This file was originally created by the Android Tools, but is now
|
device_list=($devices)
|
||||||
# used by cordova-android to manage the state of the various third party
|
if [[ ${#device_list[@]} > 0 ]] ; then
|
||||||
# libraries used in your application
|
for i in ${devices[@]}
|
||||||
|
do
|
||||||
# This is the Library Module that contains the Cordova Library, this is not
|
echo $i
|
||||||
# required when using an AAR
|
done
|
||||||
android.library.reference.1=CordovaLib
|
exit 0
|
||||||
|
else
|
||||||
# This is the application project. This is only required for Android Studio Gradle projects
|
echo "No devices found."
|
||||||
android.library.reference.2=app
|
exit 2
|
||||||
|
fi
|
||||||
# Project target.
|
|
||||||
target=This_gets_replaced
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
SET full_path=%~dp0
|
||||||
|
IF EXIST %full_path%cordova.js (
|
||||||
|
cscript "%full_path%cordova.js" list-devices //nologo
|
||||||
|
) ELSE (
|
||||||
|
ECHO.
|
||||||
|
ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
|
||||||
|
EXIT /B 1
|
||||||
|
)
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
emulator_images=`android list avds | grep "Name:" | cut -f 2 -d ":"`
|
||||||
|
emulator_list=($emulator_images)
|
||||||
|
if [[ ${#emulator_list[@]} > 0 ]] ; then
|
||||||
|
for i in ${emulator_list[@]}
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "No emulators found, if you would like to create an emulator follow the instructions"
|
||||||
|
echo " provided here : http://developer.android.com/tools/devices/index.html"
|
||||||
|
echo " Or run 'android create avd --name <name> --target <targetID>' in on the command line."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
SET full_path=%~dp0
|
||||||
|
IF EXIST %full_path%cordova.js (
|
||||||
|
cscript "%full_path%cordova.js" list-emulator-images //nologo
|
||||||
|
) ELSE (
|
||||||
|
ECHO.
|
||||||
|
ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
|
||||||
|
EXIT /B 1
|
||||||
|
)
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print $1;}}' | grep 'emulator' | grep -v 'offline'`
|
||||||
|
read -ra emulator_list <<< "$devices"
|
||||||
|
if [[ ${#emulator_list[@]} > 0 ]] ; then
|
||||||
|
for i in ${emulator_list[@]}
|
||||||
|
do
|
||||||
|
# remove space and 'device'
|
||||||
|
echo $i
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "No started emulators found (it may still be booting up), you can start an emulator by using the command"
|
||||||
|
echo " 'cordova/lib/start-emulator'"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
SET full_path=%~dp0
|
||||||
|
IF EXIST %full_path%cordova.js (
|
||||||
|
cscript "%full_path%cordova.js" list-started-emulators //nologo
|
||||||
|
) ELSE (
|
||||||
|
ECHO.
|
||||||
|
ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
|
||||||
|
EXIT /B 1
|
||||||
|
)
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
PROJECT_PATH=$( cd "$( dirname "$0" )/../.." && pwd )
|
||||||
|
|
||||||
|
function dot {
|
||||||
|
sleep 1
|
||||||
|
echo -n "."
|
||||||
|
}
|
||||||
|
|
||||||
|
function wait_for_emulator() {
|
||||||
|
local emulator_log_path="$1"
|
||||||
|
local error_string
|
||||||
|
local status
|
||||||
|
|
||||||
|
# Try to detect fatal errors early
|
||||||
|
sleep 1.5
|
||||||
|
error_string=$(grep -F "ERROR: " ${emulator_log_path})
|
||||||
|
status=$?
|
||||||
|
|
||||||
|
if [ $status -eq 0 ]; then
|
||||||
|
echo "Emulator failed to start, fatal error detected"
|
||||||
|
echo "Error: ${error_string}"
|
||||||
|
echo "Full log available at: ${emulator_log_path}"
|
||||||
|
echo "Exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local i="0"
|
||||||
|
echo -n "Waiting for emulator"
|
||||||
|
emulator_string=$($DIR/list-started-emulators)
|
||||||
|
while [ $? != 0 ]
|
||||||
|
do
|
||||||
|
dot
|
||||||
|
i=$[i+1]
|
||||||
|
emulator_string=$($DIR/list-started-emulators)
|
||||||
|
done
|
||||||
|
read -ra target <<< "$emulator_string"
|
||||||
|
echo ""
|
||||||
|
echo -n "Waiting for it to boot up (this can take a while)"
|
||||||
|
while [ $i -lt 300 ]
|
||||||
|
do
|
||||||
|
boot_anim=$(adb -s $target shell getprop init.svc.bootanim 2>&1)
|
||||||
|
if [[ "$boot_anim" =~ "stopped" ]] ; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
i=$[i+1]
|
||||||
|
dot
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Device timeout: emulator has not started in time
|
||||||
|
if [ $i -eq 300 ]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo "Emulator timeout!"
|
||||||
|
exit 69
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "Connected!"
|
||||||
|
fi
|
||||||
|
# Unlock the device
|
||||||
|
adb -s $target shell input keyevent 82
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
emulator_images=$("$DIR/list-emulator-images")
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "No emulators found, if you would like to create an emulator follow the instructions"
|
||||||
|
echo " provided here : http://developer.android.com/tools/devices/index.html"
|
||||||
|
echo " Or run 'android create avd --name <name> --target <targetID>' in on the command line."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start first emulator
|
||||||
|
log_path=$(mktemp -t android_emulator)
|
||||||
|
|
||||||
|
# if target emulator is provided
|
||||||
|
if [[ "$#" -eq 1 ]] ; then
|
||||||
|
# check that it exists
|
||||||
|
if [[ $emulator_images =~ $1 ]] ; then
|
||||||
|
#xterm -e emulator -avd $1 &
|
||||||
|
emulator -avd $1 1> "${log_path}" 2>&1 &
|
||||||
|
else
|
||||||
|
echo "Could not find the provided emulator '$1', make sure the emulator exists"
|
||||||
|
echo " by checking 'cordova/lib/list-emulator-images'"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
read -ra emulator_list <<< "$emulator_images"
|
||||||
|
#xterm -e emulator -avd ${emulator_list[0]} &
|
||||||
|
emulator -avd ${emulator_list[0]} 1> "${log_path}" 2>&1 &
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Saving emulator log to: ${log_path}"
|
||||||
|
wait_for_emulator "$log_path"
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
SET full_path=%~dp0
|
||||||
|
IF EXIST %full_path%cordova.js (
|
||||||
|
cscript "%full_path%cordova.js" start-emulator %* //nologo
|
||||||
|
) ELSE (
|
||||||
|
ECHO.
|
||||||
|
ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
|
||||||
|
EXIT /B 1
|
||||||
|
)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# or more contributor license agreements. See the NOTICE file
|
||||||
# distributed with this work for additional information
|
# distributed with this work for additional information
|
||||||
@@ -5,18 +6,15 @@
|
|||||||
# to you under the Apache License, Version 2.0 (the
|
# to you under the Apache License, Version 2.0 (the
|
||||||
# "License"); you may not use this file except in compliance
|
# "License"); you may not use this file except in compliance
|
||||||
# with the License. You may obtain a copy of the License at
|
# with the License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Unless required by applicable law or agreed to in writing,
|
||||||
# software distributed under the License is distributed on an
|
# software distributed under the License is distributed on an
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
#Thu Nov 09 10:50:25 PST 2017
|
# filter out nativeGetEnabledTags spam from latest sdk bug.
|
||||||
distributionBase=GRADLE_USER_HOME
|
adb logcat | grep -v nativeGetEnabledTags
|
||||||
distributionPath=wrapper/dists
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
%~dp0\cordova.bat log %*
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
PROJECT_PATH=$( cd "$DIR/.." && pwd )
|
||||||
|
|
||||||
|
function run_on_device_or_emulator {
|
||||||
|
devices=`$DIR/lib/list-devices`
|
||||||
|
if [ $? = 0 ]; then
|
||||||
|
$DIR/lib/install-device
|
||||||
|
else
|
||||||
|
run_on_emulator
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_on_emulator {
|
||||||
|
emulators=`$DIR/lib/list-started-emulators`
|
||||||
|
if [ $? = 0 ] ; then
|
||||||
|
$DIR/lib/install-emulator
|
||||||
|
else
|
||||||
|
images=`$DIR/lib/list-emulator-images`
|
||||||
|
if [ $? = 0 ] ; then
|
||||||
|
$DIR/lib/start-emulator
|
||||||
|
$DIR/lib/install-emulator
|
||||||
|
else
|
||||||
|
echo "No devices/emulators started nor images available to start. How are we supposed to do this, then?"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$#" -eq 2 ]] ; then
|
||||||
|
# TODO: the order of arguments here may be reversed from the assumption below
|
||||||
|
$DIR/build $2
|
||||||
|
if [[ $1 == "--device" ]] ; then
|
||||||
|
$DIR/lib/install-device
|
||||||
|
elif [[ $1 == "--emulator" ]] ; then
|
||||||
|
run_on_emulator
|
||||||
|
elif [[ $1 =~ "--target=" ]]; then
|
||||||
|
$DIR/lib/install-device $1
|
||||||
|
else
|
||||||
|
echo "Error : '$1' is not recognized as an install option"
|
||||||
|
fi
|
||||||
|
elif [[ "$#" -eq 1 ]] ; then
|
||||||
|
if [[ $1 == "--debug" || $1 == "--release" || $1 == "--nobuild" ]] ; then
|
||||||
|
$DIR/build $1
|
||||||
|
run_on_device_or_emulator
|
||||||
|
elif [[ $1 == "--device" ]] ; then
|
||||||
|
$DIR/build
|
||||||
|
$DIR/lib/install-device
|
||||||
|
elif [[ $1 == "--emulator" ]] ; then
|
||||||
|
$DIR/build
|
||||||
|
run_on_emulator
|
||||||
|
elif [[ $1 =~ "--target=" ]]; then
|
||||||
|
$DIR/build
|
||||||
|
$DIR/lib/install-device $1
|
||||||
|
else
|
||||||
|
echo "Error : '$1' is not recognized as an install option"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Warning : [ --device | --emulate | --target=<targetID> ] not specified, using defaults."
|
||||||
|
$DIR/build
|
||||||
|
run_on_device_or_emulator
|
||||||
|
fi
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
%~dp0\cordova.bat run %*
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# or more contributor license agreements. See the NOTICE file
|
||||||
# distributed with this work for additional information
|
# distributed with this work for additional information
|
||||||
@@ -5,9 +6,9 @@
|
|||||||
# to you under the Apache License, Version 2.0 (the
|
# to you under the Apache License, Version 2.0 (the
|
||||||
# "License"); you may not use this file except in compliance
|
# "License"); you may not use this file except in compliance
|
||||||
# with the License. You may obtain a copy of the License at
|
# with the License. You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Unless required by applicable law or agreed to in writing,
|
||||||
# software distributed under the License is distributed on an
|
# software distributed under the License is distributed on an
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
@@ -15,13 +16,4 @@
|
|||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
extends: '@cordova/eslint-config/node'
|
echo "2.9.0"
|
||||||
|
|
||||||
overrides:
|
|
||||||
- files: [spec/**/*.js]
|
|
||||||
extends: '@cordova/eslint-config/node-tests'
|
|
||||||
rules:
|
|
||||||
prefer-promise-reject-errors: off
|
|
||||||
|
|
||||||
- files: [cordova-js-src/**/*.js]
|
|
||||||
extends: '@cordova/eslint-config/browser'
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
:: 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.
|
||||||
|
@ECHO OFF
|
||||||
|
%~dp0\cordova.bat version %*
|
||||||
@@ -20,23 +20,17 @@
|
|||||||
package __ID__;
|
package __ID__;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.apache.cordova.*;
|
import org.apache.cordova.*;
|
||||||
|
|
||||||
public class __ACTIVITY__ extends CordovaActivity
|
public class __ACTIVITY__ extends DroidGap
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// enable Cordova apps to be started in the background
|
|
||||||
Bundle extras = getIntent().getExtras();
|
|
||||||
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
|
|
||||||
moveTaskToBack(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set by <content src="index.html" /> in config.xml
|
// Set by <content src="index.html" /> in config.xml
|
||||||
loadUrl(launchUrl);
|
super.loadUrl(Config.getStartUrl());
|
||||||
|
//super.loadUrl("file:///android_asset/www/index.html")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
|
||||||
|
package="__PACKAGE__" android:versionName="1.0" android:versionCode="1" android:hardwareAccelerated="true">
|
||||||
|
<supports-screens
|
||||||
|
android:largeScreens="true"
|
||||||
|
android:normalScreens="true"
|
||||||
|
android:smallScreens="true"
|
||||||
|
android:xlargeScreens="true"
|
||||||
|
android:resizeable="true"
|
||||||
|
android:anyDensity="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
|
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
|
||||||
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
|
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||||
|
|
||||||
|
|
||||||
|
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
||||||
|
android:hardwareAccelerated="true"
|
||||||
|
android:debuggable="true">
|
||||||
|
<activity android:name="__ACTIVITY__" android:label="@string/app_name"
|
||||||
|
android:theme="@android:style/Theme.Black.NoTitleBar"
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="__APILEVEL__"/>
|
||||||
|
</manifest>
|
||||||
@@ -102,13 +102,13 @@ h1 {
|
|||||||
50% { opacity: 0.4; }
|
50% { opacity: 0.4; }
|
||||||
to { opacity: 1.0; }
|
to { opacity: 1.0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@-webkit-keyframes fade {
|
@-webkit-keyframes fade {
|
||||||
from { opacity: 1.0; }
|
from { opacity: 1.0; }
|
||||||
50% { opacity: 0.4; }
|
50% { opacity: 0.4; }
|
||||||
to { opacity: 1.0; }
|
to { opacity: 1.0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.blink {
|
.blink {
|
||||||
animation:fade 3000ms infinite;
|
animation:fade 3000ms infinite;
|
||||||
-webkit-animation:fade 3000ms infinite;
|
-webkit-animation:fade 3000ms infinite;
|
||||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
@@ -19,20 +19,10 @@
|
|||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!--
|
<meta charset="utf-8" />
|
||||||
Customize this policy to fit your own app's needs. For more guidance, see:
|
<meta name="format-detection" content="telephone=no" />
|
||||||
https://cordova.apache.org/docs/en/latest/
|
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
|
||||||
Some notes:
|
<link rel="stylesheet" type="text/css" href="css/index.css" />
|
||||||
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
|
|
||||||
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
|
|
||||||
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
|
|
||||||
* Enable inline JS: add 'unsafe-inline' to default-src
|
|
||||||
-->
|
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
|
|
||||||
<meta name="format-detection" content="telephone=no">
|
|
||||||
<meta name="msapplication-tap-highlight" content="no">
|
|
||||||
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
|
||||||
<link rel="stylesheet" type="text/css" href="css/index.css">
|
|
||||||
<title>Hello World</title>
|
<title>Hello World</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -45,5 +35,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="cordova.js"></script>
|
<script type="text/javascript" src="cordova.js"></script>
|
||||||
<script type="text/javascript" src="js/index.js"></script>
|
<script type="text/javascript" src="js/index.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
app.initialize();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -18,25 +18,25 @@
|
|||||||
*/
|
*/
|
||||||
var app = {
|
var app = {
|
||||||
// Application Constructor
|
// Application Constructor
|
||||||
initialize: function () {
|
initialize: function() {
|
||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
},
|
},
|
||||||
// Bind Event Listeners
|
// Bind Event Listeners
|
||||||
//
|
//
|
||||||
// Bind any events that are required on startup. Common events are:
|
// Bind any events that are required on startup. Common events are:
|
||||||
// 'load', 'deviceready', 'offline', and 'online'.
|
// 'load', 'deviceready', 'offline', and 'online'.
|
||||||
bindEvents: function () {
|
bindEvents: function() {
|
||||||
document.addEventListener('deviceready', this.onDeviceReady, false);
|
document.addEventListener('deviceready', this.onDeviceReady, false);
|
||||||
},
|
},
|
||||||
// deviceready Event Handler
|
// deviceready Event Handler
|
||||||
//
|
//
|
||||||
// The scope of 'this' is the event. In order to call the 'receivedEvent'
|
// The scope of 'this' is the event. In order to call the 'receivedEvent'
|
||||||
// function, we must explicitly call 'app.receivedEvent(...);'
|
// function, we must explicity call 'app.receivedEvent(...);'
|
||||||
onDeviceReady: function () {
|
onDeviceReady: function() {
|
||||||
app.receivedEvent('deviceready');
|
app.receivedEvent('deviceready');
|
||||||
},
|
},
|
||||||
// Update DOM on a Received Event
|
// Update DOM on a Received Event
|
||||||
receivedEvent: function (id) {
|
receivedEvent: function(id) {
|
||||||
var parentElement = document.getElementById(id);
|
var parentElement = document.getElementById(id);
|
||||||
var listeningElement = parentElement.querySelector('.listening');
|
var listeningElement = parentElement.querySelector('.listening');
|
||||||
var receivedElement = parentElement.querySelector('.received');
|
var receivedElement = parentElement.querySelector('.received');
|
||||||
@@ -47,5 +47,3 @@ var app = {
|
|||||||
console.log('Received Event: ' + id);
|
console.log('Received Event: ' + id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
app.initialize();
|
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var deviceInfo = function() {
|
||||||
|
document.getElementById("platform").innerHTML = device.platform;
|
||||||
|
document.getElementById("version").innerHTML = device.version;
|
||||||
|
document.getElementById("uuid").innerHTML = device.uuid;
|
||||||
|
document.getElementById("name").innerHTML = device.name;
|
||||||
|
document.getElementById("width").innerHTML = screen.width;
|
||||||
|
document.getElementById("height").innerHTML = screen.height;
|
||||||
|
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||||
|
};
|
||||||
|
|
||||||
|
var getLocation = function() {
|
||||||
|
var suc = function(p) {
|
||||||
|
alert(p.coords.latitude + " " + p.coords.longitude);
|
||||||
|
};
|
||||||
|
var locFail = function() {
|
||||||
|
};
|
||||||
|
navigator.geolocation.getCurrentPosition(suc, locFail);
|
||||||
|
};
|
||||||
|
|
||||||
|
var beep = function() {
|
||||||
|
navigator.notification.beep(2);
|
||||||
|
};
|
||||||
|
|
||||||
|
var vibrate = function() {
|
||||||
|
navigator.notification.vibrate(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
function roundNumber(num) {
|
||||||
|
var dec = 3;
|
||||||
|
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
var accelerationWatch = null;
|
||||||
|
|
||||||
|
function updateAcceleration(a) {
|
||||||
|
document.getElementById('x').innerHTML = roundNumber(a.x);
|
||||||
|
document.getElementById('y').innerHTML = roundNumber(a.y);
|
||||||
|
document.getElementById('z').innerHTML = roundNumber(a.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
var toggleAccel = function() {
|
||||||
|
if (accelerationWatch !== null) {
|
||||||
|
navigator.accelerometer.clearWatch(accelerationWatch);
|
||||||
|
updateAcceleration({
|
||||||
|
x : "",
|
||||||
|
y : "",
|
||||||
|
z : ""
|
||||||
|
});
|
||||||
|
accelerationWatch = null;
|
||||||
|
} else {
|
||||||
|
var options = {};
|
||||||
|
options.frequency = 1000;
|
||||||
|
accelerationWatch = navigator.accelerometer.watchAcceleration(
|
||||||
|
updateAcceleration, function(ex) {
|
||||||
|
alert("accel fail (" + ex.name + ": " + ex.message + ")");
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var preventBehavior = function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
};
|
||||||
|
|
||||||
|
function dump_pic(data) {
|
||||||
|
var viewport = document.getElementById('viewport');
|
||||||
|
console.log(data);
|
||||||
|
viewport.style.display = "";
|
||||||
|
viewport.style.position = "absolute";
|
||||||
|
viewport.style.top = "10px";
|
||||||
|
viewport.style.left = "10px";
|
||||||
|
document.getElementById("test_img").src = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fail(msg) {
|
||||||
|
alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_pic() {
|
||||||
|
navigator.camera.getPicture(dump_pic, fail, {
|
||||||
|
quality : 50
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
var viewport = document.getElementById('viewport');
|
||||||
|
viewport.style.position = "relative";
|
||||||
|
viewport.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function contacts_success(contacts) {
|
||||||
|
alert(contacts.length
|
||||||
|
+ ' contacts returned.'
|
||||||
|
+ (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted)
|
||||||
|
: ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_contacts() {
|
||||||
|
var obj = new ContactFindOptions();
|
||||||
|
obj.filter = "";
|
||||||
|
obj.multiple = true;
|
||||||
|
navigator.contacts.find(
|
||||||
|
[ "displayName", "name" ], contacts_success,
|
||||||
|
fail, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_network() {
|
||||||
|
var networkState = navigator.network.connection.type;
|
||||||
|
|
||||||
|
var states = {};
|
||||||
|
states[Connection.UNKNOWN] = 'Unknown connection';
|
||||||
|
states[Connection.ETHERNET] = 'Ethernet connection';
|
||||||
|
states[Connection.WIFI] = 'WiFi connection';
|
||||||
|
states[Connection.CELL_2G] = 'Cell 2G connection';
|
||||||
|
states[Connection.CELL_3G] = 'Cell 3G connection';
|
||||||
|
states[Connection.CELL_4G] = 'Cell 4G connection';
|
||||||
|
states[Connection.NONE] = 'No network connection';
|
||||||
|
|
||||||
|
confirm('Connection type:\n ' + states[networkState]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var watchID = null;
|
||||||
|
|
||||||
|
function updateHeading(h) {
|
||||||
|
document.getElementById('h').innerHTML = h.magneticHeading;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCompass() {
|
||||||
|
if (watchID !== null) {
|
||||||
|
navigator.compass.clearWatch(watchID);
|
||||||
|
watchID = null;
|
||||||
|
updateHeading({ magneticHeading : "Off"});
|
||||||
|
} else {
|
||||||
|
var options = { frequency: 1000 };
|
||||||
|
watchID = navigator.compass.watchHeading(updateHeading, function(e) {
|
||||||
|
alert('Compass Error: ' + e.code);
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
// the next line makes it impossible to see Contacts on the HTC Evo since it
|
||||||
|
// doesn't have a scroll button
|
||||||
|
// document.addEventListener("touchmove", preventBehavior, false);
|
||||||
|
document.addEventListener("deviceready", deviceInfo, true);
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
body {
|
||||||
|
background:#222 none repeat scroll 0 0;
|
||||||
|
color:#666;
|
||||||
|
font-family:Helvetica;
|
||||||
|
font-size:72%;
|
||||||
|
line-height:1.5em;
|
||||||
|
margin:0;
|
||||||
|
border-top:1px solid #393939;
|
||||||
|
}
|
||||||
|
|
||||||
|
#info{
|
||||||
|
background:#ffa;
|
||||||
|
border: 1px solid #ffd324;
|
||||||
|
-webkit-border-radius: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
clear:both;
|
||||||
|
margin:15px 6px 0;
|
||||||
|
width:295px;
|
||||||
|
padding:4px 0px 2px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#info > h4{
|
||||||
|
font-size:.95em;
|
||||||
|
margin:5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#stage.theme{
|
||||||
|
padding-top:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Definition List */
|
||||||
|
#stage.theme > dl{
|
||||||
|
padding-top:10px;
|
||||||
|
clear:both;
|
||||||
|
margin:0;
|
||||||
|
list-style-type:none;
|
||||||
|
padding-left:10px;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#stage.theme > dl > dt{
|
||||||
|
font-weight:bold;
|
||||||
|
float:left;
|
||||||
|
margin-left:5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#stage.theme > dl > dd{
|
||||||
|
width:45px;
|
||||||
|
float:left;
|
||||||
|
color:#a87;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Content Styling */
|
||||||
|
#stage.theme > h1, #stage.theme > h2, #stage.theme > p{
|
||||||
|
margin:1em 0 .5em 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#stage.theme > h1{
|
||||||
|
color:#eee;
|
||||||
|
font-size:1.6em;
|
||||||
|
text-align:center;
|
||||||
|
margin:0;
|
||||||
|
margin-top:15px;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#stage.theme > h2{
|
||||||
|
clear:both;
|
||||||
|
margin:0;
|
||||||
|
padding:3px;
|
||||||
|
font-size:1em;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stage Buttons */
|
||||||
|
#stage.theme a.btn{
|
||||||
|
border: 1px solid #555;
|
||||||
|
-webkit-border-radius: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
text-align:center;
|
||||||
|
display:block;
|
||||||
|
float:left;
|
||||||
|
background:#444;
|
||||||
|
width:150px;
|
||||||
|
color:#9ab;
|
||||||
|
font-size:1.1em;
|
||||||
|
text-decoration:none;
|
||||||
|
padding:1.2em 0;
|
||||||
|
margin:3px 0px 3px 5px;
|
||||||
|
}
|
||||||
|
#stage.theme a.btn.large{
|
||||||
|
width:308px;
|
||||||
|
padding:1.2em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
@@ -0,0 +1,152 @@
|
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
|
||||||
|
var build_path = __dirname + '/../..',
|
||||||
|
project_path = '/tmp/example',
|
||||||
|
package_name = 'org.apache.cordova.example',
|
||||||
|
package_as_path = 'org/apache/cordova/example',
|
||||||
|
project_name = 'cordovaExample';
|
||||||
|
|
||||||
|
var path = require('path'),
|
||||||
|
fs = require('fs'),
|
||||||
|
util = require('util'),
|
||||||
|
assert = require('assert'),
|
||||||
|
spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
var version = fs.readFileSync(build_path + '/VERSION').toString().replace('\n', '');
|
||||||
|
|
||||||
|
assert(version !== undefined);
|
||||||
|
assert(version !== '');
|
||||||
|
|
||||||
|
var create_project = spawn(build_path + '/bin/create',
|
||||||
|
[project_path,
|
||||||
|
package_name,
|
||||||
|
project_name]);
|
||||||
|
|
||||||
|
process.on('uncaughtException', function (err) {
|
||||||
|
console.log('Caught exception: ' + err);
|
||||||
|
spawn('rm', ['-rf', project_path], function(code) {
|
||||||
|
if(code != 0) {
|
||||||
|
console.log("Could not delete project directory");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
create_project.on('exit', function(code) {
|
||||||
|
|
||||||
|
assert.equal(code, 0, 'Project did not get created');
|
||||||
|
|
||||||
|
// make sure the project was created
|
||||||
|
path.exists(project_path, function(exists) {
|
||||||
|
assert(exists, 'Project path does not exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure the build directory was cleaned up
|
||||||
|
// path.exists(build_path + '/framework/libs', function(exists) {
|
||||||
|
// assert(!exists, 'libs directory did not get cleaned up');
|
||||||
|
// });
|
||||||
|
path.exists(build_path + util.format('/framework/assets/cordova-%s.js', version), function(exists) {
|
||||||
|
assert(!exists, 'javascript file did not get cleaned up');
|
||||||
|
});
|
||||||
|
path.exists(build_path + util.format('/framework/cordova-%s.jar', version), function(exists) {
|
||||||
|
assert(!exists, 'jar file did not get cleaned up');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure AndroidManifest.xml was added
|
||||||
|
path.exists(util.format('%s/AndroidManifest.xml', project_path), function(exists) {
|
||||||
|
assert(exists, 'AndroidManifest.xml did not get created');
|
||||||
|
// TODO check that the activity name was properly substituted
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure main Activity was added
|
||||||
|
path.exists(util.format('%s/src/%s/%s.java', project_path, package_as_path, project_name), function(exists) {
|
||||||
|
assert(exists, 'Activity did not get created');
|
||||||
|
// TODO check that package name and activity name were substituted properly
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure plugins.xml was added
|
||||||
|
path.exists(util.format('%s/res/xml/plugins.xml', project_path), function(exists) {
|
||||||
|
assert(exists, 'plugins.xml did not get created');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure cordova.xml was added
|
||||||
|
path.exists(util.format('%s/res/xml/cordova.xml', project_path), function(exists) {
|
||||||
|
assert(exists, 'plugins.xml did not get created');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure cordova.jar was added
|
||||||
|
path.exists(util.format('%s/libs/cordova-%s.jar', project_path, version), function(exists) {
|
||||||
|
assert(exists, 'cordova.jar did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure cordova.js was added
|
||||||
|
path.exists(util.format('%s/assets/www/cordova-%s.js', project_path, version), function(exists) {
|
||||||
|
assert(exists, 'cordova.js did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure cordova master script was added
|
||||||
|
path.exists(util.format('%s/cordova/cordova', project_path), function(exists) {
|
||||||
|
assert(exists, 'cordova script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure debug script was added
|
||||||
|
path.exists(util.format('%s/cordova/debug', project_path), function(exists) {
|
||||||
|
assert(exists, 'debug script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure BOOM script was added
|
||||||
|
path.exists(util.format('%s/cordova/BOOM', project_path), function(exists) {
|
||||||
|
assert(exists, 'BOOM script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure log script was added
|
||||||
|
path.exists(util.format('%s/cordova/log', project_path), function(exists) {
|
||||||
|
assert(exists, 'log script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure clean script was added
|
||||||
|
path.exists(util.format('%s/cordova/clean', project_path), function(exists) {
|
||||||
|
assert(exists, 'clean script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure emulate script was added
|
||||||
|
path.exists(util.format('%s/cordova/emulate', project_path), function(exists) {
|
||||||
|
assert(exists, 'emulate script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure appinfo.jar script was added
|
||||||
|
path.exists(util.format('%s/cordova/appinfo.jar', project_path), function(exists) {
|
||||||
|
assert(exists, 'appinfo.jar script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// check that project compiles && creates a cordovaExample-debug.apk
|
||||||
|
var compile_project = spawn('ant', ['debug'], {cwd: project_path});
|
||||||
|
|
||||||
|
compile_project.on('exit', function(code) {
|
||||||
|
assert.equal(code, 0, 'Cordova Android Project does not compile');
|
||||||
|
// make sure cordovaExample-debug.apk was created
|
||||||
|
path.exists(util.format('%s/bin/%s-debug.apk', project_path, project_name), function(exists) {
|
||||||
|
assert(exists, 'Package did not get created');
|
||||||
|
|
||||||
|
// if project compiles properly just AXE it
|
||||||
|
spawn('rm', ['-rf', project_path], function(code) {
|
||||||
|
assert.equal(code, 0, 'Could not remove project directory');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
|
||||||
|
var build_path = __dirname + '/../..'
|
||||||
|
project_path = process.env.Temp + '\\example',
|
||||||
|
package_name = 'org.apache.cordova.example',
|
||||||
|
package_as_path = 'org/apache/cordova/example',
|
||||||
|
project_name = 'cordovaExample';
|
||||||
|
|
||||||
|
var path = require('path'),
|
||||||
|
fs = require('fs'),
|
||||||
|
util = require('util'),
|
||||||
|
assert = require('assert'),
|
||||||
|
exec = require('child_process').exec,
|
||||||
|
spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
var version = fs.readFileSync(build_path + '/VERSION').toString().replace('\r\n', '');
|
||||||
|
|
||||||
|
assert(version !== undefined);
|
||||||
|
assert(version !== '');
|
||||||
|
|
||||||
|
process.on('uncaughtException', function (err) {
|
||||||
|
console.log('Caught exception: ' + err);
|
||||||
|
exec('rd /s /q ' + project_path);
|
||||||
|
});
|
||||||
|
|
||||||
|
var create_project = spawn('cscript',
|
||||||
|
[build_path + '/bin/create.js',
|
||||||
|
project_path,
|
||||||
|
package_name,
|
||||||
|
project_name]
|
||||||
|
);
|
||||||
|
|
||||||
|
create_project.stderr.on('data', function (data) {
|
||||||
|
console.log('ps stderr: ' + data);
|
||||||
|
});
|
||||||
|
|
||||||
|
create_project.stderr.on('data', function(data) {
|
||||||
|
console.log(data.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
create_project.stdout.on('data', function(data) {
|
||||||
|
console.log(data.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
create_project.on('exit', function(code) {
|
||||||
|
assert.equal(code, 0, 'Project did not get created');
|
||||||
|
|
||||||
|
// make sure the project was created
|
||||||
|
path.exists(project_path, function(exists) {
|
||||||
|
assert(exists, 'Project path does not exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure the build directory was cleaned up
|
||||||
|
// path.exists(build_path + '/framework/libs', function(exists) {
|
||||||
|
// assert(!exists, 'libs directory did not get cleaned up');
|
||||||
|
// });
|
||||||
|
path.exists(build_path + util.format('/framework/assets/cordova-%s.js', version), function(exists) {
|
||||||
|
assert(!exists, 'javascript file did not get cleaned up');
|
||||||
|
});
|
||||||
|
path.exists(build_path + util.format('/framework/cordova-%s.jar', version), function(exists) {
|
||||||
|
assert(!exists, 'jar file did not get cleaned up');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure AndroidManifest.xml was added
|
||||||
|
path.exists(util.format('%s/AndroidManifest.xml', project_path), function(exists) {
|
||||||
|
assert(exists, 'AndroidManifest.xml did not get created');
|
||||||
|
// TODO check that the activity name was properly substituted
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure main Activity was added
|
||||||
|
path.exists(util.format('%s/src/%s/%s.java', project_path, package_as_path, project_name), function(exists) {
|
||||||
|
assert(exists, 'Activity did not get created');
|
||||||
|
// TODO check that package name and activity name were substituted properly
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure config.xml was added
|
||||||
|
path.exists(util.format('%s/res/xml/config.xml', project_path), function(exists) {
|
||||||
|
assert(exists, 'config.xml did not get created');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure cordova.jar was added
|
||||||
|
path.exists(util.format('%s/libs/cordova-%s.jar', project_path, version), function(exists) {
|
||||||
|
assert(exists, 'cordova.jar did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure cordova.js was added
|
||||||
|
path.exists(util.format('%s/assets/www/cordova-%s.js', project_path, version), function(exists) {
|
||||||
|
assert(exists, 'cordova.js did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure cordova master script was added
|
||||||
|
path.exists(util.format('%s/cordova/cordova.bat', project_path), function(exists) {
|
||||||
|
assert(exists, 'cordova script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure debug script was added
|
||||||
|
path.exists(util.format('%s/cordova/debug.bat', project_path), function(exists) {
|
||||||
|
assert(exists, 'debug script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure BOOM script was added
|
||||||
|
path.exists(util.format('%s/cordova/BOOM.bat', project_path), function(exists) {
|
||||||
|
assert(exists, 'BOOM script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure log script was added
|
||||||
|
path.exists(util.format('%s/cordova/log.bat', project_path), function(exists) {
|
||||||
|
assert(exists, 'log script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure clean script was added
|
||||||
|
path.exists(util.format('%s/cordova/clean.bat', project_path), function(exists) {
|
||||||
|
assert(exists, 'clean script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure emulate script was added
|
||||||
|
path.exists(util.format('%s/cordova/emulate.bat', project_path), function(exists) {
|
||||||
|
assert(exists, 'emulate script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// make sure appinfo.jar script was added
|
||||||
|
path.exists(util.format('%s/cordova/appinfo.jar', project_path), function(exists) {
|
||||||
|
assert(exists, 'appinfo.jar script did not get added');
|
||||||
|
});
|
||||||
|
|
||||||
|
// check that project compiles && creates a cordovaExample-debug.apk
|
||||||
|
// XXX: !@##!@# WINDOWS
|
||||||
|
exec('ant debug -f ' + project_path + "\\build.xml", function(error, stdout, stderr) {
|
||||||
|
assert(error == null, "Cordova Android Project does not compile");
|
||||||
|
path.exists(util.format('%s/bin/%s-debug.apk', project_path, project_name),
|
||||||
|
function(exists) {
|
||||||
|
assert(exists, 'Package did not get created');
|
||||||
|
// if project compiles properly just AXE it
|
||||||
|
exec('rd /s /q ' + project_path);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# update a cordova/android project's command line tools
|
||||||
|
#
|
||||||
|
# USAGE
|
||||||
|
# ./update [path]
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$1" ] || [ "$1" == "-h" ]
|
||||||
|
then
|
||||||
|
echo 'usage: update path'
|
||||||
|
echo "Make sure the Android SDK tools folder is in your PATH!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_PATH="$( cd "$( dirname "$0" )/.." && pwd )"
|
||||||
|
VERSION=$(cat "$BUILD_PATH"/VERSION)
|
||||||
|
|
||||||
|
PROJECT_PATH="${1:-'./example'}"
|
||||||
|
|
||||||
|
if [ ! -d "$PROJECT_PATH" ]
|
||||||
|
then
|
||||||
|
echo "The project path has to exist for it to be updated"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# cleanup after exit and/or on error
|
||||||
|
function on_exit {
|
||||||
|
if [ -f "$BUILD_PATH"/framework/cordova-$VERSION.jar ]
|
||||||
|
then
|
||||||
|
rm "$BUILD_PATH"/framework/cordova-$VERSION.jar
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAppInfoJar {
|
||||||
|
(cd "$BUILD_PATH"/bin/templates/cordova/ApplicationInfo &&
|
||||||
|
javac ApplicationInfo.java &&
|
||||||
|
jar -cfe ../appinfo.jar ApplicationInfo ApplicationInfo.class
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error {
|
||||||
|
echo "An unexpected error occurred: $previous_command exited with $?"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function replace {
|
||||||
|
local pattern=$1
|
||||||
|
local filename=$2
|
||||||
|
# Mac OS X requires -i argument
|
||||||
|
if [[ "$OSTYPE" =~ "darwin" ]]
|
||||||
|
then
|
||||||
|
/usr/bin/sed -i '' -e $pattern "$filename"
|
||||||
|
elif [[ "$OSTYPE" =~ "linux" ]]
|
||||||
|
then
|
||||||
|
/bin/sed -i -e $pattern "$filename"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# we do not want the script to silently fail
|
||||||
|
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
|
||||||
|
trap on_error ERR
|
||||||
|
trap on_exit EXIT
|
||||||
|
|
||||||
|
ANDROID_BIN="${ANDROID_BIN:=$( which android )}"
|
||||||
|
|
||||||
|
TARGET=$("$ANDROID_BIN" list targets | grep id: | tail -1 | cut -f 2 -d ' ' )
|
||||||
|
API_LEVEL=$("$ANDROID_BIN" list target | grep "API level:" | tail -n 1 | cut -f 2 -d ':' | tr -d ' ')
|
||||||
|
|
||||||
|
# check that build targets exist
|
||||||
|
if [ -z "$TARGET" ] || [ -z "$API_LEVEL" ]
|
||||||
|
then
|
||||||
|
echo "No Android Targets are installed. Please install at least one via the android SDK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if this a distribution release no need to build a jar
|
||||||
|
if [ ! -e "$BUILD_PATH"/cordova-$VERSION.jar ] && [ -d "$BUILD_PATH"/framework ]
|
||||||
|
then
|
||||||
|
# update the cordova-android framework for the desired target
|
||||||
|
"$ANDROID_BIN" update project --target $TARGET --path "$BUILD_PATH"/framework &> /dev/null
|
||||||
|
|
||||||
|
# compile cordova.js and cordova.jar
|
||||||
|
(cd "$BUILD_PATH"/framework && ant jar &> /dev/null )
|
||||||
|
fi
|
||||||
|
|
||||||
|
# copy cordova.js, cordova.jar and res/xml
|
||||||
|
if [ -d "$BUILD_PATH"/framework ]
|
||||||
|
then
|
||||||
|
cp "$BUILD_PATH"/framework/assets/www/cordova.js "$PROJECT_PATH"/assets/www/cordova.js
|
||||||
|
cp "$BUILD_PATH"/framework/cordova-$VERSION.jar "$PROJECT_PATH"/libs/cordova-$VERSION.jar
|
||||||
|
else
|
||||||
|
cp "$BUILD_PATH"/cordova.js "$PROJECT_PATH"/assets/www/cordova.js
|
||||||
|
cp "$BUILD_PATH"/cordova-$VERSION.jar "$PROJECT_PATH"/libs/cordova-$VERSION.jar
|
||||||
|
fi
|
||||||
|
|
||||||
|
# creating cordova folder and copying run/build/log/launch scripts
|
||||||
|
if [ ! -e "$PROJECT_PATH/cordova" ]
|
||||||
|
then
|
||||||
|
mkdir "$PROJECT_PATH"/cordova
|
||||||
|
mkdir "$PROJECT_PATH"/cordova/lib
|
||||||
|
fi
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/appinfo.jar "$PROJECT_PATH"/cordova/appinfo.jar
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/build "$PROJECT_PATH"/cordova/build
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/clean "$PROJECT_PATH"/cordova/clean
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/log "$PROJECT_PATH"/cordova/log
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/run "$PROJECT_PATH"/cordova/run
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/cordova.js "$PROJECT_PATH"/cordova/lib/cordova.js
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/install-device "$PROJECT_PATH"/cordova/lib/install-device
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/install-emulator "$PROJECT_PATH"/cordova/lib/install-emulator
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/list-devices "$PROJECT_PATH"/cordova/lib/list-devices
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/list-emulator-images "$PROJECT_PATH"/cordova/lib/list-emulator-images
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/list-started-emulators "$PROJECT_PATH"/cordova/lib/list-started-emulators
|
||||||
|
cp "$BUILD_PATH"/bin/templates/cordova/lib/start-emulator "$PROJECT_PATH"/cordova/lib/start-emulator
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
:: 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.
|
||||||
|
|
||||||
|
@ECHO OFF
|
||||||
|
IF NOT DEFINED JAVA_HOME GOTO MISSING
|
||||||
|
FOR %%X in (java.exe javac.exe ant.bat android.bat) do (
|
||||||
|
SET FOUND=%%~$PATH:X
|
||||||
|
IF NOT DEFINED FOUND GOTO MISSING
|
||||||
|
)
|
||||||
|
cscript "%~dp0\update.js" %*
|
||||||
|
GOTO END
|
||||||
|
:MISSING
|
||||||
|
ECHO Missing one of the following:
|
||||||
|
ECHO JDK: http://java.oracle.com
|
||||||
|
ECHO Android SDK: http://developer.android.com
|
||||||
|
ECHO Apache ant: http://ant.apache.org
|
||||||
|
EXIT /B 1
|
||||||
|
:END
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* create a cordova/android project
|
||||||
|
*
|
||||||
|
* USAGE
|
||||||
|
* ./update [path]
|
||||||
|
*/
|
||||||
|
|
||||||
|
var fso = WScript.CreateObject('Scripting.FileSystemObject');
|
||||||
|
|
||||||
|
function read(filename) {
|
||||||
|
var fso=WScript.CreateObject("Scripting.FileSystemObject");
|
||||||
|
var f=fso.OpenTextFile(filename, 1);
|
||||||
|
var s=f.ReadAll();
|
||||||
|
f.Close();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkTargets(targets) {
|
||||||
|
if(!targets) {
|
||||||
|
WScript.Echo("You do not have any android targets setup. Please create at least one target with the `android` command");
|
||||||
|
WScript.Quit(69);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTarget() {
|
||||||
|
var targets = shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s\d+/g);
|
||||||
|
checkTargets(targets);
|
||||||
|
return targets[targets.length - 1].replace(/id: /, ""); // TODO: give users the option to set their target
|
||||||
|
}
|
||||||
|
|
||||||
|
function setApiLevel() {
|
||||||
|
var targets = shell.Exec('android.bat list targets').StdOut.ReadAll().match(/API level:\s\d+/g);
|
||||||
|
checkTargets(targets);
|
||||||
|
return targets[targets.length - 1].replace(/API level: /, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function write(filename, contents) {
|
||||||
|
var fso=WScript.CreateObject("Scripting.FileSystemObject");
|
||||||
|
var f=fso.OpenTextFile(filename, 2, true);
|
||||||
|
f.Write(contents);
|
||||||
|
f.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceInFile(filename, regexp, replacement) {
|
||||||
|
write(filename, read(filename).replace(regexp, replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
function exec(command) {
|
||||||
|
var oShell=shell.Exec(command);
|
||||||
|
while (oShell.Status == 0) {
|
||||||
|
if(!oShell.StdOut.AtEndOfStream) {
|
||||||
|
var line = oShell.StdOut.ReadLine();
|
||||||
|
// XXX: Change to verbose mode
|
||||||
|
// WScript.StdOut.WriteLine(line);
|
||||||
|
}
|
||||||
|
WScript.sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAppInfoJar() {
|
||||||
|
if(!fso.FileExists(ROOT+"\\bin\\templates\\cordova\\appinfo.jar")) {
|
||||||
|
WScript.Echo("Creating appinfo.jar...");
|
||||||
|
var cur = shell.CurrentDirectory;
|
||||||
|
shell.CurrentDirectory = ROOT+"\\bin\\templates\\cordova\\ApplicationInfo";
|
||||||
|
exec("javac ApplicationInfo.java");
|
||||||
|
exec("jar -cfe ..\\appinfo.jar ApplicationInfo ApplicationInfo.class");
|
||||||
|
shell.CurrentDirectory = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
if(fso.FileExists(ROOT + '\\framework\\cordova-'+VERSION+'.jar')) {
|
||||||
|
fso.DeleteFile(ROOT + '\\framework\\cordova-'+VERSION+'.jar');
|
||||||
|
}
|
||||||
|
if(fso.FileExists(ROOT + '\\framework\\assets\\www\\cordova-'+VERSION+'.js')) {
|
||||||
|
fso.DeleteFile(ROOT + '\\framework\\assets\\www\\cordova-'+VERSION+'.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var args = WScript.Arguments, PROJECT_PATH="example",
|
||||||
|
shell=WScript.CreateObject("WScript.Shell");
|
||||||
|
|
||||||
|
// working dir
|
||||||
|
var ROOT = WScript.ScriptFullName.split('\\bin\\update.js').join('');
|
||||||
|
|
||||||
|
if (args.Count() == 1) {
|
||||||
|
PROJECT_PATH=args(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!fso.FolderExists(PROJECT_PATH)) {
|
||||||
|
WScript.Echo("Project doesn't exist!");
|
||||||
|
WScript.Quit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
var TARGET=setTarget();
|
||||||
|
var API_LEVEL=setApiLevel();
|
||||||
|
var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
|
||||||
|
|
||||||
|
// build from source. distro should have these files
|
||||||
|
if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
|
||||||
|
!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.js')) {
|
||||||
|
WScript.Echo("Building jar and js files...");
|
||||||
|
// update the cordova framework project to a target that exists on this machine
|
||||||
|
exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
|
||||||
|
exec('ant.bat -f \"'+ ROOT +'\\framework\\build.xml\" jar');
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if we have the source or the distro files
|
||||||
|
WScript.Echo("Copying js, jar & config.xml files...");
|
||||||
|
if(fso.FolderExists(ROOT + '\\framework')) {
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
|
||||||
|
} else {
|
||||||
|
// copy in cordova.js
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
|
||||||
|
// copy in cordova.jar
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
|
||||||
|
// copy in xml
|
||||||
|
}
|
||||||
|
|
||||||
|
// update cordova scripts
|
||||||
|
createAppInfoJar();
|
||||||
|
WScript.Echo("Copying cordova command tools...");
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\clean.bat ' + PROJECT_PATH + '\\cordova\\clean.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\build.bat ' + PROJECT_PATH + '\\cordova\\build.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\log.bat ' + PROJECT_PATH + '\\cordova\\log.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\run.bat ' + PROJECT_PATH + '\\cordova\\run.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\cordova.js ' + PROJECT_PATH + '\\cordova\\lib\\cordova.js /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\install-device.bat ' + PROJECT_PATH + '\\cordova\\lib\\install-device.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\install-emulator.bat ' + PROJECT_PATH + '\\cordova\\lib\\install-emulator.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\list-emulator-images.bat ' + PROJECT_PATH + '\\cordova\\lib\\list-emulator-images.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\list-devices.bat ' + PROJECT_PATH + '\\cordova\\lib\\list-devices.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\list-started-emulators.bat ' + PROJECT_PATH + '\\cordova\\lib\\list-started-emulators.bat /Y');
|
||||||
|
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\start-emulator.bat ' + PROJECT_PATH + '\\cordova\\lib\\start-emulator.bat /Y');
|
||||||
|
|
||||||
|
cleanup();
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a cordova command. It is up to the native side whether this action
|
|
||||||
* is synchronous or asynchronous. The native side can return:
|
|
||||||
* Synchronous: PluginResult object as a JSON string
|
|
||||||
* Asynchronous: Empty string ""
|
|
||||||
* If async, the native side will cordova.callbackSuccess or cordova.callbackError,
|
|
||||||
* depending upon the result of the action.
|
|
||||||
*
|
|
||||||
* @param {Function} success The success callback
|
|
||||||
* @param {Function} fail The fail callback
|
|
||||||
* @param {String} service The name of the service to use
|
|
||||||
* @param {String} action Action to be run in cordova
|
|
||||||
* @param {String[]} [args] Zero or more arguments to pass to the method
|
|
||||||
*/
|
|
||||||
var cordova = require('cordova');
|
|
||||||
var nativeApiProvider = require('cordova/android/nativeapiprovider');
|
|
||||||
var utils = require('cordova/utils');
|
|
||||||
var base64 = require('cordova/base64');
|
|
||||||
var channel = require('cordova/channel');
|
|
||||||
var jsToNativeModes = {
|
|
||||||
PROMPT: 0,
|
|
||||||
JS_OBJECT: 1
|
|
||||||
};
|
|
||||||
var nativeToJsModes = {
|
|
||||||
// Polls for messages using the JS->Native bridge.
|
|
||||||
POLLING: 0,
|
|
||||||
// For LOAD_URL to be viable, it would need to have a work-around for
|
|
||||||
// the bug where the soft-keyboard gets dismissed when a message is sent.
|
|
||||||
LOAD_URL: 1,
|
|
||||||
// For the ONLINE_EVENT to be viable, it would need to intercept all event
|
|
||||||
// listeners (both through addEventListener and window.ononline) as well
|
|
||||||
// as set the navigator property itself.
|
|
||||||
ONLINE_EVENT: 2,
|
|
||||||
EVAL_BRIDGE: 3
|
|
||||||
};
|
|
||||||
var jsToNativeBridgeMode; // Set lazily.
|
|
||||||
var nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE;
|
|
||||||
var pollEnabled = false;
|
|
||||||
var bridgeSecret = -1;
|
|
||||||
|
|
||||||
var messagesFromNative = [];
|
|
||||||
var isProcessing = false;
|
|
||||||
var resolvedPromise = typeof Promise === 'undefined' ? null : Promise.resolve();
|
|
||||||
var nextTick = resolvedPromise ? function (fn) { resolvedPromise.then(fn); } : function (fn) { setTimeout(fn); };
|
|
||||||
|
|
||||||
function androidExec (success, fail, service, action, args) {
|
|
||||||
if (bridgeSecret < 0) {
|
|
||||||
// If we ever catch this firing, we'll need to queue up exec()s
|
|
||||||
// and fire them once we get a secret. For now, I don't think
|
|
||||||
// it's possible for exec() to be called since plugins are parsed but
|
|
||||||
// not run until until after onNativeReady.
|
|
||||||
throw new Error('exec() called without bridgeSecret');
|
|
||||||
}
|
|
||||||
// Set default bridge modes if they have not already been set.
|
|
||||||
// By default, we use the failsafe, since addJavascriptInterface breaks too often
|
|
||||||
if (jsToNativeBridgeMode === undefined) {
|
|
||||||
androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If args is not provided, default to an empty array
|
|
||||||
args = args || [];
|
|
||||||
|
|
||||||
// Process any ArrayBuffers in the args into a string.
|
|
||||||
for (var i = 0; i < args.length; i++) {
|
|
||||||
if (utils.typeName(args[i]) === 'ArrayBuffer') {
|
|
||||||
args[i] = base64.fromArrayBuffer(args[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var callbackId = service + cordova.callbackId++;
|
|
||||||
var argsJson = JSON.stringify(args);
|
|
||||||
if (success || fail) {
|
|
||||||
cordova.callbacks[callbackId] = { success: success, fail: fail };
|
|
||||||
}
|
|
||||||
|
|
||||||
var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
|
|
||||||
// If argsJson was received by Java as null, try again with the PROMPT bridge mode.
|
|
||||||
// This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2. See CB-2666.
|
|
||||||
if (jsToNativeBridgeMode === jsToNativeModes.JS_OBJECT && msgs === '@Null arguments.') {
|
|
||||||
androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
|
|
||||||
androidExec(success, fail, service, action, args);
|
|
||||||
androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
|
|
||||||
} else if (msgs) {
|
|
||||||
messagesFromNative.push(msgs);
|
|
||||||
// Always process async to avoid exceptions messing up stack.
|
|
||||||
nextTick(processMessages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
androidExec.init = function () {
|
|
||||||
bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
|
|
||||||
channel.onNativeReady.fire();
|
|
||||||
};
|
|
||||||
|
|
||||||
function pollOnceFromOnlineEvent () {
|
|
||||||
pollOnce(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pollOnce (opt_fromOnlineEvent) {
|
|
||||||
if (bridgeSecret < 0) {
|
|
||||||
// This can happen when the NativeToJsMessageQueue resets the online state on page transitions.
|
|
||||||
// We know there's nothing to retrieve, so no need to poll.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var msgs = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent);
|
|
||||||
if (msgs) {
|
|
||||||
messagesFromNative.push(msgs);
|
|
||||||
// Process sync since we know we're already top-of-stack.
|
|
||||||
processMessages();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pollingTimerFunc () {
|
|
||||||
if (pollEnabled) {
|
|
||||||
pollOnce();
|
|
||||||
setTimeout(pollingTimerFunc, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function hookOnlineApis () {
|
|
||||||
function proxyEvent (e) {
|
|
||||||
cordova.fireWindowEvent(e.type);
|
|
||||||
}
|
|
||||||
// The network module takes care of firing online and offline events.
|
|
||||||
// It currently fires them only on document though, so we bridge them
|
|
||||||
// to window here (while first listening for exec()-releated online/offline
|
|
||||||
// events).
|
|
||||||
window.addEventListener('online', pollOnceFromOnlineEvent, false);
|
|
||||||
window.addEventListener('offline', pollOnceFromOnlineEvent, false);
|
|
||||||
cordova.addWindowEventHandler('online');
|
|
||||||
cordova.addWindowEventHandler('offline');
|
|
||||||
document.addEventListener('online', proxyEvent, false);
|
|
||||||
document.addEventListener('offline', proxyEvent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
hookOnlineApis();
|
|
||||||
|
|
||||||
androidExec.jsToNativeModes = jsToNativeModes;
|
|
||||||
androidExec.nativeToJsModes = nativeToJsModes;
|
|
||||||
|
|
||||||
androidExec.setJsToNativeBridgeMode = function (mode) {
|
|
||||||
if (mode === jsToNativeModes.JS_OBJECT && !window._cordovaNative) {
|
|
||||||
mode = jsToNativeModes.PROMPT;
|
|
||||||
}
|
|
||||||
nativeApiProvider.setPreferPrompt(mode === jsToNativeModes.PROMPT);
|
|
||||||
jsToNativeBridgeMode = mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
androidExec.setNativeToJsBridgeMode = function (mode) {
|
|
||||||
if (mode === nativeToJsBridgeMode) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (nativeToJsBridgeMode === nativeToJsModes.POLLING) {
|
|
||||||
pollEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nativeToJsBridgeMode = mode;
|
|
||||||
// Tell the native side to switch modes.
|
|
||||||
// Otherwise, it will be set by androidExec.init()
|
|
||||||
if (bridgeSecret >= 0) {
|
|
||||||
nativeApiProvider.get().setNativeToJsBridgeMode(bridgeSecret, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode === nativeToJsModes.POLLING) {
|
|
||||||
pollEnabled = true;
|
|
||||||
setTimeout(pollingTimerFunc, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function buildPayload (payload, message) {
|
|
||||||
var payloadKind = message.charAt(0);
|
|
||||||
if (payloadKind === 's') {
|
|
||||||
payload.push(message.slice(1));
|
|
||||||
} else if (payloadKind === 't') {
|
|
||||||
payload.push(true);
|
|
||||||
} else if (payloadKind === 'f') {
|
|
||||||
payload.push(false);
|
|
||||||
} else if (payloadKind === 'N') {
|
|
||||||
payload.push(null);
|
|
||||||
} else if (payloadKind === 'n') {
|
|
||||||
payload.push(+message.slice(1));
|
|
||||||
} else if (payloadKind === 'A') {
|
|
||||||
var data = message.slice(1);
|
|
||||||
payload.push(base64.toArrayBuffer(data));
|
|
||||||
} else if (payloadKind === 'S') {
|
|
||||||
payload.push(window.atob(message.slice(1)));
|
|
||||||
} else if (payloadKind === 'M') {
|
|
||||||
var multipartMessages = message.slice(1);
|
|
||||||
while (multipartMessages !== '') {
|
|
||||||
var spaceIdx = multipartMessages.indexOf(' ');
|
|
||||||
var msgLen = +multipartMessages.slice(0, spaceIdx);
|
|
||||||
var multipartMessage = multipartMessages.substr(spaceIdx + 1, msgLen);
|
|
||||||
multipartMessages = multipartMessages.slice(spaceIdx + msgLen + 1);
|
|
||||||
buildPayload(payload, multipartMessage);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
payload.push(JSON.parse(message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Processes a single message, as encoded by NativeToJsMessageQueue.java.
|
|
||||||
function processMessage (message) {
|
|
||||||
var firstChar = message.charAt(0);
|
|
||||||
if (firstChar === 'J') {
|
|
||||||
// This is deprecated on the .java side. It doesn't work with CSP enabled.
|
|
||||||
// eslint-disable-next-line no-eval
|
|
||||||
eval(message.slice(1));
|
|
||||||
} else if (firstChar === 'S' || firstChar === 'F') {
|
|
||||||
var success = firstChar === 'S';
|
|
||||||
var keepCallback = message.charAt(1) === '1';
|
|
||||||
var spaceIdx = message.indexOf(' ', 2);
|
|
||||||
var status = +message.slice(2, spaceIdx);
|
|
||||||
var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
|
|
||||||
var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
|
|
||||||
var payloadMessage = message.slice(nextSpaceIdx + 1);
|
|
||||||
var payload = [];
|
|
||||||
buildPayload(payload, payloadMessage);
|
|
||||||
cordova.callbackFromNative(callbackId, success, status, payload, keepCallback);
|
|
||||||
} else {
|
|
||||||
console.log('processMessage failed: invalid message: ' + JSON.stringify(message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function processMessages () {
|
|
||||||
// Check for the reentrant case.
|
|
||||||
if (isProcessing) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (messagesFromNative.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
isProcessing = true;
|
|
||||||
try {
|
|
||||||
var msg = popMessageFromQueue();
|
|
||||||
// The Java side can send a * message to indicate that it
|
|
||||||
// still has messages waiting to be retrieved.
|
|
||||||
if (msg === '*' && messagesFromNative.length === 0) {
|
|
||||||
nextTick(pollOnce);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
processMessage(msg);
|
|
||||||
} finally {
|
|
||||||
isProcessing = false;
|
|
||||||
if (messagesFromNative.length > 0) {
|
|
||||||
nextTick(processMessages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function popMessageFromQueue () {
|
|
||||||
var messageBatch = messagesFromNative.shift();
|
|
||||||
if (messageBatch === '*') {
|
|
||||||
return '*';
|
|
||||||
}
|
|
||||||
|
|
||||||
var spaceIdx = messageBatch.indexOf(' ');
|
|
||||||
var msgLen = +messageBatch.slice(0, spaceIdx);
|
|
||||||
var message = messageBatch.substr(spaceIdx + 1, msgLen);
|
|
||||||
messageBatch = messageBatch.slice(spaceIdx + msgLen + 1);
|
|
||||||
if (messageBatch) {
|
|
||||||
messagesFromNative.unshift(messageBatch);
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = androidExec;
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// The last resume event that was received that had the result of a plugin call.
|
|
||||||
var lastResumeEvent = null;
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
id: 'android',
|
|
||||||
bootstrap: function () {
|
|
||||||
var channel = require('cordova/channel');
|
|
||||||
var cordova = require('cordova');
|
|
||||||
var exec = require('cordova/exec');
|
|
||||||
var modulemapper = require('cordova/modulemapper');
|
|
||||||
|
|
||||||
// Get the shared secret needed to use the bridge.
|
|
||||||
exec.init();
|
|
||||||
|
|
||||||
// TODO: Extract this as a proper plugin.
|
|
||||||
modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
|
|
||||||
|
|
||||||
// Core Splash Screen
|
|
||||||
modulemapper.clobbers('cordova/plugin/android/splashscreen', 'navigator.splashscreen');
|
|
||||||
|
|
||||||
var APP_PLUGIN_NAME = Number(cordova.platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';
|
|
||||||
|
|
||||||
// Inject a listener for the backbutton on the document.
|
|
||||||
var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
|
|
||||||
backButtonChannel.onHasSubscribersChange = function () {
|
|
||||||
// If we just attached the first handler or detached the last handler,
|
|
||||||
// let native know we need to override the back button.
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'overrideBackbutton', [this.numHandlers === 1]);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add hardware MENU and SEARCH button handlers
|
|
||||||
cordova.addDocumentEventHandler('menubutton');
|
|
||||||
cordova.addDocumentEventHandler('searchbutton');
|
|
||||||
|
|
||||||
function bindButtonChannel (buttonName) {
|
|
||||||
// generic button bind used for volumeup/volumedown buttons
|
|
||||||
var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
|
|
||||||
volumeButtonChannel.onHasSubscribersChange = function () {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'overrideButton', [buttonName, this.numHandlers === 1]);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// Inject a listener for the volume buttons on the document.
|
|
||||||
bindButtonChannel('volumeup');
|
|
||||||
bindButtonChannel('volumedown');
|
|
||||||
|
|
||||||
// The resume event is not "sticky", but it is possible that the event
|
|
||||||
// will contain the result of a plugin call. We need to ensure that the
|
|
||||||
// plugin result is delivered even after the event is fired (CB-10498)
|
|
||||||
var cordovaAddEventListener = document.addEventListener;
|
|
||||||
|
|
||||||
document.addEventListener = function (evt, handler, capture) {
|
|
||||||
cordovaAddEventListener(evt, handler, capture);
|
|
||||||
|
|
||||||
if (evt === 'resume' && lastResumeEvent) {
|
|
||||||
handler(lastResumeEvent);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Let native code know we are all done on the JS side.
|
|
||||||
// Native code will then un-hide the WebView.
|
|
||||||
channel.onCordovaReady.subscribe(function () {
|
|
||||||
exec(onMessageFromNative, null, APP_PLUGIN_NAME, 'messageChannel', []);
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'show', []);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function onMessageFromNative (msg) {
|
|
||||||
var cordova = require('cordova');
|
|
||||||
var action = msg.action;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
// pause and resume are Android app life cycle events
|
|
||||||
case 'backbutton':
|
|
||||||
case 'menubutton':
|
|
||||||
case 'searchbutton':
|
|
||||||
case 'pause':
|
|
||||||
case 'volumedownbutton':
|
|
||||||
case 'volumeupbutton':
|
|
||||||
cordova.fireDocumentEvent(action);
|
|
||||||
break;
|
|
||||||
case 'resume':
|
|
||||||
if (arguments.length > 1 && msg.pendingResult) {
|
|
||||||
if (arguments.length === 2) {
|
|
||||||
msg.pendingResult.result = arguments[1];
|
|
||||||
} else {
|
|
||||||
// The plugin returned a multipart message
|
|
||||||
var res = [];
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
|
||||||
res.push(arguments[i]);
|
|
||||||
}
|
|
||||||
msg.pendingResult.result = res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the plugin result so that it can be delivered to the js
|
|
||||||
// even if they miss the initial firing of the event
|
|
||||||
lastResumeEvent = msg;
|
|
||||||
}
|
|
||||||
cordova.fireDocumentEvent(action, msg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error('Unknown event action ' + action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
var exec = require('cordova/exec');
|
|
||||||
var APP_PLUGIN_NAME = Number(require('cordova').platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
/**
|
|
||||||
* Clear the resource cache.
|
|
||||||
*/
|
|
||||||
clearCache: function () {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'clearCache', []);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the url into the WebView or into new browser instance.
|
|
||||||
*
|
|
||||||
* @param url The URL to load
|
|
||||||
* @param props Properties that can be passed in to the activity:
|
|
||||||
* wait: int => wait msec before loading URL
|
|
||||||
* loadingDialog: "Title,Message" => display a native loading dialog
|
|
||||||
* loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
|
|
||||||
* clearHistory: boolean => clear WebView history (default=false)
|
|
||||||
* openExternal: boolean => open in a new browser (default=false)
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
* navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
|
|
||||||
*/
|
|
||||||
loadUrl: function (url, props) {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'loadUrl', [url, props]);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancel loadUrl that is waiting to be loaded.
|
|
||||||
*/
|
|
||||||
cancelLoadUrl: function () {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'cancelLoadUrl', []);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear web history in this web view.
|
|
||||||
* Instead of BACK button loading the previous web page, it will exit the app.
|
|
||||||
*/
|
|
||||||
clearHistory: function () {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'clearHistory', []);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Go to previous page displayed.
|
|
||||||
* This is the same as pressing the backbutton on Android device.
|
|
||||||
*/
|
|
||||||
backHistory: function () {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'backHistory', []);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Override the default behavior of the Android back button.
|
|
||||||
* If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
|
|
||||||
*
|
|
||||||
* Note: The user should not have to call this method. Instead, when the user
|
|
||||||
* registers for the "backbutton" event, this is automatically done.
|
|
||||||
*
|
|
||||||
* @param override T=override, F=cancel override
|
|
||||||
*/
|
|
||||||
overrideBackbutton: function (override) {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'overrideBackbutton', [override]);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Override the default behavior of the Android volume button.
|
|
||||||
* If overridden, when the volume button is pressed, the "volume[up|down]button"
|
|
||||||
* JavaScript event will be fired.
|
|
||||||
*
|
|
||||||
* Note: The user should not have to call this method. Instead, when the user
|
|
||||||
* registers for the "volume[up|down]button" event, this is automatically done.
|
|
||||||
*
|
|
||||||
* @param button volumeup, volumedown
|
|
||||||
* @param override T=override, F=cancel override
|
|
||||||
*/
|
|
||||||
overrideButton: function (button, override) {
|
|
||||||
exec(null, null, APP_PLUGIN_NAME, 'overrideButton', [button, override]);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exit and terminate the application.
|
|
||||||
*/
|
|
||||||
exitApp: function () {
|
|
||||||
return exec(null, null, APP_PLUGIN_NAME, 'exitApp', []);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" path="gen"/>
|
||||||
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
|
</classpath>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Cordova</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
@@ -17,7 +17,47 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
-->
|
-->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
|
||||||
android:versionName="1.0"
|
package="org.apache.cordova" android:versionName="1.0" android:versionCode="1">
|
||||||
android:versionCode="1">
|
<supports-screens
|
||||||
|
android:largeScreens="true"
|
||||||
|
android:normalScreens="true"
|
||||||
|
android:smallScreens="true"
|
||||||
|
android:resizeable="true"
|
||||||
|
android:anyDensity="true"
|
||||||
|
/>
|
||||||
|
<!-- android:xlargeScreens="true" screen supported only after Android-9 -->
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
|
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
|
||||||
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
|
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
|
|
||||||
|
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
||||||
|
android:debuggable="true">
|
||||||
|
<activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name"
|
||||||
|
android:configChanges="orientation|keyboardHidden">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="7" />
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# This file is used to override default values used by the Ant build system.
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems, as it is
|
||||||
|
# integral to the build system of your project.
|
||||||
|
|
||||||
|
# This file is only used by the Ant script.
|
||||||
|
|
||||||
|
# You can use this to override default values such as
|
||||||
|
# 'source.dir' for the location of your java source folder and
|
||||||
|
# 'out.dir' for the location of your output folder.
|
||||||
|
|
||||||
|
# You can also use it define how the release builds are signed by declaring
|
||||||
|
# the following properties:
|
||||||
|
# 'key.store' for the location of your keystore and
|
||||||
|
# 'key.alias' for the name of the key to use.
|
||||||
|
# The password will be asked during the build when you use the 'release' target.
|
||||||
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
<resources>
|
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@@ -17,6 +16,12 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
-->
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<script src="cordova.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
<string name="app_name">UnitTests</string>
|
</body>
|
||||||
</resources>
|
</html>
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
/* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
apply from: 'cordova.gradle'
|
|
||||||
apply from: 'repositories.gradle'
|
|
||||||
|
|
||||||
repositories repos
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
// Android Gradle Plugin (AGP) Build Tools
|
|
||||||
classpath "com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}"
|
|
||||||
}
|
|
||||||
|
|
||||||
cdvHelpers.verifyCordovaConfigForBuild()
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
def hasRepositoriesGradle = file('repositories.gradle').exists()
|
|
||||||
if (hasRepositoriesGradle) {
|
|
||||||
apply from: 'repositories.gradle'
|
|
||||||
} else {
|
|
||||||
apply from: "${project.rootDir}/repositories.gradle"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories repos
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
|
||||||
|
|
||||||
android {
|
|
||||||
namespace 'org.apache.cordova'
|
|
||||||
|
|
||||||
compileSdkVersion cordovaConfig.COMPILE_SDK_VERSION
|
|
||||||
buildToolsVersion cordovaConfig.BUILD_TOOLS_VERSION
|
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaLanguageVersion.of(cordovaConfig.JAVA_SOURCE_COMPATIBILITY)
|
|
||||||
targetCompatibility JavaLanguageVersion.of(cordovaConfig.JAVA_TARGET_COMPATIBILITY)
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the Android Cordova Lib, we allow changing the minSdkVersion, but it is at the users own risk
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion cordovaConfig.MIN_SDK_VERSION
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
manifest.srcFile 'AndroidManifest.xml'
|
|
||||||
java.srcDirs = ['src']
|
|
||||||
resources.srcDirs = ['src']
|
|
||||||
aidl.srcDirs = ['src']
|
|
||||||
renderscript.srcDirs = ['src']
|
|
||||||
res.srcDirs = ['res']
|
|
||||||
assets.srcDirs = ['assets']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
packagingOptions {
|
|
||||||
exclude 'META-INF/LICENSE'
|
|
||||||
exclude 'META-INF/LICENSE.txt'
|
|
||||||
exclude 'META-INF/DEPENDENCIES'
|
|
||||||
exclude 'META-INF/NOTICE'
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
singleVariant('release') {
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api "androidx.appcompat:appcompat:${cordovaConfig.ANDROIDX_APP_COMPAT_VERSION}"
|
|
||||||
implementation "androidx.webkit:webkit:${cordovaConfig.ANDROIDX_WEBKIT_VERSION}"
|
|
||||||
implementation "androidx.core:core-splashscreen:${cordovaConfig.ANDROIDX_CORE_SPLASHSCREEN_VERSION}"
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* In a project created though CLI, the `cordova-publish.gradle` file is not copied to the `framework` dir.
|
|
||||||
* App development (CLI) projects can not and should not publish our framework.
|
|
||||||
* In this case, there is no need for the gradle build process to know about the publish process.
|
|
||||||
*/
|
|
||||||
def cordovaPublishGradle = './cordova-publish.gradle'
|
|
||||||
if(file(cordovaPublishGradle).exists()) {
|
|
||||||
apply from: cordovaPublishGradle
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<project name="Cordova" default="jar">
|
||||||
|
|
||||||
|
<!-- LOAD VERSION -->
|
||||||
|
<loadfile property="version" srcFile="../VERSION">
|
||||||
|
<filterchain>
|
||||||
|
<striplinebreaks/>
|
||||||
|
</filterchain>
|
||||||
|
</loadfile>
|
||||||
|
|
||||||
|
<!-- check that the version of ant is at least 1.8.0 -->
|
||||||
|
<antversion property="thisantversion" atleast="1.8.0" />
|
||||||
|
<fail message="The required minimum version of ant is 1.8.0, you have ${ant.version}"
|
||||||
|
unless="thisantversion" />
|
||||||
|
|
||||||
|
<!-- The local.properties file is created and updated by the 'android'
|
||||||
|
tool. (For example "sdkdir/tools/android update project -p ." inside
|
||||||
|
of this directory where the AndroidManifest.xml file exists. This
|
||||||
|
properties file that gets built contains the path to the SDK. It
|
||||||
|
should *NOT* be checked into Version Control Systems since it holds
|
||||||
|
data about the local machine. -->
|
||||||
|
<available file="local.properties" property="exists.local.properties" />
|
||||||
|
<fail message="You need to create the file 'local.properties' by running 'android update project -p .' here."
|
||||||
|
unless="exists.local.properties" />
|
||||||
|
<loadproperties srcFile="local.properties" />
|
||||||
|
|
||||||
|
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||||
|
'android' tool to add properties to it.
|
||||||
|
This is the place to change some Ant specific build properties.
|
||||||
|
Here are some properties you may want to change/update:
|
||||||
|
|
||||||
|
source.dir
|
||||||
|
The name of the source directory. Default is 'src'.
|
||||||
|
out.dir
|
||||||
|
The name of the output directory. Default is 'bin'.
|
||||||
|
|
||||||
|
For other overridable properties, look at the beginning of the rules
|
||||||
|
files in the SDK, at tools/ant/build.xml
|
||||||
|
|
||||||
|
Properties related to the SDK location or the project target should
|
||||||
|
be updated using the 'android' tool with the 'update' action.
|
||||||
|
This file is an integral part of the build system for your
|
||||||
|
application and should be checked into Version Control Systems.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<property file="ant.properties" />
|
||||||
|
|
||||||
|
<!-- The project.properties file is created and updated by the 'android'
|
||||||
|
tool, as well as ADT.
|
||||||
|
|
||||||
|
This contains project specific properties such as project target, and library
|
||||||
|
dependencies. Lower level build properties are stored in ant.properties
|
||||||
|
(or in .classpath for Eclipse projects).
|
||||||
|
|
||||||
|
This file is an integral part of the build system for your
|
||||||
|
application and should be checked into Version Control Systems. -->
|
||||||
|
<loadproperties srcFile="project.properties" />
|
||||||
|
|
||||||
|
<!-- quick check on sdk.dir -->
|
||||||
|
<fail
|
||||||
|
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
|
||||||
|
unless="sdk.dir"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- version-tag: custom -->
|
||||||
|
<!-- extension targets. Uncomment the ones where you want to do custom work
|
||||||
|
in between standard targets -->
|
||||||
|
<!--
|
||||||
|
<target name="-pre-build">
|
||||||
|
</target>
|
||||||
|
<target name="-pre-compile">
|
||||||
|
</target>
|
||||||
|
|
||||||
|
/* This is typically used for code obfuscation.
|
||||||
|
Compiled code location: ${out.classes.absolute.dir}
|
||||||
|
If this is not done in place, override ${out.dex.input.absolute.dir} */
|
||||||
|
<target name="-post-compile">
|
||||||
|
</target>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Import the actual build file.
|
||||||
|
|
||||||
|
To customize existing targets, there are two options:
|
||||||
|
- Customize only one target:
|
||||||
|
- copy/paste the target into this file, *before* the
|
||||||
|
<import> task.
|
||||||
|
- customize it to your needs.
|
||||||
|
- Customize the whole content of build.xml
|
||||||
|
- copy/paste the content of the rules files (minus the top node)
|
||||||
|
into this file, replacing the <import> task.
|
||||||
|
- customize to your needs.
|
||||||
|
|
||||||
|
***********************
|
||||||
|
****** IMPORTANT ******
|
||||||
|
***********************
|
||||||
|
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||||
|
in order to avoid having your file be overridden by tools such as "android update project"
|
||||||
|
-->
|
||||||
|
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||||
|
|
||||||
|
<!-- Build Cordova jar file that includes all native code, and Cordova JS file
|
||||||
|
that includes all JavaScript code.
|
||||||
|
-->
|
||||||
|
<target name="jar" depends="-compile">
|
||||||
|
<jar jarfile="cordova-${version}.jar" basedir="bin/classes" excludes="org/apache/cordova/R.class,org/apache/cordova/R$*.class"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- tests for Java files -->
|
||||||
|
<property name="test.dir" location="test/org/apache/cordova" />
|
||||||
|
|
||||||
|
<path id="test.classpath">
|
||||||
|
<!-- requires both junit and cordova -->
|
||||||
|
<pathelement location="libs/junit-4.10.jar" />
|
||||||
|
<pathelement location="cordova-${version}.jar" />
|
||||||
|
<pathelement location="${test.dir}" />
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<target name="compile-test">
|
||||||
|
<javac srcdir="${test.dir}" >
|
||||||
|
<classpath refid="test.classpath" />
|
||||||
|
</javac>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="test" depends="jar, compile-test">
|
||||||
|
<junit showoutput="true">
|
||||||
|
<classpath refid="test.classpath" />
|
||||||
|
<formatter type="brief" usefile="false" />
|
||||||
|
<batchtest fork="yes">
|
||||||
|
<fileset dir="${test.dir}">
|
||||||
|
<include name="*Test.java" />
|
||||||
|
<include name="**/*Test.java" />
|
||||||
|
</fileset>
|
||||||
|
</batchtest>
|
||||||
|
</junit>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="cordova_debug" depends="debug">
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="cordova_release" depends="release">
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"MIN_SDK_VERSION": 24,
|
|
||||||
"SDK_VERSION": 35,
|
|
||||||
"COMPILE_SDK_VERSION": null,
|
|
||||||
"GRADLE_VERSION": "8.13",
|
|
||||||
"MIN_BUILD_TOOLS_VERSION": "35.0.0",
|
|
||||||
"AGP_VERSION": "8.7.3",
|
|
||||||
"KOTLIN_VERSION": "1.9.24",
|
|
||||||
"ANDROIDX_APP_COMPAT_VERSION": "1.7.0",
|
|
||||||
"ANDROIDX_WEBKIT_VERSION": "1.12.1",
|
|
||||||
"ANDROIDX_CORE_SPLASHSCREEN_VERSION": "1.0.1",
|
|
||||||
"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.4.2",
|
|
||||||
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
|
|
||||||
"IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false,
|
|
||||||
"PACKAGE_NAMESPACE": "io.cordova.helloCordova",
|
|
||||||
"JAVA_SOURCE_COMPATIBILITY": 11,
|
|
||||||
"JAVA_TARGET_COMPATIBILITY": 11,
|
|
||||||
"KOTLIN_JVM_TARGET": null
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
apply plugin: 'signing'
|
|
||||||
|
|
||||||
String getCordovaAndroidVersion() {
|
|
||||||
// Fetch Data from Cordova-Android package.json (Used only by framework build/publishing)
|
|
||||||
def cordovaAndroidRepoPackageJson = "$projectDir/../package.json"
|
|
||||||
if(file(cordovaAndroidRepoPackageJson).exists()) {
|
|
||||||
def packageJsonFile = new File(cordovaAndroidRepoPackageJson)
|
|
||||||
def packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text)
|
|
||||||
return packageJson.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable signing by default when keyId and secretKeyRingFile is defined.
|
|
||||||
ext.cdvEnableSigning = project.hasProperty('signing.keyId') && project.hasProperty('signing.secretKeyRingFile')
|
|
||||||
if (cdvEnableSigning) {
|
|
||||||
logger.debug('[Cordova] Signing has been enabled by default because the signing keyId & secretKeyRingFile has been defined.')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (project.hasProperty('signEnabled')) {
|
|
||||||
if(!cdvEnableSigning && Boolean.valueOf(signEnabled)) {
|
|
||||||
logger.debug("[Cordova] The \"signEnabled\" override can not be set to \"true\" when the signing properties are missing.")
|
|
||||||
} else {
|
|
||||||
// Override the default setting with the "signEnabled" property. (In this case it should only accept false)
|
|
||||||
logger.debug("[Cordova] The \"signEnabled\" property has been detected and forcing enabled signing to \"$signEnabled\".")
|
|
||||||
cdvEnableSigning = signEnabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
groupId = 'org.apache.cordova'
|
|
||||||
artifactId = 'framework'
|
|
||||||
version = getCordovaAndroidVersion()
|
|
||||||
|
|
||||||
from components.release
|
|
||||||
|
|
||||||
pom {
|
|
||||||
name = 'Cordova'
|
|
||||||
description = 'A library to build Cordova-based projects for the Android platform.'
|
|
||||||
url = 'https://cordova.apache.org'
|
|
||||||
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name = 'Apache License, Version 2.0'
|
|
||||||
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id = 'stevengill'
|
|
||||||
name = 'Steve Gill'
|
|
||||||
}
|
|
||||||
developer {
|
|
||||||
id = 'erisu'
|
|
||||||
name = 'Bryan Ellis'
|
|
||||||
email = 'erisu@apache.org'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scm {
|
|
||||||
connection = 'scm:git:https://github.com/apache/cordova-android.git'
|
|
||||||
developerConnection = 'scm:git:git@github.com:apache/cordova-android.git'
|
|
||||||
url = 'https://github.com/apache/cordova-android'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
def releasesRepoUrl = 'https://repository.apache.org/content/repositories/releases'
|
|
||||||
def snapshotsRepoUrl = 'https://repository.apache.org/content/repositories/snapshots'
|
|
||||||
|
|
||||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
if (project.hasProperty('apacheUsername') && project.hasProperty('apachePassword')) {
|
|
||||||
username apacheUsername
|
|
||||||
password apachePassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signing {
|
|
||||||
if (Boolean.valueOf(cdvEnableSigning)) {
|
|
||||||
sign publishing.publications.mavenJava
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.whenTaskAdded {task ->
|
|
||||||
if(task.name.contains('sign')) {
|
|
||||||
logger.debug("[Cordova] The task \"${task.name}\" is enabled? ${cdvEnableSigning}")
|
|
||||||
task.enabled = cdvEnableSigning
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.regex.Pattern
|
|
||||||
import io.github.g00fy2.versioncompare.Version
|
|
||||||
|
|
||||||
String doEnsureValueExists(filePath, props, key) {
|
|
||||||
if (props.get(key) == null) {
|
|
||||||
throw new GradleException(filePath + ': Missing key required "' + key + '"')
|
|
||||||
}
|
|
||||||
return props.get(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
String doGetProjectTarget() {
|
|
||||||
def props = new Properties()
|
|
||||||
def propertiesFile = 'project.properties';
|
|
||||||
if(!(file(propertiesFile).exists())) {
|
|
||||||
propertiesFile = '../project.properties';
|
|
||||||
}
|
|
||||||
file(propertiesFile).withReader { reader ->
|
|
||||||
props.load(reader)
|
|
||||||
}
|
|
||||||
return doEnsureValueExists('project.properties', props, 'target')
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean isVersionValid(version) {
|
|
||||||
return !(new Version(version)).isEqual('0.0.0')
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean isVersionGreaterThanEqual(versionX, versionY) {
|
|
||||||
return (new Version(versionX)) >= (new Version(versionY))
|
|
||||||
}
|
|
||||||
|
|
||||||
String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) {
|
|
||||||
def buildToolsDirContents
|
|
||||||
try {
|
|
||||||
def buildToolsDir = new File(getAndroidSdkDir(), "build-tools")
|
|
||||||
buildToolsDirContents = buildToolsDir.list()
|
|
||||||
} catch (e) {
|
|
||||||
println "An exception occurred while trying to find the Android build tools."
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
|
|
||||||
def minBuildToolsVersion = new Version(minBuildToolsVersionString)
|
|
||||||
def maxVersion = new Version((minBuildToolsVersion.getMajor() + 1) + ".0.0")
|
|
||||||
|
|
||||||
def highestBuildToolsVersion = buildToolsDirContents
|
|
||||||
.collect { new Version(it) }
|
|
||||||
// Invalid inputs will be handled as 0.0.0
|
|
||||||
.findAll { it.isHigherThan('0.0.0') && it.isLowerThan(maxVersion) }
|
|
||||||
.max()
|
|
||||||
|
|
||||||
if (highestBuildToolsVersion == null) {
|
|
||||||
throw new RuntimeException("""
|
|
||||||
No installed build tools found. Please install the Android build tools
|
|
||||||
version ${minBuildToolsVersionString}.
|
|
||||||
""".replaceAll(/\s+/, ' ').trim())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (highestBuildToolsVersion.isLowerThan(minBuildToolsVersionString)) {
|
|
||||||
throw new RuntimeException("""
|
|
||||||
No usable Android build tools found. Highest ${minBuildToolsVersion.getMajor()}.x installed version is
|
|
||||||
${highestBuildToolsVersion.getOriginalString()}; Recommended version
|
|
||||||
is ${minBuildToolsVersionString}.
|
|
||||||
""".replaceAll(/\s+/, ' ').trim())
|
|
||||||
}
|
|
||||||
|
|
||||||
highestBuildToolsVersion.getOriginalString()
|
|
||||||
}
|
|
||||||
|
|
||||||
String getAndroidSdkDir() {
|
|
||||||
def rootDir = project.rootDir
|
|
||||||
def androidSdkDir = null
|
|
||||||
String envVar = System.getenv("ANDROID_HOME")
|
|
||||||
if (envVar == null) {
|
|
||||||
envVar = System.getenv("ANDROID_SDK_ROOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
def localProperties = new File(rootDir, 'local.properties')
|
|
||||||
String systemProperty = System.getProperty("android.home")
|
|
||||||
if (envVar != null) {
|
|
||||||
androidSdkDir = envVar
|
|
||||||
} else if (localProperties.exists()) {
|
|
||||||
Properties properties = new Properties()
|
|
||||||
localProperties.withInputStream { instr ->
|
|
||||||
properties.load(instr)
|
|
||||||
}
|
|
||||||
def sdkDirProp = properties.getProperty('sdk.dir')
|
|
||||||
if (sdkDirProp != null) {
|
|
||||||
androidSdkDir = sdkDirProp
|
|
||||||
} else {
|
|
||||||
sdkDirProp = properties.getProperty('android.dir')
|
|
||||||
if (sdkDirProp != null) {
|
|
||||||
androidSdkDir = (new File(rootDir, sdkDirProp)).getAbsolutePath()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (androidSdkDir == null && systemProperty != null) {
|
|
||||||
androidSdkDir = systemProperty
|
|
||||||
}
|
|
||||||
if (androidSdkDir == null) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Unable to determine Android SDK directory.")
|
|
||||||
}
|
|
||||||
androidSdkDir
|
|
||||||
}
|
|
||||||
|
|
||||||
def doExtractIntFromManifest(name) {
|
|
||||||
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
|
|
||||||
def pattern = Pattern.compile(name + "=\"(\\d+)\"")
|
|
||||||
def matcher = pattern.matcher(manifestFile.getText())
|
|
||||||
matcher.find()
|
|
||||||
return new BigInteger(matcher.group(1))
|
|
||||||
}
|
|
||||||
|
|
||||||
def doGetConfigXml() {
|
|
||||||
def xml = file("src/main/res/xml/config.xml").getText()
|
|
||||||
// Disable namespace awareness since Cordova doesn't use them properly
|
|
||||||
return new XmlParser(false, false).parseText(xml)
|
|
||||||
}
|
|
||||||
|
|
||||||
def doGetConfigPreference(name, defaultValue) {
|
|
||||||
name = name.toLowerCase()
|
|
||||||
def root = doGetConfigXml()
|
|
||||||
|
|
||||||
def ret = defaultValue
|
|
||||||
root.preference.each { it ->
|
|
||||||
def attrName = it.attribute("name")
|
|
||||||
if (attrName && attrName.toLowerCase() == name) {
|
|
||||||
ret = it.attribute("value")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
def doApplyCordovaConfigCustomization() {
|
|
||||||
// Apply user override properties that comes from the "--gradleArg=-P" parameters
|
|
||||||
if (project.hasProperty('cdvMinSdkVersion')) {
|
|
||||||
cordovaConfig.MIN_SDK_VERSION = Integer.parseInt('' + cdvMinSdkVersion)
|
|
||||||
}
|
|
||||||
if (project.hasProperty('cdvSdkVersion')) {
|
|
||||||
cordovaConfig.SDK_VERSION = Integer.parseInt('' + cdvSdkVersion)
|
|
||||||
}
|
|
||||||
if (project.hasProperty('cdvCompileSdkVersion')) {
|
|
||||||
cordovaConfig.COMPILE_SDK_VERSION = Integer.parseInt('' + cdvCompileSdkVersion)
|
|
||||||
}
|
|
||||||
if (project.hasProperty('cdvMaxSdkVersion')) {
|
|
||||||
cordovaConfig.MAX_SDK_VERSION = Integer.parseInt('' + cdvMaxSdkVersion)
|
|
||||||
}
|
|
||||||
if (project.hasProperty('cdvBuildToolsVersion')) {
|
|
||||||
cordovaConfig.BUILD_TOOLS_VERSION = cdvBuildToolsVersion
|
|
||||||
}
|
|
||||||
if (project.hasProperty('cdvAndroidXAppCompatVersion')) {
|
|
||||||
cordovaConfig.ANDROIDX_APP_COMPAT_VERSION = cdvAndroidXAppCompatVersion
|
|
||||||
}
|
|
||||||
if (project.hasProperty('cdvAndroidXWebKitVersion')) {
|
|
||||||
cordovaConfig.ANDROIDX_WEBKIT_VERSION = cdvAndroidXWebKitVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cordovaConfig.BUILD_TOOLS_VERSION) {
|
|
||||||
cordovaConfig.BUILD_TOOLS_VERSION = doFindLatestInstalledBuildTools(
|
|
||||||
cordovaConfig.MIN_BUILD_TOOLS_VERSION
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the configured build tools version is at least our declared minimum
|
|
||||||
def buildToolsVersion = new Version(cordovaConfig.BUILD_TOOLS_VERSION)
|
|
||||||
if (buildToolsVersion.isLowerThan(cordovaConfig.MIN_BUILD_TOOLS_VERSION)) {
|
|
||||||
throw new RuntimeException("""
|
|
||||||
Expected Android Build Tools version >= ${cordovaConfig.MIN_BUILD_TOOLS_VERSION},
|
|
||||||
but got Android Build Tools version ${cordovaConfig.BUILD_TOOLS_VERSION}. Please use version ${cordovaConfig.MIN_BUILD_TOOLS_VERSION} or later.
|
|
||||||
""".replaceAll(/\s+/, ' ').trim())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def doVerifyCordovaConfigForBuild() {
|
|
||||||
if (cordovaConfig.COMPILE_SDK_VERSION < cordovaConfig.SDK_VERSION) {
|
|
||||||
println "The \"compileSdkVersion\" (${cordovaConfig.COMPILE_SDK_VERSION}) should be greater than or equal to the the \"targetSdkVersion\" (${cordovaConfig.SDK_VERSION})."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Properties exported here are visible to all plugins.
|
|
||||||
ext {
|
|
||||||
def defaultsFilePath = './cdv-gradle-config-defaults.json'
|
|
||||||
def projectConfigFilePath = "$rootDir/cdv-gradle-config.json"
|
|
||||||
def targetConfigFilePath = null
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the project config file path exists. This file will exist if coming from CLI project.
|
|
||||||
* If this file does not exist, falls back onto the default file.
|
|
||||||
* This scenario can occur if building the framework's AAR package for publishing.
|
|
||||||
*/
|
|
||||||
if(file(projectConfigFilePath).exists()) {
|
|
||||||
targetConfigFilePath = projectConfigFilePath
|
|
||||||
} else {
|
|
||||||
targetConfigFilePath = defaultsFilePath
|
|
||||||
}
|
|
||||||
|
|
||||||
def jsonFile = new File(targetConfigFilePath)
|
|
||||||
cordovaConfig = new groovy.json.JsonSlurper().parseText(jsonFile.text)
|
|
||||||
|
|
||||||
if (cordovaConfig.COMPILE_SDK_VERSION == null) {
|
|
||||||
cordovaConfig.COMPILE_SDK_VERSION = cordovaConfig.SDK_VERSION
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply Gradle Properties
|
|
||||||
doApplyCordovaConfigCustomization()
|
|
||||||
|
|
||||||
// These helpers are shared, but are not guaranteed to be stable / unchanged.
|
|
||||||
privateHelpers = {}
|
|
||||||
privateHelpers.getProjectTarget = { doGetProjectTarget() }
|
|
||||||
privateHelpers.applyCordovaConfigCustomization = { doApplyCordovaConfigCustomization() }
|
|
||||||
privateHelpers.extractIntFromManifest = { name -> doExtractIntFromManifest(name) }
|
|
||||||
privateHelpers.ensureValueExists = { filePath, props, key -> doEnsureValueExists(filePath, props, key) }
|
|
||||||
|
|
||||||
// These helpers can be used by plugins / projects and will not change.
|
|
||||||
cdvHelpers = {}
|
|
||||||
// Returns a XmlParser for the config.xml. Added in 4.1.0.
|
|
||||||
cdvHelpers.getConfigXml = { doGetConfigXml() }
|
|
||||||
// Returns the value for the desired <preference>. Added in 4.1.0.
|
|
||||||
cdvHelpers.getConfigPreference = { name, defaultValue -> doGetConfigPreference(name, defaultValue) }
|
|
||||||
// Display warnings if any cordova config is not proper for build.
|
|
||||||
cdvHelpers.verifyCordovaConfigForBuild = { doVerifyCordovaConfigForBuild() }
|
|
||||||
}
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath 'io.github.g00fy2:versioncompare:1.4.1@jar'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# This file is automatically generated by Android Tools.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems.
|
||||||
|
#
|
||||||
|
# To customize properties used by the Ant build system use,
|
||||||
|
# "build.properties", and override values to adapt the script to your
|
||||||
|
# project structure.
|
||||||
|
|
||||||
|
# Indicates whether an apk should be generated for each density.
|
||||||
|
split.density=false
|
||||||
|
# Project target.
|
||||||
|
target=android-14
|
||||||
|
apk-configurations=
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
|
||||||
# to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance
|
|
||||||
# with the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing,
|
|
||||||
# software distributed under the License is distributed on an
|
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
# Project-wide Gradle settings.
|
|
||||||
|
|
||||||
# IDE (e.g. Android Studio) users:
|
|
||||||
# Gradle settings configured through the IDE *will override*
|
|
||||||
# any settings specified in this file.
|
|
||||||
|
|
||||||
# For more details on how to configure your build environment visit
|
|
||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
|
||||||
|
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
|
||||||
android.useAndroidX=true
|
|
||||||
android.enableJetifier=true
|
|
||||||
|
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
|
||||||
# org.gradle.parallel=true
|
|
||||||
@@ -1,29 +1,16 @@
|
|||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This file is automatically generated by Android Tools.
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
# 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
|
# This file must be checked in Version Control Systems.
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# To customize properties used by the Ant build system use,
|
||||||
# software distributed under the License is distributed on an
|
# "ant.properties", and override values to adapt the script to your
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# project structure.
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
# GENERATED FILE! DO NOT EDIT!
|
|
||||||
|
|
||||||
# This file was originally created by the Android Tools, but is now
|
|
||||||
# used by cordova-android to manage the project configuration.
|
|
||||||
|
|
||||||
# Indicates whether an apk should be generated for each density.
|
# Indicates whether an apk should be generated for each density.
|
||||||
split.density=false
|
split.density=false
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
|
target=Google Inc.:Google APIs:17
|
||||||
apk-configurations=
|
apk-configurations=
|
||||||
renderscript.opt.level=O0
|
renderscript.opt.level=O0
|
||||||
android.library=true
|
android.library=true
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
/* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ext.repos = {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 92 KiB |
@@ -1,4 +1,4 @@
|
|||||||
<resources>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@@ -17,13 +17,13 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
-->
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<!-- Base application theme. -->
|
android:orientation="vertical"
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
android:layout_width="fill_parent"
|
||||||
<!-- Customize your theme here. -->
|
android:layout_height="fill_parent"
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<WebView android:id="@+id/appView"
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
android:layout_height="fill_parent"
|
||||||
</style>
|
android:layout_width="fill_parent"
|
||||||
|
/>
|
||||||
</resources>
|
</LinearLayout>
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
under the License.
|
under the License.
|
||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#3F51B5</color>
|
<string name="app_name">Cordova</string>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<string name="go">Snap</string>
|
||||||
<color name="colorAccent">#FF4081</color>
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<widget xmlns = "http://www.w3.org/ns/widgets"
|
||||||
|
id = "io.cordova.helloCordova"
|
||||||
|
version = "2.0.0">
|
||||||
|
<name>Hello Cordova</name>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
A sample Apache Cordova application that responds to the deviceready event.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<author href="http://cordova.io" email="dev@cordova.apache.org">
|
||||||
|
Apache Cordova Team
|
||||||
|
</author>
|
||||||
|
|
||||||
|
<access origin="*"/>
|
||||||
|
|
||||||
|
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
|
||||||
|
<content src="index.html" />
|
||||||
|
|
||||||
|
<preference name="loglevel" value="DEBUG" />
|
||||||
|
<!--
|
||||||
|
<preference name="splashscreen" value="resourceName" />
|
||||||
|
<preference name="backgroundColor" value="0xFFF" />
|
||||||
|
<preference name="loadUrlTimeoutValue" value="20000" />
|
||||||
|
<preference name="InAppBrowserStorageEnabled" value="true" />
|
||||||
|
<preference name="disallowOverscroll" value="true" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<feature name="App">
|
||||||
|
<param name="android-package" value="org.apache.cordova.App"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Geolocation">
|
||||||
|
<param name="android-package" value="org.apache.cordova.GeoBroker"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Device">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Device"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Accelerometer">
|
||||||
|
<param name="android-package" value="org.apache.cordova.AccelListener"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Compass">
|
||||||
|
<param name="android-package" value="org.apache.cordova.CompassListener"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Media">
|
||||||
|
<param name="android-package" value="org.apache.cordova.AudioHandler"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Camera">
|
||||||
|
<param name="android-package" value="org.apache.cordova.CameraLauncher"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Contacts">
|
||||||
|
<param name="android-package" value="org.apache.cordova.ContactManager"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="File">
|
||||||
|
<param name="android-package" value="org.apache.cordova.FileUtils"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="NetworkStatus">
|
||||||
|
<param name="android-package" value="org.apache.cordova.NetworkManager"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Notification">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Notification"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Storage">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Storage"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="FileTransfer">
|
||||||
|
<param name="android-package" value="org.apache.cordova.FileTransfer"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Capture">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Capture"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Battery">
|
||||||
|
<param name="android-package" value="org.apache.cordova.BatteryListener"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="SplashScreen">
|
||||||
|
<param name="android-package" value="org.apache.cordova.SplashScreen"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Echo">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Echo"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="Globalization">
|
||||||
|
<param name="android-package" value="org.apache.cordova.Globalization"/>
|
||||||
|
</feature>
|
||||||
|
<feature name="InAppBrowser">
|
||||||
|
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
|
||||||
|
</feature>
|
||||||
|
<!-- Deprecated plugins element. Remove in 3.0 -->
|
||||||
|
<plugins>
|
||||||
|
</plugins>
|
||||||
|
</widget>
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.squareup.okhttp;
|
||||||
|
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import javax.net.ssl.HostnameVerifier;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
|
||||||
|
import static com.squareup.okhttp.internal.Util.equal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specification for a connection to an origin server. For simple connections,
|
||||||
|
* this is the server's hostname and port. If an explicit proxy is requested (or
|
||||||
|
* {@link Proxy#NO_PROXY no proxy} is explicitly requested), this also includes
|
||||||
|
* that proxy information. For secure connections the address also includes the
|
||||||
|
* SSL socket factory and hostname verifier.
|
||||||
|
*
|
||||||
|
* <p>HTTP requests that share the same {@code Address} may also share the same
|
||||||
|
* {@link Connection}.
|
||||||
|
*/
|
||||||
|
public final class Address {
|
||||||
|
final Proxy proxy;
|
||||||
|
final String uriHost;
|
||||||
|
final int uriPort;
|
||||||
|
final SSLSocketFactory sslSocketFactory;
|
||||||
|
final HostnameVerifier hostnameVerifier;
|
||||||
|
|
||||||
|
public Address(String uriHost, int uriPort, SSLSocketFactory sslSocketFactory,
|
||||||
|
HostnameVerifier hostnameVerifier, Proxy proxy) throws UnknownHostException {
|
||||||
|
if (uriHost == null) throw new NullPointerException("uriHost == null");
|
||||||
|
if (uriPort <= 0) throw new IllegalArgumentException("uriPort <= 0: " + uriPort);
|
||||||
|
this.proxy = proxy;
|
||||||
|
this.uriHost = uriHost;
|
||||||
|
this.uriPort = uriPort;
|
||||||
|
this.sslSocketFactory = sslSocketFactory;
|
||||||
|
this.hostnameVerifier = hostnameVerifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the hostname of the origin server. */
|
||||||
|
public String getUriHost() {
|
||||||
|
return uriHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the port of the origin server; typically 80 or 443. Unlike
|
||||||
|
* may {@code getPort()} accessors, this method never returns -1.
|
||||||
|
*/
|
||||||
|
public int getUriPort() {
|
||||||
|
return uriPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SSL socket factory, or null if this is not an HTTPS
|
||||||
|
* address.
|
||||||
|
*/
|
||||||
|
public SSLSocketFactory getSslSocketFactory() {
|
||||||
|
return sslSocketFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the hostname verifier, or null if this is not an HTTPS
|
||||||
|
* address.
|
||||||
|
*/
|
||||||
|
public HostnameVerifier getHostnameVerifier() {
|
||||||
|
return hostnameVerifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this address's explicitly-specified HTTP proxy, or null to
|
||||||
|
* delegate to the HTTP client's proxy selector.
|
||||||
|
*/
|
||||||
|
public Proxy getProxy() {
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean equals(Object other) {
|
||||||
|
if (other instanceof Address) {
|
||||||
|
Address that = (Address) other;
|
||||||
|
return equal(this.proxy, that.proxy)
|
||||||
|
&& this.uriHost.equals(that.uriHost)
|
||||||
|
&& this.uriPort == that.uriPort
|
||||||
|
&& equal(this.sslSocketFactory, that.sslSocketFactory)
|
||||||
|
&& equal(this.hostnameVerifier, that.hostnameVerifier);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int hashCode() {
|
||||||
|
int result = 17;
|
||||||
|
result = 31 * result + uriHost.hashCode();
|
||||||
|
result = 31 * result + uriPort;
|
||||||
|
result = 31 * result + (sslSocketFactory != null ? sslSocketFactory.hashCode() : 0);
|
||||||
|
result = 31 * result + (hostnameVerifier != null ? hostnameVerifier.hashCode() : 0);
|
||||||
|
result = 31 * result + (proxy != null ? proxy.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.squareup.okhttp;
|
||||||
|
|
||||||
|
import com.squareup.okhttp.internal.Platform;
|
||||||
|
import com.squareup.okhttp.internal.http.HttpAuthenticator;
|
||||||
|
import com.squareup.okhttp.internal.http.HttpEngine;
|
||||||
|
import com.squareup.okhttp.internal.http.HttpTransport;
|
||||||
|
import com.squareup.okhttp.internal.http.RawHeaders;
|
||||||
|
import com.squareup.okhttp.internal.http.SpdyTransport;
|
||||||
|
import com.squareup.okhttp.internal.spdy.SpdyConnection;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import javax.net.ssl.SSLSocket;
|
||||||
|
|
||||||
|
import static java.net.HttpURLConnection.HTTP_OK;
|
||||||
|
import static java.net.HttpURLConnection.HTTP_PROXY_AUTH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the sockets and streams of an HTTP, HTTPS, or HTTPS+SPDY connection,
|
||||||
|
* which may be used for multiple HTTP request/response exchanges. Connections
|
||||||
|
* may be direct to the origin server or via a proxy.
|
||||||
|
*
|
||||||
|
* <p>Typically instances of this class are created, connected and exercised
|
||||||
|
* automatically by the HTTP client. Applications may use this class to monitor
|
||||||
|
* HTTP connections as members of a {@link ConnectionPool connection pool}.
|
||||||
|
*
|
||||||
|
* <p>Do not confuse this class with the misnamed {@code HttpURLConnection},
|
||||||
|
* which isn't so much a connection as a single request/response exchange.
|
||||||
|
*
|
||||||
|
* <h3>Modern TLS</h3>
|
||||||
|
* There are tradeoffs when selecting which options to include when negotiating
|
||||||
|
* a secure connection to a remote host. Newer TLS options are quite useful:
|
||||||
|
* <ul>
|
||||||
|
* <li>Server Name Indication (SNI) enables one IP address to negotiate secure
|
||||||
|
* connections for multiple domain names.
|
||||||
|
* <li>Next Protocol Negotiation (NPN) enables the HTTPS port (443) to be used
|
||||||
|
* for both HTTP and SPDY transports.
|
||||||
|
* </ul>
|
||||||
|
* Unfortunately, older HTTPS servers refuse to connect when such options are
|
||||||
|
* presented. Rather than avoiding these options entirely, this class allows a
|
||||||
|
* connection to be attempted with modern options and then retried without them
|
||||||
|
* should the attempt fail.
|
||||||
|
*/
|
||||||
|
public final class Connection implements Closeable {
|
||||||
|
private static final byte[] NPN_PROTOCOLS = new byte[] {
|
||||||
|
6, 's', 'p', 'd', 'y', '/', '3',
|
||||||
|
8, 'h', 't', 't', 'p', '/', '1', '.', '1'
|
||||||
|
};
|
||||||
|
private static final byte[] SPDY3 = new byte[] {
|
||||||
|
's', 'p', 'd', 'y', '/', '3'
|
||||||
|
};
|
||||||
|
private static final byte[] HTTP_11 = new byte[] {
|
||||||
|
'h', 't', 't', 'p', '/', '1', '.', '1'
|
||||||
|
};
|
||||||
|
|
||||||
|
private final Route route;
|
||||||
|
|
||||||
|
private Socket socket;
|
||||||
|
private InputStream in;
|
||||||
|
private OutputStream out;
|
||||||
|
private boolean connected = false;
|
||||||
|
private SpdyConnection spdyConnection;
|
||||||
|
private int httpMinorVersion = 1; // Assume HTTP/1.1
|
||||||
|
private long idleStartTimeNs;
|
||||||
|
|
||||||
|
public Connection(Route route) {
|
||||||
|
this.route = route;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest)
|
||||||
|
throws IOException {
|
||||||
|
if (connected) {
|
||||||
|
throw new IllegalStateException("already connected");
|
||||||
|
}
|
||||||
|
connected = true;
|
||||||
|
socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket();
|
||||||
|
socket.connect(route.inetSocketAddress, connectTimeout);
|
||||||
|
socket.setSoTimeout(readTimeout);
|
||||||
|
in = socket.getInputStream();
|
||||||
|
out = socket.getOutputStream();
|
||||||
|
|
||||||
|
if (route.address.sslSocketFactory != null) {
|
||||||
|
upgradeToTls(tunnelRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use MTU-sized buffers to send fewer packets.
|
||||||
|
int mtu = Platform.get().getMtu(socket);
|
||||||
|
in = new BufferedInputStream(in, mtu);
|
||||||
|
out = new BufferedOutputStream(out, mtu);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an {@code SSLSocket} and perform the TLS handshake and certificate
|
||||||
|
* validation.
|
||||||
|
*/
|
||||||
|
private void upgradeToTls(TunnelRequest tunnelRequest) throws IOException {
|
||||||
|
Platform platform = Platform.get();
|
||||||
|
|
||||||
|
// Make an SSL Tunnel on the first message pair of each SSL + proxy connection.
|
||||||
|
if (requiresTunnel()) {
|
||||||
|
makeTunnel(tunnelRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the wrapper over connected socket.
|
||||||
|
socket = route.address.sslSocketFactory
|
||||||
|
.createSocket(socket, route.address.uriHost, route.address.uriPort, true /* autoClose */);
|
||||||
|
SSLSocket sslSocket = (SSLSocket) socket;
|
||||||
|
if (route.modernTls) {
|
||||||
|
platform.enableTlsExtensions(sslSocket, route.address.uriHost);
|
||||||
|
} else {
|
||||||
|
platform.supportTlsIntolerantServer(sslSocket);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (route.modernTls) {
|
||||||
|
platform.setNpnProtocols(sslSocket, NPN_PROTOCOLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force handshake. This can throw!
|
||||||
|
sslSocket.startHandshake();
|
||||||
|
|
||||||
|
// Verify that the socket's certificates are acceptable for the target host.
|
||||||
|
if (!route.address.hostnameVerifier.verify(route.address.uriHost, sslSocket.getSession())) {
|
||||||
|
throw new IOException("Hostname '" + route.address.uriHost + "' was not verified");
|
||||||
|
}
|
||||||
|
|
||||||
|
out = sslSocket.getOutputStream();
|
||||||
|
in = sslSocket.getInputStream();
|
||||||
|
|
||||||
|
byte[] selectedProtocol;
|
||||||
|
if (route.modernTls
|
||||||
|
&& (selectedProtocol = platform.getNpnSelectedProtocol(sslSocket)) != null) {
|
||||||
|
if (Arrays.equals(selectedProtocol, SPDY3)) {
|
||||||
|
sslSocket.setSoTimeout(0); // SPDY timeouts are set per-stream.
|
||||||
|
spdyConnection = new SpdyConnection.Builder(route.address.getUriHost(), true, in, out)
|
||||||
|
.build();
|
||||||
|
} else if (!Arrays.equals(selectedProtocol, HTTP_11)) {
|
||||||
|
throw new IOException(
|
||||||
|
"Unexpected NPN transport " + new String(selectedProtocol, "ISO-8859-1"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns true if {@link #connect} has been attempted on this connection. */
|
||||||
|
public boolean isConnected() {
|
||||||
|
return connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void close() throws IOException {
|
||||||
|
socket.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the route used by this connection. */
|
||||||
|
public Route getRoute() {
|
||||||
|
return route;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the socket that this connection uses, or null if the connection
|
||||||
|
* is not currently connected.
|
||||||
|
*/
|
||||||
|
public Socket getSocket() {
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns true if this connection is alive. */
|
||||||
|
public boolean isAlive() {
|
||||||
|
return !socket.isClosed() && !socket.isInputShutdown() && !socket.isOutputShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetIdleStartTime() {
|
||||||
|
if (spdyConnection != null) {
|
||||||
|
throw new IllegalStateException("spdyConnection != null");
|
||||||
|
}
|
||||||
|
this.idleStartTimeNs = System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns true if this connection is idle. */
|
||||||
|
public boolean isIdle() {
|
||||||
|
return spdyConnection == null || spdyConnection.isIdle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this connection has been idle for longer than
|
||||||
|
* {@code keepAliveDurationNs}.
|
||||||
|
*/
|
||||||
|
public boolean isExpired(long keepAliveDurationNs) {
|
||||||
|
return isIdle() && System.nanoTime() - getIdleStartTimeNs() > keepAliveDurationNs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the time in ns when this connection became idle. Undefined if
|
||||||
|
* this connection is not idle.
|
||||||
|
*/
|
||||||
|
public long getIdleStartTimeNs() {
|
||||||
|
return spdyConnection == null ? idleStartTimeNs : spdyConnection.getIdleStartTimeNs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the transport appropriate for this connection. */
|
||||||
|
public Object newTransport(HttpEngine httpEngine) throws IOException {
|
||||||
|
return (spdyConnection != null) ? new SpdyTransport(httpEngine, spdyConnection)
|
||||||
|
: new HttpTransport(httpEngine, out, in);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this is a SPDY connection. Such connections can be used
|
||||||
|
* in multiple HTTP requests simultaneously.
|
||||||
|
*/
|
||||||
|
public boolean isSpdy() {
|
||||||
|
return spdyConnection != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpdyConnection getSpdyConnection() {
|
||||||
|
return spdyConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the minor HTTP version that should be used for future requests on
|
||||||
|
* this connection. Either 0 for HTTP/1.0, or 1 for HTTP/1.1. The default
|
||||||
|
* value is 1 for new connections.
|
||||||
|
*/
|
||||||
|
public int getHttpMinorVersion() {
|
||||||
|
return httpMinorVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHttpMinorVersion(int httpMinorVersion) {
|
||||||
|
this.httpMinorVersion = httpMinorVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the HTTP connection needs to tunnel one protocol over
|
||||||
|
* another, such as when using HTTPS through an HTTP proxy. When doing so,
|
||||||
|
* we must avoid buffering bytes intended for the higher-level protocol.
|
||||||
|
*/
|
||||||
|
public boolean requiresTunnel() {
|
||||||
|
return route.address.sslSocketFactory != null && route.proxy.type() == Proxy.Type.HTTP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To make an HTTPS connection over an HTTP proxy, send an unencrypted
|
||||||
|
* CONNECT request to create the proxy connection. This may need to be
|
||||||
|
* retried if the proxy requires authorization.
|
||||||
|
*/
|
||||||
|
private void makeTunnel(TunnelRequest tunnelRequest) throws IOException {
|
||||||
|
RawHeaders requestHeaders = tunnelRequest.getRequestHeaders();
|
||||||
|
while (true) {
|
||||||
|
out.write(requestHeaders.toBytes());
|
||||||
|
RawHeaders responseHeaders = RawHeaders.fromBytes(in);
|
||||||
|
|
||||||
|
switch (responseHeaders.getResponseCode()) {
|
||||||
|
case HTTP_OK:
|
||||||
|
return;
|
||||||
|
case HTTP_PROXY_AUTH:
|
||||||
|
requestHeaders = new RawHeaders(requestHeaders);
|
||||||
|
URL url = new URL("https", tunnelRequest.host, tunnelRequest.port, "/");
|
||||||
|
boolean credentialsFound = HttpAuthenticator.processAuthHeader(HTTP_PROXY_AUTH,
|
||||||
|
responseHeaders, requestHeaders, route.proxy, url);
|
||||||
|
if (credentialsFound) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
throw new IOException("Failed to authenticate with proxy");
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new IOException(
|
||||||
|
"Unexpected response code for CONNECT: " + responseHeaders.getResponseCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,273 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.squareup.okhttp;
|
||||||
|
|
||||||
|
import com.squareup.okhttp.internal.Platform;
|
||||||
|
import com.squareup.okhttp.internal.Util;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages reuse of HTTP and SPDY connections for reduced network latency. HTTP
|
||||||
|
* requests that share the same {@link com.squareup.okhttp.Address} may share a
|
||||||
|
* {@link com.squareup.okhttp.Connection}. This class implements the policy of
|
||||||
|
* which connections to keep open for future use.
|
||||||
|
*
|
||||||
|
* <p>The {@link #getDefault() system-wide default} uses system properties for
|
||||||
|
* tuning parameters:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code http.keepAlive} true if HTTP and SPDY connections should be
|
||||||
|
* pooled at all. Default is true.
|
||||||
|
* <li>{@code http.maxConnections} maximum number of idle connections to
|
||||||
|
* each to keep in the pool. Default is 5.
|
||||||
|
* <li>{@code http.keepAliveDuration} Time in milliseconds to keep the
|
||||||
|
* connection alive in the pool before closing it. Default is 5 minutes.
|
||||||
|
* This property isn't used by {@code HttpURLConnection}.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>The default instance <i>doesn't</i> adjust its configuration as system
|
||||||
|
* properties are changed. This assumes that the applications that set these
|
||||||
|
* parameters do so before making HTTP connections, and that this class is
|
||||||
|
* initialized lazily.
|
||||||
|
*/
|
||||||
|
public class ConnectionPool {
|
||||||
|
private static final int MAX_CONNECTIONS_TO_CLEANUP = 2;
|
||||||
|
private static final long DEFAULT_KEEP_ALIVE_DURATION_MS = 5 * 60 * 1000; // 5 min
|
||||||
|
|
||||||
|
private static final ConnectionPool systemDefault;
|
||||||
|
|
||||||
|
static {
|
||||||
|
String keepAlive = System.getProperty("http.keepAlive");
|
||||||
|
String keepAliveDuration = System.getProperty("http.keepAliveDuration");
|
||||||
|
String maxIdleConnections = System.getProperty("http.maxConnections");
|
||||||
|
long keepAliveDurationMs = keepAliveDuration != null ? Long.parseLong(keepAliveDuration)
|
||||||
|
: DEFAULT_KEEP_ALIVE_DURATION_MS;
|
||||||
|
if (keepAlive != null && !Boolean.parseBoolean(keepAlive)) {
|
||||||
|
systemDefault = new ConnectionPool(0, keepAliveDurationMs);
|
||||||
|
} else if (maxIdleConnections != null) {
|
||||||
|
systemDefault = new ConnectionPool(Integer.parseInt(maxIdleConnections), keepAliveDurationMs);
|
||||||
|
} else {
|
||||||
|
systemDefault = new ConnectionPool(5, keepAliveDurationMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The maximum number of idle connections for each address. */
|
||||||
|
private final int maxIdleConnections;
|
||||||
|
private final long keepAliveDurationNs;
|
||||||
|
|
||||||
|
private final LinkedList<Connection> connections = new LinkedList<Connection>();
|
||||||
|
|
||||||
|
/** We use a single background thread to cleanup expired connections. */
|
||||||
|
private final ExecutorService executorService =
|
||||||
|
new ThreadPoolExecutor(0, 1, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
||||||
|
private final Callable<Void> connectionsCleanupCallable = new Callable<Void>() {
|
||||||
|
@Override public Void call() throws Exception {
|
||||||
|
List<Connection> expiredConnections = new ArrayList<Connection>(MAX_CONNECTIONS_TO_CLEANUP);
|
||||||
|
int idleConnectionCount = 0;
|
||||||
|
synchronized (ConnectionPool.this) {
|
||||||
|
for (ListIterator<Connection> i = connections.listIterator(connections.size());
|
||||||
|
i.hasPrevious(); ) {
|
||||||
|
Connection connection = i.previous();
|
||||||
|
if (!connection.isAlive() || connection.isExpired(keepAliveDurationNs)) {
|
||||||
|
i.remove();
|
||||||
|
expiredConnections.add(connection);
|
||||||
|
if (expiredConnections.size() == MAX_CONNECTIONS_TO_CLEANUP) break;
|
||||||
|
} else if (connection.isIdle()) {
|
||||||
|
idleConnectionCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ListIterator<Connection> i = connections.listIterator(connections.size());
|
||||||
|
i.hasPrevious() && idleConnectionCount > maxIdleConnections; ) {
|
||||||
|
Connection connection = i.previous();
|
||||||
|
if (connection.isIdle()) {
|
||||||
|
expiredConnections.add(connection);
|
||||||
|
i.remove();
|
||||||
|
--idleConnectionCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Connection expiredConnection : expiredConnections) {
|
||||||
|
Util.closeQuietly(expiredConnection);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public ConnectionPool(int maxIdleConnections, long keepAliveDurationMs) {
|
||||||
|
this.maxIdleConnections = maxIdleConnections;
|
||||||
|
this.keepAliveDurationNs = keepAliveDurationMs * 1000 * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a snapshot of the connections in this pool, ordered from newest to
|
||||||
|
* oldest. Waits for the cleanup callable to run if it is currently scheduled.
|
||||||
|
*/
|
||||||
|
List<Connection> getConnections() {
|
||||||
|
waitForCleanupCallableToRun();
|
||||||
|
synchronized (this) {
|
||||||
|
return new ArrayList<Connection>(connections);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blocks until the executor service has processed all currently enqueued
|
||||||
|
* jobs.
|
||||||
|
*/
|
||||||
|
private void waitForCleanupCallableToRun() {
|
||||||
|
try {
|
||||||
|
executorService.submit(new Runnable() {
|
||||||
|
@Override public void run() {
|
||||||
|
}
|
||||||
|
}).get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConnectionPool getDefault() {
|
||||||
|
return systemDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns total number of connections in the pool. */
|
||||||
|
public synchronized int getConnectionCount() {
|
||||||
|
return connections.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns total number of spdy connections in the pool. */
|
||||||
|
public synchronized int getSpdyConnectionCount() {
|
||||||
|
int total = 0;
|
||||||
|
for (Connection connection : connections) {
|
||||||
|
if (connection.isSpdy()) total++;
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns total number of http connections in the pool. */
|
||||||
|
public synchronized int getHttpConnectionCount() {
|
||||||
|
int total = 0;
|
||||||
|
for (Connection connection : connections) {
|
||||||
|
if (!connection.isSpdy()) total++;
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns a recycled connection to {@code address}, or null if no such connection exists. */
|
||||||
|
public synchronized Connection get(Address address) {
|
||||||
|
Connection foundConnection = null;
|
||||||
|
for (ListIterator<Connection> i = connections.listIterator(connections.size());
|
||||||
|
i.hasPrevious(); ) {
|
||||||
|
Connection connection = i.previous();
|
||||||
|
if (!connection.getRoute().getAddress().equals(address)
|
||||||
|
|| !connection.isAlive()
|
||||||
|
|| System.nanoTime() - connection.getIdleStartTimeNs() >= keepAliveDurationNs) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i.remove();
|
||||||
|
if (!connection.isSpdy()) {
|
||||||
|
try {
|
||||||
|
Platform.get().tagSocket(connection.getSocket());
|
||||||
|
} catch (SocketException e) {
|
||||||
|
Util.closeQuietly(connection);
|
||||||
|
// When unable to tag, skip recycling and close
|
||||||
|
Platform.get().logW("Unable to tagSocket(): " + e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foundConnection = connection;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundConnection != null && foundConnection.isSpdy()) {
|
||||||
|
connections.addFirst(foundConnection); // Add it back after iteration.
|
||||||
|
}
|
||||||
|
|
||||||
|
executorService.submit(connectionsCleanupCallable);
|
||||||
|
return foundConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gives {@code connection} to the pool. The pool may store the connection,
|
||||||
|
* or close it, as its policy describes.
|
||||||
|
*
|
||||||
|
* <p>It is an error to use {@code connection} after calling this method.
|
||||||
|
*/
|
||||||
|
public void recycle(Connection connection) {
|
||||||
|
executorService.submit(connectionsCleanupCallable);
|
||||||
|
|
||||||
|
if (connection.isSpdy()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connection.isAlive()) {
|
||||||
|
Util.closeQuietly(connection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Platform.get().untagSocket(connection.getSocket());
|
||||||
|
} catch (SocketException e) {
|
||||||
|
// When unable to remove tagging, skip recycling and close.
|
||||||
|
Platform.get().logW("Unable to untagSocket(): " + e);
|
||||||
|
Util.closeQuietly(connection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
connections.addFirst(connection);
|
||||||
|
connection.resetIdleStartTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shares the SPDY connection with the pool. Callers to this method may
|
||||||
|
* continue to use {@code connection}.
|
||||||
|
*/
|
||||||
|
public void maybeShare(Connection connection) {
|
||||||
|
executorService.submit(connectionsCleanupCallable);
|
||||||
|
if (!connection.isSpdy()) {
|
||||||
|
// Only SPDY connections are sharable.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (connection.isAlive()) {
|
||||||
|
synchronized (this) {
|
||||||
|
connections.addFirst(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Close and remove all connections in the pool. */
|
||||||
|
public void evictAll() {
|
||||||
|
List<Connection> connections;
|
||||||
|
synchronized (this) {
|
||||||
|
connections = new ArrayList<Connection>(this.connections);
|
||||||
|
this.connections.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Connection connection : connections) {
|
||||||
|
Util.closeQuietly(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||