fix handling of SMS invitations specifying a dictionary that's missing

This commit is contained in:
Eric House 2016-01-14 07:55:49 -08:00
parent 90f7438290
commit 1e50181b12
4 changed files with 23 additions and 30 deletions

View file

@ -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 ) {

View file

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

View file

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

View file

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