fix so when BT invite is tapped for game requiring a missing wordlist,

an offer's made to download and only then is game created.
This commit is contained in:
Eric House 2014-09-15 07:41:26 -07:00
parent 77192bf3bd
commit aeeb3dc3bc
3 changed files with 27 additions and 4 deletions

View file

@ -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 );
}
}

View file

@ -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,

View file

@ -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<Long> 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 );