From a48cd6e82efd29a097304bef6f13a6cafd3c099a Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 9 Feb 2024 09:36:19 -0800 Subject: [PATCH] add unquash menuitem to netstat menu (debug only) --- .../main/java/org/eehouse/android/xw4/BoardDelegate.java | 6 ++++++ .../src/main/java/org/eehouse/android/xw4/GameUtils.java | 4 ++-- .../src/main/java/org/eehouse/android/xw4/jni/XwJNI.java | 2 +- xwords4/android/app/src/main/res/menu/netstat.xml | 3 +++ xwords4/android/app/src/main/res/values/tmpstrings.xml | 5 +++++ xwords4/android/jni/xwjni.c | 4 ++-- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 61e15c176..eb07ca8e7 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -1534,6 +1534,9 @@ public class BoardDelegate extends DelegateBase popup.getMenu().removeItem( R.id.netstat_menu_traffic ); popup.getMenu().removeItem( R.id.netstat_peers ); } + if ( !m_summary.quashed ) { + popup.getMenu().removeItem( R.id.netstat_unquash ); + } popup.setOnMenuItemClickListener( new PopupMenu .OnMenuItemClickListener() { @@ -1553,6 +1556,9 @@ public class BoardDelegate extends DelegateBase case R.id.netstat_peers: showDialogFragment( DlgID.MQTT_PEERS ); break; + case R.id.netstat_unquash: + XwJNI.comms_setQuashed( m_jniGamePtr, false ); + break; default: handled = false; } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java index dfa247495..7b2d309da 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java @@ -1458,7 +1458,7 @@ public class GameUtils { for ( long rowid: rowids ) { try ( JNIThread thread = JNIThread.getRetained( rowid ) ) { if ( null != thread ) { - XwJNI.comms_setQuashed( thread.getGamePtr() ); + XwJNI.comms_setQuashed( thread.getGamePtr(), true ); // JNIThread saves automatically on release } else { try ( GameLock lock = GameLock.lock( rowid, 300 ) ) { @@ -1466,7 +1466,7 @@ public class GameUtils { CurGameInfo gi = new CurGameInfo( context ); try ( GamePtr gamePtr = loadMakeGame( context, gi, lock ) ) { if ( null != gamePtr ) { - if ( XwJNI.comms_setQuashed( gamePtr ) ) { + if ( XwJNI.comms_setQuashed( gamePtr, true ) ) { saveGame( context, gamePtr, gi, lock, false ); } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java index 07da5f3e6..d91988f9b 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java @@ -560,7 +560,7 @@ public class XwJNI { public static native CommsAddrRec comms_getHostAddr( GamePtr gamePtr ); public static native CommsAddrRec[] comms_getAddrs( GamePtr gamePtr ); public static native void comms_dropHostAddr( GamePtr gamePtr, CommsConnType typ ); - public static native boolean comms_setQuashed( GamePtr gamePtr ); + public static native boolean comms_setQuashed( GamePtr gamePtr, boolean quashed ); public static native int comms_resendAll( GamePtr gamePtr, boolean force, CommsConnType filter, boolean andAck ); diff --git a/xwords4/android/app/src/main/res/menu/netstat.xml b/xwords4/android/app/src/main/res/menu/netstat.xml index 0c3d0b3af..ac952dbe4 100644 --- a/xwords4/android/app/src/main/res/menu/netstat.xml +++ b/xwords4/android/app/src/main/res/menu/netstat.xml @@ -13,4 +13,7 @@ + diff --git a/xwords4/android/app/src/main/res/values/tmpstrings.xml b/xwords4/android/app/src/main/res/values/tmpstrings.xml index df0ef5b59..6c47af198 100644 --- a/xwords4/android/app/src/main/res/values/tmpstrings.xml +++ b/xwords4/android/app/src/main/res/values/tmpstrings.xml @@ -9,6 +9,11 @@ Peers information not available Refresh + Sort by date + + Unquash diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 9eb79cbcd..345c4cded 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -2695,13 +2695,13 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1dropHostAddr JNIEXPORT jboolean JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_comms_1setQuashed -( JNIEnv* env, jclass C, GamePtrType gamePtr ) +( JNIEnv* env, jclass C, GamePtrType gamePtr, jboolean jQuashed ) { jboolean result = false; XWJNI_START(gamePtr); XP_ASSERT( !!state->game.comms ); if ( NULL != state->game.comms ) { - result = comms_setQuashed( state->game.comms, env, XP_TRUE ); + result = comms_setQuashed( state->game.comms, env, jQuashed ); } XWJNI_END(); return result;