X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FImportExportActivity.java;h=fe4f99a02044be07b1dce82cd19fe6a9763b1778;hp=7fe893275d8397d8a1a36d354cf8518a7d42d119;hb=06922967cdc614aa38c1f63f08f39affd865b0e9;hpb=1d656c562831f535aa33903d44198dd890393f4f diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java index 7fe89327..fe4f99a0 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java @@ -1,20 +1,20 @@ /* - * Copyright © 2018-2021 Soren Stoutner . + * Copyright © 2018-2022 Soren Stoutner . * - * This file is part of Privacy Browser . + * This file is part of Privacy Browser Android . * - * Privacy Browser is free software: you can redistribute it and/or modify + * Privacy Browser Android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Privacy Browser is distributed in the hope that it will be useful, + * Privacy Browser Android is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Privacy Browser. If not, see . + * along with Privacy Browser Android. If not, see . */ package com.stoutner.privacybrowser.activities; @@ -24,7 +24,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; @@ -85,7 +84,6 @@ public class ImportExportActivity extends AppCompatActivity { // Define the saved instance state constants. private final String ENCRYPTION_PASSWORD_TEXTINPUTLAYOUT_VISIBILITY = "encryption_password_textinputlayout_visibility"; - private final String KITKAT_PASSWORD_ENCRYPTED_TEXTVIEW_VISIBILITY = "kitkat_password_encrypted_textview_visibility"; private final String OPEN_KEYCHAIN_REQUIRED_TEXTVIEW_VISIBILITY = "open_keychain_required_textview_visibility"; private final String FILE_LOCATION_CARD_VIEW = "file_location_card_view"; private final String FILE_NAME_LINEARLAYOUT_VISIBILITY = "file_name_linearlayout_visibility"; @@ -98,7 +96,6 @@ public class ImportExportActivity extends AppCompatActivity { Spinner encryptionSpinner; TextInputLayout encryptionPasswordTextInputLayout; EditText encryptionPasswordEditText; - TextView kitKatPasswordEncryptionTextView; TextView openKeychainRequiredTextView; CardView fileLocationCardView; RadioButton importRadioButton; @@ -154,9 +151,6 @@ public class ImportExportActivity extends AppCompatActivity { // Display the home arrow on the support action bar. actionBar.setDisplayHomeAsUpEnabled(true); - // Find out if the system is running KitKat - boolean runningKitKat = (Build.VERSION.SDK_INT == 19); - // Find out if OpenKeychain is installed. try { openKeychainInstalled = !getPackageManager().getPackageInfo("org.sufficientlysecure.keychain", 0).versionName.isEmpty(); @@ -168,7 +162,6 @@ public class ImportExportActivity extends AppCompatActivity { encryptionSpinner = findViewById(R.id.encryption_spinner); encryptionPasswordTextInputLayout = findViewById(R.id.encryption_password_textinputlayout); encryptionPasswordEditText = findViewById(R.id.encryption_password_edittext); - kitKatPasswordEncryptionTextView = findViewById(R.id.kitkat_password_encryption_textview); openKeychainRequiredTextView = findViewById(R.id.openkeychain_required_textview); fileLocationCardView = findViewById(R.id.file_location_cardview); importRadioButton = findViewById(R.id.import_radiobutton); @@ -195,7 +188,6 @@ public class ImportExportActivity extends AppCompatActivity { case NO_ENCRYPTION: // Hide the unneeded layout items. encryptionPasswordTextInputLayout.setVisibility(View.GONE); - kitKatPasswordEncryptionTextView.setVisibility(View.GONE); openKeychainRequiredTextView.setVisibility(View.GONE); openKeychainImportInstructionsTextView.setVisibility(View.GONE); @@ -217,43 +209,33 @@ public class ImportExportActivity extends AppCompatActivity { break; case PASSWORD_ENCRYPTION: - if (runningKitKat) { - // Show the KitKat password encryption message. - kitKatPasswordEncryptionTextView.setVisibility(View.VISIBLE); - - // Hide the OpenPGP required text view and the file location card. - openKeychainRequiredTextView.setVisibility(View.GONE); - fileLocationCardView.setVisibility(View.GONE); - } else { - // Hide the OpenPGP layout items. - openKeychainRequiredTextView.setVisibility(View.GONE); - openKeychainImportInstructionsTextView.setVisibility(View.GONE); - - // Show the password encryption layout items. - encryptionPasswordTextInputLayout.setVisibility(View.VISIBLE); + // Hide the OpenPGP layout items. + openKeychainRequiredTextView.setVisibility(View.GONE); + openKeychainImportInstructionsTextView.setVisibility(View.GONE); - // Show the file location card. - fileLocationCardView.setVisibility(View.VISIBLE); + // Show the password encryption layout items. + encryptionPasswordTextInputLayout.setVisibility(View.VISIBLE); - // Show the file name linear layout if either import or export is checked. - if (importRadioButton.isChecked() || exportRadioButton.isChecked()) { - fileNameLinearLayout.setVisibility(View.VISIBLE); - } + // Show the file location card. + fileLocationCardView.setVisibility(View.VISIBLE); - // Reset the text of the import button, which may have been changed to `Decrypt`. - if (importRadioButton.isChecked()) { - importExportButton.setText(R.string.import_button); - } + // Show the file name linear layout if either import or export is checked. + if (importRadioButton.isChecked() || exportRadioButton.isChecked()) { + fileNameLinearLayout.setVisibility(View.VISIBLE); + } - // Enable the import/button if both the password and the file name are populated. - importExportButton.setEnabled(!fileNameEditText.getText().toString().isEmpty() && !encryptionPasswordEditText.getText().toString().isEmpty()); + // Reset the text of the import button, which may have been changed to `Decrypt`. + if (importRadioButton.isChecked()) { + importExportButton.setText(R.string.import_button); } + + // Enable the import/button if both the password and the file name are populated. + importExportButton.setEnabled(!fileNameEditText.getText().toString().isEmpty() && !encryptionPasswordEditText.getText().toString().isEmpty()); break; case OPENPGP_ENCRYPTION: // Hide the password encryption layout items. encryptionPasswordTextInputLayout.setVisibility(View.GONE); - kitKatPasswordEncryptionTextView.setVisibility(View.GONE); // Updated items based on the installation status of OpenKeychain. if (openKeychainInstalled) { // OpenKeychain is installed. @@ -343,7 +325,6 @@ public class ImportExportActivity extends AppCompatActivity { if (savedInstanceState == null) { // The app has not been restarted. // Initially hide the unneeded views. encryptionPasswordTextInputLayout.setVisibility(View.GONE); - kitKatPasswordEncryptionTextView.setVisibility(View.GONE); openKeychainRequiredTextView.setVisibility(View.GONE); fileNameLinearLayout.setVisibility(View.GONE); openKeychainImportInstructionsTextView.setVisibility(View.GONE); @@ -351,7 +332,6 @@ public class ImportExportActivity extends AppCompatActivity { } else { // The app has been restarted. // Restore the visibility of the views. encryptionPasswordTextInputLayout.setVisibility(savedInstanceState.getInt(ENCRYPTION_PASSWORD_TEXTINPUTLAYOUT_VISIBILITY)); - kitKatPasswordEncryptionTextView.setVisibility(savedInstanceState.getInt(KITKAT_PASSWORD_ENCRYPTED_TEXTVIEW_VISIBILITY)); openKeychainRequiredTextView.setVisibility(savedInstanceState.getInt(OPEN_KEYCHAIN_REQUIRED_TEXTVIEW_VISIBILITY)); fileLocationCardView.setVisibility(savedInstanceState.getInt(FILE_LOCATION_CARD_VIEW)); fileNameLinearLayout.setVisibility(savedInstanceState.getInt(FILE_NAME_LINEARLAYOUT_VISIBILITY)); @@ -371,7 +351,6 @@ public class ImportExportActivity extends AppCompatActivity { // Save the visibility of the views. savedInstanceState.putInt(ENCRYPTION_PASSWORD_TEXTINPUTLAYOUT_VISIBILITY, encryptionPasswordTextInputLayout.getVisibility()); - savedInstanceState.putInt(KITKAT_PASSWORD_ENCRYPTED_TEXTVIEW_VISIBILITY, kitKatPasswordEncryptionTextView.getVisibility()); savedInstanceState.putInt(OPEN_KEYCHAIN_REQUIRED_TEXTVIEW_VISIBILITY, openKeychainRequiredTextView.getVisibility()); savedInstanceState.putInt(FILE_LOCATION_CARD_VIEW, fileLocationCardView.getVisibility()); savedInstanceState.putInt(FILE_NAME_LINEARLAYOUT_VISIBILITY, fileNameLinearLayout.getVisibility());