mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29: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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user