mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Add warning banner after plaintext export
This commit is contained in:
parent
b875baacef
commit
045b8280bf
5 changed files with 93 additions and 0 deletions
|
@ -316,6 +316,29 @@ public class Preferences {
|
||||||
return _prefs.getBoolean("pref_backups_reminder_needed", false);
|
return _prefs.getBoolean("pref_backups_reminder_needed", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsPlaintextBackupWarningNeeded(boolean needed) {
|
||||||
|
if (isPlaintextBackupWarningNeeded() != needed) {
|
||||||
|
_prefs.edit().putBoolean("pref_plaintext_backup_warning_needed", needed).apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlaintextBackupWarningNeeded() {
|
||||||
|
if (canShowPlaintextBackupWarning()) {
|
||||||
|
return _prefs.getBoolean("pref_plaintext_backup_warning_needed", false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanShowPlaintextBackupWarning(boolean canShow) {
|
||||||
|
if (canShowPlaintextBackupWarning() != canShow) {
|
||||||
|
_prefs.edit().putBoolean("pref_can_show_plaintext_backup_warning", canShow).apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canShowPlaintextBackupWarning() {
|
||||||
|
return _prefs.getBoolean("pref_can_show_plaintext_backup_warning", true);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPinKeyboardEnabled() {
|
public boolean isPinKeyboardEnabled() {
|
||||||
return _prefs.getBoolean("pref_pin_keyboard", false);
|
return _prefs.getBoolean("pref_pin_keyboard", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,18 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.view.ActionMode;
|
import androidx.appcompat.view.ActionMode;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
|
||||||
|
@ -683,11 +687,46 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
startPreferencesActivity();
|
startPreferencesActivity();
|
||||||
});
|
});
|
||||||
_btnErrorBar.setVisibility(View.VISIBLE);
|
_btnErrorBar.setVisibility(View.VISIBLE);
|
||||||
|
} else if (_prefs.isPlaintextBackupWarningNeeded()) {
|
||||||
|
_textErrorBar.setText(R.string.backup_plaintext_export_warning);
|
||||||
|
_btnErrorBar.setOnClickListener(view -> {
|
||||||
|
showPlaintextExportWarningOptions();
|
||||||
|
});
|
||||||
|
_btnErrorBar.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
_btnErrorBar.setVisibility(View.GONE);
|
_btnErrorBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showPlaintextExportWarningOptions() {
|
||||||
|
View view = LayoutInflater.from(this).inflate(R.layout.dialog_plaintext_warning_options, null);
|
||||||
|
|
||||||
|
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.backup_plaintext_export_warning)
|
||||||
|
.setView(view)
|
||||||
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.create();
|
||||||
|
|
||||||
|
CheckBox checkBox = view.findViewById(R.id.checkbox_dont_show_plaintext_warning_again);
|
||||||
|
checkBox.setChecked(false);
|
||||||
|
|
||||||
|
dialog.setOnShowListener(d -> {
|
||||||
|
Button btnPos = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
|
||||||
|
btnPos.setOnClickListener(l -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
_prefs.setCanShowPlaintextBackupWarning(!checkBox.isChecked());
|
||||||
|
_prefs.setIsPlaintextBackupWarningNeeded(false);
|
||||||
|
|
||||||
|
updateErrorBar();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Dialogs.showSecureDialog(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntryClick(VaultEntry entry) {
|
public void onEntryClick(VaultEntry entry) {
|
||||||
if (_actionMode != null) {
|
if (_actionMode != null) {
|
||||||
|
|
|
@ -292,9 +292,11 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
||||||
break;
|
break;
|
||||||
case CODE_EXPORT_PLAIN:
|
case CODE_EXPORT_PLAIN:
|
||||||
cb.exportVault((stream) -> _vaultManager.getVault().export(stream, null));
|
cb.exportVault((stream) -> _vaultManager.getVault().export(stream, null));
|
||||||
|
_prefs.setIsPlaintextBackupWarningNeeded(true);
|
||||||
break;
|
break;
|
||||||
case CODE_EXPORT_GOOGLE_URI:
|
case CODE_EXPORT_GOOGLE_URI:
|
||||||
cb.exportVault((stream) -> _vaultManager.getVault().exportGoogleUris(stream));
|
cb.exportVault((stream) -> _vaultManager.getVault().exportGoogleUris(stream));
|
||||||
|
_prefs.setIsPlaintextBackupWarningNeeded(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
app/src/main/res/layout/dialog_plaintext_warning_options.xml
Normal file
26
app/src/main/res/layout/dialog_plaintext_warning_options.xml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
|
android:paddingTop="10dp">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="25dp"
|
||||||
|
android:layout_marginEnd="25dp"
|
||||||
|
android:text="@string/backup_plaintext_warning_explanation" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/checkbox_dont_show_plaintext_warning_again"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="@string/pref_show_plaintext_warning_hint"
|
||||||
|
android:checked="true" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -321,6 +321,9 @@
|
||||||
<string name="google_qr_export_unexpected">Expected QR code #%d, but scanned #%d instead</string>
|
<string name="google_qr_export_unexpected">Expected QR code #%d, but scanned #%d instead</string>
|
||||||
<string name="backup_error_bar_message"><b>Vault backup failed recently</b></string>
|
<string name="backup_error_bar_message"><b>Vault backup failed recently</b></string>
|
||||||
<string name="backup_reminder_bar_message"><b>Recent vault changes are not backed up</b></string>
|
<string name="backup_reminder_bar_message"><b>Recent vault changes are not backed up</b></string>
|
||||||
|
<string name="backup_plaintext_export_warning"><b>The vault was recently exported in plain text</b></string>
|
||||||
|
<string name="pref_show_plaintext_warning_hint">Don\'t show this warning again</string>
|
||||||
|
<string name="backup_plaintext_warning_explanation">This warning is shown because you recently exported an unencrypted copy of the vault. To maintain security of your tokens, we recommend deleting this file once it\'s no longer needed.</string>
|
||||||
<string name="switch_camera">Switch camera</string>
|
<string name="switch_camera">Switch camera</string>
|
||||||
|
|
||||||
<string name="custom_notices_format_style" translatable="false" >
|
<string name="custom_notices_format_style" translatable="false" >
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue