remove more relay stuff

This commit is contained in:
Eric House 2022-04-27 17:58:39 -07:00
parent b2a91246fa
commit 3a15b9daa4
16 changed files with 111 additions and 101 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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<RelayCheckBoxPreference> s_this = null;
public class MQTTCheckBoxPreference extends ConfirmingCheckBoxPreference {
private static final String TAG = MQTTCheckBoxPreference.class.getSimpleName();
private static WeakReference<MQTTCheckBoxPreference> 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 );
}

View file

@ -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];
}

View file

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

View file

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

View file

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

View file

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

View file

@ -87,7 +87,7 @@
<string name="key_relay_poll">key_relay_poll</string>
<string name="key_default_timerenabled">key_default_timerenabled</string>
<string name="key_notify_sound">key_notify_sound</string>
<string name="key_disable_relay">key_disable_relay</string>
<string name="key_disable_mqtt">key_disable_mqtt</string>
<string name="key_disable_bt">key_disable_bt</string>
<string name="key_notify_vibrate">key_notify_vibrate</string>
<string name="key_enable_nbs">key_enable_nbs</string>

View file

@ -969,8 +969,8 @@
<!-- explanation of the above -->
<string name="network_behavior_summary">Settings that apply to
networked games</string>
<string name="disable_relay">Disable play via the relay </string>
<string name="disable_relay_summary">Disable all internet communication</string>
<string name="disable_mqtt">Disable play via the internet </string>
<string name="disable_mqtt_summary">Disable all internet (MQTT) communication</string>
<string name="disable_bt">Disable play via Bluetooth</string>
<string name="disable_bt_summary">Disable all Bluetooth communication</string>
<!--
@ -1013,7 +1013,7 @@
<string name="newgame_reinvite">Invite again</string>
<!-- Button offering to invite Known Player to a new game -->
<string name="title_invite_history">Invitations Sent</string>
<string name="newgame_drop_relay">Drop Relay</string>
<string name="newgame_drop_mqtt">Drop Internet</string>
<!-- EXPLAIN ME -->
<!-- <string name="bt_disabled">Bluetooth is not available. This may -->
<!-- mean that your device doesn\'t support it, or that it\'s been -->
@ -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.
</string>
<string name="warn_relay_disabled">Relay play is currently disabled
<string name="warn_mqtt_disabled">Internet play is currently disabled
on this device. No moves will be sent or received via the
relay. </string>
<string name="warn_relay_later">You can enable relay play now, or
internet. </string>
<string name="warn_mqtt_later">You can enable internet play now, or
later.</string>
<string name="warn_relay_remove">You can enable relay play now, or
<string name="warn_mqtt_remove">You can enable internet play now, or
remove it from this game.</string>
<string name="warn_relay_havegames">Are you sure you want to
disable play using the relay (internet)?
<string name="warn_mqtt_havegames">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.</string>
<string name="warn_bt_havegames">Are you sure you want to
@ -1889,9 +1889,9 @@
certain you wont play against anybody nearby theres little harm
in leaving it on.
</string>
<plurals name="warn_relay_games_fmt">
<item quantity="one">\n\n(You have one active game using the relay now.)</item>
<item quantity="other">\n\n(You have %1$d active games using the relay now.)</item>
<plurals name="warn_mqtt_games_fmt">
<item quantity="one">\n\n(You have one active game using the internet now.)</item>
<item quantity="other">\n\n(You have %1$d active games using the internet now.)</item>
</plurals>
<plurals name="warn_bt_games_fmt">
<item quantity="one">\n\n(You have one active game using Bluetooth.)</item>
@ -1899,8 +1899,8 @@
</plurals>
<string name="button_enable_sms">Enable Data SMS</string>
<string name="button_enable_bt">Enable Bluetooth</string>
<string name="button_enable_relay">Enable Relay play</string>
<string name="button_disable_relay">Disable Relay play</string>
<string name="button_enable_mqtt">Enable Internet play</string>
<string name="button_disable_mqtt">Disable internet play</string>
<string name="button_disable_bt">Disable Bluetooth play</string>
<string name="button_later">Later</string>
<!-- -->
@ -2319,13 +2319,13 @@
<string name="checking_title">Checking</string>
<string name="checking_for_fmt">Checking for wordlists in %1$s…</string>
<string name="db_store_done">SD card write complete.</string>
<string name="confirm_drop_relay">Are you sure you want to drop this
games ability to communicate via the relay?</string>
<string name="confirm_drop_mqtt">Are you sure you want to drop this
games ability to communicate via the internet?</string>
<string name="confirm_drop_relay_bt">Bluetooth only works for nearby
devices.</string>
devices.</string>
<string name="confirm_drop_relay_sms">Not all carriers support play
via Data SMS.</string>
<string name="button_enable">Enable</string>
via Data SMS.</string>
<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

View file

@ -20,16 +20,10 @@
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_enable_p2p"
android:title="@string/title_enable_p2p"
android:summary="@string/summary_enable_p2p"
android:defaultValue="false"
/>
<org.eehouse.android.xw4.RelayCheckBoxPreference
android:key="@string/key_disable_relay"
android:title="@string/disable_relay"
android:summary="@string/disable_relay_summary"
<org.eehouse.android.xw4.MQTTCheckBoxPreference
android:key="@string/key_disable_mqtt"
android:title="@string/disable_mqtt"
android:summary="@string/disable_mqtt_summary"
android:defaultValue="false"
/>
@ -40,6 +34,12 @@
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_enable_p2p"
android:title="@string/title_enable_p2p"
android:summary="@string/summary_enable_p2p"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_invite_multi"
android:title="@string/invite_multi_title"
android:summary="@string/invite_multi_summary"