Compare commits

...

10 Commits

9 changed files with 4289 additions and 4262 deletions

View File

@ -1 +1 @@
9.1.0-dev 9.1.1

View File

@ -1,386 +1,386 @@
/** /**
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
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
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.
*/ */
/** /**
* @todo update coho to update this line. * @todo update coho to update this line.
* @todo use `package.json` instead but first * @todo use `package.json` instead but first
* figure out how this fit in with the platform-centered workflow structure. * figure out how this fit in with the platform-centered workflow structure.
* This workflow would not have the `package.json` file. * This workflow would not have the `package.json` file.
*/ */
// Coho updates this line // Coho updates this line
const VERSION = '9.1.0-dev'; const VERSION = '9.1.1';
var path = require('path'); var path = require('path');
var AndroidProject = require('./lib/AndroidProject'); var AndroidProject = require('./lib/AndroidProject');
var PluginManager = require('cordova-common').PluginManager; var PluginManager = require('cordova-common').PluginManager;
var CordovaLogger = require('cordova-common').CordovaLogger; var CordovaLogger = require('cordova-common').CordovaLogger;
var selfEvents = require('cordova-common').events; var selfEvents = require('cordova-common').events;
var ConfigParser = require('cordova-common').ConfigParser; var ConfigParser = require('cordova-common').ConfigParser;
const prepare = require('./lib/prepare').prepare; const prepare = require('./lib/prepare').prepare;
var PLATFORM = 'android'; var PLATFORM = 'android';
function setupEvents (externalEventEmitter) { function setupEvents (externalEventEmitter) {
if (externalEventEmitter) { if (externalEventEmitter) {
// This will make the platform internal events visible outside // This will make the platform internal events visible outside
selfEvents.forwardEventsTo(externalEventEmitter); selfEvents.forwardEventsTo(externalEventEmitter);
return externalEventEmitter; return externalEventEmitter;
} }
// There is no logger if external emitter is not present, // There is no logger if external emitter is not present,
// so attach a console logger // so attach a console logger
CordovaLogger.get().subscribe(selfEvents); CordovaLogger.get().subscribe(selfEvents);
return selfEvents; return selfEvents;
} }
/** /**
* Class, that acts as abstraction over particular platform. Encapsulates the * Class, that acts as abstraction over particular platform. Encapsulates the
* platform's properties and methods. * platform's properties and methods.
* *
* Platform that implements own PlatformApi instance _should implement all * Platform that implements own PlatformApi instance _should implement all
* prototype methods_ of this class to be fully compatible with cordova-lib. * prototype methods_ of this class to be fully compatible with cordova-lib.
* *
* The PlatformApi instance also should define the following field: * The PlatformApi instance also should define the following field:
* *
* * platform: String that defines a platform name. * * platform: String that defines a platform name.
* @class Api * @class Api
*/ */
class Api { class Api {
constructor (platform, platformRootDir, events) { constructor (platform, platformRootDir, events) {
this.platform = PLATFORM; this.platform = PLATFORM;
this.root = path.resolve(__dirname, '..'); this.root = path.resolve(__dirname, '..');
setupEvents(events); setupEvents(events);
const appMain = path.join(this.root, 'app', 'src', 'main'); const appMain = path.join(this.root, 'app', 'src', 'main');
const appRes = path.join(appMain, 'res'); const appRes = path.join(appMain, 'res');
this.locations = { this.locations = {
root: this.root, root: this.root,
www: path.join(appMain, 'assets', 'www'), www: path.join(appMain, 'assets', 'www'),
res: appRes, res: appRes,
platformWww: path.join(this.root, 'platform_www'), platformWww: path.join(this.root, 'platform_www'),
configXml: path.join(appRes, 'xml', 'config.xml'), configXml: path.join(appRes, 'xml', 'config.xml'),
defaultConfigXml: path.join(this.root, 'cordova', 'defaults.xml'), defaultConfigXml: path.join(this.root, 'cordova', 'defaults.xml'),
strings: path.join(appRes, 'values', 'strings.xml'), strings: path.join(appRes, 'values', 'strings.xml'),
manifest: path.join(appMain, 'AndroidManifest.xml'), manifest: path.join(appMain, 'AndroidManifest.xml'),
build: path.join(this.root, 'build'), build: path.join(this.root, 'build'),
javaSrc: path.join(appMain, 'java') javaSrc: path.join(appMain, 'java')
}; };
this._builder = require('./lib/builders/builders').getBuilder(this.root); this._builder = require('./lib/builders/builders').getBuilder(this.root);
} }
/** /**
* Gets a CordovaPlatform object, that represents the platform structure. * Gets a CordovaPlatform object, that represents the platform structure.
* *
* @return {CordovaPlatform} A structure that contains the description of * @return {CordovaPlatform} A structure that contains the description of
* platform's file structure and other properties of platform. * platform's file structure and other properties of platform.
*/ */
getPlatformInfo () { getPlatformInfo () {
var result = {}; var result = {};
result.locations = this.locations; result.locations = this.locations;
result.root = this.root; result.root = this.root;
result.name = this.platform; result.name = this.platform;
result.version = Api.version(); result.version = Api.version();
result.projectConfig = this._config; result.projectConfig = this._config;
return result; return result;
} }
/** /**
* Updates installed platform with provided www assets and new app * Updates installed platform with provided www assets and new app
* configuration. This method is required for CLI workflow and will be called * configuration. This method is required for CLI workflow and will be called
* each time before build, so the changes, made to app configuration and www * each time before build, so the changes, made to app configuration and www
* code, will be applied to platform. * code, will be applied to platform.
* *
* @param {CordovaProject} cordovaProject A CordovaProject instance, that defines a * @param {CordovaProject} cordovaProject A CordovaProject instance, that defines a
* project structure and configuration, that should be applied to platform * project structure and configuration, that should be applied to platform
* (contains project's www location and ConfigParser instance for project's * (contains project's www location and ConfigParser instance for project's
* config). * config).
* *
* @return {Promise} Return a promise either fulfilled, or rejected with * @return {Promise} Return a promise either fulfilled, or rejected with
* CordovaError instance. * CordovaError instance.
*/ */
prepare (cordovaProject, prepareOptions) { prepare (cordovaProject, prepareOptions) {
cordovaProject.projectConfig = new ConfigParser(cordovaProject.locations.rootConfigXml || cordovaProject.projectConfig.path); cordovaProject.projectConfig = new ConfigParser(cordovaProject.locations.rootConfigXml || cordovaProject.projectConfig.path);
return prepare.call(this, cordovaProject, prepareOptions); return prepare.call(this, cordovaProject, prepareOptions);
} }
/** /**
* Installs a new plugin into platform. This method only copies non-www files * Installs a new plugin into platform. This method only copies non-www files
* (sources, libs, etc.) to platform. It also doesn't resolves the * (sources, libs, etc.) to platform. It also doesn't resolves the
* dependencies of plugin. Both of handling of www files, such as assets and * dependencies of plugin. Both of handling of www files, such as assets and
* js-files and resolving dependencies are the responsibility of caller. * js-files and resolving dependencies are the responsibility of caller.
* *
* @param {PluginInfo} plugin A PluginInfo instance that represents plugin * @param {PluginInfo} plugin A PluginInfo instance that represents plugin
* that will be installed. * that will be installed.
* @param {Object} installOptions An options object. Possible options below: * @param {Object} installOptions An options object. Possible options below:
* @param {Boolean} installOptions.link: Flag that specifies that plugin * @param {Boolean} installOptions.link: Flag that specifies that plugin
* sources will be symlinked to app's directory instead of copying (if * sources will be symlinked to app's directory instead of copying (if
* possible). * possible).
* @param {Object} installOptions.variables An object that represents * @param {Object} installOptions.variables An object that represents
* variables that will be used to install plugin. See more details on plugin * variables that will be used to install plugin. See more details on plugin
* variables in documentation: * variables in documentation:
* https://cordova.apache.org/docs/en/4.0.0/plugin_ref_spec.md.html * https://cordova.apache.org/docs/en/4.0.0/plugin_ref_spec.md.html
* *
* @return {Promise} Return a promise either fulfilled, or rejected with * @return {Promise} Return a promise either fulfilled, or rejected with
* CordovaError instance. * CordovaError instance.
*/ */
addPlugin (plugin, installOptions) { addPlugin (plugin, installOptions) {
var project = AndroidProject.getProjectFile(this.root); var project = AndroidProject.getProjectFile(this.root);
var self = this; var self = this;
installOptions = installOptions || {}; installOptions = installOptions || {};
installOptions.variables = installOptions.variables || {}; installOptions.variables = installOptions.variables || {};
// Add PACKAGE_NAME variable into vars // Add PACKAGE_NAME variable into vars
if (!installOptions.variables.PACKAGE_NAME) { if (!installOptions.variables.PACKAGE_NAME) {
installOptions.variables.PACKAGE_NAME = project.getPackageName(); installOptions.variables.PACKAGE_NAME = project.getPackageName();
} }
return Promise.resolve().then(function () { return Promise.resolve().then(function () {
return PluginManager.get(self.platform, self.locations, project).addPlugin(plugin, installOptions); return PluginManager.get(self.platform, self.locations, project).addPlugin(plugin, installOptions);
}).then(function () { }).then(function () {
if (plugin.getFrameworks(this.platform).length === 0) return; if (plugin.getFrameworks(this.platform).length === 0) return;
selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>'); selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
// This should pick the correct builder, not just get gradle // This should pick the correct builder, not just get gradle
this._builder.prepBuildFiles(); this._builder.prepBuildFiles();
}.bind(this)) }.bind(this))
// CB-11022 Return truthy value to prevent running prepare after // CB-11022 Return truthy value to prevent running prepare after
.then(() => true); .then(() => true);
} }
/** /**
* Removes an installed plugin from platform. * Removes an installed plugin from platform.
* *
* Since method accepts PluginInfo instance as input parameter instead of plugin * Since method accepts PluginInfo instance as input parameter instead of plugin
* id, caller shoud take care of managing/storing PluginInfo instances for * id, caller shoud take care of managing/storing PluginInfo instances for
* future uninstalls. * future uninstalls.
* *
* @param {PluginInfo} plugin A PluginInfo instance that represents plugin * @param {PluginInfo} plugin A PluginInfo instance that represents plugin
* that will be installed. * that will be installed.
* *
* @return {Promise} Return a promise either fulfilled, or rejected with * @return {Promise} Return a promise either fulfilled, or rejected with
* CordovaError instance. * CordovaError instance.
*/ */
removePlugin (plugin, uninstallOptions) { removePlugin (plugin, uninstallOptions) {
var project = AndroidProject.getProjectFile(this.root); var project = AndroidProject.getProjectFile(this.root);
if (uninstallOptions && uninstallOptions.usePlatformWww === true) { if (uninstallOptions && uninstallOptions.usePlatformWww === true) {
uninstallOptions.usePlatformWww = false; uninstallOptions.usePlatformWww = false;
} }
return PluginManager.get(this.platform, this.locations, project) return PluginManager.get(this.platform, this.locations, project)
.removePlugin(plugin, uninstallOptions) .removePlugin(plugin, uninstallOptions)
.then(function () { .then(function () {
if (plugin.getFrameworks(this.platform).length === 0) return; if (plugin.getFrameworks(this.platform).length === 0) return;
selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>'); selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
this._builder.prepBuildFiles(); this._builder.prepBuildFiles();
}.bind(this)) }.bind(this))
// CB-11022 Return truthy value to prevent running prepare after // CB-11022 Return truthy value to prevent running prepare after
.then(() => true); .then(() => true);
} }
/** /**
* Builds an application package for current platform. * Builds an application package for current platform.
* *
* @param {Object} buildOptions A build options. This object's structure is * @param {Object} buildOptions A build options. This object's structure is
* highly depends on platform's specific. The most common options are: * highly depends on platform's specific. The most common options are:
* @param {Boolean} buildOptions.debug Indicates that packages should be * @param {Boolean} buildOptions.debug Indicates that packages should be
* built with debug configuration. This is set to true by default unless the * built with debug configuration. This is set to true by default unless the
* 'release' option is not specified. * 'release' option is not specified.
* @param {Boolean} buildOptions.release Indicates that packages should be * @param {Boolean} buildOptions.release Indicates that packages should be
* built with release configuration. If not set to true, debug configuration * built with release configuration. If not set to true, debug configuration
* will be used. * will be used.
* @param {Boolean} buildOptions.device Specifies that built app is intended * @param {Boolean} buildOptions.device Specifies that built app is intended
* to run on device * to run on device
* @param {Boolean} buildOptions.emulator: Specifies that built app is * @param {Boolean} buildOptions.emulator: Specifies that built app is
* intended to run on emulator * intended to run on emulator
* @param {String} buildOptions.target Specifies the device id that will be * @param {String} buildOptions.target Specifies the device id that will be
* used to run built application. * used to run built application.
* @param {Boolean} buildOptions.nobuild Indicates that this should be a * @param {Boolean} buildOptions.nobuild Indicates that this should be a
* dry-run call, so no build artifacts will be produced. * dry-run call, so no build artifacts will be produced.
* @param {String[]} buildOptions.archs Specifies chip architectures which * @param {String[]} buildOptions.archs Specifies chip architectures which
* app packages should be built for. List of valid architectures is depends on * app packages should be built for. List of valid architectures is depends on
* platform. * platform.
* @param {String} buildOptions.buildConfig The path to build configuration * @param {String} buildOptions.buildConfig The path to build configuration
* file. The format of this file is depends on platform. * file. The format of this file is depends on platform.
* @param {String[]} buildOptions.argv Raw array of command-line arguments, * @param {String[]} buildOptions.argv Raw array of command-line arguments,
* passed to `build` command. The purpose of this property is to pass a * passed to `build` command. The purpose of this property is to pass a
* platform-specific arguments, and eventually let platform define own * platform-specific arguments, and eventually let platform define own
* arguments processing logic. * arguments processing logic.
* *
* @return {Promise<Object[]>} A promise either fulfilled with an array of build * @return {Promise<Object[]>} A promise either fulfilled with an array of build
* artifacts (application packages) if package was built successfully, * artifacts (application packages) if package was built successfully,
* or rejected with CordovaError. The resultant build artifact objects is not * or rejected with CordovaError. The resultant build artifact objects is not
* strictly typed and may conatin arbitrary set of fields as in sample below. * strictly typed and may conatin arbitrary set of fields as in sample below.
* *
* { * {
* architecture: 'x86', * architecture: 'x86',
* buildType: 'debug', * buildType: 'debug',
* path: '/path/to/build', * path: '/path/to/build',
* type: 'app' * type: 'app'
* } * }
* *
* The return value in most cases will contain only one item but in some cases * The return value in most cases will contain only one item but in some cases
* there could be multiple items in output array, e.g. when multiple * there could be multiple items in output array, e.g. when multiple
* arhcitectures is specified. * arhcitectures is specified.
*/ */
build (buildOptions) { build (buildOptions) {
var self = this; var self = this;
return require('./lib/check_reqs').run().then(function () { return require('./lib/check_reqs').run().then(function () {
return require('./lib/build').run.call(self, buildOptions); return require('./lib/build').run.call(self, buildOptions);
}).then(function (buildResults) { }).then(function (buildResults) {
// Cast build result to array of build artifacts // Cast build result to array of build artifacts
return buildResults.paths.map(function (apkPath) { return buildResults.paths.map(function (apkPath) {
return { return {
buildType: buildResults.buildType, buildType: buildResults.buildType,
buildMethod: buildResults.buildMethod, buildMethod: buildResults.buildMethod,
path: apkPath, path: apkPath,
type: path.extname(apkPath).replace(/\./g, '') type: path.extname(apkPath).replace(/\./g, '')
}; };
}); });
}); });
} }
/** /**
* Builds an application package for current platform and runs it on * Builds an application package for current platform and runs it on
* specified/default device. If no 'device'/'emulator'/'target' options are * specified/default device. If no 'device'/'emulator'/'target' options are
* specified, then tries to run app on default device if connected, otherwise * specified, then tries to run app on default device if connected, otherwise
* runs the app on emulator. * runs the app on emulator.
* *
* @param {Object} runOptions An options object. The structure is the same * @param {Object} runOptions An options object. The structure is the same
* as for build options. * as for build options.
* *
* @return {Promise} A promise either fulfilled if package was built and ran * @return {Promise} A promise either fulfilled if package was built and ran
* successfully, or rejected with CordovaError. * successfully, or rejected with CordovaError.
*/ */
run (runOptions) { run (runOptions) {
var self = this; var self = this;
return require('./lib/check_reqs').run().then(function () { return require('./lib/check_reqs').run().then(function () {
return require('./lib/run').run.call(self, runOptions); return require('./lib/run').run.call(self, runOptions);
}); });
} }
/** /**
* Cleans out the build artifacts from platform's directory, and also * Cleans out the build artifacts from platform's directory, and also
* cleans out the platform www directory if called without options specified. * cleans out the platform www directory if called without options specified.
* *
* @return {Promise} Return a promise either fulfilled, or rejected with * @return {Promise} Return a promise either fulfilled, or rejected with
* CordovaError. * CordovaError.
*/ */
clean (cleanOptions) { clean (cleanOptions) {
var self = this; var self = this;
// This will lint, checking for null won't // This will lint, checking for null won't
if (typeof cleanOptions === 'undefined') { if (typeof cleanOptions === 'undefined') {
cleanOptions = {}; cleanOptions = {};
} }
return require('./lib/check_reqs').run().then(function () { return require('./lib/check_reqs').run().then(function () {
return require('./lib/build').runClean.call(self, cleanOptions); return require('./lib/build').runClean.call(self, cleanOptions);
}).then(function () { }).then(function () {
return require('./lib/prepare').clean.call(self, cleanOptions); return require('./lib/prepare').clean.call(self, cleanOptions);
}); });
} }
/** /**
* Performs a requirements check for current platform. Each platform defines its * Performs a requirements check for current platform. Each platform defines its
* own set of requirements, which should be resolved before platform can be * own set of requirements, which should be resolved before platform can be
* built successfully. * built successfully.
* *
* @return {Promise<Requirement[]>} Promise, resolved with set of Requirement * @return {Promise<Requirement[]>} Promise, resolved with set of Requirement
* objects for current platform. * objects for current platform.
*/ */
requirements () { requirements () {
return require('./lib/check_reqs').check_all(); return require('./lib/check_reqs').check_all();
} }
/** /**
* Installs platform to specified directory and creates a platform project. * Installs platform to specified directory and creates a platform project.
* *
* @param {String} destination Destination directory, where insatll platform to * @param {String} destination Destination directory, where insatll platform to
* @param {ConfigParser} [config] ConfgiParser instance, used to retrieve * @param {ConfigParser} [config] ConfgiParser instance, used to retrieve
* project creation options, such as package id and project name. * project creation options, such as package id and project name.
* @param {Object} [options] An options object. The most common options are: * @param {Object} [options] An options object. The most common options are:
* @param {String} [options.customTemplate] A path to custom template, that * @param {String} [options.customTemplate] A path to custom template, that
* should override the default one from platform. * should override the default one from platform.
* @param {Boolean} [options.link] Flag that indicates that platform's * @param {Boolean} [options.link] Flag that indicates that platform's
* sources will be linked to installed platform instead of copying. * sources will be linked to installed platform instead of copying.
* @param {EventEmitter} [events] An EventEmitter instance that will be used for * @param {EventEmitter} [events] An EventEmitter instance that will be used for
* logging purposes. If no EventEmitter provided, all events will be logged to * logging purposes. If no EventEmitter provided, all events will be logged to
* console * console
* *
* @return {Promise<PlatformApi>} Promise either fulfilled with PlatformApi * @return {Promise<PlatformApi>} Promise either fulfilled with PlatformApi
* instance or rejected with CordovaError. * instance or rejected with CordovaError.
*/ */
static createPlatform (destination, config, options, events) { static createPlatform (destination, config, options, events) {
events = setupEvents(events); events = setupEvents(events);
var result; var result;
try { try {
result = require('../../lib/create').create(destination, config, options, events).then(function (destination) { result = require('../../lib/create').create(destination, config, options, events).then(function (destination) {
return new Api(PLATFORM, destination, events); return new Api(PLATFORM, destination, events);
}); });
} catch (e) { } catch (e) {
events.emit('error', 'createPlatform is not callable from the android project API.'); events.emit('error', 'createPlatform is not callable from the android project API.');
throw (e); throw (e);
} }
return result; return result;
} }
/** /**
* Updates already installed platform. * Updates already installed platform.
* *
* @param {String} destination Destination directory, where platform installed * @param {String} destination Destination directory, where platform installed
* @param {Object} [options] An options object. The most common options are: * @param {Object} [options] An options object. The most common options are:
* @param {String} [options.customTemplate] A path to custom template, that * @param {String} [options.customTemplate] A path to custom template, that
* should override the default one from platform. * should override the default one from platform.
* @param {Boolean} [options.link] Flag that indicates that platform's * @param {Boolean} [options.link] Flag that indicates that platform's
* sources will be linked to installed platform instead of copying. * sources will be linked to installed platform instead of copying.
* @param {EventEmitter} [events] An EventEmitter instance that will be used for * @param {EventEmitter} [events] An EventEmitter instance that will be used for
* logging purposes. If no EventEmitter provided, all events will be logged to * logging purposes. If no EventEmitter provided, all events will be logged to
* console * console
* *
* @return {Promise<PlatformApi>} Promise either fulfilled with PlatformApi * @return {Promise<PlatformApi>} Promise either fulfilled with PlatformApi
* instance or rejected with CordovaError. * instance or rejected with CordovaError.
*/ */
static updatePlatform (destination, options, events) { static updatePlatform (destination, options, events) {
events = setupEvents(events); events = setupEvents(events);
var result; var result;
try { try {
result = require('../../lib/create').update(destination, options, events).then(function (destination) { result = require('../../lib/create').update(destination, options, events).then(function (destination) {
return new Api(PLATFORM, destination, events); return new Api(PLATFORM, destination, events);
}); });
} catch (e) { } catch (e) {
events.emit('error', 'updatePlatform is not callable from the android project API, you will need to do this manually.'); events.emit('error', 'updatePlatform is not callable from the android project API, you will need to do this manually.');
throw (e); throw (e);
} }
return result; return result;
} }
static version () { static version () {
return VERSION; return VERSION;
} }
} }
module.exports = Api; module.exports = Api;

View File

@ -1,41 +1,61 @@
/* /*
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
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
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.
*/ */
package __ID__; package __ID__;
import android.os.Bundle; import android.os.Bundle;
import org.apache.cordova.*; import org.apache.cordova.*;
import android.view.KeyEvent;
public class __ACTIVITY__ extends CordovaActivity
{ public class __ACTIVITY__ extends CordovaActivity
@Override {
public void onCreate(Bundle savedInstanceState) private static final int[] SCAN_KEYCODE = {520, 521, 522, 523};
{
super.onCreate(savedInstanceState); @Override
public void onCreate(Bundle savedInstanceState)
// enable Cordova apps to be started in the background {
Bundle extras = getIntent().getExtras(); super.onCreate(savedInstanceState);
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true); // enable Cordova apps to be started in the background
} Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
// Set by <content src="index.html" /> in config.xml moveTaskToBack(true);
loadUrl(launchUrl); }
}
} // Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode >= SCAN_KEYCODE[0] && keyCode <= SCAN_KEYCODE[SCAN_KEYCODE.length - 1]) {
}
loadUrl("javascript:cordova.fireWindowEvent('native.onKeyUp',{keycode:"+keyCode+"})");
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode >= SCAN_KEYCODE[0] && keyCode <= SCAN_KEYCODE[SCAN_KEYCODE.length - 1]) {
}
loadUrl("javascript:cordova.fireWindowEvent('native.onKeyDown',{keycode:"+keyCode+"})");
return super.onKeyDown(keyCode, event);
}
}

