mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Update state in UI for Custodian
This commit is contained in:
@@ -64,7 +64,9 @@ public class CustodianReturnShardActivity extends BriarActivity
|
||||
}
|
||||
|
||||
private void onReturnShardStateChanged(CustodianTask.State state) {
|
||||
if (state instanceof CustodianTask.State.Success) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void showCameraFragment() {
|
||||
|
||||
@@ -141,7 +141,17 @@ public class CustodianReturnShardFragment extends BaseFragment
|
||||
|
||||
@UiThread
|
||||
private void onReturnShardStateChanged(@Nullable CustodianTask.State state) {
|
||||
if (state instanceof CustodianTask.State.Connecting) {
|
||||
LOG.info("State changed");
|
||||
// if (state instanceof CustodianTask.State.Connecting) {
|
||||
// try {
|
||||
// cameraView.stop();
|
||||
// } catch (CameraException e) {
|
||||
// logCameraExceptionAndFinish(e);
|
||||
// }
|
||||
// cameraView.setVisibility(INVISIBLE);
|
||||
// statusView.setVisibility(VISIBLE);
|
||||
// status.setText(R.string.connecting_to_device);
|
||||
if (state instanceof CustodianTask.State.SendingShard) {
|
||||
try {
|
||||
cameraView.stop();
|
||||
} catch (CameraException e) {
|
||||
@@ -149,8 +159,6 @@ public class CustodianReturnShardFragment extends BaseFragment
|
||||
}
|
||||
cameraView.setVisibility(INVISIBLE);
|
||||
statusView.setVisibility(VISIBLE);
|
||||
status.setText(R.string.connecting_to_device);
|
||||
} else if (state instanceof CustodianTask.State.SendingShard) {
|
||||
status.setText("Sending shard");
|
||||
} else if (state instanceof CustodianTask.State.ReceivingAck) {
|
||||
status.setText("Receiving Ack");
|
||||
|
||||
@@ -45,6 +45,7 @@ public class CustodianReturnShardViewModel extends AndroidViewModel
|
||||
private final AndroidExecutor androidExecutor;
|
||||
private final Executor ioExecutor;
|
||||
private boolean wasContinueClicked = false;
|
||||
private boolean qrCodeRead = false;
|
||||
private final MutableLiveEvent<Boolean> showCameraFragment =
|
||||
new MutableLiveEvent<>();
|
||||
private final MutableLiveData<CustodianTask.State> state =
|
||||
@@ -74,18 +75,21 @@ public class CustodianReturnShardViewModel extends AndroidViewModel
|
||||
@Override
|
||||
public void onQrCodeDecoded(Result result) {
|
||||
LOG.info("Got result from decoder");
|
||||
// Ignore results until the KeyAgreementTask is ready
|
||||
// if (!gotLocalPayload || gotRemotePayload) return;
|
||||
if (qrCodeRead) return;
|
||||
try {
|
||||
byte[] payloadBytes = result.getText().getBytes(ISO_8859_1);
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Remote payload is " + payloadBytes.length + " bytes");
|
||||
task.qrCodeDecoded(payloadBytes);
|
||||
ioExecutor.execute(() -> {
|
||||
task.qrCodeDecoded(payloadBytes);
|
||||
});
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOG.log(WARNING, "QR Code Invalid", e);
|
||||
androidExecutor.runOnUiThread(() -> Toast.makeText(getApplication(),
|
||||
R.string.qr_code_invalid, LENGTH_LONG).show());
|
||||
task.qrCodeDecoded(null);
|
||||
ioExecutor.execute(() -> {
|
||||
task.qrCodeDecoded(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,9 +114,10 @@ public class CustodianReturnShardViewModel extends AndroidViewModel
|
||||
|
||||
@Override
|
||||
public void onStateChanged(CustodianTask.State state) {
|
||||
this.state.postValue(state);
|
||||
// Connecting, SendingShard, ReceivingAck, Success, Failure
|
||||
if (state instanceof CustodianTask.State.SendingShard) {
|
||||
|
||||
qrCodeRead = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,9 @@ class OwnerReturnShardViewModel extends AndroidViewModel implements SecretOwnerT
|
||||
|
||||
@UiThread
|
||||
private void startListening() {
|
||||
task.start(this, getWifiIpv4Address());
|
||||
ioExecutor.execute(() -> {
|
||||
task.start(this, getWifiIpv4Address());
|
||||
});
|
||||
// KeyAgreementTask oldTask = task;
|
||||
// KeyAgreementTask newTask = keyAgreementTaskProvider.get();
|
||||
// task = newTask;
|
||||
|
||||
Reference in New Issue
Block a user