X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Forg%2Faverage%2Fnfcauthcr%2FCheck.java;h=36f3b1d8fe17cdb342a25ae85eb90ea56be7f30a;hb=8a70d0c43bdcbcd7d26901cfcb1740a74c1a1199;hp=eaf804d25a25353345e535ab5aeda8672830bae3;hpb=604d2e2d726b0af2d9581bb3161e0de13156caba;p=YkNeoCR.git
diff --git a/src/org/average/nfcauthcr/Check.java b/src/org/average/nfcauthcr/Check.java
index eaf804d..36f3b1d 100644
--- a/src/org/average/nfcauthcr/Check.java
+++ b/src/org/average/nfcauthcr/Check.java
@@ -1,68 +1,60 @@
package org.average.nfcauthcr;
-import android.app.Service;
+import android.app.Activity;
+import android.app.AlertDialog;
import android.app.PendingIntent;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.TagLostException;
import android.nfc.tech.IsoDep;
-import android.os.Binder;
-import android.os.IBinder;
-import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
-import org.average.nfcauthcr.CheckConnector;
import org.average.nfcauthcr.YkNeo;
import org.average.nfcauthcr.CRException;
-public class Check extends Service {
+public class Check extends Activity {
private final String TAG = getClass().getName();
- private final CheckConnector checkConnector = new CheckConnector();
- private SharedPreferences prefs;
- private int startId;
+ private AlertDialog swipeDialog;
private PendingIntent tagIntent;
@Override
- public void onCreate() {
- Log.v(TAG, "Created");
- prefs = PreferenceManager.getDefaultSharedPreferences(this);
- }
+ protected void onResume() {
+ super.onResume();
+ Log.v(TAG, "Starting the work");
- @Override
- public int onStartCommand (Intent intent, int flags, int startId) {
- Log.v(TAG, "Starting service");
- this.startId = startId;
- int slot = prefs.getInt("slot_number", -1);
+ 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);
- } else {
- stopSelf(startId);
}
- return START_NOT_STICKY;
}
@Override
- public IBinder onBind(Intent intent) {
- Log.v(TAG, "Binding");
- checkConnector.setService(this);
- return checkConnector;
- }
+ protected void onPause() {
+ super.onPause();
+ Log.v(TAG, "Finished the work");
- @Override
- public void onDestroy() {
- Log.v(TAG, "Finished the run");
+ if(swipeDialog != null) {
+ swipeDialog.dismiss();
+ swipeDialog = null;
+ }
disableDispatch();
}
- @Override
- protected void onNewIntent(Intent intent) {
+ public void onNewIntent(Intent intent) {
Log.v(TAG, "NFC Intent arrived");
int slot = intent.getIntExtra("slot", -1);
byte[] challenge = intent.getByteArrayExtra("challenge");
@@ -84,6 +76,40 @@ public class Check extends Service {
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();
+ }
+
+/*
+
+
+
+
+
+
+
+
+
+
+
+ android.nfc.tech.IsoDep
+
+
+
+*/
+
private void enableDispatch(int slot) {
Intent intent = getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);