X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebView.java;h=26237d7506af1cd5ee78c42c2e3fb7032031cced;hb=refs%2Ftags%2Fv1.14.1;hp=000cfad6e5899b85dd7b470fb0409ba94cd8cfab;hpb=c3ec2515bf9a49d4561efc47f5d21106f15cb286;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java index 000cfad6..26237d75 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java @@ -1,5 +1,5 @@ /** - * Copyright 2015-2016 Soren Stoutner . + * Copyright 2015-2017 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -127,7 +127,6 @@ public class MainWebView extends AppCompatActivity implements NavigationView.OnN public static SslCertificate sslCertificate; - // `drawerLayout` is used in `onCreate()`, `onNewIntent()`, and `onBackPressed()`. private DrawerLayout drawerLayout; @@ -529,14 +528,16 @@ public class MainWebView extends AppCompatActivity implements NavigationView.OnN // Create a variable to track if this is an ad server. boolean requestHostIsAdServer = false; - // Check all the subdomains of `requestHost`. - while (requestHost.contains(".")) { - if (adServersSet.contains(requestHost)) { - requestHostIsAdServer = true; - } + // Check all the subdomains of `requestHost` if it is not `null`. + if (requestHost != null) { + while (requestHost.contains(".")) { + if (adServersSet.contains(requestHost)) { + requestHostIsAdServer = true; + } - // Strip out the lowest subdomain of `requestHost`. - requestHost = requestHost.substring(requestHost.indexOf(".") + 1); + // Strip out the lowest subdomain of `requestHost`. + requestHost = requestHost.substring(requestHost.indexOf(".") + 1); + } } if (requestHostIsAdServer) { // It is an ad server. @@ -1518,7 +1519,7 @@ public class MainWebView extends AppCompatActivity implements NavigationView.OnN String fileName = downloadFileNameEditText.getText().toString(); // Once we have `WRITE_EXTERNAL_STORAGE` permissions we can use `setDestinationInExternalPublicDir`. - if (Build.VERSION.SDK_INT >= 23) { // If API >= 23, set the download save in the the `DIRECTORY_DOWNLOADS` using `fileName`. + if (Build.VERSION.SDK_INT >= 23) { // If API >= 23, set the download location to `/sdcard/Android/data/com.stoutner.privacybrowser.standard/files` named `fileName`. downloadRequest.setDestinationInExternalFilesDir(this, "/", fileName); } else { // Only set the title using `fileName`. downloadRequest.setTitle(fileName);