mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-08 20:46:12 +01:00
Use debug settings' language code in deciding whether to look for a
wordlist to download, and don't crash when it's a bogus value.
This commit is contained in:
parent
8e2d19e712
commit
b661e59ae2
2 changed files with 66 additions and 32 deletions
|
@ -1909,9 +1909,10 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
false ) ) {
|
false ) ) {
|
||||||
m_haveShownGetDict = true;
|
m_haveShownGetDict = true;
|
||||||
|
|
||||||
String lc = Locale.getDefault().getLanguage();
|
String lc = LocUtils.getCurLangCode( m_activity );
|
||||||
if ( !lc.equals("en") ) {
|
if ( !lc.equals("en") ) {
|
||||||
int code = LocUtils.codeForLangCode( m_activity, lc );
|
int code = LocUtils.codeForLangCode( m_activity, lc );
|
||||||
|
if ( 0 < code ) {
|
||||||
String[] names = DictLangCache.getHaveLang( m_activity, code );
|
String[] names = DictLangCache.getHaveLang( m_activity, code );
|
||||||
if ( 0 == names.length ) {
|
if ( 0 == names.length ) {
|
||||||
final Runnable onNA = new Runnable() {
|
final Runnable onNA = new Runnable() {
|
||||||
|
@ -1947,6 +1948,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showGotDictForLang( String lang )
|
private void showGotDictForLang( String lang )
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,7 @@ import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -80,6 +81,7 @@ public class LocUtils {
|
||||||
private static HashMap<Integer, String> s_idsToKeys = null;
|
private static HashMap<Integer, String> s_idsToKeys = null;
|
||||||
private static Boolean s_enabled = null;
|
private static Boolean s_enabled = null;
|
||||||
private static String s_curLocale;
|
private static String s_curLocale;
|
||||||
|
private static String s_curLang;
|
||||||
private static WeakReference<Menu> s_latestMenuRef;
|
private static WeakReference<Menu> s_latestMenuRef;
|
||||||
private static Map<WeakReference<Menu>, HashSet<String> > s_menuSets
|
private static Map<WeakReference<Menu>, HashSet<String> > s_menuSets
|
||||||
= new HashMap<WeakReference<Menu>, HashSet<String> >();
|
= new HashMap<WeakReference<Menu>, HashSet<String> >();
|
||||||
|
@ -91,6 +93,7 @@ public class LocUtils {
|
||||||
{
|
{
|
||||||
saveLocalData( context );
|
saveLocalData( context );
|
||||||
s_curLocale = newLocale;
|
s_curLocale = newLocale;
|
||||||
|
s_curLang = splitLocale( newLocale );
|
||||||
s_xlationsLocal = null;
|
s_xlationsLocal = null;
|
||||||
s_xlationsBlessed = null;
|
s_xlationsBlessed = null;
|
||||||
s_enabled = null;
|
s_enabled = null;
|
||||||
|
@ -154,6 +157,7 @@ public class LocUtils {
|
||||||
private static Map<String, Integer> s_langCodeMap = null;
|
private static Map<String, Integer> s_langCodeMap = null;
|
||||||
public static int codeForLangCode( Context context, String lc )
|
public static int codeForLangCode( Context context, String lc )
|
||||||
{
|
{
|
||||||
|
int result = 0;
|
||||||
if ( null == s_langCodeMap ) {
|
if ( null == s_langCodeMap ) {
|
||||||
s_langCodeMap = new HashMap<String, Integer>();
|
s_langCodeMap = new HashMap<String, Integer>();
|
||||||
String[] langCodes =
|
String[] langCodes =
|
||||||
|
@ -166,7 +170,10 @@ public class LocUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_langCodeMap.get( lc );
|
if ( s_langCodeMap.containsKey( lc ) ) {
|
||||||
|
result = s_langCodeMap.get( lc );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void xlateView( Activity activity )
|
public static void xlateView( Activity activity )
|
||||||
|
@ -553,10 +560,25 @@ public class LocUtils {
|
||||||
String locale_code = getCurLocale( context );
|
String locale_code = getCurLocale( context );
|
||||||
Locale locale = new Locale( locale_code );
|
Locale locale = new Locale( locale_code );
|
||||||
String name = locale.getDisplayLanguage( locale );
|
String name = locale.getDisplayLanguage( locale );
|
||||||
DbgUtils.logf( "getCurLocaleName(%s)=>%s", locale_code, name );
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getCurLangCode( Context context )
|
||||||
|
{
|
||||||
|
if ( null == s_curLang ) {
|
||||||
|
String lang = null;
|
||||||
|
String locale = XWPrefs.getFakeLocale( context );
|
||||||
|
if ( null != locale && 0 < locale.length() ) {
|
||||||
|
lang = splitLocale( locale );
|
||||||
|
}
|
||||||
|
if ( null == lang ) {
|
||||||
|
lang = Locale.getDefault().getLanguage();
|
||||||
|
}
|
||||||
|
s_curLang = lang;
|
||||||
|
}
|
||||||
|
return s_curLang;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getCurLocale( Context context )
|
public static String getCurLocale( Context context )
|
||||||
{
|
{
|
||||||
if ( null == s_curLocale ) {
|
if ( null == s_curLocale ) {
|
||||||
|
@ -802,6 +824,16 @@ public class LocUtils {
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String splitLocale( String locale )
|
||||||
|
{
|
||||||
|
String result = null;
|
||||||
|
String[] tuple = TextUtils.split( locale, "_" );
|
||||||
|
if ( null != tuple && 2 == tuple.length ) {
|
||||||
|
result = tuple[0];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static AlertDialog.Builder makeAlertBuilder( Context context )
|
public static AlertDialog.Builder makeAlertBuilder( Context context )
|
||||||
{
|
{
|
||||||
return new AlertBuilder( context );
|
return new AlertBuilder( context );
|
||||||
|
|
Loading…
Add table
Reference in a new issue