tls-psk: add specialized error screen if on bad wifi
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -8,7 +8,7 @@
|
||||
android:id="@+id/transfer_animator"
|
||||
android:inAnimation="@anim/fade_in_delayed"
|
||||
android:outAnimation="@anim/fade_out"
|
||||
custom:initialView="0">
|
||||
custom:initialView="05">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -303,4 +303,56 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/transfer_layout_wifi_error"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="96dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:src="@drawable/ic_wifi_question_96dp"
|
||||
android:tint="@color/md_grey_600"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="8dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/transfer_error_wifi_text"
|
||||
tools:text="Connection failed!"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="8dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:id="@+id/transfer_wifi_error_instructions"
|
||||
android:text="@string/transfer_error_wifi_text_instructions"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/button_scan_again"
|
||||
android:text="@string/button_scan_again"
|
||||
android:drawableLeft="@drawable/ic_qrcode_white_24dp"
|
||||
android:drawableTint="@color/md_black_1000"
|
||||
android:drawablePadding="8dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
||||
@@ -1912,5 +1912,9 @@
|
||||
<string name="transfer_confirm_ok">"Send"</string>
|
||||
<string name="transfer_confirm_title">"Send your key?"</string>
|
||||
<string name="transfer_confirm_text">"This will transfer full access to your key to the connected device. You should never send your own keys to devices you don't own!"</string>
|
||||
<string name="button_scan_again">"Scan Again"</string>
|
||||
<string name="transfer_error_wifi_text">"Connection failed!"</string>
|
||||
<string name="transfer_error_wifi_text_instructions">"Make sure you are on the same network, then scan again."</string>
|
||||
<string name="transfer_error_wifi_text_instructions_ssid">"Make sure you are on the "%s" network, then scan again."</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user