@@ -189,10+188,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
// The WebView pager adapter is accessed from `HttpAuthenticationDialog`, `PinnedMismatchDialog`, and `SslCertificateErrorDialog`. It is also used in `onCreate()`, `onResume()`, and `addTab()`.
public static WebViewPagerAdapter webViewPagerAdapter;
// The WebView pager adapter is accessed from `HttpAuthenticationDialog`, `PinnedMismatchDialog`, and `SslCertificateErrorDialog`. It is also used in `onCreate()`, `onResume()`, and `addTab()`.
public static WebViewPagerAdapter webViewPagerAdapter;
- // The load URL on restart variables are public static so they can be accessed from `BookmarksActivity`. They are used in `onRestart()`.
- public static boolean loadUrlOnRestart;
- public static String urlToLoadOnRestart;
-
// `restartFromBookmarksActivity` is public static so it can be accessed from `BookmarksActivity`. It is also used in `onRestart()`.
public static boolean restartFromBookmarksActivity;
// `restartFromBookmarksActivity` is public static so it can be accessed from `BookmarksActivity`. It is also used in `onRestart()`.
public static boolean restartFromBookmarksActivity;
@@ -550,21+545,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
// Reapply the domain settings if the URL is not null, which can happen if an empty tab is active when returning from settings.
if (nestedScrollWebView.getUrl() != null) {
// Reapply the domain settings if the URL is not null, which can happen if an empty tab is active when returning from settings.
// Check to see if the storage permission is needed.
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { // The storage permission has been granted.
// Open the file.
// Check to see if the storage permission is needed.
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { // The storage permission has been granted.
// Open the file.
@@ -3346,11+3332,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
// Select the corresponding tab if it does not match the currently selected page. This will happen if the page was scrolled by creating a new tab.
if (tabLayout.getSelectedTabPosition() != position) {
// Select the corresponding tab if it does not match the currently selected page. This will happen if the page was scrolled by creating a new tab.
if (tabLayout.getSelectedTabPosition() != position) {
- // Create a handler to select the tab.
- Handler selectTabHandler = new Handler();
-
- // Create a runnable to select the tab.
- Runnable selectTabRunnable = () -> {
+ // Wait until the new tab has been created.
+ tabLayout.post(() -> {
// Get a handle for the tab.
TabLayout.Tab tab = tabLayout.getTabAt(position);
// Get a handle for the tab.
TabLayout.Tab tab = tabLayout.getTabAt(position);
@@ -3359,10+3342,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
// Select the tab.
tab.select();
// Select the tab.
tab.select();
- };
-
- // Select the tab layout after 150 milliseconds, which leaves enough time for a new tab to be inflated. TODO.
@@ -4327,6+4307,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
if (reloadWebsite) {
nestedScrollWebView.reload();
}
if (reloadWebsite) {
nestedScrollWebView.reload();
}
+
+ // Load the URL if directed. This makes sure that the domain settings are properly loaded before the URL. By using `loadUrl()`, instead of `loadUrlFromBase()`, the Referer header will never be sent.
// Get the current URL from the nested scroll WebView. This is more accurate than using the URL passed into the method, which is sometimes not the final one.
String currentUrl = nestedScrollWebView.getUrl();
// Get the current URL from the nested scroll WebView. This is more accurate than using the URL passed into the method, which is sometimes not the final one.
String currentUrl = nestedScrollWebView.getUrl();
@@ -6375,7+6351,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
inputMethodManager.showSoftInput(urlEditText, 0);
// Apply the domain settings. This clears any settings from the previous domain.
inputMethodManager.showSoftInput(urlEditText, 0);
// Apply the domain settings. This clears any settings from the previous domain.