mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
Start adding events to InAppBrowser
This commit is contained in:
parent
48f58110fe
commit
a42dc08756
@ -209,6 +209,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void closeDialog() {
|
private void closeDialog() {
|
||||||
// TODO: fire 'exit' event
|
// TODO: fire 'exit' event
|
||||||
|
this.webView.sendJavascript("cordova.fireWindowEvent('exit');");
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
@ -272,6 +273,8 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
showLocationBar = features.get(LOCATION).booleanValue();
|
showLocationBar = features.get(LOCATION).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final CordovaWebView thatWebView = this.webView;
|
||||||
|
|
||||||
// Create dialog in new thread
|
// Create dialog in new thread
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
/**
|
/**
|
||||||
@ -394,7 +397,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
inAppWebView = new WebView(cordova.getActivity());
|
inAppWebView = new WebView(cordova.getActivity());
|
||||||
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||||
inAppWebView.setWebChromeClient(new WebChromeClient());
|
inAppWebView.setWebChromeClient(new WebChromeClient());
|
||||||
WebViewClient client = new InAppBrowserClient(edittext);
|
WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
|
||||||
inAppWebView.setWebViewClient(client);
|
inAppWebView.setWebViewClient(client);
|
||||||
WebSettings settings = inAppWebView.getSettings();
|
WebSettings settings = inAppWebView.getSettings();
|
||||||
settings.setJavaScriptEnabled(true);
|
settings.setJavaScriptEnabled(true);
|
||||||
@ -464,6 +467,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
public class InAppBrowserClient extends WebViewClient {
|
public class InAppBrowserClient extends WebViewClient {
|
||||||
EditText edittext;
|
EditText edittext;
|
||||||
|
CordovaWebView webView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -471,7 +475,8 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
* @param mContext
|
* @param mContext
|
||||||
* @param edittext
|
* @param edittext
|
||||||
*/
|
*/
|
||||||
public InAppBrowserClient(EditText mEditText) {
|
public InAppBrowserClient(CordovaWebView webView, EditText mEditText) {
|
||||||
|
this.webView = webView;
|
||||||
this.edittext = mEditText;
|
this.edittext = mEditText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,21 +500,14 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
edittext.setText(newloc);
|
edittext.setText(newloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fire 'loadstart' event
|
// TODO: Fire 'loadstart' event only on the InAppBrowser object
|
||||||
try {
|
this.webView.sendJavascript("cordova.fireWindowEvent('loadstart', '" + url + "');");
|
||||||
JSONObject obj = new JSONObject();
|
|
||||||
obj.put("type", LOCATION_CHANGED_EVENT);
|
|
||||||
obj.put("location", url);
|
|
||||||
|
|
||||||
sendUpdate(obj, true);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.d("InAppBrowser", "This should never happen");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
// TODO: Fire 'loadstop' event
|
// TODO: Fire 'loadstop' event only on the InAppBrowser object
|
||||||
|
this.webView.sendJavascript("cordova.fireWindowEvent('loadstop', '" + url + "');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user