X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FAboutVersionFragment.java;h=9436110fef7454a1019775e5d11f38e261c8ff47;hp=b088a88f07872dbec20e905ad945afe1d9b68fcc;hb=39fd3a6664fe15f9e050e6bb8c0ca0e125fd2f0f;hpb=1003c7842a01f338c8aaf9d4f07216111f294202 diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.java index b088a88f..9436110f 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.java @@ -319,7 +319,7 @@ public class AboutVersionFragment extends Fragment { if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700)); } else { - blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.violet_500)); + blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.violet_700)); } // Setup the spans to display the device information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction. @@ -356,7 +356,8 @@ public class AboutVersionFragment extends Fragment { ultraPrivacyTextView.setText(ultraPrivacyStringBuilder); // Only populate the radio text view if there is a radio in the device. - if (!radio.isEmpty()) { + // Null must be checked because some Samsung tablets report a null value for the radio instead of an empty string. Grrrr. + if ((radio != null) && !radio.isEmpty()) { String radioLabel = getString(R.string.radio) + " "; SpannableStringBuilder radioStringBuilder = new SpannableStringBuilder(radioLabel + radio); radioStringBuilder.setSpan(blueColorSpan, radioLabel.length(), radioStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); @@ -544,81 +545,76 @@ public class AboutVersionFragment extends Fragment { @Override public boolean onOptionsItemSelected(@NonNull MenuItem menuItem) { + // Remove the incorrect lint warning below that the activity might be null. + assert getActivity() != null; + // Get the ID of the menu item that was selected. int menuItemId = menuItem.getItemId(); - // Remove the warning below that `getActivity()` might be null. - assert getActivity() != null; - // Run the appropriate commands. - switch (menuItemId) { - case R.id.copy: - // Get the about version string. - String aboutVersionString = getAboutVersionString(); - - // Get a handle for the clipboard manager. - ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); - - // Remove the incorrect lint error below that the clipboard manager might be null. - assert clipboardManager != null; - - // Save the about version string in a clip data. - ClipData aboutVersionClipData = ClipData.newPlainText(getString(R.string.about), aboutVersionString); - - // Place the clip data on the clipboard. - clipboardManager.setPrimaryClip(aboutVersionClipData); + if (menuItemId == R.id.copy) { // Copy. + // Get the about version string. + String aboutVersionString = getAboutVersionString(); - // Display a snackbar. - Snackbar.make(aboutVersionLayout, R.string.version_info_copied, Snackbar.LENGTH_SHORT).show(); + // Get a handle for the clipboard manager. + ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); - // Consume the event. - return true; + // Remove the incorrect lint error below that the clipboard manager might be null. + assert clipboardManager != null; - case R.id.share: - // Get the about version string. - String aboutString = getAboutVersionString(); + // Save the about version string in a clip data. + ClipData aboutVersionClipData = ClipData.newPlainText(getString(R.string.about), aboutVersionString); - // Create an email intent. - Intent emailIntent = new Intent(Intent.ACTION_SEND); + // Place the clip data on the clipboard. + clipboardManager.setPrimaryClip(aboutVersionClipData); - // Add the about version string to the intent. - emailIntent.putExtra(Intent.EXTRA_TEXT, aboutString); + // Display a snackbar. + Snackbar.make(aboutVersionLayout, R.string.version_info_copied, Snackbar.LENGTH_SHORT).show(); - // Set the MIME type. - emailIntent.setType("text/plain"); + // Consume the event. + return true; + } else if (menuItemId == R.id.share) { // Share. + // Get the about version string. + String aboutString = getAboutVersionString(); - // Set the intent to open in a new task. - emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // Create an email intent. + Intent emailIntent = new Intent(Intent.ACTION_SEND); - // Make it so. - startActivity(Intent.createChooser(emailIntent, getString(R.string.share))); + // Add the about version string to the intent. + emailIntent.putExtra(Intent.EXTRA_TEXT, aboutString); - // Consume the event. - return true; + // Set the MIME type. + emailIntent.setType("text/plain"); - case R.id.save_text: - // Instantiate the save alert dialog. - DialogFragment saveTextDialogFragment = SaveDialog.save(SaveDialog.SAVE_ABOUT_VERSION_TEXT); + // Set the intent to open in a new task. + emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - // Show the save alert dialog. - saveTextDialogFragment.show(getActivity().getSupportFragmentManager(), getString(R.string.save_dialog)); + // Make it so. + startActivity(Intent.createChooser(emailIntent, getString(R.string.share))); - // Consume the event. - return true; + // Consume the event. + return true; + } else if (menuItemId == R.id.save_text) { // Save text. + // Instantiate the save alert dialog. + DialogFragment saveTextDialogFragment = SaveDialog.save(SaveDialog.SAVE_ABOUT_VERSION_TEXT); - case R.id.save_image: - // Instantiate the save alert dialog. - DialogFragment saveImageDialogFragment = SaveDialog.save(SaveDialog.SAVE_ABOUT_VERSION_IMAGE); + // Show the save alert dialog. + saveTextDialogFragment.show(getActivity().getSupportFragmentManager(), getString(R.string.save_dialog)); - // Show the save alert dialog. - saveImageDialogFragment.show(getActivity().getSupportFragmentManager(), getString(R.string.save_dialog)); + // Consume the event. + return true; + } else if (menuItemId == R.id.save_image) { // Save image. + // Instantiate the save alert dialog. + DialogFragment saveImageDialogFragment = SaveDialog.save(SaveDialog.SAVE_ABOUT_VERSION_IMAGE); - // Consume the event. - return true; + // Show the save alert dialog. + saveImageDialogFragment.show(getActivity().getSupportFragmentManager(), getString(R.string.save_dialog)); - default: - // Don't consume the event. - return super.onOptionsItemSelected(menuItem); + // Consume the event. + return true; + } else { // The home button was selected. + // Return the parent class. + return super.onOptionsItemSelected(menuItem); } }