show in game list item if invitations pending

This commit is contained in:
Eric House 2016-01-09 06:58:18 -08:00
parent e60945733f
commit 73a7a8836f
6 changed files with 704 additions and 683 deletions

File diff suppressed because it is too large Load diff

View file

@ -59,6 +59,8 @@
<!-- Final state: game is over. -->
<string name="summary_relay_gameover_fmt">Game over in room \"%1$s\"</string>
<string name="summary_invites_out">Players invited</string>
<!-- Games that have ended are listed with this string -->
<string name="gameOver">Game over</string>
<!-- Otherwise they're listed with this to give some indication of

View file

@ -52,6 +52,7 @@
<string name="summary_relay_conn_fmt">Emag ni yalp ni moor \"%1$s\"</string>
<!-- Final state: game is over. -->
<string name="summary_relay_gameover_fmt">Emag revo ni moor \"%1$s\"</string>
<string name="summary_invites_out">Sreyalp detivni</string>
<!-- Games that have ended are listed with this string -->
<string name="gameOver">Emag revo</string>
<!-- Otherwise they're listed with this to give some indication of

View file

@ -52,6 +52,7 @@
<string name="summary_relay_conn_fmt">GAME IN PLAY IN ROOM \"%1$s\"</string>
<!-- Final state: game is over. -->
<string name="summary_relay_gameover_fmt">GAME OVER IN ROOM \"%1$s\"</string>
<string name="summary_invites_out">PLAYERS INVITED</string>
<!-- Games that have ended are listed with this string -->
<string name="gameOver">GAME OVER</string>
<!-- Otherwise they're listed with this to give some indication of

View file

@ -320,7 +320,7 @@ public class GameListItem extends LinearLayout
}
} );
String roleSummary = summary.summarizeRole();
String roleSummary = summary.summarizeRole( m_rowid );
if ( null != roleSummary ) {
m_role.setText( roleSummary );
} else {

View file

@ -27,6 +27,7 @@ import java.util.Iterator;
import junit.framework.Assert;
import org.json.JSONObject;
import org.eehouse.android.xw4.DBUtils;
import org.eehouse.android.xw4.DbgUtils;
import org.eehouse.android.xw4.R;
import org.eehouse.android.xw4.Utils;
@ -196,15 +197,26 @@ public class GameSummary {
// FIXME: should report based on whatever conType is giving us a
// successful connection.
public String summarizeRole()
public String summarizeRole( long rowid )
{
String result = null;
if ( isMultiGame() ) {
int fmtID = 0;
int missing = countMissing();
if ( 0 < missing ) {
DBUtils.SentInvitesInfo si = DBUtils.getInvitesFor( m_context,
rowid );
if ( si.getPlayerCount() >= missing ) {
result = LocUtils.getString( m_context,
R.string.summary_invites_out );
}
}
// If we're using relay to connect, get status from that
if ( conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
if ( anyMissing() ) {
if ( null == result
&& conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
if ( 0 < missing ) {
if ( null == relayID || 0 == relayID.length() ) {
fmtID = R.string.summary_relay_conf_fmt;
} else {
@ -222,7 +234,7 @@ public class GameSummary {
if ( null == result ) {
if ( conTypes.contains( CommsConnType.COMMS_CONN_BT )
|| ( conTypes.contains( CommsConnType.COMMS_CONN_SMS))){
if ( anyMissing() ) {
if ( 0 < missing ) {
if ( DeviceRole.SERVER_ISSERVER == serverRole ) {
fmtID = R.string.summary_wait_host;
} else {
@ -277,16 +289,20 @@ public class GameSummary {
return result;
}
public boolean anyMissing()
private int countMissing()
{
boolean missing = false;
int result = 0;
for ( int ii = 0; ii < nPlayers; ++ii ) {
if ( !isLocal(ii) && (0 != ((1 << ii) & missingPlayers) ) ) {
missing = true;
break;
++result;
}
}
return missing;
return result;
}
public boolean anyMissing()
{
return 0 < countMissing();
}
public int giflags() {