mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-16 15:02:54 +00:00
Merge pull request #957 from orange-elephant/add-plaintext-export-warning
Add warning banner after plaintext export
This commit is contained in:
commit
85e230c46a
5 changed files with 93 additions and 0 deletions
|
@ -316,6 +316,29 @@ public class Preferences {
|
|||
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() {
|
||||
return _prefs.getBoolean("pref_pin_keyboard", false);
|
||||
}
|
||||
|
|
|
@ -14,14 +14,18 @@ import android.text.Spannable;
|
|||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.view.ActionMode;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
|
||||
|
@ -741,11 +745,46 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
startPreferencesActivity();
|
||||
});
|
||||
_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 {
|
||||
_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
|
||||
public void onEntryClick(VaultEntry entry) {
|
||||
if (_actionMode != null) {
|
||||
|
|
|
@ -292,9 +292,11 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
break;
|
||||
case CODE_EXPORT_PLAIN:
|
||||
cb.exportVault((stream) -> _vaultManager.getVault().export(stream, null));
|
||||
_prefs.setIsPlaintextBackupWarningNeeded(true);
|
||||
break;
|
||||
case CODE_EXPORT_GOOGLE_URI:
|
||||
cb.exportVault((stream) -> _vaultManager.getVault().exportGoogleUris(stream));
|
||||
_prefs.setIsPlaintextBackupWarningNeeded(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue