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;
import androidx.appcompat.widget.Toolbar;
import androidx.cardview.widget.CardView;
import androidx.core.content.FileProvider;
-import androidx.multidex.BuildConfig;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputLayout;
+import com.stoutner.privacybrowser.BuildConfig;
import com.stoutner.privacybrowser.R;
import com.stoutner.privacybrowser.helpers.ImportExportDatabaseHelper;
// Get a handle for the shared preferences.
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
- // Get the screenshot preference.
- boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+ // Get the preferences.
+ boolean allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false);
+ boolean bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false);
// Disable screenshots if not allowed.
if (!allowScreenshots) {
super.onCreate(savedInstanceState);
// Set the content view.
- setContentView(R.layout.import_export_coordinatorlayout);
+ if (bottomAppBar) {
+ setContentView(R.layout.import_export_bottom_appbar);
+ } else {
+ setContentView(R.layout.import_export_top_appbar);
+ }
- // Set the support action bar.
+ // Get a handle for the toolbar.
Toolbar toolbar = findViewById(R.id.import_export_toolbar);
+
+ // Set the support action bar.
setSupportActionBar(toolbar);
// Get a handle for the action bar.
// 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();
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);
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);
+ // Hide the OpenPGP layout items.
+ openKeychainRequiredTextView.setVisibility(View.GONE);
+ openKeychainImportInstructionsTextView.setVisibility(View.GONE);
- // Show the password encryption layout items.
- encryptionPasswordTextInputLayout.setVisibility(View.VISIBLE);
+ // Show the password encryption layout items.
+ encryptionPasswordTextInputLayout.setVisibility(View.VISIBLE);
- // Show the file location card.
- fileLocationCardView.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:
// Close the streams.
inputStream.close();
- temporaryPgpEncryptedImportFileOutputStream.flush();
-
+ temporaryPgpEncryptedImportFileOutputStream.close();
// Create an decryption intent for OpenKeychain.
Intent openKeychainDecryptIntent = new Intent("org.sufficientlysecure.keychain.action.DECRYPT_DATA");