From: Eugene Crosser Date: Sat, 4 May 2013 07:08:11 +0000 (+0400) Subject: move swipeDialog to activity X-Git-Url: http://www.average.org/gitweb/?p=YkNeoCR.git;a=commitdiff_plain;h=bb4b51c880cf9a1942151bf1dd8977e3a8e0ccf6 move swipeDialog to activity --- diff --git a/src/org/average/nfcauthcr/Check.java b/src/org/average/nfcauthcr/Check.java index 36f3b1d..6b6ec4f 100644 --- a/src/org/average/nfcauthcr/Check.java +++ b/src/org/average/nfcauthcr/Check.java @@ -20,7 +20,6 @@ public class Check extends Activity { private final String TAG = getClass().getName(); - private AlertDialog swipeDialog; private PendingIntent tagIntent; @Override @@ -30,14 +29,8 @@ public class Check extends Activity { Intent intent = getIntent(); setResult(RESULT_CANCELED); - if (swipeDialog != null) { - swipeDialog.dismiss(); - swipeDialog = null; - } int slot = intent.getIntExtra("slot", -1); if (slot > 0) { - swipeDialog = makeDialog(); - swipeDialog.show(); enableDispatch(slot); } } @@ -47,10 +40,6 @@ public class Check extends Activity { super.onPause(); Log.v(TAG, "Finished the work"); - if(swipeDialog != null) { - swipeDialog.dismiss(); - swipeDialog = null; - } disableDispatch(); } @@ -76,19 +65,6 @@ public class Check extends Activity { finish(); } - 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) { - finish(); - } - }); - return builder.create(); - } - /* diff --git a/src/org/average/nfcauthcr/Enroll.java b/src/org/average/nfcauthcr/Enroll.java index 190c08f..8d90488 100644 --- a/src/org/average/nfcauthcr/Enroll.java +++ b/src/org/average/nfcauthcr/Enroll.java @@ -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) @@ -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); @@ -125,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, Check.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) {