From c996e986243aa275f2395631229b98465ad377c8 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Sat, 14 May 2011 11:04:19 -0700 Subject: [PATCH] replace two menuitems, default-robot and default-human, with a single that invokes a dialog giving an explanation and three choices: robot, human and both. --- .../XWords4/res/menu/dicts_item_menu.xml | 7 +-- .../android/XWords4/res/values/strings.xml | 8 +++- .../eehouse/android/xw4/DictsActivity.java | 43 ++++++++++++++----- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/xwords4/android/XWords4/res/menu/dicts_item_menu.xml b/xwords4/android/XWords4/res/menu/dicts_item_menu.xml index 60df3fdc9..3b92109a9 100644 --- a/xwords4/android/XWords4/res/menu/dicts_item_menu.xml +++ b/xwords4/android/XWords4/res/menu/dicts_item_menu.xml @@ -4,11 +4,8 @@ - - Shuffle players Move dictionary - Make default (human) - Make default (robot) + Make default Details Move dictionary %1$s from %2$s to %3$s? + Use this dictionary as the + default for new games for what kind of players? + Human + Robot + Both Dictionary (in %s) Connection (via internet) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java index 44fe99faf..d0e2cca95 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java @@ -62,6 +62,7 @@ public class DictsActivity extends ExpandableListActivity private static final int PICK_STORAGE = DlgDelegate.DIALOG_LAST + 1; private static final int MOVE_DICT = DlgDelegate.DIALOG_LAST + 2; + private static final int SET_DEFAULT = DlgDelegate.DIALOG_LAST + 3; private int m_lang = 0; private String[] m_langs; private String m_name = null; @@ -208,12 +209,12 @@ public class DictsActivity extends ExpandableListActivity protected Dialog onCreateDialog( int id ) { Dialog dialog; - DialogInterface.OnClickListener lstnrSD; + DialogInterface.OnClickListener lstnr; switch( id ) { case PICK_STORAGE: - lstnrSD = new DialogInterface.OnClickListener() { + lstnr = new DialogInterface.OnClickListener() { public void onClick( DialogInterface dlg, int item ) { startDownload( m_lang, m_name, item != DialogInterface.BUTTON_POSITIVE ); @@ -223,12 +224,12 @@ public class DictsActivity extends ExpandableListActivity dialog = new AlertDialog.Builder( this ) .setTitle( R.string.storeWhereTitle ) .setMessage( R.string.storeWhereMsg ) - .setPositiveButton( R.string.button_internal, lstnrSD ) - .setNegativeButton( R.string.button_sd, lstnrSD ) + .setPositiveButton( R.string.button_internal, lstnr ) + .setNegativeButton( R.string.button_sd, lstnr ) .create(); break; case MOVE_DICT: - lstnrSD = new DialogInterface.OnClickListener() { + lstnr = new DialogInterface.OnClickListener() { public void onClick( DialogInterface dlg, int item ) { Utils.logf( "CALLING moveDict" ); if ( GameUtils.moveDict( DictsActivity.this, @@ -244,10 +245,32 @@ public class DictsActivity extends ExpandableListActivity }; dialog = new AlertDialog.Builder( this ) .setMessage( "" ) // will set later - .setPositiveButton( R.string.button_ok, lstnrSD ) + .setPositiveButton( R.string.button_ok, lstnr ) .setNegativeButton( R.string.button_cancel, null ) .create(); break; + case SET_DEFAULT: + lstnr = new DialogInterface.OnClickListener() { + public void onClick( DialogInterface dlg, int item ) { + if ( DialogInterface.BUTTON_NEGATIVE == item + || DialogInterface.BUTTON_POSITIVE == item ) { + setDefault( R.string.key_default_dict, m_rowView ); + } + if ( DialogInterface.BUTTON_NEGATIVE == item + || DialogInterface.BUTTON_NEUTRAL == item ) { + setDefault( R.string.key_default_robodict, + m_rowView ); + } + } + }; + dialog = new AlertDialog.Builder( this ) + .setTitle( R.string.query_title ) + .setMessage( R.string.set_default_message ) + .setPositiveButton( R.string.button_default_human, lstnr ) + .setNeutralButton( R.string.button_default_robot, lstnr ) + .setNegativeButton( R.string.button_default_both, lstnr ) + .create(); + break; default: dialog = m_delegate.onCreateDialog( id ); break; @@ -373,11 +396,9 @@ public class DictsActivity extends ExpandableListActivity case R.id.dicts_item_move: askMoveDict( row ); break; - case R.id.dicts_item_select_human: - setDefault( R.string.key_default_dict, row ); - break; - case R.id.dicts_item_select_robot: - setDefault( R.string.key_default_robodict, row ); + case R.id.dicts_item_select: + m_rowView = row; + showDialog( SET_DEFAULT ); break; case R.id.dicts_item_details: Utils.notImpl( this );