Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start adding events to InAppBrowser

  • Loading branch information...
commit a42dc087565efa3e7f414e57693d145297135e3e 1 parent 48f5811
@macdonst macdonst authored
Showing with 11 additions and 13 deletions.
  1. +11 −13 framework/src/org/apache/cordova/InAppBrowser.java
View
24 framework/src/org/apache/cordova/InAppBrowser.java
@@ -209,6 +209,7 @@ public String openExternal(String url) {
*/
private void closeDialog() {
// TODO: fire 'exit' event
+ this.webView.sendJavascript("cordova.fireWindowEvent('exit');");
if (dialog != null) {
dialog.dismiss();
}
@@ -271,6 +272,8 @@ public String showWebPage(final String url, HashMap<String, Boolean> features) {
if (features != null) {
showLocationBar = features.get(LOCATION).booleanValue();
}
+
+ final CordovaWebView thatWebView = this.webView;
// Create dialog in new thread
Runnable runnable = new Runnable() {
@@ -394,7 +397,7 @@ public void onClick(View v) {
inAppWebView = new WebView(cordova.getActivity());
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
inAppWebView.setWebChromeClient(new WebChromeClient());
- WebViewClient client = new InAppBrowserClient(edittext);
+ WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
inAppWebView.setWebViewClient(client);
WebSettings settings = inAppWebView.getSettings();
settings.setJavaScriptEnabled(true);
@@ -464,6 +467,7 @@ private void sendUpdate(JSONObject obj, boolean keepCallback) {
*/
public class InAppBrowserClient extends WebViewClient {
EditText edittext;
+ CordovaWebView webView;
/**
* Constructor.
@@ -471,7 +475,8 @@ private void sendUpdate(JSONObject obj, boolean keepCallback) {
* @param mContext
* @param edittext
*/
- public InAppBrowserClient(EditText mEditText) {
+ public InAppBrowserClient(CordovaWebView webView, EditText mEditText) {
+ this.webView = webView;
this.edittext = mEditText;
}
@@ -495,21 +500,14 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
edittext.setText(newloc);
}
- // TODO: Fire 'loadstart' event
- try {
- 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");
- }
+ // TODO: Fire 'loadstart' event only on the InAppBrowser object
+ this.webView.sendJavascript("cordova.fireWindowEvent('loadstart', '" + url + "');");
}
public void onPageFinished(WebView view, String 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 + "');");
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.