diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index 5e87df290..30d35d359 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -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 { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java index 4cd8f6dcf..c695afce4 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java @@ -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(); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java index c0c09324d..708c0a2c1 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java @@ -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 )