game config changes

get rid of password; disable, not hide, stuff that's irrelevant for a
non-local player
This commit is contained in:
Eric House 2021-01-07 11:37:06 -08:00
parent 0f97cd217d
commit 7af001d481
3 changed files with 26 additions and 9 deletions

View file

@ -104,6 +104,7 @@ android {
buildConfigField "boolean", "NON_RELEASE", "DEBUG || !IS_TAGGED_BUILD"
buildConfigField "boolean", "HAVE_KNOWN_PLAYERS", "false"
buildConfigField "boolean", "FOR_FDROID", "false"
buildConfigField "boolean", "HAVE_PASSWORD", "false"
}
xw4NoSMS {

View file

@ -365,7 +365,11 @@ public class GameConfigDelegate extends DelegateBase
// Hide remote option if in standalone mode...
final LocalPlayer lp = m_gi.players[m_whichPlayer];
Utils.setText( playerView, R.id.player_name_edit, lp.name );
Utils.setText( playerView, R.id.password_edit, lp.password );
if ( BuildConfig.HAVE_PASSWORD ) {
Utils.setText( playerView, R.id.password_edit, lp.password );
} else {
playerView.findViewById(R.id.password_set).setVisibility( View.GONE );
}
// Dicts spinner with label
TextView dictLabel = (TextView)playerView
@ -396,8 +400,7 @@ public class GameConfigDelegate extends DelegateBase
public void onCheckedChanged( CompoundButton buttonView,
boolean checked ) {
lp.isLocal = !checked;
localSet.setVisibility( checked ?
View.GONE : View.VISIBLE );
Utils.setEnabled( localSet, !checked );
checkShowPassword( playerView, lp );
}
};
@ -405,7 +408,7 @@ public class GameConfigDelegate extends DelegateBase
check.setVisibility( View.VISIBLE );
} else {
check.setVisibility( View.GONE );
localSet.setVisibility( View.VISIBLE );
Utils.setEnabled( localSet, true );
}
check = (CheckBox)playerView.findViewById( R.id.robot_check );
@ -440,7 +443,7 @@ public class GameConfigDelegate extends DelegateBase
{
boolean isRobotChecked = lp.isRobot();
// Log.d( TAG, "checkShowPassword(isRobotChecked=%b)", isRobotChecked );
boolean showPassword = !isRobotChecked;
boolean showPassword = !isRobotChecked && BuildConfig.HAVE_PASSWORD;
if ( showPassword ) {
String pwd = getText( playerView, R.id.password_edit );
@ -458,8 +461,8 @@ public class GameConfigDelegate extends DelegateBase
}
}
View view = playerView.findViewById( R.id.password_set );
view.setVisibility( showPassword ? View.VISIBLE : View.GONE );
playerView.findViewById( R.id.password_set )
.setVisibility( showPassword ? View.VISIBLE : View.GONE );
}
private void getPlayerSettings( DialogInterface di )
@ -467,7 +470,9 @@ public class GameConfigDelegate extends DelegateBase
Dialog dialog = (Dialog)di;
LocalPlayer lp = m_gi.players[m_whichPlayer];
lp.name = Utils.getText( dialog, R.id.player_name_edit );
lp.password = Utils.getText( dialog, R.id.password_edit );
if ( BuildConfig.HAVE_PASSWORD ) {
lp.password = Utils.getText( dialog, R.id.password_edit );
}
if ( localOnlyGame() ) {
int position = m_playerDictSpinner.getSelectedItemPosition();

View file

@ -521,10 +521,21 @@ public class Utils {
setText( parent, id, str );
}
public static void setEnabled( View view, boolean enabled )
{
view.setEnabled( enabled );
if ( view instanceof ViewGroup ) {
ViewGroup asGroup = (ViewGroup)view;
for ( int ii = 0; ii < asGroup.getChildCount(); ++ii ) {
setEnabled( asGroup.getChildAt( ii ), enabled );
}
}
}
public static void setEnabled( View parent, int id, boolean enabled )
{
View view = parent.findViewById( id );
parent.setEnabled( enabled );
setEnabled( view, enabled );
}
public static boolean getChecked( Dialog dialog, int id )