Add option to remove relay from a game once it's been turned off.

This commit is contained in:
Eric House 2016-06-26 15:53:26 -07:00
parent 3d682c425f
commit 3bc60c59d0
7 changed files with 318 additions and 278 deletions

File diff suppressed because it is too large Load diff

View file

@ -2103,10 +2103,14 @@
Bluetooth now, or later. Bluetooth now, or later.
</string> </string>
<string name="warn_relay_disabled">Relay play is currently disable on <string name="warn_relay_disabled">Relay play is currently disable
this device. No moves will be sent or received via the on this device. No moves will be sent or received via the
relay.\n\nYou can enable relay play now, or later. relay. </string>
</string>
<string name="warn_relay_later">You can enable relay play now, or
later.</string>
<string name="warn_relay_remove">You can enable relay play now, or
remove it from this game.</string>
<string name="warn_relay_havegames">Are you sure you want to <string name="warn_relay_havegames">Are you sure you want to
disable play using the relay?</string> disable play using the relay?</string>

View file

@ -1822,10 +1822,13 @@
ecived. On sevom lliw eb tnes aiv Htooteulb.\n\nUoy nac elbane ecived. On sevom lliw eb tnes aiv Htooteulb.\n\nUoy nac elbane
Htooteulb ,won ro retal. Htooteulb ,won ro retal.
</string> </string>
<string name="warn_relay_disabled">Yaler yalp si yltnerruc elbasid no <string name="warn_relay_disabled">Yaler yalp si yltnerruc elbasid
siht ecived. On sevom lliw eb tnes ro deviecer aiv eht no siht ecived. On sevom lliw eb tnes ro deviecer aiv eht
yaler.\n\nUoy nac elbane yaler yalp ,won ro retal. yaler. </string>
</string> <string name="warn_relay_later">Uoy nac elbane yaler yalp ,won ro
retal.</string>
<string name="warn_relay_remove">Uoy nac elbane yaler yalp ,won ro
evomer ti morf siht emag.</string>
<string name="warn_relay_havegames">Era uoy erus uoy tnaw ot <string name="warn_relay_havegames">Era uoy erus uoy tnaw ot
elbasid yalp gnisu eht ?yaler</string> elbasid yalp gnisu eht ?yaler</string>
<plurals name="warn_relay_games_fmt"> <plurals name="warn_relay_games_fmt">

View file

@ -1822,10 +1822,13 @@
DEVICE. NO MOVES WILL BE SENT VIA BLUETOOTH.\n\nYOU CAN ENABLE DEVICE. NO MOVES WILL BE SENT VIA BLUETOOTH.\n\nYOU CAN ENABLE
BLUETOOTH NOW, OR LATER. BLUETOOTH NOW, OR LATER.
</string> </string>
<string name="warn_relay_disabled">RELAY PLAY IS CURRENTLY DISABLE ON <string name="warn_relay_disabled">RELAY PLAY IS CURRENTLY DISABLE
THIS DEVICE. NO MOVES WILL BE SENT OR RECEIVED VIA THE ON THIS DEVICE. NO MOVES WILL BE SENT OR RECEIVED VIA THE
RELAY.\n\nYOU CAN ENABLE RELAY PLAY NOW, OR LATER. RELAY. </string>
</string> <string name="warn_relay_later">YOU CAN ENABLE RELAY PLAY NOW, OR
LATER.</string>
<string name="warn_relay_remove">YOU CAN ENABLE RELAY PLAY NOW, OR
REMOVE IT FROM THIS GAME.</string>
<string name="warn_relay_havegames">ARE YOU SURE YOU WANT TO <string name="warn_relay_havegames">ARE YOU SURE YOU WANT TO
DISABLE PLAY USING THE RELAY?</string> DISABLE PLAY USING THE RELAY?</string>
<plurals name="warn_relay_games_fmt"> <plurals name="warn_relay_games_fmt">

View file

@ -1035,7 +1035,22 @@ public class BoardDelegate extends DelegateBase
final Object[] params ) final Object[] params )
{ {
boolean handled = false; boolean handled = false;
if ( AlertDialog.BUTTON_POSITIVE == which ) { boolean positive = AlertDialog.BUTTON_POSITIVE == which;
DbgUtils.logf("BoardDelegate.dlgButtonClicked(%s, %b)", action.toString(), positive );
if ( Action.ENABLE_RELAY_DO == action ) {
handled = true;
if ( positive ) {
RelayService.setEnabled( m_activity, true );
} else {
// Things get very confused if askDropRelay() is called here.
postDelayed( new Runnable() {
public void run() {
askDropRelay();
}
}, 10 );
}
} else if ( positive ) {
handled = true; handled = true;
JNICmd cmd = JNICmd.CMD_NONE; JNICmd cmd = JNICmd.CMD_NONE;
switch ( action ) { switch ( action ) {
@ -2375,9 +2390,10 @@ public class BoardDelegate extends DelegateBase
} }
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) { if ( m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
if ( !RelayService.relayEnabled( m_activity ) ) { if ( !RelayService.relayEnabled( m_activity ) ) {
showConfirmThen( R.string.warn_relay_disabled, String msg = getString( R.string.warn_relay_disabled )
R.string.button_enable_relay, + "\n\n" + getString( R.string.warn_relay_remove );
R.string.button_later, showConfirmThen( msg, R.string.button_enable_relay,
R.string.newgame_drop_relay,
Action.ENABLE_RELAY_DO ); Action.ENABLE_RELAY_DO );
} }
} }

View file

@ -351,8 +351,9 @@ public class GameConfigDelegate extends DelegateBase
Action.ENABLE_BT_DO ); Action.ENABLE_BT_DO );
break; break;
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
showConfirmThen( R.string.warn_relay_disabled, String msg = getString( R.string.warn_relay_disabled )
R.string.button_enable_relay, + "\n\n" + getString( R.string.warn_relay_later );
showConfirmThen( msg, R.string.button_enable_relay,
R.string.button_later, R.string.button_later,
Action.ENABLE_RELAY_DO ); Action.ENABLE_RELAY_DO );
break; break;

View file

@ -61,6 +61,7 @@ public class XWConnAddrPreference extends DialogPreference {
m_view.configure( XWPrefs.getAddrTypes( m_context ), m_view.configure( XWPrefs.getAddrTypes( m_context ),
new ConnViaViewLayout.CheckEnabledWarner() { new ConnViaViewLayout.CheckEnabledWarner() {
public void warnDisabled( CommsConnType typ ) { public void warnDisabled( CommsConnType typ ) {
String msg;
switch( typ ) { switch( typ ) {
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
activity.showConfirmThen( R.string.warn_sms_disabled, activity.showConfirmThen( R.string.warn_sms_disabled,
@ -74,10 +75,15 @@ public class XWConnAddrPreference extends DialogPreference {
R.string.button_later, R.string.button_later,
Action.ENABLE_BT_DO ); Action.ENABLE_BT_DO );
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
activity.showConfirmThen( R.string.warn_relay_disabled, msg = LocUtils
R.string.button_enable_relay, .getString( m_context, R.string
.warn_relay_disabled );
msg += "\n\n" + LocUtils
.getString( m_context,
R.string.warn_relay_later );
activity.showConfirmThen( msg, R.string.button_enable_relay,
R.string.button_later, R.string.button_later,
Action.ENABLE_BT_DO ); Action.ENABLE_RELAY_DO );
break; break;
default: default:
Assert.fail(); Assert.fail();