Skip to content

Commit 64b2952

Browse files
author
Arik
committed
feat: Add support for Android progress bar
1 parent e2d8429 commit 64b2952

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/android/InAppBrowser.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Licensed to the Apache Software Foundation (ASF) under one
6060
import android.widget.ImageButton;
6161
import android.widget.ImageView;
6262
import android.widget.LinearLayout;
63+
import android.widget.ProgressBar;
6364
import android.widget.RelativeLayout;
6465
import android.widget.TextView;
6566

@@ -916,12 +917,24 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
916917
View footerClose = createCloseButton(7);
917918
footer.addView(footerClose);
918919

920+
// Progress of loading a page
921+
ProgressBar progressBarLoadingPage = new ProgressBar(webView.getContext(), null, android.R.attr.progressBarStyleHorizontal);
922+
progressBarLoadingPage.setLayoutParams((new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)));
923+
919924
// WebView
920925
inAppWebView = new WebView(cordova.getActivity());
926+
inAppWebView.setBackgroundColor(Color.WHITE);
927+
inAppWebView.addView(progressBarLoadingPage);
921928
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
922929
inAppWebView.setId(Integer.valueOf(6));
923930
// File Chooser Implemented ChromeClient
924931
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
932+
public void onProgressChanged(WebView view, int progress)
933+
{
934+
progressBarLoadingPage.setProgress(progress);
935+
progressBarLoadingPage.setVisibility(progress == 100 ? ProgressBar.GONE : ProgressBar.VISIBLE);
936+
}
937+
925938
public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
926939
{
927940
LOG.d(LOG_TAG, "File Chooser 5.0+");

0 commit comments

Comments
 (0)