mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-24 07:58:34 +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.
|
substituted.
|
||||||
*/
|
*/
|
||||||
public static final int no_name_found_fmt=0x7f0500b8;
|
public static final int no_name_found_fmt=0x7f0500b8;
|
||||||
|
public static final int no_relay_conn=0x7f0502fb;
|
||||||
/** This is not currently shown
|
/** This is not currently shown
|
||||||
<string name="not_again_dicts">Crosswords wordlists, which are
|
<string name="not_again_dicts">Crosswords wordlists, which are
|
||||||
just compressed lists of words plus tile information, determine
|
just compressed lists of words plus tile information, determine
|
||||||
|
|
|
@ -2462,4 +2462,10 @@
|
||||||
<string name="checking_title">Checking</string>
|
<string name="checking_title">Checking</string>
|
||||||
<string name="checking_for_fmt">Checking for wordlists in %1$s…</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="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>
|
</resources>
|
||||||
|
|
|
@ -2132,4 +2132,9 @@
|
||||||
<string name="checking_title">Gnikcehc</string>
|
<string name="checking_title">Gnikcehc</string>
|
||||||
<string name="checking_for_fmt">Gnikcehc rof stsildrow ni %1$s…</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="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>
|
</resources>
|
||||||
|
|
|
@ -2132,4 +2132,9 @@
|
||||||
<string name="checking_title">CHECKING</string>
|
<string name="checking_title">CHECKING</string>
|
||||||
<string name="checking_for_fmt">CHECKING FOR WORDLISTS IN %1$s…</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="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>
|
</resources>
|
||||||
|
|
|
@ -3444,4 +3444,10 @@ pour la langue</string>
|
||||||
<!-- <string name="db_store_done">SD card write complete.</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="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>
|
</resources>
|
||||||
|
|
|
@ -89,6 +89,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
private GameLock m_gameLock;
|
private GameLock m_gameLock;
|
||||||
private CurGameInfo m_gi;
|
private CurGameInfo m_gi;
|
||||||
private GameSummary m_summary;
|
private GameSummary m_summary;
|
||||||
|
private boolean m_relayConnected;
|
||||||
private CommsTransport m_xport;
|
private CommsTransport m_xport;
|
||||||
private Handler m_handler = null;
|
private Handler m_handler = null;
|
||||||
private TimerRunnable[] m_timers;
|
private TimerRunnable[] m_timers;
|
||||||
|
@ -431,6 +432,8 @@ public class BoardDelegate extends DelegateBase
|
||||||
.setNegativeButton( R.string.button_no, null )
|
.setNegativeButton( R.string.button_no, null )
|
||||||
.create();
|
.create();
|
||||||
break;
|
break;
|
||||||
|
case DLG_NOINVITE:
|
||||||
|
Assert.assertFalse( m_relayConnected );
|
||||||
case DLG_INVITE:
|
case DLG_INVITE:
|
||||||
lstnr = new OnClickListener() {
|
lstnr = new OnClickListener() {
|
||||||
public void onClick( DialogInterface dialog,
|
public void onClick( DialogInterface dialog,
|
||||||
|
@ -472,15 +475,18 @@ public class BoardDelegate extends DelegateBase
|
||||||
protected void prepareDialog( DlgID dlgID, Dialog dialog )
|
protected void prepareDialog( DlgID dlgID, Dialog dialog )
|
||||||
{
|
{
|
||||||
switch( dlgID ) {
|
switch( dlgID ) {
|
||||||
case DLG_INVITE: // here
|
case DLG_INVITE:
|
||||||
|
case DLG_NOINVITE:
|
||||||
AlertDialog ad = (AlertDialog)dialog;
|
AlertDialog ad = (AlertDialog)dialog;
|
||||||
String message;
|
String message;
|
||||||
int titleID;
|
int titleID = R.string.info_title;;
|
||||||
boolean rematch = m_summary.hasRematchInfo();
|
boolean nukeButton = false;
|
||||||
if ( rematch ) {
|
if ( m_summary.hasRematchInfo() ) {
|
||||||
titleID = R.string.info_title;
|
|
||||||
message = getString( R.string.rematch_msg );
|
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 {
|
} else {
|
||||||
titleID = R.string.waiting_title;
|
titleID = R.string.waiting_title;
|
||||||
message = getQuantityString( R.plurals.invite_msg_fmt, m_nMissing, m_nMissing );
|
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 );
|
message += "\n\n" + getString( R.string.invite_stays );
|
||||||
}
|
}
|
||||||
|
if ( nukeButton ) {
|
||||||
|
ad.getButton( AlertDialog.BUTTON_POSITIVE ).setVisibility( View.GONE );
|
||||||
|
}
|
||||||
ad.setMessage( message );
|
ad.setMessage( message );
|
||||||
ad.setTitle( titleID );
|
ad.setTitle( titleID );
|
||||||
break;
|
break;
|
||||||
|
@ -649,11 +658,15 @@ public class BoardDelegate extends DelegateBase
|
||||||
// in case of change...
|
// in case of change...
|
||||||
setBackgroundColor();
|
setBackgroundColor();
|
||||||
setKeepScreenOn();
|
setKeepScreenOn();
|
||||||
} else if ( 0 < m_nMissing && ! isFinishing() ) {
|
} else if ( ! isFinishing() ) {
|
||||||
|
if ( !m_relayConnected ) {
|
||||||
|
showDialog( DlgID.DLG_NOINVITE );
|
||||||
|
} else if ( 0 < m_nMissing ) {
|
||||||
showDialog( DlgID.DLG_INVITE );
|
showDialog( DlgID.DLG_INVITE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean onKeyDown( int keyCode, KeyEvent event )
|
protected boolean onKeyDown( int keyCode, KeyEvent event )
|
||||||
{
|
{
|
||||||
|
@ -1356,9 +1369,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "BoardDelegate.handleConndMessage(): nMissing = %d", nMissing );
|
DbgUtils.logf( "BoardDelegate.handleConndMessage(): nMissing = %d", nMissing );
|
||||||
|
|
||||||
if ( 0 == nMissing ) {
|
dismissInviteAlerts( nMissing, true );
|
||||||
dismissInviteAlert();
|
|
||||||
}
|
|
||||||
|
|
||||||
int naMsg = 0;
|
int naMsg = 0;
|
||||||
int naKey = 0;
|
int naKey = 0;
|
||||||
|
@ -1708,17 +1719,16 @@ public class BoardDelegate extends DelegateBase
|
||||||
m_nGuestDevs = nDevs;
|
m_nGuestDevs = nDevs;
|
||||||
|
|
||||||
// If we might have put up an alert earlier, take it down
|
// If we might have put up an alert earlier, take it down
|
||||||
if ( 0 < m_nMissing && m_nMissing != nMissing ) {
|
dismissInviteAlerts( nMissing, m_relayConnected );
|
||||||
dismissInviteAlert();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_nMissing = nMissing; // will be 0 unless isServer is true
|
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 ) {
|
if ( 0 < nMissing && isServer && !m_haveInvited ) {
|
||||||
post( new Runnable() {
|
post( new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
showDialog( DlgID.DLG_INVITE );
|
showDialog( dlgID );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -1869,6 +1879,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
String langName = m_gi.langName();
|
String langName = m_gi.langName();
|
||||||
|
|
||||||
m_summary = DBUtils.getSummary( m_activity, m_gameLock );
|
m_summary = DBUtils.getSummary( m_activity, m_gameLock );
|
||||||
|
m_relayConnected = !m_summary.relayConnectPending();
|
||||||
|
|
||||||
setThis( this );
|
setThis( this );
|
||||||
|
|
||||||
|
@ -2018,13 +2029,16 @@ 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() {
|
public void run() {
|
||||||
try {
|
if ( !m_relayConnected && connected ) {
|
||||||
|
m_relayConnected = true;
|
||||||
|
dismissDialog( DlgID.DLG_NOINVITE );
|
||||||
|
}
|
||||||
|
if ( 0 == nMissing ) {
|
||||||
dismissDialog( DlgID.DLG_INVITE );
|
dismissDialog( DlgID.DLG_INVITE );
|
||||||
} catch ( Exception ex ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -35,6 +35,7 @@ public enum DlgID {
|
||||||
, DLG_DELETED
|
, DLG_DELETED
|
||||||
, DLG_DICTGONE
|
, DLG_DICTGONE
|
||||||
, DLG_INVITE
|
, DLG_INVITE
|
||||||
|
, DLG_NOINVITE
|
||||||
, DLG_OKONLY
|
, DLG_OKONLY
|
||||||
, ENABLE_NFC
|
, ENABLE_NFC
|
||||||
, FORCE_REMOTE
|
, FORCE_REMOTE
|
||||||
|
|
|
@ -1475,7 +1475,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
break;
|
break;
|
||||||
case R.id.games_game_copy:
|
case R.id.games_game_copy:
|
||||||
final GameSummary smry = DBUtils.getSummary( m_activity, selRowIDs[0] );
|
final GameSummary smry = DBUtils.getSummary( m_activity, selRowIDs[0] );
|
||||||
if ( smry.inNetworkGame() ) {
|
if ( smry.inRelayGame() ) {
|
||||||
showOKOnlyDialog( R.string.no_copy_network );
|
showOKOnlyDialog( R.string.no_copy_network );
|
||||||
} else {
|
} else {
|
||||||
dropSels = true; // will select the new game instead
|
dropSels = true; // will select the new game instead
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class GameSummary {
|
||||||
return m_context;
|
return m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inNetworkGame()
|
public boolean inRelayGame()
|
||||||
{
|
{
|
||||||
return null != relayID;
|
return null != relayID;
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,13 @@ public class GameSummary {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean relayConnectPending()
|
||||||
|
{
|
||||||
|
boolean result = conTypes.contains( CommsConnType.COMMS_CONN_RELAY )
|
||||||
|
&& (null == relayID || 0 == relayID.length());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMultiGame()
|
public boolean isMultiGame()
|
||||||
{
|
{
|
||||||
return ( serverRole != DeviceRole.SERVER_STANDALONE );
|
return ( serverRole != DeviceRole.SERVER_STANDALONE );
|
||||||
|
|
Loading…
Add table
Reference in a new issue