Skip to content
Snippets Groups Projects
Commit 85e53479 authored by akwizgran's avatar akwizgran
Browse files

Merge branch '2172-mailbox-status-ui' into 'master'

Improve MailboxStatusFragment and record check failures as well

Closes #2172

See merge request briar/briar!1632
parents 116ee970 dea05c85
No related branches found
No related tags found
No related merge requests found
......@@ -103,22 +103,32 @@ class MailboxManagerImpl implements MailboxManager {
MailboxProperties props = db.transactionWithNullableResult(true,
mailboxSettingsManager::getOwnMailboxProperties);
success = api.checkStatus(props);
} catch (DbException | IOException | MailboxApi.ApiException e) {
} catch (DbException e) {
logException(LOG, WARNING, e);
// we don't treat this is a failure to record
return false;
} catch (IOException | MailboxApi.ApiException e) {
// we record this as a failure
success = false;
logException(LOG, WARNING, e);
}
if (success) {
try {
// we are only recording successful connections here
// as those update the UI and failures might be false negatives
db.transaction(false, txn ->
mailboxSettingsManager.recordSuccessfulConnection(txn,
clock.currentTimeMillis()));
} catch (DbException e) {
logException(LOG, WARNING, e);
}
try {
recordCheckResult(success);
} catch (DbException e) {
logException(LOG, WARNING, e);
}
return success;
}
private void recordCheckResult(boolean success) throws DbException {
long now = clock.currentTimeMillis();
db.transaction(false, txn -> {
if (success) {
mailboxSettingsManager.recordSuccessfulConnection(txn, now);
} else {
mailboxSettingsManager.recordFailedConnectionAttempt(txn, now);
}
});
}
}
......@@ -100,7 +100,7 @@ public class MailboxStatusFragment extends Fragment {
.observe(getViewLifecycleOwner(), this::onMailboxStateChanged);
// TODO
// * detect problems and show them #2175
// * Implement UI for warning user when mailbox is unreachable #2175
// * add "Unlink" button confirmation dialog and functionality #2173
Button unlinkButton = v.findViewById(R.id.unlinkButton);
unlinkButton.setOnClickListener(view -> Toast.makeText(requireContext(),
......
......@@ -19,22 +19,23 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.25"
app:layout_constraintVertical_chainStyle="packed"
app:srcCompat="@drawable/ic_check_circle_outline"
app:tint="@color/briar_brand_green"
tools:ignore="ContentDescription" />
tools:ignore="ContentDescription"
tools:srcCompat="@drawable/ic_help_outline_white"
tools:tint="@color/briar_orange_500" />
<TextView
android:id="@+id/statusTitleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/mailbox_status_connected_title"
android:gravity="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/checkButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
app:layout_constraintTop_toBottomOf="@+id/imageView"
tools:text="@string/mailbox_status_problem_title" />
<Button
android:id="@+id/checkButton"
......
......@@ -643,7 +643,7 @@
<string name="tor_offline_button_check">Check connection settings</string>
<string name="mailbox_status_title">Mailbox status</string>
<string name="mailbox_status_connected_title">Mailbox is running</string>
<string name="mailbox_status_problem_title">We are having trouble connecting to the mailbox</string>
<string name="mailbox_status_problem_title">Briar is having trouble connecting to the Mailbox</string>
<string name="mailbox_status_failure_title">Mailbox is unavailable</string>
<string name="mailbox_status_check_button">Check Connection</string>
<!-- Example for string substitution: Last connection: 3min ago-->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment