X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FPinnedMismatchDialog.java;h=9694c0ac4d9db578ee0e122eeb5775071339bc83;hp=72fc85aeeee2752e1968bbf638166449f9b81e27;hb=3f3b7c8fbe988fe730a5fbb53169489566655595;hpb=c3d422b9a5e4aad18e48c432e03c3a179f7f4912 diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java index 72fc85ae..9694c0ac 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/PinnedMismatchDialog.java @@ -59,7 +59,13 @@ import androidx.fragment.app.DialogFragment; // The AndroidX dialog fragment mu import androidx.viewpager.widget.PagerAdapter; public class PinnedMismatchDialog extends DialogFragment { + // The public interface is used to send information back to the parent activity. + public interface PinnedMismatchListener { + void pinnedErrorGoBack(); + } + // Declare the class variables. + private PinnedMismatchListener pinnedMismatchListener; private NestedScrollWebView nestedScrollWebView; private String currentSslIssuedToCName; private String currentSslIssuedToOName; @@ -70,6 +76,15 @@ public class PinnedMismatchDialog extends DialogFragment { private Date currentSslStartDate; private Date currentSslEndDate; + @Override + public void onAttach(Context context) { + // Run the default commands. + super.onAttach(context); + + // Get a handle for the listener from the launching context. + pinnedMismatchListener = (PinnedMismatchListener) context; + } + public static PinnedMismatchDialog displayDialog(long webViewFragmentId) { // Create an arguments bundle. Bundle argumentsBundle = new Bundle(); @@ -211,14 +226,8 @@ public class PinnedMismatchDialog extends DialogFragment { // Setup the back button. dialogBuilder.setNegativeButton(R.string.back, (DialogInterface dialog, int which) -> { if (nestedScrollWebView.canGoBack()) { // There is a back page in the history. - // Reset the current domain name so that navigation works if third-party requests are blocked. - nestedScrollWebView.resetCurrentDomainName(); - - // Set navigating history so that the domain settings are applied when the new URL is loaded. - nestedScrollWebView.setNavigatingHistory(true); - - // Go back. - nestedScrollWebView.goBack(); + // Invoke the navigate history listener in the calling activity. These commands cannot be run here because they need access to `applyDomainSettings()`. + pinnedMismatchListener.pinnedErrorGoBack(); } else { // There are no pages to go back to. // Load a blank page nestedScrollWebView.loadUrl("");