mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
put a different title on notifications when it's now a player's
turn. Probably only matters in three-device games, but I like it.
This commit is contained in:
parent
1e50181b12
commit
fe0504a308
8 changed files with 460 additions and 432 deletions
File diff suppressed because it is too large
Load diff
|
@ -1496,6 +1496,7 @@
|
||||||
device, and the body that appears when you pull the notifications
|
device, and the body that appears when you pull the notifications
|
||||||
down. -->
|
down. -->
|
||||||
<string name="notify_title_fmt">Move in game %1$s</string>
|
<string name="notify_title_fmt">Move in game %1$s</string>
|
||||||
|
<string name="notify_title_turn_fmt">Your turn in game %1$s</string>
|
||||||
<string name="notify_chat_title_fmt">Chat message in game %1$s</string>
|
<string name="notify_chat_title_fmt">Chat message in game %1$s</string>
|
||||||
<string name="notify_chat_body_fmt">%1$s: %2$s</string>
|
<string name="notify_chat_body_fmt">%1$s: %2$s</string>
|
||||||
<!--
|
<!--
|
||||||
|
@ -2615,10 +2616,10 @@
|
||||||
|
|
||||||
<string name="str_no_hint_found">Cannot find any moves</string>
|
<string name="str_no_hint_found">Cannot find any moves</string>
|
||||||
|
|
||||||
<string name="not_again_rematch_two_only">The Rematch button is
|
<string name="not_again_rematch_two_only">Rematch is limited to
|
||||||
disabled because, for now anyway, rematch is limited to two-person
|
two-person games, at least for now, because it\'s harder with more
|
||||||
games. I think it\'s rare that people play with more than two. Let
|
devices and I think it\'s rare that people play with more than
|
||||||
me know if I\'m wrong and I\'ll try harder to make it work.</string>
|
two. Let me know if I\'m wrong and I\'ll up the priority.</string>
|
||||||
|
|
||||||
<string name="enable_relay_toself_title">Enable relay invites to self</string>
|
<string name="enable_relay_toself_title">Enable relay invites to self</string>
|
||||||
<string name="enable_relay_toself_summary">(To aid testing and debugging)</string>
|
<string name="enable_relay_toself_summary">(To aid testing and debugging)</string>
|
||||||
|
|
|
@ -1283,6 +1283,7 @@
|
||||||
device, and the body that appears when you pull the notifications
|
device, and the body that appears when you pull the notifications
|
||||||
down. -->
|
down. -->
|
||||||
<string name="notify_title_fmt">Evom ni emag %1$s</string>
|
<string name="notify_title_fmt">Evom ni emag %1$s</string>
|
||||||
|
<string name="notify_title_turn_fmt">Ruoy nrut ni emag %1$s</string>
|
||||||
<string name="notify_chat_title_fmt">Tahc egassem ni emag %1$s</string>
|
<string name="notify_chat_title_fmt">Tahc egassem ni emag %1$s</string>
|
||||||
<string name="notify_chat_body_fmt">%1$s: %2$s</string>
|
<string name="notify_chat_body_fmt">%1$s: %2$s</string>
|
||||||
<!--
|
<!--
|
||||||
|
@ -2237,10 +2238,10 @@
|
||||||
<string name="not_again_comms_bt">Esu Htooteulb ot yalp tsniaga a
|
<string name="not_again_comms_bt">Esu Htooteulb ot yalp tsniaga a
|
||||||
ybraen ecived taht\'s \"deriap\" htiw sruoy.</string>
|
ybraen ecived taht\'s \"deriap\" htiw sruoy.</string>
|
||||||
<string name="str_no_hint_found">Tonnac dnif yna sevom</string>
|
<string name="str_no_hint_found">Tonnac dnif yna sevom</string>
|
||||||
<string name="not_again_rematch_two_only">Eht Hctamer nottub si
|
<string name="not_again_rematch_two_only">Hctamer si detimil ot
|
||||||
delbasid ,esuaceb rof won ,yawyna hctamer si detimil ot nosrep-owt
|
nosrep-owt ,semag ta tsael rof ,won esuaceb ti\'s redrah htiw erom
|
||||||
semag. I kniht ti\'s erar taht elpoep yalp htiw erom naht owt. Tel
|
secived dna I kniht ti\'s erar taht elpoep yalp htiw erom naht
|
||||||
em wonk fi I\'m gnorw dna I\'ll yrt redrah ot ekam ti krow.</string>
|
owt. Tel em wonk fi I\'m gnorw dna I\'ll pu eht ytiroirp.</string>
|
||||||
<string name="enable_relay_toself_title">Elbane yaler setivni ot fles</string>
|
<string name="enable_relay_toself_title">Elbane yaler setivni ot fles</string>
|
||||||
<string name="enable_relay_toself_summary">oT( dia gnitset dna )gniggubed</string>
|
<string name="enable_relay_toself_summary">oT( dia gnitset dna )gniggubed</string>
|
||||||
<!-- Shown after "resend messages" menuitem chosen -->
|
<!-- Shown after "resend messages" menuitem chosen -->
|
||||||
|
|
|
@ -1283,6 +1283,7 @@
|
||||||
device, and the body that appears when you pull the notifications
|
device, and the body that appears when you pull the notifications
|
||||||
down. -->
|
down. -->
|
||||||
<string name="notify_title_fmt">MOVE IN GAME %1$s</string>
|
<string name="notify_title_fmt">MOVE IN GAME %1$s</string>
|
||||||
|
<string name="notify_title_turn_fmt">YOUR TURN IN GAME %1$s</string>
|
||||||
<string name="notify_chat_title_fmt">CHAT MESSAGE IN GAME %1$s</string>
|
<string name="notify_chat_title_fmt">CHAT MESSAGE IN GAME %1$s</string>
|
||||||
<string name="notify_chat_body_fmt">%1$s: %2$s</string>
|
<string name="notify_chat_body_fmt">%1$s: %2$s</string>
|
||||||
<!--
|
<!--
|
||||||
|
@ -2237,10 +2238,10 @@
|
||||||
<string name="not_again_comms_bt">USE BLUETOOTH TO PLAY AGAINST A
|
<string name="not_again_comms_bt">USE BLUETOOTH TO PLAY AGAINST A
|
||||||
NEARBY DEVICE THAT\'S \"PAIRED\" WITH YOURS.</string>
|
NEARBY DEVICE THAT\'S \"PAIRED\" WITH YOURS.</string>
|
||||||
<string name="str_no_hint_found">CANNOT FIND ANY MOVES</string>
|
<string name="str_no_hint_found">CANNOT FIND ANY MOVES</string>
|
||||||
<string name="not_again_rematch_two_only">THE REMATCH BUTTON IS
|
<string name="not_again_rematch_two_only">REMATCH IS LIMITED TO
|
||||||
DISABLED BECAUSE, FOR NOW ANYWAY, REMATCH IS LIMITED TO TWO-PERSON
|
TWO-PERSON GAMES, AT LEAST FOR NOW, BECAUSE IT\'S HARDER WITH MORE
|
||||||
GAMES. I THINK IT\'S RARE THAT PEOPLE PLAY WITH MORE THAN TWO. LET
|
DEVICES AND I THINK IT\'S RARE THAT PEOPLE PLAY WITH MORE THAN
|
||||||
ME KNOW IF I\'M WRONG AND I\'LL TRY HARDER TO MAKE IT WORK.</string>
|
TWO. LET ME KNOW IF I\'M WRONG AND I\'LL UP THE PRIORITY.</string>
|
||||||
<string name="enable_relay_toself_title">ENABLE RELAY INVITES TO SELF</string>
|
<string name="enable_relay_toself_title">ENABLE RELAY INVITES TO SELF</string>
|
||||||
<string name="enable_relay_toself_summary">(TO AID TESTING AND DEBUGGING)</string>
|
<string name="enable_relay_toself_summary">(TO AID TESTING AND DEBUGGING)</string>
|
||||||
<!-- Shown after "resend messages" menuitem chosen -->
|
<!-- Shown after "resend messages" menuitem chosen -->
|
||||||
|
|
|
@ -595,6 +595,7 @@ public class BTService extends XWService {
|
||||||
CommsAddrRec addr = new CommsAddrRec( host.getName(),
|
CommsAddrRec addr = new CommsAddrRec( host.getName(),
|
||||||
host.getAddress() );
|
host.getAddress() );
|
||||||
|
|
||||||
|
boolean[] isLocalP = new boolean[1];
|
||||||
for ( long rowid : rowids ) {
|
for ( long rowid : rowids ) {
|
||||||
boolean consumed =
|
boolean consumed =
|
||||||
BoardDelegate.feedMessage( rowid, buffer, addr );
|
BoardDelegate.feedMessage( rowid, buffer, addr );
|
||||||
|
@ -603,10 +604,12 @@ public class BTService extends XWService {
|
||||||
new GameUtils.BackMoveResult();
|
new GameUtils.BackMoveResult();
|
||||||
if ( GameUtils.feedMessage( BTService.this, rowid,
|
if ( GameUtils.feedMessage( BTService.this, rowid,
|
||||||
buffer, addr,
|
buffer, addr,
|
||||||
m_btMsgSink, bmr ) ) {
|
m_btMsgSink, bmr,
|
||||||
|
isLocalP ) ) {
|
||||||
consumed = true;
|
consumed = true;
|
||||||
GameUtils.postMoveNotification( BTService.this,
|
GameUtils.postMoveNotification( BTService.this,
|
||||||
rowid, bmr );
|
rowid, bmr,
|
||||||
|
isLocalP[0] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !consumed ) {
|
if ( !consumed ) {
|
||||||
|
|
|
@ -875,7 +875,8 @@ public class GameUtils {
|
||||||
|
|
||||||
public static boolean feedMessages( Context context, long rowid,
|
public static boolean feedMessages( Context context, long rowid,
|
||||||
byte[][] msgs, CommsAddrRec ret,
|
byte[][] msgs, CommsAddrRec ret,
|
||||||
MultiMsgSink sink, BackMoveResult bmr )
|
MultiMsgSink sink, BackMoveResult bmr,
|
||||||
|
boolean[] isLocalOut )
|
||||||
{
|
{
|
||||||
boolean draw = false;
|
boolean draw = false;
|
||||||
Assert.assertTrue( -1 != rowid );
|
Assert.assertTrue( -1 != rowid );
|
||||||
|
@ -920,7 +921,12 @@ public class GameUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveGame( context, gamePtr, gi, lock, false );
|
saveGame( context, gamePtr, gi, lock, false );
|
||||||
summarizeAndClose( context, lock, gamePtr, gi );
|
GameSummary summary = summarizeAndClose( context, lock,
|
||||||
|
gamePtr, gi );
|
||||||
|
if ( null != isLocalOut ) {
|
||||||
|
isLocalOut[0] = 0 <= summary.turn
|
||||||
|
&& gi.players[summary.turn].isLocal;
|
||||||
|
}
|
||||||
|
|
||||||
int flags = setFromFeedImpl( feedImpl );
|
int flags = setFromFeedImpl( feedImpl );
|
||||||
if ( GameSummary.MSG_FLAGS_NONE != flags ) {
|
if ( GameSummary.MSG_FLAGS_NONE != flags ) {
|
||||||
|
@ -937,12 +943,12 @@ public class GameUtils {
|
||||||
|
|
||||||
public static boolean feedMessage( Context context, long rowid, byte[] msg,
|
public static boolean feedMessage( Context context, long rowid, byte[] msg,
|
||||||
CommsAddrRec ret, MultiMsgSink sink,
|
CommsAddrRec ret, MultiMsgSink sink,
|
||||||
BackMoveResult bmr )
|
BackMoveResult bmr, boolean[] isLocalOut )
|
||||||
{
|
{
|
||||||
Assert.assertTrue( DBUtils.ROWID_NOTFOUND != rowid );
|
Assert.assertTrue( DBUtils.ROWID_NOTFOUND != rowid );
|
||||||
byte[][] msgs = new byte[1][];
|
byte[][] msgs = new byte[1][];
|
||||||
msgs[0] = msg;
|
msgs[0] = msg;
|
||||||
return feedMessages( context, rowid, msgs, ret, sink, bmr );
|
return feedMessages( context, rowid, msgs, ret, sink, bmr, isLocalOut );
|
||||||
}
|
}
|
||||||
|
|
||||||
// This *must* involve a reset if the language is changing!!!
|
// This *must* involve a reset if the language is changing!!!
|
||||||
|
@ -1079,7 +1085,8 @@ public class GameUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void postMoveNotification( Context context, long rowid,
|
public static void postMoveNotification( Context context, long rowid,
|
||||||
BackMoveResult bmr )
|
BackMoveResult bmr,
|
||||||
|
boolean isTurnNow )
|
||||||
{
|
{
|
||||||
if ( null != bmr ) {
|
if ( null != bmr ) {
|
||||||
Intent intent = GamesListDelegate.makeRowidIntent( context, rowid );
|
Intent intent = GamesListDelegate.makeRowidIntent( context, rowid );
|
||||||
|
@ -1095,8 +1102,12 @@ public class GameUtils {
|
||||||
msg = bmr.m_chat;
|
msg = bmr.m_chat;
|
||||||
}
|
}
|
||||||
} else if ( null != bmr.m_lmi ) {
|
} else if ( null != bmr.m_lmi ) {
|
||||||
|
if ( isTurnNow ) {
|
||||||
|
titleID = R.string.notify_title_turn_fmt;
|
||||||
|
} else {
|
||||||
titleID = R.string.notify_title_fmt;
|
titleID = R.string.notify_title_fmt;
|
||||||
msg = bmr.m_lmi.format( context ); // NPE
|
}
|
||||||
|
msg = bmr.m_lmi.format( context );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 != titleID ) {
|
if ( 0 != titleID ) {
|
||||||
|
|
|
@ -452,7 +452,8 @@ public class RelayService extends XWService
|
||||||
startService( this ); // bad name: will *stop* threads too
|
startService( this ); // bad name: will *stop* threads too
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupNotifications( String[] relayIDs, BackMoveResult[] bmrs )
|
private void setupNotifications( String[] relayIDs, BackMoveResult[] bmrs,
|
||||||
|
ArrayList<Boolean> locals )
|
||||||
{
|
{
|
||||||
for ( int ii = 0; ii < relayIDs.length; ++ii ) {
|
for ( int ii = 0; ii < relayIDs.length; ++ii ) {
|
||||||
String relayID = relayIDs[ii];
|
String relayID = relayIDs[ii];
|
||||||
|
@ -460,7 +461,8 @@ public class RelayService extends XWService
|
||||||
long[] rowids = DBUtils.getRowIDsFor( this, relayID );
|
long[] rowids = DBUtils.getRowIDsFor( this, relayID );
|
||||||
if ( null != rowids ) {
|
if ( null != rowids ) {
|
||||||
for ( long rowid : rowids ) {
|
for ( long rowid : rowids ) {
|
||||||
GameUtils.postMoveNotification( this, rowid, bmr );
|
GameUtils.postMoveNotification( this, rowid, bmr,
|
||||||
|
locals.get(ii) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -993,9 +995,10 @@ public class RelayService extends XWService
|
||||||
RelayMsgSink sink = new RelayMsgSink();
|
RelayMsgSink sink = new RelayMsgSink();
|
||||||
sink.setRowID( rowid );
|
sink.setRowID( rowid );
|
||||||
BackMoveResult bmr = new BackMoveResult();
|
BackMoveResult bmr = new BackMoveResult();
|
||||||
|
boolean[] isLocalP = new boolean[1];
|
||||||
if ( GameUtils.feedMessage( this, rowid, msg, s_addr,
|
if ( GameUtils.feedMessage( this, rowid, msg, s_addr,
|
||||||
sink, bmr ) ) {
|
sink, bmr, isLocalP ) ) {
|
||||||
GameUtils.postMoveNotification( this, rowid, bmr );
|
GameUtils.postMoveNotification( this, rowid, bmr, isLocalP[0] );
|
||||||
} else {
|
} else {
|
||||||
DbgUtils.logdf( "feedMessage(): background dropped it" );
|
DbgUtils.logdf( "feedMessage(): background dropped it" );
|
||||||
}
|
}
|
||||||
|
@ -1018,9 +1021,11 @@ public class RelayService extends XWService
|
||||||
RelayMsgSink sink = new RelayMsgSink();
|
RelayMsgSink sink = new RelayMsgSink();
|
||||||
int nameCount = relayIDs.length;
|
int nameCount = relayIDs.length;
|
||||||
ArrayList<String> idsWMsgs = new ArrayList<String>( nameCount );
|
ArrayList<String> idsWMsgs = new ArrayList<String>( nameCount );
|
||||||
|
ArrayList<Boolean> isLocals = new ArrayList<Boolean>( nameCount );
|
||||||
ArrayList<BackMoveResult> bmrs =
|
ArrayList<BackMoveResult> bmrs =
|
||||||
new ArrayList<BackMoveResult>( nameCount );
|
new ArrayList<BackMoveResult>( nameCount );
|
||||||
|
|
||||||
|
boolean[] isLocalP = new boolean[1];
|
||||||
for ( int ii = 0; ii < nameCount; ++ii ) {
|
for ( int ii = 0; ii < nameCount; ++ii ) {
|
||||||
byte[][] forOne = msgs[ii];
|
byte[][] forOne = msgs[ii];
|
||||||
|
|
||||||
|
@ -1028,12 +1033,15 @@ public class RelayService extends XWService
|
||||||
if ( null != forOne ) {
|
if ( null != forOne ) {
|
||||||
BackMoveResult bmr = new BackMoveResult();
|
BackMoveResult bmr = new BackMoveResult();
|
||||||
sink.setRowID( rowIDs[ii] );
|
sink.setRowID( rowIDs[ii] );
|
||||||
|
// since BoardDelegate.feedMessages can't know:
|
||||||
|
isLocalP[0] = false;
|
||||||
if ( BoardDelegate.feedMessages( rowIDs[ii], forOne, s_addr )
|
if ( BoardDelegate.feedMessages( rowIDs[ii], forOne, s_addr )
|
||||||
|| GameUtils.feedMessages( this, rowIDs[ii],
|
|| GameUtils.feedMessages( this, rowIDs[ii],
|
||||||
forOne, s_addr,
|
forOne, s_addr,
|
||||||
sink, bmr ) ) {
|
sink, bmr, isLocalP ) ) {
|
||||||
idsWMsgs.add( relayIDs[ii] );
|
idsWMsgs.add( relayIDs[ii] );
|
||||||
bmrs.add( bmr );
|
bmrs.add( bmr );
|
||||||
|
isLocals.add( isLocalP[0] );
|
||||||
} else {
|
} else {
|
||||||
DbgUtils.logf( "RelayService.process(): message for %s (rowid %d)"
|
DbgUtils.logf( "RelayService.process(): message for %s (rowid %d)"
|
||||||
+ " not consumed", relayIDs[ii], rowIDs[ii] );
|
+ " not consumed", relayIDs[ii], rowIDs[ii] );
|
||||||
|
@ -1045,7 +1053,7 @@ public class RelayService extends XWService
|
||||||
idsWMsgs.toArray( tmp );
|
idsWMsgs.toArray( tmp );
|
||||||
BackMoveResult[] bmrsa = new BackMoveResult[bmrs.size()];
|
BackMoveResult[] bmrsa = new BackMoveResult[bmrs.size()];
|
||||||
bmrs.toArray( bmrsa );
|
bmrs.toArray( bmrsa );
|
||||||
setupNotifications( tmp, bmrsa );
|
setupNotifications( tmp, bmrsa, isLocals );
|
||||||
}
|
}
|
||||||
sink.send( this );
|
sink.send( this );
|
||||||
}
|
}
|
||||||
|
|
|
@ -718,6 +718,7 @@ public class SMSService extends XWService {
|
||||||
if ( null == rowids || 0 == rowids.length ) {
|
if ( null == rowids || 0 == rowids.length ) {
|
||||||
sendDiedPacket( addr.sms_phone, gameID );
|
sendDiedPacket( addr.sms_phone, gameID );
|
||||||
} else {
|
} else {
|
||||||
|
boolean[] isLocalP = new boolean[1];
|
||||||
for ( long rowid : rowids ) {
|
for ( long rowid : rowids ) {
|
||||||
if ( BoardDelegate.feedMessage( rowid, msg, addr ) ) {
|
if ( BoardDelegate.feedMessage( rowid, msg, addr ) ) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -725,8 +726,9 @@ public class SMSService extends XWService {
|
||||||
SMSMsgSink sink = new SMSMsgSink( this );
|
SMSMsgSink sink = new SMSMsgSink( this );
|
||||||
BackMoveResult bmr = new BackMoveResult();
|
BackMoveResult bmr = new BackMoveResult();
|
||||||
if ( GameUtils.feedMessage( this, rowid, msg, addr,
|
if ( GameUtils.feedMessage( this, rowid, msg, addr,
|
||||||
sink, bmr ) ) {
|
sink, bmr, isLocalP ) ) {
|
||||||
GameUtils.postMoveNotification( this, rowid, bmr );
|
GameUtils.postMoveNotification( this, rowid, bmr,
|
||||||
|
isLocalP[0] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue