// Open a connection to the URL. No data is actually sent at this point.
HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
- // Instantiate the variables necessary to build the request headers.
+ // Define the variables necessary to build the request headers.
requestHeadersBuilder = new SpannableStringBuilder();
int oldRequestHeadersBuilderLength;
int newRequestHeadersBuilderLength;
requestHeadersBuilder.append(": keep-alive");
- // Set the `User-Agent` header property.
- httpUrlConnection.setRequestProperty("User-Agent", userAgent);
+ // Set the `Upgrade-Insecure-Requests` header property.
+ httpUrlConnection.setRequestProperty("Upgrade-Insecure-Requests", "1");
- // Add the `User-Agent` header to the string builder and format the text.
+ // Add the `Upgrade-Insecure-Requests` header to the string builder and format the text.
requestHeadersBuilder.append(System.getProperty("line.separator"));
if (Build.VERSION.SDK_INT >= 21) { // Newer versions of Android are so smart.
- requestHeadersBuilder.append("User-Agent", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ requestHeadersBuilder.append("Upgrade-Insecure-Requests", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else { // Older versions not so much.
oldRequestHeadersBuilderLength = requestHeadersBuilder.length();
- requestHeadersBuilder.append("User-Agent");
+ requestHeadersBuilder.append("Upgrade-Insecure_Requests");
newRequestHeadersBuilderLength = requestHeadersBuilder.length();
requestHeadersBuilder.setSpan(new StyleSpan(Typeface.BOLD), oldRequestHeadersBuilderLength + 1, newRequestHeadersBuilderLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
- requestHeadersBuilder.append(": ");
- requestHeadersBuilder.append(userAgent);
+ requestHeadersBuilder.append(": 1");
- // Set the `Upgrade-Insecure-Requests` header property.
- httpUrlConnection.setRequestProperty("Upgrade-Insecure-Requests", "1");
+ // Set the `User-Agent` header property.
+ httpUrlConnection.setRequestProperty("User-Agent", userAgent);
- // Add the `Upgrade-Insecure-Requests` header to the string builder and format the text.
+ // Add the `User-Agent` header to the string builder and format the text.
requestHeadersBuilder.append(System.getProperty("line.separator"));
if (Build.VERSION.SDK_INT >= 21) { // Newer versions of Android are so smart.
- requestHeadersBuilder.append("Upgrade-Insecure-Requests", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ requestHeadersBuilder.append("User-Agent", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else { // Older versions not so much.
oldRequestHeadersBuilderLength = requestHeadersBuilder.length();
- requestHeadersBuilder.append("Upgrade-Insecure_Requests");
+ requestHeadersBuilder.append("User-Agent");
newRequestHeadersBuilderLength = requestHeadersBuilder.length();
requestHeadersBuilder.setSpan(new StyleSpan(Typeface.BOLD), oldRequestHeadersBuilderLength + 1, newRequestHeadersBuilderLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
- requestHeadersBuilder.append(": 1");
+ requestHeadersBuilder.append(": ");
+ requestHeadersBuilder.append(userAgent);
// Set the `x-requested-with` header property.
// Set the `Accept` header property.
- httpUrlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
+ httpUrlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
// Add the `Accept` header to the string builder and format the text.
requestHeadersBuilder.append(System.getProperty("line.separator"));
requestHeadersBuilder.setSpan(new StyleSpan(Typeface.BOLD), oldRequestHeadersBuilderLength + 1, newRequestHeadersBuilderLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
requestHeadersBuilder.append(": ");
- requestHeadersBuilder.append("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
+ requestHeadersBuilder.append("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
// Instantiate a locale string.
localesStringBuilder.append(",");
}
- // Get the indicated locale from the list.
- localesStringBuilder.append(localeList.get(i));
+ // Get the locale from the list.
+ Locale locale = localeList.get(i);
- // If not the first locale, append `;q=0.i`, which drops by .1 for each removal from the main locale.
+ // Add the locale to the string. `locale` by default displays as `en_US`, but WebView uses the `en-US` format.
+ localesStringBuilder.append(locale.getLanguage());
+ localesStringBuilder.append("-");
+ localesStringBuilder.append(locale.getCountry());
+
+ // If not the first locale, append `;q=0.x`, which drops by .1 for each removal from the main locale until q=0.1.
if (q < 10) {
localesStringBuilder.append(";q=0.");
localesStringBuilder.append(q);
}
- // Decrement `q`.
- q--;
+ // Decrement `q` if it is greater than 1.
+ if (q > 1) {
+ q--;
+ }
+
+ // Add a second entry for the language only portion of the locale.
+ localesStringBuilder.append(",");
+ localesStringBuilder.append(locale.getLanguage());
+
+ // Append `1;q=0.x`, which drops by .1 for each removal form the main locale until q=0.1.
+ localesStringBuilder.append(";q=0.");
+ localesStringBuilder.append(q);
+
+ // Decrement `q` if it is greater than 1.
+ if (q > 1) {
+ q--;
+ }
}
// Store the populated string builder in the locale string.
<!-- Context Menus. -->
<string name="open_in_new_tab">Abrir en nueva pestaña</string>
+ <string name="open_image_in_new_tab">Abrir imagen en nueva pestaña</string>
<string name="copy_url">Copiar URL</string>
<string name="download_url">Descargar URL</string>
<string name="email_address">Correo electrónico</string>
<string name="block_all_third_party_requests_summary">Bloquear todas las solicitudes de terceras partes aumenta la privacidad, pero rompe muchas páginas web.</string>
<string name="url_modification">Modificación de URL</string>
<string name="google_analytics">Google Analytics</string>
- <string name="google_analytics_summary">Eliminar “?utm_” o “&utm_” y cualquier cosa después de esto de las URLs.</string>
+ <string name="google_analytics_summary">Eliminar “?utm_”, “&utm_” y cualquier cosa tras ello de las URLs.</string>
<string name="facebook_click_ids">IDs de clics en Facebook</string>
- <string name="facebook_click_ids_summary">Eliminar “?fbclid=” o “&fbclid=” y cualquier cosa después de esto de las URLs.</string>
+ <string name="facebook_click_ids_summary">Eliminar “?fbclid=”, “&fbclid=”, “?fbadid=”, “&fbadid=” y cualquier cosa tras ello de las URLs.</string>
<string name="twitter_amp_redirects">Redirecciones de Twitter AMP</string>
<string name="twitter_amp_redirects_summary">Eliminar “?amp=1” y cualquier cosa después de esto de las URLs.</string>
<string name="tor">Tor</string>