mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
use rowid as notification id for all types of games, and cancel when
games deleted.
This commit is contained in:
parent
19333e33ac
commit
4bae56e631
6 changed files with 20 additions and 35 deletions
|
@ -444,7 +444,7 @@ public class BTService extends Service {
|
|||
result = BTCmd.INVITE_ACCPT;
|
||||
String body = Utils.format( BTService.this,
|
||||
R.string.new_bt_bodyf, sender );
|
||||
postNotification( gameID, R.string.new_bt_title, body );
|
||||
postNotification( gameID, R.string.new_bt_title, body, rowid );
|
||||
}
|
||||
} else {
|
||||
result = BTCmd.INVITE_DUPID;
|
||||
|
@ -497,7 +497,7 @@ public class BTService extends Service {
|
|||
buffer, addr,
|
||||
m_btMsgSink ) ) {
|
||||
postNotification( gameID, R.string.new_btmove_title,
|
||||
R.string.new_move_body );
|
||||
R.string.new_move_body, rowid );
|
||||
// do nothing
|
||||
} else {
|
||||
DbgUtils.logf( "nobody took msg for gameID %X",
|
||||
|
@ -967,16 +967,17 @@ public class BTService extends Service {
|
|||
return dos;
|
||||
}
|
||||
|
||||
private void postNotification( int gameID, int title, int body )
|
||||
private void postNotification( int gameID, int title, int body, long rowid )
|
||||
{
|
||||
postNotification( gameID, title, getString( body ) );
|
||||
postNotification( gameID, title, getString( body ), rowid );
|
||||
}
|
||||
|
||||
private void postNotification( int gameID, int title, String body )
|
||||
private void postNotification( int gameID, int title, String body,
|
||||
long rowid )
|
||||
{
|
||||
Intent intent = GamesList.makeGameIDIntent( this, gameID );
|
||||
Utils.postNotification( this, intent, R.string.new_btmove_title,
|
||||
body, gameID );
|
||||
body, (int)rowid );
|
||||
}
|
||||
|
||||
private Thread killSocketIn( final BluetoothSocket socket )
|
||||
|
|
|
@ -1732,7 +1732,7 @@ public class BoardActivity extends XWActivity
|
|||
if ( null != m_xport ) {
|
||||
warnIfNoTransport();
|
||||
trySendChats();
|
||||
removeNotifications();
|
||||
Utils.cancelNotification( this, (int)m_rowid );
|
||||
m_xport.tickle( m_connType );
|
||||
tryInvites();
|
||||
}
|
||||
|
@ -1923,26 +1923,6 @@ public class BoardActivity extends XWActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void removeNotifications()
|
||||
{
|
||||
int id = 0;
|
||||
switch( m_connType ) {
|
||||
case COMMS_CONN_BT:
|
||||
case COMMS_CONN_SMS:
|
||||
id = m_gi.gameID;
|
||||
break;
|
||||
case COMMS_CONN_RELAY:
|
||||
String relayID = DBUtils.getRelayID( this, m_rowid );
|
||||
if ( null != relayID ) {
|
||||
id = relayID.hashCode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ( 0 != id ) {
|
||||
Utils.cancelNotification( this, id );
|
||||
}
|
||||
}
|
||||
|
||||
private void tryInvites()
|
||||
{
|
||||
if ( XWApp.BTSUPPORTED || XWApp.SMSSUPPORTED ) {
|
||||
|
|
|
@ -311,6 +311,7 @@ public class GameUtils {
|
|||
GameLock lock = new GameLock( rowid, true );
|
||||
if ( lock.tryLock() ) {
|
||||
tellDied( context, lock, informNow );
|
||||
Utils.cancelNotification( context, (int)rowid );
|
||||
DBUtils.deleteGame( context, lock );
|
||||
lock.unlock();
|
||||
} else {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class RelayService extends Service {
|
|||
String msg = Utils.format( this, R.string.notify_bodyf,
|
||||
GameUtils.getName( this, rowid ) );
|
||||
Utils.postNotification( this, intent, R.string.notify_title,
|
||||
msg, relayID.hashCode() );
|
||||
msg, (int)rowid );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -432,7 +432,8 @@ public class SMSService extends Service {
|
|||
MultiService.OWNER_SMS );
|
||||
intent.putExtra( MultiService.INVITER,
|
||||
Utils.phoneToContact( this, phone, true ) );
|
||||
MultiService.postMissingDictNotification( this, intent, gameID );
|
||||
MultiService.postMissingDictNotification( this, intent,
|
||||
gameID );
|
||||
}
|
||||
break;
|
||||
case DATA:
|
||||
|
@ -542,7 +543,7 @@ public class SMSService extends Service {
|
|||
String owner = Utils.phoneToContact( this, phone, true );
|
||||
String body = Utils.format( this, R.string.new_name_bodyf,
|
||||
owner );
|
||||
postNotification( gameID, R.string.new_sms_title, body );
|
||||
postNotification( gameID, R.string.new_sms_title, body, rowid );
|
||||
|
||||
ackInvite( phone, gameID );
|
||||
}
|
||||
|
@ -607,18 +608,19 @@ public class SMSService extends Service {
|
|||
if ( GameUtils.feedMessage( this, rowid, msg, addr,
|
||||
sink ) ) {
|
||||
postNotification( gameID, R.string.new_smsmove_title,
|
||||
getString(R.string.new_move_body)
|
||||
);
|
||||
getString(R.string.new_move_body),
|
||||
rowid );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void postNotification( int gameID, int title, String body )
|
||||
private void postNotification( int gameID, int title, String body,
|
||||
long rowid )
|
||||
{
|
||||
Intent intent = GamesList.makeGameIDIntent( this, gameID );
|
||||
Utils.postNotification( this, intent, title, body, gameID );
|
||||
Utils.postNotification( this, intent, title, body, (int)rowid );
|
||||
}
|
||||
|
||||
// Runs in separate thread
|
||||
|
|
|
@ -174,7 +174,8 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static void postNotification( Context context, Intent intent,
|
||||
String title, String body, int id )
|
||||
String title, String body,
|
||||
int id )
|
||||
{
|
||||
/* s_nextCode: per this link
|
||||
http://stackoverflow.com/questions/10561419/scheduling-more-than-one-pendingintent-to-same-activity-using-alarmmanager
|
||||
|
|
Loading…
Add table
Reference in a new issue