]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/AboutDialog.java
Rename the activities.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / AboutDialog.java
index ea87318fb65796d6299cd4d34936f55b24804181..a488d0d03e2321ec049d61a0cf8fa15d30809a14 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2015 Soren Stoutner
+ * Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://privacybrowser.stoutner.com/>.
  *
@@ -26,10 +26,11 @@ import android.support.annotation.NonNull;
 import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatDialogFragment;
 import android.webkit.WebView;
+import android.webkit.WebViewClient;
 
 public class AboutDialog extends AppCompatDialogFragment {
-    // onCreateDialog requires @NonNull.
     @Override
+    // onCreateDialog requires @NonNull.
     @NonNull
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         // Create a WebView to display about_text.html
@@ -37,7 +38,7 @@ public class AboutDialog extends AppCompatDialogFragment {
         aboutDialogWebView.loadUrl("file:///android_asset/about_text.html");
 
         // Use AlertDialog.Builder to create the AlertDialog
-        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
+        final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
         alertDialogBuilder.setTitle(R.string.about_privacy_browser);
         alertDialogBuilder.setView(aboutDialogWebView);
         alertDialogBuilder.setPositiveButton(R.string.dismiss, new DialogInterface.OnClickListener() {
@@ -51,6 +52,16 @@ public class AboutDialog extends AppCompatDialogFragment {
         final AlertDialog alertDialog = alertDialogBuilder.create();
         alertDialog.show();
 
+        aboutDialogWebView.setWebViewClient(new WebViewClient() {
+            // shouldOverrideUrlLoading lets us close AboutDialog when a link is touched.  Otherwise the dialog covers the website that loads beneath in Privacy Browser.
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+                MainWebViewActivity.mainWebView.loadUrl(url);
+                alertDialog.dismiss();
+                return true;
+            }
+        });
+
         // onCreateDialog requires the return of an AlertDialog.
         return alertDialog;
     }