mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
remove .xwd from dict names displayed to users.
This commit is contained in:
parent
7daa6e33f7
commit
7faaed04f5
1 changed files with 19 additions and 4 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue