]> www.average.org Git - YkNeoCR.git/commitdiff
move swipeDialog to activity
authorEugene Crosser <crosser@average.org>
Sat, 4 May 2013 07:08:11 +0000 (11:08 +0400)
committerEugene Crosser <crosser@average.org>
Sat, 4 May 2013 07:08:11 +0000 (11:08 +0400)
src/org/average/nfcauthcr/Check.java
src/org/average/nfcauthcr/Enroll.java

index 36f3b1d8fe17cdb342a25ae85eb90ea56be7f30a..6b6ec4f568f79e043ea47cef0888432bb38257b4 100644 (file)
@@ -20,7 +20,6 @@ public class Check extends Activity {
 
        private final String TAG = getClass().getName();
 
 
        private final String TAG = getClass().getName();
 
-       private AlertDialog swipeDialog;
        private PendingIntent tagIntent;
 
        @Override
        private PendingIntent tagIntent;
 
        @Override
@@ -30,14 +29,8 @@ public class Check extends Activity {
 
                Intent intent = getIntent();
                setResult(RESULT_CANCELED);
 
                Intent intent = getIntent();
                setResult(RESULT_CANCELED);
-               if (swipeDialog != null) {
-                       swipeDialog.dismiss();
-                       swipeDialog = null;
-               }
                int slot = intent.getIntExtra("slot", -1);
                if (slot > 0) {
                int slot = intent.getIntExtra("slot", -1);
                if (slot > 0) {
-                       swipeDialog = makeDialog();
-                       swipeDialog.show();
                        enableDispatch(slot);
                }
        }
                        enableDispatch(slot);
                }
        }
@@ -47,10 +40,6 @@ public class Check extends Activity {
                super.onPause();
                Log.v(TAG, "Finished the work");
 
                super.onPause();
                Log.v(TAG, "Finished the work");
 
-               if(swipeDialog != null) {
-                       swipeDialog.dismiss();
-                       swipeDialog = null;
-               }
                disableDispatch();
        }
 
                disableDispatch();
        }
 
@@ -76,19 +65,6 @@ public class Check extends Activity {
                finish();
        }
 
                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();
-       }
-
 /*
 <receiver android:name=".IsoDepReceiver"
           android:label="IsoDepReceiver">
 /*
 <receiver android:name=".IsoDepReceiver"
           android:label="IsoDepReceiver">
index 190c08ff921c190b65754e5d3b01eb4ae9f5c331..8d90488dbc41e34e665aea4e9c84a76b71b93211 100644 (file)
@@ -24,6 +24,7 @@ public class Enroll extends Activity {
        private static boolean waitingForResult = false;
        private static SharedPreferences prefs;
        private static int slot;
        private static boolean waitingForResult = false;
        private static SharedPreferences prefs;
        private static int slot;
+       private AlertDialog swipeDialog;
 
        @Override
        protected void onCreate(Bundle savedInstanceState)
 
        @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;
                                        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);
 
                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));
                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;
                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) {
        }
 
        private String hex(byte[] a) {