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 6006a3bf5..02540821d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -1986,7 +1986,7 @@ public class GamesListDelegate extends ListDelegateBase { NetLaunchInfo nli = null; if ( MultiService.isMissingDictIntent( intent ) ) { - nli = new NetLaunchInfo( m_activity, intent ); + nli = MultiService.getMissingDictData( m_activity, intent ); } else { Uri data = intent.getData(); if ( null != data ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java index a6c382e9a..cba0d60cf 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java @@ -26,6 +26,8 @@ import android.content.Context; import android.content.Intent; import android.content.DialogInterface.OnClickListener; +import junit.framework.Assert; + import org.eehouse.android.xw4.loc.LocUtils; public class MultiService { @@ -43,7 +45,7 @@ public class MultiService { public static final String OWNER = "OWNER"; public static final String BT_NAME = "BT_NAME"; public static final String BT_ADDRESS = "BT_ADDRESS"; - public static final String NLI_DATA = "nli"; + private static final String NLI_DATA = "nli"; public enum DictFetchOwner { _NONE, OWNER_SMS, @@ -128,6 +130,15 @@ public class MultiService { return result; } + public static NetLaunchInfo getMissingDictData( Context context, + Intent intent ) + { + Assert.assertTrue( isMissingDictIntent( intent ) ); + String nliData = intent.getStringExtra( NLI_DATA ); + NetLaunchInfo nli = new NetLaunchInfo( context, nliData ); + return nli; + } + public static Dialog missingDictDialog( Context context, Intent intent, OnClickListener onDownload, OnClickListener onDecline ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java index 2d77d38bd..17540d7b1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java @@ -88,13 +88,6 @@ public class NetLaunchInfo { init( context, data ); } - public NetLaunchInfo( Context context, Intent intent ) - { - String data = intent.getStringExtra( MultiService.NLI_DATA ); - Assert.assertNotNull( data ); - init( context, data ); - } - private NetLaunchInfo( Bundle bundle ) { lang = bundle.getInt( MultiService.LANG ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index ce38b3c19..21855ea1d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -56,6 +56,7 @@ import java.util.Set; import junit.framework.Assert; import org.eehouse.android.xw4.GameUtils.BackMoveResult; +import org.eehouse.android.xw4.MultiService.DictFetchOwner; import org.eehouse.android.xw4.MultiService.MultiEvent; import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; import org.eehouse.android.xw4.jni.CommsAddrRec; @@ -348,20 +349,15 @@ public class SMSService extends XWService { inviteRemote( phone, intent.getStringExtra( GAMEDATA_STR ) ); break; case ADDED_MISSING: + NetLaunchInfo nli + = MultiService.getMissingDictData( this, intent ); phone = intent.getStringExtra( PHONE ); - int gameID = intent.getIntExtra( MultiService.GAMEID, -1 ); - String gameName = intent.getStringExtra( MultiService.GAMENAME ); - int lang = intent.getIntExtra( MultiService.LANG, -1 ); - String dict = intent.getStringExtra( MultiService.DICT ); - int nPlayersT = intent.getIntExtra( MultiService.NPLAYERST, -1 ); - int nPlayersH = intent.getIntExtra( MultiService.NPLAYERSH, -1 ); - makeForInvite( phone, gameID, gameName, lang, dict, - nPlayersT, nPlayersH, 1 ); + makeForInvite( phone, nli ); break; case SEND: phone = intent.getStringExtra( PHONE ); byte[] bytes = intent.getByteArrayExtra( BINBUFFER ); - gameID = intent.getIntExtra( MultiService.GAMEID, -1 ); + int gameID = intent.getIntExtra( MultiService.GAMEID, -1 ); sendPacket( phone, gameID, bytes ); break; case REMOVE: @@ -512,18 +508,11 @@ public class SMSService extends XWService { if ( DictLangCache.haveDict( this, nli.lang, nli.dict ) ) { makeForInvite( phone, nli ); } else { - Assert.fail(); - // Intent intent = MultiService - // .makeMissingDictIntent( this, gameName, lang, dict, - // nPlayersT, nPlayersH ); - // intent.putExtra( PHONE, phone ); - // intent.putExtra( MultiService.OWNER, - // MultiService.OWNER_SMS ); - // intent.putExtra( MultiService.INVITER, - // Utils.phoneToContact( this, phone, true ) ); - // intent.putExtra( MultiService.GAMEID, gameID ); - // MultiService.postMissingDictNotification( this, intent, - // gameID ); + Intent intent = MultiService + .makeMissingDictIntent( this, nli, + DictFetchOwner.OWNER_SMS ); + MultiService.postMissingDictNotification( this, intent, + nli.gameID() ); } } else { DbgUtils.logf( "invalid nli from: %s", nliData );