From 399fc081d744bab51c42f9b3869ca3ed1bfef6e5 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Wed, 27 Apr 2011 06:38:45 -0700 Subject: [PATCH] add menuitem to set default robot dict. --- .../XWords4/res/menu/dicts_item_menu.xml | 7 ++++-- .../android/XWords4/res/values/strings.xml | 3 ++- .../eehouse/android/xw4/DictsActivity.java | 24 ++++++++++++------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/xwords4/android/XWords4/res/menu/dicts_item_menu.xml b/xwords4/android/XWords4/res/menu/dicts_item_menu.xml index c1a0e24be..c4eca5a5e 100644 --- a/xwords4/android/XWords4/res/menu/dicts_item_menu.xml +++ b/xwords4/android/XWords4/res/menu/dicts_item_menu.xml @@ -1,8 +1,11 @@ - + Up one Down one - Make default + Make default (human) + Make default (robot) Delete dictionary Details 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 19d38e635..b875cd090 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java @@ -128,14 +128,13 @@ public class DictsActivity extends XWListActivity } int id = item.getItemId(); + int position = info.position; switch( id ) { - case R.id.dicts_item_select: - SharedPreferences sp - = PreferenceManager.getDefaultSharedPreferences( this ); - SharedPreferences.Editor editor = sp.edit(); - String key = getString( R.string.key_default_dict ); - editor.putString( key, m_dicts[info.position] ); - editor.commit(); + case R.id.dicts_item_select_human: + setDefault( R.string.key_default_dict, position ); + break; + case R.id.dicts_item_select_robot: + setDefault( R.string.key_default_robodict, position ); break; case R.id.dicts_item_details: Utils.notImpl( this ); @@ -145,6 +144,16 @@ public class DictsActivity extends XWListActivity return handled; } + private void setDefault( int keyId, int position ) + { + SharedPreferences sp + = PreferenceManager.getDefaultSharedPreferences( this ); + SharedPreferences.Editor editor = sp.edit(); + String key = getString( keyId ); + editor.putString( key, m_dicts[position] ); + editor.commit(); + } + // DeleteCallback interface public void deleteCalled( final int myPosition ) { @@ -186,5 +195,4 @@ public class DictsActivity extends XWListActivity m_dicts = GameUtils.dictList( this ); setListAdapter( new DictListAdapter( this ) ); } - } \ No newline at end of file