modify configure connection button to reflect conn type chosen; add

role-specifig hints to relay config dialog (in a way it'll be easy to
follow for others.)
This commit is contained in:
eehouse 2010-05-08 15:27:32 +00:00
parent 13ab9b233d
commit 0e3411ecd4
4 changed files with 95 additions and 5 deletions

View file

@ -31,5 +31,20 @@
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:id="@+id/room_edit_hint_host"
android:text="@string/room_edit_hint_host"
style="@style/role_config_hint"
/>
<TextView android:id="@+id/room_edit_hint_guest"
android:text="@string/room_edit_hint_guest"
style="@style/role_config_hint"
/>
<TextView android:id="@+id/room_edit_hint_connect"
android:text="@string/room_edit_hint_connect"
style="@style/role_config_hint"
/>
</LinearLayout>
</ScrollView>

View file

@ -163,7 +163,7 @@
<string name="role_label">Device role</string>
<string name="connection_label">Connection</string>
<string name="configure_role">Configure connection</string>
<string name="configure_rolef">Configure %s connection</string>
<string name="settings_label">Game settings</string>
<string name="minutes_label">Minutes in game</string>
@ -203,6 +203,16 @@
<string name="role_prompt">Standalone if all players are on this
device; otherwise Host a game or be a Guest.</string>
<string name="room_edit_hint_host">As host, you name the room you
and your guests will use. You must connect before any guests to
establish the room on the relay.</string>
<string name="room_edit_hint_guest">As a guest, you enter the room
name chosen by the host. You should wait to connect until the
host has done so.</string>
<string name="room_edit_hint_connect">(Connecting happens
automatically when you open a game that is configured to use the
relay.)</string>
<string name="phonies_ignore">Ignore phonies</string>
<string name="phonies_warn">Warn if phonies</string>
<string name="phonies_disallow">Disallow phonies</string>

View file

@ -3,8 +3,18 @@
<style name="config_separator">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:gravity">left</item>
<item name="android:background">#FF7F7F7F</item>
<item name="android:textColor">#FFFFFFFF</item>
<item name="android:gravity">left</item>
<item name="android:background">#FF7F7F7F</item>
<item name="android:textColor">#FFFFFFFF</item>
</style>
<style name="role_config_hint">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_marginLeft">20dip</item>
<item name="android:layout_marginRight">20dip</item>
<item name="android:gravity">left</item>
<item name="android:textColor">#FFFFFFFF</item>
</style>
</resources>

View file

@ -87,6 +87,7 @@ public class GameConfig extends Activity implements View.OnClickListener {
private boolean m_canDoBT = false;
private int m_nMoves = 0;
private CommsAddrRec.CommsConnType[] m_types;
private String[] m_connStrings;
class RemoteChoices extends XWListAdapter {
public RemoteChoices() { super( GameConfig.this, m_gi.nPlayers ); }
@ -222,6 +223,7 @@ public class GameConfig extends Activity implements View.OnClickListener {
case ROLE_EDIT_RELAY:
case ROLE_EDIT_SMS:
case ROLE_EDIT_BT:
setRoleHints( id, dialog );
setRoleSettings();
break;
case FORCE_REMOTE:
@ -274,6 +276,37 @@ public class GameConfig extends Activity implements View.OnClickListener {
Utils.setChecked( m_curDialog, R.id.remote_check, ! lp.isLocal );
}
private void setRoleHints( int id, Dialog dialog )
{
int[] guestHints = null;
int[] hostHints = null;
switch( id ) {
case ROLE_EDIT_RELAY:
// Can these be in an array in a resource?
guestHints = new int[] { R.id.room_edit_hint_guest };
hostHints = new int[] { R.id.room_edit_hint_host };
break;
case ROLE_EDIT_SMS:
case ROLE_EDIT_BT:
}
DeviceRole role = m_gi.serverRole;
if ( null != guestHints ) {
for ( int hintID : guestHints ) {
View view = dialog.findViewById( hintID );
view.setVisibility( DeviceRole.SERVER_ISCLIENT == role ?
View.VISIBLE : View.GONE );
}
}
if ( null != hostHints ) {
for ( int hintID : hostHints ) {
View view = dialog.findViewById( hintID );
view.setVisibility( DeviceRole.SERVER_ISSERVER == role ?
View.VISIBLE : View.GONE );
}
}
}
private void setRoleSettings()
{
switch( m_types[m_connectSpinner.getSelectedItemPosition()] ) {
@ -606,14 +639,36 @@ public class GameConfig extends Activity implements View.OnClickListener {
private void configConnectSpinner()
{
m_connectSpinner = (Spinner)findViewById( R.id.connect_spinner );
m_connStrings = makeXportStrings();
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( this,
android.R.layout.simple_spinner_item,
makeXportStrings() );
m_connStrings );
adapter.setDropDownViewResource( android.R.layout
.simple_spinner_dropdown_item );
m_connectSpinner.setAdapter( adapter );
m_connectSpinner.setSelection( connTypeToPos( m_car.conType ) );
AdapterView.OnItemSelectedListener
lstnr = new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView,
View selectedItemView,
int position,
long id )
{
String fmt = getString( R.string.configure_rolef );
m_configureButton
.setText( String.format( fmt,
m_connStrings[position] ));
}
@Override
public void onNothingSelected(AdapterView<?> parentView)
{
}
};
m_connectSpinner.setOnItemSelectedListener( lstnr );
} // configConnectSpinner
private void adjustVisibility()