mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
fix crash, and clean up rematch game naming code. Deals with solo
games too though not used.
This commit is contained in:
parent
873e0c7e92
commit
37094b72f3
3 changed files with 21 additions and 14 deletions
|
@ -2585,10 +2585,11 @@ public class BoardDelegate extends DelegateBase
|
||||||
|
|
||||||
if ( doIt ) {
|
if ( doIt ) {
|
||||||
String[] opponents = m_gi.getRemoteNames();
|
String[] opponents = m_gi.getRemoteNames();
|
||||||
|
String opponent = (0 == opponents.length) ? null : opponents[0];
|
||||||
Intent intent = GamesListDelegate
|
Intent intent = GamesListDelegate
|
||||||
.makeRematchIntent( m_activity, m_rowid, m_gi.dictName,
|
.makeRematchIntent( m_activity, m_rowid, m_gi.dictName,
|
||||||
m_gi.dictLang, m_connTypes, btAddr,
|
m_gi.dictLang, m_connTypes, btAddr,
|
||||||
phone, relayID, opponents[0] );
|
phone, relayID, opponent );
|
||||||
if ( null != intent ) {
|
if ( null != intent ) {
|
||||||
startActivity( intent );
|
startActivity( intent );
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class GameUtils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String makeDefaultName( Context context, boolean isSolo )
|
public static String makeDefaultName( Context context )
|
||||||
{
|
{
|
||||||
int count = DBUtils.getIncrementIntFor( context, DBUtils.KEY_NEWGAMECOUNT, 0, 1 );
|
int count = DBUtils.getIncrementIntFor( context, DBUtils.KEY_NEWGAMECOUNT, 0, 1 );
|
||||||
return LocUtils.getString( context, R.string.game_fmt, count );
|
return LocUtils.getString( context, R.string.game_fmt, count );
|
||||||
|
|
|
@ -851,7 +851,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
dialog = makeAlertBuilder()
|
dialog = makeAlertBuilder()
|
||||||
.setView( view )
|
.setView( view )
|
||||||
.setTitle( R.string.button_rematch )
|
.setTitle( R.string.button_rematch )
|
||||||
.setIcon( R.drawable.multigame__gen )
|
.setIcon( R.drawable.sologame__gen )
|
||||||
.setPositiveButton( android.R.string.ok, new OnClickListener() {
|
.setPositiveButton( android.R.string.ok, new OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
EditText edit = (EditText)((Dialog)dlg)
|
EditText edit = (EditText)((Dialog)dlg)
|
||||||
|
@ -883,29 +883,33 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
ad.getButton( AlertDialog.BUTTON_NEGATIVE )
|
ad.getButton( AlertDialog.BUTTON_NEGATIVE )
|
||||||
.setVisibility( canDoDefaults ? View.VISIBLE : View.GONE );
|
.setVisibility( canDoDefaults ? View.VISIBLE : View.GONE );
|
||||||
|
|
||||||
|
ad.setIcon( m_nextIsSolo ? R.drawable.sologame__gen
|
||||||
|
: R.drawable.multigame__gen );
|
||||||
|
ad.setTitle( m_nextIsSolo ? R.string.new_game
|
||||||
|
: R.string.new_game_networked);
|
||||||
|
|
||||||
String msg = getString( canDoDefaults ? R.string.new_game_message
|
String msg = getString( canDoDefaults ? R.string.new_game_message
|
||||||
: R.string.new_game_message_nodflt );
|
: R.string.new_game_message_nodflt );
|
||||||
if ( m_nextIsSolo ) {
|
if ( !m_nextIsSolo ) {
|
||||||
ad.setTitle( R.string.new_game );
|
|
||||||
ad.setIcon( R.drawable.sologame__gen );
|
|
||||||
} else {
|
|
||||||
ad.setTitle( R.string.new_game_networked );
|
|
||||||
ad.setIcon( R.drawable.multigame__gen );
|
|
||||||
|
|
||||||
msg += "\n\n" + getString( R.string.new_game_message_net );
|
msg += "\n\n" + getString( R.string.new_game_message_net );
|
||||||
}
|
}
|
||||||
TextView edit = (TextView)dialog.findViewById( R.id.msg );
|
TextView edit = (TextView)dialog.findViewById( R.id.msg );
|
||||||
edit.setText( msg );
|
edit.setText( msg );
|
||||||
edit = (TextView)dialog.findViewById( R.id.edit );
|
edit = (TextView)dialog.findViewById( R.id.edit );
|
||||||
edit.setText( GameUtils.makeDefaultName( m_activity, m_nextIsSolo ) );
|
edit.setText( GameUtils.makeDefaultName( m_activity ) );
|
||||||
edit.setVisibility( View.VISIBLE );
|
edit.setVisibility( View.VISIBLE );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GAMES_LIST_NAME_REMATCH:
|
case GAMES_LIST_NAME_REMATCH:
|
||||||
edit = (TextView)dialog.findViewById( R.id.edit );
|
edit = (TextView)dialog.findViewById( R.id.edit );
|
||||||
String name = getString( R.string.rematch_name_fmt,
|
boolean solo = m_rematchOpponent == null;
|
||||||
m_rematchOpponent );
|
String name = solo
|
||||||
|
? GameUtils.makeDefaultName( m_activity )
|
||||||
|
: getString( R.string.rematch_name_fmt, m_rematchOpponent );
|
||||||
edit.setText( name );
|
edit.setText( name );
|
||||||
|
int icon = solo
|
||||||
|
? R.drawable.sologame__gen : R.drawable.multigame__gen;
|
||||||
|
ad.setIcon( icon );
|
||||||
((TextView)dialog.findViewById( R.id.msg ))
|
((TextView)dialog.findViewById( R.id.msg ))
|
||||||
.setVisibility( View.GONE );
|
.setVisibility( View.GONE );
|
||||||
break;
|
break;
|
||||||
|
@ -2316,7 +2320,9 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
intent.putExtra( REMATCH_ROWID_EXTRA, rowid );
|
intent.putExtra( REMATCH_ROWID_EXTRA, rowid );
|
||||||
intent.putExtra( REMATCH_DICT_EXTRA, dict );
|
intent.putExtra( REMATCH_DICT_EXTRA, dict );
|
||||||
intent.putExtra( REMATCH_LANG_EXTRA, lang );
|
intent.putExtra( REMATCH_LANG_EXTRA, lang );
|
||||||
intent.putExtra( REMATCH_OPPONENT_EXTRA, opponent );
|
if ( null != opponent ) {
|
||||||
|
intent.putExtra( REMATCH_OPPONENT_EXTRA, opponent );
|
||||||
|
}
|
||||||
if ( null != addrTypes ) {
|
if ( null != addrTypes ) {
|
||||||
intent.putExtra( REMATCH_ADDRS_EXTRA, addrTypes.toInt() ); // here
|
intent.putExtra( REMATCH_ADDRS_EXTRA, addrTypes.toInt() ); // here
|
||||||
if ( null != btAddr ) {
|
if ( null != btAddr ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue