mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
add optional param to confirmation dialogs to allow positive button
other than Ok; add "Delete" and "Reset" for game and dict actions.
This commit is contained in:
parent
fda3207b78
commit
1d612288d4
5 changed files with 27 additions and 4 deletions
|
@ -611,4 +611,7 @@
|
|||
|
||||
<string name="no_moves_made">(No moves yet)</string>
|
||||
|
||||
<string name="button_delete">Delete</string>
|
||||
<string name="button_reset">Reset</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -560,7 +560,8 @@ public class DictsActivity extends ExpandableListActivity
|
|||
}
|
||||
}
|
||||
|
||||
m_delegate.showConfirmThen( msg, DELETE_DICT_ACTION );
|
||||
m_delegate.showConfirmThen( msg, R.string.button_delete,
|
||||
DELETE_DICT_ACTION );
|
||||
}
|
||||
|
||||
// SDCardWatcher.SDCardNotifiee interface
|
||||
|
|
|
@ -54,6 +54,7 @@ public class DlgDelegate {
|
|||
private static final String CALLBACK = "callback";
|
||||
private static final String MSGID = "msgid";
|
||||
private static final String PREFSKEY = "prefskey";
|
||||
private static final String POSBUTTON = "posbutton";
|
||||
|
||||
// Cache a couple of callback implementations that never change:
|
||||
private DialogInterface.OnClickListener m_cbkOnClickLstnr = null;
|
||||
|
@ -64,6 +65,7 @@ public class DlgDelegate {
|
|||
}
|
||||
|
||||
private int m_msgID;
|
||||
private int m_posButton;
|
||||
private int m_cbckID = 0; // if this can be set twice I have a
|
||||
// problem. See asserts below.
|
||||
private String m_msg;
|
||||
|
@ -82,6 +84,7 @@ public class DlgDelegate {
|
|||
m_msg = bundle.getString( MSG );
|
||||
m_cbckID = bundle.getInt( CALLBACK );
|
||||
m_msgID = bundle.getInt( MSGID );
|
||||
m_posButton = bundle.getInt( POSBUTTON );
|
||||
m_prefsKey = bundle.getInt( PREFSKEY );
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +94,7 @@ public class DlgDelegate {
|
|||
outState.putString( MSG, m_msg );
|
||||
outState.putInt( CALLBACK, m_cbckID );
|
||||
outState.putInt( MSGID, m_msgID );
|
||||
outState.putInt( POSBUTTON, m_posButton );
|
||||
outState.putInt( PREFSKEY, m_prefsKey );
|
||||
}
|
||||
|
||||
|
@ -137,6 +141,8 @@ public class DlgDelegate {
|
|||
ad.setMessage( m_activity.getString(m_msgID) );
|
||||
break;
|
||||
case CONFIRM_THEN:
|
||||
ad.getButton(AlertDialog.BUTTON_POSITIVE).
|
||||
setText( m_activity.getString( m_posButton ) );
|
||||
ad.setMessage( m_msg );
|
||||
break;
|
||||
}
|
||||
|
@ -185,8 +191,14 @@ public class DlgDelegate {
|
|||
}
|
||||
|
||||
public void showConfirmThen( String msg, int callbackID )
|
||||
{
|
||||
showConfirmThen( msg, R.string.button_ok, callbackID );
|
||||
}
|
||||
|
||||
public void showConfirmThen( String msg, int posButton, int callbackID )
|
||||
{
|
||||
m_msg = msg;
|
||||
m_posButton = posButton;
|
||||
Assert.assertTrue( 0 != callbackID );
|
||||
Assert.assertTrue( 0 == m_cbckID );
|
||||
m_cbckID = callbackID;
|
||||
|
|
|
@ -518,7 +518,7 @@ public class GamesList extends XWListActivity
|
|||
case R.id.gamel_menu_delete_all:
|
||||
if ( DBUtils.gamesList( this ).length > 0 ) {
|
||||
showConfirmThen( R.string.confirm_delete_all,
|
||||
DELETE_ALL_ACTION );
|
||||
R.string.button_delete, DELETE_ALL_ACTION );
|
||||
}
|
||||
handled = true;
|
||||
break;
|
||||
|
@ -561,12 +561,14 @@ public class GamesList extends XWListActivity
|
|||
m_rowid = DBUtils.gamesList( this )[position];
|
||||
|
||||
if ( R.id.list_item_delete == menuID ) {
|
||||
showConfirmThen( R.string.confirm_delete, DELETE_GAME_ACTION );
|
||||
showConfirmThen( R.string.confirm_delete, R.string.button_delete,
|
||||
DELETE_GAME_ACTION );
|
||||
} else {
|
||||
if ( checkWarnNoDict( m_rowid ) ) {
|
||||
switch ( menuID ) {
|
||||
case R.id.list_item_reset:
|
||||
showConfirmThen( R.string.confirm_reset, RESET_GAME_ACTION );
|
||||
showConfirmThen( R.string.confirm_reset,
|
||||
R.string.button_reset, RESET_GAME_ACTION );
|
||||
break;
|
||||
case R.id.list_item_config:
|
||||
GameUtils.doConfig( this, m_rowid, GameConfig.class );
|
||||
|
|
|
@ -137,6 +137,11 @@ public class XWListActivity extends ListActivity
|
|||
showConfirmThen( getString(msg), action );
|
||||
}
|
||||
|
||||
protected void showConfirmThen( int msg, int posButton, int action )
|
||||
{
|
||||
m_delegate.showConfirmThen( getString(msg), posButton, action );
|
||||
}
|
||||
|
||||
protected void doSyncMenuitem()
|
||||
{
|
||||
m_delegate.doSyncMenuitem();
|
||||
|
|
Loading…
Reference in a new issue