mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
put word count into list of dicts for substitution. Done by adding
actual count then stripping it back off to form the dict name again.
This commit is contained in:
parent
0059f92626
commit
ea85512c4f
2 changed files with 26 additions and 3 deletions
|
@ -79,18 +79,40 @@ public class DictLangCache {
|
|||
return count;
|
||||
}
|
||||
|
||||
public static String[] getHaveLang( Context context, int code )
|
||||
private static String[] getHaveLang( Context context, int code,
|
||||
boolean withCounts )
|
||||
{
|
||||
ArrayList<String> al = new ArrayList<String>();
|
||||
String[] dicts = GameUtils.dictList( context );
|
||||
String fmt = "%s (%d)"; // must match stripCount below
|
||||
for ( String dict : dicts ) {
|
||||
if ( code == getLangCode( context, dict ) ) {
|
||||
DictInfo info = getInfo( context, dict );
|
||||
if ( code == info.langCode ) {
|
||||
if ( withCounts ) {
|
||||
dict = String.format( fmt, dict, info.wordCount );
|
||||
}
|
||||
al.add( dict );
|
||||
}
|
||||
}
|
||||
return al.toArray( new String[al.size()] );
|
||||
}
|
||||
|
||||
public static String[] getHaveLang( Context context, int code )
|
||||
{
|
||||
return getHaveLang( context, code, false );
|
||||
}
|
||||
|
||||
public static String[] getHaveLangCounts( Context context, int code )
|
||||
{
|
||||
return getHaveLang( context, code, true );
|
||||
}
|
||||
|
||||
public static String stripCount( String nameWithCount )
|
||||
{
|
||||
int indx = nameWithCount.lastIndexOf( " (" );
|
||||
return nameWithCount.substring( 0, indx );
|
||||
}
|
||||
|
||||
public static int getLangCode( Context context, String name )
|
||||
{
|
||||
return getInfo( context, name ).langCode;
|
||||
|
|
|
@ -105,7 +105,7 @@ public class GamesList extends XWListActivity
|
|||
break;
|
||||
case SHOW_SUBST:
|
||||
m_sameLangDicts =
|
||||
DictLangCache.getHaveLang( this, m_missingDictLang );
|
||||
DictLangCache.getHaveLangCounts( this, m_missingDictLang );
|
||||
ab = new AlertDialog.Builder( this )
|
||||
.setTitle( R.string.subst_dict_title )
|
||||
.setNegativeButton( R.string.button_cancel, null )
|
||||
|
@ -114,6 +114,7 @@ public class GamesList extends XWListActivity
|
|||
public void onClick( DialogInterface dlg,
|
||||
int which ) {
|
||||
String dict = m_sameLangDicts[which];
|
||||
dict = DictLangCache.stripCount( dict );
|
||||
GameUtils.replaceDict( GamesList.this,
|
||||
m_missingDictPath,
|
||||
dict );
|
||||
|
|
Loading…
Reference in a new issue