mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
translate preferences -- finally.
This commit is contained in:
parent
3b4c672492
commit
28e81e3a74
2 changed files with 51 additions and 2 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue