mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
give user a chance to name game during rematch of solo games too
This commit is contained in:
parent
5e3ae54e2e
commit
8a3bc943c8
1 changed files with 22 additions and 28 deletions
|
@ -590,7 +590,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
private Button[] m_newGameButtons;
|
private Button[] m_newGameButtons;
|
||||||
private boolean m_haveShownGetDict;
|
private boolean m_haveShownGetDict;
|
||||||
private Intent m_rematchIntent;
|
private Intent m_rematchIntent;
|
||||||
private String m_rematchOpponent;
|
|
||||||
|
|
||||||
public GamesListDelegate( ListDelegator delegator, Bundle sis )
|
public GamesListDelegate( ListDelegator delegator, Bundle sis )
|
||||||
{
|
{
|
||||||
|
@ -902,10 +901,12 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
case GAMES_LIST_NAME_REMATCH:
|
case GAMES_LIST_NAME_REMATCH:
|
||||||
edit = (TextView)dialog.findViewById( R.id.edit );
|
edit = (TextView)dialog.findViewById( R.id.edit );
|
||||||
boolean solo = m_rematchOpponent == null;
|
String opponent =
|
||||||
|
m_rematchIntent.getStringExtra( REMATCH_OPPONENT_EXTRA );
|
||||||
|
boolean solo = opponent == null;
|
||||||
String name = solo
|
String name = solo
|
||||||
? GameUtils.makeDefaultName( m_activity )
|
? GameUtils.makeDefaultName( m_activity )
|
||||||
: getString( R.string.rematch_name_fmt, m_rematchOpponent );
|
: getString( R.string.rematch_name_fmt, opponent );
|
||||||
edit.setText( name );
|
edit.setText( name );
|
||||||
int icon = solo
|
int icon = solo
|
||||||
? R.drawable.sologame__gen : R.drawable.multigame__gen;
|
? R.drawable.sologame__gen : R.drawable.multigame__gen;
|
||||||
|
@ -1885,32 +1886,19 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
// used to connect.
|
// used to connect.
|
||||||
private void startRematch( Intent intent )
|
private void startRematch( Intent intent )
|
||||||
{
|
{
|
||||||
if ( XWApp.REMATCH_SUPPORTED ) {
|
if ( XWApp.REMATCH_SUPPORTED
|
||||||
long rowid = intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 );
|
&& ( -1 != intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 ) ) ) {
|
||||||
if ( -1 != rowid ) {
|
|
||||||
String btAddr = intent.getStringExtra( REMATCH_BTADDR_EXTRA );
|
|
||||||
String phone = intent.getStringExtra( REMATCH_PHONE_EXTRA );
|
|
||||||
String relayID = intent.getStringExtra( REMATCH_RELAYID_EXTRA );
|
|
||||||
if ( null == btAddr && null == phone && null == relayID ) {
|
|
||||||
// this will juggle if the preference is set
|
|
||||||
long newid = GameUtils.dupeGame( m_activity, rowid );
|
|
||||||
launchGame( newid );
|
|
||||||
} else {
|
|
||||||
m_rematchIntent = intent;
|
m_rematchIntent = intent;
|
||||||
m_rematchOpponent =
|
|
||||||
intent.getStringExtra( REMATCH_OPPONENT_EXTRA );
|
|
||||||
showDialog( DlgID.GAMES_LIST_NAME_REMATCH );
|
showDialog( DlgID.GAMES_LIST_NAME_REMATCH );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startRematchWithName( EditText edit )
|
private void startRematchWithName( EditText edit )
|
||||||
{
|
{
|
||||||
String gameName = edit.getText().toString();
|
String gameName = edit.getText().toString();
|
||||||
if ( null != gameName && 0 < gameName.length() ) {
|
if ( null != gameName && 0 < gameName.length() ) {
|
||||||
Intent intent = m_rematchIntent;
|
Intent intent = m_rematchIntent;
|
||||||
long rowid = intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 );
|
long srcRowID = intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 );
|
||||||
String btAddr = intent.getStringExtra( REMATCH_BTADDR_EXTRA );
|
String btAddr = intent.getStringExtra( REMATCH_BTADDR_EXTRA );
|
||||||
String phone = intent.getStringExtra( REMATCH_PHONE_EXTRA );
|
String phone = intent.getStringExtra( REMATCH_PHONE_EXTRA );
|
||||||
String relayID = intent.getStringExtra( REMATCH_RELAYID_EXTRA );
|
String relayID = intent.getStringExtra( REMATCH_RELAYID_EXTRA );
|
||||||
|
@ -1919,15 +1907,21 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
int bits = intent.getIntExtra( REMATCH_ADDRS_EXTRA, -1 );
|
int bits = intent.getIntExtra( REMATCH_ADDRS_EXTRA, -1 );
|
||||||
CommsConnTypeSet addrs = new CommsConnTypeSet( bits );
|
CommsConnTypeSet addrs = new CommsConnTypeSet( bits );
|
||||||
|
|
||||||
long groupID = DBUtils.getGroupForGame( m_activity, rowid );
|
if ( null == btAddr && null == phone && null == relayID ) {
|
||||||
|
long newid = GameUtils.dupeGame( m_activity, srcRowID );
|
||||||
|
DBUtils.setName( m_activity, newid, gameName );
|
||||||
|
launchGame( newid );
|
||||||
|
} else {
|
||||||
|
long groupID = DBUtils.getGroupForGame( m_activity, srcRowID );
|
||||||
long newid = GameUtils.makeNewMultiGame( m_activity, groupID,
|
long newid = GameUtils.makeNewMultiGame( m_activity, groupID,
|
||||||
dict, lang,
|
dict, lang,
|
||||||
addrs, gameName );
|
addrs, gameName );
|
||||||
|
|
||||||
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
|
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
|
||||||
relayID );
|
relayID );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_rematchIntent = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void tryAlert( Intent intent )
|
private void tryAlert( Intent intent )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue