]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
Clear the logcat on exit. https://redmine.stoutner.com/issues/382
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebViewActivity.java
index f9f1780f61c8575eec3a8671a2ac88d5be000073..1635e5df8bcd5e772862d7733f8c4b65a572c2ab 100644 (file)
@@ -363,7 +363,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
         // 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);
@@ -4963,6 +4963,19 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             }
         }
 
+        // 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.