diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java index c3b466612..45935e866 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java @@ -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 al = new ArrayList(); 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; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index 8d17b8e71..a12a0caf2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -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 );