tls-psk: show "Connecting…" view while waiting
This commit is contained in:
@@ -82,6 +82,7 @@ public class KeyTransferInteractor {
|
||||
private static final int CONNECTION_ERROR_LISTEN = 8;
|
||||
|
||||
private static final String QRCODE_URI_FORMAT = "PGP+TRANSFER://%s@%s:%s";
|
||||
private static final int TIMEOUT_CONNECTING = 2500;
|
||||
private static final int TIMEOUT_RECEIVING = 2000;
|
||||
private static final int TIMEOUT_WAITING = 500;
|
||||
private static final int PSK_BYTE_LENGTH = 16;
|
||||
@@ -237,6 +238,8 @@ public class KeyTransferInteractor {
|
||||
}
|
||||
|
||||
private void handleOpenConnection(Socket socket) throws IOException {
|
||||
socket.setSoTimeout(TIMEOUT_CONNECTING);
|
||||
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
OutputStream outputStream = new BufferedOutputStream(socket.getOutputStream());
|
||||
|
||||
|
||||
@@ -273,6 +273,8 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
||||
@Override
|
||||
public void onConnectionErrorConnect() {
|
||||
view.showErrorConnectionFailed();
|
||||
|
||||
resetAndStartListen();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -294,8 +296,10 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
||||
private void connectionStartConnect(String qrCodeContent) {
|
||||
connectionClear();
|
||||
|
||||
view.showEstablishingConnection();
|
||||
|
||||
keyTransferClientInteractor = new KeyTransferInteractor(DELIMITER_START, DELIMITER_END);
|
||||
keyTransferClientInteractor.connectToServer(qrCodeContent, this);
|
||||
keyTransferClientInteractor.connectToServer(qrCodeContent, TransferPresenter.this);
|
||||
}
|
||||
|
||||
private void checkWifiResetAndStartListen() {
|
||||
@@ -368,6 +372,7 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
||||
public interface TransferMvpView {
|
||||
void showNotOnWifi();
|
||||
void showWaitingForConnection();
|
||||
void showEstablishingConnection();
|
||||
void showConnectionEstablished(String hostname);
|
||||
void showReceivingKeys();
|
||||
|
||||
|
||||
@@ -63,9 +63,10 @@ import org.sufficientlysecure.keychain.ui.widget.ConnectionStatusView;
|
||||
@RequiresApi(api = VERSION_CODES.LOLLIPOP)
|
||||
public class TransferFragment extends Fragment implements TransferMvpView {
|
||||
public static final int VIEW_WAITING = 0;
|
||||
public static final int VIEW_CONNECTED = 1;
|
||||
public static final int VIEW_RECEIVING = 2;
|
||||
public static final int VIEW_NO_WIFI = 3;
|
||||
public static final int VIEW_CONNECTING = 1;
|
||||
public static final int VIEW_CONNECTED = 2;
|
||||
public static final int VIEW_RECEIVING = 3;
|
||||
public static final int VIEW_NO_WIFI = 4;
|
||||
|
||||
public static final int REQUEST_CODE_SCAN = 1;
|
||||
public static final int LOADER_ID = 1;
|
||||
@@ -182,6 +183,11 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
||||
vTransferAnimator.setDisplayedChild(VIEW_WAITING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEstablishingConnection() {
|
||||
vTransferAnimator.setDisplayedChild(VIEW_CONNECTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showConnectionEstablished(String hostname) {
|
||||
String statusText = getString(R.string.transfer_status_connected, hostname);
|
||||
|
||||
Reference in New Issue
Block a user