make known-player stuff conditional

and ifdefs to C and BuildConfig flag to java so the feature can be
hidden in release builds until it's ready.
This commit is contained in:
Eric House 2020-09-22 20:35:59 -07:00
parent b3fa1edda5
commit 49909c84d6
11 changed files with 72 additions and 21 deletions

View file

@ -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 {

View file

@ -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();

View file

@ -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()

View file

@ -13,11 +13,21 @@
android:layout_height="match_parent"
>
<!-- One of these next two will be unhidden -->
<TextView android:id="@+id/title_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/how_tab"
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="gone"
/>
<RadioGroup android:id="@+id/group_tab"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone"
>
<RadioButton android:id="@+id/radio_who"
android:layout_width="wrap_content"

View file

@ -1023,7 +1023,13 @@
<string name="invite_choice_nfc">NFC (“Android beaming”)</string>
<string name="invite_choice_relay">Internet/Relay</string>
<string name="invite_choice_p2p">Wifi Direct</string>
<string name="invite_choice_title">Inviting players</string>
<string name="invite_choice_title">Inviting a Player</string>
<!-- Text above choices for how to send invitations == ONLY WHEN
there's no choice between how and who. Replaces the how?/who?
choice radio group. -->
<string name="how_tab">Send invitation how?</string>
<!-- Radio button in invite choices dialog for list of previous opponents -->
<string name="radio_who">Who?</string>
<!-- Text shown only when there are not any previous opponents to invite -->
@ -2375,7 +2381,7 @@
when chosen -->
<string name="not_again_clip_expl_fmt">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.</string>
choice and share it with a friend.</string>
<string name="confirm_clear_chat">Are you sure you want to delete
all chat history for this game?\n\n(This action cannot be
undone.)</string>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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 ),