return count of messages sent from comms_resendAll(), and post it as a

toast so user sees something happened.
This commit is contained in:
Eric House 2015-08-13 07:05:06 -07:00
parent dea75a815e
commit 3a32d3a17b
10 changed files with 47 additions and 17 deletions

View file

@ -411,6 +411,9 @@ public final class R {
*/ */
public static final int query_trade_fmt=0x7f07000b; public static final int query_trade_fmt=0x7f07000b;
public static final int resend_finished_fmt=0x7f070007; public static final int resend_finished_fmt=0x7f070007;
/** Shown after "resend messages" menuitem chosen
*/
public static final int resent_msgs_fmt=0x7f07001f;
/** Intro to the paragraph listing all of the tiles remaining /** Intro to the paragraph listing all of the tiles remaining
*/ */
public static final int strd_remains_expl_fmt=0x7f07000a; public static final int strd_remains_expl_fmt=0x7f07000a;
@ -848,7 +851,6 @@ public final class R {
public static final int checking_for_fmt=0x7f0502ff; public static final int checking_for_fmt=0x7f0502ff;
public static final int checking_title=0x7f0502fe; public static final int checking_title=0x7f0502fe;
public static final int checkupdates_none_found=0x7f05022b; public static final int checkupdates_none_found=0x7f05022b;
public static final int clip_label=0x7f05030f;
/** color of the "crosshairs", lines drawn vertically and /** color of the "crosshairs", lines drawn vertically and
horizontally through the square the user is currently horizontally through the square the user is currently
touching in order to guide the fat-fingered (most of us) in touching in order to guide the fat-fingered (most of us) in
@ -1333,7 +1335,6 @@ public final class R {
*/ */
public static final int initial_player_minutes=0x7f050126; public static final int initial_player_minutes=0x7f050126;
public static final int invite_choice_bt=0x7f05016b; public static final int invite_choice_bt=0x7f05016b;
public static final int invite_choice_clip=0x7f05030d;
public static final int invite_choice_email=0x7f05016a; public static final int invite_choice_email=0x7f05016a;
public static final int invite_choice_nfc=0x7f05016c; public static final int invite_choice_nfc=0x7f05016c;
/** EXPLAIN ME /** EXPLAIN ME
@ -1356,7 +1357,6 @@ public final class R {
*/ */
public static final int invite_chooser_fmt=0x7f050171; public static final int invite_chooser_fmt=0x7f050171;
public static final int invite_chooser_sms=0x7f050173; public static final int invite_chooser_sms=0x7f050173;
public static final int invite_copied=0x7f05030e;
public static final int invite_dict_missing_body_fmt=0x7f05023b; public static final int invite_dict_missing_body_fmt=0x7f05023b;
public static final int invite_dict_missing_body_noname_fmt=0x7f05023c; public static final int invite_dict_missing_body_noname_fmt=0x7f05023c;
public static final int invite_dict_missing_title=0x7f05023a; public static final int invite_dict_missing_title=0x7f05023a;
@ -1965,7 +1965,6 @@ public final class R {
main Board screen main Board screen
*/ */
public static final int not_again_chat=0x7f0501b1; public static final int not_again_chat=0x7f0501b1;
public static final int not_again_clip_expl_fmt=0x7f050310;
public static final int not_again_comms_bt=0x7f05030b; public static final int not_again_comms_bt=0x7f05030b;
public static final int not_again_comms_relay=0x7f050309; public static final int not_again_comms_relay=0x7f050309;
public static final int not_again_comms_sms=0x7f05030a; public static final int not_again_comms_sms=0x7f05030a;

View file

@ -1677,20 +1677,22 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1changeDict
} }
#endif #endif
JNIEXPORT void JNICALL JNIEXPORT jint JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll
( JNIEnv* env, jclass C, jint gamePtr, jboolean force, jboolean thenAck ) ( JNIEnv* env, jclass C, jint gamePtr, jboolean force, jboolean thenAck )
{ {
jint result;
XWJNI_START(); XWJNI_START();
CommsCtxt* comms = state->game.comms; CommsCtxt* comms = state->game.comms;
XP_ASSERT( !!comms ); XP_ASSERT( !!comms );
(void)comms_resendAll( comms, force ); result = comms_resendAll( comms, force );
if ( thenAck ) { if ( thenAck ) {
#ifdef XWFEATURE_COMMSACK #ifdef XWFEATURE_COMMSACK
comms_ackAny( comms ); comms_ackAny( comms );
#endif #endif
} }
XWJNI_END(); XWJNI_END();
return result;
} }
#ifdef XWFEATURE_COMMSACK #ifdef XWFEATURE_COMMSACK

View file

@ -2532,4 +2532,10 @@
<string name="str_no_hint_found">Cannot find any moves</string> <string name="str_no_hint_found">Cannot find any moves</string>
<!-- Shown after "resend messages" menuitem chosen -->
<plurals name="resent_msgs_fmt">
<item quantity="one">One message sent</item>
<item quantity="other">%1$s messages sent</item>
</plurals>
</resources> </resources>

View file

@ -2181,4 +2181,9 @@
<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>
<!-- Shown after "resend messages" menuitem chosen -->
<plurals name="resent_msgs_fmt">
<item quantity="one">Eno egassem tnes</item>
<item quantity="other">%1$s segassem tnes</item>
</plurals>
</resources> </resources>

View file

@ -2181,4 +2181,9 @@
<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>
<!-- Shown after "resend messages" menuitem chosen -->
<plurals name="resent_msgs_fmt">
<item quantity="one">ONE MESSAGE SENT</item>
<item quantity="other">%1$s MESSAGES SENT</item>
</plurals>
</resources> </resources>

View file

@ -2011,6 +2011,11 @@ public class BoardDelegate extends DelegateBase
m_dlgTitle = msg.arg1; m_dlgTitle = msg.arg1;
showDialog( DlgID.GAME_OVER ); showDialog( DlgID.GAME_OVER );
break; break;
case JNIThread.MSGS_SENT:
int nSent = (Integer)msg.obj;
showToast( getQuantityString( R.plurals.resent_msgs_fmt,
nSent, nSent ) );
break;
} }
} }
}; };

