From 7824df67f5185be7b2a548a5400a10bb7939c964 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 13 Aug 2015 06:54:07 -0700 Subject: [PATCH 01/28] copy over VARIANT compile-time flag stuff. Not sure how it got dropped in this branch. --- xwords4/android/XWords4/jni/Android.mk | 4 ++-- xwords4/android/XWords4/jni/xwjni.c | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/xwords4/android/XWords4/jni/Android.mk b/xwords4/android/XWords4/jni/Android.mk index b0c291a38..e72775ddb 100644 --- a/xwords4/android/XWords4/jni/Android.mk +++ b/xwords4/android/XWords4/jni/Android.mk @@ -1,4 +1,4 @@ -# -*- mode: Makefile; compile-command: "cd ../; ${NDK_ROOT}/ndk-build -j3"; -*- +# -*- mode: Makefile; -*- LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) @@ -41,7 +41,7 @@ LOCAL_DEFINES += \ -DCOMMON_LAYOUT \ -DCOMMS_VERSION=1 \ -DINITIAL_CLIENT_VERS=${INITIAL_CLIENT_VERS} \ - -DVARIANT=\"${VARIANT}\" \ + -DVARIANT_${VARIANT} \ -DRELAY_ROOM_DEFAULT=\"\" \ -D__LITTLE_ENDIAN \ diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 4beaceee0..00f0a2ddf 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -469,18 +469,17 @@ JNIEXPORT jstring JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getUUID ( JNIEnv* env, jclass C ) { - jstring jstr = NULL; + jstring jstr = #ifdef XWFEATURE_BLUETOOTH - const char* uuid; - if ( 0 == XP_STRCMP( VARIANT, "xw4" ) ) { - uuid = XW_BT_UUID; - } else if ( 0 == XP_STRCMP( VARIANT, "xw4dbg" ) ) { - uuid = XW_BT_UUID_DBG; - } else { - XP_ASSERT(0); - } - jstr = (*env)->NewStringUTF( env, uuid ); +# if defined VARIANT_xw4 + (*env)->NewStringUTF( env, XW_BT_UUID ) +# elif defined VARIANT_xw4dbg + (*env)->NewStringUTF( env, XW_BT_UUID_DBG ) +# endif +#else + NULL #endif + ; return jstr; } From dea75a815e59224dcfa4c5a12de7be3d741d49ee Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 13 Aug 2015 07:02:57 -0700 Subject: [PATCH 02/28] vary common-code logging tag by variant --- xwords4/android/XWords4/jni/andutils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/jni/andutils.c b/xwords4/android/XWords4/jni/andutils.c index 25ac4b227..f9c2274e0 100644 --- a/xwords4/android/XWords4/jni/andutils.c +++ b/xwords4/android/XWords4/jni/andutils.c @@ -695,7 +695,13 @@ android_debugf( const char* format, ... ) va_end(ap); } - (void)__android_log_write( ANDROID_LOG_DEBUG, "xw4", buf ); + (void)__android_log_write( ANDROID_LOG_DEBUG, +# if defined VARIANT_xw4 + "xw4" +# elif defined VARIANT_xw4dbg + "x4bg" +# endif + , buf ); } #endif From 3a32d3a17b41ba9a03f91671d6bd9a47e6752b8b Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 13 Aug 2015 07:05:06 -0700 Subject: [PATCH 03/28] return count of messages sent from comms_resendAll(), and post it as a toast so user sees something happened. --- xwords4/android/XWords4/archive/R.java | 7 +++---- xwords4/android/XWords4/jni/xwjni.c | 6 ++++-- xwords4/android/XWords4/res/values/strings.xml | 6 ++++++ .../XWords4/res_src/values-ba_CK/strings.xml | 5 +++++ .../XWords4/res_src/values-ca_PS/strings.xml | 5 +++++ .../org/eehouse/android/xw4/BoardDelegate.java | 5 +++++ .../org/eehouse/android/xw4/jni/JNIThread.java | 9 ++++++--- .../src/org/eehouse/android/xw4/jni/XwJNI.java | 4 ++-- xwords4/common/comms.c | 15 ++++++++++----- xwords4/common/comms.h | 2 +- 10 files changed, 47 insertions(+), 17 deletions(-) diff --git a/xwords4/android/XWords4/archive/R.java b/xwords4/android/XWords4/archive/R.java index 0f5e81ec3..3ca5799b3 100644 --- a/xwords4/android/XWords4/archive/R.java +++ b/xwords4/android/XWords4/archive/R.java @@ -411,6 +411,9 @@ public final class R { */ public static final int query_trade_fmt=0x7f07000b; 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 */ 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_title=0x7f0502fe; public static final int checkupdates_none_found=0x7f05022b; - public static final int clip_label=0x7f05030f; /** color of the "crosshairs", lines drawn vertically and horizontally through the square the user is currently 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 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_nfc=0x7f05016c; /** EXPLAIN ME @@ -1356,7 +1357,6 @@ public final class R { */ public static final int invite_chooser_fmt=0x7f050171; 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_noname_fmt=0x7f05023c; public static final int invite_dict_missing_title=0x7f05023a; @@ -1965,7 +1965,6 @@ public final class R { main Board screen */ 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_relay=0x7f050309; public static final int not_again_comms_sms=0x7f05030a; diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 00f0a2ddf..88b18b050 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1677,20 +1677,22 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1changeDict } #endif -JNIEXPORT void JNICALL +JNIEXPORT jint JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll ( JNIEnv* env, jclass C, jint gamePtr, jboolean force, jboolean thenAck ) { + jint result; XWJNI_START(); CommsCtxt* comms = state->game.comms; XP_ASSERT( !!comms ); - (void)comms_resendAll( comms, force ); + result = comms_resendAll( comms, force ); if ( thenAck ) { #ifdef XWFEATURE_COMMSACK comms_ackAny( comms ); #endif } XWJNI_END(); + return result; } #ifdef XWFEATURE_COMMSACK diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 90f486618..8e51f1607 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -2532,4 +2532,10 @@ Cannot find any moves + + + One message sent + %1$s messages sent + + diff --git a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml index e0560e2da..1474ab684 100644 --- a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml +++ b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml @@ -2181,4 +2181,9 @@ Esu Htooteulb ot yalp tsniaga a ybraen ecived taht\'s \"deriap\" htiw sruoy. Tonnac dnif yna sevom + + + Eno egassem tnes + %1$s segassem tnes + diff --git a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml index 66be44729..52bb792fa 100644 --- a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml +++ b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml @@ -2181,4 +2181,9 @@ USE BLUETOOTH TO PLAY AGAINST A NEARBY DEVICE THAT\'S \"PAIRED\" WITH YOURS. CANNOT FIND ANY MOVES + + + ONE MESSAGE SENT + %1$s MESSAGES SENT + diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java index 986d5a5fb..385c60fa6 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -2011,6 +2011,11 @@ public class BoardDelegate extends DelegateBase m_dlgTitle = msg.arg1; showDialog( DlgID.GAME_OVER ); break; + case JNIThread.MSGS_SENT: + int nSent = (Integer)msg.obj; + showToast( getQuantityString( R.plurals.resent_msgs_fmt, + nSent, nSent ) ); + break; } } }; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index 7be80dd8d..b686c062b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -102,6 +102,7 @@ public class JNIThread extends Thread { public static final int TOOLBAR_STATES = 4; public static final int GOT_WORDS = 5; public static final int GAME_OVER = 6; + public static final int MSGS_SENT = 7; public class GameStateInfo implements Cloneable { public int visTileCount; @@ -522,9 +523,11 @@ public class JNIThread extends Thread { break; case CMD_RESEND: - XwJNI.comms_resendAll( m_jniGamePtr, - ((Boolean)args[0]).booleanValue(), - ((Boolean)args[1]).booleanValue() ); + int nSent = + XwJNI.comms_resendAll( m_jniGamePtr, + ((Boolean)args[0]).booleanValue(), + ((Boolean)args[1]).booleanValue() ); + Message.obtain( m_handler, MSGS_SENT, nSent ).sendToTarget(); break; // case CMD_ACKANY: // XwJNI.comms_ackAny( m_jniGamePtr ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java index 2f3da7be4..6046dcc19 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java @@ -317,8 +317,8 @@ public class XwJNI { public static native void comms_getAddr( int gamePtr, CommsAddrRec addr ); public static native CommsAddrRec[] comms_getAddrs( int gamePtr ); public static native void comms_setAddr( int gamePtr, CommsAddrRec addr ); - public static native void comms_resendAll( int gamePtr, boolean force, - boolean andAck ); + public static native int comms_resendAll( int gamePtr, boolean force, + boolean andAck ); public static native void comms_ackAny( int gamePtr ); public static native void comms_transportFailed( int gamePtr, CommsConnType failed ); diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index a3c2de639..509bbea9a 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -1436,9 +1436,10 @@ send_ack( CommsCtxt* comms ) (void)send_via_relay( comms, XWRELAY_ACK, comms->rr.myHostID, NULL, 0 ); } -XP_Bool +XP_S16 comms_resendAll( CommsCtxt* comms, XP_Bool force ) { + XP_S16 count = 0; XP_Bool success = XP_TRUE; XP_ASSERT( !!comms ); @@ -1452,9 +1453,13 @@ comms_resendAll( CommsCtxt* comms, XP_Bool force ) MsgQueueElem* msg; 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; break; + } else { + XP_ASSERT( 0 < len ); + ++count; } } @@ -1465,9 +1470,9 @@ comms_resendAll( CommsCtxt* comms, XP_Bool force ) comms->nextResend = now + comms->resendBackoff; } } - XP_LOGF( TAGFMT() "=>%d", TAGPRMS, success ); - return success; -} /* comms_resend */ + XP_LOGF( TAGFMT() "=>%d", TAGPRMS, count ); + return count; +} /* comms_resendAll */ #ifdef XWFEATURE_COMMSACK void diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h index dcd95cdf2..385e62fa2 100644 --- a/xwords4/common/comms.h +++ b/xwords4/common/comms.h @@ -214,7 +214,7 @@ void addrFromStream( CommsAddrRec* addr, XWStreamCtxt* stream ); void addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addr ); 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 ); #ifdef XWFEATURE_COMMSACK From 34c70825b96f2cf48b326beb9d7bb98dd14feda0 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 13 Aug 2015 07:06:12 -0700 Subject: [PATCH 04/28] toward figuring out why relay communication stalls: log network availability state changes. --- .../XWords4/src/org/eehouse/android/xw4/NetStateCache.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java index 6dd49af74..dea479421 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java @@ -140,6 +140,8 @@ public class NetStateCache { NetworkInfo ni = (NetworkInfo)intent. getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); NetworkInfo.State state = ni.getState(); + DbgUtils.logdf( "NetStateCache.PvtBroadcastReceiver.onReceive(state=%s)", + state.toString() ); boolean netAvail; switch ( state ) { @@ -193,6 +195,10 @@ public class NetStateCache { }; mHandler.postDelayed( mNotifyLater, WAIT_STABLE_MILLIS ); } + } else { + DbgUtils.logdf( "NetStateCache.PvtBroadcastReceiver.onReceive:" + + " no change; doing nothing; s_netAvail=%b", + s_netAvail ); } } } From 3898a85f180f875707c9fbd3930f4a0dacae22ea Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 13 Aug 2015 07:34:34 -0700 Subject: [PATCH 05/28] catch version code up --- xwords4/android/XWords4-dbg/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/android/XWords4-dbg/AndroidManifest.xml b/xwords4/android/XWords4-dbg/AndroidManifest.xml index 381e8e344..bc8a109d6 100644 --- a/xwords4/android/XWords4-dbg/AndroidManifest.xml +++ b/xwords4/android/XWords4-dbg/AndroidManifest.xml @@ -22,7 +22,7 @@ to come from a domain that you own or have control over. --> From 55d67f7599548c517e5f2e7b1b6de5998fb5910c Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 17 Aug 2015 06:34:58 -0700 Subject: [PATCH 06/28] don't show toast after message send unless user-triggered --- .../src/org/eehouse/android/xw4/jni/JNIThread.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index b686c062b..f7b41574c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -523,11 +523,13 @@ public class JNIThread extends Thread { break; case CMD_RESEND: + boolean force = ((Boolean)args[0]).booleanValue(); int nSent = - XwJNI.comms_resendAll( m_jniGamePtr, - ((Boolean)args[0]).booleanValue(), + XwJNI.comms_resendAll( m_jniGamePtr, force, ((Boolean)args[1]).booleanValue() ); - Message.obtain( m_handler, MSGS_SENT, nSent ).sendToTarget(); + if ( force ) { + Message.obtain(m_handler, MSGS_SENT, nSent).sendToTarget(); + } break; // case CMD_ACKANY: // XwJNI.comms_ackAny( m_jniGamePtr ); From cbe2c6f5f3cf24c57d72643fe2f702da1b5b3ebb Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 17 Aug 2015 07:04:10 -0700 Subject: [PATCH 07/28] copy over new translations from translation branch. --- .../XWords4/res_src/values-ca/strings.xml | 158 +++++++++--------- .../XWords4/res_src/values-nl/strings.xml | 2 + 2 files changed, 77 insertions(+), 83 deletions(-) diff --git a/xwords4/android/XWords4/res_src/values-ca/strings.xml b/xwords4/android/XWords4/res_src/values-ca/strings.xml index 702511e58..f401a62f0 100644 --- a/xwords4/android/XWords4/res_src/values-ca/strings.xml +++ b/xwords4/android/XWords4/res_src/values-ca/strings.xml @@ -188,9 +188,9 @@ Partida finalitzada en la sala «%1$s» - %1$d jugada feta - %1$d jugades fetes - + %1$d jugada feta + %1$d jugades fetes + Suprimeix Reinicialitza @@ -212,14 +212,14 @@ Canvia el nom d\'aquesta partida (només en aquest aparell) a: - Esteu segur de voler suprimir el joc seleccionat? Aquesta acció no es pot desfer. - Esteu segur de voler suprimir els %1$d jocs seleccionats? Aquesta acció no es pot desfer. - + Esteu segur de voler suprimir el joc seleccionat? Aquesta acció no es pot desfer. + Esteu segur de voler suprimir els %1$d jocs seleccionats? Aquesta acció no es pot desfer. + - Esteu segur de voler reinicialitzar el joc seleccionat?\n\n(La reinicialització suprimeix totes les jugades i qualsevol informació de connexió.) - Esteu segur de voler reinicialitzar els %1$d jocs seleccionats?\n\n(La reinicialització suprimeix totes les jugades i qualsevol informació de connexió.) - + Esteu segur de voler reinicialitzar el joc seleccionat?\n\n(La reinicialització suprimeix totes les jugades i qualsevol informació de connexió.) + Esteu segur de voler reinicialitzar els %1$d jocs seleccionats?\n\n(La reinicialització suprimeix totes les jugades i qualsevol informació de connexió.) + Incorporat @@ -228,9 +228,9 @@ Canvia la ubicació d\'emmagatzematge - Esteu segur de voler suprimir el diccionari %1$s? - Esteu segur de voler suprimir els diccionaris %1$s? - + Esteu segur de voler suprimir el diccionari %1$s? + Esteu segur de voler suprimir els diccionaris %1$s? + Si suprimiu %1$s no tindreu cap diccionari %2$s. Una o més partides no es podran obrir (fins que baixeu un diccionari de substitució.) @@ -293,16 +293,16 @@ (Encara no s\'ha fet cap jugada) - Aquesta partida està esperant a %1$d jugador remot. Si encara no ho heu fet, voleu convidar algú a unir-s\'hi? - Aquesta partida està esperant a %1$d jugadors remots. Si encara no ho heu fet, voleu convidar algú a unir-s\'hi? - + Aquesta partida està esperant a %1$d jugador remot. Si encara no ho heu fet, voleu convidar algú a unir-s\'hi? + Aquesta partida està esperant a %1$d jugadors remots. Si encara no ho heu fet, voleu convidar algú a unir-s\'hi? + O simplement toqueu per a convidar, si l\'altre aparell també té Android Beaming i és a prop. - - Manca %1$d jugador - Manquen %1$d jugadors - + + Manca %1$d jugador + Manquen %1$d jugadors + " (Esteu esperant més d\'un jugador remot. No els heu de convidar a tots a la vegada, però aquest avís no desapareixerà fins que hàgiu convidat a tothom i totes les invitacions s\'hagin acceptat.)" @@ -324,13 +324,11 @@ " vs. " - Queden %1$d fitxes al sac. - - + Queden %1$d fitxes al sac. + - %1$d fitxes romanents al sac i als faristols:\n - - + %1$d fitxes romanents al sac i als faristols:\n + Esteu segur que voleu desfer l\'últim torn enviat? (No hi ha opció per a refer-lo.) @@ -426,9 +424,8 @@ SMS - Esteu segur que voleu canviar les %1$d fitxes seleccionades (%2$s)? - - + Esteu segur que voleu canviar les %1$d fitxes seleccionades (%2$s)? + %1$s historial de missatges "Jo: " @@ -512,13 +509,11 @@ Tria les fitxes cara amunt - %1$s (%2$d paraules usant %3$d-%4$d fitxes) - - + %1$s (%2$d paraules usant %3$d-%4$d fitxes) + - %1$s (%2$d paraules usant %3$d fitxes) - - + %1$s (%2$d paraules usant %3$d fitxes) + No hi ha cap paraula a %1$s que comenci amb %2$s. Aquest botó obre l\'explorador de diccionaris en el diccionari actual del jugador. Aquest botó obre l\'explorador de diccionaris en el diccionari de la vostra elecció. @@ -633,14 +628,13 @@ Partides noves - Esteu segur de voler suprimir els %1$d grups seleccionats? - - + Esteu segur de voler suprimir els %1$d grups seleccionats? + Canvia el nom d\'aquest grup a: - %1$s (%2$d partida) - %1$s (%2$d partides) - + %1$s (%2$d partida) + %1$s (%2$d partides) + Torna a jugar-hi @@ -672,8 +666,7 @@ Copia al porta-retalls Suprimeix la selecció - S\'han copiat %1$d paraules - + S\'han copiat %1$d paraules S\'ha afegit %1$s a la llista d\'estudi %2$s Llista d\'estudi per a %1$s @@ -737,9 +730,9 @@ Recordatori: és el vostre torn - %1$d minut - %1$d minuts - + %1$d minut + %1$d minuts + %1$s ha passat (0 punts) %1$s ha perdut el torn Fitxes assignades a %1$s @@ -752,9 +745,9 @@ Partida en xarxa nova - Un jugador - %1$d jugadors - + Un jugador + %1$d jugadors + Avançat Per a jugadors experimentats Invitació múltiple @@ -793,28 +786,26 @@ %1$s (%2$d diccionari) %1$s (%2$d diccionaris) - + - + %1$d hora %1$d hores - - + + %1$d dia %1$d dies - + %1$s ha jugat fa més de %2$s. Últim avís: %1$s Oponent - %1$s ha jugat %2$s i anota %3$d punts - + %1$s ha jugat %2$s i anota %3$d punts - %1$s ha canviat %2$d fitxes - - + %1$s ha canviat %2$d fitxes + Cal configurar aquesta partida abans d\'obrir-la. Usa els valors predeterminats @@ -841,9 +832,9 @@ El número %1$s de %2$s no sembla un número de mòbil. Voleu importar-lo igualment? Introduïu el número de telèfon: - Esteu segur de voler suprimir el número de telèfon seleccionat? - Esteu segur de voler suprimir els %1$d números de telèfon seleccionats? - + Esteu segur de voler suprimir el número de telèfon seleccionat? + Esteu segur de voler suprimir els %1$d números de telèfon seleccionats? + Connexió (via SMS/missatges) Números connectats: Partida en joc amb %1$s @@ -860,14 +851,12 @@ Anomena el grup - \n\n(també se suprimiran %1$d partides.) - - + \n\n(també se suprimiran %1$d partides.) + - Esteu segur de voler suprimir les %1$d paraules seleccionades?\n\n(Aquesta acció no es pot desfer.) - - + Esteu segur de voler suprimir les %1$d paraules seleccionades?\n\n(Aquesta acció no es pot desfer.) + Les vostres paraules per a: Encara no heu desat cap paraula al llistat d\'estudi per a %1$s. @@ -876,9 +865,8 @@ Les paraules seleccionades s\'han copiat al porta-retalls del sistema. Podeu enganxar-les en qualsevol aplicació que permeti enganxar text, p. e. l\'aplicació de correu. - Ha instal·lat %1$d traduccions noves - - + Ha instal·lat %1$d traduccions noves + Traducció no permesa: les cadenes traduïdes han de tenir els mateixos indicadors de format (p. e. %1$s) que l\'original. Aquesta cadena té indicadors de format especials (p. e. %1$s). Assegureu-vos que la traducció té els mateixos que l\'original.\n\n(No podreu desar-la si no ho compleix.) @@ -892,14 +880,13 @@ La versió del Crosswords al telèfon amb número «%1$s» no és compatible amb aquest per a jugar via SMS. Heu d\'actualitzar abans de continuar. - - Seleccioneu fins a %1$d aparells que voleu incloure en aquesta partida. Useu el botó «%2$s» si no veieu l\'aparell que espereu. - - + + Seleccioneu fins a %1$d aparells que voleu incloure en aquesta partida. Useu el botó «%2$s» si no veieu l\'aparell que espereu. + - Comproveu el número de telèfon que voleu convidar a la partida nova, aleshores toqueu «%2$s». - Comproveu els %1$d números de telèfon que voleu convidar a la partida nova, aleshores toqueu «%2$s». - + Comproveu el número de telèfon que voleu convidar a la partida nova, aleshores toqueu «%2$s». + Comproveu els %1$d números de telèfon que voleu convidar a la partida nova, aleshores toqueu «%2$s». + Esteu segur que aquest número és d\'un compte amb SMS il·limitats? Feu clic a «Cancel·la si no ho esteu. Encara que pugin ser més altes @@ -937,9 +924,9 @@ Encara que la pantalla sigui massa petita - Reenviament finalitzat, s\'ha enviat %1$d missatge. - Reenviament finalitzat, s\'han enviat %1$d missatges. - + Reenviament finalitzat, s\'ha enviat %1$d missatge. + Reenviament finalitzat, s\'han enviat %1$d missatges. + Ja teniu una partida que sembla s\'ha creat (el %1$s) amb la mateixa invitació. Esteu segur de voler crear-ne una altra? @@ -1026,9 +1013,8 @@ Atenció: aquesta funcionalitat és per a telèfons amb plans de missatges SMS il·limitats. Si l\'habiliteu, per cada partida jugada, s\'enviaran dotzenes de missatges de text SMS de forma invisible. Si no teniu un pla il·limitat, la vostra operadora us pot cobrar cadascun dels missatges!\n\nVoleu habilitar el joc via SMS? - Fins ara, %1$d errors Bluetooth - - + Fins ara, %1$d errors Bluetooth + No es pot connectar al Crosswords en l\'aparell %1$s. Comproveu que l\'aparell és proper i que té el Crosswords instal·lat. @@ -1045,4 +1031,10 @@ Convida l\'amfitrió redirigit No puc trobar cap jugada +Missatge de xat a la partida %1$s + + Ho triaré + Invitació preparada per a copiar + URL de la invitació + L\'opció «%1$s» copia un URL d\'invitació al porta-retalls. Enganxeu-lo a l\'aplicació desitjada i envieu-lo al vostre amic. diff --git a/xwords4/android/XWords4/res_src/values-nl/strings.xml b/xwords4/android/XWords4/res_src/values-nl/strings.xml index 0039625fb..d599b7946 100644 --- a/xwords4/android/XWords4/res_src/values-nl/strings.xml +++ b/xwords4/android/XWords4/res_src/values-nl/strings.xml @@ -781,4 +781,6 @@ Uitnodiging kan nu geplakt worden Uitnodigingsadres De \"%1$s\" optie kopieert een uitnodigingsadres naar het kladblok. Plak het in een app naar keuze en stuur het naar een vriend. + Chatbericht in spel %1$s + From 0d8fef5c56a6afbcdecbf9fc62b2d2a06781725b Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 17 Aug 2015 08:01:36 -0700 Subject: [PATCH 08/28] cleanup --- .../XWords4/src/org/eehouse/android/xw4/DelegateBase.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java index f278985cb..d61882fa7 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -528,10 +528,9 @@ public class DelegateBase implements DlgClickNotify, m_dlgDelegate.eventOccurred( event, args ); break; default: - if ( BuildConfig.DEBUG ) { - DbgUtils.logf( "DelegateBase.eventOccurred(event=%s) (DROPPED)", - event.toString() ); - } + DbgUtils.logdf( "DelegateBase.eventOccurred(event=%s) (DROPPED)", + event.toString() ); + break; } if ( 0 != fmtId ) { From ff3d5871793b574b50e82537daac7840b86f018c Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 18 Aug 2015 06:40:31 -0700 Subject: [PATCH 09/28] really only post messages sent toast when user chose the menuitem --- .../XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index f7b41574c..79d0de388 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -523,11 +523,11 @@ public class JNIThread extends Thread { break; case CMD_RESEND: - boolean force = ((Boolean)args[0]).booleanValue(); int nSent = - XwJNI.comms_resendAll( m_jniGamePtr, force, + XwJNI.comms_resendAll( m_jniGamePtr, + ((Boolean)args[0]).booleanValue(), ((Boolean)args[1]).booleanValue() ); - if ( force ) { + if ( ((Boolean)args[2]).booleanValue() ) { Message.obtain(m_handler, MSGS_SENT, nSent).sendToTarget(); } break; From a11e5beded805eb4555e2c070a4ec83e9e08f4a4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 18 Aug 2015 06:40:50 -0700 Subject: [PATCH 10/28] goes with prev commit --- .../XWords4/src/org/eehouse/android/xw4/BoardDelegate.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java index 385c60fa6..cde6b27fc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -906,7 +906,7 @@ public class BoardDelegate extends DelegateBase break; case R.id.board_menu_game_resend: - m_jniThread.handle( JNICmd.CMD_RESEND, true, false ); + m_jniThread.handle( JNICmd.CMD_RESEND, true, false, true ); break; case R.id.gamel_menu_checkmoves: @@ -2104,7 +2104,8 @@ public class BoardDelegate extends DelegateBase } if ( 0 < m_connTypes.size() ) { - m_jniThread.handle( JNIThread.JNICmd.CMD_RESEND, force, true ); + m_jniThread.handle( JNIThread.JNICmd.CMD_RESEND, force, true, + false ); } } From 884eda06032970ba86126085d464aba5d65e8a35 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 18 Aug 2015 08:00:22 -0700 Subject: [PATCH 11/28] cleanup: use temp ptr to avoid too many dereferences --- xwords4/common/engine.c | 86 +++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/xwords4/common/engine.c b/xwords4/common/engine.c index b1aa40c62..1b3ab0763 100644 --- a/xwords4/common/engine.c +++ b/xwords4/common/engine.c @@ -1146,23 +1146,24 @@ considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft, static void saveMoveIfQualifies( EngineCtxt* engine, PossibleMove* posmove ) { - XP_S16 mostest = 0; + XP_S16 mostest; XP_S16 cmpVal; XP_Bool usePrev = engine->usePrev; XP_Bool foundEmpty = XP_FALSE; + MoveIterationData* miData = &engine->miData; if ( 1 == engine->nMovesToSave ) { /* only saving one */ mostest = 0; } else { mostest = -1; /* we're not interested if we've seen this */ - cmpVal = CMPMOVES( posmove, &engine->miData.lastSeenMove ); + cmpVal = CMPMOVES( posmove, &miData->lastSeenMove ); if ( !usePrev && cmpVal >= 0 ) { - /* XP_LOGF( "%s: dropping %d: higher than %d", __func__, */ - /* posmove->score, engine->miData.lastSeenMove.score ); */ + /* XP_LOGF( "%s: dropping %d: >= %d", __func__, */ + /* posmove->score, miData->lastSeenMove.score ); */ } else if ( usePrev && cmpVal <= 0 ) { - /* XP_LOGF( "%s: dropping %d: lower than %d", __func__, */ - /* posmove->score, engine->miData.lastSeenMove.score ); */ + /* XP_LOGF( "%s: dropping %d: <= %d", __func__, */ + /* posmove->score, miData->lastSeenMove.score ); */ } else { XP_S16 ii; /* terminate i at 1 because mostest starts at 0 */ @@ -1178,19 +1179,19 @@ saveMoveIfQualifies( EngineCtxt* engine, PossibleMove* posmove ) /* 1/20/2001 I don't see that this assertion is valid. I simply don't understand why it isn't tripped all the time in the old crosswords. */ - /* XP_ASSERT( (engine->miData.lastSeenMove.score == 0x7fff) */ - /* || (engine->miData.savedMoves[i].score */ + /* XP_ASSERT( (miData->lastSeenMove.score == 0x7fff) */ + /* || (miData->savedMoves[i].score */ /* <= posmove->score) ); */ - if ( 0 == engine->miData.savedMoves[ii].score ) { + if ( 0 == miData->savedMoves[ii].score ) { foundEmpty = XP_TRUE; mostest = ii; break; } else if ( -1 == mostest ) { mostest = ii; } else { - cmpVal = CMPMOVES( &engine->miData.savedMoves[mostest], - &engine->miData.savedMoves[ii] ); + cmpVal = CMPMOVES( &miData->savedMoves[mostest], + &miData->savedMoves[ii] ); if ( !usePrev && cmpVal > 0 ) { mostest = ii; } else if ( usePrev && cmpVal < 0 ) { @@ -1204,14 +1205,14 @@ saveMoveIfQualifies( EngineCtxt* engine, PossibleMove* posmove ) while ( mostest >= 0 ) { /* while: so we can break */ /* record the score we're dumping. No point in considering any scores lower than this for the rest of this round. */ - /* engine->miData.lowestSavedScore = */ - /* engine->miData.savedMoves[lowest].score; */ + /* miData->lowestSavedScore = */ + /* miData->savedMoves[lowest].score; */ /* XP_DEBUGF( "lowestSavedScore now %d\n", */ - /* engine->miData.lowestSavedScore ); */ + /* miData->lowestSavedScore ); */ if ( foundEmpty ) { /* we're good */ } else { - cmpVal = CMPMOVES( posmove, &engine->miData.savedMoves[mostest]); + cmpVal = CMPMOVES( posmove, &miData->savedMoves[mostest]); if ( !usePrev && cmpVal <= 0 ) { break; } else if ( usePrev && cmpVal >= 0 ) { @@ -1219,10 +1220,10 @@ saveMoveIfQualifies( EngineCtxt* engine, PossibleMove* posmove ) } } /* XP_LOGF( "saving move with score %d at %d (replacing %d)\n", */ - /* posmove->score, mostest, */ - /* engine->miData.savedMoves[mostest].score ); */ - XP_MEMCPY( &engine->miData.savedMoves[mostest], posmove, - sizeof(engine->miData.savedMoves[mostest]) ); + /* posmove->score, mostest, */ + /* miData->savedMoves[mostest].score ); */ + XP_MEMCPY( &miData->savedMoves[mostest], posmove, + sizeof(miData->savedMoves[mostest]) ); break; } } /* saveMoveIfQualifies */ @@ -1230,15 +1231,16 @@ saveMoveIfQualifies( EngineCtxt* engine, PossibleMove* posmove ) static void set_search_limits( EngineCtxt* engine ) { + MoveIterationData* miData = &engine->miData; /* If we're going to be searching backwards we want our highest cached move as the limit; otherwise the lowest */ - if ( 0 < engine->miData.nInMoveCache ) { + if ( 0 < miData->nInMoveCache ) { XP_U16 srcIndx = engine->usePrev - ? engine->nMovesToSave-1 : engine->miData.bottom; - XP_MEMCPY( &engine->miData.lastSeenMove, - &engine->miData.savedMoves[srcIndx], - sizeof(engine->miData.lastSeenMove) ); - //engine->miData.lowestSavedScore = 0; + ? engine->nMovesToSave-1 : miData->bottom; + XP_MEMCPY( &miData->lastSeenMove, + &miData->savedMoves[srcIndx], + sizeof(miData->lastSeenMove) ); + //miData->lowestSavedScore = 0; } else { /* we're doing this for first time */ engine_reset( engine ); @@ -1249,41 +1251,40 @@ static void init_move_cache( EngineCtxt* engine ) { XP_U16 nInMoveCache = engine->nMovesToSave; + MoveIterationData* miData = &engine->miData; XP_U16 ii; XP_ASSERT( engine->nMovesToSave == NUM_SAVED_ENGINE_MOVES ); for ( ii = 0; ii < NUM_SAVED_ENGINE_MOVES; ++ii ) { - if ( 0 == engine->miData.savedMoves[ii].score ) { + if ( 0 == miData->savedMoves[ii].score ) { --nInMoveCache; } else { break; } } - engine->miData.nInMoveCache = nInMoveCache; - engine->miData.bottom = NUM_SAVED_ENGINE_MOVES - nInMoveCache; + miData->nInMoveCache = nInMoveCache; + miData->bottom = NUM_SAVED_ENGINE_MOVES - nInMoveCache; - if ( engine->usePrev ) { - engine->miData.curCacheIndex = - NUM_SAVED_ENGINE_MOVES - nInMoveCache - 1; - } else { - engine->miData.curCacheIndex = NUM_SAVED_ENGINE_MOVES; - } + miData->curCacheIndex = engine->usePrev + ? NUM_SAVED_ENGINE_MOVES - nInMoveCache - 1 + : NUM_SAVED_ENGINE_MOVES; } static PossibleMove* next_from_cache( EngineCtxt* engine ) { + MoveIterationData* miData = &engine->miData; PossibleMove* move; if ( move_cache_empty( engine ) ) { move = NULL; } else { if ( engine->usePrev ) { - ++engine->miData.curCacheIndex; + ++miData->curCacheIndex; } else { - --engine->miData.curCacheIndex; + --miData->curCacheIndex; } - move = &engine->miData.savedMoves[engine->miData.curCacheIndex]; + move = &miData->savedMoves[miData->curCacheIndex]; } return move; } @@ -1309,21 +1310,22 @@ scoreQualifies( EngineCtxt* engine, XP_U16 score ) { XP_Bool qualifies = XP_FALSE; XP_Bool usePrev = engine->usePrev; + MoveIterationData* miData = &engine->miData; - if ( usePrev && score < engine->miData.lastSeenMove.score ) { + if ( usePrev && score < miData->lastSeenMove.score ) { /* drop it */ - } else if ( !usePrev && score > engine->miData.lastSeenMove.score - /* || (score < engine->miData.lowestSavedScore) */ ) { + } else if ( !usePrev && score > miData->lastSeenMove.score + /* || (score < miData->lowestSavedScore) */ ) { /* drop it */ } else { XP_S16 ii; - PossibleMove* savedMoves = engine->miData.savedMoves; + PossibleMove* savedMoves = miData->savedMoves; /* Look at each saved score, and return true as soon as one's found with a lower or equal score to this. As an optimization, consider remembering what the lowest score is *once there are NUM_SAVED_ENGINE_MOVES moves in here* and doing a quick test on that. Or better, keeping the list in sorted order. */ - for ( ii = 0, savedMoves = engine->miData.savedMoves; + for ( ii = 0, savedMoves = miData->savedMoves; ii < engine->nMovesToSave; ++ii, ++savedMoves ) { if ( savedMoves->score == 0 ) { /* empty slot */ qualifies = XP_TRUE; From 6d7123c27a2924084eec36e10728c159848d4065 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 19 Aug 2015 06:05:18 -0700 Subject: [PATCH 12/28] fix curses app for standalone games (at least to not crash) --- xwords4/linux/cursesmain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index 4a98eacae..3a538baaf 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -2119,7 +2119,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params ) #ifndef XWFEATURE_STANDALONE_ONLY /* send any events that need to get off before the event loop begins */ - if ( !isServer ) { + if ( !!cGlobals->game.comms && !isServer ) { (void)server_initClientConnection( cGlobals->game.server, mem_stream_make( MEMPOOL params->vtMgr, From 255ca56ed73a1532db7ed66d5bdc05e4557de701 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 19 Aug 2015 07:43:00 -0700 Subject: [PATCH 13/28] when no moves found, reset engine and try again. Works around bug where you do "hint", then "prev hint" and get told there are no moves found only to have the next "prev hint" succeed. This is a hack, but the right fix is eluding me, and will certainly be riskier. --- xwords4/common/engine.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xwords4/common/engine.c b/xwords4/common/engine.c index 1b3ab0763..334c69342 100644 --- a/xwords4/common/engine.c +++ b/xwords4/common/engine.c @@ -345,9 +345,6 @@ chooseMove( EngineCtxt* engine, PossibleMove** move ) result = (NULL != chosen) && (chosen->score > 0); - if ( !result ) { - engine_reset( engine ); - } return result; } /* chooseMove */ @@ -381,7 +378,7 @@ normalizeIQ( EngineCtxt* engine, XP_U16 iq ) XP_Bool engine_findMove( EngineCtxt* engine, const ModelCtxt* model, XP_U16 turn, const Tile* tiles, - XP_U16 nTiles, XP_Bool usePrev, + const XP_U16 nTiles, XP_Bool usePrev, #ifdef XWFEATURE_BONUSALL XP_U16 allTilesBonus, #endif @@ -394,7 +391,9 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model, XP_Bool result = XP_TRUE; XP_U16 star_row; XP_Bool canMove = XP_FALSE; + XP_Bool isRetry = XP_FALSE; + retry: engine->nTilesMax = XP_MIN( MAX_TRAY_TILES, nTiles ); #ifdef XWFEATURE_BONUSALL engine->allTilesBonus = allTilesBonus; @@ -542,6 +541,22 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model, newMove->nTiles = 0; } + /* Gross hack alert: there's an elusive bug in move cacheing that means + when we move forward or back from the highest-scoring move to the + lowest (or vice-versa) no move is found. But the next try succeeds, + because an engine_reset clears the state that makes that happen. So as + a workaround, try doing that when no moves are found. If none is found + for some other reason, e.g. no tiles, at least the search should be + quick. */ + if ( !canMove ) { + engine_reset( engine ); + if ( !isRetry ) { + isRetry = XP_TRUE; + XP_LOGF( "%s: no moves found so retrying", __func__ ); + goto retry; + } + } + *canMoveP = canMove; return result; } /* engine_findMove */ From 07e97107ce5e6cc4864a78835df08ba0185f492a Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Aug 2015 07:37:30 -0700 Subject: [PATCH 14/28] confirm before deleting chat history Conflicts: xwords4/android/XWords4/res/values/strings.xml --- .../android/XWords4/res/values/strings.xml | 3 ++ .../org/eehouse/android/xw4/ChatDelegate.java | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 8e51f1607..590a624f0 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -2538,4 +2538,7 @@ %1$s messages sent + Are you sure you want to delete + all chat history for this game?\n\n(This action cannot be + undone.) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java index 82d6572eb..bb2cbcd67 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java @@ -21,16 +21,18 @@ package org.eehouse.android.xw4; import android.app.Activity; +import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.view.View; import android.view.Menu; import android.view.MenuItem; -import android.view.MenuInflater; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; import android.widget.LinearLayout; +import android.widget.TextView; + +import org.eehouse.android.xw4.DlgDelegate.Action; public class ChatDelegate extends DelegateBase implements View.OnClickListener { @@ -82,10 +84,7 @@ public class ChatDelegate extends DelegateBase { boolean handled = R.id.chat_menu_clear == item.getItemId(); if ( handled ) { - DBUtils.clearChatHistory( m_activity, m_rowid ); - LinearLayout layout = - (LinearLayout)findViewById( R.id.chat_history ); - layout.removeAllViews(); + showConfirmThen( R.string.confirm_clear_chat, Action.CLEAR_ACTION ); } return handled; } @@ -105,4 +104,21 @@ public class ChatDelegate extends DelegateBase } finish(); } + + @Override + public void dlgButtonClicked( Action action, int which, Object[] params ) + { + switch ( action ) { + case CLEAR_ACTION: + if ( AlertDialog.BUTTON_POSITIVE == which ) { + DBUtils.clearChatHistory( m_activity, m_rowid ); + LinearLayout layout = + (LinearLayout)findViewById( R.id.chat_history ); + layout.removeAllViews(); + } + break; + default: + super.dlgButtonClicked( action, which, params ); + } + } } From 6b455bf743ed7e1cb2b54a9aafa69e0f68122aeb Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Aug 2015 07:15:20 -0700 Subject: [PATCH 15/28] make chat compose space multi-line; scroll chat history to bottom on open --- xwords4/android/XWords4/res/layout/chat.xml | 5 +++-- .../src/org/eehouse/android/xw4/ChatDelegate.java | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/res/layout/chat.xml b/xwords4/android/XWords4/res/layout/chat.xml index e1f02e40b..2ac2bff36 100644 --- a/xwords4/android/XWords4/res/layout/chat.xml +++ b/xwords4/android/XWords4/res/layout/chat.xml @@ -9,7 +9,8 @@ - diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java index bb2cbcd67..fa834906e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java @@ -30,6 +30,7 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; +import android.widget.ScrollView; import android.widget.TextView; import org.eehouse.android.xw4.DlgDelegate.Action; @@ -67,6 +68,14 @@ public class ChatDelegate extends DelegateBase } } + final ScrollView scroll = (ScrollView)findViewById( R.id.scroll ); + scroll.post(new Runnable() { + @Override + public void run() { + scroll.fullScroll(View.FOCUS_DOWN); + } + }); + ((Button)findViewById( R.id.send_button )) .setOnClickListener( this ); From 79ab1214e71beec97a8e7894f9bcd0553fc1b02b Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Aug 2015 07:35:01 -0700 Subject: [PATCH 16/28] replace send button with menuitem, and add icons for it and clear --- xwords4/android/XWords4/res/layout/chat.xml | 19 ++----- .../android/XWords4/res/menu/chat_menu.xml | 7 +++ .../org/eehouse/android/xw4/ChatDelegate.java | 51 +++++++++---------- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/xwords4/android/XWords4/res/layout/chat.xml b/xwords4/android/XWords4/res/layout/chat.xml index 2ac2bff36..422ccfcd7 100644 --- a/xwords4/android/XWords4/res/layout/chat.xml +++ b/xwords4/android/XWords4/res/layout/chat.xml @@ -22,24 +22,11 @@ /> - - - - -