show key fetch error in activity when there are no keys to be used

This commit is contained in:
Daniel Gultsch 2016-01-13 12:19:56 +01:00
parent 571eb2f7f9
commit 14428da108
2 changed files with 9 additions and 1 deletions

View File

@ -42,6 +42,8 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
private Button mSaveButton; private Button mSaveButton;
private Button mCancelButton; private Button mCancelButton;
private AxolotlService.FetchStatus lastFetchReport = AxolotlService.FetchStatus.SUCCESS;
private final Map<String, Boolean> ownKeysToTrust = new HashMap<>(); private final Map<String, Boolean> ownKeysToTrust = new HashMap<>();
private final Map<String, Boolean> foreignKeysToTrust = new HashMap<>(); private final Map<String, Boolean> foreignKeysToTrust = new HashMap<>();
@ -160,7 +162,11 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
} else { } else {
if (!hasForeignKeys && hasNoOtherTrustedKeys()) { if (!hasForeignKeys && hasNoOtherTrustedKeys()) {
keyErrorMessageCard.setVisibility(View.VISIBLE); keyErrorMessageCard.setVisibility(View.VISIBLE);
if (lastFetchReport == AxolotlService.FetchStatus.ERROR) {
keyErrorMessage.setText(R.string.error_no_keys_to_trust_server_error);
} else {
keyErrorMessage.setText(R.string.error_no_keys_to_trust); keyErrorMessage.setText(R.string.error_no_keys_to_trust);
}
ownKeys.removeAllViews(); ownKeysCard.setVisibility(View.GONE); ownKeys.removeAllViews(); ownKeysCard.setVisibility(View.GONE);
foreignKeys.removeAllViews(); foreignKeysCard.setVisibility(View.GONE); foreignKeys.removeAllViews(); foreignKeysCard.setVisibility(View.GONE);
} }
@ -216,6 +222,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
@Override @Override
public void onKeyStatusUpdated(final AxolotlService.FetchStatus report) { public void onKeyStatusUpdated(final AxolotlService.FetchStatus report) {
if (report != null) { if (report != null) {
lastFetchReport = report;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -408,6 +408,7 @@
<string name="purge_key">Purge key</string> <string name="purge_key">Purge key</string>
<string name="purge_key_desc_part1">Are you sure you want to purge this key?</string> <string name="purge_key_desc_part1">Are you sure you want to purge this key?</string>
<string name="purge_key_desc_part2">It will irreversibly be considered compromised, and you can never build a session with it again.</string> <string name="purge_key_desc_part2">It will irreversibly be considered compromised, and you can never build a session with it again.</string>
<string name="error_no_keys_to_trust_server_error">There are no usable keys available for this contact.\nFetching new keys from the server has been unsuccessful. Maybe there is something wrong with your contacts server.</string>
<string name="error_no_keys_to_trust">There are no usable keys available for this contact. If you have purged any of their keys, they need to generate new ones.</string> <string name="error_no_keys_to_trust">There are no usable keys available for this contact. If you have purged any of their keys, they need to generate new ones.</string>
<string name="error_trustkeys_title">Error</string> <string name="error_trustkeys_title">Error</string>
<string name="fetching_history_from_server">Fetching history from server</string> <string name="fetching_history_from_server">Fetching history from server</string>