View file

@ -102,6 +102,7 @@ public class JNIThread extends Thread {
public static final int TOOLBAR_STATES = 4; public static final int TOOLBAR_STATES = 4;
public static final int GOT_WORDS = 5; public static final int GOT_WORDS = 5;
public static final int GAME_OVER = 6; public static final int GAME_OVER = 6;
public static final int MSGS_SENT = 7;
public class GameStateInfo implements Cloneable { public class GameStateInfo implements Cloneable {
public int visTileCount; public int visTileCount;
@ -522,9 +523,11 @@ public class JNIThread extends Thread {
break; break;
case CMD_RESEND: case CMD_RESEND:
XwJNI.comms_resendAll( m_jniGamePtr, int nSent =
((Boolean)args[0]).booleanValue(), XwJNI.comms_resendAll( m_jniGamePtr,
((Boolean)args[1]).booleanValue() ); ((Boolean)args[0]).booleanValue(),
((Boolean)args[1]).booleanValue() );
Message.obtain( m_handler, MSGS_SENT, nSent ).sendToTarget();
break; break;
// case CMD_ACKANY: // case CMD_ACKANY:
// XwJNI.comms_ackAny( m_jniGamePtr ); // XwJNI.comms_ackAny( m_jniGamePtr );

View file

@ -317,8 +317,8 @@ public class XwJNI {
public static native void comms_getAddr( int gamePtr, CommsAddrRec addr ); public static native void comms_getAddr( int gamePtr, CommsAddrRec addr );
public static native CommsAddrRec[] comms_getAddrs( int gamePtr ); public static native CommsAddrRec[] comms_getAddrs( int gamePtr );
public static native void comms_setAddr( int gamePtr, CommsAddrRec addr ); public static native void comms_setAddr( int gamePtr, CommsAddrRec addr );
public static native void comms_resendAll( int gamePtr, boolean force, public static native int comms_resendAll( int gamePtr, boolean force,
boolean andAck ); boolean andAck );
public static native void comms_ackAny( int gamePtr ); public static native void comms_ackAny( int gamePtr );
public static native void comms_transportFailed( int gamePtr, public static native void comms_transportFailed( int gamePtr,
CommsConnType failed ); CommsConnType failed );

View file

@ -1436,9 +1436,10 @@ send_ack( CommsCtxt* comms )
(void)send_via_relay( comms, XWRELAY_ACK, comms->rr.myHostID, NULL, 0 ); (void)send_via_relay( comms, XWRELAY_ACK, comms->rr.myHostID, NULL, 0 );
} }
XP_Bool XP_S16
comms_resendAll( CommsCtxt* comms, XP_Bool force ) comms_resendAll( CommsCtxt* comms, XP_Bool force )
{ {
XP_S16 count = 0;
XP_Bool success = XP_TRUE; XP_Bool success = XP_TRUE;
XP_ASSERT( !!comms ); XP_ASSERT( !!comms );
@ -1452,9 +1453,13 @@ comms_resendAll( CommsCtxt* comms, XP_Bool force )
MsgQueueElem* msg; MsgQueueElem* msg;
for ( msg = comms->msgQueueHead; !!msg; msg = msg->next ) { for ( msg = comms->msgQueueHead; !!msg; msg = msg->next ) {
if ( 0 > sendMsg( comms, msg ) ) { XP_S16 len = sendMsg( comms, msg );
if ( 0 > len ) {
success = XP_FALSE; success = XP_FALSE;
break; break;
} else {
XP_ASSERT( 0 < len );
++count;
} }
} }
@ -1465,9 +1470,9 @@ comms_resendAll( CommsCtxt* comms, XP_Bool force )
comms->nextResend = now + comms->resendBackoff; comms->nextResend = now + comms->resendBackoff;
} }
} }
XP_LOGF( TAGFMT() "=>%d", TAGPRMS, success ); XP_LOGF( TAGFMT() "=>%d", TAGPRMS, count );
return success; return count;
} /* comms_resend */ } /* comms_resendAll */
#ifdef XWFEATURE_COMMSACK #ifdef XWFEATURE_COMMSACK
void void

View file

@ -214,7 +214,7 @@ void addrFromStream( CommsAddrRec* addr, XWStreamCtxt* stream );
void addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addr ); void addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addr );
XP_S16 comms_send( CommsCtxt* comms, XWStreamCtxt* stream ); XP_S16 comms_send( CommsCtxt* comms, XWStreamCtxt* stream );
XP_Bool comms_resendAll( CommsCtxt* comms, XP_Bool force ); XP_S16 comms_resendAll( CommsCtxt* comms, XP_Bool force );
XP_U16 comms_getChannelSeed( CommsCtxt* comms ); XP_U16 comms_getChannelSeed( CommsCtxt* comms );
#ifdef XWFEATURE_COMMSACK #ifdef XWFEATURE_COMMSACK