remove .xwd from dict names displayed to users.

This commit is contained in:
eehouse 2010-05-12 11:50:25 +00:00
parent 7daa6e33f7
commit 7faaed04f5

View file

@ -247,11 +247,12 @@ public class Utils {
byte[] stream = savedGame( context, path ); byte[] stream = savedGame( context, path );
CurGameInfo gi = new CurGameInfo( context ); CurGameInfo gi = new CurGameInfo( context );
XwJNI.gi_from_stream( gi, stream ); XwJNI.gi_from_stream( gi, stream );
String dictName = gi.dictName; String dictName = removeExtn( gi.dictName );
missingName[0] = dictName; missingName[0] = dictName;
boolean exists = false; boolean exists = false;
for ( String name : dictList( context ) ) { for ( String name : dictList( context ) ) {
logf( "comparing %s, %s", name, dictName );
if ( name.equals( dictName ) ){ if ( name.equals( dictName ) ){
exists = true; exists = true;
break; break;
@ -295,7 +296,7 @@ public class Utils {
String[] files = am.list(""); String[] files = am.list("");
for ( String file : files ) { for ( String file : files ) {
if ( isDict( file ) ) { if ( isDict( file ) ) {
al.add( file ); al.add( removeExtn( file ) );
} }
} }
} catch( java.io.IOException ioe ) { } catch( java.io.IOException ioe ) {
@ -304,17 +305,22 @@ public class Utils {
for ( String file : context.fileList() ) { for ( String file : context.fileList() ) {
if ( isDict( file ) ) { if ( isDict( file ) ) {
al.add( file ); al.add( removeExtn( file ) );
} }
} }
return al.toArray( new String[al.size()] ); return al.toArray( new String[al.size()] );
} }
public static byte[] openDict( Context context, final String name ) public static byte[] openDict( Context context, String name )
{ {
byte[] bytes = null; byte[] bytes = null;
InputStream dict = null; InputStream dict = null;
if ( ! name.endsWith( XWConstants.DICT_EXTN ) ) {
name += XWConstants.DICT_EXTN;
}
AssetManager am = context.getAssets(); AssetManager am = context.getAssets();
try { try {
dict = am.open( name, dict = am.open( name,
@ -569,4 +575,13 @@ public class Utils {
db.close(); db.close();
} }
private static String removeExtn( String str )
{
if ( str.endsWith( XWConstants.DICT_EXTN ) ) {
int indx = str.lastIndexOf( XWConstants.DICT_EXTN );
str = str.substring( 0, indx );
}
return str;
}
} }