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