+ }
+
+ @Override
+ public void onSave(int saveType, DialogFragment dialogFragment) {
+ // Get a handle for the dialog.
+ Dialog dialog = dialogFragment.getDialog();
+
+ // Remove the lint warning below that the dialog might be null.
+ assert dialog != null;
+
+ // Get a handle for the file name edit text.
+ EditText fileNameEditText = dialog.findViewById(R.id.file_name_edittext);
+
+ // Get the file name string.
+ String fileNameString = fileNameEditText.getText().toString();
+
+ // Get a handle for the about version linear layout.
+ LinearLayout aboutVersionLinearLayout = findViewById(R.id.about_version_linearlayout);
+
+ // Save the file according to the type.
+ switch (saveType) {
+ case SaveDialog.SAVE_ABOUT_VERSION_TEXT:
+ try {
+ // Get a handle for the about version fragment.
+ AboutVersionFragment aboutVersionFragment = (AboutVersionFragment) aboutPagerAdapter.getTabFragment(0);
+
+ // Get the about version text.
+ String aboutVersionString = aboutVersionFragment.getAboutVersionString();
+
+ // Create an input stream with the contents of about version.
+ InputStream aboutVersionInputStream = new ByteArrayInputStream(aboutVersionString.getBytes(StandardCharsets.UTF_8));
+
+ // Create an about version buffered reader.
+ BufferedReader aboutVersionBufferedReader = new BufferedReader(new InputStreamReader(aboutVersionInputStream));
+
+ // Open an output stream.
+ OutputStream outputStream = getContentResolver().openOutputStream(Uri.parse(fileNameString));
+
+ // Create a file buffered writer.
+ BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
+
+ // Create a transfer string.
+ String transferString;
+
+ // Use the transfer string to copy the about version text from the buffered reader to the buffered writer.
+ while ((transferString = aboutVersionBufferedReader.readLine()) != null) {
+ // Append the line to the buffered writer.
+ bufferedWriter.append(transferString);
+
+ // Append a line break.
+ bufferedWriter.append("\n");
+ }
+
+ // Flush the buffered writer.
+ bufferedWriter.flush();
+
+ // Close the inputs and outputs.
+ aboutVersionBufferedReader.close();
+ aboutVersionInputStream.close();
+ bufferedWriter.close();
+ outputStream.close();
+
+ // Display a snackbar with the saved about version information.
+ Snackbar.make(aboutVersionLinearLayout, getString(R.string.file_saved) + " " + fileNameString, Snackbar.LENGTH_SHORT).show();
+ } catch (Exception exception) {
+ // Display a snackbar with the error message.
+ Snackbar.make(aboutVersionLinearLayout, getString(R.string.error_saving_file) + " " + exception.toString(), Snackbar.LENGTH_INDEFINITE).show();
+ }
+ break;