diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index cbad3b5f2..f9d1d4c98 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -127,7 +127,6 @@ android { buildConfigField "boolean", "LOG_LIFECYLE", "false" buildConfigField "String", "KEY_FCMID", "\"FBMService_fcmid\"" buildConfigField "boolean", "ATTACH_SUPPORTED", "false" - buildConfigField "boolean", "OFFER_MQTT", "true" buildConfigField "boolean", "NON_RELEASE", "DEBUG || !IS_TAGGED_BUILD" buildConfigField "boolean", "HAVE_KNOWN_PLAYERS", "true" buildConfigField "boolean", "FOR_FDROID", "false" diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 44e0c2a6f..d3561f6b0 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -130,7 +130,7 @@ public class BoardDelegate extends DelegateBase private boolean m_showedReInvite; private boolean m_overNotShown; - private boolean m_dropRelayOnDismiss; + private boolean m_dropMQTTOnDismiss; private boolean m_haveStartedShowing; private Wrapper mNFCWrapper; @@ -1008,8 +1008,8 @@ public class BoardDelegate extends DelegateBase boolean handled = true; JNICmd cmd = null; switch ( action ) { - case ENABLE_RELAY_DO_OR: - RelayService.logGoneFail( TAG, 1 ); + case ENABLE_MQTT_DO_OR: + MQTTUtils.setEnabled( m_activity, true ); break; case UNDO_LAST_ACTION: cmd = JNICmd.CMD_UNDO_LAST; @@ -1071,8 +1071,8 @@ public class BoardDelegate extends DelegateBase case LOOKUP_ACTION: launchLookup( m_mySIS.words, m_gi.dictLang ); break; - case DROP_RELAY_ACTION: - dropConViaAndRestart( CommsConnType.COMMS_CONN_RELAY ); + case DROP_MQTT_ACTION: + dropConViaAndRestart( CommsConnType.COMMS_CONN_MQTT ); break; case DELETE_AND_EXIT: deleteAndClose(); @@ -1187,8 +1187,8 @@ public class BoardDelegate extends DelegateBase Log.d( TAG, "onNegButton(%s, %s)", action, DbgUtils.toStr( params ) ); boolean handled = true; switch ( action ) { - case ENABLE_RELAY_DO_OR: - m_dropRelayOnDismiss = true; + case ENABLE_MQTT_DO_OR: + m_dropMQTTOnDismiss = true; break; case DROP_SMS_ACTION: dropConViaAndRestart( CommsConnType.COMMS_CONN_SMS ); @@ -1225,12 +1225,12 @@ public class BoardDelegate extends DelegateBase Log.d( TAG, "onDismissed(%s, %s)", action, DbgUtils.toStr( params ) ); boolean handled = true; switch ( action ) { - case ENABLE_RELAY_DO_OR: - if ( m_dropRelayOnDismiss ) { + case ENABLE_MQTT_DO_OR: + if ( m_dropMQTTOnDismiss ) { postDelayed( new Runnable() { @Override public void run() { - askDropRelay(); + askDropMQTT(); } }, 10 ); } @@ -1651,16 +1651,16 @@ public class BoardDelegate extends DelegateBase finish(); } - private void askDropRelay() + private void askDropMQTT() { - String msg = getString( R.string.confirm_drop_relay ); + String msg = getString( R.string.confirm_drop_mqtt ); if ( m_connTypes.contains(CommsConnType.COMMS_CONN_BT) ) { msg += " " + getString( R.string.confirm_drop_relay_bt ); } if ( m_connTypes.contains(CommsConnType.COMMS_CONN_SMS) ) { msg += " " + getString( R.string.confirm_drop_relay_sms ); } - makeConfirmThenBuilder( msg, Action.DROP_RELAY_ACTION ).show(); + makeConfirmThenBuilder( msg, Action.DROP_MQTT_ACTION ).show(); } private void dropConViaAndRestart( CommsConnType typ ) @@ -2663,13 +2663,17 @@ public class BoardDelegate extends DelegateBase } } if ( m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) { - if ( !XWPrefs.getRelayEnabled( m_activity ) ) { - m_dropRelayOnDismiss = false; - String msg = getString( R.string.warn_relay_disabled ) - + "\n\n" + getString( R.string.warn_relay_remove ); - makeConfirmThenBuilder( msg, Action.ENABLE_RELAY_DO_OR ) - .setPosButton( R.string.button_enable_relay ) - .setNegButton( R.string.newgame_drop_relay ) + Assert.failDbg(); + } + + if ( m_connTypes.contains( CommsConnType.COMMS_CONN_MQTT ) ) { + if ( !XWPrefs.getMQTTEnabled( m_activity ) ) { + m_dropMQTTOnDismiss = false; + String msg = getString( R.string.warn_mqtt_disabled ) + + "\n\n" + getString( R.string.warn_mqtt_remove ); + makeConfirmThenBuilder( msg, Action.ENABLE_MQTT_DO_OR ) + .setPosButton( R.string.button_enable_mqtt ) + .setNegButton( R.string.newgame_drop_mqtt ) .show(); } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java index 2a5db0b12..d06408f64 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnStatusHandler.java @@ -680,8 +680,8 @@ public class ConnStatusHandler { //!getAirplaneModeOn( context ); break; case COMMS_CONN_RELAY: - result = XWPrefs.getRelayEnabled( context ) - && NetStateCache.netAvail( context ); + Assert.failDbg(); + result = false; break; case COMMS_CONN_P2P: result = WiDirService.connecting(); @@ -690,7 +690,8 @@ public class ConnStatusHandler { result = NFCUtils.nfcAvail( context )[1]; break; case COMMS_CONN_MQTT: - result = BuildConfig.OFFER_MQTT; + result = XWPrefs.getMQTTEnabled( context ) + && NetStateCache.netAvail( context ); break; default: Log.w( TAG, "connTypeEnabled: %s not handled", connType.toString() ); 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 31eec8e55..2ef7b79df 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 @@ -126,13 +126,14 @@ public class ConnViaViewLayout extends LinearLayout { enabled = BTUtils.BTEnabled(); break; case COMMS_CONN_RELAY: - enabled = XWPrefs.getRelayEnabled( context ); + Assert.failDbg(); + enabled = false; break; case COMMS_CONN_P2P: enabled = WiDirWrapper.enabled(); break; case COMMS_CONN_MQTT: - enabled = BuildConfig.OFFER_MQTT; + enabled = XWPrefs.getMQTTEnabled( context ); break; default: Assert.failDbg(); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DelegateBase.java index 7c8eca983..05d7f7f13 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DelegateBase.java @@ -798,8 +798,8 @@ public abstract class DelegateBase implements DlgClickNotify, case ENABLE_BT_DO: BTUtils.enable( m_activity ); break; - case ENABLE_RELAY_DO: - RelayService.logGoneFail( TAG, 1 ); + case ENABLE_MQTT_DO: + MQTTUtils.setEnabled( m_activity, true ); break; case PERMS_QUERY: Perms23.onGotPermsAction( this, true, params ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java index 465150d45..02169c939 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java @@ -78,7 +78,7 @@ public class DlgDelegate { VALUES_ACTION, SMS_CONFIG_ACTION, BUTTON_BROWSEALL_ACTION, - DROP_RELAY_ACTION, + DROP_MQTT_ACTION, DROP_SMS_ACTION, INVITE_SMS_DATA, BLANK_PICKED, @@ -126,9 +126,9 @@ public class DlgDelegate { ENABLE_NBS_ASK, ENABLE_NBS_DO, ENABLE_BT_DO, - ENABLE_RELAY_DO, - ENABLE_RELAY_DO_OR, - DISABLE_RELAY_DO, + ENABLE_MQTT_DO, + ENABLE_MQTT_DO_OR, + DISABLE_MQTT_DO, DISABLE_BT_DO, ASKED_PHONE_STATE, PERMS_QUERY, 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 2fb171751..5a1ba9e5b 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 @@ -272,10 +272,13 @@ public class GameConfigDelegate extends DelegateBase .show(); break; case COMMS_CONN_RELAY: - String msg = getString( R.string.warn_relay_disabled ) - + "\n\n" + getString( R.string.warn_relay_later ); - makeConfirmThenBuilder( msg, Action.ENABLE_RELAY_DO ) - .setPosButton( R.string.button_enable_relay ) + Assert.failDbg(); + break; + case COMMS_CONN_MQTT: + String msg = getString( R.string.warn_mqtt_disabled ) + + "\n\n" + getString( R.string.warn_mqtt_later ); + makeConfirmThenBuilder( msg, Action.ENABLE_MQTT_DO ) + .setPosButton( R.string.button_enable_mqtt ) .setNegButton( R.string.button_later ) .show(); break; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayCheckBoxPreference.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTCheckBoxPreference.java similarity index 75% rename from xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayCheckBoxPreference.java rename to xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTCheckBoxPreference.java index 02eef950a..d76ecaf8b 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayCheckBoxPreference.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTCheckBoxPreference.java @@ -29,11 +29,11 @@ import org.eehouse.android.xw4.DlgDelegate.Action; import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; import org.eehouse.android.xw4.loc.LocUtils; -public class RelayCheckBoxPreference extends ConfirmingCheckBoxPreference { - private static final String TAG = RelayCheckBoxPreference.class.getSimpleName(); - private static WeakReference s_this = null; +public class MQTTCheckBoxPreference extends ConfirmingCheckBoxPreference { + private static final String TAG = MQTTCheckBoxPreference.class.getSimpleName(); + private static WeakReference s_this = null; - public RelayCheckBoxPreference( Context context, AttributeSet attrs ) + public MQTTCheckBoxPreference( Context context, AttributeSet attrs ) { super( context, attrs ); s_this = new WeakReference<>( this ); @@ -44,23 +44,23 @@ public class RelayCheckBoxPreference extends ConfirmingCheckBoxPreference { { PrefsActivity activity = (PrefsActivity)getContext(); String msg = LocUtils.getString( activity, - R.string.warn_relay_havegames ); + R.string.warn_mqtt_havegames ); int count = DBUtils - .getGameCountUsing( activity, CommsConnType.COMMS_CONN_RELAY ); + .getGameCountUsing( activity, CommsConnType.COMMS_CONN_MQTT ); if ( 0 < count ) { - msg += LocUtils.getQuantityString( activity, R.plurals.warn_relay_games_fmt, + msg += LocUtils.getQuantityString( activity, R.plurals.warn_mqtt_games_fmt, count, count ); } - activity.makeConfirmThenBuilder( msg, Action.DISABLE_RELAY_DO ) - .setPosButton( R.string.button_disable_relay ) + activity.makeConfirmThenBuilder( msg, Action.DISABLE_MQTT_DO ) + .setPosButton( R.string.button_disable_mqtt ) .show(); } protected static void setChecked() { if ( null != s_this ) { - RelayCheckBoxPreference self = s_this.get(); + MQTTCheckBoxPreference self = s_this.get(); if ( null != self ) { self.super_setChecked( true ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java index fa38870aa..0c0928255 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java @@ -97,7 +97,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba public static void init( Context context ) { - Log.d( TAG, "init(OFFER_MQTT:%b)", BuildConfig.OFFER_MQTT ); + Log.d( TAG, "init()" ); getOrStart( context ); } @@ -107,11 +107,14 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba getOrStart( context ); } - public static void onFCMReceived( Context context ) + public static void setEnabled( Context context, boolean enabled ) { - Log.d( TAG, "onFCMReceived()" ); - onConfigChanged( context ); - getOrStart( context ); + Log.d( TAG, "setEnabled( %b )", enabled ); + if ( enabled ) { + getOrStart( context ); + } else { + onConfigChanged( context ); + } } private static void timerFired( Context context ) @@ -141,7 +144,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba private static MQTTUtils getOrStart( Context context ) { MQTTUtils result = null; - if ( BuildConfig.OFFER_MQTT ) { + if ( XWPrefs.getMQTTEnabled( context ) ) { synchronized( sInstance ) { result = sInstance[0]; } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java index 1e56b306d..8ed10e7e7 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java @@ -563,7 +563,7 @@ public class NetLaunchInfo implements Serializable { break; case COMMS_CONN_MQTT: mqttDevID = json.optString( MQTT_DEVID_KEY ); - doAdd = BuildConfig.OFFER_MQTT && null != mqttDevID; + doAdd = null != mqttDevID; break; default: doAdd = false; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java index 783ef5eed..d4ef1b937 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java @@ -60,7 +60,7 @@ public class PrefsDelegate extends DelegateBase R.string.key_force_radio, R.string.key_disable_nag, R.string.key_disable_nag_solo, - R.string.key_disable_relay, + R.string.key_disable_mqtt, R.string.key_disable_bt, R.string.key_force_tablet, R.string.key_mqtt_host, @@ -278,8 +278,9 @@ public class PrefsDelegate extends DelegateBase case R.string.key_disable_nag_solo: NagTurnReceiver.resetNagsDisabled( mActivity ); break; - case R.string.key_disable_relay: - RelayService.logGoneFail( TAG, 1 ); + case R.string.key_disable_mqtt: + boolean enabled = sp.getBoolean( key, true ); + MQTTUtils.setEnabled( mActivity, enabled ); break; case R.string.key_disable_bt: BTUtils.disabledChanged( mActivity ); @@ -308,8 +309,9 @@ public class PrefsDelegate extends DelegateBase XWPrefs.setNBSEnabled( mActivity, true ); SMSCheckBoxPreference.setChecked(); break; - case DISABLE_RELAY_DO: - RelayService.logGoneFail( TAG, 2 ); + case DISABLE_MQTT_DO: + MQTTUtils.setEnabled( mActivity, false ); + MQTTCheckBoxPreference.setChecked(); break; case DISABLE_BT_DO: BTUtils.setEnabled( mActivity, false ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java index 4229571fc..364b01df2 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java @@ -87,15 +87,15 @@ public class XWConnAddrPreference extends DialogPreference action = Action.ENABLE_BT_DO; buttonID = R.string.button_enable_bt; break; - case COMMS_CONN_RELAY: + case COMMS_CONN_MQTT: msg = LocUtils .getString( activity, R.string - .warn_relay_disabled ); + .warn_mqtt_disabled ); msg += "\n\n" + LocUtils .getString( activity, - R.string.warn_relay_later ); - action = Action.ENABLE_RELAY_DO; - buttonID = R.string.button_enable_relay; + R.string.warn_mqtt_later ); + action = Action.ENABLE_MQTT_DO; + buttonID = R.string.button_enable_mqtt; break; default: Assert.failDbg(); 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 e197c9130..36188cc4a 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 @@ -140,11 +140,11 @@ public class XWPrefs { return NetUtils.forceHost( host ); } - public static boolean getRelayEnabled( Context context ) + public static boolean getMQTTEnabled( Context context ) { - boolean enabled = ! getPrefsBoolean( context, R.string.key_disable_relay, + boolean enabled = ! getPrefsBoolean( context, R.string.key_disable_mqtt, false ); - // Log.d( TAG, "getRelayEnabled() => %b", enabled ); + Log.d( TAG, "getMQTTEnabled() => %b", enabled ); return enabled; } @@ -489,11 +489,8 @@ public class XWPrefs { int flags = getPrefsInt( context, R.string.key_addrs_pref, -1 ); if ( -1 == flags ) { result = new CommsConnTypeSet(); - if ( getRelayEnabled( context ) ) { + if ( getMQTTEnabled( context ) ) { result.add( CommsConnType.COMMS_CONN_MQTT ); - if ( !BuildConfig.NO_NEW_RELAY ) { - result.add( CommsConnType.COMMS_CONN_RELAY ); - } } if ( BTUtils.BTEnabled() ) { result.add( CommsConnType.COMMS_CONN_BT ); diff --git a/xwords4/android/app/src/main/res/values/common_rsrc.xml b/xwords4/android/app/src/main/res/values/common_rsrc.xml index 8b689a95e..e81e1bbbe 100644 --- a/xwords4/android/app/src/main/res/values/common_rsrc.xml +++ b/xwords4/android/app/src/main/res/values/common_rsrc.xml @@ -87,7 +87,7 @@ key_relay_poll key_default_timerenabled key_notify_sound - key_disable_relay + key_disable_mqtt key_disable_bt key_notify_vibrate key_enable_nbs diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index ac5fbd357..26969d996 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -969,8 +969,8 @@ Settings that apply to networked games - Disable play via the relay - Disable all internet communication + Disable play via the internet + Disable all internet (MQTT) communication Disable play via Bluetooth Disable all Bluetooth communication Invitations Sent - Drop Relay + Drop Internet @@ -1869,17 +1869,17 @@ disabled, and no moves will be exchanged via Bluetooth until it is enabled.\n\nYou can enable Bluetooth now, or later. - Relay play is currently disabled + Internet play is currently disabled on this device. No moves will be sent or received via the - relay. - You can enable relay play now, or + internet. + You can enable internet play now, or later. - You can enable relay play now, or + You can enable internet play now, or remove it from this game. - Are you sure you want to - disable play using the relay (internet)? + Are you sure you want to + disable play using the internet? \n\n - Most networked games exchange moves via the relay, so only do this + Most two-device games exchange moves via the internet, so only do this if you plan to play ALL games against a robot on this same device. Are you sure you want to @@ -1889,9 +1889,9 @@ certain you won’t play against anybody nearby there’s little harm in leaving it on. - - \n\n(You have one active game using the relay now.) - \n\n(You have %1$d active games using the relay now.) + + \n\n(You have one active game using the internet now.) + \n\n(You have %1$d active games using the internet now.) \n\n(You have one active game using Bluetooth.) @@ -1899,8 +1899,8 @@ Enable Data SMS Enable Bluetooth - Enable Relay play - Disable Relay play + Enable Internet play + Disable internet play Disable Bluetooth play Later @@ -2319,13 +2319,13 @@ Checking Checking for wordlists in %1$s… SD card write complete. - Are you sure you want to drop this - game’s ability to communicate via the relay? + Are you sure you want to drop this + game’s ability to communicate via the internet? Bluetooth only works for nearby - devices. + devices. Not all carriers support play - via Data SMS. - Enable + via Data SMS. + Enable The “relay” is a server for passing messages between devices running CrossWords. It’s diff --git a/xwords4/android/app/src/main/res/xml/prefs_net.xml b/xwords4/android/app/src/main/res/xml/prefs_net.xml index c55e52f02..41c2d2ae1 100644 --- a/xwords4/android/app/src/main/res/xml/prefs_net.xml +++ b/xwords4/android/app/src/main/res/xml/prefs_net.xml @@ -20,16 +20,10 @@ android:defaultValue="false" /> - - - @@ -40,6 +34,12 @@ android:defaultValue="false" /> + +