X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=229ab3b6392233e6c9737fd797c88b967c81a3c5;hb=12042264a50769030361cf51b0ac197050209f0f;hp=f2bf75366c0288d993e970a2615f7b623e54d990;hpb=5186b668274b09e37b371c0a134e53255c98ad98;p=PrivacyBrowserAndroid.git 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 f2bf7536..229ab3b6 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -759,8 +759,18 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } } } else { // The app has been restarted. - // Set the saved tab position to be the size of the saved state array list. The tab position is 0 based, meaning the at the new tab will be the tab position that is restored. - savedTabPosition = savedStateArrayList.size(); + // Get the information from the intent. + String intentAction = intent.getAction(); + Uri intentUriData = intent.getData(); + String intentStringExtra = intent.getStringExtra(Intent.EXTRA_TEXT); + + // Determine if this is a web search. + boolean isWebSearch = ((intentAction != null) && intentAction.equals(Intent.ACTION_WEB_SEARCH)); + + // If the new intent will open a new tab, set the saved tab position to be the size of the saved state array list. + // The tab position is 0 based, meaning the at the new tab will be the tab position that is restored. + if (intentUriData != null || intentStringExtra != null || isWebSearch) + savedTabPosition = savedStateArrayList.size(); // Replace the intent that started the app with this one. This will load the tab after the others have been restored. setIntent(intent); @@ -2611,7 +2621,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook startActivity(emailIntent); } catch (ActivityNotFoundException exception) { // Display a snackbar. - Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show(); + Snackbar.make(currentWebView, getString(R.string.error) + exception, Snackbar.LENGTH_INDEFINITE).show(); } // Consume the event. @@ -2940,7 +2950,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook currentWebView.loadUrl(temporaryMhtFile.toString()); } catch (Exception exception) { // Display a snackbar. - Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show(); + Snackbar.make(currentWebView, getString(R.string.error) + exception, Snackbar.LENGTH_INDEFINITE).show(); } } else { // Let the WebView handle opening of the file. // Open the file. @@ -4316,7 +4326,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook startActivity(openWithAppIntent); } catch (ActivityNotFoundException exception) { // There are no apps available to open the URL. // Show a snackbar with the error. - Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show(); + Snackbar.make(currentWebView, getString(R.string.error) + exception, Snackbar.LENGTH_INDEFINITE).show(); } } @@ -4336,7 +4346,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook startActivity(openWithBrowserIntent); } catch (ActivityNotFoundException exception) { // There are no browsers available to open the URL. // Show a snackbar with the error. - Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show(); + Snackbar.make(currentWebView, getString(R.string.error) + exception, Snackbar.LENGTH_INDEFINITE).show(); } } @@ -5372,7 +5382,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook startActivity(emailIntent); } catch (ActivityNotFoundException exception) { // Display a snackbar. - Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show(); + Snackbar.make(currentWebView, getString(R.string.error) + exception, Snackbar.LENGTH_INDEFINITE).show(); } @@ -5393,7 +5403,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook startActivity(dialIntent); } catch (ActivityNotFoundException exception) { // Display a snackbar. - Snackbar.make(currentWebView, getString(R.string.error) + " " + exception, Snackbar.LENGTH_INDEFINITE).show(); + Snackbar.make(currentWebView, getString(R.string.error) + exception, Snackbar.LENGTH_INDEFINITE).show(); } // Returning true indicates Privacy Browser is handling the URL by creating an intent. @@ -5415,7 +5425,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook try { startActivity(genericIntent); } catch (ActivityNotFoundException exception) { - Snackbar.make(nestedScrollWebView, getString(R.string.unrecognized_url) + " " + url, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(nestedScrollWebView, getString(R.string.unrecognized_url) + url, Snackbar.LENGTH_SHORT).show(); } // Returning true indicates Privacy Browser is handling the URL by creating an intent. @@ -5842,7 +5852,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook if ((currentDomainName != null) && !currentDomainName.isEmpty()) { // Get the IP addresses for the current URI. - GetHostIpAddressesCoroutine.getAddresses(currentDomainName, nestedScrollWebView, getSupportFragmentManager(), getString(R.string.pinned_mismatch)); + GetHostIpAddressesCoroutine.checkPinnedMismatch(currentDomainName, nestedScrollWebView, getSupportFragmentManager(), getString(R.string.pinned_mismatch)); } // Replace Refresh with Stop if the options menu has been created. (The first WebView typically begins loading before the menu items are instantiated.)