X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FLogcatActivity.java;h=3200c2be0b6fbfae60966ad6edcf12ef87570e1a;hp=2540ce49c848ac06ad3758e210b93f580cde9f4b;hb=39380e8e8bdb3b9e29569a263277c9c3112b44ac;hpb=86e63c8ed007311ab392d4beb7dd7ba64b9c3c70 diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java index 2540ce49..3200c2be 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java @@ -177,56 +177,52 @@ public class LogcatActivity extends AppCompatActivity implements SaveDialog.Save int menuItemId = menuItem.getItemId(); // Run the commands that correlate to the selected menu item. - switch (menuItemId) { - case R.id.copy: - // Get a handle for the clipboard manager. - ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + if (menuItemId == R.id.copy) { // Copy was selected. + // Get a handle for the clipboard manager. + ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); - // Remove the incorrect lint error below that the clipboard manager might be null. - assert clipboardManager != null; + // Remove the incorrect lint error below that the clipboard manager might be null. + assert clipboardManager != null; - // Save the logcat in a clip data. - ClipData logcatClipData = ClipData.newPlainText(getString(R.string.logcat), logcatTextView.getText()); + // Save the logcat in a clip data. + ClipData logcatClipData = ClipData.newPlainText(getString(R.string.logcat), logcatTextView.getText()); - // Place the clip data on the clipboard. - clipboardManager.setPrimaryClip(logcatClipData); + // Place the clip data on the clipboard. + clipboardManager.setPrimaryClip(logcatClipData); - // Display a snackbar. - Snackbar.make(logcatTextView, R.string.logcat_copied, Snackbar.LENGTH_SHORT).show(); + // Display a snackbar. + Snackbar.make(logcatTextView, R.string.logcat_copied, Snackbar.LENGTH_SHORT).show(); - // Consume the event. - return true; + // Consume the event. + return true; + } else if (menuItemId == R.id.save) { // Save was selected. + // Instantiate the save alert dialog. + DialogFragment saveDialogFragment = SaveDialog.save(SaveDialog.SAVE_LOGCAT); - case R.id.save: - // Instantiate the save alert dialog. - DialogFragment saveDialogFragment = SaveDialog.save(SaveDialog.SAVE_LOGCAT); + // Show the save alert dialog. + saveDialogFragment.show(getSupportFragmentManager(), getString(R.string.save_logcat)); - // Show the save alert dialog. - saveDialogFragment.show(getSupportFragmentManager(), getString(R.string.save_logcat)); + // Consume the event. + return true; + } else if (menuItemId == R.id.clear) { // Clear was selected. + 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"); - // Consume the event. - return true; + // Wait for the process to finish. + process.waitFor(); - case R.id.clear: - 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(); - - // Reload the logcat. - new GetLogcat(this, 0).execute(); - } catch (IOException|InterruptedException exception) { - // Do nothing. - } - - // Consume the event. - return true; + // Reload the logcat. + new GetLogcat(this, 0).execute(); + } catch (IOException | InterruptedException exception) { + // Do nothing. + } - default: - // Don't consume the event. - return super.onOptionsItemSelected(menuItem); + // Consume the event. + return true; + } else { // The home button was pushed. + // Do not consume the event. The system will process the home command. + return super.onOptionsItemSelected(menuItem); } }