mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
fix handling of SMS invitations specifying a dictionary that's missing
This commit is contained in:
parent
90f7438290
commit
1e50181b12
4 changed files with 23 additions and 30 deletions
|
@ -1986,7 +1986,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
{
|
{
|
||||||
NetLaunchInfo nli = null;
|
NetLaunchInfo nli = null;
|
||||||
if ( MultiService.isMissingDictIntent( intent ) ) {
|
if ( MultiService.isMissingDictIntent( intent ) ) {
|
||||||
nli = new NetLaunchInfo( m_activity, intent );
|
nli = MultiService.getMissingDictData( m_activity, intent );
|
||||||
} else {
|
} else {
|
||||||
Uri data = intent.getData();
|
Uri data = intent.getData();
|
||||||
if ( null != data ) {
|
if ( null != data ) {
|
||||||
|
|
|
@ -26,6 +26,8 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class MultiService {
|
public class MultiService {
|
||||||
|
@ -43,7 +45,7 @@ public class MultiService {
|
||||||
public static final String OWNER = "OWNER";
|
public static final String OWNER = "OWNER";
|
||||||
public static final String BT_NAME = "BT_NAME";
|
public static final String BT_NAME = "BT_NAME";
|
||||||
public static final String BT_ADDRESS = "BT_ADDRESS";
|
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,
|
public enum DictFetchOwner { _NONE,
|
||||||
OWNER_SMS,
|
OWNER_SMS,
|
||||||
|
@ -128,6 +130,15 @@ public class MultiService {
|
||||||
return result;
|
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,
|
public static Dialog missingDictDialog( Context context, Intent intent,
|
||||||
OnClickListener onDownload,
|
OnClickListener onDownload,
|
||||||
OnClickListener onDecline )
|
OnClickListener onDecline )
|
||||||
|
|
|
@ -88,13 +88,6 @@ public class NetLaunchInfo {
|
||||||
init( context, data );
|
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 )
|
private NetLaunchInfo( Bundle bundle )
|
||||||
{
|
{
|
||||||
lang = bundle.getInt( MultiService.LANG );
|
lang = bundle.getInt( MultiService.LANG );
|
||||||
|
|
|
@ -56,6 +56,7 @@ import java.util.Set;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.GameUtils.BackMoveResult;
|
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.MultiService.MultiEvent;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||||
|
@ -348,20 +349,15 @@ public class SMSService extends XWService {
|
||||||
inviteRemote( phone, intent.getStringExtra( GAMEDATA_STR ) );
|
inviteRemote( phone, intent.getStringExtra( GAMEDATA_STR ) );
|
||||||
break;
|
break;
|
||||||
case ADDED_MISSING:
|
case ADDED_MISSING:
|
||||||
|
NetLaunchInfo nli
|
||||||
|
= MultiService.getMissingDictData( this, intent );
|
||||||
phone = intent.getStringExtra( PHONE );
|
phone = intent.getStringExtra( PHONE );
|
||||||
int gameID = intent.getIntExtra( MultiService.GAMEID, -1 );
|
makeForInvite( phone, nli );
|
||||||
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 );
|
|
||||||
break;
|
break;
|
||||||
case SEND:
|
case SEND:
|
||||||
phone = intent.getStringExtra( PHONE );
|
phone = intent.getStringExtra( PHONE );
|
||||||
byte[] bytes = intent.getByteArrayExtra( BINBUFFER );
|
byte[] bytes = intent.getByteArrayExtra( BINBUFFER );
|
||||||
gameID = intent.getIntExtra( MultiService.GAMEID, -1 );
|
int gameID = intent.getIntExtra( MultiService.GAMEID, -1 );
|
||||||
sendPacket( phone, gameID, bytes );
|
sendPacket( phone, gameID, bytes );
|
||||||
break;
|
break;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
|
@ -512,18 +508,11 @@ public class SMSService extends XWService {
|
||||||
if ( DictLangCache.haveDict( this, nli.lang, nli.dict ) ) {
|
if ( DictLangCache.haveDict( this, nli.lang, nli.dict ) ) {
|
||||||
makeForInvite( phone, nli );
|
makeForInvite( phone, nli );
|
||||||
} else {
|
} else {
|
||||||
Assert.fail();
|
Intent intent = MultiService
|
||||||
// Intent intent = MultiService
|
.makeMissingDictIntent( this, nli,
|
||||||
// .makeMissingDictIntent( this, gameName, lang, dict,
|
DictFetchOwner.OWNER_SMS );
|
||||||
// nPlayersT, nPlayersH );
|
MultiService.postMissingDictNotification( this, intent,
|
||||||
// intent.putExtra( PHONE, phone );
|
nli.gameID() );
|
||||||
// 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 );
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DbgUtils.logf( "invalid nli from: %s", nliData );
|
DbgUtils.logf( "invalid nli from: %s", nliData );
|
||||||
|
|
Loading…
Reference in a new issue