X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=111cb63416c94f40cd4967122996b55bf491bde1;hp=1196fb7a84a92a1c8e2a01e96c348f8be595e205;hb=8a06558b0071fa94e2a7d1093b3118417ac5cc8f;hpb=dbbcc6598e2192990dbf9579627ad080e73094db diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 1196fb7a..111cb634 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -597,14 +597,16 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the nested scroll WebView from the tab fragment. NestedScrollWebView nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview); - // Resume the nested scroll WebView JavaScript timers. - nestedScrollWebView.resumeTimers(); - // Resume the nested scroll WebView. nestedScrollWebView.onResume(); } } + // Resume the nested scroll WebView JavaScript timers. This is a global command that resumes JavaScript timers on all WebViews. + if (currentWebView != null) { + currentWebView.resumeTimers(); + } + // Reapply the proxy settings if the system is using a proxy. This redisplays the appropriate alert dialog. if (!proxyMode.equals(ProxyHelper.NONE)) { applyProxy(false); @@ -648,12 +650,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Pause the nested scroll WebView. nestedScrollWebView.onPause(); - - // Pause the nested scroll WebView JavaScript timers. - nestedScrollWebView.pauseTimers(); } } + // Pause the WebView JavaScript timers. This is a global command that pauses JavaScript on all WebViews. + if (currentWebView != null) { + currentWebView.pauseTimers(); + } + // Pause the ad or it will continue to consume resources in the background on the free flavor. if (BuildConfig.FLAVOR.contentEquals("free")) { // Pause the ad. @@ -4788,12 +4792,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } private void closeCurrentTab() { - // Pause the current WebView. + // Pause the current WebView. This prevents buffered audio from playing after the tab is closed. currentWebView.onPause(); - // Pause the current WebView JavaScript timers. - currentWebView.pauseTimers(); - // Get the current tab number. int currentTabNumber = tabLayout.getSelectedTabPosition();