mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
post notifications when moves arrive and game isn't open. And handle
BAD_PROTO event (untested).
This commit is contained in:
parent
ba40028a91
commit
15f8cd5b33
4 changed files with 38 additions and 5 deletions
|
@ -1852,8 +1852,15 @@
|
|||
<string name="summary_bt_wait">Not yet connected</string>
|
||||
<string name="summary_bt_gameover">Game over</string>
|
||||
<string name="summary_bt_conn">Game in play</string>
|
||||
<string name="new_bt_title">New Bluetooth game</string>
|
||||
<string name="new_bt_title">New game via Bluetooth</string>
|
||||
<string name="new_bt_bodyf">Paired device %s has invited you to
|
||||
play</string>
|
||||
|
||||
<string name="bt_bad_protof">Crosswords on %s wrong version for
|
||||
Bluetooth play.</string>
|
||||
|
||||
<string name="new_btmove_title">New move via Bluetooth</string>
|
||||
<string name="new_btmove_body">One or more moves has arrived</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -596,10 +596,8 @@ public class BTService extends Service {
|
|||
lang, nPlayersT, nPlayersH );
|
||||
result = BTCmd.INVITE_ACCPT;
|
||||
|
||||
Intent intent = new Intent( this, DispatchNotify.class );
|
||||
intent.putExtra( DispatchNotify.GAMEID_EXTRA, gameID );
|
||||
String body = Utils.format( this, R.string.new_bt_bodyf, sender );
|
||||
Utils.postNotification( this, intent, R.string.new_bt_title, body );
|
||||
postNotification( gameID, R.string.new_bt_title, body );
|
||||
} else {
|
||||
result = BTCmd.INVITE_DUPID;
|
||||
}
|
||||
|
@ -642,6 +640,8 @@ public class BTService extends Service {
|
|||
} else if ( GameUtils.feedMessage( this, gameID, buffer,
|
||||
addr, m_btMsgSink ) ) {
|
||||
DbgUtils.logf( "GameUtils.feedMessage took it" );
|
||||
postNotification( gameID, R.string.new_btmove_title,
|
||||
R.string.new_btmove_body );
|
||||
// do nothing
|
||||
} else {
|
||||
DbgUtils.logf( "nobody to take message for gameID", gameID );
|
||||
|
@ -741,6 +741,19 @@ public class BTService extends Service {
|
|||
return dos;
|
||||
}
|
||||
|
||||
private void postNotification( int gameID, int title, int body )
|
||||
{
|
||||
postNotification( gameID, title, getString( body ) );
|
||||
}
|
||||
|
||||
private void postNotification( int gameID, int title, String body )
|
||||
{
|
||||
Intent intent = new Intent( this, DispatchNotify.class );
|
||||
intent.putExtra( DispatchNotify.GAMEID_EXTRA, gameID );
|
||||
Utils.postNotification( this, intent, R.string.new_btmove_title,
|
||||
body );
|
||||
}
|
||||
|
||||
private Thread killSocketIn( final BluetoothSocket socket, int seconds )
|
||||
{
|
||||
final int millis = seconds * 1000;
|
||||
|
|
|
@ -277,6 +277,19 @@ public class DlgDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
public void eventOccurred( BTService.BTEvent event, final Object ... args )
|
||||
{
|
||||
switch( event ) {
|
||||
case BAD_PROTO:
|
||||
String msg = Utils.format( m_activity, R.string.bt_bad_protof,
|
||||
(String)args[0] );
|
||||
DbgUtils.showf( m_activity, msg );
|
||||
break;
|
||||
default:
|
||||
DbgUtils.logf( "eventOccurred: unhandled event %s", event.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
private Dialog createAboutDialog()
|
||||
{
|
||||
final View view = Utils.inflate( m_activity, R.layout.about_dlg );
|
||||
|
|
|
@ -177,7 +177,7 @@ public class XWActivity extends Activity
|
|||
// BTService.BTEventListener interface
|
||||
public void eventOccurred( BTService.BTEvent event, final Object ... args )
|
||||
{
|
||||
DbgUtils.logf( "eventOccurred: unhandled event %s", event.toString() );
|
||||
m_delegate.eventOccurred( event, args );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue