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

Rebase Crosswalk to support Cordova 3.7.1 #168

Open
wants to merge 82 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
44979ad
Change CordovaWebView to derive from XWalkView.
huningxin Aug 28, 2013
01069bc
Enable remote debugging.
huningxin Aug 28, 2013
a0854bf
Use XWalkSettings
huningxin Aug 30, 2013
5281f5a
Add Looper to the threat that plugin runs in.
gaochun Sep 17, 2013
fba8b28
Fix file transfer plugin crash issue.
junmin-zhu Oct 16, 2013
0c2c1c3
Add more detail comments and TODO for file transfer plugin crash issue.
junmin-zhu Oct 16, 2013
ad75672
Hook activity life-cycle events to XWalkView handlers.
huningxin Oct 25, 2013
3284dad
Enable the pause and resume timers based on XWalkView.
huningxin Oct 28, 2013
43b20ad
Add xwalk extension system to cordova-xwalk-android.
gaochun Oct 18, 2013
1a641b1
Add xwalk_core_library to git ignore path
Oct 29, 2013
2915c19
Add empty implementation for loadDataForTest in CordovaWebView
Oct 30, 2013
50c4096
Implement the destroyExtension interface
Oct 31, 2013
a132d8b
Update the README.md according to Crosswalk dependency.
huningxin Oct 29, 2013
7899b8b
Use XWalkExtensionManager to reuse the extension system
Nov 6, 2013
487f8da
Change the CordovaWebView's onGeolocationPermissionsShowPrompt to xwalk.
huningxin Nov 15, 2013
1de309b
Bring back the CordovaWebView's WebBackForwardList related code.
junmin-zhu Nov 15, 2013
effc73e
Fix the unit test build error due to onGeolocationPermissionsShowProm…
huningxin Nov 19, 2013
32cd21e
Update the README.md
huningxin Nov 22, 2013
066cf94
Not to enable remote debugging by default.
huningxin Nov 25, 2013
caf2528
Update the README.md according to the wiki link update.
huningxin Dec 3, 2013
22da986
Fix typo in readme
rscohn2 Dec 17, 2013
7cc0ff7
Enable create script for cordova-xwalk container on Linux
Oct 10, 2013
cccaa17
Copy assets from xwalk core library to cordova app
Oct 21, 2013
e0ec9a5
Move the xwalk_core_library path into framework
huningxin Oct 25, 2013
28476f5
Execute `android update` with host supported target.
huningxin Nov 13, 2013
a87a3a0
Fix the build issue due to HttpAuthHandler API change in XwalkCoreLib…
huningxin Dec 24, 2013
9f11b8e
Temporarily to remove the APIs missing in the XWalk.
junmin-zhu Dec 24, 2013
f54ae0b
1. Don't need to update the xwalk_core_library project second times.
junmin-zhu Dec 24, 2013
dd04286
Modify the CordovaXWalkCoreExtensionBridge API due to the change of
junmin-zhu Dec 25, 2013
7fb2e86
Run android update in framework
Jan 6, 2014
9610da5
Temporarily disable 5 unit test cases for Cordova xwalk
junmin-zhu Jan 22, 2014
cc5840e
Because testOnScrollChanged test case depends on third party library
junmin-zhu Jan 26, 2014
fc342ae
Fix testUrl test case failed issue.
junmin-zhu Jan 22, 2014
98e235c
Fix that CordovaChromeClient misses all the implementation in xwalk
Feb 12, 2014
30ee41f
Exit fullscreen mode first when back key pressed
Feb 12, 2014
2961282
Fix that onNewIntent in CordovaWebView should return boolean as in XW…
Feb 28, 2014
5eaf1ef
Refactor the usage after the changes of extension mechanism in core l…
Feb 28, 2014
c1fe6b1
Enable remote debugging for debug build.
huningxin Mar 13, 2014
7b5d27e
Remove copy asset step from create script
Mar 14, 2014
c2ee61b
Fix the build error due to the rename of package name.
Mar 19, 2014
ed6eabe
Fix the compile error caused by the change of onReceivedSslError.
Mar 28, 2014
9f4864c
Remove unused import for SSL error handler.
Apr 8, 2014
c7ffb90
Refactor Cordova container to use the new API defined in Crosswalk.
Apr 9, 2014
c23c9c4
Don't use two classes XWalkUIClientImpl and XWalkResourceClientImpl.
Apr 21, 2014
1fe231b
Add two network related permissions to AndroidManifest.xml
kurli Apr 21, 2014
2e2a07b
Workaround the xwalk_core_library R.java missing issue.
huningxin Apr 24, 2014
e3c5a52
Fix XDK APX fails to build issue by bridging internal APIs.
huningxin Apr 29, 2014
0c2308f
Fix XWALK-1615 Cordova API test fails due to no JavaScript API exposed
huningxin May 4, 2014
7a331f5
Fix that cordova activity uses XWalk API with null pointer check
May 12, 2014
526071f
Change layout of splash dialog when orientation changed
kurli May 29, 2014
92d8ce6
Allow universal access from file URLs for Android 4.0.x
huningxin Jun 4, 2014
f3d3ce5
Fix onPageStarted/Finished never called in subclass of CordovaWebView…
huningxin Jun 11, 2014
6c9adae
Update the "Setup Crosswalk Dependency" section of README.md
huningxin Jun 18, 2014
4b36aa8
API calling adjust regarding to crosswalk change
Jun 19, 2014
6247ba5
Remove crosswalk internal dependency after Crosswalk Embedding API v2
Jul 3, 2014
54df49a
Ignore eclipse files and remove them from repo.
Jul 4, 2014
307113f
Remove XWalkSettings dependency in CordovaWebView
Jul 7, 2014
d49e02c
Remove the failed tests to make buildbot and trybot work.
gaochun Jun 19, 2014
cf5bddc
Fix bug: cordova.js is updated for test
Jul 18, 2014
35476c0
Do not convert xwalk's error code again
Jul 21, 2014
13cab0f
Add immersive fullscreen mode support
kurli Jul 23, 2014
a0f6a25
Disable multiple windows to align navigation behavior with upstream.
gaochun Jul 14, 2014
4bf0880
Fix white screen issue when application paused
kurli Jul 29, 2014
6fd4c87
Fix issue of failing to launch camera when tapping input tag.
gaochun Jul 30, 2014
d411373
Fix the layout issue happens when app was switched back from background.
gaochun Aug 1, 2014
3e5b00e
Don't pause timers when app is backgrounded
fujunwei Sep 11, 2014
78e1d05
Fix issue that app crashs when exit with back key.
gaochun Sep 19, 2014
02f2325
Replace WebView with XWalkView for Cordova 3.6.3
fujunwei Oct 13, 2014
f02fff6
Fix errors after runing tests
fujunwei Oct 20, 2014
052aed9
Reset CordovaBridge correctly on navigation.
pwnall Nov 8, 2014
6519e22
Align SSL error behavior with Cordova-Android.
pwnall Nov 10, 2014
3e907a9
Request focus on XWalkView to listener volume button
fujunwei Nov 11, 2014
00c92a0
CB-7674 move preference activation back into onCreate()
cmarcelk Sep 30, 2014
a3d8433
Fix immersive full screen mode doesn't recover
fujunwei Dec 19, 2014
644ee68
Update Android target sdk verion
fujunwei Dec 24, 2014
371a6a3
Add the option of --xwalk-shared-library to use Crosswalk shared mode
fujunwei Jan 23, 2015
824ea6f
Support shared mode for crosswalk library
Mar 31, 2015
dea61fb
Fix compiled errors
fujunwei Jun 4, 2015
7146cf9
Add a preference to disable immersive mode
fujunwei Apr 15, 2015
8c41af5
Add the interface of canGoBack in CordovaWebView
fujunwei Apr 23, 2015
c2662b8
Add the option of "--xwalk-apk-url" when creating Cordova project
fujunwei Apr 23, 2015
1460c63
Download runtime library from Google store if has no the option of "-…
fujunwei May 7, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ framework/assets/www/phonegap-*.js
framework/libs
framework/javadoc-public
framework/javadoc-private
framework/xwalk_core_library
framework/xwalk_shared_library
test/libs
example
./test
Expand All @@ -40,3 +42,7 @@ Desktop.ini
npm-debug.log
/node_modules
/framework/build
# 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
19 changes: 18 additions & 1 deletion bin/create
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
var path = require('path');
var create = require('./lib/create');
var args = require('./lib/simpleargs').getArgs(process.argv);
var apk_url = args['--xwalk-apk-url'];
var shared_library = args['--xwalk-shared-library'];

if (args['--help'] || args._.length === 0) {
console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'create')) + ' <path_to_new_project> <package_name> <project_name> [<template_path>] [--shared]');
Expand All @@ -29,8 +31,23 @@ if (args['--help'] || args._.length === 0) {
console.log(' <project_name>: Project name');
console.log(' <template_path>: Path to a custom application template to use');
console.log(' --shared will use the CordovaLib project directly instead of making a copy.');
console.log(' --xwalk-shared-library will use Crosswalk shared mode to package the project that without xwalk so library.');
console.log(' --xwalk-apk-url configure the download URL of the Crosswalk runtime library, it requires --xwalk-shared-library.');
process.exit(1);
}

create.createProject(args._[0], args._[1], args._[2], args._[3], args['--shared'], args['--cli']).done();
if (typeof apk_url != 'undefined' &&
(typeof apk_url != 'string' || apk_url.length == 0)) {
console.log(' --xwalk-apk-url expects a URL.');
process.exit(1);
}
if (apk_url && !shared_library) {
console.log(' --xwalk-apk-url must be used together with --xwalk-shared-library.');
process.exit(1);
}
if (args['--shared'] && (apk_url || shared_library)) {
console.log(' --shared cannot be used with --xwalk-apk-url and --xwalk-shared-library.');
process.exit(1);
}

