X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=25e61890f907c1f0f04659016dec1a0d82e9e793;hp=0e6832f9a777a1dbf18c3b3ea3ed0a6c751b285e;hb=023da122147de9e22185917e7df709ea89fbaca0;hpb=67f08c0f28550fbdb73037ba06fc810416e154b0 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 0e6832f9..25e61890 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -194,11 +194,8 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // 'homepage' is used in `onCreate()`, `onNavigationItemSelected()`, and `applyAppSettings()`. private String homepage; - // `javaScriptDisabledSearchURL` is used in `loadURLFromTextBox()` and `applyAppSettings()`. - private String javaScriptDisabledSearchURL; - - // `javaScriptEnabledSearchURL` is used in `loadURLFromTextBox()` and `applyAppSettings()`. - private String javaScriptEnabledSearchURL; + // `searchURL` is used in `loadURLFromTextBox()` and `applyAppSettings()`. + private String searchURL; // `adBlockerEnabled` is used in `onCreate()` and `applyAppSettings()`. private boolean adBlockerEnabled; @@ -666,7 +663,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/cache"); // Delete the `app_webview` folder, which contains an additional `WebView` cache. See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`. - privacyBrowserRuntime.exec("rm -rf " + privacyBrowserRuntime + "/app_webview"); + privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/app_webview"); } catch (IOException e) { // Do nothing if an error is thrown. } @@ -1417,7 +1414,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/cache"); // Delete the `app_webview` folder, which contains an additional `WebView` cache. See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`. - privacyBrowserRuntime.exec("rm -rf " + privacyBrowserRuntime + "/app_webview"); + privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/app_webview"); } catch (IOException e) { // Do nothing if an error is thrown. } @@ -1896,12 +1893,8 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Sanitize the search input and convert it to a search. final String encodedUrlString = URLEncoder.encode(unformattedUrlString, "UTF-8"); - // Use the correct search URL. - if (javaScriptEnabled) { // JavaScript is enabled. - formattedUrlString = javaScriptEnabledSearchURL + encodedUrlString; - } else { // JavaScript is disabled. - formattedUrlString = javaScriptDisabledSearchURL + encodedUrlString; - } + // Add the base search URL. + formattedUrlString = searchURL + encodedUrlString; } loadUrl(formattedUrlString); @@ -2130,16 +2123,12 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Store the values from `sharedPreferences` in variables. - String javaScriptDisabledSearchString = sharedPreferences.getString("javascript_disabled_search", "https://duckduckgo.com/html/?q="); - String javaScriptDisabledSearchCustomURLString = sharedPreferences.getString("javascript_disabled_search_custom_url", ""); - String javaScriptEnabledSearchString = sharedPreferences.getString("javascript_enabled_search", "https://duckduckgo.com/?q="); - String javaScriptEnabledSearchCustomURLString = sharedPreferences.getString("javascript_enabled_search_custom_url", ""); String homepageString = sharedPreferences.getString("homepage", "https://duckduckgo.com"); String torHomepageString = sharedPreferences.getString("tor_homepage", "https://3g2upl4pq6kufc4m.onion"); - String torJavaScriptDisabledSearchString = sharedPreferences.getString("tor_javascript_disabled_search", "https://3g2upl4pq6kufc4m.onion/html/?q="); - String torJavaScriptDisabledSearchCustomURLString = sharedPreferences.getString("tor_javascript_disabled_search_custom_url", ""); - String torJavaScriptEnabledSearchString = sharedPreferences.getString("tor_javascript_enabled_search", "https://3g2upl4pq6kufc4m.onion/?q="); - String torJavaScriptEnabledSearchCustomURLString = sharedPreferences.getString("tor_javascript_enabled_search_custom_url", ""); + String torSearchString = sharedPreferences.getString("tor_search", "https://3g2upl4pq6kufc4m.onion/html/?q="); + String torSearchCustomURLString = sharedPreferences.getString("tor_search_custom_url", ""); + String searchString = sharedPreferences.getString("search", "https://duckduckgo.com/html/?q="); + String searchCustomURLString = sharedPreferences.getString("search_custom_url", ""); adBlockerEnabled = sharedPreferences.getBoolean("block_ads", true); incognitoModeEnabled = sharedPreferences.getBoolean("incognito_mode", false); boolean doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track", false); @@ -2159,18 +2148,11 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation formattedUrlString = homepage; } - // Set JavaScript disabled search. - if (torJavaScriptDisabledSearchString.equals("Custom URL")) { // Get the custom URL string. - javaScriptDisabledSearchURL = torJavaScriptDisabledSearchCustomURLString; - } else { // Use the string from the pre-built list. - javaScriptDisabledSearchURL = torJavaScriptDisabledSearchString; - } - - // Set JavaScript enabled search. - if (torJavaScriptEnabledSearchString.equals("Custom URL")) { // Get the custom URL string. - javaScriptEnabledSearchURL = torJavaScriptEnabledSearchCustomURLString; + // Set the search URL. + if (torSearchString.equals("Custom URL")) { // Get the custom URL string. + searchURL = torSearchCustomURLString; } else { // Use the string from the pre-built list. - javaScriptEnabledSearchURL = torJavaScriptEnabledSearchString; + searchURL = torSearchString; } // Set the proxy. `this` refers to the current activity where an `AlertDialog` might be displayed. @@ -2193,18 +2175,11 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation formattedUrlString = homepage; } - // Set JavaScript disabled search. - if (javaScriptDisabledSearchString.equals("Custom URL")) { // Get the custom URL string. - javaScriptDisabledSearchURL = javaScriptDisabledSearchCustomURLString; + // Set the search URL. + if (searchString.equals("Custom URL")) { // Get the custom URL string. + searchURL = searchCustomURLString; } else { // Use the string from the pre-built list. - javaScriptDisabledSearchURL = javaScriptDisabledSearchString; - } - - // Set JavaScript enabled search. - if (javaScriptEnabledSearchString.equals("Custom URL")) { // Get the custom URL string. - javaScriptEnabledSearchURL = javaScriptEnabledSearchCustomURLString; - } else { // Use the string from the pre-built list. - javaScriptEnabledSearchURL = javaScriptEnabledSearchString; + searchURL = searchString; } // Reset the proxy to default. The host is `""` and the port is `"0"`. @@ -2257,8 +2232,10 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Reset `inFullScreenBrowsingMode` to `false`. inFullScreenBrowsingMode = false; - // Show the `appBar`. - appBar.show(); + // Show the `appBar` if `findOnPageLinearLayout` is not visible. + if (findOnPageLinearLayout.getVisibility() == View.GONE) { + appBar.show(); + } // Show the `BannerAd` in the free flavor. if (BuildConfig.FLAVOR.contentEquals("free")) {