warn when user disables all communication options in prefs

This commit is contained in:
Eric House 2015-01-31 23:17:13 -08:00
parent 5d58c09120
commit 46c4cc0669
8 changed files with 90 additions and 50 deletions

View file

@ -2604,6 +2604,7 @@ public final class R {
line in a game summary. The \u0020 is a space in xml.
*/
public static final int vs_join=0x7f050123;
public static final int warn_no_comms=0x7f0502da;
/**
*/
public static final int warn_nomobile_fmt=0x7f05021f;

View file

@ -2297,4 +2297,8 @@
<string name="enable_bt_first">Please turn Bluetooth on before enabling.</string>
<string name="enable_sms_first">Please check \"Allow games via SMS\" before enabling.</string>
<string name="warn_no_comms">If you have no default connection
options every new networked game will have to be configured
manually.</string>
</resources>

View file

@ -1951,4 +1951,7 @@
emag si nepo.</string>
<string name="enable_bt_first">Esaelp nrut Htooteulb no erofeb gnilbane.</string>
<string name="enable_sms_first">Esaelp kcehc \"Wolla semag aiv SMS\" erofeb gnilbane.</string>
<string name="warn_no_comms">Fi uoy evah on tluafed noitcennoc
snoitpo yreve wen dekrowten emag lliw evah ot eb derugifnoc
yllaunam.</string>
</resources>

View file

@ -1951,4 +1951,7 @@
GAME IS OPEN.</string>
<string name="enable_bt_first">PLEASE TURN BLUETOOTH ON BEFORE ENABLING.</string>
<string name="enable_sms_first">PLEASE CHECK \"ALLOW GAMES VIA SMS\" BEFORE ENABLING.</string>
<string name="warn_no_comms">IF YOU HAVE NO DEFAULT CONNECTION
OPTIONS EVERY NEW NETWORKED GAME WILL HAVE TO BE CONFIGURED
MANUALLY.</string>
</resources>

View file

@ -40,21 +40,26 @@ public class ConnViaViewLayout extends LinearLayout {
public interface CheckEnabledWarner {
public void warnDisabled( CommsConnType typ );
}
private CheckEnabledWarner m_warner;
public interface SetEmptyWarner {
public void typeSetEmpty();
}
private CheckEnabledWarner m_disabledWarner;
private SetEmptyWarner m_emptyWarner;
public ConnViaViewLayout( Context context, AttributeSet as ) {
super( context, as );
}
protected void setWarner( CheckEnabledWarner warner )
{
m_warner = warner;
}
protected void setTypes( CommsConnTypeSet types )
protected void configure( CommsConnTypeSet types,
CheckEnabledWarner cew,
SetEmptyWarner sew )
{
m_curSet = (CommsConnTypeSet)types.clone();
addConnections();
m_disabledWarner = cew;
m_emptyWarner = sew;
}
protected CommsConnTypeSet getTypes()
@ -88,6 +93,9 @@ public class ConnViaViewLayout extends LinearLayout {
}
} else {
m_curSet.remove( typf );
if ( null != m_emptyWarner && 0 == m_curSet.size()) {
m_emptyWarner.typeSetEmpty();
}
}
}
} );
@ -106,8 +114,8 @@ public class ConnViaViewLayout extends LinearLayout {
result = BTService.BTEnabled();
}
if ( !result && null != m_warner ) {
m_warner.warnDisabled( typ );
if ( !result && null != m_disabledWarner ) {
m_disabledWarner.warnDisabled( typ );
}
return result;

View file

@ -282,8 +282,8 @@ public class GameConfigDelegate extends DelegateBase
LinearLayout layout = (LinearLayout)inflate( R.layout.conn_types_display );
final ConnViaViewLayout items = (ConnViaViewLayout)
layout.findViewById( R.id.conn_types );
items.setTypes( m_conTypes );
items.setWarner( new ConnViaViewLayout.CheckEnabledWarner() {
items.configure( m_conTypes,
new ConnViaViewLayout.CheckEnabledWarner() {
public void warnDisabled( CommsConnType typ ) {
switch( typ ) {
case COMMS_CONN_SMS:
@ -296,7 +296,8 @@ public class GameConfigDelegate extends DelegateBase
break;
}
}
});
public void typeSetEmpty() {}
}, null );
final DialogInterface.OnClickListener lstnr =
new DialogInterface.OnClickListener() {

View file

@ -1142,7 +1142,7 @@ public class GamesListDelegate extends ListDelegateBase
break;
case NEW_GAME_PRESSED:
showDialog( DlgID.GAMES_LIST_NEWGAME );
handleNewGame( m_nextIsSolo );
break;
case DELETE_GROUPS:
@ -1330,12 +1330,10 @@ public class GamesListDelegate extends ListDelegateBase
GameUtils.resendAllIf( m_activity, null, true );
break;
case R.id.games_menu_newgame_solo:
m_nextIsSolo = true;
showDialog( DlgID.GAMES_LIST_NEWGAME );
handleNewGame( true );
break;
case R.id.games_menu_newgame_net:
m_nextIsSolo = false;
showDialog( DlgID.GAMES_LIST_NEWGAME );
handleNewGame( false );
break;
case R.id.games_menu_newgroup:
@ -1565,6 +1563,22 @@ public class GamesListDelegate extends ListDelegateBase
}
}
private void handleNewGame( boolean solo )
{
m_nextIsSolo = solo;
// force config if we don't have at least one way to communicate
boolean skipDefaults = !solo;
if ( skipDefaults ) {
skipDefaults = 0 == XWPrefs.getAddrTypes( m_activity ).size();
}
if ( skipDefaults ) {
makeThenLaunchOrConfigure( true );
} else {
showDialog( DlgID.GAMES_LIST_NEWGAME );
}
}
private void handleNewGameButton( boolean solo )
{
m_nextIsSolo = solo;
@ -1572,7 +1586,7 @@ public class GamesListDelegate extends ListDelegateBase
int count = m_adapter.getCount();
boolean skipOffer = 6 > count || XWPrefs.getHideNewgameButtons( m_activity );
if ( skipOffer ) {
showDialog( DlgID.GAMES_LIST_NEWGAME );
handleNewGame( solo );
} else {
ActionPair pair = new ActionPair( Action.SET_HIDE_NEWGAME_BUTTONS,
R.string.set_pref );

View file

@ -54,8 +54,8 @@ public class XWConnAddrPreference extends DialogPreference {
{
LocUtils.xlateView( m_context, view );
m_view = (ConnViaViewLayout)view.findViewById( R.id.conn_types );
m_view.setTypes( XWPrefs.getAddrTypes( m_context ) );
m_view.setWarner( new ConnViaViewLayout.CheckEnabledWarner() {
m_view.configure( XWPrefs.getAddrTypes( m_context ),
new ConnViaViewLayout.CheckEnabledWarner() {
public void warnDisabled( CommsConnType typ ) {
int id;
switch( typ ) {
@ -73,6 +73,12 @@ public class XWConnAddrPreference extends DialogPreference {
activity.showOKOnlyDialog( id );
}
}
},
new ConnViaViewLayout.SetEmptyWarner() {
public void typeSetEmpty() {
PrefsActivity activity = (PrefsActivity)m_context;
activity.showOKOnlyDialog( R.string.warn_no_comms );
}
} );
}