Commit d6e45bc9 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

NFC dialog update

Avoid multiple dialogs
parent 7e2aae79
...@@ -53,8 +53,6 @@ public abstract class NFCActivity extends Activity { ...@@ -53,8 +53,6 @@ public abstract class NFCActivity extends Activity {
AlertDialog alertDialog = alertDialogBuilder.create(); AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show(); alertDialog.show();
} }
else if (!NFCAdapter.isEnabled())
enableNFCDialog();
} }
protected abstract void onIdentification(final String idBadge); protected abstract void onIdentification(final String idBadge);
...@@ -111,15 +109,15 @@ public abstract class NFCActivity extends Activity { ...@@ -111,15 +109,15 @@ public abstract class NFCActivity extends Activity {
private final BroadcastReceiver NFCReceiver = new BroadcastReceiver() { private final BroadcastReceiver NFCReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
final String action = intent.getAction(); final String action = intent.getAction();
if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) { if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) {
final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF); final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF);
//if (state == NfcAdapter.STATE_OFF || state == NfcAdapter.STATE_TURNING_OFF) //if (state == NfcAdapter.STATE_OFF || state == NfcAdapter.STATE_TURNING_OFF)
if (state == NfcAdapter.STATE_OFF) if (state == NfcAdapter.STATE_OFF)
enableNFCDialog(); enableNFCDialog();
} }
} }
}; };
...@@ -127,33 +125,33 @@ public abstract class NFCActivity extends Activity { ...@@ -127,33 +125,33 @@ public abstract class NFCActivity extends Activity {
Toast.makeText(this, R.string.nfc_not_enabled, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.nfc_not_enabled, Toast.LENGTH_SHORT).show();
alertDialogBuilder alertDialogBuilder
.setTitle(R.string.nfc_not_enabled) .setTitle(R.string.nfc_not_enabled)
.setMessage(R.string.nfc_accessibility) .setMessage(R.string.nfc_accessibility)
.setCancelable(true) .setCancelable(true)
.setPositiveButton(R.string.pass, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.pass, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.cancel(); dialog.cancel();
} }
}) })
.setNeutralButton(R.string.activate, new DialogInterface.OnClickListener() { .setNeutralButton(R.string.activate, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS)); startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
dialog.cancel(); dialog.cancel();
} }
}) })
.setNegativeButton(R.string.quit, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.quit, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.cancel(); dialog.cancel();
finish(); finish();
} }
}) })
.setOnDismissListener(new DialogInterface.OnDismissListener() { .setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override @Override
public void onDismiss(final DialogInterface dialog) { public void onDismiss(final DialogInterface dialog) {
if (!NFCAdapter.isEnabled()) if (!NFCAdapter.isEnabled())
enableNFCDialog(); enableNFCDialog();
} }
}); });
AlertDialog alertDialog = alertDialogBuilder.create(); AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show(); alertDialog.show();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment