You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/09/11 17:28:43 UTC
[01/31] android commit: CB-7291: Add external-launch-whitelist and
use it for filtering intent launches
Repository: cordova-android
Updated Branches:
refs/heads/4.0.x 0b6b06809 -> dd5a337a4
CB-7291: Add external-launch-whitelist and use it for filtering intent launches
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/8b55a169
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/8b55a169
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/8b55a169
Branch: refs/heads/4.0.x
Commit: 8b55a16986de1329956b838eed93bb23bf038cf3
Parents: 41125ea
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Aug 12 11:02:55 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Aug 12 11:26:47 2014 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/Config.java | 24 +++++++++++++++++---
.../src/org/apache/cordova/ConfigXmlParser.java | 18 +++++++++++----
.../src/org/apache/cordova/CordovaActivity.java | 12 ++++++----
.../org/apache/cordova/CordovaUriHelper.java | 24 +++++++++-----------
.../src/org/apache/cordova/CordovaWebView.java | 24 +++++++++++++-------
5 files changed, 69 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8b55a169/framework/src/org/apache/cordova/Config.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java
index 5cae9a2..f13292c 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -58,7 +58,7 @@ public class Config {
Log.e(TAG, "Config was not initialised. Did you forget to Config.init(this)?");
return;
}
- parser.getWhitelist().addWhiteListEntry(origin, subdomains);
+ parser.getInternalWhitelist().addWhiteListEntry(origin, subdomains);
}
/**
@@ -72,7 +72,21 @@ public class Config {
Log.e(TAG, "Config was not initialised. Did you forget to Config.init(this)?");
return false;
}
- return parser.getWhitelist().isUrlWhiteListed(url);
+ return parser.getInternalWhitelist().isUrlWhiteListed(url);
+ }
+
+ /**
+ * Determine if URL is in approved list of URLs to launch external applications.
+ *
+ * @param url
+ * @return true if whitelisted
+ */
+ public static boolean isUrlExternallyWhiteListed(String url) {
+ if (parser == null) {
+ Log.e(TAG, "Config was not initialised. Did you forget to Config.init(this)?");
+ return false;
+ }
+ return parser.getExternalWhitelist().isUrlWhiteListed(url);
}
public static String getStartUrl() {
@@ -87,7 +101,11 @@ public class Config {
}
public static Whitelist getWhitelist() {
- return parser.getWhitelist();
+ return parser.getInternalWhitelist();
+ }
+
+ public static Whitelist getExternalWhitelist() {
+ return parser.getExternalWhitelist();
}
public static List<PluginEntry> getPluginEntries() {
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8b55a169/framework/src/org/apache/cordova/ConfigXmlParser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/ConfigXmlParser.java b/framework/src/org/apache/cordova/ConfigXmlParser.java
index a5958ef..9179f98 100644
--- a/framework/src/org/apache/cordova/ConfigXmlParser.java
+++ b/framework/src/org/apache/cordova/ConfigXmlParser.java
@@ -37,11 +37,16 @@ public class ConfigXmlParser {
private String launchUrl = "file:///android_asset/www/index.html";
private CordovaPreferences prefs = new CordovaPreferences();
- private Whitelist whitelist = new Whitelist();
+ private Whitelist internalWhitelist = new Whitelist();
+ private Whitelist externalWhitelist = new Whitelist();
private ArrayList<PluginEntry> pluginEntries = new ArrayList<PluginEntry>(20);
- public Whitelist getWhitelist() {
- return whitelist;
+ public Whitelist getInternalWhitelist() {
+ return internalWhitelist;
+ }
+
+ public Whitelist getExternalWhitelist() {
+ return externalWhitelist;
}
public CordovaPreferences getPreferences() {
@@ -104,8 +109,13 @@ public class ConfigXmlParser {
else if (strNode.equals("access")) {
String origin = xml.getAttributeValue(null, "origin");
String subdomains = xml.getAttributeValue(null, "subdomains");
+ boolean external = (xml.getAttributeValue(null, "launch-external") != null);
if (origin != null) {
- whitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
+ if (external) {
+ externalWhitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
+ } else {
+ internalWhitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
+ }
}
}
else if (strNode.equals("preference")) {
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8b55a169/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index 2fdb9a7..190309e 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -130,7 +130,8 @@ public class CordovaActivity extends Activity implements CordovaInterface {
// Read from config.xml:
protected CordovaPreferences preferences;
- protected Whitelist whitelist;
+ protected Whitelist internalWhitelist;
+ protected Whitelist externalWhitelist;
protected String launchUrl;
protected ArrayList<PluginEntry> pluginEntries;
@@ -216,7 +217,8 @@ public class CordovaActivity extends Activity implements CordovaInterface {
preferences = parser.getPreferences();
preferences.setPreferencesBundle(getIntent().getExtras());
preferences.copyIntoIntentExtras(this);
- whitelist = parser.getWhitelist();
+ internalWhitelist = parser.getInternalWhitelist();
+ externalWhitelist = parser.getExternalWhitelist();
launchUrl = parser.getLaunchUrl();
pluginEntries = parser.getPluginEntries();
Config.parser = parser;
@@ -324,7 +326,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
if (appView.pluginManager == null) {
appView.init(this, webViewClient != null ? webViewClient : makeWebViewClient(appView),
webChromeClient != null ? webChromeClient : makeChromeClient(appView),
- pluginEntries, whitelist, preferences);
+ pluginEntries, internalWhitelist, externalWhitelist, preferences);
}
// TODO: Have the views set this themselves.
@@ -789,7 +791,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
// If errorUrl specified, then load it
final String errorUrl = preferences.getString("errorUrl", null);
- if ((errorUrl != null) && (errorUrl.startsWith("file://") || whitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
+ if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
// Load URL on UI thread
me.runOnUiThread(new Runnable() {
@@ -849,7 +851,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
*/
@Deprecated // Use whitelist object directly.
public boolean isUrlWhiteListed(String url) {
- return whitelist.isUrlWhiteListed(url);
+ return internalWhitelist.isUrlWhiteListed(url);
}
/*
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8b55a169/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaUriHelper.java b/framework/src/org/apache/cordova/CordovaUriHelper.java
index bb78592..ada2851 100644
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@ -48,18 +48,11 @@ class CordovaUriHelper {
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
boolean shouldOverrideUrlLoading(WebView view, String url) {
- // The WebView should support http and https when going on the Internet
- if(url.startsWith("http:") || url.startsWith("https:"))
- {
- // We only need to whitelist sites on the Internet!
- if(appView.getWhitelist().isUrlWhiteListed(url))
- {
- return false;
- }
- }
// Give plugins the chance to handle the url
- else if (this.appView.pluginManager.onOverrideUrlLoading(url)) {
-
+ if (this.appView.pluginManager.onOverrideUrlLoading(url)) {
+ // Do nothing other than what the plugins wanted.
+ // If any returned true, then the request was handled.
+ return true;
}
else if(url.startsWith("file://") | url.startsWith("data:"))
{
@@ -67,7 +60,11 @@ class CordovaUriHelper {
//DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
return url.contains("app_webview");
}
- else
+ else if (appView.getWhitelist().isUrlWhiteListed(url)) {
+ // Allow internal navigation
+ return false;
+ }
+ else if (appView.getExternalWhitelist().isUrlWhiteListed(url))
{
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
@@ -78,11 +75,12 @@ class CordovaUriHelper {
intent.setSelector(null);
}
this.cordova.getActivity().startActivity(intent);
+ return true;
} catch (android.content.ActivityNotFoundException e) {
LOG.e(TAG, "Error loading url " + url, e);
}
}
- //Default behaviour should be to load the default intent, let's see what happens!
+ // Intercept the request and do nothing with it -- block it
return true;
}
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8b55a169/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 72aa171..403a7ae 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -88,7 +88,9 @@ public class CordovaWebView extends WebView {
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private CordovaResourceApi resourceApi;
- private Whitelist whitelist;
+ private Whitelist internalWhitelist;
+ private Whitelist externalWhitelist;
+
// The URL passed to loadUrl(), not necessarily the URL of the current page.
String loadedUrl;
private CordovaPreferences preferences;
@@ -135,14 +137,16 @@ public class CordovaWebView extends WebView {
// Use two-phase init so that the control will work with XML layouts.
public void init(CordovaInterface cordova, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient,
- List<PluginEntry> pluginEntries, Whitelist whitelist, CordovaPreferences preferences) {
+ List<PluginEntry> pluginEntries, Whitelist internalWhitelist, Whitelist externalWhitelist,
+ CordovaPreferences preferences) {
if (this.cordova != null) {
throw new IllegalStateException();
}
this.cordova = cordova;
this.viewClient = webViewClient;
this.chromeClient = webChromeClient;
- this.whitelist = whitelist;
+ this.internalWhitelist = internalWhitelist;
+ this.externalWhitelist = externalWhitelist;
this.preferences = preferences;
super.setWebChromeClient(webChromeClient);
super.setWebViewClient(webViewClient);
@@ -165,7 +169,7 @@ public class CordovaWebView extends WebView {
if (!Config.isInitialized()) {
Config.init(cdv.getActivity());
}
- init(cdv, makeWebViewClient(cdv), makeWebChromeClient(cdv), Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
+ init(cdv, makeWebViewClient(cdv), makeWebChromeClient(cdv), Config.getPluginEntries(), Config.getWhitelist(), Config.getExternalWhitelist(), Config.getPreferences());
}
}
@@ -319,9 +323,13 @@ public class CordovaWebView extends WebView {
public Whitelist getWhitelist() {
- return this.whitelist;
+ return this.internalWhitelist;
}
-
+
+ public Whitelist getExternalWhitelist() {
+ return this.externalWhitelist;
+ }
+
/**
* Load the url into the webview.
*
@@ -427,7 +435,7 @@ public class CordovaWebView extends WebView {
if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
LOG.d(TAG, ">>> loadUrlNow()");
}
- if (url.startsWith("file://") || url.startsWith("javascript:") || whitelist.isUrlWhiteListed(url)) {
+ if (url.startsWith("file://") || url.startsWith("javascript:") || internalWhitelist.isUrlWhiteListed(url)) {
super.loadUrl(url);
}
}
@@ -560,7 +568,7 @@ public class CordovaWebView extends WebView {
if (!openExternal) {
// Make sure url is in whitelist
- if (url.startsWith("file://") || whitelist.isUrlWhiteListed(url)) {
+ if (url.startsWith("file://") || internalWhitelist.isUrlWhiteListed(url)) {
// TODO: What about params?
// Load new URL
this.loadUrl(url);
[11/31] android commit: CB-3445: Ensure that JAR files in libs
directory are included
Posted by ia...@apache.org.
CB-3445: Ensure that JAR files in libs directory are included
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/7a091824
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/7a091824
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/7a091824
Branch: refs/heads/4.0.x
Commit: 7a091824466cd86a22951c3b57fdd95204021dbb
Parents: eb8cf56
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Aug 28 11:26:35 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Aug 28 13:17:26 2014 -0400
----------------------------------------------------------------------
bin/templates/project/build.gradle | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7a091824/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index dcebbc5..8bccc41 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -15,6 +15,7 @@ buildscript {
ext.multiarch=false
dependencies {
+ compile fileTree(dir: 'libs', include: '*.jar')
for (subproject in getProjectList()) {
compile project(subproject)
}
[31/31] android commit: Merge branch 'master' into 4.0.x
Posted by ia...@apache.org.
Merge branch 'master' into 4.0.x
Conflicts:
framework/src/org/apache/cordova/CordovaActivity.java
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/dd5a337a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/dd5a337a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/dd5a337a
Branch: refs/heads/4.0.x
Commit: dd5a337a49cac4110b0c114ee5c65020c4a2ecf6
Parents: 51e634c bf13fd4
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Sep 11 10:18:35 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Sep 11 10:18:35 2014 -0400
----------------------------------------------------------------------
bin/lib/check_reqs.js | 52 +++++---
bin/lib/create.js | 7 +-
bin/templates/project/build.gradle | 25 +++-
bin/templates/project/cordova.gradle | 123 +++++++++++++++++++
framework/build.gradle | 25 +++-
.../src/org/apache/cordova/CordovaActivity.java | 2 -
.../apache/cordova/test/SabotagedActivity.java | 19 +++
.../test/junit/IntentUriOverrideTest.java | 19 +++
8 files changed, 244 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd5a337a/bin/lib/create.js
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd5a337a/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaActivity.java
index c2971ae,bf1fd6a..6ec6791
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@@ -208,14 -244,12 +208,12 @@@ public class CordovaActivity extends Ac
1.0F));
// Add web view but make it invisible while loading URL
- appView.setVisibility(View.INVISIBLE);
- root.addView((View) appView);
+ appView.getView().setVisibility(View.INVISIBLE);
+ root.addView(appView.getView());
setContentView(root);
- // TODO: Setting this on the appView causes it to show when <html style="opacity:0">.
int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
root.setBackgroundColor(backgroundColor);
- appView.getView().setBackgroundColor(backgroundColor);
}
/**
[22/31] android commit: CB-7463: Looked at the Apache BigTop git,
gradle uses C-style comments
Posted by ia...@apache.org.
CB-7463: Looked at the Apache BigTop git, gradle uses C-style comments
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/83546510
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/83546510
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/83546510
Branch: refs/heads/4.0.x
Commit: 8354651059af864d92e7be63fa334a71ee9fc402
Parents: 81cc3c2
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Sep 4 10:49:43 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Sep 4 10:49:43 2014 -0700
----------------------------------------------------------------------
framework/build.gradle | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/83546510/framework/build.gradle
----------------------------------------------------------------------
diff --git a/framework/build.gradle b/framework/build.gradle
index 82c1ac2..47341b3 100644
--- a/framework/build.gradle
+++ b/framework/build.gradle
@@ -1,3 +1,24 @@
+/*
+ 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.
+*/
+
+
+
buildscript {
repositories {
mavenCentral()
[06/31] android commit: CB-7291 propogate change in method signature
to the native tests
Posted by ia...@apache.org.
CB-7291 propogate change in method signature to the native tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/94c096dd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/94c096dd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/94c096dd
Branch: refs/heads/4.0.x
Commit: 94c096dd5b2a042534de72a53ee9bf166118eb83
Parents: 2e3e4ec
Author: Marcel Kinard <cm...@gmail.com>
Authored: Tue Aug 26 16:38:04 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Tue Aug 26 16:38:04 2014 -0400
----------------------------------------------------------------------
test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/94c096dd/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index 1c1789e..d427047 100644
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@ -52,7 +52,7 @@ public class CordovaWebViewTestActivity extends Activity implements CordovaInter
cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
- Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
+ Config.getPluginEntries(), Config.getWhitelist(), Config.getExternalWhitelist(), Config.getPreferences());
cordovaWebView.loadUrl("file:///android_asset/www/index.html");
@@ -105,4 +105,4 @@ public class CordovaWebViewTestActivity extends Activity implements CordovaInter
cordovaWebView.handleDestroy();
}
}
-}
\ No newline at end of file
+}
[25/31] android commit: CB-7512: Determine SDK and build tools
version dynamcally at build time
Posted by ia...@apache.org.
CB-7512: Determine SDK and build tools version dynamcally at build time
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/c8bbdb23
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/c8bbdb23
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/c8bbdb23
Branch: refs/heads/4.0.x
Commit: c8bbdb23defb4a2fc1227b7f624934df29695937
Parents: 7ee8117
Author: Ian Clelland <ic...@chromium.org>
Authored: Wed Sep 10 10:57:43 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Sep 10 10:57:43 2014 -0400
----------------------------------------------------------------------
bin/templates/project/build.gradle | 6 +-
bin/templates/project/cordova.gradle | 147 ++++++++++++++++++++++++++++++
framework/build.gradle | 4 +-
3 files changed, 153 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c8bbdb23/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index f56784e..e3468d8 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -19,6 +19,8 @@
import java.util.regex.Pattern
+ext.cordova = {}
+apply from: 'cordova.gradle', to: ext.cordova
apply plugin: 'android'
buildscript {
@@ -57,8 +59,8 @@ android {
versionCode Integer.parseInt("" + getVersionCodeFromManifest() + "0")
}
- compileSdkVersion 19
- buildToolsVersion "19.0.0"
+ compileSdkVersion cordova.cordovaSdkVersion
+ buildToolsVersion cordova.cordovaBuildToolsVersion
if (multiarch || System.env.BUILD_MULTIPLE_APKS) {
productFlavors {
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c8bbdb23/bin/templates/project/cordova.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova.gradle b/bin/templates/project/cordova.gradle
new file mode 100644
index 0000000..40529d3
--- /dev/null
+++ b/bin/templates/project/cordova.gradle
@@ -0,0 +1,147 @@
+/*
+ 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.
+*/
+
+int[] getAvailableSdks() {
+ def availableSdks = new ByteArrayOutputStream()
+ exec {
+ commandLine 'android', 'list', 'target', '--compact'
+ standardOutput = availableSdks
+ }
+ availableSdks
+ .toString()
+ .tokenize('\n')
+ .findAll { it ==~ /android-(\d+).*/ }
+ .collect { (it =~ /android-(\d+).*/)[0][1].toInteger() }
+ .sort( { a, b -> b <=> a } )
+}
+
+int highestSdkAvailable(int minSdkVersion) {
+ def availableSdks
+ try {
+ availableSdks = getAvailableSdks()
+ } catch (e) {
+ println "An exception occurred while trying to find the Android SDK."
+ throw e
+ }
+ if (availableSdks.length > 0) {
+ def highestSdk = availableSdks[0]
+ if (highestSdk < minSdkVersion) {
+ throw new RuntimeException(
+ "No usable Android SDK found. Highest installed version is " +
+ highestSdk + "; minimum version required is " + minSdkVersion + ".")
+ }
+ highestSdk
+ } else {
+ throw new RuntimeException(
+ "No installed SDKs found. Please install the Android SDK version " +
+ minSdkVersion + " or higher.")
+ }
+}
+
+String[] getAvailableBuildTools() {
+ def buildToolsDir = new File(getAndroidSdkDir(), "build-tools")
+ buildToolsDir.list()
+ .findAll { it ==~ /[0-9.]+/ }
+ .sort { a, b -> compareVersions(b, a) }
+}
+
+String latestBuildToolsAvailable(String minBuildToolsVersion) {
+ def availableBuildToolsVersions
+ try {
+ availableBuildToolsVersions = getAvailableBuildTools()
+ } catch (e) {
+ println "An exception occurred while trying to find the Android build tools."
+ throw e
+ }
+ if (availableBuildToolsVersions.length > 0) {
+ def highestBuildToolsVersion = availableBuildToolsVersions[0]
+ if (compareVersions(highestBuildToolsVersion, minBuildToolsVersion) < 0) {
+ throw new RuntimeException(
+ "No usable Android build tools found. Highest installed version is " +
+ highestBuildToolsVersion + "; minimum version required is " +
+ minBuildToolsVersion + ".")
+ }
+ highestBuildToolsVersion
+ } else {
+ throw new RuntimeException(
+ "No installed build tools found. Please install the Android build tools version " +
+ minBuildToolsVersion + " or higher.")
+ }
+}
+
+// Return the first non-zero result of subtracting version list elements
+// pairwise. If they are all identical, return the difference in length of
+// the two lists.
+int compareVersionList(Collection aParts, Collection bParts) {
+ def pairs = ([aParts, bParts]).transpose()
+ pairs.findResult(aParts.size()-bParts.size()) {it[0] - it[1] != 0 ? it[0] - it[1] : null}
+}
+
+// Compare two version strings, such as "19.0.0" and "18.1.1.0". If all matched
+// elements are identical, the longer version is the largest by this method.
+// Examples:
+// "19.0.0" > "19"
+// "19.0.1" > "19.0.0"
+// "19.1.0" > "19.0.1"
+// "19" > "18.999.999"
+int compareVersions(String a, String b) {
+ def aParts = a.tokenize('.').collect {it.toInteger()}
+ def bParts = b.tokenize('.').collect {it.toInteger()}
+ compareVersionList(aParts, bParts)
+}
+
+String getAndroidSdkDir() {
+ def rootDir = project.rootDir
+ def localProperties = new File(rootDir, 'local.properties')
+ def androidSdkDir = ""
+ if (localProperties.exists()) {
+ Properties properties = new Properties()
+ localProperties.withInputStream { instr ->
+ properties.load(instr)
+ }
+ def sdkDirProp = properties.getProperty('sdk.dir')
+ if (sdkDirProp != null) {
+ androidSdkDir = sdkDirProp
+ } else {
+ sdkDirProp = properties.getProperty('android.dir')
+ if (sdkDirProp != null) {
+ androidSdkDir = (new File(rootDir, sdkDirProp)).getAbsolutePath()
+ } else {
+ throw new RuntimeException(
+ "No sdk.dir property defined in local.properties file.")
+ }
+ }
+ } else {
+ String envVar = System.getenv("ANDROID_HOME")
+ if (envVar != null) {
+ androidSdkDir = envVar
+ } else {
+ String property = System.getProperty("android.home")
+ if (property != null) {
+ androidSdkDir = property
+ }
+ }
+ }
+ println androidSdkDir
+ androidSdkDir
+}
+
+cordovaSdkVersion = highestSdkAvailable(19)
+cordovaBuildToolsVersion = latestBuildToolsAvailable("19.0.0")
+
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c8bbdb23/framework/build.gradle
----------------------------------------------------------------------
diff --git a/framework/build.gradle b/framework/build.gradle
index 47341b3..59e1ae7 100644
--- a/framework/build.gradle
+++ b/framework/build.gradle
@@ -32,8 +32,8 @@ buildscript {
apply plugin: 'android-library'
android {
- compileSdkVersion 19
- buildToolsVersion "19.0.0"
+ compileSdkVersion cordova.cordovaSdkVersion
+ buildToolsVersion cordova.cordovaBuildToolsVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
[12/31] android commit: CB-3445: Add environment variable
'BUILD_MULTIPLE_APKS' for splitting APKs based on architecture
Posted by ia...@apache.org.
CB-3445: Add environment variable 'BUILD_MULTIPLE_APKS' for splitting APKs based on architecture
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/34dde535
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/34dde535
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/34dde535
Branch: refs/heads/4.0.x
Commit: 34dde535068579b762dcda89ba92f8ab8adf8a97
Parents: 7a09182
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Aug 28 16:17:54 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Aug 28 16:18:02 2014 -0400
----------------------------------------------------------------------
bin/templates/cordova/lib/build.js | 26 +++++++++++++++++++-------
bin/templates/project/build.gradle | 2 +-
2 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/34dde535/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 1f4810d..77fe259 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -156,13 +156,25 @@ var builders = {
},
gradle: {
getArgs: function(cmd) {
- var lintSteps = [
- 'lint',
- 'lintVitalRelease',
- 'compileLint',
- 'copyReleaseLint',
- 'copyDebugLint'
- ];
+ var lintSteps;
+ if (process.env['BUILD_MULTIPLE_APKS']) {
+ lintSteps = [
+ 'lint',
+ 'lintVitalX86Release',
+ 'lintVitalArmv7Release',
+ 'compileLint',
+ 'copyReleaseLint',
+ 'copyDebugLint'
+ ];
+ } else {
+ lintSteps = [
+ 'lint',
+ 'lintVitalRelease',
+ 'compileLint',
+ 'copyReleaseLint',
+ 'copyDebugLint'
+ ];
+ }
var args = [cmd, '-b', path.join(ROOT, 'build.gradle')];
// 10 seconds -> 6 seconds
args.push('-Dorg.gradle.daemon=true');
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/34dde535/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index 8bccc41..9d1d45a 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -41,7 +41,7 @@ android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
- if (multiarch) {
+ if (multiarch || System.env.BUILD_MULTIPLE_APKS) {
productFlavors {
armv7 {
versionCode defaultConfig.versionCode + 2
[18/31] android commit: Update JS snapshot to version 3.7.0-dev (via
coho)
Posted by ia...@apache.org.
Update JS snapshot to version 3.7.0-dev (via coho)
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/f20708a5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/f20708a5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/f20708a5
Branch: refs/heads/4.0.x
Commit: f20708a5e732f550436394aa84bf309e769e7d23
Parents: 91cf78f
Author: Steven Gill <st...@gmail.com>
Authored: Fri Aug 29 16:34:17 2014 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Fri Aug 29 16:34:17 2014 -0700
----------------------------------------------------------------------
framework/assets/www/cordova.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f20708a5/framework/assets/www/cordova.js
----------------------------------------------------------------------
diff --git a/framework/assets/www/cordova.js b/framework/assets/www/cordova.js
index 73ec0fe..3838e63 100644
--- a/framework/assets/www/cordova.js
+++ b/framework/assets/www/cordova.js
@@ -1,5 +1,5 @@
// Platform: android
-// 3.6.3
+// 3.7.0-dev-8f41e8d
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '3.6.3';
+var CORDOVA_JS_BUILD_LABEL = '3.7.0-dev-8f41e8d';
// file: src/scripts/require.js
/*jshint -W079 */
[21/31] android commit: CB-7463: Adding licences. I don't know what
the gradle syntax is for comments, that still needs to be done.
Posted by ia...@apache.org.
CB-7463: Adding licences. I don't know what the gradle syntax is for comments, that still needs to be done.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/81cc3c26
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/81cc3c26
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/81cc3c26
Branch: refs/heads/4.0.x
Commit: 81cc3c260f6df93eefcfba99e19e9ac984478bde
Parents: 4dc32e1
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Sep 4 10:32:29 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Sep 4 10:32:29 2014 -0700
----------------------------------------------------------------------
.../apache/cordova/test/SabotagedActivity.java | 19 +++++++++++++++++++
.../test/junit/IntentUriOverrideTest.java | 19 +++++++++++++++++++
2 files changed, 38 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/81cc3c26/test/src/org/apache/cordova/test/SabotagedActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/SabotagedActivity.java b/test/src/org/apache/cordova/test/SabotagedActivity.java
index e1170ba..7f3edc5 100644
--- a/test/src/org/apache/cordova/test/SabotagedActivity.java
+++ b/test/src/org/apache/cordova/test/SabotagedActivity.java
@@ -1,3 +1,22 @@
+/*
+ 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.
+*/
+
package org.apache.cordova.test;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/81cc3c26/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java b/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
index 381e0ed..559bcc7 100644
--- a/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
+++ b/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
@@ -1,3 +1,22 @@
+/*
+ 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.
+*/
+
package org.apache.cordova.test.junit;
import org.apache.cordova.CordovaWebView;
[10/31] android commit: CB-7267 update RELEASENOTES for 3.5.1
Posted by ia...@apache.org.
CB-7267 update RELEASENOTES for 3.5.1
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/eb8cf56e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/eb8cf56e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/eb8cf56e
Branch: refs/heads/4.0.x
Commit: eb8cf56e8e7ce0419dbe444fbedaa434bf4e4009
Parents: 12a2764
Author: Marcel Kinard <cm...@gmail.com>
Authored: Thu Aug 28 09:42:53 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Thu Aug 28 09:42:53 2014 -0400
----------------------------------------------------------------------
RELEASENOTES.md | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/eb8cf56e/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index d8e467b..d15f897 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -20,6 +20,17 @@
-->
## Release Notes for Cordova (Android) ##
+### 3.5.1 (August 2014) ###
+
+This was a security update to address CVE-2014-3500, CVE-2014-3501,
+and CVE-2014-3502. For more information, see
+http://cordova.apache.org/announcements/2014/08/04/android-351.html
+
+* Filter out non-launchable intents
+* Handle unsupported protocol errors in webview better
+* Update the errorurl to no longer use intents
+* Refactoring the URI handling on Cordova, removing dead code
+
### 3.5.0 (May 2014) ###
* OkHttp has broken headers. Updating for ASF compliance.
[26/31] android commit: CB-7512: Read android target from
project.properties if possible
Posted by ia...@apache.org.
CB-7512: Read android target from project.properties if possible
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/0e78dc35
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/0e78dc35
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/0e78dc35
Branch: refs/heads/4.0.x
Commit: 0e78dc35d8aaec855aca9228bf5dca1b0795cac6
Parents: c8bbdb2
Author: Ian Clelland <ic...@chromium.org>
Authored: Wed Sep 10 11:39:29 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Sep 10 11:39:29 2014 -0400
----------------------------------------------------------------------
bin/templates/project/cordova.gradle | 42 +++++++------------------------
1 file changed, 9 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0e78dc35/bin/templates/project/cordova.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova.gradle b/bin/templates/project/cordova.gradle
index 40529d3..f552a47 100644
--- a/bin/templates/project/cordova.gradle
+++ b/bin/templates/project/cordova.gradle
@@ -17,40 +17,16 @@
under the License.
*/
-int[] getAvailableSdks() {
- def availableSdks = new ByteArrayOutputStream()
- exec {
- commandLine 'android', 'list', 'target', '--compact'
- standardOutput = availableSdks
- }
- availableSdks
- .toString()
- .tokenize('\n')
- .findAll { it ==~ /android-(\d+).*/ }
- .collect { (it =~ /android-(\d+).*/)[0][1].toInteger() }
- .sort( { a, b -> b <=> a } )
-}
+import java.util.regex.Pattern
-int highestSdkAvailable(int minSdkVersion) {
- def availableSdks
- try {
- availableSdks = getAvailableSdks()
- } catch (e) {
- println "An exception occurred while trying to find the Android SDK."
- throw e
- }
- if (availableSdks.length > 0) {
- def highestSdk = availableSdks[0]
- if (highestSdk < minSdkVersion) {
- throw new RuntimeException(
- "No usable Android SDK found. Highest installed version is " +
- highestSdk + "; minimum version required is " + minSdkVersion + ".")
- }
- highestSdk
+String getProjectTarget(String defaultTarget) {
+ def manifestFile = file("project.properties")
+ def pattern = Pattern.compile("target\\s*=\\s*(.*)")
+ def matcher = pattern.matcher(manifestFile.getText())
+ if (matcher.find()) {
+ matcher.group(1)
} else {
- throw new RuntimeException(
- "No installed SDKs found. Please install the Android SDK version " +
- minSdkVersion + " or higher.")
+ defaultTarget
}
}
@@ -142,6 +118,6 @@ String getAndroidSdkDir() {
androidSdkDir
}
-cordovaSdkVersion = highestSdkAvailable(19)
+cordovaSdkVersion = getProjectTarget("android-19")
cordovaBuildToolsVersion = latestBuildToolsAvailable("19.0.0")
[28/31] android commit: CB-7330 Don't run check_reqs for bin/create.
Posted by ia...@apache.org.
CB-7330 Don't run check_reqs for bin/create.
The create / update script doesn't require any dependencies, so we
shouldn't fail without them.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/3b99760a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/3b99760a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/3b99760a
Branch: refs/heads/4.0.x
Commit: 3b99760a4250bfd8b357584d2657f6b25a1ce152
Parents: 0e78dc3
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 10 12:42:37 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 10 12:44:17 2014 -0400
----------------------------------------------------------------------
bin/lib/create.js | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/3b99760a/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index c4c6f1b..0b79533 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -226,10 +226,6 @@ exports.createProject = function(project_path, package_name, project_name, proje
return validatePackageName(package_name)
.then(function() {
validateProjectName(project_name);
- })
- // Check that requirements are met and proper targets are installed
- .then(function() {
- return check_reqs.run();
}).then(function() {
// Log the given values for the project
console.log('Creating Cordova project for the Android platform:');
@@ -305,8 +301,7 @@ function extractProjectNameFromManifest(projectPath) {
// Returns a promise.
exports.updateProject = function(projectPath, shared) {
var newVersion = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
- // Check that requirements are met and proper targets are installed
- return check_reqs.run()
+ return Q()
.then(function() {
var projectName = extractProjectNameFromManifest(projectPath);
var target_api = check_reqs.get_target();
[13/31] android commit: CB-3445: Allow build and run scripts to
select APK by architecture
Posted by ia...@apache.org.
CB-3445: Allow build and run scripts to select APK by architecture
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4bc2051f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4bc2051f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4bc2051f
Branch: refs/heads/4.0.x
Commit: 4bc2051f442473c2c3c854e18487d1058c53b58b
Parents: 34dde53
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Aug 29 16:00:13 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Aug 29 16:00:13 2014 -0400
----------------------------------------------------------------------
bin/templates/cordova/lib/build.js | 4 ++--
bin/templates/cordova/lib/device.js | 7 ++++++-
2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4bc2051f/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 77fe259..30056f4 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -342,9 +342,9 @@ module.exports.run = function(options) {
* the script will error out. (should we error or just return undefined?)
* This is called by the run script to install the apk to the device
*/
-module.exports.get_apk = function(build_type) {
+module.exports.get_apk = function(build_type, architecture) {
var outputDir = path.join(ROOT, 'out');
- var candidates = find_files(outputDir, function() { return true; });
+ var candidates = find_files(outputDir, function(filename) { return (!architecture) || filename.indexOf(architecture) >= 0; });
if (candidates.length === 0) {
console.error('ERROR : No .apk found in ' + outputDir + ' directory');
process.exit(2);
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4bc2051f/bin/templates/cordova/lib/device.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/device.js b/bin/templates/cordova/lib/device.js
index d37f80c..df21287 100644
--- a/bin/templates/cordova/lib/device.js
+++ b/bin/templates/cordova/lib/device.js
@@ -61,7 +61,12 @@ module.exports.install = function(target) {
if (device_list.indexOf(target) < 0)
return Q.reject('ERROR: Unable to find target \'' + target + '\'.');
- var apk_path = build.get_apk();
+ var apk_path;
+ if (typeof process.env.DEPLOY_APK_ARCH == 'undefined') {
+ apk_path = build.get_apk();
+ } else {
+ apk_path = build.get_apk(null, process.env.DEPLOY_APK_ARCH);
+ }
launchName = appinfo.getActivityName();
console.log('Installing app on device...');
var cmd = 'adb -s ' + target + ' install -r "' + apk_path + '"';
[17/31] android commit: Set VERSION to 3.7.0-dev (via coho)
Posted by ia...@apache.org.
Set VERSION to 3.7.0-dev (via coho)
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/91cf78f1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/91cf78f1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/91cf78f1
Branch: refs/heads/4.0.x
Commit: 91cf78f183ebd692c47a6f745cbf0fdc4f3d4273
Parents: 0cde881
Author: Steven Gill <st...@gmail.com>
Authored: Fri Aug 29 16:34:12 2014 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Fri Aug 29 16:34:12 2014 -0700
----------------------------------------------------------------------
VERSION | 2 +-
bin/templates/cordova/version | 2 +-
.../src/org/apache/cordova/CordovaWebView.java | 2 +-
package.json | 54 ++++++++++----------
4 files changed, 30 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/91cf78f1/VERSION
----------------------------------------------------------------------
diff --git a/VERSION b/VERSION
index 86bab9c..a4ce38e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.6.0-dev
+3.7.0-dev
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/91cf78f1/bin/templates/cordova/version
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/version b/bin/templates/cordova/version
index ac3bb54..2e1ade7 100755
--- a/bin/templates/cordova/version
+++ b/bin/templates/cordova/version
@@ -20,6 +20,6 @@
*/
// Coho updates this line:
-var VERSION = "3.6.0-dev";
+var VERSION = "3.7.0-dev";
console.log(VERSION);
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/91cf78f1/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 403a7ae..f7a94ae 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -61,7 +61,7 @@ import android.widget.FrameLayout;
public class CordovaWebView extends WebView {
public static final String TAG = "CordovaWebView";
- public static final String CORDOVA_VERSION = "3.6.0-dev";
+ public static final String CORDOVA_VERSION = "3.7.0-dev";
private HashSet<Integer> boundKeyCodes = new HashSet<Integer>();
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/91cf78f1/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index ed01458..8a6ab09 100644
--- a/package.json
+++ b/package.json
@@ -1,28 +1,28 @@
{
- "name": "cordova-android",
- "version": "3.4.0",
- "description": "cordova-android release",
- "main": "bin/create",
- "repository": {
- "type": "git",
- "url": "https://git-wip-us.apache.org/repos/asf/cordova-android.git"
- },
- "keywords": [
- "android",
- "cordova",
- "apache"
- ],
- "scripts": {
- "test": "jasmine-node --color spec"
- },
- "author": "Apache Software Foundation",
- "license": "Apache version 2.0",
- "dependencies": {
- "q": "^0.9.0",
- "shelljs": "^0.2.6"
- },
- "devDependencies": {
- "jasmine-node": "~1",
- "promise-matchers": "~0"
- }
-}
+ "name": "cordova-android",
+ "version": "3.7.0-dev",
+ "description": "cordova-android release",
+ "main": "bin/create",
+ "repository": {
+ "type": "git",
+ "url": "https://git-wip-us.apache.org/repos/asf/cordova-android.git"
+ },
+ "keywords": [
+ "android",
+ "cordova",
+ "apache"
+ ],
+ "scripts": {
+ "test": "jasmine-node --color spec"
+ },
+ "author": "Apache Software Foundation",
+ "license": "Apache version 2.0",
+ "dependencies": {
+ "q": "^0.9.0",
+ "shelljs": "^0.2.6"
+ },
+ "devDependencies": {
+ "jasmine-node": "~1",
+ "promise-matchers": "~0"
+ }
+}
\ No newline at end of file
[03/31] android commit: CB-7291: Add defaults to external whitelist
Posted by ia...@apache.org.
CB-7291: Add defaults to external whitelist
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4e3331ba
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4e3331ba
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4e3331ba
Branch: refs/heads/4.0.x
Commit: 4e3331ba6699d323420c7762efef633c7ca20324
Parents: 8b55a16
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Aug 21 15:59:05 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Aug 21 16:27:48 2014 -0400
----------------------------------------------------------------------
framework/res/xml/config.xml | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4e3331ba/framework/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/framework/res/xml/config.xml b/framework/res/xml/config.xml
index 50459b9..6f4a264 100644
--- a/framework/res/xml/config.xml
+++ b/framework/res/xml/config.xml
@@ -30,7 +30,20 @@
Apache Cordova Team
</author>
- <access origin="*"/>
+ <!-- Allow access to arbitrary URLs in the Cordova WebView. This is a
+ development mode setting, and should be changed for production. -->
+ <access origin="http://*/*"/>
+ <access origin="https://*/*"/>
+
+ <!-- Grant certain URLs the ability to launch external applications. This
+ behaviour is set to match that of Cordova versions before 3.6.0, and
+ should be reviewed before launching an application in production. It
+ may be changed in the future. -->
+ <access origin="tel:*" launch-external="yes"/>
+ <access origin="geo:*" launch-external="yes"/>
+ <access origin="mailto:*" launch-external="yes"/>
+ <access origin="sms:*" launch-external="yes"/>
+ <access origin="market:*" launch-external="yes"/>
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
<content src="index.html" />
[05/31] android commit: Merge branch 'CB-7291'
Posted by ia...@apache.org.
Merge branch 'CB-7291'
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/2e3e4ec3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/2e3e4ec3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/2e3e4ec3
Branch: refs/heads/4.0.x
Commit: 2e3e4ec3b246aae8fc89525dc061d15c70bb44ea
Parents: b6c5a5f 6e222c3
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Aug 26 15:25:41 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Aug 26 15:25:41 2014 -0400
----------------------------------------------------------------------
framework/res/xml/config.xml | 15 +++++++++-
framework/src/org/apache/cordova/Config.java | 24 +++++++++++++--
.../src/org/apache/cordova/ConfigXmlParser.java | 31 +++++++++++++++++---
.../src/org/apache/cordova/CordovaActivity.java | 12 ++++----
.../org/apache/cordova/CordovaUriHelper.java | 24 +++++++--------
.../src/org/apache/cordova/CordovaWebView.java | 24 ++++++++++-----
framework/src/org/apache/cordova/Whitelist.java | 4 ---
7 files changed, 96 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
[16/31] android commit: CB-7410 fix the menu test
Posted by ia...@apache.org.
CB-7410 fix the menu test
Need to show the title in order for the options menu button to be visible.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/0cde8819
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/0cde8819
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/0cde8819
Branch: refs/heads/4.0.x
Commit: 0cde8819cfdfa7df03639b9d3b24f7d2933dee1a
Parents: 07632b0
Author: Marcel Kinard <cm...@gmail.com>
Authored: Fri Aug 29 18:07:29 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Fri Aug 29 18:07:29 2014 -0400
----------------------------------------------------------------------
test/assets/www/menus/index.html | 2 +-
test/src/org/apache/cordova/test/menus.java | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0cde8819/test/assets/www/menus/index.html
----------------------------------------------------------------------
diff --git a/test/assets/www/menus/index.html b/test/assets/www/menus/index.html
index 58d64c3..ff0b93b 100755
--- a/test/assets/www/menus/index.html
+++ b/test/assets/www/menus/index.html
@@ -33,7 +33,7 @@
<h4>Deviceready: <span id="deviceready"> </span></h4>
</div>
<div id="info">
- <h4>The menu items should be:</h4>
+ <h4>The options menu items should be:</h4>
<li>Item1<br>
<li>Item2<br>
<li>Item3<br>
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0cde8819/test/src/org/apache/cordova/test/menus.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/menus.java b/test/src/org/apache/cordova/test/menus.java
index 12d5230..6d0d3f1 100755
--- a/test/src/org/apache/cordova/test/menus.java
+++ b/test/src/org/apache/cordova/test/menus.java
@@ -28,10 +28,12 @@ import android.view.ContextMenu.ContextMenuInfo;
import org.apache.cordova.*;
import org.apache.cordova.LOG;
-public class menus extends DroidGap {
+public class menus extends CordovaActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ // need the title to be shown for the options menu to be visible
+ preferences.set("showTitle", true);
super.init();
super.registerForContextMenu(super.appView);
super.loadUrl("file:///android_asset/www/menus/index.html");
[19/31] android commit: updated releasenotes
Posted by ia...@apache.org.
updated releasenotes
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/5a82dd51
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/5a82dd51
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/5a82dd51
Branch: refs/heads/4.0.x
Commit: 5a82dd5110a995fbec5e63b28446677c976ef93f
Parents: f20708a
Author: Steven Gill <st...@gmail.com>
Authored: Tue Sep 2 17:09:14 2014 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Tue Sep 2 17:09:24 2014 -0700
----------------------------------------------------------------------
RELEASENOTES.md | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 118 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/5a82dd51/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index d15f897..43bb326 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -20,6 +20,124 @@
-->
## Release Notes for Cordova (Android) ##
+### 3.6.0 (Sept 2014) ###
+
+* Set VERSION to 3.6.0 (via coho)
+* CB-7410 fix the menu test
+* CB-7410 Fix the errorUrl test
+* CB-7410 Fix Basic Authentication test
+* CB-3445: Allow build and run scripts to select APK by architecture
+* CB-3445: Add environment variable 'BUILD_MULTIPLE_APKS' for splitting APKs based on architecture
+* CB-3445: Ensure that JAR files in libs directory are included
+* CB-7267 update RELEASENOTES for 3.5.1
+* CB-7410 clarify the title
+* CB-7385 update cordova.js for testing prior to branch/tag
+* CB-7410 add whitelist entries to get iframe/GoogleMaps working
+* CB-7291 propogate change in method signature to the native tests
+* CB-7291: Restrict meaning of "\*" in internal whitelist to just http and https
+* CB-7291: Only add file, content and data URLs to internal whitelist
+* CB-7291: Add defaults to external whitelist
+* CB-7291: Add external-launch-whitelist and use it for filtering intent launches
+* CB-3445: Read project.properties to configure gradle libraries
+* CB-7325 Fix error message in android_sdk_version.js when missing SDK on windows
+* CB-7335 Add a .gitignore to android project template
+* CB-7330 Fix dangling function call in last commit (broke gradle builds)
+* CB-7330 Don't run "android update" during creation
+* CB-3445 Add gradle support clean command (plus some code cleanup)
+* CB-7044 Fix typo in prev commit causing check_reqs to always fail.
+* CB-3445 Copy gradle wrapper in build instead of create
+* CB-3445 Add .gradle template files for "update" as well as "create"
+* CB-7044 Add JAVA_HOME when not set. Be stricter about ANDROID_HOME
+* CB-3445 Speed up gradle building (incremental builds go from 10s -> 1.5s for me)
+* CB-3445: android: Copy Gradle wrapper from Android SDK rather than bundling a JAR
+* CB-3445: Add which to checked-in node_modules
+* CB-3445: Add option to build and install with gradle
+* CB-3445: Add an initial set of Gradle build scripts
+* CB-7321 Don't require ant for create script
+* CB-7044, CB-7299 Fix up PATH problems when possible.
+* Change in test's AndroidManifest.xml needed for the test to run properly. Forgot the manifest.
+* Change in test's AndroidManifest.xml needed for the test to run properly
+* Adding tests related to 3.5.1
+* CB-7261 Fix setNativeToJsBridgeMode sometimes crashing when switching to ONLINE_EVENT
+* CB-7265 Fix crash when navigating to custom protocol (introduced in 3.5.1)
+* Filter out non-launchable intents
+* Handle unsupported protocol errors in webview better
+* CB-7238: I should have collapsed this, but Config.init() must go before the creation of CordovaWebView
+* CB-7238: Minor band-aid to get tests running again, this has to go away before 3.6.0 is released, since this is an API change.
+* Extend whitelist to handle URLs without // chars
+* CB-7172 Force window to have focus after resume
+* CB-7159 Set background color of webView as well as its parent
+* CB-7018 Fix setButtonPlumbedToJs never un-listening
+* Undeprecate some just-deprecated symbols in PluginManager.
+* @Deprecate methods of PluginManager that were never meant to be public
+* Move plugin instantiation and instance storing logic PluginEntry->PluginManager
+* Fix broken unit test due to missing Config.init() call
+* Update to check for Google Glass APIs
+* Fix for `android` not being in PATH check on Windows
+* Displaying error when regex does not match.
+* Fix broken compile due to previous commit :(
+* Tweak CordovaPlugin.initialize method to be less deprecated.
+* Un-deprecate CordovaActivity.init() - it's needed to tweak prefs in onCreate
+* Tweak log messages in CordovaBridge with bridgeSecret is wrong
+* Backport CordovaBridge from 4.0.x -> master
+* Update unit tests to not use most deprecated things (e.g. DroidGap)
+* Add non-String overloades for CordovaPreferences.set()
+* Make CordovaWebview resilient to init() not being called (for backwards-compatibility)
+* Add node_module licenses to LICENSE
+* Update cordova.js snapshot to work with bridge changes
+* Provide CordovaPlugin with CordovaPreferences. Add new Plugin.initialize()
+* Convert usages of Config.\* to use the non-static versions
+* Change getProperty -> prefs.get\* within CordovaActivity
+* Make CordovaUriHelper class package-private
+* Fix PluginManager.setPluginEntries not removing old entries
+* Move registration of App plugin from config.xml -> code
+* Make setWebViewClient an override instead of an overload. Delete Location-change JS->Native bridge mode (missed some of it).
+* CB-4404 Revert setting android:windowSoftInputMode to "adjustPan"
+* Refactor: Use ConfigXmlParser in activity. Adds CordovaWebView.init()
+* Deprecate some convenience methods on CordovaActivity
+* Fix CordovaPreferences not correctly parsing hex values (valueOf->decode)
+* Refactor: Move url-filter information into PluginEntry.
+* Don't re-parse config.xml in onResume.
+* Move handling of Fullscreen preference to CordovaActivity
+* Delete dead code from CordovaActivity
+* Update .classpath to make Eclipse happy (just re-orders one line)
+* Delete "CB-3064: The errorUrl is..." Log message left over from debugging presumably
+* Refactor Config into ConfigXmlParser, CordovaPreferences
+* Delete Location-change JS->Native bridge mode
+* CB-5988 Allow exec() only from file: or start-up URL's domain
+* CB-6761 Fix native->JS bridge ceasing to fire when page changes and online is set to false and the JS loads quickly
+* Update the errorurl to no longer use intents
+* This breaks running the JUnit tests, we'll bring it back soon
+* Refactoring the URI handling on Cordova, removing dead code
+* CB-7018 Clean up and deprecation of some button-related functions
+* CB-7017 Fix onload=true being set on all subsequent plugins
+* CB-5971: Fix package / project validation
+* CB-5971: Add unit tests to cordova-android
+* CB-5971: Factor out package/project name validation logic
+* Delete explicit activity.finish() in back button handling. No change in behaviour.
+* CB-5971: This would have been a good first bug, too bad
+* CB-4404: Changing where android:windowSoftInputMode is in the manifest so it works
+* Add documentation referencing other implementation.
+* CB-6851 Deprecate WebView.sendJavascript()
+* CB-6876 Show the correct executable name
+* CB-6876 Fix the "print usage"
+* Trivial spelling fix in comments when reading CordovaResourceApi
+* CB-6818: I want to remove this code, because Square didn't do their headers properly
+* CB-6860 Add activity_name and launcher_name to AndroidManifest.xml & strings.xml
+* Add a comment to custom_rules.xml saying why we move AndroidManifest.xml
+* Remove +x from README.md
+* CB-6784 Add missing licenses
+* CB-6784 Add license to CONTRIBUTING.md
+* Revert "defaults.xml: Add AndroidLaunchMode preference"
+* updated RELEASENOTES
+* CB-6315: Wrapping this so it runs on the UI thread
+* CB-6723 Update package name for Robotium
+* CB-6707 Update minSdkVersion to 10 consistently
+* CB-5652 make visible cordova version
+* Update JS snapshot to version 3.6.0-dev (via coho)
+* Update JS snapshot to version 3.6.0-dev (via coho)
+* Set VERSION to 3.6.0-dev (via coho)
+
### 3.5.1 (August 2014) ###
This was a security update to address CVE-2014-3500, CVE-2014-3501,
[07/31] android commit: CB-7410 add whitelist entries to get
iframe/GoogleMaps working
Posted by ia...@apache.org.
CB-7410 add whitelist entries to get iframe/GoogleMaps working
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/16e3ebd8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/16e3ebd8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/16e3ebd8
Branch: refs/heads/4.0.x
Commit: 16e3ebd87bbfa075defb5c4f2b1dd2e8a1eeb5b0
Parents: 94c096d
Author: Marcel Kinard <cm...@gmail.com>
Authored: Tue Aug 26 17:20:58 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Tue Aug 26 17:20:58 2014 -0400
----------------------------------------------------------------------
test/res/xml/config.xml | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/16e3ebd8/test/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/test/res/xml/config.xml b/test/res/xml/config.xml
index 7572732..148bad5 100644
--- a/test/res/xml/config.xml
+++ b/test/res/xml/config.xml
@@ -26,6 +26,10 @@
Apache Cordova Team
</author>
<access origin="*.apache.org" />
+ <access origin="http://*.google.com/*" />
+ <access origin="https://*.google.com/*" />
+ <access origin="https://*.googleapis.com/*" />
+ <access origin="https://*.gstatic.com/*" />
<content src="index.html" />
<preference name="loglevel" value="DEBUG" />
<preference name="useBrowserHistory" value="true" />
[09/31] android commit: CB-7410 clarify the title
Posted by ia...@apache.org.
CB-7410 clarify the title
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/12a27643
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/12a27643
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/12a27643
Branch: refs/heads/4.0.x
Commit: 12a27643db8d0e01f412f5001e3aaaa187191abe
Parents: c6ccde0
Author: Marcel Kinard <cm...@gmail.com>
Authored: Wed Aug 27 13:56:31 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Wed Aug 27 13:56:31 2014 -0400
----------------------------------------------------------------------
test/assets/www/index.html | 2 +-
test/res/values/strings.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/12a27643/test/assets/www/index.html
----------------------------------------------------------------------
diff --git a/test/assets/www/index.html b/test/assets/www/index.html
index 2876d78..d4659f7 100755
--- a/test/assets/www/index.html
+++ b/test/assets/www/index.html
@@ -36,7 +36,7 @@
</head>
<body onload="init();" id="stage" class="theme">
- <h1>Cordova Android Tests</h1>
+ <h1>Cordova Android Native Tests</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> </span></h4>
<h4>Deviceready: <span id="deviceready"> </span></h4>
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/12a27643/test/res/values/strings.xml
----------------------------------------------------------------------
diff --git a/test/res/values/strings.xml b/test/res/values/strings.xml
index 2eff663..59e22e6 100644
--- a/test/res/values/strings.xml
+++ b/test/res/values/strings.xml
@@ -18,5 +18,5 @@
under the License.
-->
<resources>
- <string name="app_name">CordovaTests</string>
+ <string name="app_name">CordovaNativeTests</string>
</resources>
[30/31] android commit: Merge branch 'master' into 4.0.x (up to
3.7.0-dev)
Posted by ia...@apache.org.
Merge branch 'master' into 4.0.x (up to 3.7.0-dev)
Conflicts:
VERSION
bin/templates/cordova/version
framework/src/org/apache/cordova/CordovaWebView.java
package.json
test/src/org/apache/cordova/test/basicauth.java
test/src/org/apache/cordova/test/menus.java
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/51e634cc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/51e634cc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/51e634cc
Branch: refs/heads/4.0.x
Commit: 51e634ccb4d64444198ff2a60174e42feab2a183
Parents: 31b1a82 5a82dd5
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Sep 11 10:16:28 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Sep 11 10:16:46 2014 -0400
----------------------------------------------------------------------
RELEASENOTES.md | 129 +++++++++++++++++++++++++++
framework/assets/www/cordova.js | 34 ++++++-
package.json | 54 +++++------
test/assets/www/htmlnotfound/error.html | 23 ++++-
test/assets/www/index.html | 2 +-
test/assets/www/menus/index.html | 2 +-
test/res/values/strings.xml | 2 +-
7 files changed, 210 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/51e634cc/package.json
----------------------------------------------------------------------
diff --cc package.json
index ca620f7,8a6ab09..7f1b8d9
--- a/package.json
+++ b/package.json
@@@ -1,29 -1,28 +1,29 @@@
{
- "name": "cordova-android",
- "version": "4.0.0-dev",
- "description": "cordova-android release",
- "main": "bin/create",
- "repository": {
- "type": "git",
- "url": "https://git-wip-us.apache.org/repos/asf/cordova-android.git"
- },
- "keywords": [
- "android",
- "cordova",
- "apache"
- ],
- "scripts": {
- "test": "jasmine-node --color spec"
- },
- "author": "Apache Software Foundation",
- "license": "Apache version 2.0",
- "dependencies": {
- "q": "^0.9.0",
- "shelljs": "^0.2.6",
- "which": "^1.0.5"
- },
- "devDependencies": {
- "jasmine-node": "~1",
- "promise-matchers": "~0"
- }
+ "name": "cordova-android",
- "version": "3.7.0-dev",
++ "version": "4.0.0-dev",
+ "description": "cordova-android release",
+ "main": "bin/create",
+ "repository": {
+ "type": "git",
+ "url": "https://git-wip-us.apache.org/repos/asf/cordova-android.git"
+ },
+ "keywords": [
+ "android",
+ "cordova",
+ "apache"
+ ],
+ "scripts": {
+ "test": "jasmine-node --color spec"
+ },
+ "author": "Apache Software Foundation",
+ "license": "Apache version 2.0",
+ "dependencies": {
+ "q": "^0.9.0",
- "shelljs": "^0.2.6"
++ "shelljs": "^0.2.6",
++ "which": "^1.0.5"
+ },
+ "devDependencies": {
+ "jasmine-node": "~1",
+ "promise-matchers": "~0"
+ }
-}
+}
[27/31] android commit: Use add --compact flag in check_reqs when
listing targets. No functional change.
Posted by ia...@apache.org.
Use add --compact flag in check_reqs when listing targets. No functional change.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/bf13fd48
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/bf13fd48
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/bf13fd48
Branch: refs/heads/4.0.x
Commit: bf13fd48ceb23a671a03ddfe4400003b70b72a9d
Parents: 3b99760
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 10 12:43:40 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 10 12:44:17 2014 -0400
----------------------------------------------------------------------
bin/lib/check_reqs.js | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/bf13fd48/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index d2b3dcf..00137ff 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -48,20 +48,21 @@ function tryCommand(cmd, errMsg) {
// Get valid target from framework/project.properties
module.exports.get_target = function() {
- if(fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
- var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'framework', 'project.properties'));
- return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
- } else if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
- // if no target found, we're probably in a project and project.properties is in ROOT.
- // this is called on the project itself, and can support Google APIs AND Vanilla Android
- var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties')) ||
- shelljs.grep(/target=Google Inc.:Google APIs:[\d+]/, path.join(ROOT, 'project.properties'));
- if(target == "" || !target) {
- // Try Google Glass APIs
- target = shelljs.grep(/target=Google Inc.:Glass Development Kit Preview:[\d+]/, path.join(ROOT, 'project.properties'));
+ function extractFromFile(filePath) {
+ var target = shelljs.grep(/\btarget=/, filePath);
+ if (!target) {
+ throw new Error('Could not find android target within: ' + filePath);
}
- return target.split('=')[1].replace('\n', '').replace('\r', '');
+ return target.split('=')[1].trim();
+ }
+ if (fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
+ return extractFromFile(path.join(ROOT, 'framework', 'project.properties'));
+ }
+ if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
+ // if no target found, we're probably in a project and project.properties is in ROOT.
+ return extractFromFile(path.join(ROOT, 'project.properties'));
}
+ throw new Error('Could not find android target. File missing: ' + path.join(ROOT, 'project.properties'));
}
// Returns a promise. Called only by build and clean commands.
@@ -180,13 +181,17 @@ module.exports.check_android = function() {
};
module.exports.check_android_target = function(valid_target) {
+ // valid_target can look like:
+ // android-19
+ // android-L
+ // Google Inc.:Google APIs:20
+ // Google Inc.:Glass Development Kit Preview:20
var msg = 'Failed to run "android". Make sure you have the latest Android SDK installed, and that the "android" command (inside the tools/ folder) is added to your PATH.';
- return tryCommand('android list targets', msg)
+ return tryCommand('android list targets --compact', msg)
.then(function(output) {
- if (!output.match(valid_target)) {
- throw new Error('Please install Android target "' + valid_target + '".\n' +
- output + '\n\n' +
- 'Hint: Install it using the SDK manager by running: ' + forgivingWhichSync('android'));
+ if (output.split('\n').indexOf(valid_target) == -1) {
+ throw new Error('Please install Android target: "' + valid_target + '".\n' +
+ 'Hint: Open the SDK manager by running: ' + forgivingWhichSync('android'));
}
});
};
[20/31] android commit: CB-7460: Fixing bug with KitKat where the
background colour would override the CSS colours on the application
Posted by ia...@apache.org.
CB-7460: Fixing bug with KitKat where the background colour would override the CSS colours on the application
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4dc32e19
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4dc32e19
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4dc32e19
Branch: refs/heads/4.0.x
Commit: 4dc32e194b04480cca5fa118a6fe346e54ff23fa
Parents: 5a82dd5
Author: Joe Bowser <bo...@apache.org>
Authored: Wed Sep 3 15:23:41 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Wed Sep 3 15:42:39 2014 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/CordovaActivity.java | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4dc32e19/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index 190309e..bf1fd6a 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -248,10 +248,8 @@ public class CordovaActivity extends Activity implements CordovaInterface {
root.addView((View) appView);
setContentView(root);
- // TODO: Setting this on the appView causes it to show when <html style="opacity:0">.
int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
root.setBackgroundColor(backgroundColor);
- appView.setBackgroundColor(backgroundColor);
}
/**
[14/31] android commit: CB-7410 Fix Basic Authentication test
Posted by ia...@apache.org.
CB-7410 Fix Basic Authentication test
Looks like the Chromium webview does not include the port number on the
hostname during the callback challenge, but the classic webview does
include the port number. Handle both cases here.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4a7f825c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4a7f825c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4a7f825c
Branch: refs/heads/4.0.x
Commit: 4a7f825cfe829a1fd5a92402170fa233ec9211d6
Parents: 4bc2051
Author: Marcel Kinard <cm...@gmail.com>
Authored: Fri Aug 29 16:38:38 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Fri Aug 29 16:41:51 2014 -0400
----------------------------------------------------------------------
test/src/org/apache/cordova/test/basicauth.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4a7f825c/test/src/org/apache/cordova/test/basicauth.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/basicauth.java b/test/src/org/apache/cordova/test/basicauth.java
index 1b09f3d..a0aaa7c 100755
--- a/test/src/org/apache/cordova/test/basicauth.java
+++ b/test/src/org/apache/cordova/test/basicauth.java
@@ -21,7 +21,7 @@ package org.apache.cordova.test;
import android.os.Bundle;
import org.apache.cordova.*;
-public class basicauth extends DroidGap {
+public class basicauth extends CordovaActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -31,11 +31,13 @@ public class basicauth extends DroidGap {
AuthenticationToken token = new AuthenticationToken();
token.setUserName("test");
token.setPassword("test");
- super.setAuthenticationToken(token, "browserspy.dk:80", "BrowserSpy.dk - HTTP Password Test");
+ // classic webview includes port in hostname, Chromium webview does not. Handle both here.
+ // BTW, the realm is optional.
+ setAuthenticationToken(token, "browserspy.dk:80", "BrowserSpy.dk - HTTP Password Test");
+ setAuthenticationToken(token, "browserspy.dk", "BrowserSpy.dk - HTTP Password Test");
// Add web site to whitelist
- Config.init();
- Config.addWhiteListEntry("http://browserspy.dk*", true);
+ Config.getWhitelist().addWhiteListEntry("http://browserspy.dk/*", true);
// Load test
super.loadUrl("file:///android_asset/www/basicauth/index.html");
[15/31] android commit: CB-7410 Fix the errorUrl test
Posted by ia...@apache.org.
CB-7410 Fix the errorUrl test
Make the error.html page a well-formed html document, otherwise it
won't display.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/07632b0e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/07632b0e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/07632b0e
Branch: refs/heads/4.0.x
Commit: 07632b0eeba6dde4032f338941e8e5891456e97e
Parents: 4a7f825
Author: Marcel Kinard <cm...@gmail.com>
Authored: Fri Aug 29 17:38:03 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Fri Aug 29 17:38:03 2014 -0400
----------------------------------------------------------------------
test/assets/www/htmlnotfound/error.html | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/07632b0e/test/assets/www/htmlnotfound/error.html
----------------------------------------------------------------------
diff --git a/test/assets/www/htmlnotfound/error.html b/test/assets/www/htmlnotfound/error.html
index e32cd29..3852efe 100755
--- a/test/assets/www/htmlnotfound/error.html
+++ b/test/assets/www/htmlnotfound/error.html
@@ -14,6 +14,25 @@
"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.$
+ under the License.
-->
-This is an error page.
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta name="viewport" content="width=320, user-scalable=no" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>Expected Error</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+ <script type="text/javascript" charset="utf-8" src="../main.js"></script>
+ </head>
+ <body onload="init();" id="stage" class="theme">
+ <h1>Expected Error</h1>
+ <div id="info">
+ <h4>Cordova: <span id="cordova"> </span></h4>
+ <h4>Deviceready: <span id="deviceready"> </span></h4>
+ </div>
+ <div id="info">
+ This is an expected error page because the initial href doesn't exist.
+ </body>
+</html>
[29/31] android commit: Merge branch 'master' into 4.0.x (External
whitelist changes)
Posted by ia...@apache.org.
Merge branch 'master' into 4.0.x (External whitelist changes)
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/31b1a821
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/31b1a821
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/31b1a821
Branch: refs/heads/4.0.x
Commit: 31b1a821ca412978e3b80de5e97fe122880f62d5
Parents: 0b6b068 16e3ebd
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Sep 11 10:08:45 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Sep 11 10:08:45 2014 -0400
----------------------------------------------------------------------
framework/res/xml/config.xml | 15 +++++++++-
.../src/org/apache/cordova/AndroidWebView.java | 22 +++++++++-----
framework/src/org/apache/cordova/Config.java | 24 +++++++++++++--
.../src/org/apache/cordova/ConfigXmlParser.java | 31 +++++++++++++++++---
.../src/org/apache/cordova/CordovaActivity.java | 10 ++++---
.../org/apache/cordova/CordovaUriHelper.java | 24 +++++++--------
.../src/org/apache/cordova/CordovaWebView.java | 4 ++-
framework/src/org/apache/cordova/Whitelist.java | 4 ---
test/res/xml/config.xml | 4 +++
.../test/CordovaWebViewTestActivity.java | 3 +-
10 files changed, 103 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/31b1a821/framework/res/xml/config.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/31b1a821/framework/src/org/apache/cordova/AndroidWebView.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/AndroidWebView.java
index bd73384,0000000..8986d58
mode 100755,000000..100755
--- a/framework/src/org/apache/cordova/AndroidWebView.java
+++ b/framework/src/org/apache/cordova/AndroidWebView.java
@@@ -1,767 -1,0 +1,775 @@@
+/*
+ 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.
+*/
+
+package org.apache.cordova;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.ApplicationInfo;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
+import android.webkit.WebBackForwardList;
+import android.webkit.WebHistoryItem;
+import android.webkit.WebChromeClient;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebSettings.LayoutAlgorithm;
+import android.webkit.WebViewClient;
+import android.widget.FrameLayout;
+
+
+/*
+ * This class is our web view.
+ *
+ * @see <a href="http://developer.android.com/guide/webapps/webview.html">WebView guide</a>
+ * @see <a href="http://developer.android.com/reference/android/webkit/WebView.html">WebView</a>
+ */
+public class AndroidWebView extends WebView implements CordovaWebView {
+
+ public static final String TAG = "AndroidWebView";
+
+ private HashSet<Integer> boundKeyCodes = new HashSet<Integer>();
+
+ PluginManager pluginManager;
+
+ private BroadcastReceiver receiver;
+
+
+ /** Activities and other important classes **/
+ private CordovaInterface cordova;
+ AndroidWebViewClient viewClient;
+ private AndroidChromeClient chromeClient;
+
+ // Flag to track that a loadUrl timeout occurred
+ int loadUrlTimeout = 0;
+
+ private long lastMenuEventTime = 0;
+
+ CordovaBridge bridge;
+
+ /** custom view created by the browser (a video player for example) */
+ private View mCustomView;
+ private WebChromeClient.CustomViewCallback mCustomViewCallback;
+
+ private CordovaResourceApi resourceApi;
- private Whitelist whitelist;
++ private Whitelist internalWhitelist;
++ private Whitelist externalWhitelist;
+ private CordovaPreferences preferences;
+ // The URL passed to loadUrl(), not necessarily the URL of the current page.
+ String loadedUrl;
+
+ static final FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER =
+ new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ Gravity.CENTER);
+
+ /** Used when created via reflection. */
+ public AndroidWebView(Context context) {
+ this(context, null);
+ }
+
+ /** Required to allow view to be used within XML layouts. */
+ public AndroidWebView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ // Use two-phase init so that the control will work with XML layouts.
+ @Override
+ public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
- Whitelist whitelist, CordovaPreferences preferences) {
++ Whitelist internalWhitelist, Whitelist externalWhitelist,
++ CordovaPreferences preferences) {
+ if (this.cordova != null) {
+ throw new IllegalStateException();
+ }
+ this.cordova = cordova;
- this.whitelist = whitelist;
++ this.internalWhitelist = internalWhitelist;
++ this.externalWhitelist = externalWhitelist;
+ this.preferences = preferences;
+
+ pluginManager = new PluginManager(this, this.cordova, pluginEntries);
+ resourceApi = new CordovaResourceApi(this.getContext(), pluginManager);
+ bridge = new CordovaBridge(pluginManager, new NativeToJsMessageQueue(this, cordova));
+ pluginManager.addService("App", "org.apache.cordova.CoreAndroid");
+ initWebViewSettings();
+
+ if (this.viewClient == null) {
+ setWebViewClient(Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH ?
+ new AndroidWebViewClient(cordova, this) :
+ new IceCreamCordovaWebViewClient(cordova, this));
+ }
+ if (this.chromeClient == null) {
+ setWebChromeClient(new AndroidChromeClient(cordova, this));
+ }
+
+ exposeJsInterface();
+ }
+
+ @SuppressLint("SetJavaScriptEnabled")
+ @SuppressWarnings("deprecation")
+ private void initWebViewSettings() {
+ this.setInitialScale(0);
+ this.setVerticalScrollBarEnabled(false);
+ // TODO: The Activity is the one that should call requestFocus().
+ if (shouldRequestFocusOnInit()) {
+ this.requestFocusFromTouch();
+ }
+ this.setInitialScale(0);
+ this.setVerticalScrollBarEnabled(false);
+ if (shouldRequestFocusOnInit()) {
+ this.requestFocusFromTouch();
+ }
+ // Enable JavaScript
+ final WebSettings settings = this.getSettings();
+ settings.setJavaScriptEnabled(true);
+ settings.setJavaScriptCanOpenWindowsAutomatically(true);
+ settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
+
+ // Set the nav dump for HTC 2.x devices (disabling for ICS, deprecated entirely for Jellybean 4.2)
+ try {
+ Method gingerbread_getMethod = WebSettings.class.getMethod("setNavDump", new Class[] { boolean.class });
+
+ String manufacturer = android.os.Build.MANUFACTURER;
+ Log.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);
+ if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB &&
+ android.os.Build.MANUFACTURER.contains("HTC"))
+ {
+ gingerbread_getMethod.invoke(settings, true);
+ }
+ } catch (NoSuchMethodException e) {
+ Log.d(TAG, "We are on a modern version of Android, we will deprecate HTC 2.3 devices in 2.8");
+ } catch (IllegalArgumentException e) {
+ Log.d(TAG, "Doing the NavDump failed with bad arguments");
+ } catch (IllegalAccessException e) {
+ Log.d(TAG, "This should never happen: IllegalAccessException means this isn't Android anymore");
+ } catch (InvocationTargetException e) {
+ Log.d(TAG, "This should never happen: InvocationTargetException means this isn't Android anymore.");
+ }
+
+ //We don't save any form data in the application
+ settings.setSaveFormData(false);
+ settings.setSavePassword(false);
+
+ // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
+ // while we do this
+ if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
+ Level16Apis.enableUniversalAccess(settings);
+ // Enable database
+ // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
+ String databasePath = getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
+ settings.setDatabaseEnabled(true);
+ settings.setDatabasePath(databasePath);
+
+
+ //Determine whether we're in debug or release mode, and turn on Debugging!
+ ApplicationInfo appInfo = getContext().getApplicationContext().getApplicationInfo();
+ if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&
+ android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
+ enableRemoteDebugging();
+ }
+
+ settings.setGeolocationDatabasePath(databasePath);
+
+ // Enable DOM storage
+ settings.setDomStorageEnabled(true);
+
+ // Enable built-in geolocation
+ settings.setGeolocationEnabled(true);
+
+ // Enable AppCache
+ // Fix for CB-2282
+ settings.setAppCacheMaxSize(5 * 1048576);
+ settings.setAppCachePath(databasePath);
+ settings.setAppCacheEnabled(true);
+
+ // Fix for CB-1405
+ // Google issue 4641
+ settings.getUserAgentString();
+
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
+ if (this.receiver == null) {
+ this.receiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ settings.getUserAgentString();
+ }
+ };
+ getContext().registerReceiver(this.receiver, intentFilter);
+ }
+ // end CB-1405
+ }
+
+ @TargetApi(Build.VERSION_CODES.KITKAT)
+ private void enableRemoteDebugging() {
+ try {
+ WebView.setWebContentsDebuggingEnabled(true);
+ } catch (IllegalArgumentException e) {
+ Log.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Override this method to decide whether or not you need to request the
+ * focus when your application start
+ *
+ * @return true unless this method is overriden to return a different value
+ */
+ protected boolean shouldRequestFocusOnInit() {
+ return true;
+ }
+
+ private void exposeJsInterface() {
+ if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
+ Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
+ // Bug being that Java Strings do not get converted to JS strings automatically.
+ // This isn't hard to work-around on the JS side, but it's easier to just
+ // use the prompt bridge instead.
+ return;
+ }
+ AndroidExposedJsApi exposedJsApi = new AndroidExposedJsApi(bridge);
+ this.addJavascriptInterface(exposedJsApi, "_cordovaNative");
+ }
+
+ @Override
+ public void setWebViewClient(WebViewClient client) {
+ this.viewClient = (AndroidWebViewClient)client;
+ super.setWebViewClient(client);
+ }
+
+ @Override
+ public void setWebChromeClient(WebChromeClient client) {
+ this.chromeClient = (AndroidChromeClient)client;
+ super.setWebChromeClient(client);
+ }
+
+ /**
+ * Load the url into the webview.
+ */
+ @Override
+ public void loadUrl(String url) {
+ this.loadUrlIntoView(url, true);
+ }
+
+ /**
+ * Load the url into the webview.
+ */
+ @Override
+ public void loadUrlIntoView(final String url, boolean recreatePlugins) {
+ if (url.equals("about:blank") || url.startsWith("javascript:")) {
+ this.loadUrlNow(url);
+ return;
+ }
+
+ LOG.d(TAG, ">>> loadUrl(" + url + ")");
+ recreatePlugins = recreatePlugins || (loadedUrl == null);
+
+ if (recreatePlugins) {
+ this.loadedUrl = url;
+ this.pluginManager.init();
+ }
+
+ // Create a timeout timer for loadUrl
+ final AndroidWebView me = this;
+ final int currentLoadUrlTimeout = me.loadUrlTimeout;
+ final int loadUrlTimeoutValue = preferences.getInteger("LoadUrlTimeoutValue", 20000);
+
+ // Timeout error method
+ final Runnable loadError = new Runnable() {
+ public void run() {
+ me.stopLoading();
+ LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
+ if (viewClient != null) {
+ viewClient.onReceivedError(AndroidWebView.this, -6, "The connection to the server was unsuccessful.", url);
+ }
+ }
+ };
+
+ // Timeout timer method
+ final Runnable timeoutCheck = new Runnable() {
+ public void run() {
+ try {
+ synchronized (this) {
+ wait(loadUrlTimeoutValue);
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ // If timeout, then stop loading and handle error
+ if (me.loadUrlTimeout == currentLoadUrlTimeout) {
+ me.cordova.getActivity().runOnUiThread(loadError);
+ }
+ }
+ };
+
+ // Load url
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ cordova.getThreadPool().execute(timeoutCheck);
+ me.loadUrlNow(url);
+ }
+ });
+ }
+
+ /**
+ * Load URL in webview.
+ */
+ private void loadUrlNow(String url) {
+ if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
+ LOG.d(TAG, ">>> loadUrlNow()");
+ }
- if (url.startsWith("file://") || url.startsWith("javascript:") || whitelist.isUrlWhiteListed(url)) {
++ if (url.startsWith("file://") || url.startsWith("javascript:") || internalWhitelist.isUrlWhiteListed(url)) {
+ super.loadUrl(url);
+ }
+ }
+
+ @Override
+ public void stopLoading() {
+ //viewClient.isCurrentlyLoading = false;
+ super.stopLoading();
+ }
+
+ 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);
+ pluginManager.postMessage("onScrollChanged", myEvent);
+ }
+
+ /**
+ * Send JavaScript statement back to JavaScript.
+ * (This is a convenience method)
+ */
+ public void sendJavascript(String statement) {
+ bridge.getMessageQueue().addJavaScript(statement);
+ }
+
+ /**
+ * Send a plugin result back to JavaScript.
+ */
+ public void sendPluginResult(PluginResult result, String callbackId) {
+ bridge.getMessageQueue().addPluginResult(result, callbackId);
+ }
+
+ /**
+ * Go to previous page in history. (We manage our own history)
+ *
+ * @return true if we went back, false if we are already at top
+ */
+ public boolean backHistory() {
+
+ // Check webview first to see if there is a history
+ // This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
+ if (super.canGoBack()) {
+ printBackForwardList();
+ super.goBack();
+
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Load the specified URL in the Cordova webview or a new browser instance.
+ *
+ * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
+ *
+ * @param url The url to load.
+ * @param openExternal Load url in browser instead of Cordova webview.
+ * @param clearHistory Clear the history stack, so new page becomes top of history
+ * @param params Parameters for new app
+ */
+ public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
+ LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);
+
+ // If clearing history
+ if (clearHistory) {
+ this.clearHistory();
+ }
+
+ // If loading into our webview
+ if (!openExternal) {
+
+ // Make sure url is in whitelist
- if (url.startsWith("file://") || whitelist.isUrlWhiteListed(url)) {
++ if (url.startsWith("file://") || internalWhitelist.isUrlWhiteListed(url)) {
+ // TODO: What about params?
+ // Load new URL
+ loadUrlIntoView(url, true);
+ return;
+ }
+ // Load in default viewer if not
+ LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list. Loading into browser instead. (URL=" + url + ")");
+ }
+ try {
+ // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
+ // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ Uri uri = Uri.parse(url);
+ if ("file".equals(uri.getScheme())) {
+ intent.setDataAndType(uri, resourceApi.getMimeType(uri));
+ } else {
+ intent.setData(uri);
+ }
+ cordova.getActivity().startActivity(intent);
+ } catch (android.content.ActivityNotFoundException e) {
+ LOG.e(TAG, "Error loading url " + url, e);
+ }
+ }
+
+ /*
+ * onKeyDown
+ */
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event)
+ {
+ if(boundKeyCodes.contains(keyCode))
+ {
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
+ this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');");
+ return true;
+ }
+ else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+ this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');");
+ return true;
+ }
+ else
+ {
+ return super.onKeyDown(keyCode, event);
+ }
+ }
+ else if(keyCode == KeyEvent.KEYCODE_BACK)
+ {
+ return !(this.startOfHistory()) || isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK);
+
+ }
+ else if(keyCode == KeyEvent.KEYCODE_MENU)
+ {
+ //How did we get here? Is there a childView?
+ View childView = this.getFocusedChild();
+ if(childView != null)
+ {
+ //Make sure we close the keyboard if it's present
+ InputMethodManager imm = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(childView.getWindowToken(), 0);
+ cordova.getActivity().openOptionsMenu();
+ return true;
+ } else {
+ return super.onKeyDown(keyCode, event);
+ }
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event)
+ {
+ // If back key
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ // A custom view is currently displayed (e.g. playing a video)
+ if(mCustomView != null) {
+ this.hideCustomView();
+ return true;
+ } else {
+ // The webview is currently displayed
+ // If back key is bound, then send event to JavaScript
+ if (isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK)) {
+ this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
+ return true;
+ } else {
+ // If not bound
+ // Go to previous page in webview if it is possible to go back
+ if (this.backHistory()) {
+ return true;
+ }
+ // If not, then invoke default behavior
+ }
+ }
+ }
+ // Legacy
+ else if (keyCode == KeyEvent.KEYCODE_MENU) {
+ if (this.lastMenuEventTime < event.getEventTime()) {
+ this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');");
+ }
+ this.lastMenuEventTime = event.getEventTime();
+ return super.onKeyUp(keyCode, event);
+ }
+ // If search key
+ else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
+ this.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');");
+ return true;
+ }
+
+ //Does webkit change this behavior?
+ return super.onKeyUp(keyCode, event);
+ }
+
+ @Override
+ public void setButtonPlumbedToJs(int keyCode, boolean override) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ case KeyEvent.KEYCODE_BACK:
+ // TODO: Why are search and menu buttons handled separately?
+ if (override) {
+ boundKeyCodes.add(keyCode);
+ } else {
+ boundKeyCodes.remove(keyCode);
+ }
+ return;
+ default:
+ throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
+ }
+ }
+
+ @Override
+ public boolean isButtonPlumbedToJs(int keyCode)
+ {
+ return boundKeyCodes.contains(keyCode);
+ }
+
+ public void handlePause(boolean keepRunning)
+ {
+ LOG.d(TAG, "Handle the pause");
+ // Send pause event to JavaScript
+ this.loadUrl("javascript:try{cordova.fireDocumentEvent('pause');}catch(e){console.log('exception firing pause event from native');};");
+
+ // Forward to plugins
+ if (this.pluginManager != null) {
+ this.pluginManager.onPause(keepRunning);
+ }
+
+ // If app doesn't want to run in background
+ if (!keepRunning) {
+ // Pause JavaScript timers (including setInterval)
+ this.pauseTimers();
+ }
+ }
+
+ public void handleResume(boolean keepRunning, boolean activityResultKeepRunning)
+ {
+ this.loadUrl("javascript:try{cordova.fireDocumentEvent('resume');}catch(e){console.log('exception firing resume event from native');};");
+
+ // Forward to plugins
+ if (this.pluginManager != null) {
+ this.pluginManager.onResume(keepRunning);
+ }
+
+ // Resume JavaScript timers (including setInterval)
+ this.resumeTimers();
+ }
+
+ public void handleDestroy()
+ {
+ // Send destroy event to JavaScript
+ this.loadUrl("javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
+
+ // Load blank page so that JavaScript onunload is called
+ this.loadUrl("about:blank");
+
+ // Forward to plugins
+ if (this.pluginManager != null) {
+ this.pluginManager.onDestroy();
+ }
+
+ // unregister the receiver
+ if (this.receiver != null) {
+ try {
+ getContext().unregisterReceiver(this.receiver);
+ } catch (Exception e) {
+ Log.e(TAG, "Error unregistering configuration receiver: " + e.getMessage(), e);
+ }
+ }
+ }
+
+ public void onNewIntent(Intent intent)
+ {
+ //Forward to plugins
+ if (this.pluginManager != null) {
+ this.pluginManager.onNewIntent(intent);
+ }
+ }
+
+ // Wrapping these functions in their own class prevents warnings in adb like:
+ // VFY: unable to resolve virtual method 285: Landroid/webkit/WebSettings;.setAllowUniversalAccessFromFileURLs
+ @TargetApi(16)
+ private static class Level16Apis {
+ static void enableUniversalAccess(WebSettings settings) {
+ settings.setAllowUniversalAccessFromFileURLs(true);
+ }
+ }
+
+ public void printBackForwardList() {
+ WebBackForwardList currentList = this.copyBackForwardList();
+ int currentSize = currentList.getSize();
+ for(int i = 0; i < currentSize; ++i)
+ {
+ WebHistoryItem item = currentList.getItemAtIndex(i);
+ String url = item.getUrl();
+ LOG.d(TAG, "The URL at index: " + Integer.toString(i) + " is " + url );
+ }
+ }
+
+
+ //Can Go Back is BROKEN!
+ public boolean startOfHistory()
+ {
+ WebBackForwardList currentList = this.copyBackForwardList();
+ WebHistoryItem item = currentList.getItemAtIndex(0);
+ if( item!=null){ // Null-fence in case they haven't called loadUrl yet (CB-2458)
+ String url = item.getUrl();
+ String currentUrl = this.getUrl();
+ LOG.d(TAG, "The current URL is: " + currentUrl);
+ LOG.d(TAG, "The URL at item 0 is: " + url);
+ return currentUrl.equals(url);
+ }
+ return false;
+ }
+
+ public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
+ // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
+ Log.d(TAG, "showing Custom View");
+ // if a view already exists then immediately terminate the new one
+ if (mCustomView != null) {
+ callback.onCustomViewHidden();
+ return;
+ }
+
+ // Store the view and its callback for later (to kill it properly)
+ mCustomView = view;
+ mCustomViewCallback = callback;
+
+ // Add the custom view to its container.
+ ViewGroup parent = (ViewGroup) this.getParent();
+ parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
+
+ // Hide the content view.
+ this.setVisibility(View.GONE);
+
+ // Finally show the custom view container.
+ parent.setVisibility(View.VISIBLE);
+ parent.bringToFront();
+ }
+
+ public void hideCustomView() {
+ // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
+ Log.d(TAG, "Hiding Custom View");
+ if (mCustomView == null) return;
+
+ // Hide the custom view.
+ mCustomView.setVisibility(View.GONE);
+
+ // Remove the custom view from its container.
+ ViewGroup parent = (ViewGroup) this.getParent();
+ parent.removeView(mCustomView);
+ mCustomView = null;
+ mCustomViewCallback.onCustomViewHidden();
+
+ // Show the content view.
+ this.setVisibility(View.VISIBLE);
+ }
+
+ /**
+ * if the video overlay is showing then we need to know
+ * as it effects back button handling
+ *
+ * @return true if custom view is showing
+ */
+ public boolean isCustomViewShowing() {
+ return mCustomView != null;
+ }
+
+ public WebBackForwardList restoreState(Bundle savedInstanceState)
+ {
+ WebBackForwardList myList = super.restoreState(savedInstanceState);
+ Log.d(TAG, "WebView restoration crew now restoring!");
+ //Initialize the plugin manager once more
+ this.pluginManager.init();
+ return myList;
+ }
+
+ public CordovaResourceApi getResourceApi() {
+ return resourceApi;
+ }
+
+ void onPageReset() {
+ boundKeyCodes.clear();
+ pluginManager.onReset();
+ bridge.reset(loadedUrl);
+ }
+
+ @Override
+ public PluginManager getPluginManager() {
+ return this.pluginManager;
+ }
+
+ @Override
+ public View getView() {
+ return this;
+ }
+
+ @Override
+ public Whitelist getWhitelist() {
- return this.whitelist;
++ return this.internalWhitelist;
+ }
-
++
++ @Override
++ public Whitelist getExternalWhitelist() {
++ return this.externalWhitelist;
++ }
++
+ @Override
+ public CordovaPreferences getPreferences() {
+ return preferences;
+ }
+
+ @Override
+ public void onFilePickerResult(Uri uri) {
+ if (null == chromeClient.mUploadMessage)
+ return;
+ chromeClient.mUploadMessage.onReceiveValue(uri);
+ chromeClient.mUploadMessage = null;
+ }
+
+ @Override
+ public Object postMessage(String id, Object data) {
+ return pluginManager.postMessage(id, data);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/31b1a821/framework/src/org/apache/cordova/ConfigXmlParser.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/ConfigXmlParser.java
index e5cb1db,1ada1af..0b1f529
--- a/framework/src/org/apache/cordova/ConfigXmlParser.java
+++ b/framework/src/org/apache/cordova/ConfigXmlParser.java
@@@ -74,7 -80,13 +79,12 @@@ public class ConfigXmlParser
String service = "", pluginClass = "", paramType = "";
boolean onload = false;
boolean insideFeature = false;
- ArrayList<String> urlMap = null;
+ // Add implicitly allowed URLs
+ internalWhitelist.addWhiteListEntry("file:///*", false);
+ internalWhitelist.addWhiteListEntry("content:///*", false);
+ internalWhitelist.addWhiteListEntry("data:*", false);
+
while (eventType != XmlResourceParser.END_DOCUMENT) {
if (eventType == XmlResourceParser.START_TAG) {
String strNode = xml.getName();
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/31b1a821/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaActivity.java
index fa332e5,190309e..c2971ae
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@@ -230,34 -268,76 +232,34 @@@ public class CordovaActivity extends Ac
* require a more specialized web view.
*/
protected CordovaWebView makeWebView() {
- return new CordovaWebView(CordovaActivity.this);
- }
-
- /**
- * Construct the client for the default web view object.
- *
- * This is intended to be overridable by subclasses of CordovaIntent which
- * require a more specialized web view.
- *
- * @param webView the default constructed web view object
- */
- protected CordovaWebViewClient makeWebViewClient(CordovaWebView webView) {
- return webView.makeWebViewClient(this);
- }
-
- /**
- * Construct the chrome client for the default web view object.
- *
- * This is intended to be overridable by subclasses of CordovaIntent which
- * require a more specialized web view.
- *
- * @param webView the default constructed web view object
- */
- protected CordovaChromeClient makeChromeClient(CordovaWebView webView) {
- return webView.makeWebChromeClient(this);
- }
-
- public void init() {
- this.init(appView, null, null);
- }
-
- @SuppressLint("NewApi")
- @Deprecated // Call init() instead and override makeWebView() to customize.
- public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
- LOG.d(TAG, "CordovaActivity.init()");
-
- if(!preferences.getBoolean("ShowTitle", false))
- {
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);
- }
-
- if(preferences.getBoolean("SetFullscreen", false))
- {
- Log.d(TAG, "The SetFullscreen configuration is deprecated in favor of Fullscreen, and will be removed in a future version.");
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- } else if (preferences.getBoolean("Fullscreen", false)) {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- } else {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
- }
-
- appView = webView != null ? webView : makeWebView();
- if (appView.pluginManager == null) {
- appView.init(this, webViewClient != null ? webViewClient : makeWebViewClient(appView),
- webChromeClient != null ? webChromeClient : makeChromeClient(appView),
- pluginEntries, internalWhitelist, externalWhitelist, preferences);
+ String r = preferences.getString("webView", null);
+ CordovaWebView ret = null;
+ if (r != null) {
+ try {
+ Class<?> webViewClass = Class.forName(r);
+ Constructor<?> constructor = webViewClass.getConstructor(Context.class);
+ ret = (CordovaWebView) constructor.newInstance((Context)this);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
}
-
- // TODO: Have the views set this themselves.
- if (preferences.getBoolean("DisallowOverscroll", false)) {
- appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
+
+ if (ret == null) {
+ // If all else fails, return a default WebView
+ ret = new AndroidWebView(this);
}
- ret.init(this, pluginEntries, whitelist, preferences);
- createViews();
-
- // TODO: Make this a preference (CB-6153)
- // Setup the hardware volume controls to handle volume control
- setVolumeControlStream(AudioManager.STREAM_MUSIC);
++ ret.init(this, pluginEntries, internalWhitelist, externalWhitelist, preferences);
+ return ret;
}
/**
@@@ -544,7 -791,8 +546,7 @@@
// If errorUrl specified, then load it
final String errorUrl = preferences.getString("errorUrl", null);
- if ((errorUrl != null) && (errorUrl.startsWith("file://") || whitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
+ if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
-
// Load URL on UI thread
me.runOnUiThread(new Runnable() {
public void run() {
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/31b1a821/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaUriHelper.java
index f7d22da,ada2851..6c1c4fa
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@@ -47,19 -47,12 +47,12 @@@ public class CordovaUriHelper
* @return true to override, false for default behavior
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
- boolean shouldOverrideUrlLoading(WebView view, String url) {
+ public boolean shouldOverrideUrlLoading(String url) {
- // The WebView should support http and https when going on the Internet
- if(url.startsWith("http:") || url.startsWith("https:"))
- {
- // We only need to whitelist sites on the Internet!
- if(appView.getWhitelist().isUrlWhiteListed(url))
- {
- return false;
- }
- }
// Give plugins the chance to handle the url
- else if (this.appView.getPluginManager().onOverrideUrlLoading(url)) {
-
- if (this.appView.pluginManager.onOverrideUrlLoading(url)) {
++ if (this.appView.getPluginManager().onOverrideUrlLoading(url)) {
+ // Do nothing other than what the plugins wanted.
+ // If any returned true, then the request was handled.
+ return true;
}
else if(url.startsWith("file://") | url.startsWith("data:"))
{
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/31b1a821/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaWebView.java
index 213e062,403a7ae..47abfc0
mode 100644,100755..100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@@ -1,47 -1,488 +1,48 @@@
-/*
- 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.
-*/
-
package org.apache.cordova;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
-import java.util.Locale;
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.ApplicationInfo;
import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.KeyEvent;
import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
-import android.webkit.WebBackForwardList;
-import android.webkit.WebHistoryItem;
-import android.webkit.WebChromeClient;
-import android.webkit.WebSettings;
-import android.webkit.WebView;
-import android.webkit.WebSettings.LayoutAlgorithm;
-import android.webkit.WebViewClient;
-import android.widget.FrameLayout;
-
-/*
- * This class is our web view.
- *
- * @see <a href="http://developer.android.com/guide/webapps/webview.html">WebView guide</a>
- * @see <a href="http://developer.android.com/reference/android/webkit/WebView.html">WebView</a>
- */
-public class CordovaWebView extends WebView {
-
- public static final String TAG = "CordovaWebView";
- public static final String CORDOVA_VERSION = "3.6.0-dev";
-
- private HashSet<Integer> boundKeyCodes = new HashSet<Integer>();
-
- public PluginManager pluginManager;
- private boolean paused;
-
- private BroadcastReceiver receiver;
-
-
- /** Activities and other important classes **/
- private CordovaInterface cordova;
- CordovaWebViewClient viewClient;
- private CordovaChromeClient chromeClient;
-
- // Flag to track that a loadUrl timeout occurred
- int loadUrlTimeout = 0;
-
- private long lastMenuEventTime = 0;
-
- CordovaBridge bridge;
-
- /** custom view created by the browser (a video player for example) */
- private View mCustomView;
- private WebChromeClient.CustomViewCallback mCustomViewCallback;
-
- private CordovaResourceApi resourceApi;
- private Whitelist internalWhitelist;
- private Whitelist externalWhitelist;
-
- // The URL passed to loadUrl(), not necessarily the URL of the current page.
- String loadedUrl;
- private CordovaPreferences preferences;
-
- class ActivityResult {
-
- int request;
- int result;
- Intent incoming;
-
- public ActivityResult(int req, int res, Intent intent) {
- request = req;
- result = res;
- incoming = intent;
- }
-
-
- }
-
- static final FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER =
- new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT,
- Gravity.CENTER);
-
- public CordovaWebView(Context context) {
- this(context, null);
- }
-
- public CordovaWebView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Deprecated
- public CordovaWebView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @TargetApi(11)
- @Deprecated
- public CordovaWebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
- super(context, attrs, defStyle, privateBrowsing);
- }
-
- // Use two-phase init so that the control will work with XML layouts.
- public void init(CordovaInterface cordova, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient,
- List<PluginEntry> pluginEntries, Whitelist internalWhitelist, Whitelist externalWhitelist,
- CordovaPreferences preferences) {
- if (this.cordova != null) {
- throw new IllegalStateException();
- }
- this.cordova = cordova;
- this.viewClient = webViewClient;
- this.chromeClient = webChromeClient;
- this.internalWhitelist = internalWhitelist;
- this.externalWhitelist = externalWhitelist;
- this.preferences = preferences;
- super.setWebChromeClient(webChromeClient);
- super.setWebViewClient(webViewClient);
-
- pluginManager = new PluginManager(this, this.cordova, pluginEntries);
- bridge = new CordovaBridge(pluginManager, new NativeToJsMessageQueue(this, cordova));
- resourceApi = new CordovaResourceApi(this.getContext(), pluginManager);
-
- pluginManager.addService("App", "org.apache.cordova.App");
- initWebViewSettings();
- exposeJsInterface();
- }
-
- @SuppressWarnings("deprecation")
- private void initIfNecessary() {
- if (pluginManager == null) {
- Log.w(TAG, "CordovaWebView.init() was not called. This will soon be required.");
- // Before the refactor to a two-phase init, the Context needed to implement CordovaInterface.
- CordovaInterface cdv = (CordovaInterface)getContext();
- if (!Config.isInitialized()) {
- Config.init(cdv.getActivity());
- }
- init(cdv, makeWebViewClient(cdv), makeWebChromeClient(cdv), Config.getPluginEntries(), Config.getWhitelist(), Config.getExternalWhitelist(), Config.getPreferences());
- }
- }
-
- @SuppressLint("SetJavaScriptEnabled")
- @SuppressWarnings("deprecation")
- private void initWebViewSettings() {
- this.setInitialScale(0);
- this.setVerticalScrollBarEnabled(false);
- // TODO: The Activity is the one that should call requestFocus().
- if (shouldRequestFocusOnInit()) {
- this.requestFocusFromTouch();
- }
- // Enable JavaScript
- WebSettings settings = this.getSettings();
- settings.setJavaScriptEnabled(true);
- settings.setJavaScriptCanOpenWindowsAutomatically(true);
- settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
-
- // Set the nav dump for HTC 2.x devices (disabling for ICS, deprecated entirely for Jellybean 4.2)
- try {
- Method gingerbread_getMethod = WebSettings.class.getMethod("setNavDump", new Class[] { boolean.class });
-
- String manufacturer = android.os.Build.MANUFACTURER;
- Log.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);
- if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB &&
- android.os.Build.MANUFACTURER.contains("HTC"))
- {
- gingerbread_getMethod.invoke(settings, true);
- }
- } catch (NoSuchMethodException e) {
- Log.d(TAG, "We are on a modern version of Android, we will deprecate HTC 2.3 devices in 2.8");
- } catch (IllegalArgumentException e) {
- Log.d(TAG, "Doing the NavDump failed with bad arguments");
- } catch (IllegalAccessException e) {
- Log.d(TAG, "This should never happen: IllegalAccessException means this isn't Android anymore");
- } catch (InvocationTargetException e) {
- Log.d(TAG, "This should never happen: InvocationTargetException means this isn't Android anymore.");
- }
+import android.webkit.WebChromeClient.CustomViewCallback;
- //We don't save any form data in the application
- settings.setSaveFormData(false);
- settings.setSavePassword(false);
-
- // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
- // while we do this
- if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
- Level16Apis.enableUniversalAccess(settings);
- // Enable database
- // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
- String databasePath = getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
- settings.setDatabaseEnabled(true);
- settings.setDatabasePath(databasePath);
-
-
- //Determine whether we're in debug or release mode, and turn on Debugging!
- ApplicationInfo appInfo = getContext().getApplicationContext().getApplicationInfo();
- if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&
- android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
- enableRemoteDebugging();
- }
-
- settings.setGeolocationDatabasePath(databasePath);
+public interface CordovaWebView {
+ public static final String CORDOVA_VERSION = "4.0.0-dev";
- // Enable DOM storage
- settings.setDomStorageEnabled(true);
+ void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
- Whitelist whitelist, CordovaPreferences preferences);
++ Whitelist internalWhitelist, Whitelist externalWhitelist,
++ CordovaPreferences preferences);
- // Enable built-in geolocation
- settings.setGeolocationEnabled(true);
-
- // Enable AppCache
- // Fix for CB-2282
- settings.setAppCacheMaxSize(5 * 1048576);
- settings.setAppCachePath(databasePath);
- settings.setAppCacheEnabled(true);
-
- // Fix for CB-1405
- // Google issue 4641
- settings.getUserAgentString();
-
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
- if (this.receiver == null) {
- this.receiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- getSettings().getUserAgentString();
- }
- };
- getContext().registerReceiver(this.receiver, intentFilter);
- }
- // end CB-1405
- }
+ View getView();
- @TargetApi(Build.VERSION_CODES.KITKAT)
- private void enableRemoteDebugging() {
- try {
- WebView.setWebContentsDebuggingEnabled(true);
- } catch (IllegalArgumentException e) {
- Log.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
- e.printStackTrace();
- }
- }
+ void loadUrlIntoView(String url, boolean recreatePlugins);
- public CordovaChromeClient makeWebChromeClient(CordovaInterface cordova) {
- return new CordovaChromeClient(cordova, this);
- }
+ void stopLoading();
- public CordovaWebViewClient makeWebViewClient(CordovaInterface cordova) {
- if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- return new CordovaWebViewClient(cordova, this);
- }
- return new IceCreamCordovaWebViewClient(cordova, this);
- }
+ boolean canGoBack();
- /**
- * Override this method to decide whether or not you need to request the
- * focus when your application start
- *
- * @return true unless this method is overriden to return a different value
- */
- protected boolean shouldRequestFocusOnInit() {
- return true;
- }
+ void clearCache(boolean b);
- private void exposeJsInterface() {
- if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
- Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
- // Bug being that Java Strings do not get converted to JS strings automatically.
- // This isn't hard to work-around on the JS side, but it's easier to just
- // use the prompt bridge instead.
- return;
- }
- this.addJavascriptInterface(new ExposedJsApi(bridge), "_cordovaNative");
- }
-
- @Override
- public void setWebViewClient(WebViewClient client) {
- this.viewClient = (CordovaWebViewClient)client;
- super.setWebViewClient(client);
- }
-
- @Override
- public void setWebChromeClient(WebChromeClient client) {
- this.chromeClient = (CordovaChromeClient)client;
- super.setWebChromeClient(client);
- }
-
- public CordovaChromeClient getWebChromeClient() {
- return this.chromeClient;
- }
-
-
- public Whitelist getWhitelist() {
- return this.internalWhitelist;
- }
-
- public Whitelist getExternalWhitelist() {
- return this.externalWhitelist;
- }
-
- /**
- * Load the url into the webview.
- *
- * @param url
- */
- @Override
- public void loadUrl(String url) {
- if (url.equals("about:blank") || url.startsWith("javascript:")) {
- this.loadUrlNow(url);
- }
- else {
- this.loadUrlIntoView(url);
- }
- }
-
- /**
- * Load the url into the webview after waiting for period of time.
- * This is used to display the splashscreen for certain amount of time.
- *
- * @param url
- * @param time The number of ms to wait before loading webview
- */
- @Deprecated
- public void loadUrl(final String url, int time) {
- if(url == null)
- {
- this.loadUrlIntoView(Config.getStartUrl());
- }
- else
- {
- this.loadUrlIntoView(url);
- }
- }
-
- public void loadUrlIntoView(final String url) {
- loadUrlIntoView(url, true);
- }
-
- /**
- * Load the url into the webview.
- *
- * @param url
- */
- public void loadUrlIntoView(final String url, boolean recreatePlugins) {
- LOG.d(TAG, ">>> loadUrl(" + url + ")");
-
- initIfNecessary();
-
- if (recreatePlugins) {
- this.loadedUrl = url;
- this.pluginManager.init();
- }
-
- // Create a timeout timer for loadUrl
- final CordovaWebView me = this;
- final int currentLoadUrlTimeout = me.loadUrlTimeout;
- final int loadUrlTimeoutValue = Integer.parseInt(this.getProperty("LoadUrlTimeoutValue", "20000"));
-
- // Timeout error method
- final Runnable loadError = new Runnable() {
- public void run() {
- me.stopLoading();
- LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
- if (viewClient != null) {
- viewClient.onReceivedError(me, -6, "The connection to the server was unsuccessful.", url);
- }
- }
- };
-
- // Timeout timer method
- final Runnable timeoutCheck = new Runnable() {
- public void run() {
- try {
- synchronized (this) {
- wait(loadUrlTimeoutValue);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- // If timeout, then stop loading and handle error
- if (me.loadUrlTimeout == currentLoadUrlTimeout) {
- me.cordova.getActivity().runOnUiThread(loadError);
- }
- }
- };
-
- // Load url
- this.cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- cordova.getThreadPool().execute(timeoutCheck);
- me.loadUrlNow(url);
- }
- });
- }
-
- /**
- * Load URL in webview.
- *
- * @param url
- */
- void loadUrlNow(String url) {
- if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
- LOG.d(TAG, ">>> loadUrlNow()");
- }
- if (url.startsWith("file://") || url.startsWith("javascript:") || internalWhitelist.isUrlWhiteListed(url)) {
- super.loadUrl(url);
- }
- }
+ void clearHistory();
- /**
- * Load the url into the webview after waiting for period of time.
- * This is used to display the splashscreen for certain amount of time.
- *
- * @param url
- * @param time The number of ms to wait before loading webview
- */
- public void loadUrlIntoView(final String url, final int time) {
+ boolean backHistory();
- // If not first page of app, then load immediately
- // Add support for browser history if we use it.
- if ((url.startsWith("javascript:")) || this.canGoBack()) {
- }
+ void handlePause(boolean keepRunning);
- // If first page, then show splashscreen
- else {
+ void onNewIntent(Intent intent);
- LOG.d(TAG, "loadUrlIntoView(%s, %d)", url, time);
+ void handleResume(boolean keepRunning, boolean activityResultKeepRunning);
- // Send message to show splashscreen now if desired
- this.postMessage("splashscreen", "show");
- }
+ void handleDestroy();
- // Load url
- this.loadUrlIntoView(url);
- }
-
- @Override
- public void stopLoading() {
- viewClient.isCurrentlyLoading = false;
- super.stopLoading();
- }
-
- 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);
- }
-
/**
* Send JavaScript statement back to JavaScript.
+ * (This is a convenience method)
+ *
+ * @param statement
* Deprecated (https://issues.apache.org/jira/browse/CB-6851)
* Instead of executing snippets of JS, you should use the exec bridge
* to create a Java->JS communication channel.
@@@ -61,36 -502,433 +62,37 @@@
* savedCallbackContext.sendPluginResult(dataResult);
*/
@Deprecated
- public void sendJavascript(String statement) {
- this.bridge.getMessageQueue().addJavaScript(statement);
- }
-
- /**
- * Send a plugin result back to JavaScript.
- * (This is a convenience method)
- *
- * @param result
- * @param callbackId
- */
- public void sendPluginResult(PluginResult result, String callbackId) {
- this.bridge.getMessageQueue().addPluginResult(result, callbackId);
- }
+ void sendJavascript(String statememt);
- /**
- * Send a message to all plugins.
- *
- * @param id The message id
- * @param data The message data
- */
- public void postMessage(String id, Object data) {
- if (this.pluginManager != null) {
- this.pluginManager.postMessage(id, data);
- }
- }
+ void showWebPage(String errorUrl, boolean b, boolean c, HashMap<String, Object> params);
+ boolean isCustomViewShowing();
- /**
- * Go to previous page in history. (We manage our own history)
- *
- * @return true if we went back, false if we are already at top
- */
- public boolean backHistory() {
- // Check webview first to see if there is a history
- // This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
- if (super.canGoBack()) {
- super.goBack();
- return true;
- }
- return false;
- }
+ void showCustomView(View view, CustomViewCallback callback);
+ void hideCustomView();
- /**
- * Load the specified URL in the Cordova webview or a new browser instance.
- *
- * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
- *
- * @param url The url to load.
- * @param openExternal Load url in browser instead of Cordova webview.
- * @param clearHistory Clear the history stack, so new page becomes top of history
- * @param params Parameters for new app
- */
- public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
- LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);
-
- // If clearing history
- if (clearHistory) {
- this.clearHistory();
- }
-
- // If loading into our webview
- if (!openExternal) {
+ CordovaResourceApi getResourceApi();
- // Make sure url is in whitelist
- if (url.startsWith("file://") || internalWhitelist.isUrlWhiteListed(url)) {
- // TODO: What about params?
- // Load new URL
- this.loadUrl(url);
- return;
- }
- // Load in default viewer if not
- LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list. Loading into browser instead. (URL=" + url + ")");
- }
- try {
- // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
- // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
- Intent intent = new Intent(Intent.ACTION_VIEW);
- Uri uri = Uri.parse(url);
- if ("file".equals(uri.getScheme())) {
- intent.setDataAndType(uri, resourceApi.getMimeType(uri));
- } else {
- intent.setData(uri);
- }
- cordova.getActivity().startActivity(intent);
- } catch (android.content.ActivityNotFoundException e) {
- LOG.e(TAG, "Error loading url " + url, e);
- }
- }
+ void setButtonPlumbedToJs(int keyCode, boolean override);
+ boolean isButtonPlumbedToJs(int keyCode);
- /**
- * Get string property for activity.
- *
- * @param name
- * @param defaultValue
- * @return the String value for the named property
- */
- public String getProperty(String name, String defaultValue) {
- Bundle bundle = this.cordova.getActivity().getIntent().getExtras();
- if (bundle == null) {
- return defaultValue;
- }
- name = name.toLowerCase(Locale.getDefault());
- Object p = bundle.get(name);
- if (p == null) {
- return defaultValue;
- }
- return p.toString();
- }
+ void sendPluginResult(PluginResult cr, String callbackId);
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- if(boundKeyCodes.contains(keyCode))
- {
- if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
- this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');");
- return true;
- }
- // If volumeup key
- else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
- this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');");
- return true;
- }
- else
- {
- return super.onKeyDown(keyCode, event);
- }
- }
- else if(keyCode == KeyEvent.KEYCODE_BACK)
- {
- return !(this.startOfHistory()) || isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK);
- }
- else if(keyCode == KeyEvent.KEYCODE_MENU)
- {
- //How did we get here? Is there a childView?
- View childView = this.getFocusedChild();
- if(childView != null)
- {
- //Make sure we close the keyboard if it's present
- InputMethodManager imm = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(childView.getWindowToken(), 0);
- cordova.getActivity().openOptionsMenu();
- return true;
- } else {
- return super.onKeyDown(keyCode, event);
- }
- }
- return super.onKeyDown(keyCode, event);
- }
+ PluginManager getPluginManager();
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event)
- {
- // If back key
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- // A custom view is currently displayed (e.g. playing a video)
- if(mCustomView != null) {
- this.hideCustomView();
- return true;
- } else {
- // The webview is currently displayed
- // If back key is bound, then send event to JavaScript
- if (isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK)) {
- this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
- return true;
- } else {
- // If not bound
- // Go to previous page in webview if it is possible to go back
- if (this.backHistory()) {
- return true;
- }
- // If not, then invoke default behavior
- }
- }
- }
- // Legacy
- else if (keyCode == KeyEvent.KEYCODE_MENU) {
- if (this.lastMenuEventTime < event.getEventTime()) {
- this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');");
- }
- this.lastMenuEventTime = event.getEventTime();
- return super.onKeyUp(keyCode, event);
- }
- // If search key
- else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
- this.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');");
- return true;
- }
-
- //Does webkit change this behavior?
- return super.onKeyUp(keyCode, event);
- }
-
- public void setButtonPlumbedToJs(int keyCode, boolean override) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- case KeyEvent.KEYCODE_VOLUME_UP:
- case KeyEvent.KEYCODE_BACK:
- // TODO: Why are search and menu buttons handled separately?
- if (override) {
- boundKeyCodes.add(keyCode);
- } else {
- boundKeyCodes.remove(keyCode);
- }
- return;
- default:
- throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
- }
- }
-
- @Deprecated // Use setButtonPlumbedToJs() instead.
- public void bindButton(boolean override)
- {
- setButtonPlumbedToJs(KeyEvent.KEYCODE_BACK, override);
- }
-
- @Deprecated // Use setButtonPlumbedToJs() instead.
- public void bindButton(String button, boolean override) {
- if (button.compareTo("volumeup")==0) {
- setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_UP, override);
- }
- else if (button.compareTo("volumedown")==0) {
- setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_DOWN, override);
- }
- }
-
- @Deprecated // Use setButtonPlumbedToJs() instead.
- public void bindButton(int keyCode, boolean keyDown, boolean override) {
- setButtonPlumbedToJs(keyCode, override);
- }
-
- @Deprecated // Use isButtonPlumbedToJs
- public boolean isBackButtonBound()
- {
- return isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK);
- }
-
- public boolean isButtonPlumbedToJs(int keyCode)
- {
- return boundKeyCodes.contains(keyCode);
- }
-
- public void handlePause(boolean keepRunning)
- {
- LOG.d(TAG, "Handle the pause");
- // Send pause event to JavaScript
- this.loadUrl("javascript:try{cordova.fireDocumentEvent('pause');}catch(e){console.log('exception firing pause event from native');};");
-
- // Forward to plugins
- if (this.pluginManager != null) {
- this.pluginManager.onPause(keepRunning);
- }
-
- // If app doesn't want to run in background
- if (!keepRunning) {
- // Pause JavaScript timers (including setInterval)
- this.pauseTimers();
- }
- paused = true;
-
- }
-
- public void handleResume(boolean keepRunning, boolean activityResultKeepRunning)
- {
-
- this.loadUrl("javascript:try{cordova.fireDocumentEvent('resume');}catch(e){console.log('exception firing resume event from native');};");
-
- // Forward to plugins
- if (this.pluginManager != null) {
- this.pluginManager.onResume(keepRunning);
- }
-
- // Resume JavaScript timers (including setInterval)
- this.resumeTimers();
- paused = false;
- }
-
- public void handleDestroy()
- {
- // Send destroy event to JavaScript
- this.loadUrl("javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};");
-
- // Load blank page so that JavaScript onunload is called
- this.loadUrl("about:blank");
-
- // Forward to plugins
- if (this.pluginManager != null) {
- this.pluginManager.onDestroy();
- }
-
- // unregister the receiver
- if (this.receiver != null) {
- try {
- getContext().unregisterReceiver(this.receiver);
- } catch (Exception e) {
- Log.e(TAG, "Error unregistering configuration receiver: " + e.getMessage(), e);
- }
- }
- }
-
- public void onNewIntent(Intent intent)
- {
- //Forward to plugins
- if (this.pluginManager != null) {
- this.pluginManager.onNewIntent(intent);
- }
- }
-
- public boolean isPaused()
- {
- return paused;
- }
-
- @Deprecated // This never did anything.
- public boolean hadKeyEvent() {
- return false;
- }
-
- // Wrapping these functions in their own class prevents warnings in adb like:
- // VFY: unable to resolve virtual method 285: Landroid/webkit/WebSettings;.setAllowUniversalAccessFromFileURLs
- @TargetApi(16)
- private static class Level16Apis {
- static void enableUniversalAccess(WebSettings settings) {
- settings.setAllowUniversalAccessFromFileURLs(true);
- }
- }
-
- public void printBackForwardList() {
- WebBackForwardList currentList = this.copyBackForwardList();
- int currentSize = currentList.getSize();
- for(int i = 0; i < currentSize; ++i)
- {
- WebHistoryItem item = currentList.getItemAtIndex(i);
- String url = item.getUrl();
- LOG.d(TAG, "The URL at index: " + Integer.toString(i) + " is " + url );
- }
- }
-
-
- //Can Go Back is BROKEN!
- public boolean startOfHistory()
- {
- WebBackForwardList currentList = this.copyBackForwardList();
- WebHistoryItem item = currentList.getItemAtIndex(0);
- if( item!=null){ // Null-fence in case they haven't called loadUrl yet (CB-2458)
- String url = item.getUrl();
- String currentUrl = this.getUrl();
- LOG.d(TAG, "The current URL is: " + currentUrl);
- LOG.d(TAG, "The URL at item 0 is: " + url);
- return currentUrl.equals(url);
- }
- return false;
- }
-
- public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
- // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
- Log.d(TAG, "showing Custom View");
- // if a view already exists then immediately terminate the new one
- if (mCustomView != null) {
- callback.onCustomViewHidden();
- return;
- }
-
- // Store the view and its callback for later (to kill it properly)
- mCustomView = view;
- mCustomViewCallback = callback;
-
- // Add the custom view to its container.
- ViewGroup parent = (ViewGroup) this.getParent();
- parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
-
- // Hide the content view.
- this.setVisibility(View.GONE);
-
- // Finally show the custom view container.
- parent.setVisibility(View.VISIBLE);
- parent.bringToFront();
- }
-
- public void hideCustomView() {
- // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
- Log.d(TAG, "Hiding Custom View");
- if (mCustomView == null) return;
-
- // Hide the custom view.
- mCustomView.setVisibility(View.GONE);
-
- // Remove the custom view from its container.
- ViewGroup parent = (ViewGroup) this.getParent();
- parent.removeView(mCustomView);
- mCustomView = null;
- mCustomViewCallback.onCustomViewHidden();
-
- // Show the content view.
- this.setVisibility(View.VISIBLE);
- }
-
- /**
- * if the video overlay is showing then we need to know
- * as it effects back button handling
- *
- * @return true if custom view is showing
- */
- public boolean isCustomViewShowing() {
- return mCustomView != null;
- }
+ Whitelist getWhitelist();
++ Whitelist getExternalWhitelist();
+ CordovaPreferences getPreferences();
- public WebBackForwardList restoreState(Bundle savedInstanceState)
- {
- WebBackForwardList myList = super.restoreState(savedInstanceState);
- Log.d(TAG, "WebView restoration crew now restoring!");
- //Initialize the plugin manager once more
- this.pluginManager.init();
- return myList;
- }
+ void onFilePickerResult(Uri uri);
- @Deprecated // This never did anything
- public void storeResult(int requestCode, int resultCode, Intent intent) {
- }
+ void setNetworkAvailable(boolean online);
- public CordovaResourceApi getResourceApi() {
- return resourceApi;
- }
+ String getUrl();
- public CordovaPreferences getPreferences() {
- return preferences;
- }
+ // TODO: Work on deleting these by removing refs from plugins.
+ Context getContext();
+ void loadUrl(String url);
+ Object postMessage(String id, Object data);
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/31b1a821/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --cc test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index b143521,d427047..43e0b2b
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@@ -51,7 -51,8 +51,8 @@@ public class CordovaWebViewTestActivit
Config.init(this);
cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
- cordovaWebView.init(this, Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
- cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
- Config.getPluginEntries(), Config.getWhitelist(), Config.getExternalWhitelist(), Config.getPreferences());
++ cordovaWebView.init(this, Config.getPluginEntries(), Config.getWhitelist(),
++ Config.getExternalWhitelist(), Config.getPreferences());
cordovaWebView.loadUrl("file:///android_asset/www/index.html");
[24/31] android commit: CB-7463: Adding licence to project template
gradle file
Posted by ia...@apache.org.
CB-7463: Adding licence to project template gradle file
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/7ee81171
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/7ee81171
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/7ee81171
Branch: refs/heads/4.0.x
Commit: 7ee8117186f71b6f83f6b701c17e6daefe95752c
Parents: 8237c41
Author: Ian Clelland <ic...@chromium.org>
Authored: Wed Sep 10 10:54:21 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Sep 10 10:54:21 2014 -0400
----------------------------------------------------------------------
bin/templates/project/build.gradle | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7ee81171/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index 9d1d45a..f56784e 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -1,3 +1,22 @@
+/*
+ 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.
+*/
+
import java.util.regex.Pattern
apply plugin: 'android'
[02/31] android commit: CB-7291: Only add file,
content and data URLs to internal whitelist
Posted by ia...@apache.org.
CB-7291: Only add file, content and data URLs to internal whitelist
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/3b3bd9b6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/3b3bd9b6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/3b3bd9b6
Branch: refs/heads/4.0.x
Commit: 3b3bd9b6c917fe3ca9fdc967e9812b56ce7ca47a
Parents: 4e3331b
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Aug 21 16:10:32 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Aug 21 16:27:48 2014 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/ConfigXmlParser.java | 5 +++++
framework/src/org/apache/cordova/Whitelist.java | 4 ----
2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/3b3bd9b6/framework/src/org/apache/cordova/ConfigXmlParser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/ConfigXmlParser.java b/framework/src/org/apache/cordova/ConfigXmlParser.java
index 9179f98..2a667a9 100644
--- a/framework/src/org/apache/cordova/ConfigXmlParser.java
+++ b/framework/src/org/apache/cordova/ConfigXmlParser.java
@@ -82,6 +82,11 @@ public class ConfigXmlParser {
boolean insideFeature = false;
ArrayList<String> urlMap = null;
+ // Add implicitly allowed URLs
+ internalWhitelist.addWhiteListEntry("file:///*", false);
+ internalWhitelist.addWhiteListEntry("content:///*", false);
+ internalWhitelist.addWhiteListEntry("data:*", false);
+
while (eventType != XmlResourceParser.END_DOCUMENT) {
if (eventType == XmlResourceParser.START_TAG) {
String strNode = xml.getName();
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/3b3bd9b6/framework/src/org/apache/cordova/Whitelist.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Whitelist.java b/framework/src/org/apache/cordova/Whitelist.java
index 5101ec3..d0f823c 100644
--- a/framework/src/org/apache/cordova/Whitelist.java
+++ b/framework/src/org/apache/cordova/Whitelist.java
@@ -98,10 +98,6 @@ public class Whitelist {
public Whitelist() {
this.whiteList = new ArrayList<URLPattern>();
- // Add implicitly allowed URLs
- addWhiteListEntry("file:///*", false);
- addWhiteListEntry("content:///*", false);
- addWhiteListEntry("data:*", false);
}
/* Match patterns (from http://developer.chrome.com/extensions/match_patterns.html)
[04/31] android commit: CB-7291: Restrict meaning of "*" in internal
whitelist to just http and https
Posted by ia...@apache.org.
CB-7291: Restrict meaning of "*" in internal whitelist to just http and https
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/6e222c39
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/6e222c39
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/6e222c39
Branch: refs/heads/4.0.x
Commit: 6e222c3938db43fc00f3d6f8fbb138af075c689b
Parents: 3b3bd9b
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Aug 26 14:58:00 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Aug 26 15:23:24 2014 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/ConfigXmlParser.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/6e222c39/framework/src/org/apache/cordova/ConfigXmlParser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/ConfigXmlParser.java b/framework/src/org/apache/cordova/ConfigXmlParser.java
index 2a667a9..1ada1af 100644
--- a/framework/src/org/apache/cordova/ConfigXmlParser.java
+++ b/framework/src/org/apache/cordova/ConfigXmlParser.java
@@ -119,7 +119,15 @@ public class ConfigXmlParser {
if (external) {
externalWhitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
} else {
- internalWhitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
+ if ("*".equals(origin)) {
+ // Special-case * origin to mean http and https when used for internal
+ // whitelist. This prevents external urls like sms: and geo: from being
+ // handled internally.
+ internalWhitelist.addWhiteListEntry("http://*/*", false);
+ internalWhitelist.addWhiteListEntry("https://*/*", false);
+ } else {
+ internalWhitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
+ }
}
}
}
[23/31] android commit: CB-7511 Auto-detect Android SDK when Android
Studio is installed
Posted by ia...@apache.org.
CB-7511 Auto-detect Android SDK when Android Studio is installed
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/8237c411
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/8237c411
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/8237c411
Branch: refs/heads/4.0.x
Commit: 8237c41143abf594ff0bcc717a7847a7aa38654c
Parents: 8354651
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 10 10:14:38 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 10 10:14:38 2014 -0400
----------------------------------------------------------------------
bin/lib/check_reqs.js | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8237c411/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 40f3ade..d2b3dcf 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -141,6 +141,20 @@ module.exports.check_android = function() {
var androidCmdPath = forgivingWhichSync('android');
var adbInPath = !!forgivingWhichSync('adb');
var hasAndroidHome = !!process.env['ANDROID_HOME'] && fs.existsSync(process.env['ANDROID_HOME']);
+ function maybeSetAndroidHome(value) {
+ if (fs.existsSync(value)) {
+ hasAndroidHome = true;
+ process.env['ANDROID_HOME'] = value;
+ }
+ }
+ if (!hasAndroidHome && !androidCmdPath) {
+ if (isWindows) {
+ maybeSetAndroidHome(path.join(process.env['LOCALAPPDATA'], 'Android', 'android-studio', 'sdk'));
+ maybeSetAndroidHome(path.join(process.env['ProgramFiles'], 'Android', 'android-studio', 'sdk'));
+ } else if (process.platform == 'darwin') {
+ maybeSetAndroidHome('/Applications/Android Studio.app/sdk');
+ }
+ }
if (hasAndroidHome && !androidCmdPath) {
process.env['PATH'] += path.delimiter + path.join(process.env['ANDROID_HOME'], 'tools');
}
@@ -171,7 +185,8 @@ module.exports.check_android_target = function(valid_target) {
.then(function(output) {
if (!output.match(valid_target)) {
throw new Error('Please install Android target "' + valid_target + '".\n' +
- 'Hint: Run "android" from your command-line to open the SDK manager.');
+ output + '\n\n' +
+ 'Hint: Install it using the SDK manager by running: ' + forgivingWhichSync('android'));
}
});
};
[08/31] android commit: CB-7385 update cordova.js for testing prior
to branch/tag
Posted by ia...@apache.org.
CB-7385 update cordova.js for testing prior to branch/tag
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/c6ccde05
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/c6ccde05
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/c6ccde05
Branch: refs/heads/4.0.x
Commit: c6ccde0558369272acdb02c153af034dfcd0525b
Parents: 16e3ebd
Author: Marcel Kinard <cm...@gmail.com>
Authored: Wed Aug 27 09:04:32 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Wed Aug 27 09:04:32 2014 -0400
----------------------------------------------------------------------
framework/assets/www/cordova.js | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6ccde05/framework/assets/www/cordova.js
----------------------------------------------------------------------
diff --git a/framework/assets/www/cordova.js b/framework/assets/www/cordova.js
index f0e57cd..73ec0fe 100644
--- a/framework/assets/www/cordova.js
+++ b/framework/assets/www/cordova.js
@@ -1,5 +1,5 @@
// Platform: android
-// 3.6.0-dev-70cdca3
+// 3.6.3
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '3.6.0-dev-70cdca3';
+var CORDOVA_JS_BUILD_LABEL = '3.6.3';
// file: src/scripts/require.js
/*jshint -W079 */
@@ -1497,6 +1497,17 @@ module.exports = {
cordova.addDocumentEventHandler('menubutton');
cordova.addDocumentEventHandler('searchbutton');
+ function bindButtonChannel(buttonName) {
+ // generic button bind used for volumeup/volumedown buttons
+ var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
+ volumeButtonChannel.onHasSubscribersChange = function() {
+ exec(null, null, "App", "overrideButton", [buttonName, this.numHandlers == 1]);
+ };
+ }
+ // Inject a listener for the volume buttons on the document.
+ bindButtonChannel('volumeup');
+ bindButtonChannel('volumedown');
+
// Let native code know we are all done on the JS side.
// Native code will then un-hide the WebView.
channel.onCordovaReady.subscribe(function() {
@@ -1575,6 +1586,21 @@ module.exports = {
},
/**
+ * Override the default behavior of the Android volume button.
+ * If overridden, when the volume button is pressed, the "volume[up|down]button"
+ * JavaScript event will be fired.
+ *
+ * Note: The user should not have to call this method. Instead, when the user
+ * registers for the "volume[up|down]button" event, this is automatically done.
+ *
+ * @param button volumeup, volumedown
+ * @param override T=override, F=cancel override
+ */
+ overrideButton:function(button, override) {
+ exec(null, null, "App", "overrideButton", [button, override]);
+ },
+
+ /**
* Exit and terminate the application.
*/
exitApp:function() {
@@ -1667,11 +1693,11 @@ function handlePluginsObject(path, moduleList, finishPluginLoading) {
function findCordovaPath() {
var path = null;
var scripts = document.getElementsByTagName('script');
- var term = 'cordova.js';
+ var term = '/cordova.js';
for (var n = scripts.length-1; n>-1; n--) {
var src = scripts[n].src.replace(/\?.*$/, ''); // Strip any query param (CB-6007).
if (src.indexOf(term) == (src.length - term.length)) {
- path = src.substring(0, src.length - term.length);
+ path = src.substring(0, src.length - term.length) + '/';
break;
}
}