Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hds
flexin
android-app
Commits
d6e45bc9
Commit
d6e45bc9
authored
Oct 26, 2017
by
Nastuzzi Samy
Browse files
NFC dialog update
Avoid multiple dialogs
parent
7e2aae79
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fr/utc/simde/payutc/tools/NFCActivity.java
View file @
d6e45bc9
...
...
@@ -53,8 +53,6 @@ public abstract class NFCActivity extends Activity {
AlertDialog
alertDialog
=
alertDialogBuilder
.
create
();
alertDialog
.
show
();
}
else
if
(!
NFCAdapter
.
isEnabled
())
enableNFCDialog
();
}
protected
abstract
void
onIdentification
(
final
String
idBadge
);
...
...
@@ -111,15 +109,15 @@ public abstract class NFCActivity extends Activity {
private
final
BroadcastReceiver
NFCReceiver
=
new
BroadcastReceiver
()
{
@Override
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
))
{
final
int
state
=
intent
.
getIntExtra
(
NfcAdapter
.
EXTRA_ADAPTER_STATE
,
NfcAdapter
.
STATE_OFF
);
if
(
action
.
equals
(
NfcAdapter
.
ACTION_ADAPTER_STATE_CHANGED
))
{
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
)
enableNFCDialog
();
}
//if (state == NfcAdapter.STATE_OFF || state == NfcAdapter.STATE_TURNING_OFF)
if
(
state
==
NfcAdapter
.
STATE_OFF
)
enableNFCDialog
();
}
}
};
...
...
@@ -127,33 +125,33 @@ public abstract class NFCActivity extends Activity {
Toast
.
makeText
(
this
,
R
.
string
.
nfc_not_enabled
,
Toast
.
LENGTH_SHORT
).
show
();
alertDialogBuilder
.
setTitle
(
R
.
string
.
nfc_not_enabled
)
.
setMessage
(
R
.
string
.
nfc_accessibility
)
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
pass
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
dialog
.
cancel
();
}
})
.
setNeutralButton
(
R
.
string
.
activate
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
startActivity
(
new
Intent
(
android
.
provider
.
Settings
.
ACTION_WIRELESS_SETTINGS
));
dialog
.
cancel
();
}
})
.
setNegativeButton
(
R
.
string
.
quit
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
dialog
.
cancel
();
finish
();
}
})
.
setOnDismissListener
(
new
DialogInterface
.
OnDismissListener
()
{
@Override
public
void
onDismiss
(
final
DialogInterface
dialog
)
{
if
(!
NFCAdapter
.
isEnabled
())
enableNFCDialog
();
}
});
.
setTitle
(
R
.
string
.
nfc_not_enabled
)
.
setMessage
(
R
.
string
.
nfc_accessibility
)
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
pass
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
dialog
.
cancel
();
}
})
.
setNeutralButton
(
R
.
string
.
activate
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
startActivity
(
new
Intent
(
android
.
provider
.
Settings
.
ACTION_WIRELESS_SETTINGS
));
dialog
.
cancel
();
}
})
.
setNegativeButton
(
R
.
string
.
quit
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
dialog
.
cancel
();
finish
();
}
})
.
setOnDismissListener
(
new
DialogInterface
.
OnDismissListener
()
{
@Override
public
void
onDismiss
(
final
DialogInterface
dialog
)
{
if
(!
NFCAdapter
.
isEnabled
())
enableNFCDialog
();
}
});
AlertDialog
alertDialog
=
alertDialogBuilder
.
create
();
alertDialog
.
show
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment