mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
Show a warning before unlinking the mailbox when there haven't been any connection failures
This commit is contained in:
@@ -53,6 +53,7 @@ public class MailboxStatusFragment extends Fragment {
|
|||||||
private final Handler handler = new Handler(Looper.getMainLooper());
|
private final Handler handler = new Handler(Looper.getMainLooper());
|
||||||
@Nullable // UiThread
|
@Nullable // UiThread
|
||||||
private Runnable refresher = null;
|
private Runnable refresher = null;
|
||||||
|
private boolean showUnlinkWarning = true;
|
||||||
|
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
private TextView statusTitleView;
|
private TextView statusTitleView;
|
||||||
@@ -105,7 +106,9 @@ public class MailboxStatusFragment extends Fragment {
|
|||||||
// * Implement UI for warning user when mailbox is unreachable #2175
|
// * Implement UI for warning user when mailbox is unreachable #2175
|
||||||
unlinkButton = v.findViewById(R.id.unlinkButton);
|
unlinkButton = v.findViewById(R.id.unlinkButton);
|
||||||
unlinkProgress = v.findViewById(R.id.unlinkProgress);
|
unlinkProgress = v.findViewById(R.id.unlinkProgress);
|
||||||
unlinkButton.setOnClickListener(view -> onUnlinkButtonClicked());
|
unlinkButton.setOnClickListener(view ->
|
||||||
|
onUnlinkButtonClicked(showUnlinkWarning)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -131,14 +134,17 @@ public class MailboxStatusFragment extends Fragment {
|
|||||||
iconRes = R.drawable.ic_check_circle_outline;
|
iconRes = R.drawable.ic_check_circle_outline;
|
||||||
title = getString(R.string.mailbox_status_connected_title);
|
title = getString(R.string.mailbox_status_connected_title);
|
||||||
tintRes = R.color.briar_brand_green;
|
tintRes = R.color.briar_brand_green;
|
||||||
|
showUnlinkWarning = true;
|
||||||
} else if (status.getAttemptsSinceSuccess() < NUM_FAILURES) {
|
} else if (status.getAttemptsSinceSuccess() < NUM_FAILURES) {
|
||||||
iconRes = R.drawable.ic_help_outline_white;
|
iconRes = R.drawable.ic_help_outline_white;
|
||||||
title = getString(R.string.mailbox_status_problem_title);
|
title = getString(R.string.mailbox_status_problem_title);
|
||||||
tintRes = R.color.briar_orange_500;
|
tintRes = R.color.briar_orange_500;
|
||||||
|
showUnlinkWarning = false;
|
||||||
} else {
|
} else {
|
||||||
tintRes = R.color.briar_red_500;
|
tintRes = R.color.briar_red_500;
|
||||||
title = getString(R.string.mailbox_status_failure_title);
|
title = getString(R.string.mailbox_status_failure_title);
|
||||||
iconRes = R.drawable.alerts_and_states_error;
|
iconRes = R.drawable.alerts_and_states_error;
|
||||||
|
showUnlinkWarning = false;
|
||||||
}
|
}
|
||||||
imageView.setImageResource(iconRes);
|
imageView.setImageResource(iconRes);
|
||||||
int color = getColor(requireContext(), tintRes);
|
int color = getColor(requireContext(), tintRes);
|
||||||
@@ -168,11 +174,16 @@ public class MailboxStatusFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUnlinkButtonClicked() {
|
private void onUnlinkButtonClicked(boolean showWarning) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext(),
|
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext(),
|
||||||
R.style.BriarDialogTheme);
|
R.style.BriarDialogTheme);
|
||||||
builder.setTitle(R.string.mailbox_status_unlink_dialog_title);
|
builder.setTitle(R.string.mailbox_status_unlink_dialog_title);
|
||||||
builder.setMessage(R.string.mailbox_status_unlink_dialog_question);
|
String msg = getString(R.string.mailbox_status_unlink_dialog_question);
|
||||||
|
if (showWarning) {
|
||||||
|
msg = getString(R.string.mailbox_status_unlink_dialog_warning) +
|
||||||
|
"\n\n" + msg;
|
||||||
|
}
|
||||||
|
builder.setMessage(msg);
|
||||||
builder.setPositiveButton(R.string.cancel,
|
builder.setPositiveButton(R.string.cancel,
|
||||||
(dialog, which) -> dialog.cancel());
|
(dialog, which) -> dialog.cancel());
|
||||||
builder.setNegativeButton(R.string.mailbox_status_unlink_button,
|
builder.setNegativeButton(R.string.mailbox_status_unlink_button,
|
||||||
|
|||||||
Reference in New Issue
Block a user