diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java index d056f70d9..8d00b7593 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java @@ -25,6 +25,8 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceActivity; +import org.eehouse.android.xw4.loc.LocUtils; + public class PrefsActivity extends PreferenceActivity { private PrefsDelegate m_dlgt; @@ -38,12 +40,18 @@ public class PrefsActivity extends PreferenceActivity { @Override protected void onCreate( Bundle savedInstanceState ) { - super.onCreate( savedInstanceState ); - m_dlgt = new PrefsDelegate( this, savedInstanceState ); + super.onCreate( savedInstanceState ); m_dlgt.init( savedInstanceState ); } + @Override + protected void onStart() + { + LocUtils.xlatePreferences( this ); + super.onStart(); + } + @Override protected void onResume() { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java index e32146912..485fa0659 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java @@ -36,6 +36,9 @@ import android.widget.Button; import android.widget.CheckBox; import android.widget.Spinner; import android.widget.TextView; +import android.preference.Preference; +import android.preference.PreferenceGroup; +import android.preference.PreferenceActivity; import java.util.HashMap; import java.util.HashSet; @@ -119,6 +122,11 @@ public class LocUtils { xlateView( activity, Utils.getContentView( activity ) ); } + public static void xlatePreferences( PreferenceActivity activity ) + { + xlatePreferences( activity, activity.getPreferenceScreen(), 0 ); + } + public static void xlateView( Context context, View view ) { DbgUtils.logf( "xlateView() top level" ); @@ -130,6 +138,15 @@ public class LocUtils { xlateMenu( activity, menu, 0 ); } + private static String xlateString( Context context, CharSequence str ) + { + String result = null; + if ( null != str ) { + result = xlateString( context, str.toString() ); + } + return result; + } + public static String xlateString( Context context, String str ) { if ( LocIDs.getS_MAP( context ).containsKey( str ) ) { @@ -416,6 +433,30 @@ public class LocUtils { } } + public static void xlatePreferences( Context context, Preference pref, + int depth ) + { + // DbgUtils.logf( "xlatePreferences(depth=%d, view=%s, canRecurse=%b)", depth, + // pref.getClass().getName(), pref instanceof PreferenceGroup ); + + String str = xlateString( context, pref.getSummary() ); + if ( null != str ) { + pref.setSummary( str ); + } + str = xlateString( context, pref.getTitle() ); + if ( null != str ) { + pref.setTitle( str ); + } + + if ( pref instanceof PreferenceGroup ) { + PreferenceGroup group = (PreferenceGroup)pref; + int count = group.getPreferenceCount(); + for ( int ii = 0; ii < count; ++ii ) { + xlatePreferences( context, group.getPreference(ii), 1 + depth ); + } + } + } + // This is for testing, but the ability to pull the formatters will be // critical for validating local transations of strings containing // formatters.