don't add relay to new games -- mqtt only

This commit is contained in:
Eric House 2021-04-01 08:56:02 -07:00
parent fbc7a70c43
commit a1cabd6c4c
8 changed files with 44 additions and 29 deletions

View file

@ -113,6 +113,7 @@ android {
buildConfigField "boolean", "HAVE_KNOWN_PLAYERS", "true"
buildConfigField "boolean", "FOR_FDROID", "false"
buildConfigField "boolean", "HAVE_PASSWORD", "false"
buildConfigField "boolean", "NO_NEW_RELAY", "true"
}
xw4GPlay {

View file

@ -102,9 +102,9 @@ public class ConnViaViewLayout extends LinearLayout {
if ( isChecked ) {
showNotAgainTypeTip( typf );
enabledElseWarn( typf );
m_curSet.addWithCheck( typf );
m_curSet.add( typf );
} else {
m_curSet.removeWithCheck( typf );
m_curSet.remove( typf );
if ( null != m_emptyWarner && 0 == m_curSet.size()) {
m_emptyWarner.typeSetEmpty();
}
@ -151,7 +151,7 @@ public class ConnViaViewLayout extends LinearLayout {
int msgID = 0;
switch( typ ) {
case COMMS_CONN_RELAY:
msgID = R.string.not_again_comms_relay;
msgID = R.string.not_again_comms_relay_depr;
keyID = R.string.key_na_comms_relay;
break;
case COMMS_CONN_SMS:

View file

@ -370,8 +370,13 @@ public class DBUtils {
}
} // saveSummary
public static void addRematchInfo( Context context, long rowid, CommsAddrRec addr )
public static void addRematchInfo( Context context, long rowid,
CommsAddrRec addr )
{
if ( BuildConfig.NO_NEW_RELAY ) {
addr.remove(CommsConnType.COMMS_CONN_RELAY);
}
try ( GameLock lock = GameLock.tryLock(rowid) ) {
if ( null != lock ) {
String as64 = Utils.serializableToString64( addr );

View file

@ -317,8 +317,11 @@ public class GameConfigDelegate extends DelegateBase
DialogInterface.OnClickListener lstnr =
new DialogInterface.OnClickListener() {
@Override
public void onClick( DialogInterface dlg, int button ) {
m_conTypes = items.getTypes();
// Remove it if it's actually possible it's there
Assert.assertTrueNR( !m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) );
if ( cb.isChecked()) {
XWPrefs.setAddrTypes( m_activity, m_conTypes );
}

View file

@ -626,6 +626,9 @@ public class GameUtils {
String[] dictArray = {dict};
if ( null == addrSet ) {
addrSet = XWPrefs.getAddrTypes( context );
if ( BuildConfig.NO_NEW_RELAY ) {
addrSet.remove( CommsConnType.COMMS_CONN_RELAY );
}
}
// Silently add this to any networked game if our device supports

View file

@ -517,7 +517,7 @@ public class XWPrefs {
if ( -1 == flags ) {
result = new CommsConnTypeSet();
if ( getRelayEnabled( context ) ) {
result.addWithCheck( CommsConnType.COMMS_CONN_RELAY );
result.add( CommsConnType.COMMS_CONN_RELAY );
}
if ( BTUtils.BTEnabled() ) {
result.add( CommsConnType.COMMS_CONN_BT );

View file

@ -51,12 +51,12 @@ public class CommsAddrRec implements Serializable {
_COMMS_CONN_NONE,
COMMS_CONN_IR,
COMMS_CONN_IP_DIRECT,
COMMS_CONN_RELAY,
COMMS_CONN_RELAY(!BuildConfig.NO_NEW_RELAY),
COMMS_CONN_BT,
COMMS_CONN_SMS,
COMMS_CONN_P2P,
COMMS_CONN_NFC(false),
COMMS_CONN_MQTT(false);
COMMS_CONN_MQTT(BuildConfig.NO_NEW_RELAY);
private boolean mIsSelectable = true;
@ -137,11 +137,11 @@ public class CommsAddrRec implements Serializable {
for ( CommsConnType value : values ) {
int ord = value.ordinal();
if ( 0 != (bits & (1 << (ord - 1)))) {
addWithCheck( value );
add( value );
}
}
} else if ( bits < values.length ) { // don't crash
addWithCheck( values[bits] );
add( values[bits] );
} else {
Log.e( TAG, "<init>: bad bits value: 0x%x", inBits );
}
@ -169,7 +169,9 @@ public class CommsAddrRec implements Serializable {
public static List<CommsConnType> getSupported( Context context )
{
List<CommsConnType> supported = new ArrayList<>();
supported.add( CommsConnType.COMMS_CONN_RELAY );
if ( !BuildConfig.NO_NEW_RELAY ) {
supported.add( CommsConnType.COMMS_CONN_RELAY );
}
if ( BuildConfig.OFFER_MQTT ) {
supported.add( CommsConnType.COMMS_CONN_MQTT );
}
@ -218,20 +220,6 @@ public class CommsAddrRec implements Serializable {
return result;
}
public void addWithCheck( CommsConnType typ ) {
add( typ );
if ( BuildConfig.OFFER_MQTT && typ == CommsConnType.COMMS_CONN_RELAY ) {
add( CommsConnType.COMMS_CONN_MQTT );
}
}
public void removeWithCheck( CommsConnType typ ) {
remove( typ );
if ( typ == CommsConnType.COMMS_CONN_RELAY ) {
remove( CommsConnType.COMMS_CONN_MQTT );
}
}
@Override
public String toString()
{

View file

@ -2372,12 +2372,24 @@
devices.</string>
<string name="confirm_drop_relay_sms">Not all carriers support play
via Data SMS.</string>
<string name="button_enable">Enable</string>
<string name="not_again_comms_relay">The “relay” is a server on
<string name="button_enable">Enable</string>
<!-- Won't be shown much longer if at all.... -->
<string name="not_again_comms_relay_depr">The “relay” is a server
for passing messages between devices running CrossWords. Its
being replaced by a more modern server called
“Mosquitto.”</string>
<!-- Message shown to users as a hint when they enable
play-via-internet in the connect-via dialog, e.g. when
configuring a new game. -->
<string name="not_again_comms_mqtt">There is a server on
the internet that passes messages between devices that are running
CrossWords. It works any time you have a fully-functional internet
connection, but might have problems on restricted WiFi
networks.</string>
<!-- Message shown to users as a hint when they enable
play-via-data-sms in the connect-via dialog, e.g. when
configuring a new game. -->
<string name="not_again_comms_sms">Play via Data SMS uses the
technology on which “texting” is built. Though the messages are
invisible to you, your carrier bills them as texts, so you want to
@ -2385,11 +2397,16 @@
budget.) Note that Android only supports this feature on devices on
a GSM carrier, i.e. every carrier in the world except Verizon and
Sprint.</string>
<!-- Message shown to users as a hint when they enable
play-via-Bluetooth in the connect-via dialog, e.g. when
configuring a new game. -->
<string name="not_again_comms_bt">Use Bluetooth to play against a
nearby device thats “paired” with yours.</string>
<string name="not_again_comms_p2p">Use WiFi Direct to play against a
nearby WiFi Direct-capable device with CrossWords installed.</string>
<string name="str_no_hint_found">Cannot find any moves</string>
<!-- Shown when user tries to use "Rematch" feature in a three- or
four-device game -->
<string name="not_again_rematch_two_only">Rematch is limited to
two-person games, at least for now, because its harder with more
devices and I think its rare that people play with more than
@ -2648,10 +2665,8 @@
relay. Currently I use this only for testing. -->
<string name="remote_msg_title">Remote message</string>
<!-- MQTT stuff. May not see the light of day -->
<string name="invite_choice_mqtt">Internet/MQTT</string>
<string name="invite_choice_mqtt">Internet</string>
<string name="mqtt_invite_title">MQTT Invitation</string>
<string name="not_again_comms_mqtt">Im experimenting with this
as a replacement for the relay.</string>
<!-- Title of menuitem that launches Known Players viewer -->
<string name="gamel_menu_knownplyrs">Known Players…</string>
<string name="knowns_expl">These are your known remote