mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
add menuitem to set default robot dict.
This commit is contained in:
parent
17fd65fb2d
commit
399fc081d7
3 changed files with 23 additions and 11 deletions
|
@ -1,8 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/dicts_item_select"
|
||||
android:title="@string/dicts_item_select"
|
||||
<item android:id="@+id/dicts_item_select_human"
|
||||
android:title="@string/dicts_item_select_human"
|
||||
/>
|
||||
<item android:id="@+id/dicts_item_select_robot"
|
||||
android:title="@string/dicts_item_select_robot"
|
||||
/>
|
||||
<item android:id="@+id/dicts_item_details"
|
||||
android:title="@string/dicts_item_details"
|
||||
|
|
|
@ -163,7 +163,8 @@
|
|||
|
||||
<string name="list_item_up">Up one</string>
|
||||
<string name="list_item_down">Down one</string>
|
||||
<string name="dicts_item_select">Make default</string>
|
||||
<string name="dicts_item_select_human">Make default (human)</string>
|
||||
<string name="dicts_item_select_robot">Make default (robot)</string>
|
||||
<string name="dicts_item_delete">Delete dictionary</string>
|
||||
<string name="dicts_item_details">Details</string>
|
||||
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue