mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Pass String instead of the TextView
This commit is contained in:
@@ -2,7 +2,6 @@ package org.briarproject.briar.android.keyagreement;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactExchangeListener;
|
||||
@@ -115,31 +114,31 @@ public class ContactExchangeActivity extends KeyAgreementActivity implements
|
||||
|
||||
@UiThread
|
||||
@Override
|
||||
public void keyAgreementWaiting(TextView status) {
|
||||
status.setText(R.string.waiting_for_contact_to_scan);
|
||||
public String keyAgreementWaiting() {
|
||||
return getString(R.string.waiting_for_contact_to_scan);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@Override
|
||||
public void keyAgreementStarted(TextView status) {
|
||||
status.setText(R.string.authenticating_with_device);
|
||||
public String keyAgreementStarted() {
|
||||
return getString(R.string.authenticating_with_device);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@Override
|
||||
public void keyAgreementAborted(boolean remoteAborted) {
|
||||
public String keyAgreementAborted(boolean remoteAborted) {
|
||||
// TODO show abort somewhere persistent?
|
||||
Toast.makeText(this,
|
||||
remoteAborted ? R.string.connection_aborted_remote :
|
||||
R.string.connection_aborted_local, LENGTH_LONG)
|
||||
.show();
|
||||
return null;
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@Override
|
||||
public void keyAgreementFinished(TextView status,
|
||||
KeyAgreementResult result) {
|
||||
status.setText(R.string.exchanging_contact_details);
|
||||
public String keyAgreementFinished(KeyAgreementResult result) {
|
||||
startContactExchange(result);
|
||||
return getString(string.exchanging_contact_details);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.briarproject.bramble.api.keyagreement.event.KeyAgreementStartedEvent;
|
||||
import org.briarproject.bramble.api.keyagreement.event.KeyAgreementWaitingEvent;
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||
@@ -90,7 +91,8 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
private KeyAgreementTask task;
|
||||
private KeyAgreementEventListener listener;
|
||||
|
||||
public static KeyAgreementFragment newInstance(KeyAgreementEventListener listener) {
|
||||
public static KeyAgreementFragment newInstance(
|
||||
KeyAgreementEventListener listener) {
|
||||
Bundle args = new Bundle();
|
||||
KeyAgreementFragment fragment = new KeyAgreementFragment();
|
||||
fragment.listener = listener;
|
||||
@@ -281,14 +283,14 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
|
||||
private void keyAgreementWaiting() {
|
||||
runOnUiThreadUnlessDestroyed(
|
||||
() -> listener.keyAgreementWaiting(status));
|
||||
() -> status.setText(listener.keyAgreementWaiting()));
|
||||
}
|
||||
|
||||
private void keyAgreementStarted() {
|
||||
runOnUiThreadUnlessDestroyed(() -> {
|
||||
qrCodeView.setVisibility(INVISIBLE);
|
||||
statusView.setVisibility(VISIBLE);
|
||||
listener.keyAgreementStarted(status);
|
||||
status.setText(listener.keyAgreementStarted());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -297,15 +299,14 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
reset();
|
||||
qrCodeView.setVisibility(VISIBLE);
|
||||
statusView.setVisibility(INVISIBLE);
|
||||
status.setText("");
|
||||
listener.keyAgreementAborted(remoteAborted);
|
||||
status.setText(listener.keyAgreementAborted(remoteAborted));
|
||||
});
|
||||
}
|
||||
|
||||
private void keyAgreementFinished(KeyAgreementResult result) {
|
||||
runOnUiThreadUnlessDestroyed(() -> {
|
||||
statusView.setVisibility(VISIBLE);
|
||||
listener.keyAgreementFinished(status, result);
|
||||
status.setText(listener.keyAgreementFinished(result));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -341,21 +342,30 @@ public class KeyAgreementFragment extends BaseEventFragment
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
|
||||
@NotNullByDefault
|
||||
interface KeyAgreementEventListener {
|
||||
|
||||
@UiThread
|
||||
void keyAgreementFailed();
|
||||
|
||||
// Should return a string to be displayed as status.
|
||||
@UiThread
|
||||
void keyAgreementWaiting(TextView status);
|
||||
@Nullable
|
||||
String keyAgreementWaiting();
|
||||
|
||||
// Should return a string to be displayed as status.
|
||||
@UiThread
|
||||
void keyAgreementStarted(TextView status);
|
||||
@Nullable
|
||||
String keyAgreementStarted();
|
||||
|
||||
// Should return a string to be displayed as status.
|
||||
@UiThread
|
||||
void keyAgreementAborted(boolean remoteAborted);
|
||||
@Nullable
|
||||
String keyAgreementAborted(boolean remoteAborted);
|
||||
|
||||
// Should return a string to be displayed as status.
|
||||
@UiThread
|
||||
void keyAgreementFinished(TextView status, KeyAgreementResult result);
|
||||
@Nullable
|
||||
String keyAgreementFinished(KeyAgreementResult result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user