mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Improve MailboxStatusFragment and record check failures as well
This commit is contained in:
@@ -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-->
|
||||
|
||||
Reference in New Issue
Block a user