tls-psk: add specialized error screen if on bad wifi

This commit is contained in:
Vincent Breitmoser
2017-06-28 23:59:29 +02:00
parent 9a37fabb45
commit ba5a1a1969
10 changed files with 180 additions and 4 deletions

View File

@@ -134,6 +134,10 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
view.scanQrCode();
}
public void onUiClickScanAgain() {
onUiClickScan();
}
public void onUiClickDone() {
view.finishFragmentOrActivity();
}
@@ -296,6 +300,7 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
@Override
public void onConnectionErrorConnect() {
view.showWaitingForConnection();
view.showErrorConnectionFailed();
resetAndStartListen();
@@ -303,9 +308,17 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
@Override
public void onConnectionErrorNoRouteToHost(String wifiSsid) {
view.showErrorConnectionFailed();
connectionClear();
resetAndStartListen();
String ownWifiSsid = getConnectedWifiSsid();
if (!wifiSsid.equalsIgnoreCase(ownWifiSsid)) {
view.showWifiError(wifiSsid);
} else {
view.showWaitingForConnection();
view.showErrorConnectionFailed();
resetAndStartListen();
}
}
@Override
@@ -440,6 +453,9 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
void showWaitingForConnection();
void showEstablishingConnection();
void showConnectionEstablished(String hostname);
void showWifiError(String wifiSsid);
void showReceivingKeys();
void showViewDisconnected();

View File

@@ -42,6 +42,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -102,6 +103,7 @@ public class TransferFragment extends Fragment implements TransferMvpView {
};
private boolean showDoneIcon;
private AlertDialog confirmationDialog;
private TextView vWifiErrorInstructions;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -116,6 +118,7 @@ public class TransferFragment extends Fragment implements TransferMvpView {
vTransferKeyList = (RecyclerView) view.findViewById(R.id.transfer_key_list);
vTransferKeyListEmptyView = view.findViewById(R.id.transfer_key_list_empty);
vReceivedKeyList = (RecyclerView) view.findViewById(R.id.received_key_list);
vWifiErrorInstructions = (TextView) view.findViewById(R.id.transfer_wifi_error_instructions);
vQrCodeImage = (ImageView) view.findViewById(R.id.qr_code_image);
@@ -128,6 +131,15 @@ public class TransferFragment extends Fragment implements TransferMvpView {
}
});
view.findViewById(R.id.button_scan_again).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (presenter != null) {
presenter.onUiClickScanAgain();
}
}
});
presenter = new TransferPresenter(getContext(), getLoaderManager(), LOADER_ID, this);
setHasOptionsMenu(true);
@@ -223,6 +235,18 @@ public class TransferFragment extends Fragment implements TransferMvpView {
vTransferAnimator.setDisplayedChildId(R.id.transfer_layout_connected);
}
@Override
public void showWifiError(String wifiSsid) {
vTransferAnimator.setDisplayedChildId(R.id.transfer_layout_wifi_error);
if (!TextUtils.isEmpty(wifiSsid)) {
vWifiErrorInstructions
.setText(getResources().getString(R.string.transfer_error_wifi_text_instructions_ssid, wifiSsid));
} else {
vWifiErrorInstructions.setText(R.string.transfer_error_wifi_text_instructions);
}
}
@Override
public void showReceivingKeys() {
vTransferAnimator.setDisplayedChildId(R.id.transfer_layout_passive);