add enum to hold all dialogIDs so they're forced to be unique across the app. (The diff's big but there's no behavior change.)

This commit is contained in:
Eric House 2014-03-14 06:37:32 -07:00
parent ad0f882335
commit 94d9a03d51
13 changed files with 241 additions and 209 deletions

View file

@ -71,25 +71,6 @@ public class BoardActivity extends XWActivity
public static final String INTENT_KEY_CHAT = "chat";
private static final int BLOCKING_DLG_NONE = -1;
private static final int DLG_OKONLY = DlgDelegate.DIALOG_LAST + 1;
private static final int DLG_BADWORDS_BLK = DLG_OKONLY + 1;
private static final int QUERY_REQUEST_BLK = DLG_OKONLY + 2;
private static final int QUERY_INFORM_BLK = DLG_OKONLY + 3;
private static final int PICK_TILE_REQUESTBLANK_BLK = DLG_OKONLY + 4;
private static final int ASK_PASSWORD_BLK = DLG_OKONLY + 5;
private static final int DLG_RETRY = DLG_OKONLY + 6;
private static final int QUERY_ENDGAME = DLG_OKONLY + 7;
private static final int DLG_DELETED = DLG_OKONLY + 8;
private static final int DLG_INVITE = DLG_OKONLY + 9;
private static final int DLG_SCORES_BLK = DLG_OKONLY + 10;
private static final int PICK_TILE_REQUESTTRAY_BLK = DLG_OKONLY + 11;
private static final int DLG_USEDICT = DLG_OKONLY + 12;
private static final int DLG_GETDICT = DLG_OKONLY + 13;
private static final int GAME_OVER = DLG_OKONLY + 14;
private static final int DLG_CONNSTAT = DLG_OKONLY + 15;
private static final int ENABLE_NFC = DLG_OKONLY + 16;
private static final int CHAT_REQUEST = 1;
private static final int BT_INVITE_RESULT = 2;
private static final int SMS_INVITE_RESULT = 3;
@ -169,7 +150,7 @@ public class BoardActivity extends XWActivity
private Thread m_blockingThread;
private JNIThread m_jniThread;
private JNIThread.GameStateInfo m_gsi;
private int m_blockingDlgID = BLOCKING_DLG_NONE;
private DlgID m_blockingDlgID = DlgID.NONE;
private String m_room;
private String m_toastStr;
@ -275,14 +256,15 @@ public class BoardActivity extends XWActivity
}
@Override
protected Dialog onCreateDialog( final int id )
protected Dialog onCreateDialog( int id )
{
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
DialogInterface.OnClickListener lstnr;
AlertDialog.Builder ab;
switch ( id ) {
final DlgID dlgID = DlgID.values()[id];
switch ( dlgID ) {
case DLG_OKONLY:
case DLG_RETRY:
case GAME_OVER:
@ -291,7 +273,7 @@ public class BoardActivity extends XWActivity
.setTitle( m_dlgTitle )
.setMessage( m_dlgBytes )
.setPositiveButton( R.string.button_ok, null );
if ( DLG_RETRY == id ) {
if ( DlgID.DLG_RETRY == dlgID ) {
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
int whichButton ) {
@ -299,7 +281,7 @@ public class BoardActivity extends XWActivity
}
};
ab.setNegativeButton( R.string.button_retry, lstnr );
} else if ( XWApp.REMATCH_SUPPORTED && GAME_OVER == id ) {
} else if ( XWApp.REMATCH_SUPPORTED && DlgID.GAME_OVER == dlgID ) {
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
int whichButton ) {
@ -307,7 +289,7 @@ public class BoardActivity extends XWActivity
}
};
ab.setNegativeButton( R.string.button_rematch, lstnr );
} else if ( DLG_CONNSTAT == id &&
} else if ( DlgID.DLG_CONNSTAT == dlgID &&
CommsConnType.COMMS_CONN_RELAY == m_connType ) {
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
@ -318,7 +300,7 @@ public class BoardActivity extends XWActivity
ab.setNegativeButton( R.string.button_reconnect, lstnr );
}
dialog = ab.create();
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
break;
case DLG_USEDICT:
@ -326,7 +308,7 @@ public class BoardActivity extends XWActivity
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
int whichButton ) {
if ( DLG_USEDICT == id ) {
if ( DlgID.DLG_USEDICT == dlgID ) {
setGotGameDict( m_getDict );
} else {
DictImportActivity
@ -343,7 +325,7 @@ public class BoardActivity extends XWActivity
.setPositiveButton( R.string.button_yes, lstnr )
.setNegativeButton( R.string.button_no, null )
.create();
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
break;
case DLG_DELETED:
@ -380,10 +362,10 @@ public class BoardActivity extends XWActivity
m_resultCode = 1;
}
};
ab.setPositiveButton( QUERY_REQUEST_BLK == id ?
ab.setPositiveButton( DlgID.QUERY_REQUEST_BLK == dlgID ?
R.string.button_yes : R.string.button_ok,
lstnr );
if ( QUERY_REQUEST_BLK == id ) {
if ( DlgID.QUERY_REQUEST_BLK == dlgID ) {
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog,
int whichButton ) {
@ -391,7 +373,7 @@ public class BoardActivity extends XWActivity
}
};
ab.setNegativeButton( R.string.button_no, lstnr );
} else if ( DLG_SCORES_BLK == id ) {
} else if ( DlgID.DLG_SCORES_BLK == dlgID ) {
if ( null != m_words && m_words.length > 0 ) {
String buttonTxt;
boolean studyOn = XWPrefs.getStudyEnabled( this );
@ -434,7 +416,7 @@ public class BoardActivity extends XWActivity
};
ab.setItems( m_texts, lstnr );
if ( PICK_TILE_REQUESTBLANK_BLK == id ) {
if ( DlgID.PICK_TILE_REQUESTBLANK_BLK == dlgID ) {
ab.setTitle( R.string.title_tile_picker );
} else {
ab.setTitle( Utils.format( this, R.string.cur_tilesf,
@ -445,7 +427,7 @@ public class BoardActivity extends XWActivity
public void onClick( DialogInterface dialog,
int whichButton ) {
m_resultCode = UtilCtxt.PICKER_BACKUP;
removeDialog( id );
removeDialog( dlgID.ordinal() );
}
};
ab.setPositiveButton( R.string.tilepick_undo,
@ -456,7 +438,7 @@ public class BoardActivity extends XWActivity
public void onClick( DialogInterface dialog,
int whichButton ) {
m_resultCode = UtilCtxt.PICKER_PICKALL;
removeDialog( id );
removeDialog( dlgID.ordinal() );
}
};
ab.setNegativeButton( R.string.tilepick_all, doAllClicked );
@ -535,7 +517,8 @@ public class BoardActivity extends XWActivity
public void onPrepareDialog( int id, Dialog dialog )
{
DbgUtils.logf( "BoardActivity:onPrepareDialog(id=%d)", id );
switch( id ) {
DlgID dlgID = DlgID.values()[id];
switch( dlgID ) {
case DLG_INVITE:
AlertDialog ad = (AlertDialog)dialog;
String message = getString( R.string.invite_msgf, m_missing );
@ -602,7 +585,7 @@ public class BoardActivity extends XWActivity
{
super.onResume();
m_handler = new Handler();
m_blockingDlgID = BLOCKING_DLG_NONE;
m_blockingDlgID = DlgID.NONE;
setKeepScreenOn();
@ -890,7 +873,7 @@ public class BoardActivity extends XWActivity
showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION );
break;
case R.id.board_menu_invite:
showDialog( DLG_INVITE );
showDialog( DlgID.DLG_INVITE.ordinal() );
break;
// small devices only
case R.id.board_menu_dict:
@ -958,7 +941,7 @@ public class BoardActivity extends XWActivity
showNotAgainDlgThen( R.string.not_again_sms_ready,
R.string.key_notagain_sms_ready );
} else {
showDialog( ENABLE_NFC );
showDialog( DlgID.ENABLE_NFC.ordinal() );
}
} else {
String inviteID = GameUtils.formatGameID( m_gi.gameID );
@ -1079,7 +1062,7 @@ public class BoardActivity extends XWActivity
if ( gameID == m_gi.gameID ) {
post( new Runnable() {
public void run() {
showDialog( DLG_DELETED );
showDialog( DlgID.DLG_DELETED.ordinal() );
}
} );
}
@ -1146,21 +1129,21 @@ public class BoardActivity extends XWActivity
public void tpmRelayErrorProc( TransportProcs.XWRELAY_ERROR relayErr )
{
int strID = -1;
int dlgID = -1;
DlgID dlgID = DlgID.NONE;
boolean doToast = false;
switch ( relayErr ) {
case TOO_MANY:
strID = R.string.msg_too_many;
dlgID = DLG_OKONLY;
dlgID = DlgID.DLG_OKONLY;
break;
case NO_ROOM:
strID = R.string.msg_no_room;
dlgID = DLG_RETRY;
dlgID = DlgID.DLG_RETRY;
break;
case DUP_ROOM:
strID = R.string.msg_dup_room;
dlgID = DLG_OKONLY;
dlgID = DlgID.DLG_OKONLY;
break;
case LOST_OTHER:
case OTHER_DISCON:
@ -1171,7 +1154,7 @@ public class BoardActivity extends XWActivity
case DEADGAME:
case DELETED:
strID = R.string.msg_dev_deleted;
dlgID = DLG_DELETED;
dlgID = DlgID.DLG_DELETED;
break;
case OLDFLAGS:
@ -1186,9 +1169,9 @@ public class BoardActivity extends XWActivity
if ( doToast ) {
Utils.showToast( this, strID );
} else if ( dlgID >= 0 ) {
} else if ( dlgID != DlgID.NONE ) {
final int strIDf = strID;
final int dlgIDf = dlgID;
final int dlgIDf = dlgID.ordinal();
post( new Runnable() {
public void run() {
m_dlgBytes = getString( strIDf );
@ -1250,7 +1233,7 @@ public class BoardActivity extends XWActivity
public void run() {
m_dlgBytes = msg;
m_dlgTitle = R.string.info_title;
showDialog( DLG_CONNSTAT );
showDialog( DlgID.DLG_CONNSTAT.ordinal() );
}
} );
}
@ -1370,7 +1353,7 @@ public class BoardActivity extends XWActivity
m_haveInvited = true;
m_room = room;
m_missing = nMissing;
showDialog( DLG_INVITE );
showDialog( DlgID.DLG_INVITE.ordinal() );
ABUtils.invalidateOptionsMenuIf( this );
} else {
toastStr = getString( R.string.msg_relay_waiting, devOrder,
@ -1533,7 +1516,7 @@ public class BoardActivity extends XWActivity
public int userPickTileBlank( int playerNum, String[] texts)
{
m_texts = texts;
waitBlockingDialog( PICK_TILE_REQUESTBLANK_BLK, 0 );
waitBlockingDialog( DlgID.PICK_TILE_REQUESTBLANK_BLK, 0 );
return m_resultCode;
}
@ -1544,7 +1527,7 @@ public class BoardActivity extends XWActivity
m_texts = texts;
m_curTiles = TextUtils.join( ", ", curTiles );
m_canUndoTiles = 0 < nPicked;
waitBlockingDialog( PICK_TILE_REQUESTTRAY_BLK,
waitBlockingDialog( DlgID.PICK_TILE_REQUESTTRAY_BLK,
UtilCtxt.PICKER_PICKALL );
return m_resultCode;
}
@ -1557,7 +1540,7 @@ public class BoardActivity extends XWActivity
m_pwdName = name;
setupPasswdVars();
waitBlockingDialog( ASK_PASSWORD_BLK, 0 );
waitBlockingDialog( DlgID.ASK_PASSWORD_BLK, 0 );
String result = null; // means cancelled
if ( 0 != m_resultCode ) {
@ -1599,7 +1582,7 @@ public class BoardActivity extends XWActivity
case UtilCtxt.QUERY_ROBOT_TRADE:
m_dlgBytes = query;
m_dlgTitle = R.string.info_title;
waitBlockingDialog( QUERY_INFORM_BLK, 0 );
waitBlockingDialog( DlgID.QUERY_INFORM_BLK, 0 );
result = true;
break;
@ -1607,7 +1590,7 @@ public class BoardActivity extends XWActivity
case UtilCtxt.QUERY_COMMIT_TURN:
m_dlgBytes = query;
m_dlgTitle = R.string.query_title;
result = 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 );
result = 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
break;
default:
Assert.fail();
@ -1624,7 +1607,7 @@ public class BoardActivity extends XWActivity
m_dlgBytes =
Utils.format( BoardActivity.this, R.string.query_tradef,
TextUtils.join( ", ", tiles ) );
return 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 );
return 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
}
@Override
@ -1679,7 +1662,7 @@ public class BoardActivity extends XWActivity
}
if ( resid != 0 ) {
nonBlockingDialog( DLG_OKONLY, getString( resid ) );
nonBlockingDialog( DlgID.DLG_OKONLY, getString( resid ) );
}
} // userError
@ -1723,13 +1706,13 @@ public class BoardActivity extends XWActivity
m_dlgBytes = expl;
m_dlgTitle = R.string.info_title;
m_words = null == words? null : wordsToArray( words );
waitBlockingDialog( DLG_SCORES_BLK, 0 );
waitBlockingDialog( DlgID.DLG_SCORES_BLK, 0 );
}
@Override
public void informUndo()
{
nonBlockingDialog( DLG_OKONLY, getString( R.string.remote_undone ) );
nonBlockingDialog( DlgID.DLG_OKONLY, getString( R.string.remote_undone ) );
}
@Override
@ -1753,14 +1736,14 @@ public class BoardActivity extends XWActivity
} else {
// Different dict! If we have the other one, switch
// to it. Otherwise offer to download
int dlgID;
DlgID dlgID;
msg = getString( R.string.inform_dict_diffdictf,
oldName, newName, newName );
if ( DictLangCache.haveDict( BoardActivity.this, code,
newName ) ) {
dlgID = DLG_USEDICT;
dlgID = DlgID.DLG_USEDICT;
} else {
dlgID = DLG_GETDICT;
dlgID = DlgID.DLG_GETDICT;
msg += getString( R.string.inform_dict_download );
}
m_getDict = newName;
@ -1793,11 +1776,11 @@ public class BoardActivity extends XWActivity
if ( turnLost ) {
m_dlgBytes = message + getString( R.string.badwords_lost );
m_dlgTitle = R.string.badwords_title;
waitBlockingDialog( DLG_BADWORDS_BLK, 0 );
waitBlockingDialog( DlgID.DLG_BADWORDS_BLK, 0 );
} else {
m_dlgBytes = message + getString( R.string.badwords_accept );
m_dlgTitle = R.string.query_title;
accept = 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 );
accept = 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
}
return accept;
@ -1872,10 +1855,10 @@ public class BoardActivity extends XWActivity
case JNIThread.DIALOG:
m_dlgBytes = (String)msg.obj;
m_dlgTitle = msg.arg1;
showDialog( DLG_OKONLY );
showDialog( DlgID.DLG_OKONLY.ordinal() );
break;
case JNIThread.QUERY_ENDGAME:
showDialog( QUERY_ENDGAME );
showDialog( DlgID.QUERY_ENDGAME.ordinal() );
break;
case JNIThread.TOOLBAR_STATES:
if ( null != m_jniThread ) {
@ -1898,7 +1881,7 @@ public class BoardActivity extends XWActivity
case JNIThread.GAME_OVER:
m_dlgBytes = (String)msg.obj;
m_dlgTitle = msg.arg1;
showDialog( GAME_OVER );
showDialog( DlgID.GAME_OVER.ordinal() );
break;
}
}
@ -2025,11 +2008,11 @@ public class BoardActivity extends XWActivity
};
}
private int waitBlockingDialog( final int dlgID, int cancelResult )
private int waitBlockingDialog( final DlgID dlgID, int cancelResult )
{
int result = cancelResult;
// this has been true; dunno why
if ( BLOCKING_DLG_NONE != m_blockingDlgID ) {
if ( DlgID.NONE != m_blockingDlgID ) {
DbgUtils.logf( "waitBlockingDialog: dropping dlgID %d b/c %d set",
dlgID, m_blockingDlgID );
} else {
@ -2047,15 +2030,15 @@ public class BoardActivity extends XWActivity
m_forResultWait.acquire();
} catch ( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie );
if ( BLOCKING_DLG_NONE != m_blockingDlgID ) {
if ( DlgID.NONE != m_blockingDlgID ) {
try {
dismissDialog( m_blockingDlgID );
dismissDialog( m_blockingDlgID.ordinal() );
} catch ( java.lang.IllegalArgumentException iae ) {
DbgUtils.loge( iae );
}
}
}
m_blockingDlgID = BLOCKING_DLG_NONE;
m_blockingDlgID = DlgID.NONE;
}
clearBlockingThread();
@ -2064,7 +2047,7 @@ public class BoardActivity extends XWActivity
return result;
}
private void nonBlockingDialog( final int dlgID, String txt )
private void nonBlockingDialog( final DlgID dlgID, String txt )
{
switch ( dlgID ) {
case DLG_OKONLY:

View file

@ -81,10 +81,6 @@ public class DictsActivity extends XWExpandableListActivity
private static final int DELETE_DICT_ACTION = 1;
private static final int DOWNLOAD_DICT_ACTION = 2;
private static final int MOVE_DICT = DlgDelegate.DIALOG_LAST + 1;
private static final int SET_DEFAULT = DlgDelegate.DIALOG_LAST + 2;
private static final int DICT_OR_DECLINE = DlgDelegate.DIALOG_LAST + 3;
// I can't provide a subclass of MenuItem to hold DictAndLoc, so
// settle for a hash on the side.
private static HashMap<MenuItem, DictAndLoc> s_itemData;
@ -255,7 +251,8 @@ public class DictsActivity extends XWExpandableListActivity
String message;
boolean doRemove = true;
switch( id ) {
DlgID dlgID = DlgID.values()[id];
switch( dlgID ) {
case MOVE_DICT:
final XWListItem[] selItems = getSelItems();
final int[] moveTo = { -1 };
@ -360,7 +357,7 @@ public class DictsActivity extends XWExpandableListActivity
}
if ( doRemove && null != dialog ) {
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
}
return dialog;
@ -371,7 +368,7 @@ public class DictsActivity extends XWExpandableListActivity
{
super.onPrepareDialog( id, dialog );
if ( MOVE_DICT == id ) {
if ( DlgID.MOVE_DICT.ordinal() == id ) {
// The move button should always start out disabled
// because the selected location should be where it
// currently is.
@ -417,7 +414,7 @@ public class DictsActivity extends XWExpandableListActivity
Intent intent = getIntent();
if ( null != intent ) {
if ( MultiService.isMissingDictIntent( intent ) ) {
showDialog( DICT_OR_DECLINE );
showDialog( DlgID.DICT_OR_DECLINE.ordinal() );
} else {
boolean downloadNow = intent.getBooleanExtra( DICT_DOLAUNCH, false );
if ( downloadNow ) {
@ -509,7 +506,7 @@ public class DictsActivity extends XWExpandableListActivity
askMoveSelDicts();
break;
case R.id.dicts_select:
showDialog( SET_DEFAULT );
showDialog( DlgID.SET_DEFAULT.ordinal() );
break;
default:
handled = false;
@ -545,7 +542,7 @@ public class DictsActivity extends XWExpandableListActivity
// options for YY?
private void askMoveSelDicts()
{
showDialog( MOVE_DICT );
showDialog( DlgID.MOVE_DICT.ordinal() );
}
// OnItemLongClickListener interface

View file

@ -39,14 +39,6 @@ import junit.framework.Assert;
public class DlgDelegate {
public static final int DIALOG_ABOUT = 1;
public static final int DIALOG_OKONLY = 2;
public static final int DIALOG_NOTAGAIN = 3;
public static final int CONFIRM_THEN = 4;
public static final int INVITE_CHOICES_THEN = 5;
public static final int DLG_DICTGONE = 6;
public static final int DIALOG_LAST = DLG_DICTGONE;
public static final int SMS_BTN = AlertDialog.BUTTON_POSITIVE;
public static final int EMAIL_BTN = AlertDialog.BUTTON_NEGATIVE;
public static final int NFC_BTN = AlertDialog.BUTTON_NEUTRAL;
@ -70,7 +62,7 @@ public class DlgDelegate {
private ProgressDialog m_progress;
private Handler m_handler;
private HashMap<Integer, DlgState> m_dlgStates;
private HashMap<DlgID, DlgState> m_dlgStates;
public DlgDelegate( Activity activity, DlgClickNotify callback,
Bundle bundle )
@ -78,7 +70,7 @@ public class DlgDelegate {
m_activity = activity;
m_clickCallback = callback;
m_handler = new Handler();
m_dlgStates = new HashMap<Integer,DlgState>();
m_dlgStates = new HashMap<DlgID,DlgState>();
if ( null != bundle ) {
int[] ids = bundle.getIntArray( IDS );
@ -99,7 +91,7 @@ public class DlgDelegate {
DlgState state = iter.next();
String key = String.format( STATE_KEYF, state.m_id );
outState.putParcelable( key, state );
ids[indx++] = state.m_id;
ids[indx++] = state.m_id.ordinal();
}
}
outState.putIntArray( IDS, ids );
@ -109,22 +101,23 @@ public class DlgDelegate {
{
// DbgUtils.logf("onCreateDialog(id=%d)", id );
Dialog dialog = null;
DlgState state = findForID( id );
switch( id ) {
DlgID dlgID = DlgID.values()[id];
DlgState state = findForID( dlgID );
switch( dlgID ) {
case DIALOG_ABOUT:
dialog = createAboutDialog();
break;
case DIALOG_OKONLY:
dialog = createOKDialog( state, id );
dialog = createOKDialog( state, dlgID );
break;
case DIALOG_NOTAGAIN:
dialog = createNotAgainDialog( state, id );
dialog = createNotAgainDialog( state, dlgID );
break;
case CONFIRM_THEN:
dialog = createConfirmThenDialog( state, id );
dialog = createConfirmThenDialog( state, dlgID );
break;
case INVITE_CHOICES_THEN:
dialog = createInviteChoicesDialog( state, id );
dialog = createInviteChoicesDialog( state, dlgID );
break;
case DLG_DICTGONE:
dialog = createDictGoneDialog();
@ -141,9 +134,9 @@ public class DlgDelegate {
public void showOKOnlyDialog( String msg, int callbackID )
{
// Assert.assertNull( m_dlgStates );
DlgState state = new DlgState( DIALOG_OKONLY, msg, callbackID );
DlgState state = new DlgState( DlgID.DIALOG_OKONLY, msg, callbackID );
addState( state );
m_activity.showDialog( DIALOG_OKONLY );
m_activity.showDialog( DlgID.DIALOG_OKONLY.ordinal() );
}
public void showOKOnlyDialog( int msgID )
@ -153,12 +146,12 @@ public class DlgDelegate {
public void showDictGoneFinish()
{
m_activity.showDialog( DLG_DICTGONE );
m_activity.showDialog( DlgID.DLG_DICTGONE.ordinal() );
}
public void showAboutDialog()
{
m_activity.showDialog( DIALOG_ABOUT );
m_activity.showDialog( DlgID.DIALOG_ABOUT.ordinal() );
}
public void showNotAgainDlgThen( int msgID, int prefsKey,
@ -188,10 +181,10 @@ public class DlgDelegate {
}
} else {
DlgState state =
new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey,
new DlgState( DlgID.DIALOG_NOTAGAIN, msg, callbackID, prefsKey,
params );
addState( state );
m_activity.showDialog( DIALOG_NOTAGAIN );
m_activity.showDialog( DlgID.DIALOG_NOTAGAIN.ordinal() );
}
}
@ -224,19 +217,19 @@ public class DlgDelegate {
public void showConfirmThen( String msg, int posButton, int callbackID,
Object[] params )
{
DlgState state = new DlgState( CONFIRM_THEN, msg, posButton,
DlgState state = new DlgState( DlgID.CONFIRM_THEN, msg, posButton,
callbackID, 0, params );
addState( state );
m_activity.showDialog( CONFIRM_THEN );
m_activity.showDialog( DlgID.CONFIRM_THEN.ordinal() );
}
public void showInviteChoicesThen( final int callbackID )
{
if ( Utils.deviceSupportsSMS( m_activity )
|| NFCUtils.nfcAvail( m_activity )[0] ) {
DlgState state = new DlgState( INVITE_CHOICES_THEN, callbackID );
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN, callbackID );
addState( state );
m_activity.showDialog( INVITE_CHOICES_THEN );
m_activity.showDialog( DlgID.INVITE_CHOICES_THEN.ordinal() );
} else {
post( new Runnable() {
public void run() {
@ -358,19 +351,19 @@ public class DlgDelegate {
.create();
}
private Dialog createOKDialog( DlgState state, int id )
private Dialog createOKDialog( DlgState state, DlgID dlgID )
{
Dialog dialog = new AlertDialog.Builder( m_activity )
.setTitle( R.string.info_title )
.setMessage( state.m_msg )
.setPositiveButton( R.string.button_ok, null )
.create();
dialog = setCallbackDismissListener( dialog, state, id );
dialog = setCallbackDismissListener( dialog, state, dlgID );
return dialog;
}
private Dialog createNotAgainDialog( final DlgState state, int id )
private Dialog createNotAgainDialog( final DlgState state, DlgID dlgID )
{
OnClickListener lstnr_p = mkCallbackClickListener( state );
@ -395,10 +388,10 @@ public class DlgDelegate {
.setNegativeButton( R.string.button_notagain, lstnr_n )
.create();
return setCallbackDismissListener( dialog, state, id );
return setCallbackDismissListener( dialog, state, dlgID );
} // createNotAgainDialog
private Dialog createConfirmThenDialog( DlgState state, int id )
private Dialog createConfirmThenDialog( DlgState state, DlgID dlgID )
{
OnClickListener lstnr = mkCallbackClickListener( state );
@ -409,10 +402,10 @@ public class DlgDelegate {
.setNegativeButton( R.string.button_cancel, lstnr )
.create();
return setCallbackDismissListener( dialog, state, id );
return setCallbackDismissListener( dialog, state, dlgID );
}
private Dialog createInviteChoicesDialog( DlgState state, int id )
private Dialog createInviteChoicesDialog( DlgState state, DlgID dlgID )
{
OnClickListener lstnr = mkCallbackClickListener( state );
@ -439,7 +432,7 @@ public class DlgDelegate {
builder.setNeutralButton( R.string.button_nfc, lstnr );
}
return setCallbackDismissListener( builder.create(), state, id );
return setCallbackDismissListener( builder.create(), state, dlgID );
}
private Dialog createDictGoneDialog()
@ -476,8 +469,9 @@ public class DlgDelegate {
private Dialog setCallbackDismissListener( final Dialog dialog,
final DlgState state,
final int id )
DlgID dlgID )
{
final int id = dlgID.ordinal();
DialogInterface.OnDismissListener cbkOnDismissLstnr
= new DialogInterface.OnDismissListener() {
public void onDismiss( DialogInterface di ) {
@ -495,9 +489,9 @@ public class DlgDelegate {
return dialog;
}
private DlgState findForID( int id )
private DlgState findForID( DlgID dlgID )
{
DlgState state = m_dlgStates.get( id );
DlgState state = m_dlgStates.get( dlgID );
// DbgUtils.logf( "findForID(%d)=>%H", id, state );
return state;
}

View file

@ -0,0 +1,72 @@
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
/*
* Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.eehouse.android.xw4;
public enum DlgID {
NONE
, LOOKUP
,CHANGE_GROUP
,CONFIRM_CHANGE
,CONFIRM_CHANGE_PLAY
,CONFIRM_THEN
,DIALOG_ABOUT
,DIALOG_NOTAGAIN
,DIALOG_OKONLY
,DICT_OR_DECLINE
,DLG_CONNSTAT
,DLG_DELETED
,DLG_DICTGONE
,DLG_INVITE
,DLG_OKONLY
,ENABLE_NFC
,EXPLAIN_TITLE
,FORCE_REMOTE
,GAME_OVER
,GET_NAME
,GET_NUMBER
,INVITE_CHOICES_THEN
,MOVE_DICT
,NAME_GAME
,NEW_GROUP
,NO_NAME_FOUND
,PLAYER_EDIT
,CONFIRM_SMS
,QUERY_ENDGAME
,RENAME_GAME
,RENAME_GROUP
,REVERT_ALL
,REVERT_COLORS
,SET_DEFAULT
,SHOW_SUBST
,WARN_NODICT
,WARN_NODICT_NEW
,WARN_NODICT_SUBST
, BLOCKING_DLG_NONE
, DLG_BADWORDS_BLK
, QUERY_REQUEST_BLK
, QUERY_INFORM_BLK
, PICK_TILE_REQUESTBLANK_BLK
, ASK_PASSWORD_BLK
, DLG_RETRY
, DLG_SCORES_BLK
, PICK_TILE_REQUESTTRAY_BLK
, DLG_USEDICT
, DLG_GETDICT
}

View file

@ -24,40 +24,40 @@ import android.os.Parcelable;
import android.os.Parcel;
public class DlgState implements Parcelable {
public int m_id;
public DlgID m_id;
public String m_msg;
public int m_posButton;
public int m_cbckID = 0;
public int m_prefsKey;
public Object[] m_params;
public DlgState( int id, String msg, int cbckID )
public DlgState( DlgID dlgID, String msg, int cbckID )
{
this( id, msg, R.string.button_ok, cbckID, 0 );
this( dlgID, msg, R.string.button_ok, cbckID, 0 );
}
public DlgState( int id, String msg, int cbckID, int prefsKey )
public DlgState( DlgID dlgID, String msg, int cbckID, int prefsKey )
{
this( id, msg, R.string.button_ok, cbckID, prefsKey );
this( dlgID, msg, R.string.button_ok, cbckID, prefsKey );
}
public DlgState( int id, String msg, int cbckID, int prefsKey,
public DlgState( DlgID dlgID, String msg, int cbckID, int prefsKey,
Object[] params )
{
this( id, msg, R.string.button_ok, cbckID, prefsKey );
this( dlgID, msg, R.string.button_ok, cbckID, prefsKey );
m_params = params;
}
public DlgState( int id, String msg, int posButton,
public DlgState( DlgID dlgID, String msg, int posButton,
int cbckID, int prefsKey )
{
this( id, msg, posButton, cbckID, prefsKey, null );
this( dlgID, msg, posButton, cbckID, prefsKey, null );
}
public DlgState( int id, String msg, int posButton,
public DlgState( DlgID dlgID, String msg, int posButton,
int cbckID, int prefsKey, Object[] params )
{
m_id = id;
m_id = dlgID;
m_msg = msg;
m_posButton = posButton;
m_cbckID = cbckID;
@ -65,9 +65,9 @@ public class DlgState implements Parcelable {
m_params = params;
}
public DlgState( int id, int cbckID )
public DlgState( DlgID dlgID, int cbckID )
{
this( id, null, 0, cbckID, 0 );
this( dlgID, null, 0, cbckID, 0 );
}
public int describeContents() {
@ -75,7 +75,7 @@ public class DlgState implements Parcelable {
}
public void writeToParcel( Parcel out, int flags ) {
out.writeInt( m_id );
out.writeInt( m_id.ordinal() );
out.writeInt( m_posButton );
out.writeInt( m_cbckID );
out.writeInt( m_prefsKey );
@ -85,7 +85,7 @@ public class DlgState implements Parcelable {
public static final Parcelable.Creator<DlgState> CREATOR
= new Parcelable.Creator<DlgState>() {
public DlgState createFromParcel(Parcel in) {
int id = in.readInt();
DlgID id = DlgID.values()[in.readInt()];
int posButton = in.readInt();
int cbckID = in.readInt();
int prefsKey = in.readInt();

View file

@ -63,12 +63,6 @@ public class GameConfig extends XWActivity
,XWListItem.DeleteCallback
,RefreshNamesTask.NoNameFound {
private static final int PLAYER_EDIT = DlgDelegate.DIALOG_LAST + 1;
private static final int FORCE_REMOTE = PLAYER_EDIT + 1;
private static final int CONFIRM_CHANGE = PLAYER_EDIT + 2;
private static final int CONFIRM_CHANGE_PLAY = PLAYER_EDIT + 3;
private static final int NO_NAME_FOUND = PLAYER_EDIT + 4;
private static final String WHICH_PLAYER = "WHICH_PLAYER";
private static final int LOCKED_CHANGE_ACTION = 1;
@ -155,7 +149,7 @@ public class GameConfig extends XWActivity
}
@Override
protected Dialog onCreateDialog( final int id )
protected Dialog onCreateDialog( int id )
{
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
@ -163,7 +157,8 @@ public class GameConfig extends XWActivity
DialogInterface.OnClickListener dlpos;
AlertDialog.Builder ab;
switch (id) {
final DlgID dlgID = DlgID.values()[id];
switch (dlgID) {
case PLAYER_EDIT:
View playerEditView
= Utils.inflate( this, R.layout.player_edit );
@ -210,7 +205,7 @@ public class GameConfig extends XWActivity
};
dialog = new AlertDialog.Builder( this )
.setTitle( R.string.force_title )
.setView( Utils.inflate( this, layoutForDlg(id) ) )
.setView( Utils.inflate( this, layoutForDlg(dlgID) ) )
.setPositiveButton( R.string.button_ok, dlpos )
.create();
DialogInterface.OnDismissListener dismiss =
@ -233,7 +228,7 @@ public class GameConfig extends XWActivity
public void onClick( DialogInterface dlg,
int whichButton ) {
applyChanges( true );
if ( CONFIRM_CHANGE_PLAY == id ) {
if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) {
launchGame();
}
}
@ -242,7 +237,7 @@ public class GameConfig extends XWActivity
.setTitle( R.string.confirm_save_title )
.setMessage( R.string.confirm_save )
.setPositiveButton( R.string.button_save, dlpos );
if ( CONFIRM_CHANGE_PLAY == id ) {
if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) {
dlpos = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg,
int whichButton ) {
@ -280,7 +275,8 @@ public class GameConfig extends XWActivity
@Override
protected void onPrepareDialog( int id, Dialog dialog )
{
switch ( id ) {
DlgID dlgID = DlgID.values()[id];
switch ( dlgID ) {
case PLAYER_EDIT:
setPlayerSettings( dialog );
break;
@ -596,7 +592,7 @@ public class GameConfig extends XWActivity
// NoNameFound interface
public void NoNameFound()
{
showDialog( NO_NAME_FOUND );
showDialog( DlgID.NO_NAME_FOUND.ordinal() );
}
@Override
@ -649,7 +645,7 @@ public class GameConfig extends XWActivity
launchGame();
} else if ( m_giOrig.changesMatter(m_gi)
|| m_carOrig.changesMatter(m_car) ) {
showDialog( CONFIRM_CHANGE_PLAY );
showDialog( DlgID.CONFIRM_CHANGE_PLAY.ordinal() );
} else {
applyChanges( false );
launchGame();
@ -672,7 +668,7 @@ public class GameConfig extends XWActivity
applyChanges( true );
} else if ( m_giOrig.changesMatter(m_gi)
|| m_carOrig.changesMatter(m_car) ) {
showDialog( CONFIRM_CHANGE );
showDialog( DlgID.CONFIRM_CHANGE.ordinal() );
consumed = true; // don't dismiss activity yet!
} else {
applyChanges( false );
@ -695,7 +691,7 @@ public class GameConfig extends XWActivity
@Override
public void onClick( View view ) {
m_whichPlayer = ((XWListItem)view).getPosition();
showDialog( PLAYER_EDIT );
showDialog( DlgID.PLAYER_EDIT.ordinal() );
}
};
@ -738,7 +734,7 @@ public class GameConfig extends XWActivity
if ( ! localOnlyGame()
&& ((0 == m_gi.remoteCount() )
|| (m_gi.nPlayers == m_gi.remoteCount()) ) ) {
showDialog( FORCE_REMOTE );
showDialog( DlgID.FORCE_REMOTE.ordinal() );
}
adjustPlayersLabel();
} // loadPlayersList
@ -998,9 +994,9 @@ public class GameConfig extends XWActivity
}
}
private int layoutForDlg( int id )
private int layoutForDlg( DlgID dlgID )
{
switch( id ) {
switch( dlgID ) {
// case ROLE_EDIT_RELAY:
// return R.layout.role_edit_relay;
// case ROLE_EDIT_SMS:

View file

@ -62,16 +62,6 @@ public class GamesList extends XWExpandableListActivity
DBUtils.DBChangeListener, SelectableItem,
DictImportActivity.DownloadFinishedListener {
private static final int WARN_NODICT = DlgDelegate.DIALOG_LAST + 1;
private static final int WARN_NODICT_SUBST = WARN_NODICT + 1;
private static final int SHOW_SUBST = WARN_NODICT + 2;
private static final int GET_NAME = WARN_NODICT + 3;
private static final int RENAME_GAME = WARN_NODICT + 4;
private static final int NEW_GROUP = WARN_NODICT + 5;
private static final int RENAME_GROUP = WARN_NODICT + 6;
private static final int CHANGE_GROUP = WARN_NODICT + 7;
private static final int WARN_NODICT_NEW = WARN_NODICT + 8;
private static final String SAVE_ROWID = "SAVE_ROWID";
private static final String SAVE_ROWIDS = "SAVE_ROWIDS";
private static final String SAVE_GROUPID = "SAVE_GROUPID";
@ -147,7 +137,8 @@ public class GamesList extends XWExpandableListActivity
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
AlertDialog.Builder ab;
switch ( id ) {
DlgID dlgID = DlgID.values()[id];
switch ( dlgID ) {
case WARN_NODICT:
case WARN_NODICT_NEW:
case WARN_NODICT_SUBST:
@ -170,10 +161,10 @@ public class GamesList extends XWExpandableListActivity
String langName =
DictLangCache.getLangName( this, m_missingDictLang );
String gameName = GameUtils.getName( this, m_missingDictRowId );
if ( WARN_NODICT == id ) {
if ( DlgID.WARN_NODICT == dlgID ) {
message = getString( R.string.no_dictf,
gameName, langName );
} else if ( WARN_NODICT_NEW == id ) {
} else if ( DlgID.WARN_NODICT_NEW == dlgID ) {
message =
getString( R.string.invite_dict_missing_body_nonamef,
null, m_missingDictName, langName );
@ -189,16 +180,16 @@ public class GamesList extends XWExpandableListActivity
.setPositiveButton( R.string.button_cancel, null )
.setNegativeButton( R.string.button_download, lstnr )
;
if ( WARN_NODICT_SUBST == id ) {
if ( DlgID.WARN_NODICT_SUBST == dlgID ) {
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
showDialog( SHOW_SUBST );
showDialog( DlgID.SHOW_SUBST.ordinal() );
}
};
ab.setNeutralButton( R.string.button_substdict, lstnr );
}
dialog = ab.create();
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
break;
case SHOW_SUBST:
m_sameLangDicts =
@ -228,7 +219,7 @@ public class GamesList extends XWExpandableListActivity
// called next time and we can insert a different
// list. There seems to be no way to change the list
// inside onPrepareDialog().
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
break;
case RENAME_GAME:
@ -242,7 +233,7 @@ public class GamesList extends XWExpandableListActivity
dialog = buildNamerDlg( GameUtils.getName( this, m_rowid ),
R.string.rename_label,
R.string.game_rename_title,
lstnr, RENAME_GAME );
lstnr, DlgID.RENAME_GAME );
break;
case RENAME_GROUP:
@ -258,7 +249,7 @@ public class GamesList extends XWExpandableListActivity
dialog = buildNamerDlg( m_adapter.groupName( m_groupid ),
R.string.rename_group_label,
R.string.game_name_group_title,
lstnr, RENAME_GROUP );
lstnr, DlgID.RENAME_GROUP );
break;
case NEW_GROUP:
@ -272,8 +263,8 @@ public class GamesList extends XWExpandableListActivity
};
dialog = buildNamerDlg( "", R.string.newgroup_label,
R.string.game_name_group_title,
lstnr, RENAME_GROUP );
Utils.setRemoveOnDismiss( this, dialog, id );
lstnr, DlgID.RENAME_GROUP );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
break;
case CHANGE_GROUP:
@ -314,7 +305,7 @@ public class GamesList extends XWExpandableListActivity
.setPositiveButton( R.string.button_move, lstnr2 )
.setNegativeButton( R.string.button_cancel, null )
.create();
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
break;
case GET_NAME:
@ -357,7 +348,7 @@ public class GamesList extends XWExpandableListActivity
{
super.onPrepareDialog( id, dialog );
if ( CHANGE_GROUP == id ) {
if ( DlgID.CHANGE_GROUP.ordinal() == id ) {
((AlertDialog)dialog).getButton( AlertDialog.BUTTON_POSITIVE )
.setEnabled( false );
}
@ -762,7 +753,7 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.games_menu_newgroup:
showDialog( NEW_GROUP );
showDialog( DlgID.NEW_GROUP.ordinal() );
break;
case R.id.games_game_config:
@ -832,7 +823,7 @@ public class GamesList extends XWExpandableListActivity
showOKOnlyDialog( R.string.no_move_onegroup );
} else {
m_rowids = selRowIDs;
showDialog( CHANGE_GROUP );
showDialog( DlgID.CHANGE_GROUP.ordinal() );
}
break;
case R.id.games_game_new_from:
@ -873,7 +864,7 @@ public class GamesList extends XWExpandableListActivity
case R.id.games_game_rename:
m_rowid = selRowIDs[0];
showDialog( RENAME_GAME );
showDialog( DlgID.RENAME_GAME.ordinal() );
break;
// Group menus
@ -906,7 +897,7 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.games_group_rename:
m_groupid = groupID;
showDialog( RENAME_GROUP );
showDialog( DlgID.RENAME_GROUP.ordinal() );
break;
case R.id.games_group_moveup:
changeContent = m_adapter.moveGroup( groupID, -1 );
@ -988,7 +979,7 @@ public class GamesList extends XWExpandableListActivity
m_netLaunchInfo = nli;
m_missingDictLang = nli.lang;
m_missingDictName = nli.dict;
showDialog( WARN_NODICT_NEW );
showDialog( DlgID.WARN_NODICT_NEW.ordinal() );
}
return haveDict;
}
@ -1008,9 +999,9 @@ public class GamesList extends XWExpandableListActivity
}
m_missingDictRowId = rowid;
if ( 0 == DictLangCache.getLangCount( this, m_missingDictLang ) ) {
showDialog( WARN_NODICT );
showDialog( DlgID.WARN_NODICT.ordinal() );
} else if ( null != m_missingDictName ) {
showDialog( WARN_NODICT_SUBST );
showDialog( DlgID.WARN_NODICT_SUBST.ordinal() );
} else {
String dict =
DictLangCache.getHaveLang( this, m_missingDictLang)[0];
@ -1176,7 +1167,7 @@ public class GamesList extends XWExpandableListActivity
if ( null == CommonPrefs.getDefaultPlayerName( this, 0, false ) ) {
String name = CommonPrefs.getDefaultPlayerName( this, 0, true );
CommonPrefs.setDefaultPlayerName( GamesList.this, name );
showDialog( GET_NAME );
showDialog( DlgID.GET_NAME.ordinal() );
}
}
@ -1192,7 +1183,7 @@ public class GamesList extends XWExpandableListActivity
private Dialog buildNamerDlg( String curname, int labelID, int titleID,
DialogInterface.OnClickListener lstnr,
int dlgID )
DlgID dlgID )
{
m_namer = (GameNamer)Utils.inflate( this, R.layout.rename_game );
m_namer.setName( curname );

View file

@ -57,10 +57,6 @@ public class NewGameActivity extends XWActivity {
private static final int INVITE_FOR_BT = 3;
private static final int INVITE_FOR_SMS = 4;
// Dialogs
private static final int NAME_GAME = DlgDelegate.DIALOG_LAST + 1;
private static final int ENABLE_NFC = DlgDelegate.DIALOG_LAST + 2;
private boolean m_showsOn;
private boolean m_nameForBT;
private boolean m_firingPrefs = false;
@ -202,7 +198,7 @@ public class NewGameActivity extends XWActivity {
m_gameID = GameUtils.newGameID();
m_gameName = Utils.format( this, R.string.dft_namef,
m_gameID & 0xFFFF );
showDialog( NAME_GAME );
showDialog( DlgID.NAME_GAME.ordinal() );
}
break;
}
@ -214,7 +210,8 @@ public class NewGameActivity extends XWActivity {
{
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
switch( id ) {
DlgID dlgID = DlgID.values()[id];
switch( dlgID ) {
case NAME_GAME:
final GameNamer namerView =
(GameNamer)Utils.inflate( this, R.layout.rename_game );
@ -253,7 +250,7 @@ public class NewGameActivity extends XWActivity {
.setPositiveButton( R.string.button_ok, lstnr )
.setView( namerView )
.create();
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
break;
case ENABLE_NFC:
@ -324,7 +321,7 @@ public class NewGameActivity extends XWActivity {
{
boolean viaNFC = DlgDelegate.NFC_BTN == chosen;
if ( viaNFC && !NFCUtils.nfcAvail( this )[1] ) {
showDialog( ENABLE_NFC );
showDialog( DlgID.ENABLE_NFC.ordinal() );
} else {
String room = null;
String inviteID = null;

View file

@ -36,11 +36,6 @@ import java.io.File;
public class PrefsActivity extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final int REVERT_COLORS = 1;
private static final int REVERT_ALL = 2;
public static final int CONFIRM_SMS = 3;
public static final int EXPLAIN_TITLE = 4;
private String m_keyLogging;
private String m_smsToasting;
private String m_smsEnable;
@ -56,7 +51,8 @@ public class PrefsActivity extends PreferenceActivity
DialogInterface.OnClickListener lstnr = null;
int confirmID = 0;
switch( id ) {
DlgID dlgID = DlgID.values()[id];
switch( dlgID ) {
case REVERT_COLORS:
confirmID = R.string.confirm_revert_colors;
lstnr = new DialogInterface.OnClickListener() {
@ -142,13 +138,13 @@ public class PrefsActivity extends PreferenceActivity
Button button = (Button)findViewById( R.id.revert_colors );
button.setOnClickListener( new View.OnClickListener() {
public void onClick( View v ) {
showDialog( REVERT_COLORS );
showDialog( DlgID.REVERT_COLORS.ordinal() );
}
} );
button = (Button)findViewById( R.id.revert_all );
button.setOnClickListener(new View.OnClickListener() {
public void onClick( View v ) {
showDialog( REVERT_ALL );
showDialog( DlgID.REVERT_ALL.ordinal() );
}
} );
}
@ -208,7 +204,7 @@ public class PrefsActivity extends PreferenceActivity
= (CheckBoxPreference)findPreference(key);
pref.setChecked( false );
pref.setEnabled( false );
showDialog( EXPLAIN_TITLE );
showDialog( DlgID.EXPLAIN_TITLE.ordinal() );
}
}
}

View file

@ -58,7 +58,7 @@ public class SMSCheckBoxPreference extends CheckBoxPreference {
{
if ( checked && m_attached && m_context instanceof PrefsActivity ) {
PrefsActivity activity = (PrefsActivity)m_context;
activity.showDialog( PrefsActivity.CONFIRM_SMS );
activity.showDialog( DlgID.CONFIRM_SMS.ordinal() );
} else {
super_setChecked( checked );
}
@ -99,4 +99,4 @@ public class SMSCheckBoxPreference extends CheckBoxPreference {
return dialog;
}
}
}

View file

@ -43,7 +43,6 @@ import java.util.Iterator;
public class SMSInviteActivity extends InviteActivity {
private static final int GET_CONTACT = 1;
private static final int GET_NUMBER = DlgDelegate.DIALOG_LAST + 1;
private static final String SAVE_NAME = "SAVE_NAME";
private static final String SAVE_NUMBER = "SAVE_NUMBER";
@ -79,7 +78,7 @@ public class SMSInviteActivity extends InviteActivity {
m_addButton.setOnClickListener( new View.OnClickListener() {
public void onClick( View view )
{
showDialog( GET_NUMBER );
showDialog( DlgID.GET_NUMBER.ordinal() );
}
} );
@ -123,7 +122,8 @@ public class SMSInviteActivity extends InviteActivity {
Dialog dialog = super.onCreateDialog( id );
if ( null == dialog ) {
DialogInterface.OnClickListener lstnr;
switch( id ) {
DlgID dlgID = DlgID.values()[id];
switch( dlgID ) {
case GET_NUMBER:
final GameNamer namerView =
(GameNamer)Utils.inflate( this, R.layout.rename_game );
@ -147,7 +147,7 @@ public class SMSInviteActivity extends InviteActivity {
.create();
break;
}
Utils.setRemoveOnDismiss( this, dialog, id );
Utils.setRemoveOnDismiss( this, dialog, dlgID );
}
return dialog;
}

View file

@ -132,8 +132,9 @@ public class Utils {
}
public static void setRemoveOnDismiss( final Activity activity,
Dialog dialog, final int id )
Dialog dialog, DlgID dlgID )
{
final int id = dlgID.ordinal();
dialog.setOnDismissListener( new DialogInterface.OnDismissListener() {
public void onDismiss( DialogInterface di ) {
activity.removeDialog( id );

View file

@ -100,6 +100,11 @@ public class XWActivity extends Activity
return dialog;
}
public void showDialog( DlgID dlgID )
{
super.showDialog( dlgID.ordinal() );
}
// these are duplicated in XWListActivity -- sometimes multiple
// inheritance would be nice to have...
protected void showAboutDialog()