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