diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index 640064d8e..c1548e65e 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -86,6 +86,7 @@ android { buildConfigField "boolean", "ATTACH_SUPPORTED", "false" buildConfigField "boolean", "OFFER_MQTT", "true" buildConfigField "boolean", "NON_RELEASE", "DEBUG || !IS_TAGGED_BUILD" + buildConfigField "boolean", "HAVE_KNOWN_PLAYERS", "false" } xw4NoSMS { @@ -135,6 +136,8 @@ android { resValue "string", "nfc_aid", "$NFC_AID_XW4d" externalNativeBuild.ndkBuild.cFlags += ['-DVARIANT_xw4d'] externalNativeBuild.ndkBuild.arguments += ['XW_BT_UUID=' + XWD_UUID] + externalNativeBuild.ndkBuild.cFlags += ['-DXWFEATURE_KNOWNPLAYERS'] + buildConfigField "boolean", "HAVE_KNOWN_PLAYERS", "true" } xw4dNoSMS { @@ -152,6 +155,8 @@ android { resValue "string", "nfc_aid", "$NFC_AID_XW4d" externalNativeBuild.ndkBuild.cFlags += ['-DVARIANT_xw4dNoSMS'] externalNativeBuild.ndkBuild.arguments += ['XW_BT_UUID=' + XWD_UUID] + externalNativeBuild.ndkBuild.cFlags += ['-DXWFEATURE_KNOWNPLAYERS'] + buildConfigField "boolean", "HAVE_KNOWN_PLAYERS", "true" } xw4SMS { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteView.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteView.java index 2e6b3dc28..712b46104 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteView.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteView.java @@ -60,12 +60,17 @@ public class InviteView extends ScrollView { Context context = getContext(); - mIsWho = null != players && 0 < players.length; + boolean showWho = null != players && 0 < players.length; - // top/horizontal group first - mGroupTab = (RadioGroup)findViewById( R.id.group_tab ); - mGroupTab.check(mIsWho ? R.id.radio_who : R.id.radio_how ); - mGroupTab.setOnCheckedChangeListener( this ); + // top/horizontal group or title first + if ( showWho ) { + mGroupTab = (RadioGroup)findViewById( R.id.group_tab ); + mGroupTab.check( R.id.radio_who ); + mGroupTab.setOnCheckedChangeListener( this ); + mGroupTab.setVisibility( View.VISIBLE ); + } else { + findViewById( R.id.title_tab ).setVisibility( View.VISIBLE ); + } mGroupHow = (RadioGroup)findViewById( R.id.group_how ); mGroupHow.setOnCheckedChangeListener( this ); @@ -77,9 +82,9 @@ public class InviteView extends ScrollView mHowMeans.put( button, means ); } - mGroupWho = (RadioGroup)findViewById( R.id.group_who ); - mGroupWho.setOnCheckedChangeListener( this ); - if ( mIsWho ) { + if ( showWho ) { + mGroupWho = (RadioGroup)findViewById( R.id.group_who ); + mGroupWho.setOnCheckedChangeListener( this ); for ( String player : players ) { RadioButton button = new RadioButton( context ); button.setText( player ); @@ -87,6 +92,7 @@ public class InviteView extends ScrollView mWhoPlayers.put( button, player ); } } + mIsWho = showWho; showWhoOrHow(); return this; @@ -146,7 +152,9 @@ public class InviteView extends ScrollView private void showWhoOrHow() { - mGroupWho.setVisibility( mIsWho ? View.VISIBLE : View.INVISIBLE ); + if ( null != mGroupWho ) { + mGroupWho.setVisibility( mIsWho ? View.VISIBLE : View.INVISIBLE ); + } mGroupHow.setVisibility( mIsWho ? View.INVISIBLE : View.VISIBLE ); boolean showEmpty = mIsWho && 0 == mWhoPlayers.size(); 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 a8465d12f..fe50e0955 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 @@ -173,12 +173,16 @@ public class XwJNI { public static String[] kplr_getPlayers() { - return kplr_getPlayers( getJNI().m_ptrGlobals ); + return BuildConfig.HAVE_KNOWN_PLAYERS + ? kplr_getPlayers( getJNI().m_ptrGlobals ) + : null; } public static CommsAddrRec kplr_getAddr( String name ) { - return kplr_getAddr( getJNI().m_ptrGlobals, name ); + return BuildConfig.HAVE_KNOWN_PLAYERS + ? kplr_getAddr( getJNI().m_ptrGlobals, name ) + : null; } private static void cleanGlobals() diff --git a/xwords4/android/app/src/main/res/layout/invite_view.xml b/xwords4/android/app/src/main/res/layout/invite_view.xml index 9ddda2c36..2577b151e 100644 --- a/xwords4/android/app/src/main/res/layout/invite_view.xml +++ b/xwords4/android/app/src/main/res/layout/invite_view.xml @@ -13,11 +13,21 @@ android:layout_height="match_parent" > + + + NFC (“Android beaming”) Internet/Relay Wifi Direct - Inviting players + Inviting a Player + + + Send invitation how? + Who? @@ -2375,7 +2381,7 @@ when chosen --> The “%1$s” option copies an invitation URL to the clipboard. Paste it into the app of your - choice and send it to your friend. + choice and share it with a friend. 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/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 284f580ea..1aa737a6c 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -771,6 +771,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1parseMQTTPacket DVC_HEADER_END(); } +# ifdef XWFEATURE_KNOWNPLAYERS JNIEXPORT jobjectArray JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_kplr_1getPlayers ( JNIEnv* env, jclass C, jlong jniGlobalPtr ) @@ -806,6 +807,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_kplr_1getAddr DVC_HEADER_END(); return jaddr; } +#endif JNIEXPORT jbyteArray JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_gi_1to_1stream diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index c54f7ef7f..f684308aa 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -2595,6 +2595,7 @@ comms_isConnected( const CommsCtxt* const comms ) void comms_gatherPlayers( CommsCtxt* comms, XWEnv xwe ) { +#ifdef XWFEATURE_KNOWNPLAYERS LOG_FUNC(); if ( 0 == (comms->flags & FLAG_HARVEST_DONE) ) { CommsAddrRec addrs[4] = {{0}}; @@ -2607,6 +2608,10 @@ comms_gatherPlayers( CommsCtxt* comms, XWEnv xwe ) // comms->flags |= FLAG_HARVEST_DONE; } } +#else + XP_USE( comms ); + XP_USE( xwe ); +#endif } #ifdef RELAY_VIA_HTTP diff --git a/xwords4/common/knownplyr.c b/xwords4/common/knownplyr.c index 9fb182fcd..30c000bdc 100644 --- a/xwords4/common/knownplyr.c +++ b/xwords4/common/knownplyr.c @@ -1,7 +1,6 @@ /* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */ /* - * Copyright 2001 - 2020 by Eric House (xwords@eehouse.org). All rights - * reserved. + * Copyright 2020 by Eric House (xwords@eehouse.org). All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,6 +22,8 @@ #include "comms.h" #include "dbgutil.h" +#ifdef XWFEATURE_KNOWNPLAYERS + typedef struct _KnownPlayer { struct _KnownPlayer* next; XP_UCHAR* name; @@ -230,3 +231,4 @@ kplr_cleanup( XW_DUtilCtxt* dutil ) XP_FREEP( dutil->mpool, state ); } } +#endif diff --git a/xwords4/common/knownplyr.h b/xwords4/common/knownplyr.h index ee7d6859a..1adc712b4 100644 --- a/xwords4/common/knownplyr.h +++ b/xwords4/common/knownplyr.h @@ -27,6 +27,7 @@ /* XP_UCHAR** knpl_listPlayers( XW_DUtilCtxt* dctxt, uint_t* nNames ); */ /* void knpl_freePlayers( XW_DUtilCtxt* dctxt, XP_UCHAR** names ); */ +# ifdef XWFEATURE_KNOWNPLAYERS void kplr_cleanup( XW_DUtilCtxt* dutil ); XP_Bool kplr_havePlayers( XW_DUtilCtxt* dutil, XWEnv xwe ); @@ -38,5 +39,7 @@ XP_Bool kplr_getAddr( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* name, XP_Bool kplr_addAddrs( XW_DUtilCtxt* dutil, XWEnv xwe, const CurGameInfo* gi, CommsAddrRec addrs[], XP_U16 nAddrs ); - +# else +# define kplr_cleanup( dutil ) +# endif #endif diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index c05eba2be..0b81ea76a 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -166,6 +166,7 @@ DEFINES += -DXWFEATURE_DIRECTIP DEFINES += -DXWFEATURE_SLOW_ROBOT -DXWFEATURE_ROBOTPHONIES DEFINES += -DXWFEATURE_DEVICE +DEFINES += -DXWFEATURE_KNOWNPLAYERS # Support device-to-device connection via UDP, e.g. using wifi on a # LAN or where the host/server isn't behind a firewall. diff --git a/xwords4/linux/gtkinvit.c b/xwords4/linux/gtkinvit.c index 40f5b0b2a..eb2cbadef 100644 --- a/xwords4/linux/gtkinvit.c +++ b/xwords4/linux/gtkinvit.c @@ -56,8 +56,9 @@ typedef struct _GtkInviteState { GtkWidget* mqttDevID; - /* Known players */ +#ifdef XWFEATURE_KNOWNPLAYERS GtkWidget* knownsCombo; +#endif GtkWidget* bgScanButton; GtkWidget* okButton; @@ -99,10 +100,13 @@ handle_ok( GtkWidget* XP_UNUSED(widget), gpointer closure ) PageData* data = &state->pageData[curPage]; CommsConnType conType = data->pageType; - if ( COMMS_CONN_NONE == conType ) { + if ( 0 ) { +#ifdef XWFEATURE_KNOWNPLAYERS + } else if ( COMMS_CONN_NONE == conType ) { gchar* name = gtk_combo_box_text_get_active_text( GTK_COMBO_BOX_TEXT(state->knownsCombo) ); kplr_getAddr( state->dutil, NULL_XWE, name, state->addr ); +#endif } else { addr_addType( state->addr, conType ); switch ( conType ) { @@ -271,7 +275,7 @@ makeSMSPage( GtkInviteState* state, PageData* data ) return vbox; } /* makeBTPage */ - +#ifdef XWFEATURE_KNOWNPLAYERS static GtkWidget* makeKnownsPage( GtkInviteState* state, PageData* data ) { @@ -301,6 +305,7 @@ makeKnownsPage( GtkInviteState* state, PageData* data ) return vbox; } +#endif static GtkWidget* makeMQTTPage( GtkInviteState* state, PageData* data ) @@ -376,14 +381,14 @@ gtkInviteDlg( GtkGameGlobals* globals, CommsAddrRec* addr, G_CALLBACK(onPageChanged), &state ); PageData* data; - +#ifdef XWFEATURE_KNOWNPLAYERS if ( kplr_havePlayers( state.dutil, NULL_XWE ) ) { data = getNextData( &state, COMMS_CONN_NONE, "Knowns" ); (void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook), makeKnownsPage( &state, data ), data->label ); } - +#endif data = getNextData( &state, COMMS_CONN_MQTT, "MQTT" ); (void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook), makeMQTTPage( &state, data ),