mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Fix UI around receiving multiple returned shards
This commit is contained in:
@@ -104,15 +104,7 @@ public class OwnerReturnShardActivity extends BaseActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
// TODO should we cancel the return shard task here?
|
// TODO should we cancel the return shard task here?
|
||||||
if (viewModel.getState()
|
super.onBackPressed();
|
||||||
.getValue() instanceof SecretOwnerTask.State.Failure) {
|
|
||||||
// re-create this activity when going back in failed state
|
|
||||||
Intent i = new Intent(this, OwnerReturnShardActivity.class);
|
|
||||||
i.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
startActivity(i);
|
|
||||||
} else {
|
|
||||||
super.onBackPressed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showQrCodeFragment() {
|
private void showQrCodeFragment() {
|
||||||
@@ -136,10 +128,13 @@ public class OwnerReturnShardActivity extends BaseActivity
|
|||||||
"Success - got shard" + (added ? "" : " duplicate"),
|
"Success - got shard" + (added ? "" : " duplicate"),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
if (added && viewModel.canRecover()) {
|
if (added && viewModel.canRecover()) {
|
||||||
|
Toast.makeText(this,
|
||||||
|
"Secret key recovered!",
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
// finish();
|
|
||||||
} else if (state instanceof SecretOwnerTask.State.Failure) {
|
} else if (state instanceof SecretOwnerTask.State.Failure) {
|
||||||
// TODO error screen, handle reason
|
// TODO error screen, handle reason
|
||||||
Toast.makeText(this,
|
Toast.makeText(this,
|
||||||
|
|||||||
@@ -137,8 +137,6 @@ class OwnerReturnShardViewModel extends AndroidViewModel
|
|||||||
@UiThread
|
@UiThread
|
||||||
public void startListening() {
|
public void startListening() {
|
||||||
ioExecutor.execute(() -> {
|
ioExecutor.execute(() -> {
|
||||||
task.cancel();
|
|
||||||
// wait until really cancelled
|
|
||||||
task.start(this, getWifiIpv4Address());
|
task.start(this, getWifiIpv4Address());
|
||||||
});
|
});
|
||||||
// KeyAgreementTask oldTask = task;
|
// KeyAgreementTask oldTask = task;
|
||||||
@@ -208,8 +206,12 @@ class OwnerReturnShardViewModel extends AndroidViewModel
|
|||||||
// Use ISO 8859-1 to encode bytes directly as a string
|
// Use ISO 8859-1 to encode bytes directly as a string
|
||||||
String content = new String(payloadBytes, ISO_8859_1);
|
String content = new String(payloadBytes, ISO_8859_1);
|
||||||
qrCodeBitmap = QrCodeUtils.createQrCode(dm, content);
|
qrCodeBitmap = QrCodeUtils.createQrCode(dm, content);
|
||||||
this.state.postValue(state);
|
this.state.postValue(state);
|
||||||
});
|
});
|
||||||
|
} else if (state instanceof SecretOwnerTask.State.Success) {
|
||||||
|
// startClicked.setEvent(true);
|
||||||
|
this.state.postValue(state);
|
||||||
|
// TODO do same for failure
|
||||||
} else {
|
} else {
|
||||||
this.state.postValue(state);
|
this.state.postValue(state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,13 @@ public class SecretOwnerTaskImpl extends ReturnShardTaskImpl
|
|||||||
LOG.info("InetAddress is " + inetAddress);
|
LOG.info("InetAddress is " + inetAddress);
|
||||||
socketAddress = new InetSocketAddress(inetAddress, PORT);
|
socketAddress = new InetSocketAddress(inetAddress, PORT);
|
||||||
|
|
||||||
|
// If we have a socket already open, close it and start fresh
|
||||||
|
if (serverSocket != null) {
|
||||||
|
try {
|
||||||
|
serverSocket.close();
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
// Start listening on socketAddress
|
// Start listening on socketAddress
|
||||||
try {
|
try {
|
||||||
LOG.info("Binding socket");
|
LOG.info("Binding socket");
|
||||||
|
|||||||
Reference in New Issue
Block a user