mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
put up NFC button even if turned off, and when it's used offer to turn
it on.
This commit is contained in:
parent
37083c3ea1
commit
03f532374b
3 changed files with 31 additions and 5 deletions
|
@ -2176,4 +2176,8 @@
|
||||||
<string name="dropped_dupe">Invitation ignored: already used</string>
|
<string name="dropped_dupe">Invitation ignored: already used</string>
|
||||||
<string name="cur_menu_markerf">%1$s (yours)</string>
|
<string name="cur_menu_markerf">%1$s (yours)</string>
|
||||||
<string name="board_menu_invite">Invite</string>
|
<string name="board_menu_invite">Invite</string>
|
||||||
|
|
||||||
|
<string name="enable_nfc">NFC is turned off on this device. Use
|
||||||
|
the Android Settings app to turn it on .</string>
|
||||||
|
<string name="button_go_settings">Launch Settings</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -86,6 +86,7 @@ public class BoardActivity extends XWActivity
|
||||||
private static final int DLG_GETDICT = DLG_OKONLY + 13;
|
private static final int DLG_GETDICT = DLG_OKONLY + 13;
|
||||||
private static final int GAME_OVER = DLG_OKONLY + 14;
|
private static final int GAME_OVER = DLG_OKONLY + 14;
|
||||||
private static final int DLG_CONNSTAT = DLG_OKONLY + 15;
|
private static final int DLG_CONNSTAT = DLG_OKONLY + 15;
|
||||||
|
private static final int ENABLE_NFC = DLG_OKONLY + 16;
|
||||||
|
|
||||||
private static final int CHAT_REQUEST = 1;
|
private static final int CHAT_REQUEST = 1;
|
||||||
private static final int BT_INVITE_RESULT = 2;
|
private static final int BT_INVITE_RESULT = 2;
|
||||||
|
@ -512,6 +513,22 @@ public class BoardActivity extends XWActivity
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ENABLE_NFC:
|
||||||
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick( DialogInterface dialog,
|
||||||
|
int item ) {
|
||||||
|
startActivity( new Intent("android.settings"
|
||||||
|
+ ".NFC_SETTINGS" ) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
dialog = new AlertDialog.Builder( this )
|
||||||
|
.setTitle( R.string.info_title )
|
||||||
|
.setMessage( R.string.enable_nfc )
|
||||||
|
.setPositiveButton( R.string.button_cancel, null )
|
||||||
|
.setNegativeButton( R.string.button_go_settings, lstnr )
|
||||||
|
.create();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// just drop it; super.onCreateDialog likely failed
|
// just drop it; super.onCreateDialog likely failed
|
||||||
break;
|
break;
|
||||||
|
@ -918,10 +935,15 @@ public class BoardActivity extends XWActivity
|
||||||
{
|
{
|
||||||
if ( LAUNCH_INVITE_ACTION == id ) {
|
if ( LAUNCH_INVITE_ACTION == id ) {
|
||||||
if ( DlgDelegate.DISMISS_BUTTON != which ) {
|
if ( DlgDelegate.DISMISS_BUTTON != which ) {
|
||||||
|
if ( DlgDelegate.NFC_BTN == which
|
||||||
|
&& !NFCUtils.nfcAvail( this )[1] ) {
|
||||||
|
showDialog( ENABLE_NFC );
|
||||||
|
} else {
|
||||||
GameUtils.launchInviteActivity( this, which,
|
GameUtils.launchInviteActivity( this, which,
|
||||||
m_room, null, m_gi.dictLang,
|
m_room, null, m_gi.dictLang,
|
||||||
m_gi.dictName, m_gi.nPlayers );
|
m_gi.dictName, m_gi.nPlayers );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
} else if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||||
JNICmd cmd = JNICmd.CMD_NONE;
|
JNICmd cmd = JNICmd.CMD_NONE;
|
||||||
switch ( id ) {
|
switch ( id ) {
|
||||||
|
|
|
@ -229,7 +229,7 @@ public class DlgDelegate {
|
||||||
public void showInviteChoicesThen( final int callbackID )
|
public void showInviteChoicesThen( final int callbackID )
|
||||||
{
|
{
|
||||||
if ( Utils.deviceSupportsSMS( m_activity )
|
if ( Utils.deviceSupportsSMS( m_activity )
|
||||||
|| NFCUtils.nfcAvail( m_activity )[1] ) {
|
|| NFCUtils.nfcAvail( m_activity )[0] ) {
|
||||||
DlgState state = new DlgState( INVITE_CHOICES_THEN, callbackID );
|
DlgState state = new DlgState( INVITE_CHOICES_THEN, callbackID );
|
||||||
addState( state );
|
addState( state );
|
||||||
m_activity.showDialog( INVITE_CHOICES_THEN );
|
m_activity.showDialog( INVITE_CHOICES_THEN );
|
||||||
|
@ -415,7 +415,7 @@ public class DlgDelegate {
|
||||||
OnClickListener lstnr = mkCallbackClickListener( state );
|
OnClickListener lstnr = mkCallbackClickListener( state );
|
||||||
|
|
||||||
boolean haveSMS = Utils.deviceSupportsSMS( m_activity );
|
boolean haveSMS = Utils.deviceSupportsSMS( m_activity );
|
||||||
boolean haveNFC = NFCUtils.nfcAvail( m_activity )[1];
|
boolean haveNFC = NFCUtils.nfcAvail( m_activity )[0];
|
||||||
int msgID;
|
int msgID;
|
||||||
if ( haveSMS && haveNFC ) {
|
if ( haveSMS && haveNFC ) {
|
||||||
msgID = R.string.nfc_or_sms_or_email;
|
msgID = R.string.nfc_or_sms_or_email;
|
||||||
|
|
Loading…
Reference in a new issue