View File

@ -1,5 +1,5 @@
// Platform: android // Platform: android
// 538a985db128858c0a0eb4dd40fb9c8e5433fc94 // cordova-js rel/6.0.0-10-g07379820
/* /*
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
@ -19,7 +19,7 @@
under the License. under the License.
*/ */
;(function() { ;(function() {
var PLATFORM_VERSION_BUILD_LABEL = '9.1.0-dev'; var PLATFORM_VERSION_BUILD_LABEL = '9.1.0';
// file: src/scripts/require.js // file: src/scripts/require.js
var require; var require;
var define; var define;

View File

@ -1,150 +1,150 @@
/* 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
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
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.
*/ */
ext { ext {
apply from: 'cordova.gradle' apply from: 'cordova.gradle'
cdvCompileSdkVersion = privateHelpers.getProjectTarget() cdvCompileSdkVersion = privateHelpers.getProjectTarget()
cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools() cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
if (project.hasProperty('cdvMinSdkVersion') && cdvMinSdkVersion.isInteger()) { if (project.hasProperty('cdvMinSdkVersion') && cdvMinSdkVersion.isInteger()) {
cdvMinSdkVersion = cdvMinSdkVersion as int cdvMinSdkVersion = cdvMinSdkVersion as int
println '[Cordova] cdvMinSdkVersion is overridden, try it at your own risk.' println '[Cordova] cdvMinSdkVersion is overridden, try it at your own risk.'
} else { } else {
cdvMinSdkVersion = 22; // current Cordova's default cdvMinSdkVersion = 22; // current Cordova's default
} }
} }
buildscript { buildscript {
apply from: 'repositories.gradle' apply from: 'repositories.gradle'
repositories repos repositories repos
dependencies { dependencies {
// The gradle plugin and the maven plugin have to be updated after each version of Android // The gradle plugin and the maven plugin have to be updated after each version of Android
// studio comes out // studio comes out
classpath 'com.android.tools.build:gradle:4.0.0' classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
} }
} }
allprojects { allprojects {
apply from: 'repositories.gradle' apply from: 'repositories.gradle'
repositories repos repositories repos
} }
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray' apply plugin: 'com.jfrog.bintray'
group = 'org.apache.cordova' group = 'org.apache.cordova'
version = '9.1.0-dev' version = '9.1.1'
android { android {
compileSdkVersion cdvCompileSdkVersion compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion buildToolsVersion cdvBuildToolsVersion
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
// For the Android Cordova Lib, we allow changing the minSdkVersion, but it is at the users own risk // For the Android Cordova Lib, we allow changing the minSdkVersion, but it is at the users own risk
defaultConfig { defaultConfig {
minSdkVersion cdvMinSdkVersion minSdkVersion cdvMinSdkVersion
} }
sourceSets { sourceSets {
main { main {
manifest.srcFile 'AndroidManifest.xml' manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src'] java.srcDirs = ['src']
resources.srcDirs = ['src'] resources.srcDirs = ['src']
aidl.srcDirs = ['src'] aidl.srcDirs = ['src']
renderscript.srcDirs = ['src'] renderscript.srcDirs = ['src']
res.srcDirs = ['res'] res.srcDirs = ['res']
assets.srcDirs = ['assets'] assets.srcDirs = ['assets']
} }
} }
packagingOptions { packagingOptions {
exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE'
} }
} }
install { install {
repositories.mavenInstaller { repositories.mavenInstaller {
pom { pom {
project { project {
packaging 'aar' packaging 'aar'
name 'Cordova' name 'Cordova'
url 'https://cordova.apache.org' url 'https://cordova.apache.org'
licenses { licenses {
license { license {
name 'The Apache Software License, Version 2.0' name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt' url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
} }
} }
developers { developers {
developer { developer {
id 'stevengill' id 'stevengill'
name 'Steve Gill' name 'Steve Gill'
} }
} }
scm { scm {
connection 'scm:git:https://github.com/apache/cordova-android.git' connection 'scm:git:https://github.com/apache/cordova-android.git'
developerConnection 'scm:git:git@github.com:apache/cordova-android.git' developerConnection 'scm:git:git@github.com:apache/cordova-android.git'
url 'https://github.com/apache/cordova-android' url 'https://github.com/apache/cordova-android'
} }
} }
} }
} }
} }
task sourcesJar(type: Jar) { task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs from android.sourceSets.main.java.srcDirs
classifier = 'sources' classifier = 'sources'
} }
artifacts { artifacts {
archives sourcesJar archives sourcesJar
} }
bintray { bintray {
user = System.getenv('BINTRAY_USER') user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY') key = System.getenv('BINTRAY_KEY')
configurations = ['archives'] configurations = ['archives']
pkg { pkg {
repo = 'maven' repo = 'maven'
name = 'cordova-android' name = 'cordova-android'
userOrg = 'cordova' userOrg = 'cordova'
licenses = ['Apache-2.0'] licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/apache/cordova-android' vcsUrl = 'https://github.com/apache/cordova-android'
websiteUrl = 'https://cordova.apache.org' websiteUrl = 'https://cordova.apache.org'
issueTrackerUrl = 'https://github.com/apache/cordova-android/issues' issueTrackerUrl = 'https://github.com/apache/cordova-android/issues'
publicDownloadNumbers = true publicDownloadNumbers = true
licenses = ['Apache-2.0'] licenses = ['Apache-2.0']
labels = ['android', 'cordova', 'phonegap'] labels = ['android', 'cordova', 'phonegap']
version { version {
name = '9.1.0-dev' name = '9.1.0'
released = new Date() released = new Date()
vcsTag = '9.1.0-dev' vcsTag = '9.1.0'
} }
} }
} }

View File

@ -1,142 +1,142 @@
/* /*
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
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
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.
*/ */
package org.apache.cordova; package org.apache.cordova;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.view.View; import android.view.View;
import android.webkit.WebChromeClient.CustomViewCallback; import android.webkit.WebChromeClient.CustomViewCallback;
/** /**
* Main interface for interacting with a Cordova webview - implemented by CordovaWebViewImpl. * Main interface for interacting with a Cordova webview - implemented by CordovaWebViewImpl.
* This is an interface so that it can be easily mocked in tests. * This is an interface so that it can be easily mocked in tests.
* Methods may be added to this interface without a major version bump, as plugins & embedders * Methods may be added to this interface without a major version bump, as plugins & embedders
* are not expected to implement it. * are not expected to implement it.
*/ */
public interface CordovaWebView { public interface CordovaWebView {
public static final String CORDOVA_VERSION = "9.1.0-dev"; public static final String CORDOVA_VERSION = "9.1.1";
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences); void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
boolean isInitialized(); boolean isInitialized();
View getView(); View getView();
void loadUrlIntoView(String url, boolean recreatePlugins); void loadUrlIntoView(String url, boolean recreatePlugins);
void stopLoading(); void stopLoading();
boolean canGoBack(); boolean canGoBack();
void clearCache(); void clearCache();
/** Use parameter-less overload */ /** Use parameter-less overload */
@Deprecated @Deprecated
void clearCache(boolean b); void clearCache(boolean b);
void clearHistory(); void clearHistory();
boolean backHistory(); boolean backHistory();
void handlePause(boolean keepRunning); void handlePause(boolean keepRunning);
void onNewIntent(Intent intent); void onNewIntent(Intent intent);
void handleResume(boolean keepRunning); void handleResume(boolean keepRunning);
void handleStart(); void handleStart();
void handleStop(); void handleStop();
void handleDestroy(); void handleDestroy();
/** /**
* Send JavaScript statement back to JavaScript. * Send JavaScript statement back to JavaScript.
* *
* Deprecated (https://issues.apache.org/jira/browse/CB-6851) * Deprecated (https://issues.apache.org/jira/browse/CB-6851)
* Instead of executing snippets of JS, you should use the exec bridge * Instead of executing snippets of JS, you should use the exec bridge
* to create a Java->JS communication channel. * to create a Java->JS communication channel.
* To do this: * To do this:
* 1. Within plugin.xml (to have your JS run before deviceready): * 1. Within plugin.xml (to have your JS run before deviceready):
* <js-module><runs/></js-module> * <js-module><runs/></js-module>
* 2. Within your .js (call exec on start-up): * 2. Within your .js (call exec on start-up):
* require('cordova/channel').onCordovaReady.subscribe(function() { * require('cordova/channel').onCordovaReady.subscribe(function() {
* require('cordova/exec')(win, null, 'Plugin', 'method', []); * require('cordova/exec')(win, null, 'Plugin', 'method', []);
* function win(message) { * function win(message) {
* ... process message from java here ... * ... process message from java here ...
* } * }
* }); * });
* 3. Within your .java: * 3. Within your .java:
* PluginResult dataResult = new PluginResult(PluginResult.Status.OK, CODE); * PluginResult dataResult = new PluginResult(PluginResult.Status.OK, CODE);
* dataResult.setKeepCallback(true); * dataResult.setKeepCallback(true);
* savedCallbackContext.sendPluginResult(dataResult); * savedCallbackContext.sendPluginResult(dataResult);
*/ */
@Deprecated @Deprecated
void sendJavascript(String statememt); void sendJavascript(String statememt);
/** /**
* Load the specified URL in the Cordova webview or a new browser instance. * Load the specified URL in the Cordova webview or a new browser instance.
* *
* NOTE: If openExternal is false, only whitelisted URLs can be loaded. * NOTE: If openExternal is false, only whitelisted URLs can be loaded.
* *
* @param url The url to load. * @param url The url to load.
* @param openExternal Load url in browser instead of Cordova webview. * @param openExternal Load url in browser instead of Cordova webview.
* @param clearHistory Clear the history stack, so new page becomes top of history * @param clearHistory Clear the history stack, so new page becomes top of history
* @param params Parameters for new app * @param params Parameters for new app
*/ */
void showWebPage(String url, boolean openExternal, boolean clearHistory, Map<String, Object> params); void showWebPage(String url, boolean openExternal, boolean clearHistory, Map<String, Object> params);
/** /**
* Deprecated in 4.0.0. Use your own View-toggling logic. * Deprecated in 4.0.0. Use your own View-toggling logic.
*/ */
@Deprecated @Deprecated
boolean isCustomViewShowing(); boolean isCustomViewShowing();
/** /**
* Deprecated in 4.0.0. Use your own View-toggling logic. * Deprecated in 4.0.0. Use your own View-toggling logic.
*/ */
@Deprecated @Deprecated
void showCustomView(View view, CustomViewCallback callback); void showCustomView(View view, CustomViewCallback callback);
/** /**
* Deprecated in 4.0.0. Use your own View-toggling logic. * Deprecated in 4.0.0. Use your own View-toggling logic.
*/ */
@Deprecated @Deprecated
void hideCustomView(); void hideCustomView();
CordovaResourceApi getResourceApi(); CordovaResourceApi getResourceApi();
void setButtonPlumbedToJs(int keyCode, boolean override); void setButtonPlumbedToJs(int keyCode, boolean override);
boolean isButtonPlumbedToJs(int keyCode); boolean isButtonPlumbedToJs(int keyCode);
void sendPluginResult(PluginResult cr, String callbackId); void sendPluginResult(PluginResult cr, String callbackId);
PluginManager getPluginManager(); PluginManager getPluginManager();
CordovaWebViewEngine getEngine(); CordovaWebViewEngine getEngine();
CordovaPreferences getPreferences(); CordovaPreferences getPreferences();
ICordovaCookieManager getCookieManager(); ICordovaCookieManager getCookieManager();
String getUrl(); String getUrl();
// TODO: Work on deleting these by removing refs from plugins. // TODO: Work on deleting these by removing refs from plugins.
Context getContext(); Context getContext();
void loadUrl(String url); void loadUrl(String url);
Object postMessage(String id, Object data); Object postMessage(String id, Object data);
} }

View File

@ -79,6 +79,13 @@ public class SystemWebView extends WebView implements CordovaWebViewEngine.Engin
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) { public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getKeyCode()>=520 && event.getKeyCode() <=523){
if (event.getAction() == KeyEvent.ACTION_UP) {
loadUrl("javascript:cordova.fireWindowEvent('native.onKeyUp',{keycode:"+event.getKeyCode()+"})");
} else if(event.getAction() == KeyEvent.ACTION_DOWN){
loadUrl("javascript:cordova.fireWindowEvent('native.onKeyDown',{keycode:"+event.getKeyCode()+"})");
}
}
Boolean ret = parentEngine.client.onDispatchKeyEvent(event); Boolean ret = parentEngine.client.onDispatchKeyEvent(event);
if (ret != null) { if (ret != null) {
return ret.booleanValue(); return ret.booleanValue();

6962
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +1,59 @@
{ {
"name": "cordova-android", "name": "cordova-android",
"version": "9.1.0", "version": "9.1.1",
"description": "cordova-android release", "description": "cordova-android release",
"bin": { "bin": {
"create": "bin/create" "create": "bin/create"
}, },
"main": "bin/templates/cordova/Api.js", "main": "bin/templates/cordova/Api.js",
"repository": "github:apache/cordova-android", "repository": "github:apache/cordova-android",
"bugs": "https://github.com/apache/cordova-android/issues", "bugs": "https://github.com/apache/cordova-android/issues",
"keywords": [ "keywords": [
"android", "android",
"cordova", "cordova",
"apache" "apache"
], ],
"scripts": { "scripts": {
"test": "npm run lint && npm run cover && npm run java-unit-tests", "test": "npm run lint && npm run cover && npm run java-unit-tests",
"lint": "eslint . \"bin/**/!(*.*|gitignore)\"", "lint": "eslint . \"bin/**/!(*.*|gitignore)\"",
"unit-tests": "jasmine --config=spec/unit/jasmine.json", "unit-tests": "jasmine --config=spec/unit/jasmine.json",
"cover": "nyc jasmine --config=spec/coverage.json", "cover": "nyc jasmine --config=spec/coverage.json",
"e2e-tests": "jasmine --config=spec/e2e/jasmine.json", "e2e-tests": "jasmine --config=spec/e2e/jasmine.json",
"java-unit-tests": "node test/run_java_unit_tests.js", "java-unit-tests": "node test/run_java_unit_tests.js",
"clean:java-unit-tests": "node test/clean.js" "clean:java-unit-tests": "node test/clean.js"
}, },
"author": "Apache Software Foundation", "author": "Apache Software Foundation",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"android-versions": "^1.5.0", "android-versions": "^1.5.0",
"cordova-common": "^4.0.1", "cordova-common": "^4.0.1",
"execa": "^4.0.2", "execa": "^4.0.2",
"fast-glob": "^3.2.4", "fast-glob": "^3.2.4",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
"is-path-inside": "^3.0.2", "is-path-inside": "^3.0.2",
"nopt": "^4.0.3", "nopt": "^4.0.3",
"properties-parser": "^0.3.1", "properties-parser": "^0.3.1",
"semver": "^7.3.4", "semver": "^7.3.4",
"which": "^2.0.2" "which": "^2.0.2"
}, },
"devDependencies": { "devDependencies": {
"@cordova/eslint-config": "^3.0.0", "@cordova/eslint-config": "^3.0.0",
"jasmine": "^3.5.0", "jasmine": "^3.5.0",
"jasmine-spec-reporter": "^5.0.2", "jasmine-spec-reporter": "^5.0.2",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"rewire": "^5.0.0" "rewire": "^5.0.0"
}, },
"engines": { "engines": {
"node": ">=10.10.0" "node": ">=10.10.0"
}, },
"nyc": { "nyc": {
"include": [ "include": [
"bin/lib/**", "bin/lib/**",
"bin/templates/cordova/**" "bin/templates/cordova/**"
], ],
"reporter": [ "reporter": [
"lcov", "lcov",
"text" "text"
] ]
} }
} }