X-Git-Url: http://www.average.org/gitweb/?p=YkNeoCR.git;a=blobdiff_plain;f=src%2Forg%2Faverage%2Fnfcauthcr%2FEnroll.java;h=12533e7bf8c469fb9bd719696d5215fa898b3826;hp=9f9d53593da811965c43d9c4ef4167826f35da07;hb=9194bb54ed7bfd3ccb2ee93151fb3b1467cdae35;hpb=a0d60dab1717e69b6d853eb91d0065fe378e3c28 diff --git a/src/org/average/nfcauthcr/Enroll.java b/src/org/average/nfcauthcr/Enroll.java index 9f9d535..12533e7 100644 --- a/src/org/average/nfcauthcr/Enroll.java +++ b/src/org/average/nfcauthcr/Enroll.java @@ -15,7 +15,7 @@ import android.view.View; import android.widget.TextView; import android.widget.RadioButton; -import org.average.nfcauthcr.Check; +import org.average.nfcauthcr.TagEvent; public class Enroll extends Activity { @@ -24,6 +24,7 @@ public class Enroll extends Activity { private static boolean waitingForResult = false; private static SharedPreferences prefs; private static int slot; + private AlertDialog swipeDialog; @Override protected void onCreate(Bundle savedInstanceState) @@ -80,7 +81,7 @@ public class Enroll extends Activity { if (slot > 0) { runEnrollment(slot); } else { - showEnrollResult("Must specify which slot to use"); + showEnrollResult(R.string.need_slot); } } @@ -88,6 +89,10 @@ public class Enroll extends Activity { Intent intent) { Log.v(TAG, "Got activity result"); waitingForResult = false; + if(swipeDialog != null) { + swipeDialog.dismiss(); + swipeDialog = null; + } if (resultCode != RESULT_OK) { Log.v(TAG, "Error result code " + resultCode); @@ -101,15 +106,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) { @@ -126,12 +130,27 @@ public class Enroll extends Activity { byte[] challenge = new byte[63]; rng.nextBytes(challenge); Log.v(TAG, "Random challenge: " + hex(challenge)); - Log.v(TAG, "Launching challenging activity"); - Intent crIntent = new Intent(this, NFCAuthCRCheck.class); + Intent crIntent = new Intent(this, TagEvent.class); crIntent.putExtra("slot", slot); crIntent.putExtra("challenge", challenge); this.startActivityForResult(crIntent, 0); waitingForResult = true; + if (swipeDialog != null) swipeDialog.dismiss(); + swipeDialog = makeDialog(); + swipeDialog.show(); + } + + private AlertDialog makeDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.challenging); + builder.setMessage(R.string.swipe); + builder.setOnCancelListener( + new DialogInterface.OnCancelListener() { + public void onCancel(DialogInterface dialog) { + Log.v(TAG, "unbind service FIXME"); + } + }); + return builder.create(); } private String hex(byte[] a) {