mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:id="@+id/dicts_item_select"
|
<item android:id="@+id/dicts_item_select_human"
|
||||||
android:title="@string/dicts_item_select"
|
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"
|
<item android:id="@+id/dicts_item_details"
|
||||||
android:title="@string/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_up">Up one</string>
|
||||||
<string name="list_item_down">Down 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_delete">Delete dictionary</string>
|
||||||
<string name="dicts_item_details">Details</string>
|
<string name="dicts_item_details">Details</string>
|
||||||
|
|
||||||
|
|
|
@ -128,14 +128,13 @@ public class DictsActivity extends XWListActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
int position = info.position;
|
||||||
switch( id ) {
|
switch( id ) {
|
||||||
case R.id.dicts_item_select:
|
case R.id.dicts_item_select_human:
|
||||||
SharedPreferences sp
|
setDefault( R.string.key_default_dict, position );
|
||||||
= PreferenceManager.getDefaultSharedPreferences( this );
|
break;
|
||||||
SharedPreferences.Editor editor = sp.edit();
|
case R.id.dicts_item_select_robot:
|
||||||
String key = getString( R.string.key_default_dict );
|
setDefault( R.string.key_default_robodict, position );
|
||||||
editor.putString( key, m_dicts[info.position] );
|
|
||||||
editor.commit();
|
|
||||||
break;
|
break;
|
||||||
case R.id.dicts_item_details:
|
case R.id.dicts_item_details:
|
||||||
Utils.notImpl( this );
|
Utils.notImpl( this );
|
||||||
|
@ -145,6 +144,16 @@ public class DictsActivity extends XWListActivity
|
||||||
return handled;
|
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
|
// DeleteCallback interface
|
||||||
public void deleteCalled( final int myPosition )
|
public void deleteCalled( final int myPosition )
|
||||||
{
|
{
|
||||||
|
@ -186,5 +195,4 @@ public class DictsActivity extends XWListActivity
|
||||||
m_dicts = GameUtils.dictList( this );
|
m_dicts = GameUtils.dictList( this );
|
||||||
setListAdapter( new DictListAdapter( this ) );
|
setListAdapter( new DictListAdapter( this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue