mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
create BT game and display with BT icon using hard-coded defaults for
now and no addressing. Fails in assert when trying to send as BT addressing isn't handled yet.
This commit is contained in:
parent
beef55e3ac
commit
2c24441ff3
5 changed files with 58 additions and 20 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue