mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
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:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user