mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
Merge branch 'android_invite' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_invite
This commit is contained in:
commit
35bfdb1dd6
7 changed files with 42 additions and 13 deletions
|
@ -562,6 +562,11 @@
|
|||
<string name="invite_msgf">This game is missing %1$d remote
|
||||
player[s]. Would you like to invite someone to join -- assuming
|
||||
you haven\'t already?</string>
|
||||
|
||||
<string name="invite_multiple">\u0020(You are expecting multiple
|
||||
remote players. Be sure to address your invitation to
|
||||
that many people.)</string>
|
||||
|
||||
<string name="invite_subject">Let\'s play Crosswords</string>
|
||||
<string name="invite_bodyf">Tap on this link to start a game:
|
||||
%1$s .</string>
|
||||
|
|
|
@ -270,7 +270,8 @@ public class BoardActivity extends XWActivity
|
|||
int item ) {
|
||||
GameUtils.launchInviteActivity( BoardActivity.this,
|
||||
m_room,
|
||||
m_gi.dictLang );
|
||||
m_gi.dictLang,
|
||||
m_gi.nPlayers );
|
||||
}
|
||||
};
|
||||
dialog = new AlertDialog.Builder( this )
|
||||
|
@ -296,7 +297,11 @@ public class BoardActivity extends XWActivity
|
|||
case DLG_INVITE:
|
||||
AlertDialog ad = (AlertDialog)dialog;
|
||||
String format = getString( R.string.invite_msgf );
|
||||
ad.setMessage( String.format( format, m_missing) );
|
||||
String message = String.format( format, m_missing );
|
||||
if ( m_missing > 1 ) {
|
||||
message += getString( R.string.invite_multiple );
|
||||
}
|
||||
ad.setMessage( message );
|
||||
break;
|
||||
default:
|
||||
super.onPrepareDialog( id, dialog );
|
||||
|
@ -706,7 +711,7 @@ public class BoardActivity extends XWActivity
|
|||
|
||||
// Let's only invite for two-person games for now. Simple
|
||||
// case first....
|
||||
if ( nMissing == 1 /* && is_2_person_game() */ && !m_haveInvited ) {
|
||||
if ( !m_haveInvited ) {
|
||||
m_haveInvited = true;
|
||||
m_room = room;
|
||||
m_missing = nMissing;
|
||||
|
|
|
@ -356,7 +356,8 @@ public class GameUtils {
|
|||
}
|
||||
|
||||
public static String makeNewNetGame( Context context, String room,
|
||||
int[] lang, int nPlayers )
|
||||
int[] lang, int nPlayersT,
|
||||
int nPlayersH )
|
||||
{
|
||||
CommsAddrRec addr = new CommsAddrRec( context );
|
||||
addr.ip_relay_invite = room;
|
||||
|
@ -364,10 +365,11 @@ public class GameUtils {
|
|||
CurGameInfo gi = new CurGameInfo( context, true );
|
||||
gi.setLang( lang[0] );
|
||||
lang[0] = gi.dictLang;
|
||||
gi.setNPlayers( nPlayersT, nPlayersH );
|
||||
gi.juggle();
|
||||
// Will need to add a setNPlayers() method to gi to make this
|
||||
// work
|
||||
Assert.assertTrue( gi.nPlayers == nPlayers );
|
||||
Assert.assertTrue( gi.nPlayers == nPlayersT );
|
||||
String path = saveNew( context, gi );
|
||||
|
||||
GameLock lock = new GameLock( path, true ).lock();
|
||||
|
@ -381,20 +383,21 @@ public class GameUtils {
|
|||
int lang, int nPlayers )
|
||||
{
|
||||
int[] langarr = { lang };
|
||||
return makeNewNetGame( context, room, langarr, nPlayers );
|
||||
return makeNewNetGame( context, room, langarr, nPlayers, 1 );
|
||||
}
|
||||
|
||||
public static String makeNewNetGame( Context context, NetLaunchInfo info )
|
||||
{
|
||||
return makeNewNetGame( context, info.room, info.lang, info.nPlayers );
|
||||
return makeNewNetGame( context, info.room, info.lang,
|
||||
info.nPlayers );
|
||||
}
|
||||
|
||||
public static void launchInviteActivity( Context context, String room,
|
||||
int lang )
|
||||
int lang, int nPlayers )
|
||||
{
|
||||
Random random = new Random();
|
||||
Uri gameUri = NetLaunchInfo.makeLaunchUri( context, room,
|
||||
lang, 2 );
|
||||
lang, nPlayers );
|
||||
|
||||
if ( null != gameUri ) {
|
||||
Intent intent = new Intent( Intent.ACTION_SEND );
|
||||
|
|
|
@ -57,7 +57,8 @@ public class NetLaunchInfo {
|
|||
room = data.getQueryParameter( "room" );
|
||||
String langStr = data.getQueryParameter( "lang" );
|
||||
lang = Integer.decode( langStr );
|
||||
nPlayers = 2; // Should this be a param?
|
||||
String np = data.getQueryParameter( "np" );
|
||||
nPlayers = Integer.decode( np );
|
||||
m_valid = true;
|
||||
} catch ( Exception e ) {
|
||||
Utils.logf( "unable to parse \"%s\"", data.toString() );
|
||||
|
|
|
@ -91,11 +91,12 @@ public class NewGameActivity extends XWActivity {
|
|||
String room = null;
|
||||
String path;
|
||||
int[] lang = {0};
|
||||
final int nPlayers = 2; // hard-coded for no-configure case
|
||||
|
||||
if ( networked ) {
|
||||
Random random = new Random();
|
||||
room = String.format( "%X", random.nextInt() ).substring( 0, 4 );
|
||||
path = GameUtils.makeNewNetGame( this, room, lang, 2 );
|
||||
path = GameUtils.makeNewNetGame( this, room, lang, nPlayers, 1 );
|
||||
} else {
|
||||
path = GameUtils.saveNew( this, new CurGameInfo( this ) );
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ public class NewGameActivity extends XWActivity {
|
|||
if ( launch ) {
|
||||
GameUtils.launchGame( this, path, networked );
|
||||
if ( networked ) {
|
||||
GameUtils.launchInviteActivity( this, room, lang[0] );
|
||||
GameUtils.launchInviteActivity( this, room, lang[0], nPlayers );
|
||||
}
|
||||
} else {
|
||||
GameUtils.doConfig( this, path, GameConfig.class );
|
||||
|
|
|
@ -310,6 +310,19 @@ public class CurGameInfo {
|
|||
return added;
|
||||
}
|
||||
|
||||
public void setNPlayers( int nPlayersTotal, int nPlayersHere )
|
||||
{
|
||||
assert( nPlayersTotal < MAX_NUM_PLAYERS );
|
||||
assert( nPlayersHere < nPlayersTotal );
|
||||
|
||||
nPlayers = nPlayersTotal;
|
||||
|
||||
for ( int ii = 0; ii < nPlayersTotal; ++ii ) {
|
||||
players[ii].isLocal = ii < nPlayersHere;
|
||||
assert( !players[ii].isRobot() );
|
||||
}
|
||||
}
|
||||
|
||||
public void setFirstLocalName( String name ) {
|
||||
for ( int ii = 0; ii < nPlayers; ++ii ) {
|
||||
if ( players[ii].isLocal ) {
|
||||
|
|
|
@ -8,6 +8,7 @@ $scheme = "newxwgame";
|
|||
$host = "10.0.2.2";
|
||||
$lang = $_REQUEST["lang"];
|
||||
$room = $_REQUEST["room"];
|
||||
$np = $_REQUEST["np"];
|
||||
|
||||
print <<<EOF
|
||||
|
||||
|
@ -16,7 +17,7 @@ print <<<EOF
|
|||
<head>
|
||||
<title>Crosswords SMS redirect</title>
|
||||
<meta http-equiv="REFRESH"
|
||||
content="0;url=$scheme://$host?room=$room&lang=$lang">
|
||||
content="0;url=$scheme://$host?room=$room&lang=$lang&np=$np">
|
||||
</head>
|
||||
<body>
|
||||
<p>redirecting to Crosswords....</p>
|
||||
|
|
Loading…
Reference in a new issue