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.util.KeyFormattingUtils;
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.util.Iso7816TLV;
import org.sufficientlysecure.keychain.util.Log;
@ -68,14 +67,18 @@ public abstract class BaseNfcActivity extends BaseActivity {
try {
handleNdefDiscoveredIntent(intent);
} catch (IOException e) {
Log.e(Constants.TAG, "Connection error!", e);
toast("Connection Error: " + e.getMessage());
setResult(RESULT_CANCELED);
finish();
handleNfcError(e);
}
}
}
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,
* disables NFC Foreground Dispatch

View File

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