diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index ff2b28d3c..09033fd47 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1185,6 +1185,17 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1transportFailed XWJNI_END(); } +JNIEXPORT jboolean JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_comms_1isConnected +( JNIEnv* env, jclass C, jint gamePtr ) +{ + jboolean result; + XWJNI_START(); + result = NULL != state->game.comms && comms_isConnected( state->game.comms ); + XWJNI_END(); + return result; +} + JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_server_1endGame ( JNIEnv* env, jclass C, jint gamePtr ) @@ -1206,3 +1217,4 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1sendChat (*env)->ReleaseStringUTFChars( env, jmsg, msg ); XWJNI_END(); } + diff --git a/xwords4/android/XWords4/res/layout/player_edit.xml b/xwords4/android/XWords4/res/layout/player_edit.xml index f36718914..e3899d32e 100644 --- a/xwords4/android/XWords4/res/layout/player_edit.xml +++ b/xwords4/android/XWords4/res/layout/player_edit.xml @@ -54,6 +54,7 @@ android:autoText="false" android:capitalize="none" android:gravity="fill_horizontal" + android:singleLine="true" android:textAppearance="?android:attr/textAppearanceMedium" /> @@ -88,6 +89,7 @@ android:capitalize="none" android:gravity="fill_horizontal" android:password="true" + android:singleLine="true" android:textAppearance="?android:attr/textAppearanceMedium" /> 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 3f81a8a5a..ecf0b09ce 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 @@ -204,6 +204,7 @@ public class XwJNI { public static native void comms_resendAll( int gamePtr ); public static native void comms_transportFailed( int gamePtr ); public static native boolean comms_canChat( int gamePtr ); + public static native boolean comms_isConnected( int gamePtr ); // Dicts public static native boolean dict_tilesAreSame( int dictPtr1, int dictPtr2 ); diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 0a8ddf9b8..62c9f7ba9 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -796,7 +796,6 @@ comms_getInitialAddr( CommsAddrRec* addr } addr->u.ip_relay.seeksPublicRoom = XP_FALSE; addr->u.ip_relay.advertiseRoom = XP_FALSE; - #elif defined PLATFORM_PALM /* default values; default is still IR where there's a choice, at least on Palm... */ @@ -1660,6 +1659,20 @@ comms_canChat( const CommsCtxt* const comms ) return canChat; } +XP_Bool +comms_isConnected( const CommsCtxt* const comms ) +{ + XP_Bool result = XP_FALSE; + switch ( comms->addr.conType ) { + case COMMS_CONN_RELAY: + result = 0 != comms->r.connName[0]; + break; + default: + break; + } + return result; +} + #ifdef COMMS_HEARTBEAT static void sendEmptyMsg( CommsCtxt* comms, AddressRecord* rec ) diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h index e664734be..d67bf5620 100644 --- a/xwords4/common/comms.h +++ b/xwords4/common/comms.h @@ -186,6 +186,7 @@ XP_Bool comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream, XP_Bool comms_checkComplete( const CommsAddrRec* const addr ); XP_Bool comms_canChat( const CommsCtxt* comms ); +XP_Bool comms_isConnected( const CommsCtxt* const comms ); # ifdef DEBUG void comms_getStats( CommsCtxt* comms, XWStreamCtxt* stream ); diff --git a/xwords4/linux/gtkchat.c b/xwords4/linux/gtkchat.c index 47348935b..b8b09940e 100644 --- a/xwords4/linux/gtkchat.c +++ b/xwords4/linux/gtkchat.c @@ -24,13 +24,29 @@ gchar* gtkGetChatMessage( GtkAppGlobals* XP_UNUSED(globals) ) { - /* GtkWidget* dlg = gtk_message_dialog_new( NULL, /\* parent *\/ */ - /* GTK_MESSAGE_QUESTION, */ - /* GTK_DIALOG_MODAL, */ - /* buttons, "%s", message ); */ + gchar* result = NULL; + GtkWidget* dialog = gtk_dialog_new_with_buttons( "message text", NULL, //GtkWindow *parent, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, + NULL ); - gchar* msg = g_strdup( "Hello world" ); - return msg; + GtkWidget* entry = gtk_entry_new(); + + gtk_container_add( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG (dialog))), + entry ); + gtk_widget_show_all( dialog ); + gtk_dialog_run( GTK_DIALOG (dialog) ); + + const char* text = gtk_entry_get_text( GTK_ENTRY(entry) ); + + if ( 0 != text[0] ) { + result = g_strdup( text ); + } + gtk_widget_destroy (dialog); + + LOG_RETURNF( "%s", result ); + return result; } #endif