change player name when [un]made a robot

This commit is contained in:
Eric House 2020-08-23 14:18:41 -07:00
parent 12e8328e83
commit 3f92b879de
2 changed files with 16 additions and 2 deletions

View file

@ -383,14 +383,19 @@ public class DelegateBase implements DlgClickNotify,
m_activity.runOnUiThread( runnable );
}
public void setText( int id, String value )
public void setText( View parent, int id, String value )
{
EditText editText = (EditText)findViewById( id );
EditText editText = (EditText)parent.findViewById( id );
if ( null != editText ) {
editText.setText( value, TextView.BufferType.EDITABLE );
}
}
public void setText( int id, String value )
{
setText( m_rootView, id, value );
}
public String getText( View parent, int id )
{
EditText editText = (EditText)parent.findViewById( id );

View file

@ -413,6 +413,7 @@ public class GameConfigDelegate extends DelegateBase
public void onCheckedChanged( CompoundButton buttonView,
boolean checked ) {
lp.setIsRobot( checked );
setPlayerName( playerView, lp );
checkShowPassword( playerView, lp );
}
};
@ -424,6 +425,14 @@ public class GameConfigDelegate extends DelegateBase
Log.d( TAG, "setPlayerSettings() DONE" );
}
private void setPlayerName( View playerView, LocalPlayer lp )
{
String name = lp.isRobot()
? CommonPrefs.getDefaultRobotName( m_activity )
: CommonPrefs.getDefaultPlayerName( m_activity, m_whichPlayer );
setText( playerView, R.id.player_name_edit, name );
}
// We show the password stuff only if: non-robot player AND there's more
// than one local non-robot OR there's already a password set.
private void checkShowPassword( View playerView, LocalPlayer lp )