cleanup workflow
authorEugene Crosser <crosser@average.org>
Fri, 3 May 2013 10:31:06 +0000 (14:31 +0400)
committerEugene Crosser <crosser@average.org>
Fri, 3 May 2013 10:31:06 +0000 (14:31 +0400)
res/values/strings.xml
src/org/average/nfcauthcr/Check.java
src/org/average/nfcauthcr/Enroll.java
src/org/average/nfcauthcr/YkNeo.java

index b13405eded132bab4e7d944554afe7e724fc9cf3..aadb0f439587139504b70d83cbe228a18de50f9f 100644 (file)
@@ -5,9 +5,11 @@
        <string name="select_slot">Select Slot</string>
        <string name="slot_1">Slot 1</string>
        <string name="slot_2">Slot 2</string>
+       <string name="need_slot">You must select which slot to use</string>
        <string name="enrollresult">Enrollment result:</string>
+       <string name="enroll_success">Token successfully bound to the device</string>
        <string name="challenging">Ready to send challenge</string>
-       <string name="swipe">Please touch the token with the phone</string>
+       <string name="swipe">Please touch the back of the phone with the NFC token to enroll it</string>
        <string name="no_nfc">Cannot reach the NFC adapter</string>
        <string name="nfc_disabled">Need to enable NFC in Settings</string>
        <string name="tag_lost">Communitation with the tag lost</string>
index 1fc5ceaf00f36d497b5cae113390f2361d4d7bf6..f65ae1ba034536692c5ba0be8c216e329bac146f 100644 (file)
@@ -101,13 +101,11 @@ public class Check extends Activity {
                        Toast.makeText(this, R.string.no_nfc,
                                                Toast.LENGTH_LONG).show();
                        finish();
-                       return;
                }
                if (! adapter.isEnabled()) {
                        Toast.makeText(this, R.string.nfc_disabled,
                                                Toast.LENGTH_LONG).show();
                        finish();
-                       return;
                }
                adapter.enableForegroundDispatch(
                        this, tagIntent, new IntentFilter[] {iso},
index 5b125fa490a3d4cb01527eb2a48a576530ba3171..190c08ff921c190b65754e5d3b01eb4ae9f5c331 100644 (file)
@@ -80,7 +80,7 @@ public class Enroll extends Activity {
                if (slot > 0) {
                        runEnrollment(slot);
                } else {
-                       showEnrollResult("Must specify which slot to use");
+                       showEnrollResult(R.string.need_slot);
                }
        }
 
@@ -101,15 +101,14 @@ public class Enroll extends Activity {
                editor.putString("challenge", hex(challenge));
                editor.putString("response", hex(response));
                editor.commit();
+               showEnrollResult(R.string.enroll_success);
                Log.v(TAG, "stored new challenge and response");
        }
 
-       private void showEnrollResult(final String msg) {
-               Log.v(TAG, "Show result: \"" + msg + "\"");
-
+       private void showEnrollResult(int messageid) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(R.string.enrollresult);
-               builder.setMessage(msg);
+               builder.setMessage(messageid);
                builder.setPositiveButton(android.R.string.ok,
                                new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
index 1537459ba7e7c6ef4513370a844fc8b234194e07..26a685350657228170874dc39dc24042e47cc21a 100644 (file)
@@ -54,6 +54,10 @@ public class YkNeo {
                                throw new CRException(
                                "NFC Error code in the response to CR");
                        }
+                       if (length != 22) {
+                               throw new CRException(
+                               "NFC wrong response size: " + (length-2));
+                       }
                        return Arrays.copyOf(resp, length-2);
                } catch (TagLostException e) {
                        throw new CRException("NFC connection lost", e);