mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
Merge branch 'master' into 4.0.x (move preference activation, alert dialog leak)
Conflicts: framework/src/org/apache/cordova/AndroidChromeClient.java framework/src/org/apache/cordova/CordovaActivity.java framework/src/org/apache/cordova/CordovaWebView.java test/src/org/apache/cordova/test/menus.java closes #123
This commit is contained in:
commit
7f4d5aeb0e
1
.gitignore
vendored
1
.gitignore
vendored
@ -37,3 +37,4 @@ Desktop.ini
|
|||||||
# IntelliJ IDEA files
|
# IntelliJ IDEA files
|
||||||
*.iml
|
*.iml
|
||||||
.idea
|
.idea
|
||||||
|
npm-debug.log
|
||||||
|
@ -20,6 +20,17 @@
|
|||||||
-->
|
-->
|
||||||
## Release Notes for Cordova (Android) ##
|
## Release Notes for Cordova (Android) ##
|
||||||
|
|
||||||
|
### 3.6.4 (Sept 30, 2014) ###
|
||||||
|
|
||||||
|
* Set VERSION to 3.6.4 (via coho)
|
||||||
|
* Update JS snapshot to version 3.6.4 (via coho)
|
||||||
|
* CB-7634 Detect JAVA_HOME properly on Ubuntu
|
||||||
|
* CB-7579 Fix run script's ability to use non-arch-specific APKs
|
||||||
|
* CB-6511 Fixes build for android when app name contains unicode characters.
|
||||||
|
* CB-7463: Adding licences. I don't know what the gradle syntax is for comments, that still needs to be done.
|
||||||
|
* CB-7463: Looked at the Apache BigTop git, gradle uses C-style comments
|
||||||
|
* CB-7460: Fixing bug with KitKat where the background colour would override the CSS colours on the application
|
||||||
|
|
||||||
### 3.6.0 (Sept 2014) ###
|
### 3.6.0 (Sept 2014) ###
|
||||||
|
|
||||||
* Set VERSION to 3.6.0 (via coho)
|
* Set VERSION to 3.6.0 (via coho)
|
||||||
|
27
framework/assets/www/cordova.js
vendored
27
framework/assets/www/cordova.js
vendored
@ -1,5 +1,5 @@
|
|||||||
// Platform: android
|
// Platform: android
|
||||||
// 3.7.0-dev-1258511
|
// 8ca0f3b2b87e0759c5236b91c80f18438544409c
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@ -19,7 +19,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
;(function() {
|
;(function() {
|
||||||
var CORDOVA_JS_BUILD_LABEL = '3.7.0-dev-1258511';
|
var PLATFORM_VERSION_BUILD_LABEL = '3.7.0-dev';
|
||||||
// file: src/scripts/require.js
|
// file: src/scripts/require.js
|
||||||
|
|
||||||
/*jshint -W079 */
|
/*jshint -W079 */
|
||||||
@ -175,7 +175,8 @@ function createEvent(type, data) {
|
|||||||
var cordova = {
|
var cordova = {
|
||||||
define:define,
|
define:define,
|
||||||
require:require,
|
require:require,
|
||||||
version:CORDOVA_JS_BUILD_LABEL,
|
version:PLATFORM_VERSION_BUILD_LABEL,
|
||||||
|
platformVersion:PLATFORM_VERSION_BUILD_LABEL,
|
||||||
platformId:platform.id,
|
platformId:platform.id,
|
||||||
/**
|
/**
|
||||||
* Methods to add/remove your own addEventListener hijacking on document + window.
|
* Methods to add/remove your own addEventListener hijacking on document + window.
|
||||||
@ -1183,6 +1184,16 @@ function replaceNavigator(origNavigator) {
|
|||||||
for (var key in origNavigator) {
|
for (var key in origNavigator) {
|
||||||
if (typeof origNavigator[key] == 'function') {
|
if (typeof origNavigator[key] == 'function') {
|
||||||
newNavigator[key] = origNavigator[key].bind(origNavigator);
|
newNavigator[key] = origNavigator[key].bind(origNavigator);
|
||||||
|
} else {
|
||||||
|
(function(k) {
|
||||||
|
Object.defineProperty(newNavigator, k, {
|
||||||
|
get: function() {
|
||||||
|
return origNavigator[k];
|
||||||
|
},
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
})(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1302,6 +1313,16 @@ function replaceNavigator(origNavigator) {
|
|||||||
for (var key in origNavigator) {
|
for (var key in origNavigator) {
|
||||||
if (typeof origNavigator[key] == 'function') {
|
if (typeof origNavigator[key] == 'function') {
|
||||||
newNavigator[key] = origNavigator[key].bind(origNavigator);
|
newNavigator[key] = origNavigator[key].bind(origNavigator);
|
||||||
|
} else {
|
||||||
|
(function(k) {
|
||||||
|
Object.defineProperty(newNavigator, k, {
|
||||||
|
get: function() {
|
||||||
|
return origNavigator[k];
|
||||||
|
},
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
})(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,9 @@ public class AndroidChromeClient extends WebChromeClient {
|
|||||||
// the video progress view
|
// the video progress view
|
||||||
private View mVideoProgressView;
|
private View mVideoProgressView;
|
||||||
|
|
||||||
|
//Keep track of last AlertDialog showed
|
||||||
|
private AlertDialog lastHandledDialog;
|
||||||
|
|
||||||
// File Chooser
|
// File Chooser
|
||||||
protected ValueCallback<Uri> mUploadMessage;
|
protected ValueCallback<Uri> mUploadMessage;
|
||||||
|
|
||||||
@ -113,7 +116,7 @@ public class AndroidChromeClient extends WebChromeClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.show();
|
lastHandledDialog = dlg.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +165,7 @@ public class AndroidChromeClient extends WebChromeClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.show();
|
lastHandledDialog = dlg.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +209,7 @@ public class AndroidChromeClient extends WebChromeClient {
|
|||||||
res.cancel();
|
res.cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.show();
|
lastHandledDialog = dlg.show();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -314,4 +317,11 @@ public class AndroidChromeClient extends WebChromeClient {
|
|||||||
this.cordova.getActivity().startActivityForResult(Intent.createChooser(i, "File Browser"),
|
this.cordova.getActivity().startActivityForResult(Intent.createChooser(i, "File Browser"),
|
||||||
FILECHOOSER_RESULTCODE);
|
FILECHOOSER_RESULTCODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void destroyLastDialog(){
|
||||||
|
if(lastHandledDialog != null){
|
||||||
|
lastHandledDialog.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -604,6 +604,9 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
|||||||
// Load blank page so that JavaScript onunload is called
|
// Load blank page so that JavaScript onunload is called
|
||||||
this.loadUrl("about:blank");
|
this.loadUrl("about:blank");
|
||||||
|
|
||||||
|
//Remove last AlertDialog
|
||||||
|
this.chromeClient.destroyLastDialog();
|
||||||
|
|
||||||
// Forward to plugins
|
// Forward to plugins
|
||||||
if (this.pluginManager != null) {
|
if (this.pluginManager != null) {
|
||||||
this.pluginManager.onDestroy();
|
this.pluginManager.onDestroy();
|
||||||
|
@ -48,6 +48,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
@ -70,6 +71,7 @@ import android.widget.LinearLayout;
|
|||||||
* @Override
|
* @Override
|
||||||
* public void onCreate(Bundle savedInstanceState) {
|
* public void onCreate(Bundle savedInstanceState) {
|
||||||
* super.onCreate(savedInstanceState);
|
* super.onCreate(savedInstanceState);
|
||||||
|
* super.init();
|
||||||
* // Load your application
|
* // Load your application
|
||||||
* loadUrl(launchUrl);
|
* loadUrl(launchUrl);
|
||||||
* }
|
* }
|
||||||
@ -133,17 +135,9 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
LOG.i(TAG, "Apache Cordova native platform version " + CordovaWebView.CORDOVA_VERSION + " is starting");
|
LOG.i(TAG, "Apache Cordova native platform version " + CordovaWebView.CORDOVA_VERSION + " is starting");
|
||||||
LOG.d(TAG, "CordovaActivity.onCreate()");
|
LOG.d(TAG, "CordovaActivity.onCreate()");
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
if(savedInstanceState != null)
|
|
||||||
{
|
|
||||||
initCallbackClass = savedInstanceState.getString("callbackClass");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// need to activate preferences before super.onCreate to avoid "requestFeature() must be called before adding content" exception
|
||||||
loadConfig();
|
loadConfig();
|
||||||
}
|
|
||||||
|
|
||||||
protected void init() {
|
|
||||||
if(!preferences.getBoolean("ShowTitle", false))
|
if(!preferences.getBoolean("ShowTitle", false))
|
||||||
{
|
{
|
||||||
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
@ -162,6 +156,15 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if(savedInstanceState != null)
|
||||||
|
{
|
||||||
|
initCallbackClass = savedInstanceState.getString("callbackClass");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init() {
|
||||||
appView = makeWebView();
|
appView = makeWebView();
|
||||||
|
|
||||||
// TODO: Have the views set this themselves.
|
// TODO: Have the views set this themselves.
|
||||||
@ -209,6 +212,13 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
// Add web view but make it invisible while loading URL
|
// Add web view but make it invisible while loading URL
|
||||||
appView.getView().setVisibility(View.INVISIBLE);
|
appView.getView().setVisibility(View.INVISIBLE);
|
||||||
|
// need to remove appView from any existing parent before invoking root.addView(appView)
|
||||||
|
ViewParent parent = appView.getView().getParent();
|
||||||
|
if ((parent != null) && (parent != root)) {
|
||||||
|
LOG.d(TAG, "removing appView from existing parent");
|
||||||
|
ViewGroup parentGroup = (ViewGroup) parent;
|
||||||
|
parentGroup.removeView(appView.getView());
|
||||||
|
}
|
||||||
root.addView(appView.getView());
|
root.addView(appView.getView());
|
||||||
setContentView(root);
|
setContentView(root);
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<preference name="loglevel" value="DEBUG" />
|
<preference name="loglevel" value="DEBUG" />
|
||||||
<preference name="useBrowserHistory" value="true" />
|
<preference name="useBrowserHistory" value="true" />
|
||||||
<preference name="exit-on-suspend" value="false" />
|
<preference name="exit-on-suspend" value="false" />
|
||||||
|
<preference name="showTitle" value="true" />
|
||||||
<feature name="Activity">
|
<feature name="Activity">
|
||||||
<param name="android-package" value="org.apache.cordova.test.ActivityPlugin" />
|
<param name="android-package" value="org.apache.cordova.test.ActivityPlugin" />
|
||||||
</feature>
|
</feature>
|
||||||
|
@ -75,6 +75,7 @@ public class IntentUriOverrideTest extends ActivityInstrumentationTestCase2<Sabo
|
|||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
sleep();
|
||||||
boolean isBadUrl = testView.getUrl().equals(BAD_URL);
|
boolean isBadUrl = testView.getUrl().equals(BAD_URL);
|
||||||
assertFalse(isBadUrl);
|
assertFalse(isBadUrl);
|
||||||
}
|
}
|
||||||
|
81
test/src/org/apache/cordova/test/menus.java
Executable file
81
test/src/org/apache/cordova/test/menus.java
Executable file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
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 android.os.Bundle;
|
||||||
|
import android.view.ContextMenu;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
|
|
||||||
|
import org.apache.cordova.*;
|
||||||
|
import org.apache.cordova.LOG;
|
||||||
|
|
||||||
|
public class menus extends CordovaActivity {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
// need the title to be shown (config.xml) for the options menu to be visible
|
||||||
|
super.init();
|
||||||
|
super.registerForContextMenu(super.appView);
|
||||||
|
super.loadUrl("file:///android_asset/www/menus/index.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Demonstrate how to add your own menus to app
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
super.onCreateOptionsMenu(menu);
|
||||||
|
int base = Menu.FIRST;
|
||||||
|
// Group, item id, order, title
|
||||||
|
menu.add(base, base, base, "Item1");
|
||||||
|
menu.add(base, base + 1, base + 1, "Item2");
|
||||||
|
menu.add(base, base + 2, base + 2, "Item3");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
LOG.d("menus", "Item " + item.getItemId() + " pressed.");
|
||||||
|
this.appView.loadUrl("javascript:alert('Menu " + item.getItemId() + " pressed.')");
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
|
LOG.d("menus", "onPrepareOptionsMenu()");
|
||||||
|
// this.appView.loadUrl("javascript:alert('onPrepareOptionsMenu()')");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
|
||||||
|
LOG.d("menus", "onCreateContextMenu()");
|
||||||
|
menu.setHeaderTitle("Test Context Menu");
|
||||||
|
menu.add(200, 200, 200, "Context Item1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
|
this.appView.loadUrl("javascript:alert('Context Menu " + item.getItemId() + " pressed.')");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user