use new params-passing DlgDelegate to add hint about new selecting

feature.
This commit is contained in:
Eric House 2013-10-15 19:04:58 -07:00
parent 2ec0a7ba8d
commit 4bc554bc40
5 changed files with 56 additions and 21 deletions

View file

@ -2176,7 +2176,7 @@
<string name="relay_alert_title">Message from relay</string>
<string name="not_again_newselect">Tapping a game opens it.\n\nYou
can instead tap the icon at the left to select or deselect games,
can instead tap the icons at the left to select or deselect games,
then act on selected games, e.g. to delete them, using the menu or
\"Actionbar.\"</string>
</resources>

View file

@ -157,7 +157,7 @@ public class DlgDelegate {
}
public void showNotAgainDlgThen( int msgID, int prefsKey,
int callbackID )
int callbackID, Object[] params )
{
if ( XWPrefs.getPrefsBoolean( m_activity, prefsKey, false ) ) {
// If it's set, do the action without bothering with the
@ -165,17 +165,24 @@ public class DlgDelegate {
if ( SKIP_CALLBACK != callbackID ) {
m_clickCallback.dlgButtonClicked( callbackID,
AlertDialog.BUTTON_POSITIVE,
null );
params );
}
} else {
String msg = m_activity.getString( msgID );
DlgState state =
new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey );
new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey,
params );
addState( state );
m_activity.showDialog( DIALOG_NOTAGAIN );
}
}
public void showNotAgainDlgThen( int msgID, int prefsKey,
int callbackID )
{
showNotAgainDlgThen( msgID, prefsKey, callbackID, null );
}
public void showNotAgainDlgThen( int msgID, int prefsKey )
{
showNotAgainDlgThen( msgID, prefsKey, SKIP_CALLBACK );

View file

@ -41,6 +41,13 @@ public class DlgState implements Parcelable {
this( id, msg, R.string.button_ok, cbckID, prefsKey );
}
public DlgState( int id, String msg, int cbckID, int prefsKey,
Object[] params )
{
this( id, msg, R.string.button_ok, cbckID, prefsKey );
m_params = params;
}
public DlgState( int id, String msg, int posButton,
int cbckID, int prefsKey )
{

View file

@ -90,6 +90,7 @@ public class GamesList extends XWExpandableListActivity
private static final int NEW_FROM_ACTION = 5;
private static final int DELETE_GROUP_ACTION = 6;
private static final int DELETE_SELGAMES_ACTION = 7;
private static final int OPEN_GAME_ACTION = 8;
private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
, R.id.gamel_menu_storedb
, R.id.gamel_menu_checkupdates
@ -494,23 +495,9 @@ public class GamesList extends XWExpandableListActivity
// dialog in case it was dismissed. That way it to check for
// an empty room name.
if ( !m_gameLaunched ) {
if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
&& summary.roomName.length() == 0 ) {
// If it's unconfigured and of the type RelayGameActivity
// can handle send it there, otherwise use the full-on
// config.
Class clazz;
if ( RelayGameActivity.isSimpleGame( summary ) ) {
clazz = RelayGameActivity.class;
} else {
clazz = GameConfig.class;
}
GameUtils.doConfig( this, rowid, clazz );
} else {
if ( checkWarnNoDict( rowid ) ) {
launchGame( rowid );
}
}
showNotAgainDlgThen( R.string.not_again_newselect,
R.string.key_notagain_newselect,
OPEN_GAME_ACTION, rowid, summary );
}
}
@ -585,6 +572,9 @@ public class GamesList extends XWExpandableListActivity
case DELETE_SELGAMES_ACTION:
deleteSelected();
break;
case OPEN_GAME_ACTION:
doOpenGame( params );
break;
default:
Assert.fail();
}
@ -1186,6 +1176,31 @@ public class GamesList extends XWExpandableListActivity
tryAlert( intent );
}
private void doOpenGame( Object[] params )
{
GameSummary summary = (GameSummary)params[1];
long rowid = (Long)params[0];
if ( summary.conType == CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
&& summary.roomName.length() == 0 ) {
// If it's unconfigured and of the type RelayGameActivity
// can handle send it there, otherwise use the full-on
// config.
Class clazz;
if ( RelayGameActivity.isSimpleGame( summary ) ) {
clazz = RelayGameActivity.class;
} else {
clazz = GameConfig.class;
}
GameUtils.doConfig( this, rowid, clazz );
} else {
if ( checkWarnNoDict( rowid ) ) {
launchGame( rowid );
}
}
}
public static void onGameDictDownload( Context context, Intent intent )
{
intent.setClass( context, GamesList.class );

View file

@ -84,6 +84,12 @@ public class XWExpandableListActivity extends ExpandableListActivity
m_delegate.doSyncMenuitem();
}
protected void showNotAgainDlgThen( int msgID, int prefsKey,
int action, Object... params )
{
m_delegate.showNotAgainDlgThen( msgID, prefsKey, action, params );
}
protected void showNotAgainDlgThen( int msgID, int prefsKey,
int action )
{