mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-20 22:26:54 +01:00
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:
parent
ad0f882335
commit
94d9a03d51
13 changed files with 241 additions and 209 deletions
|
@ -71,25 +71,6 @@ public class BoardActivity extends XWActivity
|
||||||
|
|
||||||
public static final String INTENT_KEY_CHAT = "chat";
|
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 CHAT_REQUEST = 1;
|
||||||
private static final int BT_INVITE_RESULT = 2;
|
private static final int BT_INVITE_RESULT = 2;
|
||||||
private static final int SMS_INVITE_RESULT = 3;
|
private static final int SMS_INVITE_RESULT = 3;
|
||||||
|
@ -169,7 +150,7 @@ public class BoardActivity extends XWActivity
|
||||||
private Thread m_blockingThread;
|
private Thread m_blockingThread;
|
||||||
private JNIThread m_jniThread;
|
private JNIThread m_jniThread;
|
||||||
private JNIThread.GameStateInfo m_gsi;
|
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_room;
|
||||||
private String m_toastStr;
|
private String m_toastStr;
|
||||||
|
@ -275,14 +256,15 @@ public class BoardActivity extends XWActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog( final int id )
|
protected Dialog onCreateDialog( int id )
|
||||||
{
|
{
|
||||||
Dialog dialog = super.onCreateDialog( id );
|
Dialog dialog = super.onCreateDialog( id );
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
DialogInterface.OnClickListener lstnr;
|
DialogInterface.OnClickListener lstnr;
|
||||||
AlertDialog.Builder ab;
|
AlertDialog.Builder ab;
|
||||||
|
|
||||||
switch ( id ) {
|
final DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch ( dlgID ) {
|
||||||
case DLG_OKONLY:
|
case DLG_OKONLY:
|
||||||
case DLG_RETRY:
|
case DLG_RETRY:
|
||||||
case GAME_OVER:
|
case GAME_OVER:
|
||||||
|
@ -291,7 +273,7 @@ public class BoardActivity extends XWActivity
|
||||||
.setTitle( m_dlgTitle )
|
.setTitle( m_dlgTitle )
|
||||||
.setMessage( m_dlgBytes )
|
.setMessage( m_dlgBytes )
|
||||||
.setPositiveButton( R.string.button_ok, null );
|
.setPositiveButton( R.string.button_ok, null );
|
||||||
if ( DLG_RETRY == id ) {
|
if ( DlgID.DLG_RETRY == dlgID ) {
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
|
@ -299,7 +281,7 @@ public class BoardActivity extends XWActivity
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setNegativeButton( R.string.button_retry, lstnr );
|
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() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
|
@ -307,7 +289,7 @@ public class BoardActivity extends XWActivity
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setNegativeButton( R.string.button_rematch, lstnr );
|
ab.setNegativeButton( R.string.button_rematch, lstnr );
|
||||||
} else if ( DLG_CONNSTAT == id &&
|
} else if ( DlgID.DLG_CONNSTAT == dlgID &&
|
||||||
CommsConnType.COMMS_CONN_RELAY == m_connType ) {
|
CommsConnType.COMMS_CONN_RELAY == m_connType ) {
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
|
@ -318,7 +300,7 @@ public class BoardActivity extends XWActivity
|
||||||
ab.setNegativeButton( R.string.button_reconnect, lstnr );
|
ab.setNegativeButton( R.string.button_reconnect, lstnr );
|
||||||
}
|
}
|
||||||
dialog = ab.create();
|
dialog = ab.create();
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLG_USEDICT:
|
case DLG_USEDICT:
|
||||||
|
@ -326,7 +308,7 @@ public class BoardActivity extends XWActivity
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
if ( DLG_USEDICT == id ) {
|
if ( DlgID.DLG_USEDICT == dlgID ) {
|
||||||
setGotGameDict( m_getDict );
|
setGotGameDict( m_getDict );
|
||||||
} else {
|
} else {
|
||||||
DictImportActivity
|
DictImportActivity
|
||||||
|
@ -343,7 +325,7 @@ public class BoardActivity extends XWActivity
|
||||||
.setPositiveButton( R.string.button_yes, lstnr )
|
.setPositiveButton( R.string.button_yes, lstnr )
|
||||||
.setNegativeButton( R.string.button_no, null )
|
.setNegativeButton( R.string.button_no, null )
|
||||||
.create();
|
.create();
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLG_DELETED:
|
case DLG_DELETED:
|
||||||
|
@ -380,10 +362,10 @@ public class BoardActivity extends XWActivity
|
||||||
m_resultCode = 1;
|
m_resultCode = 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setPositiveButton( QUERY_REQUEST_BLK == id ?
|
ab.setPositiveButton( DlgID.QUERY_REQUEST_BLK == dlgID ?
|
||||||
R.string.button_yes : R.string.button_ok,
|
R.string.button_yes : R.string.button_ok,
|
||||||
lstnr );
|
lstnr );
|
||||||
if ( QUERY_REQUEST_BLK == id ) {
|
if ( DlgID.QUERY_REQUEST_BLK == dlgID ) {
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dialog,
|
public void onClick( DialogInterface dialog,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
|
@ -391,7 +373,7 @@ public class BoardActivity extends XWActivity
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setNegativeButton( R.string.button_no, lstnr );
|
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 ) {
|
if ( null != m_words && m_words.length > 0 ) {
|
||||||
String buttonTxt;
|
String buttonTxt;
|
||||||
boolean studyOn = XWPrefs.getStudyEnabled( this );
|
boolean studyOn = XWPrefs.getStudyEnabled( this );
|
||||||
|
@ -434,7 +416,7 @@ public class BoardActivity extends XWActivity
|
||||||
};
|
};
|
||||||
ab.setItems( m_texts, lstnr );
|
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 );
|
ab.setTitle( R.string.title_tile_picker );
|
||||||
} else {
|
} else {
|
||||||
ab.setTitle( Utils.format( this, R.string.cur_tilesf,
|
ab.setTitle( Utils.format( this, R.string.cur_tilesf,
|
||||||
|
@ -445,7 +427,7 @@ public class BoardActivity extends XWActivity
|
||||||
public void onClick( DialogInterface dialog,
|
public void onClick( DialogInterface dialog,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
m_resultCode = UtilCtxt.PICKER_BACKUP;
|
m_resultCode = UtilCtxt.PICKER_BACKUP;
|
||||||
removeDialog( id );
|
removeDialog( dlgID.ordinal() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setPositiveButton( R.string.tilepick_undo,
|
ab.setPositiveButton( R.string.tilepick_undo,
|
||||||
|
@ -456,7 +438,7 @@ public class BoardActivity extends XWActivity
|
||||||
public void onClick( DialogInterface dialog,
|
public void onClick( DialogInterface dialog,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
m_resultCode = UtilCtxt.PICKER_PICKALL;
|
m_resultCode = UtilCtxt.PICKER_PICKALL;
|
||||||
removeDialog( id );
|
removeDialog( dlgID.ordinal() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setNegativeButton( R.string.tilepick_all, doAllClicked );
|
ab.setNegativeButton( R.string.tilepick_all, doAllClicked );
|
||||||
|
@ -535,7 +517,8 @@ public class BoardActivity extends XWActivity
|
||||||
public void onPrepareDialog( int id, Dialog dialog )
|
public void onPrepareDialog( int id, Dialog dialog )
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "BoardActivity:onPrepareDialog(id=%d)", id );
|
DbgUtils.logf( "BoardActivity:onPrepareDialog(id=%d)", id );
|
||||||
switch( id ) {
|
DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch( dlgID ) {
|
||||||
case DLG_INVITE:
|
case DLG_INVITE:
|
||||||
AlertDialog ad = (AlertDialog)dialog;
|
AlertDialog ad = (AlertDialog)dialog;
|
||||||
String message = getString( R.string.invite_msgf, m_missing );
|
String message = getString( R.string.invite_msgf, m_missing );
|
||||||
|
@ -602,7 +585,7 @@ public class BoardActivity extends XWActivity
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
m_handler = new Handler();
|
m_handler = new Handler();
|
||||||
m_blockingDlgID = BLOCKING_DLG_NONE;
|
m_blockingDlgID = DlgID.NONE;
|
||||||
|
|
||||||
setKeepScreenOn();
|
setKeepScreenOn();
|
||||||
|
|
||||||
|
@ -890,7 +873,7 @@ public class BoardActivity extends XWActivity
|
||||||
showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION );
|
showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION );
|
||||||
break;
|
break;
|
||||||
case R.id.board_menu_invite:
|
case R.id.board_menu_invite:
|
||||||
showDialog( DLG_INVITE );
|
showDialog( DlgID.DLG_INVITE.ordinal() );
|
||||||
break;
|
break;
|
||||||
// small devices only
|
// small devices only
|
||||||
case R.id.board_menu_dict:
|
case R.id.board_menu_dict:
|
||||||
|
@ -958,7 +941,7 @@ public class BoardActivity extends XWActivity
|
||||||
showNotAgainDlgThen( R.string.not_again_sms_ready,
|
showNotAgainDlgThen( R.string.not_again_sms_ready,
|
||||||
R.string.key_notagain_sms_ready );
|
R.string.key_notagain_sms_ready );
|
||||||
} else {
|
} else {
|
||||||
showDialog( ENABLE_NFC );
|
showDialog( DlgID.ENABLE_NFC.ordinal() );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String inviteID = GameUtils.formatGameID( m_gi.gameID );
|
String inviteID = GameUtils.formatGameID( m_gi.gameID );
|
||||||
|
@ -1079,7 +1062,7 @@ public class BoardActivity extends XWActivity
|
||||||
if ( gameID == m_gi.gameID ) {
|
if ( gameID == m_gi.gameID ) {
|
||||||
post( new Runnable() {
|
post( new Runnable() {
|
||||||
public void run() {
|
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 )
|
public void tpmRelayErrorProc( TransportProcs.XWRELAY_ERROR relayErr )
|
||||||
{
|
{
|
||||||
int strID = -1;
|
int strID = -1;
|
||||||
int dlgID = -1;
|
DlgID dlgID = DlgID.NONE;
|
||||||
boolean doToast = false;
|
boolean doToast = false;
|
||||||
|
|
||||||
switch ( relayErr ) {
|
switch ( relayErr ) {
|
||||||
case TOO_MANY:
|
case TOO_MANY:
|
||||||
strID = R.string.msg_too_many;
|
strID = R.string.msg_too_many;
|
||||||
dlgID = DLG_OKONLY;
|
dlgID = DlgID.DLG_OKONLY;
|
||||||
break;
|
break;
|
||||||
case NO_ROOM:
|
case NO_ROOM:
|
||||||
strID = R.string.msg_no_room;
|
strID = R.string.msg_no_room;
|
||||||
dlgID = DLG_RETRY;
|
dlgID = DlgID.DLG_RETRY;
|
||||||
break;
|
break;
|
||||||
case DUP_ROOM:
|
case DUP_ROOM:
|
||||||
strID = R.string.msg_dup_room;
|
strID = R.string.msg_dup_room;
|
||||||
dlgID = DLG_OKONLY;
|
dlgID = DlgID.DLG_OKONLY;
|
||||||
break;
|
break;
|
||||||
case LOST_OTHER:
|
case LOST_OTHER:
|
||||||
case OTHER_DISCON:
|
case OTHER_DISCON:
|
||||||
|
@ -1171,7 +1154,7 @@ public class BoardActivity extends XWActivity
|
||||||
case DEADGAME:
|
case DEADGAME:
|
||||||
case DELETED:
|
case DELETED:
|
||||||
strID = R.string.msg_dev_deleted;
|
strID = R.string.msg_dev_deleted;
|
||||||
dlgID = DLG_DELETED;
|
dlgID = DlgID.DLG_DELETED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OLDFLAGS:
|
case OLDFLAGS:
|
||||||
|
@ -1186,9 +1169,9 @@ public class BoardActivity extends XWActivity
|
||||||
|
|
||||||
if ( doToast ) {
|
if ( doToast ) {
|
||||||
Utils.showToast( this, strID );
|
Utils.showToast( this, strID );
|
||||||
} else if ( dlgID >= 0 ) {
|
} else if ( dlgID != DlgID.NONE ) {
|
||||||
final int strIDf = strID;
|
final int strIDf = strID;
|
||||||
final int dlgIDf = dlgID;
|
final int dlgIDf = dlgID.ordinal();
|
||||||
post( new Runnable() {
|
post( new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
m_dlgBytes = getString( strIDf );
|
m_dlgBytes = getString( strIDf );
|
||||||
|
@ -1250,7 +1233,7 @@ public class BoardActivity extends XWActivity
|
||||||
public void run() {
|
public void run() {
|
||||||
m_dlgBytes = msg;
|
m_dlgBytes = msg;
|
||||||
m_dlgTitle = R.string.info_title;
|
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_haveInvited = true;
|
||||||
m_room = room;
|
m_room = room;
|
||||||
m_missing = nMissing;
|
m_missing = nMissing;
|
||||||
showDialog( DLG_INVITE );
|
showDialog( DlgID.DLG_INVITE.ordinal() );
|
||||||
ABUtils.invalidateOptionsMenuIf( this );
|
ABUtils.invalidateOptionsMenuIf( this );
|
||||||
} else {
|
} else {
|
||||||
toastStr = getString( R.string.msg_relay_waiting, devOrder,
|
toastStr = getString( R.string.msg_relay_waiting, devOrder,
|
||||||
|
@ -1533,7 +1516,7 @@ public class BoardActivity extends XWActivity
|
||||||
public int userPickTileBlank( int playerNum, String[] texts)
|
public int userPickTileBlank( int playerNum, String[] texts)
|
||||||
{
|
{
|
||||||
m_texts = texts;
|
m_texts = texts;
|
||||||
waitBlockingDialog( PICK_TILE_REQUESTBLANK_BLK, 0 );
|
waitBlockingDialog( DlgID.PICK_TILE_REQUESTBLANK_BLK, 0 );
|
||||||
return m_resultCode;
|
return m_resultCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1544,7 +1527,7 @@ public class BoardActivity extends XWActivity
|
||||||
m_texts = texts;
|
m_texts = texts;
|
||||||
m_curTiles = TextUtils.join( ", ", curTiles );
|
m_curTiles = TextUtils.join( ", ", curTiles );
|
||||||
m_canUndoTiles = 0 < nPicked;
|
m_canUndoTiles = 0 < nPicked;
|
||||||
waitBlockingDialog( PICK_TILE_REQUESTTRAY_BLK,
|
waitBlockingDialog( DlgID.PICK_TILE_REQUESTTRAY_BLK,
|
||||||
UtilCtxt.PICKER_PICKALL );
|
UtilCtxt.PICKER_PICKALL );
|
||||||
return m_resultCode;
|
return m_resultCode;
|
||||||
}
|
}
|
||||||
|
@ -1557,7 +1540,7 @@ public class BoardActivity extends XWActivity
|
||||||
m_pwdName = name;
|
m_pwdName = name;
|
||||||
setupPasswdVars();
|
setupPasswdVars();
|
||||||
|
|
||||||
waitBlockingDialog( ASK_PASSWORD_BLK, 0 );
|
waitBlockingDialog( DlgID.ASK_PASSWORD_BLK, 0 );
|
||||||
|
|
||||||
String result = null; // means cancelled
|
String result = null; // means cancelled
|
||||||
if ( 0 != m_resultCode ) {
|
if ( 0 != m_resultCode ) {
|
||||||
|
@ -1599,7 +1582,7 @@ public class BoardActivity extends XWActivity
|
||||||
case UtilCtxt.QUERY_ROBOT_TRADE:
|
case UtilCtxt.QUERY_ROBOT_TRADE:
|
||||||
m_dlgBytes = query;
|
m_dlgBytes = query;
|
||||||
m_dlgTitle = R.string.info_title;
|
m_dlgTitle = R.string.info_title;
|
||||||
waitBlockingDialog( QUERY_INFORM_BLK, 0 );
|
waitBlockingDialog( DlgID.QUERY_INFORM_BLK, 0 );
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1607,7 +1590,7 @@ public class BoardActivity extends XWActivity
|
||||||
case UtilCtxt.QUERY_COMMIT_TURN:
|
case UtilCtxt.QUERY_COMMIT_TURN:
|
||||||
m_dlgBytes = query;
|
m_dlgBytes = query;
|
||||||
m_dlgTitle = R.string.query_title;
|
m_dlgTitle = R.string.query_title;
|
||||||
result = 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 );
|
result = 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
|
@ -1624,7 +1607,7 @@ public class BoardActivity extends XWActivity
|
||||||
m_dlgBytes =
|
m_dlgBytes =
|
||||||
Utils.format( BoardActivity.this, R.string.query_tradef,
|
Utils.format( BoardActivity.this, R.string.query_tradef,
|
||||||
TextUtils.join( ", ", tiles ) );
|
TextUtils.join( ", ", tiles ) );
|
||||||
return 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 );
|
return 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1679,7 +1662,7 @@ public class BoardActivity extends XWActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( resid != 0 ) {
|
if ( resid != 0 ) {
|
||||||
nonBlockingDialog( DLG_OKONLY, getString( resid ) );
|
nonBlockingDialog( DlgID.DLG_OKONLY, getString( resid ) );
|
||||||
}
|
}
|
||||||
} // userError
|
} // userError
|
||||||
|
|
||||||
|
@ -1723,13 +1706,13 @@ public class BoardActivity extends XWActivity
|
||||||
m_dlgBytes = expl;
|
m_dlgBytes = expl;
|
||||||
m_dlgTitle = R.string.info_title;
|
m_dlgTitle = R.string.info_title;
|
||||||
m_words = null == words? null : wordsToArray( words );
|
m_words = null == words? null : wordsToArray( words );
|
||||||
waitBlockingDialog( DLG_SCORES_BLK, 0 );
|
waitBlockingDialog( DlgID.DLG_SCORES_BLK, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void informUndo()
|
public void informUndo()
|
||||||
{
|
{
|
||||||
nonBlockingDialog( DLG_OKONLY, getString( R.string.remote_undone ) );
|
nonBlockingDialog( DlgID.DLG_OKONLY, getString( R.string.remote_undone ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1753,14 +1736,14 @@ public class BoardActivity extends XWActivity
|
||||||
} else {
|
} else {
|
||||||
// Different dict! If we have the other one, switch
|
// Different dict! If we have the other one, switch
|
||||||
// to it. Otherwise offer to download
|
// to it. Otherwise offer to download
|
||||||
int dlgID;
|
DlgID dlgID;
|
||||||
msg = getString( R.string.inform_dict_diffdictf,
|
msg = getString( R.string.inform_dict_diffdictf,
|
||||||
oldName, newName, newName );
|
oldName, newName, newName );
|
||||||
if ( DictLangCache.haveDict( BoardActivity.this, code,
|
if ( DictLangCache.haveDict( BoardActivity.this, code,
|
||||||
newName ) ) {
|
newName ) ) {
|
||||||
dlgID = DLG_USEDICT;
|
dlgID = DlgID.DLG_USEDICT;
|
||||||
} else {
|
} else {
|
||||||
dlgID = DLG_GETDICT;
|
dlgID = DlgID.DLG_GETDICT;
|
||||||
msg += getString( R.string.inform_dict_download );
|
msg += getString( R.string.inform_dict_download );
|
||||||
}
|
}
|
||||||
m_getDict = newName;
|
m_getDict = newName;
|
||||||
|
@ -1793,11 +1776,11 @@ public class BoardActivity extends XWActivity
|
||||||
if ( turnLost ) {
|
if ( turnLost ) {
|
||||||
m_dlgBytes = message + getString( R.string.badwords_lost );
|
m_dlgBytes = message + getString( R.string.badwords_lost );
|
||||||
m_dlgTitle = R.string.badwords_title;
|
m_dlgTitle = R.string.badwords_title;
|
||||||
waitBlockingDialog( DLG_BADWORDS_BLK, 0 );
|
waitBlockingDialog( DlgID.DLG_BADWORDS_BLK, 0 );
|
||||||
} else {
|
} else {
|
||||||
m_dlgBytes = message + getString( R.string.badwords_accept );
|
m_dlgBytes = message + getString( R.string.badwords_accept );
|
||||||
m_dlgTitle = R.string.query_title;
|
m_dlgTitle = R.string.query_title;
|
||||||
accept = 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 );
|
accept = 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return accept;
|
return accept;
|
||||||
|
@ -1872,10 +1855,10 @@ public class BoardActivity extends XWActivity
|
||||||
case JNIThread.DIALOG:
|
case JNIThread.DIALOG:
|
||||||
m_dlgBytes = (String)msg.obj;
|
m_dlgBytes = (String)msg.obj;
|
||||||
m_dlgTitle = msg.arg1;
|
m_dlgTitle = msg.arg1;
|
||||||
showDialog( DLG_OKONLY );
|
showDialog( DlgID.DLG_OKONLY.ordinal() );
|
||||||
break;
|
break;
|
||||||
case JNIThread.QUERY_ENDGAME:
|
case JNIThread.QUERY_ENDGAME:
|
||||||
showDialog( QUERY_ENDGAME );
|
showDialog( DlgID.QUERY_ENDGAME.ordinal() );
|
||||||
break;
|
break;
|
||||||
case JNIThread.TOOLBAR_STATES:
|
case JNIThread.TOOLBAR_STATES:
|
||||||
if ( null != m_jniThread ) {
|
if ( null != m_jniThread ) {
|
||||||
|
@ -1898,7 +1881,7 @@ public class BoardActivity extends XWActivity
|
||||||
case JNIThread.GAME_OVER:
|
case JNIThread.GAME_OVER:
|
||||||
m_dlgBytes = (String)msg.obj;
|
m_dlgBytes = (String)msg.obj;
|
||||||
m_dlgTitle = msg.arg1;
|
m_dlgTitle = msg.arg1;
|
||||||
showDialog( GAME_OVER );
|
showDialog( DlgID.GAME_OVER.ordinal() );
|
||||||
break;
|
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;
|
int result = cancelResult;
|
||||||
// this has been true; dunno why
|
// 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",
|
DbgUtils.logf( "waitBlockingDialog: dropping dlgID %d b/c %d set",
|
||||||
dlgID, m_blockingDlgID );
|
dlgID, m_blockingDlgID );
|
||||||
} else {
|
} else {
|
||||||
|
@ -2047,15 +2030,15 @@ public class BoardActivity extends XWActivity
|
||||||
m_forResultWait.acquire();
|
m_forResultWait.acquire();
|
||||||
} catch ( java.lang.InterruptedException ie ) {
|
} catch ( java.lang.InterruptedException ie ) {
|
||||||
DbgUtils.loge( ie );
|
DbgUtils.loge( ie );
|
||||||
if ( BLOCKING_DLG_NONE != m_blockingDlgID ) {
|
if ( DlgID.NONE != m_blockingDlgID ) {
|
||||||
try {
|
try {
|
||||||
dismissDialog( m_blockingDlgID );
|
dismissDialog( m_blockingDlgID.ordinal() );
|
||||||
} catch ( java.lang.IllegalArgumentException iae ) {
|
} catch ( java.lang.IllegalArgumentException iae ) {
|
||||||
DbgUtils.loge( iae );
|
DbgUtils.loge( iae );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_blockingDlgID = BLOCKING_DLG_NONE;
|
m_blockingDlgID = DlgID.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearBlockingThread();
|
clearBlockingThread();
|
||||||
|
@ -2064,7 +2047,7 @@ public class BoardActivity extends XWActivity
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nonBlockingDialog( final int dlgID, String txt )
|
private void nonBlockingDialog( final DlgID dlgID, String txt )
|
||||||
{
|
{
|
||||||
switch ( dlgID ) {
|
switch ( dlgID ) {
|
||||||
case DLG_OKONLY:
|
case DLG_OKONLY:
|
||||||
|
|
|
@ -81,10 +81,6 @@ public class DictsActivity extends XWExpandableListActivity
|
||||||
private static final int DELETE_DICT_ACTION = 1;
|
private static final int DELETE_DICT_ACTION = 1;
|
||||||
private static final int DOWNLOAD_DICT_ACTION = 2;
|
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
|
// I can't provide a subclass of MenuItem to hold DictAndLoc, so
|
||||||
// settle for a hash on the side.
|
// settle for a hash on the side.
|
||||||
private static HashMap<MenuItem, DictAndLoc> s_itemData;
|
private static HashMap<MenuItem, DictAndLoc> s_itemData;
|
||||||
|
@ -255,7 +251,8 @@ public class DictsActivity extends XWExpandableListActivity
|
||||||
String message;
|
String message;
|
||||||
boolean doRemove = true;
|
boolean doRemove = true;
|
||||||
|
|
||||||
switch( id ) {
|
DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch( dlgID ) {
|
||||||
case MOVE_DICT:
|
case MOVE_DICT:
|
||||||
final XWListItem[] selItems = getSelItems();
|
final XWListItem[] selItems = getSelItems();
|
||||||
final int[] moveTo = { -1 };
|
final int[] moveTo = { -1 };
|
||||||
|
@ -360,7 +357,7 @@ public class DictsActivity extends XWExpandableListActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( doRemove && null != dialog ) {
|
if ( doRemove && null != dialog ) {
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
}
|
}
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
@ -371,7 +368,7 @@ public class DictsActivity extends XWExpandableListActivity
|
||||||
{
|
{
|
||||||
super.onPrepareDialog( id, dialog );
|
super.onPrepareDialog( id, dialog );
|
||||||
|
|
||||||
if ( MOVE_DICT == id ) {
|
if ( DlgID.MOVE_DICT.ordinal() == id ) {
|
||||||
// The move button should always start out disabled
|
// The move button should always start out disabled
|
||||||
// because the selected location should be where it
|
// because the selected location should be where it
|
||||||
// currently is.
|
// currently is.
|
||||||
|
@ -417,7 +414,7 @@ public class DictsActivity extends XWExpandableListActivity
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if ( null != intent ) {
|
if ( null != intent ) {
|
||||||
if ( MultiService.isMissingDictIntent( intent ) ) {
|
if ( MultiService.isMissingDictIntent( intent ) ) {
|
||||||
showDialog( DICT_OR_DECLINE );
|
showDialog( DlgID.DICT_OR_DECLINE.ordinal() );
|
||||||
} else {
|
} else {
|
||||||
boolean downloadNow = intent.getBooleanExtra( DICT_DOLAUNCH, false );
|
boolean downloadNow = intent.getBooleanExtra( DICT_DOLAUNCH, false );
|
||||||
if ( downloadNow ) {
|
if ( downloadNow ) {
|
||||||
|
@ -509,7 +506,7 @@ public class DictsActivity extends XWExpandableListActivity
|
||||||
askMoveSelDicts();
|
askMoveSelDicts();
|
||||||
break;
|
break;
|
||||||
case R.id.dicts_select:
|
case R.id.dicts_select:
|
||||||
showDialog( SET_DEFAULT );
|
showDialog( DlgID.SET_DEFAULT.ordinal() );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
handled = false;
|
handled = false;
|
||||||
|
@ -545,7 +542,7 @@ public class DictsActivity extends XWExpandableListActivity
|
||||||
// options for YY?
|
// options for YY?
|
||||||
private void askMoveSelDicts()
|
private void askMoveSelDicts()
|
||||||
{
|
{
|
||||||
showDialog( MOVE_DICT );
|
showDialog( DlgID.MOVE_DICT.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnItemLongClickListener interface
|
// OnItemLongClickListener interface
|
||||||
|
|
|
@ -39,14 +39,6 @@ import junit.framework.Assert;
|
||||||
|
|
||||||
public class DlgDelegate {
|
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 SMS_BTN = AlertDialog.BUTTON_POSITIVE;
|
||||||
public static final int EMAIL_BTN = AlertDialog.BUTTON_NEGATIVE;
|
public static final int EMAIL_BTN = AlertDialog.BUTTON_NEGATIVE;
|
||||||
public static final int NFC_BTN = AlertDialog.BUTTON_NEUTRAL;
|
public static final int NFC_BTN = AlertDialog.BUTTON_NEUTRAL;
|
||||||
|
@ -70,7 +62,7 @@ public class DlgDelegate {
|
||||||
private ProgressDialog m_progress;
|
private ProgressDialog m_progress;
|
||||||
private Handler m_handler;
|
private Handler m_handler;
|
||||||
|
|
||||||
private HashMap<Integer, DlgState> m_dlgStates;
|
private HashMap<DlgID, DlgState> m_dlgStates;
|
||||||
|
|
||||||
public DlgDelegate( Activity activity, DlgClickNotify callback,
|
public DlgDelegate( Activity activity, DlgClickNotify callback,
|
||||||
Bundle bundle )
|
Bundle bundle )
|
||||||
|
@ -78,7 +70,7 @@ public class DlgDelegate {
|
||||||
m_activity = activity;
|
m_activity = activity;
|
||||||
m_clickCallback = callback;
|
m_clickCallback = callback;
|
||||||
m_handler = new Handler();
|
m_handler = new Handler();
|
||||||
m_dlgStates = new HashMap<Integer,DlgState>();
|
m_dlgStates = new HashMap<DlgID,DlgState>();
|
||||||
|
|
||||||
if ( null != bundle ) {
|
if ( null != bundle ) {
|
||||||
int[] ids = bundle.getIntArray( IDS );
|
int[] ids = bundle.getIntArray( IDS );
|
||||||
|
@ -99,7 +91,7 @@ public class DlgDelegate {
|
||||||
DlgState state = iter.next();
|
DlgState state = iter.next();
|
||||||
String key = String.format( STATE_KEYF, state.m_id );
|
String key = String.format( STATE_KEYF, state.m_id );
|
||||||
outState.putParcelable( key, state );
|
outState.putParcelable( key, state );
|
||||||
ids[indx++] = state.m_id;
|
ids[indx++] = state.m_id.ordinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outState.putIntArray( IDS, ids );
|
outState.putIntArray( IDS, ids );
|
||||||
|
@ -109,22 +101,23 @@ public class DlgDelegate {
|
||||||
{
|
{
|
||||||
// DbgUtils.logf("onCreateDialog(id=%d)", id );
|
// DbgUtils.logf("onCreateDialog(id=%d)", id );
|
||||||
Dialog dialog = null;
|
Dialog dialog = null;
|
||||||
DlgState state = findForID( id );
|
DlgID dlgID = DlgID.values()[id];
|
||||||
switch( id ) {
|
DlgState state = findForID( dlgID );
|
||||||
|
switch( dlgID ) {
|
||||||
case DIALOG_ABOUT:
|
case DIALOG_ABOUT:
|
||||||
dialog = createAboutDialog();
|
dialog = createAboutDialog();
|
||||||
break;
|
break;
|
||||||
case DIALOG_OKONLY:
|
case DIALOG_OKONLY:
|
||||||
dialog = createOKDialog( state, id );
|
dialog = createOKDialog( state, dlgID );
|
||||||
break;
|
break;
|
||||||
case DIALOG_NOTAGAIN:
|
case DIALOG_NOTAGAIN:
|
||||||
dialog = createNotAgainDialog( state, id );
|
dialog = createNotAgainDialog( state, dlgID );
|
||||||
break;
|
break;
|
||||||
case CONFIRM_THEN:
|
case CONFIRM_THEN:
|
||||||
dialog = createConfirmThenDialog( state, id );
|
dialog = createConfirmThenDialog( state, dlgID );
|
||||||
break;
|
break;
|
||||||
case INVITE_CHOICES_THEN:
|
case INVITE_CHOICES_THEN:
|
||||||
dialog = createInviteChoicesDialog( state, id );
|
dialog = createInviteChoicesDialog( state, dlgID );
|
||||||
break;
|
break;
|
||||||
case DLG_DICTGONE:
|
case DLG_DICTGONE:
|
||||||
dialog = createDictGoneDialog();
|
dialog = createDictGoneDialog();
|
||||||
|
@ -141,9 +134,9 @@ public class DlgDelegate {
|
||||||
public void showOKOnlyDialog( String msg, int callbackID )
|
public void showOKOnlyDialog( String msg, int callbackID )
|
||||||
{
|
{
|
||||||
// Assert.assertNull( m_dlgStates );
|
// Assert.assertNull( m_dlgStates );
|
||||||
DlgState state = new DlgState( DIALOG_OKONLY, msg, callbackID );
|
DlgState state = new DlgState( DlgID.DIALOG_OKONLY, msg, callbackID );
|
||||||
addState( state );
|
addState( state );
|
||||||
m_activity.showDialog( DIALOG_OKONLY );
|
m_activity.showDialog( DlgID.DIALOG_OKONLY.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showOKOnlyDialog( int msgID )
|
public void showOKOnlyDialog( int msgID )
|
||||||
|
@ -153,12 +146,12 @@ public class DlgDelegate {
|
||||||
|
|
||||||
public void showDictGoneFinish()
|
public void showDictGoneFinish()
|
||||||
{
|
{
|
||||||
m_activity.showDialog( DLG_DICTGONE );
|
m_activity.showDialog( DlgID.DLG_DICTGONE.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAboutDialog()
|
public void showAboutDialog()
|
||||||
{
|
{
|
||||||
m_activity.showDialog( DIALOG_ABOUT );
|
m_activity.showDialog( DlgID.DIALOG_ABOUT.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showNotAgainDlgThen( int msgID, int prefsKey,
|
public void showNotAgainDlgThen( int msgID, int prefsKey,
|
||||||
|
@ -188,10 +181,10 @@ public class DlgDelegate {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DlgState state =
|
DlgState state =
|
||||||
new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey,
|
new DlgState( DlgID.DIALOG_NOTAGAIN, msg, callbackID, prefsKey,
|
||||||
params );
|
params );
|
||||||
addState( state );
|
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,
|
public void showConfirmThen( String msg, int posButton, int callbackID,
|
||||||
Object[] params )
|
Object[] params )
|
||||||
{
|
{
|
||||||
DlgState state = new DlgState( CONFIRM_THEN, msg, posButton,
|
DlgState state = new DlgState( DlgID.CONFIRM_THEN, msg, posButton,
|
||||||
callbackID, 0, params );
|
callbackID, 0, params );
|
||||||
addState( state );
|
addState( state );
|
||||||
m_activity.showDialog( CONFIRM_THEN );
|
m_activity.showDialog( DlgID.CONFIRM_THEN.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showInviteChoicesThen( final int callbackID )
|
public void showInviteChoicesThen( final int callbackID )
|
||||||
{
|
{
|
||||||
if ( Utils.deviceSupportsSMS( m_activity )
|
if ( Utils.deviceSupportsSMS( m_activity )
|
||||||
|| NFCUtils.nfcAvail( m_activity )[0] ) {
|
|| NFCUtils.nfcAvail( m_activity )[0] ) {
|
||||||
DlgState state = new DlgState( INVITE_CHOICES_THEN, callbackID );
|
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN, callbackID );
|
||||||
addState( state );
|
addState( state );
|
||||||
m_activity.showDialog( INVITE_CHOICES_THEN );
|
m_activity.showDialog( DlgID.INVITE_CHOICES_THEN.ordinal() );
|
||||||
} else {
|
} else {
|
||||||
post( new Runnable() {
|
post( new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -358,19 +351,19 @@ public class DlgDelegate {
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dialog createOKDialog( DlgState state, int id )
|
private Dialog createOKDialog( DlgState state, DlgID dlgID )
|
||||||
{
|
{
|
||||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||||
.setTitle( R.string.info_title )
|
.setTitle( R.string.info_title )
|
||||||
.setMessage( state.m_msg )
|
.setMessage( state.m_msg )
|
||||||
.setPositiveButton( R.string.button_ok, null )
|
.setPositiveButton( R.string.button_ok, null )
|
||||||
.create();
|
.create();
|
||||||
dialog = setCallbackDismissListener( dialog, state, id );
|
dialog = setCallbackDismissListener( dialog, state, dlgID );
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dialog createNotAgainDialog( final DlgState state, int id )
|
private Dialog createNotAgainDialog( final DlgState state, DlgID dlgID )
|
||||||
{
|
{
|
||||||
OnClickListener lstnr_p = mkCallbackClickListener( state );
|
OnClickListener lstnr_p = mkCallbackClickListener( state );
|
||||||
|
|
||||||
|
@ -395,10 +388,10 @@ public class DlgDelegate {
|
||||||
.setNegativeButton( R.string.button_notagain, lstnr_n )
|
.setNegativeButton( R.string.button_notagain, lstnr_n )
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
return setCallbackDismissListener( dialog, state, id );
|
return setCallbackDismissListener( dialog, state, dlgID );
|
||||||
} // createNotAgainDialog
|
} // createNotAgainDialog
|
||||||
|
|
||||||
private Dialog createConfirmThenDialog( DlgState state, int id )
|
private Dialog createConfirmThenDialog( DlgState state, DlgID dlgID )
|
||||||
{
|
{
|
||||||
OnClickListener lstnr = mkCallbackClickListener( state );
|
OnClickListener lstnr = mkCallbackClickListener( state );
|
||||||
|
|
||||||
|
@ -409,10 +402,10 @@ public class DlgDelegate {
|
||||||
.setNegativeButton( R.string.button_cancel, lstnr )
|
.setNegativeButton( R.string.button_cancel, lstnr )
|
||||||
.create();
|
.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 );
|
OnClickListener lstnr = mkCallbackClickListener( state );
|
||||||
|
|
||||||
|
@ -439,7 +432,7 @@ public class DlgDelegate {
|
||||||
builder.setNeutralButton( R.string.button_nfc, lstnr );
|
builder.setNeutralButton( R.string.button_nfc, lstnr );
|
||||||
}
|
}
|
||||||
|
|
||||||
return setCallbackDismissListener( builder.create(), state, id );
|
return setCallbackDismissListener( builder.create(), state, dlgID );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dialog createDictGoneDialog()
|
private Dialog createDictGoneDialog()
|
||||||
|
@ -476,8 +469,9 @@ public class DlgDelegate {
|
||||||
|
|
||||||
private Dialog setCallbackDismissListener( final Dialog dialog,
|
private Dialog setCallbackDismissListener( final Dialog dialog,
|
||||||
final DlgState state,
|
final DlgState state,
|
||||||
final int id )
|
DlgID dlgID )
|
||||||
{
|
{
|
||||||
|
final int id = dlgID.ordinal();
|
||||||
DialogInterface.OnDismissListener cbkOnDismissLstnr
|
DialogInterface.OnDismissListener cbkOnDismissLstnr
|
||||||
= new DialogInterface.OnDismissListener() {
|
= new DialogInterface.OnDismissListener() {
|
||||||
public void onDismiss( DialogInterface di ) {
|
public void onDismiss( DialogInterface di ) {
|
||||||
|
@ -495,9 +489,9 @@ public class DlgDelegate {
|
||||||
return dialog;
|
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 );
|
// DbgUtils.logf( "findForID(%d)=>%H", id, state );
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -24,40 +24,40 @@ import android.os.Parcelable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
||||||
public class DlgState implements Parcelable {
|
public class DlgState implements Parcelable {
|
||||||
public int m_id;
|
public DlgID m_id;
|
||||||
public String m_msg;
|
public String m_msg;
|
||||||
public int m_posButton;
|
public int m_posButton;
|
||||||
public int m_cbckID = 0;
|
public int m_cbckID = 0;
|
||||||
public int m_prefsKey;
|
public int m_prefsKey;
|
||||||
public Object[] m_params;
|
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 )
|
Object[] params )
|
||||||
{
|
{
|
||||||
this( id, msg, R.string.button_ok, cbckID, prefsKey );
|
this( dlgID, msg, R.string.button_ok, cbckID, prefsKey );
|
||||||
m_params = params;
|
m_params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DlgState( int id, String msg, int posButton,
|
public DlgState( DlgID dlgID, String msg, int posButton,
|
||||||
int cbckID, int prefsKey )
|
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 )
|
int cbckID, int prefsKey, Object[] params )
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = dlgID;
|
||||||
m_msg = msg;
|
m_msg = msg;
|
||||||
m_posButton = posButton;
|
m_posButton = posButton;
|
||||||
m_cbckID = cbckID;
|
m_cbckID = cbckID;
|
||||||
|
@ -65,9 +65,9 @@ public class DlgState implements Parcelable {
|
||||||
m_params = params;
|
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() {
|
public int describeContents() {
|
||||||
|
@ -75,7 +75,7 @@ public class DlgState implements Parcelable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToParcel( Parcel out, int flags ) {
|
public void writeToParcel( Parcel out, int flags ) {
|
||||||
out.writeInt( m_id );
|
out.writeInt( m_id.ordinal() );
|
||||||
out.writeInt( m_posButton );
|
out.writeInt( m_posButton );
|
||||||
out.writeInt( m_cbckID );
|
out.writeInt( m_cbckID );
|
||||||
out.writeInt( m_prefsKey );
|
out.writeInt( m_prefsKey );
|
||||||
|
@ -85,7 +85,7 @@ public class DlgState implements Parcelable {
|
||||||
public static final Parcelable.Creator<DlgState> CREATOR
|
public static final Parcelable.Creator<DlgState> CREATOR
|
||||||
= new Parcelable.Creator<DlgState>() {
|
= new Parcelable.Creator<DlgState>() {
|
||||||
public DlgState createFromParcel(Parcel in) {
|
public DlgState createFromParcel(Parcel in) {
|
||||||
int id = in.readInt();
|
DlgID id = DlgID.values()[in.readInt()];
|
||||||
int posButton = in.readInt();
|
int posButton = in.readInt();
|
||||||
int cbckID = in.readInt();
|
int cbckID = in.readInt();
|
||||||
int prefsKey = in.readInt();
|
int prefsKey = in.readInt();
|
||||||
|
|
|
@ -63,12 +63,6 @@ public class GameConfig extends XWActivity
|
||||||
,XWListItem.DeleteCallback
|
,XWListItem.DeleteCallback
|
||||||
,RefreshNamesTask.NoNameFound {
|
,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 String WHICH_PLAYER = "WHICH_PLAYER";
|
||||||
private static final int LOCKED_CHANGE_ACTION = 1;
|
private static final int LOCKED_CHANGE_ACTION = 1;
|
||||||
|
|
||||||
|
@ -155,7 +149,7 @@ public class GameConfig extends XWActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog( final int id )
|
protected Dialog onCreateDialog( int id )
|
||||||
{
|
{
|
||||||
Dialog dialog = super.onCreateDialog( id );
|
Dialog dialog = super.onCreateDialog( id );
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
|
@ -163,7 +157,8 @@ public class GameConfig extends XWActivity
|
||||||
DialogInterface.OnClickListener dlpos;
|
DialogInterface.OnClickListener dlpos;
|
||||||
AlertDialog.Builder ab;
|
AlertDialog.Builder ab;
|
||||||
|
|
||||||
switch (id) {
|
final DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch (dlgID) {
|
||||||
case PLAYER_EDIT:
|
case PLAYER_EDIT:
|
||||||
View playerEditView
|
View playerEditView
|
||||||
= Utils.inflate( this, R.layout.player_edit );
|
= Utils.inflate( this, R.layout.player_edit );
|
||||||
|
@ -210,7 +205,7 @@ public class GameConfig extends XWActivity
|
||||||
};
|
};
|
||||||
dialog = new AlertDialog.Builder( this )
|
dialog = new AlertDialog.Builder( this )
|
||||||
.setTitle( R.string.force_title )
|
.setTitle( R.string.force_title )
|
||||||
.setView( Utils.inflate( this, layoutForDlg(id) ) )
|
.setView( Utils.inflate( this, layoutForDlg(dlgID) ) )
|
||||||
.setPositiveButton( R.string.button_ok, dlpos )
|
.setPositiveButton( R.string.button_ok, dlpos )
|
||||||
.create();
|
.create();
|
||||||
DialogInterface.OnDismissListener dismiss =
|
DialogInterface.OnDismissListener dismiss =
|
||||||
|
@ -233,7 +228,7 @@ public class GameConfig extends XWActivity
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
applyChanges( true );
|
applyChanges( true );
|
||||||
if ( CONFIRM_CHANGE_PLAY == id ) {
|
if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) {
|
||||||
launchGame();
|
launchGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +237,7 @@ public class GameConfig extends XWActivity
|
||||||
.setTitle( R.string.confirm_save_title )
|
.setTitle( R.string.confirm_save_title )
|
||||||
.setMessage( R.string.confirm_save )
|
.setMessage( R.string.confirm_save )
|
||||||
.setPositiveButton( R.string.button_save, dlpos );
|
.setPositiveButton( R.string.button_save, dlpos );
|
||||||
if ( CONFIRM_CHANGE_PLAY == id ) {
|
if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) {
|
||||||
dlpos = new DialogInterface.OnClickListener() {
|
dlpos = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
|
@ -280,7 +275,8 @@ public class GameConfig extends XWActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onPrepareDialog( int id, Dialog dialog )
|
protected void onPrepareDialog( int id, Dialog dialog )
|
||||||
{
|
{
|
||||||
switch ( id ) {
|
DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch ( dlgID ) {
|
||||||
case PLAYER_EDIT:
|
case PLAYER_EDIT:
|
||||||
setPlayerSettings( dialog );
|
setPlayerSettings( dialog );
|
||||||
break;
|
break;
|
||||||
|
@ -596,7 +592,7 @@ public class GameConfig extends XWActivity
|
||||||
// NoNameFound interface
|
// NoNameFound interface
|
||||||
public void NoNameFound()
|
public void NoNameFound()
|
||||||
{
|
{
|
||||||
showDialog( NO_NAME_FOUND );
|
showDialog( DlgID.NO_NAME_FOUND.ordinal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -649,7 +645,7 @@ public class GameConfig extends XWActivity
|
||||||
launchGame();
|
launchGame();
|
||||||
} else if ( m_giOrig.changesMatter(m_gi)
|
} else if ( m_giOrig.changesMatter(m_gi)
|
||||||
|| m_carOrig.changesMatter(m_car) ) {
|
|| m_carOrig.changesMatter(m_car) ) {
|
||||||
showDialog( CONFIRM_CHANGE_PLAY );
|
showDialog( DlgID.CONFIRM_CHANGE_PLAY.ordinal() );
|
||||||
} else {
|
} else {
|
||||||
applyChanges( false );
|
applyChanges( false );
|
||||||
launchGame();
|
launchGame();
|
||||||
|
@ -672,7 +668,7 @@ public class GameConfig extends XWActivity
|
||||||
applyChanges( true );
|
applyChanges( true );
|
||||||
} else if ( m_giOrig.changesMatter(m_gi)
|
} else if ( m_giOrig.changesMatter(m_gi)
|
||||||
|| m_carOrig.changesMatter(m_car) ) {
|
|| m_carOrig.changesMatter(m_car) ) {
|
||||||
showDialog( CONFIRM_CHANGE );
|
showDialog( DlgID.CONFIRM_CHANGE.ordinal() );
|
||||||
consumed = true; // don't dismiss activity yet!
|
consumed = true; // don't dismiss activity yet!
|
||||||
} else {
|
} else {
|
||||||
applyChanges( false );
|
applyChanges( false );
|
||||||
|
@ -695,7 +691,7 @@ public class GameConfig extends XWActivity
|
||||||
@Override
|
@Override
|
||||||
public void onClick( View view ) {
|
public void onClick( View view ) {
|
||||||
m_whichPlayer = ((XWListItem)view).getPosition();
|
m_whichPlayer = ((XWListItem)view).getPosition();
|
||||||
showDialog( PLAYER_EDIT );
|
showDialog( DlgID.PLAYER_EDIT.ordinal() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -738,7 +734,7 @@ public class GameConfig extends XWActivity
|
||||||
if ( ! localOnlyGame()
|
if ( ! localOnlyGame()
|
||||||
&& ((0 == m_gi.remoteCount() )
|
&& ((0 == m_gi.remoteCount() )
|
||||||
|| (m_gi.nPlayers == m_gi.remoteCount()) ) ) {
|
|| (m_gi.nPlayers == m_gi.remoteCount()) ) ) {
|
||||||
showDialog( FORCE_REMOTE );
|
showDialog( DlgID.FORCE_REMOTE.ordinal() );
|
||||||
}
|
}
|
||||||
adjustPlayersLabel();
|
adjustPlayersLabel();
|
||||||
} // loadPlayersList
|
} // 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:
|
// case ROLE_EDIT_RELAY:
|
||||||
// return R.layout.role_edit_relay;
|
// return R.layout.role_edit_relay;
|
||||||
// case ROLE_EDIT_SMS:
|
// case ROLE_EDIT_SMS:
|
||||||
|
|
|
@ -62,16 +62,6 @@ public class GamesList extends XWExpandableListActivity
|
||||||
DBUtils.DBChangeListener, SelectableItem,
|
DBUtils.DBChangeListener, SelectableItem,
|
||||||
DictImportActivity.DownloadFinishedListener {
|
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_ROWID = "SAVE_ROWID";
|
||||||
private static final String SAVE_ROWIDS = "SAVE_ROWIDS";
|
private static final String SAVE_ROWIDS = "SAVE_ROWIDS";
|
||||||
private static final String SAVE_GROUPID = "SAVE_GROUPID";
|
private static final String SAVE_GROUPID = "SAVE_GROUPID";
|
||||||
|
@ -147,7 +137,8 @@ public class GamesList extends XWExpandableListActivity
|
||||||
Dialog dialog = super.onCreateDialog( id );
|
Dialog dialog = super.onCreateDialog( id );
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
AlertDialog.Builder ab;
|
AlertDialog.Builder ab;
|
||||||
switch ( id ) {
|
DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch ( dlgID ) {
|
||||||
case WARN_NODICT:
|
case WARN_NODICT:
|
||||||
case WARN_NODICT_NEW:
|
case WARN_NODICT_NEW:
|
||||||
case WARN_NODICT_SUBST:
|
case WARN_NODICT_SUBST:
|
||||||
|
@ -170,10 +161,10 @@ public class GamesList extends XWExpandableListActivity
|
||||||
String langName =
|
String langName =
|
||||||
DictLangCache.getLangName( this, m_missingDictLang );
|
DictLangCache.getLangName( this, m_missingDictLang );
|
||||||
String gameName = GameUtils.getName( this, m_missingDictRowId );
|
String gameName = GameUtils.getName( this, m_missingDictRowId );
|
||||||
if ( WARN_NODICT == id ) {
|
if ( DlgID.WARN_NODICT == dlgID ) {
|
||||||
message = getString( R.string.no_dictf,
|
message = getString( R.string.no_dictf,
|
||||||
gameName, langName );
|
gameName, langName );
|
||||||
} else if ( WARN_NODICT_NEW == id ) {
|
} else if ( DlgID.WARN_NODICT_NEW == dlgID ) {
|
||||||
message =
|
message =
|
||||||
getString( R.string.invite_dict_missing_body_nonamef,
|
getString( R.string.invite_dict_missing_body_nonamef,
|
||||||
null, m_missingDictName, langName );
|
null, m_missingDictName, langName );
|
||||||
|
@ -189,16 +180,16 @@ public class GamesList extends XWExpandableListActivity
|
||||||
.setPositiveButton( R.string.button_cancel, null )
|
.setPositiveButton( R.string.button_cancel, null )
|
||||||
.setNegativeButton( R.string.button_download, lstnr )
|
.setNegativeButton( R.string.button_download, lstnr )
|
||||||
;
|
;
|
||||||
if ( WARN_NODICT_SUBST == id ) {
|
if ( DlgID.WARN_NODICT_SUBST == dlgID ) {
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
showDialog( SHOW_SUBST );
|
showDialog( DlgID.SHOW_SUBST.ordinal() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setNeutralButton( R.string.button_substdict, lstnr );
|
ab.setNeutralButton( R.string.button_substdict, lstnr );
|
||||||
}
|
}
|
||||||
dialog = ab.create();
|
dialog = ab.create();
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
break;
|
break;
|
||||||
case SHOW_SUBST:
|
case SHOW_SUBST:
|
||||||
m_sameLangDicts =
|
m_sameLangDicts =
|
||||||
|
@ -228,7 +219,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
// called next time and we can insert a different
|
// called next time and we can insert a different
|
||||||
// list. There seems to be no way to change the list
|
// list. There seems to be no way to change the list
|
||||||
// inside onPrepareDialog().
|
// inside onPrepareDialog().
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RENAME_GAME:
|
case RENAME_GAME:
|
||||||
|
@ -242,7 +233,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
dialog = buildNamerDlg( GameUtils.getName( this, m_rowid ),
|
dialog = buildNamerDlg( GameUtils.getName( this, m_rowid ),
|
||||||
R.string.rename_label,
|
R.string.rename_label,
|
||||||
R.string.game_rename_title,
|
R.string.game_rename_title,
|
||||||
lstnr, RENAME_GAME );
|
lstnr, DlgID.RENAME_GAME );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RENAME_GROUP:
|
case RENAME_GROUP:
|
||||||
|
@ -258,7 +249,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
dialog = buildNamerDlg( m_adapter.groupName( m_groupid ),
|
dialog = buildNamerDlg( m_adapter.groupName( m_groupid ),
|
||||||
R.string.rename_group_label,
|
R.string.rename_group_label,
|
||||||
R.string.game_name_group_title,
|
R.string.game_name_group_title,
|
||||||
lstnr, RENAME_GROUP );
|
lstnr, DlgID.RENAME_GROUP );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NEW_GROUP:
|
case NEW_GROUP:
|
||||||
|
@ -272,8 +263,8 @@ public class GamesList extends XWExpandableListActivity
|
||||||
};
|
};
|
||||||
dialog = buildNamerDlg( "", R.string.newgroup_label,
|
dialog = buildNamerDlg( "", R.string.newgroup_label,
|
||||||
R.string.game_name_group_title,
|
R.string.game_name_group_title,
|
||||||
lstnr, RENAME_GROUP );
|
lstnr, DlgID.RENAME_GROUP );
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHANGE_GROUP:
|
case CHANGE_GROUP:
|
||||||
|
@ -314,7 +305,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
.setPositiveButton( R.string.button_move, lstnr2 )
|
.setPositiveButton( R.string.button_move, lstnr2 )
|
||||||
.setNegativeButton( R.string.button_cancel, null )
|
.setNegativeButton( R.string.button_cancel, null )
|
||||||
.create();
|
.create();
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GET_NAME:
|
case GET_NAME:
|
||||||
|
@ -357,7 +348,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
{
|
{
|
||||||
super.onPrepareDialog( id, dialog );
|
super.onPrepareDialog( id, dialog );
|
||||||
|
|
||||||
if ( CHANGE_GROUP == id ) {
|
if ( DlgID.CHANGE_GROUP.ordinal() == id ) {
|
||||||
((AlertDialog)dialog).getButton( AlertDialog.BUTTON_POSITIVE )
|
((AlertDialog)dialog).getButton( AlertDialog.BUTTON_POSITIVE )
|
||||||
.setEnabled( false );
|
.setEnabled( false );
|
||||||
}
|
}
|
||||||
|
@ -762,7 +753,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.games_menu_newgroup:
|
case R.id.games_menu_newgroup:
|
||||||
showDialog( NEW_GROUP );
|
showDialog( DlgID.NEW_GROUP.ordinal() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.games_game_config:
|
case R.id.games_game_config:
|
||||||
|
@ -832,7 +823,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
showOKOnlyDialog( R.string.no_move_onegroup );
|
showOKOnlyDialog( R.string.no_move_onegroup );
|
||||||
} else {
|
} else {
|
||||||
m_rowids = selRowIDs;
|
m_rowids = selRowIDs;
|
||||||
showDialog( CHANGE_GROUP );
|
showDialog( DlgID.CHANGE_GROUP.ordinal() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.games_game_new_from:
|
case R.id.games_game_new_from:
|
||||||
|
@ -873,7 +864,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
|
|
||||||
case R.id.games_game_rename:
|
case R.id.games_game_rename:
|
||||||
m_rowid = selRowIDs[0];
|
m_rowid = selRowIDs[0];
|
||||||
showDialog( RENAME_GAME );
|
showDialog( DlgID.RENAME_GAME.ordinal() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Group menus
|
// Group menus
|
||||||
|
@ -906,7 +897,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
break;
|
break;
|
||||||
case R.id.games_group_rename:
|
case R.id.games_group_rename:
|
||||||
m_groupid = groupID;
|
m_groupid = groupID;
|
||||||
showDialog( RENAME_GROUP );
|
showDialog( DlgID.RENAME_GROUP.ordinal() );
|
||||||
break;
|
break;
|
||||||
case R.id.games_group_moveup:
|
case R.id.games_group_moveup:
|
||||||
changeContent = m_adapter.moveGroup( groupID, -1 );
|
changeContent = m_adapter.moveGroup( groupID, -1 );
|
||||||
|
@ -988,7 +979,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
m_netLaunchInfo = nli;
|
m_netLaunchInfo = nli;
|
||||||
m_missingDictLang = nli.lang;
|
m_missingDictLang = nli.lang;
|
||||||
m_missingDictName = nli.dict;
|
m_missingDictName = nli.dict;
|
||||||
showDialog( WARN_NODICT_NEW );
|
showDialog( DlgID.WARN_NODICT_NEW.ordinal() );
|
||||||
}
|
}
|
||||||
return haveDict;
|
return haveDict;
|
||||||
}
|
}
|
||||||
|
@ -1008,9 +999,9 @@ public class GamesList extends XWExpandableListActivity
|
||||||
}
|
}
|
||||||
m_missingDictRowId = rowid;
|
m_missingDictRowId = rowid;
|
||||||
if ( 0 == DictLangCache.getLangCount( this, m_missingDictLang ) ) {
|
if ( 0 == DictLangCache.getLangCount( this, m_missingDictLang ) ) {
|
||||||
showDialog( WARN_NODICT );
|
showDialog( DlgID.WARN_NODICT.ordinal() );
|
||||||
} else if ( null != m_missingDictName ) {
|
} else if ( null != m_missingDictName ) {
|
||||||
showDialog( WARN_NODICT_SUBST );
|
showDialog( DlgID.WARN_NODICT_SUBST.ordinal() );
|
||||||
} else {
|
} else {
|
||||||
String dict =
|
String dict =
|
||||||
DictLangCache.getHaveLang( this, m_missingDictLang)[0];
|
DictLangCache.getHaveLang( this, m_missingDictLang)[0];
|
||||||
|
@ -1176,7 +1167,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
if ( null == CommonPrefs.getDefaultPlayerName( this, 0, false ) ) {
|
if ( null == CommonPrefs.getDefaultPlayerName( this, 0, false ) ) {
|
||||||
String name = CommonPrefs.getDefaultPlayerName( this, 0, true );
|
String name = CommonPrefs.getDefaultPlayerName( this, 0, true );
|
||||||
CommonPrefs.setDefaultPlayerName( GamesList.this, name );
|
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,
|
private Dialog buildNamerDlg( String curname, int labelID, int titleID,
|
||||||
DialogInterface.OnClickListener lstnr,
|
DialogInterface.OnClickListener lstnr,
|
||||||
int dlgID )
|
DlgID dlgID )
|
||||||
{
|
{
|
||||||
m_namer = (GameNamer)Utils.inflate( this, R.layout.rename_game );
|
m_namer = (GameNamer)Utils.inflate( this, R.layout.rename_game );
|
||||||
m_namer.setName( curname );
|
m_namer.setName( curname );
|
||||||
|
|
|
@ -57,10 +57,6 @@ public class NewGameActivity extends XWActivity {
|
||||||
private static final int INVITE_FOR_BT = 3;
|
private static final int INVITE_FOR_BT = 3;
|
||||||
private static final int INVITE_FOR_SMS = 4;
|
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_showsOn;
|
||||||
private boolean m_nameForBT;
|
private boolean m_nameForBT;
|
||||||
private boolean m_firingPrefs = false;
|
private boolean m_firingPrefs = false;
|
||||||
|
@ -202,7 +198,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
m_gameID = GameUtils.newGameID();
|
m_gameID = GameUtils.newGameID();
|
||||||
m_gameName = Utils.format( this, R.string.dft_namef,
|
m_gameName = Utils.format( this, R.string.dft_namef,
|
||||||
m_gameID & 0xFFFF );
|
m_gameID & 0xFFFF );
|
||||||
showDialog( NAME_GAME );
|
showDialog( DlgID.NAME_GAME.ordinal() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +210,8 @@ public class NewGameActivity extends XWActivity {
|
||||||
{
|
{
|
||||||
Dialog dialog = super.onCreateDialog( id );
|
Dialog dialog = super.onCreateDialog( id );
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
switch( id ) {
|
DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch( dlgID ) {
|
||||||
case NAME_GAME:
|
case NAME_GAME:
|
||||||
final GameNamer namerView =
|
final GameNamer namerView =
|
||||||
(GameNamer)Utils.inflate( this, R.layout.rename_game );
|
(GameNamer)Utils.inflate( this, R.layout.rename_game );
|
||||||
|
@ -253,7 +250,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
.setPositiveButton( R.string.button_ok, lstnr )
|
.setPositiveButton( R.string.button_ok, lstnr )
|
||||||
.setView( namerView )
|
.setView( namerView )
|
||||||
.create();
|
.create();
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ENABLE_NFC:
|
case ENABLE_NFC:
|
||||||
|
@ -324,7 +321,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
{
|
{
|
||||||
boolean viaNFC = DlgDelegate.NFC_BTN == chosen;
|
boolean viaNFC = DlgDelegate.NFC_BTN == chosen;
|
||||||
if ( viaNFC && !NFCUtils.nfcAvail( this )[1] ) {
|
if ( viaNFC && !NFCUtils.nfcAvail( this )[1] ) {
|
||||||
showDialog( ENABLE_NFC );
|
showDialog( DlgID.ENABLE_NFC.ordinal() );
|
||||||
} else {
|
} else {
|
||||||
String room = null;
|
String room = null;
|
||||||
String inviteID = null;
|
String inviteID = null;
|
||||||
|
|
|
@ -36,11 +36,6 @@ import java.io.File;
|
||||||
public class PrefsActivity extends PreferenceActivity
|
public class PrefsActivity extends PreferenceActivity
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
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_keyLogging;
|
||||||
private String m_smsToasting;
|
private String m_smsToasting;
|
||||||
private String m_smsEnable;
|
private String m_smsEnable;
|
||||||
|
@ -56,7 +51,8 @@ public class PrefsActivity extends PreferenceActivity
|
||||||
DialogInterface.OnClickListener lstnr = null;
|
DialogInterface.OnClickListener lstnr = null;
|
||||||
int confirmID = 0;
|
int confirmID = 0;
|
||||||
|
|
||||||
switch( id ) {
|
DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch( dlgID ) {
|
||||||
case REVERT_COLORS:
|
case REVERT_COLORS:
|
||||||
confirmID = R.string.confirm_revert_colors;
|
confirmID = R.string.confirm_revert_colors;
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
|
@ -142,13 +138,13 @@ public class PrefsActivity extends PreferenceActivity
|
||||||
Button button = (Button)findViewById( R.id.revert_colors );
|
Button button = (Button)findViewById( R.id.revert_colors );
|
||||||
button.setOnClickListener( new View.OnClickListener() {
|
button.setOnClickListener( new View.OnClickListener() {
|
||||||
public void onClick( View v ) {
|
public void onClick( View v ) {
|
||||||
showDialog( REVERT_COLORS );
|
showDialog( DlgID.REVERT_COLORS.ordinal() );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
button = (Button)findViewById( R.id.revert_all );
|
button = (Button)findViewById( R.id.revert_all );
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick( View v ) {
|
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);
|
= (CheckBoxPreference)findPreference(key);
|
||||||
pref.setChecked( false );
|
pref.setChecked( false );
|
||||||
pref.setEnabled( false );
|
pref.setEnabled( false );
|
||||||
showDialog( EXPLAIN_TITLE );
|
showDialog( DlgID.EXPLAIN_TITLE.ordinal() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class SMSCheckBoxPreference extends CheckBoxPreference {
|
||||||
{
|
{
|
||||||
if ( checked && m_attached && m_context instanceof PrefsActivity ) {
|
if ( checked && m_attached && m_context instanceof PrefsActivity ) {
|
||||||
PrefsActivity activity = (PrefsActivity)m_context;
|
PrefsActivity activity = (PrefsActivity)m_context;
|
||||||
activity.showDialog( PrefsActivity.CONFIRM_SMS );
|
activity.showDialog( DlgID.CONFIRM_SMS.ordinal() );
|
||||||
} else {
|
} else {
|
||||||
super_setChecked( checked );
|
super_setChecked( checked );
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ import java.util.Iterator;
|
||||||
public class SMSInviteActivity extends InviteActivity {
|
public class SMSInviteActivity extends InviteActivity {
|
||||||
|
|
||||||
private static final int GET_CONTACT = 1;
|
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_NAME = "SAVE_NAME";
|
||||||
private static final String SAVE_NUMBER = "SAVE_NUMBER";
|
private static final String SAVE_NUMBER = "SAVE_NUMBER";
|
||||||
|
|
||||||
|
@ -79,7 +78,7 @@ public class SMSInviteActivity extends InviteActivity {
|
||||||
m_addButton.setOnClickListener( new View.OnClickListener() {
|
m_addButton.setOnClickListener( new View.OnClickListener() {
|
||||||
public void onClick( View view )
|
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 );
|
Dialog dialog = super.onCreateDialog( id );
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
DialogInterface.OnClickListener lstnr;
|
DialogInterface.OnClickListener lstnr;
|
||||||
switch( id ) {
|
DlgID dlgID = DlgID.values()[id];
|
||||||
|
switch( dlgID ) {
|
||||||
case GET_NUMBER:
|
case GET_NUMBER:
|
||||||
final GameNamer namerView =
|
final GameNamer namerView =
|
||||||
(GameNamer)Utils.inflate( this, R.layout.rename_game );
|
(GameNamer)Utils.inflate( this, R.layout.rename_game );
|
||||||
|
@ -147,7 +147,7 @@ public class SMSInviteActivity extends InviteActivity {
|
||||||
.create();
|
.create();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, dlgID );
|
||||||
}
|
}
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,8 +132,9 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRemoveOnDismiss( final Activity activity,
|
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() {
|
dialog.setOnDismissListener( new DialogInterface.OnDismissListener() {
|
||||||
public void onDismiss( DialogInterface di ) {
|
public void onDismiss( DialogInterface di ) {
|
||||||
activity.removeDialog( id );
|
activity.removeDialog( id );
|
||||||
|
|
|
@ -100,6 +100,11 @@ public class XWActivity extends Activity
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showDialog( DlgID dlgID )
|
||||||
|
{
|
||||||
|
super.showDialog( dlgID.ordinal() );
|
||||||
|
}
|
||||||
|
|
||||||
// these are duplicated in XWListActivity -- sometimes multiple
|
// these are duplicated in XWListActivity -- sometimes multiple
|
||||||
// inheritance would be nice to have...
|
// inheritance would be nice to have...
|
||||||
protected void showAboutDialog()
|
protected void showAboutDialog()
|
||||||
|
|
Loading…
Reference in a new issue