// Get the screenshot preference.
String appTheme = sharedPreferences.getString("app_theme", getString(R.string.app_theme_default_value));
- boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+ boolean allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false);
// Get the theme entry values string array.
String[] appThemeEntryValuesStringArray = getResources().getStringArray(R.array.app_theme_entry_values);
}
}
+ // Clear the logcat.
+ if (clearEverything || sharedPreferences.getBoolean(getString(R.string.clear_logcat_key), true)) {
+ try {
+ // Clear the logcat. `-c` clears the logcat. `-b all` clears all the buffers (instead of just crash, main, and system).
+ Process process = Runtime.getRuntime().exec("logcat -b all -c");
+
+ // Wait for the process to finish.
+ process.waitFor();
+ } catch (IOException|InterruptedException exception) {
+ // Do nothing.
+ }
+ }
+
// Clear the cache.
if (clearEverything || sharedPreferences.getBoolean("clear_cache", true)) {
// Clear the cache from each WebView.
Preference customUserAgentPreference = findPreference("custom_user_agent");
Preference incognitoModePreference = findPreference("incognito_mode");
Preference doNotTrackPreference = findPreference("do_not_track");
- Preference allowScreenshotsPreference = findPreference("allow_screenshots");
+ Preference allowScreenshotsPreference = findPreference(getString(R.string.allow_screenshots_key));
Preference easyListPreference = findPreference("easylist");
Preference easyPrivacyPreference = findPreference("easyprivacy");
Preference fanboyAnnoyanceListPreference = findPreference("fanboys_annoyance_list");
Preference clearCookiesPreference = findPreference("clear_cookies");
Preference clearDomStoragePreference = findPreference("clear_dom_storage");
Preference clearFormDataPreference = findPreference("clear_form_data"); // The clear form data preference can be removed once the minimum API >= 26.
+ Preference clearLogcatPreference = findPreference(getString(R.string.clear_logcat_key));
Preference clearCachePreference = findPreference("clear_cache");
Preference homepagePreference = findPreference("homepage");
Preference downloadLocationPreference = findPreference("download_location");
assert clearCookiesPreference != null;
assert clearDomStoragePreference != null;
assert clearFormDataPreference != null;
+ assert clearLogcatPreference != null;
assert clearCachePreference != null;
assert homepagePreference != null;
assert downloadLocationPreference != null;
proxyCustomUrlPreference.setEnabled(proxyString.equals("Custom"));
- // Set the status of the Clear and Exit preferences.
+ // Set the status of the clear and exit preferences.
clearCookiesPreference.setEnabled(!clearEverything);
clearDomStoragePreference.setEnabled(!clearEverything);
clearFormDataPreference.setEnabled(!clearEverything); // The form data line can be removed once the minimum API is >= 26.
+ clearLogcatPreference.setEnabled(!clearEverything);
clearCachePreference.setEnabled(!clearEverything);
}
// Set the allow screenshots icon.
- if (savedPreferences.getBoolean("allow_screenshots", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_night);
- } else {
+ if (savedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_day);
+ } else {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_night);
}
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_night);
- } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_day);
+ } else {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_night);
}
}
}
}
+ // Set the clear logcat preference icon.
+ if (clearEverything || savedPreferences.getBoolean(getString(R.string.clear_logcat_key), true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_day);
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_night);
+ }
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.bug_warning);
+ }
+
// Set the clear cache preference icon.
if (clearEverything || savedPreferences.getBoolean("clear_cache", true)) {
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
case "allow_screenshots":
// Update the icon.
- if (sharedPreferences.getBoolean("allow_screenshots", false)) {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_night);
- } else {
+ if (sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_day);
+ } else {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_night);
}
} else {
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_night);
- } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_day);
+ } else {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_night);
}
}
break;
case "clear_everything":
- // Store the new `clear_everything` status
+ // Store the new clear everything status
boolean newClearEverythingBoolean = sharedPreferences.getBoolean("clear_everything", true);
- // Update the status of the `Clear and Exit` preferences.
+ // Update the status of the clear and exit preferences.
clearCookiesPreference.setEnabled(!newClearEverythingBoolean);
clearDomStoragePreference.setEnabled(!newClearEverythingBoolean);
clearFormDataPreference.setEnabled(!newClearEverythingBoolean); // This line can be removed once the minimum API >= 26.
+ clearLogcatPreference.setEnabled(!newClearEverythingBoolean);
clearCachePreference.setEnabled(!newClearEverythingBoolean);
- // Update the `clearEverythingPreference` icon.
+ // Update the clear everything preference icon.
if (newClearEverythingBoolean) {
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled_night);
clearEverythingPreference.setIcon(R.drawable.clear_everything_disabled);
}
- // Update the `clearCookiesPreference` icon.
+ // Update the clear cookies preference icon.
if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cookies", true)) {
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
clearCookiesPreference.setIcon(R.drawable.cookies_cleared_night);
clearCookiesPreference.setIcon(R.drawable.cookies_warning);
}
- // Update the `clearDomStoragePreference` icon.
+ // Update the clear dom storage preference icon.
if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_dom_storage", true)) {
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_night);
}
}
- // Update the `clearCachePreference` icon.
+ // Update the clear logcat preference icon.
+ if (newClearEverythingBoolean || sharedPreferences.getBoolean(getString(R.string.clear_logcat_key), true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_day);
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_night);
+ }
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.cache_warning);
+ }
+
+ // Update the clear cache preference icon.
if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cache", true)) {
if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
clearCachePreference.setIcon(R.drawable.cache_cleared_night);
}
break;
+ case "clear_logcat":
+ // Update the icon.
+ if (sharedPreferences.getBoolean(getString(R.string.clear_logcat_key), true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_day);
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_night);
+ }
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.bug_warning);
+ }
+ break;
+
case "clear_cache":
// Update the icon.
if (sharedPreferences.getBoolean("clear_cache", true)) {
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `bug_report`. It is released under the Apache License 2.0. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FF1565C0"
+ android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"/>
+</vector>
\ No newline at end of file
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `bug_report`. It is released under the Apache License 2.0. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FF8AB4F8"
+ android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"/>
+</vector>
\ No newline at end of file
--- /dev/null
+<!-- This file comes from the Android Material icon set, where it is called `bug_report`. It is released under the Apache License 2.0. -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0" >
+
+ <!-- A hard coded color must be used until API >= 21. Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+ <path
+ android:fillColor="#FFB71C1C"
+ android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"/>
+</vector>
\ No newline at end of file
<string name="hide_app_bar_summary">Hide the app bar that contains the URL.</string>
<string name="clear_everything">Clear everything</string>
<!-- The form data part of this string can be removed once the minimum API >= 26. -->
- <string name="clear_everything_summary">Clears cookies, DOM storage, form data, and WebView’s cache. Then manually deletes the entire “app_webview” and “cache” directories.</string>
+ <string name="clear_everything_summary">Clears cookies, DOM storage, form data, the logcat, and WebView’s cache. Then manually deletes the entire “app_webview” and “cache” directories.</string>
<string name="clear_cookies_preference">Clear cookies</string>
<string name="clear_cookies_summary">Clears first and third-party cookies.</string>
<string name="clear_dom_storage_preference">Clear DOM storage</string>
<string name="clear_dom_storage_summary">Clears DOM storage.</string>
<string name="clear_form_data_preference">Clear form data</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
<string name="clear_form_data_summary">Clears form data.</string> <!-- The form data strings can be removed once the minimum API >= 26. -->
+ <string name="clear_logcat_preference">Clear logcat</string>
+ <string name="clear_logcat_summary">Clears the logcat.</string>
<string name="clear_cache">Clear cache</string>
<string name="clear_cache_summary">Clears WebView’s cache.</string>
<string name="general">General</string>
<!-- Non-translatable preference keys. -->
<string name="allow_screenshots_key" translatable="false">allow_screenshots</string>
+ <string name="clear_logcat_key" translatable="false">clear_logcat</string>
<!-- Non-translatable preference default values. -->
<string name="user_agent_default_value" translatable="false">Privacy Browser</string>
android:summary="@string/clear_form_data_summary"
android:defaultValue="true" />
+ <SwitchPreference
+ android:key="clear_logcat"
+ android:title="@string/clear_logcat_preference"
+ android:summary="@string/clear_logcat_summary"
+ android:defaultValue="true" />
+
<SwitchPreference
android:key="clear_cache"
android:title="@string/clear_cache"