+ public void onClickRadioButton(View view) {
+ // Get handles for the views.
+ Spinner encryptionSpinner = findViewById(R.id.encryption_spinner);
+ LinearLayout fileNameLinearLayout = findViewById(R.id.file_name_linearlayout);
+ EditText fileNameEditText = findViewById(R.id.file_name_edittext);
+ TextView openKeychainImportInstructionTextView = findViewById(R.id.openkeychain_import_instructions_textview);
+ Button importExportButton = findViewById(R.id.import_export_button);
+
+ // Check to see if import or export was selected.
+ switch (view.getId()) {
+ case R.id.import_radiobutton:
+ // Check to see if OpenPGP encryption is selected.
+ if (encryptionSpinner.getSelectedItemPosition() == OPENPGP_ENCRYPTION) { // OpenPGP encryption selected.
+ // Show the OpenKeychain import instructions.
+ openKeychainImportInstructionTextView.setVisibility(View.VISIBLE);
+
+ // Set the text on the import/export button to be `Decrypt`.
+ importExportButton.setText(R.string.decrypt);
+
+ // Enable the decrypt button if there is a file name.
+ importExportButton.setEnabled(!fileNameEditText.getText().toString().isEmpty());
+ } else { // OpenPGP encryption not selected.
+ // Hide the OpenKeychain import instructions.
+ openKeychainImportInstructionTextView.setVisibility(View.GONE);
+
+ // Set the text on the import/export button to be `Import`.
+ importExportButton.setText(R.string.import_button);
+ }
+
+ // Display the file name views.
+ fileNameLinearLayout.setVisibility(View.VISIBLE);
+ importExportButton.setVisibility(View.VISIBLE);
+ break;
+
+ case R.id.export_radiobutton:
+ // Hide the OpenKeychain import instructions.
+ openKeychainImportInstructionTextView.setVisibility(View.GONE);
+
+ // Set the text on the import/export button to be `Export`.
+ importExportButton.setText(R.string.export);
+
+ // Show the import/export button.
+ importExportButton.setVisibility(View.VISIBLE);
+
+ // Check to see if OpenPGP encryption is selected.
+ if (encryptionSpinner.getSelectedItemPosition() == OPENPGP_ENCRYPTION) { // OpenPGP encryption is selected.
+ // Hide the file name views.
+ fileNameLinearLayout.setVisibility(View.GONE);
+
+ // Enable the export button.
+ importExportButton.setEnabled(true);
+ } else { // OpenPGP encryption is not selected.
+ // Show the file name views.
+ fileNameLinearLayout.setVisibility(View.VISIBLE);
+ }
+ break;
+ }
+ }
+