diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 63eb945..99bbcf7 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -20,9 +20,7 @@ package org.apache.cordova.inappbrowser; import android.annotation.SuppressLint; import android.content.ComponentName; -import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; @@ -59,6 +57,7 @@ import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; @@ -68,7 +67,6 @@ import org.apache.cordova.CordovaArgs; import org.apache.cordova.CordovaHttpAuthHandler; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaWebView; -import org.apache.cordova.inappbrowser.InAppBrowserDialog; import org.apache.cordova.LOG; import org.apache.cordova.PluginManager; import org.apache.cordova.PluginResult; @@ -119,6 +117,7 @@ public class InAppBrowser extends CordovaPlugin { private InAppBrowserDialog dialog; private WebView inAppWebView; private EditText edittext; + private ProgressBar progressBar; private CallbackContext callbackContext; private boolean showLocationBar = true; private boolean showZoomControls = true; @@ -991,6 +990,13 @@ public class InAppBrowser extends CordovaPlugin { main.addView(toolbar); } + // Progress Bar + progressBar = new ProgressBar(webView.getContext(), null, android.R.attr.progressBarStyleHorizontal); + progressBar.setIndeterminate(true); + progressBar.setVisibility(View.GONE); + + main.addView(progressBar); + // Add our webview to our main view/layout RelativeLayout webViewLayout = new RelativeLayout(cordova.getActivity()); webViewLayout.addView(inAppWebView); @@ -1088,7 +1094,6 @@ public class InAppBrowser extends CordovaPlugin { public class InAppBrowserClient extends WebViewClient { EditText edittext; CordovaWebView webView; - ProgressDialog progressDialog; /** * Constructor. @@ -1099,17 +1104,6 @@ public class InAppBrowser extends CordovaPlugin { public InAppBrowserClient(CordovaWebView webView, EditText mEditText) { this.webView = webView; this.edittext = mEditText; - - progressDialog = new ProgressDialog(webView.getContext()); - progressDialog.setCancelable(true); - progressDialog.setCanceledOnTouchOutside(false); - progressDialog.setIndeterminate(true); - progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener(){ - @Override - public void onCancel(DialogInterface dialog){ - inAppWebView.stopLoading(); - } - }); } /** @@ -1236,8 +1230,7 @@ public class InAppBrowser extends CordovaPlugin { } catch (JSONException ex) { LOG.e(LOG_TAG, "URI passed in has caused a JSON error."); } - - progressDialog.show(); + progressBar.setVisibility(View.VISIBLE); } @@ -1265,8 +1258,7 @@ public class InAppBrowser extends CordovaPlugin { } catch (JSONException ex) { LOG.d(LOG_TAG, "Should never happen"); } - - progressDialog.dismiss(); + progressBar.setVisibility(View.GONE); } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { @@ -1283,8 +1275,7 @@ public class InAppBrowser extends CordovaPlugin { } catch (JSONException ex) { LOG.d(LOG_TAG, "Should never happen"); } - - progressDialog.dismiss(); + progressBar.setVisibility(View.GONE); } /**