mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
When relay-configured game is opened that hasn't yet managed to
connect to relay, instead of suggesting user invite another player warn him/her that it's unconnected and suggest opening again later. The problem this addresses is that a game must be opened to make the initial relay connection, and that doesn't happen in the background. This is a temporary fix that should prevent sending invitations to games that the relay doesn't yet know about.
This commit is contained in:
parent
766a814019
commit
d0d81483e3
9 changed files with 68 additions and 23 deletions
|
@ -1927,6 +1927,7 @@ public final class R {
|
|||
substituted.
|
||||
*/
|
||||
public static final int no_name_found_fmt=0x7f0500b8;
|
||||
public static final int no_relay_conn=0x7f0502fb;
|
||||
/** This is not currently shown
|
||||
<string name="not_again_dicts">Crosswords wordlists, which are
|
||||
just compressed lists of words plus tile information, determine
|
||||
|
|
|
@ -2462,4 +2462,10 @@
|
|||
<string name="checking_title">Checking</string>
|
||||
<string name="checking_for_fmt">Checking for wordlists in %1$s…</string>
|
||||
<string name="db_store_done">SD card write complete.</string>
|
||||
|
||||
<string name="no_relay_conn">This game is configured to use the
|
||||
relay for communication but has been unable to connect, either
|
||||
because of problems with your device\'s internet connection or
|
||||
because the relay is not running.\n\nPlease try opening the game again
|
||||
later.</string>
|
||||
</resources>
|
||||
|
|
|
@ -2132,4 +2132,9 @@
|
|||
<string name="checking_title">Gnikcehc</string>
|
||||
<string name="checking_for_fmt">Gnikcehc rof stsildrow ni %1$s…</string>
|
||||
<string name="db_store_done">DS drac etirw etelpmoc.</string>
|
||||
<string name="no_relay_conn">Siht emag si derugifnoc ot esu eht
|
||||
yaler rof noitacinummoc tub sah neeb elbanu ot ,tcennoc rehtie
|
||||
esuaceb fo smelborp htiw ruoy ecived\'s tenretni noitcennoc ro
|
||||
esuaceb eht yaler si ton gninnur.\n\nEsaelp yrt gninepo eht emag niaga
|
||||
retal.</string>
|
||||
</resources>
|
||||
|
|
|
@ -2132,4 +2132,9 @@
|
|||
<string name="checking_title">CHECKING</string>
|
||||
<string name="checking_for_fmt">CHECKING FOR WORDLISTS IN %1$s…</string>
|
||||
<string name="db_store_done">SD CARD WRITE COMPLETE.</string>
|
||||
<string name="no_relay_conn">THIS GAME IS CONFIGURED TO USE THE
|
||||
RELAY FOR COMMUNICATION BUT HAS BEEN UNABLE TO CONNECT, EITHER
|
||||
BECAUSE OF PROBLEMS WITH YOUR DEVICE\'S INTERNET CONNECTION OR
|
||||
BECAUSE THE RELAY IS NOT RUNNING.\n\nPLEASE TRY OPENING THE GAME AGAIN
|
||||
LATER.</string>
|
||||
</resources>
|
||||
|
|
|
@ -3444,4 +3444,10 @@ pour la langue</string>
|
|||
<!-- <string name="db_store_done">SD card write complete.</string> -->
|
||||
<string name="db_store_done">Écriture sur la carte SD finie.</string>
|
||||
|
||||
<string name="no_relay_conn">Cette partie est configurée pour
|
||||
communiquer en utilisant le relai mais n\'a pas pu se connecter, soit
|
||||
à cause de problèmes avec la connexion Internet de votre périphérique,
|
||||
soit parce que le relai est hors service.\n\n Veuillez réessayer
|
||||
d\'ouvrir la partie ultérieurement.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -89,6 +89,7 @@ public class BoardDelegate extends DelegateBase
|
|||
private GameLock m_gameLock;
|
||||
private CurGameInfo m_gi;
|
||||
private GameSummary m_summary;
|
||||
private boolean m_relayConnected;
|
||||
private CommsTransport m_xport;
|
||||
private Handler m_handler = null;
|
||||
private TimerRunnable[] m_timers;
|
||||
|
@ -431,6 +432,8 @@ public class BoardDelegate extends DelegateBase
|
|||
.setNegativeButton( R.string.button_no, null )
|
||||
.create();
|
||||
break;
|
||||
case DLG_NOINVITE:
|
||||
Assert.assertFalse( m_relayConnected );
|
||||
case DLG_INVITE:
|
||||
lstnr = new OnClickListener() {
|
||||
public void onClick( DialogInterface dialog,
|
||||
|
@ -472,15 +475,18 @@ public class BoardDelegate extends DelegateBase
|
|||
protected void prepareDialog( DlgID dlgID, Dialog dialog )
|
||||
{
|
||||
switch( dlgID ) {
|
||||
case DLG_INVITE: // here
|
||||
case DLG_INVITE:
|
||||
case DLG_NOINVITE:
|
||||
AlertDialog ad = (AlertDialog)dialog;
|
||||
String message;
|
||||
int titleID;
|
||||
boolean rematch = m_summary.hasRematchInfo();
|
||||
if ( rematch ) {
|
||||
titleID = R.string.info_title;
|
||||
int titleID = R.string.info_title;;
|
||||
boolean nukeButton = false;
|
||||
if ( m_summary.hasRematchInfo() ) {
|
||||
message = getString( R.string.rematch_msg );
|
||||
ad.getButton( AlertDialog.BUTTON_POSITIVE ).setVisibility( View.GONE );
|
||||
nukeButton = true;
|
||||
} else if ( DlgID.DLG_NOINVITE == dlgID ) {
|
||||
message = getString( R.string.no_relay_conn );
|
||||
nukeButton = true;
|
||||
} else {
|
||||
titleID = R.string.waiting_title;
|
||||
message = getQuantityString( R.plurals.invite_msg_fmt, m_nMissing, m_nMissing );
|
||||
|
@ -500,6 +506,9 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
message += "\n\n" + getString( R.string.invite_stays );
|
||||
}
|
||||
if ( nukeButton ) {
|
||||
ad.getButton( AlertDialog.BUTTON_POSITIVE ).setVisibility( View.GONE );
|
||||
}
|
||||
ad.setMessage( message );
|
||||
ad.setTitle( titleID );
|
||||
break;
|
||||
|
@ -649,8 +658,12 @@ public class BoardDelegate extends DelegateBase
|
|||
// in case of change...
|
||||
setBackgroundColor();
|
||||
setKeepScreenOn();
|
||||
} else if ( 0 < m_nMissing && ! isFinishing() ) {
|
||||
showDialog( DlgID.DLG_INVITE );
|
||||
} else if ( ! isFinishing() ) {
|
||||
if ( !m_relayConnected ) {
|
||||
showDialog( DlgID.DLG_NOINVITE );
|
||||
} else if ( 0 < m_nMissing ) {
|
||||
showDialog( DlgID.DLG_INVITE );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1356,9 +1369,7 @@ public class BoardDelegate extends DelegateBase
|
|||
{
|
||||
DbgUtils.logf( "BoardDelegate.handleConndMessage(): nMissing = %d", nMissing );
|
||||
|
||||
if ( 0 == nMissing ) {
|
||||
dismissInviteAlert();
|
||||
}
|
||||
dismissInviteAlerts( nMissing, true );
|
||||
|
||||
int naMsg = 0;
|
||||
int naKey = 0;
|
||||
|
@ -1708,17 +1719,16 @@ public class BoardDelegate extends DelegateBase
|
|||
m_nGuestDevs = nDevs;
|
||||
|
||||
// If we might have put up an alert earlier, take it down
|
||||
if ( 0 < m_nMissing && m_nMissing != nMissing ) {
|
||||
dismissInviteAlert();
|
||||
}
|
||||
dismissInviteAlerts( nMissing, m_relayConnected );
|
||||
|
||||
m_nMissing = nMissing; // will be 0 unless isServer is true
|
||||
|
||||
Action action = null;
|
||||
final DlgID dlgID =
|
||||
m_relayConnected ? DlgID.DLG_INVITE : DlgID.DLG_NOINVITE;
|
||||
if ( 0 < nMissing && isServer && !m_haveInvited ) {
|
||||
post( new Runnable() {
|
||||
public void run() {
|
||||
showDialog( DlgID.DLG_INVITE );
|
||||
showDialog( dlgID );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
@ -1869,6 +1879,7 @@ public class BoardDelegate extends DelegateBase
|
|||
String langName = m_gi.langName();
|
||||
|
||||
m_summary = DBUtils.getSummary( m_activity, m_gameLock );
|
||||
m_relayConnected = !m_summary.relayConnectPending();
|
||||
|
||||
setThis( this );
|
||||
|
||||
|
@ -2018,14 +2029,17 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
}
|
||||
|
||||
private void dismissInviteAlert()
|
||||
private void dismissInviteAlerts( final int nMissing, final boolean connected )
|
||||
{
|
||||
post( new Runnable() {
|
||||
runOnUiThread( new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
dismissDialog( DlgID.DLG_INVITE );
|
||||
} catch ( Exception ex ) {
|
||||
if ( !m_relayConnected && connected ) {
|
||||
m_relayConnected = true;
|
||||
dismissDialog( DlgID.DLG_NOINVITE );
|
||||
}
|
||||
if ( 0 == nMissing ) {
|
||||
dismissDialog( DlgID.DLG_INVITE );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public enum DlgID {
|
|||
, DLG_DELETED
|
||||
, DLG_DICTGONE
|
||||
, DLG_INVITE
|
||||
, DLG_NOINVITE
|
||||
, DLG_OKONLY
|
||||
, ENABLE_NFC
|
||||
, FORCE_REMOTE
|
||||
|
|
|
@ -1475,7 +1475,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
break;
|
||||
case R.id.games_game_copy:
|
||||
final GameSummary smry = DBUtils.getSummary( m_activity, selRowIDs[0] );
|
||||
if ( smry.inNetworkGame() ) {
|
||||
if ( smry.inRelayGame() ) {
|
||||
showOKOnlyDialog( R.string.no_copy_network );
|
||||
} else {
|
||||
dropSels = true; // will select the new game instead
|
||||
|
|
|
@ -102,7 +102,7 @@ public class GameSummary {
|
|||
return m_context;
|
||||
}
|
||||
|
||||
public boolean inNetworkGame()
|
||||
public boolean inRelayGame()
|
||||
{
|
||||
return null != relayID;
|
||||
}
|
||||
|
@ -242,6 +242,13 @@ public class GameSummary {
|
|||
return result;
|
||||
}
|
||||
|
||||
public boolean relayConnectPending()
|
||||
{
|
||||
boolean result = conTypes.contains( CommsConnType.COMMS_CONN_RELAY )
|
||||
&& (null == relayID || 0 == relayID.length());
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isMultiGame()
|
||||
{
|
||||
return ( serverRole != DeviceRole.SERVER_STANDALONE );
|
||||
|
|
Loading…
Reference in a new issue