From a1cabd6c4c59b9e0f59191cd180b9501326af271 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 1 Apr 2021 08:56:02 -0700 Subject: [PATCH] don't add relay to new games -- mqtt only --- xwords4/android/app/build.gradle | 1 + .../android/xw4/ConnViaViewLayout.java | 6 ++--- .../java/org/eehouse/android/xw4/DBUtils.java | 7 ++++- .../android/xw4/GameConfigDelegate.java | 3 +++ .../org/eehouse/android/xw4/GameUtils.java | 3 +++ .../java/org/eehouse/android/xw4/XWPrefs.java | 2 +- .../eehouse/android/xw4/jni/CommsAddrRec.java | 26 +++++-------------- .../app/src/main/res/values/strings.xml | 25 ++++++++++++++---- 8 files changed, 44 insertions(+), 29 deletions(-) diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index 0b41e0ecb..88d8e68ce 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -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 { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java index 6f579478c..31eec8e55 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java @@ -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: diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java index a5311a30b..33f8a931f 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java @@ -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 ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java index 7f7ff9e57..b7a7022af 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameConfigDelegate.java @@ -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 ); } 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 135a0e1fc..a127b7774 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 @@ -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 diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java index 1ba960ddf..53251592f 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java @@ -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 ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java index be4f182dc..2d171f6c4 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java @@ -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, ": bad bits value: 0x%x", inBits ); } @@ -169,7 +169,9 @@ public class CommsAddrRec implements Serializable { public static List getSupported( Context context ) { List 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() { diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index e656116e0..cd1933f0b 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2372,12 +2372,24 @@ devices. Not all carriers support play via Data SMS. - Enable - The “relay” is a server on + Enable + + The “relay” is a server + for passing messages between devices running CrossWords. It’s + being replaced by a more modern server called + “Mosquitto.” + + + 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. + 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. + Use Bluetooth to play against a nearby device that’s “paired” with yours. Use WiFi Direct to play against a nearby WiFi Direct-capable device with CrossWords installed. Cannot find any moves + Rematch is limited to two-person games, at least for now, because it’s harder with more devices and I think it’s rare that people play with more than @@ -2648,10 +2665,8 @@ relay. Currently I use this only for testing. --> Remote message - Internet/MQTT + Internet MQTT Invitation - I’m experimenting with this - as a replacement for the relay. Known Players… These are your known remote