mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +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:
@@ -65,6 +65,9 @@ public class AndroidChromeClient extends WebChromeClient {
|
||||
// the video progress view
|
||||
private View mVideoProgressView;
|
||||
|
||||
//Keep track of last AlertDialog showed
|
||||
private AlertDialog lastHandledDialog;
|
||||
|
||||
// File Chooser
|
||||
protected ValueCallback<Uri> mUploadMessage;
|
||||
|
||||
@@ -113,7 +116,7 @@ public class AndroidChromeClient extends WebChromeClient {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
dlg.show();
|
||||
lastHandledDialog = dlg.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -162,7 +165,7 @@ public class AndroidChromeClient extends WebChromeClient {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
dlg.show();
|
||||
lastHandledDialog = dlg.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -206,7 +209,7 @@ public class AndroidChromeClient extends WebChromeClient {
|
||||
res.cancel();
|
||||
}
|
||||
});
|
||||
dlg.show();
|
||||
lastHandledDialog = dlg.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -314,4 +317,11 @@ public class AndroidChromeClient extends WebChromeClient {
|
||||
this.cordova.getActivity().startActivityForResult(Intent.createChooser(i, "File Browser"),
|
||||
FILECHOOSER_RESULTCODE);
|
||||
}
|
||||
|
||||
public void destroyLastDialog(){
|
||||
if(lastHandledDialog != null){
|
||||
lastHandledDialog.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -603,6 +603,9 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
||||
|
||||
// Load blank page so that JavaScript onunload is called
|
||||
this.loadUrl("about:blank");
|
||||
|
||||
//Remove last AlertDialog
|
||||
this.chromeClient.destroyLastDialog();
|
||||
|
||||
// Forward to plugins
|
||||
if (this.pluginManager != null) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebViewClient;
|
||||
@@ -70,6 +71,7 @@ import android.widget.LinearLayout;
|
||||
* @Override
|
||||
* public void onCreate(Bundle savedInstanceState) {
|
||||
* super.onCreate(savedInstanceState);
|
||||
* super.init();
|
||||
* // Load your application
|
||||
* loadUrl(launchUrl);
|
||||
* }
|
||||
@@ -133,22 +135,14 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
LOG.i(TAG, "Apache Cordova native platform version " + CordovaWebView.CORDOVA_VERSION + " is starting");
|
||||
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();
|
||||
}
|
||||
|
||||
protected void 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.");
|
||||
@@ -162,6 +156,15 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
||||
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if(savedInstanceState != null)
|
||||
{
|
||||
initCallbackClass = savedInstanceState.getString("callbackClass");
|
||||
}
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
appView = makeWebView();
|
||||
|
||||
// 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
|
||||
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());
|
||||
setContentView(root);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user