You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/08/13 17:53:25 UTC
(cordova-plugin-inappbrowser) branch pr-android-add-progress-bar created (now 1aaf3234)
This is an automated email from the ASF dual-hosted git repository.
GitToTheHub pushed a change to branch pr-android-add-progress-bar
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
at 1aaf3234 feat(android): add progress bar
This branch includes the following new commits:
new 1aaf3234 feat(android): add progress bar
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
(cordova-plugin-inappbrowser) 01/01: feat(android): add progress bar
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
GitToTheHub pushed a commit to branch pr-android-add-progress-bar
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
commit 1aaf3234b882bb63e61ab068a747dffc1445cc26
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Thu Aug 13 19:53:12 2026 +0200
feat(android): add progress bar
- The progress bar is enabled by default but can be hidden by the option `hideloadingindicator`.
- Superseds #1073
---
README.md | 1 +
src/android/InAppBrowser.java | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/README.md b/README.md
index 9f0bd3f5..96162585 100644
--- a/README.md
+++ b/README.md
@@ -135,6 +135,7 @@ instance, or the system browser.
- __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)).
- __useWideViewPort__: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is `no`, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is `yes` and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport wil [...]
- __fullscreen__: Sets whether the InappBrowser WebView is displayed fullscreen or not. In fullscreen mode, the status bar is hidden. Default value is `yes`.
+ - __hideloadingindicator__: Set to `yes` to hide the loading progress bar. Set to `no` or omit it to show the bar while pages load (default is `no`).
iOS supports these additional options:
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 258a1a76..1638b128 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -62,6 +62,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;
@@ -98,6 +99,7 @@ public class InAppBrowser extends CordovaPlugin {
private static final String ZOOM = "zoom";
private static final String ZOOMCONTROLS = "zoomcontrols";
private static final String HIDDEN = "hidden";
+ private static final String HIDE_LOADING_INDICATOR = "hideloadingindicator";
private static final String LOAD_START_EVENT = "loadstart";
private static final String LOAD_STOP_EVENT = "loadstop";
private static final String LOAD_ERROR_EVENT = "loaderror";
@@ -134,6 +136,7 @@ public class InAppBrowser extends CordovaPlugin {
private boolean enableZoom = true;
private boolean showZoomControls = true;
private boolean openWindowHidden = false;
+ private boolean hideLoadingIndicator = false;
private boolean clearAllCache = false;
private boolean clearSessionCache = false;
private boolean hadwareBackButton = true;
@@ -639,6 +642,7 @@ public class InAppBrowser extends CordovaPlugin {
enableZoom = true;
showZoomControls = true;
openWindowHidden = false;
+ hideLoadingIndicator = false;
mediaPlaybackRequiresUserGesture = false;
if (features != null) {
@@ -664,6 +668,10 @@ public class InAppBrowser extends CordovaPlugin {
if (hidden != null) {
openWindowHidden = hidden.equals("yes") ? true : false;
}
+ String hideLoadingIndicatorSet = features.get(HIDE_LOADING_INDICATOR);
+ if (hideLoadingIndicatorSet != null) {
+ hideLoadingIndicator = hideLoadingIndicatorSet.equals("yes");
+ }
String hardwareBack = features.get(HARDWARE_BACK_BUTTON);
if (hardwareBack != null) {
hadwareBackButton = hardwareBack.equals("yes") ? true : false;
@@ -960,8 +968,24 @@ public class InAppBrowser extends CordovaPlugin {
inAppWebView = new WebView(cordova.getActivity());
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
inAppWebView.setId(Integer.valueOf(6));
+ final ProgressBar progressBar = new ProgressBar(cordova.getActivity(), null, android.R.attr.progressBarStyleHorizontal);
+ progressBar.setMax(100);
+ // WebChromeClient reports the page load percentage as a value from 0 to 100.
+ progressBar.setIndeterminate(false);
+ progressBar.setVisibility(View.GONE);
// File Chooser Implemented ChromeClient
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
+ @Override
+ public void onProgressChanged(WebView view, int newProgress) {
+ super.onProgressChanged(view, newProgress);
+ if (hideLoadingIndicator) {
+ return;
+ }
+
+ progressBar.setProgress(newProgress);
+ progressBar.setVisibility(newProgress < 100 ? View.VISIBLE : View.GONE);
+ }
+
@Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
// New-window navigations (for example window.open or target=_blank)
@@ -1157,6 +1181,9 @@ public class InAppBrowser extends CordovaPlugin {
RelativeLayout webViewLayout = new RelativeLayout(cordova.getActivity());
webViewLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1.0f));
webViewLayout.addView(inAppWebView);
+ RelativeLayout.LayoutParams progressLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(2));
+ progressLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ webViewLayout.addView(progressBar, progressLayoutParams);
main.addView(webViewLayout);
// Don't add the footer unless it's been enabled
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org