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);

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

View File

@ -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>

View File

@ -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 &quot;%s&quot; network, then scan again."</string>
</resources>

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
fill="#000000"
height="24"
viewBox="0 0 24 24"
width="24"
version="1.1"
id="svg6"
sodipodi:docname="ic_wifi_question.svg"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview8"
showgrid="false"
inkscape:measure-start="15.5,6.9"
inkscape:measure-end="21.5,14.4"
inkscape:zoom="39.333333"
inkscape:cx="12.121876"
inkscape:cy="9.0333709"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="svg6" />
<path
d="M0 0h24v24H0V0z"
fill="none"
id="path2" />
<path
d="m 15.5,14.5 c 0,-2.8 2.2,-5 5,-5 0.4,0 0.7,0 1,0.1 L 23.6,7 C 23.2,6.7 18.7,3 12,3 5.3,3 0.8,6.7 0.4,7 L 12,21.5 15.5,17.1 Z"
id="path4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ssccscccs" />
<g
style="fill:none;fill-rule:evenodd;stroke:none;stroke-width:1"
id="Page-1"
sketch:type="MSPage"
transform="matrix(0.14184741,0,0,0.14184741,13.309409,9.1313496)">
<g
style="fill:#000000"
id="signature-unverified"
sketch:type="MSArtboardGroup">
<path
inkscape:connector-curvature="0"
d="M 56.359,80.095 H 42.883 V 66.877 H 56.359 Z M 70.222,40.709 c -0.717,1.773 -1.602,3.289 -2.66,4.547 -1.061,1.259 -2.232,2.332 -3.52,3.218 -1.287,0.888 -2.504,1.772 -3.648,2.659 -1.145,0.889 -2.16,1.903 -3.047,3.047 -0.889,1.145 -1.445,2.573 -1.674,4.289 v 3.26 H 44.086 v -3.861 c 0.172,-2.457 0.643,-4.518 1.416,-6.176 0.771,-1.658 1.674,-3.075 2.703,-4.248 1.031,-1.172 2.117,-2.188 3.261,-3.046 1.145,-0.856 2.203,-1.716 3.176,-2.573 0.973,-0.858 1.76,-1.801 2.361,-2.831 0.601,-1.03 0.871,-2.316 0.814,-3.86 0,-2.631 -0.643,-4.576 -1.93,-5.836 -1.289,-1.256 -3.078,-1.887 -5.365,-1.887 -1.545,0 -2.875,0.301 -3.992,0.901 -1.115,0.601 -2.031,1.401 -2.746,2.402 -0.717,1.001 -1.244,2.174 -1.588,3.517 -0.344,1.346 -0.516,2.79 -0.516,4.334 H 29.065 c 0.055,-3.09 0.586,-5.921 1.588,-8.494 1,-2.574 2.402,-4.805 4.205,-6.691 1.803,-1.889 3.977,-3.361 6.523,-4.422 2.547,-1.059 5.395,-1.588 8.541,-1.588 4.062,0 7.453,0.559 10.171,1.674 2.717,1.116 4.906,2.504 6.566,4.164 1.66,1.659 2.846,3.446 3.562,5.362 0.715,1.917 1.072,3.703 1.072,5.362 0.002,2.745 -0.356,5.006 -1.071,6.777 z"
sketch:type="MSShapeGroup"
id="path8"
sodipodi:nodetypes="ccccccccccccccccccsccsccccccccsccccc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -32,7 +32,7 @@ inkscape -w 72 -h 72 -e "$XXDPI_DIR/${NAME}_24dp.png" "$SRC_DIR/$NAME.svg"
inkscape -w 96 -h 96 -e "$XXXDPI_DIR/${NAME}_24dp.png" "$SRC_DIR/$NAME.svg"
done
for NAME in "ic_android" "ic_wifi_off" "status_signature_expired_cutout" "status_signature_invalid_cutout" "status_signature_revoked_cutout" "status_signature_unknown_cutout" "status_signature_unverified_cutout" "status_signature_verified_cutout" "status_signature_verified_inner"
for NAME in "ic_android" "ic_wifi_question" "ic_wifi_off" "status_signature_expired_cutout" "status_signature_invalid_cutout" "status_signature_revoked_cutout" "status_signature_unknown_cutout" "status_signature_unverified_cutout" "status_signature_verified_cutout" "status_signature_verified_inner"
do
echo $NAME
inkscape -w 96 -h 96 -e "$MDPI_DIR/${NAME}_96dp.png" "$SRC_DIR/$NAME.svg"