diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index c39d13288..fe244da01 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -40,6 +40,7 @@ import junit.framework.Assert; import org.eehouse.android.xw4.jni.*; import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole; +import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; public class GameListAdapter extends XWListAdapter { private Context m_context; @@ -173,7 +174,7 @@ public class GameListAdapter extends XWListAdapter { view.setText( String.format( " %d", summary.scores[ii] ) ); if ( summary.isNextToPlay( ii ) ) { tmp.setBackgroundColor( TURN_COLOR ); - if ( summary.isRelayGame() ) { + if ( summary.isMultiGame() ) { haveNetTurn = true; } } @@ -188,12 +189,15 @@ public class GameListAdapter extends XWListAdapter { int iconID; ImageView marker = (ImageView)layout.findViewById( R.id.msg_marker ); - if ( summary.isRelayGame() ) { + CommsConnType conType = summary.conType; + if ( CommsConnType.COMMS_CONN_RELAY == conType ) { if ( summary.pendingMsgLevel != GameSummary.MSG_FLAGS_NONE ) { iconID = R.drawable.ic_popup_sync_1; } else { iconID = R.drawable.relaygame; } + } else if ( CommsConnType.COMMS_CONN_BT == conType ) { + iconID = android.R.drawable.stat_sys_data_bluetooth; } else { iconID = R.drawable.sologame; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index aa3501d26..ac6ebacd5 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -380,13 +380,11 @@ public class GameUtils { return rowid; } - public static long makeNewNetGame( Context context, String room, - String inviteID, int[] lang, - int nPlayersT, int nPlayersH ) + private static long makeNewMultiGame( Context context, CommsAddrRec addr, + int[] lang, int nPlayersT, + int nPlayersH, String inviteID ) { long rowid = -1; - CommsAddrRec addr = new CommsAddrRec( context ); - addr.ip_relay_invite = room; CurGameInfo gi = new CurGameInfo( context, true ); gi.setLang( lang[0] ); @@ -405,6 +403,20 @@ public class GameUtils { return rowid; } + public static long makeNewNetGame( Context context, String room, + String inviteID, int[] lang, + int nPlayersT, int nPlayersH ) + { + long rowid = -1; + CommsAddrRec addr = + new CommsAddrRec( context, + CommsAddrRec.CommsConnType.COMMS_CONN_RELAY ); + addr.ip_relay_invite = room; + + return makeNewMultiGame( context, addr, lang, nPlayersT, + nPlayersH, inviteID ); + } + public static long makeNewNetGame( Context context, String room, String inviteID, int lang, int nPlayers ) { @@ -418,6 +430,17 @@ public class GameUtils { info.nPlayers ); } + public static long makeNewBTGame( Context context, boolean fixme ) + { + long rowid = -1; + CommsAddrRec addr = + new CommsAddrRec( context, + CommsAddrRec.CommsConnType.COMMS_CONN_BT ); + + int[] lang = { 1 }; // English + return makeNewMultiGame( context, addr, lang, 2, 1, null ); + } + public static void launchInviteActivity( Context context, boolean choseEmail, String room, String inviteID, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java index b04d7aa90..e521b7ada 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java @@ -170,12 +170,12 @@ public class NewGameActivity extends XWActivity private void makeNewBTGame( boolean useDefaults ) { - Utils.notImpl( this ); + GameUtils.makeNewBTGame( this, useDefaults ); + finish(); } private void checkEnableBT( boolean force ) { - DbgUtils.logf( "checkEnableBT" ); boolean enabled = BTConnection.BTEnabled(); if ( force || enabled != m_showsOn ) { @@ -191,14 +191,14 @@ public class NewGameActivity extends XWActivity button = (Button)findViewById( R.id.newgame_invite_bt ); button.setOnClickListener( new View.OnClickListener() { @Override - public void onClick( View v ) { + public void onClick( View v ) { makeNewBTGame( true ); } } ); button = (Button)findViewById( R.id.newgame_bt_config ); button.setOnClickListener( new View.OnClickListener() { @Override - public void onClick( View v ) { + public void onClick( View v ) { makeNewBTGame( false ); } } ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommsAddrRec.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommsAddrRec.java index a6dddf6dc..f95469c31 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommsAddrRec.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommsAddrRec.java @@ -48,17 +48,28 @@ public class CommsAddrRec { public boolean ip_relay_seeksPublicRoom; public boolean ip_relay_advertiseRoom; + // bt case + public String bt_hostName; + public byte[] bt_btAddr; // array of 6 bytes on the C side + // sms case - public String sms_phone; - public int sms_port; // NBS port, if they still use those + // public String sms_phone; + // public int sms_port; // NBS port, if they still use those + + public CommsAddrRec( Context context, CommsConnType cTyp ) + { + conType = cTyp; + if ( CommsConnType.COMMS_CONN_RELAY == cTyp ) { + ip_relay_hostName = CommonPrefs.getDefaultRelayHost( context ); + ip_relay_port = CommonPrefs.getDefaultRelayPort( context ); + ip_relay_seeksPublicRoom = false; + ip_relay_advertiseRoom = false; + } + } public CommsAddrRec( Context context ) { - conType = CommsConnType.COMMS_CONN_RELAY; - ip_relay_hostName = CommonPrefs.getDefaultRelayHost( context ); - ip_relay_port = CommonPrefs.getDefaultRelayPort( context ); - ip_relay_seeksPublicRoom = false; - ip_relay_advertiseRoom = false; + this( context, CommsConnType.COMMS_CONN_RELAY ); } public CommsAddrRec( final CommsAddrRec src ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java index ead5c034b..eeebfd12e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java @@ -147,7 +147,7 @@ public class GameSummary { public String summarizeRole() { String result = null; - if ( isRelayGame() ) { + if ( isMultiGame() ) { if ( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY == conType ) { int fmtID; @@ -166,7 +166,7 @@ public class GameSummary { return result; } - public boolean isRelayGame() + public boolean isMultiGame() { // This definition will expand as other transports are added return ( null != conType