Remind user to wipe mailbox if it's unreachable when unpairing

If we fail to tell the mailbox to wipe itself when unpairing, remind the user that they should wipe the mailbox next time they have access to it.
This commit is contained in:
Torsten Grote
2022-04-27 08:39:44 -03:00
parent 3138213f39
commit 2411c82d9c
4 changed files with 27 additions and 5 deletions

View File

@@ -15,6 +15,7 @@ import org.briarproject.briar.android.fragment.FinalFragment;
import javax.inject.Inject;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.ViewModelProvider;
@@ -53,7 +54,8 @@ public class MailboxActivity extends BriarActivity {
viewModel.getPairingState().observeEvent(this, state -> {
if (state instanceof MailboxState.NotSetup) {
onNotSetup();
MailboxState.NotSetup s = (MailboxState.NotSetup) state;
onNotSetup(s.tellUserToWipeMailbox);
} else if (state instanceof MailboxState.ShowDownload) {
onShowDownload();
} else if (state instanceof MailboxState.ScanningQrCode) {
@@ -95,8 +97,17 @@ public class MailboxActivity extends BriarActivity {
}
}
private void onNotSetup() {
private void onNotSetup(boolean tellUserToWipeMailbox) {
progressBar.setVisibility(INVISIBLE);
if (tellUserToWipeMailbox) {
AlertDialog.Builder builder =
new AlertDialog.Builder(this, R.style.BriarDialogTheme);
builder.setTitle(R.string.mailbox_status_unlink_no_wipe_title);
builder.setMessage(R.string.mailbox_status_unlink_no_wipe_message);
builder.setNeutralButton(R.string.got_it,
(dialog, which) -> dialog.cancel());
builder.show();
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, new SetupIntroFragment(),
SetupIntroFragment.TAG)
@@ -126,7 +137,7 @@ public class MailboxActivity extends BriarActivity {
if (fm.getBackStackEntryCount() == 0) {
// We re-launched into an existing state,
// need to re-populate the back stack.
onNotSetup();
onNotSetup(false);
onShowDownload();
}
Fragment f;

View File

@@ -5,6 +5,15 @@ import org.briarproject.bramble.api.mailbox.MailboxPairingState;
class MailboxState {
static class NotSetup extends MailboxState {
final boolean tellUserToWipeMailbox;
NotSetup() {
this(false);
}
NotSetup(boolean tellUserToWipeMailbox) {
this.tellUserToWipeMailbox = tellUserToWipeMailbox;
}
}
static class ShowDownload extends MailboxState {

View File

@@ -225,8 +225,8 @@ class MailboxViewModel extends DbViewModel
void unlink() {
ioExecutor.execute(() -> {
try {
mailboxManager.unPair();
pairingState.postEvent(new MailboxState.NotSetup());
boolean wasWiped = mailboxManager.unPair();
pairingState.postEvent(new MailboxState.NotSetup(!wasWiped));
} catch (DbException e) {
handleException(e);
}

View File

@@ -654,6 +654,8 @@
<string name="mailbox_status_unlink_dialog_title">Unlink mailbox?</string>
<string name="mailbox_status_unlink_dialog_question">Are you sure you want to unlink your Mailbox?</string>
<string name="mailbox_status_unlink_dialog_warning">If you unlink your Mailbox, you won\'t be able to receive messages while Briar is offline.</string>
<string name="mailbox_status_unlink_no_wipe_title">Your Mailbox has been unlinked</string>
<string name="mailbox_status_unlink_no_wipe_message">Next time you have access to your Mailbox device, please open the Mailbox app and tap the \"Unlink\" button to complete the process.\n\nIf you no longer have access to your Mailbox device, don\'t worry. Everything stored in your Mailbox is encrypted, so your data will remain secure even if you don\'t complete the process.</string>
<!-- Conversation Settings -->
<string name="disappearing_messages_title">Disappearing messages</string>