mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
as a DEBUG-only feature, enable "send" of NFC to self to better
duplicate on a single device how real devices are meant to be inviting.
This commit is contained in:
parent
019d9987c7
commit
c2a87c187d
6 changed files with 623 additions and 595 deletions
File diff suppressed because it is too large
Load diff
|
@ -167,6 +167,8 @@
|
||||||
<string name="xlations_locale">Fake locale for translation</string>
|
<string name="xlations_locale">Fake locale for translation</string>
|
||||||
<string name="enable_dupes_summary">Accept invitations more than once</string>
|
<string name="enable_dupes_summary">Accept invitations more than once</string>
|
||||||
<string name="nag_intervals">Reminder intervals (minutes1,minutes2,...)</string>
|
<string name="nag_intervals">Reminder intervals (minutes1,minutes2,...)</string>
|
||||||
|
|
||||||
|
<string name="nfc_to_self">Send via NFC to self?</string>
|
||||||
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
|
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
|
||||||
|
|
||||||
<string-array name="board_sizes">
|
<string-array name="board_sizes">
|
||||||
|
|
|
@ -984,6 +984,9 @@ public class BoardDelegate extends DelegateBase
|
||||||
case LOOKUP_ACTION:
|
case LOOKUP_ACTION:
|
||||||
launchLookup( m_words, m_gi.dictLang );
|
launchLookup( m_words, m_gi.dictLang );
|
||||||
break;
|
break;
|
||||||
|
case NFC_TO_SELF:
|
||||||
|
GamesListDelegate.sendNFCToSelf( m_activity, makeNFCMessage() );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
}
|
}
|
||||||
|
@ -1000,7 +1003,9 @@ public class BoardDelegate extends DelegateBase
|
||||||
if ( action == Action.LAUNCH_INVITE_ACTION ) {
|
if ( action == Action.LAUNCH_INVITE_ACTION ) {
|
||||||
switch( means ) {
|
switch( means ) {
|
||||||
case NFC:
|
case NFC:
|
||||||
if ( ! NFCUtils.nfcAvail( m_activity )[1] ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
|
showConfirmThen( R.string.nfc_to_self, Action.NFC_TO_SELF );
|
||||||
|
} else if ( ! NFCUtils.nfcAvail( m_activity )[1] ) {
|
||||||
showDialog( DlgID.ENABLE_NFC );
|
showDialog( DlgID.ENABLE_NFC );
|
||||||
} else {
|
} else {
|
||||||
showOKOnlyDialog( R.string.nfc_just_tap );
|
showOKOnlyDialog( R.string.nfc_just_tap );
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class DlgDelegate {
|
||||||
VALUES_ACTION,
|
VALUES_ACTION,
|
||||||
SMS_CONFIG_ACTION,
|
SMS_CONFIG_ACTION,
|
||||||
BUTTON_BROWSEALL_ACTION,
|
BUTTON_BROWSEALL_ACTION,
|
||||||
|
NFC_TO_SELF,
|
||||||
|
|
||||||
// Dict Browser
|
// Dict Browser
|
||||||
FINISH_ACTION,
|
FINISH_ACTION,
|
||||||
|
@ -345,7 +346,7 @@ public class DlgDelegate {
|
||||||
public void showInviteChoicesThen( final Action action )
|
public void showInviteChoicesThen( final Action action )
|
||||||
{
|
{
|
||||||
if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity ))
|
if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity ))
|
||||||
|| NFCUtils.nfcAvail( m_activity )[0]
|
|| (BuildConfig.DEBUG || NFCUtils.nfcAvail( m_activity )[0])
|
||||||
|| BTService.BTAvailable() ) {
|
|| BTService.BTAvailable() ) {
|
||||||
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN, action );
|
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN, action );
|
||||||
addState( state );
|
addState( state );
|
||||||
|
@ -571,7 +572,7 @@ public class DlgDelegate {
|
||||||
items.add( getString( R.string.invite_choice_bt ) );
|
items.add( getString( R.string.invite_choice_bt ) );
|
||||||
means.add( DlgClickNotify.InviteMeans.BLUETOOTH );
|
means.add( DlgClickNotify.InviteMeans.BLUETOOTH );
|
||||||
}
|
}
|
||||||
if ( NFCUtils.nfcAvail( m_activity )[0] ) {
|
if ( BuildConfig.DEBUG || NFCUtils.nfcAvail( m_activity )[0] ) {
|
||||||
items.add( getString( R.string.invite_choice_nfc ) );
|
items.add( getString( R.string.invite_choice_nfc ) );
|
||||||
means.add( DlgClickNotify.InviteMeans.NFC );
|
means.add( DlgClickNotify.InviteMeans.NFC );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2163,6 +2163,13 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendNFCToSelf( Context context, String data )
|
||||||
|
{
|
||||||
|
Intent intent = makeSelfIntent( context );
|
||||||
|
NFCUtils.populateIntent( intent, data );
|
||||||
|
context.startActivity( intent );
|
||||||
|
}
|
||||||
|
|
||||||
public static void openGame( Context context, Uri data )
|
public static void openGame( Context context, Uri data )
|
||||||
{
|
{
|
||||||
Intent intent = makeSelfIntent( context );
|
Intent intent = makeSelfIntent( context );
|
||||||
|
|
|
@ -40,6 +40,9 @@ import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class NFCUtils {
|
public class NFCUtils {
|
||||||
|
|
||||||
|
private static final String NFC_TO_SELF_ACTION = "nfc_tsa";
|
||||||
|
private static final String NFC_TO_SELF_DATA = "nfc_data";
|
||||||
|
|
||||||
public interface NFCActor {
|
public interface NFCActor {
|
||||||
String makeNFCMessage();
|
String makeNFCMessage();
|
||||||
}
|
}
|
||||||
|
@ -105,18 +108,27 @@ public class NFCUtils {
|
||||||
{
|
{
|
||||||
String result = null;
|
String result = null;
|
||||||
|
|
||||||
if ( NfcAdapter.ACTION_NDEF_DISCOVERED.equals( intent.getAction() ) ) {
|
String action = intent.getAction();
|
||||||
|
if ( NfcAdapter.ACTION_NDEF_DISCOVERED.equals( action ) ) {
|
||||||
Parcelable[] rawMsgs =
|
Parcelable[] rawMsgs =
|
||||||
intent.getParcelableArrayExtra( NfcAdapter.EXTRA_NDEF_MESSAGES );
|
intent.getParcelableArrayExtra( NfcAdapter.EXTRA_NDEF_MESSAGES );
|
||||||
// only one message sent during the beam
|
// only one message sent during the beam
|
||||||
NdefMessage msg = (NdefMessage)rawMsgs[0];
|
NdefMessage msg = (NdefMessage)rawMsgs[0];
|
||||||
// record 0 contains the MIME type, record 1 is the AAR, if present
|
// record 0 contains the MIME type, record 1 is the AAR, if present
|
||||||
result = new String( msg.getRecords()[0].getPayload() );
|
result = new String( msg.getRecords()[0].getPayload() );
|
||||||
|
} else if ( BuildConfig.DEBUG && NFC_TO_SELF_ACTION.equals( action ) ) {
|
||||||
|
result = intent.getStringExtra( NFC_TO_SELF_DATA );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void populateIntent( Intent intent, String data )
|
||||||
|
{
|
||||||
|
intent.setAction( NFC_TO_SELF_ACTION );
|
||||||
|
intent.putExtra( NFC_TO_SELF_DATA, data );
|
||||||
|
}
|
||||||
|
|
||||||
public static void register( Activity activity, NFCActor actor )
|
public static void register( Activity activity, NFCActor actor )
|
||||||
{
|
{
|
||||||
if ( null != s_safeNFC ) {
|
if ( null != s_safeNFC ) {
|
||||||
|
|
Loading…
Reference in a new issue