nicer handling of nfc errors

This commit is contained in:
Vincent Breitmoser 2015-03-23 01:09:39 +01:00
parent 5227b45af8
commit 3bb194fc08
2 changed files with 9 additions and 5 deletions

View File

@ -28,7 +28,6 @@ import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
import org.sufficientlysecure.keychain.ui.ViewKeyActivity; import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.util.Iso7816TLV; import org.sufficientlysecure.keychain.util.Iso7816TLV;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
@ -68,14 +67,18 @@ public abstract class BaseNfcActivity extends BaseActivity {
try { try {
handleNdefDiscoveredIntent(intent); handleNdefDiscoveredIntent(intent);
} catch (IOException e) { } catch (IOException e) {
Log.e(Constants.TAG, "Connection error!", e); handleNfcError(e);
toast("Connection Error: " + e.getMessage());
setResult(RESULT_CANCELED);
finish();
} }
} }
} }
public void handleNfcError(IOException e) {
Log.e(Constants.TAG, "nfc error", e);
Notify.create(this, getString(R.string.error_nfc, e.getMessage()), Style.WARN).show();
}
/** /**
* Called when the system is about to start resuming a previous activity, * Called when the system is about to start resuming a previous activity,
* disables NFC Foreground Dispatch * disables NFC Foreground Dispatch

View File

@ -1278,5 +1278,6 @@
<string name="yubikey_status_partly">"Yubikey matches, partly bound to key"</string> <string name="yubikey_status_partly">"Yubikey matches, partly bound to key"</string>
<string name="btn_import">"Import"</string> <string name="btn_import">"Import"</string>
<string name="snack_yubi_other">Different key stored on Yubikey!</string> <string name="snack_yubi_other">Different key stored on Yubikey!</string>
<string name="error_nfc">"NFC Error: %s"</string>
</resources> </resources>