mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-24 07:58:34 +01:00
force wordlists and language to match when newgame default list
changed from wordlist browser.
This commit is contained in:
parent
bf334054e8
commit
ea68ea015e
1 changed files with 23 additions and 4 deletions
|
@ -370,11 +370,13 @@ public class DictsDelegate extends ListDelegateBase
|
|||
public void onClick( DialogInterface dlg, int item ) {
|
||||
if ( DialogInterface.BUTTON_NEGATIVE == item
|
||||
|| DialogInterface.BUTTON_POSITIVE == item ) {
|
||||
setDefault( row, R.string.key_default_dict );
|
||||
setDefault( row, R.string.key_default_dict,
|
||||
R.string.key_default_robodict );
|
||||
}
|
||||
if ( DialogInterface.BUTTON_NEGATIVE == item
|
||||
|| DialogInterface.BUTTON_NEUTRAL == item ) {
|
||||
setDefault( row, R.string.key_default_robodict );
|
||||
setDefault( row, R.string.key_default_robodict,
|
||||
R.string.key_default_dict );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -649,14 +651,31 @@ public class DictsDelegate extends ListDelegateBase
|
|||
}
|
||||
}
|
||||
|
||||
private void setDefault( XWListItem view, int keyId )
|
||||
private void setDefault( XWListItem view, int keyId, int otherKey )
|
||||
{
|
||||
String name = view.getText();
|
||||
int langCode = DictLangCache.getDictLangCode( m_activity, name );
|
||||
String curLangName = XWPrefs.getPrefsString( m_activity, R.string.key_default_language );
|
||||
int curLangCode = DictLangCache.getLangLangCode( m_activity, curLangName );
|
||||
boolean changeLang = langCode != curLangCode;
|
||||
|
||||
SharedPreferences sp
|
||||
= PreferenceManager.getDefaultSharedPreferences( m_activity );
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
String key = getString( keyId );
|
||||
String name = view.getText();
|
||||
editor.putString( key, name );
|
||||
|
||||
if ( changeLang ) {
|
||||
// change other dict too
|
||||
key = getString( otherKey );
|
||||
editor.putString( key, name );
|
||||
|
||||
// and change language
|
||||
String langName = DictLangCache.getLangName( m_activity, langCode );
|
||||
key = getString( R.string.key_default_language );
|
||||
editor.putString( key, langName );
|
||||
}
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue