mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-14 08:01:38 +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;
|
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>();
|
ArrayList<String> al = new ArrayList<String>();
|
||||||
String[] dicts = GameUtils.dictList( context );
|
String[] dicts = GameUtils.dictList( context );
|
||||||
|
String fmt = "%s (%d)"; // must match stripCount below
|
||||||
for ( String dict : dicts ) {
|
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 );
|
al.add( dict );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return al.toArray( new String[al.size()] );
|
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 )
|
public static int getLangCode( Context context, String name )
|
||||||
{
|
{
|
||||||
return getInfo( context, name ).langCode;
|
return getInfo( context, name ).langCode;
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class GamesList extends XWListActivity
|
||||||
break;
|
break;
|
||||||
case SHOW_SUBST:
|
case SHOW_SUBST:
|
||||||
m_sameLangDicts =
|
m_sameLangDicts =
|
||||||
DictLangCache.getHaveLang( this, m_missingDictLang );
|
DictLangCache.getHaveLangCounts( this, m_missingDictLang );
|
||||||
ab = new AlertDialog.Builder( this )
|
ab = new AlertDialog.Builder( this )
|
||||||
.setTitle( R.string.subst_dict_title )
|
.setTitle( R.string.subst_dict_title )
|
||||||
.setNegativeButton( R.string.button_cancel, null )
|
.setNegativeButton( R.string.button_cancel, null )
|
||||||
|
@ -114,6 +114,7 @@ public class GamesList extends XWListActivity
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
int which ) {
|
int which ) {
|
||||||
String dict = m_sameLangDicts[which];
|
String dict = m_sameLangDicts[which];
|
||||||
|
dict = DictLangCache.stripCount( dict );
|
||||||
GameUtils.replaceDict( GamesList.this,
|
GameUtils.replaceDict( GamesList.this,
|
||||||
m_missingDictPath,
|
m_missingDictPath,
|
||||||
dict );
|
dict );
|
||||||
|
|
Loading…
Reference in a new issue