diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTLaunchInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTLaunchInfo.java index ab6eb3781..82cc448c1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTLaunchInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTLaunchInfo.java @@ -25,6 +25,7 @@ import org.json.JSONObject; import org.json.JSONException; import android.content.Context; +import org.eehouse.android.xw4.jni.CommsAddrRec; public class BTLaunchInfo extends AbsLaunchInfo { private static final String INVITE_GAMEID = "INVITE_GAMEID"; @@ -70,4 +71,9 @@ public class BTLaunchInfo extends AbsLaunchInfo { } return result; } + + public CommsAddrRec getAddrRec() + { + return new CommsAddrRec( btName, btAddress ); + } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 56c51c53a..a8d44ade1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -553,6 +553,13 @@ public class GameUtils { lang, dict, nPlayersT, nPlayersH ); } + public static long makeNewBTGame( Context context, BTLaunchInfo bli ) + { + return makeNewBTGame( context, null, DBUtils.GROUPID_UNSPEC, bli.gameID, + bli.getAddrRec(), bli.lang, bli.dict, + bli.nPlayersT, 1 ); + } + public static long makeNewBTGame( Context context, MultiMsgSink sink, long groupID, int gameID, CommsAddrRec addr, int lang, String dict, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index bba4b9714..c88f77dae 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -514,7 +514,7 @@ public class GamesListDelegate extends ListDelegateBase private long[] m_rowids; private long m_groupid; private String m_nameField; - private NetLaunchInfo m_netLaunchInfo; + private AbsLaunchInfo m_netLaunchInfo; private GameNamer m_namer; private Set m_launchedGames; private boolean m_menuPrepared; @@ -1391,7 +1391,7 @@ public class GamesListDelegate extends ListDelegateBase } } - private boolean checkWarnNoDict( NetLaunchInfo nli ) + private boolean checkWarnNoDict( AbsLaunchInfo nli ) { // check that we have the dict required boolean haveDict; @@ -1600,7 +1600,7 @@ public class GamesListDelegate extends ListDelegateBase break; } BTLaunchInfo bli = new BTLaunchInfo( data ); - if ( bli.isValid() ) { + if ( bli.isValid() && checkWarnNoDict( bli ) ) { BTService.gotGameViaNFC( m_activity, bli ); break; } @@ -1660,7 +1660,11 @@ public class GamesListDelegate extends ListDelegateBase { boolean madeGame = null != m_netLaunchInfo; if ( madeGame ) { - makeNewNetGame( m_netLaunchInfo ); + if ( m_netLaunchInfo instanceof NetLaunchInfo ) { + makeNewNetGame( (NetLaunchInfo)m_netLaunchInfo ); + } else if ( m_netLaunchInfo instanceof BTLaunchInfo ) { + makeNewBTGame( (BTLaunchInfo)m_netLaunchInfo ); + } m_netLaunchInfo = null; } return madeGame; @@ -1748,6 +1752,12 @@ public class GamesListDelegate extends ListDelegateBase launchGame( rowid, true ); } + private void makeNewBTGame( BTLaunchInfo nli ) + { + long rowid = GameUtils.makeNewBTGame( m_activity, nli ); + launchGame( rowid, true ); + } + private void tryStartsFromIntent( Intent intent ) { startFirstHasDict( intent );