summaryrefslogtreecommitdiff
path: root/plugins/cordova-plugin-crosswalk-webview/src/android
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/cordova-plugin-crosswalk-webview/src/android')
-rw-r--r--plugins/cordova-plugin-crosswalk-webview/src/android/XWalkWebViewEngine.java11
-rw-r--r--plugins/cordova-plugin-crosswalk-webview/src/android/xwalk.gradle93
2 files changed, 93 insertions, 11 deletions
diff --git a/plugins/cordova-plugin-crosswalk-webview/src/android/XWalkWebViewEngine.java b/plugins/cordova-plugin-crosswalk-webview/src/android/XWalkWebViewEngine.java
index 7e5a4f1c..9e94edbe 100644
--- a/plugins/cordova-plugin-crosswalk-webview/src/android/XWalkWebViewEngine.java
+++ b/plugins/cordova-plugin-crosswalk-webview/src/android/XWalkWebViewEngine.java
@@ -113,17 +113,6 @@ public class XWalkWebViewEngine implements CordovaWebViewEngine {
webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
}
- // TODO(ningxin): XWalkViewUIClient should provide onScrollChanged callback
- /*
- public void onScrollChanged(int l, int t, int oldl, int oldt)
- {
- super.onScrollChanged(l, t, oldl, oldt);
- //We should post a message that the scroll changed
- ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, this);
- this.postMessage("onScrollChanged", myEvent);
- }
- */
-
@Override
public boolean canGoBack() {
return this.webView.getNavigationHistory().canGoBack();
diff --git a/plugins/cordova-plugin-crosswalk-webview/src/android/xwalk.gradle b/plugins/cordova-plugin-crosswalk-webview/src/android/xwalk.gradle
new file mode 100644
index 00000000..3c0a23ee
--- /dev/null
+++ b/plugins/cordova-plugin-crosswalk-webview/src/android/xwalk.gradle
@@ -0,0 +1,93 @@
+/*
+ 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.
+*/
+
+def DEFAULT_VERSION = "org.xwalk:xwalk_core_library_beta:13+"
+def DEFAULT_COMMAND_LINE = "--disable-pull-to-refresh-effect"
+
+repositories {
+ maven {
+ url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
+ }
+}
+
+if (cdvBuildMultipleApks == null) {
+ ext.cdvBuildMultipleApks = true
+}
+if (cdvMinSdkVersion == null) {
+ ext.cdvMinSdkVersion = 14
+}
+
+def getConfigPreference(name, defaultValue) {
+ name = name.toLowerCase()
+ def xml = file("res/xml/config.xml").getText()
+ // Disable namespace awareness since Cordova doesn't use them properly
+ def root = new XmlParser(false, false).parseText(xml)
+
+ def ret = defaultValue
+ root.preference.each { it ->
+ def attrName = it.attribute("name")
+ if (attrName && attrName.toLowerCase() == name) {
+ ret = it.attribute("value")
+ }
+ }
+ return ret
+}
+
+// Set defaults before project's build-extras.gradle
+if (!project.hasProperty('xwalkVersion')) {
+ ext.xwalkVersion = getConfigPreference("xwalkversion", DEFAULT_VERSION)
+}
+if (!project.hasProperty('xwalkCommandLine')) {
+ ext.xwalkCommandLine = getConfigPreference("xwalkcommandline", DEFAULT_COMMAND_LINE)
+}
+
+// Apply values after project's build-extras.gradle
+cdvPluginPostBuildExtras.add({
+
+ def xwalkSpec = xwalkVersion
+ if ((xwalkSpec =~ /:/).count == 1) {
+ xwalkSpec = "org.xwalk:${xwalkSpec}"
+ } else if ((xwalkSpec =~ /:/).count == 0) {
+ if (xwalkSpec ==~ /\d+/) {
+ xwalkSpec = "${xwalkSpec}+"
+ }
+ xwalkSpec = "org.xwalk:xwalk_core_library_beta:${xwalkSpec}"
+ }
+
+ dependencies {
+ compile xwalkSpec
+ }
+
+ if (file('assets/xwalk-command-line').exists()) {
+ println('Not writing assets/xwalk-command-line since file already exists.')
+ return
+ }
+ android.applicationVariants.all { variant ->
+ def variantName = variant.name.capitalize()
+ def mergeTask = tasks["merge${variantName}Assets"]
+ def processTask = tasks["process${variantName}Resources"]
+ def outFile = new File (mergeTask.outputDir, "xwalk-command-line")
+ def newTask = project.task("createXwalkCommandLineFile${variantName}") << {
+ mergeTask.outputDir.mkdirs()
+ outFile.write("xwalk ${xwalkCommandLine}\n")
+ }
+ newTask.dependsOn(mergeTask)
+ processTask.dependsOn(newTask)
+ }
+})