X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.kt;h=0d9755f1f21d2621716c6f678ad5d3da6f025332;hb=5987e0cf5095be146f4fdece1d6d01b5a4cc128d;hp=3e6acce2a0820758051297c0d18bfbee828abaaf;hpb=6b662fcb3e0c8dfbdc212e55d10ad291ec569280;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 3e6acce2..0d9755f1 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2023 Soren Stoutner . + * Copyright 2015-2024 Soren Stoutner . * * Download cookie code contributed 2017 Hendrik Knackstedt. Copyright assigned to Soren Stoutner . * @@ -644,9 +644,9 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook drawerLayout.visibility = View.GONE // Initialize the WebView state adapter. - webViewStateAdapter = WebViewStateAdapter(this) + webViewStateAdapter = WebViewStateAdapter(this, bottomAppBar) - // Set the pager adapter on the web view pager. + // Set the WebView pager adapter. webViewViewPager2.adapter = webViewStateAdapter // Store up to 100 tabs in memory. @@ -2114,7 +2114,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Add the extra information to the intent. domainsIntent.putExtra(LOAD_DOMAIN, currentWebView!!.domainSettingsDatabaseId) domainsIntent.putExtra(CLOSE_ON_BACK, true) - domainsIntent.putExtra(CURRENT_URL, currentWebView!!.url) domainsIntent.putExtra(CURRENT_IP_ADDRESSES, currentWebView!!.currentIpAddresses) // Get the current certificate. @@ -2221,7 +2220,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Set the font size integer. val fontSizeInt = if (textZoomInt == defaultFontSizeString.toInt()) // The current system default is used, which is encoded as a zoom of `0`. - 0 + SYSTEM_DEFAULT else // A custom font size is used. textZoomInt @@ -2271,7 +2270,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Add the extra information to the intent. domainsIntent.putExtra(LOAD_DOMAIN, newDomainDatabaseId) domainsIntent.putExtra(CLOSE_ON_BACK, true) - domainsIntent.putExtra(CURRENT_URL, currentWebView!!.url) domainsIntent.putExtra(CURRENT_IP_ADDRESSES, currentWebView!!.currentIpAddresses) // Get the current certificate. @@ -2488,7 +2486,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook val domainsIntent = Intent(this, DomainsActivity::class.java) // Add the extra information to the intent. - domainsIntent.putExtra(CURRENT_URL, currentWebView!!.url) domainsIntent.putExtra(CURRENT_IP_ADDRESSES, currentWebView!!.currentIpAddresses) // Get the current certificate. @@ -3007,17 +3004,21 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Clear the focus from the URL edit text, so that it will be populated with the information from the new tab. urlEditText.clearFocus() - // Get the new tab position. - val newTabPosition = if (adjacent) // The new tab position is immediately to the right of the current tab position. - tabLayout.selectedTabPosition + 1 - else // The new tab position is at the end. The tab positions are 0 indexed, so the new page number will match the current count. - tabLayout.tabCount + // Add the new tab after the tab layout has quiesced. + // Otherwise, there can be problems when restoring a large number of tabs and processing a new intent at the same time. + tabLayout.post { + // Get the new tab position. + val newTabPosition = if (adjacent) // The new tab position is immediately to the right of the current tab position. + tabLayout.selectedTabPosition + 1 + else // The new tab position is at the end. The tab positions are 0 indexed, so the new page number will match the current count. + tabLayout.tabCount - // Add the new WebView page. - webViewStateAdapter!!.addPage(newTabPosition, urlString) + // Add the new WebView page. + webViewStateAdapter!!.addPage(newTabPosition, urlString) - // Add the new tab. - addNewTab(newTabPosition, moveToTab) + // Add the new tab. + addNewTab(newTabPosition, moveToTab) + } } private fun addNewTab(newTabPosition: Int, moveToTab: Boolean) { @@ -3104,7 +3105,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean(getString(R.string.full_screen_browsing_mode_key), false) hideAppBar = sharedPreferences.getBoolean(getString(R.string.hide_app_bar_key), true) downloadWithExternalApp = sharedPreferences.getBoolean(getString(R.string.download_with_external_app_key), false) - scrollAppBar = sharedPreferences.getBoolean(getString(R.string.scroll_app_bar_key), true) + scrollAppBar = sharedPreferences.getBoolean(getString(R.string.scroll_app_bar_key), false) // Apply the saved proxy mode if the app has been restarted. if (savedProxyMode != null) {