// '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;
// `translucentNavigationBarOnFullscreen` is used in `onCreate()` and `applyAppSettings()`.
private boolean translucentNavigationBarOnFullscreen;
- // `proxyThroughOrbot` is used in `onCreate()` and `applyAppSettings()`.
- private boolean proxyThroughOrbot;
-
// `currentDomainName` is used in `onCreate(), `onNavigationItemSelected()`, and `applyDomainSettings()`.
private String currentDomainName;
}
// Update `urlTextBox` and apply domain settings if not waiting on Orbot.
- if (!waitingForOrbot && !url.startsWith("data:text/html,<html><body><br/><center><h1>")) { // Sometimes `waitingForOrbot` is reset while the Orbot message `onPageFinished()` is running, causing a race condition. For this reason we check both.
+ if (!waitingForOrbot) {
// Check to see if `WebView` has set `url` to be `about:blank`.
if (url.equals("about:blank")) { // `WebView` is blank, so `formattedUrlString` should be `""` and `urlTextBox` should display a hint.
// Set `formattedUrlString` to `""`.
// Initialize `webViewTitle`.
webViewTitle = getString(R.string.no_title);
- // Apply the app settings from the shared preferences.
- applyAppSettings();
-
// Initialize `favoriteIconBitmap`. We have to use `ContextCompat` until API >= 21.
Drawable favoriteIconDrawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.world);
BitmapDrawable favoriteIconBitmapDrawable = (BitmapDrawable) favoriteIconDrawable;
favoriteIconBitmap = favoriteIconDefaultBitmap;
}
+ // Apply the app settings from the shared preferences.
+ applyAppSettings();
+
// Load `formattedUrlString` if we are not waiting for Orbot to connect.
if (!waitingForOrbot) {
loadUrl(formattedUrlString);
// Prepare the font size title and current size menu item.
switch (fontSize) {
+ case 25:
+ fontSizeTitle = getResources().getString(R.string.font_size) + " - " + getResources().getString(R.string.twenty_five_percent);
+ selectedFontSizeMenuItem = menu.findItem(R.id.fontSizeTwentyFivePercent);
+ break;
+
case 50:
fontSizeTitle = getResources().getString(R.string.font_size) + " - " + getResources().getString(R.string.fifty_percent);
selectedFontSizeMenuItem = menu.findItem(R.id.fontSizeFiftyPercent);
Snackbar.make(findViewById(R.id.main_webview), R.string.form_data_deleted, Snackbar.LENGTH_SHORT).show();
return true;
+ case R.id.fontSizeTwentyFivePercent:
+ mainWebView.getSettings().setTextZoom(25);
+ return true;
+
case R.id.fontSizeFiftyPercent:
mainWebView.getSettings().setTextZoom(50);
return true;
}
@Override
- public void onResume() {
+ public void onResume() { // `onResume()` also runs every time the app starts after `onCreate()` and `onStart()`.
super.onResume();
// Resume JavaScript (if enabled).
// 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);
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);
- proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
+ boolean proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("enable_full_screen_browsing_mode", false);
hideSystemBarsOnFullscreen = sharedPreferences.getBoolean("hide_system_bars", false);
translucentNavigationBarOnFullscreen = sharedPreferences.getBoolean("translucent_navigation_bar", true);
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.
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"`.
// 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")) {