1 package org.average.nfcauthcr;
3 import android.os.Bundle;
4 import android.app.Activity;
5 import android.app.AlertDialog;
6 import android.preference.PreferenceManager;
7 import android.content.SharedPreferences;
8 import android.content.SharedPreferences.Editor;
9 import android.content.DialogInterface;
10 import android.util.Log;
11 import android.view.View;
12 import android.widget.TextView;
13 import android.widget.RadioButton;
15 public class NFCAuthCREnroll extends Activity
17 private final String TAG = getClass().getName();
19 private static boolean waitingForResult = false;
20 private static SharedPreferences prefs;
21 private static int slot;
24 protected void onCreate(Bundle savedInstanceState)
26 super.onCreate(savedInstanceState);
27 Log.v(TAG, "Starting");
28 prefs = PreferenceManager.getDefaultSharedPreferences(this);
32 protected void onResume() {
34 setContentView(R.layout.main);
35 slot = prefs.getInt("slot_number", -1);
36 Log.v(TAG, "found saved slot value " + slot);
37 RadioButton btn = null;
39 case 1: btn = (RadioButton)findViewById(R.id.slot_1);
41 case 2: btn = (RadioButton)findViewById(R.id.slot_2);
44 if (btn != null) btn.setChecked(true);
48 protected void onPause() {
50 Log.v(TAG, "Going inactive, try to stop");
51 if (!waitingForResult) { finish(); }
55 protected void onStop() {
57 Log.v(TAG, "Stop requested");
60 public void onSlotSelectionClicked(View view) {
61 Log.v(TAG, "Radio Button selected");
62 if (! ((RadioButton) view).isChecked()) return;
63 switch(view.getId()) {
64 case R.id.slot_1: slot=1; break;
65 case R.id.slot_2: slot=2; break;
67 Editor editor = prefs.edit();
68 editor.putInt("slot_number", slot);
70 Log.v(TAG, "stored slot number " + slot);
73 public void onEnrollClicked(View view) {
74 Log.v(TAG, "Enroll clicked");
76 showEnrollResult("<FIXME> using slot" + slot);
78 showEnrollResult("Must specify which slot to use");
82 private void showEnrollResult(final String msg) {
83 Log.v(TAG, "Show result: \"" + msg + "\"");
85 AlertDialog.Builder builder = new AlertDialog.Builder(this);
86 builder.setTitle(R.string.enrollresult);
87 builder.setMessage(msg);
88 builder.setPositiveButton(android.R.string.ok,
89 new DialogInterface.OnClickListener() {
90 public void onClick(DialogInterface dialog, int which) {
92 if (!waitingForResult) { finish(); }
95 AlertDialog dialog = builder.create();