From 63ba7d45d3c79a2b89ca3af6e51772a415ff1ae1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 19 Nov 2013 06:37:39 -0800 Subject: [PATCH] use gameID as inviteID for non-NFC invites too --- .../src/org/eehouse/android/xw4/BoardActivity.java | 8 +++++--- .../src/org/eehouse/android/xw4/GameUtils.java | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 572895e40..9069f7d03 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -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 ) { 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 ea157dfd6..b542ca4b9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -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()