Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #146 from fujunwei/local_master
Browse files Browse the repository at this point in the history
Rebase Crosswalk to support Cordova 3.6.3
  • Loading branch information
huningxin committed Oct 22, 2014
2 parents e2e38ad + e91e805 commit b67d26e
Show file tree
Hide file tree
Showing 29 changed files with 516 additions and 645 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ framework/assets/www/phonegap-*.js
framework/libs
framework/javadoc-public
framework/javadoc-private
framework/xwalk_core_library
test/libs
example
./test
Expand All @@ -37,3 +38,7 @@ Desktop.ini
# IntelliJ IDEA files
*.iml
.idea
# Eclipse files
.classpath
.project
.settings
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
# under the License.
#
-->
Cordova Android
Crosswalk-based Cordova Android
===

Cordova Android is an Android application library that allows for Cordova-based
Crosswalk-based Cordova Android is derived from [Cordova Android](https://github.com/apache/cordova-android)
and uses [Crosswalk](https://github.com/crosswalk-project/crosswalk) as the
HTML5 runtime. It 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.

Expand All @@ -34,6 +36,18 @@ Requires
- Java JDK 1.5 or greater
- Apache Ant 1.8.0 or greater
- Android SDK [http://developer.android.com](http://developer.android.com)
- Python 2.6 or greater

Setup Crosswalk Dependency
---

1. Please download the crosswalk-webview for Android package from [Crosswalk download site](https://download.01.org/crosswalk/releases/crosswalk/android/).
2. Unzip the crosswalk-webview package to a folder and create a link named `xwalk_core_library` under `framework` linking to that folder.

For example, on Linux:

$cd /path/to/crosswalk-cordova-android/framework
$ln -s /path/to/crosswalk-webview-unzipped-folder/ xwalk_core_library


Cordova Android Developer Tools
Expand All @@ -57,27 +71,14 @@ These commands live in a generated Cordova Android project. Any interactions wit
./cordova/run ........................ calls `build` then deploys to a connected Android device. If no Android device is detected, will launch an emulator and deploy to it.
./cordova/version ...................... returns the cordova-android version of the current project

Importing a Cordova Android Project into Eclipse
Importing a Crosswalk-based 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-19
ant jar

1. Import Crosswalk-based Cordova Android and XWalkCoreLibrary library projects by File > Import... > Existing Android Code Into Workspace. Point to `[path_to_cordova_xwalk_android]/framework` and click `Finish`.
2. Build `xwalk_core_library` and `Cordova` projects.
3. Import generated project by File > Import... > Existing Android Code. Point to the generated app path.
4. Right click on the project root: Run as > Run Configurations
5. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)

Running Tests
----
Expand Down
17 changes: 15 additions & 2 deletions bin/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var shell = require('shelljs'),
path = require('path'),
fs = require('fs'),
check_reqs = require('./check_reqs'),
ROOT = path.join(__dirname, '..', '..');
ROOT = path.join(__dirname, '..', '..'),
XWALK_LIBRARY_PATH= path.join(ROOT, 'framework', 'xwalk_core_library');

// Returns a promise.
function exec(command, opt_cwd) {
Expand Down Expand Up @@ -73,6 +74,7 @@ function copyJsAndLibrary(projectPath, shared, projectName) {
shell.cp('-f', path.join(ROOT, 'framework', 'project.properties'), nestedCordovaLibPath);
shell.cp('-f', path.join(ROOT, 'framework', 'build.gradle'), nestedCordovaLibPath);
shell.cp('-r', path.join(ROOT, 'framework', 'src'), nestedCordovaLibPath);
shell.cp('-r', path.join(ROOT, 'framework', 'xwalk_core_library'), nestedCordovaLibPath);
// Create an eclipse project file and set the name of it to something unique.
// Without this, you can't import multiple CordovaLib projects into the same workspace.
var eclipseProjectFilePath = path.join(nestedCordovaLibPath, '.project');
Expand Down Expand Up @@ -115,11 +117,14 @@ function writeProjectProperties(projectPath, target_api, shared) {
data += 'android.library.reference.' + (i+1) + '=' + subProjects[i] + '\n';
}
fs.writeFileSync(dstPath, data);

var targetFrameworkDir = getFrameworkDir(projectPath, shared);
exec('android update lib-project -p "' + targetFrameworkDir + '" --target ' + target_api);
}

function copyBuildRules(projectPath) {
var srcDir = path.join(ROOT, 'bin', 'templates', 'project');
shell.cp('-f', path.join(srcDir, 'custom_rules.xml'), projectPath);
//shell.cp('-f', path.join(srcDir, 'custom_rules.xml'), projectPath);

shell.cp('-f', path.join(srcDir, 'build.gradle'), projectPath);
shell.cp('-f', path.join(srcDir, 'settings.gradle'), projectPath);
Expand Down Expand Up @@ -222,6 +227,14 @@ exports.createProject = function(project_path, package_name, project_name, proje
return Q.reject('Project already exists! Delete and recreate');
}

// prepare xwalk_core_library
if(fs.existsSync(XWALK_LIBRARY_PATH)) {
exec('android update lib-project --path "' + XWALK_LIBRARY_PATH + '" --target "' + target_api + '"' )
} else {
// TODO(wang16): download xwalk core library here
return Q.reject('No XWalk Library Project found. Please download it and extract it to $XWALK_LIBRARY_PATH')
}

//Make the package conform to Java package types
return validatePackageName(package_name)
.then(function() {
Expand Down
2 changes: 2 additions & 0 deletions bin/templates/project/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
android:anyDensity="true"
/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<application android:icon="@drawable/icon" android:label="@string/app_name"
Expand Down
9 changes: 0 additions & 9 deletions framework/.classpath

This file was deleted.

33 changes: 0 additions & 33 deletions framework/.project

This file was deleted.

4 changes: 0 additions & 4 deletions framework/.settings/org.eclipse.jdt.core.prefs

This file was deleted.

1 change: 1 addition & 0 deletions framework/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ target=android-19
apk-configurations=
renderscript.opt.level=O0
android.library=true
android.library.reference.1=xwalk_core_library
2 changes: 1 addition & 1 deletion framework/src/org/apache/cordova/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ else if (value.getClass().equals(Integer.class)) {
public void clearHistory() {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
webView.clearHistory();
webView.getNavigationHistory().clear();
}
});
}
Expand Down
Loading

0 comments on commit b67d26e

Please sign in to comment.