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

Commit b67d26e

Browse files
committed
Merge pull request #146 from fujunwei/local_master
Rebase Crosswalk to support Cordova 3.6.3
2 parents e2e38ad + e91e805 commit b67d26e

29 files changed

+516
-645
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ framework/assets/www/phonegap-*.js
1616
framework/libs
1717
framework/javadoc-public
1818
framework/javadoc-private
19+
framework/xwalk_core_library
1920
test/libs
2021
example
2122
./test
@@ -37,3 +38,7 @@ Desktop.ini
3738
# IntelliJ IDEA files
3839
*.iml
3940
.idea
41+
# Eclipse files
42+
.classpath
43+
.project
44+
.settings

README.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
# under the License.
1919
#
2020
-->
21-
Cordova Android
21+
Crosswalk-based Cordova Android
2222
===
2323

24-
Cordova Android is an Android application library that allows for Cordova-based
24+
Crosswalk-based Cordova Android is derived from [Cordova Android](https://github.com/apache/cordova-android)
25+
and uses [Crosswalk](https://github.com/crosswalk-project/crosswalk) as the
26+
HTML5 runtime. It is an Android application library that allows for Cordova-based
2527
projects to be built for the Android Platform. Cordova based applications are,
2628
at the core, applications written with web technology: HTML, CSS and JavaScript.
2729

@@ -34,6 +36,18 @@ Requires
3436
- Java JDK 1.5 or greater
3537
- Apache Ant 1.8.0 or greater
3638
- Android SDK [http://developer.android.com](http://developer.android.com)
39+
- Python 2.6 or greater
40+
41+
Setup Crosswalk Dependency
42+
---
43+
44+
1. Please download the crosswalk-webview for Android package from [Crosswalk download site](https://download.01.org/crosswalk/releases/crosswalk/android/).
45+
2. Unzip the crosswalk-webview package to a folder and create a link named `xwalk_core_library` under `framework` linking to that folder.
46+
47+
For example, on Linux:
48+
49+
$cd /path/to/crosswalk-cordova-android/framework
50+
$ln -s /path/to/crosswalk-webview-unzipped-folder/ xwalk_core_library
3751

3852

3953
Cordova Android Developer Tools
@@ -57,27 +71,14 @@ These commands live in a generated Cordova Android project. Any interactions wit
5771
./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.
5872
./cordova/version ...................... returns the cordova-android version of the current project
5973

60-
Importing a Cordova Android Project into Eclipse
74+
Importing a Crosswalk-based Cordova Android Project into Eclipse
6175
----
6276

63-
1. File > New > Project...
64-
2. Android > Android Project
65-
3. Create project from existing source (point to the generated app found in tmp/android)
66-
4. Right click on libs/cordova.jar and add to build path
67-
5. Right click on the project root: Run as > Run Configurations
68-
6. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)
69-
70-
Building without the Tooling
71-
---
72-
Note: The Developer Tools handle this. This is only to be done if the tooling fails, or if
73-
you are developing directly against the framework.
74-
75-
76-
To create your `cordova.jar` file, run in the framework directory:
77-
78-
android update project -p . -t android-19
79-
ant jar
80-
77+
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`.
78+
2. Build `xwalk_core_library` and `Cordova` projects.
79+
3. Import generated project by File > Import... > Existing Android Code. Point to the generated app path.
80+
4. Right click on the project root: Run as > Run Configurations
81+
5. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)
8182

8283
Running Tests
8384
----

bin/lib/create.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ var shell = require('shelljs'),
2424
path = require('path'),
2525
fs = require('fs'),
2626
check_reqs = require('./check_reqs'),
27-
ROOT = path.join(__dirname, '..', '..');
27+
ROOT = path.join(__dirname, '..', '..'),
28+
XWALK_LIBRARY_PATH= path.join(ROOT, 'framework', 'xwalk_core_library');
2829

2930
// Returns a promise.
3031
function exec(command, opt_cwd) {
@@ -73,6 +74,7 @@ function copyJsAndLibrary(projectPath, shared, projectName) {
7374
shell.cp('-f', path.join(ROOT, 'framework', 'project.properties'), nestedCordovaLibPath);
7475
shell.cp('-f', path.join(ROOT, 'framework', 'build.gradle'), nestedCordovaLibPath);
7576
shell.cp('-r', path.join(ROOT, 'framework', 'src'), nestedCordovaLibPath);
77+
shell.cp('-r', path.join(ROOT, 'framework', 'xwalk_core_library'), nestedCordovaLibPath);
7678
// Create an eclipse project file and set the name of it to something unique.
7779
// Without this, you can't import multiple CordovaLib projects into the same workspace.
7880
var eclipseProjectFilePath = path.join(nestedCordovaLibPath, '.project');
@@ -115,11 +117,14 @@ function writeProjectProperties(projectPath, target_api, shared) {
115117
data += 'android.library.reference.' + (i+1) + '=' + subProjects[i] + '\n';
116118
}
117119
fs.writeFileSync(dstPath, data);
120+
121+
var targetFrameworkDir = getFrameworkDir(projectPath, shared);
122+
exec('android update lib-project -p "' + targetFrameworkDir + '" --target ' + target_api);
118123
}
119124

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

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

230+
// prepare xwalk_core_library
231+
if(fs.existsSync(XWALK_LIBRARY_PATH)) {
232+
exec('android update lib-project --path "' + XWALK_LIBRARY_PATH + '" --target "' + target_api + '"' )
233+
} else {
234+
// TODO(wang16): download xwalk core library here
235+
return Q.reject('No XWalk Library Project found. Please download it and extract it to $XWALK_LIBRARY_PATH')
236+
}
237+
225238
//Make the package conform to Java package types
226239
return validatePackageName(package_name)
227240
.then(function() {

bin/templates/project/AndroidManifest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
android:anyDensity="true"
2929
/>
3030

31+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
32+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
3133
<uses-permission android:name="android.permission.INTERNET" />
3234

3335
<application android:icon="@drawable/icon" android:label="@string/app_name"

framework/.classpath

-9
This file was deleted.

framework/.project

-33
This file was deleted.

framework/.settings/org.eclipse.jdt.core.prefs

-4
This file was deleted.

framework/project.properties

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ target=android-19
1414
apk-configurations=
1515
renderscript.opt.level=O0
1616
android.library=true
17+
android.library.reference.1=xwalk_core_library

framework/src/org/apache/cordova/App.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ else if (value.getClass().equals(Integer.class)) {
189189
public void clearHistory() {
190190
cordova.getActivity().runOnUiThread(new Runnable() {
191191
public void run() {
192-
webView.clearHistory();
192+
webView.getNavigationHistory().clear();
193193
}
194194
});
195195
}

0 commit comments

Comments
 (0)