X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.kt;h=1e41ca201686b4a502ddcf904b3ff11c20dd8bae;hb=b664d689b9757ffd1fd224c85a9659d2f4df1204;hp=ac27dcd657c4315e254ab1db442094f8963f0e1e;hpb=f8486dc082d82deead08a6747670e22ce7263c97;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index ac27dcd6..1e41ca20 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -4207,11 +4207,14 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Close the find on page bar if it is open. closeFindOnPage(null) - // Select the same page in the view pager. - webViewViewPager2.currentItem = tab.position + // Update the view pager when it has quiesced. Otherwise, if a page launched by a new intent on restart has not yet been created, the view pager will not be updated to match the tab layout. + webViewViewPager2.post { + // Select the same page in the view pager. + webViewViewPager2.currentItem = tab.position - // Set the current WebView. - setCurrentWebView(tab.position) + // Set the current WebView. + setCurrentWebView(tab.position) + } } override fun onTabUnselected(tab: TabLayout.Tab) {} @@ -4223,8 +4226,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Calculate the milliseconds since the last restart. This can be replaced by the simpler LocalDateTime once the minimum API >= 26. val millisecondsSinceLastRestart = Date().time - restartTime.time - // Only display the SSL certificate dialog if it has been at least 1 second since the last restart as deep restarts sometimes end up selecting a tab twice. - if (millisecondsSinceLastRestart > 1000) { + // Only display the SSL certificate dialog if it has been at least 3 seconds since the last restart as deep restarts sometimes end up selecting a tab twice. + if (millisecondsSinceLastRestart > 3000) { // Instantiate the View SSL Certificate dialog. val viewSslCertificateDialogFragment: DialogFragment = ViewSslCertificateDialog.displayDialog(currentWebView!!.webViewFragmentId, currentWebView!!.getFavoriteIcon())