use gameID as inviteID for non-NFC invites too

This commit is contained in:
Eric House 2013-11-19 06:37:39 -08:00
parent 0cef5fce50
commit 63ba7d45d3
2 changed files with 15 additions and 7 deletions

View file

@ -940,9 +940,11 @@ public class BoardActivity extends XWActivity
&& !NFCUtils.nfcAvail( this )[1] ) {
showDialog( ENABLE_NFC );
} else {
GameUtils.launchInviteActivity( this, which,
m_room, null, m_gi.dictLang,
m_gi.dictName, m_gi.nPlayers );
String inviteID = GameUtils.formatGameID( m_gi.gameID );
GameUtils.launchInviteActivity( this, which, m_room,
inviteID, m_gi.dictLang,
m_gi.dictName,
m_gi.nPlayers );
}
}
} else if ( AlertDialog.BUTTON_POSITIVE == which ) {

View file

@ -522,9 +522,8 @@ public class GameUtils {
int lang, String dict,
int nPlayers )
{
if ( null == inviteID ) {
inviteID = makeRandomID();
}
Assert.assertNotNull( inviteID );
String msgString;
if ( DlgDelegate.NFC_BTN == chosen ) {
msgString = NetLaunchInfo.makeLaunchJSON( activity, room, inviteID,
@ -870,10 +869,17 @@ public class GameUtils {
activity.startActivity( intent );
}
public static String formatGameID( int gameID )
{
Assert.assertTrue( 0 != gameID );
// substring: Keep it short so fits in SMS better
return String.format( "%X", gameID ).substring( 0, 4 );
}
public static String makeRandomID()
{
int rint = newGameID();
return String.format( "%X", rint ).substring( 0, 4 );
return formatGameID( rint );
}
public static int newGameID()