create.createProject(args._[0], args._[1], args._[2], args._[3], args['--shared'], args['--cli'], args['--xwalk-shared-library'], args['--xwalk-apk-url']).done();
43 changes: 36 additions & 7 deletions bin/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ 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');
XWALK_SHARED_LIBRARY_PATH= path.join(ROOT, 'framework', 'xwalk_shared_library');

// Returns a promise.
function exec(command, opt_cwd) {
Expand All @@ -50,7 +52,7 @@ function getFrameworkDir(projectPath, shared) {
return shared ? path.join(ROOT, 'framework') : path.join(projectPath, 'CordovaLib');
}

function copyJsAndLibrary(projectPath, shared, projectName) {
function copyJsAndLibrary(projectPath, shared, projectName, xwalkSharedLibrary) {
var nestedCordovaLibPath = getFrameworkDir(projectPath, false);
shell.cp('-f', path.join(ROOT, 'framework', 'assets', 'www', 'cordova.js'), path.join(projectPath, 'assets', 'www', 'cordova.js'));
// Don't fail if there are no old jars.
Expand All @@ -74,6 +76,12 @@ function copyJsAndLibrary(projectPath, shared, projectName) {
shell.cp('-f', path.join(ROOT, 'framework', 'build.gradle'), nestedCordovaLibPath);
shell.cp('-f', path.join(ROOT, 'framework', 'cordova.gradle'), nestedCordovaLibPath);
shell.cp('-r', path.join(ROOT, 'framework', 'src'), nestedCordovaLibPath);
if (xwalkSharedLibrary) {
shell.mkdir(path.join(nestedCordovaLibPath, 'xwalk_core_library'));
shell.cp('-r', path.join(ROOT, 'framework', 'xwalk_shared_library/*'), path.join(nestedCordovaLibPath, 'xwalk_core_library'));
} else {
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 @@ -116,11 +124,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);
}
Expand Down Expand Up @@ -198,7 +209,8 @@ function validateProjectName(project_name) {
* Returns a promise.
*/

exports.createProject = function(project_path, package_name, project_name, project_template_dir, use_shared_project, use_cli_template) {
exports.createProject = function(project_path, package_name, project_name, project_template_dir,
use_shared_project, use_cli_template, xwalk_shared_library, xwalk_apk_url) {
var VERSION = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();

// Set default values for path, package and name
Expand All @@ -209,6 +221,7 @@ exports.createProject = function(project_path, package_name, project_name, proje
project_template_dir = typeof project_template_dir !== 'undefined' ?
project_template_dir :
path.join(ROOT, 'bin', 'templates', 'project');
xwalk_apk_url = typeof xwalk_apk_url !== 'undefined' ? xwalk_apk_url : "";

var package_as_path = package_name.replace(/\./g, path.sep);
var activity_dir = path.join(project_path, 'src', package_as_path);
Expand All @@ -224,6 +237,21 @@ 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')
}
if (xwalk_shared_library) {
if (fs.existsSync(XWALK_SHARED_LIBRARY_PATH)) {
exec('android update lib-project --path "' + XWALK_SHARED_LIBRARY_PATH + '" --target "' + target_api + '"' )
} else {
return Q.reject('No XWalk Shared Library Project found. Please download it and extract it to $XWALK_SHARED_LIBRARY_PATH')
}
}

//Make the package conform to Java package types
return validatePackageName(package_name)
.then(function() {
Expand Down Expand Up @@ -260,7 +288,7 @@ exports.createProject = function(project_path, package_name, project_name, proje
}

// copy cordova.js, cordova.jar
copyJsAndLibrary(project_path, use_shared_project, safe_activity_name);
copyJsAndLibrary(project_path, use_shared_project, safe_activity_name, xwalk_shared_library);

// interpolate the activity name and package
shell.mkdir('-p', activity_dir);
Expand All @@ -274,6 +302,7 @@ exports.createProject = function(project_path, package_name, project_name, proje
shell.sed('-i', /__ACTIVITY__/, safe_activity_name, manifest_path);
shell.sed('-i', /__PACKAGE__/, package_name, manifest_path);
shell.sed('-i', /__APILEVEL__/, target_api.split('-')[1], manifest_path);
shell.sed('-i', /__XWALKAPKURL__/, xwalk_apk_url, manifest_path);
copyScripts(project_path);
copyBuildRules(project_path);
});
Expand Down Expand Up @@ -301,13 +330,13 @@ function extractProjectNameFromManifest(projectPath) {
}

// Returns a promise.
exports.updateProject = function(projectPath, shared) {
exports.updateProject = function(projectPath, shared, xwalkSharedLibrary) {
var newVersion = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
return Q()
.then(function() {
var projectName = extractProjectNameFromManifest(projectPath);
var target_api = check_reqs.get_target();
copyJsAndLibrary(projectPath, shared, projectName);
copyJsAndLibrary(projectPath, shared, projectName, xwalkSharedLibrary);
copyScripts(projectPath);
copyBuildRules(projectPath);
removeDebuggableFromManifest(projectPath);
Expand Down
7 changes: 6 additions & 1 deletion bin/lib/simpleargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ exports.getArgs = function(argv) {
var posArgs = [];
for (var i = 2, arg; arg = argv[i] || i < argv.length; ++i) {
if (/^--/.exec(arg)) {
ret[arg] = true;
if (arg.indexOf("=") != -1) {
var arr = arg.split("=");
ret[arr[0]] = arr[1];
} else {
ret[arg] = true;
}
} else {
posArgs.push(arg);
}
Expand Down
4 changes: 4 additions & 0 deletions bin/templates/project/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class __ACTIVITY__ extends CordovaActivity
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}

@Override
protected void onXWalkReady() {
super.init();
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
Expand Down
7 changes: 6 additions & 1 deletion bin/templates/project/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@
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" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application android:icon="@drawable/icon" android:label="@string/app_name"
<application android:name="org.apache.cordova.CordovaApplication"
android:icon="@drawable/icon" android:label="@string/app_name"
android:hardwareAccelerated="true" android:supportsRtl="true">
<meta-data android:name="xwalk_apk_url" android:value="__XWALKAPKURL__" />
<activity android:name="__ACTIVITY__"
android:label="@string/activity_name"
android:launchMode="singleTop"
Expand Down
8 changes: 7 additions & 1 deletion bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ var args = require('./lib/simpleargs').getArgs(process.argv);
if (args['--help'] || args._.length === 0) {
console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'update')) + ' <path_to_project> [--shared]');
console.log(' --shared will use the CordovaLib project directly instead of making a copy.');
console.log(' --xwalk-shared-library will use Crosswalk shared mode to package the project that without xwalk so library.');
process.exit(1);
}
create.updateProject(args._[0], args['--shared']).done();
if (args['--shared'] && args['--xwalk-shared-library']) {
console.log(' --xwalk-shared-library do not support --shared.');
process.exit(1);
}

create.updateProject(args._[0], args['--shared'], args['--xwalk-shared-library']).done();

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-21
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 @@ -205,7 +205,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