From 9fccbcc6b4bca385732b4c84b4f7b27cb95dba5f Mon Sep 17 00:00:00 2001 From: Andy2 Date: Sat, 6 Nov 2010 16:41:12 -0700 Subject: [PATCH] Problem with new minimal-config relay dialog: user can accidentally tap "play game" and wind up connecting and creating an empty-room-name game; or can dismiss the dialog and be confused because there's no way back to it. Solution: define empty-room-name as an illegal case. Check for it when "play game" is tapped in either config dialog and raise an alert. And when user wants to open a game from the GamesList activity go to the minimal config dialog if it's a relay game without a room name. --- .../android/XWords4/res/values/strings.xml | 9 ++++++--- .../org/eehouse/android/xw4/GameConfig.java | 6 +++++- .../org/eehouse/android/xw4/GamesList.java | 20 ++++++++++++++----- .../android/xw4/RelayGameActivity.java | 17 +++++++++++----- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 93d5a027c..5d099f2d4 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -169,7 +169,7 @@ Connection (via internet) Make new room public Join public room - New room name + Room name Select public room Configure connection @@ -471,8 +471,8 @@ • Agree on a room name with the other player. - • Enter the new room name in the first - box below. The room names on your two phones must be + • Enter the room name in the first box + below. The room names on your two phones must be identical. • Optionally, enter player names in the second box (one per phone) @@ -482,4 +482,7 @@ Advanced game settings Player name + This game cannot connect without a + room name. + diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java index e7f45f31a..dee23bd65 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java @@ -874,7 +874,11 @@ public class GameConfig extends XWActivity private void launchGame() { - GameUtils.launchGame( this, m_path ); + if ( m_car.ip_relay_invite.length() == 0 ) { + showOKOnlyDialog( R.string.no_empty_rooms ); + } else { + GameUtils.launchGame( this, m_path ); + } } private void refreshNames() diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index a5f0c91ee..3e91b81b3 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -263,11 +263,21 @@ public class GamesList extends XWListActivity { super.onListItemClick( l, v, position, id ); String path = GameUtils.gamesList( this )[position]; - File file = new File( path ); - Uri uri = Uri.fromFile( file ); - Intent intent = new Intent( Intent.ACTION_EDIT, uri, - this, BoardActivity.class ); - startActivity( intent ); + + // We need a way to let the user get back to the basic-config + // dialog in case it was dismissed. That way it to check for + // an empty room name. + GameSummary summary = DBUtils.getSummary( this, path ); + if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY + && summary.roomName.length() == 0 ) { + GameUtils.doConfig( this, path, RelayGameActivity.class ); + } else { + File file = new File( path ); + Uri uri = Uri.fromFile( file ); + Intent intent = new Intent( Intent.ACTION_EDIT, uri, + this, BoardActivity.class ); + startActivity( intent ); + } m_invalPath = path; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayGameActivity.java index 541d8ec4b..04759bb3e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayGameActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayGameActivity.java @@ -89,11 +89,18 @@ public class RelayGameActivity extends XWActivity public void onClick( View view ) { if ( view == m_playButton ) { - m_car.ip_relay_invite = Utils.getText( this, R.id.room_edit ).trim(); - String name = Utils.getText( this, R.id.local_name_edit ); - m_gi.setFirstLocalName( name ); - GameUtils.applyChanges( this, m_gi, m_car, m_path, false ); - GameUtils.launchGame( this, m_path ); + String room = Utils.getText( this, R.id.room_edit ).trim(); + if ( room.length() == 0 ) { + showOKOnlyDialog( R.string.no_empty_rooms ); + } else { + m_car.ip_relay_invite = room; + String name = Utils.getText( this, R.id.local_name_edit ); + if ( name.length() > 0 ) { + m_gi.setFirstLocalName( name ); + } + GameUtils.applyChanges( this, m_gi, m_car, m_path, false ); + GameUtils.launchGame( this, m_path ); + } } else if ( view == m_configButton ) { GameUtils.doConfig( this, m_path, GameConfig.class ); finish();